From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Linux PCI <linux-pci@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/8] PCI PCIe portdrv: Aviod using service devices with wrong interrupts
Date: Sun, 4 Jan 2009 23:49:59 +0100 [thread overview]
Message-ID: <200901042350.00158.rjw@sisk.pl> (raw)
In-Reply-To: <200901042346.42723.rjw@sisk.pl>
From: Rafael J. Wysocki <rjw@sisk.pl>
The PCI Express port driver should not attempt to register service
devices that require the ability to generate interrupts if generating
interrupts is not possible. Namely, if the port has no interrupt pin
configured and we cannot set up MSI or MSI-X for it, there is no way
it can generate interrupts and in such a case the port services that
rely on interrupts (PME, PCIe HP, AER) should not be enabled for it.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
drivers/pci/pcie/portdrv_core.c | 40 +++++++++++++++++++++++++++-------------
include/linux/pcieport_if.h | 1 +
2 files changed, 28 insertions(+), 13 deletions(-)
Index: linux-2.6/include/linux/pcieport_if.h
===================================================================
--- linux-2.6.orig/include/linux/pcieport_if.h
+++ linux-2.6/include/linux/pcieport_if.h
@@ -22,6 +22,7 @@
#define PCIE_PORT_SERVICE_VC 8 /* Virtual Channel */
/* Root/Upstream/Downstream Port's Interrupt Mode */
+#define PCIE_PORT_NO_IRQ (-1)
#define PCIE_PORT_INTx_MODE 0
#define PCIE_PORT_MSI_MODE 1
#define PCIE_PORT_MSIX_MODE 2
Index: linux-2.6/drivers/pci/pcie/portdrv_core.c
===================================================================
--- linux-2.6.orig/drivers/pci/pcie/portdrv_core.c
+++ linux-2.6/drivers/pci/pcie/portdrv_core.c
@@ -41,13 +41,15 @@ static void release_pcie_device(struct d
static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask)
{
int i, pos, nvec, status = -EINVAL;
- int interrupt_mode = PCIE_PORT_INTx_MODE;
+ int interrupt_mode = PCIE_PORT_NO_IRQ;
/* Set INTx as default */
for (i = 0, nvec = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++) {
if (mask & (1 << i))
nvec++;
vectors[i] = dev->irq;
+ if (dev->pin)
+ interrupt_mode = PCIE_PORT_INTx_MODE;
}
/* Select MSI-X over MSI if supported */
@@ -137,7 +139,7 @@ static void pcie_device_init(struct pci_
dev->id.vendor = parent->vendor;
dev->id.device = parent->device;
dev->id.port_type = port_type;
- dev->id.service_type = (1 << service_type);
+ dev->id.service_type = service_type;
/* Initialize generic device interface */
device = &dev->device;
@@ -227,23 +229,35 @@ int pcie_port_device_register(struct pci
/* Allocate child services if any */
for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++) {
struct pcie_device *child;
+ int service = 1 << i;
+
+ if (!(capabilities & service))
+ continue;
- if (capabilities & (1 << i)) {
- child = alloc_pcie_device(
+ /*
+ * Don't use service devices that require interrupts if there is
+ * no way to generate them.
+ */
+ if (irq_mode == PCIE_PORT_NO_IRQ
+ && service != PCIE_PORT_SERVICE_VC)
+ continue;
+
+ child = alloc_pcie_device(
dev, /* parent */
type, /* port type */
- i, /* service type */
+ service, /* service type */
vectors[i], /* irq */
irq_mode /* interrupt mode */);
- if (child) {
- status = device_register(&child->device);
- if (status) {
- kfree(child);
- continue;
- }
- get_device(&child->device);
- }
+ if (!child)
+ continue;
+
+ status = device_register(&child->device);
+ if (status) {
+ kfree(child);
+ continue;
}
+
+ get_device(&child->device);
}
return 0;
}
next prev parent reply other threads:[~2009-01-04 23:02 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-04 22:46 [PATCH 0/8] PCI Express port driver fixes and cleanups Rafael J. Wysocki
2009-01-04 22:48 ` [PATCH 1/8] PCI PCIe portdrv: Remove root ports MSI quirk Rafael J. Wysocki
2009-01-09 23:12 ` Jesse Barnes
2009-01-09 23:18 ` Jesse Barnes
2009-01-09 23:33 ` Rafael J. Wysocki
2009-01-04 22:49 ` Rafael J. Wysocki [this message]
2009-01-09 23:23 ` [PATCH 2/8] PCI PCIe portdrv: Aviod using service devices with wrong interrupts Jesse Barnes
2009-01-04 22:51 ` [PATCH 3/8] PCI PCIe portdrv: Remove unused device extension Rafael J. Wysocki
2009-01-09 23:23 ` Jesse Barnes
2009-01-04 22:54 ` [PATCH 4/8] PCI PCIe portdrv: Do not enable port device before setting up interrupts Rafael J. Wysocki
2009-01-09 23:25 ` Jesse Barnes
2009-01-04 22:55 ` [PATCH 5/8] PCI PCIe portdrv: Fix allocation of interrupts Rafael J. Wysocki
2009-01-08 3:02 ` Kenji Kaneshige
2009-01-08 7:13 ` Rafael J. Wysocki
2009-01-08 8:20 ` Kenji Kaneshige
2009-01-08 16:53 ` Rafael J. Wysocki
2009-01-08 20:45 ` Rafael J. Wysocki
2009-01-09 23:33 ` Jesse Barnes
2009-01-09 23:38 ` Rafael J. Wysocki
2009-01-13 2:47 ` Kenji Kaneshige
2009-01-13 11:17 ` Rafael J. Wysocki
2009-01-14 6:08 ` Kenji Kaneshige
2009-01-14 10:35 ` Rafael J. Wysocki
2009-01-14 10:57 ` Rafael J. Wysocki
2009-01-15 6:24 ` Kenji Kaneshige
2009-01-15 7:38 ` Hidetoshi Seto
2009-01-15 10:31 ` Kenji Kaneshige
2009-01-15 16:42 ` Rafael J. Wysocki
2009-01-15 19:05 ` Rafael J. Wysocki
2009-01-15 19:10 ` Rafael J. Wysocki
2009-01-16 7:33 ` Hidetoshi Seto
2009-01-16 9:29 ` Rafael J. Wysocki
2009-01-17 0:20 ` Rafael J. Wysocki
2009-01-19 1:52 ` Hidetoshi Seto
2009-01-19 6:27 ` Kenji Kaneshige
2009-01-13 2:34 ` Kenji Kaneshige
2009-01-04 22:57 ` [PATCH 6/8] PCI PCIe portdrv: Remove unnecessary function Rafael J. Wysocki
2009-01-04 22:59 ` [PATCH 7/8] PCI PCIe portdrv: Simplily probe callback of service drivers Rafael J. Wysocki
2009-01-07 12:15 ` Rafael J. Wysocki
2009-01-04 23:01 ` [PATCH 8/8] PCI PCIe portdrv: Remove struct pcie_port_service_id Rafael J. Wysocki
2009-01-07 12:16 ` Rafael J. Wysocki
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=200901042350.00158.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.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
Powered by JetHome