[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] move pci_find_ext_capability() into common PCI code
# HG changeset patch # User Jan Beulich <jbeulich@xxxxxxxx> # Date 1321978951 -3600 # Node ID 2b5c6fff0e5b51035656a4af8214c724defce17b # Parent b21b6c91c1f4f44523c0d401100a8cd9498fa514 move pci_find_ext_capability() into common PCI code There's nothing architecture specific about it. It requires, however, that x86-32's pci_conf_read32() tolerates register accesses above 255 (for consistency the adjustment is done to all pci_conf_readNN() functions). Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Keir Fraser <keir@xxxxxxx> --- diff -r b21b6c91c1f4 -r 2b5c6fff0e5b xen/arch/ia64/xen/pci.c --- a/xen/arch/ia64/xen/pci.c Tue Nov 22 16:19:48 2011 +0000 +++ b/xen/arch/ia64/xen/pci.c Tue Nov 22 17:22:31 2011 +0100 @@ -135,8 +135,3 @@ BUG_ON((seg > 65535) || (bus > 255) || (dev > 31) || (func > 7) || (reg > 255)); pci_sal_write(seg, bus, (dev<<3)|func, reg, 4, data); } - -int pci_find_ext_capability(int seg, int bus, int devfn, int cap) -{ - return 0; -} diff -r b21b6c91c1f4 -r 2b5c6fff0e5b xen/arch/x86/x86_32/pci.c --- a/xen/arch/x86/x86_32/pci.c Tue Nov 22 16:19:48 2011 +0000 +++ b/xen/arch/x86/x86_32/pci.c Tue Nov 22 17:22:31 2011 +0100 @@ -15,9 +15,9 @@ unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg) { - if ( seg ) + if ( seg || (reg > 255) ) return ~0; - BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255)); + BUG_ON((bus > 255) || (dev > 31) || (func > 7)); return pci_conf_read(PCI_CONF_ADDRESS(bus, dev, func, reg), reg & 3, 1); } @@ -25,9 +25,9 @@ unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg) { - if ( seg ) + if ( seg || (reg > 255) ) return ~0; - BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255)); + BUG_ON((bus > 255) || (dev > 31) || (func > 7)); return pci_conf_read(PCI_CONF_ADDRESS(bus, dev, func, reg), reg & 2, 2); } @@ -35,9 +35,9 @@ unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg) { - if ( seg ) + if ( seg || (reg > 255) ) return ~0; - BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255)); + BUG_ON((bus > 255) || (dev > 31) || (func > 7)); return pci_conf_read(PCI_CONF_ADDRESS(bus, dev, func, reg), 0, 4); } @@ -70,8 +70,3 @@ BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255)); pci_conf_write(PCI_CONF_ADDRESS(bus, dev, func, reg), 0, 4, data); } - -int pci_find_ext_capability(int seg, int bus, int devfn, int cap) -{ - return 0; -} diff -r b21b6c91c1f4 -r 2b5c6fff0e5b xen/arch/x86/x86_64/mmconfig-shared.c --- a/xen/arch/x86/x86_64/mmconfig-shared.c Tue Nov 22 16:19:48 2011 +0000 +++ b/xen/arch/x86/x86_64/mmconfig-shared.c Tue Nov 22 17:22:31 2011 +0100 @@ -450,43 +450,3 @@ return -ENODEV; } - -/** - * 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(int seg, int bus, int devfn, int cap) -{ - u32 header; - int ttl = 480; /* 3840 bytes, minimum 8 bytes per capability */ - int pos = 0x100; - - header = pci_conf_read32(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pos); - - /* - * If we have no capabilities, this is indicated by cap ID, - * cap version and next pointer all being 0. - */ - if ( (header == 0) || (header == -1) ) - return 0; - - while ( ttl-- > 0 ) { - if ( PCI_EXT_CAP_ID(header) == cap ) - return pos; - pos = PCI_EXT_CAP_NEXT(header); - if ( pos < 0x100 ) - break; - header = pci_conf_read32(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pos); - } - return 0; -} diff -r b21b6c91c1f4 -r 2b5c6fff0e5b xen/drivers/pci/pci.c --- a/xen/drivers/pci/pci.c Tue Nov 22 16:19:48 2011 +0000 +++ b/xen/drivers/pci/pci.c Tue Nov 22 17:22:31 2011 +0100 @@ -62,3 +62,43 @@ } return 0; } + +/** + * 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(int seg, int bus, int devfn, int cap) +{ + u32 header; + int ttl = 480; /* 3840 bytes, minimum 8 bytes per capability */ + int pos = 0x100; + + header = pci_conf_read32(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pos); + + /* + * If we have no capabilities, this is indicated by cap ID, + * cap version and next pointer all being 0. + */ + if ( (header == 0) || (header == -1) ) + return 0; + + while ( ttl-- > 0 ) { + if ( PCI_EXT_CAP_ID(header) == cap ) + return pos; + pos = PCI_EXT_CAP_NEXT(header); + if ( pos < 0x100 ) + break; + header = pci_conf_read32(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pos); + } + return 0; +} _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |