Re: [PATCH 05/12] PCI: add pci_swizzle_interrupt_pin()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 11 December 2008 10:34:52 am David Howells wrote:
> Bjorn Helgaas <bjorn.helgaas@xxxxxx> wrote:
> 
> > +/**
> > + * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge
> > + * @dev: the PCI device
> > + * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTD, 4=INTD)
> > + *
> > + * The PCI-to-PCI bridge specification requires INTx swizzling for
> > + * devices behind bridges on add-in cards.  This performs the swizzle
> > + * for one level of bridge.
> > + */
> 
> Better.
> 
> > +u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin)
> > +{
> > +	/* This implements Table 9-1 of the PCI-to-PCI bridge spec */
> 
> I'd recommend merging this comment into the banner.

OK.  How's this?  I suck at writing comments.

PCI: add pci_swizzle_interrupt_pin()

From: Bjorn Helgaas <bjorn.helgaas@xxxxxx>

This patch adds pci_swizzle_interrupt_pin(), which implements the
INTx swizzling algorithm specified in Table 9-1 of the "PCI-to-PCI
Bridge Architecture Specification," revision 1.2.

There are many architecture-specific implementations of this
swizzle that can be replaced by this common one.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@xxxxxx>
---
 drivers/pci/pci.c   |   16 +++++++++++++++-
 include/linux/pci.h |    1 +
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 46f6821..dfa26d1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1337,6 +1337,20 @@ void pci_enable_ari(struct pci_dev *dev)
 	bridge->ari_enabled = 1;
 }
 
+/**
+ * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge
+ * @dev: the PCI device
+ * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTD, 4=INTD)
+ *
+ * The PCI-to-PCI bridge specification, section 9.1, requires INTx swizzling
+ * for devices behind bridges on add-in cards.  This performs the swizzle
+ * for one level of bridge.
+ */
+u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin)
+{
+	return (((pin - 1) + PCI_SLOT(dev->devfn)) % 4) + 1;
+}
+
 int
 pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
 {
@@ -1347,7 +1361,7 @@ pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
 		return -1;
 
 	while (dev->bus->self) {
-		pin = (((pin - 1) + PCI_SLOT(dev->devfn)) % 4) + 1;
+		pin = pci_swizzle_interrupt_pin(dev, pin);
 		dev = dev->bus->self;
 	}
 	*bridge = dev;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index feb4657..4be596f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -527,6 +527,7 @@ int __must_check pci_bus_add_device(struct pci_dev *dev);
 void pci_read_bridge_bases(struct pci_bus *child);
 struct resource *pci_find_parent_resource(const struct pci_dev *dev,
 					  struct resource *res);
+u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin);
 int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
 extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
 extern void pci_dev_put(struct pci_dev *dev);
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux