* [PATCH] PCI: Fix bus error reset when CONFIG_SYSFS not set
@ 2018-09-26 15:23 Keith Busch
2018-09-26 19:24 ` Bjorn Helgaas
0 siblings, 1 reply; 2+ messages in thread
From: Keith Busch @ 2018-09-26 15:23 UTC (permalink / raw)
To: Linux PCI, Bjorn Helgaas; +Cc: Stephen Rothwell, 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 <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(-)
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI: Fix bus error reset when CONFIG_SYSFS not set
2018-09-26 15:23 [PATCH] PCI: Fix bus error reset when CONFIG_SYSFS not set Keith Busch
@ 2018-09-26 19:24 ` Bjorn Helgaas
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2018-09-26 19:24 UTC (permalink / raw)
To: Keith Busch; +Cc: Linux PCI, Bjorn Helgaas, Stephen Rothwell
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-26 19:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-26 15:23 [PATCH] PCI: Fix bus error reset when CONFIG_SYSFS not set Keith Busch
2018-09-26 19:24 ` Bjorn Helgaas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.