Lines Matching refs:cxled
164 static void __cxl_dpa_release(struct cxl_endpoint_decoder *cxled) in __cxl_dpa_release() argument
166 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in __cxl_dpa_release()
167 struct cxl_port *port = cxled_to_port(cxled); in __cxl_dpa_release()
169 struct resource *res = cxled->dpa_res; in __cxl_dpa_release()
175 skip_start = res->start - cxled->skip; in __cxl_dpa_release()
177 if (cxled->skip) in __cxl_dpa_release()
178 __release_region(&cxlds->dpa_res, skip_start, cxled->skip); in __cxl_dpa_release()
179 cxled->skip = 0; in __cxl_dpa_release()
180 cxled->dpa_res = NULL; in __cxl_dpa_release()
181 put_device(&cxled->cxld.dev); in __cxl_dpa_release()
185 static void cxl_dpa_release(void *cxled) in cxl_dpa_release() argument
188 __cxl_dpa_release(cxled); in cxl_dpa_release()
196 static void devm_cxl_dpa_release(struct cxl_endpoint_decoder *cxled) in devm_cxl_dpa_release() argument
198 struct cxl_port *port = cxled_to_port(cxled); in devm_cxl_dpa_release()
201 devm_remove_action(&port->dev, cxl_dpa_release, cxled); in devm_cxl_dpa_release()
202 __cxl_dpa_release(cxled); in devm_cxl_dpa_release()
205 static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled, in __cxl_dpa_reserve() argument
209 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in __cxl_dpa_reserve()
210 struct cxl_port *port = cxled_to_port(cxled); in __cxl_dpa_reserve()
220 if (cxled->dpa_res) { in __cxl_dpa_reserve()
222 port->id, cxled->cxld.id, cxled->dpa_res); in __cxl_dpa_reserve()
226 if (port->hdm_end + 1 != cxled->cxld.id) { in __cxl_dpa_reserve()
234 cxled->cxld.id, port->id, port->hdm_end + 1); in __cxl_dpa_reserve()
240 dev_name(&cxled->cxld.dev), 0); in __cxl_dpa_reserve()
244 port->id, cxled->cxld.id); in __cxl_dpa_reserve()
249 dev_name(&cxled->cxld.dev), 0); in __cxl_dpa_reserve()
252 port->id, cxled->cxld.id); in __cxl_dpa_reserve()
258 cxled->dpa_res = res; in __cxl_dpa_reserve()
259 cxled->skip = skipped; in __cxl_dpa_reserve()
262 cxled->mode = CXL_DECODER_PMEM; in __cxl_dpa_reserve()
264 cxled->mode = CXL_DECODER_RAM; in __cxl_dpa_reserve()
267 cxled->cxld.id, cxled->dpa_res); in __cxl_dpa_reserve()
268 cxled->mode = CXL_DECODER_MIXED; in __cxl_dpa_reserve()
273 get_device(&cxled->cxld.dev); in __cxl_dpa_reserve()
277 static int devm_cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled, in devm_cxl_dpa_reserve() argument
281 struct cxl_port *port = cxled_to_port(cxled); in devm_cxl_dpa_reserve()
285 rc = __cxl_dpa_reserve(cxled, base, len, skipped); in devm_cxl_dpa_reserve()
291 return devm_add_action_or_reset(&port->dev, cxl_dpa_release, cxled); in devm_cxl_dpa_reserve()
294 resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled) in cxl_dpa_size() argument
299 if (cxled->dpa_res) in cxl_dpa_size()
300 size = resource_size(cxled->dpa_res); in cxl_dpa_size()
306 resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled) in cxl_dpa_resource_start() argument
311 if (cxled->dpa_res) in cxl_dpa_resource_start()
312 base = cxled->dpa_res->start; in cxl_dpa_resource_start()
318 int cxl_dpa_free(struct cxl_endpoint_decoder *cxled) in cxl_dpa_free() argument
320 struct cxl_port *port = cxled_to_port(cxled); in cxl_dpa_free()
321 struct device *dev = &cxled->cxld.dev; in cxl_dpa_free()
325 if (!cxled->dpa_res) { in cxl_dpa_free()
329 if (cxled->cxld.region) { in cxl_dpa_free()
331 dev_name(&cxled->cxld.region->dev)); in cxl_dpa_free()
335 if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) { in cxl_dpa_free()
340 if (cxled->cxld.id != port->hdm_end) { in cxl_dpa_free()
346 devm_cxl_dpa_release(cxled); in cxl_dpa_free()
353 int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled, in cxl_dpa_set_mode() argument
356 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in cxl_dpa_set_mode()
358 struct device *dev = &cxled->cxld.dev; in cxl_dpa_set_mode()
371 if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) { in cxl_dpa_set_mode()
391 cxled->mode = mode; in cxl_dpa_set_mode()
399 int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size) in cxl_dpa_alloc() argument
401 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in cxl_dpa_alloc()
403 struct cxl_port *port = cxled_to_port(cxled); in cxl_dpa_alloc()
405 struct device *dev = &cxled->cxld.dev; in cxl_dpa_alloc()
411 if (cxled->cxld.region) { in cxl_dpa_alloc()
413 dev_name(&cxled->cxld.region->dev)); in cxl_dpa_alloc()
418 if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) { in cxl_dpa_alloc()
438 if (cxled->mode == CXL_DECODER_RAM) { in cxl_dpa_alloc()
442 } else if (cxled->mode == CXL_DECODER_PMEM) { in cxl_dpa_alloc()
467 cxled->mode == CXL_DECODER_RAM ? "ram" : "pmem", in cxl_dpa_alloc()
473 rc = __cxl_dpa_reserve(cxled, start, size, skip); in cxl_dpa_alloc()
480 return devm_add_action_or_reset(&port->dev, cxl_dpa_release, cxled); in cxl_dpa_alloc()
616 struct cxl_endpoint_decoder *cxled = in cxl_decoder_commit() local
621 writel(upper_32_bits(cxled->skip), sk_hi); in cxl_decoder_commit()
622 writel(lower_32_bits(cxled->skip), sk_lo); in cxl_decoder_commit()
681 struct cxl_endpoint_decoder *cxled = NULL; in init_hdm_decoder() local
693 cxled = to_cxl_endpoint_decoder(&cxld->dev); in init_hdm_decoder()
752 if (!cxled) { in init_hdm_decoder()
772 rc = devm_cxl_dpa_reserve(cxled, *dpa_base + skip, dpa_size, skip); in init_hdm_decoder()
819 struct cxl_endpoint_decoder *cxled; in devm_cxl_enumerate_decoders() local
821 cxled = cxl_endpoint_decoder_alloc(port); in devm_cxl_enumerate_decoders()
822 if (IS_ERR(cxled)) { in devm_cxl_enumerate_decoders()
825 return PTR_ERR(cxled); in devm_cxl_enumerate_decoders()
827 cxld = &cxled->cxld; in devm_cxl_enumerate_decoders()