Skip to content

Commit 3624a22

Browse files
liming011davejiang
authored andcommitted
cxl/hdm: Add support for 32 switch decoders
Per CXL r4.0 section 8.2.4.20.1. CXL host bridge and switch ports can support 32 HDM decoders. Current implementation misses some decoders on CXL host bridge and switch in the case that the value of Decoder Count field in CXL HDM decoder Capability Register is greater than or equal to 9. Update calculation implementation to ensure the decoder count calculation is correct for CXL host bridge/switch ports. Signed-off-by: Li Ming <ming.li@zohomail.com> Reviewed-by: Gregory Price <gourry@gourry.net> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Link: https://patch.msgid.link/20260321061459.1910205-1-ming.li@zohomail.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 9b6e1ed commit 3624a22

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/cxl/core/hdm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port,
177177
}
178178

179179
parse_hdm_decoder_caps(cxlhdm);
180-
if (cxlhdm->decoder_count == 0) {
180+
if (cxlhdm->decoder_count < 0) {
181181
dev_err(dev, "Spec violation. Caps invalid\n");
182182
return ERR_PTR(-ENXIO);
183183
}

drivers/cxl/cxl.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,16 @@ static inline int cxl_hdm_decoder_count(u32 cap_hdr)
7777
{
7878
int val = FIELD_GET(CXL_HDM_DECODER_COUNT_MASK, cap_hdr);
7979

80-
return val ? val * 2 : 1;
80+
switch (val) {
81+
case 0:
82+
return 1;
83+
case 1 ... 8:
84+
return val * 2;
85+
case 9 ... 12:
86+
return (val - 4) * 4;
87+
default:
88+
return -ENXIO;
89+
}
8190
}
8291

8392
/* Encode defined in CXL 2.0 8.2.5.12.7 HDM Decoder Control Register */

drivers/cxl/cxlmem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ int cxl_mem_sanitize(struct cxl_memdev *cxlmd, u16 cmd);
923923
*/
924924
struct cxl_hdm {
925925
struct cxl_component_regs regs;
926-
unsigned int decoder_count;
926+
int decoder_count;
927927
unsigned int target_count;
928928
unsigned int interleave_mask;
929929
unsigned long iw_cap_mask;

0 commit comments

Comments
 (0)