* [PATCH 0/2] Infrastructure for Vendor-Specific extended capabilities
@ 2012-07-13 21:57 Bjorn Helgaas
2012-07-13 21:57 ` [PATCH 1/2] PCI: add pci_find_next_ext_capability() Bjorn Helgaas
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2012-07-13 21:57 UTC (permalink / raw)
To: linux-pci
This adds pci_find_next_ext_capability(), analogous to
pci_find_next_capability(), which allows drivers to iterate through
multiple capabilities of the same type.
Many devices include multiple Vendor-Specific extended capabilities, for
example:
00:00.0 Host bridge: Intel Corporation Sandy Bridge DMI2 (rev 06)
Capabilities: [100 v1] Vendor Specific Information: ID=0002 Rev=0 Len=00c <?>
Capabilities: [144 v1] Vendor Specific Information: ID=0004 Rev=1 Len=03c <?>
Capabilities: [1d0 v1] Vendor Specific Information: ID=0003 Rev=1 Len=00a <?>
Capabilities: [280 v1] Vendor Specific Information: ID=0004 Rev=2 Len=018 <?>
---
Bjorn Helgaas (2):
PCI: add pci_find_next_ext_capability()
PCI: add Vendor-Specific Extended Capability header info
drivers/pci/pci.c | 40 ++++++++++++++++++++++++++++++----------
include/linux/pci.h | 3 +--
include/linux/pci_regs.h | 6 ++++++
3 files changed, 37 insertions(+), 12 deletions(-)
--
Bjorn
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] PCI: add pci_find_next_ext_capability()
2012-07-13 21:57 [PATCH 0/2] Infrastructure for Vendor-Specific extended capabilities Bjorn Helgaas
@ 2012-07-13 21:57 ` Bjorn Helgaas
2012-07-13 21:57 ` [PATCH 2/2] PCI: add Vendor-Specific Extended Capability header info Bjorn Helgaas
2012-08-24 21:26 ` [PATCH 0/2] Infrastructure for Vendor-Specific extended capabilities Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2012-07-13 21:57 UTC (permalink / raw)
To: linux-pci
Some extended capabilities, e.g., the vendor-specific capability, can
occur several times. The existing pci_find_ext_capability() always finds
the first occurrence. This adds pci_find_next_ext_capability(), which can
iterate through all of them.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/pci.c | 40 ++++++++++++++++++++++++++++++----------
include/linux/pci.h | 3 +--
2 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 447e834..fa0aa94 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -278,20 +278,17 @@ int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
}
/**
- * pci_find_ext_capability - Find an extended capability
+ * pci_find_next_ext_capability - Find an extended capability
* @dev: PCI device to query
+ * @start: address at which to start looking (0 to start at beginning of list)
* @cap: capability code
*
- * Returns the address of the requested extended capability structure
+ * Returns the address of the next matching extended capability structure
* within the device's PCI configuration space or 0 if the device does
- * not support it. Possible values for @cap:
- *
- * %PCI_EXT_CAP_ID_ERR Advanced Error Reporting
- * %PCI_EXT_CAP_ID_VC Virtual Channel
- * %PCI_EXT_CAP_ID_DSN Device Serial Number
- * %PCI_EXT_CAP_ID_PWR Power Budgeting
+ * not support it. Some capabilities can occur several times, e.g., the
+ * vendor-specific capability, and this provides a way to find them all.
*/
-int pci_find_ext_capability(struct pci_dev *dev, int cap)
+int pci_find_next_ext_capability(struct pci_dev *dev, int start, int cap)
{
u32 header;
int ttl;
@@ -303,6 +300,9 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap)
if (dev->cfg_size <= PCI_CFG_SPACE_SIZE)
return 0;
+ if (start)
+ pos = start;
+
if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL)
return 0;
@@ -314,7 +314,7 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap)
return 0;
while (ttl-- > 0) {
- if (PCI_EXT_CAP_ID(header) == cap)
+ if (PCI_EXT_CAP_ID(header) == cap && pos != start)
return pos;
pos = PCI_EXT_CAP_NEXT(header);
@@ -327,6 +327,26 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap)
return 0;
}
+EXPORT_SYMBOL_GPL(pci_find_next_ext_capability);
+
+/**
+ * pci_find_ext_capability - Find an extended capability
+ * @dev: PCI device to query
+ * @cap: capability code
+ *
+ * Returns the address of the requested extended capability structure
+ * within the device's PCI configuration space or 0 if the device does
+ * not support it. Possible values for @cap:
+ *
+ * %PCI_EXT_CAP_ID_ERR Advanced Error Reporting
+ * %PCI_EXT_CAP_ID_VC Virtual Channel
+ * %PCI_EXT_CAP_ID_DSN Device Serial Number
+ * %PCI_EXT_CAP_ID_PWR Power Budgeting
+ */
+int pci_find_ext_capability(struct pci_dev *dev, int cap)
+{
+ return pci_find_next_ext_capability(dev, 0, cap);
+}
EXPORT_SYMBOL_GPL(pci_find_ext_capability);
/**
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d8c379d..39d2fe0 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -714,8 +714,7 @@ enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *dev);
int pci_find_capability(struct pci_dev *dev, int cap);
int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap);
int pci_find_ext_capability(struct pci_dev *dev, int cap);
-int pci_bus_find_ext_capability(struct pci_bus *bus, unsigned int devfn,
- int cap);
+int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap);
int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] PCI: add Vendor-Specific Extended Capability header info
2012-07-13 21:57 [PATCH 0/2] Infrastructure for Vendor-Specific extended capabilities Bjorn Helgaas
2012-07-13 21:57 ` [PATCH 1/2] PCI: add pci_find_next_ext_capability() Bjorn Helgaas
@ 2012-07-13 21:57 ` Bjorn Helgaas
2012-08-24 21:26 ` [PATCH 0/2] Infrastructure for Vendor-Specific extended capabilities Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2012-07-13 21:57 UTC (permalink / raw)
To: linux-pci
This adds the fields in the Vendor-Specific Header: ID, Rev, and Length.
There may be multiple Vendor-Specific capabilities, so drivers should use
the VSEC ID to identify the one of interest.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
include/linux/pci_regs.h | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
index 4b608f5..0f3e814 100644
--- a/include/linux/pci_regs.h
+++ b/include/linux/pci_regs.h
@@ -615,6 +615,12 @@
#define PCI_PWR_CAP 12 /* Capability */
#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */
+/* Vendor-Specific (VSEC, PCI_EXT_CAP_ID_VNDR) */
+#define PCI_VNDR_HEADER 4 /* Vendor-Specific Header */
+#define PCI_VNDR_HEADER_ID(x) ((x) & 0xffff)
+#define PCI_VNDR_HEADER_REV(x) (((x) >> 16) & 0xf)
+#define PCI_VNDR_HEADER_LEN(x) (((x) >> 20) & 0xfff)
+
/*
* Hypertransport sub capability types
*
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Infrastructure for Vendor-Specific extended capabilities
2012-07-13 21:57 [PATCH 0/2] Infrastructure for Vendor-Specific extended capabilities Bjorn Helgaas
2012-07-13 21:57 ` [PATCH 1/2] PCI: add pci_find_next_ext_capability() Bjorn Helgaas
2012-07-13 21:57 ` [PATCH 2/2] PCI: add Vendor-Specific Extended Capability header info Bjorn Helgaas
@ 2012-08-24 21:26 ` Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2012-08-24 21:26 UTC (permalink / raw)
To: linux-pci
On Fri, Jul 13, 2012 at 3:57 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> This adds pci_find_next_ext_capability(), analogous to
> pci_find_next_capability(), which allows drivers to iterate through
> multiple capabilities of the same type.
I applied these patches to my "next" branch.
> Many devices include multiple Vendor-Specific extended capabilities, for
> example:
>
> 00:00.0 Host bridge: Intel Corporation Sandy Bridge DMI2 (rev 06)
> Capabilities: [100 v1] Vendor Specific Information: ID=0002 Rev=0 Len=00c <?>
> Capabilities: [144 v1] Vendor Specific Information: ID=0004 Rev=1 Len=03c <?>
> Capabilities: [1d0 v1] Vendor Specific Information: ID=0003 Rev=1 Len=00a <?>
> Capabilities: [280 v1] Vendor Specific Information: ID=0004 Rev=2 Len=018 <?>
>
>
> ---
>
> Bjorn Helgaas (2):
> PCI: add pci_find_next_ext_capability()
> PCI: add Vendor-Specific Extended Capability header info
>
>
> drivers/pci/pci.c | 40 ++++++++++++++++++++++++++++++----------
> include/linux/pci.h | 3 +--
> include/linux/pci_regs.h | 6 ++++++
> 3 files changed, 37 insertions(+), 12 deletions(-)
>
> --
> Bjorn
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-08-24 21:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-13 21:57 [PATCH 0/2] Infrastructure for Vendor-Specific extended capabilities Bjorn Helgaas
2012-07-13 21:57 ` [PATCH 1/2] PCI: add pci_find_next_ext_capability() Bjorn Helgaas
2012-07-13 21:57 ` [PATCH 2/2] PCI: add Vendor-Specific Extended Capability header info Bjorn Helgaas
2012-08-24 21:26 ` [PATCH 0/2] Infrastructure for Vendor-Specific extended capabilities Bjorn Helgaas
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).