diff mbox series

PCI: Fix bus error reset when CONFIG_SYSFS not set

Message ID 20180926152326.14821-1-keith.busch@intel.com
State Accepted
Headers show
Series PCI: Fix bus error reset when CONFIG_SYSFS not set | expand

Commit Message

Keith Busch Sept. 26, 2018, 3:23 p.m. UTC
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 <sfr@canb.auug.org.au>
Signed-off-by: Keith Busch <keith.busch@intel.com>
---
 drivers/pci/pci.c  | 24 ++++++++++++++----------
 drivers/pci/slot.c |  1 -
 2 files changed, 14 insertions(+), 11 deletions(-)

Comments

Bjorn Helgaas Sept. 26, 2018, 7:24 p.m. UTC | #1
On Wed, Sep 26, 2018 at 09:23:26AM -0600, Keith Busch wrote:
> 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 <sfr@canb.auug.org.au>
> Signed-off-by: Keith Busch <keith.busch@intel.com>

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.

> ---
>  drivers/pci/pci.c  | 24 ++++++++++++++----------
>  drivers/pci/slot.c |  1 -
>  2 files changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 2b4117011313..f6104a551b60 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -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:
> diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
> index 3da03fcc6fbf..c46d5e1ff536 100644
> --- a/drivers/pci/slot.c
> +++ b/drivers/pci/slot.c
> @@ -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)
> -- 
> 2.14.4
>
diff mbox series

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2b4117011313..f6104a551b60 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -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:
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 3da03fcc6fbf..c46d5e1ff536 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -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)