diff options
57 files changed, 3099 insertions, 1127 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index e07c432c731f..9cf7b34f2db0 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -1496,6 +1496,9 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1496 | Use with caution as certain devices share | 1496 | Use with caution as certain devices share |
1497 | address decoders between ROMs and other | 1497 | address decoders between ROMs and other |
1498 | resources. | 1498 | resources. |
1499 | norom [X86-32,X86_64] Do not assign address space to | ||
1500 | expansion ROMs that do not already have | ||
1501 | BIOS assigned address ranges. | ||
1499 | irqmask=0xMMMM [X86-32] Set a bit mask of IRQs allowed to be | 1502 | irqmask=0xMMMM [X86-32] Set a bit mask of IRQs allowed to be |
1500 | assigned automatically to PCI devices. You can | 1503 | assigned automatically to PCI devices. You can |
1501 | make the kernel exclude IRQs of your ISA cards | 1504 | make the kernel exclude IRQs of your ISA cards |
diff --git a/MAINTAINERS b/MAINTAINERS index e3560df4608e..02a85ab7387d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -248,7 +248,7 @@ S: Supported | |||
248 | ACPI PCI HOTPLUG DRIVER | 248 | ACPI PCI HOTPLUG DRIVER |
249 | P: Kristen Carlson Accardi | 249 | P: Kristen Carlson Accardi |
250 | M: kristen.c.accardi@intel.com | 250 | M: kristen.c.accardi@intel.com |
251 | L: pcihpd-discuss@lists.sourceforge.net | 251 | L: linux-pci@vger.kernel.org |
252 | S: Supported | 252 | S: Supported |
253 | 253 | ||
254 | ACPI THERMAL DRIVER | 254 | ACPI THERMAL DRIVER |
@@ -1134,21 +1134,21 @@ COMPACTPCI HOTPLUG CORE | |||
1134 | P: Scott Murray | 1134 | P: Scott Murray |
1135 | M: scottm@somanetworks.com | 1135 | M: scottm@somanetworks.com |
1136 | M: scott@spiteful.org | 1136 | M: scott@spiteful.org |
1137 | L: pcihpd-discuss@lists.sourceforge.net | 1137 | L: linux-pci@vger.kernel.org |
1138 | S: Supported | 1138 | S: Supported |
1139 | 1139 | ||
1140 | COMPACTPCI HOTPLUG ZIATECH ZT5550 DRIVER | 1140 | COMPACTPCI HOTPLUG ZIATECH ZT5550 DRIVER |
1141 | P: Scott Murray | 1141 | P: Scott Murray |
1142 | M: scottm@somanetworks.com | 1142 | M: scottm@somanetworks.com |
1143 | M: scott@spiteful.org | 1143 | M: scott@spiteful.org |
1144 | L: pcihpd-discuss@lists.sourceforge.net | 1144 | L: linux-pci@vger.kernel.org |
1145 | S: Supported | 1145 | S: Supported |
1146 | 1146 | ||
1147 | COMPACTPCI HOTPLUG GENERIC DRIVER | 1147 | COMPACTPCI HOTPLUG GENERIC DRIVER |
1148 | P: Scott Murray | 1148 | P: Scott Murray |
1149 | M: scottm@somanetworks.com | 1149 | M: scottm@somanetworks.com |
1150 | M: scott@spiteful.org | 1150 | M: scott@spiteful.org |
1151 | L: pcihpd-discuss@lists.sourceforge.net | 1151 | L: linux-pci@vger.kernel.org |
1152 | S: Supported | 1152 | S: Supported |
1153 | 1153 | ||
1154 | COMPUTONE INTELLIPORT MULTIPORT CARD | 1154 | COMPUTONE INTELLIPORT MULTIPORT CARD |
@@ -3177,7 +3177,7 @@ S: Supported | |||
3177 | PCIE HOTPLUG DRIVER | 3177 | PCIE HOTPLUG DRIVER |
3178 | P: Kristen Carlson Accardi | 3178 | P: Kristen Carlson Accardi |
3179 | M: kristen.c.accardi@intel.com | 3179 | M: kristen.c.accardi@intel.com |
3180 | L: pcihpd-discuss@lists.sourceforge.net | 3180 | L: linux-pci@vger.kernel.org |
3181 | S: Supported | 3181 | S: Supported |
3182 | 3182 | ||
3183 | PCMCIA SUBSYSTEM | 3183 | PCMCIA SUBSYSTEM |
@@ -3808,7 +3808,7 @@ S: Maintained | |||
3808 | SHPC HOTPLUG DRIVER | 3808 | SHPC HOTPLUG DRIVER |
3809 | P: Kristen Carlson Accardi | 3809 | P: Kristen Carlson Accardi |
3810 | M: kristen.c.accardi@intel.com | 3810 | M: kristen.c.accardi@intel.com |
3811 | L: pcihpd-discuss@lists.sourceforge.net | 3811 | L: linux-pci@vger.kernel.org |
3812 | S: Supported | 3812 | S: Supported |
3813 | 3813 | ||
3814 | SECURE DIGITAL HOST CONTROLLER INTERFACE DRIVER | 3814 | SECURE DIGITAL HOST CONTROLLER INTERFACE DRIVER |
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c index bf9290e29013..c1735f61a2c0 100644 --- a/arch/x86/kernel/apm_32.c +++ b/arch/x86/kernel/apm_32.c | |||
@@ -1211,9 +1211,9 @@ static int suspend(int vetoable) | |||
1211 | if (err != APM_SUCCESS) | 1211 | if (err != APM_SUCCESS) |
1212 | apm_error("suspend", err); | 1212 | apm_error("suspend", err); |
1213 | err = (err == APM_SUCCESS) ? 0 : -EIO; | 1213 | err = (err == APM_SUCCESS) ? 0 : -EIO; |
1214 | device_power_up(); | 1214 | device_power_up(PMSG_RESUME); |
1215 | local_irq_enable(); | 1215 | local_irq_enable(); |
1216 | device_resume(); | 1216 | device_resume(PMSG_RESUME); |
1217 | queue_event(APM_NORMAL_RESUME, NULL); | 1217 | queue_event(APM_NORMAL_RESUME, NULL); |
1218 | spin_lock(&user_list_lock); | 1218 | spin_lock(&user_list_lock); |
1219 | for (as = user_list; as != NULL; as = as->next) { | 1219 | for (as = user_list; as != NULL; as = as->next) { |
@@ -1238,7 +1238,7 @@ static void standby(void) | |||
1238 | apm_error("standby", err); | 1238 | apm_error("standby", err); |
1239 | 1239 | ||
1240 | local_irq_disable(); | 1240 | local_irq_disable(); |
1241 | device_power_up(); | 1241 | device_power_up(PMSG_RESUME); |
1242 | local_irq_enable(); | 1242 | local_irq_enable(); |
1243 | } | 1243 | } |
1244 | 1244 | ||
@@ -1324,7 +1324,7 @@ static void check_events(void) | |||
1324 | ignore_bounce = 1; | 1324 | ignore_bounce = 1; |
1325 | if ((event != APM_NORMAL_RESUME) | 1325 | if ((event != APM_NORMAL_RESUME) |
1326 | || (ignore_normal_resume == 0)) { | 1326 | || (ignore_normal_resume == 0)) { |
1327 | device_resume(); | 1327 | device_resume(PMSG_RESUME); |
1328 | queue_event(event, NULL); | 1328 | queue_event(event, NULL); |
1329 | } | 1329 | } |
1330 | ignore_normal_resume = 0; | 1330 | ignore_normal_resume = 0; |
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c index 6dff1286ad8a..524b6850b2c0 100644 --- a/arch/x86/kernel/setup_64.c +++ b/arch/x86/kernel/setup_64.c | |||
@@ -361,6 +361,11 @@ void __init setup_arch(char **cmdline_p) | |||
361 | 361 | ||
362 | parse_early_param(); | 362 | parse_early_param(); |
363 | 363 | ||
364 | #ifdef CONFIG_PCI | ||
365 | if (pci_early_dump_regs) | ||
366 | early_dump_pci_devices(); | ||
367 | #endif | ||
368 | |||
364 | #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT | 369 | #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT |
365 | if (init_ohci1394_dma_early) | 370 | if (init_ohci1394_dma_early) |
366 | init_ohci1394_dma_on_all_controllers(); | 371 | init_ohci1394_dma_on_all_controllers(); |
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 6e64aaf00d1d..d19fd07bafd6 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c | |||
@@ -20,6 +20,7 @@ | |||
20 | unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | | 20 | unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | |
21 | PCI_PROBE_MMCONF; | 21 | PCI_PROBE_MMCONF; |
22 | 22 | ||
23 | unsigned int pci_early_dump_regs; | ||
23 | static int pci_bf_sort; | 24 | static int pci_bf_sort; |
24 | int pci_routeirq; | 25 | int pci_routeirq; |
25 | int pcibios_last_bus = -1; | 26 | int pcibios_last_bus = -1; |
@@ -121,6 +122,21 @@ void __init dmi_check_skip_isa_align(void) | |||
121 | dmi_check_system(can_skip_pciprobe_dmi_table); | 122 | dmi_check_system(can_skip_pciprobe_dmi_table); |
122 | } | 123 | } |
123 | 124 | ||
125 | static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev) | ||
126 | { | ||
127 | struct resource *rom_r = &dev->resource[PCI_ROM_RESOURCE]; | ||
128 | |||
129 | if (pci_probe & PCI_NOASSIGN_ROMS) { | ||
130 | if (rom_r->parent) | ||
131 | return; | ||
132 | if (rom_r->start) { | ||
133 | /* we deal with BIOS assigned ROM later */ | ||
134 | return; | ||
135 | } | ||
136 | rom_r->start = rom_r->end = rom_r->flags = 0; | ||
137 | } | ||
138 | } | ||
139 | |||
124 | /* | 140 | /* |
125 | * Called after each bus is probed, but before its children | 141 | * Called after each bus is probed, but before its children |
126 | * are examined. | 142 | * are examined. |
@@ -128,7 +144,11 @@ void __init dmi_check_skip_isa_align(void) | |||
128 | 144 | ||
129 | void __devinit pcibios_fixup_bus(struct pci_bus *b) | 145 | void __devinit pcibios_fixup_bus(struct pci_bus *b) |
130 | { | 146 | { |
147 | struct pci_dev *dev; | ||
148 | |||
131 | pci_read_bridge_bases(b); | 149 | pci_read_bridge_bases(b); |
150 | list_for_each_entry(dev, &b->devices, bus_list) | ||
151 | pcibios_fixup_device_resources(dev); | ||
132 | } | 152 | } |
133 | 153 | ||
134 | /* | 154 | /* |
@@ -483,12 +503,18 @@ char * __devinit pcibios_setup(char *str) | |||
483 | else if (!strcmp(str, "rom")) { | 503 | else if (!strcmp(str, "rom")) { |
484 | pci_probe |= PCI_ASSIGN_ROMS; | 504 | pci_probe |= PCI_ASSIGN_ROMS; |
485 | return NULL; | 505 | return NULL; |
506 | } else if (!strcmp(str, "norom")) { | ||
507 | pci_probe |= PCI_NOASSIGN_ROMS; | ||
508 | return NULL; | ||
486 | } else if (!strcmp(str, "assign-busses")) { | 509 | } else if (!strcmp(str, "assign-busses")) { |
487 | pci_probe |= PCI_ASSIGN_ALL_BUSSES; | 510 | pci_probe |= PCI_ASSIGN_ALL_BUSSES; |
488 | return NULL; | 511 | return NULL; |
489 | } else if (!strcmp(str, "use_crs")) { | 512 | } else if (!strcmp(str, "use_crs")) { |
490 | pci_probe |= PCI_USE__CRS; | 513 | pci_probe |= PCI_USE__CRS; |
491 | return NULL; | 514 | return NULL; |
515 | } else if (!strcmp(str, "earlydump")) { | ||
516 | pci_early_dump_regs = 1; | ||
517 | return NULL; | ||
492 | } else if (!strcmp(str, "routeirq")) { | 518 | } else if (!strcmp(str, "routeirq")) { |
493 | pci_routeirq = 1; | 519 | pci_routeirq = 1; |
494 | return NULL; | 520 | return NULL; |
diff --git a/arch/x86/pci/early.c b/arch/x86/pci/early.c index 42df4b6606df..858dbe3399f9 100644 --- a/arch/x86/pci/early.c +++ b/arch/x86/pci/early.c | |||
@@ -49,7 +49,14 @@ void write_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset, u8 val) | |||
49 | { | 49 | { |
50 | PDprintk("%x writing to %x: %x\n", slot, offset, val); | 50 | PDprintk("%x writing to %x: %x\n", slot, offset, val); |
51 | outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8); | 51 | outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8); |
52 | outb(val, 0xcfc); | 52 | outb(val, 0xcfc + (offset&3)); |
53 | } | ||
54 | |||
55 | void write_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset, u16 val) | ||
56 | { | ||
57 | PDprintk("%x writing to %x: %x\n", slot, offset, val); | ||
58 | outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8); | ||
59 | outw(val, 0xcfc + (offset&2)); | ||
53 | } | 60 | } |
54 | 61 | ||
55 | int early_pci_allowed(void) | 62 | int early_pci_allowed(void) |
@@ -57,3 +64,54 @@ int early_pci_allowed(void) | |||
57 | return (pci_probe & (PCI_PROBE_CONF1|PCI_PROBE_NOEARLY)) == | 64 | return (pci_probe & (PCI_PROBE_CONF1|PCI_PROBE_NOEARLY)) == |
58 | PCI_PROBE_CONF1; | 65 | PCI_PROBE_CONF1; |
59 | } | 66 | } |
67 | |||
68 | void early_dump_pci_device(u8 bus, u8 slot, u8 func) | ||
69 | { | ||
70 | int i; | ||
71 | int j; | ||
72 | u32 val; | ||
73 | |||
74 | printk("PCI: %02x:%02x:%02x", bus, slot, func); | ||
75 | |||
76 | for (i = 0; i < 256; i += 4) { | ||
77 | if (!(i & 0x0f)) | ||
78 | printk("\n%04x:",i); | ||
79 | |||
80 | val = read_pci_config(bus, slot, func, i); | ||
81 | for (j = 0; j < 4; j++) { | ||
82 | printk(" %02x", val & 0xff); | ||
83 | val >>= 8; | ||
84 | } | ||
85 | } | ||
86 | printk("\n"); | ||
87 | } | ||
88 | |||
89 | void early_dump_pci_devices(void) | ||
90 | { | ||
91 | unsigned bus, slot, func; | ||
92 | |||
93 | if (!early_pci_allowed()) | ||
94 | return; | ||
95 | |||
96 | for (bus = 0; bus < 256; bus++) { | ||
97 | for (slot = 0; slot < 32; slot++) { | ||
98 | for (func = 0; func < 8; func++) { | ||
99 | u32 class; | ||
100 | u8 type; | ||
101 | class = read_pci_config(bus, slot, func, | ||
102 | PCI_CLASS_REVISION); | ||
103 | if (class == 0xffffffff) | ||
104 | break; | ||
105 | |||
106 | early_dump_pci_device(bus, slot, func); | ||
107 | |||
108 | /* No multi-function device? */ | ||
109 | type = read_pci_config_byte(bus, slot, func, | ||
110 | PCI_HEADER_TYPE); | ||
111 | if (!(type & 0x80)) | ||
112 | break; | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | |||
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c index ca8df9c260bc..c422e10337be 100644 --- a/arch/x86/pci/irq.c +++ b/arch/x86/pci/irq.c | |||
@@ -11,8 +11,8 @@ | |||
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/interrupt.h> | 12 | #include <linux/interrupt.h> |
13 | #include <linux/dmi.h> | 13 | #include <linux/dmi.h> |
14 | #include <asm/io.h> | 14 | #include <linux/io.h> |
15 | #include <asm/smp.h> | 15 | #include <linux/smp.h> |
16 | #include <asm/io_apic.h> | 16 | #include <asm/io_apic.h> |
17 | #include <linux/irq.h> | 17 | #include <linux/irq.h> |
18 | #include <linux/acpi.h> | 18 | #include <linux/acpi.h> |
@@ -45,7 +45,8 @@ struct irq_router { | |||
45 | char *name; | 45 | char *name; |
46 | u16 vendor, device; | 46 | u16 vendor, device; |
47 | int (*get)(struct pci_dev *router, struct pci_dev *dev, int pirq); | 47 | int (*get)(struct pci_dev *router, struct pci_dev *dev, int pirq); |
48 | int (*set)(struct pci_dev *router, struct pci_dev *dev, int pirq, int new); | 48 | int (*set)(struct pci_dev *router, struct pci_dev *dev, int pirq, |
49 | int new); | ||
49 | }; | 50 | }; |
50 | 51 | ||
51 | struct irq_router_handler { | 52 | struct irq_router_handler { |
@@ -61,7 +62,7 @@ void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL; | |||
61 | * and perform checksum verification. | 62 | * and perform checksum verification. |
62 | */ | 63 | */ |
63 | 64 | ||
64 | static inline struct irq_routing_table * pirq_check_routing_table(u8 *addr) | 65 | static inline struct irq_routing_table *pirq_check_routing_table(u8 *addr) |
65 | { | 66 | { |
66 | struct irq_routing_table *rt; | 67 | struct irq_routing_table *rt; |
67 | int i; | 68 | int i; |
@@ -74,10 +75,11 @@ static inline struct irq_routing_table * pirq_check_routing_table(u8 *addr) | |||
74 | rt->size < sizeof(struct irq_routing_table)) | 75 | rt->size < sizeof(struct irq_routing_table)) |
75 | return NULL; | 76 | return NULL; |
76 | sum = 0; | 77 | sum = 0; |
77 | for (i=0; i < rt->size; i++) | 78 | for (i = 0; i < rt->size; i++) |
78 | sum += addr[i]; | 79 | sum += addr[i]; |
79 | if (!sum) { | 80 | if (!sum) { |
80 | DBG(KERN_DEBUG "PCI: Interrupt Routing Table found at 0x%p\n", rt); | 81 | DBG(KERN_DEBUG "PCI: Interrupt Routing Table found at 0x%p\n", |
82 | rt); | ||
81 | return rt; | 83 | return rt; |
82 | } | 84 | } |
83 | return NULL; | 85 | return NULL; |
@@ -100,7 +102,8 @@ static struct irq_routing_table * __init pirq_find_routing_table(void) | |||
100 | return rt; | 102 | return rt; |
101 | printk(KERN_WARNING "PCI: PIRQ table NOT found at pirqaddr\n"); | 103 | printk(KERN_WARNING "PCI: PIRQ table NOT found at pirqaddr\n"); |
102 | } | 104 | } |
103 | for(addr = (u8 *) __va(0xf0000); addr < (u8 *) __va(0x100000); addr += 16) { | 105 | for (addr = (u8 *) __va(0xf0000); addr < (u8 *) __va(0x100000); |
106 | addr += 16) { | ||
104 | rt = pirq_check_routing_table(addr); | 107 | rt = pirq_check_routing_table(addr); |
105 | if (rt) | 108 | if (rt) |
106 | return rt; | 109 | return rt; |
@@ -122,20 +125,23 @@ static void __init pirq_peer_trick(void) | |||
122 | struct irq_info *e; | 125 | struct irq_info *e; |
123 | 126 | ||
124 | memset(busmap, 0, sizeof(busmap)); | 127 | memset(busmap, 0, sizeof(busmap)); |
125 | for(i=0; i < (rt->size - sizeof(struct irq_routing_table)) / sizeof(struct irq_info); i++) { | 128 | for (i = 0; i < (rt->size - sizeof(struct irq_routing_table)) / |
129 | sizeof(struct irq_info); i++) { | ||
126 | e = &rt->slots[i]; | 130 | e = &rt->slots[i]; |
127 | #ifdef DEBUG | 131 | #ifdef DEBUG |
128 | { | 132 | { |
129 | int j; | 133 | int j; |
130 | DBG(KERN_DEBUG "%02x:%02x slot=%02x", e->bus, e->devfn/8, e->slot); | 134 | DBG(KERN_DEBUG "%02x:%02x slot=%02x", e->bus, |
131 | for(j=0; j<4; j++) | 135 | e->devfn/8, e->slot); |
132 | DBG(" %d:%02x/%04x", j, e->irq[j].link, e->irq[j].bitmap); | 136 | for (j = 0; j < 4; j++) |
137 | DBG(" %d:%02x/%04x", j, e->irq[j].link, | ||
138 | e->irq[j].bitmap); | ||
133 | DBG("\n"); | 139 | DBG("\n"); |
134 | } | 140 | } |
135 | #endif | 141 | #endif |
136 | busmap[e->bus] = 1; | 142 | busmap[e->bus] = 1; |
137 | } | 143 | } |
138 | for(i = 1; i < 256; i++) { | 144 | for (i = 1; i < 256; i++) { |
139 | int node; | 145 | int node; |
140 | if (!busmap[i] || pci_find_bus(0, i)) | 146 | if (!busmap[i] || pci_find_bus(0, i)) |
141 | continue; | 147 | continue; |
@@ -174,7 +180,8 @@ void eisa_set_level_irq(unsigned int irq) | |||
174 | * Common IRQ routing practice: nibbles in config space, | 180 | * Common IRQ routing practice: nibbles in config space, |
175 | * offset by some magic constant. | 181 | * offset by some magic constant. |
176 | */ | 182 | */ |
177 | static unsigned int read_config_nybble(struct pci_dev *router, unsigned offset, unsigned nr) | 183 | static unsigned int |
184 | read_config_nybble(struct pci_dev *router, unsigned offset, unsigned nr) | ||
178 | { | 185 | { |
179 | u8 x; | 186 | u8 x; |
180 | unsigned reg = offset + (nr >> 1); | 187 | unsigned reg = offset + (nr >> 1); |
@@ -183,7 +190,8 @@ static unsigned int read_config_nybble(struct pci_dev *router, unsigned offset, | |||
183 | return (nr & 1) ? (x >> 4) : (x & 0xf); | 190 | return (nr & 1) ? (x >> 4) : (x & 0xf); |
184 | } | 191 | } |
185 | 192 | ||
186 | static void write_config_nybble(struct pci_dev *router, unsigned offset, unsigned nr, unsigned int val) | 193 | static void write_config_nybble(struct pci_dev *router, unsigned offset, |
194 | unsigned nr, unsigned int val) | ||
187 | { | 195 | { |
188 | u8 x; | 196 | u8 x; |
189 | unsigned reg = offset + (nr >> 1); | 197 | unsigned reg = offset + (nr >> 1); |
@@ -200,15 +208,18 @@ static void write_config_nybble(struct pci_dev *router, unsigned offset, unsigne | |||
200 | */ | 208 | */ |
201 | static int pirq_ali_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | 209 | static int pirq_ali_get(struct pci_dev *router, struct pci_dev *dev, int pirq) |
202 | { | 210 | { |
203 | static const unsigned char irqmap[16] = { 0, 9, 3, 10, 4, 5, 7, 6, 1, 11, 0, 12, 0, 14, 0, 15 }; | 211 | static const unsigned char irqmap[16] = { 0, 9, 3, 10, 4, 5, 7, 6, 1, |
212 | 11, 0, 12, 0, 14, 0, 15 }; | ||
204 | 213 | ||
205 | WARN_ON_ONCE(pirq > 16); | 214 | WARN_ON_ONCE(pirq > 16); |
206 | return irqmap[read_config_nybble(router, 0x48, pirq-1)]; | 215 | return irqmap[read_config_nybble(router, 0x48, pirq-1)]; |
207 | } | 216 | } |
208 | 217 | ||
209 | static int pirq_ali_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 218 | static int |
219 | pirq_ali_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | ||
210 | { | 220 | { |
211 | static const unsigned char irqmap[16] = { 0, 8, 0, 2, 4, 5, 7, 6, 0, 1, 3, 9, 11, 0, 13, 15 }; | 221 | static const unsigned char irqmap[16] = { 0, 8, 0, 2, 4, 5, 7, 6, 0, 1, |
222 | 3, 9, 11, 0, 13, 15 }; | ||
212 | unsigned int val = irqmap[irq]; | 223 | unsigned int val = irqmap[irq]; |
213 | 224 | ||
214 | WARN_ON_ONCE(pirq > 16); | 225 | WARN_ON_ONCE(pirq > 16); |
@@ -231,7 +242,8 @@ static int pirq_piix_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | |||
231 | return (x < 16) ? x : 0; | 242 | return (x < 16) ? x : 0; |
232 | } | 243 | } |
233 | 244 | ||
234 | static int pirq_piix_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 245 | static int |
246 | pirq_piix_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | ||
235 | { | 247 | { |
236 | pci_write_config_byte(router, pirq, irq); | 248 | pci_write_config_byte(router, pirq, irq); |
237 | return 1; | 249 | return 1; |
@@ -247,7 +259,8 @@ static int pirq_via_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | |||
247 | return read_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq); | 259 | return read_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq); |
248 | } | 260 | } |
249 | 261 | ||
250 | static int pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 262 | static int |
263 | pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | ||
251 | { | 264 | { |
252 | write_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq, irq); | 265 | write_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq, irq); |
253 | return 1; | 266 | return 1; |
@@ -258,7 +271,8 @@ static int pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, i | |||
258 | * but without the ugly irq number munging. | 271 | * but without the ugly irq number munging. |
259 | * However, for 82C586, nibble map is different . | 272 | * However, for 82C586, nibble map is different . |
260 | */ | 273 | */ |
261 | static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | 274 | static int |
275 | pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | ||
262 | { | 276 | { |
263 | static const unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 }; | 277 | static const unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 }; |
264 | 278 | ||
@@ -266,7 +280,8 @@ static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq | |||
266 | return read_config_nybble(router, 0x55, pirqmap[pirq-1]); | 280 | return read_config_nybble(router, 0x55, pirqmap[pirq-1]); |
267 | } | 281 | } |
268 | 282 | ||
269 | static int pirq_via586_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 283 | static int |
284 | pirq_via586_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | ||
270 | { | 285 | { |
271 | static const unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 }; | 286 | static const unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 }; |
272 | 287 | ||
@@ -285,10 +300,11 @@ static int pirq_ite_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | |||
285 | static const unsigned char pirqmap[4] = { 1, 0, 2, 3 }; | 300 | static const unsigned char pirqmap[4] = { 1, 0, 2, 3 }; |
286 | 301 | ||
287 | WARN_ON_ONCE(pirq > 4); | 302 | WARN_ON_ONCE(pirq > 4); |
288 | return read_config_nybble(router,0x43, pirqmap[pirq-1]); | 303 | return read_config_nybble(router, 0x43, pirqmap[pirq-1]); |
289 | } | 304 | } |
290 | 305 | ||
291 | static int pirq_ite_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 306 | static int |
307 | pirq_ite_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | ||
292 | { | 308 | { |
293 | static const unsigned char pirqmap[4] = { 1, 0, 2, 3 }; | 309 | static const unsigned char pirqmap[4] = { 1, 0, 2, 3 }; |
294 | 310 | ||
@@ -306,7 +322,8 @@ static int pirq_opti_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | |||
306 | return read_config_nybble(router, 0xb8, pirq >> 4); | 322 | return read_config_nybble(router, 0xb8, pirq >> 4); |
307 | } | 323 | } |
308 | 324 | ||
309 | static int pirq_opti_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 325 | static int |
326 | pirq_opti_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | ||
310 | { | 327 | { |
311 | write_config_nybble(router, 0xb8, pirq >> 4, irq); | 328 | write_config_nybble(router, 0xb8, pirq >> 4, irq); |
312 | return 1; | 329 | return 1; |
@@ -314,7 +331,7 @@ static int pirq_opti_set(struct pci_dev *router, struct pci_dev *dev, int pirq, | |||
314 | 331 | ||
315 | /* | 332 | /* |
316 | * Cyrix: nibble offset 0x5C | 333 | * Cyrix: nibble offset 0x5C |
317 | * 0x5C bits 7:4 is INTB bits 3:0 is INTA | 334 | * 0x5C bits 7:4 is INTB bits 3:0 is INTA |
318 | * 0x5D bits 7:4 is INTD bits 3:0 is INTC | 335 | * 0x5D bits 7:4 is INTD bits 3:0 is INTC |
319 | */ | 336 | */ |
320 | static int pirq_cyrix_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | 337 | static int pirq_cyrix_get(struct pci_dev *router, struct pci_dev *dev, int pirq) |
@@ -322,7 +339,8 @@ static int pirq_cyrix_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | |||
322 | return read_config_nybble(router, 0x5C, (pirq-1)^1); | 339 | return read_config_nybble(router, 0x5C, (pirq-1)^1); |
323 | } | 340 | } |
324 | 341 | ||
325 | static int pirq_cyrix_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 342 | static int |
343 | pirq_cyrix_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | ||
326 | { | 344 | { |
327 | write_config_nybble(router, 0x5C, (pirq-1)^1, irq); | 345 | write_config_nybble(router, 0x5C, (pirq-1)^1, irq); |
328 | return 1; | 346 | return 1; |
@@ -350,7 +368,7 @@ static int pirq_cyrix_set(struct pci_dev *router, struct pci_dev *dev, int pirq, | |||
350 | * Apparently there are systems implementing PCI routing table using | 368 | * Apparently there are systems implementing PCI routing table using |
351 | * link values 0x01-0x04 and others using 0x41-0x44 for PCI INTA..D. | 369 | * link values 0x01-0x04 and others using 0x41-0x44 for PCI INTA..D. |
352 | * We try our best to handle both link mappings. | 370 | * We try our best to handle both link mappings. |
353 | * | 371 | * |
354 | * Currently (2003-05-21) it appears most SiS chipsets follow the | 372 | * Currently (2003-05-21) it appears most SiS chipsets follow the |
355 | * definition of routing registers from the SiS-5595 southbridge. | 373 | * definition of routing registers from the SiS-5595 southbridge. |
356 | * According to the SiS 5595 datasheets the revision id's of the | 374 | * According to the SiS 5595 datasheets the revision id's of the |
@@ -370,7 +388,7 @@ static int pirq_cyrix_set(struct pci_dev *router, struct pci_dev *dev, int pirq, | |||
370 | * | 388 | * |
371 | * 0x62: USBIRQ: | 389 | * 0x62: USBIRQ: |
372 | * bit 6 OHCI function disabled (0), enabled (1) | 390 | * bit 6 OHCI function disabled (0), enabled (1) |
373 | * | 391 | * |
374 | * 0x6a: ACPI/SCI IRQ: bits 4-6 reserved | 392 | * 0x6a: ACPI/SCI IRQ: bits 4-6 reserved |
375 | * | 393 | * |
376 | * 0x7e: Data Acq. Module IRQ - bits 4-6 reserved | 394 | * 0x7e: Data Acq. Module IRQ - bits 4-6 reserved |
@@ -405,7 +423,8 @@ static int pirq_sis_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | |||
405 | return (x & PIRQ_SIS_IRQ_DISABLE) ? 0 : (x & PIRQ_SIS_IRQ_MASK); | 423 | return (x & PIRQ_SIS_IRQ_DISABLE) ? 0 : (x & PIRQ_SIS_IRQ_MASK); |
406 | } | 424 | } |
407 | 425 | ||
408 | static int pirq_sis_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 426 | static int |
427 | pirq_sis_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | ||
409 | { | 428 | { |
410 | u8 x; | 429 | u8 x; |
411 | int reg; | 430 | int reg; |
@@ -439,7 +458,8 @@ static int pirq_vlsi_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | |||
439 | return read_config_nybble(router, 0x74, pirq-1); | 458 | return read_config_nybble(router, 0x74, pirq-1); |
440 | } | 459 | } |
441 | 460 | ||
442 | static int pirq_vlsi_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 461 | static int |
462 | pirq_vlsi_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | ||
443 | { | 463 | { |
444 | WARN_ON_ONCE(pirq >= 9); | 464 | WARN_ON_ONCE(pirq >= 9); |
445 | if (pirq > 8) { | 465 | if (pirq > 8) { |
@@ -461,13 +481,15 @@ static int pirq_vlsi_set(struct pci_dev *router, struct pci_dev *dev, int pirq, | |||
461 | * 0x00 for ACPI (SCI), 0x01 for USB, 0x02 for IDE0, 0x04 for IDE1, | 481 | * 0x00 for ACPI (SCI), 0x01 for USB, 0x02 for IDE0, 0x04 for IDE1, |
462 | * and 0x03 for SMBus. | 482 | * and 0x03 for SMBus. |
463 | */ | 483 | */ |
464 | static int pirq_serverworks_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | 484 | static int |
485 | pirq_serverworks_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | ||
465 | { | 486 | { |
466 | outb(pirq, 0xc00); | 487 | outb(pirq, 0xc00); |
467 | return inb(0xc01) & 0xf; | 488 | return inb(0xc01) & 0xf; |
468 | } | 489 | } |
469 | 490 | ||
470 | static int pirq_serverworks_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 491 | static int pirq_serverworks_set(struct pci_dev *router, struct pci_dev *dev, |
492 | int pirq, int irq) | ||
471 | { | 493 | { |
472 | outb(pirq, 0xc00); | 494 | outb(pirq, 0xc00); |
473 | outb(irq, 0xc01); | 495 | outb(irq, 0xc01); |
@@ -482,27 +504,27 @@ static int pirq_serverworks_set(struct pci_dev *router, struct pci_dev *dev, int | |||
482 | * offset 0x56 0-3 PIRQA 4-7 PIRQB | 504 | * offset 0x56 0-3 PIRQA 4-7 PIRQB |
483 | * offset 0x57 0-3 PIRQC 4-7 PIRQD | 505 | * offset 0x57 0-3 PIRQC 4-7 PIRQD |
484 | */ | 506 | */ |
485 | static int pirq_amd756_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | 507 | static int |
508 | pirq_amd756_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | ||
486 | { | 509 | { |
487 | u8 irq; | 510 | u8 irq; |
488 | irq = 0; | 511 | irq = 0; |
489 | if (pirq <= 4) | 512 | if (pirq <= 4) |
490 | { | ||
491 | irq = read_config_nybble(router, 0x56, pirq - 1); | 513 | irq = read_config_nybble(router, 0x56, pirq - 1); |
492 | } | 514 | printk(KERN_INFO |
493 | printk(KERN_INFO "AMD756: dev %04x:%04x, router pirq : %d get irq : %2d\n", | 515 | "AMD756: dev %04x:%04x, router pirq : %d get irq : %2d\n", |
494 | dev->vendor, dev->device, pirq, irq); | 516 | dev->vendor, dev->device, pirq, irq); |
495 | return irq; | 517 | return irq; |
496 | } | 518 | } |
497 | 519 | ||
498 | static int pirq_amd756_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 520 | static int |
521 | pirq_amd756_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | ||
499 | { | 522 | { |
500 | printk(KERN_INFO "AMD756: dev %04x:%04x, router pirq : %d SET irq : %2d\n", | 523 | printk(KERN_INFO |
524 | "AMD756: dev %04x:%04x, router pirq : %d SET irq : %2d\n", | ||
501 | dev->vendor, dev->device, pirq, irq); | 525 | dev->vendor, dev->device, pirq, irq); |
502 | if (pirq <= 4) | 526 | if (pirq <= 4) |
503 | { | ||
504 | write_config_nybble(router, 0x56, pirq - 1, irq); | 527 | write_config_nybble(router, 0x56, pirq - 1, irq); |
505 | } | ||
506 | return 1; | 528 | return 1; |
507 | } | 529 | } |
508 | 530 | ||
@@ -528,7 +550,8 @@ static int pirq_pico_set(struct pci_dev *router, struct pci_dev *dev, int pirq, | |||
528 | 550 | ||
529 | #ifdef CONFIG_PCI_BIOS | 551 | #ifdef CONFIG_PCI_BIOS |
530 | 552 | ||
531 | static int pirq_bios_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | 553 | static int |
554 | pirq_bios_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) | ||
532 | { | 555 | { |
533 | struct pci_dev *bridge; | 556 | struct pci_dev *bridge; |
534 | int pin = pci_get_interrupt_pin(dev, &bridge); | 557 | int pin = pci_get_interrupt_pin(dev, &bridge); |
@@ -537,11 +560,14 @@ static int pirq_bios_set(struct pci_dev *router, struct pci_dev *dev, int pirq, | |||
537 | 560 | ||
538 | #endif | 561 | #endif |
539 | 562 | ||
540 | static __init int intel_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | 563 | static __init int |
564 | intel_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | ||
541 | { | 565 | { |
542 | static struct pci_device_id __initdata pirq_440gx[] = { | 566 | static struct pci_device_id __initdata pirq_440gx[] = { |
543 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_0) }, | 567 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, |
544 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_2) }, | 568 | PCI_DEVICE_ID_INTEL_82443GX_0) }, |
569 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, | ||
570 | PCI_DEVICE_ID_INTEL_82443GX_2) }, | ||
545 | { }, | 571 | { }, |
546 | }; | 572 | }; |
547 | 573 | ||
@@ -549,50 +575,49 @@ static __init int intel_router_probe(struct irq_router *r, struct pci_dev *route | |||
549 | if (pci_dev_present(pirq_440gx)) | 575 | if (pci_dev_present(pirq_440gx)) |
550 | return 0; | 576 | return 0; |
551 | 577 | ||
552 | switch(device) | 578 | switch (device) { |
553 | { | 579 | case PCI_DEVICE_ID_INTEL_82371FB_0: |
554 | case PCI_DEVICE_ID_INTEL_82371FB_0: | 580 | case PCI_DEVICE_ID_INTEL_82371SB_0: |
555 | case PCI_DEVICE_ID_INTEL_82371SB_0: | 581 | case PCI_DEVICE_ID_INTEL_82371AB_0: |
556 | case PCI_DEVICE_ID_INTEL_82371AB_0: | 582 | case PCI_DEVICE_ID_INTEL_82371MX: |
557 | case PCI_DEVICE_ID_INTEL_82371MX: | 583 | case PCI_DEVICE_ID_INTEL_82443MX_0: |
558 | case PCI_DEVICE_ID_INTEL_82443MX_0: | 584 | case PCI_DEVICE_ID_INTEL_82801AA_0: |
559 | case PCI_DEVICE_ID_INTEL_82801AA_0: | 585 | case PCI_DEVICE_ID_INTEL_82801AB_0: |
560 | case PCI_DEVICE_ID_INTEL_82801AB_0: | 586 | case PCI_DEVICE_ID_INTEL_82801BA_0: |
561 | case PCI_DEVICE_ID_INTEL_82801BA_0: | 587 | case PCI_DEVICE_ID_INTEL_82801BA_10: |
562 | case PCI_DEVICE_ID_INTEL_82801BA_10: | 588 | case PCI_DEVICE_ID_INTEL_82801CA_0: |
563 | case PCI_DEVICE_ID_INTEL_82801CA_0: | 589 | case PCI_DEVICE_ID_INTEL_82801CA_12: |
564 | case PCI_DEVICE_ID_INTEL_82801CA_12: | 590 | case PCI_DEVICE_ID_INTEL_82801DB_0: |
565 | case PCI_DEVICE_ID_INTEL_82801DB_0: | 591 | case PCI_DEVICE_ID_INTEL_82801E_0: |
566 | case PCI_DEVICE_ID_INTEL_82801E_0: | 592 | case PCI_DEVICE_ID_INTEL_82801EB_0: |
567 | case PCI_DEVICE_ID_INTEL_82801EB_0: | 593 | case PCI_DEVICE_ID_INTEL_ESB_1: |
568 | case PCI_DEVICE_ID_INTEL_ESB_1: | 594 | case PCI_DEVICE_ID_INTEL_ICH6_0: |
569 | case PCI_DEVICE_ID_INTEL_ICH6_0: | 595 | case PCI_DEVICE_ID_INTEL_ICH6_1: |
570 | case PCI_DEVICE_ID_INTEL_ICH6_1: | 596 | case PCI_DEVICE_ID_INTEL_ICH7_0: |
571 | case PCI_DEVICE_ID_INTEL_ICH7_0: | 597 | case PCI_DEVICE_ID_INTEL_ICH7_1: |
572 | case PCI_DEVICE_ID_INTEL_ICH7_1: | 598 | case PCI_DEVICE_ID_INTEL_ICH7_30: |
573 | case PCI_DEVICE_ID_INTEL_ICH7_30: | 599 | case PCI_DEVICE_ID_INTEL_ICH7_31: |
574 | case PCI_DEVICE_ID_INTEL_ICH7_31: | 600 | case PCI_DEVICE_ID_INTEL_ESB2_0: |
575 | case PCI_DEVICE_ID_INTEL_ESB2_0: | 601 | case PCI_DEVICE_ID_INTEL_ICH8_0: |
576 | case PCI_DEVICE_ID_INTEL_ICH8_0: | 602 | case PCI_DEVICE_ID_INTEL_ICH8_1: |
577 | case PCI_DEVICE_ID_INTEL_ICH8_1: | 603 | case PCI_DEVICE_ID_INTEL_ICH8_2: |
578 | case PCI_DEVICE_ID_INTEL_ICH8_2: | 604 | case PCI_DEVICE_ID_INTEL_ICH8_3: |
579 | case PCI_DEVICE_ID_INTEL_ICH8_3: | 605 | case PCI_DEVICE_ID_INTEL_ICH8_4: |
580 | case PCI_DEVICE_ID_INTEL_ICH8_4: | 606 | case PCI_DEVICE_ID_INTEL_ICH9_0: |
581 | case PCI_DEVICE_ID_INTEL_ICH9_0: | 607 | case PCI_DEVICE_ID_INTEL_ICH9_1: |
582 | case PCI_DEVICE_ID_INTEL_ICH9_1: | 608 | case PCI_DEVICE_ID_INTEL_ICH9_2: |
583 | case PCI_DEVICE_ID_INTEL_ICH9_2: | 609 | case PCI_DEVICE_ID_INTEL_ICH9_3: |
584 | case PCI_DEVICE_ID_INTEL_ICH9_3: | 610 | case PCI_DEVICE_ID_INTEL_ICH9_4: |
585 | case PCI_DEVICE_ID_INTEL_ICH9_4: | 611 | case PCI_DEVICE_ID_INTEL_ICH9_5: |
586 | case PCI_DEVICE_ID_INTEL_ICH9_5: | 612 | case PCI_DEVICE_ID_INTEL_TOLAPAI_0: |
587 | case PCI_DEVICE_ID_INTEL_TOLAPAI_0: | 613 | case PCI_DEVICE_ID_INTEL_ICH10_0: |
588 | case PCI_DEVICE_ID_INTEL_ICH10_0: | 614 | case PCI_DEVICE_ID_INTEL_ICH10_1: |
589 | case PCI_DEVICE_ID_INTEL_ICH10_1: | 615 | case PCI_DEVICE_ID_INTEL_ICH10_2: |
590 | case PCI_DEVICE_ID_INTEL_ICH10_2: | 616 | case PCI_DEVICE_ID_INTEL_ICH10_3: |
591 | case PCI_DEVICE_ID_INTEL_ICH10_3: | 617 | r->name = "PIIX/ICH"; |
592 | r->name = "PIIX/ICH"; | 618 | r->get = pirq_piix_get; |
593 | r->get = pirq_piix_get; | 619 | r->set = pirq_piix_set; |
594 | r->set = pirq_piix_set; | 620 | return 1; |
595 | return 1; | ||
596 | } | 621 | } |
597 | return 0; | 622 | return 0; |
598 | } | 623 | } |
@@ -606,7 +631,7 @@ static __init int via_router_probe(struct irq_router *r, | |||
606 | * workarounds for some buggy BIOSes | 631 | * workarounds for some buggy BIOSes |
607 | */ | 632 | */ |
608 | if (device == PCI_DEVICE_ID_VIA_82C586_0) { | 633 | if (device == PCI_DEVICE_ID_VIA_82C586_0) { |
609 | switch(router->device) { | 634 | switch (router->device) { |
610 | case PCI_DEVICE_ID_VIA_82C686: | 635 | case PCI_DEVICE_ID_VIA_82C686: |
611 | /* | 636 | /* |
612 | * Asus k7m bios wrongly reports 82C686A | 637 | * Asus k7m bios wrongly reports 82C686A |
@@ -631,7 +656,7 @@ static __init int via_router_probe(struct irq_router *r, | |||
631 | } | 656 | } |
632 | } | 657 | } |
633 | 658 | ||
634 | switch(device) { | 659 | switch (device) { |
635 | case PCI_DEVICE_ID_VIA_82C586_0: | 660 | case PCI_DEVICE_ID_VIA_82C586_0: |
636 | r->name = "VIA"; | 661 | r->name = "VIA"; |
637 | r->get = pirq_via586_get; | 662 | r->get = pirq_via586_get; |
@@ -652,88 +677,89 @@ static __init int via_router_probe(struct irq_router *r, | |||
652 | return 0; | 677 | return 0; |
653 | } | 678 | } |
654 | 679 | ||
655 | static __init int vlsi_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | 680 | static __init int |
681 | vlsi_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | ||
656 | { | 682 | { |
657 | switch(device) | 683 | switch (device) { |
658 | { | 684 | case PCI_DEVICE_ID_VLSI_82C534: |
659 | case PCI_DEVICE_ID_VLSI_82C534: | 685 | r->name = "VLSI 82C534"; |
660 | r->name = "VLSI 82C534"; | 686 | r->get = pirq_vlsi_get; |
661 | r->get = pirq_vlsi_get; | 687 | r->set = pirq_vlsi_set; |
662 | r->set = pirq_vlsi_set; | 688 | return 1; |
663 | return 1; | ||
664 | } | 689 | } |
665 | return 0; | 690 | return 0; |
666 | } | 691 | } |
667 | 692 | ||
668 | 693 | ||
669 | static __init int serverworks_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | 694 | static __init int serverworks_router_probe(struct irq_router *r, |
695 | struct pci_dev *router, u16 device) | ||
670 | { | 696 | { |
671 | switch(device) | 697 | switch (device) { |
672 | { | 698 | case PCI_DEVICE_ID_SERVERWORKS_OSB4: |
673 | case PCI_DEVICE_ID_SERVERWORKS_OSB4: | 699 | case PCI_DEVICE_ID_SERVERWORKS_CSB5: |
674 | case PCI_DEVICE_ID_SERVERWORKS_CSB5: | 700 | r->name = "ServerWorks"; |
675 | r->name = "ServerWorks"; | 701 | r->get = pirq_serverworks_get; |
676 | r->get = pirq_serverworks_get; | 702 | r->set = pirq_serverworks_set; |
677 | r->set = pirq_serverworks_set; | 703 | return 1; |
678 | return 1; | ||
679 | } | 704 | } |
680 | return 0; | 705 | return 0; |
681 | } | 706 | } |
682 | 707 | ||
683 | static __init int sis_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | 708 | static __init int |
709 | sis_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | ||
684 | { | 710 | { |
685 | if (device != PCI_DEVICE_ID_SI_503) | 711 | if (device != PCI_DEVICE_ID_SI_503) |
686 | return 0; | 712 | return 0; |
687 | 713 | ||
688 | r->name = "SIS"; | 714 | r->name = "SIS"; |
689 | r->get = pirq_sis_get; | 715 | r->get = pirq_sis_get; |
690 | r->set = pirq_sis_set; | 716 | r->set = pirq_sis_set; |
691 | return 1; | 717 | return 1; |
692 | } | 718 | } |
693 | 719 | ||
694 | static __init int cyrix_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | 720 | static __init int |
721 | cyrix_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | ||
695 | { | 722 | { |
696 | switch(device) | 723 | switch (device) { |
697 | { | 724 | case PCI_DEVICE_ID_CYRIX_5520: |
698 | case PCI_DEVICE_ID_CYRIX_5520: | 725 | r->name = "NatSemi"; |
699 | r->name = "NatSemi"; | 726 | r->get = pirq_cyrix_get; |
700 | r->get = pirq_cyrix_get; | 727 | r->set = pirq_cyrix_set; |
701 | r->set = pirq_cyrix_set; | 728 | return 1; |
702 | return 1; | ||
703 | } | 729 | } |
704 | return 0; | 730 | return 0; |
705 | } | 731 | } |
706 | 732 | ||
707 | static __init int opti_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | 733 | static __init int |
734 | opti_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | ||
708 | { | 735 | { |
709 | switch(device) | 736 | switch (device) { |
710 | { | 737 | case PCI_DEVICE_ID_OPTI_82C700: |
711 | case PCI_DEVICE_ID_OPTI_82C700: | 738 | r->name = "OPTI"; |
712 | r->name = "OPTI"; | 739 | r->get = pirq_opti_get; |
713 | r->get = pirq_opti_get; | 740 | r->set = pirq_opti_set; |
714 | r->set = pirq_opti_set; | 741 | return 1; |
715 | return 1; | ||
716 | } | 742 | } |
717 | return 0; | 743 | return 0; |
718 | } | 744 | } |
719 | 745 | ||
720 | static __init int ite_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | 746 | static __init int |
747 | ite_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | ||
721 | { | 748 | { |
722 | switch(device) | 749 | switch (device) { |
723 | { | 750 | case PCI_DEVICE_ID_ITE_IT8330G_0: |
724 | case PCI_DEVICE_ID_ITE_IT8330G_0: | 751 | r->name = "ITE"; |
725 | r->name = "ITE"; | 752 | r->get = pirq_ite_get; |
726 | r->get = pirq_ite_get; | 753 | r->set = pirq_ite_set; |
727 | r->set = pirq_ite_set; | 754 | return 1; |
728 | return 1; | ||
729 | } | 755 | } |
730 | return 0; | 756 | return 0; |
731 | } | 757 | } |
732 | 758 | ||
733 | static __init int ali_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | 759 | static __init int |
760 | ali_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | ||
734 | { | 761 | { |
735 | switch(device) | 762 | switch (device) { |
736 | { | ||
737 | case PCI_DEVICE_ID_AL_M1533: | 763 | case PCI_DEVICE_ID_AL_M1533: |
738 | case PCI_DEVICE_ID_AL_M1563: | 764 | case PCI_DEVICE_ID_AL_M1563: |
739 | printk(KERN_DEBUG "PCI: Using ALI IRQ Router\n"); | 765 | printk(KERN_DEBUG "PCI: Using ALI IRQ Router\n"); |
@@ -745,28 +771,29 @@ static __init int ali_router_probe(struct irq_router *r, struct pci_dev *router, | |||
745 | return 0; | 771 | return 0; |
746 | } | 772 | } |
747 | 773 | ||
748 | static __init int amd_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | 774 | static __init int |
775 | amd_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | ||
749 | { | 776 | { |
750 | switch(device) | 777 | switch (device) { |
751 | { | 778 | case PCI_DEVICE_ID_AMD_VIPER_740B: |
752 | case PCI_DEVICE_ID_AMD_VIPER_740B: | 779 | r->name = "AMD756"; |
753 | r->name = "AMD756"; | 780 | break; |
754 | break; | 781 | case PCI_DEVICE_ID_AMD_VIPER_7413: |
755 | case PCI_DEVICE_ID_AMD_VIPER_7413: | 782 | r->name = "AMD766"; |
756 | r->name = "AMD766"; | 783 | break; |
757 | break; | 784 | case PCI_DEVICE_ID_AMD_VIPER_7443: |
758 | case PCI_DEVICE_ID_AMD_VIPER_7443: | 785 | r->name = "AMD768"; |
759 | r->name = "AMD768"; | 786 | break; |
760 | break; | 787 | default: |
761 | default: | 788 | return 0; |
762 | return 0; | ||
763 | } | 789 | } |
764 | r->get = pirq_amd756_get; | 790 | r->get = pirq_amd756_get; |
765 | r->set = pirq_amd756_set; | 791 | r->set = pirq_amd756_set; |
766 | return 1; | 792 | return 1; |
767 | } | 793 | } |
768 | 794 | ||
769 | static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | 795 | static __init int |
796 | pico_router_probe(struct irq_router *r, struct pci_dev *router, u16 device) | ||
770 | { | 797 | { |
771 | switch (device) { | 798 | switch (device) { |
772 | case PCI_DEVICE_ID_PICOPOWER_PT86C523: | 799 | case PCI_DEVICE_ID_PICOPOWER_PT86C523: |
@@ -807,7 +834,7 @@ static struct pci_dev *pirq_router_dev; | |||
807 | * FIXME: should we have an option to say "generic for | 834 | * FIXME: should we have an option to say "generic for |
808 | * chipset" ? | 835 | * chipset" ? |
809 | */ | 836 | */ |
810 | 837 | ||
811 | static void __init pirq_find_router(struct irq_router *r) | 838 | static void __init pirq_find_router(struct irq_router *r) |
812 | { | 839 | { |
813 | struct irq_routing_table *rt = pirq_table; | 840 | struct irq_routing_table *rt = pirq_table; |
@@ -826,7 +853,7 @@ static void __init pirq_find_router(struct irq_router *r) | |||
826 | r->name = "default"; | 853 | r->name = "default"; |
827 | r->get = NULL; | 854 | r->get = NULL; |
828 | r->set = NULL; | 855 | r->set = NULL; |
829 | 856 | ||
830 | DBG(KERN_DEBUG "PCI: Attempting to find IRQ router for %04x:%04x\n", | 857 | DBG(KERN_DEBUG "PCI: Attempting to find IRQ router for %04x:%04x\n", |
831 | rt->rtr_vendor, rt->rtr_device); | 858 | rt->rtr_vendor, rt->rtr_device); |
832 | 859 | ||
@@ -837,12 +864,14 @@ static void __init pirq_find_router(struct irq_router *r) | |||
837 | return; | 864 | return; |
838 | } | 865 | } |
839 | 866 | ||
840 | for( h = pirq_routers; h->vendor; h++) { | 867 | for (h = pirq_routers; h->vendor; h++) { |
841 | /* First look for a router match */ | 868 | /* First look for a router match */ |
842 | if (rt->rtr_vendor == h->vendor && h->probe(r, pirq_router_dev, rt->rtr_device)) | 869 | if (rt->rtr_vendor == h->vendor && |
870 | h->probe(r, pirq_router_dev, rt->rtr_device)) | ||
843 | break; | 871 | break; |
844 | /* Fall back to a device match */ | 872 | /* Fall back to a device match */ |
845 | if (pirq_router_dev->vendor == h->vendor && h->probe(r, pirq_router_dev, pirq_router_dev->device)) | 873 | if (pirq_router_dev->vendor == h->vendor && |
874 | h->probe(r, pirq_router_dev, pirq_router_dev->device)) | ||
846 | break; | 875 | break; |
847 | } | 876 | } |
848 | printk(KERN_INFO "PCI: Using IRQ router %s [%04x/%04x] at %s\n", | 877 | printk(KERN_INFO "PCI: Using IRQ router %s [%04x/%04x] at %s\n", |
@@ -857,11 +886,13 @@ static void __init pirq_find_router(struct irq_router *r) | |||
857 | static struct irq_info *pirq_get_info(struct pci_dev *dev) | 886 | static struct irq_info *pirq_get_info(struct pci_dev *dev) |
858 | { | 887 | { |
859 | struct irq_routing_table *rt = pirq_table; | 888 | struct irq_routing_table *rt = pirq_table; |
860 | int entries = (rt->size - sizeof(struct irq_routing_table)) / sizeof(struct irq_info); | 889 | int entries = (rt->size - sizeof(struct irq_routing_table)) / |
890 | sizeof(struct irq_info); | ||
861 | struct irq_info *info; | 891 | struct irq_info *info; |
862 | 892 | ||
863 | for (info = rt->slots; entries--; info++) | 893 | for (info = rt->slots; entries--; info++) |
864 | if (info->bus == dev->bus->number && PCI_SLOT(info->devfn) == PCI_SLOT(dev->devfn)) | 894 | if (info->bus == dev->bus->number && |
895 | PCI_SLOT(info->devfn) == PCI_SLOT(dev->devfn)) | ||
865 | return info; | 896 | return info; |
866 | return NULL; | 897 | return NULL; |
867 | } | 898 | } |
@@ -889,7 +920,7 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign) | |||
889 | 920 | ||
890 | if (!pirq_table) | 921 | if (!pirq_table) |
891 | return 0; | 922 | return 0; |
892 | 923 | ||
893 | DBG(KERN_DEBUG "IRQ for %s[%c]", pci_name(dev), 'A' + pin); | 924 | DBG(KERN_DEBUG "IRQ for %s[%c]", pci_name(dev), 'A' + pin); |
894 | info = pirq_get_info(dev); | 925 | info = pirq_get_info(dev); |
895 | if (!info) { | 926 | if (!info) { |
@@ -902,7 +933,8 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign) | |||
902 | DBG(" -> not routed\n" KERN_DEBUG); | 933 | DBG(" -> not routed\n" KERN_DEBUG); |
903 | return 0; | 934 | return 0; |
904 | } | 935 | } |
905 | DBG(" -> PIRQ %02x, mask %04x, excl %04x", pirq, mask, pirq_table->exclusive_irqs); | 936 | DBG(" -> PIRQ %02x, mask %04x, excl %04x", pirq, mask, |
937 | pirq_table->exclusive_irqs); | ||
906 | mask &= pcibios_irq_mask; | 938 | mask &= pcibios_irq_mask; |
907 | 939 | ||
908 | /* Work around broken HP Pavilion Notebooks which assign USB to | 940 | /* Work around broken HP Pavilion Notebooks which assign USB to |
@@ -915,7 +947,8 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign) | |||
915 | } | 947 | } |
916 | 948 | ||
917 | /* same for Acer Travelmate 360, but with CB and irq 11 -> 10 */ | 949 | /* same for Acer Travelmate 360, but with CB and irq 11 -> 10 */ |
918 | if (acer_tm360_irqrouting && dev->irq == 11 && dev->vendor == PCI_VENDOR_ID_O2) { | 950 | if (acer_tm360_irqrouting && dev->irq == 11 && |
951 | dev->vendor == PCI_VENDOR_ID_O2) { | ||
919 | pirq = 0x68; | 952 | pirq = 0x68; |
920 | mask = 0x400; | 953 | mask = 0x400; |
921 | dev->irq = r->get(pirq_router_dev, dev, pirq); | 954 | dev->irq = r->get(pirq_router_dev, dev, pirq); |
@@ -928,17 +961,20 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign) | |||
928 | */ | 961 | */ |
929 | newirq = dev->irq; | 962 | newirq = dev->irq; |
930 | if (newirq && !((1 << newirq) & mask)) { | 963 | if (newirq && !((1 << newirq) & mask)) { |
931 | if ( pci_probe & PCI_USE_PIRQ_MASK) newirq = 0; | 964 | if (pci_probe & PCI_USE_PIRQ_MASK) |
932 | else printk("\n" KERN_WARNING | 965 | newirq = 0; |
933 | "PCI: IRQ %i for device %s doesn't match PIRQ mask " | 966 | else |
934 | "- try pci=usepirqmask\n" KERN_DEBUG, newirq, | 967 | printk("\n" KERN_WARNING |
935 | pci_name(dev)); | 968 | "PCI: IRQ %i for device %s doesn't match PIRQ mask - try pci=usepirqmask\n" |
969 | KERN_DEBUG, newirq, | ||
970 | pci_name(dev)); | ||
936 | } | 971 | } |
937 | if (!newirq && assign) { | 972 | if (!newirq && assign) { |
938 | for (i = 0; i < 16; i++) { | 973 | for (i = 0; i < 16; i++) { |
939 | if (!(mask & (1 << i))) | 974 | if (!(mask & (1 << i))) |
940 | continue; | 975 | continue; |
941 | if (pirq_penalty[i] < pirq_penalty[newirq] && can_request_irq(i, IRQF_SHARED)) | 976 | if (pirq_penalty[i] < pirq_penalty[newirq] && |
977 | can_request_irq(i, IRQF_SHARED)) | ||
942 | newirq = i; | 978 | newirq = i; |
943 | } | 979 | } |
944 | } | 980 | } |
@@ -949,12 +985,13 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign) | |||
949 | irq = pirq & 0xf; | 985 | irq = pirq & 0xf; |
950 | DBG(" -> hardcoded IRQ %d\n", irq); | 986 | DBG(" -> hardcoded IRQ %d\n", irq); |
951 | msg = "Hardcoded"; | 987 | msg = "Hardcoded"; |
952 | } else if ( r->get && (irq = r->get(pirq_router_dev, dev, pirq)) && \ | 988 | } else if (r->get && (irq = r->get(pirq_router_dev, dev, pirq)) && \ |
953 | ((!(pci_probe & PCI_USE_PIRQ_MASK)) || ((1 << irq) & mask)) ) { | 989 | ((!(pci_probe & PCI_USE_PIRQ_MASK)) || ((1 << irq) & mask))) { |
954 | DBG(" -> got IRQ %d\n", irq); | 990 | DBG(" -> got IRQ %d\n", irq); |
955 | msg = "Found"; | 991 | msg = "Found"; |
956 | eisa_set_level_irq(irq); | 992 | eisa_set_level_irq(irq); |
957 | } else if (newirq && r->set && (dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) { | 993 | } else if (newirq && r->set && |
994 | (dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) { | ||
958 | DBG(" -> assigning IRQ %d", newirq); | 995 | DBG(" -> assigning IRQ %d", newirq); |
959 | if (r->set(pirq_router_dev, dev, pirq, newirq)) { | 996 | if (r->set(pirq_router_dev, dev, pirq, newirq)) { |
960 | eisa_set_level_irq(newirq); | 997 | eisa_set_level_irq(newirq); |
@@ -972,7 +1009,8 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign) | |||
972 | } else | 1009 | } else |
973 | return 0; | 1010 | return 0; |
974 | } | 1011 | } |
975 | printk(KERN_INFO "PCI: %s IRQ %d for device %s\n", msg, irq, pci_name(dev)); | 1012 | printk(KERN_INFO "PCI: %s IRQ %d for device %s\n", msg, irq, |
1013 | pci_name(dev)); | ||
976 | 1014 | ||
977 | /* Update IRQ for all devices with the same pirq value */ | 1015 | /* Update IRQ for all devices with the same pirq value */ |
978 | while ((dev2 = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev2)) != NULL) { | 1016 | while ((dev2 = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev2)) != NULL) { |
@@ -984,20 +1022,26 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign) | |||
984 | if (!info) | 1022 | if (!info) |
985 | continue; | 1023 | continue; |
986 | if (info->irq[pin].link == pirq) { | 1024 | if (info->irq[pin].link == pirq) { |
987 | /* We refuse to override the dev->irq information. Give a warning! */ | 1025 | /* |
988 | if ( dev2->irq && dev2->irq != irq && \ | 1026 | * We refuse to override the dev->irq |
1027 | * information. Give a warning! | ||
1028 | */ | ||
1029 | if (dev2->irq && dev2->irq != irq && \ | ||
989 | (!(pci_probe & PCI_USE_PIRQ_MASK) || \ | 1030 | (!(pci_probe & PCI_USE_PIRQ_MASK) || \ |
990 | ((1 << dev2->irq) & mask)) ) { | 1031 | ((1 << dev2->irq) & mask))) { |
991 | #ifndef CONFIG_PCI_MSI | 1032 | #ifndef CONFIG_PCI_MSI |
992 | printk(KERN_INFO "IRQ routing conflict for %s, have irq %d, want irq %d\n", | 1033 | printk(KERN_INFO |
993 | pci_name(dev2), dev2->irq, irq); | 1034 | "IRQ routing conflict for %s, have irq %d, want irq %d\n", |
1035 | pci_name(dev2), dev2->irq, irq); | ||
994 | #endif | 1036 | #endif |
995 | continue; | 1037 | continue; |
996 | } | 1038 | } |
997 | dev2->irq = irq; | 1039 | dev2->irq = irq; |
998 | pirq_penalty[irq]++; | 1040 | pirq_penalty[irq]++; |
999 | if (dev != dev2) | 1041 | if (dev != dev2) |
1000 | printk(KERN_INFO "PCI: Sharing IRQ %d with %s\n", irq, pci_name(dev2)); | 1042 | printk(KERN_INFO |
1043 | "PCI: Sharing IRQ %d with %s\n", | ||
1044 | irq, pci_name(dev2)); | ||
1001 | } | 1045 | } |
1002 | } | 1046 | } |
1003 | return 1; | 1047 | return 1; |
@@ -1011,15 +1055,21 @@ static void __init pcibios_fixup_irqs(void) | |||
1011 | DBG(KERN_DEBUG "PCI: IRQ fixup\n"); | 1055 | DBG(KERN_DEBUG "PCI: IRQ fixup\n"); |
1012 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { | 1056 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { |
1013 | /* | 1057 | /* |
1014 | * If the BIOS has set an out of range IRQ number, just ignore it. | 1058 | * If the BIOS has set an out of range IRQ number, just |
1015 | * Also keep track of which IRQ's are already in use. | 1059 | * ignore it. Also keep track of which IRQ's are |
1060 | * already in use. | ||
1016 | */ | 1061 | */ |
1017 | if (dev->irq >= 16) { | 1062 | if (dev->irq >= 16) { |
1018 | DBG(KERN_DEBUG "%s: ignoring bogus IRQ %d\n", pci_name(dev), dev->irq); | 1063 | DBG(KERN_DEBUG "%s: ignoring bogus IRQ %d\n", |
1064 | pci_name(dev), dev->irq); | ||
1019 | dev->irq = 0; | 1065 | dev->irq = 0; |
1020 | } | 1066 | } |
1021 | /* If the IRQ is already assigned to a PCI device, ignore its ISA use penalty */ | 1067 | /* |
1022 | if (pirq_penalty[dev->irq] >= 100 && pirq_penalty[dev->irq] < 100000) | 1068 | * If the IRQ is already assigned to a PCI device, |
1069 | * ignore its ISA use penalty | ||
1070 | */ | ||
1071 | if (pirq_penalty[dev->irq] >= 100 && | ||
1072 | pirq_penalty[dev->irq] < 100000) | ||
1023 | pirq_penalty[dev->irq] = 0; | 1073 | pirq_penalty[dev->irq] = 0; |
1024 | pirq_penalty[dev->irq]++; | 1074 | pirq_penalty[dev->irq]++; |
1025 | } | 1075 | } |
@@ -1031,31 +1081,40 @@ static void __init pcibios_fixup_irqs(void) | |||
1031 | /* | 1081 | /* |
1032 | * Recalculate IRQ numbers if we use the I/O APIC. | 1082 | * Recalculate IRQ numbers if we use the I/O APIC. |
1033 | */ | 1083 | */ |
1034 | if (io_apic_assign_pci_irqs) | 1084 | if (io_apic_assign_pci_irqs) { |
1035 | { | ||
1036 | int irq; | 1085 | int irq; |
1037 | 1086 | ||
1038 | if (pin) { | 1087 | if (pin) { |
1039 | pin--; /* interrupt pins are numbered starting from 1 */ | 1088 | /* |
1040 | irq = IO_APIC_get_PCI_irq_vector(dev->bus->number, PCI_SLOT(dev->devfn), pin); | 1089 | * interrupt pins are numbered starting |
1090 | * from 1 | ||
1091 | */ | ||
1092 | pin--; | ||
1093 | irq = IO_APIC_get_PCI_irq_vector(dev->bus->number, | ||
1094 | PCI_SLOT(dev->devfn), pin); | ||
1041 | /* | 1095 | /* |
1042 | * Busses behind bridges are typically not listed in the MP-table. | 1096 | * Busses behind bridges are typically not listed in the MP-table. |
1043 | * In this case we have to look up the IRQ based on the parent bus, | 1097 | * In this case we have to look up the IRQ based on the parent bus, |
1044 | * parent slot, and pin number. The SMP code detects such bridged | 1098 | * parent slot, and pin number. The SMP code detects such bridged |
1045 | * busses itself so we should get into this branch reliably. | 1099 | * busses itself so we should get into this branch reliably. |
1046 | */ | 1100 | */ |
1047 | if (irq < 0 && dev->bus->parent) { /* go back to the bridge */ | 1101 | if (irq < 0 && dev->bus->parent) { |
1048 | struct pci_dev * bridge = dev->bus->self; | 1102 | /* go back to the bridge */ |
1103 | struct pci_dev *bridge = dev->bus->self; | ||
1049 | 1104 | ||
1050 | pin = (pin + PCI_SLOT(dev->devfn)) % 4; | 1105 | pin = (pin + PCI_SLOT(dev->devfn)) % 4; |
1051 | irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number, | 1106 | irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number, |
1052 | PCI_SLOT(bridge->devfn), pin); | 1107 | PCI_SLOT(bridge->devfn), |
1108 | pin); | ||
1053 | if (irq >= 0) | 1109 | if (irq >= 0) |
1054 | printk(KERN_WARNING "PCI: using PPB %s[%c] to get irq %d\n", | 1110 | printk(KERN_WARNING |
1055 | pci_name(bridge), 'A' + pin, irq); | 1111 | "PCI: using PPB %s[%c] to get irq %d\n", |
1112 | pci_name(bridge), | ||
1113 | 'A' + pin, irq); | ||
1056 | } | 1114 | } |
1057 | if (irq >= 0) { | 1115 | if (irq >= 0) { |
1058 | printk(KERN_INFO "PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n", | 1116 | printk(KERN_INFO |
1117 | "PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n", | ||
1059 | pci_name(dev), 'A' + pin, irq); | 1118 | pci_name(dev), 'A' + pin, irq); |
1060 | dev->irq = irq; | 1119 | dev->irq = irq; |
1061 | } | 1120 | } |
@@ -1078,7 +1137,8 @@ static int __init fix_broken_hp_bios_irq9(const struct dmi_system_id *d) | |||
1078 | { | 1137 | { |
1079 | if (!broken_hp_bios_irq9) { | 1138 | if (!broken_hp_bios_irq9) { |
1080 | broken_hp_bios_irq9 = 1; | 1139 | broken_hp_bios_irq9 = 1; |
1081 | printk(KERN_INFO "%s detected - fixing broken IRQ routing\n", d->ident); | 1140 | printk(KERN_INFO "%s detected - fixing broken IRQ routing\n", |
1141 | d->ident); | ||
1082 | } | 1142 | } |
1083 | return 0; | 1143 | return 0; |
1084 | } | 1144 | } |
@@ -1091,7 +1151,8 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d) | |||
1091 | { | 1151 | { |
1092 | if (!acer_tm360_irqrouting) { | 1152 | if (!acer_tm360_irqrouting) { |
1093 | acer_tm360_irqrouting = 1; | 1153 | acer_tm360_irqrouting = 1; |
1094 | printk(KERN_INFO "%s detected - fixing broken IRQ routing\n", d->ident); | 1154 | printk(KERN_INFO "%s detected - fixing broken IRQ routing\n", |
1155 | d->ident); | ||
1095 | } | 1156 | } |
1096 | return 0; | 1157 | return 0; |
1097 | } | 1158 | } |
@@ -1103,7 +1164,8 @@ static struct dmi_system_id __initdata pciirq_dmi_table[] = { | |||
1103 | .matches = { | 1164 | .matches = { |
1104 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | 1165 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
1105 | DMI_MATCH(DMI_BIOS_VERSION, "GE.M1.03"), | 1166 | DMI_MATCH(DMI_BIOS_VERSION, "GE.M1.03"), |
1106 | DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook Model GE"), | 1167 | DMI_MATCH(DMI_PRODUCT_VERSION, |
1168 | "HP Pavilion Notebook Model GE"), | ||
1107 | DMI_MATCH(DMI_BOARD_VERSION, "OmniBook N32N-736"), | 1169 | DMI_MATCH(DMI_BOARD_VERSION, "OmniBook N32N-736"), |
1108 | }, | 1170 | }, |
1109 | }, | 1171 | }, |
@@ -1138,11 +1200,14 @@ static int __init pcibios_irq_init(void) | |||
1138 | pirq_find_router(&pirq_router); | 1200 | pirq_find_router(&pirq_router); |
1139 | if (pirq_table->exclusive_irqs) { | 1201 | if (pirq_table->exclusive_irqs) { |
1140 | int i; | 1202 | int i; |
1141 | for (i=0; i<16; i++) | 1203 | for (i = 0; i < 16; i++) |
1142 | if (!(pirq_table->exclusive_irqs & (1 << i))) | 1204 | if (!(pirq_table->exclusive_irqs & (1 << i))) |
1143 | pirq_penalty[i] += 100; | 1205 | pirq_penalty[i] += 100; |
1144 | } | 1206 | } |
1145 | /* If we're using the I/O APIC, avoid using the PCI IRQ routing table */ | 1207 | /* |
1208 | * If we're using the I/O APIC, avoid using the PCI IRQ | ||
1209 | * routing table | ||
1210 | */ | ||
1146 | if (io_apic_assign_pci_irqs) | 1211 | if (io_apic_assign_pci_irqs) |
1147 | pirq_table = NULL; | 1212 | pirq_table = NULL; |
1148 | } | 1213 | } |
@@ -1189,33 +1254,40 @@ static int pirq_enable_irq(struct pci_dev *dev) | |||
1189 | if (pin && !pcibios_lookup_irq(dev, 1) && !dev->irq) { | 1254 | if (pin && !pcibios_lookup_irq(dev, 1) && !dev->irq) { |
1190 | char *msg = ""; | 1255 | char *msg = ""; |
1191 | 1256 | ||
1192 | pin--; /* interrupt pins are numbered starting from 1 */ | 1257 | pin--; /* interrupt pins are numbered starting from 1 */ |
1193 | 1258 | ||
1194 | if (io_apic_assign_pci_irqs) { | 1259 | if (io_apic_assign_pci_irqs) { |
1195 | int irq; | 1260 | int irq; |
1196 | 1261 | ||
1197 | irq = IO_APIC_get_PCI_irq_vector(dev->bus->number, PCI_SLOT(dev->devfn), pin); | 1262 | irq = IO_APIC_get_PCI_irq_vector(dev->bus->number, |
1263 | PCI_SLOT(dev->devfn), pin); | ||
1198 | /* | 1264 | /* |
1199 | * Busses behind bridges are typically not listed in the MP-table. | 1265 | * Busses behind bridges are typically not |
1200 | * In this case we have to look up the IRQ based on the parent bus, | 1266 | * listed in the MP-table. In this case we have |
1201 | * parent slot, and pin number. The SMP code detects such bridged | 1267 | * to look up the IRQ based on the parent bus, |
1202 | * busses itself so we should get into this branch reliably. | 1268 | * parent slot, and pin number. The SMP code |
1269 | * detects such bridged busses itself so we | ||
1270 | * should get into this branch reliably. | ||
1203 | */ | 1271 | */ |
1204 | temp_dev = dev; | 1272 | temp_dev = dev; |
1205 | while (irq < 0 && dev->bus->parent) { /* go back to the bridge */ | 1273 | while (irq < 0 && dev->bus->parent) { |
1206 | struct pci_dev * bridge = dev->bus->self; | 1274 | /* go back to the bridge */ |
1275 | struct pci_dev *bridge = dev->bus->self; | ||
1207 | 1276 | ||
1208 | pin = (pin + PCI_SLOT(dev->devfn)) % 4; | 1277 | pin = (pin + PCI_SLOT(dev->devfn)) % 4; |
1209 | irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number, | 1278 | irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number, |
1210 | PCI_SLOT(bridge->devfn), pin); | 1279 | PCI_SLOT(bridge->devfn), pin); |
1211 | if (irq >= 0) | 1280 | if (irq >= 0) |
1212 | printk(KERN_WARNING "PCI: using PPB %s[%c] to get irq %d\n", | 1281 | printk(KERN_WARNING |
1213 | pci_name(bridge), 'A' + pin, irq); | 1282 | "PCI: using PPB %s[%c] to get irq %d\n", |
1283 | pci_name(bridge), | ||
1284 | 'A' + pin, irq); | ||
1214 | dev = bridge; | 1285 | dev = bridge; |
1215 | } | 1286 | } |
1216 | dev = temp_dev; | 1287 | dev = temp_dev; |
1217 | if (irq >= 0) { | 1288 | if (irq >= 0) { |
1218 | printk(KERN_INFO "PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n", | 1289 | printk(KERN_INFO |
1290 | "PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n", | ||
1219 | pci_name(dev), 'A' + pin, irq); | 1291 | pci_name(dev), 'A' + pin, irq); |
1220 | dev->irq = irq; | 1292 | dev->irq = irq; |
1221 | return 0; | 1293 | return 0; |
@@ -1226,12 +1298,17 @@ static int pirq_enable_irq(struct pci_dev *dev) | |||
1226 | else | 1298 | else |
1227 | msg = " Please try using pci=biosirq."; | 1299 | msg = " Please try using pci=biosirq."; |
1228 | 1300 | ||
1229 | /* With IDE legacy devices the IRQ lookup failure is not a problem.. */ | 1301 | /* |
1230 | if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE && !(dev->class & 0x5)) | 1302 | * With IDE legacy devices the IRQ lookup failure is not |
1303 | * a problem.. | ||
1304 | */ | ||
1305 | if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE && | ||
1306 | !(dev->class & 0x5)) | ||
1231 | return 0; | 1307 | return 0; |
1232 | 1308 | ||
1233 | printk(KERN_WARNING "PCI: No IRQ known for interrupt pin %c of device %s.%s\n", | 1309 | printk(KERN_WARNING |
1234 | 'A' + pin, pci_name(dev), msg); | 1310 | "PCI: No IRQ known for interrupt pin %c of device %s.%s\n", |
1311 | 'A' + pin, pci_name(dev), msg); | ||
1235 | } | 1312 | } |
1236 | return 0; | 1313 | return 0; |
1237 | } | 1314 | } |
diff --git a/arch/x86/pci/pci.h b/arch/x86/pci/pci.h index 720c4c554534..291dafec07b7 100644 --- a/arch/x86/pci/pci.h +++ b/arch/x86/pci/pci.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define PCI_CAN_SKIP_ISA_ALIGN 0x8000 | 27 | #define PCI_CAN_SKIP_ISA_ALIGN 0x8000 |
28 | #define PCI_USE__CRS 0x10000 | 28 | #define PCI_USE__CRS 0x10000 |
29 | #define PCI_CHECK_ENABLE_AMD_MMCONF 0x20000 | 29 | #define PCI_CHECK_ENABLE_AMD_MMCONF 0x20000 |
30 | #define PCI_NOASSIGN_ROMS 0x40000 | ||
30 | 31 | ||
31 | extern unsigned int pci_probe; | 32 | extern unsigned int pci_probe; |
32 | extern unsigned long pirq_table_addr; | 33 | extern unsigned long pirq_table_addr; |
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index c52fca833268..250d41a24f78 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -338,6 +338,15 @@ config ACPI_EC | |||
338 | the battery and thermal drivers. If you are compiling for a | 338 | the battery and thermal drivers. If you are compiling for a |
339 | mobile system, say Y. | 339 | mobile system, say Y. |
340 | 340 | ||
341 | config ACPI_PCI_SLOT | ||
342 | tristate "PCI slot detection driver" | ||
343 | default n | ||
344 | help | ||
345 | This driver will attempt to discover all PCI slots in your system, | ||
346 | and creates entries in /sys/bus/pci/slots/. This feature can | ||
347 | help you correlate PCI bus addresses with the physical geography | ||
348 | of your slots. If you are unsure, say N. | ||
349 | |||
341 | config ACPI_POWER | 350 | config ACPI_POWER |
342 | bool | 351 | bool |
343 | default y | 352 | default y |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 40b0fcae4c78..579c29c0665f 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -48,6 +48,7 @@ obj-$(CONFIG_ACPI_DOCK) += dock.o | |||
48 | obj-$(CONFIG_ACPI_BAY) += bay.o | 48 | obj-$(CONFIG_ACPI_BAY) += bay.o |
49 | obj-$(CONFIG_ACPI_VIDEO) += video.o | 49 | obj-$(CONFIG_ACPI_VIDEO) += video.o |
50 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o | 50 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o |
51 | obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o | ||
51 | obj-$(CONFIG_ACPI_POWER) += power.o | 52 | obj-$(CONFIG_ACPI_POWER) += power.o |
52 | obj-$(CONFIG_ACPI_PROCESSOR) += processor.o | 53 | obj-$(CONFIG_ACPI_PROCESSOR) += processor.o |
53 | obj-$(CONFIG_ACPI_CONTAINER) += container.o | 54 | obj-$(CONFIG_ACPI_CONTAINER) += container.o |
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c new file mode 100644 index 000000000000..b9ab030a52d5 --- /dev/null +++ b/drivers/acpi/pci_slot.c | |||
@@ -0,0 +1,368 @@ | |||
1 | /* | ||
2 | * pci_slot.c - ACPI PCI Slot Driver | ||
3 | * | ||
4 | * The code here is heavily leveraged from the acpiphp module. | ||
5 | * Thanks to Matthew Wilcox <matthew@wil.cx> for much guidance. | ||
6 | * Thanks to Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> for code | ||
7 | * review and fixes. | ||
8 | * | ||
9 | * Copyright (C) 2007 Alex Chiang <achiang@hp.com> | ||
10 | * Copyright (C) 2007 Hewlett-Packard Development Company, L.P. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms and conditions of the GNU General Public License, | ||
14 | * version 2, as published by the Free Software Foundation. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | * General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License along | ||
22 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
23 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
24 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <linux/types.h> | ||
30 | #include <linux/pci.h> | ||
31 | #include <linux/acpi.h> | ||
32 | #include <acpi/acpi_bus.h> | ||
33 | #include <acpi/acpi_drivers.h> | ||
34 | |||
35 | static int debug; | ||
36 | static int check_sta_before_sun; | ||
37 | |||
38 | #define DRIVER_VERSION "0.1" | ||
39 | #define DRIVER_AUTHOR "Alex Chiang <achiang@hp.com>" | ||
40 | #define DRIVER_DESC "ACPI PCI Slot Detection Driver" | ||
41 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
42 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
43 | MODULE_LICENSE("GPL"); | ||
44 | MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); | ||
45 | module_param(debug, bool, 0644); | ||
46 | |||
47 | #define _COMPONENT ACPI_PCI_COMPONENT | ||
48 | ACPI_MODULE_NAME("pci_slot"); | ||
49 | |||
50 | #define MY_NAME "pci_slot" | ||
51 | #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) | ||
52 | #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg) | ||
53 | #define dbg(format, arg...) \ | ||
54 | do { \ | ||
55 | if (debug) \ | ||
56 | printk(KERN_DEBUG "%s: " format, \ | ||
57 | MY_NAME , ## arg); \ | ||
58 | } while (0) | ||
59 | |||
60 | #define SLOT_NAME_SIZE 20 /* Inspired by #define in acpiphp.h */ | ||
61 | |||
62 | struct acpi_pci_slot { | ||
63 | acpi_handle root_handle; /* handle of the root bridge */ | ||
64 | struct pci_slot *pci_slot; /* corresponding pci_slot */ | ||
65 | struct list_head list; /* node in the list of slots */ | ||
66 | }; | ||
67 | |||
68 | static int acpi_pci_slot_add(acpi_handle handle); | ||
69 | static void acpi_pci_slot_remove(acpi_handle handle); | ||
70 | |||
71 | static LIST_HEAD(slot_list); | ||
72 | static DEFINE_MUTEX(slot_list_lock); | ||
73 | static struct acpi_pci_driver acpi_pci_slot_driver = { | ||
74 | .add = acpi_pci_slot_add, | ||
75 | .remove = acpi_pci_slot_remove, | ||
76 | }; | ||
77 | |||
78 | static int | ||
79 | check_slot(acpi_handle handle, int *device, unsigned long *sun) | ||
80 | { | ||
81 | int retval = 0; | ||
82 | unsigned long adr, sta; | ||
83 | acpi_status status; | ||
84 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
85 | |||
86 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | ||
87 | dbg("Checking slot on path: %s\n", (char *)buffer.pointer); | ||
88 | |||
89 | if (check_sta_before_sun) { | ||
90 | /* If SxFy doesn't have _STA, we just assume it's there */ | ||
91 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | ||
92 | if (ACPI_SUCCESS(status) && !(sta & ACPI_STA_DEVICE_PRESENT)) { | ||
93 | retval = -1; | ||
94 | goto out; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); | ||
99 | if (ACPI_FAILURE(status)) { | ||
100 | dbg("_ADR returned %d on %s\n", status, (char *)buffer.pointer); | ||
101 | retval = -1; | ||
102 | goto out; | ||
103 | } | ||
104 | |||
105 | *device = (adr >> 16) & 0xffff; | ||
106 | |||
107 | /* No _SUN == not a slot == bail */ | ||
108 | status = acpi_evaluate_integer(handle, "_SUN", NULL, sun); | ||
109 | if (ACPI_FAILURE(status)) { | ||
110 | dbg("_SUN returned %d on %s\n", status, (char *)buffer.pointer); | ||
111 | retval = -1; | ||
112 | goto out; | ||
113 | } | ||
114 | |||
115 | out: | ||
116 | kfree(buffer.pointer); | ||
117 | return retval; | ||
118 | } | ||
119 | |||
120 | struct callback_args { | ||
121 | acpi_walk_callback user_function; /* only for walk_p2p_bridge */ | ||
122 | struct pci_bus *pci_bus; | ||
123 | acpi_handle root_handle; | ||
124 | }; | ||
125 | |||
126 | /* | ||
127 | * register_slot | ||
128 | * | ||
129 | * Called once for each SxFy object in the namespace. Don't worry about | ||
130 | * calling pci_create_slot multiple times for the same pci_bus:device, | ||
131 | * since each subsequent call simply bumps the refcount on the pci_slot. | ||
132 | * | ||
133 | * The number of calls to pci_destroy_slot from unregister_slot is | ||
134 | * symmetrical. | ||
135 | */ | ||
136 | static acpi_status | ||
137 | register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
138 | { | ||
139 | int device; | ||
140 | unsigned long sun; | ||
141 | char name[SLOT_NAME_SIZE]; | ||
142 | struct acpi_pci_slot *slot; | ||
143 | struct pci_slot *pci_slot; | ||
144 | struct callback_args *parent_context = context; | ||
145 | struct pci_bus *pci_bus = parent_context->pci_bus; | ||
146 | |||
147 | if (check_slot(handle, &device, &sun)) | ||
148 | return AE_OK; | ||
149 | |||
150 | slot = kmalloc(sizeof(*slot), GFP_KERNEL); | ||
151 | if (!slot) { | ||
152 | err("%s: cannot allocate memory\n", __func__); | ||
153 | return AE_OK; | ||
154 | } | ||
155 | |||
156 | snprintf(name, sizeof(name), "%u", (u32)sun); | ||
157 | pci_slot = pci_create_slot(pci_bus, device, name); | ||
158 | if (IS_ERR(pci_slot)) { | ||
159 | err("pci_create_slot returned %ld\n", PTR_ERR(pci_slot)); | ||
160 | kfree(slot); | ||
161 | } | ||
162 | |||
163 | slot->root_handle = parent_context->root_handle; | ||
164 | slot->pci_slot = pci_slot; | ||
165 | INIT_LIST_HEAD(&slot->list); | ||
166 | mutex_lock(&slot_list_lock); | ||
167 | list_add(&slot->list, &slot_list); | ||
168 | mutex_unlock(&slot_list_lock); | ||
169 | |||
170 | dbg("pci_slot: %p, pci_bus: %x, device: %d, name: %s\n", | ||
171 | pci_slot, pci_bus->number, device, name); | ||
172 | |||
173 | return AE_OK; | ||
174 | } | ||
175 | |||
176 | /* | ||
177 | * walk_p2p_bridge - discover and walk p2p bridges | ||
178 | * @handle: points to an acpi_pci_root | ||
179 | * @context: p2p_bridge_context pointer | ||
180 | * | ||
181 | * Note that when we call ourselves recursively, we pass a different | ||
182 | * value of pci_bus in the child_context. | ||
183 | */ | ||
184 | static acpi_status | ||
185 | walk_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
186 | { | ||
187 | int device, function; | ||
188 | unsigned long adr; | ||
189 | acpi_status status; | ||
190 | acpi_handle dummy_handle; | ||
191 | acpi_walk_callback user_function; | ||
192 | |||
193 | struct pci_dev *dev; | ||
194 | struct pci_bus *pci_bus; | ||
195 | struct callback_args child_context; | ||
196 | struct callback_args *parent_context = context; | ||
197 | |||
198 | pci_bus = parent_context->pci_bus; | ||
199 | user_function = parent_context->user_function; | ||
200 | |||
201 | status = acpi_get_handle(handle, "_ADR", &dummy_handle); | ||
202 | if (ACPI_FAILURE(status)) | ||
203 | return AE_OK; | ||
204 | |||
205 | status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); | ||
206 | if (ACPI_FAILURE(status)) | ||
207 | return AE_OK; | ||
208 | |||
209 | device = (adr >> 16) & 0xffff; | ||
210 | function = adr & 0xffff; | ||
211 | |||
212 | dev = pci_get_slot(pci_bus, PCI_DEVFN(device, function)); | ||
213 | if (!dev || !dev->subordinate) | ||
214 | goto out; | ||
215 | |||
216 | child_context.pci_bus = dev->subordinate; | ||
217 | child_context.user_function = user_function; | ||
218 | child_context.root_handle = parent_context->root_handle; | ||
219 | |||
220 | dbg("p2p bridge walk, pci_bus = %x\n", dev->subordinate->number); | ||
221 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, | ||
222 | user_function, &child_context, NULL); | ||
223 | if (ACPI_FAILURE(status)) | ||
224 | goto out; | ||
225 | |||
226 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, | ||
227 | walk_p2p_bridge, &child_context, NULL); | ||
228 | out: | ||
229 | pci_dev_put(dev); | ||
230 | return AE_OK; | ||
231 | } | ||
232 | |||
233 | /* | ||
234 | * walk_root_bridge - generic root bridge walker | ||
235 | * @handle: points to an acpi_pci_root | ||
236 | * @user_function: user callback for slot objects | ||
237 | * | ||
238 | * Call user_function for all objects underneath this root bridge. | ||
239 | * Walk p2p bridges underneath us and call user_function on those too. | ||
240 | */ | ||
241 | static int | ||
242 | walk_root_bridge(acpi_handle handle, acpi_walk_callback user_function) | ||
243 | { | ||
244 | int seg, bus; | ||
245 | unsigned long tmp; | ||
246 | acpi_status status; | ||
247 | acpi_handle dummy_handle; | ||
248 | struct pci_bus *pci_bus; | ||
249 | struct callback_args context; | ||
250 | |||
251 | /* If the bridge doesn't have _STA, we assume it is always there */ | ||
252 | status = acpi_get_handle(handle, "_STA", &dummy_handle); | ||
253 | if (ACPI_SUCCESS(status)) { | ||
254 | status = acpi_evaluate_integer(handle, "_STA", NULL, &tmp); | ||
255 | if (ACPI_FAILURE(status)) { | ||
256 | info("%s: _STA evaluation failure\n", __func__); | ||
257 | return 0; | ||
258 | } | ||
259 | if ((tmp & ACPI_STA_DEVICE_FUNCTIONING) == 0) | ||
260 | /* don't register this object */ | ||
261 | return 0; | ||
262 | } | ||
263 | |||
264 | status = acpi_evaluate_integer(handle, "_SEG", NULL, &tmp); | ||
265 | seg = ACPI_SUCCESS(status) ? tmp : 0; | ||
266 | |||
267 | status = acpi_evaluate_integer(handle, "_BBN", NULL, &tmp); | ||
268 | bus = ACPI_SUCCESS(status) ? tmp : 0; | ||
269 | |||
270 | pci_bus = pci_find_bus(seg, bus); | ||
271 | if (!pci_bus) | ||
272 | return 0; | ||
273 | |||
274 | context.pci_bus = pci_bus; | ||
275 | context.user_function = user_function; | ||
276 | context.root_handle = handle; | ||
277 | |||
278 | dbg("root bridge walk, pci_bus = %x\n", pci_bus->number); | ||
279 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, | ||
280 | user_function, &context, NULL); | ||
281 | if (ACPI_FAILURE(status)) | ||
282 | return status; | ||
283 | |||
284 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, | ||
285 | walk_p2p_bridge, &context, NULL); | ||
286 | if (ACPI_FAILURE(status)) | ||
287 | err("%s: walk_p2p_bridge failure - %d\n", __func__, status); | ||
288 | |||
289 | return status; | ||
290 | } | ||
291 | |||
292 | /* | ||
293 | * acpi_pci_slot_add | ||
294 | * @handle: points to an acpi_pci_root | ||
295 | */ | ||
296 | static int | ||
297 | acpi_pci_slot_add(acpi_handle handle) | ||
298 | { | ||
299 | acpi_status status; | ||
300 | |||
301 | status = walk_root_bridge(handle, register_slot); | ||
302 | if (ACPI_FAILURE(status)) | ||
303 | err("%s: register_slot failure - %d\n", __func__, status); | ||
304 | |||
305 | return status; | ||
306 | } | ||
307 | |||
308 | /* | ||
309 | * acpi_pci_slot_remove | ||
310 | * @handle: points to an acpi_pci_root | ||
311 | */ | ||
312 | static void | ||
313 | acpi_pci_slot_remove(acpi_handle handle) | ||
314 | { | ||
315 | struct acpi_pci_slot *slot, *tmp; | ||
316 | |||
317 | mutex_lock(&slot_list_lock); | ||
318 | list_for_each_entry_safe(slot, tmp, &slot_list, list) { | ||
319 | if (slot->root_handle == handle) { | ||
320 | list_del(&slot->list); | ||
321 | pci_destroy_slot(slot->pci_slot); | ||
322 | kfree(slot); | ||
323 | } | ||
324 | } | ||
325 | mutex_unlock(&slot_list_lock); | ||
326 | } | ||
327 | |||
328 | static int do_sta_before_sun(const struct dmi_system_id *d) | ||
329 | { | ||
330 | info("%s detected: will evaluate _STA before calling _SUN\n", d->ident); | ||
331 | check_sta_before_sun = 1; | ||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | static struct dmi_system_id acpi_pci_slot_dmi_table[] __initdata = { | ||
336 | /* | ||
337 | * Fujitsu Primequest machines will return 1023 to indicate an | ||
338 | * error if the _SUN method is evaluated on SxFy objects that | ||
339 | * are not present (as indicated by _STA), so for those machines, | ||
340 | * we want to check _STA before evaluating _SUN. | ||
341 | */ | ||
342 | { | ||
343 | .callback = do_sta_before_sun, | ||
344 | .ident = "Fujitsu PRIMEQUEST", | ||
345 | .matches = { | ||
346 | DMI_MATCH(DMI_BIOS_VENDOR, "FUJITSU LIMITED"), | ||
347 | DMI_MATCH(DMI_BIOS_VERSION, "PRIMEQUEST"), | ||
348 | }, | ||
349 | }, | ||
350 | {} | ||
351 | }; | ||
352 | |||
353 | static int __init | ||
354 | acpi_pci_slot_init(void) | ||
355 | { | ||
356 | dmi_check_system(acpi_pci_slot_dmi_table); | ||
357 | acpi_pci_register_driver(&acpi_pci_slot_driver); | ||
358 | return 0; | ||
359 | } | ||
360 | |||
361 | static void __exit | ||
362 | acpi_pci_slot_exit(void) | ||
363 | { | ||
364 | acpi_pci_unregister_driver(&acpi_pci_slot_driver); | ||
365 | } | ||
366 | |||
367 | module_init(acpi_pci_slot_init); | ||
368 | module_exit(acpi_pci_slot_exit); | ||
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 911ec600fe71..3f940393d6c7 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -453,6 +453,8 @@ int platform_driver_register(struct platform_driver *drv) | |||
453 | drv->driver.suspend = platform_drv_suspend; | 453 | drv->driver.suspend = platform_drv_suspend; |
454 | if (drv->resume) | 454 | if (drv->resume) |
455 | drv->driver.resume = platform_drv_resume; | 455 | drv->driver.resume = platform_drv_resume; |
456 | if (drv->pm) | ||
457 | drv->driver.pm = &drv->pm->base; | ||
456 | return driver_register(&drv->driver); | 458 | return driver_register(&drv->driver); |
457 | } | 459 | } |
458 | EXPORT_SYMBOL_GPL(platform_driver_register); | 460 | EXPORT_SYMBOL_GPL(platform_driver_register); |
@@ -560,7 +562,9 @@ static int platform_match(struct device *dev, struct device_driver *drv) | |||
560 | return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0); | 562 | return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0); |
561 | } | 563 | } |
562 | 564 | ||
563 | static int platform_suspend(struct device *dev, pm_message_t mesg) | 565 | #ifdef CONFIG_PM_SLEEP |
566 | |||
567 | static int platform_legacy_suspend(struct device *dev, pm_message_t mesg) | ||
564 | { | 568 | { |
565 | int ret = 0; | 569 | int ret = 0; |
566 | 570 | ||
@@ -570,7 +574,7 @@ static int platform_suspend(struct device *dev, pm_message_t mesg) | |||
570 | return ret; | 574 | return ret; |
571 | } | 575 | } |
572 | 576 | ||
573 | static int platform_suspend_late(struct device *dev, pm_message_t mesg) | 577 | static int platform_legacy_suspend_late(struct device *dev, pm_message_t mesg) |
574 | { | 578 | { |
575 | struct platform_driver *drv = to_platform_driver(dev->driver); | 579 | struct platform_driver *drv = to_platform_driver(dev->driver); |
576 | struct platform_device *pdev; | 580 | struct platform_device *pdev; |
@@ -583,7 +587,7 @@ static int platform_suspend_late(struct device *dev, pm_message_t mesg) | |||
583 | return ret; | 587 | return ret; |
584 | } | 588 | } |
585 | 589 | ||
586 | static int platform_resume_early(struct device *dev) | 590 | static int platform_legacy_resume_early(struct device *dev) |
587 | { | 591 | { |
588 | struct platform_driver *drv = to_platform_driver(dev->driver); | 592 | struct platform_driver *drv = to_platform_driver(dev->driver); |
589 | struct platform_device *pdev; | 593 | struct platform_device *pdev; |
@@ -596,7 +600,7 @@ static int platform_resume_early(struct device *dev) | |||
596 | return ret; | 600 | return ret; |
597 | } | 601 | } |
598 | 602 | ||
599 | static int platform_resume(struct device *dev) | 603 | static int platform_legacy_resume(struct device *dev) |
600 | { | 604 | { |
601 | int ret = 0; | 605 | int ret = 0; |
602 | 606 | ||
@@ -606,15 +610,291 @@ static int platform_resume(struct device *dev) | |||
606 | return ret; | 610 | return ret; |
607 | } | 611 | } |
608 | 612 | ||
613 | static int platform_pm_prepare(struct device *dev) | ||
614 | { | ||
615 | struct device_driver *drv = dev->driver; | ||
616 | int ret = 0; | ||
617 | |||
618 | if (drv && drv->pm && drv->pm->prepare) | ||
619 | ret = drv->pm->prepare(dev); | ||
620 | |||
621 | return ret; | ||
622 | } | ||
623 | |||
624 | static void platform_pm_complete(struct device *dev) | ||
625 | { | ||
626 | struct device_driver *drv = dev->driver; | ||
627 | |||
628 | if (drv && drv->pm && drv->pm->complete) | ||
629 | drv->pm->complete(dev); | ||
630 | } | ||
631 | |||
632 | #ifdef CONFIG_SUSPEND | ||
633 | |||
634 | static int platform_pm_suspend(struct device *dev) | ||
635 | { | ||
636 | struct device_driver *drv = dev->driver; | ||
637 | int ret = 0; | ||
638 | |||
639 | if (drv && drv->pm) { | ||
640 | if (drv->pm->suspend) | ||
641 | ret = drv->pm->suspend(dev); | ||
642 | } else { | ||
643 | ret = platform_legacy_suspend(dev, PMSG_SUSPEND); | ||
644 | } | ||
645 | |||
646 | return ret; | ||
647 | } | ||
648 | |||
649 | static int platform_pm_suspend_noirq(struct device *dev) | ||
650 | { | ||
651 | struct platform_driver *pdrv; | ||
652 | int ret = 0; | ||
653 | |||
654 | if (!dev->driver) | ||
655 | return 0; | ||
656 | |||
657 | pdrv = to_platform_driver(dev->driver); | ||
658 | if (pdrv->pm) { | ||
659 | if (pdrv->pm->suspend_noirq) | ||
660 | ret = pdrv->pm->suspend_noirq(dev); | ||
661 | } else { | ||
662 | ret = platform_legacy_suspend_late(dev, PMSG_SUSPEND); | ||
663 | } | ||
664 | |||
665 | return ret; | ||
666 | } | ||
667 | |||
668 | static int platform_pm_resume(struct device *dev) | ||
669 | { | ||
670 | struct device_driver *drv = dev->driver; | ||
671 | int ret = 0; | ||
672 | |||
673 | if (drv && drv->pm) { | ||
674 | if (drv->pm->resume) | ||
675 | ret = drv->pm->resume(dev); | ||
676 | } else { | ||
677 | ret = platform_legacy_resume(dev); | ||
678 | } | ||
679 | |||
680 | return ret; | ||
681 | } | ||
682 | |||
683 | static int platform_pm_resume_noirq(struct device *dev) | ||
684 | { | ||
685 | struct platform_driver *pdrv; | ||
686 | int ret = 0; | ||
687 | |||
688 | if (!dev->driver) | ||
689 | return 0; | ||
690 | |||
691 | pdrv = to_platform_driver(dev->driver); | ||
692 | if (pdrv->pm) { | ||
693 | if (pdrv->pm->resume_noirq) | ||
694 | ret = pdrv->pm->resume_noirq(dev); | ||
695 | } else { | ||
696 | ret = platform_legacy_resume_early(dev); | ||
697 | } | ||
698 | |||
699 | return ret; | ||
700 | } | ||
701 | |||
702 | #else /* !CONFIG_SUSPEND */ | ||
703 | |||
704 | #define platform_pm_suspend NULL | ||
705 | #define platform_pm_resume NULL | ||
706 | #define platform_pm_suspend_noirq NULL | ||
707 | #define platform_pm_resume_noirq NULL | ||
708 | |||
709 | #endif /* !CONFIG_SUSPEND */ | ||
710 | |||
711 | #ifdef CONFIG_HIBERNATION | ||
712 | |||
713 | static int platform_pm_freeze(struct device *dev) | ||
714 | { | ||
715 | struct device_driver *drv = dev->driver; | ||
716 | int ret = 0; | ||
717 | |||
718 | if (!drv) | ||
719 | return 0; | ||
720 | |||
721 | if (drv->pm) { | ||
722 | if (drv->pm->freeze) | ||
723 | ret = drv->pm->freeze(dev); | ||
724 | } else { | ||
725 | ret = platform_legacy_suspend(dev, PMSG_FREEZE); | ||
726 | } | ||
727 | |||
728 | return ret; | ||
729 | } | ||
730 | |||
731 | static int platform_pm_freeze_noirq(struct device *dev) | ||
732 | { | ||
733 | struct platform_driver *pdrv; | ||
734 | int ret = 0; | ||
735 | |||
736 | if (!dev->driver) | ||
737 | return 0; | ||
738 | |||
739 | pdrv = to_platform_driver(dev->driver); | ||
740 | if (pdrv->pm) { | ||
741 | if (pdrv->pm->freeze_noirq) | ||
742 | ret = pdrv->pm->freeze_noirq(dev); | ||
743 | } else { | ||
744 | ret = platform_legacy_suspend_late(dev, PMSG_FREEZE); | ||
745 | } | ||
746 | |||
747 | return ret; | ||
748 | } | ||
749 | |||
750 | static int platform_pm_thaw(struct device *dev) | ||
751 | { | ||
752 | struct device_driver *drv = dev->driver; | ||
753 | int ret = 0; | ||
754 | |||
755 | if (drv && drv->pm) { | ||
756 | if (drv->pm->thaw) | ||
757 | ret = drv->pm->thaw(dev); | ||
758 | } else { | ||
759 | ret = platform_legacy_resume(dev); | ||
760 | } | ||
761 | |||
762 | return ret; | ||
763 | } | ||
764 | |||
765 | static int platform_pm_thaw_noirq(struct device *dev) | ||
766 | { | ||
767 | struct platform_driver *pdrv; | ||
768 | int ret = 0; | ||
769 | |||
770 | if (!dev->driver) | ||
771 | return 0; | ||
772 | |||
773 | pdrv = to_platform_driver(dev->driver); | ||
774 | if (pdrv->pm) { | ||
775 | if (pdrv->pm->thaw_noirq) | ||
776 | ret = pdrv->pm->thaw_noirq(dev); | ||
777 | } else { | ||
778 | ret = platform_legacy_resume_early(dev); | ||
779 | } | ||
780 | |||
781 | return ret; | ||
782 | } | ||
783 | |||
784 | static int platform_pm_poweroff(struct device *dev) | ||
785 | { | ||
786 | struct device_driver *drv = dev->driver; | ||
787 | int ret = 0; | ||
788 | |||
789 | if (drv && drv->pm) { | ||
790 | if (drv->pm->poweroff) | ||
791 | ret = drv->pm->poweroff(dev); | ||
792 | } else { | ||
793 | ret = platform_legacy_suspend(dev, PMSG_HIBERNATE); | ||
794 | } | ||
795 | |||
796 | return ret; | ||
797 | } | ||
798 | |||
799 | static int platform_pm_poweroff_noirq(struct device *dev) | ||
800 | { | ||
801 | struct platform_driver *pdrv; | ||
802 | int ret = 0; | ||
803 | |||
804 | if (!dev->driver) | ||
805 | return 0; | ||
806 | |||
807 | pdrv = to_platform_driver(dev->driver); | ||
808 | if (pdrv->pm) { | ||
809 | if (pdrv->pm->poweroff_noirq) | ||
810 | ret = pdrv->pm->poweroff_noirq(dev); | ||
811 | } else { | ||
812 | ret = platform_legacy_suspend_late(dev, PMSG_HIBERNATE); | ||
813 | } | ||
814 | |||
815 | return ret; | ||
816 | } | ||
817 | |||
818 | static int platform_pm_restore(struct device *dev) | ||
819 | { | ||
820 | struct device_driver *drv = dev->driver; | ||
821 | int ret = 0; | ||
822 | |||
823 | if (drv && drv->pm) { | ||
824 | if (drv->pm->restore) | ||
825 | ret = drv->pm->restore(dev); | ||
826 | } else { | ||
827 | ret = platform_legacy_resume(dev); | ||
828 | } | ||
829 | |||
830 | return ret; | ||
831 | } | ||
832 | |||
833 | static int platform_pm_restore_noirq(struct device *dev) | ||
834 | { | ||
835 | struct platform_driver *pdrv; | ||
836 | int ret = 0; | ||
837 | |||
838 | if (!dev->driver) | ||
839 | return 0; | ||
840 | |||
841 | pdrv = to_platform_driver(dev->driver); | ||
842 | if (pdrv->pm) { | ||
843 | if (pdrv->pm->restore_noirq) | ||
844 | ret = pdrv->pm->restore_noirq(dev); | ||
845 | } else { | ||
846 | ret = platform_legacy_resume_early(dev); | ||
847 | } | ||
848 | |||
849 | return ret; | ||
850 | } | ||
851 | |||
852 | #else /* !CONFIG_HIBERNATION */ | ||
853 | |||
854 | #define platform_pm_freeze NULL | ||
855 | #define platform_pm_thaw NULL | ||
856 | #define platform_pm_poweroff NULL | ||
857 | #define platform_pm_restore NULL | ||
858 | #define platform_pm_freeze_noirq NULL | ||
859 | #define platform_pm_thaw_noirq NULL | ||
860 | #define platform_pm_poweroff_noirq NULL | ||
861 | #define platform_pm_restore_noirq NULL | ||
862 | |||
863 | #endif /* !CONFIG_HIBERNATION */ | ||
864 | |||
865 | struct pm_ext_ops platform_pm_ops = { | ||
866 | .base = { | ||
867 | .prepare = platform_pm_prepare, | ||
868 | .complete = platform_pm_complete, | ||
869 | .suspend = platform_pm_suspend, | ||
870 | .resume = platform_pm_resume, | ||
871 | .freeze = platform_pm_freeze, | ||
872 | .thaw = platform_pm_thaw, | ||
873 | .poweroff = platform_pm_poweroff, | ||
874 | .restore = platform_pm_restore, | ||
875 | }, | ||
876 | .suspend_noirq = platform_pm_suspend_noirq, | ||
877 | .resume_noirq = platform_pm_resume_noirq, | ||
878 | .freeze_noirq = platform_pm_freeze_noirq, | ||
879 | .thaw_noirq = platform_pm_thaw_noirq, | ||
880 | .poweroff_noirq = platform_pm_poweroff_noirq, | ||
881 | .restore_noirq = platform_pm_restore_noirq, | ||
882 | }; | ||
883 | |||
884 | #define PLATFORM_PM_OPS_PTR &platform_pm_ops | ||
885 | |||
886 | #else /* !CONFIG_PM_SLEEP */ | ||
887 | |||
888 | #define PLATFORM_PM_OPS_PTR NULL | ||
889 | |||
890 | #endif /* !CONFIG_PM_SLEEP */ | ||
891 | |||
609 | struct bus_type platform_bus_type = { | 892 | struct bus_type platform_bus_type = { |
610 | .name = "platform", | 893 | .name = "platform", |
611 | .dev_attrs = platform_dev_attrs, | 894 | .dev_attrs = platform_dev_attrs, |
612 | .match = platform_match, | 895 | .match = platform_match, |
613 | .uevent = platform_uevent, | 896 | .uevent = platform_uevent, |
614 | .suspend = platform_suspend, | 897 | .pm = PLATFORM_PM_OPS_PTR, |
615 | .suspend_late = platform_suspend_late, | ||
616 | .resume_early = platform_resume_early, | ||
617 | .resume = platform_resume, | ||
618 | }; | 898 | }; |
619 | EXPORT_SYMBOL_GPL(platform_bus_type); | 899 | EXPORT_SYMBOL_GPL(platform_bus_type); |
620 | 900 | ||
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 45cc3d9eacb8..d571204aaff7 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -12,11 +12,9 @@ | |||
12 | * and add it to the list of power-controlled devices. sysfs entries for | 12 | * and add it to the list of power-controlled devices. sysfs entries for |
13 | * controlling device power management will also be added. | 13 | * controlling device power management will also be added. |
14 | * | 14 | * |
15 | * A different set of lists than the global subsystem list are used to | 15 | * A separate list is used for keeping track of power info, because the power |
16 | * keep track of power info because we use different lists to hold | 16 | * domain dependencies may differ from the ancestral dependencies that the |
17 | * devices based on what stage of the power management process they | 17 | * subsystem list maintains. |
18 | * are in. The power domain dependencies may also differ from the | ||
19 | * ancestral dependencies that the subsystem list maintains. | ||
20 | */ | 18 | */ |
21 | 19 | ||
22 | #include <linux/device.h> | 20 | #include <linux/device.h> |
@@ -30,31 +28,40 @@ | |||
30 | #include "power.h" | 28 | #include "power.h" |
31 | 29 | ||
32 | /* | 30 | /* |
33 | * The entries in the dpm_active list are in a depth first order, simply | 31 | * The entries in the dpm_list list are in a depth first order, simply |
34 | * because children are guaranteed to be discovered after parents, and | 32 | * because children are guaranteed to be discovered after parents, and |
35 | * are inserted at the back of the list on discovery. | 33 | * are inserted at the back of the list on discovery. |
36 | * | 34 | * |
37 | * All the other lists are kept in the same order, for consistency. | ||
38 | * However the lists aren't always traversed in the same order. | ||
39 | * Semaphores must be acquired from the top (i.e., front) down | ||
40 | * and released in the opposite order. Devices must be suspended | ||
41 | * from the bottom (i.e., end) up and resumed in the opposite order. | ||
42 | * That way no parent will be suspended while it still has an active | ||
43 | * child. | ||
44 | * | ||
45 | * Since device_pm_add() may be called with a device semaphore held, | 35 | * Since device_pm_add() may be called with a device semaphore held, |
46 | * we must never try to acquire a device semaphore while holding | 36 | * we must never try to acquire a device semaphore while holding |
47 | * dpm_list_mutex. | 37 | * dpm_list_mutex. |
48 | */ | 38 | */ |
49 | 39 | ||
50 | LIST_HEAD(dpm_active); | 40 | LIST_HEAD(dpm_list); |
51 | static LIST_HEAD(dpm_off); | ||
52 | static LIST_HEAD(dpm_off_irq); | ||
53 | 41 | ||
54 | static DEFINE_MUTEX(dpm_list_mtx); | 42 | static DEFINE_MUTEX(dpm_list_mtx); |
55 | 43 | ||
56 | /* 'true' if all devices have been suspended, protected by dpm_list_mtx */ | 44 | /* |
57 | static bool all_sleeping; | 45 | * Set once the preparation of devices for a PM transition has started, reset |
46 | * before starting to resume devices. Protected by dpm_list_mtx. | ||
47 | */ | ||
48 | static bool transition_started; | ||
49 | |||
50 | /** | ||
51 | * device_pm_lock - lock the list of active devices used by the PM core | ||
52 | */ | ||
53 | void device_pm_lock(void) | ||
54 | { | ||
55 | mutex_lock(&dpm_list_mtx); | ||
56 | } | ||
57 | |||
58 | /** | ||
59 | * device_pm_unlock - unlock the list of active devices used by the PM core | ||
60 | */ | ||
61 | void device_pm_unlock(void) | ||
62 | { | ||
63 | mutex_unlock(&dpm_list_mtx); | ||
64 | } | ||
58 | 65 | ||
59 | /** | 66 | /** |
60 | * device_pm_add - add a device to the list of active devices | 67 | * device_pm_add - add a device to the list of active devices |
@@ -68,17 +75,25 @@ int device_pm_add(struct device *dev) | |||
68 | dev->bus ? dev->bus->name : "No Bus", | 75 | dev->bus ? dev->bus->name : "No Bus", |
69 | kobject_name(&dev->kobj)); | 76 | kobject_name(&dev->kobj)); |
70 | mutex_lock(&dpm_list_mtx); | 77 | mutex_lock(&dpm_list_mtx); |
71 | if ((dev->parent && dev->parent->power.sleeping) || all_sleeping) { | 78 | if (dev->parent) { |
72 | if (dev->parent->power.sleeping) | 79 | if (dev->parent->power.status >= DPM_SUSPENDING) { |
73 | dev_warn(dev, "parent %s is sleeping\n", | 80 | dev_warn(dev, "parent %s is sleeping, will not add\n", |
74 | dev->parent->bus_id); | 81 | dev->parent->bus_id); |
75 | else | 82 | WARN_ON(true); |
76 | dev_warn(dev, "all devices are sleeping\n"); | 83 | } |
84 | } else if (transition_started) { | ||
85 | /* | ||
86 | * We refuse to register parentless devices while a PM | ||
87 | * transition is in progress in order to avoid leaving them | ||
88 | * unhandled down the road | ||
89 | */ | ||
77 | WARN_ON(true); | 90 | WARN_ON(true); |
78 | } | 91 | } |
79 | error = dpm_sysfs_add(dev); | 92 | error = dpm_sysfs_add(dev); |
80 | if (!error) | 93 | if (!error) { |
81 | list_add_tail(&dev->power.entry, &dpm_active); | 94 | dev->power.status = DPM_ON; |
95 | list_add_tail(&dev->power.entry, &dpm_list); | ||
96 | } | ||
82 | mutex_unlock(&dpm_list_mtx); | 97 | mutex_unlock(&dpm_list_mtx); |
83 | return error; | 98 | return error; |
84 | } | 99 | } |
@@ -100,73 +115,243 @@ void device_pm_remove(struct device *dev) | |||
100 | mutex_unlock(&dpm_list_mtx); | 115 | mutex_unlock(&dpm_list_mtx); |
101 | } | 116 | } |
102 | 117 | ||
118 | /** | ||
119 | * pm_op - execute the PM operation appropiate for given PM event | ||
120 | * @dev: Device. | ||
121 | * @ops: PM operations to choose from. | ||
122 | * @state: PM transition of the system being carried out. | ||
123 | */ | ||
124 | static int pm_op(struct device *dev, struct pm_ops *ops, pm_message_t state) | ||
125 | { | ||
126 | int error = 0; | ||
127 | |||
128 | switch (state.event) { | ||
129 | #ifdef CONFIG_SUSPEND | ||
130 | case PM_EVENT_SUSPEND: | ||
131 | if (ops->suspend) { | ||
132 | error = ops->suspend(dev); | ||
133 | suspend_report_result(ops->suspend, error); | ||
134 | } | ||
135 | break; | ||
136 | case PM_EVENT_RESUME: | ||
137 | if (ops->resume) { | ||
138 | error = ops->resume(dev); | ||
139 | suspend_report_result(ops->resume, error); | ||
140 | } | ||
141 | break; | ||
142 | #endif /* CONFIG_SUSPEND */ | ||
143 | #ifdef CONFIG_HIBERNATION | ||
144 | case PM_EVENT_FREEZE: | ||
145 | case PM_EVENT_QUIESCE: | ||
146 | if (ops->freeze) { | ||
147 | error = ops->freeze(dev); | ||
148 | suspend_report_result(ops->freeze, error); | ||
149 | } | ||
150 | break; | ||
151 | case PM_EVENT_HIBERNATE: | ||
152 | if (ops->poweroff) { | ||
153 | error = ops->poweroff(dev); | ||
154 | suspend_report_result(ops->poweroff, error); | ||
155 | } | ||
156 | break; | ||
157 | case PM_EVENT_THAW: | ||
158 | case PM_EVENT_RECOVER: | ||
159 | if (ops->thaw) { | ||
160 | error = ops->thaw(dev); | ||
161 | suspend_report_result(ops->thaw, error); | ||
162 | } | ||
163 | break; | ||
164 | case PM_EVENT_RESTORE: | ||
165 | if (ops->restore) { | ||
166 | error = ops->restore(dev); | ||
167 | suspend_report_result(ops->restore, error); | ||
168 | } | ||
169 | break; | ||
170 | #endif /* CONFIG_HIBERNATION */ | ||
171 | default: | ||
172 | error = -EINVAL; | ||
173 | } | ||
174 | return error; | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * pm_noirq_op - execute the PM operation appropiate for given PM event | ||
179 | * @dev: Device. | ||
180 | * @ops: PM operations to choose from. | ||
181 | * @state: PM transition of the system being carried out. | ||
182 | * | ||
183 | * The operation is executed with interrupts disabled by the only remaining | ||
184 | * functional CPU in the system. | ||
185 | */ | ||
186 | static int pm_noirq_op(struct device *dev, struct pm_ext_ops *ops, | ||
187 | pm_message_t state) | ||
188 | { | ||
189 | int error = 0; | ||
190 | |||
191 | switch (state.event) { | ||
192 | #ifdef CONFIG_SUSPEND | ||
193 | case PM_EVENT_SUSPEND: | ||
194 | if (ops->suspend_noirq) { | ||
195 | error = ops->suspend_noirq(dev); | ||
196 | suspend_report_result(ops->suspend_noirq, error); | ||
197 | } | ||
198 | break; | ||
199 | case PM_EVENT_RESUME: | ||
200 | if (ops->resume_noirq) { | ||
201 | error = ops->resume_noirq(dev); | ||
202 | suspend_report_result(ops->resume_noirq, error); | ||
203 | } | ||
204 | break; | ||
205 | #endif /* CONFIG_SUSPEND */ | ||
206 | #ifdef CONFIG_HIBERNATION | ||
207 | case PM_EVENT_FREEZE: | ||
208 | case PM_EVENT_QUIESCE: | ||
209 | if (ops->freeze_noirq) { | ||
210 | error = ops->freeze_noirq(dev); | ||
211 | suspend_report_result(ops->freeze_noirq, error); | ||
212 | } | ||
213 | break; | ||
214 | case PM_EVENT_HIBERNATE: | ||
215 | if (ops->poweroff_noirq) { | ||
216 | error = ops->poweroff_noirq(dev); | ||
217 | suspend_report_result(ops->poweroff_noirq, error); | ||
218 | } | ||
219 | break; | ||
220 | case PM_EVENT_THAW: | ||
221 | case PM_EVENT_RECOVER: | ||
222 | if (ops->thaw_noirq) { | ||
223 | error = ops->thaw_noirq(dev); | ||
224 | suspend_report_result(ops->thaw_noirq, error); | ||
225 | } | ||
226 | break; | ||
227 | case PM_EVENT_RESTORE: | ||
228 | if (ops->restore_noirq) { | ||
229 | error = ops->restore_noirq(dev); | ||
230 | suspend_report_result(ops->restore_noirq, error); | ||
231 | } | ||
232 | break; | ||
233 | #endif /* CONFIG_HIBERNATION */ | ||
234 | default: | ||
235 | error = -EINVAL; | ||
236 | } | ||
237 | return error; | ||
238 | } | ||
239 | |||
240 | static char *pm_verb(int event) | ||
241 | { | ||
242 | switch (event) { | ||
243 | case PM_EVENT_SUSPEND: | ||
244 | return "suspend"; | ||
245 | case PM_EVENT_RESUME: | ||
246 | return "resume"; | ||
247 | case PM_EVENT_FREEZE: | ||
248 | return "freeze"; | ||
249 | case PM_EVENT_QUIESCE: | ||
250 | return "quiesce"; | ||
251 | case PM_EVENT_HIBERNATE: | ||
252 | return "hibernate"; | ||
253 | case PM_EVENT_THAW: | ||
254 | return "thaw"; | ||
255 | case PM_EVENT_RESTORE: | ||
256 | return "restore"; | ||
257 | case PM_EVENT_RECOVER: | ||
258 | return "recover"; | ||
259 | default: | ||
260 | return "(unknown PM event)"; | ||
261 | } | ||
262 | } | ||
263 | |||
264 | static void pm_dev_dbg(struct device *dev, pm_message_t state, char *info) | ||
265 | { | ||
266 | dev_dbg(dev, "%s%s%s\n", info, pm_verb(state.event), | ||
267 | ((state.event & PM_EVENT_SLEEP) && device_may_wakeup(dev)) ? | ||
268 | ", may wakeup" : ""); | ||
269 | } | ||
270 | |||
271 | static void pm_dev_err(struct device *dev, pm_message_t state, char *info, | ||
272 | int error) | ||
273 | { | ||
274 | printk(KERN_ERR "PM: Device %s failed to %s%s: error %d\n", | ||
275 | kobject_name(&dev->kobj), pm_verb(state.event), info, error); | ||
276 | } | ||
277 | |||
103 | /*------------------------- Resume routines -------------------------*/ | 278 | /*------------------------- Resume routines -------------------------*/ |
104 | 279 | ||
105 | /** | 280 | /** |
106 | * resume_device_early - Power on one device (early resume). | 281 | * resume_device_noirq - Power on one device (early resume). |
107 | * @dev: Device. | 282 | * @dev: Device. |
283 | * @state: PM transition of the system being carried out. | ||
108 | * | 284 | * |
109 | * Must be called with interrupts disabled. | 285 | * Must be called with interrupts disabled. |
110 | */ | 286 | */ |
111 | static int resume_device_early(struct device *dev) | 287 | static int resume_device_noirq(struct device *dev, pm_message_t state) |
112 | { | 288 | { |
113 | int error = 0; | 289 | int error = 0; |
114 | 290 | ||
115 | TRACE_DEVICE(dev); | 291 | TRACE_DEVICE(dev); |
116 | TRACE_RESUME(0); | 292 | TRACE_RESUME(0); |
117 | 293 | ||
118 | if (dev->bus && dev->bus->resume_early) { | 294 | if (!dev->bus) |
119 | dev_dbg(dev, "EARLY resume\n"); | 295 | goto End; |
296 | |||
297 | if (dev->bus->pm) { | ||
298 | pm_dev_dbg(dev, state, "EARLY "); | ||
299 | error = pm_noirq_op(dev, dev->bus->pm, state); | ||
300 | } else if (dev->bus->resume_early) { | ||
301 | pm_dev_dbg(dev, state, "legacy EARLY "); | ||
120 | error = dev->bus->resume_early(dev); | 302 | error = dev->bus->resume_early(dev); |
121 | } | 303 | } |
122 | 304 | End: | |
123 | TRACE_RESUME(error); | 305 | TRACE_RESUME(error); |
124 | return error; | 306 | return error; |
125 | } | 307 | } |
126 | 308 | ||
127 | /** | 309 | /** |
128 | * dpm_power_up - Power on all regular (non-sysdev) devices. | 310 | * dpm_power_up - Power on all regular (non-sysdev) devices. |
311 | * @state: PM transition of the system being carried out. | ||
129 | * | 312 | * |
130 | * Walk the dpm_off_irq list and power each device up. This | 313 | * Execute the appropriate "noirq resume" callback for all devices marked |
131 | * is used for devices that required they be powered down with | 314 | * as DPM_OFF_IRQ. |
132 | * interrupts disabled. As devices are powered on, they are moved | ||
133 | * to the dpm_off list. | ||
134 | * | 315 | * |
135 | * Must be called with interrupts disabled and only one CPU running. | 316 | * Must be called with interrupts disabled and only one CPU running. |
136 | */ | 317 | */ |
137 | static void dpm_power_up(void) | 318 | static void dpm_power_up(pm_message_t state) |
138 | { | 319 | { |
320 | struct device *dev; | ||
139 | 321 | ||
140 | while (!list_empty(&dpm_off_irq)) { | 322 | list_for_each_entry(dev, &dpm_list, power.entry) |
141 | struct list_head *entry = dpm_off_irq.next; | 323 | if (dev->power.status > DPM_OFF) { |
142 | struct device *dev = to_device(entry); | 324 | int error; |
143 | 325 | ||
144 | list_move_tail(entry, &dpm_off); | 326 | dev->power.status = DPM_OFF; |
145 | resume_device_early(dev); | 327 | error = resume_device_noirq(dev, state); |
146 | } | 328 | if (error) |
329 | pm_dev_err(dev, state, " early", error); | ||
330 | } | ||
147 | } | 331 | } |
148 | 332 | ||
149 | /** | 333 | /** |
150 | * device_power_up - Turn on all devices that need special attention. | 334 | * device_power_up - Turn on all devices that need special attention. |
335 | * @state: PM transition of the system being carried out. | ||
151 | * | 336 | * |
152 | * Power on system devices, then devices that required we shut them down | 337 | * Power on system devices, then devices that required we shut them down |
153 | * with interrupts disabled. | 338 | * with interrupts disabled. |
154 | * | 339 | * |
155 | * Must be called with interrupts disabled. | 340 | * Must be called with interrupts disabled. |
156 | */ | 341 | */ |
157 | void device_power_up(void) | 342 | void device_power_up(pm_message_t state) |
158 | { | 343 | { |
159 | sysdev_resume(); | 344 | sysdev_resume(); |
160 | dpm_power_up(); | 345 | dpm_power_up(state); |
161 | } | 346 | } |
162 | EXPORT_SYMBOL_GPL(device_power_up); | 347 | EXPORT_SYMBOL_GPL(device_power_up); |
163 | 348 | ||
164 | /** | 349 | /** |
165 | * resume_device - Restore state for one device. | 350 | * resume_device - Restore state for one device. |
166 | * @dev: Device. | 351 | * @dev: Device. |
167 | * | 352 | * @state: PM transition of the system being carried out. |
168 | */ | 353 | */ |
169 | static int resume_device(struct device *dev) | 354 | static int resume_device(struct device *dev, pm_message_t state) |
170 | { | 355 | { |
171 | int error = 0; | 356 | int error = 0; |
172 | 357 | ||
@@ -175,21 +360,40 @@ static int resume_device(struct device *dev) | |||
175 | 360 | ||
176 | down(&dev->sem); | 361 | down(&dev->sem); |
177 | 362 | ||
178 | if (dev->bus && dev->bus->resume) { | 363 | if (dev->bus) { |
179 | dev_dbg(dev,"resuming\n"); | 364 | if (dev->bus->pm) { |
180 | error = dev->bus->resume(dev); | 365 | pm_dev_dbg(dev, state, ""); |
366 | error = pm_op(dev, &dev->bus->pm->base, state); | ||
367 | } else if (dev->bus->resume) { | ||
368 | pm_dev_dbg(dev, state, "legacy "); | ||
369 | error = dev->bus->resume(dev); | ||
370 | } | ||
371 | if (error) | ||
372 | goto End; | ||
181 | } | 373 | } |
182 | 374 | ||
183 | if (!error && dev->type && dev->type->resume) { | 375 | if (dev->type) { |
184 | dev_dbg(dev,"resuming\n"); | 376 | if (dev->type->pm) { |
185 | error = dev->type->resume(dev); | 377 | pm_dev_dbg(dev, state, "type "); |
378 | error = pm_op(dev, dev->type->pm, state); | ||
379 | } else if (dev->type->resume) { | ||
380 | pm_dev_dbg(dev, state, "legacy type "); | ||
381 | error = dev->type->resume(dev); | ||
382 | } | ||
383 | if (error) | ||
384 | goto End; | ||
186 | } | 385 | } |
187 | 386 | ||
188 | if (!error && dev->class && dev->class->resume) { | 387 | if (dev->class) { |
189 | dev_dbg(dev,"class resume\n"); | 388 | if (dev->class->pm) { |
190 | error = dev->class->resume(dev); | 389 | pm_dev_dbg(dev, state, "class "); |
390 | error = pm_op(dev, dev->class->pm, state); | ||
391 | } else if (dev->class->resume) { | ||
392 | pm_dev_dbg(dev, state, "legacy class "); | ||
393 | error = dev->class->resume(dev); | ||
394 | } | ||
191 | } | 395 | } |
192 | 396 | End: | |
193 | up(&dev->sem); | 397 | up(&dev->sem); |
194 | 398 | ||
195 | TRACE_RESUME(error); | 399 | TRACE_RESUME(error); |
@@ -198,78 +402,161 @@ static int resume_device(struct device *dev) | |||
198 | 402 | ||
199 | /** | 403 | /** |
200 | * dpm_resume - Resume every device. | 404 | * dpm_resume - Resume every device. |
405 | * @state: PM transition of the system being carried out. | ||
201 | * | 406 | * |
202 | * Resume the devices that have either not gone through | 407 | * Execute the appropriate "resume" callback for all devices the status of |
203 | * the late suspend, or that did go through it but also | 408 | * which indicates that they are inactive. |
204 | * went through the early resume. | 409 | */ |
410 | static void dpm_resume(pm_message_t state) | ||
411 | { | ||
412 | struct list_head list; | ||
413 | |||
414 | INIT_LIST_HEAD(&list); | ||
415 | mutex_lock(&dpm_list_mtx); | ||
416 | transition_started = false; | ||
417 | while (!list_empty(&dpm_list)) { | ||
418 | struct device *dev = to_device(dpm_list.next); | ||
419 | |||
420 | get_device(dev); | ||
421 | if (dev->power.status >= DPM_OFF) { | ||
422 | int error; | ||
423 | |||
424 | dev->power.status = DPM_RESUMING; | ||
425 | mutex_unlock(&dpm_list_mtx); | ||
426 | |||
427 | error = resume_device(dev, state); | ||
428 | |||
429 | mutex_lock(&dpm_list_mtx); | ||
430 | if (error) | ||
431 | pm_dev_err(dev, state, "", error); | ||
432 | } else if (dev->power.status == DPM_SUSPENDING) { | ||
433 | /* Allow new children of the device to be registered */ | ||
434 | dev->power.status = DPM_RESUMING; | ||
435 | } | ||
436 | if (!list_empty(&dev->power.entry)) | ||
437 | list_move_tail(&dev->power.entry, &list); | ||
438 | put_device(dev); | ||
439 | } | ||
440 | list_splice(&list, &dpm_list); | ||
441 | mutex_unlock(&dpm_list_mtx); | ||
442 | } | ||
443 | |||
444 | /** | ||
445 | * complete_device - Complete a PM transition for given device | ||
446 | * @dev: Device. | ||
447 | * @state: PM transition of the system being carried out. | ||
448 | */ | ||
449 | static void complete_device(struct device *dev, pm_message_t state) | ||
450 | { | ||
451 | down(&dev->sem); | ||
452 | |||
453 | if (dev->class && dev->class->pm && dev->class->pm->complete) { | ||
454 | pm_dev_dbg(dev, state, "completing class "); | ||
455 | dev->class->pm->complete(dev); | ||
456 | } | ||
457 | |||
458 | if (dev->type && dev->type->pm && dev->type->pm->complete) { | ||
459 | pm_dev_dbg(dev, state, "completing type "); | ||
460 | dev->type->pm->complete(dev); | ||
461 | } | ||
462 | |||
463 | if (dev->bus && dev->bus->pm && dev->bus->pm->base.complete) { | ||
464 | pm_dev_dbg(dev, state, "completing "); | ||
465 | dev->bus->pm->base.complete(dev); | ||
466 | } | ||
467 | |||
468 | up(&dev->sem); | ||
469 | } | ||
470 | |||
471 | /** | ||
472 | * dpm_complete - Complete a PM transition for all devices. | ||
473 | * @state: PM transition of the system being carried out. | ||
205 | * | 474 | * |
206 | * Take devices from the dpm_off_list, resume them, | 475 | * Execute the ->complete() callbacks for all devices that are not marked |
207 | * and put them on the dpm_locked list. | 476 | * as DPM_ON. |
208 | */ | 477 | */ |
209 | static void dpm_resume(void) | 478 | static void dpm_complete(pm_message_t state) |
210 | { | 479 | { |
480 | struct list_head list; | ||
481 | |||
482 | INIT_LIST_HEAD(&list); | ||
211 | mutex_lock(&dpm_list_mtx); | 483 | mutex_lock(&dpm_list_mtx); |
212 | all_sleeping = false; | 484 | while (!list_empty(&dpm_list)) { |
213 | while(!list_empty(&dpm_off)) { | 485 | struct device *dev = to_device(dpm_list.prev); |
214 | struct list_head *entry = dpm_off.next; | ||
215 | struct device *dev = to_device(entry); | ||
216 | 486 | ||
217 | list_move_tail(entry, &dpm_active); | 487 | get_device(dev); |
218 | dev->power.sleeping = false; | 488 | if (dev->power.status > DPM_ON) { |
219 | mutex_unlock(&dpm_list_mtx); | 489 | dev->power.status = DPM_ON; |
220 | resume_device(dev); | 490 | mutex_unlock(&dpm_list_mtx); |
221 | mutex_lock(&dpm_list_mtx); | 491 | |
492 | complete_device(dev, state); | ||
493 | |||
494 | mutex_lock(&dpm_list_mtx); | ||
495 | } | ||
496 | if (!list_empty(&dev->power.entry)) | ||
497 | list_move(&dev->power.entry, &list); | ||
498 | put_device(dev); | ||
222 | } | 499 | } |
500 | list_splice(&list, &dpm_list); | ||
223 | mutex_unlock(&dpm_list_mtx); | 501 | mutex_unlock(&dpm_list_mtx); |
224 | } | 502 | } |
225 | 503 | ||
226 | /** | 504 | /** |
227 | * device_resume - Restore state of each device in system. | 505 | * device_resume - Restore state of each device in system. |
506 | * @state: PM transition of the system being carried out. | ||
228 | * | 507 | * |
229 | * Resume all the devices, unlock them all, and allow new | 508 | * Resume all the devices, unlock them all, and allow new |
230 | * devices to be registered once again. | 509 | * devices to be registered once again. |
231 | */ | 510 | */ |
232 | void device_resume(void) | 511 | void device_resume(pm_message_t state) |
233 | { | 512 | { |
234 | might_sleep(); | 513 | might_sleep(); |
235 | dpm_resume(); | 514 | dpm_resume(state); |
515 | dpm_complete(state); | ||
236 | } | 516 | } |
237 | EXPORT_SYMBOL_GPL(device_resume); | 517 | EXPORT_SYMBOL_GPL(device_resume); |
238 | 518 | ||
239 | 519 | ||
240 | /*------------------------- Suspend routines -------------------------*/ | 520 | /*------------------------- Suspend routines -------------------------*/ |
241 | 521 | ||
242 | static inline char *suspend_verb(u32 event) | 522 | /** |
523 | * resume_event - return a PM message representing the resume event | ||
524 | * corresponding to given sleep state. | ||
525 | * @sleep_state: PM message representing a sleep state. | ||
526 | */ | ||
527 | static pm_message_t resume_event(pm_message_t sleep_state) | ||
243 | { | 528 | { |
244 | switch (event) { | 529 | switch (sleep_state.event) { |
245 | case PM_EVENT_SUSPEND: return "suspend"; | 530 | case PM_EVENT_SUSPEND: |
246 | case PM_EVENT_FREEZE: return "freeze"; | 531 | return PMSG_RESUME; |
247 | case PM_EVENT_PRETHAW: return "prethaw"; | 532 | case PM_EVENT_FREEZE: |
248 | default: return "(unknown suspend event)"; | 533 | case PM_EVENT_QUIESCE: |
534 | return PMSG_RECOVER; | ||
535 | case PM_EVENT_HIBERNATE: | ||
536 | return PMSG_RESTORE; | ||
249 | } | 537 | } |
250 | } | 538 | return PMSG_ON; |
251 | |||
252 | static void | ||
253 | suspend_device_dbg(struct device *dev, pm_message_t state, char *info) | ||
254 | { | ||
255 | dev_dbg(dev, "%s%s%s\n", info, suspend_verb(state.event), | ||
256 | ((state.event == PM_EVENT_SUSPEND) && device_may_wakeup(dev)) ? | ||
257 | ", may wakeup" : ""); | ||
258 | } | 539 | } |
259 | 540 | ||
260 | /** | 541 | /** |
261 | * suspend_device_late - Shut down one device (late suspend). | 542 | * suspend_device_noirq - Shut down one device (late suspend). |
262 | * @dev: Device. | 543 | * @dev: Device. |
263 | * @state: Power state device is entering. | 544 | * @state: PM transition of the system being carried out. |
264 | * | 545 | * |
265 | * This is called with interrupts off and only a single CPU running. | 546 | * This is called with interrupts off and only a single CPU running. |
266 | */ | 547 | */ |
267 | static int suspend_device_late(struct device *dev, pm_message_t state) | 548 | static int suspend_device_noirq(struct device *dev, pm_message_t state) |
268 | { | 549 | { |
269 | int error = 0; | 550 | int error = 0; |
270 | 551 | ||
271 | if (dev->bus && dev->bus->suspend_late) { | 552 | if (!dev->bus) |
272 | suspend_device_dbg(dev, state, "LATE "); | 553 | return 0; |
554 | |||
555 | if (dev->bus->pm) { | ||
556 | pm_dev_dbg(dev, state, "LATE "); | ||
557 | error = pm_noirq_op(dev, dev->bus->pm, state); | ||
558 | } else if (dev->bus->suspend_late) { | ||
559 | pm_dev_dbg(dev, state, "legacy LATE "); | ||
273 | error = dev->bus->suspend_late(dev, state); | 560 | error = dev->bus->suspend_late(dev, state); |
274 | suspend_report_result(dev->bus->suspend_late, error); | 561 | suspend_report_result(dev->bus->suspend_late, error); |
275 | } | 562 | } |
@@ -278,37 +565,30 @@ static int suspend_device_late(struct device *dev, pm_message_t state) | |||
278 | 565 | ||
279 | /** | 566 | /** |
280 | * device_power_down - Shut down special devices. | 567 | * device_power_down - Shut down special devices. |
281 | * @state: Power state to enter. | 568 | * @state: PM transition of the system being carried out. |
282 | * | 569 | * |
283 | * Power down devices that require interrupts to be disabled | 570 | * Power down devices that require interrupts to be disabled. |
284 | * and move them from the dpm_off list to the dpm_off_irq list. | ||
285 | * Then power down system devices. | 571 | * Then power down system devices. |
286 | * | 572 | * |
287 | * Must be called with interrupts disabled and only one CPU running. | 573 | * Must be called with interrupts disabled and only one CPU running. |
288 | */ | 574 | */ |
289 | int device_power_down(pm_message_t state) | 575 | int device_power_down(pm_message_t state) |
290 | { | 576 | { |
577 | struct device *dev; | ||
291 | int error = 0; | 578 | int error = 0; |
292 | 579 | ||
293 | while (!list_empty(&dpm_off)) { | 580 | list_for_each_entry_reverse(dev, &dpm_list, power.entry) { |
294 | struct list_head *entry = dpm_off.prev; | 581 | error = suspend_device_noirq(dev, state); |
295 | struct device *dev = to_device(entry); | ||
296 | |||
297 | error = suspend_device_late(dev, state); | ||
298 | if (error) { | 582 | if (error) { |
299 | printk(KERN_ERR "Could not power down device %s: " | 583 | pm_dev_err(dev, state, " late", error); |
300 | "error %d\n", | ||
301 | kobject_name(&dev->kobj), error); | ||
302 | break; | 584 | break; |
303 | } | 585 | } |
304 | if (!list_empty(&dev->power.entry)) | 586 | dev->power.status = DPM_OFF_IRQ; |
305 | list_move(&dev->power.entry, &dpm_off_irq); | ||
306 | } | 587 | } |
307 | |||
308 | if (!error) | 588 | if (!error) |
309 | error = sysdev_suspend(state); | 589 | error = sysdev_suspend(state); |
310 | if (error) | 590 | if (error) |
311 | dpm_power_up(); | 591 | dpm_power_up(resume_event(state)); |
312 | return error; | 592 | return error; |
313 | } | 593 | } |
314 | EXPORT_SYMBOL_GPL(device_power_down); | 594 | EXPORT_SYMBOL_GPL(device_power_down); |
@@ -316,7 +596,7 @@ EXPORT_SYMBOL_GPL(device_power_down); | |||
316 | /** | 596 | /** |
317 | * suspend_device - Save state of one device. | 597 | * suspend_device - Save state of one device. |
318 | * @dev: Device. | 598 | * @dev: Device. |
319 | * @state: Power state device is entering. | 599 | * @state: PM transition of the system being carried out. |
320 | */ | 600 | */ |
321 | static int suspend_device(struct device *dev, pm_message_t state) | 601 | static int suspend_device(struct device *dev, pm_message_t state) |
322 | { | 602 | { |
@@ -324,24 +604,43 @@ static int suspend_device(struct device *dev, pm_message_t state) | |||
324 | 604 | ||
325 | down(&dev->sem); | 605 | down(&dev->sem); |
326 | 606 | ||
327 | if (dev->class && dev->class->suspend) { | 607 | if (dev->class) { |
328 | suspend_device_dbg(dev, state, "class "); | 608 | if (dev->class->pm) { |
329 | error = dev->class->suspend(dev, state); | 609 | pm_dev_dbg(dev, state, "class "); |
330 | suspend_report_result(dev->class->suspend, error); | 610 | error = pm_op(dev, dev->class->pm, state); |
611 | } else if (dev->class->suspend) { | ||
612 | pm_dev_dbg(dev, state, "legacy class "); | ||
613 | error = dev->class->suspend(dev, state); | ||
614 | suspend_report_result(dev->class->suspend, error); | ||
615 | } | ||
616 | if (error) | ||
617 | goto End; | ||
331 | } | 618 | } |
332 | 619 | ||
333 | if (!error && dev->type && dev->type->suspend) { | 620 | if (dev->type) { |
334 | suspend_device_dbg(dev, state, "type "); | 621 | if (dev->type->pm) { |
335 | error = dev->type->suspend(dev, state); | 622 | pm_dev_dbg(dev, state, "type "); |
336 | suspend_report_result(dev->type->suspend, error); | 623 | error = pm_op(dev, dev->type->pm, state); |
624 | } else if (dev->type->suspend) { | ||
625 | pm_dev_dbg(dev, state, "legacy type "); | ||
626 | error = dev->type->suspend(dev, state); | ||
627 | suspend_report_result(dev->type->suspend, error); | ||
628 | } | ||
629 | if (error) | ||
630 | goto End; | ||
337 | } | 631 | } |
338 | 632 | ||
339 | if (!error && dev->bus && dev->bus->suspend) { | 633 | if (dev->bus) { |
340 | suspend_device_dbg(dev, state, ""); | 634 | if (dev->bus->pm) { |
341 | error = dev->bus->suspend(dev, state); | 635 | pm_dev_dbg(dev, state, ""); |
342 | suspend_report_result(dev->bus->suspend, error); | 636 | error = pm_op(dev, &dev->bus->pm->base, state); |
637 | } else if (dev->bus->suspend) { | ||
638 | pm_dev_dbg(dev, state, "legacy "); | ||
639 | error = dev->bus->suspend(dev, state); | ||
640 | suspend_report_result(dev->bus->suspend, error); | ||
641 | } | ||
343 | } | 642 | } |
344 | 643 | End: | |
345 | up(&dev->sem); | 644 | up(&dev->sem); |
346 | 645 | ||
347 | return error; | 646 | return error; |
@@ -349,67 +648,141 @@ static int suspend_device(struct device *dev, pm_message_t state) | |||
349 | 648 | ||
350 | /** | 649 | /** |
351 | * dpm_suspend - Suspend every device. | 650 | * dpm_suspend - Suspend every device. |
352 | * @state: Power state to put each device in. | 651 | * @state: PM transition of the system being carried out. |
353 | * | 652 | * |
354 | * Walk the dpm_locked list. Suspend each device and move it | 653 | * Execute the appropriate "suspend" callbacks for all devices. |
355 | * to the dpm_off list. | ||
356 | * | ||
357 | * (For historical reasons, if it returns -EAGAIN, that used to mean | ||
358 | * that the device would be called again with interrupts disabled. | ||
359 | * These days, we use the "suspend_late()" callback for that, so we | ||
360 | * print a warning and consider it an error). | ||
361 | */ | 654 | */ |
362 | static int dpm_suspend(pm_message_t state) | 655 | static int dpm_suspend(pm_message_t state) |
363 | { | 656 | { |
657 | struct list_head list; | ||
364 | int error = 0; | 658 | int error = 0; |
365 | 659 | ||
660 | INIT_LIST_HEAD(&list); | ||
366 | mutex_lock(&dpm_list_mtx); | 661 | mutex_lock(&dpm_list_mtx); |
367 | while (!list_empty(&dpm_active)) { | 662 | while (!list_empty(&dpm_list)) { |
368 | struct list_head *entry = dpm_active.prev; | 663 | struct device *dev = to_device(dpm_list.prev); |
369 | struct device *dev = to_device(entry); | ||
370 | |||
371 | WARN_ON(dev->parent && dev->parent->power.sleeping); | ||
372 | 664 | ||
373 | dev->power.sleeping = true; | 665 | get_device(dev); |
374 | mutex_unlock(&dpm_list_mtx); | 666 | mutex_unlock(&dpm_list_mtx); |
667 | |||
375 | error = suspend_device(dev, state); | 668 | error = suspend_device(dev, state); |
669 | |||
376 | mutex_lock(&dpm_list_mtx); | 670 | mutex_lock(&dpm_list_mtx); |
377 | if (error) { | 671 | if (error) { |
378 | printk(KERN_ERR "Could not suspend device %s: " | 672 | pm_dev_err(dev, state, "", error); |
379 | "error %d%s\n", | 673 | put_device(dev); |
380 | kobject_name(&dev->kobj), | ||
381 | error, | ||
382 | (error == -EAGAIN ? | ||
383 | " (please convert to suspend_late)" : | ||
384 | "")); | ||
385 | dev->power.sleeping = false; | ||
386 | break; | 674 | break; |
387 | } | 675 | } |
676 | dev->power.status = DPM_OFF; | ||
388 | if (!list_empty(&dev->power.entry)) | 677 | if (!list_empty(&dev->power.entry)) |
389 | list_move(&dev->power.entry, &dpm_off); | 678 | list_move(&dev->power.entry, &list); |
679 | put_device(dev); | ||
390 | } | 680 | } |
391 | if (!error) | 681 | list_splice(&list, dpm_list.prev); |
392 | all_sleeping = true; | ||
393 | mutex_unlock(&dpm_list_mtx); | 682 | mutex_unlock(&dpm_list_mtx); |
683 | return error; | ||
684 | } | ||
685 | |||
686 | /** | ||
687 | * prepare_device - Execute the ->prepare() callback(s) for given device. | ||
688 | * @dev: Device. | ||
689 | * @state: PM transition of the system being carried out. | ||
690 | */ | ||
691 | static int prepare_device(struct device *dev, pm_message_t state) | ||
692 | { | ||
693 | int error = 0; | ||
694 | |||
695 | down(&dev->sem); | ||
696 | |||
697 | if (dev->bus && dev->bus->pm && dev->bus->pm->base.prepare) { | ||
698 | pm_dev_dbg(dev, state, "preparing "); | ||
699 | error = dev->bus->pm->base.prepare(dev); | ||
700 | suspend_report_result(dev->bus->pm->base.prepare, error); | ||
701 | if (error) | ||
702 | goto End; | ||
703 | } | ||
704 | |||
705 | if (dev->type && dev->type->pm && dev->type->pm->prepare) { | ||
706 | pm_dev_dbg(dev, state, "preparing type "); | ||
707 | error = dev->type->pm->prepare(dev); | ||
708 | suspend_report_result(dev->type->pm->prepare, error); | ||
709 | if (error) | ||
710 | goto End; | ||
711 | } | ||
712 | |||
713 | if (dev->class && dev->class->pm && dev->class->pm->prepare) { | ||
714 | pm_dev_dbg(dev, state, "preparing class "); | ||
715 | error = dev->class->pm->prepare(dev); | ||
716 | suspend_report_result(dev->class->pm->prepare, error); | ||
717 | } | ||
718 | End: | ||
719 | up(&dev->sem); | ||
720 | |||
721 | return error; | ||
722 | } | ||
394 | 723 | ||
724 | /** | ||
725 | * dpm_prepare - Prepare all devices for a PM transition. | ||
726 | * @state: PM transition of the system being carried out. | ||
727 | * | ||
728 | * Execute the ->prepare() callback for all devices. | ||
729 | */ | ||
730 | static int dpm_prepare(pm_message_t state) | ||
731 | { | ||
732 | struct list_head list; | ||
733 | int error = 0; | ||
734 | |||
735 | INIT_LIST_HEAD(&list); | ||
736 | mutex_lock(&dpm_list_mtx); | ||
737 | transition_started = true; | ||
738 | while (!list_empty(&dpm_list)) { | ||
739 | struct device *dev = to_device(dpm_list.next); | ||
740 | |||
741 | get_device(dev); | ||
742 | dev->power.status = DPM_PREPARING; | ||
743 | mutex_unlock(&dpm_list_mtx); | ||
744 | |||
745 | error = prepare_device(dev, state); | ||
746 | |||
747 | mutex_lock(&dpm_list_mtx); | ||
748 | if (error) { | ||
749 | dev->power.status = DPM_ON; | ||
750 | if (error == -EAGAIN) { | ||
751 | put_device(dev); | ||
752 | continue; | ||
753 | } | ||
754 | printk(KERN_ERR "PM: Failed to prepare device %s " | ||
755 | "for power transition: error %d\n", | ||
756 | kobject_name(&dev->kobj), error); | ||
757 | put_device(dev); | ||
758 | break; | ||
759 | } | ||
760 | dev->power.status = DPM_SUSPENDING; | ||
761 | if (!list_empty(&dev->power.entry)) | ||
762 | list_move_tail(&dev->power.entry, &list); | ||
763 | put_device(dev); | ||
764 | } | ||
765 | list_splice(&list, &dpm_list); | ||
766 | mutex_unlock(&dpm_list_mtx); | ||
395 | return error; | 767 | return error; |
396 | } | 768 | } |
397 | 769 | ||
398 | /** | 770 | /** |
399 | * device_suspend - Save state and stop all devices in system. | 771 | * device_suspend - Save state and stop all devices in system. |
400 | * @state: new power management state | 772 | * @state: PM transition of the system being carried out. |
401 | * | 773 | * |
402 | * Prevent new devices from being registered, then lock all devices | 774 | * Prepare and suspend all devices. |
403 | * and suspend them. | ||
404 | */ | 775 | */ |
405 | int device_suspend(pm_message_t state) | 776 | int device_suspend(pm_message_t state) |
406 | { | 777 | { |
407 | int error; | 778 | int error; |
408 | 779 | ||
409 | might_sleep(); | 780 | might_sleep(); |
410 | error = dpm_suspend(state); | 781 | error = dpm_prepare(state); |
782 | if (!error) | ||
783 | error = dpm_suspend(state); | ||
411 | if (error) | 784 | if (error) |
412 | device_resume(); | 785 | device_resume(resume_event(state)); |
413 | return error; | 786 | return error; |
414 | } | 787 | } |
415 | EXPORT_SYMBOL_GPL(device_suspend); | 788 | EXPORT_SYMBOL_GPL(device_suspend); |
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index a6894f2a4b99..a3252c0e2887 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * main.c | 4 | * main.c |
5 | */ | 5 | */ |
6 | 6 | ||
7 | extern struct list_head dpm_active; /* The active device list */ | 7 | extern struct list_head dpm_list; /* The active device list */ |
8 | 8 | ||
9 | static inline struct device *to_device(struct list_head *entry) | 9 | static inline struct device *to_device(struct list_head *entry) |
10 | { | 10 | { |
diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c index 2b4b392dcbc1..8c1e656b5f8b 100644 --- a/drivers/base/power/trace.c +++ b/drivers/base/power/trace.c | |||
@@ -188,9 +188,9 @@ static int show_file_hash(unsigned int value) | |||
188 | static int show_dev_hash(unsigned int value) | 188 | static int show_dev_hash(unsigned int value) |
189 | { | 189 | { |
190 | int match = 0; | 190 | int match = 0; |
191 | struct list_head * entry = dpm_active.prev; | 191 | struct list_head *entry = dpm_list.prev; |
192 | 192 | ||
193 | while (entry != &dpm_active) { | 193 | while (entry != &dpm_list) { |
194 | struct device * dev = to_device(entry); | 194 | struct device * dev = to_device(entry); |
195 | unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH); | 195 | unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH); |
196 | if (hash == value) { | 196 | if (hash == value) { |
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 4d1ce2e7361e..7d63f8ced24b 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for the PCI bus specific drivers. | 2 | # Makefile for the PCI bus specific drivers. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += access.o bus.o probe.o remove.o pci.o quirks.o \ | 5 | obj-y += access.o bus.o probe.o remove.o pci.o quirks.o slot.o \ |
6 | pci-driver.o search.o pci-sysfs.o rom.o setup-res.o | 6 | pci-driver.o search.o pci-sysfs.o rom.o setup-res.o |
7 | obj-$(CONFIG_PROC_FS) += proc.o | 7 | obj-$(CONFIG_PROC_FS) += proc.o |
8 | 8 | ||
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c index f8c187a763bd..93e37f0666ab 100644 --- a/drivers/pci/hotplug/acpi_pcihp.c +++ b/drivers/pci/hotplug/acpi_pcihp.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
31 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
32 | #include <linux/pci_hotplug.h> | 32 | #include <linux/pci_hotplug.h> |
33 | #include <linux/pci-acpi.h> | ||
33 | #include <acpi/acpi.h> | 34 | #include <acpi/acpi.h> |
34 | #include <acpi/acpi_bus.h> | 35 | #include <acpi/acpi_bus.h> |
35 | #include <acpi/actypes.h> | 36 | #include <acpi/actypes.h> |
@@ -299,7 +300,7 @@ free_and_return: | |||
299 | * | 300 | * |
300 | * @handle - the handle of the hotplug controller. | 301 | * @handle - the handle of the hotplug controller. |
301 | */ | 302 | */ |
302 | acpi_status acpi_run_oshp(acpi_handle handle) | 303 | static acpi_status acpi_run_oshp(acpi_handle handle) |
303 | { | 304 | { |
304 | acpi_status status; | 305 | acpi_status status; |
305 | struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL }; | 306 | struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL }; |
@@ -322,9 +323,6 @@ acpi_status acpi_run_oshp(acpi_handle handle) | |||
322 | kfree(string.pointer); | 323 | kfree(string.pointer); |
323 | return status; | 324 | return status; |
324 | } | 325 | } |
325 | EXPORT_SYMBOL_GPL(acpi_run_oshp); | ||
326 | |||
327 | |||
328 | 326 | ||
329 | /* acpi_get_hp_params_from_firmware | 327 | /* acpi_get_hp_params_from_firmware |
330 | * | 328 | * |
@@ -374,6 +372,85 @@ acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus, | |||
374 | } | 372 | } |
375 | EXPORT_SYMBOL_GPL(acpi_get_hp_params_from_firmware); | 373 | EXPORT_SYMBOL_GPL(acpi_get_hp_params_from_firmware); |
376 | 374 | ||
375 | /** | ||
376 | * acpi_get_hp_hw_control_from_firmware | ||
377 | * @dev: the pci_dev of the bridge that has a hotplug controller | ||
378 | * @flags: requested control bits for _OSC | ||
379 | * | ||
380 | * Attempt to take hotplug control from firmware. | ||
381 | */ | ||
382 | int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags) | ||
383 | { | ||
384 | acpi_status status; | ||
385 | acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev)); | ||
386 | struct pci_dev *pdev = dev; | ||
387 | struct pci_bus *parent; | ||
388 | struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
389 | |||
390 | flags &= (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | | ||
391 | OSC_SHPC_NATIVE_HP_CONTROL | | ||
392 | OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); | ||
393 | if (!flags) { | ||
394 | err("Invalid flags %u specified!\n", flags); | ||
395 | return -EINVAL; | ||
396 | } | ||
397 | |||
398 | /* | ||
399 | * Per PCI firmware specification, we should run the ACPI _OSC | ||
400 | * method to get control of hotplug hardware before using it. If | ||
401 | * an _OSC is missing, we look for an OSHP to do the same thing. | ||
402 | * To handle different BIOS behavior, we look for _OSC and OSHP | ||
403 | * within the scope of the hotplug controller and its parents, | ||
404 | * upto the host bridge under which this controller exists. | ||
405 | */ | ||
406 | while (!handle) { | ||
407 | /* | ||
408 | * This hotplug controller was not listed in the ACPI name | ||
409 | * space at all. Try to get acpi handle of parent pci bus. | ||
410 | */ | ||
411 | if (!pdev || !pdev->bus->parent) | ||
412 | break; | ||
413 | parent = pdev->bus->parent; | ||
414 | dbg("Could not find %s in acpi namespace, trying parent\n", | ||
415 | pci_name(pdev)); | ||
416 | if (!parent->self) | ||
417 | /* Parent must be a host bridge */ | ||
418 | handle = acpi_get_pci_rootbridge_handle( | ||
419 | pci_domain_nr(parent), | ||
420 | parent->number); | ||
421 | else | ||
422 | handle = DEVICE_ACPI_HANDLE(&(parent->self->dev)); | ||
423 | pdev = parent->self; | ||
424 | } | ||
425 | |||
426 | while (handle) { | ||
427 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); | ||
428 | dbg("Trying to get hotplug control for %s \n", | ||
429 | (char *)string.pointer); | ||
430 | status = pci_osc_control_set(handle, flags); | ||
431 | if (status == AE_NOT_FOUND) | ||
432 | status = acpi_run_oshp(handle); | ||
433 | if (ACPI_SUCCESS(status)) { | ||
434 | dbg("Gained control for hotplug HW for pci %s (%s)\n", | ||
435 | pci_name(dev), (char *)string.pointer); | ||
436 | kfree(string.pointer); | ||
437 | return 0; | ||
438 | } | ||
439 | if (acpi_root_bridge(handle)) | ||
440 | break; | ||
441 | chandle = handle; | ||
442 | status = acpi_get_parent(chandle, &handle); | ||
443 | if (ACPI_FAILURE(status)) | ||
444 | break; | ||
445 | } | ||
446 | |||
447 | dbg("Cannot get control of hotplug hardware for pci %s\n", | ||
448 | pci_name(dev)); | ||
449 | |||
450 | kfree(string.pointer); | ||
451 | return -ENODEV; | ||
452 | } | ||
453 | EXPORT_SYMBOL(acpi_get_hp_hw_control_from_firmware); | ||
377 | 454 | ||
378 | /* acpi_root_bridge - check to see if this acpi object is a root bridge | 455 | /* acpi_root_bridge - check to see if this acpi object is a root bridge |
379 | * | 456 | * |
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index 7a29164d4b32..eecf7cbf4139 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h | |||
@@ -215,7 +215,6 @@ extern u8 acpiphp_get_power_status (struct acpiphp_slot *slot); | |||
215 | extern u8 acpiphp_get_attention_status (struct acpiphp_slot *slot); | 215 | extern u8 acpiphp_get_attention_status (struct acpiphp_slot *slot); |
216 | extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot); | 216 | extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot); |
217 | extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); | 217 | extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); |
218 | extern u32 acpiphp_get_address (struct acpiphp_slot *slot); | ||
219 | 218 | ||
220 | /* variables */ | 219 | /* variables */ |
221 | extern int acpiphp_debug; | 220 | extern int acpiphp_debug; |
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index 7af68ba27903..0e496e866a84 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c | |||
@@ -70,7 +70,6 @@ static int disable_slot (struct hotplug_slot *slot); | |||
70 | static int set_attention_status (struct hotplug_slot *slot, u8 value); | 70 | static int set_attention_status (struct hotplug_slot *slot, u8 value); |
71 | static int get_power_status (struct hotplug_slot *slot, u8 *value); | 71 | static int get_power_status (struct hotplug_slot *slot, u8 *value); |
72 | static int get_attention_status (struct hotplug_slot *slot, u8 *value); | 72 | static int get_attention_status (struct hotplug_slot *slot, u8 *value); |
73 | static int get_address (struct hotplug_slot *slot, u32 *value); | ||
74 | static int get_latch_status (struct hotplug_slot *slot, u8 *value); | 73 | static int get_latch_status (struct hotplug_slot *slot, u8 *value); |
75 | static int get_adapter_status (struct hotplug_slot *slot, u8 *value); | 74 | static int get_adapter_status (struct hotplug_slot *slot, u8 *value); |
76 | 75 | ||
@@ -83,7 +82,6 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops = { | |||
83 | .get_attention_status = get_attention_status, | 82 | .get_attention_status = get_attention_status, |
84 | .get_latch_status = get_latch_status, | 83 | .get_latch_status = get_latch_status, |
85 | .get_adapter_status = get_adapter_status, | 84 | .get_adapter_status = get_adapter_status, |
86 | .get_address = get_address, | ||
87 | }; | 85 | }; |
88 | 86 | ||
89 | 87 | ||
@@ -274,23 +272,6 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
274 | return 0; | 272 | return 0; |
275 | } | 273 | } |
276 | 274 | ||
277 | |||
278 | /** | ||
279 | * get_address - get pci address of a slot | ||
280 | * @hotplug_slot: slot to get status | ||
281 | * @value: pointer to struct pci_busdev (seg, bus, dev) | ||
282 | */ | ||
283 | static int get_address(struct hotplug_slot *hotplug_slot, u32 *value) | ||
284 | { | ||
285 | struct slot *slot = hotplug_slot->private; | ||
286 | |||
287 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | ||
288 | |||
289 | *value = acpiphp_get_address(slot->acpi_slot); | ||
290 | |||
291 | return 0; | ||
292 | } | ||
293 | |||
294 | static int __init init_acpi(void) | 275 | static int __init init_acpi(void) |
295 | { | 276 | { |
296 | int retval; | 277 | int retval; |
@@ -357,7 +338,11 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) | |||
357 | acpiphp_slot->slot = slot; | 338 | acpiphp_slot->slot = slot; |
358 | snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun); | 339 | snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun); |
359 | 340 | ||
360 | retval = pci_hp_register(slot->hotplug_slot); | 341 | retval = pci_hp_register(slot->hotplug_slot, |
342 | acpiphp_slot->bridge->pci_bus, | ||
343 | acpiphp_slot->device); | ||
344 | if (retval == -EBUSY) | ||
345 | goto error_hpslot; | ||
361 | if (retval) { | 346 | if (retval) { |
362 | err("pci_hp_register failed with error %d\n", retval); | 347 | err("pci_hp_register failed with error %d\n", retval); |
363 | goto error_hpslot; | 348 | goto error_hpslot; |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 648596d469f6..9342c848db29 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -258,7 +258,12 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
258 | bridge->pci_bus->number, slot->device); | 258 | bridge->pci_bus->number, slot->device); |
259 | retval = acpiphp_register_hotplug_slot(slot); | 259 | retval = acpiphp_register_hotplug_slot(slot); |
260 | if (retval) { | 260 | if (retval) { |
261 | warn("acpiphp_register_hotplug_slot failed(err code = 0x%x)\n", retval); | 261 | if (retval == -EBUSY) |
262 | warn("Slot %d already registered by another " | ||
263 | "hotplug driver\n", slot->sun); | ||
264 | else | ||
265 | warn("acpiphp_register_hotplug_slot failed " | ||
266 | "(err code = 0x%x)\n", retval); | ||
262 | goto err_exit; | 267 | goto err_exit; |
263 | } | 268 | } |
264 | } | 269 | } |
@@ -1867,19 +1872,3 @@ u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot) | |||
1867 | 1872 | ||
1868 | return (sta == 0) ? 0 : 1; | 1873 | return (sta == 0) ? 0 : 1; |
1869 | } | 1874 | } |
1870 | |||
1871 | |||
1872 | /* | ||
1873 | * pci address (seg/bus/dev) | ||
1874 | */ | ||
1875 | u32 acpiphp_get_address(struct acpiphp_slot *slot) | ||
1876 | { | ||
1877 | u32 address; | ||
1878 | struct pci_bus *pci_bus = slot->bridge->pci_bus; | ||
1879 | |||
1880 | address = (pci_domain_nr(pci_bus) << 16) | | ||
1881 | (pci_bus->number << 8) | | ||
1882 | slot->device; | ||
1883 | |||
1884 | return address; | ||
1885 | } | ||
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c index ede9051fdb5d..2b7c45e39370 100644 --- a/drivers/pci/hotplug/acpiphp_ibm.c +++ b/drivers/pci/hotplug/acpiphp_ibm.c | |||
@@ -33,8 +33,10 @@ | |||
33 | #include <linux/kobject.h> | 33 | #include <linux/kobject.h> |
34 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
35 | #include <linux/moduleparam.h> | 35 | #include <linux/moduleparam.h> |
36 | #include <linux/pci.h> | ||
36 | 37 | ||
37 | #include "acpiphp.h" | 38 | #include "acpiphp.h" |
39 | #include "../pci.h" | ||
38 | 40 | ||
39 | #define DRIVER_VERSION "1.0.1" | 41 | #define DRIVER_VERSION "1.0.1" |
40 | #define DRIVER_AUTHOR "Irene Zubarev <zubarev@us.ibm.com>, Vernon Mauery <vernux@us.ibm.com>" | 42 | #define DRIVER_AUTHOR "Irene Zubarev <zubarev@us.ibm.com>, Vernon Mauery <vernux@us.ibm.com>" |
@@ -430,7 +432,7 @@ static int __init ibm_acpiphp_init(void) | |||
430 | int retval = 0; | 432 | int retval = 0; |
431 | acpi_status status; | 433 | acpi_status status; |
432 | struct acpi_device *device; | 434 | struct acpi_device *device; |
433 | struct kobject *sysdir = &pci_hotplug_slots_kset->kobj; | 435 | struct kobject *sysdir = &pci_slots_kset->kobj; |
434 | 436 | ||
435 | dbg("%s\n", __func__); | 437 | dbg("%s\n", __func__); |
436 | 438 | ||
@@ -477,7 +479,7 @@ init_return: | |||
477 | static void __exit ibm_acpiphp_exit(void) | 479 | static void __exit ibm_acpiphp_exit(void) |
478 | { | 480 | { |
479 | acpi_status status; | 481 | acpi_status status; |
480 | struct kobject *sysdir = &pci_hotplug_slots_kset->kobj; | 482 | struct kobject *sysdir = &pci_slots_kset->kobj; |
481 | 483 | ||
482 | dbg("%s\n", __func__); | 484 | dbg("%s\n", __func__); |
483 | 485 | ||
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c index d8a6b80ab42a..935947991dc9 100644 --- a/drivers/pci/hotplug/cpci_hotplug_core.c +++ b/drivers/pci/hotplug/cpci_hotplug_core.c | |||
@@ -285,7 +285,7 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) | |||
285 | info->attention_status = cpci_get_attention_status(slot); | 285 | info->attention_status = cpci_get_attention_status(slot); |
286 | 286 | ||
287 | dbg("registering slot %s", slot->hotplug_slot->name); | 287 | dbg("registering slot %s", slot->hotplug_slot->name); |
288 | status = pci_hp_register(slot->hotplug_slot); | 288 | status = pci_hp_register(slot->hotplug_slot, bus, i); |
289 | if (status) { | 289 | if (status) { |
290 | err("pci_hp_register failed with error %d", status); | 290 | err("pci_hp_register failed with error %d", status); |
291 | goto error_name; | 291 | goto error_name; |
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index 36b115b27b0b..54defec51d08 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c | |||
@@ -434,7 +434,9 @@ static int ctrl_slot_setup(struct controller *ctrl, | |||
434 | slot->bus, slot->device, | 434 | slot->bus, slot->device, |
435 | slot->number, ctrl->slot_device_offset, | 435 | slot->number, ctrl->slot_device_offset, |
436 | slot_number); | 436 | slot_number); |
437 | result = pci_hp_register(hotplug_slot); | 437 | result = pci_hp_register(hotplug_slot, |
438 | ctrl->pci_dev->subordinate, | ||
439 | slot->device); | ||
438 | if (result) { | 440 | if (result) { |
439 | err("pci_hp_register failed with error %d\n", result); | 441 | err("pci_hp_register failed with error %d\n", result); |
440 | goto error_name; | 442 | goto error_name; |
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c index 7e9a827c2687..40337a06c18a 100644 --- a/drivers/pci/hotplug/fakephp.c +++ b/drivers/pci/hotplug/fakephp.c | |||
@@ -66,6 +66,7 @@ struct dummy_slot { | |||
66 | struct pci_dev *dev; | 66 | struct pci_dev *dev; |
67 | struct work_struct remove_work; | 67 | struct work_struct remove_work; |
68 | unsigned long removed; | 68 | unsigned long removed; |
69 | char name[8]; | ||
69 | }; | 70 | }; |
70 | 71 | ||
71 | static int debug; | 72 | static int debug; |
@@ -100,6 +101,7 @@ static int add_slot(struct pci_dev *dev) | |||
100 | struct dummy_slot *dslot; | 101 | struct dummy_slot *dslot; |
101 | struct hotplug_slot *slot; | 102 | struct hotplug_slot *slot; |
102 | int retval = -ENOMEM; | 103 | int retval = -ENOMEM; |
104 | static int count = 1; | ||
103 | 105 | ||
104 | slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); | 106 | slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); |
105 | if (!slot) | 107 | if (!slot) |
@@ -113,18 +115,18 @@ static int add_slot(struct pci_dev *dev) | |||
113 | slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; | 115 | slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; |
114 | slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; | 116 | slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; |
115 | 117 | ||
116 | slot->name = &dev->dev.bus_id[0]; | ||
117 | dbg("slot->name = %s\n", slot->name); | ||
118 | |||
119 | dslot = kzalloc(sizeof(struct dummy_slot), GFP_KERNEL); | 118 | dslot = kzalloc(sizeof(struct dummy_slot), GFP_KERNEL); |
120 | if (!dslot) | 119 | if (!dslot) |
121 | goto error_info; | 120 | goto error_info; |
122 | 121 | ||
122 | slot->name = dslot->name; | ||
123 | snprintf(slot->name, sizeof(dslot->name), "fake%d", count++); | ||
124 | dbg("slot->name = %s\n", slot->name); | ||
123 | slot->ops = &dummy_hotplug_slot_ops; | 125 | slot->ops = &dummy_hotplug_slot_ops; |
124 | slot->release = &dummy_release; | 126 | slot->release = &dummy_release; |
125 | slot->private = dslot; | 127 | slot->private = dslot; |
126 | 128 | ||
127 | retval = pci_hp_register(slot); | 129 | retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn)); |
128 | if (retval) { | 130 | if (retval) { |
129 | err("pci_hp_register failed with error %d\n", retval); | 131 | err("pci_hp_register failed with error %d\n", retval); |
130 | goto error_dslot; | 132 | goto error_dslot; |
@@ -148,17 +150,17 @@ error: | |||
148 | static int __init pci_scan_buses(void) | 150 | static int __init pci_scan_buses(void) |
149 | { | 151 | { |
150 | struct pci_dev *dev = NULL; | 152 | struct pci_dev *dev = NULL; |
151 | int retval = 0; | 153 | int lastslot = 0; |
152 | 154 | ||
153 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { | 155 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { |
154 | retval = add_slot(dev); | 156 | if (PCI_FUNC(dev->devfn) > 0 && |
155 | if (retval) { | 157 | lastslot == PCI_SLOT(dev->devfn)) |
156 | pci_dev_put(dev); | 158 | continue; |
157 | break; | 159 | lastslot = PCI_SLOT(dev->devfn); |
158 | } | 160 | add_slot(dev); |
159 | } | 161 | } |
160 | 162 | ||
161 | return retval; | 163 | return 0; |
162 | } | 164 | } |
163 | 165 | ||
164 | static void remove_slot(struct dummy_slot *dslot) | 166 | static void remove_slot(struct dummy_slot *dslot) |
@@ -296,23 +298,9 @@ static int enable_slot(struct hotplug_slot *hotplug_slot) | |||
296 | return 0; | 298 | return 0; |
297 | } | 299 | } |
298 | 300 | ||
299 | /* find the hotplug_slot for the pci_dev */ | ||
300 | static struct hotplug_slot *get_slot_from_dev(struct pci_dev *dev) | ||
301 | { | ||
302 | struct dummy_slot *dslot; | ||
303 | |||
304 | list_for_each_entry(dslot, &slot_list, node) { | ||
305 | if (dslot->dev == dev) | ||
306 | return dslot->slot; | ||
307 | } | ||
308 | return NULL; | ||
309 | } | ||
310 | |||
311 | |||
312 | static int disable_slot(struct hotplug_slot *slot) | 301 | static int disable_slot(struct hotplug_slot *slot) |
313 | { | 302 | { |
314 | struct dummy_slot *dslot; | 303 | struct dummy_slot *dslot; |
315 | struct hotplug_slot *hslot; | ||
316 | struct pci_dev *dev; | 304 | struct pci_dev *dev; |
317 | int func; | 305 | int func; |
318 | 306 | ||
@@ -322,41 +310,27 @@ static int disable_slot(struct hotplug_slot *slot) | |||
322 | 310 | ||
323 | dbg("%s - physical_slot = %s\n", __func__, slot->name); | 311 | dbg("%s - physical_slot = %s\n", __func__, slot->name); |
324 | 312 | ||
325 | /* don't disable bridged devices just yet, we can't handle them easily... */ | 313 | for (func = 7; func >= 0; func--) { |
326 | if (dslot->dev->subordinate) { | 314 | dev = pci_get_slot(dslot->dev->bus, dslot->dev->devfn + func); |
327 | err("Can't remove PCI devices with other PCI devices behind it yet.\n"); | 315 | if (!dev) |
328 | return -ENODEV; | 316 | continue; |
329 | } | 317 | |
330 | if (test_and_set_bit(0, &dslot->removed)) { | 318 | if (test_and_set_bit(0, &dslot->removed)) { |
331 | dbg("Slot already scheduled for removal\n"); | 319 | dbg("Slot already scheduled for removal\n"); |
332 | return -ENODEV; | 320 | return -ENODEV; |
333 | } | ||
334 | /* search for subfunctions and disable them first */ | ||
335 | if (!(dslot->dev->devfn & 7)) { | ||
336 | for (func = 1; func < 8; func++) { | ||
337 | dev = pci_get_slot(dslot->dev->bus, | ||
338 | dslot->dev->devfn + func); | ||
339 | if (dev) { | ||
340 | hslot = get_slot_from_dev(dev); | ||
341 | if (hslot) | ||
342 | disable_slot(hslot); | ||
343 | else { | ||
344 | err("Hotplug slot not found for subfunction of PCI device\n"); | ||
345 | return -ENODEV; | ||
346 | } | ||
347 | pci_dev_put(dev); | ||
348 | } else | ||
349 | dbg("No device in slot found\n"); | ||
350 | } | 321 | } |
351 | } | ||
352 | 322 | ||
353 | /* remove the device from the pci core */ | 323 | /* queue work item to blow away this sysfs entry and other |
354 | pci_remove_bus_device(dslot->dev); | 324 | * parts. |
325 | */ | ||
326 | INIT_WORK(&dslot->remove_work, remove_slot_worker); | ||
327 | queue_work(dummyphp_wq, &dslot->remove_work); | ||
355 | 328 | ||
356 | /* queue work item to blow away this sysfs entry and other parts. */ | 329 | /* blow away this sysfs entry and other parts. */ |
357 | INIT_WORK(&dslot->remove_work, remove_slot_worker); | 330 | remove_slot(dslot); |
358 | queue_work(dummyphp_wq, &dslot->remove_work); | ||
359 | 331 | ||
332 | pci_dev_put(dev); | ||
333 | } | ||
360 | return 0; | 334 | return 0; |
361 | } | 335 | } |
362 | 336 | ||
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c index dca7efc14be2..8467d0287325 100644 --- a/drivers/pci/hotplug/ibmphp_ebda.c +++ b/drivers/pci/hotplug/ibmphp_ebda.c | |||
@@ -1001,7 +1001,8 @@ static int __init ebda_rsrc_controller (void) | |||
1001 | tmp_slot = list_entry (list, struct slot, ibm_slot_list); | 1001 | tmp_slot = list_entry (list, struct slot, ibm_slot_list); |
1002 | 1002 | ||
1003 | snprintf (tmp_slot->hotplug_slot->name, 30, "%s", create_file_name (tmp_slot)); | 1003 | snprintf (tmp_slot->hotplug_slot->name, 30, "%s", create_file_name (tmp_slot)); |
1004 | pci_hp_register (tmp_slot->hotplug_slot); | 1004 | pci_hp_register(tmp_slot->hotplug_slot, |
1005 | pci_find_bus(0, tmp_slot->bus), tmp_slot->device); | ||
1005 | } | 1006 | } |
1006 | 1007 | ||
1007 | print_ebda_hpc (); | 1008 | print_ebda_hpc (); |
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c index a11021e8ce37..b3b2d8cf4370 100644 --- a/drivers/pci/hotplug/pci_hotplug_core.c +++ b/drivers/pci/hotplug/pci_hotplug_core.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/pci.h> | 40 | #include <linux/pci.h> |
41 | #include <linux/pci_hotplug.h> | 41 | #include <linux/pci_hotplug.h> |
42 | #include <asm/uaccess.h> | 42 | #include <asm/uaccess.h> |
43 | #include "../pci.h" | ||
43 | 44 | ||
44 | #define MY_NAME "pci_hotplug" | 45 | #define MY_NAME "pci_hotplug" |
45 | 46 | ||
@@ -60,41 +61,7 @@ static int debug; | |||
60 | ////////////////////////////////////////////////////////////////// | 61 | ////////////////////////////////////////////////////////////////// |
61 | 62 | ||
62 | static LIST_HEAD(pci_hotplug_slot_list); | 63 | static LIST_HEAD(pci_hotplug_slot_list); |
63 | 64 | static DEFINE_SPINLOCK(pci_hotplug_slot_list_lock); | |
64 | struct kset *pci_hotplug_slots_kset; | ||
65 | |||
66 | static ssize_t hotplug_slot_attr_show(struct kobject *kobj, | ||
67 | struct attribute *attr, char *buf) | ||
68 | { | ||
69 | struct hotplug_slot *slot = to_hotplug_slot(kobj); | ||
70 | struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr); | ||
71 | return attribute->show ? attribute->show(slot, buf) : -EIO; | ||
72 | } | ||
73 | |||
74 | static ssize_t hotplug_slot_attr_store(struct kobject *kobj, | ||
75 | struct attribute *attr, const char *buf, size_t len) | ||
76 | { | ||
77 | struct hotplug_slot *slot = to_hotplug_slot(kobj); | ||
78 | struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr); | ||
79 | return attribute->store ? attribute->store(slot, buf, len) : -EIO; | ||
80 | } | ||
81 | |||
82 | static struct sysfs_ops hotplug_slot_sysfs_ops = { | ||
83 | .show = hotplug_slot_attr_show, | ||
84 | .store = hotplug_slot_attr_store, | ||
85 | }; | ||
86 | |||
87 | static void hotplug_slot_release(struct kobject *kobj) | ||
88 | { | ||
89 | struct hotplug_slot *slot = to_hotplug_slot(kobj); | ||
90 | if (slot->release) | ||
91 | slot->release(slot); | ||
92 | } | ||
93 | |||
94 | static struct kobj_type hotplug_slot_ktype = { | ||
95 | .sysfs_ops = &hotplug_slot_sysfs_ops, | ||
96 | .release = &hotplug_slot_release, | ||
97 | }; | ||
98 | 65 | ||
99 | /* these strings match up with the values in pci_bus_speed */ | 66 | /* these strings match up with the values in pci_bus_speed */ |
100 | static char *pci_bus_speed_strings[] = { | 67 | static char *pci_bus_speed_strings[] = { |
@@ -149,16 +116,15 @@ GET_STATUS(power_status, u8) | |||
149 | GET_STATUS(attention_status, u8) | 116 | GET_STATUS(attention_status, u8) |
150 | GET_STATUS(latch_status, u8) | 117 | GET_STATUS(latch_status, u8) |
151 | GET_STATUS(adapter_status, u8) | 118 | GET_STATUS(adapter_status, u8) |
152 | GET_STATUS(address, u32) | ||
153 | GET_STATUS(max_bus_speed, enum pci_bus_speed) | 119 | GET_STATUS(max_bus_speed, enum pci_bus_speed) |
154 | GET_STATUS(cur_bus_speed, enum pci_bus_speed) | 120 | GET_STATUS(cur_bus_speed, enum pci_bus_speed) |
155 | 121 | ||
156 | static ssize_t power_read_file (struct hotplug_slot *slot, char *buf) | 122 | static ssize_t power_read_file(struct pci_slot *slot, char *buf) |
157 | { | 123 | { |
158 | int retval; | 124 | int retval; |
159 | u8 value; | 125 | u8 value; |
160 | 126 | ||
161 | retval = get_power_status (slot, &value); | 127 | retval = get_power_status(slot->hotplug, &value); |
162 | if (retval) | 128 | if (retval) |
163 | goto exit; | 129 | goto exit; |
164 | retval = sprintf (buf, "%d\n", value); | 130 | retval = sprintf (buf, "%d\n", value); |
@@ -166,9 +132,10 @@ exit: | |||
166 | return retval; | 132 | return retval; |
167 | } | 133 | } |
168 | 134 | ||
169 | static ssize_t power_write_file (struct hotplug_slot *slot, const char *buf, | 135 | static ssize_t power_write_file(struct pci_slot *pci_slot, const char *buf, |
170 | size_t count) | 136 | size_t count) |
171 | { | 137 | { |
138 | struct hotplug_slot *slot = pci_slot->hotplug; | ||
172 | unsigned long lpower; | 139 | unsigned long lpower; |
173 | u8 power; | 140 | u8 power; |
174 | int retval = 0; | 141 | int retval = 0; |
@@ -204,29 +171,30 @@ exit: | |||
204 | return count; | 171 | return count; |
205 | } | 172 | } |
206 | 173 | ||
207 | static struct hotplug_slot_attribute hotplug_slot_attr_power = { | 174 | static struct pci_slot_attribute hotplug_slot_attr_power = { |
208 | .attr = {.name = "power", .mode = S_IFREG | S_IRUGO | S_IWUSR}, | 175 | .attr = {.name = "power", .mode = S_IFREG | S_IRUGO | S_IWUSR}, |
209 | .show = power_read_file, | 176 | .show = power_read_file, |
210 | .store = power_write_file | 177 | .store = power_write_file |
211 | }; | 178 | }; |
212 | 179 | ||
213 | static ssize_t attention_read_file (struct hotplug_slot *slot, char *buf) | 180 | static ssize_t attention_read_file(struct pci_slot *slot, char *buf) |
214 | { | 181 | { |
215 | int retval; | 182 | int retval; |
216 | u8 value; | 183 | u8 value; |
217 | 184 | ||
218 | retval = get_attention_status (slot, &value); | 185 | retval = get_attention_status(slot->hotplug, &value); |
219 | if (retval) | 186 | if (retval) |
220 | goto exit; | 187 | goto exit; |
221 | retval = sprintf (buf, "%d\n", value); | 188 | retval = sprintf(buf, "%d\n", value); |
222 | 189 | ||
223 | exit: | 190 | exit: |
224 | return retval; | 191 | return retval; |
225 | } | 192 | } |
226 | 193 | ||
227 | static ssize_t attention_write_file (struct hotplug_slot *slot, const char *buf, | 194 | static ssize_t attention_write_file(struct pci_slot *slot, const char *buf, |
228 | size_t count) | 195 | size_t count) |
229 | { | 196 | { |
197 | struct hotplug_slot_ops *ops = slot->hotplug->ops; | ||
230 | unsigned long lattention; | 198 | unsigned long lattention; |
231 | u8 attention; | 199 | u8 attention; |
232 | int retval = 0; | 200 | int retval = 0; |
@@ -235,13 +203,13 @@ static ssize_t attention_write_file (struct hotplug_slot *slot, const char *buf, | |||
235 | attention = (u8)(lattention & 0xff); | 203 | attention = (u8)(lattention & 0xff); |
236 | dbg (" - attention = %d\n", attention); | 204 | dbg (" - attention = %d\n", attention); |
237 | 205 | ||
238 | if (!try_module_get(slot->ops->owner)) { | 206 | if (!try_module_get(ops->owner)) { |
239 | retval = -ENODEV; | 207 | retval = -ENODEV; |
240 | goto exit; | 208 | goto exit; |
241 | } | 209 | } |
242 | if (slot->ops->set_attention_status) | 210 | if (ops->set_attention_status) |
243 | retval = slot->ops->set_attention_status(slot, attention); | 211 | retval = ops->set_attention_status(slot->hotplug, attention); |
244 | module_put(slot->ops->owner); | 212 | module_put(ops->owner); |
245 | 213 | ||
246 | exit: | 214 | exit: |
247 | if (retval) | 215 | if (retval) |
@@ -249,18 +217,18 @@ exit: | |||
249 | return count; | 217 | return count; |
250 | } | 218 | } |
251 | 219 | ||
252 | static struct hotplug_slot_attribute hotplug_slot_attr_attention = { | 220 | static struct pci_slot_attribute hotplug_slot_attr_attention = { |
253 | .attr = {.name = "attention", .mode = S_IFREG | S_IRUGO | S_IWUSR}, | 221 | .attr = {.name = "attention", .mode = S_IFREG | S_IRUGO | S_IWUSR}, |
254 | .show = attention_read_file, | 222 | .show = attention_read_file, |
255 | .store = attention_write_file | 223 | .store = attention_write_file |
256 | }; | 224 | }; |
257 | 225 | ||
258 | static ssize_t latch_read_file (struct hotplug_slot *slot, char *buf) | 226 | static ssize_t latch_read_file(struct pci_slot *slot, char *buf) |
259 | { | 227 | { |
260 | int retval; | 228 | int retval; |
261 | u8 value; | 229 | u8 value; |
262 | 230 | ||
263 | retval = get_latch_status (slot, &value); | 231 | retval = get_latch_status(slot->hotplug, &value); |
264 | if (retval) | 232 | if (retval) |
265 | goto exit; | 233 | goto exit; |
266 | retval = sprintf (buf, "%d\n", value); | 234 | retval = sprintf (buf, "%d\n", value); |
@@ -269,17 +237,17 @@ exit: | |||
269 | return retval; | 237 | return retval; |
270 | } | 238 | } |
271 | 239 | ||
272 | static struct hotplug_slot_attribute hotplug_slot_attr_latch = { | 240 | static struct pci_slot_attribute hotplug_slot_attr_latch = { |
273 | .attr = {.name = "latch", .mode = S_IFREG | S_IRUGO}, | 241 | .attr = {.name = "latch", .mode = S_IFREG | S_IRUGO}, |
274 | .show = latch_read_file, | 242 | .show = latch_read_file, |
275 | }; | 243 | }; |
276 | 244 | ||
277 | static ssize_t presence_read_file (struct hotplug_slot *slot, char *buf) | 245 | static ssize_t presence_read_file(struct pci_slot *slot, char *buf) |
278 | { | 246 | { |
279 | int retval; | 247 | int retval; |
280 | u8 value; | 248 | u8 value; |
281 | 249 | ||
282 | retval = get_adapter_status (slot, &value); | 250 | retval = get_adapter_status(slot->hotplug, &value); |
283 | if (retval) | 251 | if (retval) |
284 | goto exit; | 252 | goto exit; |
285 | retval = sprintf (buf, "%d\n", value); | 253 | retval = sprintf (buf, "%d\n", value); |
@@ -288,42 +256,20 @@ exit: | |||
288 | return retval; | 256 | return retval; |
289 | } | 257 | } |
290 | 258 | ||
291 | static struct hotplug_slot_attribute hotplug_slot_attr_presence = { | 259 | static struct pci_slot_attribute hotplug_slot_attr_presence = { |
292 | .attr = {.name = "adapter", .mode = S_IFREG | S_IRUGO}, | 260 | .attr = {.name = "adapter", .mode = S_IFREG | S_IRUGO}, |
293 | .show = presence_read_file, | 261 | .show = presence_read_file, |
294 | }; | 262 | }; |
295 | 263 | ||
296 | static ssize_t address_read_file (struct hotplug_slot *slot, char *buf) | ||
297 | { | ||
298 | int retval; | ||
299 | u32 address; | ||
300 | |||
301 | retval = get_address (slot, &address); | ||
302 | if (retval) | ||
303 | goto exit; | ||
304 | retval = sprintf (buf, "%04x:%02x:%02x\n", | ||
305 | (address >> 16) & 0xffff, | ||
306 | (address >> 8) & 0xff, | ||
307 | address & 0xff); | ||
308 | |||
309 | exit: | ||
310 | return retval; | ||
311 | } | ||
312 | |||
313 | static struct hotplug_slot_attribute hotplug_slot_attr_address = { | ||
314 | .attr = {.name = "address", .mode = S_IFREG | S_IRUGO}, | ||
315 | .show = address_read_file, | ||
316 | }; | ||
317 | |||
318 | static char *unknown_speed = "Unknown bus speed"; | 264 | static char *unknown_speed = "Unknown bus speed"; |
319 | 265 | ||
320 | static ssize_t max_bus_speed_read_file (struct hotplug_slot *slot, char *buf) | 266 | static ssize_t max_bus_speed_read_file(struct pci_slot *slot, char *buf) |
321 | { | 267 | { |
322 | char *speed_string; | 268 | char *speed_string; |
323 | int retval; | 269 | int retval; |
324 | enum pci_bus_speed value; | 270 | enum pci_bus_speed value; |
325 | 271 | ||
326 | retval = get_max_bus_speed (slot, &value); | 272 | retval = get_max_bus_speed(slot->hotplug, &value); |
327 | if (retval) | 273 | if (retval) |
328 | goto exit; | 274 | goto exit; |
329 | 275 | ||
@@ -338,18 +284,18 @@ exit: | |||
338 | return retval; | 284 | return retval; |
339 | } | 285 | } |
340 | 286 | ||
341 | static struct hotplug_slot_attribute hotplug_slot_attr_max_bus_speed = { | 287 | static struct pci_slot_attribute hotplug_slot_attr_max_bus_speed = { |
342 | .attr = {.name = "max_bus_speed", .mode = S_IFREG | S_IRUGO}, | 288 | .attr = {.name = "max_bus_speed", .mode = S_IFREG | S_IRUGO}, |
343 | .show = max_bus_speed_read_file, | 289 | .show = max_bus_speed_read_file, |
344 | }; | 290 | }; |
345 | 291 | ||
346 | static ssize_t cur_bus_speed_read_file (struct hotplug_slot *slot, char *buf) | 292 | static ssize_t cur_bus_speed_read_file(struct pci_slot *slot, char *buf) |
347 | { | 293 | { |
348 | char *speed_string; | 294 | char *speed_string; |
349 | int retval; | 295 | int retval; |
350 | enum pci_bus_speed value; | 296 | enum pci_bus_speed value; |
351 | 297 | ||
352 | retval = get_cur_bus_speed (slot, &value); | 298 | retval = get_cur_bus_speed(slot->hotplug, &value); |
353 | if (retval) | 299 | if (retval) |
354 | goto exit; | 300 | goto exit; |
355 | 301 | ||
@@ -364,14 +310,15 @@ exit: | |||
364 | return retval; | 310 | return retval; |
365 | } | 311 | } |
366 | 312 | ||
367 | static struct hotplug_slot_attribute hotplug_slot_attr_cur_bus_speed = { | 313 | static struct pci_slot_attribute hotplug_slot_attr_cur_bus_speed = { |
368 | .attr = {.name = "cur_bus_speed", .mode = S_IFREG | S_IRUGO}, | 314 | .attr = {.name = "cur_bus_speed", .mode = S_IFREG | S_IRUGO}, |
369 | .show = cur_bus_speed_read_file, | 315 | .show = cur_bus_speed_read_file, |
370 | }; | 316 | }; |
371 | 317 | ||
372 | static ssize_t test_write_file (struct hotplug_slot *slot, const char *buf, | 318 | static ssize_t test_write_file(struct pci_slot *pci_slot, const char *buf, |
373 | size_t count) | 319 | size_t count) |
374 | { | 320 | { |
321 | struct hotplug_slot *slot = pci_slot->hotplug; | ||
375 | unsigned long ltest; | 322 | unsigned long ltest; |
376 | u32 test; | 323 | u32 test; |
377 | int retval = 0; | 324 | int retval = 0; |
@@ -394,13 +341,14 @@ exit: | |||
394 | return count; | 341 | return count; |
395 | } | 342 | } |
396 | 343 | ||
397 | static struct hotplug_slot_attribute hotplug_slot_attr_test = { | 344 | static struct pci_slot_attribute hotplug_slot_attr_test = { |
398 | .attr = {.name = "test", .mode = S_IFREG | S_IRUGO | S_IWUSR}, | 345 | .attr = {.name = "test", .mode = S_IFREG | S_IRUGO | S_IWUSR}, |
399 | .store = test_write_file | 346 | .store = test_write_file |
400 | }; | 347 | }; |
401 | 348 | ||
402 | static int has_power_file (struct hotplug_slot *slot) | 349 | static int has_power_file(struct pci_slot *pci_slot) |
403 | { | 350 | { |
351 | struct hotplug_slot *slot = pci_slot->hotplug; | ||
404 | if ((!slot) || (!slot->ops)) | 352 | if ((!slot) || (!slot->ops)) |
405 | return -ENODEV; | 353 | return -ENODEV; |
406 | if ((slot->ops->enable_slot) || | 354 | if ((slot->ops->enable_slot) || |
@@ -410,8 +358,9 @@ static int has_power_file (struct hotplug_slot *slot) | |||
410 | return -ENOENT; | 358 | return -ENOENT; |
411 | } | 359 | } |
412 | 360 | ||
413 | static int has_attention_file (struct hotplug_slot *slot) | 361 | static int has_attention_file(struct pci_slot *pci_slot) |
414 | { | 362 | { |
363 | struct hotplug_slot *slot = pci_slot->hotplug; | ||
415 | if ((!slot) || (!slot->ops)) | 364 | if ((!slot) || (!slot->ops)) |
416 | return -ENODEV; | 365 | return -ENODEV; |
417 | if ((slot->ops->set_attention_status) || | 366 | if ((slot->ops->set_attention_status) || |
@@ -420,8 +369,9 @@ static int has_attention_file (struct hotplug_slot *slot) | |||
420 | return -ENOENT; | 369 | return -ENOENT; |
421 | } | 370 | } |
422 | 371 | ||
423 | static int has_latch_file (struct hotplug_slot *slot) | 372 | static int has_latch_file(struct pci_slot *pci_slot) |
424 | { | 373 | { |
374 | struct hotplug_slot *slot = pci_slot->hotplug; | ||
425 | if ((!slot) || (!slot->ops)) | 375 | if ((!slot) || (!slot->ops)) |
426 | return -ENODEV; | 376 | return -ENODEV; |
427 | if (slot->ops->get_latch_status) | 377 | if (slot->ops->get_latch_status) |
@@ -429,8 +379,9 @@ static int has_latch_file (struct hotplug_slot *slot) | |||
429 | return -ENOENT; | 379 | return -ENOENT; |
430 | } | 380 | } |
431 | 381 | ||
432 | static int has_adapter_file (struct hotplug_slot *slot) | 382 | static int has_adapter_file(struct pci_slot *pci_slot) |
433 | { | 383 | { |
384 | struct hotplug_slot *slot = pci_slot->hotplug; | ||
434 | if ((!slot) || (!slot->ops)) | 385 | if ((!slot) || (!slot->ops)) |
435 | return -ENODEV; | 386 | return -ENODEV; |
436 | if (slot->ops->get_adapter_status) | 387 | if (slot->ops->get_adapter_status) |
@@ -438,17 +389,9 @@ static int has_adapter_file (struct hotplug_slot *slot) | |||
438 | return -ENOENT; | 389 | return -ENOENT; |
439 | } | 390 | } |
440 | 391 | ||
441 | static int has_address_file (struct hotplug_slot *slot) | 392 | static int has_max_bus_speed_file(struct pci_slot *pci_slot) |
442 | { | ||
443 | if ((!slot) || (!slot->ops)) | ||
444 | return -ENODEV; | ||
445 | if (slot->ops->get_address) | ||
446 | return 0; | ||
447 | return -ENOENT; | ||
448 | } | ||
449 | |||
450 | static int has_max_bus_speed_file (struct hotplug_slot *slot) | ||
451 | { | 393 | { |
394 | struct hotplug_slot *slot = pci_slot->hotplug; | ||
452 | if ((!slot) || (!slot->ops)) | 395 | if ((!slot) || (!slot->ops)) |
453 | return -ENODEV; | 396 | return -ENODEV; |
454 | if (slot->ops->get_max_bus_speed) | 397 | if (slot->ops->get_max_bus_speed) |
@@ -456,8 +399,9 @@ static int has_max_bus_speed_file (struct hotplug_slot *slot) | |||
456 | return -ENOENT; | 399 | return -ENOENT; |
457 | } | 400 | } |
458 | 401 | ||
459 | static int has_cur_bus_speed_file (struct hotplug_slot *slot) | 402 | static int has_cur_bus_speed_file(struct pci_slot *pci_slot) |
460 | { | 403 | { |
404 | struct hotplug_slot *slot = pci_slot->hotplug; | ||
461 | if ((!slot) || (!slot->ops)) | 405 | if ((!slot) || (!slot->ops)) |
462 | return -ENODEV; | 406 | return -ENODEV; |
463 | if (slot->ops->get_cur_bus_speed) | 407 | if (slot->ops->get_cur_bus_speed) |
@@ -465,8 +409,9 @@ static int has_cur_bus_speed_file (struct hotplug_slot *slot) | |||
465 | return -ENOENT; | 409 | return -ENOENT; |
466 | } | 410 | } |
467 | 411 | ||
468 | static int has_test_file (struct hotplug_slot *slot) | 412 | static int has_test_file(struct pci_slot *pci_slot) |
469 | { | 413 | { |
414 | struct hotplug_slot *slot = pci_slot->hotplug; | ||
470 | if ((!slot) || (!slot->ops)) | 415 | if ((!slot) || (!slot->ops)) |
471 | return -ENODEV; | 416 | return -ENODEV; |
472 | if (slot->ops->hardware_test) | 417 | if (slot->ops->hardware_test) |
@@ -474,7 +419,7 @@ static int has_test_file (struct hotplug_slot *slot) | |||
474 | return -ENOENT; | 419 | return -ENOENT; |
475 | } | 420 | } |
476 | 421 | ||
477 | static int fs_add_slot (struct hotplug_slot *slot) | 422 | static int fs_add_slot(struct pci_slot *slot) |
478 | { | 423 | { |
479 | int retval = 0; | 424 | int retval = 0; |
480 | 425 | ||
@@ -505,13 +450,6 @@ static int fs_add_slot (struct hotplug_slot *slot) | |||
505 | goto exit_adapter; | 450 | goto exit_adapter; |
506 | } | 451 | } |
507 | 452 | ||
508 | if (has_address_file(slot) == 0) { | ||
509 | retval = sysfs_create_file(&slot->kobj, | ||
510 | &hotplug_slot_attr_address.attr); | ||
511 | if (retval) | ||
512 | goto exit_address; | ||
513 | } | ||
514 | |||
515 | if (has_max_bus_speed_file(slot) == 0) { | 453 | if (has_max_bus_speed_file(slot) == 0) { |
516 | retval = sysfs_create_file(&slot->kobj, | 454 | retval = sysfs_create_file(&slot->kobj, |
517 | &hotplug_slot_attr_max_bus_speed.attr); | 455 | &hotplug_slot_attr_max_bus_speed.attr); |
@@ -544,10 +482,6 @@ exit_cur_speed: | |||
544 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); | 482 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); |
545 | 483 | ||
546 | exit_max_speed: | 484 | exit_max_speed: |
547 | if (has_address_file(slot) == 0) | ||
548 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_address.attr); | ||
549 | |||
550 | exit_address: | ||
551 | if (has_adapter_file(slot) == 0) | 485 | if (has_adapter_file(slot) == 0) |
552 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_presence.attr); | 486 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_presence.attr); |
553 | 487 | ||
@@ -567,7 +501,7 @@ exit: | |||
567 | return retval; | 501 | return retval; |
568 | } | 502 | } |
569 | 503 | ||
570 | static void fs_remove_slot (struct hotplug_slot *slot) | 504 | static void fs_remove_slot(struct pci_slot *slot) |
571 | { | 505 | { |
572 | if (has_power_file(slot) == 0) | 506 | if (has_power_file(slot) == 0) |
573 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr); | 507 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr); |
@@ -581,9 +515,6 @@ static void fs_remove_slot (struct hotplug_slot *slot) | |||
581 | if (has_adapter_file(slot) == 0) | 515 | if (has_adapter_file(slot) == 0) |
582 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_presence.attr); | 516 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_presence.attr); |
583 | 517 | ||
584 | if (has_address_file(slot) == 0) | ||
585 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_address.attr); | ||
586 | |||
587 | if (has_max_bus_speed_file(slot) == 0) | 518 | if (has_max_bus_speed_file(slot) == 0) |
588 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); | 519 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); |
589 | 520 | ||
@@ -599,12 +530,16 @@ static struct hotplug_slot *get_slot_from_name (const char *name) | |||
599 | struct hotplug_slot *slot; | 530 | struct hotplug_slot *slot; |
600 | struct list_head *tmp; | 531 | struct list_head *tmp; |
601 | 532 | ||
533 | spin_lock(&pci_hotplug_slot_list_lock); | ||
602 | list_for_each (tmp, &pci_hotplug_slot_list) { | 534 | list_for_each (tmp, &pci_hotplug_slot_list) { |
603 | slot = list_entry (tmp, struct hotplug_slot, slot_list); | 535 | slot = list_entry (tmp, struct hotplug_slot, slot_list); |
604 | if (strcmp(slot->name, name) == 0) | 536 | if (strcmp(slot->name, name) == 0) |
605 | return slot; | 537 | goto out; |
606 | } | 538 | } |
607 | return NULL; | 539 | slot = NULL; |
540 | out: | ||
541 | spin_unlock(&pci_hotplug_slot_list_lock); | ||
542 | return slot; | ||
608 | } | 543 | } |
609 | 544 | ||
610 | /** | 545 | /** |
@@ -616,9 +551,10 @@ static struct hotplug_slot *get_slot_from_name (const char *name) | |||
616 | * | 551 | * |
617 | * Returns 0 if successful, anything else for an error. | 552 | * Returns 0 if successful, anything else for an error. |
618 | */ | 553 | */ |
619 | int pci_hp_register (struct hotplug_slot *slot) | 554 | int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr) |
620 | { | 555 | { |
621 | int result; | 556 | int result; |
557 | struct pci_slot *pci_slot; | ||
622 | struct hotplug_slot *tmp; | 558 | struct hotplug_slot *tmp; |
623 | 559 | ||
624 | if (slot == NULL) | 560 | if (slot == NULL) |
@@ -636,19 +572,44 @@ int pci_hp_register (struct hotplug_slot *slot) | |||
636 | if (tmp) | 572 | if (tmp) |
637 | return -EEXIST; | 573 | return -EEXIST; |
638 | 574 | ||
639 | slot->kobj.kset = pci_hotplug_slots_kset; | 575 | /* |
640 | result = kobject_init_and_add(&slot->kobj, &hotplug_slot_ktype, NULL, | 576 | * No problems if we call this interface from both ACPI_PCI_SLOT |
641 | "%s", slot->name); | 577 | * driver and call it here again. If we've already created the |
642 | if (result) { | 578 | * pci_slot, the interface will simply bump the refcount. |
643 | err("Unable to register kobject '%s'", slot->name); | 579 | */ |
644 | return -EINVAL; | 580 | pci_slot = pci_create_slot(bus, slot_nr, slot->name); |
581 | if (IS_ERR(pci_slot)) | ||
582 | return PTR_ERR(pci_slot); | ||
583 | |||
584 | if (pci_slot->hotplug) { | ||
585 | dbg("%s: already claimed\n", __func__); | ||
586 | pci_destroy_slot(pci_slot); | ||
587 | return -EBUSY; | ||
645 | } | 588 | } |
646 | 589 | ||
647 | list_add (&slot->slot_list, &pci_hotplug_slot_list); | 590 | slot->pci_slot = pci_slot; |
591 | pci_slot->hotplug = slot; | ||
592 | |||
593 | /* | ||
594 | * Allow pcihp drivers to override the ACPI_PCI_SLOT name. | ||
595 | */ | ||
596 | if (strcmp(kobject_name(&pci_slot->kobj), slot->name)) { | ||
597 | result = kobject_rename(&pci_slot->kobj, slot->name); | ||
598 | if (result) { | ||
599 | pci_destroy_slot(pci_slot); | ||
600 | return result; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | spin_lock(&pci_hotplug_slot_list_lock); | ||
605 | list_add(&slot->slot_list, &pci_hotplug_slot_list); | ||
606 | spin_unlock(&pci_hotplug_slot_list_lock); | ||
607 | |||
608 | result = fs_add_slot(pci_slot); | ||
609 | kobject_uevent(&pci_slot->kobj, KOBJ_ADD); | ||
610 | dbg("Added slot %s to the list\n", slot->name); | ||
611 | |||
648 | 612 | ||
649 | result = fs_add_slot (slot); | ||
650 | kobject_uevent(&slot->kobj, KOBJ_ADD); | ||
651 | dbg ("Added slot %s to the list\n", slot->name); | ||
652 | return result; | 613 | return result; |
653 | } | 614 | } |
654 | 615 | ||
@@ -661,22 +622,30 @@ int pci_hp_register (struct hotplug_slot *slot) | |||
661 | * | 622 | * |
662 | * Returns 0 if successful, anything else for an error. | 623 | * Returns 0 if successful, anything else for an error. |
663 | */ | 624 | */ |
664 | int pci_hp_deregister (struct hotplug_slot *slot) | 625 | int pci_hp_deregister(struct hotplug_slot *hotplug) |
665 | { | 626 | { |
666 | struct hotplug_slot *temp; | 627 | struct hotplug_slot *temp; |
628 | struct pci_slot *slot; | ||
667 | 629 | ||
668 | if (slot == NULL) | 630 | if (!hotplug) |
669 | return -ENODEV; | 631 | return -ENODEV; |
670 | 632 | ||
671 | temp = get_slot_from_name (slot->name); | 633 | temp = get_slot_from_name(hotplug->name); |
672 | if (temp != slot) { | 634 | if (temp != hotplug) |
673 | return -ENODEV; | 635 | return -ENODEV; |
674 | } | ||
675 | list_del (&slot->slot_list); | ||
676 | 636 | ||
677 | fs_remove_slot (slot); | 637 | spin_lock(&pci_hotplug_slot_list_lock); |
678 | dbg ("Removed slot %s from the list\n", slot->name); | 638 | list_del(&hotplug->slot_list); |
679 | kobject_put(&slot->kobj); | 639 | spin_unlock(&pci_hotplug_slot_list_lock); |
640 | |||
641 | slot = hotplug->pci_slot; | ||
642 | fs_remove_slot(slot); | ||
643 | dbg("Removed slot %s from the list\n", hotplug->name); | ||
644 | |||
645 | hotplug->release(hotplug); | ||
646 | slot->hotplug = NULL; | ||
647 | pci_destroy_slot(slot); | ||
648 | |||
680 | return 0; | 649 | return 0; |
681 | } | 650 | } |
682 | 651 | ||
@@ -690,13 +659,15 @@ int pci_hp_deregister (struct hotplug_slot *slot) | |||
690 | * | 659 | * |
691 | * Returns 0 if successful, anything else for an error. | 660 | * Returns 0 if successful, anything else for an error. |
692 | */ | 661 | */ |
693 | int __must_check pci_hp_change_slot_info(struct hotplug_slot *slot, | 662 | int __must_check pci_hp_change_slot_info(struct hotplug_slot *hotplug, |
694 | struct hotplug_slot_info *info) | 663 | struct hotplug_slot_info *info) |
695 | { | 664 | { |
696 | if ((slot == NULL) || (info == NULL)) | 665 | struct pci_slot *slot; |
666 | if (!hotplug || !info) | ||
697 | return -ENODEV; | 667 | return -ENODEV; |
668 | slot = hotplug->pci_slot; | ||
698 | 669 | ||
699 | memcpy (slot->info, info, sizeof (struct hotplug_slot_info)); | 670 | memcpy(hotplug->info, info, sizeof(struct hotplug_slot_info)); |
700 | 671 | ||
701 | return 0; | 672 | return 0; |
702 | } | 673 | } |
@@ -704,36 +675,22 @@ int __must_check pci_hp_change_slot_info(struct hotplug_slot *slot, | |||
704 | static int __init pci_hotplug_init (void) | 675 | static int __init pci_hotplug_init (void) |
705 | { | 676 | { |
706 | int result; | 677 | int result; |
707 | struct kset *pci_bus_kset; | ||
708 | 678 | ||
709 | pci_bus_kset = bus_get_kset(&pci_bus_type); | ||
710 | |||
711 | pci_hotplug_slots_kset = kset_create_and_add("slots", NULL, | ||
712 | &pci_bus_kset->kobj); | ||
713 | if (!pci_hotplug_slots_kset) { | ||
714 | result = -ENOMEM; | ||
715 | err("Register subsys error\n"); | ||
716 | goto exit; | ||
717 | } | ||
718 | result = cpci_hotplug_init(debug); | 679 | result = cpci_hotplug_init(debug); |
719 | if (result) { | 680 | if (result) { |
720 | err ("cpci_hotplug_init with error %d\n", result); | 681 | err ("cpci_hotplug_init with error %d\n", result); |
721 | goto err_subsys; | 682 | goto err_cpci; |
722 | } | 683 | } |
723 | 684 | ||
724 | info (DRIVER_DESC " version: " DRIVER_VERSION "\n"); | 685 | info (DRIVER_DESC " version: " DRIVER_VERSION "\n"); |
725 | goto exit; | ||
726 | 686 | ||
727 | err_subsys: | 687 | err_cpci: |
728 | kset_unregister(pci_hotplug_slots_kset); | ||
729 | exit: | ||
730 | return result; | 688 | return result; |
731 | } | 689 | } |
732 | 690 | ||
733 | static void __exit pci_hotplug_exit (void) | 691 | static void __exit pci_hotplug_exit (void) |
734 | { | 692 | { |
735 | cpci_hotplug_exit(); | 693 | cpci_hotplug_exit(); |
736 | kset_unregister(pci_hotplug_slots_kset); | ||
737 | } | 694 | } |
738 | 695 | ||
739 | module_init(pci_hotplug_init); | 696 | module_init(pci_hotplug_init); |
@@ -745,7 +702,6 @@ MODULE_LICENSE("GPL"); | |||
745 | module_param(debug, bool, 0644); | 702 | module_param(debug, bool, 0644); |
746 | MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); | 703 | MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); |
747 | 704 | ||
748 | EXPORT_SYMBOL_GPL(pci_hotplug_slots_kset); | ||
749 | EXPORT_SYMBOL_GPL(pci_hp_register); | 705 | EXPORT_SYMBOL_GPL(pci_hp_register); |
750 | EXPORT_SYMBOL_GPL(pci_hp_deregister); | 706 | EXPORT_SYMBOL_GPL(pci_hp_deregister); |
751 | EXPORT_SYMBOL_GPL(pci_hp_change_slot_info); | 707 | EXPORT_SYMBOL_GPL(pci_hp_change_slot_info); |
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 79c9ddaad3fb..8492fab800cc 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h | |||
@@ -202,8 +202,13 @@ struct hpc_ops { | |||
202 | #include <acpi/actypes.h> | 202 | #include <acpi/actypes.h> |
203 | #include <linux/pci-acpi.h> | 203 | #include <linux/pci-acpi.h> |
204 | 204 | ||
205 | #define pciehp_get_hp_hw_control_from_firmware(dev) \ | 205 | static inline int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev) |
206 | pciehp_acpi_get_hp_hw_control_from_firmware(dev) | 206 | { |
207 | u32 flags = (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | | ||
208 | OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); | ||
209 | return acpi_get_hp_hw_control_from_firmware(dev, flags); | ||
210 | } | ||
211 | |||
207 | static inline int pciehp_get_hp_params_from_firmware(struct pci_dev *dev, | 212 | static inline int pciehp_get_hp_params_from_firmware(struct pci_dev *dev, |
208 | struct hotplug_params *hpp) | 213 | struct hotplug_params *hpp) |
209 | { | 214 | { |
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 48a2ed378914..7b21c86e4bff 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c | |||
@@ -41,7 +41,7 @@ int pciehp_debug; | |||
41 | int pciehp_poll_mode; | 41 | int pciehp_poll_mode; |
42 | int pciehp_poll_time; | 42 | int pciehp_poll_time; |
43 | int pciehp_force; | 43 | int pciehp_force; |
44 | int pciehp_slot_with_bus; | 44 | static int pciehp_slot_with_bus; |
45 | struct workqueue_struct *pciehp_wq; | 45 | struct workqueue_struct *pciehp_wq; |
46 | 46 | ||
47 | #define DRIVER_VERSION "0.4" | 47 | #define DRIVER_VERSION "0.4" |
@@ -72,7 +72,6 @@ static int get_power_status (struct hotplug_slot *slot, u8 *value); | |||
72 | static int get_attention_status (struct hotplug_slot *slot, u8 *value); | 72 | static int get_attention_status (struct hotplug_slot *slot, u8 *value); |
73 | static int get_latch_status (struct hotplug_slot *slot, u8 *value); | 73 | static int get_latch_status (struct hotplug_slot *slot, u8 *value); |
74 | static int get_adapter_status (struct hotplug_slot *slot, u8 *value); | 74 | static int get_adapter_status (struct hotplug_slot *slot, u8 *value); |
75 | static int get_address (struct hotplug_slot *slot, u32 *value); | ||
76 | static int get_max_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); | 75 | static int get_max_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); |
77 | static int get_cur_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); | 76 | static int get_cur_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); |
78 | 77 | ||
@@ -85,7 +84,6 @@ static struct hotplug_slot_ops pciehp_hotplug_slot_ops = { | |||
85 | .get_attention_status = get_attention_status, | 84 | .get_attention_status = get_attention_status, |
86 | .get_latch_status = get_latch_status, | 85 | .get_latch_status = get_latch_status, |
87 | .get_adapter_status = get_adapter_status, | 86 | .get_adapter_status = get_adapter_status, |
88 | .get_address = get_address, | ||
89 | .get_max_bus_speed = get_max_bus_speed, | 87 | .get_max_bus_speed = get_max_bus_speed, |
90 | .get_cur_bus_speed = get_cur_bus_speed, | 88 | .get_cur_bus_speed = get_cur_bus_speed, |
91 | }; | 89 | }; |
@@ -252,7 +250,9 @@ static int init_slots(struct controller *ctrl) | |||
252 | dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " | 250 | dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " |
253 | "slot_device_offset=%x\n", slot->bus, slot->device, | 251 | "slot_device_offset=%x\n", slot->bus, slot->device, |
254 | slot->hp_slot, slot->number, ctrl->slot_device_offset); | 252 | slot->hp_slot, slot->number, ctrl->slot_device_offset); |
255 | retval = pci_hp_register(hotplug_slot); | 253 | retval = pci_hp_register(hotplug_slot, |
254 | ctrl->pci_dev->subordinate, | ||
255 | slot->device); | ||
256 | if (retval) { | 256 | if (retval) { |
257 | err("pci_hp_register failed with error %d\n", retval); | 257 | err("pci_hp_register failed with error %d\n", retval); |
258 | if (retval == -EEXIST) | 258 | if (retval == -EEXIST) |
@@ -263,7 +263,7 @@ static int init_slots(struct controller *ctrl) | |||
263 | } | 263 | } |
264 | /* create additional sysfs entries */ | 264 | /* create additional sysfs entries */ |
265 | if (EMI(ctrl)) { | 265 | if (EMI(ctrl)) { |
266 | retval = sysfs_create_file(&hotplug_slot->kobj, | 266 | retval = sysfs_create_file(&hotplug_slot->pci_slot->kobj, |
267 | &hotplug_slot_attr_lock.attr); | 267 | &hotplug_slot_attr_lock.attr); |
268 | if (retval) { | 268 | if (retval) { |
269 | pci_hp_deregister(hotplug_slot); | 269 | pci_hp_deregister(hotplug_slot); |
@@ -296,7 +296,7 @@ static void cleanup_slots(struct controller *ctrl) | |||
296 | slot = list_entry(tmp, struct slot, slot_list); | 296 | slot = list_entry(tmp, struct slot, slot_list); |
297 | list_del(&slot->slot_list); | 297 | list_del(&slot->slot_list); |
298 | if (EMI(ctrl)) | 298 | if (EMI(ctrl)) |
299 | sysfs_remove_file(&slot->hotplug_slot->kobj, | 299 | sysfs_remove_file(&slot->hotplug_slot->pci_slot->kobj, |
300 | &hotplug_slot_attr_lock.attr); | 300 | &hotplug_slot_attr_lock.attr); |
301 | cancel_delayed_work(&slot->work); | 301 | cancel_delayed_work(&slot->work); |
302 | flush_scheduled_work(); | 302 | flush_scheduled_work(); |
@@ -398,19 +398,8 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
398 | return 0; | 398 | return 0; |
399 | } | 399 | } |
400 | 400 | ||
401 | static int get_address(struct hotplug_slot *hotplug_slot, u32 *value) | 401 | static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, |
402 | { | 402 | enum pci_bus_speed *value) |
403 | struct slot *slot = hotplug_slot->private; | ||
404 | struct pci_bus *bus = slot->ctrl->pci_dev->subordinate; | ||
405 | |||
406 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | ||
407 | |||
408 | *value = (pci_domain_nr(bus) << 16) | (slot->bus << 8) | slot->device; | ||
409 | |||
410 | return 0; | ||
411 | } | ||
412 | |||
413 | static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) | ||
414 | { | 403 | { |
415 | struct slot *slot = hotplug_slot->private; | 404 | struct slot *slot = hotplug_slot->private; |
416 | int retval; | 405 | int retval; |
@@ -444,7 +433,13 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
444 | struct controller *ctrl; | 433 | struct controller *ctrl; |
445 | struct slot *t_slot; | 434 | struct slot *t_slot; |
446 | u8 value; | 435 | u8 value; |
447 | struct pci_dev *pdev; | 436 | struct pci_dev *pdev = dev->port; |
437 | |||
438 | if (pciehp_force) | ||
439 | dbg("Bypassing BIOS check for pciehp use on %s\n", | ||
440 | pci_name(pdev)); | ||
441 | else if (pciehp_get_hp_hw_control_from_firmware(pdev)) | ||
442 | goto err_out_none; | ||
448 | 443 | ||
449 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); | 444 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); |
450 | if (!ctrl) { | 445 | if (!ctrl) { |
@@ -453,9 +448,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
453 | } | 448 | } |
454 | INIT_LIST_HEAD(&ctrl->slot_list); | 449 | INIT_LIST_HEAD(&ctrl->slot_list); |
455 | 450 | ||
456 | pdev = dev->port; | ||
457 | ctrl->pci_dev = pdev; | ||
458 | |||
459 | rc = pcie_init(ctrl, dev); | 451 | rc = pcie_init(ctrl, dev); |
460 | if (rc) { | 452 | if (rc) { |
461 | dbg("%s: controller initialization failed\n", PCIE_MODULE_NAME); | 453 | dbg("%s: controller initialization failed\n", PCIE_MODULE_NAME); |
@@ -471,7 +463,12 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
471 | /* Setup the slot information structures */ | 463 | /* Setup the slot information structures */ |
472 | rc = init_slots(ctrl); | 464 | rc = init_slots(ctrl); |
473 | if (rc) { | 465 | if (rc) { |
474 | err("%s: slot initialization failed\n", PCIE_MODULE_NAME); | 466 | if (rc == -EBUSY) |
467 | warn("%s: slot already registered by another " | ||
468 | "hotplug driver\n", PCIE_MODULE_NAME); | ||
469 | else | ||
470 | err("%s: slot initialization failed\n", | ||
471 | PCIE_MODULE_NAME); | ||
475 | goto err_out_release_ctlr; | 472 | goto err_out_release_ctlr; |
476 | } | 473 | } |
477 | 474 | ||
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 79f104963166..0cfaedf2edca 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -268,9 +268,8 @@ completed: | |||
268 | return timeout; | 268 | return timeout; |
269 | } | 269 | } |
270 | 270 | ||
271 | static inline int pcie_wait_cmd(struct controller *ctrl, int poll) | 271 | static inline void pcie_wait_cmd(struct controller *ctrl, int poll) |
272 | { | 272 | { |
273 | int retval = 0; | ||
274 | unsigned int msecs = pciehp_poll_mode ? 2500 : 1000; | 273 | unsigned int msecs = pciehp_poll_mode ? 2500 : 1000; |
275 | unsigned long timeout = msecs_to_jiffies(msecs); | 274 | unsigned long timeout = msecs_to_jiffies(msecs); |
276 | int rc; | 275 | int rc; |
@@ -278,16 +277,9 @@ static inline int pcie_wait_cmd(struct controller *ctrl, int poll) | |||
278 | if (poll) | 277 | if (poll) |
279 | rc = pcie_poll_cmd(ctrl); | 278 | rc = pcie_poll_cmd(ctrl); |
280 | else | 279 | else |
281 | rc = wait_event_interruptible_timeout(ctrl->queue, | 280 | rc = wait_event_timeout(ctrl->queue, !ctrl->cmd_busy, timeout); |
282 | !ctrl->cmd_busy, timeout); | ||
283 | if (!rc) | 281 | if (!rc) |
284 | dbg("Command not completed in 1000 msec\n"); | 282 | dbg("Command not completed in 1000 msec\n"); |
285 | else if (rc < 0) { | ||
286 | retval = -EINTR; | ||
287 | info("Command was interrupted by a signal\n"); | ||
288 | } | ||
289 | |||
290 | return retval; | ||
291 | } | 283 | } |
292 | 284 | ||
293 | /** | 285 | /** |
@@ -365,7 +357,7 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) | |||
365 | if (!(slot_ctrl & HP_INTR_ENABLE) || | 357 | if (!(slot_ctrl & HP_INTR_ENABLE) || |
366 | !(slot_ctrl & CMD_CMPL_INTR_ENABLE)) | 358 | !(slot_ctrl & CMD_CMPL_INTR_ENABLE)) |
367 | poll = 1; | 359 | poll = 1; |
368 | retval = pcie_wait_cmd(ctrl, poll); | 360 | pcie_wait_cmd(ctrl, poll); |
369 | } | 361 | } |
370 | out: | 362 | out: |
371 | mutex_unlock(&ctrl->ctrl_lock); | 363 | mutex_unlock(&ctrl->ctrl_lock); |
@@ -785,7 +777,7 @@ static irqreturn_t pcie_isr(int irq, void *dev_id) | |||
785 | intr_loc |= detected; | 777 | intr_loc |= detected; |
786 | if (!intr_loc) | 778 | if (!intr_loc) |
787 | return IRQ_NONE; | 779 | return IRQ_NONE; |
788 | if (pciehp_writew(ctrl, SLOTSTATUS, detected)) { | 780 | if (detected && pciehp_writew(ctrl, SLOTSTATUS, detected)) { |
789 | err("%s: Cannot write to SLOTSTATUS\n", __func__); | 781 | err("%s: Cannot write to SLOTSTATUS\n", __func__); |
790 | return IRQ_NONE; | 782 | return IRQ_NONE; |
791 | } | 783 | } |
@@ -797,7 +789,7 @@ static irqreturn_t pcie_isr(int irq, void *dev_id) | |||
797 | if (intr_loc & CMD_COMPLETED) { | 789 | if (intr_loc & CMD_COMPLETED) { |
798 | ctrl->cmd_busy = 0; | 790 | ctrl->cmd_busy = 0; |
799 | smp_mb(); | 791 | smp_mb(); |
800 | wake_up_interruptible(&ctrl->queue); | 792 | wake_up(&ctrl->queue); |
801 | } | 793 | } |
802 | 794 | ||
803 | if (!(intr_loc & ~CMD_COMPLETED)) | 795 | if (!(intr_loc & ~CMD_COMPLETED)) |
@@ -1017,75 +1009,6 @@ static struct hpc_ops pciehp_hpc_ops = { | |||
1017 | .check_lnk_status = hpc_check_lnk_status, | 1009 | .check_lnk_status = hpc_check_lnk_status, |
1018 | }; | 1010 | }; |
1019 | 1011 | ||
1020 | #ifdef CONFIG_ACPI | ||
1021 | static int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
1022 | { | ||
1023 | acpi_status status; | ||
1024 | acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev)); | ||
1025 | struct pci_dev *pdev = dev; | ||
1026 | struct pci_bus *parent; | ||
1027 | struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
1028 | |||
1029 | /* | ||
1030 | * Per PCI firmware specification, we should run the ACPI _OSC | ||
1031 | * method to get control of hotplug hardware before using it. | ||
1032 | * If an _OSC is missing, we look for an OSHP to do the same thing. | ||
1033 | * To handle different BIOS behavior, we look for _OSC and OSHP | ||
1034 | * within the scope of the hotplug controller and its parents, upto | ||
1035 | * the host bridge under which this controller exists. | ||
1036 | */ | ||
1037 | while (!handle) { | ||
1038 | /* | ||
1039 | * This hotplug controller was not listed in the ACPI name | ||
1040 | * space at all. Try to get acpi handle of parent pci bus. | ||
1041 | */ | ||
1042 | if (!pdev || !pdev->bus->parent) | ||
1043 | break; | ||
1044 | parent = pdev->bus->parent; | ||
1045 | dbg("Could not find %s in acpi namespace, trying parent\n", | ||
1046 | pci_name(pdev)); | ||
1047 | if (!parent->self) | ||
1048 | /* Parent must be a host bridge */ | ||
1049 | handle = acpi_get_pci_rootbridge_handle( | ||
1050 | pci_domain_nr(parent), | ||
1051 | parent->number); | ||
1052 | else | ||
1053 | handle = DEVICE_ACPI_HANDLE( | ||
1054 | &(parent->self->dev)); | ||
1055 | pdev = parent->self; | ||
1056 | } | ||
1057 | |||
1058 | while (handle) { | ||
1059 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); | ||
1060 | dbg("Trying to get hotplug control for %s \n", | ||
1061 | (char *)string.pointer); | ||
1062 | status = pci_osc_control_set(handle, | ||
1063 | OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL | | ||
1064 | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL); | ||
1065 | if (status == AE_NOT_FOUND) | ||
1066 | status = acpi_run_oshp(handle); | ||
1067 | if (ACPI_SUCCESS(status)) { | ||
1068 | dbg("Gained control for hotplug HW for pci %s (%s)\n", | ||
1069 | pci_name(dev), (char *)string.pointer); | ||
1070 | kfree(string.pointer); | ||
1071 | return 0; | ||
1072 | } | ||
1073 | if (acpi_root_bridge(handle)) | ||
1074 | break; | ||
1075 | chandle = handle; | ||
1076 | status = acpi_get_parent(chandle, &handle); | ||
1077 | if (ACPI_FAILURE(status)) | ||
1078 | break; | ||
1079 | } | ||
1080 | |||
1081 | dbg("Cannot get control of hotplug hardware for pci %s\n", | ||
1082 | pci_name(dev)); | ||
1083 | |||
1084 | kfree(string.pointer); | ||
1085 | return -1; | ||
1086 | } | ||
1087 | #endif | ||
1088 | |||
1089 | static int pcie_init_hardware_part1(struct controller *ctrl, | 1012 | static int pcie_init_hardware_part1(struct controller *ctrl, |
1090 | struct pcie_device *dev) | 1013 | struct pcie_device *dev) |
1091 | { | 1014 | { |
@@ -1122,23 +1045,10 @@ int pcie_init_hardware_part2(struct controller *ctrl, struct pcie_device *dev) | |||
1122 | 1045 | ||
1123 | if (pcie_write_cmd(ctrl, cmd, mask)) { | 1046 | if (pcie_write_cmd(ctrl, cmd, mask)) { |
1124 | err("%s: Cannot enable software notification\n", __func__); | 1047 | err("%s: Cannot enable software notification\n", __func__); |
1125 | goto abort; | 1048 | return -1; |
1126 | } | 1049 | } |
1127 | 1050 | ||
1128 | if (pciehp_force) | ||
1129 | dbg("Bypassing BIOS check for pciehp use on %s\n", | ||
1130 | pci_name(ctrl->pci_dev)); | ||
1131 | else if (pciehp_get_hp_hw_control_from_firmware(ctrl->pci_dev)) | ||
1132 | goto abort_disable_intr; | ||
1133 | |||
1134 | return 0; | 1051 | return 0; |
1135 | |||
1136 | /* We end up here for the many possible ways to fail this API. */ | ||
1137 | abort_disable_intr: | ||
1138 | if (pcie_write_cmd(ctrl, 0, HP_INTR_ENABLE)) | ||
1139 | err("%s : disabling interrupts failed\n", __func__); | ||
1140 | abort: | ||
1141 | return -1; | ||
1142 | } | 1052 | } |
1143 | 1053 | ||
1144 | static inline void dbg_ctrl(struct controller *ctrl) | 1054 | static inline void dbg_ctrl(struct controller *ctrl) |
@@ -1176,7 +1086,7 @@ static inline void dbg_ctrl(struct controller *ctrl) | |||
1176 | dbg(" Comamnd Completed : %3s\n", NO_CMD_CMPL(ctrl)? "no" : "yes"); | 1086 | dbg(" Comamnd Completed : %3s\n", NO_CMD_CMPL(ctrl)? "no" : "yes"); |
1177 | pciehp_readw(ctrl, SLOTSTATUS, ®16); | 1087 | pciehp_readw(ctrl, SLOTSTATUS, ®16); |
1178 | dbg("Slot Status : 0x%04x\n", reg16); | 1088 | dbg("Slot Status : 0x%04x\n", reg16); |
1179 | pciehp_readw(ctrl, SLOTSTATUS, ®16); | 1089 | pciehp_readw(ctrl, SLOTCTRL, ®16); |
1180 | dbg("Slot Control : 0x%04x\n", reg16); | 1090 | dbg("Slot Control : 0x%04x\n", reg16); |
1181 | } | 1091 | } |
1182 | 1092 | ||
diff --git a/drivers/pci/hotplug/rpadlpar_sysfs.c b/drivers/pci/hotplug/rpadlpar_sysfs.c index 779c5db71be4..a796301ea03f 100644 --- a/drivers/pci/hotplug/rpadlpar_sysfs.c +++ b/drivers/pci/hotplug/rpadlpar_sysfs.c | |||
@@ -14,8 +14,10 @@ | |||
14 | */ | 14 | */ |
15 | #include <linux/kobject.h> | 15 | #include <linux/kobject.h> |
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include <linux/pci.h> | ||
17 | #include <linux/pci_hotplug.h> | 18 | #include <linux/pci_hotplug.h> |
18 | #include "rpadlpar.h" | 19 | #include "rpadlpar.h" |
20 | #include "../pci.h" | ||
19 | 21 | ||
20 | #define DLPAR_KOBJ_NAME "control" | 22 | #define DLPAR_KOBJ_NAME "control" |
21 | 23 | ||
@@ -27,7 +29,6 @@ | |||
27 | 29 | ||
28 | #define MAX_DRC_NAME_LEN 64 | 30 | #define MAX_DRC_NAME_LEN 64 |
29 | 31 | ||
30 | |||
31 | static ssize_t add_slot_store(struct kobject *kobj, struct kobj_attribute *attr, | 32 | static ssize_t add_slot_store(struct kobject *kobj, struct kobj_attribute *attr, |
32 | const char *buf, size_t nbytes) | 33 | const char *buf, size_t nbytes) |
33 | { | 34 | { |
@@ -112,7 +113,7 @@ int dlpar_sysfs_init(void) | |||
112 | int error; | 113 | int error; |
113 | 114 | ||
114 | dlpar_kobj = kobject_create_and_add(DLPAR_KOBJ_NAME, | 115 | dlpar_kobj = kobject_create_and_add(DLPAR_KOBJ_NAME, |
115 | &pci_hotplug_slots_kset->kobj); | 116 | &pci_slots_kset->kobj); |
116 | if (!dlpar_kobj) | 117 | if (!dlpar_kobj) |
117 | return -EINVAL; | 118 | return -EINVAL; |
118 | 119 | ||
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index 56197b600d36..9b714ea93d20 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c | |||
@@ -33,33 +33,6 @@ | |||
33 | #include <asm/rtas.h> | 33 | #include <asm/rtas.h> |
34 | #include "rpaphp.h" | 34 | #include "rpaphp.h" |
35 | 35 | ||
36 | static ssize_t address_read_file (struct hotplug_slot *php_slot, char *buf) | ||
37 | { | ||
38 | int retval; | ||
39 | struct slot *slot = (struct slot *)php_slot->private; | ||
40 | struct pci_bus *bus; | ||
41 | |||
42 | if (!slot) | ||
43 | return -ENOENT; | ||
44 | |||
45 | bus = slot->bus; | ||
46 | if (!bus) | ||
47 | return -ENOENT; | ||
48 | |||
49 | if (bus->self) | ||
50 | retval = sprintf(buf, pci_name(bus->self)); | ||
51 | else | ||
52 | retval = sprintf(buf, "%04x:%02x:00.0", | ||
53 | pci_domain_nr(bus), bus->number); | ||
54 | |||
55 | return retval; | ||
56 | } | ||
57 | |||
58 | static struct hotplug_slot_attribute php_attr_address = { | ||
59 | .attr = {.name = "address", .mode = S_IFREG | S_IRUGO}, | ||
60 | .show = address_read_file, | ||
61 | }; | ||
62 | |||
63 | /* free up the memory used by a slot */ | 36 | /* free up the memory used by a slot */ |
64 | static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot) | 37 | static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot) |
65 | { | 38 | { |
@@ -135,9 +108,6 @@ int rpaphp_deregister_slot(struct slot *slot) | |||
135 | 108 | ||
136 | list_del(&slot->rpaphp_slot_list); | 109 | list_del(&slot->rpaphp_slot_list); |
137 | 110 | ||
138 | /* remove "address" file */ | ||
139 | sysfs_remove_file(&php_slot->kobj, &php_attr_address.attr); | ||
140 | |||
141 | retval = pci_hp_deregister(php_slot); | 111 | retval = pci_hp_deregister(php_slot); |
142 | if (retval) | 112 | if (retval) |
143 | err("Problem unregistering a slot %s\n", slot->name); | 113 | err("Problem unregistering a slot %s\n", slot->name); |
@@ -151,6 +121,7 @@ int rpaphp_register_slot(struct slot *slot) | |||
151 | { | 121 | { |
152 | struct hotplug_slot *php_slot = slot->hotplug_slot; | 122 | struct hotplug_slot *php_slot = slot->hotplug_slot; |
153 | int retval; | 123 | int retval; |
124 | int slotno; | ||
154 | 125 | ||
155 | dbg("%s registering slot:path[%s] index[%x], name[%s] pdomain[%x] type[%d]\n", | 126 | dbg("%s registering slot:path[%s] index[%x], name[%s] pdomain[%x] type[%d]\n", |
156 | __func__, slot->dn->full_name, slot->index, slot->name, | 127 | __func__, slot->dn->full_name, slot->index, slot->name, |
@@ -162,19 +133,16 @@ int rpaphp_register_slot(struct slot *slot) | |||
162 | return -EAGAIN; | 133 | return -EAGAIN; |
163 | } | 134 | } |
164 | 135 | ||
165 | retval = pci_hp_register(php_slot); | 136 | if (slot->dn->child) |
137 | slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn); | ||
138 | else | ||
139 | slotno = -1; | ||
140 | retval = pci_hp_register(php_slot, slot->bus, slotno); | ||
166 | if (retval) { | 141 | if (retval) { |
167 | err("pci_hp_register failed with error %d\n", retval); | 142 | err("pci_hp_register failed with error %d\n", retval); |
168 | return retval; | 143 | return retval; |
169 | } | 144 | } |
170 | 145 | ||
171 | /* create "address" file */ | ||
172 | retval = sysfs_create_file(&php_slot->kobj, &php_attr_address.attr); | ||
173 | if (retval) { | ||
174 | err("sysfs_create_file failed with error %d\n", retval); | ||
175 | goto sysfs_fail; | ||
176 | } | ||
177 | |||
178 | /* add slot to our internal list */ | 146 | /* add slot to our internal list */ |
179 | list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head); | 147 | list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head); |
180 | info("Slot [%s] registered\n", slot->name); | 148 | info("Slot [%s] registered\n", slot->name); |
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index 2fe37cd85b69..410fe0394a8e 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c | |||
@@ -197,13 +197,15 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot, | |||
197 | static struct hotplug_slot * sn_hp_destroy(void) | 197 | static struct hotplug_slot * sn_hp_destroy(void) |
198 | { | 198 | { |
199 | struct slot *slot; | 199 | struct slot *slot; |
200 | struct pci_slot *pci_slot; | ||
200 | struct hotplug_slot *bss_hotplug_slot = NULL; | 201 | struct hotplug_slot *bss_hotplug_slot = NULL; |
201 | 202 | ||
202 | list_for_each_entry(slot, &sn_hp_list, hp_list) { | 203 | list_for_each_entry(slot, &sn_hp_list, hp_list) { |
203 | bss_hotplug_slot = slot->hotplug_slot; | 204 | bss_hotplug_slot = slot->hotplug_slot; |
205 | pci_slot = bss_hotplug_slot->pci_slot; | ||
204 | list_del(&((struct slot *)bss_hotplug_slot->private)-> | 206 | list_del(&((struct slot *)bss_hotplug_slot->private)-> |
205 | hp_list); | 207 | hp_list); |
206 | sysfs_remove_file(&bss_hotplug_slot->kobj, | 208 | sysfs_remove_file(&pci_slot->kobj, |
207 | &sn_slot_path_attr.attr); | 209 | &sn_slot_path_attr.attr); |
208 | break; | 210 | break; |
209 | } | 211 | } |
@@ -614,6 +616,7 @@ static void sn_release_slot(struct hotplug_slot *bss_hotplug_slot) | |||
614 | static int sn_hotplug_slot_register(struct pci_bus *pci_bus) | 616 | static int sn_hotplug_slot_register(struct pci_bus *pci_bus) |
615 | { | 617 | { |
616 | int device; | 618 | int device; |
619 | struct pci_slot *pci_slot; | ||
617 | struct hotplug_slot *bss_hotplug_slot; | 620 | struct hotplug_slot *bss_hotplug_slot; |
618 | int rc = 0; | 621 | int rc = 0; |
619 | 622 | ||
@@ -650,11 +653,12 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) | |||
650 | bss_hotplug_slot->ops = &sn_hotplug_slot_ops; | 653 | bss_hotplug_slot->ops = &sn_hotplug_slot_ops; |
651 | bss_hotplug_slot->release = &sn_release_slot; | 654 | bss_hotplug_slot->release = &sn_release_slot; |
652 | 655 | ||
653 | rc = pci_hp_register(bss_hotplug_slot); | 656 | rc = pci_hp_register(bss_hotplug_slot, pci_bus, device); |
654 | if (rc) | 657 | if (rc) |
655 | goto register_err; | 658 | goto register_err; |
656 | 659 | ||
657 | rc = sysfs_create_file(&bss_hotplug_slot->kobj, | 660 | pci_slot = bss_hotplug_slot->pci_slot; |
661 | rc = sysfs_create_file(&pci_slot->kobj, | ||
658 | &sn_slot_path_attr.attr); | 662 | &sn_slot_path_attr.attr); |
659 | if (rc) | 663 | if (rc) |
660 | goto register_err; | 664 | goto register_err; |
@@ -664,7 +668,7 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) | |||
664 | 668 | ||
665 | register_err: | 669 | register_err: |
666 | dev_dbg(&pci_bus->self->dev, "bus failed to register with err = %d\n", | 670 | dev_dbg(&pci_bus->self->dev, "bus failed to register with err = %d\n", |
667 | rc); | 671 | rc); |
668 | 672 | ||
669 | alloc_err: | 673 | alloc_err: |
670 | if (rc == -ENOMEM) | 674 | if (rc == -ENOMEM) |
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h index f66e8d6315ab..8a026f750deb 100644 --- a/drivers/pci/hotplug/shpchp.h +++ b/drivers/pci/hotplug/shpchp.h | |||
@@ -170,6 +170,7 @@ extern void shpchp_queue_pushbutton_work(struct work_struct *work); | |||
170 | extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev); | 170 | extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev); |
171 | 171 | ||
172 | #ifdef CONFIG_ACPI | 172 | #ifdef CONFIG_ACPI |
173 | #include <linux/pci-acpi.h> | ||
173 | static inline int get_hp_params_from_firmware(struct pci_dev *dev, | 174 | static inline int get_hp_params_from_firmware(struct pci_dev *dev, |
174 | struct hotplug_params *hpp) | 175 | struct hotplug_params *hpp) |
175 | { | 176 | { |
@@ -177,14 +178,15 @@ static inline int get_hp_params_from_firmware(struct pci_dev *dev, | |||
177 | return -ENODEV; | 178 | return -ENODEV; |
178 | return 0; | 179 | return 0; |
179 | } | 180 | } |
180 | #define get_hp_hw_control_from_firmware(pdev) \ | 181 | |
181 | do { \ | 182 | static inline int get_hp_hw_control_from_firmware(struct pci_dev *dev) |
182 | if (DEVICE_ACPI_HANDLE(&(pdev->dev))) \ | 183 | { |
183 | acpi_run_oshp(DEVICE_ACPI_HANDLE(&(pdev->dev)));\ | 184 | u32 flags = OSC_SHPC_NATIVE_HP_CONTROL; |
184 | } while (0) | 185 | return acpi_get_hp_hw_control_from_firmware(dev, flags); |
186 | } | ||
185 | #else | 187 | #else |
186 | #define get_hp_params_from_firmware(dev, hpp) (-ENODEV) | 188 | #define get_hp_params_from_firmware(dev, hpp) (-ENODEV) |
187 | #define get_hp_hw_control_from_firmware(dev) do { } while (0) | 189 | #define get_hp_hw_control_from_firmware(dev) (0) |
188 | #endif | 190 | #endif |
189 | 191 | ||
190 | struct ctrl_reg { | 192 | struct ctrl_reg { |
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index 97848654652a..a8cbd039b85b 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c | |||
@@ -39,7 +39,7 @@ | |||
39 | int shpchp_debug; | 39 | int shpchp_debug; |
40 | int shpchp_poll_mode; | 40 | int shpchp_poll_mode; |
41 | int shpchp_poll_time; | 41 | int shpchp_poll_time; |
42 | int shpchp_slot_with_bus; | 42 | static int shpchp_slot_with_bus; |
43 | struct workqueue_struct *shpchp_wq; | 43 | struct workqueue_struct *shpchp_wq; |
44 | 44 | ||
45 | #define DRIVER_VERSION "0.4" | 45 | #define DRIVER_VERSION "0.4" |
@@ -68,7 +68,6 @@ static int get_power_status (struct hotplug_slot *slot, u8 *value); | |||
68 | static int get_attention_status (struct hotplug_slot *slot, u8 *value); | 68 | static int get_attention_status (struct hotplug_slot *slot, u8 *value); |
69 | static int get_latch_status (struct hotplug_slot *slot, u8 *value); | 69 | static int get_latch_status (struct hotplug_slot *slot, u8 *value); |
70 | static int get_adapter_status (struct hotplug_slot *slot, u8 *value); | 70 | static int get_adapter_status (struct hotplug_slot *slot, u8 *value); |
71 | static int get_address (struct hotplug_slot *slot, u32 *value); | ||
72 | static int get_max_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); | 71 | static int get_max_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); |
73 | static int get_cur_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); | 72 | static int get_cur_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); |
74 | 73 | ||
@@ -81,7 +80,6 @@ static struct hotplug_slot_ops shpchp_hotplug_slot_ops = { | |||
81 | .get_attention_status = get_attention_status, | 80 | .get_attention_status = get_attention_status, |
82 | .get_latch_status = get_latch_status, | 81 | .get_latch_status = get_latch_status, |
83 | .get_adapter_status = get_adapter_status, | 82 | .get_adapter_status = get_adapter_status, |
84 | .get_address = get_address, | ||
85 | .get_max_bus_speed = get_max_bus_speed, | 83 | .get_max_bus_speed = get_max_bus_speed, |
86 | .get_cur_bus_speed = get_cur_bus_speed, | 84 | .get_cur_bus_speed = get_cur_bus_speed, |
87 | }; | 85 | }; |
@@ -159,7 +157,8 @@ static int init_slots(struct controller *ctrl) | |||
159 | dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " | 157 | dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " |
160 | "slot_device_offset=%x\n", slot->bus, slot->device, | 158 | "slot_device_offset=%x\n", slot->bus, slot->device, |
161 | slot->hp_slot, slot->number, ctrl->slot_device_offset); | 159 | slot->hp_slot, slot->number, ctrl->slot_device_offset); |
162 | retval = pci_hp_register(slot->hotplug_slot); | 160 | retval = pci_hp_register(slot->hotplug_slot, |
161 | ctrl->pci_dev->subordinate, slot->device); | ||
163 | if (retval) { | 162 | if (retval) { |
164 | err("pci_hp_register failed with error %d\n", retval); | 163 | err("pci_hp_register failed with error %d\n", retval); |
165 | if (retval == -EEXIST) | 164 | if (retval == -EEXIST) |
@@ -288,19 +287,8 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
288 | return 0; | 287 | return 0; |
289 | } | 288 | } |
290 | 289 | ||
291 | static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) | 290 | static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, |
292 | { | 291 | enum pci_bus_speed *value) |
293 | struct slot *slot = get_slot(hotplug_slot); | ||
294 | struct pci_bus *bus = slot->ctrl->pci_dev->subordinate; | ||
295 | |||
296 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | ||
297 | |||
298 | *value = (pci_domain_nr(bus) << 16) | (slot->bus << 8) | slot->device; | ||
299 | |||
300 | return 0; | ||
301 | } | ||
302 | |||
303 | static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) | ||
304 | { | 292 | { |
305 | struct slot *slot = get_slot(hotplug_slot); | 293 | struct slot *slot = get_slot(hotplug_slot); |
306 | int retval; | 294 | int retval; |
@@ -330,13 +318,14 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp | |||
330 | 318 | ||
331 | static int is_shpc_capable(struct pci_dev *dev) | 319 | static int is_shpc_capable(struct pci_dev *dev) |
332 | { | 320 | { |
333 | if ((dev->vendor == PCI_VENDOR_ID_AMD) || (dev->device == | 321 | if ((dev->vendor == PCI_VENDOR_ID_AMD) || (dev->device == |
334 | PCI_DEVICE_ID_AMD_GOLAM_7450)) | 322 | PCI_DEVICE_ID_AMD_GOLAM_7450)) |
335 | return 1; | 323 | return 1; |
336 | if (pci_find_capability(dev, PCI_CAP_ID_SHPC)) | 324 | if (!pci_find_capability(dev, PCI_CAP_ID_SHPC)) |
337 | return 1; | 325 | return 0; |
338 | 326 | if (get_hp_hw_control_from_firmware(dev)) | |
339 | return 0; | 327 | return 0; |
328 | return 1; | ||
340 | } | 329 | } |
341 | 330 | ||
342 | static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | 331 | static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index 7d770b2cd889..7a0bff364cd4 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c | |||
@@ -1084,7 +1084,6 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev) | |||
1084 | dbg("%s: HPC at b:d:f:irq=0x%x:%x:%x:%x\n", __func__, | 1084 | dbg("%s: HPC at b:d:f:irq=0x%x:%x:%x:%x\n", __func__, |
1085 | pdev->bus->number, PCI_SLOT(pdev->devfn), | 1085 | pdev->bus->number, PCI_SLOT(pdev->devfn), |
1086 | PCI_FUNC(pdev->devfn), pdev->irq); | 1086 | PCI_FUNC(pdev->devfn), pdev->irq); |
1087 | get_hp_hw_control_from_firmware(pdev); | ||
1088 | 1087 | ||
1089 | /* | 1088 | /* |
1090 | * If this is the first controller to be initialized, | 1089 | * If this is the first controller to be initialized, |
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index 66c0fd21894b..4f05d91a0fd8 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -1725,7 +1725,6 @@ int __init init_dmars(void) | |||
1725 | deferred_flush = kzalloc(g_num_of_iommus * | 1725 | deferred_flush = kzalloc(g_num_of_iommus * |
1726 | sizeof(struct deferred_flush_tables), GFP_KERNEL); | 1726 | sizeof(struct deferred_flush_tables), GFP_KERNEL); |
1727 | if (!deferred_flush) { | 1727 | if (!deferred_flush) { |
1728 | kfree(g_iommus); | ||
1729 | ret = -ENOMEM; | 1728 | ret = -ENOMEM; |
1730 | goto error; | 1729 | goto error; |
1731 | } | 1730 | } |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 8c61304cbb37..ccb1974464fb 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -70,12 +70,10 @@ arch_teardown_msi_irqs(struct pci_dev *dev) | |||
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | static void msi_set_enable(struct pci_dev *dev, int enable) | 73 | static void __msi_set_enable(struct pci_dev *dev, int pos, int enable) |
74 | { | 74 | { |
75 | int pos; | ||
76 | u16 control; | 75 | u16 control; |
77 | 76 | ||
78 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); | ||
79 | if (pos) { | 77 | if (pos) { |
80 | pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control); | 78 | pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control); |
81 | control &= ~PCI_MSI_FLAGS_ENABLE; | 79 | control &= ~PCI_MSI_FLAGS_ENABLE; |
@@ -85,6 +83,11 @@ static void msi_set_enable(struct pci_dev *dev, int enable) | |||
85 | } | 83 | } |
86 | } | 84 | } |
87 | 85 | ||
86 | static void msi_set_enable(struct pci_dev *dev, int enable) | ||
87 | { | ||
88 | __msi_set_enable(dev, pci_find_capability(dev, PCI_CAP_ID_MSI), enable); | ||
89 | } | ||
90 | |||
88 | static void msix_set_enable(struct pci_dev *dev, int enable) | 91 | static void msix_set_enable(struct pci_dev *dev, int enable) |
89 | { | 92 | { |
90 | int pos; | 93 | int pos; |
@@ -141,7 +144,8 @@ static void msi_set_mask_bits(unsigned int irq, u32 mask, u32 flag) | |||
141 | mask_bits |= flag & mask; | 144 | mask_bits |= flag & mask; |
142 | pci_write_config_dword(entry->dev, pos, mask_bits); | 145 | pci_write_config_dword(entry->dev, pos, mask_bits); |
143 | } else { | 146 | } else { |
144 | msi_set_enable(entry->dev, !flag); | 147 | __msi_set_enable(entry->dev, entry->msi_attrib.pos, |
148 | !flag); | ||
145 | } | 149 | } |
146 | break; | 150 | break; |
147 | case PCI_CAP_ID_MSIX: | 151 | case PCI_CAP_ID_MSIX: |
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index dab9d471914c..056ea80ee27a 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -21,12 +21,19 @@ | |||
21 | 21 | ||
22 | struct acpi_osc_data { | 22 | struct acpi_osc_data { |
23 | acpi_handle handle; | 23 | acpi_handle handle; |
24 | u32 ctrlset_buf[3]; | 24 | u32 support_set; |
25 | u32 global_ctrlsets; | 25 | u32 control_set; |
26 | int is_queried; | ||
27 | u32 query_result; | ||
26 | struct list_head sibiling; | 28 | struct list_head sibiling; |
27 | }; | 29 | }; |
28 | static LIST_HEAD(acpi_osc_data_list); | 30 | static LIST_HEAD(acpi_osc_data_list); |
29 | 31 | ||
32 | struct acpi_osc_args { | ||
33 | u32 capbuf[3]; | ||
34 | u32 query_result; | ||
35 | }; | ||
36 | |||
30 | static struct acpi_osc_data *acpi_get_osc_data(acpi_handle handle) | 37 | static struct acpi_osc_data *acpi_get_osc_data(acpi_handle handle) |
31 | { | 38 | { |
32 | struct acpi_osc_data *data; | 39 | struct acpi_osc_data *data; |
@@ -44,42 +51,18 @@ static struct acpi_osc_data *acpi_get_osc_data(acpi_handle handle) | |||
44 | return data; | 51 | return data; |
45 | } | 52 | } |
46 | 53 | ||
47 | static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; | 54 | static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, |
55 | 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; | ||
48 | 56 | ||
49 | static acpi_status | 57 | static acpi_status acpi_run_osc(acpi_handle handle, |
50 | acpi_query_osc ( | 58 | struct acpi_osc_args *osc_args) |
51 | acpi_handle handle, | ||
52 | u32 level, | ||
53 | void *context, | ||
54 | void **retval ) | ||
55 | { | 59 | { |
56 | acpi_status status; | 60 | acpi_status status; |
57 | struct acpi_object_list input; | 61 | struct acpi_object_list input; |
58 | union acpi_object in_params[4]; | 62 | union acpi_object in_params[4]; |
59 | struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; | 63 | struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; |
60 | union acpi_object *out_obj; | 64 | union acpi_object *out_obj; |
61 | u32 osc_dw0; | 65 | u32 osc_dw0, flags = osc_args->capbuf[OSC_QUERY_TYPE]; |
62 | acpi_status *ret_status = (acpi_status *)retval; | ||
63 | struct acpi_osc_data *osc_data; | ||
64 | u32 flags = (unsigned long)context, temp; | ||
65 | acpi_handle tmp; | ||
66 | |||
67 | status = acpi_get_handle(handle, "_OSC", &tmp); | ||
68 | if (ACPI_FAILURE(status)) | ||
69 | return status; | ||
70 | |||
71 | osc_data = acpi_get_osc_data(handle); | ||
72 | if (!osc_data) { | ||
73 | printk(KERN_ERR "acpi osc data array is full\n"); | ||
74 | return AE_ERROR; | ||
75 | } | ||
76 | |||
77 | osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] |= (flags & OSC_SUPPORT_MASKS); | ||
78 | |||
79 | /* do _OSC query for all possible controls */ | ||
80 | temp = osc_data->ctrlset_buf[OSC_CONTROL_TYPE]; | ||
81 | osc_data->ctrlset_buf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; | ||
82 | osc_data->ctrlset_buf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; | ||
83 | 66 | ||
84 | /* Setting up input parameters */ | 67 | /* Setting up input parameters */ |
85 | input.count = 4; | 68 | input.count = 4; |
@@ -93,20 +76,19 @@ acpi_query_osc ( | |||
93 | in_params[2].integer.value = 3; | 76 | in_params[2].integer.value = 3; |
94 | in_params[3].type = ACPI_TYPE_BUFFER; | 77 | in_params[3].type = ACPI_TYPE_BUFFER; |
95 | in_params[3].buffer.length = 12; | 78 | in_params[3].buffer.length = 12; |
96 | in_params[3].buffer.pointer = (u8 *)osc_data->ctrlset_buf; | 79 | in_params[3].buffer.pointer = (u8 *)osc_args->capbuf; |
97 | 80 | ||
98 | status = acpi_evaluate_object(handle, "_OSC", &input, &output); | 81 | status = acpi_evaluate_object(handle, "_OSC", &input, &output); |
99 | if (ACPI_FAILURE(status)) | 82 | if (ACPI_FAILURE(status)) |
100 | goto out_nofree; | 83 | return status; |
101 | out_obj = output.pointer; | ||
102 | 84 | ||
85 | out_obj = output.pointer; | ||
103 | if (out_obj->type != ACPI_TYPE_BUFFER) { | 86 | if (out_obj->type != ACPI_TYPE_BUFFER) { |
104 | printk(KERN_DEBUG | 87 | printk(KERN_DEBUG "Evaluate _OSC returns wrong type\n"); |
105 | "Evaluate _OSC returns wrong type\n"); | ||
106 | status = AE_TYPE; | 88 | status = AE_TYPE; |
107 | goto query_osc_out; | 89 | goto out_kfree; |
108 | } | 90 | } |
109 | osc_dw0 = *((u32 *) out_obj->buffer.pointer); | 91 | osc_dw0 = *((u32 *)out_obj->buffer.pointer); |
110 | if (osc_dw0) { | 92 | if (osc_dw0) { |
111 | if (osc_dw0 & OSC_REQUEST_ERROR) | 93 | if (osc_dw0 & OSC_REQUEST_ERROR) |
112 | printk(KERN_DEBUG "_OSC request fails\n"); | 94 | printk(KERN_DEBUG "_OSC request fails\n"); |
@@ -115,93 +97,58 @@ acpi_query_osc ( | |||
115 | if (osc_dw0 & OSC_INVALID_REVISION_ERROR) | 97 | if (osc_dw0 & OSC_INVALID_REVISION_ERROR) |
116 | printk(KERN_DEBUG "_OSC invalid revision\n"); | 98 | printk(KERN_DEBUG "_OSC invalid revision\n"); |
117 | if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { | 99 | if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { |
118 | /* Update Global Control Set */ | 100 | if (flags & OSC_QUERY_ENABLE) |
119 | osc_data->global_ctrlsets = | 101 | goto out_success; |
120 | *((u32 *)(out_obj->buffer.pointer + 8)); | 102 | printk(KERN_DEBUG "_OSC FW not grant req. control\n"); |
121 | status = AE_OK; | 103 | status = AE_SUPPORT; |
122 | goto query_osc_out; | 104 | goto out_kfree; |
123 | } | 105 | } |
124 | status = AE_ERROR; | 106 | status = AE_ERROR; |
125 | goto query_osc_out; | 107 | goto out_kfree; |
126 | } | 108 | } |
127 | 109 | out_success: | |
128 | /* Update Global Control Set */ | 110 | if (flags & OSC_QUERY_ENABLE) |
129 | osc_data->global_ctrlsets = *((u32 *)(out_obj->buffer.pointer + 8)); | 111 | osc_args->query_result = |
112 | *((u32 *)(out_obj->buffer.pointer + 8)); | ||
130 | status = AE_OK; | 113 | status = AE_OK; |
131 | 114 | ||
132 | query_osc_out: | 115 | out_kfree: |
133 | kfree(output.pointer); | 116 | kfree(output.pointer); |
134 | out_nofree: | ||
135 | *ret_status = status; | ||
136 | |||
137 | osc_data->ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE; | ||
138 | osc_data->ctrlset_buf[OSC_CONTROL_TYPE] = temp; | ||
139 | if (ACPI_FAILURE(status)) { | ||
140 | /* no osc support at all */ | ||
141 | osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] = 0; | ||
142 | } | ||
143 | |||
144 | return status; | 117 | return status; |
145 | } | 118 | } |
146 | 119 | ||
147 | 120 | static acpi_status acpi_query_osc(acpi_handle handle, | |
148 | static acpi_status | 121 | u32 level, void *context, void **retval) |
149 | acpi_run_osc ( | ||
150 | acpi_handle handle, | ||
151 | void *context) | ||
152 | { | 122 | { |
153 | acpi_status status; | 123 | acpi_status status; |
154 | struct acpi_object_list input; | 124 | struct acpi_osc_data *osc_data; |
155 | union acpi_object in_params[4]; | 125 | u32 flags = (unsigned long)context, support_set; |
156 | struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; | 126 | acpi_handle tmp; |
157 | union acpi_object *out_obj; | 127 | struct acpi_osc_args osc_args; |
158 | u32 osc_dw0; | ||
159 | |||
160 | /* Setting up input parameters */ | ||
161 | input.count = 4; | ||
162 | input.pointer = in_params; | ||
163 | in_params[0].type = ACPI_TYPE_BUFFER; | ||
164 | in_params[0].buffer.length = 16; | ||
165 | in_params[0].buffer.pointer = OSC_UUID; | ||
166 | in_params[1].type = ACPI_TYPE_INTEGER; | ||
167 | in_params[1].integer.value = 1; | ||
168 | in_params[2].type = ACPI_TYPE_INTEGER; | ||
169 | in_params[2].integer.value = 3; | ||
170 | in_params[3].type = ACPI_TYPE_BUFFER; | ||
171 | in_params[3].buffer.length = 12; | ||
172 | in_params[3].buffer.pointer = (u8 *)context; | ||
173 | 128 | ||
174 | status = acpi_evaluate_object(handle, "_OSC", &input, &output); | 129 | status = acpi_get_handle(handle, "_OSC", &tmp); |
175 | if (ACPI_FAILURE (status)) | 130 | if (ACPI_FAILURE(status)) |
176 | return status; | 131 | return status; |
177 | 132 | ||
178 | out_obj = output.pointer; | 133 | osc_data = acpi_get_osc_data(handle); |
179 | if (out_obj->type != ACPI_TYPE_BUFFER) { | 134 | if (!osc_data) { |
180 | printk(KERN_DEBUG | 135 | printk(KERN_ERR "acpi osc data array is full\n"); |
181 | "Evaluate _OSC returns wrong type\n"); | 136 | return AE_ERROR; |
182 | status = AE_TYPE; | ||
183 | goto run_osc_out; | ||
184 | } | 137 | } |
185 | osc_dw0 = *((u32 *) out_obj->buffer.pointer); | 138 | |
186 | if (osc_dw0) { | 139 | /* do _OSC query for all possible controls */ |
187 | if (osc_dw0 & OSC_REQUEST_ERROR) | 140 | support_set = osc_data->support_set | (flags & OSC_SUPPORT_MASKS); |
188 | printk(KERN_DEBUG "_OSC request fails\n"); | 141 | osc_args.capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; |
189 | if (osc_dw0 & OSC_INVALID_UUID_ERROR) | 142 | osc_args.capbuf[OSC_SUPPORT_TYPE] = support_set; |
190 | printk(KERN_DEBUG "_OSC invalid UUID\n"); | 143 | osc_args.capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; |
191 | if (osc_dw0 & OSC_INVALID_REVISION_ERROR) | 144 | |
192 | printk(KERN_DEBUG "_OSC invalid revision\n"); | 145 | status = acpi_run_osc(handle, &osc_args); |
193 | if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { | 146 | if (ACPI_SUCCESS(status)) { |
194 | printk(KERN_DEBUG "_OSC FW not grant req. control\n"); | 147 | osc_data->support_set = support_set; |
195 | status = AE_SUPPORT; | 148 | osc_data->query_result = osc_args.query_result; |
196 | goto run_osc_out; | 149 | osc_data->is_queried = 1; |
197 | } | ||
198 | status = AE_ERROR; | ||
199 | goto run_osc_out; | ||
200 | } | 150 | } |
201 | status = AE_OK; | ||
202 | 151 | ||
203 | run_osc_out: | ||
204 | kfree(output.pointer); | ||
205 | return status; | 152 | return status; |
206 | } | 153 | } |
207 | 154 | ||
@@ -215,15 +162,11 @@ run_osc_out: | |||
215 | **/ | 162 | **/ |
216 | acpi_status __pci_osc_support_set(u32 flags, const char *hid) | 163 | acpi_status __pci_osc_support_set(u32 flags, const char *hid) |
217 | { | 164 | { |
218 | acpi_status retval = AE_NOT_FOUND; | 165 | if (!(flags & OSC_SUPPORT_MASKS)) |
219 | |||
220 | if (!(flags & OSC_SUPPORT_MASKS)) { | ||
221 | return AE_TYPE; | 166 | return AE_TYPE; |
222 | } | 167 | |
223 | acpi_get_devices(hid, | 168 | acpi_get_devices(hid, acpi_query_osc, |
224 | acpi_query_osc, | 169 | (void *)(unsigned long)flags, NULL); |
225 | (void *)(unsigned long)flags, | ||
226 | (void **) &retval ); | ||
227 | return AE_OK; | 170 | return AE_OK; |
228 | } | 171 | } |
229 | 172 | ||
@@ -236,10 +179,11 @@ acpi_status __pci_osc_support_set(u32 flags, const char *hid) | |||
236 | **/ | 179 | **/ |
237 | acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) | 180 | acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) |
238 | { | 181 | { |
239 | acpi_status status; | 182 | acpi_status status; |
240 | u32 ctrlset; | 183 | u32 ctrlset, control_set; |
241 | acpi_handle tmp; | 184 | acpi_handle tmp; |
242 | struct acpi_osc_data *osc_data; | 185 | struct acpi_osc_data *osc_data; |
186 | struct acpi_osc_args osc_args; | ||
243 | 187 | ||
244 | status = acpi_get_handle(handle, "_OSC", &tmp); | 188 | status = acpi_get_handle(handle, "_OSC", &tmp); |
245 | if (ACPI_FAILURE(status)) | 189 | if (ACPI_FAILURE(status)) |
@@ -252,19 +196,21 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) | |||
252 | } | 196 | } |
253 | 197 | ||
254 | ctrlset = (flags & OSC_CONTROL_MASKS); | 198 | ctrlset = (flags & OSC_CONTROL_MASKS); |
255 | if (!ctrlset) { | 199 | if (!ctrlset) |
256 | return AE_TYPE; | 200 | return AE_TYPE; |
257 | } | 201 | |
258 | if (osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] && | 202 | if (osc_data->is_queried && |
259 | ((osc_data->global_ctrlsets & ctrlset) != ctrlset)) { | 203 | ((osc_data->query_result & ctrlset) != ctrlset)) |
260 | return AE_SUPPORT; | 204 | return AE_SUPPORT; |
261 | } | 205 | |
262 | osc_data->ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset; | 206 | control_set = osc_data->control_set | ctrlset; |
263 | status = acpi_run_osc(handle, osc_data->ctrlset_buf); | 207 | osc_args.capbuf[OSC_QUERY_TYPE] = 0; |
264 | if (ACPI_FAILURE (status)) { | 208 | osc_args.capbuf[OSC_SUPPORT_TYPE] = osc_data->support_set; |
265 | osc_data->ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset; | 209 | osc_args.capbuf[OSC_CONTROL_TYPE] = control_set; |
266 | } | 210 | status = acpi_run_osc(handle, &osc_args); |
267 | 211 | if (ACPI_SUCCESS(status)) | |
212 | osc_data->control_set = control_set; | ||
213 | |||
268 | return status; | 214 | return status; |
269 | } | 215 | } |
270 | EXPORT_SYMBOL(pci_osc_control_set); | 216 | EXPORT_SYMBOL(pci_osc_control_set); |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 72cf61ed8f96..8eb8a3091dc7 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -274,7 +274,57 @@ static int pci_device_remove(struct device * dev) | |||
274 | return 0; | 274 | return 0; |
275 | } | 275 | } |
276 | 276 | ||
277 | static int pci_device_suspend(struct device * dev, pm_message_t state) | 277 | static void pci_device_shutdown(struct device *dev) |
278 | { | ||
279 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
280 | struct pci_driver *drv = pci_dev->driver; | ||
281 | |||
282 | if (drv && drv->shutdown) | ||
283 | drv->shutdown(pci_dev); | ||
284 | pci_msi_shutdown(pci_dev); | ||
285 | pci_msix_shutdown(pci_dev); | ||
286 | } | ||
287 | |||
288 | #ifdef CONFIG_PM_SLEEP | ||
289 | |||
290 | /* | ||
291 | * Default "suspend" method for devices that have no driver provided suspend, | ||
292 | * or not even a driver at all. | ||
293 | */ | ||
294 | static void pci_default_pm_suspend(struct pci_dev *pci_dev) | ||
295 | { | ||
296 | pci_save_state(pci_dev); | ||
297 | /* | ||
298 | * mark its power state as "unknown", since we don't know if | ||
299 | * e.g. the BIOS will change its device state when we suspend. | ||
300 | */ | ||
301 | if (pci_dev->current_state == PCI_D0) | ||
302 | pci_dev->current_state = PCI_UNKNOWN; | ||
303 | } | ||
304 | |||
305 | /* | ||
306 | * Default "resume" method for devices that have no driver provided resume, | ||
307 | * or not even a driver at all. | ||
308 | */ | ||
309 | static int pci_default_pm_resume(struct pci_dev *pci_dev) | ||
310 | { | ||
311 | int retval = 0; | ||
312 | |||
313 | /* restore the PCI config space */ | ||
314 | pci_restore_state(pci_dev); | ||
315 | /* if the device was enabled before suspend, reenable */ | ||
316 | retval = pci_reenable_device(pci_dev); | ||
317 | /* | ||
318 | * if the device was busmaster before the suspend, make it busmaster | ||
319 | * again | ||
320 | */ | ||
321 | if (pci_dev->is_busmaster) | ||
322 | pci_set_master(pci_dev); | ||
323 | |||
324 | return retval; | ||
325 | } | ||
326 | |||
327 | static int pci_legacy_suspend(struct device *dev, pm_message_t state) | ||
278 | { | 328 | { |
279 | struct pci_dev * pci_dev = to_pci_dev(dev); | 329 | struct pci_dev * pci_dev = to_pci_dev(dev); |
280 | struct pci_driver * drv = pci_dev->driver; | 330 | struct pci_driver * drv = pci_dev->driver; |
@@ -284,18 +334,12 @@ static int pci_device_suspend(struct device * dev, pm_message_t state) | |||
284 | i = drv->suspend(pci_dev, state); | 334 | i = drv->suspend(pci_dev, state); |
285 | suspend_report_result(drv->suspend, i); | 335 | suspend_report_result(drv->suspend, i); |
286 | } else { | 336 | } else { |
287 | pci_save_state(pci_dev); | 337 | pci_default_pm_suspend(pci_dev); |
288 | /* | ||
289 | * mark its power state as "unknown", since we don't know if | ||
290 | * e.g. the BIOS will change its device state when we suspend. | ||
291 | */ | ||
292 | if (pci_dev->current_state == PCI_D0) | ||
293 | pci_dev->current_state = PCI_UNKNOWN; | ||
294 | } | 338 | } |
295 | return i; | 339 | return i; |
296 | } | 340 | } |
297 | 341 | ||
298 | static int pci_device_suspend_late(struct device * dev, pm_message_t state) | 342 | static int pci_legacy_suspend_late(struct device *dev, pm_message_t state) |
299 | { | 343 | { |
300 | struct pci_dev * pci_dev = to_pci_dev(dev); | 344 | struct pci_dev * pci_dev = to_pci_dev(dev); |
301 | struct pci_driver * drv = pci_dev->driver; | 345 | struct pci_driver * drv = pci_dev->driver; |
@@ -308,26 +352,7 @@ static int pci_device_suspend_late(struct device * dev, pm_message_t state) | |||
308 | return i; | 352 | return i; |
309 | } | 353 | } |
310 | 354 | ||
311 | /* | 355 | static int pci_legacy_resume(struct device *dev) |
312 | * Default resume method for devices that have no driver provided resume, | ||
313 | * or not even a driver at all. | ||
314 | */ | ||
315 | static int pci_default_resume(struct pci_dev *pci_dev) | ||
316 | { | ||
317 | int retval = 0; | ||
318 | |||
319 | /* restore the PCI config space */ | ||
320 | pci_restore_state(pci_dev); | ||
321 | /* if the device was enabled before suspend, reenable */ | ||
322 | retval = pci_reenable_device(pci_dev); | ||
323 | /* if the device was busmaster before the suspend, make it busmaster again */ | ||
324 | if (pci_dev->is_busmaster) | ||
325 | pci_set_master(pci_dev); | ||
326 | |||
327 | return retval; | ||
328 | } | ||
329 | |||
330 | static int pci_device_resume(struct device * dev) | ||
331 | { | 356 | { |
332 | int error; | 357 | int error; |
333 | struct pci_dev * pci_dev = to_pci_dev(dev); | 358 | struct pci_dev * pci_dev = to_pci_dev(dev); |
@@ -336,34 +361,313 @@ static int pci_device_resume(struct device * dev) | |||
336 | if (drv && drv->resume) | 361 | if (drv && drv->resume) |
337 | error = drv->resume(pci_dev); | 362 | error = drv->resume(pci_dev); |
338 | else | 363 | else |
339 | error = pci_default_resume(pci_dev); | 364 | error = pci_default_pm_resume(pci_dev); |
340 | return error; | 365 | return error; |
341 | } | 366 | } |
342 | 367 | ||
343 | static int pci_device_resume_early(struct device * dev) | 368 | static int pci_legacy_resume_early(struct device *dev) |
344 | { | 369 | { |
345 | int error = 0; | 370 | int error = 0; |
346 | struct pci_dev * pci_dev = to_pci_dev(dev); | 371 | struct pci_dev * pci_dev = to_pci_dev(dev); |
347 | struct pci_driver * drv = pci_dev->driver; | 372 | struct pci_driver * drv = pci_dev->driver; |
348 | 373 | ||
349 | pci_fixup_device(pci_fixup_resume, pci_dev); | ||
350 | |||
351 | if (drv && drv->resume_early) | 374 | if (drv && drv->resume_early) |
352 | error = drv->resume_early(pci_dev); | 375 | error = drv->resume_early(pci_dev); |
353 | return error; | 376 | return error; |
354 | } | 377 | } |
355 | 378 | ||
356 | static void pci_device_shutdown(struct device *dev) | 379 | static int pci_pm_prepare(struct device *dev) |
380 | { | ||
381 | struct device_driver *drv = dev->driver; | ||
382 | int error = 0; | ||
383 | |||
384 | if (drv && drv->pm && drv->pm->prepare) | ||
385 | error = drv->pm->prepare(dev); | ||
386 | |||
387 | return error; | ||
388 | } | ||
389 | |||
390 | static void pci_pm_complete(struct device *dev) | ||
391 | { | ||
392 | struct device_driver *drv = dev->driver; | ||
393 | |||
394 | if (drv && drv->pm && drv->pm->complete) | ||
395 | drv->pm->complete(dev); | ||
396 | } | ||
397 | |||
398 | #ifdef CONFIG_SUSPEND | ||
399 | |||
400 | static int pci_pm_suspend(struct device *dev) | ||
401 | { | ||
402 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
403 | struct device_driver *drv = dev->driver; | ||
404 | int error = 0; | ||
405 | |||
406 | if (drv && drv->pm) { | ||
407 | if (drv->pm->suspend) { | ||
408 | error = drv->pm->suspend(dev); | ||
409 | suspend_report_result(drv->pm->suspend, error); | ||
410 | } else { | ||
411 | pci_default_pm_suspend(pci_dev); | ||
412 | } | ||
413 | } else { | ||
414 | error = pci_legacy_suspend(dev, PMSG_SUSPEND); | ||
415 | } | ||
416 | pci_fixup_device(pci_fixup_suspend, pci_dev); | ||
417 | |||
418 | return error; | ||
419 | } | ||
420 | |||
421 | static int pci_pm_suspend_noirq(struct device *dev) | ||
357 | { | 422 | { |
358 | struct pci_dev *pci_dev = to_pci_dev(dev); | 423 | struct pci_dev *pci_dev = to_pci_dev(dev); |
359 | struct pci_driver *drv = pci_dev->driver; | 424 | struct pci_driver *drv = pci_dev->driver; |
425 | int error = 0; | ||
360 | 426 | ||
361 | if (drv && drv->shutdown) | 427 | if (drv && drv->pm) { |
362 | drv->shutdown(pci_dev); | 428 | if (drv->pm->suspend_noirq) { |
363 | pci_msi_shutdown(pci_dev); | 429 | error = drv->pm->suspend_noirq(dev); |
364 | pci_msix_shutdown(pci_dev); | 430 | suspend_report_result(drv->pm->suspend_noirq, error); |
431 | } | ||
432 | } else { | ||
433 | error = pci_legacy_suspend_late(dev, PMSG_SUSPEND); | ||
434 | } | ||
435 | |||
436 | return error; | ||
365 | } | 437 | } |
366 | 438 | ||
439 | static int pci_pm_resume(struct device *dev) | ||
440 | { | ||
441 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
442 | struct device_driver *drv = dev->driver; | ||
443 | int error; | ||
444 | |||
445 | pci_fixup_device(pci_fixup_resume, pci_dev); | ||
446 | |||
447 | if (drv && drv->pm) { | ||
448 | error = drv->pm->resume ? drv->pm->resume(dev) : | ||
449 | pci_default_pm_resume(pci_dev); | ||
450 | } else { | ||
451 | error = pci_legacy_resume(dev); | ||
452 | } | ||
453 | |||
454 | return error; | ||
455 | } | ||
456 | |||
457 | static int pci_pm_resume_noirq(struct device *dev) | ||
458 | { | ||
459 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
460 | struct pci_driver *drv = pci_dev->driver; | ||
461 | int error = 0; | ||
462 | |||
463 | pci_fixup_device(pci_fixup_resume_early, pci_dev); | ||
464 | |||
465 | if (drv && drv->pm) { | ||
466 | if (drv->pm->resume_noirq) | ||
467 | error = drv->pm->resume_noirq(dev); | ||
468 | } else { | ||
469 | error = pci_legacy_resume_early(dev); | ||
470 | } | ||
471 | |||
472 | return error; | ||
473 | } | ||
474 | |||
475 | #else /* !CONFIG_SUSPEND */ | ||
476 | |||
477 | #define pci_pm_suspend NULL | ||
478 | #define pci_pm_suspend_noirq NULL | ||
479 | #define pci_pm_resume NULL | ||
480 | #define pci_pm_resume_noirq NULL | ||
481 | |||
482 | #endif /* !CONFIG_SUSPEND */ | ||
483 | |||
484 | #ifdef CONFIG_HIBERNATION | ||
485 | |||
486 | static int pci_pm_freeze(struct device *dev) | ||
487 | { | ||
488 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
489 | struct device_driver *drv = dev->driver; | ||
490 | int error = 0; | ||
491 | |||
492 | if (drv && drv->pm) { | ||
493 | if (drv->pm->freeze) { | ||
494 | error = drv->pm->freeze(dev); | ||
495 | suspend_report_result(drv->pm->freeze, error); | ||
496 | } else { | ||
497 | pci_default_pm_suspend(pci_dev); | ||
498 | } | ||
499 | } else { | ||
500 | error = pci_legacy_suspend(dev, PMSG_FREEZE); | ||
501 | pci_fixup_device(pci_fixup_suspend, pci_dev); | ||
502 | } | ||
503 | |||
504 | return error; | ||
505 | } | ||
506 | |||
507 | static int pci_pm_freeze_noirq(struct device *dev) | ||
508 | { | ||
509 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
510 | struct pci_driver *drv = pci_dev->driver; | ||
511 | int error = 0; | ||
512 | |||
513 | if (drv && drv->pm) { | ||
514 | if (drv->pm->freeze_noirq) { | ||
515 | error = drv->pm->freeze_noirq(dev); | ||
516 | suspend_report_result(drv->pm->freeze_noirq, error); | ||
517 | } | ||
518 | } else { | ||
519 | error = pci_legacy_suspend_late(dev, PMSG_FREEZE); | ||
520 | } | ||
521 | |||
522 | return error; | ||
523 | } | ||
524 | |||
525 | static int pci_pm_thaw(struct device *dev) | ||
526 | { | ||
527 | struct device_driver *drv = dev->driver; | ||
528 | int error = 0; | ||
529 | |||
530 | if (drv && drv->pm) { | ||
531 | if (drv->pm->thaw) | ||
532 | error = drv->pm->thaw(dev); | ||
533 | } else { | ||
534 | pci_fixup_device(pci_fixup_resume, to_pci_dev(dev)); | ||
535 | error = pci_legacy_resume(dev); | ||
536 | } | ||
537 | |||
538 | return error; | ||
539 | } | ||
540 | |||
541 | static int pci_pm_thaw_noirq(struct device *dev) | ||
542 | { | ||
543 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
544 | struct pci_driver *drv = pci_dev->driver; | ||
545 | int error = 0; | ||
546 | |||
547 | if (drv && drv->pm) { | ||
548 | if (drv->pm->thaw_noirq) | ||
549 | error = drv->pm->thaw_noirq(dev); | ||
550 | } else { | ||
551 | pci_fixup_device(pci_fixup_resume_early, pci_dev); | ||
552 | error = pci_legacy_resume_early(dev); | ||
553 | } | ||
554 | |||
555 | return error; | ||
556 | } | ||
557 | |||
558 | static int pci_pm_poweroff(struct device *dev) | ||
559 | { | ||
560 | struct device_driver *drv = dev->driver; | ||
561 | int error = 0; | ||
562 | |||
563 | pci_fixup_device(pci_fixup_suspend, to_pci_dev(dev)); | ||
564 | |||
565 | if (drv && drv->pm) { | ||
566 | if (drv->pm->poweroff) { | ||
567 | error = drv->pm->poweroff(dev); | ||
568 | suspend_report_result(drv->pm->poweroff, error); | ||
569 | } | ||
570 | } else { | ||
571 | error = pci_legacy_suspend(dev, PMSG_HIBERNATE); | ||
572 | } | ||
573 | |||
574 | return error; | ||
575 | } | ||
576 | |||
577 | static int pci_pm_poweroff_noirq(struct device *dev) | ||
578 | { | ||
579 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
580 | struct pci_driver *drv = pci_dev->driver; | ||
581 | int error = 0; | ||
582 | |||
583 | if (drv && drv->pm) { | ||
584 | if (drv->pm->poweroff_noirq) { | ||
585 | error = drv->pm->poweroff_noirq(dev); | ||
586 | suspend_report_result(drv->pm->poweroff_noirq, error); | ||
587 | } | ||
588 | } else { | ||
589 | error = pci_legacy_suspend_late(dev, PMSG_HIBERNATE); | ||
590 | } | ||
591 | |||
592 | return error; | ||
593 | } | ||
594 | |||
595 | static int pci_pm_restore(struct device *dev) | ||
596 | { | ||
597 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
598 | struct device_driver *drv = dev->driver; | ||
599 | int error; | ||
600 | |||
601 | if (drv && drv->pm) { | ||
602 | error = drv->pm->restore ? drv->pm->restore(dev) : | ||
603 | pci_default_pm_resume(pci_dev); | ||
604 | } else { | ||
605 | error = pci_legacy_resume(dev); | ||
606 | } | ||
607 | pci_fixup_device(pci_fixup_resume, pci_dev); | ||
608 | |||
609 | return error; | ||
610 | } | ||
611 | |||
612 | static int pci_pm_restore_noirq(struct device *dev) | ||
613 | { | ||
614 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
615 | struct pci_driver *drv = pci_dev->driver; | ||
616 | int error = 0; | ||
617 | |||
618 | pci_fixup_device(pci_fixup_resume, pci_dev); | ||
619 | |||
620 | if (drv && drv->pm) { | ||
621 | if (drv->pm->restore_noirq) | ||
622 | error = drv->pm->restore_noirq(dev); | ||
623 | } else { | ||
624 | error = pci_legacy_resume_early(dev); | ||
625 | } | ||
626 | pci_fixup_device(pci_fixup_resume_early, pci_dev); | ||
627 | |||
628 | return error; | ||
629 | } | ||
630 | |||
631 | #else /* !CONFIG_HIBERNATION */ | ||
632 | |||
633 | #define pci_pm_freeze NULL | ||
634 | #define pci_pm_freeze_noirq NULL | ||
635 | #define pci_pm_thaw NULL | ||
636 | #define pci_pm_thaw_noirq NULL | ||
637 | #define pci_pm_poweroff NULL | ||
638 | #define pci_pm_poweroff_noirq NULL | ||
639 | #define pci_pm_restore NULL | ||
640 | #define pci_pm_restore_noirq NULL | ||
641 | |||
642 | #endif /* !CONFIG_HIBERNATION */ | ||
643 | |||
644 | struct pm_ext_ops pci_pm_ops = { | ||
645 | .base = { | ||
646 | .prepare = pci_pm_prepare, | ||
647 | .complete = pci_pm_complete, | ||
648 | .suspend = pci_pm_suspend, | ||
649 | .resume = pci_pm_resume, | ||
650 | .freeze = pci_pm_freeze, | ||
651 | .thaw = pci_pm_thaw, | ||
652 | .poweroff = pci_pm_poweroff, | ||
653 | .restore = pci_pm_restore, | ||
654 | }, | ||
655 | .suspend_noirq = pci_pm_suspend_noirq, | ||
656 | .resume_noirq = pci_pm_resume_noirq, | ||
657 | .freeze_noirq = pci_pm_freeze_noirq, | ||
658 | .thaw_noirq = pci_pm_thaw_noirq, | ||
659 | .poweroff_noirq = pci_pm_poweroff_noirq, | ||
660 | .restore_noirq = pci_pm_restore_noirq, | ||
661 | }; | ||
662 | |||
663 | #define PCI_PM_OPS_PTR &pci_pm_ops | ||
664 | |||
665 | #else /* !CONFIG_PM_SLEEP */ | ||
666 | |||
667 | #define PCI_PM_OPS_PTR NULL | ||
668 | |||
669 | #endif /* !CONFIG_PM_SLEEP */ | ||
670 | |||
367 | /** | 671 | /** |
368 | * __pci_register_driver - register a new pci driver | 672 | * __pci_register_driver - register a new pci driver |
369 | * @drv: the driver structure to register | 673 | * @drv: the driver structure to register |
@@ -386,6 +690,9 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner, | |||
386 | drv->driver.owner = owner; | 690 | drv->driver.owner = owner; |
387 | drv->driver.mod_name = mod_name; | 691 | drv->driver.mod_name = mod_name; |
388 | 692 | ||
693 | if (drv->pm) | ||
694 | drv->driver.pm = &drv->pm->base; | ||
695 | |||
389 | spin_lock_init(&drv->dynids.lock); | 696 | spin_lock_init(&drv->dynids.lock); |
390 | INIT_LIST_HEAD(&drv->dynids.list); | 697 | INIT_LIST_HEAD(&drv->dynids.list); |
391 | 698 | ||
@@ -511,12 +818,9 @@ struct bus_type pci_bus_type = { | |||
511 | .uevent = pci_uevent, | 818 | .uevent = pci_uevent, |
512 | .probe = pci_device_probe, | 819 | .probe = pci_device_probe, |
513 | .remove = pci_device_remove, | 820 | .remove = pci_device_remove, |
514 | .suspend = pci_device_suspend, | ||
515 | .suspend_late = pci_device_suspend_late, | ||
516 | .resume_early = pci_device_resume_early, | ||
517 | .resume = pci_device_resume, | ||
518 | .shutdown = pci_device_shutdown, | 821 | .shutdown = pci_device_shutdown, |
519 | .dev_attrs = pci_dev_attrs, | 822 | .dev_attrs = pci_dev_attrs, |
823 | .pm = PCI_PM_OPS_PTR, | ||
520 | }; | 824 | }; |
521 | 825 | ||
522 | static int __init pci_driver_init(void) | 826 | static int __init pci_driver_init(void) |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 75c60239cadd..7869f8f75c9e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: pci.c,v 1.91 1999/01/21 13:34:01 davem Exp $ | ||
3 | * | ||
4 | * PCI Bus Services, see include/linux/pci.h for further explanation. | 2 | * PCI Bus Services, see include/linux/pci.h for further explanation. |
5 | * | 3 | * |
6 | * Copyright 1993 -- 1997 Drew Eckhardt, Frederic Potter, | 4 | * Copyright 1993 -- 1997 Drew Eckhardt, Frederic Potter, |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index ff30b3c91aad..e0eff35825a6 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -105,3 +105,16 @@ pci_match_one_device(const struct pci_device_id *id, const struct pci_dev *dev) | |||
105 | } | 105 | } |
106 | 106 | ||
107 | struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev); | 107 | struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev); |
108 | |||
109 | /* PCI slot sysfs helper code */ | ||
110 | #define to_pci_slot(s) container_of(s, struct pci_slot, kobj) | ||
111 | |||
112 | extern struct kset *pci_slots_kset; | ||
113 | |||
114 | struct pci_slot_attribute { | ||
115 | struct attribute attr; | ||
116 | ssize_t (*show)(struct pci_slot *, char *); | ||
117 | ssize_t (*store)(struct pci_slot *, const char *, size_t); | ||
118 | }; | ||
119 | #define to_pci_slot_attr(s) container_of(s, struct pci_slot_attribute, attr) | ||
120 | |||
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c index 07c3bdb6edc2..b7a3aa602d40 100644 --- a/drivers/pci/pcie/aer/aerdrv.c +++ b/drivers/pci/pcie/aer/aerdrv.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/pcieport_if.h> | 26 | #include <linux/pcieport_if.h> |
27 | 27 | ||
28 | #include "aerdrv.h" | 28 | #include "aerdrv.h" |
29 | #include "../../pci.h" | ||
29 | 30 | ||
30 | /* | 31 | /* |
31 | * Version Information | 32 | * Version Information |
diff --git a/drivers/pci/pcie/portdrv_bus.c b/drivers/pci/pcie/portdrv_bus.c index 3f0976868eda..359fe5568df1 100644 --- a/drivers/pci/pcie/portdrv_bus.c +++ b/drivers/pci/pcie/portdrv_bus.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/pm.h> | 13 | #include <linux/pm.h> |
14 | 14 | ||
15 | #include <linux/pcieport_if.h> | 15 | #include <linux/pcieport_if.h> |
16 | #include "portdrv.h" | ||
16 | 17 | ||
17 | static int pcie_port_bus_match(struct device *dev, struct device_driver *drv); | 18 | static int pcie_port_bus_match(struct device *dev, struct device_driver *drv); |
18 | static int pcie_port_bus_suspend(struct device *dev, pm_message_t state); | 19 | static int pcie_port_bus_suspend(struct device *dev, pm_message_t state); |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 3706ce7972dd..4562827b7e22 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -414,6 +414,7 @@ static struct pci_bus * pci_alloc_bus(void) | |||
414 | INIT_LIST_HEAD(&b->node); | 414 | INIT_LIST_HEAD(&b->node); |
415 | INIT_LIST_HEAD(&b->children); | 415 | INIT_LIST_HEAD(&b->children); |
416 | INIT_LIST_HEAD(&b->devices); | 416 | INIT_LIST_HEAD(&b->devices); |
417 | INIT_LIST_HEAD(&b->slots); | ||
417 | } | 418 | } |
418 | return b; | 419 | return b; |
419 | } | 420 | } |
@@ -857,6 +858,49 @@ int pci_cfg_space_size_ext(struct pci_dev *dev) | |||
857 | return PCI_CFG_SPACE_SIZE; | 858 | return PCI_CFG_SPACE_SIZE; |
858 | } | 859 | } |
859 | 860 | ||
861 | /** | ||
862 | * pci_disable_pme - Disable the PME function of PCI device | ||
863 | * @dev: PCI device affected | ||
864 | * -EINVAL is returned if PCI device doesn't support PME. | ||
865 | * Zero is returned if the PME is supported and can be disabled. | ||
866 | */ | ||
867 | static int pci_disable_pme(struct pci_dev *dev) | ||
868 | { | ||
869 | int pm; | ||
870 | u16 value; | ||
871 | |||
872 | /* find PCI PM capability in list */ | ||
873 | pm = pci_find_capability(dev, PCI_CAP_ID_PM); | ||
874 | |||
875 | /* If device doesn't support PM Capabilities, it means that PME is | ||
876 | * not supported. | ||
877 | */ | ||
878 | if (!pm) | ||
879 | return -EINVAL; | ||
880 | /* Check device's ability to generate PME# */ | ||
881 | pci_read_config_word(dev, pm + PCI_PM_PMC, &value); | ||
882 | |||
883 | value &= PCI_PM_CAP_PME_MASK; | ||
884 | /* Check if it can generate PME# */ | ||
885 | if (!value) { | ||
886 | /* | ||
887 | * If it is zero, it means that PME is still unsupported | ||
888 | * although there exists the PM capability. | ||
889 | */ | ||
890 | return -EINVAL; | ||
891 | } | ||
892 | |||
893 | pci_read_config_word(dev, pm + PCI_PM_CTRL, &value); | ||
894 | |||
895 | /* Clear PME_Status by writing 1 to it */ | ||
896 | value |= PCI_PM_CTRL_PME_STATUS ; | ||
897 | /* Disable PME enable bit */ | ||
898 | value &= ~PCI_PM_CTRL_PME_ENABLE; | ||
899 | pci_write_config_word(dev, pm + PCI_PM_CTRL, value); | ||
900 | |||
901 | return 0; | ||
902 | } | ||
903 | |||
860 | int pci_cfg_space_size(struct pci_dev *dev) | 904 | int pci_cfg_space_size(struct pci_dev *dev) |
861 | { | 905 | { |
862 | int pos; | 906 | int pos; |
@@ -964,6 +1008,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) | |||
964 | } | 1008 | } |
965 | 1009 | ||
966 | pci_vpd_pci22_init(dev); | 1010 | pci_vpd_pci22_init(dev); |
1011 | pci_disable_pme(dev); | ||
967 | 1012 | ||
968 | return dev; | 1013 | return dev; |
969 | } | 1014 | } |
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 963a97642ae9..4400dffbd93a 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: proc.c,v 1.13 1998/05/12 07:36:07 mj Exp $ | ||
3 | * | ||
4 | * Procfs interface for the PCI bus. | 2 | * Procfs interface for the PCI bus. |
5 | * | 3 | * |
6 | * Copyright (c) 1997--1999 Martin Mares <mj@ucw.cz> | 4 | * Copyright (c) 1997--1999 Martin Mares <mj@ucw.cz> |
@@ -482,5 +480,5 @@ static int __init pci_proc_init(void) | |||
482 | return 0; | 480 | return 0; |
483 | } | 481 | } |
484 | 482 | ||
485 | __initcall(pci_proc_init); | 483 | device_initcall(pci_proc_init); |
486 | 484 | ||
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index dabb563f51d9..92b52ebd0eb6 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -556,7 +556,7 @@ static void quirk_via_ioapic(struct pci_dev *dev) | |||
556 | pci_write_config_byte (dev, 0x58, tmp); | 556 | pci_write_config_byte (dev, 0x58, tmp); |
557 | } | 557 | } |
558 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_ioapic); | 558 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_ioapic); |
559 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_ioapic); | 559 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_ioapic); |
560 | 560 | ||
561 | /* | 561 | /* |
562 | * VIA 8237: Some BIOSs don't set the 'Bypass APIC De-Assert Message' Bit. | 562 | * VIA 8237: Some BIOSs don't set the 'Bypass APIC De-Assert Message' Bit. |
@@ -576,7 +576,7 @@ static void quirk_via_vt8237_bypass_apic_deassert(struct pci_dev *dev) | |||
576 | } | 576 | } |
577 | } | 577 | } |
578 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk_via_vt8237_bypass_apic_deassert); | 578 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk_via_vt8237_bypass_apic_deassert); |
579 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk_via_vt8237_bypass_apic_deassert); | 579 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk_via_vt8237_bypass_apic_deassert); |
580 | 580 | ||
581 | /* | 581 | /* |
582 | * The AMD io apic can hang the box when an apic irq is masked. | 582 | * The AMD io apic can hang the box when an apic irq is masked. |
@@ -622,7 +622,7 @@ static void quirk_amd_8131_ioapic(struct pci_dev *dev) | |||
622 | } | 622 | } |
623 | } | 623 | } |
624 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_amd_8131_ioapic); | 624 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_amd_8131_ioapic); |
625 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_amd_8131_ioapic); | 625 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_amd_8131_ioapic); |
626 | #endif /* CONFIG_X86_IO_APIC */ | 626 | #endif /* CONFIG_X86_IO_APIC */ |
627 | 627 | ||
628 | /* | 628 | /* |
@@ -774,7 +774,7 @@ static void quirk_cardbus_legacy(struct pci_dev *dev) | |||
774 | pci_write_config_dword(dev, PCI_CB_LEGACY_MODE_BASE, 0); | 774 | pci_write_config_dword(dev, PCI_CB_LEGACY_MODE_BASE, 0); |
775 | } | 775 | } |
776 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, quirk_cardbus_legacy); | 776 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, quirk_cardbus_legacy); |
777 | DECLARE_PCI_FIXUP_RESUME(PCI_ANY_ID, PCI_ANY_ID, quirk_cardbus_legacy); | 777 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_ANY_ID, PCI_ANY_ID, quirk_cardbus_legacy); |
778 | 778 | ||
779 | /* | 779 | /* |
780 | * Following the PCI ordering rules is optional on the AMD762. I'm not | 780 | * Following the PCI ordering rules is optional on the AMD762. I'm not |
@@ -797,7 +797,7 @@ static void quirk_amd_ordering(struct pci_dev *dev) | |||
797 | } | 797 | } |
798 | } | 798 | } |
799 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_700C, quirk_amd_ordering); | 799 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_700C, quirk_amd_ordering); |
800 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_700C, quirk_amd_ordering); | 800 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_700C, quirk_amd_ordering); |
801 | 801 | ||
802 | /* | 802 | /* |
803 | * DreamWorks provided workaround for Dunord I-3000 problem | 803 | * DreamWorks provided workaround for Dunord I-3000 problem |
@@ -865,7 +865,7 @@ static void quirk_disable_pxb(struct pci_dev *pdev) | |||
865 | } | 865 | } |
866 | } | 866 | } |
867 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); | 867 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); |
868 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); | 868 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); |
869 | 869 | ||
870 | static void __devinit quirk_amd_ide_mode(struct pci_dev *pdev) | 870 | static void __devinit quirk_amd_ide_mode(struct pci_dev *pdev) |
871 | { | 871 | { |
@@ -885,9 +885,9 @@ static void __devinit quirk_amd_ide_mode(struct pci_dev *pdev) | |||
885 | } | 885 | } |
886 | } | 886 | } |
887 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); | 887 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); |
888 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); | 888 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); |
889 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); | 889 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); |
890 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); | 890 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); |
891 | 891 | ||
892 | /* | 892 | /* |
893 | * Serverworks CSB5 IDE does not fully support native mode | 893 | * Serverworks CSB5 IDE does not fully support native mode |
@@ -1054,6 +1054,20 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev) | |||
1054 | * its on-board VGA controller */ | 1054 | * its on-board VGA controller */ |
1055 | asus_hides_smbus = 1; | 1055 | asus_hides_smbus = 1; |
1056 | } | 1056 | } |
1057 | else if (dev->device == PCI_DEVICE_ID_INTEL_82845G_IG) | ||
1058 | switch(dev->subsystem_device) { | ||
1059 | case 0x00b8: /* Compaq Evo D510 CMT */ | ||
1060 | case 0x00b9: /* Compaq Evo D510 SFF */ | ||
1061 | asus_hides_smbus = 1; | ||
1062 | } | ||
1063 | else if (dev->device == PCI_DEVICE_ID_INTEL_82815_CGC) | ||
1064 | switch (dev->subsystem_device) { | ||
1065 | case 0x001A: /* Compaq Deskpro EN SSF P667 815E */ | ||
1066 | /* Motherboard doesn't have host bridge | ||
1067 | * subvendor/subdevice IDs, therefore checking | ||
1068 | * its on-board VGA controller */ | ||
1069 | asus_hides_smbus = 1; | ||
1070 | } | ||
1057 | } | 1071 | } |
1058 | } | 1072 | } |
1059 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845_HB, asus_hides_smbus_hostbridge); | 1073 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845_HB, asus_hides_smbus_hostbridge); |
@@ -1068,6 +1082,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82855GM_HB, as | |||
1068 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82915GM_HB, asus_hides_smbus_hostbridge); | 1082 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82915GM_HB, asus_hides_smbus_hostbridge); |
1069 | 1083 | ||
1070 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810_IG3, asus_hides_smbus_hostbridge); | 1084 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810_IG3, asus_hides_smbus_hostbridge); |
1085 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845G_IG, asus_hides_smbus_hostbridge); | ||
1086 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82815_CGC, asus_hides_smbus_hostbridge); | ||
1071 | 1087 | ||
1072 | static void asus_hides_smbus_lpc(struct pci_dev *dev) | 1088 | static void asus_hides_smbus_lpc(struct pci_dev *dev) |
1073 | { | 1089 | { |
@@ -1093,31 +1109,61 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, asu | |||
1093 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12, asus_hides_smbus_lpc); | 1109 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12, asus_hides_smbus_lpc); |
1094 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, asus_hides_smbus_lpc); | 1110 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, asus_hides_smbus_lpc); |
1095 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, asus_hides_smbus_lpc); | 1111 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, asus_hides_smbus_lpc); |
1096 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, asus_hides_smbus_lpc); | 1112 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, asus_hides_smbus_lpc); |
1097 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, asus_hides_smbus_lpc); | 1113 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, asus_hides_smbus_lpc); |
1098 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, asus_hides_smbus_lpc); | 1114 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, asus_hides_smbus_lpc); |
1099 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, asus_hides_smbus_lpc); | 1115 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, asus_hides_smbus_lpc); |
1100 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12, asus_hides_smbus_lpc); | 1116 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12, asus_hides_smbus_lpc); |
1101 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, asus_hides_smbus_lpc); | 1117 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, asus_hides_smbus_lpc); |
1102 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, asus_hides_smbus_lpc); | 1118 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, asus_hides_smbus_lpc); |
1103 | 1119 | ||
1104 | static void asus_hides_smbus_lpc_ich6(struct pci_dev *dev) | 1120 | /* It appears we just have one such device. If not, we have a warning */ |
1121 | static void __iomem *asus_rcba_base; | ||
1122 | static void asus_hides_smbus_lpc_ich6_suspend(struct pci_dev *dev) | ||
1105 | { | 1123 | { |
1106 | u32 val, rcba; | 1124 | u32 rcba; |
1107 | void __iomem *base; | ||
1108 | 1125 | ||
1109 | if (likely(!asus_hides_smbus)) | 1126 | if (likely(!asus_hides_smbus)) |
1110 | return; | 1127 | return; |
1128 | WARN_ON(asus_rcba_base); | ||
1129 | |||
1111 | pci_read_config_dword(dev, 0xF0, &rcba); | 1130 | pci_read_config_dword(dev, 0xF0, &rcba); |
1112 | base = ioremap_nocache(rcba & 0xFFFFC000, 0x4000); /* use bits 31:14, 16 kB aligned */ | 1131 | /* use bits 31:14, 16 kB aligned */ |
1113 | if (base == NULL) return; | 1132 | asus_rcba_base = ioremap_nocache(rcba & 0xFFFFC000, 0x4000); |
1114 | val=readl(base + 0x3418); /* read the Function Disable register, dword mode only */ | 1133 | if (asus_rcba_base == NULL) |
1115 | writel(val & 0xFFFFFFF7, base + 0x3418); /* enable the SMBus device */ | 1134 | return; |
1116 | iounmap(base); | 1135 | } |
1136 | |||
1137 | static void asus_hides_smbus_lpc_ich6_resume_early(struct pci_dev *dev) | ||
1138 | { | ||
1139 | u32 val; | ||
1140 | |||
1141 | if (likely(!asus_hides_smbus || !asus_rcba_base)) | ||
1142 | return; | ||
1143 | /* read the Function Disable register, dword mode only */ | ||
1144 | val = readl(asus_rcba_base + 0x3418); | ||
1145 | writel(val & 0xFFFFFFF7, asus_rcba_base + 0x3418); /* enable the SMBus device */ | ||
1146 | } | ||
1147 | |||
1148 | static void asus_hides_smbus_lpc_ich6_resume(struct pci_dev *dev) | ||
1149 | { | ||
1150 | if (likely(!asus_hides_smbus || !asus_rcba_base)) | ||
1151 | return; | ||
1152 | iounmap(asus_rcba_base); | ||
1153 | asus_rcba_base = NULL; | ||
1117 | dev_info(&dev->dev, "Enabled ICH6/i801 SMBus device\n"); | 1154 | dev_info(&dev->dev, "Enabled ICH6/i801 SMBus device\n"); |
1118 | } | 1155 | } |
1156 | |||
1157 | static void asus_hides_smbus_lpc_ich6(struct pci_dev *dev) | ||
1158 | { | ||
1159 | asus_hides_smbus_lpc_ich6_suspend(dev); | ||
1160 | asus_hides_smbus_lpc_ich6_resume_early(dev); | ||
1161 | asus_hides_smbus_lpc_ich6_resume(dev); | ||
1162 | } | ||
1119 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6); | 1163 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6); |
1120 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6); | 1164 | DECLARE_PCI_FIXUP_SUSPEND(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6_suspend); |
1165 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6_resume); | ||
1166 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6_resume_early); | ||
1121 | 1167 | ||
1122 | /* | 1168 | /* |
1123 | * SiS 96x south bridge: BIOS typically hides SMBus device... | 1169 | * SiS 96x south bridge: BIOS typically hides SMBus device... |
@@ -1135,10 +1181,10 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_961, quirk_sis_96x_ | |||
1135 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_smbus); | 1181 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_smbus); |
1136 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_963, quirk_sis_96x_smbus); | 1182 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_963, quirk_sis_96x_smbus); |
1137 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_LPC, quirk_sis_96x_smbus); | 1183 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_LPC, quirk_sis_96x_smbus); |
1138 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_961, quirk_sis_96x_smbus); | 1184 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_961, quirk_sis_96x_smbus); |
1139 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_smbus); | 1185 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_smbus); |
1140 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_963, quirk_sis_96x_smbus); | 1186 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_963, quirk_sis_96x_smbus); |
1141 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_LPC, quirk_sis_96x_smbus); | 1187 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_LPC, quirk_sis_96x_smbus); |
1142 | 1188 | ||
1143 | /* | 1189 | /* |
1144 | * ... This is further complicated by the fact that some SiS96x south | 1190 | * ... This is further complicated by the fact that some SiS96x south |
@@ -1172,7 +1218,7 @@ static void quirk_sis_503(struct pci_dev *dev) | |||
1172 | quirk_sis_96x_smbus(dev); | 1218 | quirk_sis_96x_smbus(dev); |
1173 | } | 1219 | } |
1174 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, quirk_sis_503); | 1220 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, quirk_sis_503); |
1175 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, quirk_sis_503); | 1221 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, quirk_sis_503); |
1176 | 1222 | ||
1177 | 1223 | ||
1178 | /* | 1224 | /* |
@@ -1205,7 +1251,7 @@ static void asus_hides_ac97_lpc(struct pci_dev *dev) | |||
1205 | } | 1251 | } |
1206 | } | 1252 | } |
1207 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc); | 1253 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc); |
1208 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc); | 1254 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc); |
1209 | 1255 | ||
1210 | #if defined(CONFIG_ATA) || defined(CONFIG_ATA_MODULE) | 1256 | #if defined(CONFIG_ATA) || defined(CONFIG_ATA_MODULE) |
1211 | 1257 | ||
@@ -1270,12 +1316,12 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363, qui | |||
1270 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365, quirk_jmicron_ata); | 1316 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365, quirk_jmicron_ata); |
1271 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366, quirk_jmicron_ata); | 1317 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366, quirk_jmicron_ata); |
1272 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368, quirk_jmicron_ata); | 1318 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368, quirk_jmicron_ata); |
1273 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB360, quirk_jmicron_ata); | 1319 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB360, quirk_jmicron_ata); |
1274 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361, quirk_jmicron_ata); | 1320 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361, quirk_jmicron_ata); |
1275 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363, quirk_jmicron_ata); | 1321 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363, quirk_jmicron_ata); |
1276 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365, quirk_jmicron_ata); | 1322 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365, quirk_jmicron_ata); |
1277 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366, quirk_jmicron_ata); | 1323 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366, quirk_jmicron_ata); |
1278 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368, quirk_jmicron_ata); | 1324 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368, quirk_jmicron_ata); |
1279 | 1325 | ||
1280 | #endif | 1326 | #endif |
1281 | 1327 | ||
@@ -1521,6 +1567,10 @@ extern struct pci_fixup __start_pci_fixups_enable[]; | |||
1521 | extern struct pci_fixup __end_pci_fixups_enable[]; | 1567 | extern struct pci_fixup __end_pci_fixups_enable[]; |
1522 | extern struct pci_fixup __start_pci_fixups_resume[]; | 1568 | extern struct pci_fixup __start_pci_fixups_resume[]; |
1523 | extern struct pci_fixup __end_pci_fixups_resume[]; | 1569 | extern struct pci_fixup __end_pci_fixups_resume[]; |
1570 | extern struct pci_fixup __start_pci_fixups_resume_early[]; | ||
1571 | extern struct pci_fixup __end_pci_fixups_resume_early[]; | ||
1572 | extern struct pci_fixup __start_pci_fixups_suspend[]; | ||
1573 | extern struct pci_fixup __end_pci_fixups_suspend[]; | ||
1524 | 1574 | ||
1525 | 1575 | ||
1526 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) | 1576 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) |
@@ -1553,6 +1603,16 @@ void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) | |||
1553 | end = __end_pci_fixups_resume; | 1603 | end = __end_pci_fixups_resume; |
1554 | break; | 1604 | break; |
1555 | 1605 | ||
1606 | case pci_fixup_resume_early: | ||
1607 | start = __start_pci_fixups_resume_early; | ||
1608 | end = __end_pci_fixups_resume_early; | ||
1609 | break; | ||
1610 | |||
1611 | case pci_fixup_suspend: | ||
1612 | start = __start_pci_fixups_suspend; | ||
1613 | end = __end_pci_fixups_suspend; | ||
1614 | break; | ||
1615 | |||
1556 | default: | 1616 | default: |
1557 | /* stupid compiler warning, you would think with an enum... */ | 1617 | /* stupid compiler warning, you would think with an enum... */ |
1558 | return; | 1618 | return; |
@@ -1629,7 +1689,7 @@ static void quirk_nvidia_ck804_pcie_aer_ext_cap(struct pci_dev *dev) | |||
1629 | } | 1689 | } |
1630 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, | 1690 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, |
1631 | quirk_nvidia_ck804_pcie_aer_ext_cap); | 1691 | quirk_nvidia_ck804_pcie_aer_ext_cap); |
1632 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, | 1692 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, |
1633 | quirk_nvidia_ck804_pcie_aer_ext_cap); | 1693 | quirk_nvidia_ck804_pcie_aer_ext_cap); |
1634 | 1694 | ||
1635 | static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev) | 1695 | static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev) |
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c new file mode 100644 index 000000000000..7e5b85cbd948 --- /dev/null +++ b/drivers/pci/slot.c | |||
@@ -0,0 +1,233 @@ | |||
1 | /* | ||
2 | * drivers/pci/slot.c | ||
3 | * Copyright (C) 2006 Matthew Wilcox <matthew@wil.cx> | ||
4 | * Copyright (C) 2006-2008 Hewlett-Packard Development Company, L.P. | ||
5 | * Alex Chiang <achiang@hp.com> | ||
6 | */ | ||
7 | |||
8 | #include <linux/kobject.h> | ||
9 | #include <linux/pci.h> | ||
10 | #include <linux/err.h> | ||
11 | #include "pci.h" | ||
12 | |||
13 | struct kset *pci_slots_kset; | ||
14 | EXPORT_SYMBOL_GPL(pci_slots_kset); | ||
15 | |||
16 | static ssize_t pci_slot_attr_show(struct kobject *kobj, | ||
17 | struct attribute *attr, char *buf) | ||
18 | { | ||
19 | struct pci_slot *slot = to_pci_slot(kobj); | ||
20 | struct pci_slot_attribute *attribute = to_pci_slot_attr(attr); | ||
21 | return attribute->show ? attribute->show(slot, buf) : -EIO; | ||
22 | } | ||
23 | |||
24 | static ssize_t pci_slot_attr_store(struct kobject *kobj, | ||
25 | struct attribute *attr, const char *buf, size_t len) | ||
26 | { | ||
27 | struct pci_slot *slot = to_pci_slot(kobj); | ||
28 | struct pci_slot_attribute *attribute = to_pci_slot_attr(attr); | ||
29 | return attribute->store ? attribute->store(slot, buf, len) : -EIO; | ||
30 | } | ||
31 | |||
32 | static struct sysfs_ops pci_slot_sysfs_ops = { | ||
33 | .show = pci_slot_attr_show, | ||
34 | .store = pci_slot_attr_store, | ||
35 | }; | ||
36 | |||
37 | static ssize_t address_read_file(struct pci_slot *slot, char *buf) | ||
38 | { | ||
39 | if (slot->number == 0xff) | ||
40 | return sprintf(buf, "%04x:%02x\n", | ||
41 | pci_domain_nr(slot->bus), | ||
42 | slot->bus->number); | ||
43 | else | ||
44 | return sprintf(buf, "%04x:%02x:%02x\n", | ||
45 | pci_domain_nr(slot->bus), | ||
46 | slot->bus->number, | ||
47 | slot->number); | ||
48 | } | ||
49 | |||
50 | static void pci_slot_release(struct kobject *kobj) | ||
51 | { | ||
52 | struct pci_slot *slot = to_pci_slot(kobj); | ||
53 | |||
54 | pr_debug("%s: releasing pci_slot on %x:%d\n", __func__, | ||
55 | slot->bus->number, slot->number); | ||
56 | |||
57 | list_del(&slot->list); | ||
58 | |||
59 | kfree(slot); | ||
60 | } | ||
61 | |||
62 | static struct pci_slot_attribute pci_slot_attr_address = | ||
63 | __ATTR(address, (S_IFREG | S_IRUGO), address_read_file, NULL); | ||
64 | |||
65 | static struct attribute *pci_slot_default_attrs[] = { | ||
66 | &pci_slot_attr_address.attr, | ||
67 | NULL, | ||
68 | }; | ||
69 | |||
70 | static struct kobj_type pci_slot_ktype = { | ||
71 | .sysfs_ops = &pci_slot_sysfs_ops, | ||
72 | .release = &pci_slot_release, | ||
73 | .default_attrs = pci_slot_default_attrs, | ||
74 | }; | ||
75 | |||
76 | /** | ||
77 | * pci_create_slot - create or increment refcount for physical PCI slot | ||
78 | * @parent: struct pci_bus of parent bridge | ||
79 | * @slot_nr: PCI_SLOT(pci_dev->devfn) or -1 for placeholder | ||
80 | * @name: user visible string presented in /sys/bus/pci/slots/<name> | ||
81 | * | ||
82 | * PCI slots have first class attributes such as address, speed, width, | ||
83 | * and a &struct pci_slot is used to manage them. This interface will | ||
84 | * either return a new &struct pci_slot to the caller, or if the pci_slot | ||
85 | * already exists, its refcount will be incremented. | ||
86 | * | ||
87 | * Slots are uniquely identified by a @pci_bus, @slot_nr, @name tuple. | ||
88 | * | ||
89 | * Placeholder slots: | ||
90 | * In most cases, @pci_bus, @slot_nr will be sufficient to uniquely identify | ||
91 | * a slot. There is one notable exception - pSeries (rpaphp), where the | ||
92 | * @slot_nr cannot be determined until a device is actually inserted into | ||
93 | * the slot. In this scenario, the caller may pass -1 for @slot_nr. | ||
94 | * | ||
95 | * The following semantics are imposed when the caller passes @slot_nr == | ||
96 | * -1. First, the check for existing %struct pci_slot is skipped, as the | ||
97 | * caller may know about several unpopulated slots on a given %struct | ||
98 | * pci_bus, and each slot would have a @slot_nr of -1. Uniqueness for | ||
99 | * these slots is then determined by the @name parameter. We expect | ||
100 | * kobject_init_and_add() to warn us if the caller attempts to create | ||
101 | * multiple slots with the same name. The other change in semantics is | ||
102 | * user-visible, which is the 'address' parameter presented in sysfs will | ||
103 | * consist solely of a dddd:bb tuple, where dddd is the PCI domain of the | ||
104 | * %struct pci_bus and bb is the bus number. In other words, the devfn of | ||
105 | * the 'placeholder' slot will not be displayed. | ||
106 | */ | ||
107 | |||
108 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, | ||
109 | const char *name) | ||
110 | { | ||
111 | struct pci_slot *slot; | ||
112 | int err; | ||
113 | |||
114 | down_write(&pci_bus_sem); | ||
115 | |||
116 | if (slot_nr == -1) | ||
117 | goto placeholder; | ||
118 | |||
119 | /* If we've already created this slot, bump refcount and return. */ | ||
120 | list_for_each_entry(slot, &parent->slots, list) { | ||
121 | if (slot->number == slot_nr) { | ||
122 | kobject_get(&slot->kobj); | ||
123 | pr_debug("%s: inc refcount to %d on %04x:%02x:%02x\n", | ||
124 | __func__, | ||
125 | atomic_read(&slot->kobj.kref.refcount), | ||
126 | pci_domain_nr(parent), parent->number, | ||
127 | slot_nr); | ||
128 | goto out; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | placeholder: | ||
133 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); | ||
134 | if (!slot) { | ||
135 | slot = ERR_PTR(-ENOMEM); | ||
136 | goto out; | ||
137 | } | ||
138 | |||
139 | slot->bus = parent; | ||
140 | slot->number = slot_nr; | ||
141 | |||
142 | slot->kobj.kset = pci_slots_kset; | ||
143 | err = kobject_init_and_add(&slot->kobj, &pci_slot_ktype, NULL, | ||
144 | "%s", name); | ||
145 | if (err) { | ||
146 | printk(KERN_ERR "Unable to register kobject %s\n", name); | ||
147 | goto err; | ||
148 | } | ||
149 | |||
150 | INIT_LIST_HEAD(&slot->list); | ||
151 | list_add(&slot->list, &parent->slots); | ||
152 | |||
153 | /* Don't care if debug printk has a -1 for slot_nr */ | ||
154 | pr_debug("%s: created pci_slot on %04x:%02x:%02x\n", | ||
155 | __func__, pci_domain_nr(parent), parent->number, slot_nr); | ||
156 | |||
157 | out: | ||
158 | up_write(&pci_bus_sem); | ||
159 | return slot; | ||
160 | err: | ||
161 | kfree(slot); | ||
162 | slot = ERR_PTR(err); | ||
163 | goto out; | ||
164 | } | ||
165 | EXPORT_SYMBOL_GPL(pci_create_slot); | ||
166 | |||
167 | /** | ||
168 | * pci_update_slot_number - update %struct pci_slot -> number | ||
169 | * @slot - %struct pci_slot to update | ||
170 | * @slot_nr - new number for slot | ||
171 | * | ||
172 | * The primary purpose of this interface is to allow callers who earlier | ||
173 | * created a placeholder slot in pci_create_slot() by passing a -1 as | ||
174 | * slot_nr, to update their %struct pci_slot with the correct @slot_nr. | ||
175 | */ | ||
176 | |||
177 | void pci_update_slot_number(struct pci_slot *slot, int slot_nr) | ||
178 | { | ||
179 | int name_count = 0; | ||
180 | struct pci_slot *tmp; | ||
181 | |||
182 | down_write(&pci_bus_sem); | ||
183 | |||
184 | list_for_each_entry(tmp, &slot->bus->slots, list) { | ||
185 | WARN_ON(tmp->number == slot_nr); | ||
186 | if (!strcmp(kobject_name(&tmp->kobj), kobject_name(&slot->kobj))) | ||
187 | name_count++; | ||
188 | } | ||
189 | |||
190 | if (name_count > 1) | ||
191 | printk(KERN_WARNING "pci_update_slot_number found %d slots with the same name: %s\n", name_count, kobject_name(&slot->kobj)); | ||
192 | |||
193 | slot->number = slot_nr; | ||
194 | up_write(&pci_bus_sem); | ||
195 | } | ||
196 | EXPORT_SYMBOL_GPL(pci_update_slot_number); | ||
197 | |||
198 | /** | ||
199 | * pci_destroy_slot - decrement refcount for physical PCI slot | ||
200 | * @slot: struct pci_slot to decrement | ||
201 | * | ||
202 | * %struct pci_slot is refcounted, so destroying them is really easy; we | ||
203 | * just call kobject_put on its kobj and let our release methods do the | ||
204 | * rest. | ||
205 | */ | ||
206 | |||
207 | void pci_destroy_slot(struct pci_slot *slot) | ||
208 | { | ||
209 | pr_debug("%s: dec refcount to %d on %04x:%02x:%02x\n", __func__, | ||
210 | atomic_read(&slot->kobj.kref.refcount) - 1, | ||
211 | pci_domain_nr(slot->bus), slot->bus->number, slot->number); | ||
212 | |||
213 | down_write(&pci_bus_sem); | ||
214 | kobject_put(&slot->kobj); | ||
215 | up_write(&pci_bus_sem); | ||
216 | } | ||
217 | EXPORT_SYMBOL_GPL(pci_destroy_slot); | ||
218 | |||
219 | static int pci_slot_init(void) | ||
220 | { | ||
221 | struct kset *pci_bus_kset; | ||
222 | |||
223 | pci_bus_kset = bus_get_kset(&pci_bus_type); | ||
224 | pci_slots_kset = kset_create_and_add("slots", NULL, | ||
225 | &pci_bus_kset->kobj); | ||
226 | if (!pci_slots_kset) { | ||
227 | printk(KERN_ERR "PCI: Slot initialization failure\n"); | ||
228 | return -ENOMEM; | ||
229 | } | ||
230 | return 0; | ||
231 | } | ||
232 | |||
233 | subsys_initcall(pci_slot_init); | ||
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index f054778e916c..cf108a3c7f59 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -84,6 +84,12 @@ | |||
84 | VMLINUX_SYMBOL(__start_pci_fixups_resume) = .; \ | 84 | VMLINUX_SYMBOL(__start_pci_fixups_resume) = .; \ |
85 | *(.pci_fixup_resume) \ | 85 | *(.pci_fixup_resume) \ |
86 | VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \ | 86 | VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \ |
87 | VMLINUX_SYMBOL(__start_pci_fixups_resume_early) = .; \ | ||
88 | *(.pci_fixup_resume_early) \ | ||
89 | VMLINUX_SYMBOL(__end_pci_fixups_resume_early) = .; \ | ||
90 | VMLINUX_SYMBOL(__start_pci_fixups_suspend) = .; \ | ||
91 | *(.pci_fixup_suspend) \ | ||
92 | VMLINUX_SYMBOL(__end_pci_fixups_suspend) = .; \ | ||
87 | } \ | 93 | } \ |
88 | \ | 94 | \ |
89 | /* RapidIO route ops */ \ | 95 | /* RapidIO route ops */ \ |
diff --git a/include/asm-x86/pci-direct.h b/include/asm-x86/pci-direct.h index 5b21485be573..80c775d9fe20 100644 --- a/include/asm-x86/pci-direct.h +++ b/include/asm-x86/pci-direct.h | |||
@@ -11,7 +11,11 @@ extern u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset); | |||
11 | extern u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset); | 11 | extern u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset); |
12 | extern void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset, u32 val); | 12 | extern void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset, u32 val); |
13 | extern void write_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset, u8 val); | 13 | extern void write_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset, u8 val); |
14 | extern void write_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset, u16 val); | ||
14 | 15 | ||
15 | extern int early_pci_allowed(void); | 16 | extern int early_pci_allowed(void); |
16 | 17 | ||
18 | extern unsigned int pci_early_dump_regs; | ||
19 | extern void early_dump_pci_device(u8 bus, u8 slot, u8 func); | ||
20 | extern void early_dump_pci_devices(void); | ||
17 | #endif | 21 | #endif |
diff --git a/include/linux/device.h b/include/linux/device.h index 6a2d04c011bc..f71a78d123ae 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -68,6 +68,8 @@ struct bus_type { | |||
68 | int (*resume_early)(struct device *dev); | 68 | int (*resume_early)(struct device *dev); |
69 | int (*resume)(struct device *dev); | 69 | int (*resume)(struct device *dev); |
70 | 70 | ||
71 | struct pm_ext_ops *pm; | ||
72 | |||
71 | struct bus_type_private *p; | 73 | struct bus_type_private *p; |
72 | }; | 74 | }; |
73 | 75 | ||
@@ -131,6 +133,8 @@ struct device_driver { | |||
131 | int (*resume) (struct device *dev); | 133 | int (*resume) (struct device *dev); |
132 | struct attribute_group **groups; | 134 | struct attribute_group **groups; |
133 | 135 | ||
136 | struct pm_ops *pm; | ||
137 | |||
134 | struct driver_private *p; | 138 | struct driver_private *p; |
135 | }; | 139 | }; |
136 | 140 | ||
@@ -197,6 +201,8 @@ struct class { | |||
197 | 201 | ||
198 | int (*suspend)(struct device *dev, pm_message_t state); | 202 | int (*suspend)(struct device *dev, pm_message_t state); |
199 | int (*resume)(struct device *dev); | 203 | int (*resume)(struct device *dev); |
204 | |||
205 | struct pm_ops *pm; | ||
200 | }; | 206 | }; |
201 | 207 | ||
202 | extern int __must_check class_register(struct class *class); | 208 | extern int __must_check class_register(struct class *class); |
@@ -248,8 +254,11 @@ struct device_type { | |||
248 | struct attribute_group **groups; | 254 | struct attribute_group **groups; |
249 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); | 255 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); |
250 | void (*release)(struct device *dev); | 256 | void (*release)(struct device *dev); |
257 | |||
251 | int (*suspend)(struct device *dev, pm_message_t state); | 258 | int (*suspend)(struct device *dev, pm_message_t state); |
252 | int (*resume)(struct device *dev); | 259 | int (*resume)(struct device *dev); |
260 | |||
261 | struct pm_ops *pm; | ||
253 | }; | 262 | }; |
254 | 263 | ||
255 | /* interface for exporting device attributes */ | 264 | /* interface for exporting device attributes */ |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 509159bcd4e7..f1f73f79a180 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -17,8 +17,7 @@ | |||
17 | #ifndef LINUX_PCI_H | 17 | #ifndef LINUX_PCI_H |
18 | #define LINUX_PCI_H | 18 | #define LINUX_PCI_H |
19 | 19 | ||
20 | /* Include the pci register defines */ | 20 | #include <linux/pci_regs.h> /* The pci register defines */ |
21 | #include <linux/pci_regs.h> | ||
22 | 21 | ||
23 | /* | 22 | /* |
24 | * The PCI interface treats multi-function devices as independent | 23 | * The PCI interface treats multi-function devices as independent |
@@ -49,12 +48,22 @@ | |||
49 | #include <linux/list.h> | 48 | #include <linux/list.h> |
50 | #include <linux/compiler.h> | 49 | #include <linux/compiler.h> |
51 | #include <linux/errno.h> | 50 | #include <linux/errno.h> |
51 | #include <linux/kobject.h> | ||
52 | #include <asm/atomic.h> | 52 | #include <asm/atomic.h> |
53 | #include <linux/device.h> | 53 | #include <linux/device.h> |
54 | 54 | ||
55 | /* Include the ID list */ | 55 | /* Include the ID list */ |
56 | #include <linux/pci_ids.h> | 56 | #include <linux/pci_ids.h> |
57 | 57 | ||
58 | /* pci_slot represents a physical slot */ | ||
59 | struct pci_slot { | ||
60 | struct pci_bus *bus; /* The bus this slot is on */ | ||
61 | struct list_head list; /* node in list of slots on this bus */ | ||
62 | struct hotplug_slot *hotplug; /* Hotplug info (migrate over time) */ | ||
63 | unsigned char number; /* PCI_SLOT(pci_dev->devfn) */ | ||
64 | struct kobject kobj; | ||
65 | }; | ||
66 | |||
58 | /* File state for mmap()s on /proc/bus/pci/X/Y */ | 67 | /* File state for mmap()s on /proc/bus/pci/X/Y */ |
59 | enum pci_mmap_state { | 68 | enum pci_mmap_state { |
60 | pci_mmap_io, | 69 | pci_mmap_io, |
@@ -142,6 +151,7 @@ struct pci_dev { | |||
142 | 151 | ||
143 | void *sysdata; /* hook for sys-specific extension */ | 152 | void *sysdata; /* hook for sys-specific extension */ |
144 | struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ | 153 | struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ |
154 | struct pci_slot *slot; /* Physical slot this device is in */ | ||
145 | 155 | ||
146 | unsigned int devfn; /* encoded device & function index */ | 156 | unsigned int devfn; /* encoded device & function index */ |
147 | unsigned short vendor; | 157 | unsigned short vendor; |
@@ -266,6 +276,7 @@ struct pci_bus { | |||
266 | struct list_head children; /* list of child buses */ | 276 | struct list_head children; /* list of child buses */ |
267 | struct list_head devices; /* list of devices on this bus */ | 277 | struct list_head devices; /* list of devices on this bus */ |
268 | struct pci_dev *self; /* bridge device as seen by parent */ | 278 | struct pci_dev *self; /* bridge device as seen by parent */ |
279 | struct list_head slots; /* list of slots on this bus */ | ||
269 | struct resource *resource[PCI_BUS_NUM_RESOURCES]; | 280 | struct resource *resource[PCI_BUS_NUM_RESOURCES]; |
270 | /* address space routed to this bus */ | 281 | /* address space routed to this bus */ |
271 | 282 | ||
@@ -389,7 +400,7 @@ struct pci_driver { | |||
389 | int (*resume_early) (struct pci_dev *dev); | 400 | int (*resume_early) (struct pci_dev *dev); |
390 | int (*resume) (struct pci_dev *dev); /* Device woken up */ | 401 | int (*resume) (struct pci_dev *dev); /* Device woken up */ |
391 | void (*shutdown) (struct pci_dev *dev); | 402 | void (*shutdown) (struct pci_dev *dev); |
392 | 403 | struct pm_ext_ops *pm; | |
393 | struct pci_error_handlers *err_handler; | 404 | struct pci_error_handlers *err_handler; |
394 | struct device_driver driver; | 405 | struct device_driver driver; |
395 | struct pci_dynids dynids; | 406 | struct pci_dynids dynids; |
@@ -488,6 +499,10 @@ struct pci_bus *pci_create_bus(struct device *parent, int bus, | |||
488 | struct pci_ops *ops, void *sysdata); | 499 | struct pci_ops *ops, void *sysdata); |
489 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, | 500 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, |
490 | int busnr); | 501 | int busnr); |
502 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, | ||
503 | const char *name); | ||
504 | void pci_destroy_slot(struct pci_slot *slot); | ||
505 | void pci_update_slot_number(struct pci_slot *slot, int slot_nr); | ||
491 | int pci_scan_slot(struct pci_bus *bus, int devfn); | 506 | int pci_scan_slot(struct pci_bus *bus, int devfn); |
492 | struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn); | 507 | struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn); |
493 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); | 508 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); |
@@ -1013,7 +1028,9 @@ enum pci_fixup_pass { | |||
1013 | pci_fixup_header, /* After reading configuration header */ | 1028 | pci_fixup_header, /* After reading configuration header */ |
1014 | pci_fixup_final, /* Final phase of device fixups */ | 1029 | pci_fixup_final, /* Final phase of device fixups */ |
1015 | pci_fixup_enable, /* pci_enable_device() time */ | 1030 | pci_fixup_enable, /* pci_enable_device() time */ |
1016 | pci_fixup_resume, /* pci_enable_device() time */ | 1031 | pci_fixup_resume, /* pci_device_resume() */ |
1032 | pci_fixup_suspend, /* pci_device_suspend */ | ||
1033 | pci_fixup_resume_early, /* pci_device_resume_early() */ | ||
1017 | }; | 1034 | }; |
1018 | 1035 | ||
1019 | /* Anonymous variables would be nice... */ | 1036 | /* Anonymous variables would be nice... */ |
@@ -1035,6 +1052,12 @@ enum pci_fixup_pass { | |||
1035 | #define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \ | 1052 | #define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \ |
1036 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ | 1053 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ |
1037 | resume##vendor##device##hook, vendor, device, hook) | 1054 | resume##vendor##device##hook, vendor, device, hook) |
1055 | #define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \ | ||
1056 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \ | ||
1057 | resume_early##vendor##device##hook, vendor, device, hook) | ||
1058 | #define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \ | ||
1059 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ | ||
1060 | suspend##vendor##device##hook, vendor, device, hook) | ||
1038 | 1061 | ||
1039 | 1062 | ||
1040 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); | 1063 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); |
@@ -1059,7 +1082,10 @@ extern int pci_pci_problems; | |||
1059 | extern unsigned long pci_cardbus_io_size; | 1082 | extern unsigned long pci_cardbus_io_size; |
1060 | extern unsigned long pci_cardbus_mem_size; | 1083 | extern unsigned long pci_cardbus_mem_size; |
1061 | 1084 | ||
1062 | extern int pcibios_add_platform_entries(struct pci_dev *dev); | 1085 | int pcibios_add_platform_entries(struct pci_dev *dev); |
1086 | void pcibios_disable_device(struct pci_dev *dev); | ||
1087 | int pcibios_set_pcie_reset_state(struct pci_dev *dev, | ||
1088 | enum pcie_reset_state state); | ||
1063 | 1089 | ||
1064 | #ifdef CONFIG_PCI_MMCONFIG | 1090 | #ifdef CONFIG_PCI_MMCONFIG |
1065 | extern void __init pci_mmcfg_early_init(void); | 1091 | extern void __init pci_mmcfg_early_init(void); |
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h index 8f67e8f2a3cc..a08cd06b541a 100644 --- a/include/linux/pci_hotplug.h +++ b/include/linux/pci_hotplug.h | |||
@@ -95,9 +95,6 @@ struct hotplug_slot_attribute { | |||
95 | * @get_adapter_status: Called to get see if an adapter is present in the slot or not. | 95 | * @get_adapter_status: Called to get see if an adapter is present in the slot or not. |
96 | * If this field is NULL, the value passed in the struct hotplug_slot_info | 96 | * If this field is NULL, the value passed in the struct hotplug_slot_info |
97 | * will be used when this value is requested by a user. | 97 | * will be used when this value is requested by a user. |
98 | * @get_address: Called to get pci address of a slot. | ||
99 | * If this field is NULL, the value passed in the struct hotplug_slot_info | ||
100 | * will be used when this value is requested by a user. | ||
101 | * @get_max_bus_speed: Called to get the max bus speed for a slot. | 98 | * @get_max_bus_speed: Called to get the max bus speed for a slot. |
102 | * If this field is NULL, the value passed in the struct hotplug_slot_info | 99 | * If this field is NULL, the value passed in the struct hotplug_slot_info |
103 | * will be used when this value is requested by a user. | 100 | * will be used when this value is requested by a user. |
@@ -120,7 +117,6 @@ struct hotplug_slot_ops { | |||
120 | int (*get_attention_status) (struct hotplug_slot *slot, u8 *value); | 117 | int (*get_attention_status) (struct hotplug_slot *slot, u8 *value); |
121 | int (*get_latch_status) (struct hotplug_slot *slot, u8 *value); | 118 | int (*get_latch_status) (struct hotplug_slot *slot, u8 *value); |
122 | int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value); | 119 | int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value); |
123 | int (*get_address) (struct hotplug_slot *slot, u32 *value); | ||
124 | int (*get_max_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); | 120 | int (*get_max_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); |
125 | int (*get_cur_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); | 121 | int (*get_cur_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); |
126 | }; | 122 | }; |
@@ -140,7 +136,6 @@ struct hotplug_slot_info { | |||
140 | u8 attention_status; | 136 | u8 attention_status; |
141 | u8 latch_status; | 137 | u8 latch_status; |
142 | u8 adapter_status; | 138 | u8 adapter_status; |
143 | u32 address; | ||
144 | enum pci_bus_speed max_bus_speed; | 139 | enum pci_bus_speed max_bus_speed; |
145 | enum pci_bus_speed cur_bus_speed; | 140 | enum pci_bus_speed cur_bus_speed; |
146 | }; | 141 | }; |
@@ -166,15 +161,14 @@ struct hotplug_slot { | |||
166 | 161 | ||
167 | /* Variables below this are for use only by the hotplug pci core. */ | 162 | /* Variables below this are for use only by the hotplug pci core. */ |
168 | struct list_head slot_list; | 163 | struct list_head slot_list; |
169 | struct kobject kobj; | 164 | struct pci_slot *pci_slot; |
170 | }; | 165 | }; |
171 | #define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj) | 166 | #define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj) |
172 | 167 | ||
173 | extern int pci_hp_register (struct hotplug_slot *slot); | 168 | extern int pci_hp_register(struct hotplug_slot *, struct pci_bus *, int nr); |
174 | extern int pci_hp_deregister (struct hotplug_slot *slot); | 169 | extern int pci_hp_deregister(struct hotplug_slot *slot); |
175 | extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot, | 170 | extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot, |
176 | struct hotplug_slot_info *info); | 171 | struct hotplug_slot_info *info); |
177 | extern struct kset *pci_hotplug_slots_kset; | ||
178 | 172 | ||
179 | /* PCI Setting Record (Type 0) */ | 173 | /* PCI Setting Record (Type 0) */ |
180 | struct hpp_type0 { | 174 | struct hpp_type0 { |
@@ -227,9 +221,9 @@ struct hotplug_params { | |||
227 | #include <acpi/acpi.h> | 221 | #include <acpi/acpi.h> |
228 | #include <acpi/acpi_bus.h> | 222 | #include <acpi/acpi_bus.h> |
229 | #include <acpi/actypes.h> | 223 | #include <acpi/actypes.h> |
230 | extern acpi_status acpi_run_oshp(acpi_handle handle); | ||
231 | extern acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus, | 224 | extern acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus, |
232 | struct hotplug_params *hpp); | 225 | struct hotplug_params *hpp); |
226 | int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags); | ||
233 | int acpi_root_bridge(acpi_handle handle); | 227 | int acpi_root_bridge(acpi_handle handle); |
234 | #endif | 228 | #endif |
235 | #endif | 229 | #endif |
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 3261681c82a4..95ac21ab3a09 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h | |||
@@ -53,6 +53,7 @@ struct platform_driver { | |||
53 | int (*suspend_late)(struct platform_device *, pm_message_t state); | 53 | int (*suspend_late)(struct platform_device *, pm_message_t state); |
54 | int (*resume_early)(struct platform_device *); | 54 | int (*resume_early)(struct platform_device *); |
55 | int (*resume)(struct platform_device *); | 55 | int (*resume)(struct platform_device *); |
56 | struct pm_ext_ops *pm; | ||
56 | struct device_driver driver; | 57 | struct device_driver driver; |
57 | }; | 58 | }; |
58 | 59 | ||
diff --git a/include/linux/pm.h b/include/linux/pm.h index 39a7ee859b67..4ad9de94449a 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
@@ -112,7 +112,9 @@ typedef struct pm_message { | |||
112 | int event; | 112 | int event; |
113 | } pm_message_t; | 113 | } pm_message_t; |
114 | 114 | ||
115 | /* | 115 | /** |
116 | * struct pm_ops - device PM callbacks | ||
117 | * | ||
116 | * Several driver power state transitions are externally visible, affecting | 118 | * Several driver power state transitions are externally visible, affecting |
117 | * the state of pending I/O queues and (for drivers that touch hardware) | 119 | * the state of pending I/O queues and (for drivers that touch hardware) |
118 | * interrupts, wakeups, DMA, and other hardware state. There may also be | 120 | * interrupts, wakeups, DMA, and other hardware state. There may also be |
@@ -120,6 +122,284 @@ typedef struct pm_message { | |||
120 | * to the rest of the driver stack (such as a driver that's ON gating off | 122 | * to the rest of the driver stack (such as a driver that's ON gating off |
121 | * clocks which are not in active use). | 123 | * clocks which are not in active use). |
122 | * | 124 | * |
125 | * The externally visible transitions are handled with the help of the following | ||
126 | * callbacks included in this structure: | ||
127 | * | ||
128 | * @prepare: Prepare the device for the upcoming transition, but do NOT change | ||
129 | * its hardware state. Prevent new children of the device from being | ||
130 | * registered after @prepare() returns (the driver's subsystem and | ||
131 | * generally the rest of the kernel is supposed to prevent new calls to the | ||
132 | * probe method from being made too once @prepare() has succeeded). If | ||
133 | * @prepare() detects a situation it cannot handle (e.g. registration of a | ||
134 | * child already in progress), it may return -EAGAIN, so that the PM core | ||
135 | * can execute it once again (e.g. after the new child has been registered) | ||
136 | * to recover from the race condition. This method is executed for all | ||
137 | * kinds of suspend transitions and is followed by one of the suspend | ||
138 | * callbacks: @suspend(), @freeze(), or @poweroff(). | ||
139 | * The PM core executes @prepare() for all devices before starting to | ||
140 | * execute suspend callbacks for any of them, so drivers may assume all of | ||
141 | * the other devices to be present and functional while @prepare() is being | ||
142 | * executed. In particular, it is safe to make GFP_KERNEL memory | ||
143 | * allocations from within @prepare(). However, drivers may NOT assume | ||
144 | * anything about the availability of the user space at that time and it | ||
145 | * is not correct to request firmware from within @prepare() (it's too | ||
146 | * late to do that). [To work around this limitation, drivers may | ||
147 | * register suspend and hibernation notifiers that are executed before the | ||
148 | * freezing of tasks.] | ||
149 | * | ||
150 | * @complete: Undo the changes made by @prepare(). This method is executed for | ||
151 | * all kinds of resume transitions, following one of the resume callbacks: | ||
152 | * @resume(), @thaw(), @restore(). Also called if the state transition | ||
153 | * fails before the driver's suspend callback (@suspend(), @freeze(), | ||
154 | * @poweroff()) can be executed (e.g. if the suspend callback fails for one | ||
155 | * of the other devices that the PM core has unsuccessfully attempted to | ||
156 | * suspend earlier). | ||
157 | * The PM core executes @complete() after it has executed the appropriate | ||
158 | * resume callback for all devices. | ||
159 | * | ||
160 | * @suspend: Executed before putting the system into a sleep state in which the | ||
161 | * contents of main memory are preserved. Quiesce the device, put it into | ||
162 | * a low power state appropriate for the upcoming system state (such as | ||
163 | * PCI_D3hot), and enable wakeup events as appropriate. | ||
164 | * | ||
165 | * @resume: Executed after waking the system up from a sleep state in which the | ||
166 | * contents of main memory were preserved. Put the device into the | ||
167 | * appropriate state, according to the information saved in memory by the | ||
168 | * preceding @suspend(). The driver starts working again, responding to | ||
169 | * hardware events and software requests. The hardware may have gone | ||
170 | * through a power-off reset, or it may have maintained state from the | ||
171 | * previous suspend() which the driver may rely on while resuming. On most | ||
172 | * platforms, there are no restrictions on availability of resources like | ||
173 | * clocks during @resume(). | ||
174 | * | ||
175 | * @freeze: Hibernation-specific, executed before creating a hibernation image. | ||
176 | * Quiesce operations so that a consistent image can be created, but do NOT | ||
177 | * otherwise put the device into a low power device state and do NOT emit | ||
178 | * system wakeup events. Save in main memory the device settings to be | ||
179 | * used by @restore() during the subsequent resume from hibernation or by | ||
180 | * the subsequent @thaw(), if the creation of the image or the restoration | ||
181 | * of main memory contents from it fails. | ||
182 | * | ||
183 | * @thaw: Hibernation-specific, executed after creating a hibernation image OR | ||
184 | * if the creation of the image fails. Also executed after a failing | ||
185 | * attempt to restore the contents of main memory from such an image. | ||
186 | * Undo the changes made by the preceding @freeze(), so the device can be | ||
187 | * operated in the same way as immediately before the call to @freeze(). | ||
188 | * | ||
189 | * @poweroff: Hibernation-specific, executed after saving a hibernation image. | ||
190 | * Quiesce the device, put it into a low power state appropriate for the | ||
191 | * upcoming system state (such as PCI_D3hot), and enable wakeup events as | ||
192 | * appropriate. | ||
193 | * | ||
194 | * @restore: Hibernation-specific, executed after restoring the contents of main | ||
195 | * memory from a hibernation image. Driver starts working again, | ||
196 | * responding to hardware events and software requests. Drivers may NOT | ||
197 | * make ANY assumptions about the hardware state right prior to @restore(). | ||
198 | * On most platforms, there are no restrictions on availability of | ||
199 | * resources like clocks during @restore(). | ||
200 | * | ||
201 | * All of the above callbacks, except for @complete(), return error codes. | ||
202 | * However, the error codes returned by the resume operations, @resume(), | ||
203 | * @thaw(), and @restore(), do not cause the PM core to abort the resume | ||
204 | * transition during which they are returned. The error codes returned in | ||
205 | * that cases are only printed by the PM core to the system logs for debugging | ||
206 | * purposes. Still, it is recommended that drivers only return error codes | ||
207 | * from their resume methods in case of an unrecoverable failure (i.e. when the | ||
208 | * device being handled refuses to resume and becomes unusable) to allow us to | ||
209 | * modify the PM core in the future, so that it can avoid attempting to handle | ||
210 | * devices that failed to resume and their children. | ||
211 | * | ||
212 | * It is allowed to unregister devices while the above callbacks are being | ||
213 | * executed. However, it is not allowed to unregister a device from within any | ||
214 | * of its own callbacks. | ||
215 | */ | ||
216 | |||
217 | struct pm_ops { | ||
218 | int (*prepare)(struct device *dev); | ||
219 | void (*complete)(struct device *dev); | ||
220 | int (*suspend)(struct device *dev); | ||
221 | int (*resume)(struct device *dev); | ||
222 | int (*freeze)(struct device *dev); | ||
223 | int (*thaw)(struct device *dev); | ||
224 | int (*poweroff)(struct device *dev); | ||
225 | int (*restore)(struct device *dev); | ||
226 | }; | ||
227 | |||
228 | /** | ||
229 | * struct pm_ext_ops - extended device PM callbacks | ||
230 | * | ||
231 | * Some devices require certain operations related to suspend and hibernation | ||
232 | * to be carried out with interrupts disabled. Thus, 'struct pm_ext_ops' below | ||
233 | * is defined, adding callbacks to be executed with interrupts disabled to | ||
234 | * 'struct pm_ops'. | ||
235 | * | ||
236 | * The following callbacks included in 'struct pm_ext_ops' are executed with | ||
237 | * the nonboot CPUs switched off and with interrupts disabled on the only | ||
238 | * functional CPU. They also are executed with the PM core list of devices | ||
239 | * locked, so they must NOT unregister any devices. | ||
240 | * | ||
241 | * @suspend_noirq: Complete the operations of ->suspend() by carrying out any | ||
242 | * actions required for suspending the device that need interrupts to be | ||
243 | * disabled | ||
244 | * | ||
245 | * @resume_noirq: Prepare for the execution of ->resume() by carrying out any | ||
246 | * actions required for resuming the device that need interrupts to be | ||
247 | * disabled | ||
248 | * | ||
249 | * @freeze_noirq: Complete the operations of ->freeze() by carrying out any | ||
250 | * actions required for freezing the device that need interrupts to be | ||
251 | * disabled | ||
252 | * | ||
253 | * @thaw_noirq: Prepare for the execution of ->thaw() by carrying out any | ||
254 | * actions required for thawing the device that need interrupts to be | ||
255 | * disabled | ||
256 | * | ||
257 | * @poweroff_noirq: Complete the operations of ->poweroff() by carrying out any | ||
258 | * actions required for handling the device that need interrupts to be | ||
259 | * disabled | ||
260 | * | ||
261 | * @restore_noirq: Prepare for the execution of ->restore() by carrying out any | ||
262 | * actions required for restoring the operations of the device that need | ||
263 | * interrupts to be disabled | ||
264 | * | ||
265 | * All of the above callbacks return error codes, but the error codes returned | ||
266 | * by the resume operations, @resume_noirq(), @thaw_noirq(), and | ||
267 | * @restore_noirq(), do not cause the PM core to abort the resume transition | ||
268 | * during which they are returned. The error codes returned in that cases are | ||
269 | * only printed by the PM core to the system logs for debugging purposes. | ||
270 | * Still, as stated above, it is recommended that drivers only return error | ||
271 | * codes from their resume methods if the device being handled fails to resume | ||
272 | * and is not usable any more. | ||
273 | */ | ||
274 | |||
275 | struct pm_ext_ops { | ||
276 | struct pm_ops base; | ||
277 | int (*suspend_noirq)(struct device *dev); | ||
278 | int (*resume_noirq)(struct device *dev); | ||
279 | int (*freeze_noirq)(struct device *dev); | ||
280 | int (*thaw_noirq)(struct device *dev); | ||
281 | int (*poweroff_noirq)(struct device *dev); | ||
282 | int (*restore_noirq)(struct device *dev); | ||
283 | }; | ||
284 | |||
285 | /** | ||
286 | * PM_EVENT_ messages | ||
287 | * | ||
288 | * The following PM_EVENT_ messages are defined for the internal use of the PM | ||
289 | * core, in order to provide a mechanism allowing the high level suspend and | ||
290 | * hibernation code to convey the necessary information to the device PM core | ||
291 | * code: | ||
292 | * | ||
293 | * ON No transition. | ||
294 | * | ||
295 | * FREEZE System is going to hibernate, call ->prepare() and ->freeze() | ||
296 | * for all devices. | ||
297 | * | ||
298 | * SUSPEND System is going to suspend, call ->prepare() and ->suspend() | ||
299 | * for all devices. | ||
300 | * | ||
301 | * HIBERNATE Hibernation image has been saved, call ->prepare() and | ||
302 | * ->poweroff() for all devices. | ||
303 | * | ||
304 | * QUIESCE Contents of main memory are going to be restored from a (loaded) | ||
305 | * hibernation image, call ->prepare() and ->freeze() for all | ||
306 | * devices. | ||
307 | * | ||
308 | * RESUME System is resuming, call ->resume() and ->complete() for all | ||
309 | * devices. | ||
310 | * | ||
311 | * THAW Hibernation image has been created, call ->thaw() and | ||
312 | * ->complete() for all devices. | ||
313 | * | ||
314 | * RESTORE Contents of main memory have been restored from a hibernation | ||
315 | * image, call ->restore() and ->complete() for all devices. | ||
316 | * | ||
317 | * RECOVER Creation of a hibernation image or restoration of the main | ||
318 | * memory contents from a hibernation image has failed, call | ||
319 | * ->thaw() and ->complete() for all devices. | ||
320 | */ | ||
321 | |||
322 | #define PM_EVENT_ON 0x0000 | ||
323 | #define PM_EVENT_FREEZE 0x0001 | ||
324 | #define PM_EVENT_SUSPEND 0x0002 | ||
325 | #define PM_EVENT_HIBERNATE 0x0004 | ||
326 | #define PM_EVENT_QUIESCE 0x0008 | ||
327 | #define PM_EVENT_RESUME 0x0010 | ||
328 | #define PM_EVENT_THAW 0x0020 | ||
329 | #define PM_EVENT_RESTORE 0x0040 | ||
330 | #define PM_EVENT_RECOVER 0x0080 | ||
331 | |||
332 | #define PM_EVENT_SLEEP (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE) | ||
333 | |||
334 | #define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) | ||
335 | #define PMSG_QUIESCE ((struct pm_message){ .event = PM_EVENT_QUIESCE, }) | ||
336 | #define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, }) | ||
337 | #define PMSG_HIBERNATE ((struct pm_message){ .event = PM_EVENT_HIBERNATE, }) | ||
338 | #define PMSG_RESUME ((struct pm_message){ .event = PM_EVENT_RESUME, }) | ||
339 | #define PMSG_THAW ((struct pm_message){ .event = PM_EVENT_THAW, }) | ||
340 | #define PMSG_RESTORE ((struct pm_message){ .event = PM_EVENT_RESTORE, }) | ||
341 | #define PMSG_RECOVER ((struct pm_message){ .event = PM_EVENT_RECOVER, }) | ||
342 | #define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) | ||
343 | |||
344 | /** | ||
345 | * Device power management states | ||
346 | * | ||
347 | * These state labels are used internally by the PM core to indicate the current | ||
348 | * status of a device with respect to the PM core operations. | ||
349 | * | ||
350 | * DPM_ON Device is regarded as operational. Set this way | ||
351 | * initially and when ->complete() is about to be called. | ||
352 | * Also set when ->prepare() fails. | ||
353 | * | ||
354 | * DPM_PREPARING Device is going to be prepared for a PM transition. Set | ||
355 | * when ->prepare() is about to be called. | ||
356 | * | ||
357 | * DPM_RESUMING Device is going to be resumed. Set when ->resume(), | ||
358 | * ->thaw(), or ->restore() is about to be called. | ||
359 | * | ||
360 | * DPM_SUSPENDING Device has been prepared for a power transition. Set | ||
361 | * when ->prepare() has just succeeded. | ||
362 | * | ||
363 | * DPM_OFF Device is regarded as inactive. Set immediately after | ||
364 | * ->suspend(), ->freeze(), or ->poweroff() has succeeded. | ||
365 | * Also set when ->resume()_noirq, ->thaw_noirq(), or | ||
366 | * ->restore_noirq() is about to be called. | ||
367 | * | ||
368 | * DPM_OFF_IRQ Device is in a "deep sleep". Set immediately after | ||
369 | * ->suspend_noirq(), ->freeze_noirq(), or | ||
370 | * ->poweroff_noirq() has just succeeded. | ||
371 | */ | ||
372 | |||
373 | enum dpm_state { | ||
374 | DPM_INVALID, | ||
375 | DPM_ON, | ||
376 | DPM_PREPARING, | ||
377 | DPM_RESUMING, | ||
378 | DPM_SUSPENDING, | ||
379 | DPM_OFF, | ||
380 | DPM_OFF_IRQ, | ||
381 | }; | ||
382 | |||
383 | struct dev_pm_info { | ||
384 | pm_message_t power_state; | ||
385 | unsigned can_wakeup:1; | ||
386 | unsigned should_wakeup:1; | ||
387 | enum dpm_state status; /* Owned by the PM core */ | ||
388 | #ifdef CONFIG_PM_SLEEP | ||
389 | struct list_head entry; | ||
390 | #endif | ||
391 | }; | ||
392 | |||
393 | /* | ||
394 | * The PM_EVENT_ messages are also used by drivers implementing the legacy | ||
395 | * suspend framework, based on the ->suspend() and ->resume() callbacks common | ||
396 | * for suspend and hibernation transitions, according to the rules below. | ||
397 | */ | ||
398 | |||
399 | /* Necessary, because several drivers use PM_EVENT_PRETHAW */ | ||
400 | #define PM_EVENT_PRETHAW PM_EVENT_QUIESCE | ||
401 | |||
402 | /* | ||
123 | * One transition is triggered by resume(), after a suspend() call; the | 403 | * One transition is triggered by resume(), after a suspend() call; the |
124 | * message is implicit: | 404 | * message is implicit: |
125 | * | 405 | * |
@@ -164,35 +444,13 @@ typedef struct pm_message { | |||
164 | * or from system low-power states such as standby or suspend-to-RAM. | 444 | * or from system low-power states such as standby or suspend-to-RAM. |
165 | */ | 445 | */ |
166 | 446 | ||
167 | #define PM_EVENT_ON 0 | 447 | #ifdef CONFIG_PM_SLEEP |
168 | #define PM_EVENT_FREEZE 1 | 448 | extern void device_pm_lock(void); |
169 | #define PM_EVENT_SUSPEND 2 | 449 | extern void device_power_up(pm_message_t state); |
170 | #define PM_EVENT_HIBERNATE 4 | 450 | extern void device_resume(pm_message_t state); |
171 | #define PM_EVENT_PRETHAW 8 | ||
172 | |||
173 | #define PM_EVENT_SLEEP (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE) | ||
174 | |||
175 | #define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) | ||
176 | #define PMSG_PRETHAW ((struct pm_message){ .event = PM_EVENT_PRETHAW, }) | ||
177 | #define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, }) | ||
178 | #define PMSG_HIBERNATE ((struct pm_message){ .event = PM_EVENT_HIBERNATE, }) | ||
179 | #define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) | ||
180 | |||
181 | struct dev_pm_info { | ||
182 | pm_message_t power_state; | ||
183 | unsigned can_wakeup:1; | ||
184 | unsigned should_wakeup:1; | ||
185 | bool sleeping:1; /* Owned by the PM core */ | ||
186 | #ifdef CONFIG_PM_SLEEP | ||
187 | struct list_head entry; | ||
188 | #endif | ||
189 | }; | ||
190 | 451 | ||
452 | extern void device_pm_unlock(void); | ||
191 | extern int device_power_down(pm_message_t state); | 453 | extern int device_power_down(pm_message_t state); |
192 | extern void device_power_up(void); | ||
193 | extern void device_resume(void); | ||
194 | |||
195 | #ifdef CONFIG_PM_SLEEP | ||
196 | extern int device_suspend(pm_message_t state); | 454 | extern int device_suspend(pm_message_t state); |
197 | extern int device_prepare_suspend(pm_message_t state); | 455 | extern int device_prepare_suspend(pm_message_t state); |
198 | 456 | ||
diff --git a/kernel/power/disk.c b/kernel/power/disk.c index 14a656cdc652..d416be0efa8a 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c | |||
@@ -193,6 +193,7 @@ static int create_image(int platform_mode) | |||
193 | if (error) | 193 | if (error) |
194 | return error; | 194 | return error; |
195 | 195 | ||
196 | device_pm_lock(); | ||
196 | local_irq_disable(); | 197 | local_irq_disable(); |
197 | /* At this point, device_suspend() has been called, but *not* | 198 | /* At this point, device_suspend() has been called, but *not* |
198 | * device_power_down(). We *must* call device_power_down() now. | 199 | * device_power_down(). We *must* call device_power_down() now. |
@@ -224,9 +225,11 @@ static int create_image(int platform_mode) | |||
224 | /* NOTE: device_power_up() is just a resume() for devices | 225 | /* NOTE: device_power_up() is just a resume() for devices |
225 | * that suspended with irqs off ... no overall powerup. | 226 | * that suspended with irqs off ... no overall powerup. |
226 | */ | 227 | */ |
227 | device_power_up(); | 228 | device_power_up(in_suspend ? |
229 | (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); | ||
228 | Enable_irqs: | 230 | Enable_irqs: |
229 | local_irq_enable(); | 231 | local_irq_enable(); |
232 | device_pm_unlock(); | ||
230 | return error; | 233 | return error; |
231 | } | 234 | } |
232 | 235 | ||
@@ -280,7 +283,8 @@ int hibernation_snapshot(int platform_mode) | |||
280 | Finish: | 283 | Finish: |
281 | platform_finish(platform_mode); | 284 | platform_finish(platform_mode); |
282 | Resume_devices: | 285 | Resume_devices: |
283 | device_resume(); | 286 | device_resume(in_suspend ? |
287 | (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); | ||
284 | Resume_console: | 288 | Resume_console: |
285 | resume_console(); | 289 | resume_console(); |
286 | Close: | 290 | Close: |
@@ -300,8 +304,9 @@ static int resume_target_kernel(void) | |||
300 | { | 304 | { |
301 | int error; | 305 | int error; |
302 | 306 | ||
307 | device_pm_lock(); | ||
303 | local_irq_disable(); | 308 | local_irq_disable(); |
304 | error = device_power_down(PMSG_PRETHAW); | 309 | error = device_power_down(PMSG_QUIESCE); |
305 | if (error) { | 310 | if (error) { |
306 | printk(KERN_ERR "PM: Some devices failed to power down, " | 311 | printk(KERN_ERR "PM: Some devices failed to power down, " |
307 | "aborting resume\n"); | 312 | "aborting resume\n"); |
@@ -329,9 +334,10 @@ static int resume_target_kernel(void) | |||
329 | swsusp_free(); | 334 | swsusp_free(); |
330 | restore_processor_state(); | 335 | restore_processor_state(); |
331 | touch_softlockup_watchdog(); | 336 | touch_softlockup_watchdog(); |
332 | device_power_up(); | 337 | device_power_up(PMSG_RECOVER); |
333 | Enable_irqs: | 338 | Enable_irqs: |
334 | local_irq_enable(); | 339 | local_irq_enable(); |
340 | device_pm_unlock(); | ||
335 | return error; | 341 | return error; |
336 | } | 342 | } |
337 | 343 | ||
@@ -350,7 +356,7 @@ int hibernation_restore(int platform_mode) | |||
350 | 356 | ||
351 | pm_prepare_console(); | 357 | pm_prepare_console(); |
352 | suspend_console(); | 358 | suspend_console(); |
353 | error = device_suspend(PMSG_PRETHAW); | 359 | error = device_suspend(PMSG_QUIESCE); |
354 | if (error) | 360 | if (error) |
355 | goto Finish; | 361 | goto Finish; |
356 | 362 | ||
@@ -362,7 +368,7 @@ int hibernation_restore(int platform_mode) | |||
362 | enable_nonboot_cpus(); | 368 | enable_nonboot_cpus(); |
363 | } | 369 | } |
364 | platform_restore_cleanup(platform_mode); | 370 | platform_restore_cleanup(platform_mode); |
365 | device_resume(); | 371 | device_resume(PMSG_RECOVER); |
366 | Finish: | 372 | Finish: |
367 | resume_console(); | 373 | resume_console(); |
368 | pm_restore_console(); | 374 | pm_restore_console(); |
@@ -403,6 +409,7 @@ int hibernation_platform_enter(void) | |||
403 | if (error) | 409 | if (error) |
404 | goto Finish; | 410 | goto Finish; |
405 | 411 | ||
412 | device_pm_lock(); | ||
406 | local_irq_disable(); | 413 | local_irq_disable(); |
407 | error = device_power_down(PMSG_HIBERNATE); | 414 | error = device_power_down(PMSG_HIBERNATE); |
408 | if (!error) { | 415 | if (!error) { |
@@ -411,6 +418,7 @@ int hibernation_platform_enter(void) | |||
411 | while (1); | 418 | while (1); |
412 | } | 419 | } |
413 | local_irq_enable(); | 420 | local_irq_enable(); |
421 | device_pm_unlock(); | ||
414 | 422 | ||
415 | /* | 423 | /* |
416 | * We don't need to reenable the nonboot CPUs or resume consoles, since | 424 | * We don't need to reenable the nonboot CPUs or resume consoles, since |
@@ -419,7 +427,7 @@ int hibernation_platform_enter(void) | |||
419 | Finish: | 427 | Finish: |
420 | hibernation_ops->finish(); | 428 | hibernation_ops->finish(); |
421 | Resume_devices: | 429 | Resume_devices: |
422 | device_resume(); | 430 | device_resume(PMSG_RESTORE); |
423 | Resume_console: | 431 | Resume_console: |
424 | resume_console(); | 432 | resume_console(); |
425 | Close: | 433 | Close: |
diff --git a/kernel/power/main.c b/kernel/power/main.c index 6a6d5eb3524e..d023b6b584e5 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -228,6 +228,7 @@ static int suspend_enter(suspend_state_t state) | |||
228 | { | 228 | { |
229 | int error = 0; | 229 | int error = 0; |
230 | 230 | ||
231 | device_pm_lock(); | ||
231 | arch_suspend_disable_irqs(); | 232 | arch_suspend_disable_irqs(); |
232 | BUG_ON(!irqs_disabled()); | 233 | BUG_ON(!irqs_disabled()); |
233 | 234 | ||
@@ -239,10 +240,11 @@ static int suspend_enter(suspend_state_t state) | |||
239 | if (!suspend_test(TEST_CORE)) | 240 | if (!suspend_test(TEST_CORE)) |
240 | error = suspend_ops->enter(state); | 241 | error = suspend_ops->enter(state); |
241 | 242 | ||
242 | device_power_up(); | 243 | device_power_up(PMSG_RESUME); |
243 | Done: | 244 | Done: |
244 | arch_suspend_enable_irqs(); | 245 | arch_suspend_enable_irqs(); |
245 | BUG_ON(irqs_disabled()); | 246 | BUG_ON(irqs_disabled()); |
247 | device_pm_unlock(); | ||
246 | return error; | 248 | return error; |
247 | } | 249 | } |
248 | 250 | ||
@@ -291,7 +293,7 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
291 | if (suspend_ops->finish) | 293 | if (suspend_ops->finish) |
292 | suspend_ops->finish(); | 294 | suspend_ops->finish(); |
293 | Resume_devices: | 295 | Resume_devices: |
294 | device_resume(); | 296 | device_resume(PMSG_RESUME); |
295 | Resume_console: | 297 | Resume_console: |
296 | resume_console(); | 298 | resume_console(); |
297 | Close: | 299 | Close: |
diff --git a/lib/kobject.c b/lib/kobject.c index 718e5101c263..dcade0543bd2 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -439,6 +439,7 @@ out: | |||
439 | 439 | ||
440 | return error; | 440 | return error; |
441 | } | 441 | } |
442 | EXPORT_SYMBOL_GPL(kobject_rename); | ||
442 | 443 | ||
443 | /** | 444 | /** |
444 | * kobject_move - move object to another parent | 445 | * kobject_move - move object to another parent |