cxl/region: Verify target positions using the ordered target list

When a root decoder is configured the interleave target list is read
from the BIOS populated CFMWS structure. Per the CXL spec 3.1 Table
9-22 the target list is in interleave order. The CXL driver populates
its decoder target list in the same order and stores it in 'struct
cxl_switch_decoder' field "@target: active ordered target list in
current decoder configuration"

Given the promise of an ordered list, the driver can stop duplicating
the work of BIOS and simply check target positions against the ordered
list during region configuration.

The simplified check against the ordered list is presented here.
A follow-on patch will remove the unused code.

For Modulo arithmetic this is not a fix, only a simplification.
For XOR arithmetic this is a fix for HB IW of 3,6,12.

Fixes: f9db85bfec0d ("cxl/acpi: Support CXL XOR Interleave Math (CXIMS)")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://patch.msgid.link/35d08d3aba08fee0f9b86ab1cef0c25116ca8a55.1719980933.git.alison.schofield@intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>

authored by Alison Schofield and committed by Dave Jiang 82a3e3a2 3b2fedcd

+4 -1
+4 -1
drivers/cxl/core/region.c
··· 1559 const struct cxl_dport *dport, int pos) 1560 { 1561 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); 1562 struct cxl_port *iter; 1563 int rc; 1564 1565 - if (cxlrd->calc_hb(cxlrd, pos) != dport) { 1566 dev_dbg(&cxlr->dev, "%s:%s invalid target position for %s\n", 1567 dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), 1568 dev_name(&cxlrd->cxlsd.cxld.dev));
··· 1559 const struct cxl_dport *dport, int pos) 1560 { 1561 struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); 1562 + struct cxl_switch_decoder *cxlsd = &cxlrd->cxlsd; 1563 + struct cxl_decoder *cxld = &cxlsd->cxld; 1564 + int iw = cxld->interleave_ways; 1565 struct cxl_port *iter; 1566 int rc; 1567 1568 + if (dport != cxlrd->cxlsd.target[pos % iw]) { 1569 dev_dbg(&cxlr->dev, "%s:%s invalid target position for %s\n", 1570 dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), 1571 dev_name(&cxlrd->cxlsd.cxld.dev));