Skip to content

Commit 98a04c7

Browse files
jimharrisdjbw
authored andcommitted
cxl/region: Fix x1 root-decoder granularity calculations
Root decoder granularity must match value from CFWMS, which may not be the region's granularity for non-interleaved root decoders. So when calculating granularities for host bridge decoders, use the region's granularity instead of the root decoder's granularity to ensure the correct granularities are set for the host bridge decoders and any downstream switch decoders. Test configuration is 1 host bridge * 2 switches * 2 endpoints per switch. Region created with 2048 granularity using following command line: cxl create-region -m -d decoder0.0 -w 4 mem0 mem2 mem1 mem3 \ -g 2048 -s 2048M Use "cxl list -PDE | grep granularity" to get a view of the granularity set at each level of the topology. Before this patch: "interleave_granularity":2048, "interleave_granularity":2048, "interleave_granularity":512, "interleave_granularity":2048, "interleave_granularity":2048, "interleave_granularity":512, "interleave_granularity":256, After: "interleave_granularity":2048, "interleave_granularity":2048, "interleave_granularity":4096, "interleave_granularity":2048, "interleave_granularity":2048, "interleave_granularity":4096, "interleave_granularity":2048, Fixes: 27b3f8d ("cxl/region: Program target lists") Cc: <stable@vger.kernel.org> Signed-off-by: Jim Harris <jim.harris@samsung.com> Link: https://lore.kernel.org/r/169824893473.1403938.16110924262989774582.stgit@bgt-140510-bm03.eng.stellus.in [djbw: fixup the prebuilt cxl_test region] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 3531b27 commit 98a04c7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

drivers/cxl/core/region.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,14 @@ static int cxl_port_setup_targets(struct cxl_port *port,
11271127
}
11281128

11291129
if (is_cxl_root(parent_port)) {
1130-
parent_ig = cxlrd->cxlsd.cxld.interleave_granularity;
1130+
/*
1131+
* Root decoder IG is always set to value in CFMWS which
1132+
* may be different than this region's IG. We can use the
1133+
* region's IG here since interleave_granularity_store()
1134+
* does not allow interleaved host-bridges with
1135+
* root IG != region IG.
1136+
*/
1137+
parent_ig = p->interleave_granularity;
11311138
parent_iw = cxlrd->cxlsd.cxld.interleave_ways;
11321139
/*
11331140
* For purposes of address bit routing, use power-of-2 math for

tools/testing/cxl/test/cxl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ static void mock_init_hdm_decoder(struct cxl_decoder *cxld)
831831
cxld->interleave_ways = 2;
832832
else
833833
cxld->interleave_ways = 1;
834-
cxld->interleave_granularity = 256;
834+
cxld->interleave_granularity = 4096;
835835
cxld->hpa_range = (struct range) {
836836
.start = base,
837837
.end = base + size - 1,

0 commit comments

Comments
 (0)