Skip to content

Commit 83cea4e

Browse files
committed
cxl/core: Return endpoint decoder information from region search
cxl_dpa_to_region() finds the region from a <DPA, device> tuple. The search involves finding the device endpoint decoder as well. Dynamic capacity extent processing uses the endpoint decoder HPA information to calculate the HPA offset. In addition, well behaved extents should be contained within an endpoint decoder. Return the endpoint decoder found to be used in subsequent DCD code. Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Fan Ni <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Reviewed-by: Li Ming <[email protected]> Reviewed-by: Alison Schofield <[email protected]> Signed-off-by: Ira Weiny <[email protected]> --- Changes: [iweiny: rebase]
1 parent 13a1803 commit 83cea4e

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

drivers/cxl/core/core.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled);
4040
int cxl_region_init(void);
4141
void cxl_region_exit(void);
4242
int cxl_get_poison_by_endpoint(struct cxl_port *port);
43-
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa);
43+
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa,
44+
struct cxl_endpoint_decoder **cxled);
4445
u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
4546
u64 dpa);
4647

@@ -51,7 +52,8 @@ static inline u64 cxl_dpa_to_hpa(struct cxl_region *cxlr,
5152
return ULLONG_MAX;
5253
}
5354
static inline
54-
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa)
55+
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa,
56+
struct cxl_endpoint_decoder **cxled)
5557
{
5658
return NULL;
5759
}

drivers/cxl/core/mbox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd,
957957
guard(rwsem_read)(&cxl_dpa_rwsem);
958958

959959
dpa = le64_to_cpu(evt->media_hdr.phys_addr) & CXL_DPA_MASK;
960-
cxlr = cxl_dpa_to_region(cxlmd, dpa);
960+
cxlr = cxl_dpa_to_region(cxlmd, dpa, NULL);
961961
if (cxlr) {
962962
u64 cache_size = cxlr->params.cache_size;
963963

drivers/cxl/core/memdev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa)
320320
if (rc)
321321
goto out;
322322

323-
cxlr = cxl_dpa_to_region(cxlmd, dpa);
323+
cxlr = cxl_dpa_to_region(cxlmd, dpa, NULL);
324324
if (cxlr)
325325
dev_warn_once(cxl_mbox->host,
326326
"poison inject dpa:%#llx region: %s\n", dpa,
@@ -384,7 +384,7 @@ int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa)
384384
if (rc)
385385
goto out;
386386

387-
cxlr = cxl_dpa_to_region(cxlmd, dpa);
387+
cxlr = cxl_dpa_to_region(cxlmd, dpa, NULL);
388388
if (cxlr)
389389
dev_warn_once(cxl_mbox->host,
390390
"poison clear dpa:%#llx region: %s\n", dpa,

drivers/cxl/core/region.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2839,6 +2839,7 @@ int cxl_get_poison_by_endpoint(struct cxl_port *port)
28392839
struct cxl_dpa_to_region_context {
28402840
struct cxl_region *cxlr;
28412841
u64 dpa;
2842+
struct cxl_endpoint_decoder *cxled;
28422843
};
28432844

28442845
static int __cxl_dpa_to_region(struct device *dev, void *arg)
@@ -2872,11 +2873,13 @@ static int __cxl_dpa_to_region(struct device *dev, void *arg)
28722873
dev_name(dev));
28732874

28742875
ctx->cxlr = cxlr;
2876+
ctx->cxled = cxled;
28752877

28762878
return 1;
28772879
}
28782880

2879-
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa)
2881+
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa,
2882+
struct cxl_endpoint_decoder **cxled)
28802883
{
28812884
struct cxl_dpa_to_region_context ctx;
28822885
struct cxl_port *port;
@@ -2888,6 +2891,9 @@ struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa)
28882891
if (port && is_cxl_endpoint(port) && cxl_num_decoders_committed(port))
28892892
device_for_each_child(&port->dev, &ctx, __cxl_dpa_to_region);
28902893

2894+
if (cxled)
2895+
*cxled = ctx.cxled;
2896+
28912897
return ctx.cxlr;
28922898
}
28932899

0 commit comments

Comments
 (0)