Skip to content

Commit 92c45b6

Browse files
Mark Tomlinsonbjorn-helgaas
authored andcommitted
PCI: Reduce warnings on possible RW1C corruption
For hardware that only supports 32-bit writes to PCI there is the possibility of clearing RW1C (write-one-to-clear) bits. A rate-limited messages was introduced by fb26592, but rate-limiting is not the best choice here. Some devices may not show the warnings they should if another device has just produced a bunch of warnings. Also, the number of messages can be a nuisance on devices which are otherwise working fine. Change the ratelimit to a single warning per bus. This ensures no bus is 'starved' of emitting a warning and also that there isn't a continuous stream of warnings. It would be preferable to have a warning per device, but the pci_dev structure is not available here, and a lookup from devfn would be far too slow. Suggested-by: Bjorn Helgaas <helgaas@kernel.org> Fixes: fb26592 ("PCI: Warn on possible RW1C corruption for sub-32 bit config writes") Link: https://lore.kernel.org/r/20200806041455.11070-1-mark.tomlinson@alliedtelesis.co.nz Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Rob Herring <robh@kernel.org> Acked-by: Scott Branden <scott.branden@broadcom.com>
1 parent 3dc8a1f commit 92c45b6

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

drivers/pci/access.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,12 @@ int pci_generic_config_write32(struct pci_bus *bus, unsigned int devfn,
159159
* write happen to have any RW1C (write-one-to-clear) bits set, we
160160
* just inadvertently cleared something we shouldn't have.
161161
*/
162-
dev_warn_ratelimited(&bus->dev, "%d-byte config write to %04x:%02x:%02x.%d offset %#x may corrupt adjacent RW1C bits\n",
163-
size, pci_domain_nr(bus), bus->number,
164-
PCI_SLOT(devfn), PCI_FUNC(devfn), where);
162+
if (!bus->unsafe_warn) {
163+
dev_warn(&bus->dev, "%d-byte config write to %04x:%02x:%02x.%d offset %#x may corrupt adjacent RW1C bits\n",
164+
size, pci_domain_nr(bus), bus->number,
165+
PCI_SLOT(devfn), PCI_FUNC(devfn), where);
166+
bus->unsafe_warn = 1;
167+
}
165168

166169
mask = ~(((1 << (size * 8)) - 1) << ((where & 0x3) * 8));
167170
tmp = readl(addr) & mask;

include/linux/pci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ struct pci_bus {
668668
struct bin_attribute *legacy_io; /* Legacy I/O for this bus */
669669
struct bin_attribute *legacy_mem; /* Legacy mem */
670670
unsigned int is_added:1;
671+
unsigned int unsafe_warn:1; /* warned about RW1C config write */
671672
};
672673

673674
#define to_pci_bus(n) container_of(n, struct pci_bus, dev)

0 commit comments

Comments
 (0)