]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cxl: Remove the CXL_DECODER_MIXED mistake
authorDan Williams <dan.j.williams@intel.com>
Tue, 4 Feb 2025 04:24:06 +0000 (20:24 -0800)
committerDave Jiang <dave.jiang@intel.com>
Tue, 4 Feb 2025 20:48:18 +0000 (13:48 -0700)
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>
drivers/cxl/core/hdm.c
drivers/cxl/core/region.c
drivers/cxl/cxl.h

index 50e6a45b30ba260c066a0781b9ed3a2f6f3462d7..b7f6a2d69f7811daedc06aaf4a715684799cf17c 100644 (file)
@@ -332,9 +332,9 @@ static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled,
        else if (resource_contains(&cxlds->ram_res, res))
                cxled->mode = CXL_DECODER_RAM;
        else {
-               dev_warn(dev, "decoder%d.%d: %pr mixed mode not supported\n",
-                        port->id, cxled->cxld.id, cxled->dpa_res);
-               cxled->mode = CXL_DECODER_MIXED;
+               dev_warn(dev, "decoder%d.%d: %pr does not map any partition\n",
+                        port->id, cxled->cxld.id, res);
+               cxled->mode = CXL_DECODER_NONE;
        }
 
        port->hdm_end++;
index e8d11a988fd926a81e9eae993c2fe42d8e625787..34aa3d45fafadefd03df8f5bb3c239fc2b427c3c 100644 (file)
@@ -2738,18 +2738,6 @@ static int poison_by_decoder(struct device *dev, void *arg)
        if (!cxled->dpa_res || !resource_size(cxled->dpa_res))
                return rc;
 
-       /*
-        * Regions are only created with single mode decoders: pmem or ram.
-        * Linux does not support mixed mode decoders. This means that
-        * reading poison per endpoint decoder adheres to the requirement
-        * that poison reads of pmem and ram must be separated.
-        * CXL 3.0 Spec 8.2.9.8.4.1
-        */
-       if (cxled->mode == CXL_DECODER_MIXED) {
-               dev_dbg(dev, "poison list read unsupported in mixed mode\n");
-               return rc;
-       }
-
        cxlmd = cxled_to_memdev(cxled);
        if (cxled->skip) {
                offset = cxled->dpa_res->start - cxled->skip;
index bbbaa0d0a67036c997e5f970cb8741e67fbb644a..9fd1524ed150838885f6d735a9821b2ccc98e633 100644 (file)
@@ -380,7 +380,6 @@ enum cxl_decoder_mode {
        CXL_DECODER_NONE,
        CXL_DECODER_RAM,
        CXL_DECODER_PMEM,
-       CXL_DECODER_MIXED,
        CXL_DECODER_DEAD,
 };
 
@@ -390,10 +389,9 @@ static inline const char *cxl_decoder_mode_name(enum cxl_decoder_mode mode)
                [CXL_DECODER_NONE] = "none",
                [CXL_DECODER_RAM] = "ram",
                [CXL_DECODER_PMEM] = "pmem",
-               [CXL_DECODER_MIXED] = "mixed",
        };
 
-       if (mode >= CXL_DECODER_NONE && mode <= CXL_DECODER_MIXED)
+       if (mode >= CXL_DECODER_NONE && mode < CXL_DECODER_DEAD)
                return names[mode];
        return "mixed";
 }