From: Dan Williams Date: Fri, 10 Feb 2023 09:05:51 +0000 (-0800) Subject: cxl/region: Validate region mode vs decoder mode X-Git-Tag: v6.6.7~3417^2~6^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b9b7a6fd618239db47a83da39dff9e725a5865a;p=platform%2Fkernel%2Flinux-starfive.git cxl/region: Validate region mode vs decoder mode 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 Reviewed-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Ira Weiny Reviewed-by: Jonathan Cameron Tested-by: Fan Ni Link: https://lore.kernel.org/r/167601995111.1924368.7459128614177994602.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams --- diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 0fc8047..2858351 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1221,6 +1221,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;