Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cxl/core/regs.c: Skip Memory Space Enable check for RCD and RCH Ports

According to CXL r3.2 section 8.2.1.2, the PCI_COMMAND register fields,
including Memory Space Enable bit, have no effect on the behavior of an
RCD Upstream Port. Retaining this check may incorrectly cause
cxl_pci_probe() to fail on a valid RCD upstream Port.

While the specification is explicit only for RCD Upstream Ports, this
check is solely for accessing the RCRB, which is always mapped through
memory space. Therefore, its safe to remove the check entirely. In
practice, firmware reliably enables the Memory Space Enable bit for
RCH Downstream Ports and no failures have been observed.

Removing the check simplifies the code and avoids unnecessary
special-casing, while relying on BIOS/firmware to configure devices
correctly. Moreover, any failures due to inaccessible RCRB regions
will still be caught either in __rcrb_to_component() or while
parsing the component register block.

The following failure was observed in dmesg when the check was present:
cxl_pci 0000:7f:00.0: No component registers (-6)

Fixes: d5b1a27143cb ("cxl/acpi: Extract component registers of restricted hosts from RCRB")
Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
Cc: <stable@vger.kernel.org>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Robert Richter <rrichter@amd.com>
Link: https://patch.msgid.link/20250407192734.70631-1-Smita.KoralahalliChannabasappa@amd.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>

authored by

Smita Koralahalli and committed by
Dave Jiang
078d3ee7 25174d5c

-4
-4
drivers/cxl/core/regs.c
··· 581 581 resource_size_t rcrb = ri->base; 582 582 void __iomem *addr; 583 583 u32 bar0, bar1; 584 - u16 cmd; 585 584 u32 id; 586 585 587 586 if (which == CXL_RCRB_UPSTREAM) ··· 602 603 } 603 604 604 605 id = readl(addr + PCI_VENDOR_ID); 605 - cmd = readw(addr + PCI_COMMAND); 606 606 bar0 = readl(addr + PCI_BASE_ADDRESS_0); 607 607 bar1 = readl(addr + PCI_BASE_ADDRESS_1); 608 608 iounmap(addr); ··· 616 618 dev_err(dev, "Failed to access Downstream Port RCRB\n"); 617 619 return CXL_RESOURCE_NONE; 618 620 } 619 - if (!(cmd & PCI_COMMAND_MEMORY)) 620 - return CXL_RESOURCE_NONE; 621 621 /* The RCRB is a Memory Window, and the MEM_TYPE_1M bit is obsolete */ 622 622 if (bar0 & (PCI_BASE_ADDRESS_MEM_TYPE_1M | PCI_BASE_ADDRESS_SPACE_IO)) 623 623 return CXL_RESOURCE_NONE;