Lines Matching refs:cxled
195 static void __cxl_dpa_release(struct cxl_endpoint_decoder *cxled) in __cxl_dpa_release() argument
197 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in __cxl_dpa_release()
198 struct cxl_port *port = cxled_to_port(cxled); in __cxl_dpa_release()
200 struct resource *res = cxled->dpa_res; in __cxl_dpa_release()
206 skip_start = res->start - cxled->skip; in __cxl_dpa_release()
208 if (cxled->skip) in __cxl_dpa_release()
209 __release_region(&cxlds->dpa_res, skip_start, cxled->skip); in __cxl_dpa_release()
210 cxled->skip = 0; in __cxl_dpa_release()
211 cxled->dpa_res = NULL; in __cxl_dpa_release()
212 put_device(&cxled->cxld.dev); in __cxl_dpa_release()
216 static void cxl_dpa_release(void *cxled) in cxl_dpa_release() argument
219 __cxl_dpa_release(cxled); in cxl_dpa_release()
227 static void devm_cxl_dpa_release(struct cxl_endpoint_decoder *cxled) in devm_cxl_dpa_release() argument
229 struct cxl_port *port = cxled_to_port(cxled); in devm_cxl_dpa_release()
232 devm_remove_action(&port->dev, cxl_dpa_release, cxled); in devm_cxl_dpa_release()
233 __cxl_dpa_release(cxled); in devm_cxl_dpa_release()
236 static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled, in __cxl_dpa_reserve() argument
240 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in __cxl_dpa_reserve()
241 struct cxl_port *port = cxled_to_port(cxled); in __cxl_dpa_reserve()
251 if (cxled->dpa_res) { in __cxl_dpa_reserve()
253 port->id, cxled->cxld.id, cxled->dpa_res); in __cxl_dpa_reserve()
257 if (port->hdm_end + 1 != cxled->cxld.id) { in __cxl_dpa_reserve()
265 cxled->cxld.id, port->id, port->hdm_end + 1); in __cxl_dpa_reserve()
271 dev_name(&cxled->cxld.dev), 0); in __cxl_dpa_reserve()
275 port->id, cxled->cxld.id); in __cxl_dpa_reserve()
280 dev_name(&cxled->cxld.dev), 0); in __cxl_dpa_reserve()
283 port->id, cxled->cxld.id); in __cxl_dpa_reserve()
289 cxled->dpa_res = res; in __cxl_dpa_reserve()
290 cxled->skip = skipped; in __cxl_dpa_reserve()
293 cxled->mode = CXL_DECODER_PMEM; in __cxl_dpa_reserve()
295 cxled->mode = CXL_DECODER_RAM; in __cxl_dpa_reserve()
298 cxled->cxld.id, cxled->dpa_res); in __cxl_dpa_reserve()
299 cxled->mode = CXL_DECODER_MIXED; in __cxl_dpa_reserve()
304 get_device(&cxled->cxld.dev); in __cxl_dpa_reserve()
308 int devm_cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled, in devm_cxl_dpa_reserve() argument
312 struct cxl_port *port = cxled_to_port(cxled); in devm_cxl_dpa_reserve()
316 rc = __cxl_dpa_reserve(cxled, base, len, skipped); in devm_cxl_dpa_reserve()
322 return devm_add_action_or_reset(&port->dev, cxl_dpa_release, cxled); in devm_cxl_dpa_reserve()
326 resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled) in cxl_dpa_size() argument
331 if (cxled->dpa_res) in cxl_dpa_size()
332 size = resource_size(cxled->dpa_res); in cxl_dpa_size()
338 resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled) in cxl_dpa_resource_start() argument
343 if (cxled->dpa_res) in cxl_dpa_resource_start()
344 base = cxled->dpa_res->start; in cxl_dpa_resource_start()
350 int cxl_dpa_free(struct cxl_endpoint_decoder *cxled) in cxl_dpa_free() argument
352 struct cxl_port *port = cxled_to_port(cxled); in cxl_dpa_free()
353 struct device *dev = &cxled->cxld.dev; in cxl_dpa_free()
357 if (!cxled->dpa_res) { in cxl_dpa_free()
361 if (cxled->cxld.region) { in cxl_dpa_free()
363 dev_name(&cxled->cxld.region->dev)); in cxl_dpa_free()
367 if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) { in cxl_dpa_free()
372 if (cxled->cxld.id != port->hdm_end) { in cxl_dpa_free()
378 devm_cxl_dpa_release(cxled); in cxl_dpa_free()
385 int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled, in cxl_dpa_set_mode() argument
388 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in cxl_dpa_set_mode()
390 struct device *dev = &cxled->cxld.dev; in cxl_dpa_set_mode()
403 if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) { in cxl_dpa_set_mode()
423 cxled->mode = mode; in cxl_dpa_set_mode()
431 int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size) in cxl_dpa_alloc() argument
433 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); in cxl_dpa_alloc()
435 struct cxl_port *port = cxled_to_port(cxled); in cxl_dpa_alloc()
437 struct device *dev = &cxled->cxld.dev; in cxl_dpa_alloc()
443 if (cxled->cxld.region) { in cxl_dpa_alloc()
445 dev_name(&cxled->cxld.region->dev)); in cxl_dpa_alloc()
450 if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) { in cxl_dpa_alloc()
470 if (cxled->mode == CXL_DECODER_RAM) { in cxl_dpa_alloc()
474 } else if (cxled->mode == CXL_DECODER_PMEM) { in cxl_dpa_alloc()
499 cxled->mode == CXL_DECODER_RAM ? "ram" : "pmem", in cxl_dpa_alloc()
505 rc = __cxl_dpa_reserve(cxled, start, size, skip); in cxl_dpa_alloc()
512 return devm_add_action_or_reset(&port->dev, cxl_dpa_release, cxled); in cxl_dpa_alloc()
648 struct cxl_endpoint_decoder *cxled = in cxl_decoder_commit() local
653 writel(upper_32_bits(cxled->skip), sk_hi); in cxl_decoder_commit()
654 writel(lower_32_bits(cxled->skip), sk_lo); in cxl_decoder_commit()
708 struct cxl_endpoint_decoder *cxled; in cxl_decoder_reset() local
710 cxled = to_cxl_endpoint_decoder(&cxld->dev); in cxl_decoder_reset()
711 cxled->state = CXL_DECODER_STATE_MANUAL; in cxl_decoder_reset()
772 struct cxl_endpoint_decoder *cxled = NULL; in init_hdm_decoder() local
787 cxled = to_cxl_endpoint_decoder(&cxld->dev); in init_hdm_decoder()
809 if (cxled && !committed && range_len(&info->dvsec_range[which])) in init_hdm_decoder()
849 if (!cxled) { in init_hdm_decoder()
869 rc = devm_cxl_dpa_reserve(cxled, *dpa_base + skip, dpa_size, skip); in init_hdm_decoder()
879 cxled->state = CXL_DECODER_STATE_AUTO; in init_hdm_decoder()
932 struct cxl_endpoint_decoder *cxled; in devm_cxl_enumerate_decoders() local
934 cxled = cxl_endpoint_decoder_alloc(port); in devm_cxl_enumerate_decoders()
935 if (IS_ERR(cxled)) { in devm_cxl_enumerate_decoders()
939 return PTR_ERR(cxled); in devm_cxl_enumerate_decoders()
941 cxld = &cxled->cxld; in devm_cxl_enumerate_decoders()