Skip to content

Commit 188e952

Browse files
djbwdavejiang
authored andcommitted
cxl: Remove the CXL_DECODER_MIXED mistake
CXL_DECODER_MIXED is a safety mechanism introduced for the case where platform firmware has programmed an endpoint decoder that straddles a DPA partition boundary. While the kernel is careful to only allocate DPA capacity within a single partition there is no guarantee that platform firmware, or anything that touched the device before the current kernel, gets that right. However, __cxl_dpa_reserve() will never get to the CXL_DECODER_MIXED designation because of the way it tracks partition boundaries. A request_resource() that spans ->ram_res and ->pmem_res fails with the following signature: __cxl_dpa_reserve: cxl_port endpoint15: decoder15.0: failed to reserve allocation CXL_DECODER_MIXED is dead defensive programming after the driver has already given up on the device. It has never offered any protection in practice, just delete it. Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alejandro Lucero <alucerop@amd.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Fan Ni <fan.ni@samsung.com> Tested-by: Alejandro Lucero <alucerop@amd.com> Link: https://patch.msgid.link/173864304660.668823.17000888505587850279.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 2014c95 commit 188e952

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

drivers/cxl/core/hdm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,9 @@ static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled,
332332
else if (resource_contains(&cxlds->ram_res, res))
333333
cxled->mode = CXL_DECODER_RAM;
334334
else {
335-
dev_warn(dev, "decoder%d.%d: %pr mixed mode not supported\n",
336-
port->id, cxled->cxld.id, cxled->dpa_res);
337-
cxled->mode = CXL_DECODER_MIXED;
335+
dev_warn(dev, "decoder%d.%d: %pr does not map any partition\n",
336+
port->id, cxled->cxld.id, res);
337+
cxled->mode = CXL_DECODER_NONE;
338338
}
339339

340340
port->hdm_end++;

drivers/cxl/core/region.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,18 +2738,6 @@ static int poison_by_decoder(struct device *dev, void *arg)
27382738
if (!cxled->dpa_res || !resource_size(cxled->dpa_res))
27392739
return rc;
27402740

2741-
/*
2742-
* Regions are only created with single mode decoders: pmem or ram.
2743-
* Linux does not support mixed mode decoders. This means that
2744-
* reading poison per endpoint decoder adheres to the requirement
2745-
* that poison reads of pmem and ram must be separated.
2746-
* CXL 3.0 Spec 8.2.9.8.4.1
2747-
*/
2748-
if (cxled->mode == CXL_DECODER_MIXED) {
2749-
dev_dbg(dev, "poison list read unsupported in mixed mode\n");
2750-
return rc;
2751-
}
2752-
27532741
cxlmd = cxled_to_memdev(cxled);
27542742
if (cxled->skip) {
27552743
offset = cxled->dpa_res->start - cxled->skip;

drivers/cxl/cxl.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ enum cxl_decoder_mode {
380380
CXL_DECODER_NONE,
381381
CXL_DECODER_RAM,
382382
CXL_DECODER_PMEM,
383-
CXL_DECODER_MIXED,
384383
CXL_DECODER_DEAD,
385384
};
386385

@@ -390,10 +389,9 @@ static inline const char *cxl_decoder_mode_name(enum cxl_decoder_mode mode)
390389
[CXL_DECODER_NONE] = "none",
391390
[CXL_DECODER_RAM] = "ram",
392391
[CXL_DECODER_PMEM] = "pmem",
393-
[CXL_DECODER_MIXED] = "mixed",
394392
};
395393

396-
if (mode >= CXL_DECODER_NONE && mode <= CXL_DECODER_MIXED)
394+
if (mode >= CXL_DECODER_NONE && mode < CXL_DECODER_DEAD)
397395
return names[mode];
398396
return "mixed";
399397
}

0 commit comments

Comments
 (0)