Skip to content

Commit 8c897b3

Browse files
committed
cxl/region: Manage decoder target_type at decoder-attach time
Switch-level (mid-level) decoders between the platform root and an endpoint can dynamically switch modes between HDM-H and HDM-D[B] depending on which region they target. Use the region type to fixup each decoder that gets allocated to map the given region. Note that endpoint decoders are meant to determine the region type, so warn if those ever need to be fixed up, but since it is possible to continue do so. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/168679262543.3436160.13053831955768440312.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent cecbb5d commit 8c897b3

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/cxl/core/region.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,18 @@ static int cxl_rr_alloc_decoder(struct cxl_port *port, struct cxl_region *cxlr,
809809
return -EBUSY;
810810
}
811811

812+
/*
813+
* Endpoints should already match the region type, but backstop that
814+
* assumption with an assertion. Switch-decoders change mapping-type
815+
* based on what is mapped when they are assigned to a region.
816+
*/
817+
dev_WARN_ONCE(&cxlr->dev,
818+
port == cxled_to_port(cxled) &&
819+
cxld->target_type != cxlr->type,
820+
"%s:%s mismatch decoder type %d -> %d\n",
821+
dev_name(&cxled_to_memdev(cxled)->dev),
822+
dev_name(&cxld->dev), cxld->target_type, cxlr->type);
823+
cxld->target_type = cxlr->type;
812824
cxl_rr->decoder = cxld;
813825
return 0;
814826
}

0 commit comments

Comments
 (0)