PCI: Fix bus error reset when CONFIG_SYSFS not set
PATCH 1/1 PCI: Fix bus error reset when CONFIG_SYSFS not set
The pci slot component is not compiled if the kernel config does not set CONFIG_SYSFS, but a previous commit used a lock symbol from there without considering when it isn't defined.
This patch fixes that by moving the mutex definition to a context outside CONFIG_SYSFS. This also made it obvious the implementation missed going to the fallback when there were no bus slots, so this is also fixed.
--- drivers/pci/pci.c | 24 ++++++++++++++---------- drivers/pci/slot.c | 1 - 2 files changed, 14 insertions(+), 11 deletions(-)
drivers/pci/pci.c +14 -10
@@ -35,6 +35,8 @@#include <linux/aer.h> #include "pci.h" +DEFINE_MUTEX (pci_slot_mutex); +const char *pci_power_names[] = {"error" ,"D0" ,"D1" ,"D2" ,"D3hot" ,"D3cold" ,"unknown" , };
@@ -5201,21 +5203,23 @@ static int pci_bus_reset(struct pci_bus *bus, int probe)int pci_bus_error_reset (struct pci_dev *bridge) {struct pci_bus *bus = bridge->subordinate; +struct pci_slot *slot;if (!bus)return -ENOTTY ;mutex_lock (&pci_slot_mutex); -if (!list_empty (&bus->slots)) { -struct pci_slot *slot; - -list_for_each_entry (slot, &bus->slots, list) -if (pci_probe_reset_slot (slot)) - goto bus_reset; -list_for_each_entry (slot, &bus->slots, list) -if (pci_slot_reset (slot,0 )) - goto bus_reset; - } +if (list_empty (&bus->slots)) + goto bus_reset; + +list_for_each_entry (slot, &bus->slots, list) +if (pci_probe_reset_slot (slot)) + goto bus_reset; + +list_for_each_entry (slot, &bus->slots, list) +if (pci_slot_reset (slot,0 )) + goto bus_reset; +mutex_unlock (&pci_slot_mutex);return 0 ; bus_reset:
drivers/pci/slot.c +0 -1
@@ -14,7 +14,6 @@struct kset *pci_slots_kset;EXPORT_SYMBOL_GPL (pci_slots_kset); -DEFINE_MUTEX (pci_slot_mutex);static ssize_t pci_slot_attr_show (struct kobject *kobj,struct attribute *attr,char *buf)
Signature · 1 line
2.14.4
Quoted 11 lines · Keith Busch
The pci slot component is not compiled if the kernel config does not set
CONFIG_SYSFS, but a previous commit used a lock symbol from there without considering when it isn't defined.This patch fixes that by moving the mutex definition to a context outside
CONFIG_SYSFS. This also made it obvious the implementation missed going to the fallback when there were no bus slots, so this is also fixed.Fixes 131b0ca2c7b263fd ("PCI/ERR: Use slot reset if available")Reported-by Stephen Rothwell <[email protected]>Signed-off-by Keith Busch <[email protected]>
Folded into 131b0ca2c7b263fd ("PCI/ERR: Use slot reset if available") since it hasn't been merged upstream yet, thanks! This on pci/hotplug, headed for v4.20.
Quoted 67 lines
--- drivers/pci/pci.c | 24 ++++++++++++++---------- drivers/pci/slot.c | 1 - 2 files changed, 14 insertions(+), 11 deletions(-)drivers/pci/pci.c +14
-10@@ -35,6 +35,8 @@#include <linux/aer.h> #include "pci.h" +DEFINE_MUTEX (pci_slot_mutex); +const char *pci_power_names[] = {"error" ,"D0" ,"D1" ,"D2" ,"D3hot" ,"D3cold" ,"unknown" , };@@ -5201,21 +5203,23 @@ static int pci_bus_reset(struct pci_bus *bus, int probe)int pci_bus_error_reset (struct pci_dev *bridge) {struct pci_bus *bus = bridge->subordinate; +struct pci_slot *slot;if (!bus)return -ENOTTY ;mutex_lock (&pci_slot_mutex); -if (!list_empty (&bus->slots)) { -struct pci_slot *slot; - -list_for_each_entry (slot, &bus->slots, list) -if (pci_probe_reset_slot (slot)) - goto bus_reset; -list_for_each_entry (slot, &bus->slots, list) -if (pci_slot_reset (slot,0 )) - goto bus_reset; - } +if (list_empty (&bus->slots)) + goto bus_reset; + +list_for_each_entry (slot, &bus->slots, list) +if (pci_probe_reset_slot (slot)) + goto bus_reset; + +list_for_each_entry (slot, &bus->slots, list) +if (pci_slot_reset (slot,0 )) + goto bus_reset; +mutex_unlock (&pci_slot_mutex);return 0 ; bus_reset:drivers/pci/slot.c +0
-1@@ -14,7 +14,6 @@struct kset *pci_slots_kset;EXPORT_SYMBOL_GPL (pci_slots_kset); -DEFINE_MUTEX (pci_slot_mutex);static ssize_t pci_slot_attr_show (struct kobject *kobj,struct attribute *attr,char *buf)Signature · 1 line
2.14.4