cxl: Allow passthrough decoders with >16K granularity
Alison Schofield
maintainerv2 cover cxl: Allow passthrough decoders with >16K granularity
Changes in v2:
- Rebased on Linux 7.2-rc1
- Only v1 feedback was from Sashiko and that was not an issue Link to v1:
https://lore.kernel.org/linux-cxl/[email protected]/
Sashiko reported [1] that region setup rejects valid topologies containing a passthrough decoder beneath a wide parent interleave. In these configurations, a passthrough decoder can compute a granularity above the 16K maximum encodable in the interleave granularity (IG) field even though non-interleaving decoders do not consume that field.
The first patch avoids validating the interleave granularity of non-interleaving decoders, encodes the IG field as a don't-care when committing those decoders, and updates the sysfs ABI documentation accordingly.
The second patch extends cxl-test with a topology that allows a CXL unit test to cover this case.
A unit test update for this case is posted for review [2].
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Alison Schofield (2):
cxl/region: Allow passthrough decoders with >16K granularity cxl/test: Add a 2-way 16K root decoder for passthrough testing
Documentation/ABI/testing/sysfs-bus-cxl | 5 ++- drivers/cxl/core/hdm.c | 13 +++++-- drivers/cxl/core/region.c | 47 ++++++++++++++---------- tools/testing/cxl/test/cxl.c | 48 +++++++++++++++++++++++-- 4 files changed, 88 insertions(+), 25 deletions(-)
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
Signature · 1 line
2.37.3
Alison Schofield
maintainerPATCH v2 1/2 cxl/region: Allow passthrough decoders with >16K granularity
Region configuration rejects valid topologies that contain a passthrough decoder beneath a wide parent interleave.
For example, a passthrough switch below an 8-way root decoder with 4K granularity computes a 32K granularity. That exceeds the maximum encodable value of the HDM Decoder Control IG field, causing region setup to fail even though a non-interleaving decoder does not consume the IG field.
Only require the granularity to be encodable for interleaving decoders, both where it is inherited from the parent and where it is computed for the current decoder. Keep the computed value for passthrough decoders so it can seed descendant decoder setup, and program a don't-care IG encoding when committing a non-interleaving decoder.
As a consequence, the interleave_granularity attribute of a decoder whose interleave_ways is 1 may report a value above 16K. Document that the reported granularity for non-interleaving decoders is a don't-care value that may exceed the maximum encodable in hardware.
--- Documentation/ABI/testing/sysfs-bus-cxl | 5 ++- drivers/cxl/core/hdm.c | 13 +++++-- drivers/cxl/core/region.c | 47 +++++++++++++++---------- 3 files changed, 42 insertions(+), 23 deletions(-)
Documentation/ABI/testing/sysfs-bus-cxl +4 -1
@@ -407,7 +407,10 @@ Description: space this decoder claims at address N before the decode rotates to the next target in the interleave at address N + interleave_granularity (assuming N is aligned to - interleave_granularity). + interleave_granularity). When 'interleave_ways' is 1, the + decoder does not interleave and the reported granularity is + a don't-care value that may exceed the maximum encodable in + hardware. What: /sys/bus/cxl/devices/decoderX.Y/create_{pmem,ram}_region
drivers/cxl/core/hdm.c +10 -3
@@ -691,9 +691,16 @@ static void cxld_set_interleave(struct cxl_decoder *cxld, u32 *ctrl)if (WARN_ONCE (ways_to_eiw (cxld->interleave_ways, &eiw),"invalid interleave_ways: %d\n" , cxld->interleave_ways))return ; -if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), -"invalid interleave_granularity: %d\n" , - cxld->interleave_granularity)) + +/* +* A non-interleaving decoder ignores the IG field. Encode a +* don't-care value instead of validating the stored granularity. +*/ +if (cxld->interleave_ways ==1 ) + eig =0 ; +else if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), +"invalid interleave_granularity: %d\n" , + cxld->interleave_granularity))return ;u32p_replace_bits (ctrl, eig,CXL_HDM_DECODER0_CTRL_IG_MASK );
drivers/cxl/core/region.c +28 -19
60 lines not on this page · raw message
Signature · 1 line
2.37.3
Alison Schofield
maintainerPATCH v2 2/2 cxl/test: Add a 2-way 16K root decoder for passthrough testing
In reply to Alison SchofieldThe cxl-test topologies do not provide a configuration where pass- through decoders compute a granularity above the 16K max encodable in hardware. The widest power-of-2 root decoder currently available is 2-way at 4K granularity, so a passthrough decoder below it computes at most 16K.
Add a CFMWS entry for a 2-way root decoder at 16K granularity. This topology supports a region configuration spanning the two multi-port host bridges and placing one endpoint under each bridge. The intermediate switch decoders are then passthrough decoders with a computed granularity of 32K.
This allows a CXL unit test to be added for this case.
Place the new window in the XOR topology set so the default modulo topology used by most cxl-test coverage is unchanged.
--- tools/testing/cxl/test/cxl.c | 48 ++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-)
tools/testing/cxl/test/cxl.c +46 -2
@@ -188,10 +188,18 @@ static struct {struct acpi_cedt_cfmws cfmws;u32 target[3 ]; } cfmws8; +struct { +struct acpi_cedt_cfmws cfmws; +u32 target[2 ]; + } cfmws9;struct {struct acpi_cedt_cxims cxims;u64 xormap_list[2 ]; } cxims0; +struct { +struct acpi_cedt_cxims cxims; +u64 xormap_list[1 ]; + } cxims1; }__packed mock_cedt = { .cedt = { .header = {
@@ -371,6 +379,28 @@ static struct { }, .target = { 0, 1, 2, }, }, +/* +* A 2-way root at 16K granularity. A passthrough decoder below this +* root computes a 32K granularity (16K * 2), which exceeds the maximum +* encodable in hardware. It exercises the passthrough granularity path +* in cxl_port_setup_targets(). +*/ + .cfmws9 = { + .cfmws = { + .header = { + .type =ACPI_CEDT_TYPE_CFMWS , + .length = sizeof(mock_cedt.cfmws9), + }, + .interleave_arithmetic =ACPI_CEDT_CFMWS_ARITHMETIC_XOR , + .interleave_ways = 1, + .granularity = 6, + .restrictions = ACPI_CEDT_CFMWS_RESTRICT_HOSTONLYMEM | +ACPI_CEDT_CFMWS_RESTRICT_PMEM , + .qtg_id = FAKE_QTG_ID, + .window_size = SZ_256M * 8UL, + }, + .target = { 0, 1, }, + }, .cxims0 = { .cxims = { .header = {
@@ -382,6 +412,18 @@ static struct { }, .xormap_list = { 0x404100, 0x808200, }, }, +/* CXIMS for the 16K (hbig = 6) 2-way root, cfmws9 */ + .cxims1 = { + .cxims = { + .header = { + .type =ACPI_CEDT_TYPE_CXIMS , + .length = sizeof(mock_cedt.cxims1), + }, + .hbig =6 , + .nr_xormaps = 1, + }, + .xormap_list = { 0x0, }, + }, }; struct acpi_cedt_cfmws *mock_cfmws[] = {
@@ -395,6 +437,7 @@ struct acpi_cedt_cfmws *mock_cfmws[] = { [6] = &mock_cedt.cfmws6.cfmws, [7] = &mock_cedt.cfmws7.cfmws, [8] = &mock_cedt.cfmws8.cfmws, + [9] = &mock_cedt.cfmws9.cfmws, };static int cfmws_start;
@@ -402,10 +445,11 @@ static int cfmws_end;#define CFMWS_MOD_ARRAY_START 0#define CFMWS_MOD_ARRAY_END 5#define CFMWS_XOR_ARRAY_START 6 -#define CFMWS_XOR_ARRAY_END 8 +#define CFMWS_XOR_ARRAY_END 9 -struct acpi_cedt_cxims *mock_cxims[1 ] = { +struct acpi_cedt_cxims *mock_cxims[2 ] = { [0 ] = &mock_cedt.cxims0.cxims, + [1 ] = &mock_cedt.cxims1.cxims, };struct cxl_mock_res {
Signature · 1 line
2.37.3
[email protected]
AI reviewRe: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity
In reply to Alison SchofieldThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] During auto-discovery (CXL_REGION_F_AUTO), passthrough decoders fail to update their…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] During auto-discovery (CXL_REGION_F_AUTO), passthrough decoders fail to update their interleave_granularity software state to the computed value, causing downstream decoders to inherit incorrect granularity and fail validation upon reboot. --
--- Patch [1]: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity --- commit 9e2526342188a97e338bfc63d454c253f1e2b3ef
Author: Alison Schofield <[email protected]>
cxl/region: Allow passthrough decoders with >16K granularity
This commit allows passthrough decoders beneath wide parent interleaves to have a granularity exceeding 16K by programming a don't-care value in hardware for non-interleaving decoders.
Quoted 24 lines
drivers/cxl/core/hdm.c +10
-3@@ -691,9 +691,16 @@ static void cxld_set_interleave(struct cxl_decoder *cxld, u32 *ctrl)if (WARN_ONCE (ways_to_eiw (cxld->interleave_ways, &eiw),"invalid interleave_ways: %d\n" , cxld->interleave_ways))return ; -if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), -"invalid interleave_granularity: %d\n" , - cxld->interleave_granularity)) + +/* +* A non-interleaving decoder ignores the IG field. Encode a +* don't-care value instead of validating the stored granularity. +*/ +if (cxld->interleave_ways ==1 ) + eig =0 ; +else if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), +"invalid interleave_granularity: %d\n" , + cxld->interleave_granularity))return ;u32p_replace_bits (ctrl, eig,CXL_HDM_DECODER0_CTRL_IG_MASK );
[ ... ]
Quoted 4 lines
drivers/cxl/core/region.c +0
-0
[ ... ]
Quoted 25 lines
drivers/cxl/core/region.c +7
-13@@ -1549,20 +1557,21 @@ static int cxl_port_setup_targets(struct cxl_port *port,* Interleave granularity is a multiple of @parent_port granularity. * Multiplier is the parent port interleave ways. */ - rc =granularity_to_eig (parent_ig * parent_iw, &eig); -if (rc) { -dev_dbg (&cxlr->dev, -"%s: invalid granularity calculation (%d * %d)\n" , -dev_name (&parent_port->dev), parent_ig, parent_iw); -return rc; - } + ig = parent_ig * parent_iw; - rc =eig_to_granularity (eig, &ig); -if (rc) { -dev_dbg (&cxlr->dev,"%s:%s: invalid interleave: %d\n" , -dev_name (port->uport_dev),dev_name (&port->dev), -256 << eig); -return rc; +/* +* Keep the computed granularity for descendant setup. Only +* interleaving decoders require an encodable granularity. +*/ +if (iw >1 ) { + rc =granularity_to_eig (ig, &eig);
drivers/cxl/core/region.c static int cxl_port_setup_targets(struct cxl_port *port, · line 1577
Quoted 10 lines
drivers/cxl/core/region.c +7
-0+if (rc) { +dev_dbg (&cxlr->dev, +"%s: invalid granularity calculation (%d * %d)\n" , +dev_name (&parent_port->dev), parent_ig, + parent_iw); +return rc; + } }if (iw >8 || iw > cxlsd->nr_targets) {
[Severity: High]
Does this code break region auto-discovery on reboot for topologies containing a passthrough decoder?
When cxld_set_interleave() configures a passthrough decoder, it now sets eig = 0 (a don't-care value) in the hardware.
Upon reboot, reading this hardware state will initialize the decoder's software interleave_granularity to a stale value.
During auto-discovery in cxl_port_setup_targets(), the CXL_REGION_F_AUTO path skips validating the granularity for passthrough decoders (iw == 1), but it appears to be missing an update to correct the software state:
if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) {
if (cxld->interleave_ways != iw ||
(iw > 1 && cxld->interleave_granularity != ig) ||
!spa_maps_hpa(p, &cxld->hpa_range) ||
((cxld->flags & CXL_DECODER_F_ENABLE) == 0)) {
...
return -ENXIO;
}
/* missing update: cxld->interleave_granularity = ig; */
}If cxld->interleave_granularity is not updated to the computed ig here, won't any interleaving descendants read the stale parent_ig, compute a mismatched expected granularity, and fail validation?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Alison Schofield
maintainerRe: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity
Quoted 2 lines · On Sat, Jul 11, 2026 at 08:15:07PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] During auto-discovery (CXL_REGION_F_AUTO), passthrough decoders fail to update theirinterleave_granularitysoftware state to the computed value, causing downstream decoders to inherit incorrect granularity and fail validation upon reboot.
Same NO as in v1[1] and I don't see a way to graciously alert you to this in the code. Gratuitously updating the field is not the right thing to do.
[1] https://lore.kernel.org/linux-cxl/[email protected]/#r
No. A downstream decoder can't inherit an unecodable value into a failing check. A >16K granularity only appears below a wide interleave, and everything below that inherits an equal-or-larger value that an interleaving decoder couldn't encode. So every descendant is necessarily passthrough and never validates granularity. There is no path where updating the F_AUTO value would prevent a failure because the failure cannot happen.
Quoted 113 lines
--
--- Patch [1]: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity --- commit
9e2526342188a97e338bfc63d454c253f1e2b3ef
Author: Alison Schofield <[email protected]>cxl/region: Allow passthrough decoders with >16K granularity
This commit allows passthrough decoders beneath wide parent interleaves to have a granularity exceeding 16K by programming a don't-care value in hardware for non-interleaving decoders.
Quoted 24 lines
drivers/cxl/core/hdm.c +10
-3@@ -691,9 +691,16 @@ static void cxld_set_interleave(struct cxl_decoder *cxld, u32 *ctrl)if (WARN_ONCE (ways_to_eiw (cxld->interleave_ways, &eiw),"invalid interleave_ways: %d\n" , cxld->interleave_ways))return ; -if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), -"invalid interleave_granularity: %d\n" , - cxld->interleave_granularity)) + +/* +* A non-interleaving decoder ignores the IG field. Encode a +* don't-care value instead of validating the stored granularity. +*/ +if (cxld->interleave_ways ==1 ) + eig =0 ; +else if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), +"invalid interleave_granularity: %d\n" , + cxld->interleave_granularity))return ;u32p_replace_bits (ctrl, eig,CXL_HDM_DECODER0_CTRL_IG_MASK );[ ... ]
Quoted 4 lines
drivers/cxl/core/region.c +0
-0[ ... ]
Quoted 25 lines
drivers/cxl/core/region.c +7
-13@@ -1549,20 +1557,21 @@ static int cxl_port_setup_targets(struct cxl_port *port,* Interleave granularity is a multiple of @parent_port granularity. * Multiplier is the parent port interleave ways. */ - rc =granularity_to_eig (parent_ig * parent_iw, &eig); -if (rc) { -dev_dbg (&cxlr->dev, -"%s: invalid granularity calculation (%d * %d)\n" , -dev_name (&parent_port->dev), parent_ig, parent_iw); -return rc; - } + ig = parent_ig * parent_iw; - rc =eig_to_granularity (eig, &ig); -if (rc) { -dev_dbg (&cxlr->dev,"%s:%s: invalid interleave: %d\n" , -dev_name (port->uport_dev),dev_name (&port->dev), -256 << eig); -return rc; +/* +* Keep the computed granularity for descendant setup. Only +* interleaving decoders require an encodable granularity. +*/ +if (iw >1 ) { + rc =granularity_to_eig (ig, &eig);drivers/cxl/core/region.c static int cxl_port_setup_targets(struct cxl_port *port, · line 1577
Quoted 10 lines
drivers/cxl/core/region.c +7
-0+if (rc) { +dev_dbg (&cxlr->dev, +"%s: invalid granularity calculation (%d * %d)\n" , +dev_name (&parent_port->dev), parent_ig, + parent_iw); +return rc; + } }if (iw >8 || iw > cxlsd->nr_targets) {[Severity: High]
Does this code break region auto-discovery on reboot for topologies containing a passthrough decoder?When
cxld_set_interleave()configures a passthrough decoder, it now sets eig = 0 (a don't-care value) in the hardware.Upon reboot, reading this hardware state will initialize the decoder's software
interleave_granularityto a stale value.During auto-discovery in
cxl_port_setup_targets(), theCXL_REGION_F_AUTOpath skips validating the granularity for passthrough decoders (iw == 1), but it appears to be missing an update to correct the software state:if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { if (cxld->interleave_ways != iw || (iw > 1 && cxld->interleave_granularity != ig) || !spa_maps_hpa(p, &cxld->hpa_range) || ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)) { ... return -ENXIO; } /* missing update: cxld->interleave_granularity = ig; */ }If
cxld->interleave_granularityis not updated to the computed ig here, won't any interleaving descendants read the staleparent_ig, compute a mismatched expected granularity, and fail validation?Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity
Quoted 9 lines · Alison Schofield
Quoted 2 lines · On Sat, Jul 11, 2026 at 08:15:07PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] During auto-discovery (CXL_REGION_F_AUTO), passthrough decoders fail to update theirinterleave_granularitysoftware state to the computed value, causing downstream decoders to inherit incorrect granularity and fail validation upon reboot.Same NO as in v1[1] and I don't see a way to graciously alert you to this in the code. Gratuitously updating the field is not the right thing to do.
Quoted 8 lines
[1] https://lore.kernel.org/linux-cxl/[email protected]/#r
No. A downstream decoder can't inherit an unecodable value into a failing check. A >16K granularity only appears below a wide interleave, and everything below that inherits an equal-or-larger value that an interleaving decoder couldn't encode. So every descendant is necessarily passthrough and never validates granularity. There is no path where updating theF_AUTOvalue would prevent a failure because the failure cannot happen.
Hi Alison,
I'm thinking of 1 scenario where a regression might still happen, independent of whether an interleaving decoder can appear below a >16k passthrough decoder.
The new cxld_set_interleave() behavior writes EIG=0 for every IW=1 decoder, including cases where logical granularity is encodable.
For example,
root: IW=2, IG=4k
passthrough: IW=1, logical IG=8K
downstream: IW=2, IG=8K
During manual setup, the passthrough decoder gets a logical IG of 8K. With your change, committing it writes EIG=0. On rediscovery, that is read back as 256 byte.
The AUTO path accepts the passthrough decoder because it skips the IG comparison for IW=1, but it does not restore.
The downstream decoder will inherits 256 bytes instead of 8K and its 8K config fails validation.
Could cxld_set_interleave() keep the real IG encoding when it's encodable and use EIG=0 only when an IW=1 value isn't encodable?
For latter case, AUTO still need to restore the computed logical IG before walking descendants.
What do you think ?
Best regards,
Richard Cheng.
Quoted 116 lines
Quoted 115 lines
--
--- Patch [1]: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity --- commit
9e2526342188a97e338bfc63d454c253f1e2b3ef
Author: Alison Schofield <[email protected]>cxl/region: Allow passthrough decoders with >16K granularity
This commit allows passthrough decoders beneath wide parent interleaves to have a granularity exceeding 16K by programming a don't-care value in hardware for non-interleaving decoders.
Quoted 24 lines
drivers/cxl/core/hdm.c +10
-3@@ -691,9 +691,16 @@ static void cxld_set_interleave(struct cxl_decoder *cxld, u32 *ctrl)if (WARN_ONCE (ways_to_eiw (cxld->interleave_ways, &eiw),"invalid interleave_ways: %d\n" , cxld->interleave_ways))return ; -if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), -"invalid interleave_granularity: %d\n" , - cxld->interleave_granularity)) + +/* +* A non-interleaving decoder ignores the IG field. Encode a +* don't-care value instead of validating the stored granularity. +*/ +if (cxld->interleave_ways ==1 ) + eig =0 ; +else if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), +"invalid interleave_granularity: %d\n" , + cxld->interleave_granularity))return ;u32p_replace_bits (ctrl, eig,CXL_HDM_DECODER0_CTRL_IG_MASK );[ ... ]
Quoted 4 lines
drivers/cxl/core/region.c +0
-0[ ... ]
Quoted 25 lines
drivers/cxl/core/region.c +7
-13@@ -1549,20 +1557,21 @@ static int cxl_port_setup_targets(struct cxl_port *port,* Interleave granularity is a multiple of @parent_port granularity. * Multiplier is the parent port interleave ways. */ - rc =granularity_to_eig (parent_ig * parent_iw, &eig); -if (rc) { -dev_dbg (&cxlr->dev, -"%s: invalid granularity calculation (%d * %d)\n" , -dev_name (&parent_port->dev), parent_ig, parent_iw); -return rc; - } + ig = parent_ig * parent_iw; - rc =eig_to_granularity (eig, &ig); -if (rc) { -dev_dbg (&cxlr->dev,"%s:%s: invalid interleave: %d\n" , -dev_name (port->uport_dev),dev_name (&port->dev), -256 << eig); -return rc; +/* +* Keep the computed granularity for descendant setup. Only +* interleaving decoders require an encodable granularity. +*/ +if (iw >1 ) { + rc =granularity_to_eig (ig, &eig);drivers/cxl/core/region.c static int cxl_port_setup_targets(struct cxl_port *port, · line 1577
Quoted 10 lines
drivers/cxl/core/region.c +7
-0+if (rc) { +dev_dbg (&cxlr->dev, +"%s: invalid granularity calculation (%d * %d)\n" , +dev_name (&parent_port->dev), parent_ig, + parent_iw); +return rc; + } }if (iw >8 || iw > cxlsd->nr_targets) {[Severity: High]
Does this code break region auto-discovery on reboot for topologies containing a passthrough decoder?When
cxld_set_interleave()configures a passthrough decoder, it now sets eig = 0 (a don't-care value) in the hardware.Upon reboot, reading this hardware state will initialize the decoder's software
interleave_granularityto a stale value.During auto-discovery in
cxl_port_setup_targets(), theCXL_REGION_F_AUTOpath skips validating the granularity for passthrough decoders (iw == 1), but it appears to be missing an update to correct the software state:if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { if (cxld->interleave_ways != iw || (iw > 1 && cxld->interleave_granularity != ig) || !spa_maps_hpa(p, &cxld->hpa_range) || ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)) { ... return -ENXIO; } /* missing update: cxld->interleave_granularity = ig; */ }If
cxld->interleave_granularityis not updated to the computed ig here, won't any interleaving descendants read the staleparent_ig, compute a mismatched expected granularity, and fail validation?Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Alison Schofield
maintainerRe: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity
In reply to [email protected]Quoted 109 lines · On Sat, Jul 11, 2026 at 08:15:07PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] During auto-discovery (CXL_REGION_F_AUTO), passthrough decoders fail to update theirinterleave_granularitysoftware state to the computed value, causing downstream decoders to inherit incorrect granularity and fail validation upon reboot. ----- Patch [1]: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity --- commit
9e2526342188a97e338bfc63d454c253f1e2b3ef
Author: Alison Schofield <[email protected]>cxl/region: Allow passthrough decoders with >16K granularity
This commit allows passthrough decoders beneath wide parent interleaves to have a granularity exceeding 16K by programming a don't-care value in hardware for non-interleaving decoders.
Quoted 24 lines
drivers/cxl/core/hdm.c +10
-3@@ -691,9 +691,16 @@ static void cxld_set_interleave(struct cxl_decoder *cxld, u32 *ctrl)if (WARN_ONCE (ways_to_eiw (cxld->interleave_ways, &eiw),"invalid interleave_ways: %d\n" , cxld->interleave_ways))return ; -if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), -"invalid interleave_granularity: %d\n" , - cxld->interleave_granularity)) + +/* +* A non-interleaving decoder ignores the IG field. Encode a +* don't-care value instead of validating the stored granularity. +*/ +if (cxld->interleave_ways ==1 ) + eig =0 ; +else if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), +"invalid interleave_granularity: %d\n" , + cxld->interleave_granularity))return ;u32p_replace_bits (ctrl, eig,CXL_HDM_DECODER0_CTRL_IG_MASK );[ ... ]
Quoted 4 lines
drivers/cxl/core/region.c +0
-0[ ... ]
Quoted 25 lines
drivers/cxl/core/region.c +7
-13@@ -1549,20 +1557,21 @@ static int cxl_port_setup_targets(struct cxl_port *port,* Interleave granularity is a multiple of @parent_port granularity. * Multiplier is the parent port interleave ways. */ - rc =granularity_to_eig (parent_ig * parent_iw, &eig); -if (rc) { -dev_dbg (&cxlr->dev, -"%s: invalid granularity calculation (%d * %d)\n" , -dev_name (&parent_port->dev), parent_ig, parent_iw); -return rc; - } + ig = parent_ig * parent_iw; - rc =eig_to_granularity (eig, &ig); -if (rc) { -dev_dbg (&cxlr->dev,"%s:%s: invalid interleave: %d\n" , -dev_name (port->uport_dev),dev_name (&port->dev), -256 << eig); -return rc; +/* +* Keep the computed granularity for descendant setup. Only +* interleaving decoders require an encodable granularity. +*/ +if (iw >1 ) { + rc =granularity_to_eig (ig, &eig);drivers/cxl/core/region.c static int cxl_port_setup_targets(struct cxl_port *port, · line 1577
Quoted 10 lines
drivers/cxl/core/region.c +7
-0+if (rc) { +dev_dbg (&cxlr->dev, +"%s: invalid granularity calculation (%d * %d)\n" , +dev_name (&parent_port->dev), parent_ig, + parent_iw); +return rc; + } }if (iw >8 || iw > cxlsd->nr_targets) {[Severity: High]
Does this code break region auto-discovery on reboot for topologies containing a passthrough decoder?When
cxld_set_interleave()configures a passthrough decoder, it now sets eig = 0 (a don't-care value) in the hardware.Upon reboot, reading this hardware state will initialize the decoder's software
interleave_granularityto a stale value.During auto-discovery in
cxl_port_setup_targets(), theCXL_REGION_F_AUTOpath skips validating the granularity for passthrough decoders (iw == 1), but it appears to be missing an update to correct the software state:if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { if (cxld->interleave_ways != iw || (iw > 1 && cxld->interleave_granularity != ig) || !spa_maps_hpa(p, &cxld->hpa_range) || ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)) { ... return -ENXIO; } /* missing update: cxld->interleave_granularity = ig; */ }
Quoted 3 lines
If
cxld->interleave_granularityis not updated to the computed ig here, won't any interleaving descendants read the staleparent_ig, compute a mismatched expected granularity, and fail validation?
In preparing v3 I found I didn't reply to this last piece. It is real for the encodable case. My v2 clobbered it and read back state. I've fixed it in v3 at the encode side, so F_AUTO has nothing to restore.
-- Alison
Quoted 3 lines
Signature · 2 lines
-- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Alison Schofield
maintainerRe: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity
In reply to Richard ChengQuoted 37 lines · Richard Cheng
Quoted 9 lines · Alison Schofield
Quoted 2 lines · On Sat, Jul 11, 2026 at 08:15:07PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] During auto-discovery (CXL_REGION_F_AUTO), passthrough decoders fail to update theirinterleave_granularitysoftware state to the computed value, causing downstream decoders to inherit incorrect granularity and fail validation upon reboot.Same NO as in v1[1] and I don't see a way to graciously alert you to this in the code. Gratuitously updating the field is not the right thing to do.
Quoted 8 lines
[1] https://lore.kernel.org/linux-cxl/[email protected]/#r
No. A downstream decoder can't inherit an unecodable value into a failing check. A >16K granularity only appears below a wide interleave, and everything below that inherits an equal-or-larger value that an interleaving decoder couldn't encode. So every descendant is necessarily passthrough and never validates granularity. There is no path where updating theF_AUTOvalue would prevent a failure because the failure cannot happen.Hi Alison,
I'm thinking of 1 scenario where a regression might still happen, independent of whether an interleaving decoder can appear below a >16k passthrough decoder.
The new
cxld_set_interleave()behavior writes EIG=0 for every IW=1 decoder, including cases where logical granularity is encodable.For example,
root: IW=2, IG=4k
passthrough: IW=1, logical IG=8K
downstream: IW=2, IG=8KDuring manual setup, the passthrough decoder gets a logical IG of 8K. With your change, committing it writes EIG=0. On rediscovery, that is read back as 256 byte.
Quoted 8 lines
The AUTO path accepts the passthrough decoder because it skips the IG comparison for IW=1, but it does not restore.
The downstream decoder will inherits 256 bytes instead of 8K and its 8K config fails validation.
Could
cxld_set_interleave()keep the real IG encoding when it's encodable and use EIG=0 only when an IW=1 value isn't encodable?
Yes, and fixed that up in v3.
Quoted 2 lines
For latter case, AUTO still need to restore the computed logical IG before walking descendants.
I don't find it needed for the unencodabe (>16K) case. Every descendant is itself passthru and never validates granularity. And with the encode fix, the encodabe case is no longer clobbered, so there is nothing state to restore, and nothing left to test for.
Please take a look at v3.
Thanks for the review!
-- Alison
Quoted 121 lines
What do you think ?
Best regards,
Richard Cheng.Quoted 116 lines
Quoted 115 lines
--
--- Patch [1]: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity --- commit
9e2526342188a97e338bfc63d454c253f1e2b3ef
Author: Alison Schofield <[email protected]>cxl/region: Allow passthrough decoders with >16K granularity
This commit allows passthrough decoders beneath wide parent interleaves to have a granularity exceeding 16K by programming a don't-care value in hardware for non-interleaving decoders.
Quoted 24 lines
drivers/cxl/core/hdm.c +10
-3@@ -691,9 +691,16 @@ static void cxld_set_interleave(struct cxl_decoder *cxld, u32 *ctrl)if (WARN_ONCE (ways_to_eiw (cxld->interleave_ways, &eiw),"invalid interleave_ways: %d\n" , cxld->interleave_ways))return ; -if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), -"invalid interleave_granularity: %d\n" , - cxld->interleave_granularity)) + +/* +* A non-interleaving decoder ignores the IG field. Encode a +* don't-care value instead of validating the stored granularity. +*/ +if (cxld->interleave_ways ==1 ) + eig =0 ; +else if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), +"invalid interleave_granularity: %d\n" , + cxld->interleave_granularity))return ;u32p_replace_bits (ctrl, eig,CXL_HDM_DECODER0_CTRL_IG_MASK );[ ... ]
Quoted 4 lines
drivers/cxl/core/region.c +0
-0[ ... ]
Quoted 25 lines
drivers/cxl/core/region.c +7
-13@@ -1549,20 +1557,21 @@ static int cxl_port_setup_targets(struct cxl_port *port,* Interleave granularity is a multiple of @parent_port granularity. * Multiplier is the parent port interleave ways. */ - rc =granularity_to_eig (parent_ig * parent_iw, &eig); -if (rc) { -dev_dbg (&cxlr->dev, -"%s: invalid granularity calculation (%d * %d)\n" , -dev_name (&parent_port->dev), parent_ig, parent_iw); -return rc; - } + ig = parent_ig * parent_iw; - rc =eig_to_granularity (eig, &ig); -if (rc) { -dev_dbg (&cxlr->dev,"%s:%s: invalid interleave: %d\n" , -dev_name (port->uport_dev),dev_name (&port->dev), -256 << eig); -return rc; +/* +* Keep the computed granularity for descendant setup. Only +* interleaving decoders require an encodable granularity. +*/ +if (iw >1 ) { + rc =granularity_to_eig (ig, &eig);drivers/cxl/core/region.c static int cxl_port_setup_targets(struct cxl_port *port, · line 1577
Quoted 10 lines
drivers/cxl/core/region.c +7
-0+if (rc) { +dev_dbg (&cxlr->dev, +"%s: invalid granularity calculation (%d * %d)\n" , +dev_name (&parent_port->dev), parent_ig, + parent_iw); +return rc; + } }if (iw >8 || iw > cxlsd->nr_targets) {[Severity: High]
Does this code break region auto-discovery on reboot for topologies containing a passthrough decoder?When
cxld_set_interleave()configures a passthrough decoder, it now sets eig = 0 (a don't-care value) in the hardware.Upon reboot, reading this hardware state will initialize the decoder's software
interleave_granularityto a stale value.During auto-discovery in
cxl_port_setup_targets(), theCXL_REGION_F_AUTOpath skips validating the granularity for passthrough decoders (iw == 1), but it appears to be missing an update to correct the software state:if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { if (cxld->interleave_ways != iw || (iw > 1 && cxld->interleave_granularity != ig) || !spa_maps_hpa(p, &cxld->hpa_range) || ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)) { ... return -ENXIO; } /* missing update: cxld->interleave_granularity = ig; */ }If
cxld->interleave_granularityis not updated to the computed ig here, won't any interleaving descendants read the staleparent_ig, compute a mismatched expected granularity, and fail validation?Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Jonathan Cameron
maintainerRe: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity
In reply to Richard ChengQuoted 37 lines · On Tue, 14 Jul 2026 15:56:18 +0800 Richard Cheng <[email protected]> wrote:
Quoted 9 lines · Alison Schofield
Quoted 2 lines · On Sat, Jul 11, 2026 at 08:15:07PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] During auto-discovery (CXL_REGION_F_AUTO), passthrough decoders fail to update theirinterleave_granularitysoftware state to the computed value, causing downstream decoders to inherit incorrect granularity and fail validation upon reboot.Same NO as in v1[1] and I don't see a way to graciously alert you to this in the code. Gratuitously updating the field is not the right thing to do.
Quoted 8 lines
[1] https://lore.kernel.org/linux-cxl/[email protected]/#r
No. A downstream decoder can't inherit an unecodable value into a failing check. A >16K granularity only appears below a wide interleave, and everything below that inherits an equal-or-larger value that an interleaving decoder couldn't encode. So every descendant is necessarily passthrough and never validates granularity. There is no path where updating theF_AUTOvalue would prevent a failure because the failure cannot happen.Hi Alison,
I'm thinking of 1 scenario where a regression might still happen, independent of whether an interleaving decoder can appear below a >16k passthrough decoder.
The new
cxld_set_interleave()behavior writes EIG=0 for every IW=1 decoder, including cases where logical granularity is encodable.For example,
root: IW=2, IG=4k
passthrough: IW=1, logical IG=8K
downstream: IW=2, IG=8KDuring manual setup, the passthrough decoder gets a logical IG of 8K. With your change, committing it writes EIG=0. On rediscovery, that is read back as 256 byte.
Quoted 5 lines
The AUTO path accepts the passthrough decoder because it skips the IG comparison for IW=1, but it does not restore.
The downstream decoder will inherits 256 bytes instead of 8K and its 8K config fails validation.
I was looking back having seen some text on this in v4 that confused me.
Isn't a failure on this combination a bug anyway (that we should fix)? The downstream decoder shouldn't inherit a value of granularity from a pass through decoder (as it's meaningless) it should be getting the appropriate values from next level up in the tree (or further if there are more passthrough decoders up there).
Jonathan
Quoted 126 lines
Could
cxld_set_interleave()keep the real IG encoding when it's encodable and use EIG=0 only when an IW=1 value isn't encodable?
For latter case, AUTO still need to restore the computed logical IG before walking descendants.What do you think ?
Best regards,
Richard Cheng.Quoted 116 lines
Quoted 115 lines
--
--- Patch [1]: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity --- commit
9e2526342188a97e338bfc63d454c253f1e2b3ef
Author: Alison Schofield <[email protected]>cxl/region: Allow passthrough decoders with >16K granularity
This commit allows passthrough decoders beneath wide parent interleaves to have a granularity exceeding 16K by programming a don't-care value in hardware for non-interleaving decoders.
Quoted 24 lines
drivers/cxl/core/hdm.c +10
-3@@ -691,9 +691,16 @@ static void cxld_set_interleave(struct cxl_decoder *cxld, u32 *ctrl)if (WARN_ONCE (ways_to_eiw (cxld->interleave_ways, &eiw),"invalid interleave_ways: %d\n" , cxld->interleave_ways))return ; -if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), -"invalid interleave_granularity: %d\n" , - cxld->interleave_granularity)) + +/* +* A non-interleaving decoder ignores the IG field. Encode a +* don't-care value instead of validating the stored granularity. +*/ +if (cxld->interleave_ways ==1 ) + eig =0 ; +else if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), +"invalid interleave_granularity: %d\n" , + cxld->interleave_granularity))return ;u32p_replace_bits (ctrl, eig,CXL_HDM_DECODER0_CTRL_IG_MASK );[ ... ]
Quoted 4 lines
drivers/cxl/core/region.c +0
-0[ ... ]
Quoted 25 lines
drivers/cxl/core/region.c +7
-13@@ -1549,20 +1557,21 @@ static int cxl_port_setup_targets(struct cxl_port *port,* Interleave granularity is a multiple of @parent_port granularity. * Multiplier is the parent port interleave ways. */ - rc =granularity_to_eig (parent_ig * parent_iw, &eig); -if (rc) { -dev_dbg (&cxlr->dev, -"%s: invalid granularity calculation (%d * %d)\n" , -dev_name (&parent_port->dev), parent_ig, parent_iw); -return rc; - } + ig = parent_ig * parent_iw; - rc =eig_to_granularity (eig, &ig); -if (rc) { -dev_dbg (&cxlr->dev,"%s:%s: invalid interleave: %d\n" , -dev_name (port->uport_dev),dev_name (&port->dev), -256 << eig); -return rc; +/* +* Keep the computed granularity for descendant setup. Only +* interleaving decoders require an encodable granularity. +*/ +if (iw >1 ) { + rc =granularity_to_eig (ig, &eig);drivers/cxl/core/region.c static int cxl_port_setup_targets(struct cxl_port *port, · line 1577
Quoted 10 lines
drivers/cxl/core/region.c +7
-0+if (rc) { +dev_dbg (&cxlr->dev, +"%s: invalid granularity calculation (%d * %d)\n" , +dev_name (&parent_port->dev), parent_ig, + parent_iw); +return rc; + } }if (iw >8 || iw > cxlsd->nr_targets) {[Severity: High]
Does this code break region auto-discovery on reboot for topologies containing a passthrough decoder?When
cxld_set_interleave()configures a passthrough decoder, it now sets eig = 0 (a don't-care value) in the hardware.Upon reboot, reading this hardware state will initialize the decoder's software
interleave_granularityto a stale value.During auto-discovery in
cxl_port_setup_targets(), theCXL_REGION_F_AUTOpath skips validating the granularity for passthrough decoders (iw == 1), but it appears to be missing an update to correct the software state:if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { if (cxld->interleave_ways != iw || (iw > 1 && cxld->interleave_granularity != ig) || !spa_maps_hpa(p, &cxld->hpa_range) || ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)) { ... return -ENXIO; } /* missing update: cxld->interleave_granularity = ig; */ }If
cxld->interleave_granularityis not updated to the computed ig here, won't any interleaving descendants read the staleparent_ig, compute a mismatched expected granularity, and fail validation?Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity
Quoted 48 lines · Jonathan Cameron
Quoted 37 lines · On Tue, 14 Jul 2026 15:56:18 +0800 Richard Cheng <[email protected]> wrote:
Quoted 9 lines · Alison Schofield
Quoted 2 lines · On Sat, Jul 11, 2026 at 08:15:07PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] During auto-discovery (CXL_REGION_F_AUTO), passthrough decoders fail to update theirinterleave_granularitysoftware state to the computed value, causing downstream decoders to inherit incorrect granularity and fail validation upon reboot.Same NO as in v1[1] and I don't see a way to graciously alert you to this in the code. Gratuitously updating the field is not the right thing to do.
Quoted 8 lines
[1] https://lore.kernel.org/linux-cxl/[email protected]/#r
No. A downstream decoder can't inherit an unecodable value into a failing check. A >16K granularity only appears below a wide interleave, and everything below that inherits an equal-or-larger value that an interleaving decoder couldn't encode. So every descendant is necessarily passthrough and never validates granularity. There is no path where updating theF_AUTOvalue would prevent a failure because the failure cannot happen.Hi Alison,
I'm thinking of 1 scenario where a regression might still happen, independent of whether an interleaving decoder can appear below a >16k passthrough decoder.
The new
cxld_set_interleave()behavior writes EIG=0 for every IW=1 decoder, including cases where logical granularity is encodable.For example,
root: IW=2, IG=4k
passthrough: IW=1, logical IG=8K
downstream: IW=2, IG=8KDuring manual setup, the passthrough decoder gets a logical IG of 8K. With your change, committing it writes EIG=0. On rediscovery, that is read back as 256 byte.
Quoted 5 lines
The AUTO path accepts the passthrough decoder because it skips the IG comparison for IW=1, but it does not restore.
The downstream decoder will inherits 256 bytes instead of 8K and its 8K config fails validation.
I was looking back having seen some text on this in v4 that confused me.
Quoted 8 lines
Isn't a failure on this combination a bug anyway (that we should fix)? The downstream decoder shouldn't inherit a value of granularity from a pass through decoder (as it's meaningless) it should be getting the appropriate values from next level up in the tree (or further if there are more passthrough decoders up there).
Jonathan
Hi Jonathan,
I think you're right, one problem I'm not sure about is that whether a passthrough decoder will stay as is for the whole runtime ?
Since we're assuming its register will be ignored with IW=1, it makes sense to me if that's the case for the whole runtime.
But if IW at somepoint becomes larger than 1, not sure if it's possible in any scenario, without the correct bookkeeping we can corrupt the topology.
Maybe carrying the effective IG/IW through the walk would be better ?
Best regards,
Richard Cheng.
Quoted 127 lines
Quoted 126 lines
Could
cxld_set_interleave()keep the real IG encoding when it's encodable and use EIG=0 only when an IW=1 value isn't encodable?
For latter case, AUTO still need to restore the computed logical IG before walking descendants.What do you think ?
Best regards,
Richard Cheng.Quoted 116 lines
Quoted 115 lines
--
--- Patch [1]: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity --- commit
9e2526342188a97e338bfc63d454c253f1e2b3ef
Author: Alison Schofield <[email protected]>cxl/region: Allow passthrough decoders with >16K granularity
This commit allows passthrough decoders beneath wide parent interleaves to have a granularity exceeding 16K by programming a don't-care value in hardware for non-interleaving decoders.
Quoted 24 lines
drivers/cxl/core/hdm.c +10
-3@@ -691,9 +691,16 @@ static void cxld_set_interleave(struct cxl_decoder *cxld, u32 *ctrl)if (WARN_ONCE (ways_to_eiw (cxld->interleave_ways, &eiw),"invalid interleave_ways: %d\n" , cxld->interleave_ways))return ; -if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), -"invalid interleave_granularity: %d\n" , - cxld->interleave_granularity)) + +/* +* A non-interleaving decoder ignores the IG field. Encode a +* don't-care value instead of validating the stored granularity. +*/ +if (cxld->interleave_ways ==1 ) + eig =0 ; +else if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), +"invalid interleave_granularity: %d\n" , + cxld->interleave_granularity))return ;u32p_replace_bits (ctrl, eig,CXL_HDM_DECODER0_CTRL_IG_MASK );[ ... ]
Quoted 4 lines
drivers/cxl/core/region.c +0
-0[ ... ]
Quoted 25 lines
drivers/cxl/core/region.c +7
-13@@ -1549,20 +1557,21 @@ static int cxl_port_setup_targets(struct cxl_port *port,* Interleave granularity is a multiple of @parent_port granularity. * Multiplier is the parent port interleave ways. */ - rc =granularity_to_eig (parent_ig * parent_iw, &eig); -if (rc) { -dev_dbg (&cxlr->dev, -"%s: invalid granularity calculation (%d * %d)\n" , -dev_name (&parent_port->dev), parent_ig, parent_iw); -return rc; - } + ig = parent_ig * parent_iw; - rc =eig_to_granularity (eig, &ig); -if (rc) { -dev_dbg (&cxlr->dev,"%s:%s: invalid interleave: %d\n" , -dev_name (port->uport_dev),dev_name (&port->dev), -256 << eig); -return rc; +/* +* Keep the computed granularity for descendant setup. Only +* interleaving decoders require an encodable granularity. +*/ +if (iw >1 ) { + rc =granularity_to_eig (ig, &eig);drivers/cxl/core/region.c static int cxl_port_setup_targets(struct cxl_port *port, · line 1577
Quoted 10 lines
drivers/cxl/core/region.c +7
-0+if (rc) { +dev_dbg (&cxlr->dev, +"%s: invalid granularity calculation (%d * %d)\n" , +dev_name (&parent_port->dev), parent_ig, + parent_iw); +return rc; + } }if (iw >8 || iw > cxlsd->nr_targets) {[Severity: High]
Does this code break region auto-discovery on reboot for topologies containing a passthrough decoder?When
cxld_set_interleave()configures a passthrough decoder, it now sets eig = 0 (a don't-care value) in the hardware.Upon reboot, reading this hardware state will initialize the decoder's software
interleave_granularityto a stale value.During auto-discovery in
cxl_port_setup_targets(), theCXL_REGION_F_AUTOpath skips validating the granularity for passthrough decoders (iw == 1), but it appears to be missing an update to correct the software state:if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { if (cxld->interleave_ways != iw || (iw > 1 && cxld->interleave_granularity != ig) || !spa_maps_hpa(p, &cxld->hpa_range) || ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)) { ... return -ENXIO; } /* missing update: cxld->interleave_granularity = ig; */ }If
cxld->interleave_granularityis not updated to the computed ig here, won't any interleaving descendants read the staleparent_ig, compute a mismatched expected granularity, and fail validation?Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Alison Schofield
maintainerRe: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity
Quoted 66 lines · Richard Cheng
Quoted 48 lines · Jonathan Cameron
Quoted 37 lines · On Tue, 14 Jul 2026 15:56:18 +0800 Richard Cheng <[email protected]> wrote:
Quoted 9 lines · Alison Schofield
Quoted 2 lines · On Sat, Jul 11, 2026 at 08:15:07PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] During auto-discovery (CXL_REGION_F_AUTO), passthrough decoders fail to update theirinterleave_granularitysoftware state to the computed value, causing downstream decoders to inherit incorrect granularity and fail validation upon reboot.Same NO as in v1[1] and I don't see a way to graciously alert you to this in the code. Gratuitously updating the field is not the right thing to do.
Quoted 8 lines
[1] https://lore.kernel.org/linux-cxl/[email protected]/#r
No. A downstream decoder can't inherit an unecodable value into a failing check. A >16K granularity only appears below a wide interleave, and everything below that inherits an equal-or-larger value that an interleaving decoder couldn't encode. So every descendant is necessarily passthrough and never validates granularity. There is no path where updating theF_AUTOvalue would prevent a failure because the failure cannot happen.Hi Alison,
I'm thinking of 1 scenario where a regression might still happen, independent of whether an interleaving decoder can appear below a >16k passthrough decoder.
The new
cxld_set_interleave()behavior writes EIG=0 for every IW=1 decoder, including cases where logical granularity is encodable.For example,
root: IW=2, IG=4k
passthrough: IW=1, logical IG=8K
downstream: IW=2, IG=8KDuring manual setup, the passthrough decoder gets a logical IG of 8K. With your change, committing it writes EIG=0. On rediscovery, that is read back as 256 byte.
Quoted 5 lines
The AUTO path accepts the passthrough decoder because it skips the IG comparison for IW=1, but it does not restore.
The downstream decoder will inherits 256 bytes instead of 8K and its 8K config fails validation.
I was looking back having seen some text on this in v4 that confused me.
Quoted 8 lines
Isn't a failure on this combination a bug anyway (that we should fix)? The downstream decoder shouldn't inherit a value of granularity from a pass through decoder (as it's meaningless) it should be getting the appropriate values from next level up in the tree (or further if there are more passthrough decoders up there).
Jonathan
Hi Jonathan,
I think you're right, one problem I'm not sure about is that whether a passthrough decoder will stay as is for the whole runtime ?
Since we're assuming its register will be ignored with IW=1, it makes sense to me if that's the case for the whole runtime.
Quoted 8 lines
But if IW at somepoint becomes larger than 1, not sure if it's possible in any scenario, without the correct bookkeeping we can corrupt the topology.
Maybe carrying the effective IG/IW through the walk would be better ?
Best regards,
Richard Cheng.
Replying here to this v2 because this is where we have the most matching thread, however, for other readers, the set is at v4 now. (Not to worry though, because the next rework may blow all of that away ;))
Jonathan, Richard,
I think I understand the concern now, and it looks like the >16K failure exposed a pre-existing problem rather than requiring special handling for large passthrough granularity.
I reproduced the existing AUTO problem using cxl_test by changing the IG of a passthrough HB from 4K to 256, modeling what's described in:ce32b0c9c522 cxl: core/region - ignore interleave granularity when ways=1. There is a 2-way@4K switch below it.
AUTO accepts the 256 because the host bridge is passthrough. The walk computes the correct 4K for that level, but discards it. At the switch below, it reads the host bridge IG back as 256 and expects the switch IG to be 256. The switch is correctly programmed with 4K, so AUTO fails.
The non-AUTO path works because it stores the computed value in the passthrough decoder. So the underlying problem appears to be using the decoder object to persist the effective interleave state through the walk. That works for an interleaving decoder, but not for a passthrough decoder whose IG is don't-care.
Following Richard's suggestion, I'm looking at carrying the effective IG/IW in the region refs instead. An interleaving level would consume and update that state, and an IW=1 level would carry it through unchanged.
If that's the right model, there is nothing special needed to support >16K. A 2-way@16K root followed by passthrough decoders simply carries (16K, 2) through those levels. No 32K decoder IG is created. If a later decoder actually interleaves, it computes 32K there and correctly fails validation.
One remaining question is what interleave_granularity should report for an IW=1 decoder. Jonathan, I think your suggestion was to report the effective IG carried from the last interleaving level. ie. with a 2-way@4K root followed by a 2-way@8K HB and then a passthrough switch, that switch would report 8K. The alternative is to leave its hardware don't-care IG untouched once the walk no longer depends on it.
Direction check please and thank-you!
-- Alison
Quoted 129 lines
Quoted 129 lines
Quoted 128 lines
Could
cxld_set_interleave()keep the real IG encoding when it's encodable and use EIG=0 only when an IW=1 value isn't encodable?
For latter case, AUTO still need to restore the computed logical IG before walking descendants.What do you think ?
Best regards,
Richard Cheng.Quoted 116 lines
Quoted 115 lines
--
--- Patch [1]: [PATCH v2 1/2] cxl/region: Allow passthrough decoders with >16K granularity --- commit
9e2526342188a97e338bfc63d454c253f1e2b3ef
Author: Alison Schofield <[email protected]>cxl/region: Allow passthrough decoders with >16K granularity
This commit allows passthrough decoders beneath wide parent interleaves to have a granularity exceeding 16K by programming a don't-care value in hardware for non-interleaving decoders.
Quoted 24 lines
drivers/cxl/core/hdm.c +10
-3@@ -691,9 +691,16 @@ static void cxld_set_interleave(struct cxl_decoder *cxld, u32 *ctrl)if (WARN_ONCE (ways_to_eiw (cxld->interleave_ways, &eiw),"invalid interleave_ways: %d\n" , cxld->interleave_ways))return ; -if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), -"invalid interleave_granularity: %d\n" , - cxld->interleave_granularity)) + +/* +* A non-interleaving decoder ignores the IG field. Encode a +* don't-care value instead of validating the stored granularity. +*/ +if (cxld->interleave_ways ==1 ) + eig =0 ; +else if (WARN_ONCE (granularity_to_eig (cxld->interleave_granularity, &eig), +"invalid interleave_granularity: %d\n" , + cxld->interleave_granularity))return ;u32p_replace_bits (ctrl, eig,CXL_HDM_DECODER0_CTRL_IG_MASK );[ ... ]
Quoted 4 lines
drivers/cxl/core/region.c +0
-0[ ... ]
Quoted 25 lines
drivers/cxl/core/region.c +7
-13@@ -1549,20 +1557,21 @@ static int cxl_port_setup_targets(struct cxl_port *port,* Interleave granularity is a multiple of @parent_port granularity. * Multiplier is the parent port interleave ways. */ - rc =granularity_to_eig (parent_ig * parent_iw, &eig); -if (rc) { -dev_dbg (&cxlr->dev, -"%s: invalid granularity calculation (%d * %d)\n" , -dev_name (&parent_port->dev), parent_ig, parent_iw); -return rc; - } + ig = parent_ig * parent_iw; - rc =eig_to_granularity (eig, &ig); -if (rc) { -dev_dbg (&cxlr->dev,"%s:%s: invalid interleave: %d\n" , -dev_name (port->uport_dev),dev_name (&port->dev), -256 << eig); -return rc; +/* +* Keep the computed granularity for descendant setup. Only +* interleaving decoders require an encodable granularity. +*/ +if (iw >1 ) { + rc =granularity_to_eig (ig, &eig);drivers/cxl/core/region.c static int cxl_port_setup_targets(struct cxl_port *port, · line 1577
Quoted 10 lines
drivers/cxl/core/region.c +7
-0+if (rc) { +dev_dbg (&cxlr->dev, +"%s: invalid granularity calculation (%d * %d)\n" , +dev_name (&parent_port->dev), parent_ig, + parent_iw); +return rc; + } }if (iw >8 || iw > cxlsd->nr_targets) {[Severity: High]
Does this code break region auto-discovery on reboot for topologies containing a passthrough decoder?When
cxld_set_interleave()configures a passthrough decoder, it now sets eig = 0 (a don't-care value) in the hardware.Upon reboot, reading this hardware state will initialize the decoder's software
interleave_granularityto a stale value.During auto-discovery in
cxl_port_setup_targets(), theCXL_REGION_F_AUTOpath skips validating the granularity for passthrough decoders (iw == 1), but it appears to be missing an update to correct the software state:if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { if (cxld->interleave_ways != iw || (iw > 1 && cxld->interleave_granularity != ig) || !spa_maps_hpa(p, &cxld->hpa_range) || ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)) { ... return -ENXIO; } /* missing update: cxld->interleave_granularity = ig; */ }If
cxld->interleave_granularityis not updated to the computed ig here, won't any interleaving descendants read the staleparent_ig, compute a mismatched expected granularity, and fail validation?Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1