From: Keith Busch <keith.busch@intel.com>
To: Linux PCI <linux-pci@vger.kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
Keith Busch <keith.busch@intel.com>
Subject: [PATCH] PCI: Fix bus error reset when CONFIG_SYSFS not set
Date: Wed, 26 Sep 2018 09:23:26 -0600 [thread overview]
Message-ID: <20180926152326.14821-1-keith.busch@intel.com> (raw)
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
next reply other threads:[~2018-09-26 15:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-26 15:23 Keith Busch [this message]
2018-09-26 19:24 ` [PATCH] PCI: Fix bus error reset when CONFIG_SYSFS not set Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180926152326.14821-1-keith.busch@intel.com \
--to=keith.busch@intel.com \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.