Lines Matching refs:cxled
227 static void __cxl_dpa_release(struct cxl_endpoint_decoder *cxled) in __cxl_dpa_release() argument
229 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in __cxl_dpa_release()
230 struct cxl_port *port = cxled_to_port(cxled); in __cxl_dpa_release()
232 struct resource *res = cxled->dpa_res; in __cxl_dpa_release()
238 skip_start = res->start - cxled->skip; in __cxl_dpa_release()
240 if (cxled->skip) in __cxl_dpa_release()
241 __release_region(&cxlds->dpa_res, skip_start, cxled->skip); in __cxl_dpa_release()
242 cxled->skip = 0; in __cxl_dpa_release()
243 cxled->dpa_res = NULL; in __cxl_dpa_release()
244 put_device(&cxled->cxld.dev); in __cxl_dpa_release()
248 static void cxl_dpa_release(void *cxled) in cxl_dpa_release() argument
251 __cxl_dpa_release(cxled); in cxl_dpa_release()
259 static void devm_cxl_dpa_release(struct cxl_endpoint_decoder *cxled) in devm_cxl_dpa_release() argument
261 struct cxl_port *port = cxled_to_port(cxled); in devm_cxl_dpa_release()
264 devm_remove_action(&port->dev, cxl_dpa_release, cxled); in devm_cxl_dpa_release()
265 __cxl_dpa_release(cxled); in devm_cxl_dpa_release()
268 static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled, in __cxl_dpa_reserve() argument
272 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in __cxl_dpa_reserve()
273 struct cxl_port *port = cxled_to_port(cxled); in __cxl_dpa_reserve()
282 port->id, cxled->cxld.id); in __cxl_dpa_reserve()
286 if (cxled->dpa_res) { in __cxl_dpa_reserve()
288 port->id, cxled->cxld.id, cxled->dpa_res); in __cxl_dpa_reserve()
292 if (port->hdm_end + 1 != cxled->cxld.id) { in __cxl_dpa_reserve()
300 cxled->cxld.id, port->id, port->hdm_end + 1); in __cxl_dpa_reserve()
306 dev_name(&cxled->cxld.dev), 0); in __cxl_dpa_reserve()
310 port->id, cxled->cxld.id); in __cxl_dpa_reserve()
315 dev_name(&cxled->cxld.dev), 0); in __cxl_dpa_reserve()
318 port->id, cxled->cxld.id); in __cxl_dpa_reserve()
324 cxled->dpa_res = res; in __cxl_dpa_reserve()
325 cxled->skip = skipped; in __cxl_dpa_reserve()
328 cxled->mode = CXL_DECODER_PMEM; in __cxl_dpa_reserve()
330 cxled->mode = CXL_DECODER_RAM; in __cxl_dpa_reserve()
333 cxled->cxld.id, cxled->dpa_res); in __cxl_dpa_reserve()
334 cxled->mode = CXL_DECODER_MIXED; in __cxl_dpa_reserve()
338 get_device(&cxled->cxld.dev); in __cxl_dpa_reserve()
342 int devm_cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled, in devm_cxl_dpa_reserve() argument
346 struct cxl_port *port = cxled_to_port(cxled); in devm_cxl_dpa_reserve()
350 rc = __cxl_dpa_reserve(cxled, base, len, skipped); in devm_cxl_dpa_reserve()
356 return devm_add_action_or_reset(&port->dev, cxl_dpa_release, cxled); in devm_cxl_dpa_reserve()
360 resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled) in cxl_dpa_size() argument
365 if (cxled->dpa_res) in cxl_dpa_size()
366 size = resource_size(cxled->dpa_res); in cxl_dpa_size()
372 resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled) in cxl_dpa_resource_start() argument
377 if (cxled->dpa_res) in cxl_dpa_resource_start()
378 base = cxled->dpa_res->start; in cxl_dpa_resource_start()
384 int cxl_dpa_free(struct cxl_endpoint_decoder *cxled) in cxl_dpa_free() argument
386 struct cxl_port *port = cxled_to_port(cxled); in cxl_dpa_free()
387 struct device *dev = &cxled->cxld.dev; in cxl_dpa_free()
391 if (!cxled->dpa_res) { in cxl_dpa_free()
395 if (cxled->cxld.region) { in cxl_dpa_free()
397 dev_name(&cxled->cxld.region->dev)); in cxl_dpa_free()
401 if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) { in cxl_dpa_free()
406 if (cxled->cxld.id != port->hdm_end) { in cxl_dpa_free()
412 devm_cxl_dpa_release(cxled); in cxl_dpa_free()
419 int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled, in cxl_dpa_set_mode() argument
422 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in cxl_dpa_set_mode()
424 struct device *dev = &cxled->cxld.dev; in cxl_dpa_set_mode()
437 if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) { in cxl_dpa_set_mode()
457 cxled->mode = mode; in cxl_dpa_set_mode()
465 int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size) in cxl_dpa_alloc() argument
467 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in cxl_dpa_alloc()
469 struct cxl_port *port = cxled_to_port(cxled); in cxl_dpa_alloc()
471 struct device *dev = &cxled->cxld.dev; in cxl_dpa_alloc()
477 if (cxled->cxld.region) { in cxl_dpa_alloc()
479 dev_name(&cxled->cxld.region->dev)); in cxl_dpa_alloc()
484 if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) { in cxl_dpa_alloc()
504 if (cxled->mode == CXL_DECODER_RAM) { in cxl_dpa_alloc()
508 } else if (cxled->mode == CXL_DECODER_PMEM) { in cxl_dpa_alloc()
533 cxled->mode == CXL_DECODER_RAM ? "ram" : "pmem", in cxl_dpa_alloc()
539 rc = __cxl_dpa_reserve(cxled, start, size, skip); in cxl_dpa_alloc()
546 return devm_add_action_or_reset(&port->dev, cxl_dpa_release, cxled); in cxl_dpa_alloc()
683 struct cxl_endpoint_decoder *cxled = in cxl_decoder_commit() local
688 writel(upper_32_bits(cxled->skip), sk_hi); in cxl_decoder_commit()
689 writel(lower_32_bits(cxled->skip), sk_lo); in cxl_decoder_commit()
743 struct cxl_endpoint_decoder *cxled; in cxl_decoder_reset() local
745 cxled = to_cxl_endpoint_decoder(&cxld->dev); in cxl_decoder_reset()
746 cxled->state = CXL_DECODER_STATE_MANUAL; in cxl_decoder_reset()
756 struct cxl_endpoint_decoder *cxled; in cxl_setup_hdm_decoder_from_dvsec() local
763 cxled = to_cxl_endpoint_decoder(&cxld->dev); in cxl_setup_hdm_decoder_from_dvsec()
780 rc = devm_cxl_dpa_reserve(cxled, *dpa_base, len, 0); in cxl_setup_hdm_decoder_from_dvsec()
788 cxled->state = CXL_DECODER_STATE_AUTO; in cxl_setup_hdm_decoder_from_dvsec()
797 struct cxl_endpoint_decoder *cxled = NULL; in init_hdm_decoder() local
832 cxled = to_cxl_endpoint_decoder(&cxld->dev); in init_hdm_decoder()
862 if (cxled) { in init_hdm_decoder()
863 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in init_hdm_decoder()
902 if (!cxled) { in init_hdm_decoder()
925 rc = devm_cxl_dpa_reserve(cxled, *dpa_base + skip, dpa_size, skip); in init_hdm_decoder()
935 cxled->state = CXL_DECODER_STATE_AUTO; in init_hdm_decoder()
988 struct cxl_endpoint_decoder *cxled; in devm_cxl_enumerate_decoders() local
990 cxled = cxl_endpoint_decoder_alloc(port); in devm_cxl_enumerate_decoders()
991 if (IS_ERR(cxled)) { in devm_cxl_enumerate_decoders()
995 return PTR_ERR(cxled); in devm_cxl_enumerate_decoders()
997 cxld = &cxled->cxld; in devm_cxl_enumerate_decoders()