linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: Enable PCIe AER only after checking firmware support
@ 2009-02-19 17:11 Andrew Patterson
  2009-02-20 21:52 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Patterson @ 2009-02-19 17:11 UTC (permalink / raw)
  To: linux-kernel, linux-pci; +Cc: andrew.patterson

PCI: Enable PCIe AER only after checking firmware support

The PCIe port driver currently sets the PCIe AER error reporting bits for
any root or switch port without first checking to see if firmware will grant
control. This patch moves setting these bits to the AER service driver
aer_enable_port routine.  The bits are then set for the root port and any
downstream switch ports after the check for firmware support (aer_osc_setup)
is made. The patch also unsets the bits in a similar fashion when the AER
service driver is unloaded.

Signed-off-by: Andrew Patterson <andrew.patterson@hp.com>
---

diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 872ea7d..2070830 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -108,6 +108,35 @@ int pci_cleanup_aer_correct_error_status(struct pci_dev *dev)
 }
 #endif  /*  0  */
 
+
+static void set_device_error_reporting(struct pci_dev *dev, void *data)
+{
+	bool enable = *((bool *)data);
+
+	if (dev->pcie_type != PCIE_RC_PORT &&
+	    dev->pcie_type != PCIE_SW_UPSTREAM_PORT &&
+	    dev->pcie_type != PCIE_SW_DOWNSTREAM_PORT)
+		return;
+
+	if (enable)
+		pci_enable_pcie_error_reporting(dev);
+	else
+		pci_disable_pcie_error_reporting(dev);
+}
+
+/**
+ * set_downstream_devices_error_reporting - enable/disable the error reporting
+ * bits on the root port and its downstream ports.
+ * @dev: pointer to root port's pci_dev data structure
+ * @enable: true = enable error reporting, false = disable error reporting.
+ */
+static void set_downstream_devices_error_reporting(struct pci_dev *dev,
+						   bool enable)
+{
+	set_device_error_reporting(dev, &enable);
+	pci_walk_bus(dev->subordinate, set_device_error_reporting, &enable);
+}
+
 static int find_device_iter(struct device *device, void *data)
 {
 	struct pci_dev *dev;
@@ -525,15 +554,11 @@ void aer_enable_rootport(struct aer_rpc *rpc)
 	pci_read_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, &reg32);
 	pci_write_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, reg32);
 
-	/* Enable Root Port device reporting error itself */
-	pci_read_config_word(pdev, pos+PCI_EXP_DEVCTL, &reg16);
-	reg16 = reg16 |
-		PCI_EXP_DEVCTL_CERE |
-		PCI_EXP_DEVCTL_NFERE |
-		PCI_EXP_DEVCTL_FERE |
-		PCI_EXP_DEVCTL_URRE;
-	pci_write_config_word(pdev, pos+PCI_EXP_DEVCTL,
-		reg16);
+	/*
+	 * Enable error reporting for the root port device and downstream port
+	 * devices.
+	 */
+	set_downstream_devices_error_reporting(pdev, true);
 
 	/* Enable Root Port's interrupt in response to error messages */
 	pci_write_config_dword(pdev,
@@ -553,6 +578,12 @@ static void disable_root_aer(struct aer_rpc *rpc)
 	u32 reg32;
 	int pos;
 
+	/*
+	 * Disable error reporting for the root port device and downstream port
+	 * devices.
+	 */
+	set_downstream_devices_error_reporting(pdev, false);
+
 	pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);
 	/* Disable Root's interrupt in response to error messages */
 	pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_COMMAND, 0);
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 32ab6dd..db8700b 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -87,8 +87,6 @@ static int __devinit pcie_portdrv_probe (struct pci_dev *dev,
 
 	pci_save_state(dev);
 
-	pci_enable_pcie_error_reporting(dev);
-
 	return 0;
 }
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] PCI: Enable PCIe AER only after checking firmware support
  2009-02-19 17:11 [PATCH] PCI: Enable PCIe AER only after checking firmware support Andrew Patterson
@ 2009-02-20 21:52 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2009-02-20 21:52 UTC (permalink / raw)
  To: Andrew Patterson; +Cc: linux-kernel, linux-pci, andrew.patterson

On Thu, 19 Feb 2009 10:11:07 -0700
Andrew Patterson <andrew.patterson@hp.com> wrote:

> PCI: Enable PCIe AER only after checking firmware support
> 
> The PCIe port driver currently sets the PCIe AER error reporting bits for
> any root or switch port without first checking to see if firmware will grant
> control. This patch moves setting these bits to the AER service driver
> aer_enable_port routine.  The bits are then set for the root port and any
> downstream switch ports after the check for firmware support (aer_osc_setup)
> is made. The patch also unsets the bits in a similar fashion when the AER
> service driver is unloaded.
> 
> ...
>
> +/**
> + * set_downstream_devices_error_reporting - enable/disable the error reporting
> + * bits on the root port and its downstream ports.

Alas, silly kerneldoc does not permit multi-line titles.  We're forced
to do this:

--- a/drivers/pci/pcie/aer/aerdrv_core.c~pci-enable-pcie-aer-only-after-checking-firmware-support-fix
+++ a/drivers/pci/pcie/aer/aerdrv_core.c
@@ -125,8 +125,7 @@ static void set_device_error_reporting(s
 }
 
 /**
- * set_downstream_devices_error_reporting - enable/disable the error reporting
- * bits on the root port and its downstream ports.
+ * set_downstream_devices_error_reporting - enable/disable the error reporting bits on the root port and its downstream ports.
  * @dev: pointer to root port's pci_dev data structure
  * @enable: true = enable error reporting, false = disable error reporting.
  */
_


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-20 21:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-19 17:11 [PATCH] PCI: Enable PCIe AER only after checking firmware support Andrew Patterson
2009-02-20 21:52 ` Andrew Morton

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).