Skip to content

Commit 3937fa8

Browse files
axiqiagregkh
authored andcommitted
PCI/AER: Clear only error bits in PCIe Device Status
commit a8aeea1 upstream. Currently, pcie_clear_device_status() clears the entire PCIe Device Status register (PCI_EXP_DEVSTA) by writing back the value read from the register, which affects not only the error status bits but also other writable bits. According to PCIe r7.0, sec 7.5.3.5, this register contains: - RW1C error status bits (CED, NFED, FED, URD at bits 0-3): These are the four error status bits that need to be cleared. - Read-only bits (AUXPD at bit 4, TRPND at bit 5): Writing to these has no effect. - Emergency Power Reduction Detected (bit 6): A RW1C non-error bit introduced in PCIe r5.0 (2019). This is currently the only writable non-error bit in the Device Status register. Unconditionally clearing this bit can interfere with other software components that rely on this power management indication. - Reserved bits (RsvdZ): These bits are required to be written as zero. Writing 1s to them (as the current implementation may do) violates the specification. To prevent unintended side effects, modify pcie_clear_device_status() to only write 1s to the four error status bits (CED, NFED, FED, URD), leaving the Emergency Power Reduction Detected bit and reserved bits unaffected. Fixes: ec752f5 ("PCI/AER: Clear device status bits during ERR_FATAL and ERR_NONFATAL") Suggested-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Reviewed-by: Lukas Wunner <lukas@wunner.de> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260211124624.49656-1-xueshuai@linux.alibaba.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b1e9f2d commit 3937fa8

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

drivers/pci/pci.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,10 +2426,9 @@ EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
24262426
#ifdef CONFIG_PCIEAER
24272427
void pcie_clear_device_status(struct pci_dev *dev)
24282428
{
2429-
u16 sta;
2430-
2431-
pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &sta);
2432-
pcie_capability_write_word(dev, PCI_EXP_DEVSTA, sta);
2429+
pcie_capability_write_word(dev, PCI_EXP_DEVSTA,
2430+
PCI_EXP_DEVSTA_CED | PCI_EXP_DEVSTA_NFED |
2431+
PCI_EXP_DEVSTA_FED | PCI_EXP_DEVSTA_URD);
24332432
}
24342433
#endif
24352434

0 commit comments

Comments
 (0)