Expanded PCI config space (against 2.6.3-rc4)
PATCH 1/1 Expanded PCI config space (against 2.6.3-rc4)
Patch against 2.6.3-rc4 for implementing expanded PCI configuration space.
- Enables MMCONFIG space on i386.
- Moves the acpi apic cruft into its own function on i386.
- Uses the extended SAL call on ia64.
- Makes the expanded config space available through sysfs & proc.
- Adds pci_find_ext_capability() to find extended capabilities.
- Adds definitions for some of the extended capabilities.
- Adds pci_cfg_space_size() to determine whether a given device supports expanded PCI config space.
- Now handles both Express and PCI-X 2 devices.
- Changes the PCI-X capability definitions to correspond to the spec. No current users in-tree.
Patch by Sundarapandian Durairaj and Matthew Wilcox
arch/i386/Kconfig +16 -6
@@ -1030,12 +1030,16 @@ config PCI_GOBIOS PCI-based systems don't have any BIOS at all. Linux can also try to detect the PCI hardware directly without using the BIOS. - With this option, you can specify how Linux should detect the PCI - devices. If you choose "BIOS", the BIOS will be used, if you choose - "Direct", the BIOS won't be used, and if you choose "Any", the - kernel will try the direct access method and falls back to the BIOS - if that doesn't work. If unsure, go with the default, which is - "Any". + With this option, you can specify how Linux should detect the + PCI devices. If you choose "BIOS", the BIOS will be used, + if you choose "Direct", the BIOS won't be used, and if you + choose "MMConfig", then PCI Express MMCONFIG will be used. + If you choose "Any", the kernel will try MMCONFIG, then the + direct access method and falls back to the BIOS if that doesn't + work. If unsure, go with the default, which is "Any". + +config PCI_GOMMCONFIG + bool "MMConfig" config PCI_GODIRECT bool "Direct"
@@ -1055,6 +1059,12 @@ config PCI_DIRECT depends on PCI && ((PCI_GODIRECT || PCI_GOANY) || X86_VISWS) default y +config PCI_MMCONFIG + bool + depends on PCI && (PCI_GOMMCONFIG || PCI_GOANY) + select ACPI_BOOT + default y + config PCI_USE_VECTOR bool "Vector-based interrupt indexing" depends on X86_LOCAL_APIC && X86_IO_APIC
arch/i386/kernel/acpi/boot.c +106 -63
215 lines not on this page · raw message
arch/i386/pci/Makefile +1 -0
@@ -1,6 +1,7 @@ obj-y := i386.o obj-$(CONFIG_PCI_BIOS) += pcbios.o +obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o obj-$(CONFIG_PCI_DIRECT) += direct.o pci-y := fixup.o
arch/i386/pci/common.c +8 -1
@@ -20,7 +20,8 @@extern void pcibios_sort (void );#endif -unsigned int pci_probe =PCI_PROBE_BIOS |PCI_PROBE_CONF1 |PCI_PROBE_CONF2 ; +unsigned int pci_probe =PCI_PROBE_BIOS |PCI_PROBE_CONF1 |PCI_PROBE_CONF2 | +PCI_PROBE_MMCONF ;int pcibios_last_bus =-1 ;struct pci_bus *pci_root_bus =NULL ;
@@ -198,6 +199,12 @@ char * __devinit pcibios_setup(char *streturn NULL ; }#endif +#ifdef CONFIG_PCI_MMCONFIG + else if (!strcmp(str, "nommconf")) { + pci_probe &= ~PCI_PROBE_MMCONF ; +return NULL ; + } +#endif else if (!strcmp(str, "noacpi")) {acpi_noirq_set ();return NULL ;
arch/i386/pci/mmconfig.c +109 -0
109 lines not on this page · raw message
arch/i386/pci/pci.h +3 -0
@@ -15,6 +15,9 @@#define PCI_PROBE_BIOS 0x0001#define PCI_PROBE_CONF1 0x0002#define PCI_PROBE_CONF2 0x0004 +#define PCI_PROBE_MMCONF 0x0008 +#define PCI_PROBE_MASK 0x000f +#define PCI_NO_SORT 0x0100#define PCI_BIOS_SORT 0x0200#define PCI_NO_CHECKS 0x0400
arch/ia64/pci/pci.c +17 -6
@@ -55,8 +55,11 @@ struct pci_fixup pcibios_fixups[1];#define PCI_SAL_ADDRESS (seg, bus, devfn, reg) \ ((u64)(seg << 24) | (u64)(bus << 16) | \ - (u64)(devfn << 8) | (u64)(reg)) + (u64)(devfn << 8) | (u64)(reg)), 0 +#define PCI_SAL_EXT_ADDRESS (seg, bus, devfn, reg) \ + ((u64)(seg << 28) | (u64)(bus << 20) | \ + (u64)(devfn << 12) | (u64)(reg)), 1static int pci_sal_read (int seg,int bus,int devfn,int reg,int len,u32 *value)
@@ -64,10 +67,14 @@ pci_sal_read (int seg, int bus, int devfint result =0 ;u64 data =0 ; -if (!value || (seg >255 ) || (bus >255 ) || (devfn >255 ) || (reg >255 )) +if (!value || (seg >65535 ) || (bus >255 ) || (devfn >255 ) || (reg >4095 ))return -EINVAL ; - result =ia64_sal_pci_config_read (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, &data); +if ((seg <256 ) && (reg <256 )) { + result =ia64_sal_pci_config_read (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, &data); + }else { + result =ia64_sal_pci_config_read (PCI_SAL_EXT_ADDRESS (seg, bus, devfn, reg), len, &data); + } *value = (u32 ) data;
@@ -77,13 +84,17 @@ pci_sal_read (int seg, int bus, int devfstatic int pci_sal_write (int seg,int bus,int devfn,int reg,int len,u32 value) { -if ((seg >255 ) || (bus >255 ) || (devfn >255 ) || (reg >255 )) +if ((seg >65535 ) || (bus >255 ) || (devfn >255 ) || (reg >4095 ))return -EINVAL ; -return ia64_sal_pci_config_write (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, value); +if ((seg <256 ) && (reg <256 )) { +return ia64_sal_pci_config_write (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, value); + }else { +return ia64_sal_pci_config_write (PCI_SAL_EXT_ADDRESS (seg, bus, devfn, reg), len, value); + } } -struct pci_raw_ops pci_sal_ops = { +static struct pci_raw_ops pci_sal_ops = { .read = pci_sal_read, .write = pci_sal_write };
drivers/acpi/tables.c +1 -0
@@ -58,6 +58,7 @@ static char *acpi_table_signatures[ACPI_ [ACPI_SSDT] = "SSDT", [ACPI_SPMI] = "SPMI", [ACPI_HPET] = "HPET", + [ACPI_MCFG] = "MCFG", };static char *mps_inti_flags_polarity[] = {"dfl" ,"high" ,"res" ,"low" };
drivers/pci/pci-sysfs.c +19 -5
@@ -71,7 +71,7 @@ pci_read_config(struct kobject *kobj, ch/* Several chips lock up trying to read undefined config space */ if (capable (CAP_SYS_ADMIN )) { - size =256 ; + size = dev->cfg_size; }else if (dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS ) { size =128 ; }
@@ -123,10 +123,10 @@ pci_write_config(struct kobject *kobj, cunsigned int size = count;loff_t init_off = off; -if (off >256 ) +if (off > dev->cfg_size)return 0 ; -if (off + count >256 ) { - size =256 - off; +if (off + count > dev->cfg_size) { + size = dev->cfg_size - off; count = size; }
@@ -167,6 +167,16 @@ static struct bin_attribute pci_config_a .write = pci_write_config, }; +static struct bin_attribute pcie_config_attr = { + .attr = { + .name ="config" , + .mode =S_IRUGO |S_IWUSR , + }, + .size =4096 , + .read = pci_read_config, + .write = pci_write_config, +}; +void pci_create_sysfs_dev_files (struct pci_dev *pdev) {struct device *dev = &pdev->dev;
@@ -179,7 +189,11 @@ void pci_create_sysfs_dev_files (structdevice_create_file (dev, &dev_attr_class);device_create_file (dev, &dev_attr_irq);device_create_file (dev, &dev_attr_resource); -sysfs_create_bin_file (&dev->kobj, &pci_config_attr); +if (pdev->cfg_size <4096 ) { +sysfs_create_bin_file (&dev->kobj, &pci_config_attr); + }else { +sysfs_create_bin_file (&dev->kobj, &pcie_config_attr); + }/* add platform-specific attributes */ pcibios_add_platform_entries (pdev);
drivers/pci/pci.c +50 -8
77 lines not on this page · raw message
drivers/pci/probe.c +28 -0
@@ -18,6 +18,8 @@#define CARDBUS_LATENCY_TIMER 176/* secondary latency timer */ #define CARDBUS_RESERVE_BUSNR 3 +#define PCI_CFG_SPACE_SIZE 256 +#define PCI_CFG_SPACE_EXP_SIZE 4096/* Ugh. Need to stop exporting this to modules. */ LIST_HEAD (pci_root_buses);
@@ -526,6 +528,31 @@ static void pci_release_dev(struct devickfree (pci_dev); } +/** +* pci_cfg_space_size - get the configuration space size of the PCI device. +* Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices +* have 4096 bytes. +*/ +static int pci_cfg_space_size (struct pci_dev *dev) +{ +int pos; + + pos =pci_find_capability (dev,PCI_CAP_ID_EXP ); +if (pos) +return PCI_CFG_SPACE_EXP_SIZE ; + + pos =pci_find_capability (dev,PCI_CAP_ID_PCIX ); +if (pos) { +u32 status; +pci_read_config_dword (dev, pos +PCI_X_STATUS , &status); + +if (status & (PCI_X_STATUS_266MHZ |PCI_X_STATUS_533MHZ )) +return PCI_CFG_SPACE_EXP_SIZE ; + } + +return PCI_CFG_SPACE_SIZE ; +} +/* * Read the config data for a PCI device, sanity-check it * and fill in the dev structure...
@@ -562,6 +589,7 @@ pci_scan_device(struct pci_bus *bus, int dev->multifunction = !!(hdr_type &0x80 ); dev->vendor = l &0xffff ; dev->device = (l >>16 ) &0xffff ; + dev->cfg_size =pci_cfg_space_size (dev);/* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer) set this higher, assuming the system even supports it. */
drivers/pci/proc.c +13 -13
@@ -16,16 +16,15 @@#include <asm/uaccess.h> #include <asm/byteorder.h> -#define PCI_CFG_SPACE_SIZE 256 -static int proc_initialized;/* = 0 */ static loff_t proc_bus_pci_lseek (struct file *file,loff_t off,int whence) {loff_t new =-1 ; +struct inode *inode = file->f_dentry->d_inode; -down (&file->f_dentry->d_inode->i_sem); +down (&inode->i_sem);switch (whence) {case 0 : new = off;
@@ -34,14 +33,14 @@ proc_bus_pci_lseek(struct file *file, lo new = file->f_pos + off;break ;case 2 : - new =PCI_CFG_SPACE_SIZE + off; + new = inode->i_size + off;break ; } -if (new <0 || new >PCI_CFG_SPACE_SIZE ) +if (new <0 || new > inode->i_size) new = -EINVAL ;else file->f_pos = new; -up (&file->f_dentry->d_inode->i_sem); +up (&inode->i_sem);return new; }
@@ -61,7 +60,7 @@ proc_bus_pci_read(struct file *file, cha*/ if (capable (CAP_SYS_ADMIN )) - size =PCI_CFG_SPACE_SIZE ; + size = dev->cfg_size;else if (dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS ) size =128 ;else
@@ -134,14 +133,15 @@ proc_bus_pci_write(struct file *file, coconst struct proc_dir_entry *dp =PDE (ino);struct pci_dev *dev = dp->data;int pos = *ppos; +int size = dev->cfg_size;int cnt; -if (pos >=PCI_CFG_SPACE_SIZE ) +if (pos >= size)return 0 ; -if (nbytes >=PCI_CFG_SPACE_SIZE ) - nbytes =PCI_CFG_SPACE_SIZE ; -if (pos + nbytes >PCI_CFG_SPACE_SIZE ) - nbytes =PCI_CFG_SPACE_SIZE - pos; +if (nbytes >= size) + nbytes = size; +if (pos + nbytes > size) + nbytes = size - pos; cnt = nbytes;if (!access_ok (VERIFY_READ , buf, cnt))
@@ -403,7 +403,7 @@ int pci_proc_attach_device(struct pci_dereturn -ENOMEM ; e->proc_fops = &proc_bus_pci_operations; e->data = dev; - e->size =PCI_CFG_SPACE_SIZE ; + e->size = dev->cfg_size;return 0 ; }
include/asm-i386/fixmap.h +3 -0
@@ -71,6 +71,9 @@ enum fixed_addresses { FIX_ACPI_BEGIN, FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1,#endif +#ifdef CONFIG_PCI_MMCONFIG + FIX_PCIE_MCFG, +#endif __end_of_permanent_fixed_addresses,/* temporary boot-time mappings, used before ioremap() is functional */ #define NR_FIX_BTMAPS 16
include/asm-ia64/sal.h +4 -4
@@ -741,10 +741,10 @@ ia64_sal_mc_set_params (u64 param_type,/* Read from PCI configuration space */ static inline s64 -ia64_sal_pci_config_read (u64 pci_config_addr,u64 size,u64 *value) +ia64_sal_pci_config_read (u64 pci_config_addr,int type,u64 size,u64 *value) {struct ia64_sal_retval isrv; -SAL_CALL (isrv,SAL_PCI_CONFIG_READ , pci_config_addr, size,0 ,0 ,0 ,0 ,0 ); +SAL_CALL (isrv,SAL_PCI_CONFIG_READ , pci_config_addr, size, type,0 ,0 ,0 ,0 );if (value) *value = isrv.v0;return isrv.status;
@@ -752,11 +752,11 @@ ia64_sal_pci_config_read (u64 pci_config/* Write to PCI configuration space */ static inline s64 -ia64_sal_pci_config_write (u64 pci_config_addr,u64 size,u64 value) +ia64_sal_pci_config_write (u64 pci_config_addr,int type,u64 size,u64 value) {struct ia64_sal_retval isrv;SAL_CALL (isrv,SAL_PCI_CONFIG_WRITE , pci_config_addr, size, value, -0 ,0 ,0 ,0 ); + type,0 ,0 ,0 );return isrv.status; }
include/linux/acpi.h +12 -0
@@ -317,6 +317,15 @@ struct acpi_table_ecdt {char ec_id[0 ]; } __attribute__ ((packed)); +/* PCI MMCONFIG */ + +struct acpi_table_mcfg { +struct acpi_table_header header; +u8 reserved[8 ]; +u32 base_address; +u32 base_reserved; +} __attribute__ ((packed)); +/* Table Handlers */ enum acpi_table_id {
@@ -338,6 +347,7 @@ enum acpi_table_id {ACPI_SSDT ,ACPI_SPMI ,ACPI_HPET , +ACPI_MCFG , ACPI_TABLE_COUNT };
@@ -369,6 +379,8 @@ void acpi_numa_arch_fixup(void);extern int acpi_mp_config; +extern u32 pci_mmcfg_base_addr; +#else /*!CONFIG_ACPI_BOOT*/ #define acpi_mp_config 0
include/linux/pci.h +58 -12
94 lines not on this page · raw message
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon the nation that is attacked, and every man will be glad of those conscience-soothing falsities, and will diligently study them, and refuse to examine any refutations of them; and thus he will by and by convince himself that the war is just, and will thank God for the better sleep he enjoys after this process of grotesque self-deception." -- Mark Twain
Updated for 2.6.3, and reinserted an ifdef I had thought was unnecessary.
Patch against 2.6.3 for implementing extended PCI configuration space.
- Enables MMCONFIG space on i386.
- Move the acpi apic cruft into its own function on i386.
- Uses the extended SAL call on ia64.
- Makes the extended config space available through sysfs & proc.
- Adds pci_find_ext_capability() to find extended capabilities.
- Adds definitions for some of the extended capabilities.
- Adds pci_cfg_space_size() to determine whether a given device supports extended PCI config space.
- Now handles both Express and PCI-X 2 devices.
- Changes the PCI-X capability definitions to correspond to the spec. No current users in-tree.
Patch by Sundarapandian Durairaj and Matthew Wilcox
arch/i386/Kconfig +16 -6
@@ -1030,12 +1030,16 @@ config PCI_GOBIOS PCI-based systems don't have any BIOS at all. Linux can also try to detect the PCI hardware directly without using the BIOS. - With this option, you can specify how Linux should detect the PCI - devices. If you choose "BIOS", the BIOS will be used, if you choose - "Direct", the BIOS won't be used, and if you choose "Any", the - kernel will try the direct access method and falls back to the BIOS - if that doesn't work. If unsure, go with the default, which is - "Any". + With this option, you can specify how Linux should detect the + PCI devices. If you choose "BIOS", the BIOS will be used, + if you choose "Direct", the BIOS won't be used, and if you + choose "MMConfig", then PCI Express MMCONFIG will be used. + If you choose "Any", the kernel will try MMCONFIG, then the + direct access method and falls back to the BIOS if that doesn't + work. If unsure, go with the default, which is "Any". + +config PCI_GOMMCONFIG + bool "MMConfig" config PCI_GODIRECT bool "Direct"
@@ -1055,6 +1059,12 @@ config PCI_DIRECT depends on PCI && ((PCI_GODIRECT || PCI_GOANY) || X86_VISWS) default y +config PCI_MMCONFIG + bool + depends on PCI && (PCI_GOMMCONFIG || PCI_GOANY) + select ACPI_BOOT + default y + config PCI_USE_VECTOR bool "Vector-based interrupt indexing" depends on X86_LOCAL_APIC && X86_IO_APIC
arch/i386/kernel/acpi/boot.c +106 -61
208 lines not on this page · raw message
arch/i386/pci/Makefile +1 -0
@@ -1,6 +1,7 @@ obj-y := i386.o obj-$(CONFIG_PCI_BIOS) += pcbios.o +obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o obj-$(CONFIG_PCI_DIRECT) += direct.o pci-y := fixup.o
arch/i386/pci/common.c +8 -1
@@ -20,7 +20,8 @@extern void pcibios_sort (void );#endif -unsigned int pci_probe =PCI_PROBE_BIOS |PCI_PROBE_CONF1 |PCI_PROBE_CONF2 ; +unsigned int pci_probe =PCI_PROBE_BIOS |PCI_PROBE_CONF1 |PCI_PROBE_CONF2 | +PCI_PROBE_MMCONF ;int pcibios_last_bus =-1 ;struct pci_bus *pci_root_bus =NULL ;
@@ -198,6 +199,12 @@ char * __devinit pcibios_setup(char *streturn NULL ; }#endif +#ifdef CONFIG_PCI_MMCONFIG + else if (!strcmp(str, "nommconf")) { + pci_probe &= ~PCI_PROBE_MMCONF ; +return NULL ; + } +#endif else if (!strcmp(str, "noacpi")) {acpi_noirq_set ();return NULL ;
arch/i386/pci/mmconfig.c +109 -0
109 lines not on this page · raw message
arch/i386/pci/pci.h +3 -0
@@ -15,6 +15,9 @@#define PCI_PROBE_BIOS 0x0001#define PCI_PROBE_CONF1 0x0002#define PCI_PROBE_CONF2 0x0004 +#define PCI_PROBE_MMCONF 0x0008 +#define PCI_PROBE_MASK 0x000f +#define PCI_NO_SORT 0x0100#define PCI_BIOS_SORT 0x0200#define PCI_NO_CHECKS 0x0400
arch/ia64/pci/pci.c +17 -6
@@ -55,8 +55,11 @@ struct pci_fixup pcibios_fixups[1];#define PCI_SAL_ADDRESS (seg, bus, devfn, reg) \ ((u64)(seg << 24) | (u64)(bus << 16) | \ - (u64)(devfn << 8) | (u64)(reg)) + (u64)(devfn << 8) | (u64)(reg)), 0 +#define PCI_SAL_EXT_ADDRESS (seg, bus, devfn, reg) \ + ((u64)(seg << 28) | (u64)(bus << 20) | \ + (u64)(devfn << 12) | (u64)(reg)), 1static int pci_sal_read (int seg,int bus,int devfn,int reg,int len,u32 *value)
@@ -64,10 +67,14 @@ pci_sal_read (int seg, int bus, int devfint result =0 ;u64 data =0 ; -if (!value || (seg >255 ) || (bus >255 ) || (devfn >255 ) || (reg >255 )) +if (!value || (seg >65535 ) || (bus >255 ) || (devfn >255 ) || (reg >4095 ))return -EINVAL ; - result =ia64_sal_pci_config_read (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, &data); +if ((seg <256 ) && (reg <256 )) { + result =ia64_sal_pci_config_read (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, &data); + }else { + result =ia64_sal_pci_config_read (PCI_SAL_EXT_ADDRESS (seg, bus, devfn, reg), len, &data); + } *value = (u32 ) data;
@@ -77,13 +84,17 @@ pci_sal_read (int seg, int bus, int devfstatic int pci_sal_write (int seg,int bus,int devfn,int reg,int len,u32 value) { -if ((seg >255 ) || (bus >255 ) || (devfn >255 ) || (reg >255 )) +if ((seg >65535 ) || (bus >255 ) || (devfn >255 ) || (reg >4095 ))return -EINVAL ; -return ia64_sal_pci_config_write (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, value); +if ((seg <256 ) && (reg <256 )) { +return ia64_sal_pci_config_write (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, value); + }else { +return ia64_sal_pci_config_write (PCI_SAL_EXT_ADDRESS (seg, bus, devfn, reg), len, value); + } } -struct pci_raw_ops pci_sal_ops = { +static struct pci_raw_ops pci_sal_ops = { .read = pci_sal_read, .write = pci_sal_write };
drivers/acpi/tables.c +1 -0
@@ -58,6 +58,7 @@ static char *acpi_table_signatures[ACPI_ [ACPI_SSDT] = "SSDT", [ACPI_SPMI] = "SPMI", [ACPI_HPET] = "HPET", + [ACPI_MCFG] = "MCFG", };static char *mps_inti_flags_polarity[] = {"dfl" ,"high" ,"res" ,"low" };
drivers/pci/pci-sysfs.c +19 -5
@@ -71,7 +71,7 @@ pci_read_config(struct kobject *kobj, ch/* Several chips lock up trying to read undefined config space */ if (capable (CAP_SYS_ADMIN )) { - size =256 ; + size = dev->cfg_size; }else if (dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS ) { size =128 ; }
@@ -123,10 +123,10 @@ pci_write_config(struct kobject *kobj, cunsigned int size = count;loff_t init_off = off; -if (off >256 ) +if (off > dev->cfg_size)return 0 ; -if (off + count >256 ) { - size =256 - off; +if (off + count > dev->cfg_size) { + size = dev->cfg_size - off; count = size; }
@@ -167,6 +167,16 @@ static struct bin_attribute pci_config_a .write = pci_write_config, }; +static struct bin_attribute pcie_config_attr = { + .attr = { + .name ="config" , + .mode =S_IRUGO |S_IWUSR , + }, + .size =4096 , + .read = pci_read_config, + .write = pci_write_config, +}; +void pci_create_sysfs_dev_files (struct pci_dev *pdev) {struct device *dev = &pdev->dev;
@@ -179,7 +189,11 @@ void pci_create_sysfs_dev_files (structdevice_create_file (dev, &dev_attr_class);device_create_file (dev, &dev_attr_irq);device_create_file (dev, &dev_attr_resource); -sysfs_create_bin_file (&dev->kobj, &pci_config_attr); +if (pdev->cfg_size <4096 ) { +sysfs_create_bin_file (&dev->kobj, &pci_config_attr); + }else { +sysfs_create_bin_file (&dev->kobj, &pcie_config_attr); + }/* add platform-specific attributes */ pcibios_add_platform_entries (pdev);
drivers/pci/pci.c +50 -8
77 lines not on this page · raw message
drivers/pci/probe.c +28 -0
@@ -18,6 +18,8 @@#define CARDBUS_LATENCY_TIMER 176/* secondary latency timer */ #define CARDBUS_RESERVE_BUSNR 3 +#define PCI_CFG_SPACE_SIZE 256 +#define PCI_CFG_SPACE_EXP_SIZE 4096/* Ugh. Need to stop exporting this to modules. */ LIST_HEAD (pci_root_buses);
@@ -526,6 +528,31 @@ static void pci_release_dev(struct devickfree (pci_dev); } +/** +* pci_cfg_space_size - get the configuration space size of the PCI device. +* Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices +* have 4096 bytes. +*/ +static int pci_cfg_space_size (struct pci_dev *dev) +{ +int pos; + + pos =pci_find_capability (dev,PCI_CAP_ID_EXP ); +if (pos) +return PCI_CFG_SPACE_EXP_SIZE ; + + pos =pci_find_capability (dev,PCI_CAP_ID_PCIX ); +if (pos) { +u32 status; +pci_read_config_dword (dev, pos +PCI_X_STATUS , &status); + +if (status & (PCI_X_STATUS_266MHZ |PCI_X_STATUS_533MHZ )) +return PCI_CFG_SPACE_EXP_SIZE ; + } + +return PCI_CFG_SPACE_SIZE ; +} +/* * Read the config data for a PCI device, sanity-check it * and fill in the dev structure...
@@ -562,6 +589,7 @@ pci_scan_device(struct pci_bus *bus, int dev->multifunction = !!(hdr_type &0x80 ); dev->vendor = l &0xffff ; dev->device = (l >>16 ) &0xffff ; + dev->cfg_size =pci_cfg_space_size (dev);/* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer) set this higher, assuming the system even supports it. */
drivers/pci/proc.c +13 -13
@@ -16,16 +16,15 @@#include <asm/uaccess.h> #include <asm/byteorder.h> -#define PCI_CFG_SPACE_SIZE 256 -static int proc_initialized;/* = 0 */ static loff_t proc_bus_pci_lseek (struct file *file,loff_t off,int whence) {loff_t new =-1 ; +struct inode *inode = file->f_dentry->d_inode; -down (&file->f_dentry->d_inode->i_sem); +down (&inode->i_sem);switch (whence) {case 0 : new = off;
@@ -34,14 +33,14 @@ proc_bus_pci_lseek(struct file *file, lo new = file->f_pos + off;break ;case 2 : - new =PCI_CFG_SPACE_SIZE + off; + new = inode->i_size + off;break ; } -if (new <0 || new >PCI_CFG_SPACE_SIZE ) +if (new <0 || new > inode->i_size) new = -EINVAL ;else file->f_pos = new; -up (&file->f_dentry->d_inode->i_sem); +up (&inode->i_sem);return new; }
@@ -61,7 +60,7 @@ proc_bus_pci_read(struct file *file, cha*/ if (capable (CAP_SYS_ADMIN )) - size =PCI_CFG_SPACE_SIZE ; + size = dev->cfg_size;else if (dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS ) size =128 ;else
@@ -134,14 +133,15 @@ proc_bus_pci_write(struct file *file, coconst struct proc_dir_entry *dp =PDE (ino);struct pci_dev *dev = dp->data;int pos = *ppos; +int size = dev->cfg_size;int cnt; -if (pos >=PCI_CFG_SPACE_SIZE ) +if (pos >= size)return 0 ; -if (nbytes >=PCI_CFG_SPACE_SIZE ) - nbytes =PCI_CFG_SPACE_SIZE ; -if (pos + nbytes >PCI_CFG_SPACE_SIZE ) - nbytes =PCI_CFG_SPACE_SIZE - pos; +if (nbytes >= size) + nbytes = size; +if (pos + nbytes > size) + nbytes = size - pos; cnt = nbytes;if (!access_ok (VERIFY_READ , buf, cnt))
@@ -403,7 +403,7 @@ int pci_proc_attach_device(struct pci_dereturn -ENOMEM ; e->proc_fops = &proc_bus_pci_operations; e->data = dev; - e->size =PCI_CFG_SPACE_SIZE ; + e->size = dev->cfg_size;return 0 ; }
include/asm-i386/fixmap.h +3 -0
@@ -71,6 +71,9 @@ enum fixed_addresses { FIX_ACPI_BEGIN, FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1,#endif +#ifdef CONFIG_PCI_MMCONFIG + FIX_PCIE_MCFG, +#endif __end_of_permanent_fixed_addresses,/* temporary boot-time mappings, used before ioremap() is functional */ #define NR_FIX_BTMAPS 16
include/asm-ia64/sal.h +4 -4
@@ -741,10 +741,10 @@ ia64_sal_mc_set_params (u64 param_type,/* Read from PCI configuration space */ static inline s64 -ia64_sal_pci_config_read (u64 pci_config_addr,u64 size,u64 *value) +ia64_sal_pci_config_read (u64 pci_config_addr,int type,u64 size,u64 *value) {struct ia64_sal_retval isrv; -SAL_CALL (isrv,SAL_PCI_CONFIG_READ , pci_config_addr, size,0 ,0 ,0 ,0 ,0 ); +SAL_CALL (isrv,SAL_PCI_CONFIG_READ , pci_config_addr, size, type,0 ,0 ,0 ,0 );if (value) *value = isrv.v0;return isrv.status;
@@ -752,11 +752,11 @@ ia64_sal_pci_config_read (u64 pci_config/* Write to PCI configuration space */ static inline s64 -ia64_sal_pci_config_write (u64 pci_config_addr,u64 size,u64 value) +ia64_sal_pci_config_write (u64 pci_config_addr,int type,u64 size,u64 value) {struct ia64_sal_retval isrv;SAL_CALL (isrv,SAL_PCI_CONFIG_WRITE , pci_config_addr, size, value, -0 ,0 ,0 ,0 ); + type,0 ,0 ,0 );return isrv.status; }
include/linux/acpi.h +12 -0
@@ -317,6 +317,15 @@ struct acpi_table_ecdt {char ec_id[0 ]; } __attribute__ ((packed)); +/* PCI MMCONFIG */ + +struct acpi_table_mcfg { +struct acpi_table_header header; +u8 reserved[8 ]; +u32 base_address; +u32 base_reserved; +} __attribute__ ((packed)); +/* Table Handlers */ enum acpi_table_id {
@@ -338,6 +347,7 @@ enum acpi_table_id {ACPI_SSDT ,ACPI_SPMI ,ACPI_HPET , +ACPI_MCFG , ACPI_TABLE_COUNT };
@@ -369,6 +379,8 @@ void acpi_numa_arch_fixup(void);extern int acpi_mp_config; +extern u32 pci_mmcfg_base_addr; +#else /*!CONFIG_ACPI_BOOT*/ #define acpi_mp_config 0
include/linux/pci.h +58 -12
94 lines not on this page · raw message
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon the nation that is attacked, and every man will be glad of those conscience-soothing falsities, and will diligently study them, and refuse to examine any refutations of them; and thus he will by and by convince himself that the war is just, and will thank God for the better sleep he enjoys after this process of grotesque self-deception." -- Mark Twain
Quoted 19 lines · Matthew Wilcox
Updated for 2.6.3, and reinserted an ifdef I had thought was unnecessary.
Patch against 2.6.3 for implementing extended PCI configuration space.
- Enables MMCONFIG space on i386.
- Move the acpi apic cruft into its own function on i386.
- Uses the extended SAL call on ia64.
- Makes the extended config space available through sysfs & proc.
- Addspci_find_ext_capability()to find extended capabilities.
- Adds definitions for some of the extended capabilities.
- Addspci_cfg_space_size()to determine whether a given device supports extended PCI config space.
- Now handles both Express and PCI-X 2 devices.
- Changes the PCI-X capability definitions to correspond to the spec. No current users in-tree.Patch by Sundarapandian Durairaj and Matthew Wilcox
[SNIP]
Quoted 44 lines
diff -urpNX build-tools/dontdiff
linus-2.6/arch/ia64/pci/pci.cpciexp-2.6/arch/ia64/pci/pci.carch/ia64/pci/pci.c +13
-5@@ -55,8 +55,11 @@ struct pci_fixup pcibios_fixups[1];#define PCI_SAL_ADDRESS (seg, bus, devfn, reg) \ ((u64)(seg << 24) | (u64)(bus << 16) | \ - (u64)(devfn << 8) | (u64)(reg)) + (u64)(devfn << 8) | (u64)(reg)), 0 +#define PCI_SAL_EXT_ADDRESS (seg, bus, devfn, reg) \ + ((u64)(seg << 28) | (u64)(bus << 20) | \ + (u64)(devfn << 12) | (u64)(reg)), 1static int pci_sal_read (int seg,int bus,int devfn,int reg,int len,u32 *value)@@ -64,10 +67,14 @@ pci_sal_read (int seg, int bus, int devfint result =0 ;u64 data =0 ; -if (!value || (seg >255 ) || (bus >255 ) || (devfn >255 ) || (reg >255 )) +if (!value || (seg >65535 ) || (bus >255 ) || (devfn >255 ) || (reg >4095 ))return -EINVAL ; - result =ia64_sal_pci_config_read (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, &data); +if ((seg <256 ) && (reg <256 )) { + result =ia64_sal_pci_config_read (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, &data); + }else { + result =ia64_sal_pci_config_read (PCI_SAL_EXT_ADDRESS (seg, bus, devfn, reg), len, &data); + } *value = (u32 ) data;@@ -77,13 +84,17 @@ pci_sal_read (int seg, int bus, int devfstatic int pci_sal_write (int seg,int bus,int devfn,int reg,int len,u32 value) { -if ((seg >255 ) || (bus >255 ) || (devfn >255 ) || (reg >255 )) +if ((seg >65535 ) || (bus >255 ) || (devfn >255 ) || (reg >4095 ))return -EINVAL ; -return ia64_sal_pci_config_write (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, value); +if ((seg <256 ) && (reg <256 )) { +return ia64_sal_pci_config_write (PCI_SAL_ADDRESS (seg, bus, devfn, reg), len, value);
arch/ia64/pci/pci.c pci_sal_read (int seg, int bus, int devf · line 100
Quoted 10 lines
arch/ia64/pci/pci.c +4
-1+ }else { +return ia64_sal_pci_config_write (PCI_SAL_EXT_ADDRESS (seg, bus, devfn, reg), len, value); + } } -struct pci_raw_ops pci_sal_ops = { +static struct pci_raw_ops pci_sal_ops = { .read = pci_sal_read, .write = pci_sal_write };
Having PCI_SAL_*ADDRESS() return 2 values is counter-intuituitive, since it looks like a normal function call. Just add the type flag to the ia64_sal_pci_config_* call directly.
--
Brian Gerst
Quoted 16 lines · Brian Gerst
Quoted 15 lines · Matthew Wilcox
arch/ia64/pci/pci.c +4
-1@@ -55,8 +55,11 @@ struct pci_fixup pcibios_fixups[1];#define PCI_SAL_ADDRESS (seg, bus, devfn, reg) \ ((u64)(seg << 24) | (u64)(bus << 16) | \ - (u64)(devfn << 8) | (u64)(reg)) + (u64)(devfn << 8) | (u64)(reg)), 0 +#define PCI_SAL_EXT_ADDRESS (seg, bus, devfn, reg) \ + ((u64)(seg << 28) | (u64)(bus << 20) | \ + (u64)(devfn << 12) | (u64)(reg)), 1static int
pci_sal_read(int seg, int bus, int devfn, int reg, int len, u32 *value)
Quoted 14 lines
Review
Quoted 10 lines
(quoted diff) +0
-1- result = ia64_sal_pci_config_read(PCI_SAL_ADDRESS(seg, bus, devfn,reg), len, &data);
(quoted diff) +2
-0+ if ((seg < 256) && (reg < 256)) { + result = ia64_sal_pci_config_read(PCI_SAL_ADDRESS(seg, bus,devfn, reg), len, &data);
(quoted diff) +2
-0+ } else { + result = ia64_sal_pci_config_read(PCI_SAL_EXT_ADDRESS(seg,bus, devfn, reg), len, &data);
(quoted diff) +1
-0+ }Having PCI_SAL_*ADDRESS() return 2 values is counter-intuituitive, since it looks like a normal function call. Just add the type flag to the ia64_sal_pci_config_* call directly.
um, it doesn't look like a normal function call. it looks like a macro because it's all in upper case. if this were in a header file or used more generally, i'd agree with you. but it's not, it's just a convenience macro used in 4 places in this one file.
besides, i got this wrong the first time, and combining it all into the one macro doesn't let me get it wrong.
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon the nation that is attacked, and every man will be glad of those conscience-soothing falsities, and will diligently study them, and refuse to examine any refutations of them; and thus he will by and by convince himself that the war is just, and will thank God for the better sleep he enjoys after this process of grotesque self-deception." -- Mark Twain