PCI: Disable RRS polling for Intel SSDPE2KX020T8 nvme
Subsystems (2)
PATCH 1/1 PCI: Disable RRS polling for Intel SSDPE2KX020T8 nvme
Prior to commit d591f6804e7e ("PCI: Wait for device readiness with Configuration RRS"), this Intel nvme [8086:0a54] works well. Since that patch is merged to the kernel, this nvme stops working.
Through debugging, we found that commit introduces the RRS polling in the pci_dev_wait(), for this nvme, when polling the PCI_VENDOR_ID, it will return ~0 if the config access is not ready yet, but the polling expects a return value of 0x0001 or a valid vendor_id, so the RRS polling doesn't work for this nvme.
Here we add a pci quirk to disable the RRS polling for the device.
--- drivers/pci/probe.c | 3 ++- drivers/pci/quirks.c | 18 ++++++++++++++++++ include/linux/pci.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-)
drivers/pci/probe.c +2 -1
@@ -1270,7 +1270,8 @@ static void pci_enable_rrs_sv(struct pci_dev *pdev)if (root_cap &PCI_EXP_RTCAP_RRS_SV ) {pcie_capability_set_word (pdev,PCI_EXP_RTCTL ,PCI_EXP_RTCTL_RRS_SVE ); - pdev->config_rrs_sv =1 ; +if (!(pdev->dev_flags &PCI_DEV_FLAGS_NO_RRS_SV )) + pdev->config_rrs_sv =1 ; } }
drivers/pci/quirks.c +18 -0
@@ -6336,3 +6336,21 @@ static void pci_mask_replay_timer_timeout(struct pci_dev *pdev)DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_GLI ,0x9750 , pci_mask_replay_timer_timeout);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_GLI ,0x9755 , pci_mask_replay_timer_timeout);#endif + +/* +* Although the root port device claims to support RRS, some devices don't work +* with RRS polling, when reading the Vendor ID, they just return ~0 if config +* access is not ready, this will break the pci_dev_wait(). Here disable the RRS +* forcibly for this type of device. +*/ +static void quirk_no_rrs_sv (struct pci_dev *dev) +{ +struct pci_dev *root; + + root =pcie_find_root_port (dev); +if (root) { + root->dev_flags |=PCI_DEV_FLAGS_NO_RRS_SV ; + root->config_rrs_sv =0 ; + } +} +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x0a54 , quirk_no_rrs_sv);
include/linux/pci.h +2 -0
@@ -247,6 +247,8 @@ enum pci_dev_flags {PCI_DEV_FLAGS_HAS_MSI_MASKING = (__force pci_dev_flags_t) (1 <<12 ),/* Device requires write to PCI_MSIX_ENTRY_DATA before any MSIX reads */ PCI_DEV_FLAGS_MSIX_TOUCH_ENTRY_DATA_FIRST = (__force pci_dev_flags_t) (1 <<13 ), +/* Do not use Configuration Request Retry Status polling in pci_dev_wait() */ + PCI_DEV_FLAGS_NO_RRS_SV = (__force pci_dev_flags_t) (1 << 14), }; enum pci_irq_reroute_variant {
Signature · 1 line
2.34.1
[+cc VMD folks]
Quoted 9 lines · Hui Wang
Prior to commit
d591f6804e7e("PCI: Wait for device readiness with Configuration RRS"), this Intel nvme [8086:0a54] works well. Since that patch is merged to the kernel, this nvme stops working.Through debugging, we found that commit introduces the RRS polling in the
pci_dev_wait(), for this nvme, when polling thePCI_VENDOR_ID, it will return ~0 if the config access is not ready yet, but the polling expects a return value of0x0001or a validvendor_id, so the RRS polling doesn't work for this nvme.
Sorry for breaking this, and thanks for all your work in debugging this! Issues like this are really hard to track down.
I would think we would have heard about this earlier if the NVMe device were broken on all systems. Maybe there's some connection with VMD? From the non-working dmesg log in your bug report
(https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/+attachment/5879970/+files/dmesg-60.txt):
DMI: ASUSTeK COMPUTER INC. ESC8000 G4/Z11PG-D24 Series, BIOS 5501 04/17/2019 vmd 0000:d7:05.5: PCI host bridge to bus 10000:00
pci 10000:00:02.0: [8086:2032] type 01 class 0x060400 PCIe Root Port pci 10000:00:02.0: PCI bridge to [bus 01]
pci 10000:00:02.0: bridge window [mem 0xf8000000-0xf81fffff]: assigned pci 10000:01:00.0: [8086:0a54] type 00 class 0x010802 PCIe Endpoint pci 10000:01:00.0: BAR 0 [mem 0x00000000-0x00003fff 64bit]
<I think vmd_enable_domain() calls pci_reset_bus() here>
pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (high 0x00000000 != 0xffffffff) pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (0xf8010004 != 0xffffffff) nvme nvme0: pci function 10000:01:00.0
nvme 10000:01:00.0: enabling device (0000 -> 0002)
Things I notice:
- The 10000:01:00.0 NVMe device is behind a VMD bridge
- We successfully read the Vendor & Device IDs (8086:0a54)
- The NVMe device is uninitialized. We successfully sized the BAR, which included successful config reads and writes. The BAR wasn't assigned by BIOS, which is normal since it's behind VMD.
- We allocated space for BAR 0 but the config writes to program the BAR failed. The read back from the BAR was 0xffffffff; probably a PCIe error, e.g., the NVMe device didn't respond.
- The device *did* respond when nvme_probe() enabled it: the
"enabling device (0000 -> 0002)" means pci_enable_resources() read
PCI_COMMAND and got 0x0000. - The dmesg from the working config doesn't include the "enabling device" line, which suggests that pci_enable_resources() saw PCI_COMMAND_MEMORY (0x0002) already set and didn't bother setting it again. I don't know why it would already be set.
d591f6804e7e really only changes pci_dev_wait(), which is used after device resets. I think vmd_enable_domain() resets the VMD Root Ports after pci_scan_child_bus(), and maybe we're not waiting long enough afterwards.
My guess is that we got the ~0 because we did a config read too soon after reset and the device didn't respond. The Root Port would time out, log an error, and synthesize ~0 data to complete the CPU read (see PCIe r6.0, sec 2.3.2 implementation note).
It's *possible* that we waited long enough but the NVMe device is broken and didn't respond when it should have, but my money is on a software defect.
There are a few pci_dbg() calls about these delays; can you set CONFIG_DYNAMIC_DEBUG=y and boot with dyndbg="file drivers/pci/* +p" to collect that output? Please also collect the "sudo lspci -vv" output from a working system.
Bjorn
Quoted 28 lines · Bjorn Helgaas
[+cc VMD folks]
Quoted 9 lines · Hui Wang
Prior to commit
d591f6804e7e("PCI: Wait for device readiness with Configuration RRS"), this Intel nvme [8086:0a54] works well. Since that patch is merged to the kernel, this nvme stops working.Through debugging, we found that commit introduces the RRS polling in the
pci_dev_wait(), for this nvme, when polling thePCI_VENDOR_ID, it will return ~0 if the config access is not ready yet, but the polling expects a return value of0x0001or a validvendor_id, so the RRS polling doesn't work for this nvme.Sorry for breaking this, and thanks for all your work in debugging this! Issues like this are really hard to track down.
I would think we would have heard about this earlier if the NVMe device were broken on all systems. Maybe there's some connection with VMD? From the non-working dmesg log in your bug report
(https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/+attachment/5879970/+files/dmesg-60.txt):DMI: ASUSTeK COMPUTER INC. ESC8000 G4/Z11PG-D24 Series, BIOS 5501 04/17/2019 vmd 0000:d7:05.5: PCI host bridge to bus 10000:00
pci 10000:00:02.0: [8086:2032] type 01 class0x060400PCIe Root Port pci 10000:00:02.0: PCI bridge to [bus 01]
pci 10000:00:02.0: bridge window [mem 0xf8000000-0xf81fffff]: assigned pci 10000:01:00.0: [8086:0a54] type 00 class0x010802PCIe Endpoint pci 10000:01:00.0: BAR 0 [mem 0x00000000-0x00003fff 64bit]
Quoted 1 line
<I think
vmd_enable_domain()callspci_reset_bus()here>
Yes, and the pci_dev_wait() is called here. With the RRS polling, will get a ~0 from PCI_VENDOR_ID, then will get 0xfffffff when configuring the BAR0 subsequently. With the original polling method, it will get enough delay in the pci_dev_wait(), so nvme works normally.
The line "[ 10.193589] hhhhhhhhhhhhhhhhhhhhhhhhhhhh dev->device = 0a54 id = ffffffff" is output from pci_dev_wait(), please refer to https://launchpadlibrarian.net/798708446/LP2111521-dmesg-test9.txt
Quoted 41 lines
pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (high 0x00000000 != 0xffffffff) pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (0xf8010004 != 0xffffffff) nvme nvme0: pci function 10000:01:00.0 nvme 10000:01:00.0: enabling device (0000 -> 0002)Things I notice:
- The 10000:01:00.0 NVMe device is behind a VMD bridge
- We successfully read the Vendor & Device IDs (8086:0a54)
- The NVMe device is uninitialized. We successfully sized the BAR, which included successful config reads and writes. The BAR wasn't assigned by BIOS, which is normal since it's behind VMD.
- We allocated space for BAR 0 but the config writes to program the BAR failed. The read back from the BAR was
0xffffffff; probably a PCIe error, e.g., the NVMe device didn't respond.- The device *did* respond when
nvme_probe()enabled it: the"enabling device (0000 -> 0002)" means pci_enable_resources() read PCI_COMMAND and got 0x0000.- The dmesg from the working config doesn't include the "enabling device" line, which suggests that
pci_enable_resources()sawPCI_COMMAND_MEMORY(0x0002) already set and didn't bother setting it again. I don't know why it would already be set.
d591f6804e7ereally only changespci_dev_wait(), which is used after device resets. I thinkvmd_enable_domain()resets the VMD Root Ports afterpci_scan_child_bus(), and maybe we're not waiting long enough afterwards.My guess is that we got the ~0 because we did a config read too soon after reset and the device didn't respond. The Root Port would time out, log an error, and synthesize ~0 data to complete the CPU read (see PCIe r6.0, sec 2.3.2 implementation note).
Quoted 8 lines
It's *possible* that we waited long enough but the NVMe device is broken and didn't respond when it should have, but my money is on a software defect.
There are a few
pci_dbg()calls about these delays; can you setCONFIG_DYNAMIC_DEBUG=yand boot with dyndbg="filedrivers/pci/*+p" to collect that output? Please also collect the "sudo lspci -vv" output from a working system.
Already passed the testing request to bug reporters, wait for their feedback.
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/55
Thanks,
Hui.
Quoted 2 lines
Bjorn
Quoted 86 lines · Hui Wang
Quoted 29 lines · Bjorn Helgaas
[+cc VMD folks]
Quoted 9 lines · Hui Wang
Prior to commit
d591f6804e7e("PCI: Wait for device readiness with Configuration RRS"), this Intel nvme [8086:0a54] works well. Since that patch is merged to the kernel, this nvme stops working.Through debugging, we found that commit introduces the RRS polling in the
pci_dev_wait(), for this nvme, when polling thePCI_VENDOR_ID, it will return ~0 if the config access is not ready yet, but the polling expects a return value of0x0001or a validvendor_id, so the RRS polling doesn't work for this nvme.Sorry for breaking this, and thanks for all your work in debugging this! Issues like this are really hard to track down.
I would think we would have heard about this earlier if the NVMe device were broken on all systems. Maybe there's some connection with VMD? From the non-working dmesg log in your bug report
(https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/+attachment/5879970/+files/dmesg-60.txt):DMI: ASUSTeK COMPUTER INC. ESC8000 G4/Z11PG-D24 Series, BIOS 5501 04/17/2019 vmd 0000:d7:05.5: PCI host bridge to bus 10000:00
pci 10000:00:02.0: [8086:2032] type 01 class0x060400PCIe Root Port pci 10000:00:02.0: PCI bridge to [bus 01]
pci 10000:00:02.0: bridge window [mem 0xf8000000-0xf81fffff]: assigned pci 10000:01:00.0: [8086:0a54] type 00 class0x010802PCIe Endpoint pci 10000:01:00.0: BAR 0 [mem 0x00000000-0x00003fff 64bit]Quoted 1 line
<I think
vmd_enable_domain()callspci_reset_bus()here>Yes, and the
pci_dev_wait()is called here. With the RRS polling, will get a ~0 fromPCI_VENDOR_ID, then will get0xfffffffwhen configuring the BAR0 subsequently. With the original polling method, it will get enough delay in thepci_dev_wait(), so nvme works normally.The line "[ 10.193589] hhhhhhhhhhhhhhhhhhhhhhhhhhhh
dev->device= 0a54 id = ffffffff" is output frompci_dev_wait(), please refer to https://launchpadlibrarian.net/798708446/LP2111521-dmesg-test9.txtQuoted 40 lines
pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (high
0x00000000!=0xffffffff) pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (0xf8010004!=0xffffffff) nvme nvme0: pci function 10000:01:00.0
nvme 10000:01:00.0: enabling device (0000 -> 0002)Things I notice:
- The 10000:01:00.0 NVMe device is behind a VMD bridge
- We successfully read the Vendor & Device IDs (8086:0a54)
- The NVMe device is uninitialized. We successfully sized the BAR, which included successful config reads and writes. The BAR wasn't assigned by BIOS, which is normal since it's behind VMD.
- We allocated space for BAR 0 but the config writes to program the BAR failed. The read back from the BAR was
0xffffffff; probably a PCIe error, e.g., the NVMe device didn't respond.- The device *did* respond when
nvme_probe()enabled it: the "enabling device (0000 -> 0002)" meanspci_enable_resources()readPCI_COMMANDand got0x0000.- The dmesg from the working config doesn't include the "enabling device" line, which suggests that
pci_enable_resources()sawPCI_COMMAND_MEMORY(0x0002) already set and didn't bother setting it again. I don't know why it would already be set.d591f6804e7ereally only changespci_dev_wait(), which is used after device resets. I thinkvmd_enable_domain()resets the VMD Root Ports afterpci_scan_child_bus(), and maybe we're not waiting long enough afterwards.My guess is that we got the ~0 because we did a config read too soon after reset and the device didn't respond. The Root Port would time out, log an error, and synthesize ~0 data to complete the CPU read (see PCIe r6.0, sec 2.3.2 implementation note).
Quoted 8 lines
It's *possible* that we waited long enough but the NVMe device is broken and didn't respond when it should have, but my money is on a software defect.
There are a few
pci_dbg()calls about these delays; can you setCONFIG_DYNAMIC_DEBUG=yand boot with dyndbg="filedrivers/pci/*+p" to collect that output? Please also collect the "sudo lspci -vv" output from a working system.
Quoted 7 lines
Already passed the testing request to bug reporters, wait for their feedback.
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/55
Thanks,
Hui.
This is the dmesg with dyndbg="file drivers/pci/* +p"
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/56
And this is the lspci output:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/57
Quoted 4 lines
Quoted 4 lines
Bjorn
[+cc Chaitanya, Ville for possible Intel NVMe contacts]
Quoted 94 lines · Hui Wang
Quoted 93 lines · Hui Wang
Quoted 32 lines · Bjorn Helgaas
[+cc VMD folks]
Quoted 9 lines · Hui Wang
Prior to commit
d591f6804e7e("PCI: Wait for device readiness with Configuration RRS"), this Intel nvme [8086:0a54] works well. Since that patch is merged to the kernel, this nvme stops working.Through debugging, we found that commit introduces the RRS polling in the
pci_dev_wait(), for this nvme, when polling thePCI_VENDOR_ID, it will return ~0 if the config access is not ready yet, but the polling expects a return value of0x0001or a validvendor_id, so the RRS polling doesn't work for this nvme.Sorry for breaking this, and thanks for all your work in debugging this! Issues like this are really hard to track down.
I would think we would have heard about this earlier if the NVMe device were broken on all systems. Maybe there's some connection with VMD? From the non-working dmesg log in your bug report
(https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/+attachment/5879970/+files/dmesg-60.txt):DMI: ASUSTeK COMPUTER INC. ESC8000 G4/Z11PG-D24 Series, BIOS 5501 04/17/2019
vmd 0000:d7:05.5: PCI host bridge to bus 10000:00
pci 10000:00:02.0: [8086:2032] type 01 class0x060400PCIe Root Port pci 10000:00:02.0: PCI bridge to [bus 01]
pci 10000:00:02.0: bridge window [mem 0xf8000000-0xf81fffff]:
assigned
pci 10000:01:00.0: [8086:0a54] type 00 class0x010802PCIe Endpoint pci 10000:01:00.0: BAR 0 [mem 0x00000000-0x00003fff 64bit]Quoted 1 line
<I think
vmd_enable_domain()callspci_reset_bus()here>Yes, and the
pci_dev_wait()is called here. With the RRS polling, will get a ~0 fromPCI_VENDOR_ID, then will get0xfffffffwhen configuring the BAR0 subsequently. With the original polling method, it will get enough delay in thepci_dev_wait(), so nvme works normally.The line "[ 10.193589] hhhhhhhhhhhhhhhhhhhhhhhhhhhh
dev->device= 0a54 id = ffffffff" is output frompci_dev_wait(), please refer to
https://launchpadlibrarian.net/798708446/LP2111521-dmesg-test9.txtQuoted 48 lines
pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (high
0x00000000!=0xffffffff)
pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (0xf8010004!=0xffffffff) nvme nvme0: pci function 10000:01:00.0
nvme 10000:01:00.0: enabling device (0000 -> 0002)Things I notice:
- The 10000:01:00.0 NVMe device is behind a VMD bridge
- We successfully read the Vendor & Device IDs (8086:0a54)
- The NVMe device is uninitialized. We successfully sized the BAR, which included successful config reads and writes. The BAR wasn't assigned by BIOS, which is normal since it's behind VMD.
- We allocated space for BAR 0 but the config writes to program the BAR failed. The read back from the BAR was
0xffffffff; probably a PCIe error, e.g., the NVMe device didn't respond.- The device *did* respond when
nvme_probe()enabled it: the "enabling device (0000 -> 0002)" meanspci_enable_resources()readPCI_COMMANDand got0x0000.- The dmesg from the working config doesn't include the "enabling device" line, which suggests that
pci_enable_resources()sawPCI_COMMAND_MEMORY(0x0002) already set and didn't bother setting it again. I don't know why it would already be set.d591f6804e7ereally only changespci_dev_wait(), which is used after device resets. I thinkvmd_enable_domain()resets the VMD Root Ports afterpci_scan_child_bus(), and maybe we're not waiting long enough afterwards.My guess is that we got the ~0 because we did a config read too soon after reset and the device didn't respond. The Root Port would time out, log an error, and synthesize ~0 data to complete the CPU read (see PCIe r6.0, sec 2.3.2 implementation note).
It's *possible* that we waited long enough but the NVMe device is broken and didn't respond when it should have, but my money is on a software defect.
There are a few
pci_dbg()calls about these delays; can you setCONFIG_DYNAMIC_DEBUG=yand boot with dyndbg="filedrivers/pci/*+p" to collect that output? Please also collect the "sudo lspci -vv" output from a working system.
Quoted 8 lines
Quoted 4 lines
Already passed the testing request to bug reporters, wait for their feedback.
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/55
This is the dmesg with dyndbg="file
drivers/pci/*+p"https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/56
Thank you very much! I'm stumped.
Both Ports here are capable of 8GT/s, and the Root Port is hot-plug capable and supports Data Link Layer Link Active Reporting but not DRS:
10000:00:02.0 Intel Sky Lake-E PCI Express Root Port C
LnkCap: Port #11, Speed 8GT/s, Width x4, ASPM L1, Exit Latency L1 <16us
ClockPM- Surprise+ LLActRep+ BwNot+ ASPMOptComp+
LnkSta: Speed 8GT/s, Width x4
TrErr- Train- SlotClk+ DLActive+ BWMgmt- ABWMgmt-
SltCap: AttnBtn- PwrCtrl- MRL- AttnInd+ PwrInd+ HotPlug+ Surprise+
LnkCap2: Supported Link Speeds: 2.5-8GT/s, Crosslink- Retimer- 2Retimers- DRS-
10000:01:00.0 Intel NVMe Datacenter SSD
LnkCap: Port #0, Speed 8GT/s, Width x4, ASPM L0s, Exit Latency L0s <64ns
After a reset, we have to delay before doing config reads. The wait time requirements are in PCIe r6.0, sec 6.6.1:
• ... For cases where system software cannot determine that DRS is supported by the attached device, or by the Downstream Port above the attached device [as in this case]:
◦ ...
◦ With a Downstream Port that supports Link speeds greater than
5.0 GT/s, software must wait a minimum of 100 ms after Link training completes before sending a Configuration Request to the device immediately below that Port. Software can determine when Link training completes by polling the Data Link Layer Link Active bit or by setting up an associated interrupt (see § Section 6.7.3.3). It is strongly recommended for software to use this mechanism whenever the Downstream Port supports it.
Since the Port supports 8GT/s, we should wait 100ms after Link training completes (PCI_EXP_LNKSTA_DLLLA becomes set), and based on the code path below, I think we *do*:
pci_bridge_secondary_bus_reset
pcibios_reset_secondary_bus
pci_reset_secondary_bus
# assert PCI_BRIDGE_CTL_BUS_RESET
pci_bridge_wait_for_secondary_bus(bridge, "bus reset")
pci_dbg("waiting %d ms for downstream link, after activation\n") # 10.86
delay = pci_bus_max_d3cold_delay() # default 100ms
pcie_wait_for_link_delay(bridge, active=true, delay=100)
pcie_wait_for_link_status(use_lt=false, active=true)
end_jiffies = jiffies + PCIE_LINK_RETRAIN_TIMEOUT_MS
do {
pcie_capability_read_word(PCI_EXP_LNKSTA, &lnksta)
if ((lnksta & PCI_EXP_LNKSTA_DLLLA) == PCI_EXP_LNKSTA_DLLLA)
return 0
msleep(1) # likely wait several ms for link active
} while (time_before(jiffies, end_jiffies))
if (active) # (true)
msleep(delay) # wait 100ms here
pci_dev_wait(child, "bus reset", PCIE_RESET_READY_POLL_MS - delay)
delay = 1
for (;;) {
pci_read_config_dword(PCI_VENDOR_ID, &id)
if (!pci_bus_rrs_vendor_id(id)) # got 0xffff, assume valid
break;
}
pci_dbg("ready 0ms after bus reset", delay - 1) # 11.11And from the dmesg log:
[ 10.862226] pci 10000:00:02.0: waiting 100 ms for downstream link, after activation [ 11.109581] pci 10000:01:00.0: ready 0ms after bus reset
it looks like we waited about .25s (250ms) after the link came up before trying to read the Vendor ID, which should be plenty.
I guess maybe this device requires more than 250ms after reset before it can respond? That still seems surprising to me; I *assume* Intel would have tested this for spec conformance. But maybe there's some erratum. I added a couple Intel folks who are mentioned in the nvme history in case they have pointers.
But it *is* also true that pci_dev_wait() doesn't know how to handle PCIe errors at all, and maybe there's a way to make it smarter.
Can you try adding the patch below and collect another dmesg log (with dyndbg="file drivers/pci/* +p" as before)? This isn't a fix, but might give a little more insight into what's happening.
drivers/pci/pci.c +23 -2
@@ -1268,6 +1268,7 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)bool retrain = false;struct pci_dev *root, *bridge; +pci_dbg (dev,"%s: %s timeout %d\n" , __func__, reset_type, timeout); root =pcie_find_root_port (dev);if (pci_is_pcie (dev)) {
@@ -1305,14 +1306,32 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)if (root && root->config_rrs_sv) {pci_read_config_dword (dev,PCI_VENDOR_ID , &id); -if (!pci_bus_rrs_vendor_id (id)) -break ; +pci_dbg (dev,"%s: vf %d read %#06x\n" , __func__, + dev->is_virtfn, id); +if (pci_bus_rrs_vendor_id (id)) + goto retry; + +/* +* We might read 0xffff if the device is a VF and +* the read was successful (the VF Vendor ID is +* 0xffff per spec). +* +* If the device is not a VF, 0xffff likely means +* there was an error on PCIe. E.g., maybe the +* device couldn't even respond with RRS status, +* and the RC timed out and synthesized ~0 data. +*/ +if (PCI_POSSIBLE_ERROR (id) && !dev->is_virtfn) + goto retry; + +break ; }else {pci_read_config_dword (dev,PCI_COMMAND , &id);if (!PCI_POSSIBLE_ERROR (id))break ; } +retry:if (delay > timeout) {pci_warn (dev,"not ready %dms after %s; giving up\n" , delay -1 , reset_type);
@@ -4760,6 +4779,8 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,* Some controllers might not implement link active reporting. In this * case, we wait for 1000 ms + any delay requested by the caller. */ +pci_dbg (pdev,"%s: active %d delay %d link_active_reporting %d\n" , + __func__, active, delay, pdev->link_active_reporting);if (!pdev->link_active_reporting) {msleep (PCIE_LINK_RETRAIN_TIMEOUT_MS + delay);return true;
Ping, any chance you could try the patch below to collect a little more data. The proposed quirk covers up a deeper problem, and I want to fix that problem instead of covering it up.
Quoted 248 lines · Bjorn Helgaas
[+cc Chaitanya, Ville for possible Intel NVMe contacts]
Quoted 94 lines · Hui Wang
Quoted 93 lines · Hui Wang
Quoted 32 lines · Bjorn Helgaas
[+cc VMD folks]
Quoted 9 lines · Hui Wang
Prior to commit
d591f6804e7e("PCI: Wait for device readiness with Configuration RRS"), this Intel nvme [8086:0a54] works well. Since that patch is merged to the kernel, this nvme stops working.Through debugging, we found that commit introduces the RRS polling in the
pci_dev_wait(), for this nvme, when polling thePCI_VENDOR_ID, it will return ~0 if the config access is not ready yet, but the polling expects a return value of0x0001or a validvendor_id, so the RRS polling doesn't work for this nvme.Sorry for breaking this, and thanks for all your work in debugging this! Issues like this are really hard to track down.
I would think we would have heard about this earlier if the NVMe device were broken on all systems. Maybe there's some connection with VMD? From the non-working dmesg log in your bug report
(https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/+attachment/5879970/+files/dmesg-60.txt):DMI: ASUSTeK COMPUTER INC. ESC8000 G4/Z11PG-D24 Series, BIOS 5501 04/17/2019
vmd 0000:d7:05.5: PCI host bridge to bus 10000:00
pci 10000:00:02.0: [8086:2032] type 01 class0x060400PCIe Root Port pci 10000:00:02.0: PCI bridge to [bus 01]
pci 10000:00:02.0: bridge window [mem 0xf8000000-0xf81fffff]:
assigned
pci 10000:01:00.0: [8086:0a54] type 00 class0x010802PCIe Endpoint pci 10000:01:00.0: BAR 0 [mem 0x00000000-0x00003fff 64bit]Quoted 1 line
<I think
vmd_enable_domain()callspci_reset_bus()here>Yes, and the
pci_dev_wait()is called here. With the RRS polling, will get a ~0 fromPCI_VENDOR_ID, then will get0xfffffffwhen configuring the BAR0 subsequently. With the original polling method, it will get enough delay in thepci_dev_wait(), so nvme works normally.The line "[ 10.193589] hhhhhhhhhhhhhhhhhhhhhhhhhhhh
dev->device= 0a54 id = ffffffff" is output frompci_dev_wait(), please refer to
https://launchpadlibrarian.net/798708446/LP2111521-dmesg-test9.txtQuoted 48 lines
pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (high
0x00000000!=0xffffffff)
pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (0xf8010004!=0xffffffff) nvme nvme0: pci function 10000:01:00.0
nvme 10000:01:00.0: enabling device (0000 -> 0002)Things I notice:
- The 10000:01:00.0 NVMe device is behind a VMD bridge
- We successfully read the Vendor & Device IDs (8086:0a54)
- The NVMe device is uninitialized. We successfully sized the BAR, which included successful config reads and writes. The BAR wasn't assigned by BIOS, which is normal since it's behind VMD.
- We allocated space for BAR 0 but the config writes to program the BAR failed. The read back from the BAR was
0xffffffff; probably a PCIe error, e.g., the NVMe device didn't respond.- The device *did* respond when
nvme_probe()enabled it: the "enabling device (0000 -> 0002)" meanspci_enable_resources()readPCI_COMMANDand got0x0000.- The dmesg from the working config doesn't include the "enabling device" line, which suggests that
pci_enable_resources()sawPCI_COMMAND_MEMORY(0x0002) already set and didn't bother setting it again. I don't know why it would already be set.d591f6804e7ereally only changespci_dev_wait(), which is used after device resets. I thinkvmd_enable_domain()resets the VMD Root Ports afterpci_scan_child_bus(), and maybe we're not waiting long enough afterwards.My guess is that we got the ~0 because we did a config read too soon after reset and the device didn't respond. The Root Port would time out, log an error, and synthesize ~0 data to complete the CPU read (see PCIe r6.0, sec 2.3.2 implementation note).
It's *possible* that we waited long enough but the NVMe device is broken and didn't respond when it should have, but my money is on a software defect.
There are a few
pci_dbg()calls about these delays; can you setCONFIG_DYNAMIC_DEBUG=yand boot with dyndbg="filedrivers/pci/*+p" to collect that output? Please also collect the "sudo lspci -vv" output from a working system.Quoted 8 lines
Quoted 4 lines
Already passed the testing request to bug reporters, wait for their feedback.
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/55
This is the dmesg with dyndbg="file
drivers/pci/*+p"https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/56
Thank you very much! I'm stumped.
Both Ports here are capable of 8GT/s, and the Root Port is hot-plug capable and supports Data Link Layer Link Active Reporting but not DRS:
10000:00:02.0 Intel Sky Lake-E PCI Express Root Port C
LnkCap: Port #11, Speed 8GT/s, Width x4, ASPM L1, Exit Latency L1 <16us
ClockPM- Surprise+ LLActRep+ BwNot+ ASPMOptComp+
LnkSta: Speed 8GT/s, Width x4
TrErr- Train- SlotClk+ DLActive+ BWMgmt- ABWMgmt-
SltCap: AttnBtn- PwrCtrl- MRL- AttnInd+ PwrInd+ HotPlug+ Surprise+
LnkCap2: Supported Link Speeds: 2.5-8GT/s, Crosslink- Retimer- 2Retimers- DRS-10000:01:00.0 Intel NVMe Datacenter SSD
LnkCap: Port #0, Speed 8GT/s, Width x4, ASPM L0s, Exit Latency L0s <64nsAfter a reset, we have to delay before doing config reads. The wait time requirements are in PCIe r6.0, sec 6.6.1:
• ... For cases where system software cannot determine that DRS is supported by the attached device, or by the Downstream Port above the attached device [as in this case]:
◦ ...
◦ With a Downstream Port that supports Link speeds greater than
5.0 GT/s, software must wait a minimum of 100 ms after Link training completes before sending a Configuration Request to the device immediately below that Port. Software can determine when Link training completes by polling the Data Link Layer Link Active bit or by setting up an associated interrupt (see § Section 6.7.3.3). It is strongly recommended for software to use this mechanism whenever the Downstream Port supports it.Since the Port supports 8GT/s, we should wait 100ms after Link training completes (
PCI_EXP_LNKSTA_DLLLAbecomes set), and based on the code path below, I think we *do*:pci_bridge_secondary_bus_reset pcibios_reset_secondary_bus pci_reset_secondary_bus # assert PCI_BRIDGE_CTL_BUS_RESET pci_bridge_wait_for_secondary_bus(bridge, "bus reset") pci_dbg("waiting %d ms for downstream link, after activation\n") # 10.86 delay = pci_bus_max_d3cold_delay() # default 100ms pcie_wait_for_link_delay(bridge, active=true, delay=100) pcie_wait_for_link_status(use_lt=false, active=true) end_jiffies = jiffies + PCIE_LINK_RETRAIN_TIMEOUT_MS do { pcie_capability_read_word(PCI_EXP_LNKSTA, &lnksta) if ((lnksta & PCI_EXP_LNKSTA_DLLLA) == PCI_EXP_LNKSTA_DLLLA) return 0 msleep(1) # likely wait several ms for link active } while (time_before(jiffies, end_jiffies)) if (active) # (true) msleep(delay) # wait 100ms here pci_dev_wait(child, "bus reset", PCIE_RESET_READY_POLL_MS - delay) delay = 1 for (;;) { pci_read_config_dword(PCI_VENDOR_ID, &id) if (!pci_bus_rrs_vendor_id(id)) # got 0xffff, assume valid break; } pci_dbg("ready 0ms after bus reset", delay - 1) # 11.11And from the dmesg log:
[ 10.862226] pci 10000:00:02.0: waiting 100 ms for downstream link, after activation [ 11.109581] pci 10000:01:00.0: ready 0ms after bus resetit looks like we waited about .25s (250ms) after the link came up before trying to read the Vendor ID, which should be plenty.
I guess maybe this device requires more than 250ms after reset before it can respond? That still seems surprising to me; I *assume* Intel would have tested this for spec conformance. But maybe there's some erratum. I added a couple Intel folks who are mentioned in the nvme history in case they have pointers.
But it *is* also true that
pci_dev_wait()doesn't know how to handle PCIe errors at all, and maybe there's a way to make it smarter.Can you try adding the patch below and collect another dmesg log (with dyndbg="file
drivers/pci/*+p" as before)? This isn't a fix, but might give a little more insight into what's happening.drivers/pci/pci.c +23
-2@@ -1268,6 +1268,7 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)bool retrain = false;struct pci_dev *root, *bridge; +pci_dbg (dev,"%s: %s timeout %d\n" , __func__, reset_type, timeout); root =pcie_find_root_port (dev);if (pci_is_pcie (dev)) {@@ -1305,14 +1306,32 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)if (root && root->config_rrs_sv) {pci_read_config_dword (dev,PCI_VENDOR_ID , &id); -if (!pci_bus_rrs_vendor_id (id)) -break ; +pci_dbg (dev,"%s: vf %d read %#06x\n" , __func__, + dev->is_virtfn, id); +if (pci_bus_rrs_vendor_id (id)) + goto retry; + +/* +* We might read 0xffff if the device is a VF and +* the read was successful (the VF Vendor ID is +* 0xffff per spec). +* +* If the device is not a VF, 0xffff likely means +* there was an error on PCIe. E.g., maybe the +* device couldn't even respond with RRS status, +* and the RC timed out and synthesized ~0 data. +*/ +if (PCI_POSSIBLE_ERROR (id) && !dev->is_virtfn) + goto retry; + +break ; }else {pci_read_config_dword (dev,PCI_COMMAND , &id);if (!PCI_POSSIBLE_ERROR (id))break ; } +retry:if (delay > timeout) {pci_warn (dev,"not ready %dms after %s; giving up\n" , delay -1 , reset_type);@@ -4760,6 +4779,8 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,* Some controllers might not implement link active reporting. In this * case, we wait for 1000 ms + any delay requested by the caller. */ +pci_dbg (pdev,"%s: active %d delay %d link_active_reporting %d\n" , + __func__, active, delay, pdev->link_active_reporting);if (!pdev->link_active_reporting) {msleep (PCIE_LINK_RETRAIN_TIMEOUT_MS + delay);return true;
Sorry for late response, I was OOO the past week.
This is the log after applied your patch: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/61
Looks like the "retry" makes the nvme work.
Quoted 248 lines · Bjorn Helgaas
Ping, any chance you could try the patch below to collect a little more data. The proposed quirk covers up a deeper problem, and I want to fix that problem instead of covering it up.
Quoted 243 lines · Bjorn Helgaas
[+cc Chaitanya, Ville for possible Intel NVMe contacts]
Quoted 91 lines · Hui Wang
Quoted 90 lines · Hui Wang
Quoted 31 lines · Bjorn Helgaas
[+cc VMD folks]
Quoted 9 lines · Hui Wang
Prior to commit
d591f6804e7e("PCI: Wait for device readiness with Configuration RRS"), this Intel nvme [8086:0a54] works well. Since that patch is merged to the kernel, this nvme stops working.Through debugging, we found that commit introduces the RRS polling in the
pci_dev_wait(), for this nvme, when polling thePCI_VENDOR_ID, it will return ~0 if the config access is not ready yet, but the polling expects a return value of0x0001or a validvendor_id, so the RRS polling doesn't work for this nvme.Sorry for breaking this, and thanks for all your work in debugging this! Issues like this are really hard to track down.
I would think we would have heard about this earlier if the NVMe device were broken on all systems. Maybe there's some connection with VMD? From the non-working dmesg log in your bug report
(https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/+attachment/5879970/+files/dmesg-60.txt):DMI: ASUSTeK COMPUTER INC. ESC8000 G4/Z11PG-D24 Series, BIOS 5501
04/17/2019
vmd 0000:d7:05.5: PCI host bridge to bus 10000:00
pci 10000:00:02.0: [8086:2032] type 01 class0x060400PCIe Root Port pci 10000:00:02.0: PCI bridge to [bus 01]
pci 10000:00:02.0: bridge window [mem 0xf8000000-0xf81fffff]:
assigned
pci 10000:01:00.0: [8086:0a54] type 00 class0x010802PCIe Endpoint pci 10000:01:00.0: BAR 0 [mem 0x00000000-0x00003fff 64bit]Quoted 1 line
<I think
vmd_enable_domain()callspci_reset_bus()here>Yes, and the
pci_dev_wait()is called here. With the RRS polling, will get a ~0 fromPCI_VENDOR_ID, then will get0xfffffffwhen configuring the BAR0 subsequently. With the original polling method, it will get enough delay in thepci_dev_wait(), so nvme works normally.The line "[ 10.193589] hhhhhhhhhhhhhhhhhhhhhhhhhhhh
dev->device= 0a54 id = ffffffff" is output frompci_dev_wait(), please refer to
https://launchpadlibrarian.net/798708446/LP2111521-dmesg-test9.txtQuoted 48 lines
pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (high
0x00000000!=0xffffffff)
pci 10000:01:00.0: BAR 0 [mem 0xf8010000-0xf8013fff 64bit]: assigned pci 10000:01:00.0: BAR 0: error updating (0xf8010004!=0xffffffff) nvme nvme0: pci function 10000:01:00.0
nvme 10000:01:00.0: enabling device (0000 -> 0002)Things I notice:
- The 10000:01:00.0 NVMe device is behind a VMD bridge
- We successfully read the Vendor & Device IDs (8086:0a54)
- The NVMe device is uninitialized. We successfully sized the BAR, which included successful config reads and writes. The BAR wasn't assigned by BIOS, which is normal since it's behind VMD.
- We allocated space for BAR 0 but the config writes to program the BAR failed. The read back from the BAR was
0xffffffff; probably a PCIe error, e.g., the NVMe device didn't respond.- The device *did* respond when
nvme_probe()enabled it: the "enabling device (0000 -> 0002)" meanspci_enable_resources()readPCI_COMMANDand got0x0000.- The dmesg from the working config doesn't include the "enabling device" line, which suggests that
pci_enable_resources()sawPCI_COMMAND_MEMORY(0x0002) already set and didn't bother setting it again. I don't know why it would already be set.d591f6804e7ereally only changespci_dev_wait(), which is used after device resets. I thinkvmd_enable_domain()resets the VMD Root Ports afterpci_scan_child_bus(), and maybe we're not waiting long enough afterwards.My guess is that we got the ~0 because we did a config read too soon after reset and the device didn't respond. The Root Port would time out, log an error, and synthesize ~0 data to complete the CPU read (see PCIe r6.0, sec 2.3.2 implementation note).
It's *possible* that we waited long enough but the NVMe device is broken and didn't respond when it should have, but my money is on a software defect.
There are a few
pci_dbg()calls about these delays; can you setCONFIG_DYNAMIC_DEBUG=yand boot with dyndbg="filedrivers/pci/*+p" to collect that output? Please also collect the "sudo lspci -vv" output from a working system.Quoted 7 lines
Quoted 4 lines
Already passed the testing request to bug reporters, wait for their feedback.
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/55
This is the dmesg with dyndbg="file
drivers/pci/*+p"https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/56
Thank you very much! I'm stumped.
Both Ports here are capable of 8GT/s, and the Root Port is hot-plug capable and supports Data Link Layer Link Active Reporting but not DRS:
10000:00:02.0 Intel Sky Lake-E PCI Express Root Port C
LnkCap: Port #11, Speed 8GT/s, Width x4, ASPM L1, Exit Latency L1 <16us
ClockPM- Surprise+ LLActRep+ BwNot+ ASPMOptComp+
LnkSta: Speed 8GT/s, Width x4
TrErr- Train- SlotClk+ DLActive+ BWMgmt- ABWMgmt-
SltCap: AttnBtn- PwrCtrl- MRL- AttnInd+ PwrInd+ HotPlug+ Surprise+
LnkCap2: Supported Link Speeds: 2.5-8GT/s, Crosslink- Retimer- 2Retimers- DRS-10000:01:00.0 Intel NVMe Datacenter SSD
LnkCap: Port #0, Speed 8GT/s, Width x4, ASPM L0s, Exit Latency L0s <64nsAfter a reset, we have to delay before doing config reads. The wait time requirements are in PCIe r6.0, sec 6.6.1:
• ... For cases where system software cannot determine that DRS is supported by the attached device, or by the Downstream Port above the attached device [as in this case]:
◦ ...
◦ With a Downstream Port that supports Link speeds greater than
5.0 GT/s, software must wait a minimum of 100 ms after Link training completes before sending a Configuration Request to the device immediately below that Port. Software can determine when Link training completes by polling the Data Link Layer Link Active bit or by setting up an associated interrupt (see § Section 6.7.3.3). It is strongly recommended for software to use this mechanism whenever the Downstream Port supports it.Since the Port supports 8GT/s, we should wait 100ms after Link training completes (
PCI_EXP_LNKSTA_DLLLAbecomes set), and based on the code path below, I think we *do*:pci_bridge_secondary_bus_reset pcibios_reset_secondary_bus pci_reset_secondary_bus # assert PCI_BRIDGE_CTL_BUS_RESET pci_bridge_wait_for_secondary_bus(bridge, "bus reset") pci_dbg("waiting %d ms for downstream link, after activation\n") # 10.86 delay = pci_bus_max_d3cold_delay() # default 100ms pcie_wait_for_link_delay(bridge, active=true, delay=100) pcie_wait_for_link_status(use_lt=false, active=true) end_jiffies = jiffies + PCIE_LINK_RETRAIN_TIMEOUT_MS do { pcie_capability_read_word(PCI_EXP_LNKSTA, &lnksta) if ((lnksta & PCI_EXP_LNKSTA_DLLLA) == PCI_EXP_LNKSTA_DLLLA) return 0 msleep(1) # likely wait several ms for link active } while (time_before(jiffies, end_jiffies)) if (active) # (true) msleep(delay) # wait 100ms here pci_dev_wait(child, "bus reset", PCIE_RESET_READY_POLL_MS - delay) delay = 1 for (;;) { pci_read_config_dword(PCI_VENDOR_ID, &id) if (!pci_bus_rrs_vendor_id(id)) # got 0xffff, assume valid break; } pci_dbg("ready 0ms after bus reset", delay - 1) # 11.11And from the dmesg log:
[ 10.862226] pci 10000:00:02.0: waiting 100 ms for downstream link, after activation [ 11.109581] pci 10000:01:00.0: ready 0ms after bus resetit looks like we waited about .25s (250ms) after the link came up before trying to read the Vendor ID, which should be plenty.
I guess maybe this device requires more than 250ms after reset before it can respond? That still seems surprising to me; I *assume* Intel would have tested this for spec conformance. But maybe there's some erratum. I added a couple Intel folks who are mentioned in the nvme history in case they have pointers.
But it *is* also true that
pci_dev_wait()doesn't know how to handle PCIe errors at all, and maybe there's a way to make it smarter.Can you try adding the patch below and collect another dmesg log (with dyndbg="file
drivers/pci/*+p" as before)? This isn't a fix, but might give a little more insight into what's happening.drivers/pci/pci.c +23
-2@@ -1268,6 +1268,7 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)bool retrain = false;struct pci_dev *root, *bridge; +pci_dbg (dev,"%s: %s timeout %d\n" , __func__, reset_type, timeout); root =pcie_find_root_port (dev);if (pci_is_pcie (dev)) {@@ -1305,14 +1306,32 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)if (root && root->config_rrs_sv) {pci_read_config_dword (dev,PCI_VENDOR_ID , &id); -if (!pci_bus_rrs_vendor_id (id)) -break ; +pci_dbg (dev,"%s: vf %d read %#06x\n" , __func__, + dev->is_virtfn, id); +if (pci_bus_rrs_vendor_id (id)) + goto retry; + +/* +* We might read 0xffff if the device is a VF and +* the read was successful (the VF Vendor ID is +* 0xffff per spec). +* +* If the device is not a VF, 0xffff likely means +* there was an error on PCIe. E.g., maybe the +* device couldn't even respond with RRS status, +* and the RC timed out and synthesized ~0 data. +*/ +if (PCI_POSSIBLE_ERROR (id) && !dev->is_virtfn) + goto retry; + +break ; }else {pci_read_config_dword (dev,PCI_COMMAND , &id);if (!PCI_POSSIBLE_ERROR (id))break ; } +retry:if (delay > timeout) {pci_warn (dev,"not ready %dms after %s; giving up\n" , delay -1 , reset_type);@@ -4760,6 +4779,8 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,* Some controllers might not implement link active reporting. In this * case, we wait for 1000 ms + any delay requested by the caller. */ +pci_dbg (pdev,"%s: active %d delay %d link_active_reporting %d\n" , + __func__, active, delay, pdev->link_active_reporting);if (!pdev->link_active_reporting) {msleep (PCIE_LINK_RETRAIN_TIMEOUT_MS + delay);return true;
Quoted 6 lines · Hui Wang
Sorry for late response, I was OOO the past week.
This is the log after applied your patch:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/61Looks like the "retry" makes the nvme work.
Thank you! It seems like we get 0xffffffff (probably PCIe error) for a long time after we think the device should be able to respond with RRS.
I always thought the spec required that after the delays, a device should respond with RRS if it's not ready, but now I guess I'm not 100% sure. Maybe it's allowed to just do nothing, which would lead to the Root Port timing out and logging an Unsupported Request error.
Can I trouble you to try the patch below? I think we might have to start explicitly checking for that error. That probably would require some setup to enable the error, check for it, and clear it. I hacked in some of that here, but ultimately some of it should go elsewhere.
drivers/pci/pci.c +45 -5
@@ -1264,10 +1264,13 @@ void pci_resume_bus(struct pci_bus *bus)static int pci_dev_wait (struct pci_dev *dev,char *reset_type,int timeout) { -int delay =1 ; +int delay =10 ;bool retrain = false;struct pci_dev *root, *bridge; +u16 devctl, devsta; +pci_info (dev,"%s: VF%c %s timeout %d\n" , __func__, + dev->is_virtfn ?'+' :'-' , reset_type, timeout); root =pcie_find_root_port (dev);if (pci_is_pcie (dev)) {
@@ -1276,6 +1279,19 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) retrain = true; } +if (root) { +pcie_capability_read_word (root,PCI_EXP_DEVCTL , &devctl); +if (!(devctl &PCI_EXP_DEVCTL_URRE )) +pcie_capability_write_word (root,PCI_EXP_DEVCTL , + devctl |PCI_EXP_DEVCTL_URRE ); +pcie_capability_read_word (root,PCI_EXP_DEVSTA , &devsta); +if (devsta &PCI_EXP_DEVSTA_URD ) +pcie_capability_write_word (root,PCI_EXP_DEVSTA , +PCI_EXP_DEVSTA_URD ); +pci_info (root,"%s: DEVCTL %#06x DEVSTA %#06x\n" , __func__, + devctl, devsta); + } +/* * The caller has already waited long enough after a reset that the * device should respond to config requests, but it may respond
@@ -1305,14 +1321,33 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)if (root && root->config_rrs_sv) {pci_read_config_dword (dev,PCI_VENDOR_ID , &id); -if (!pci_bus_rrs_vendor_id (id)) -break ; + +if (pci_bus_rrs_vendor_id (id)) { +pci_info (dev,"%s: read %#06x (RRS)\n" , + __func__, id); + goto retry; + } + +if (PCI_POSSIBLE_ERROR (id)) { +pcie_capability_read_word (root,PCI_EXP_DEVSTA , + &devsta); +if (devsta &PCI_EXP_DEVSTA_URD ) +pcie_capability_write_word (root, +PCI_EXP_DEVSTA , +PCI_EXP_DEVSTA_URD ); +pci_info (root,"%s: read %#06x DEVSTA %#06x\n" , + __func__, id, devsta); + goto retry; + } + +break ; }else {pci_read_config_dword (dev,PCI_COMMAND , &id);if (!PCI_POSSIBLE_ERROR (id))break ; } +retry:if (delay > timeout) {pci_warn (dev,"not ready %dms after %s; giving up\n" , delay -1 , reset_type);
@@ -1332,7 +1367,6 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) }msleep (delay); - delay *=2 ; }if (delay >PCI_RESET_WAIT )
@@ -4670,8 +4704,10 @@ static int pcie_wait_for_link_status(struct pci_dev *pdev, end_jiffies = jiffies +msecs_to_jiffies (PCIE_LINK_RETRAIN_TIMEOUT_MS );do {pcie_capability_read_word (pdev,PCI_EXP_LNKSTA , &lnksta); -if ((lnksta & lnksta_mask) == lnksta_match) +if ((lnksta & lnksta_mask) == lnksta_match) { +pci_info (pdev,"%s: LNKSTA %#06x\n" , __func__, lnksta);return 0 ; + }msleep (1 ); }while (time_before (jiffies, end_jiffies));
@@ -4760,6 +4796,8 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,* Some controllers might not implement link active reporting. In this * case, we wait for 1000 ms + any delay requested by the caller. */ +pci_info (pdev,"%s: active %d delay %d link_active_reporting %d\n" , + __func__, active, delay, pdev->link_active_reporting);if (!pdev->link_active_reporting) {msleep (PCIE_LINK_RETRAIN_TIMEOUT_MS + delay);return true;
@@ -4784,6 +4822,7 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,return false;msleep (delay); +pci_info (pdev,"%s: waited %dms\n" , __func__, delay);return true; }
@@ -4960,6 +4999,7 @@ void pci_reset_secondary_bus(struct pci_dev *dev) ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET ;pci_write_config_word (dev,PCI_BRIDGE_CONTROL , ctrl); +pci_info (dev,"%s: PCI_BRIDGE_CTL_BUS_RESET deasserted\n" , __func__); }void __weak pcibios_reset_secondary_bus (struct pci_dev *dev)
Quoted 16 lines · Bjorn Helgaas
Quoted 6 lines · Hui Wang
Sorry for late response, I was OOO the past week.
This is the log after applied your patch:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/61Looks like the "retry" makes the nvme work.
Thank you! It seems like we get
0xffffffff(probably PCIe error) for a long time after we think the device should be able to respond with RRS.I always thought the spec required that after the delays, a device should respond with RRS if it's not ready, but now I guess I'm not 100% sure. Maybe it's allowed to just do nothing, which would lead to the Root Port timing out and logging an Unsupported Request error.
Quoted 4 lines
Can I trouble you to try the patch below? I think we might have to start explicitly checking for that error. That probably would require some setup to enable the error, check for it, and clear it. I hacked in some of that here, but ultimately some of it should go elsewhere.
OK, built a testing kernel, wait for bug reporter to test it and collect the log.
Quoted 120 lines
drivers/pci/pci.c +45
-5@@ -1264,10 +1264,13 @@ void pci_resume_bus(struct pci_bus *bus)static int pci_dev_wait (struct pci_dev *dev,char *reset_type,int timeout) { -int delay =1 ; +int delay =10 ;bool retrain = false;struct pci_dev *root, *bridge; +u16 devctl, devsta; +pci_info (dev,"%s: VF%c %s timeout %d\n" , __func__, + dev->is_virtfn ?'+' :'-' , reset_type, timeout); root =pcie_find_root_port (dev);if (pci_is_pcie (dev)) {@@ -1276,6 +1279,19 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) retrain = true; } +if (root) { +pcie_capability_read_word (root,PCI_EXP_DEVCTL , &devctl); +if (!(devctl &PCI_EXP_DEVCTL_URRE )) +pcie_capability_write_word (root,PCI_EXP_DEVCTL , + devctl |PCI_EXP_DEVCTL_URRE ); +pcie_capability_read_word (root,PCI_EXP_DEVSTA , &devsta); +if (devsta &PCI_EXP_DEVSTA_URD ) +pcie_capability_write_word (root,PCI_EXP_DEVSTA , +PCI_EXP_DEVSTA_URD ); +pci_info (root,"%s: DEVCTL %#06x DEVSTA %#06x\n" , __func__, + devctl, devsta); + } +/* * The caller has already waited long enough after a reset that the * device should respond to config requests, but it may respond @@ -1305,14 +1321,33 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)if (root && root->config_rrs_sv) {pci_read_config_dword (dev,PCI_VENDOR_ID , &id); -if (!pci_bus_rrs_vendor_id (id)) -break ; + +if (pci_bus_rrs_vendor_id (id)) { +pci_info (dev,"%s: read %#06x (RRS)\n" , + __func__, id); + goto retry; + } + +if (PCI_POSSIBLE_ERROR (id)) { +pcie_capability_read_word (root,PCI_EXP_DEVSTA , + &devsta); +if (devsta &PCI_EXP_DEVSTA_URD ) +pcie_capability_write_word (root, +PCI_EXP_DEVSTA , +PCI_EXP_DEVSTA_URD ); +pci_info (root,"%s: read %#06x DEVSTA %#06x\n" , + __func__, id, devsta); + goto retry; + } + +break ; }else {pci_read_config_dword (dev,PCI_COMMAND , &id);if (!PCI_POSSIBLE_ERROR (id))break ; } +retry:if (delay > timeout) {pci_warn (dev,"not ready %dms after %s; giving up\n" , delay -1 , reset_type);@@ -1332,7 +1367,6 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) }msleep (delay); - delay *=2 ; }if (delay >PCI_RESET_WAIT )@@ -4670,8 +4704,10 @@ static int pcie_wait_for_link_status(struct pci_dev *pdev, end_jiffies = jiffies +msecs_to_jiffies (PCIE_LINK_RETRAIN_TIMEOUT_MS );do {pcie_capability_read_word (pdev,PCI_EXP_LNKSTA , &lnksta); -if ((lnksta & lnksta_mask) == lnksta_match) +if ((lnksta & lnksta_mask) == lnksta_match) { +pci_info (pdev,"%s: LNKSTA %#06x\n" , __func__, lnksta);return 0 ; + }msleep (1 ); }while (time_before (jiffies, end_jiffies));@@ -4760,6 +4796,8 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,* Some controllers might not implement link active reporting. In this * case, we wait for 1000 ms + any delay requested by the caller. */ +pci_info (pdev,"%s: active %d delay %d link_active_reporting %d\n" , + __func__, active, delay, pdev->link_active_reporting);if (!pdev->link_active_reporting) {msleep (PCIE_LINK_RETRAIN_TIMEOUT_MS + delay);return true;@@ -4784,6 +4822,7 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,return false;msleep (delay); +pci_info (pdev,"%s: waited %dms\n" , __func__, delay);return true; }@@ -4960,6 +4999,7 @@ void pci_reset_secondary_bus(struct pci_dev *dev) ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET ;pci_write_config_word (dev,PCI_BRIDGE_CONTROL , ctrl); +pci_info (dev,"%s: PCI_BRIDGE_CTL_BUS_RESET deasserted\n" , __func__); }void __weak pcibios_reset_secondary_bus (struct pci_dev *dev)
Quoted 19 lines · Hui Wang
Quoted 17 lines · Bjorn Helgaas
Quoted 7 lines · Hui Wang
Sorry for late response, I was OOO the past week.
This is the log after applied your patch:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/61Looks like the "retry" makes the nvme work.
Thank you! It seems like we get
0xffffffff(probably PCIe error) for a long time after we think the device should be able to respond with RRS.I always thought the spec required that after the delays, a device should respond with RRS if it's not ready, but now I guess I'm not 100% sure. Maybe it's allowed to just do nothing, which would lead to the Root Port timing out and logging an Unsupported Request error.
Quoted 7 lines
Quoted 4 lines
Can I trouble you to try the patch below? I think we might have to start explicitly checking for that error. That probably would require some setup to enable the error, check for it, and clear it. I hacked in some of that here, but ultimately some of it should go elsewhere.
OK, built a testing kernel, wait for bug reporter to test it and collect the log.
This is the testing result and log. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/65
Quoted 114 lines
Quoted 114 lines
drivers/pci/pci.c +15
-1@@ -1264,10 +1264,13 @@ void pci_resume_bus(struct pci_bus *bus) static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) { - int delay = 1; + int delay = 10; bool retrain = false; struct pci_dev *root, *bridge; + u16 devctl, devsta; + pci_info(dev, "%s: VF%c %s timeout %d\n", __func__, + dev->is_virtfn ? '+' : '-', reset_type, timeout); root = pcie_find_root_port(dev); if (pci_is_pcie(dev)) {@@ -1276,6 +1279,19 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) retrain = true; } + if (root) { + pcie_capability_read_word(root, PCI_EXP_DEVCTL, &devctl); + if (!(devctl & PCI_EXP_DEVCTL_URRE)) + pcie_capability_write_word(root, PCI_EXP_DEVCTL, + devctl | PCI_EXP_DEVCTL_URRE); + pcie_capability_read_word(root, PCI_EXP_DEVSTA, &devsta); + if (devsta & PCI_EXP_DEVSTA_URD) + pcie_capability_write_word(root, PCI_EXP_DEVSTA, + PCI_EXP_DEVSTA_URD); + pci_info(root, "%s: DEVCTL %#06x DEVSTA %#06x\n", __func__, + devctl, devsta); + } + /** The caller has already waited long enough after a reset that the * device should respond to config requests, but it may respond
drivers/pci/pci.c +20
-2@@ -1305,14 +1321,33 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) if (root && root->config_rrs_sv) { pci_read_config_dword(dev, PCI_VENDOR_ID, &id); - if (!pci_bus_rrs_vendor_id(id)) - break; + + if (pci_bus_rrs_vendor_id(id)) { + pci_info(dev, "%s: read %#06x (RRS)\n", + __func__, id); + goto retry; + } + + if (PCI_POSSIBLE_ERROR(id)) { + pcie_capability_read_word(root, PCI_EXP_DEVSTA, + &devsta); + if (devsta & PCI_EXP_DEVSTA_URD) + pcie_capability_write_word(root, + PCI_EXP_DEVSTA, + PCI_EXP_DEVSTA_URD); + pci_info(root, "%s: read %#06x DEVSTA %#06x\n", + __func__, id, devsta); + goto retry; + } + + break; } else { pci_read_config_dword(dev, PCI_COMMAND, &id); if (!PCI_POSSIBLE_ERROR(id)) break; }+retry:
if (delay > timeout) {
pci_warn(dev, "not ready %dms after %s; giving up\n", delay - 1, reset_type);drivers/pci/pci.c +3
-2@@ -1332,7 +1367,6 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) } msleep(delay); - delay *= 2; } if (delay > PCI_RESET_WAIT)@@ -4670,8 +4704,10 @@ static int pcie_wait_for_link_status(structpci_dev *pdev, end_jiffies = jiffies + msecs_to_jiffies(PCIE_LINK_RETRAIN_TIMEOUT_MS); do { pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta); - if ((lnksta & lnksta_mask) == lnksta_match) + if ((lnksta & lnksta_mask) == lnksta_match) { + pci_info(pdev, "%s: LNKSTA %#06x\n", __func__, lnksta); return 0; + } msleep(1); } while (time_before(jiffies, end_jiffies));@@ -4760,6 +4796,8 @@ static bool pcie_wait_for_link_delay(struct
pci_dev*pdev, bool active,
* Some controllers might not implement link active reporting. In this
* case, we wait for 1000 ms + any delay requested by the caller.
*/
+ pci_info(pdev, "%s: active %d delay %dlink_active_reporting%d\n",
+__func__, active, delay,pdev->link_active_reporting);
if (!pdev->link_active_reporting) {
msleep(PCIE_LINK_RETRAIN_TIMEOUT_MS + delay);
return true;drivers/pci/pci.c +1
-0@@ -4784,6 +4822,7 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active, return false; msleep(delay); + pci_info(pdev, "%s: waited %dms\n", __func__, delay); return true; } @@ -4960,6 +4999,7 @@ void pci_reset_secondary_bus(struct pci_dev *dev)ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET;
pci_write_config_word(dev, PCI_BRIDGE_CONTROL, ctrl); +pci_info(dev, "%s: PCI_BRIDGE_CTL_BUS_RESET deasserted\n", __func__);
}
void__weakpcibios_reset_secondary_bus(struct pci_dev *dev)
Hi Bjorn,
Any progress on this issue, do we have a fix for this now? The ubuntu users are waiting for a fix :-).
Thanks,
Hui.
Quoted 146 lines · Hui Wang
Quoted 19 lines · Hui Wang
Quoted 17 lines · Bjorn Helgaas
Quoted 7 lines · Hui Wang
Sorry for late response, I was OOO the past week.
This is the log after applied your patch:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/61Looks like the "retry" makes the nvme work.
Thank you! It seems like we get
0xffffffff(probably PCIe error) for a long time after we think the device should be able to respond with RRS.I always thought the spec required that after the delays, a device should respond with RRS if it's not ready, but now I guess I'm not 100% sure. Maybe it's allowed to just do nothing, which would lead to the Root Port timing out and logging an Unsupported Request error.
Quoted 7 lines
Quoted 4 lines
Can I trouble you to try the patch below? I think we might have to start explicitly checking for that error. That probably would require some setup to enable the error, check for it, and clear it. I hacked in some of that here, but ultimately some of it should go elsewhere.
OK, built a testing kernel, wait for bug reporter to test it and collect the log.
This is the testing result and log. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/65
Quoted 115 lines
Quoted 115 lines
drivers/pci/pci.c +15
-1@@ -1264,10 +1264,13 @@ void pci_resume_bus(struct pci_bus *bus) static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) { - int delay = 1; + int delay = 10; bool retrain = false; struct pci_dev *root, *bridge; + u16 devctl, devsta; + pci_info(dev, "%s: VF%c %s timeout %d\n", __func__, + dev->is_virtfn ? '+' : '-', reset_type, timeout); root = pcie_find_root_port(dev); if (pci_is_pcie(dev)) {@@ -1276,6 +1279,19 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) retrain = true; } + if (root) { + pcie_capability_read_word(root, PCI_EXP_DEVCTL, &devctl); + if (!(devctl & PCI_EXP_DEVCTL_URRE)) + pcie_capability_write_word(root, PCI_EXP_DEVCTL, + devctl | PCI_EXP_DEVCTL_URRE); + pcie_capability_read_word(root, PCI_EXP_DEVSTA, &devsta); + if (devsta & PCI_EXP_DEVSTA_URD) + pcie_capability_write_word(root, PCI_EXP_DEVSTA, + PCI_EXP_DEVSTA_URD); + pci_info(root, "%s: DEVCTL %#06x DEVSTA %#06x\n", __func__, + devctl, devsta); + } + /** The caller has already waited long enough after a reset that the * device should respond to config requests, but it may respond
drivers/pci/pci.c +20
-2@@ -1305,14 +1321,33 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) if (root && root->config_rrs_sv) { pci_read_config_dword(dev, PCI_VENDOR_ID, &id); - if (!pci_bus_rrs_vendor_id(id)) - break; + + if (pci_bus_rrs_vendor_id(id)) { + pci_info(dev, "%s: read %#06x (RRS)\n", + __func__, id); + goto retry; + } + + if (PCI_POSSIBLE_ERROR(id)) { + pcie_capability_read_word(root, PCI_EXP_DEVSTA, + &devsta); + if (devsta & PCI_EXP_DEVSTA_URD) + pcie_capability_write_word(root, + PCI_EXP_DEVSTA, + PCI_EXP_DEVSTA_URD); + pci_info(root, "%s: read %#06x DEVSTA %#06x\n", + __func__, id, devsta); + goto retry; + } + + break; } else { pci_read_config_dword(dev, PCI_COMMAND, &id); if (!PCI_POSSIBLE_ERROR(id)) break; }+retry:
if (delay > timeout) {
pci_warn(dev, "not ready %dms after %s; giving up\n", delay - 1, reset_type);drivers/pci/pci.c +3
-2@@ -1332,7 +1367,6 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) } msleep(delay); - delay *= 2; } if (delay > PCI_RESET_WAIT)@@ -4670,8 +4704,10 @@ static int pcie_wait_for_link_status(structpci_dev *pdev, end_jiffies = jiffies + msecs_to_jiffies(PCIE_LINK_RETRAIN_TIMEOUT_MS); do { pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta); - if ((lnksta & lnksta_mask) == lnksta_match) + if ((lnksta & lnksta_mask) == lnksta_match) { + pci_info(pdev, "%s: LNKSTA %#06x\n", __func__, lnksta); return 0; + } msleep(1); } while (time_before(jiffies, end_jiffies));@@ -4760,6 +4796,8 @@ static bool pcie_wait_for_link_delay(struct
pci_dev*pdev, bool active,
* Some controllers might not implement link active reporting. In this
* case, we wait for 1000 ms + any delay requested by the caller.
*/
+ pci_info(pdev, "%s: active %d delay %dlink_active_reporting
%d\n",
+__func__, active, delay,pdev->link_active_reporting);
if (!pdev->link_active_reporting) {
msleep(PCIE_LINK_RETRAIN_TIMEOUT_MS + delay);
return true;drivers/pci/pci.c +1
-0@@ -4784,6 +4822,7 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active, return false; msleep(delay); + pci_info(pdev, "%s: waited %dms\n", __func__, delay); return true; } @@ -4960,6 +4999,7 @@ void pci_reset_secondary_bus(struct pci_dev *dev)ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET;
pci_write_config_word(dev, PCI_BRIDGE_CONTROL, ctrl); +pci_info(dev, "%s: PCI_BRIDGE_CTL_BUS_RESET deasserted\n", __func__);
}
void__weakpcibios_reset_secondary_bus(struct pci_dev *dev)
Quoted 4 lines · Hui Wang
Hi Bjorn,
Any progress on this issue, do we have a fix for this now? The ubuntu users are waiting for a fix :-).
Not yet, but thanks for the reminder. Keep bugging me!
PCIe r7.0, sec 2.3.1, makes it clear that devices are permitted to return RRS after FLR:
◦ For Configuration Requests only, if Device Readiness Status is not
supported, following reset it is permitted for a Function to terminate the request and indicate that it is temporarily unable to process the Request, but will be able to process the Request in the future - in this case, the Request Retry Status (RRS) Completion Status must be used (see § Section 6.6). Valid reset conditions after which a device/Function is permitted to return RRS in response to a Configuration Request are:
▪ FLRs
...
But I am a little bit concerned because sec 2.3.2, which talks about how a Root Complex handles that RRS and the RRS Software Visiblity feature, says (note the "system reset" period):
Root Complex handling of a Completion with Request Retry Status for a Configuration Request is implementation specific, except for the period following SYSTEM RESET (see § Section 6.6). For Root Complexes that support Configuration RRS Software Visibility, the following rules apply:
◦ If Configuration RRS Software Visibility is enabled:
▪ For a Configuration Read Request that includes both bytes of
the Vendor ID field of a device Function's Configuration Space Header, the Root Complex must complete the Request to the host by returning a read-data value of 0001h for the Vendor ID field and all 1's for any additional bytes included in the request.
So I'm worried that the Software Visibility feature might work after *system reset*, but not necessarily after an FLR. That might make sense because I don't think the RC can tell when we are doing an FLR to a device.
It seems that after FLR, most RCs *do* make RRS visible via SV. But if we can't rely on that, I don't know how we're supposed to learn when a device becomes ready.
Bjorn
Quoted 27 lines · Hui Wang
Quoted 25 lines · Hui Wang
Quoted 24 lines · Bjorn Helgaas
Quoted 23 lines · Hui Wang
Quoted 6 lines
Sorry for late response, I was OOO the past week.
This is the log after applied your patch:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/61Looks like the "retry" makes the nvme work.
Thank you! It seems like we get
0xffffffff(probably PCIe error) for a long time after we think the device should be able to respond with RRS.I always thought the spec required that after the delays, a device should respond with RRS if it's not ready, but now I guess I'm not 100% sure. Maybe it's allowed to just do nothing, which would lead to the Root Port timing out and logging an Unsupported Request error.
Can I trouble you to try the patch below? I think we might have to start explicitly checking for that error. That probably would require some setup to enable the error, check for it, and clear it. I hacked in some of that here, but ultimately some of it should go elsewhere.
...
Bjorn,
Quoted 7 lines · Bjorn Helgaas
Quoted 4 lines · Hui Wang
Hi Bjorn,
Any progress on this issue, do we have a fix for this now? The ubuntu users are waiting for a fix :-).
Not yet, but thanks for the reminder. Keep bugging me!
Other distributions' users waiting for the fix too!
Thanks,
Quoted 74 lines
PCIe r7.0, sec 2.3.1, makes it clear that devices are permitted to return RRS after FLR:
◦ For Configuration Requests only, if Device Readiness Status is not
supported, following reset it is permitted for a Function to terminate the request and indicate that it is temporarily unable to process the Request, but will be able to process the Request in the future - in this case, the Request Retry Status (RRS) Completion Status must be used (see § Section 6.6). Valid reset conditions after which a device/Function is permitted to return RRS in response to a Configuration Request are:▪ FLRs
...
But I am a little bit concerned because sec 2.3.2, which talks about how a Root Complex handles that RRS and the RRS Software Visiblity feature, says (note the "system reset" period):
Root Complex handling of a Completion with Request Retry Status for a Configuration Request is implementation specific, except for the period following SYSTEM RESET (see § Section 6.6). For Root Complexes that support Configuration RRS Software Visibility, the following rules apply:
◦ If Configuration RRS Software Visibility is enabled:
▪ For a Configuration Read Request that includes both bytes of
the Vendor ID field of a device Function's Configuration Space Header, the Root Complex must complete the Request to the host by returning a read-data value of 0001h for the Vendor ID field and all 1's for any additional bytes included in the request.So I'm worried that the Software Visibility feature might work after *system reset*, but not necessarily after an FLR. That might make sense because I don't think the RC can tell when we are doing an FLR to a device.
It seems that after FLR, most RCs *do* make RRS visible via SV. But if we can't rely on that, I don't know how we're supposed to learn when a device becomes ready.
Bjorn
Quoted 27 lines · Hui Wang
Quoted 25 lines · Hui Wang
Quoted 24 lines · Bjorn Helgaas
Quoted 23 lines · Hui Wang
Quoted 6 lines
Sorry for late response, I was OOO the past week.
This is the log after applied your patch:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/61Looks like the "retry" makes the nvme work.
Thank you! It seems like we get
0xffffffff(probably PCIe error) for a long time after we think the device should be able to respond with RRS.I always thought the spec required that after the delays, a device should respond with RRS if it's not ready, but now I guess I'm not 100% sure. Maybe it's allowed to just do nothing, which would lead to the Root Port timing out and logging an Unsupported Request error.
Can I trouble you to try the patch below? I think we might have to start explicitly checking for that error. That probably would require some setup to enable the error, check for it, and clear it. I hacked in some of that here, but ultimately some of it should go elsewhere.
...
Quoted 24 lines · Hui Wang
Quoted 23 lines · Hui Wang
Quoted 21 lines · Bjorn Helgaas
Quoted 7 lines · Hui Wang
Sorry for late response, I was OOO the past week.
This is the log after applied your patch:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/61Looks like the "retry" makes the nvme work.
Thank you! It seems like we get
0xffffffff(probably PCIe error) for a long time after we think the device should be able to respond with RRS.I always thought the spec required that after the delays, a device should respond with RRS if it's not ready, but now I guess I'm not 100% sure. Maybe it's allowed to just do nothing, which would lead to the Root Port timing out and logging an Unsupported Request error.
Can I trouble you to try the patch below? I think we might have to start explicitly checking for that error. That probably would require some setup to enable the error, check for it, and clear it. I hacked in some of that here, but ultimately some of it should go elsewhere.
Quoted 5 lines
Quoted 3 lines
OK, built a testing kernel, wait for bug reporter to test it and collect the log.
This is the testing result and log.
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/65
Thanks! This looks like an Intel S2600WFT, and I assume it has a BMC that maintains a System Event Log. Any chance you check or keep that log?
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/pci/pci.c +8
-2@@ -1305,14 +1321,33 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) if (root && root->config_rrs_sv) { pci_read_config_dword(dev, PCI_VENDOR_ID, &id); - if (!pci_bus_rrs_vendor_id(id)) - break; + + if (pci_bus_rrs_vendor_id(id)) { + pci_info(dev, "%s: read %#06x (RRS)\n", + __func__, id); + goto retry; + } + + if (PCI_POSSIBLE_ERROR(id)) {
Quoted 8 lines
Quoted 8 lines
drivers/pci/pci.c static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) · line 1339
Quoted 8 lines
drivers/pci/pci.c +8
-0+ pcie_capability_read_word(root, PCI_EXP_DEVSTA, + &devsta); + if (devsta & PCI_EXP_DEVSTA_URD) + pcie_capability_write_word(root, + PCI_EXP_DEVSTA, + PCI_EXP_DEVSTA_URD); + pci_info(root, "%s: read %#06x DEVSTA %#06x\n", + __func__, id, devsta);
We're waiting for 01:00.0, and we're seeing the poll message for about 375 ms:
[ 10.334786] pci 10000:01:00.0: pci_dev_wait: VF- bus reset timeout 59900 [ 10.334792] pci 10000:00:02.0: pci_dev_wait: read 0xffffffff DEVSTA 0x0000 ... [ 10.708367] pci 10000:00:02.0: pci_dev_wait: read 0xffffffff DEVSTA 0x0000
The 00:02.0 Root Port has RRS enabled, but the config reads of the 01:00.0 Vendor ID did not return the RRS value (0x0001). Instead, they returned 0xffffffff, which typically means an error on PCIe.
If an error occurred, I think it *should* set one of the Error Detected bits in the Device Status register, but we always see 0 there.
I think the platform enabled firmware-first error handling and declined to give Linux control of AER, so I'm wondering if BIOS is capturing and clearing those errors before Linux would see them, hence my question about the SEL.
[ 6.565996] GHES: APEI firmware first mode is enabled by APEI bit and WHEA _OSC. [ 6.702329] acpi PNP0A08:00: _OSC: platform does not support [SHPCHotplug AER LTR DPC] [ 6.702463] acpi PNP0A08:00: _OSC: OS now controls [PCIeHotplug PME PCIeCapability]
Even if this is the case and the SEL has error info, I don't know how that would help us, other than maybe to understand why Linux doesn't see the errors.
Bjorn
Nirmal, Jonathan, can you confirm that when RRS SV is enabled for VMD Root Ports, we should actually see the 0x0001 value when a device downstream of VMD responds with RRS? From the log below, it appears that we actually get 0xffffffff when reading Device ID after a reset.
Quoted 14 lines · Bjorn Helgaas
Quoted 2 lines · Hui Wang
Quoted 1 line · Hui Wang
On 7/2/25 07:23, Bjorn Helgaas wrote:
...
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Thank you! It seems like we get
0xffffffff(probably PCIe error) for a long time after we think the device should be able to respond with RRS.I always thought the spec required that after the delays, a device should respond with RRS if it's not ready, but now I guess I'm not 100% sure. Maybe it's allowed to just do nothing, which would lead to the Root Port timing out and logging an Unsupported Request error.
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Can I trouble you to try the patch below? I think we might have to start explicitly checking for that error. That probably would require some setup to enable the error, check for it, and clear it. I hacked in some of that here, but ultimately some of it should go elsewhere.
...
The patch is here:
https://lore.kernel.org/r/20250701232341.GA1859056@bhelgaas
and the log with that patch is here:
Quoted 5 lines
Quoted 2 lines
This is the testing result and log.
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/65We're waiting for 01:00.0, and we're seeing the poll message for about 375 ms:
[ 10.177356] pci 10000:00:02.0: PCI bridge to [bus 01] [ 10.182278] pci 10000:01:00.0: [8086:0a54] type 00 class 0x010802 PCIe Endpoint [ 10.195247] pci 10000:00:02.0: pci_reset_secondary_bus: PCI_BRIDGE_CTL_BUS_RESET deasserted [ 10.195464] pci 10000:00:02.0: waiting 100 ms for downstream link, after activation [ 10.195467] pci 10000:00:02.0: pcie_wait_for_link_delay: active 1 delay 100 link_active_reporting 1 [ 10.229269] pci 10000:00:02.0: pcie_wait_for_link_status: LNKSTA 0xb043 [ 10.334784] pci 10000:00:02.0: pcie_wait_for_link_delay: waited 100ms
Quoted 8 lines
[ 10.334786] pci 10000:01:00.0: pci_dev_wait: VF- bus reset timeout 59900 [ 10.334792] pci 10000:00:02.0: pci_dev_wait: read 0xffffffff DEVSTA 0x0000 ... [ 10.708367] pci 10000:00:02.0: pci_dev_wait: read 0xffffffff DEVSTA 0x0000The 00:02.0 Root Port has RRS SV enabled, but the config reads of the 01:00.0 Vendor ID did not return the RRS value (
0x0001). Instead, they returned0xffffffff, which typically means an error on PCIe.
[top-posting to facilitate processing]
The issue discussed in this thread is still on my list of tracked regression, which got me wondering what's the status here. Did it fall through the cracks? Or was the regression maybe fixed already and I just missed it?
Ciao, Thorsten
Quoted 52 lines · Bjorn Helgaas
Nirmal, Jonathan, can you confirm that when RRS SV is enabled for VMD Root Ports, we should actually see the
0x0001value when a device downstream of VMD responds with RRS? From the log below, it appears that we actually get0xffffffffwhen reading Device ID after a reset.Quoted 14 lines · Bjorn Helgaas
Quoted 2 lines · Hui Wang
Quoted 1 line · Hui Wang
On 7/2/25 07:23, Bjorn Helgaas wrote:
...
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Thank you! It seems like we get
0xffffffff(probably PCIe error) for a long time after we think the device should be able to respond with RRS.I always thought the spec required that after the delays, a device should respond with RRS if it's not ready, but now I guess I'm not 100% sure. Maybe it's allowed to just do nothing, which would lead to the Root Port timing out and logging an Unsupported Request error.
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Can I trouble you to try the patch below? I think we might have to start explicitly checking for that error. That probably would require some setup to enable the error, check for it, and clear it. I hacked in some of that here, but ultimately some of it should go elsewhere.
...
The patch is here:
https://lore.kernel.org/r/20250701232341.GA1859056@bhelgaas
and the log with that patch is here:Quoted 5 lines
Quoted 2 lines
This is the testing result and log.
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521/comments/65We're waiting for 01:00.0, and we're seeing the poll message for about 375 ms:
[ 10.177356] pci 10000:00:02.0: PCI bridge to [bus 01] [ 10.182278] pci 10000:01:00.0: [8086:0a54] type 00 class 0x010802 PCIe Endpoint [ 10.195247] pci 10000:00:02.0: pci_reset_secondary_bus: PCI_BRIDGE_CTL_BUS_RESET deasserted [ 10.195464] pci 10000:00:02.0: waiting 100 ms for downstream link, after activation [ 10.195467] pci 10000:00:02.0: pcie_wait_for_link_delay: active 1 delay 100 link_active_reporting 1 [ 10.229269] pci 10000:00:02.0: pcie_wait_for_link_status: LNKSTA 0xb043 [ 10.334784] pci 10000:00:02.0: pcie_wait_for_link_delay: waited 100msQuoted 8 lines
[ 10.334786] pci 10000:01:00.0: pci_dev_wait: VF- bus reset timeout 59900 [ 10.334792] pci 10000:00:02.0: pci_dev_wait: read 0xffffffff DEVSTA 0x0000 ... [ 10.708367] pci 10000:00:02.0: pci_dev_wait: read 0xffffffff DEVSTA 0x0000The 00:02.0 Root Port has RRS SV enabled, but the config reads of the 01:00.0 Vendor ID did not return the RRS value (
0x0001). Instead, they returned0xffffffff, which typically means an error on PCIe.
Quoted 6 lines · Linux regression tracking (Thorsten Leemhuis)
[top-posting to facilitate processing]
The issue discussed in this thread is still on my list of tracked regression, which got me wondering what's the status here. Did it fall through the cracks? Or was the regression maybe fixed already and I just missed it?
Hello Thorsten,
I saw the regression was closed here:
<https://lore.kernel.org/regressions/[email protected]/>
I am one of the users affected by this issue and are currently running an old Linux version (Linux 6.1 from Debian oldstable) to work around it. As a user I would very much appreciate an upstream fix.
The Debian bug is still open
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1112238> whereas I think Ubuntu got a patch working around the issue for their users:
<https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521>
Is there a chance to possibly include the workaround in the upstream?
As the issue is reproducible on my system, I should be able to test some patches if necessary. Tests are not easy to perform because it degrades the RAID system and I would like to avoid damaging my “production” data hence limit the tests to the required minimum.
But if there is some real doubt that the issue is still present, tell me and I check it again with a more recent kernel version?
Thanks in advance and Kind regards
Linux-Fan
Quoted 9 lines · Bjorn Helgaas
Quoted 8 lines
Nirmal, Jonathan, can you confirm that when RRS SV is enabled for VMD Root Ports, we should actually see the
0x0001value when a device downstream of VMD responds with RRS? From the log below, it appears that we actually get0xffffffffwhen reading Device ID after a reset.Quoted 2 lines · Bjorn Helgaas
Quoted 1 line · Hui Wang
On 7/2/25 17:43, Hui Wang wrote:
[...]
Quoted 3 lines
Quoted 3 lines
The patch is here:
https://lore.kernel.org/r/20250701232341.GA1859056@bhelgaas
and the log with that patch is here:
[...]
Quoted 9 lines · Linux-Fan
Quoted 6 lines · Linux regression tracking (Thorsten Leemhuis)
[top-posting to facilitate processing]
The issue discussed in this thread is still on my list of tracked regression, which got me wondering what's the status here. Did it fall through the cracks? Or was the regression maybe fixed already and I just missed it?
Quoted 5 lines
Hello Thorsten,
I saw the regression was closed here:
<https://lore.kernel.org/regressions/e03d4af5-5cdb-4bf4-
[email protected]/>
That is not much relevant, what is relevant is the bug report and the activity, in this case this thread.
Quoted 10 lines
I am one of the users affected by this issue and are currently running an old Linux version (Linux 6.1 from Debian oldstable) to work around it. As a user I would very much appreciate an upstream fix.
The Debian bug is still open
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1112238> whereas I think Ubuntu got a patch working around the issue for their users:
<https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521>Is there a chance to possibly include the workaround in the upstream?
The workaround: maybe. But getting it fixed is what you want, and the workaround might be the wrong solution for that. That's up for the developers of the affected area to decide.
But the thing is, this thread got messy and doesn't work on its own anymore (it should ideally answer questions like "What does the workaround look like" without providing a URL, as developers are busy and might not follow it; any by now devs likely have totally forgotten what this is about, so a kind of re-start might be needed).
But maybe we are lucky, and some developers of this area will reply within the next two or three days.
If not, I'd suggest checking if 6.19 vanilla is still affected (fixing 6.12.y comes later, so let's ignore that for now). If it is, check if the workaround from Ubuntu fixes it there. It might even make sense to check if a revert of the culprit fixes it, too. Then report your findings and sum up the situation briefly (somewhat similar to a new bug report; people likely have forgotten what this thread is about). That should work as a good base to restart things here.
Ciao, Thorsten
Quoted 29 lines
As the issue is reproducible on my system, I should be able to test some patches if necessary. Tests are not easy to perform because it degrades the RAID system and I would like to avoid damaging my “production” data hence limit the tests to the required minimum.
But if there is some real doubt that the issue is still present, tell me and I check it again with a more recent kernel version?
Thanks in advance and Kind regards
Linux-FanQuoted 9 lines · Bjorn Helgaas
Quoted 8 lines
Nirmal, Jonathan, can you confirm that when RRS SV is enabled for VMD Root Ports, we should actually see the
0x0001value when a device downstream of VMD responds with RRS? From the log below, it appears that we actually get0xffffffffwhen reading Device ID after a reset.Quoted 2 lines · Bjorn Helgaas
Quoted 1 line · Hui Wang
On 7/2/25 17:43, Hui Wang wrote:
[...]
Quoted 3 lines
Quoted 3 lines
The patch is here:
https://lore.kernel.org/r/20250701232341.GA1859056@bhelgaas
and the log with that patch is here:[...]
Quoted 19 lines · Linux-Fan
Quoted 4 lines · Linux regression tracking (Thorsten Leemhuis)
The issue discussed in this thread is still on my list of tracked regression, which got me wondering what's the status here. Did it fall through the cracks? Or was the regression maybe fixed already and I just missed it?
I am one of the users affected by this issue and are currently running an old Linux version (Linux 6.1 from Debian oldstable) to work around it. As a user I would very much appreciate an upstream fix.
The Debian bug is still open
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1112238> whereas I think Ubuntu got a patch working around the issue for their users:
<https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521>Is there a chance to possibly include the workaround in the upstream?
Quoted 7 lines
As the issue is reproducible on my system, I should be able to test some patches if necessary. Tests are not easy to perform because it degrades the RAID system and I would like to avoid damaging my “production” data hence limit the tests to the required minimum.
But if there is some real doubt that the issue is still present, tell me and I check it again with a more recent kernel version?
As far as I know this issue still exists, and it has unfortunately fallen through the cracks, mostly because I don't have a good idea how to debug it.
Thanks for keeping it alive. I'll try to come up with some ideas.
Quoted 17 lines
Quoted 9 lines · Bjorn Helgaas
Quoted 8 lines
Nirmal, Jonathan, can you confirm that when RRS SV is enabled for VMD Root Ports, we should actually see the
0x0001value when a device downstream of VMD responds with RRS? From the log below, it appears that we actually get0xffffffffwhen reading Device ID after a reset.Quoted 2 lines · Bjorn Helgaas
Quoted 1 line · Hui Wang
On 7/2/25 17:43, Hui Wang wrote:
[...]
Quoted 3 lines
Quoted 3 lines
The patch is here:
https://lore.kernel.org/r/20250701232341.GA1859056@bhelgaas
and the log with that patch is here:[...]
Quoted 1 line · Bjorn Helgaas
On Sun, Feb 08, 2026 at 10:30:39PM +0100, Linux-Fan wrote:
[...]
Quoted 5 lines
Quoted 5 lines
As the issue is reproducible on my system, I should be able to test some patches if necessary. Tests are not easy to perform because it degrades the RAID system and I would like to avoid damaging my “production” data hence limit the tests to the required minimum.
Quoted 8 lines
Quoted 2 lines
But if there is some real doubt that the issue is still present, tell me and I check it again with a more recent kernel version?
As far as I know this issue still exists, and it has unfortunately fallen through the cracks, mostly because I don't have a good idea how to debug it.
Thanks for keeping it alive. I'll try to come up with some ideas.
[...]
In the meantime, I would like to follow up on the suggestion by Thorsten to summarize the state of the issue. I hope it is not too long-winded...
On 2025-05-22, an Ubuntu user reported that after updating the Linux kernel, their NVME SSDs (Intel Corporation NVMe Datacenter SSD [3DNAND, Beta Rock Controller] [8086:0a54]) were no longer detected [1].
It was bisected to be caused byd591f6804e ("PCI: Wait for device readiness with Configuration RRS").
I encountered this issue upon upgrading to Debian Trixie (Linux 6.12.41) and for me the issue manifests as only one of two Intel P4510 SSDs being recognized, causing RAID arrays to be degraded [2].
I think the most recent state of the error analysis starts here [5]. I cannot summarize it since I know too little about the matter.
During the work on the issue, multiple patches were devised:
* One was implemented by Ubuntu as a workaround.
I attach it as ubuntu.patch.
* One was suggested on this very thread for debugging [3]. I attach it as patch.patch.
I have performed additional testing as suggested by Thorsten [4]
* Tested with vanilla Linux 6.19 commit 05f7e89ab9 ("Linux 6.19"). I call it “standard” in my tests below. It recognizes only one of two SSDs on my system (issue still present)
* Tested with reverting the culprit. The revert produced some conflicts. I tried to resolve the conflicts (it may be wrong...) and have attached the outcome as revert.patch.
I applied each of the patches on top of the 6.19 “standard” checkout (undoing previous patches for the next test of course) and gave the builds different names.
The outcome of the test is as follows:
* standard - FAILS - issue is still present on Linux 6.19 per my testing
* ubuntu - WORKS - workaround patch applies and bypasses the issue * patch - WORKS - suggested debugging patch applies and bypasses the issue * revert - WORKS - my experimental revert commit bypasses the issue
In case it matters I have collected dmesg output of all four test runs, attached as dmesgs.tar.gz.
In case I could help with testing some additional patches etc. I have now setup a separate system (on a CF card) that I can boot as an alternative to the main system and which leaves the RAID arrays alone, avoiding the RAID degradation on testing.
Kind regards
Linux-Fan
[1] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2111521
[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1112238
[3] https://lore.kernel.org/linux-pci/20250701232341.GA1859056@bhelgaas/
[4] https://lore.kernel.org/linux-pci/[email protected]/
[5] https://lore.kernel.org/linux-pci/20250821163936.GA681451@bhelgaas/
drivers/pci/pci.c +45 -5
@@ -1208,10 +1208,13 @@ void pci_resume_bus(struct pci_bus *bus)static int pci_dev_wait (struct pci_dev *dev,char *reset_type,int timeout) { -int delay =1 ; +int delay =10 ;bool retrain = false;struct pci_dev *root, *bridge; +u16 devctl, devsta; +pci_info (dev,"%s: VF%c %s timeout %d\n" , __func__, + dev->is_virtfn ?'+' :'-' , reset_type, timeout); root =pcie_find_root_port (dev);if (pci_is_pcie (dev)) {
@@ -1220,6 +1223,19 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) retrain = true; } +if (root) { +pcie_capability_read_word (root,PCI_EXP_DEVCTL , &devctl); +if (!(devctl &PCI_EXP_DEVCTL_URRE )) +pcie_capability_write_word (root,PCI_EXP_DEVCTL , + devctl |PCI_EXP_DEVCTL_URRE ); +pcie_capability_read_word (root,PCI_EXP_DEVSTA , &devsta); +if (devsta &PCI_EXP_DEVSTA_URD ) +pcie_capability_write_word (root,PCI_EXP_DEVSTA , +PCI_EXP_DEVSTA_URD ); +pci_info (root,"%s: DEVCTL %#06x DEVSTA %#06x\n" , __func__, + devctl, devsta); + } +/* * The caller has already waited long enough after a reset that the * device should respond to config requests, but it may respond
@@ -1249,14 +1265,33 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)if (root && root->config_rrs_sv) {pci_read_config_dword (dev,PCI_VENDOR_ID , &id); -if (!pci_bus_rrs_vendor_id (id)) -break ; + +if (pci_bus_rrs_vendor_id (id)) { +pci_info (dev,"%s: read %#06x (RRS)\n" , + __func__, id); + goto retry; + } + +if (PCI_POSSIBLE_ERROR (id)) { +pcie_capability_read_word (root,PCI_EXP_DEVSTA , + &devsta); +if (devsta &PCI_EXP_DEVSTA_URD ) +pcie_capability_write_word (root, +PCI_EXP_DEVSTA , +PCI_EXP_DEVSTA_URD ); +pci_info (root,"%s: read %#06x DEVSTA %#06x\n" , + __func__, id, devsta); + goto retry; + } + +break ; }else {pci_read_config_dword (dev,PCI_COMMAND , &id);if (!PCI_POSSIBLE_ERROR (id))break ; } +retry:if (delay > timeout) {pci_warn (dev,"not ready %dms after %s; giving up\n" , delay -1 , reset_type);
@@ -1276,7 +1311,6 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) }msleep (delay); - delay *=2 ; }if (delay >PCI_RESET_WAIT )
@@ -4482,8 +4516,10 @@ static int pcie_wait_for_link_status(struct pci_dev *pdev, end_jiffies = jiffies +msecs_to_jiffies (PCIE_LINK_RETRAIN_TIMEOUT_MS );do {pcie_capability_read_word (pdev,PCI_EXP_LNKSTA , &lnksta); -if ((lnksta & lnksta_mask) == lnksta_match) +if ((lnksta & lnksta_mask) == lnksta_match) { +pci_info (pdev,"%s: LNKSTA %#06x\n" , __func__, lnksta);return 0 ; + }msleep (1 ); }while (time_before (jiffies, end_jiffies));
@@ -4572,6 +4608,8 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,* Some controllers might not implement link active reporting. In this * case, we wait for 1000 ms + any delay requested by the caller. */ +pci_info (pdev,"%s: active %d delay %d link_active_reporting %d\n" , + __func__, active, delay, pdev->link_active_reporting);if (!pdev->link_active_reporting) {msleep (PCIE_LINK_RETRAIN_TIMEOUT_MS + delay);return true;
@@ -4596,6 +4634,7 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,return false;msleep (delay); +pci_info (pdev,"%s: waited %dms\n" , __func__, delay);return true; }
@@ -4772,6 +4811,7 @@ void pci_reset_secondary_bus(struct pci_dev *dev) ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET ;pci_write_config_word (dev,PCI_BRIDGE_CONTROL , ctrl); +pci_info (dev,"%s: PCI_BRIDGE_CTL_BUS_RESET deasserted\n" , __func__); }void __weak pcibios_reset_secondary_bus (struct pci_dev *dev)
commit 2eecca1afcfae786128a698b07320c3ef74ee477
Author: Hui Wang <[email protected]> Date: Tue Aug 19 16:21:23 2025 +0800
UBUNTU: SAUCE: PCI: Disable RRS polling for Intel SSDPE2KX020T8 nvme
Prior to commit d591f6804e7e ("PCI: Wait for device readiness with Configuration RRS"), this Intel nvme [8086:0a54] works well. Since that patch is merged to the kernel, this nvme stops working.
Through debugging, we found that commit introduces the RRS polling in the pci_dev_wait(), for this nvme, when polling the PCI_VENDOR_ID, it will return ~0 if the config access is not ready yet, but the polling expects a return value of 0x0001 or a valid vendor_id, so the RRS polling doesn't work for this nvme.
Here we add a pci quirk to disable the RRS polling for the device.
drivers/pci/probe.c +2 -1
@@ -1270,7 +1270,8 @@ static void pci_enable_rrs_sv(struct pci_dev *pdev)if (root_cap &PCI_EXP_RTCAP_RRS_SV ) {pcie_capability_set_word (pdev,PCI_EXP_RTCTL ,PCI_EXP_RTCTL_RRS_SVE ); - pdev->config_rrs_sv =1 ; +if (!(pdev->dev_flags &PCI_DEV_FLAGS_NO_RRS_SV )) + pdev->config_rrs_sv =1 ; } }
drivers/pci/quirks.c +18 -0
@@ -6353,3 +6353,21 @@ static void pci_mask_replay_timer_timeout(struct pci_dev *pdev)DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_GLI ,0x9750 , pci_mask_replay_timer_timeout);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_GLI ,0x9755 , pci_mask_replay_timer_timeout);#endif + +/* +* Although the root port device claims to support RRS, some devices don't work +* with RRS polling, when reading the Vendor ID, they just return ~0 if config +* access is not ready, this will break the pci_dev_wait(). Here disable the RRS +* forcibly for this type of device. +*/ +static void quirk_no_rrs_sv (struct pci_dev *dev) +{ +struct pci_dev *root; + + root =pcie_find_root_port (dev); +if (root) { + root->dev_flags |=PCI_DEV_FLAGS_NO_RRS_SV ; + root->config_rrs_sv =0 ; + } +} +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x0a54 , quirk_no_rrs_sv);
include/linux/pci.h +2 -0
@@ -247,6 +247,8 @@ enum pci_dev_flags {PCI_DEV_FLAGS_HAS_MSI_MASKING = (__force pci_dev_flags_t) (1 <<12 ),/* Device requires write to PCI_MSIX_ENTRY_DATA before any MSIX reads */ PCI_DEV_FLAGS_MSIX_TOUCH_ENTRY_DATA_FIRST = (__force pci_dev_flags_t) (1 <<13 ), +/* Do not use Configuration Request Retry Status polling in pci_dev_wait() */ + PCI_DEV_FLAGS_NO_RRS_SV = (__force pci_dev_flags_t) (1 << 14), }; enum pci_irq_reroute_variant {
From ea7e9b43b8bdc4633bb264e0bbf7fff8af640ec6 Mon Sep 17 00:00:00 2001
From: Linux-Fan <[email protected]>
Date: Thu, 12 Feb 2026 21:01:32 +0100
Subject: [PATCH] Revert "PCI: Wait for device readiness with Configuration
RRS"
MA TEST
This reverts commit d591f6804e7e1310881c9224d72247a2b65039af.
--- drivers/pci/pci.c | 41 +++++++++++++---------------------------- drivers/pci/probe.c | 4 +--- include/linux/pci.h | 1 - 3 files changed, 14 insertions(+), 32 deletions(-)
drivers/pci/pci.c +13 -28
60 lines not on this page · raw message
drivers/pci/probe.c +1 -3
@@ -1304,11 +1304,9 @@ static void pci_enable_rrs_sv(struct pci_dev *pdev)/* Enable Configuration RRS Software Visibility if supported */ pcie_capability_read_word (pdev,PCI_EXP_RTCAP , &root_cap); -if (root_cap &PCI_EXP_RTCAP_RRS_SV ) { +if (root_cap &PCI_EXP_RTCAP_RRS_SV )pcie_capability_set_word (pdev,PCI_EXP_RTCTL ,PCI_EXP_RTCTL_RRS_SVE ); - pdev->config_rrs_sv =1 ; - } } static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,
include/linux/pci.h +0 -1
@@ -388,7 +388,6 @@ struct pci_dev {can be generated */ unsigned int pme_poll:1; /* Poll device's PME status bit */ unsigned int pinned:1; /* Whether this dev is pinned */ - unsigned int config_rrs_sv:1; /* Config RRS software visibility */ unsigned int imm_ready:1; /* Supports Immediate Readiness */ unsigned int d1_support:1; /* Low power state D1 is supported */ unsigned int d2_support:1; /* Low power state D2 is supported */
Signature · 1 line
2.51.0
Quoted 10 lines · Hui Wang
Prior to commit
d591f6804e7e("PCI: Wait for device readiness with Configuration RRS"), this Intel nvme [8086:0a54] works well. Since that patch is merged to the kernel, this nvme stops working.Through debugging, we found that commit introduces the RRS polling in the
pci_dev_wait(), for this nvme, when polling thePCI_VENDOR_ID, it will return ~0 if the config access is not ready yet, but the polling expects a return value of0x0001or a validvendor_id, so the RRS polling doesn't work for this nvme.
Quoted 5 lines
Here we add a pci quirk to disable the RRS polling for the device.
Fixes d591f6804e7e ("PCI: Wait for device readiness with Configuration RRS")Signed-off-by Hui Wang <[email protected]>
To help keep this top of mind:
#regzbot introduced: d591f6804e7e ("PCI: Wait for device readiness with Configuration RRS")
Quoted 62 lines
--- drivers/pci/probe.c | 3 ++- drivers/pci/quirks.c | 18 ++++++++++++++++++ include/linux/pci.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-)drivers/pci/probe.c +2
-1@@ -1270,7 +1270,8 @@ static void pci_enable_rrs_sv(struct pci_dev *pdev)if (root_cap &PCI_EXP_RTCAP_RRS_SV ) {pcie_capability_set_word (pdev,PCI_EXP_RTCTL ,PCI_EXP_RTCTL_RRS_SVE ); - pdev->config_rrs_sv =1 ; +if (!(pdev->dev_flags &PCI_DEV_FLAGS_NO_RRS_SV )) + pdev->config_rrs_sv =1 ; } }drivers/pci/quirks.c +18
-0@@ -6336,3 +6336,21 @@ static void pci_mask_replay_timer_timeout(struct pci_dev *pdev)DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_GLI ,0x9750 , pci_mask_replay_timer_timeout);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_GLI ,0x9755 , pci_mask_replay_timer_timeout);#endif + +/* +* Although the root port device claims to support RRS, some devices don't work +* with RRS polling, when reading the Vendor ID, they just return ~0 if config +* access is not ready, this will break the pci_dev_wait(). Here disable the RRS +* forcibly for this type of device. +*/ +static void quirk_no_rrs_sv (struct pci_dev *dev) +{ +struct pci_dev *root; + + root =pcie_find_root_port (dev); +if (root) { + root->dev_flags |=PCI_DEV_FLAGS_NO_RRS_SV ; + root->config_rrs_sv =0 ; + } +} +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x0a54 , quirk_no_rrs_sv);include/linux/pci.h +2
-0@@ -247,6 +247,8 @@ enum pci_dev_flags {PCI_DEV_FLAGS_HAS_MSI_MASKING = (__force pci_dev_flags_t) (1 <<12 ),/* Device requires write to PCI_MSIX_ENTRY_DATA before any MSIX reads */ PCI_DEV_FLAGS_MSIX_TOUCH_ENTRY_DATA_FIRST = (__force pci_dev_flags_t) (1 <<13 ), +/* Do not use Configuration Request Retry Status polling in pci_dev_wait() */ + PCI_DEV_FLAGS_NO_RRS_SV = (__force pci_dev_flags_t) (1 << 14), }; enum pci_irq_reroute_variant {Signature · 1 line
2.34.1