From: Prarit Bhargava <prarit@redhat.com>
To: linux-pci@vger.kernel.org
Cc: Prarit Bhargava <prarit@redhat.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Shyam Iyer <Shyam_Iyer@Dell.com>,
gregkh@linuxfoundation.org, ddutile@redhat.com
Subject: Re: [PATCH] pci, Add AER_panic sysfs file
Date: Fri, 18 May 2012 10:16:46 -0400 [thread overview]
Message-ID: <1337350606-32648-1-git-send-email-prarit@redhat.com> (raw)
In-Reply-To: <20120518045130.GA3281@kroah.com>
Bjorn, ... [v2] with missing Doc file.
P.
----8<----
Consider the following case
[ RP ]
|
|
+---------+-----------+
| | |
[H1] [H2] [X1]
where RP is a PCIE Root Port, H1 and H2 are devices with drivers that support
PCIE AER driver error handling (ie, they have pci_error_handlers defined in
the driver), and X1 is a device with a driver that does not support PCIE
AER driver error handling.
If the Root Port takes an error what currently happens is that the
bus resets and H1 & H2 call their slot_reset functions. X1 does nothing.
In some cases a user may not wish the system to continue because X1 is
an unhardened driver. In these cases, the system should not do a bus reset,
but rather the system should panic to avoid any further possible data
corruption.
This patch implements an AER_panic sysfs entry for each root port which
a user can modify. AER_panic = 1, means the system will panic on a
PCIE error which would have normally resulted in a secondary bus reset.
The default is AER_panic = 0.
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Shyam Iyer <Shyam_Iyer@Dell.com>
Cc: gregkh@linuxfoundation.org
Cc: ddutile@redhat.com
[v2]: added missing Documentation/ABI/testing/sysfs-bus-pci
---
Documentation/ABI/testing/sysfs-bus-pci | 10 +++++++
drivers/pci/pci-sysfs.c | 42 ++++++++++++++++++++++++++++++-
drivers/pci/pcie/aer/aerdrv.c | 3 ++
include/linux/pci.h | 1 +
4 files changed, 55 insertions(+), 1 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci
index 34f5110..e64d434 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci
+++ b/Documentation/ABI/testing/sysfs-bus-pci
@@ -210,3 +210,13 @@ Users:
firmware assigned instance number of the PCI
device that can help in understanding the firmware
intended order of the PCI device.
+
+What: /sys/bus/pci/devices/.../AER_panic
+Date: May 2012
+Contact: linux-pci@vger.kernel.org, Prarit Bhargava <prarit@redhat.com>
+Description:
+ This file is present for PCIe Root Ports only and changes the
+ behavior when an AER event targets the port.
+ This attribute can have two values. If the value is 0, this
+ PCIe bus will issue a bus reset on the secondary bus. If the
+ value is 1, the kernel will panic. The default value is 0.
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index a55e248..8c6d525 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1135,6 +1135,35 @@ static ssize_t reset_store(struct device *dev,
static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_store);
+static ssize_t AER_panic_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+
+ return sprintf(buf, "%d\n", pdev->rp_AER_panic);
+}
+
+static ssize_t AER_panic_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+ unsigned long val;
+
+ if (kstrtoul(buf, 0, &val) < 0)
+ return -EINVAL;
+
+ if ((val > 1) || (val < 0))
+ return -EINVAL;
+
+ pdev->rp_AER_panic = val;
+
+ return count;
+}
+
+static struct device_attribute rp_AER_panic_attr =
+ __ATTR(AER_panic, 0600, AER_panic_show, AER_panic_store);
+
static int pci_create_capabilities_sysfs(struct pci_dev *dev)
{
int retval;
@@ -1169,8 +1198,16 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev)
goto error;
dev->reset_fn = 1;
}
- return 0;
+ /* PCIE Root Port panic-on-AER allows a user to configure each root
+ * port to panic on an AER error instead of issuing a bus reset.
+ */
+ if (dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) {
+ retval = device_create_file(&dev->dev, &rp_AER_panic_attr);
+ if (retval)
+ goto error;
+ }
+ return 0;
error:
pcie_aspm_remove_sysfs_dev_files(dev);
if (dev->vpd && dev->vpd->attr) {
@@ -1279,6 +1316,9 @@ static void pci_remove_capabilities_sysfs(struct pci_dev *dev)
device_remove_file(&dev->dev, &reset_attr);
dev->reset_fn = 0;
}
+
+ if (dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT)
+ device_remove_file(&dev->dev, &rp_AER_panic_attr);
}
/**
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
index 58ad791..dd6b352 100644
--- a/drivers/pci/pcie/aer/aerdrv.c
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -346,6 +346,9 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
u32 reg32;
int pos;
+ if (dev->rp_AER_panic)
+ panic("%s: AER detected on Root Port", pci_name(dev));
+
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
/* Disable Root's interrupt in response to error messages */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e444f5b..a4e6a5a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -324,6 +324,7 @@ struct pci_dev {
unsigned int is_hotplug_bridge:1;
unsigned int __aer_firmware_first_valid:1;
unsigned int __aer_firmware_first:1;
+ unsigned int rp_AER_panic:1; /* if 1, panic on AER bus reset */
pci_dev_flags_t dev_flags;
atomic_t enable_cnt; /* pci_enable_device has been called */
--
1.7.1
next prev parent reply other threads:[~2012-05-18 14:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-17 17:04 [PATCH] pci, Add AER_panic sysfs file Prarit Bhargava
2012-05-17 17:29 ` Shyam_Iyer
2012-05-17 17:39 ` Prarit Bhargava
2012-05-17 17:51 ` Shyam_Iyer
[not found] ` <DBFB1B45AF80394ABD1C807E9F28D15707BC712175@BLRX7MCDC203.AMER.DELL.COM>
2012-05-17 18:00 ` Shyam_Iyer
2012-05-17 18:51 ` Don Dutile
2012-05-17 18:54 ` Prarit Bhargava
2012-05-17 19:11 ` Don Dutile
2012-05-17 22:16 ` Prarit Bhargava
2012-05-17 21:32 ` Betty Dall
2012-05-18 4:51 ` Greg KH
2012-05-18 10:26 ` Prarit Bhargava
2012-05-18 14:16 ` Prarit Bhargava [this message]
2012-05-18 15:47 ` Greg KH
2012-05-18 17:17 ` Prarit Bhargava
2012-05-18 18:13 ` Greg KH
2012-05-18 19:28 ` Prarit Bhargava
2012-05-18 23:19 ` Greg KH
2012-05-18 17:26 ` Prarit Bhargava
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=1337350606-32648-1-git-send-email-prarit@redhat.com \
--to=prarit@redhat.com \
--cc=Shyam_Iyer@Dell.com \
--cc=bhelgaas@google.com \
--cc=ddutile@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-pci@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).