Merge branch 'for-6.5/cxl-region-fixes' into for-6.5/cxl
[platform/kernel/linux-starfive.git] / drivers / cxl / core / region.c
index bfdd424..38db377 100644 (file)
@@ -853,6 +853,18 @@ static int cxl_rr_alloc_decoder(struct cxl_port *port, struct cxl_region *cxlr,
                return -EBUSY;
        }
 
+       /*
+        * Endpoints should already match the region type, but backstop that
+        * assumption with an assertion. Switch-decoders change mapping-type
+        * based on what is mapped when they are assigned to a region.
+        */
+       dev_WARN_ONCE(&cxlr->dev,
+                     port == cxled_to_port(cxled) &&
+                             cxld->target_type != cxlr->type,
+                     "%s:%s mismatch decoder type %d -> %d\n",
+                     dev_name(&cxled_to_memdev(cxled)->dev),
+                     dev_name(&cxld->dev), cxld->target_type, cxlr->type);
+       cxld->target_type = cxlr->type;
        cxl_rr->decoder = cxld;
        return 0;
 }
@@ -2146,7 +2158,7 @@ static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd,
                return ERR_PTR(-EBUSY);
        }
 
-       return devm_cxl_add_region(cxlrd, id, mode, CXL_DECODER_EXPANDER);
+       return devm_cxl_add_region(cxlrd, id, mode, CXL_DECODER_HOSTONLYMEM);
 }
 
 static ssize_t create_pmem_region_store(struct device *dev,