summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2023-02-10 01:05:51 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-11-28 17:07:17 +0000
commit93d242f63ed39f5742160ddc9b89a5c16e3fd9b6 (patch)
tree9e0ea2907262152ba803dec862bc58cf557f5a28
parent3b70d45c7ea8e6c4584f497b1bad1dba1c3b9557 (diff)
downloadlinux-stable-93d242f63ed39f5742160ddc9b89a5c16e3fd9b6.tar.gz
linux-stable-93d242f63ed39f5742160ddc9b89a5c16e3fd9b6.tar.bz2
linux-stable-93d242f63ed39f5742160ddc9b89a5c16e3fd9b6.zip
cxl/region: Validate region mode vs decoder mode
[ Upstream commit 1b9b7a6fd618239db47a83da39dff9e725a5865a ] In preparation for a new region mode, do not, for example, allow 'ram' decoders to be assigned to 'pmem' regions and vice versa. Reviewed-by: Vishal Verma <vishal.l.verma@intel.com> Reviewed-by: Gregory Price <gregory.price@memverge.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Tested-by: Fan Ni <fan.ni@samsung.com> Link: https://lore.kernel.org/r/167601995111.1924368.7459128614177994602.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com> Stable-dep-of: 0718588c7aaa ("cxl/region: Do not try to cleanup after cxl_region_setup_targets() fails") Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/cxl/core/region.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 9709bbf773b7..99b0501066e5 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1191,6 +1191,12 @@ static int cxl_region_attach(struct cxl_region *cxlr,
struct cxl_dport *dport;
int i, rc = -ENXIO;
+ if (cxled->mode != cxlr->mode) {
+ dev_dbg(&cxlr->dev, "%s region mode: %d mismatch: %d\n",
+ dev_name(&cxled->cxld.dev), cxlr->mode, cxled->mode);
+ return -EINVAL;
+ }
+
if (cxled->mode == CXL_DECODER_DEAD) {
dev_dbg(&cxlr->dev, "%s dead\n", dev_name(&cxled->cxld.dev));
return -ENODEV;