diff options
author | Bogicevic Sasa <brutallesale@gmail.com> | 2015-12-27 16:21:11 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2016-01-08 11:35:24 -0500 |
commit | ff3ce480e8b59fbc0f459476fe1b5451464592a5 (patch) | |
tree | 46500e2528f05508dd8923306368df2855680491 /drivers/pci/hotplug/ibmphp_pci.c | |
parent | 1d1e8cdc823b9c0ed9b51dffef59b874b0aac808 (diff) |
PCI: Fix all whitespace issues
Fix all whitespace issues (missing or needed whitespace) in all files in
drivers/pci. Code is compiled with allyesconfig before and after code
changes and objects are recorded and checked with objdiff and they are not
changed after this commit.
Signed-off-by: Bogicevic Sasa <brutallesale@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/hotplug/ibmphp_pci.c')
-rw-r--r-- | drivers/pci/hotplug/ibmphp_pci.c | 728 |
1 files changed, 364 insertions, 364 deletions
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c index 814cea22a9fa..eb89a1838d18 100644 --- a/drivers/pci/hotplug/ibmphp_pci.c +++ b/drivers/pci/hotplug/ibmphp_pci.c | |||
@@ -37,8 +37,8 @@ | |||
37 | static int configure_device(struct pci_func *); | 37 | static int configure_device(struct pci_func *); |
38 | static int configure_bridge(struct pci_func **, u8); | 38 | static int configure_bridge(struct pci_func **, u8); |
39 | static struct res_needed *scan_behind_bridge(struct pci_func *, u8); | 39 | static struct res_needed *scan_behind_bridge(struct pci_func *, u8); |
40 | static int add_new_bus (struct bus_node *, struct resource_node *, struct resource_node *, struct resource_node *, u8); | 40 | static int add_new_bus(struct bus_node *, struct resource_node *, struct resource_node *, struct resource_node *, u8); |
41 | static u8 find_sec_number (u8 primary_busno, u8 slotno); | 41 | static u8 find_sec_number(u8 primary_busno, u8 slotno); |
42 | 42 | ||
43 | /* | 43 | /* |
44 | * NOTE..... If BIOS doesn't provide default routing, we assign: | 44 | * NOTE..... If BIOS doesn't provide default routing, we assign: |
@@ -47,7 +47,7 @@ static u8 find_sec_number (u8 primary_busno, u8 slotno); | |||
47 | * We also assign the same irq numbers for multi function devices. | 47 | * We also assign the same irq numbers for multi function devices. |
48 | * These are PIC mode, so shouldn't matter n.e.ways (hopefully) | 48 | * These are PIC mode, so shouldn't matter n.e.ways (hopefully) |
49 | */ | 49 | */ |
50 | static void assign_alt_irq (struct pci_func *cur_func, u8 class_code) | 50 | static void assign_alt_irq(struct pci_func *cur_func, u8 class_code) |
51 | { | 51 | { |
52 | int j; | 52 | int j; |
53 | for (j = 0; j < 4; j++) { | 53 | for (j = 0; j < 4; j++) { |
@@ -78,7 +78,7 @@ static void assign_alt_irq (struct pci_func *cur_func, u8 class_code) | |||
78 | * if there is an error, will need to go through all previous functions and | 78 | * if there is an error, will need to go through all previous functions and |
79 | * unconfigure....or can add some code into unconfigure_card.... | 79 | * unconfigure....or can add some code into unconfigure_card.... |
80 | */ | 80 | */ |
81 | int ibmphp_configure_card (struct pci_func *func, u8 slotno) | 81 | int ibmphp_configure_card(struct pci_func *func, u8 slotno) |
82 | { | 82 | { |
83 | u16 vendor_id; | 83 | u16 vendor_id; |
84 | u32 class; | 84 | u32 class; |
@@ -92,7 +92,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
92 | u8 flag; | 92 | u8 flag; |
93 | u8 valid_device = 0x00; /* to see if we are able to read from card any device info at all */ | 93 | u8 valid_device = 0x00; /* to see if we are able to read from card any device info at all */ |
94 | 94 | ||
95 | debug ("inside configure_card, func->busno = %x\n", func->busno); | 95 | debug("inside configure_card, func->busno = %x\n", func->busno); |
96 | 96 | ||
97 | device = func->device; | 97 | device = func->device; |
98 | cur_func = func; | 98 | cur_func = func; |
@@ -109,15 +109,15 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
109 | 109 | ||
110 | cur_func->function = function; | 110 | cur_func->function = function; |
111 | 111 | ||
112 | debug ("inside the loop, cur_func->busno = %x, cur_func->device = %x, cur_func->function = %x\n", | 112 | debug("inside the loop, cur_func->busno = %x, cur_func->device = %x, cur_func->function = %x\n", |
113 | cur_func->busno, cur_func->device, cur_func->function); | 113 | cur_func->busno, cur_func->device, cur_func->function); |
114 | 114 | ||
115 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); | 115 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); |
116 | 116 | ||
117 | debug ("vendor_id is %x\n", vendor_id); | 117 | debug("vendor_id is %x\n", vendor_id); |
118 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { | 118 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { |
119 | /* found correct device!!! */ | 119 | /* found correct device!!! */ |
120 | debug ("found valid device, vendor_id = %x\n", vendor_id); | 120 | debug("found valid device, vendor_id = %x\n", vendor_id); |
121 | 121 | ||
122 | ++valid_device; | 122 | ++valid_device; |
123 | 123 | ||
@@ -126,29 +126,29 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
126 | * |_=> 0 = single function device, 1 = multi-function device | 126 | * |_=> 0 = single function device, 1 = multi-function device |
127 | */ | 127 | */ |
128 | 128 | ||
129 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); | 129 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); |
130 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); | 130 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); |
131 | 131 | ||
132 | class_code = class >> 24; | 132 | class_code = class >> 24; |
133 | debug ("hrd_type = %x, class = %x, class_code %x\n", hdr_type, class, class_code); | 133 | debug("hrd_type = %x, class = %x, class_code %x\n", hdr_type, class, class_code); |
134 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ | 134 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ |
135 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { | 135 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { |
136 | err ("The device %x is VGA compatible and as is not supported for hot plugging. " | 136 | err("The device %x is VGA compatible and as is not supported for hot plugging. " |
137 | "Please choose another device.\n", cur_func->device); | 137 | "Please choose another device.\n", cur_func->device); |
138 | return -ENODEV; | 138 | return -ENODEV; |
139 | } else if (class == PCI_CLASS_DISPLAY_VGA) { | 139 | } else if (class == PCI_CLASS_DISPLAY_VGA) { |
140 | err ("The device %x is not supported for hot plugging. Please choose another device.\n", | 140 | err("The device %x is not supported for hot plugging. Please choose another device.\n", |
141 | cur_func->device); | 141 | cur_func->device); |
142 | return -ENODEV; | 142 | return -ENODEV; |
143 | } | 143 | } |
144 | switch (hdr_type) { | 144 | switch (hdr_type) { |
145 | case PCI_HEADER_TYPE_NORMAL: | 145 | case PCI_HEADER_TYPE_NORMAL: |
146 | debug ("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class); | 146 | debug("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class); |
147 | assign_alt_irq (cur_func, class_code); | 147 | assign_alt_irq(cur_func, class_code); |
148 | rc = configure_device(cur_func); | 148 | rc = configure_device(cur_func); |
149 | if (rc < 0) { | 149 | if (rc < 0) { |
150 | /* We need to do this in case some other BARs were properly inserted */ | 150 | /* We need to do this in case some other BARs were properly inserted */ |
151 | err ("was not able to configure devfunc %x on bus %x.\n", | 151 | err("was not able to configure devfunc %x on bus %x.\n", |
152 | cur_func->device, cur_func->busno); | 152 | cur_func->device, cur_func->busno); |
153 | cleanup_count = 6; | 153 | cleanup_count = 6; |
154 | goto error; | 154 | goto error; |
@@ -157,18 +157,18 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
157 | function = 0x8; | 157 | function = 0x8; |
158 | break; | 158 | break; |
159 | case PCI_HEADER_TYPE_MULTIDEVICE: | 159 | case PCI_HEADER_TYPE_MULTIDEVICE: |
160 | assign_alt_irq (cur_func, class_code); | 160 | assign_alt_irq(cur_func, class_code); |
161 | rc = configure_device(cur_func); | 161 | rc = configure_device(cur_func); |
162 | if (rc < 0) { | 162 | if (rc < 0) { |
163 | /* We need to do this in case some other BARs were properly inserted */ | 163 | /* We need to do this in case some other BARs were properly inserted */ |
164 | err ("was not able to configure devfunc %x on bus %x...bailing out\n", | 164 | err("was not able to configure devfunc %x on bus %x...bailing out\n", |
165 | cur_func->device, cur_func->busno); | 165 | cur_func->device, cur_func->busno); |
166 | cleanup_count = 6; | 166 | cleanup_count = 6; |
167 | goto error; | 167 | goto error; |
168 | } | 168 | } |
169 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 169 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
170 | if (!newfunc) { | 170 | if (!newfunc) { |
171 | err ("out of system memory\n"); | 171 | err("out of system memory\n"); |
172 | return -ENOMEM; | 172 | return -ENOMEM; |
173 | } | 173 | } |
174 | newfunc->busno = cur_func->busno; | 174 | newfunc->busno = cur_func->busno; |
@@ -181,32 +181,32 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
181 | case PCI_HEADER_TYPE_MULTIBRIDGE: | 181 | case PCI_HEADER_TYPE_MULTIBRIDGE: |
182 | class >>= 8; | 182 | class >>= 8; |
183 | if (class != PCI_CLASS_BRIDGE_PCI) { | 183 | if (class != PCI_CLASS_BRIDGE_PCI) { |
184 | err ("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n", | 184 | err("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n", |
185 | cur_func->device); | 185 | cur_func->device); |
186 | return -ENODEV; | 186 | return -ENODEV; |
187 | } | 187 | } |
188 | assign_alt_irq (cur_func, class_code); | 188 | assign_alt_irq(cur_func, class_code); |
189 | rc = configure_bridge (&cur_func, slotno); | 189 | rc = configure_bridge(&cur_func, slotno); |
190 | if (rc == -ENODEV) { | 190 | if (rc == -ENODEV) { |
191 | err ("You chose to insert Single Bridge, or nested bridges, this is not supported...\n"); | 191 | err("You chose to insert Single Bridge, or nested bridges, this is not supported...\n"); |
192 | err ("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device); | 192 | err("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device); |
193 | return rc; | 193 | return rc; |
194 | } | 194 | } |
195 | if (rc) { | 195 | if (rc) { |
196 | /* We need to do this in case some other BARs were properly inserted */ | 196 | /* We need to do this in case some other BARs were properly inserted */ |
197 | err ("was not able to hot-add PPB properly.\n"); | 197 | err("was not able to hot-add PPB properly.\n"); |
198 | func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */ | 198 | func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */ |
199 | cleanup_count = 2; | 199 | cleanup_count = 2; |
200 | goto error; | 200 | goto error; |
201 | } | 201 | } |
202 | 202 | ||
203 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 203 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
204 | flag = 0; | 204 | flag = 0; |
205 | for (i = 0; i < 32; i++) { | 205 | for (i = 0; i < 32; i++) { |
206 | if (func->devices[i]) { | 206 | if (func->devices[i]) { |
207 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 207 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
208 | if (!newfunc) { | 208 | if (!newfunc) { |
209 | err ("out of system memory\n"); | 209 | err("out of system memory\n"); |
210 | return -ENOMEM; | 210 | return -ENOMEM; |
211 | } | 211 | } |
212 | newfunc->busno = sec_number; | 212 | newfunc->busno = sec_number; |
@@ -220,7 +220,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
220 | } else | 220 | } else |
221 | cur_func->next = newfunc; | 221 | cur_func->next = newfunc; |
222 | 222 | ||
223 | rc = ibmphp_configure_card (newfunc, slotno); | 223 | rc = ibmphp_configure_card(newfunc, slotno); |
224 | /* This could only happen if kmalloc failed */ | 224 | /* This could only happen if kmalloc failed */ |
225 | if (rc) { | 225 | if (rc) { |
226 | /* We need to do this in case bridge itself got configured properly, but devices behind it failed */ | 226 | /* We need to do this in case bridge itself got configured properly, but devices behind it failed */ |
@@ -234,53 +234,53 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
234 | 234 | ||
235 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 235 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
236 | if (!newfunc) { | 236 | if (!newfunc) { |
237 | err ("out of system memory\n"); | 237 | err("out of system memory\n"); |
238 | return -ENOMEM; | 238 | return -ENOMEM; |
239 | } | 239 | } |
240 | newfunc->busno = cur_func->busno; | 240 | newfunc->busno = cur_func->busno; |
241 | newfunc->device = device; | 241 | newfunc->device = device; |
242 | for (j = 0; j < 4; j++) | 242 | for (j = 0; j < 4; j++) |
243 | newfunc->irq[j] = cur_func->irq[j]; | 243 | newfunc->irq[j] = cur_func->irq[j]; |
244 | for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next) ; | 244 | for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next); |
245 | prev_func->next = newfunc; | 245 | prev_func->next = newfunc; |
246 | cur_func = newfunc; | 246 | cur_func = newfunc; |
247 | break; | 247 | break; |
248 | case PCI_HEADER_TYPE_BRIDGE: | 248 | case PCI_HEADER_TYPE_BRIDGE: |
249 | class >>= 8; | 249 | class >>= 8; |
250 | debug ("class now is %x\n", class); | 250 | debug("class now is %x\n", class); |
251 | if (class != PCI_CLASS_BRIDGE_PCI) { | 251 | if (class != PCI_CLASS_BRIDGE_PCI) { |
252 | err ("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n", | 252 | err("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n", |
253 | cur_func->device); | 253 | cur_func->device); |
254 | return -ENODEV; | 254 | return -ENODEV; |
255 | } | 255 | } |
256 | 256 | ||
257 | assign_alt_irq (cur_func, class_code); | 257 | assign_alt_irq(cur_func, class_code); |
258 | 258 | ||
259 | debug ("cur_func->busno b4 configure_bridge is %x\n", cur_func->busno); | 259 | debug("cur_func->busno b4 configure_bridge is %x\n", cur_func->busno); |
260 | rc = configure_bridge (&cur_func, slotno); | 260 | rc = configure_bridge(&cur_func, slotno); |
261 | if (rc == -ENODEV) { | 261 | if (rc == -ENODEV) { |
262 | err ("You chose to insert Single Bridge, or nested bridges, this is not supported...\n"); | 262 | err("You chose to insert Single Bridge, or nested bridges, this is not supported...\n"); |
263 | err ("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device); | 263 | err("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device); |
264 | return rc; | 264 | return rc; |
265 | } | 265 | } |
266 | if (rc) { | 266 | if (rc) { |
267 | /* We need to do this in case some other BARs were properly inserted */ | 267 | /* We need to do this in case some other BARs were properly inserted */ |
268 | func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */ | 268 | func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */ |
269 | err ("was not able to hot-add PPB properly.\n"); | 269 | err("was not able to hot-add PPB properly.\n"); |
270 | cleanup_count = 2; | 270 | cleanup_count = 2; |
271 | goto error; | 271 | goto error; |
272 | } | 272 | } |
273 | debug ("cur_func->busno = %x, device = %x, function = %x\n", | 273 | debug("cur_func->busno = %x, device = %x, function = %x\n", |
274 | cur_func->busno, device, function); | 274 | cur_func->busno, device, function); |
275 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 275 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
276 | debug ("after configuring bridge..., sec_number = %x\n", sec_number); | 276 | debug("after configuring bridge..., sec_number = %x\n", sec_number); |
277 | flag = 0; | 277 | flag = 0; |
278 | for (i = 0; i < 32; i++) { | 278 | for (i = 0; i < 32; i++) { |
279 | if (func->devices[i]) { | 279 | if (func->devices[i]) { |
280 | debug ("inside for loop, device is %x\n", i); | 280 | debug("inside for loop, device is %x\n", i); |
281 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 281 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
282 | if (!newfunc) { | 282 | if (!newfunc) { |
283 | err (" out of system memory\n"); | 283 | err(" out of system memory\n"); |
284 | return -ENOMEM; | 284 | return -ENOMEM; |
285 | } | 285 | } |
286 | newfunc->busno = sec_number; | 286 | newfunc->busno = sec_number; |
@@ -289,12 +289,12 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
289 | newfunc->irq[j] = cur_func->irq[j]; | 289 | newfunc->irq[j] = cur_func->irq[j]; |
290 | 290 | ||
291 | if (flag) { | 291 | if (flag) { |
292 | for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next) ; | 292 | for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next); |
293 | prev_func->next = newfunc; | 293 | prev_func->next = newfunc; |
294 | } else | 294 | } else |
295 | cur_func->next = newfunc; | 295 | cur_func->next = newfunc; |
296 | 296 | ||
297 | rc = ibmphp_configure_card (newfunc, slotno); | 297 | rc = ibmphp_configure_card(newfunc, slotno); |
298 | 298 | ||
299 | /* Again, this case should not happen... For complete paranoia, will need to call remove_bus */ | 299 | /* Again, this case should not happen... For complete paranoia, will need to call remove_bus */ |
300 | if (rc) { | 300 | if (rc) { |
@@ -310,7 +310,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
310 | function = 0x8; | 310 | function = 0x8; |
311 | break; | 311 | break; |
312 | default: | 312 | default: |
313 | err ("MAJOR PROBLEM!!!!, header type not supported? %x\n", hdr_type); | 313 | err("MAJOR PROBLEM!!!!, header type not supported? %x\n", hdr_type); |
314 | return -ENXIO; | 314 | return -ENXIO; |
315 | break; | 315 | break; |
316 | } /* end of switch */ | 316 | } /* end of switch */ |
@@ -318,7 +318,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
318 | } /* end of for */ | 318 | } /* end of for */ |
319 | 319 | ||
320 | if (!valid_device) { | 320 | if (!valid_device) { |
321 | err ("Cannot find any valid devices on the card. Or unable to read from card.\n"); | 321 | err("Cannot find any valid devices on the card. Or unable to read from card.\n"); |
322 | return -ENODEV; | 322 | return -ENODEV; |
323 | } | 323 | } |
324 | 324 | ||
@@ -327,13 +327,13 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
327 | error: | 327 | error: |
328 | for (i = 0; i < cleanup_count; i++) { | 328 | for (i = 0; i < cleanup_count; i++) { |
329 | if (cur_func->io[i]) { | 329 | if (cur_func->io[i]) { |
330 | ibmphp_remove_resource (cur_func->io[i]); | 330 | ibmphp_remove_resource(cur_func->io[i]); |
331 | cur_func->io[i] = NULL; | 331 | cur_func->io[i] = NULL; |
332 | } else if (cur_func->pfmem[i]) { | 332 | } else if (cur_func->pfmem[i]) { |
333 | ibmphp_remove_resource (cur_func->pfmem[i]); | 333 | ibmphp_remove_resource(cur_func->pfmem[i]); |
334 | cur_func->pfmem[i] = NULL; | 334 | cur_func->pfmem[i] = NULL; |
335 | } else if (cur_func->mem[i]) { | 335 | } else if (cur_func->mem[i]) { |
336 | ibmphp_remove_resource (cur_func->mem[i]); | 336 | ibmphp_remove_resource(cur_func->mem[i]); |
337 | cur_func->mem[i] = NULL; | 337 | cur_func->mem[i] = NULL; |
338 | } | 338 | } |
339 | } | 339 | } |
@@ -345,7 +345,7 @@ error: | |||
345 | * Input: pointer to the pci_func | 345 | * Input: pointer to the pci_func |
346 | * Output: configured PCI, 0, or error | 346 | * Output: configured PCI, 0, or error |
347 | */ | 347 | */ |
348 | static int configure_device (struct pci_func *func) | 348 | static int configure_device(struct pci_func *func) |
349 | { | 349 | { |
350 | u32 bar[6]; | 350 | u32 bar[6]; |
351 | u32 address[] = { | 351 | u32 address[] = { |
@@ -366,7 +366,7 @@ static int configure_device (struct pci_func *func) | |||
366 | struct resource_node *pfmem[6]; | 366 | struct resource_node *pfmem[6]; |
367 | unsigned int devfn; | 367 | unsigned int devfn; |
368 | 368 | ||
369 | debug ("%s - inside\n", __func__); | 369 | debug("%s - inside\n", __func__); |
370 | 370 | ||
371 | devfn = PCI_DEVFN(func->device, func->function); | 371 | devfn = PCI_DEVFN(func->device, func->function); |
372 | ibmphp_pci_bus->number = func->busno; | 372 | ibmphp_pci_bus->number = func->busno; |
@@ -386,27 +386,27 @@ static int configure_device (struct pci_func *func) | |||
386 | pcibios_write_config_dword(cur_func->busno, cur_func->device, | 386 | pcibios_write_config_dword(cur_func->busno, cur_func->device, |
387 | PCI_BASE_ADDRESS_0 + 4 * count, 0xFFFFFFFF); | 387 | PCI_BASE_ADDRESS_0 + 4 * count, 0xFFFFFFFF); |
388 | */ | 388 | */ |
389 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); | 389 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); |
390 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 390 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
391 | 391 | ||
392 | if (!bar[count]) /* This BAR is not implemented */ | 392 | if (!bar[count]) /* This BAR is not implemented */ |
393 | continue; | 393 | continue; |
394 | 394 | ||
395 | debug ("Device %x BAR %d wants %x\n", func->device, count, bar[count]); | 395 | debug("Device %x BAR %d wants %x\n", func->device, count, bar[count]); |
396 | 396 | ||
397 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { | 397 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { |
398 | /* This is IO */ | 398 | /* This is IO */ |
399 | debug ("inside IO SPACE\n"); | 399 | debug("inside IO SPACE\n"); |
400 | 400 | ||
401 | len[count] = bar[count] & 0xFFFFFFFC; | 401 | len[count] = bar[count] & 0xFFFFFFFC; |
402 | len[count] = ~len[count] + 1; | 402 | len[count] = ~len[count] + 1; |
403 | 403 | ||
404 | debug ("len[count] in IO %x, count %d\n", len[count], count); | 404 | debug("len[count] in IO %x, count %d\n", len[count], count); |
405 | 405 | ||
406 | io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 406 | io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
407 | 407 | ||
408 | if (!io[count]) { | 408 | if (!io[count]) { |
409 | err ("out of system memory\n"); | 409 | err("out of system memory\n"); |
410 | return -ENOMEM; | 410 | return -ENOMEM; |
411 | } | 411 | } |
412 | io[count]->type = IO; | 412 | io[count]->type = IO; |
@@ -414,36 +414,36 @@ static int configure_device (struct pci_func *func) | |||
414 | io[count]->devfunc = PCI_DEVFN(func->device, func->function); | 414 | io[count]->devfunc = PCI_DEVFN(func->device, func->function); |
415 | io[count]->len = len[count]; | 415 | io[count]->len = len[count]; |
416 | if (ibmphp_check_resource(io[count], 0) == 0) { | 416 | if (ibmphp_check_resource(io[count], 0) == 0) { |
417 | ibmphp_add_resource (io[count]); | 417 | ibmphp_add_resource(io[count]); |
418 | func->io[count] = io[count]; | 418 | func->io[count] = io[count]; |
419 | } else { | 419 | } else { |
420 | err ("cannot allocate requested io for bus %x device %x function %x len %x\n", | 420 | err("cannot allocate requested io for bus %x device %x function %x len %x\n", |
421 | func->busno, func->device, func->function, len[count]); | 421 | func->busno, func->device, func->function, len[count]); |
422 | kfree (io[count]); | 422 | kfree(io[count]); |
423 | return -EIO; | 423 | return -EIO; |
424 | } | 424 | } |
425 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->io[count]->start); | 425 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->io[count]->start); |
426 | 426 | ||
427 | /* _______________This is for debugging purposes only_____________________ */ | 427 | /* _______________This is for debugging purposes only_____________________ */ |
428 | debug ("b4 writing, the IO address is %x\n", func->io[count]->start); | 428 | debug("b4 writing, the IO address is %x\n", func->io[count]->start); |
429 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 429 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
430 | debug ("after writing.... the start address is %x\n", bar[count]); | 430 | debug("after writing.... the start address is %x\n", bar[count]); |
431 | /* _________________________________________________________________________*/ | 431 | /* _________________________________________________________________________*/ |
432 | 432 | ||
433 | } else { | 433 | } else { |
434 | /* This is Memory */ | 434 | /* This is Memory */ |
435 | if (bar[count] & PCI_BASE_ADDRESS_MEM_PREFETCH) { | 435 | if (bar[count] & PCI_BASE_ADDRESS_MEM_PREFETCH) { |
436 | /* pfmem */ | 436 | /* pfmem */ |
437 | debug ("PFMEM SPACE\n"); | 437 | debug("PFMEM SPACE\n"); |
438 | 438 | ||
439 | len[count] = bar[count] & 0xFFFFFFF0; | 439 | len[count] = bar[count] & 0xFFFFFFF0; |
440 | len[count] = ~len[count] + 1; | 440 | len[count] = ~len[count] + 1; |
441 | 441 | ||
442 | debug ("len[count] in PFMEM %x, count %d\n", len[count], count); | 442 | debug("len[count] in PFMEM %x, count %d\n", len[count], count); |
443 | 443 | ||
444 | pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 444 | pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
445 | if (!pfmem[count]) { | 445 | if (!pfmem[count]) { |
446 | err ("out of system memory\n"); | 446 | err("out of system memory\n"); |
447 | return -ENOMEM; | 447 | return -ENOMEM; |
448 | } | 448 | } |
449 | pfmem[count]->type = PFMEM; | 449 | pfmem[count]->type = PFMEM; |
@@ -452,64 +452,64 @@ static int configure_device (struct pci_func *func) | |||
452 | func->function); | 452 | func->function); |
453 | pfmem[count]->len = len[count]; | 453 | pfmem[count]->len = len[count]; |
454 | pfmem[count]->fromMem = 0; | 454 | pfmem[count]->fromMem = 0; |
455 | if (ibmphp_check_resource (pfmem[count], 0) == 0) { | 455 | if (ibmphp_check_resource(pfmem[count], 0) == 0) { |
456 | ibmphp_add_resource (pfmem[count]); | 456 | ibmphp_add_resource(pfmem[count]); |
457 | func->pfmem[count] = pfmem[count]; | 457 | func->pfmem[count] = pfmem[count]; |
458 | } else { | 458 | } else { |
459 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); | 459 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
460 | if (!mem_tmp) { | 460 | if (!mem_tmp) { |
461 | err ("out of system memory\n"); | 461 | err("out of system memory\n"); |
462 | kfree (pfmem[count]); | 462 | kfree(pfmem[count]); |
463 | return -ENOMEM; | 463 | return -ENOMEM; |
464 | } | 464 | } |
465 | mem_tmp->type = MEM; | 465 | mem_tmp->type = MEM; |
466 | mem_tmp->busno = pfmem[count]->busno; | 466 | mem_tmp->busno = pfmem[count]->busno; |
467 | mem_tmp->devfunc = pfmem[count]->devfunc; | 467 | mem_tmp->devfunc = pfmem[count]->devfunc; |
468 | mem_tmp->len = pfmem[count]->len; | 468 | mem_tmp->len = pfmem[count]->len; |
469 | debug ("there's no pfmem... going into mem.\n"); | 469 | debug("there's no pfmem... going into mem.\n"); |
470 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { | 470 | if (ibmphp_check_resource(mem_tmp, 0) == 0) { |
471 | ibmphp_add_resource (mem_tmp); | 471 | ibmphp_add_resource(mem_tmp); |
472 | pfmem[count]->fromMem = 1; | 472 | pfmem[count]->fromMem = 1; |
473 | pfmem[count]->rangeno = mem_tmp->rangeno; | 473 | pfmem[count]->rangeno = mem_tmp->rangeno; |
474 | pfmem[count]->start = mem_tmp->start; | 474 | pfmem[count]->start = mem_tmp->start; |
475 | pfmem[count]->end = mem_tmp->end; | 475 | pfmem[count]->end = mem_tmp->end; |
476 | ibmphp_add_pfmem_from_mem (pfmem[count]); | 476 | ibmphp_add_pfmem_from_mem(pfmem[count]); |
477 | func->pfmem[count] = pfmem[count]; | 477 | func->pfmem[count] = pfmem[count]; |
478 | } else { | 478 | } else { |
479 | err ("cannot allocate requested pfmem for bus %x, device %x, len %x\n", | 479 | err("cannot allocate requested pfmem for bus %x, device %x, len %x\n", |
480 | func->busno, func->device, len[count]); | 480 | func->busno, func->device, len[count]); |
481 | kfree (mem_tmp); | 481 | kfree(mem_tmp); |
482 | kfree (pfmem[count]); | 482 | kfree(pfmem[count]); |
483 | return -EIO; | 483 | return -EIO; |
484 | } | 484 | } |
485 | } | 485 | } |
486 | 486 | ||
487 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); | 487 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); |
488 | 488 | ||
489 | /*_______________This is for debugging purposes only______________________________*/ | 489 | /*_______________This is for debugging purposes only______________________________*/ |
490 | debug ("b4 writing, start address is %x\n", func->pfmem[count]->start); | 490 | debug("b4 writing, start address is %x\n", func->pfmem[count]->start); |
491 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 491 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
492 | debug ("after writing, start address is %x\n", bar[count]); | 492 | debug("after writing, start address is %x\n", bar[count]); |
493 | /*_________________________________________________________________________________*/ | 493 | /*_________________________________________________________________________________*/ |
494 | 494 | ||
495 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { /* takes up another dword */ | 495 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { /* takes up another dword */ |
496 | debug ("inside the mem 64 case, count %d\n", count); | 496 | debug("inside the mem 64 case, count %d\n", count); |
497 | count += 1; | 497 | count += 1; |
498 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ | 498 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ |
499 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); | 499 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000); |
500 | } | 500 | } |
501 | } else { | 501 | } else { |
502 | /* regular memory */ | 502 | /* regular memory */ |
503 | debug ("REGULAR MEM SPACE\n"); | 503 | debug("REGULAR MEM SPACE\n"); |
504 | 504 | ||
505 | len[count] = bar[count] & 0xFFFFFFF0; | 505 | len[count] = bar[count] & 0xFFFFFFF0; |
506 | len[count] = ~len[count] + 1; | 506 | len[count] = ~len[count] + 1; |
507 | 507 | ||
508 | debug ("len[count] in Mem %x, count %d\n", len[count], count); | 508 | debug("len[count] in Mem %x, count %d\n", len[count], count); |
509 | 509 | ||
510 | mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 510 | mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
511 | if (!mem[count]) { | 511 | if (!mem[count]) { |
512 | err ("out of system memory\n"); | 512 | err("out of system memory\n"); |
513 | return -ENOMEM; | 513 | return -ENOMEM; |
514 | } | 514 | } |
515 | mem[count]->type = MEM; | 515 | mem[count]->type = MEM; |
@@ -517,43 +517,43 @@ static int configure_device (struct pci_func *func) | |||
517 | mem[count]->devfunc = PCI_DEVFN(func->device, | 517 | mem[count]->devfunc = PCI_DEVFN(func->device, |
518 | func->function); | 518 | func->function); |
519 | mem[count]->len = len[count]; | 519 | mem[count]->len = len[count]; |
520 | if (ibmphp_check_resource (mem[count], 0) == 0) { | 520 | if (ibmphp_check_resource(mem[count], 0) == 0) { |
521 | ibmphp_add_resource (mem[count]); | 521 | ibmphp_add_resource(mem[count]); |
522 | func->mem[count] = mem[count]; | 522 | func->mem[count] = mem[count]; |
523 | } else { | 523 | } else { |
524 | err ("cannot allocate requested mem for bus %x, device %x, len %x\n", | 524 | err("cannot allocate requested mem for bus %x, device %x, len %x\n", |
525 | func->busno, func->device, len[count]); | 525 | func->busno, func->device, len[count]); |
526 | kfree (mem[count]); | 526 | kfree(mem[count]); |
527 | return -EIO; | 527 | return -EIO; |
528 | } | 528 | } |
529 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); | 529 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); |
530 | /* _______________________This is for debugging purposes only _______________________*/ | 530 | /* _______________________This is for debugging purposes only _______________________*/ |
531 | debug ("b4 writing, start address is %x\n", func->mem[count]->start); | 531 | debug("b4 writing, start address is %x\n", func->mem[count]->start); |
532 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 532 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
533 | debug ("after writing, the address is %x\n", bar[count]); | 533 | debug("after writing, the address is %x\n", bar[count]); |
534 | /* __________________________________________________________________________________*/ | 534 | /* __________________________________________________________________________________*/ |
535 | 535 | ||
536 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { | 536 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { |
537 | /* takes up another dword */ | 537 | /* takes up another dword */ |
538 | debug ("inside mem 64 case, reg. mem, count %d\n", count); | 538 | debug("inside mem 64 case, reg. mem, count %d\n", count); |
539 | count += 1; | 539 | count += 1; |
540 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ | 540 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ |
541 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); | 541 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000); |
542 | } | 542 | } |
543 | } | 543 | } |
544 | } /* end of mem */ | 544 | } /* end of mem */ |
545 | } /* end of for */ | 545 | } /* end of for */ |
546 | 546 | ||
547 | func->bus = 0; /* To indicate that this is not a PPB */ | 547 | func->bus = 0; /* To indicate that this is not a PPB */ |
548 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); | 548 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); |
549 | if ((irq > 0x00) && (irq < 0x05)) | 549 | if ((irq > 0x00) && (irq < 0x05)) |
550 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); | 550 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); |
551 | 551 | ||
552 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); | 552 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); |
553 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); | 553 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); |
554 | 554 | ||
555 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_ROM_ADDRESS, 0x00L); | 555 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, PCI_ROM_ADDRESS, 0x00L); |
556 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); | 556 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); |
557 | 557 | ||
558 | return 0; | 558 | return 0; |
559 | } | 559 | } |
@@ -563,7 +563,7 @@ static int configure_device (struct pci_func *func) | |||
563 | * Parameters: pci_func | 563 | * Parameters: pci_func |
564 | * Returns: | 564 | * Returns: |
565 | ******************************************************************************/ | 565 | ******************************************************************************/ |
566 | static int configure_bridge (struct pci_func **func_passed, u8 slotno) | 566 | static int configure_bridge(struct pci_func **func_passed, u8 slotno) |
567 | { | 567 | { |
568 | int count; | 568 | int count; |
569 | int i; | 569 | int i; |
@@ -597,7 +597,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
597 | u8 irq; | 597 | u8 irq; |
598 | int retval; | 598 | int retval; |
599 | 599 | ||
600 | debug ("%s - enter\n", __func__); | 600 | debug("%s - enter\n", __func__); |
601 | 601 | ||
602 | devfn = PCI_DEVFN(func->function, func->device); | 602 | devfn = PCI_DEVFN(func->function, func->device); |
603 | ibmphp_pci_bus->number = func->busno; | 603 | ibmphp_pci_bus->number = func->busno; |
@@ -606,43 +606,43 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
606 | * behind it | 606 | * behind it |
607 | */ | 607 | */ |
608 | 608 | ||
609 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, func->busno); | 609 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, func->busno); |
610 | 610 | ||
611 | /* _____________________For debugging purposes only __________________________ | 611 | /* _____________________For debugging purposes only __________________________ |
612 | pci_bus_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); | 612 | pci_bus_config_byte(ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); |
613 | debug ("primary # written into the bridge is %x\n", pri_number); | 613 | debug("primary # written into the bridge is %x\n", pri_number); |
614 | ___________________________________________________________________________*/ | 614 | ___________________________________________________________________________*/ |
615 | 615 | ||
616 | /* in EBDA, only get allocated 1 additional bus # per slot */ | 616 | /* in EBDA, only get allocated 1 additional bus # per slot */ |
617 | sec_number = find_sec_number (func->busno, slotno); | 617 | sec_number = find_sec_number(func->busno, slotno); |
618 | if (sec_number == 0xff) { | 618 | if (sec_number == 0xff) { |
619 | err ("cannot allocate secondary bus number for the bridged device\n"); | 619 | err("cannot allocate secondary bus number for the bridged device\n"); |
620 | return -EINVAL; | 620 | return -EINVAL; |
621 | } | 621 | } |
622 | 622 | ||
623 | debug ("after find_sec_number, the number we got is %x\n", sec_number); | 623 | debug("after find_sec_number, the number we got is %x\n", sec_number); |
624 | debug ("AFTER FIND_SEC_NUMBER, func->busno IS %x\n", func->busno); | 624 | debug("AFTER FIND_SEC_NUMBER, func->busno IS %x\n", func->busno); |
625 | 625 | ||
626 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, sec_number); | 626 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, sec_number); |
627 | 627 | ||
628 | /* __________________For debugging purposes only __________________________________ | 628 | /* __________________For debugging purposes only __________________________________ |
629 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 629 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
630 | debug ("sec_number after write/read is %x\n", sec_number); | 630 | debug("sec_number after write/read is %x\n", sec_number); |
631 | ________________________________________________________________________________*/ | 631 | ________________________________________________________________________________*/ |
632 | 632 | ||
633 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, sec_number); | 633 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, sec_number); |
634 | 634 | ||
635 | /* __________________For debugging purposes only ____________________________________ | 635 | /* __________________For debugging purposes only ____________________________________ |
636 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sec_number); | 636 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sec_number); |
637 | debug ("subordinate number after write/read is %x\n", sec_number); | 637 | debug("subordinate number after write/read is %x\n", sec_number); |
638 | __________________________________________________________________________________*/ | 638 | __________________________________________________________________________________*/ |
639 | 639 | ||
640 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); | 640 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); |
641 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); | 641 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); |
642 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SEC_LATENCY_TIMER, LATENCY); | 642 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_SEC_LATENCY_TIMER, LATENCY); |
643 | 643 | ||
644 | debug ("func->busno is %x\n", func->busno); | 644 | debug("func->busno is %x\n", func->busno); |
645 | debug ("sec_number after writing is %x\n", sec_number); | 645 | debug("sec_number after writing is %x\n", sec_number); |
646 | 646 | ||
647 | 647 | ||
648 | /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 648 | /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
@@ -652,29 +652,29 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
652 | 652 | ||
653 | /* First we need to allocate mem/io for the bridge itself in case it needs it */ | 653 | /* First we need to allocate mem/io for the bridge itself in case it needs it */ |
654 | for (count = 0; address[count]; count++) { /* for 2 BARs */ | 654 | for (count = 0; address[count]; count++) { /* for 2 BARs */ |
655 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); | 655 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); |
656 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 656 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
657 | 657 | ||
658 | if (!bar[count]) { | 658 | if (!bar[count]) { |
659 | /* This BAR is not implemented */ | 659 | /* This BAR is not implemented */ |
660 | debug ("so we come here then, eh?, count = %d\n", count); | 660 | debug("so we come here then, eh?, count = %d\n", count); |
661 | continue; | 661 | continue; |
662 | } | 662 | } |
663 | // tmp_bar = bar[count]; | 663 | // tmp_bar = bar[count]; |
664 | 664 | ||
665 | debug ("Bar %d wants %x\n", count, bar[count]); | 665 | debug("Bar %d wants %x\n", count, bar[count]); |
666 | 666 | ||
667 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { | 667 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { |
668 | /* This is IO */ | 668 | /* This is IO */ |
669 | len[count] = bar[count] & 0xFFFFFFFC; | 669 | len[count] = bar[count] & 0xFFFFFFFC; |
670 | len[count] = ~len[count] + 1; | 670 | len[count] = ~len[count] + 1; |
671 | 671 | ||
672 | debug ("len[count] in IO = %x\n", len[count]); | 672 | debug("len[count] in IO = %x\n", len[count]); |
673 | 673 | ||
674 | bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 674 | bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
675 | 675 | ||
676 | if (!bus_io[count]) { | 676 | if (!bus_io[count]) { |
677 | err ("out of system memory\n"); | 677 | err("out of system memory\n"); |
678 | retval = -ENOMEM; | 678 | retval = -ENOMEM; |
679 | goto error; | 679 | goto error; |
680 | } | 680 | } |
@@ -683,17 +683,17 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
683 | bus_io[count]->devfunc = PCI_DEVFN(func->device, | 683 | bus_io[count]->devfunc = PCI_DEVFN(func->device, |
684 | func->function); | 684 | func->function); |
685 | bus_io[count]->len = len[count]; | 685 | bus_io[count]->len = len[count]; |
686 | if (ibmphp_check_resource (bus_io[count], 0) == 0) { | 686 | if (ibmphp_check_resource(bus_io[count], 0) == 0) { |
687 | ibmphp_add_resource (bus_io[count]); | 687 | ibmphp_add_resource(bus_io[count]); |
688 | func->io[count] = bus_io[count]; | 688 | func->io[count] = bus_io[count]; |
689 | } else { | 689 | } else { |
690 | err ("cannot allocate requested io for bus %x, device %x, len %x\n", | 690 | err("cannot allocate requested io for bus %x, device %x, len %x\n", |
691 | func->busno, func->device, len[count]); | 691 | func->busno, func->device, len[count]); |
692 | kfree (bus_io[count]); | 692 | kfree(bus_io[count]); |
693 | return -EIO; | 693 | return -EIO; |
694 | } | 694 | } |
695 | 695 | ||
696 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->io[count]->start); | 696 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->io[count]->start); |
697 | 697 | ||
698 | } else { | 698 | } else { |
699 | /* This is Memory */ | 699 | /* This is Memory */ |
@@ -702,11 +702,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
702 | len[count] = bar[count] & 0xFFFFFFF0; | 702 | len[count] = bar[count] & 0xFFFFFFF0; |
703 | len[count] = ~len[count] + 1; | 703 | len[count] = ~len[count] + 1; |
704 | 704 | ||
705 | debug ("len[count] in PFMEM = %x\n", len[count]); | 705 | debug("len[count] in PFMEM = %x\n", len[count]); |
706 | 706 | ||
707 | bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 707 | bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
708 | if (!bus_pfmem[count]) { | 708 | if (!bus_pfmem[count]) { |
709 | err ("out of system memory\n"); | 709 | err("out of system memory\n"); |
710 | retval = -ENOMEM; | 710 | retval = -ENOMEM; |
711 | goto error; | 711 | goto error; |
712 | } | 712 | } |
@@ -716,13 +716,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
716 | func->function); | 716 | func->function); |
717 | bus_pfmem[count]->len = len[count]; | 717 | bus_pfmem[count]->len = len[count]; |
718 | bus_pfmem[count]->fromMem = 0; | 718 | bus_pfmem[count]->fromMem = 0; |
719 | if (ibmphp_check_resource (bus_pfmem[count], 0) == 0) { | 719 | if (ibmphp_check_resource(bus_pfmem[count], 0) == 0) { |
720 | ibmphp_add_resource (bus_pfmem[count]); | 720 | ibmphp_add_resource(bus_pfmem[count]); |
721 | func->pfmem[count] = bus_pfmem[count]; | 721 | func->pfmem[count] = bus_pfmem[count]; |
722 | } else { | 722 | } else { |
723 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); | 723 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
724 | if (!mem_tmp) { | 724 | if (!mem_tmp) { |
725 | err ("out of system memory\n"); | 725 | err("out of system memory\n"); |
726 | retval = -ENOMEM; | 726 | retval = -ENOMEM; |
727 | goto error; | 727 | goto error; |
728 | } | 728 | } |
@@ -730,28 +730,28 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
730 | mem_tmp->busno = bus_pfmem[count]->busno; | 730 | mem_tmp->busno = bus_pfmem[count]->busno; |
731 | mem_tmp->devfunc = bus_pfmem[count]->devfunc; | 731 | mem_tmp->devfunc = bus_pfmem[count]->devfunc; |
732 | mem_tmp->len = bus_pfmem[count]->len; | 732 | mem_tmp->len = bus_pfmem[count]->len; |
733 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { | 733 | if (ibmphp_check_resource(mem_tmp, 0) == 0) { |
734 | ibmphp_add_resource (mem_tmp); | 734 | ibmphp_add_resource(mem_tmp); |
735 | bus_pfmem[count]->fromMem = 1; | 735 | bus_pfmem[count]->fromMem = 1; |
736 | bus_pfmem[count]->rangeno = mem_tmp->rangeno; | 736 | bus_pfmem[count]->rangeno = mem_tmp->rangeno; |
737 | ibmphp_add_pfmem_from_mem (bus_pfmem[count]); | 737 | ibmphp_add_pfmem_from_mem(bus_pfmem[count]); |
738 | func->pfmem[count] = bus_pfmem[count]; | 738 | func->pfmem[count] = bus_pfmem[count]; |
739 | } else { | 739 | } else { |
740 | err ("cannot allocate requested pfmem for bus %x, device %x, len %x\n", | 740 | err("cannot allocate requested pfmem for bus %x, device %x, len %x\n", |
741 | func->busno, func->device, len[count]); | 741 | func->busno, func->device, len[count]); |
742 | kfree (mem_tmp); | 742 | kfree(mem_tmp); |
743 | kfree (bus_pfmem[count]); | 743 | kfree(bus_pfmem[count]); |
744 | return -EIO; | 744 | return -EIO; |
745 | } | 745 | } |
746 | } | 746 | } |
747 | 747 | ||
748 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); | 748 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); |
749 | 749 | ||
750 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { | 750 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { |
751 | /* takes up another dword */ | 751 | /* takes up another dword */ |
752 | count += 1; | 752 | count += 1; |
753 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ | 753 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ |
754 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); | 754 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000); |
755 | 755 | ||
756 | } | 756 | } |
757 | } else { | 757 | } else { |
@@ -759,11 +759,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
759 | len[count] = bar[count] & 0xFFFFFFF0; | 759 | len[count] = bar[count] & 0xFFFFFFF0; |
760 | len[count] = ~len[count] + 1; | 760 | len[count] = ~len[count] + 1; |
761 | 761 | ||
762 | debug ("len[count] in Memory is %x\n", len[count]); | 762 | debug("len[count] in Memory is %x\n", len[count]); |
763 | 763 | ||
764 | bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 764 | bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
765 | if (!bus_mem[count]) { | 765 | if (!bus_mem[count]) { |
766 | err ("out of system memory\n"); | 766 | err("out of system memory\n"); |
767 | retval = -ENOMEM; | 767 | retval = -ENOMEM; |
768 | goto error; | 768 | goto error; |
769 | } | 769 | } |
@@ -772,23 +772,23 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
772 | bus_mem[count]->devfunc = PCI_DEVFN(func->device, | 772 | bus_mem[count]->devfunc = PCI_DEVFN(func->device, |
773 | func->function); | 773 | func->function); |
774 | bus_mem[count]->len = len[count]; | 774 | bus_mem[count]->len = len[count]; |
775 | if (ibmphp_check_resource (bus_mem[count], 0) == 0) { | 775 | if (ibmphp_check_resource(bus_mem[count], 0) == 0) { |
776 | ibmphp_add_resource (bus_mem[count]); | 776 | ibmphp_add_resource(bus_mem[count]); |
777 | func->mem[count] = bus_mem[count]; | 777 | func->mem[count] = bus_mem[count]; |
778 | } else { | 778 | } else { |
779 | err ("cannot allocate requested mem for bus %x, device %x, len %x\n", | 779 | err("cannot allocate requested mem for bus %x, device %x, len %x\n", |
780 | func->busno, func->device, len[count]); | 780 | func->busno, func->device, len[count]); |
781 | kfree (bus_mem[count]); | 781 | kfree(bus_mem[count]); |
782 | return -EIO; | 782 | return -EIO; |
783 | } | 783 | } |
784 | 784 | ||
785 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); | 785 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); |
786 | 786 | ||
787 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { | 787 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { |
788 | /* takes up another dword */ | 788 | /* takes up another dword */ |
789 | count += 1; | 789 | count += 1; |
790 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ | 790 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ |
791 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); | 791 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000); |
792 | 792 | ||
793 | } | 793 | } |
794 | } | 794 | } |
@@ -796,45 +796,45 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
796 | } /* end of for */ | 796 | } /* end of for */ |
797 | 797 | ||
798 | /* Now need to see how much space the devices behind the bridge needed */ | 798 | /* Now need to see how much space the devices behind the bridge needed */ |
799 | amount_needed = scan_behind_bridge (func, sec_number); | 799 | amount_needed = scan_behind_bridge(func, sec_number); |
800 | if (amount_needed == NULL) | 800 | if (amount_needed == NULL) |
801 | return -ENOMEM; | 801 | return -ENOMEM; |
802 | 802 | ||
803 | ibmphp_pci_bus->number = func->busno; | 803 | ibmphp_pci_bus->number = func->busno; |
804 | debug ("after coming back from scan_behind_bridge\n"); | 804 | debug("after coming back from scan_behind_bridge\n"); |
805 | debug ("amount_needed->not_correct = %x\n", amount_needed->not_correct); | 805 | debug("amount_needed->not_correct = %x\n", amount_needed->not_correct); |
806 | debug ("amount_needed->io = %x\n", amount_needed->io); | 806 | debug("amount_needed->io = %x\n", amount_needed->io); |
807 | debug ("amount_needed->mem = %x\n", amount_needed->mem); | 807 | debug("amount_needed->mem = %x\n", amount_needed->mem); |
808 | debug ("amount_needed->pfmem = %x\n", amount_needed->pfmem); | 808 | debug("amount_needed->pfmem = %x\n", amount_needed->pfmem); |
809 | 809 | ||
810 | if (amount_needed->not_correct) { | 810 | if (amount_needed->not_correct) { |
811 | debug ("amount_needed is not correct\n"); | 811 | debug("amount_needed is not correct\n"); |
812 | for (count = 0; address[count]; count++) { | 812 | for (count = 0; address[count]; count++) { |
813 | /* for 2 BARs */ | 813 | /* for 2 BARs */ |
814 | if (bus_io[count]) { | 814 | if (bus_io[count]) { |
815 | ibmphp_remove_resource (bus_io[count]); | 815 | ibmphp_remove_resource(bus_io[count]); |
816 | func->io[count] = NULL; | 816 | func->io[count] = NULL; |
817 | } else if (bus_pfmem[count]) { | 817 | } else if (bus_pfmem[count]) { |
818 | ibmphp_remove_resource (bus_pfmem[count]); | 818 | ibmphp_remove_resource(bus_pfmem[count]); |
819 | func->pfmem[count] = NULL; | 819 | func->pfmem[count] = NULL; |
820 | } else if (bus_mem[count]) { | 820 | } else if (bus_mem[count]) { |
821 | ibmphp_remove_resource (bus_mem[count]); | 821 | ibmphp_remove_resource(bus_mem[count]); |
822 | func->mem[count] = NULL; | 822 | func->mem[count] = NULL; |
823 | } | 823 | } |
824 | } | 824 | } |
825 | kfree (amount_needed); | 825 | kfree(amount_needed); |
826 | return -ENODEV; | 826 | return -ENODEV; |
827 | } | 827 | } |
828 | 828 | ||
829 | if (!amount_needed->io) { | 829 | if (!amount_needed->io) { |
830 | debug ("it doesn't want IO?\n"); | 830 | debug("it doesn't want IO?\n"); |
831 | flag_io = 1; | 831 | flag_io = 1; |
832 | } else { | 832 | } else { |
833 | debug ("it wants %x IO behind the bridge\n", amount_needed->io); | 833 | debug("it wants %x IO behind the bridge\n", amount_needed->io); |
834 | io = kzalloc(sizeof(*io), GFP_KERNEL); | 834 | io = kzalloc(sizeof(*io), GFP_KERNEL); |
835 | 835 | ||
836 | if (!io) { | 836 | if (!io) { |
837 | err ("out of system memory\n"); | 837 | err("out of system memory\n"); |
838 | retval = -ENOMEM; | 838 | retval = -ENOMEM; |
839 | goto error; | 839 | goto error; |
840 | } | 840 | } |
@@ -842,21 +842,21 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
842 | io->busno = func->busno; | 842 | io->busno = func->busno; |
843 | io->devfunc = PCI_DEVFN(func->device, func->function); | 843 | io->devfunc = PCI_DEVFN(func->device, func->function); |
844 | io->len = amount_needed->io; | 844 | io->len = amount_needed->io; |
845 | if (ibmphp_check_resource (io, 1) == 0) { | 845 | if (ibmphp_check_resource(io, 1) == 0) { |
846 | debug ("were we able to add io\n"); | 846 | debug("were we able to add io\n"); |
847 | ibmphp_add_resource (io); | 847 | ibmphp_add_resource(io); |
848 | flag_io = 1; | 848 | flag_io = 1; |
849 | } | 849 | } |
850 | } | 850 | } |
851 | 851 | ||
852 | if (!amount_needed->mem) { | 852 | if (!amount_needed->mem) { |
853 | debug ("it doesn't want n.e.memory?\n"); | 853 | debug("it doesn't want n.e.memory?\n"); |
854 | flag_mem = 1; | 854 | flag_mem = 1; |
855 | } else { | 855 | } else { |
856 | debug ("it wants %x memory behind the bridge\n", amount_needed->mem); | 856 | debug("it wants %x memory behind the bridge\n", amount_needed->mem); |
857 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); | 857 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); |
858 | if (!mem) { | 858 | if (!mem) { |
859 | err ("out of system memory\n"); | 859 | err("out of system memory\n"); |
860 | retval = -ENOMEM; | 860 | retval = -ENOMEM; |
861 | goto error; | 861 | goto error; |
862 | } | 862 | } |
@@ -864,21 +864,21 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
864 | mem->busno = func->busno; | 864 | mem->busno = func->busno; |
865 | mem->devfunc = PCI_DEVFN(func->device, func->function); | 865 | mem->devfunc = PCI_DEVFN(func->device, func->function); |
866 | mem->len = amount_needed->mem; | 866 | mem->len = amount_needed->mem; |
867 | if (ibmphp_check_resource (mem, 1) == 0) { | 867 | if (ibmphp_check_resource(mem, 1) == 0) { |
868 | ibmphp_add_resource (mem); | 868 | ibmphp_add_resource(mem); |
869 | flag_mem = 1; | 869 | flag_mem = 1; |
870 | debug ("were we able to add mem\n"); | 870 | debug("were we able to add mem\n"); |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | if (!amount_needed->pfmem) { | 874 | if (!amount_needed->pfmem) { |
875 | debug ("it doesn't want n.e.pfmem mem?\n"); | 875 | debug("it doesn't want n.e.pfmem mem?\n"); |
876 | flag_pfmem = 1; | 876 | flag_pfmem = 1; |
877 | } else { | 877 | } else { |
878 | debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); | 878 | debug("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); |
879 | pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); | 879 | pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); |
880 | if (!pfmem) { | 880 | if (!pfmem) { |
881 | err ("out of system memory\n"); | 881 | err("out of system memory\n"); |
882 | retval = -ENOMEM; | 882 | retval = -ENOMEM; |
883 | goto error; | 883 | goto error; |
884 | } | 884 | } |
@@ -887,13 +887,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
887 | pfmem->devfunc = PCI_DEVFN(func->device, func->function); | 887 | pfmem->devfunc = PCI_DEVFN(func->device, func->function); |
888 | pfmem->len = amount_needed->pfmem; | 888 | pfmem->len = amount_needed->pfmem; |
889 | pfmem->fromMem = 0; | 889 | pfmem->fromMem = 0; |
890 | if (ibmphp_check_resource (pfmem, 1) == 0) { | 890 | if (ibmphp_check_resource(pfmem, 1) == 0) { |
891 | ibmphp_add_resource (pfmem); | 891 | ibmphp_add_resource(pfmem); |
892 | flag_pfmem = 1; | 892 | flag_pfmem = 1; |
893 | } else { | 893 | } else { |
894 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); | 894 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
895 | if (!mem_tmp) { | 895 | if (!mem_tmp) { |
896 | err ("out of system memory\n"); | 896 | err("out of system memory\n"); |
897 | retval = -ENOMEM; | 897 | retval = -ENOMEM; |
898 | goto error; | 898 | goto error; |
899 | } | 899 | } |
@@ -901,18 +901,18 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
901 | mem_tmp->busno = pfmem->busno; | 901 | mem_tmp->busno = pfmem->busno; |
902 | mem_tmp->devfunc = pfmem->devfunc; | 902 | mem_tmp->devfunc = pfmem->devfunc; |
903 | mem_tmp->len = pfmem->len; | 903 | mem_tmp->len = pfmem->len; |
904 | if (ibmphp_check_resource (mem_tmp, 1) == 0) { | 904 | if (ibmphp_check_resource(mem_tmp, 1) == 0) { |
905 | ibmphp_add_resource (mem_tmp); | 905 | ibmphp_add_resource(mem_tmp); |
906 | pfmem->fromMem = 1; | 906 | pfmem->fromMem = 1; |
907 | pfmem->rangeno = mem_tmp->rangeno; | 907 | pfmem->rangeno = mem_tmp->rangeno; |
908 | ibmphp_add_pfmem_from_mem (pfmem); | 908 | ibmphp_add_pfmem_from_mem(pfmem); |
909 | flag_pfmem = 1; | 909 | flag_pfmem = 1; |
910 | } | 910 | } |
911 | } | 911 | } |
912 | } | 912 | } |
913 | 913 | ||
914 | debug ("b4 if (flag_io && flag_mem && flag_pfmem)\n"); | 914 | debug("b4 if (flag_io && flag_mem && flag_pfmem)\n"); |
915 | debug ("flag_io = %x, flag_mem = %x, flag_pfmem = %x\n", flag_io, flag_mem, flag_pfmem); | 915 | debug("flag_io = %x, flag_mem = %x, flag_pfmem = %x\n", flag_io, flag_mem, flag_pfmem); |
916 | 916 | ||
917 | if (flag_io && flag_mem && flag_pfmem) { | 917 | if (flag_io && flag_mem && flag_pfmem) { |
918 | /* If on bootup, there was a bridged card in this slot, | 918 | /* If on bootup, there was a bridged card in this slot, |
@@ -920,127 +920,127 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
920 | * back again, there's no way for us to remove the bus | 920 | * back again, there's no way for us to remove the bus |
921 | * struct, so no need to kmalloc, can use existing node | 921 | * struct, so no need to kmalloc, can use existing node |
922 | */ | 922 | */ |
923 | bus = ibmphp_find_res_bus (sec_number); | 923 | bus = ibmphp_find_res_bus(sec_number); |
924 | if (!bus) { | 924 | if (!bus) { |
925 | bus = kzalloc(sizeof(*bus), GFP_KERNEL); | 925 | bus = kzalloc(sizeof(*bus), GFP_KERNEL); |
926 | if (!bus) { | 926 | if (!bus) { |
927 | err ("out of system memory\n"); | 927 | err("out of system memory\n"); |
928 | retval = -ENOMEM; | 928 | retval = -ENOMEM; |
929 | goto error; | 929 | goto error; |
930 | } | 930 | } |
931 | bus->busno = sec_number; | 931 | bus->busno = sec_number; |
932 | debug ("b4 adding new bus\n"); | 932 | debug("b4 adding new bus\n"); |
933 | rc = add_new_bus (bus, io, mem, pfmem, func->busno); | 933 | rc = add_new_bus(bus, io, mem, pfmem, func->busno); |
934 | } else if (!(bus->rangeIO) && !(bus->rangeMem) && !(bus->rangePFMem)) | 934 | } else if (!(bus->rangeIO) && !(bus->rangeMem) && !(bus->rangePFMem)) |
935 | rc = add_new_bus (bus, io, mem, pfmem, 0xFF); | 935 | rc = add_new_bus(bus, io, mem, pfmem, 0xFF); |
936 | else { | 936 | else { |
937 | err ("expected bus structure not empty?\n"); | 937 | err("expected bus structure not empty?\n"); |
938 | retval = -EIO; | 938 | retval = -EIO; |
939 | goto error; | 939 | goto error; |
940 | } | 940 | } |
941 | if (rc) { | 941 | if (rc) { |
942 | if (rc == -ENOMEM) { | 942 | if (rc == -ENOMEM) { |
943 | ibmphp_remove_bus (bus, func->busno); | 943 | ibmphp_remove_bus(bus, func->busno); |
944 | kfree (amount_needed); | 944 | kfree(amount_needed); |
945 | return rc; | 945 | return rc; |
946 | } | 946 | } |
947 | retval = rc; | 947 | retval = rc; |
948 | goto error; | 948 | goto error; |
949 | } | 949 | } |
950 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &io_base); | 950 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, &io_base); |
951 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &pfmem_base); | 951 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &pfmem_base); |
952 | 952 | ||
953 | if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { | 953 | if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { |
954 | debug ("io 32\n"); | 954 | debug("io 32\n"); |
955 | need_io_upper = 1; | 955 | need_io_upper = 1; |
956 | } | 956 | } |
957 | if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { | 957 | if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { |
958 | debug ("pfmem 64\n"); | 958 | debug("pfmem 64\n"); |
959 | need_pfmem_upper = 1; | 959 | need_pfmem_upper = 1; |
960 | } | 960 | } |
961 | 961 | ||
962 | if (bus->noIORanges) { | 962 | if (bus->noIORanges) { |
963 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00 | bus->rangeIO->start >> 8); | 963 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00 | bus->rangeIO->start >> 8); |
964 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00 | bus->rangeIO->end >> 8); | 964 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00 | bus->rangeIO->end >> 8); |
965 | 965 | ||
966 | /* _______________This is for debugging purposes only ____________________ | 966 | /* _______________This is for debugging purposes only ____________________ |
967 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &temp); | 967 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, &temp); |
968 | debug ("io_base = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); | 968 | debug("io_base = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); |
969 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &temp); | 969 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &temp); |
970 | debug ("io_limit = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); | 970 | debug("io_limit = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); |
971 | ________________________________________________________________________*/ | 971 | ________________________________________________________________________*/ |
972 | 972 | ||
973 | if (need_io_upper) { /* since can't support n.e.ways */ | 973 | if (need_io_upper) { /* since can't support n.e.ways */ |
974 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, 0x0000); | 974 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, 0x0000); |
975 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, 0x0000); | 975 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, 0x0000); |
976 | } | 976 | } |
977 | } else { | 977 | } else { |
978 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00); | 978 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00); |
979 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00); | 979 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00); |
980 | } | 980 | } |
981 | 981 | ||
982 | if (bus->noMemRanges) { | 982 | if (bus->noMemRanges) { |
983 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0x0000 | bus->rangeMem->start >> 16); | 983 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0x0000 | bus->rangeMem->start >> 16); |
984 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000 | bus->rangeMem->end >> 16); | 984 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000 | bus->rangeMem->end >> 16); |
985 | 985 | ||
986 | /* ____________________This is for debugging purposes only ________________________ | 986 | /* ____________________This is for debugging purposes only ________________________ |
987 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &temp); | 987 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &temp); |
988 | debug ("mem_base = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); | 988 | debug("mem_base = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); |
989 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &temp); | 989 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &temp); |
990 | debug ("mem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); | 990 | debug("mem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); |
991 | __________________________________________________________________________________*/ | 991 | __________________________________________________________________________________*/ |
992 | 992 | ||
993 | } else { | 993 | } else { |
994 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0xffff); | 994 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0xffff); |
995 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000); | 995 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000); |
996 | } | 996 | } |
997 | if (bus->noPFMemRanges) { | 997 | if (bus->noPFMemRanges) { |
998 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0x0000 | bus->rangePFMem->start >> 16); | 998 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0x0000 | bus->rangePFMem->start >> 16); |
999 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000 | bus->rangePFMem->end >> 16); | 999 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000 | bus->rangePFMem->end >> 16); |
1000 | 1000 | ||
1001 | /* __________________________This is for debugging purposes only _______________________ | 1001 | /* __________________________This is for debugging purposes only _______________________ |
1002 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &temp); | 1002 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &temp); |
1003 | debug ("pfmem_base = %x", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); | 1003 | debug("pfmem_base = %x", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); |
1004 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &temp); | 1004 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &temp); |
1005 | debug ("pfmem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); | 1005 | debug("pfmem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); |
1006 | ______________________________________________________________________________________*/ | 1006 | ______________________________________________________________________________________*/ |
1007 | 1007 | ||
1008 | if (need_pfmem_upper) { /* since can't support n.e.ways */ | 1008 | if (need_pfmem_upper) { /* since can't support n.e.ways */ |
1009 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, 0x00000000); | 1009 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, 0x00000000); |
1010 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, 0x00000000); | 1010 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, 0x00000000); |
1011 | } | 1011 | } |
1012 | } else { | 1012 | } else { |
1013 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0xffff); | 1013 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0xffff); |
1014 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000); | 1014 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000); |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | debug ("b4 writing control information\n"); | 1017 | debug("b4 writing control information\n"); |
1018 | 1018 | ||
1019 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); | 1019 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); |
1020 | if ((irq > 0x00) && (irq < 0x05)) | 1020 | if ((irq > 0x00) && (irq < 0x05)) |
1021 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); | 1021 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); |
1022 | /* | 1022 | /* |
1023 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, ctrl); | 1023 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, ctrl); |
1024 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_PARITY); | 1024 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_PARITY); |
1025 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_SERR); | 1025 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_SERR); |
1026 | */ | 1026 | */ |
1027 | 1027 | ||
1028 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); | 1028 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); |
1029 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, 0x07); | 1029 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, 0x07); |
1030 | for (i = 0; i < 32; i++) { | 1030 | for (i = 0; i < 32; i++) { |
1031 | if (amount_needed->devices[i]) { | 1031 | if (amount_needed->devices[i]) { |
1032 | debug ("device where devices[i] is 1 = %x\n", i); | 1032 | debug("device where devices[i] is 1 = %x\n", i); |
1033 | func->devices[i] = 1; | 1033 | func->devices[i] = 1; |
1034 | } | 1034 | } |
1035 | } | 1035 | } |
1036 | func->bus = 1; /* For unconfiguring, to indicate it's PPB */ | 1036 | func->bus = 1; /* For unconfiguring, to indicate it's PPB */ |
1037 | func_passed = &func; | 1037 | func_passed = &func; |
1038 | debug ("func->busno b4 returning is %x\n", func->busno); | 1038 | debug("func->busno b4 returning is %x\n", func->busno); |
1039 | debug ("func->busno b4 returning in the other structure is %x\n", (*func_passed)->busno); | 1039 | debug("func->busno b4 returning in the other structure is %x\n", (*func_passed)->busno); |
1040 | kfree (amount_needed); | 1040 | kfree(amount_needed); |
1041 | return 0; | 1041 | return 0; |
1042 | } else { | 1042 | } else { |
1043 | err ("Configuring bridge was unsuccessful...\n"); | 1043 | err("Configuring bridge was unsuccessful...\n"); |
1044 | mem_tmp = NULL; | 1044 | mem_tmp = NULL; |
1045 | retval = -EIO; | 1045 | retval = -EIO; |
1046 | goto error; | 1046 | goto error; |
@@ -1049,20 +1049,20 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
1049 | error: | 1049 | error: |
1050 | kfree(amount_needed); | 1050 | kfree(amount_needed); |
1051 | if (pfmem) | 1051 | if (pfmem) |
1052 | ibmphp_remove_resource (pfmem); | 1052 | ibmphp_remove_resource(pfmem); |
1053 | if (io) | 1053 | if (io) |
1054 | ibmphp_remove_resource (io); | 1054 | ibmphp_remove_resource(io); |
1055 | if (mem) | 1055 | if (mem) |
1056 | ibmphp_remove_resource (mem); | 1056 | ibmphp_remove_resource(mem); |
1057 | for (i = 0; i < 2; i++) { /* for 2 BARs */ | 1057 | for (i = 0; i < 2; i++) { /* for 2 BARs */ |
1058 | if (bus_io[i]) { | 1058 | if (bus_io[i]) { |
1059 | ibmphp_remove_resource (bus_io[i]); | 1059 | ibmphp_remove_resource(bus_io[i]); |
1060 | func->io[i] = NULL; | 1060 | func->io[i] = NULL; |
1061 | } else if (bus_pfmem[i]) { | 1061 | } else if (bus_pfmem[i]) { |
1062 | ibmphp_remove_resource (bus_pfmem[i]); | 1062 | ibmphp_remove_resource(bus_pfmem[i]); |
1063 | func->pfmem[i] = NULL; | 1063 | func->pfmem[i] = NULL; |
1064 | } else if (bus_mem[i]) { | 1064 | } else if (bus_mem[i]) { |
1065 | ibmphp_remove_resource (bus_mem[i]); | 1065 | ibmphp_remove_resource(bus_mem[i]); |
1066 | func->mem[i] = NULL; | 1066 | func->mem[i] = NULL; |
1067 | } | 1067 | } |
1068 | } | 1068 | } |
@@ -1075,7 +1075,7 @@ error: | |||
1075 | * Input: bridge function | 1075 | * Input: bridge function |
1076 | * Output: amount of resources needed | 1076 | * Output: amount of resources needed |
1077 | *****************************************************************************/ | 1077 | *****************************************************************************/ |
1078 | static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno) | 1078 | static struct res_needed *scan_behind_bridge(struct pci_func *func, u8 busno) |
1079 | { | 1079 | { |
1080 | int count, len[6]; | 1080 | int count, len[6]; |
1081 | u16 vendor_id; | 1081 | u16 vendor_id; |
@@ -1102,36 +1102,36 @@ static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno) | |||
1102 | 1102 | ||
1103 | ibmphp_pci_bus->number = busno; | 1103 | ibmphp_pci_bus->number = busno; |
1104 | 1104 | ||
1105 | debug ("the bus_no behind the bridge is %x\n", busno); | 1105 | debug("the bus_no behind the bridge is %x\n", busno); |
1106 | debug ("scanning devices behind the bridge...\n"); | 1106 | debug("scanning devices behind the bridge...\n"); |
1107 | for (device = 0; device < 32; device++) { | 1107 | for (device = 0; device < 32; device++) { |
1108 | amount->devices[device] = 0; | 1108 | amount->devices[device] = 0; |
1109 | for (function = 0; function < 8; function++) { | 1109 | for (function = 0; function < 8; function++) { |
1110 | devfn = PCI_DEVFN(device, function); | 1110 | devfn = PCI_DEVFN(device, function); |
1111 | 1111 | ||
1112 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); | 1112 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); |
1113 | 1113 | ||
1114 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { | 1114 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { |
1115 | /* found correct device!!! */ | 1115 | /* found correct device!!! */ |
1116 | howmany++; | 1116 | howmany++; |
1117 | 1117 | ||
1118 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); | 1118 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); |
1119 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); | 1119 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); |
1120 | 1120 | ||
1121 | debug ("hdr_type behind the bridge is %x\n", hdr_type); | 1121 | debug("hdr_type behind the bridge is %x\n", hdr_type); |
1122 | if (hdr_type & PCI_HEADER_TYPE_BRIDGE) { | 1122 | if (hdr_type & PCI_HEADER_TYPE_BRIDGE) { |
1123 | err ("embedded bridges not supported for hot-plugging.\n"); | 1123 | err("embedded bridges not supported for hot-plugging.\n"); |
1124 | amount->not_correct = 1; | 1124 | amount->not_correct = 1; |
1125 | return amount; | 1125 | return amount; |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ | 1128 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ |
1129 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { | 1129 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { |
1130 | err ("The device %x is VGA compatible and as is not supported for hot plugging. Please choose another device.\n", device); | 1130 | err("The device %x is VGA compatible and as is not supported for hot plugging. Please choose another device.\n", device); |
1131 | amount->not_correct = 1; | 1131 | amount->not_correct = 1; |
1132 | return amount; | 1132 | return amount; |
1133 | } else if (class == PCI_CLASS_DISPLAY_VGA) { | 1133 | } else if (class == PCI_CLASS_DISPLAY_VGA) { |
1134 | err ("The device %x is not supported for hot plugging. Please choose another device.\n", device); | 1134 | err("The device %x is not supported for hot plugging. Please choose another device.\n", device); |
1135 | amount->not_correct = 1; | 1135 | amount->not_correct = 1; |
1136 | return amount; | 1136 | return amount; |
1137 | } | 1137 | } |
@@ -1141,23 +1141,23 @@ static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno) | |||
1141 | for (count = 0; address[count]; count++) { | 1141 | for (count = 0; address[count]; count++) { |
1142 | /* for 6 BARs */ | 1142 | /* for 6 BARs */ |
1143 | /* | 1143 | /* |
1144 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, address[count], &tmp); | 1144 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, address[count], &tmp); |
1145 | if (tmp & 0x01) // IO | 1145 | if (tmp & 0x01) // IO |
1146 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFD); | 1146 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFD); |
1147 | else // MEMORY | 1147 | else // MEMORY |
1148 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); | 1148 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); |
1149 | */ | 1149 | */ |
1150 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); | 1150 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); |
1151 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 1151 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
1152 | 1152 | ||
1153 | debug ("what is bar[count]? %x, count = %d\n", bar[count], count); | 1153 | debug("what is bar[count]? %x, count = %d\n", bar[count], count); |
1154 | 1154 | ||
1155 | if (!bar[count]) /* This BAR is not implemented */ | 1155 | if (!bar[count]) /* This BAR is not implemented */ |
1156 | continue; | 1156 | continue; |
1157 | 1157 | ||
1158 | //tmp_bar = bar[count]; | 1158 | //tmp_bar = bar[count]; |
1159 | 1159 | ||
1160 | debug ("count %d device %x function %x wants %x resources\n", count, device, function, bar[count]); | 1160 | debug("count %d device %x function %x wants %x resources\n", count, device, function, bar[count]); |
1161 | 1161 | ||
1162 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { | 1162 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { |
1163 | /* This is IO */ | 1163 | /* This is IO */ |
@@ -1211,7 +1211,7 @@ static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno) | |||
1211 | * Change: we also call these functions even if we configured the card ourselves (i.e., not | 1211 | * Change: we also call these functions even if we configured the card ourselves (i.e., not |
1212 | * the bootup case), since it should work same way | 1212 | * the bootup case), since it should work same way |
1213 | */ | 1213 | */ |
1214 | static int unconfigure_boot_device (u8 busno, u8 device, u8 function) | 1214 | static int unconfigure_boot_device(u8 busno, u8 device, u8 function) |
1215 | { | 1215 | { |
1216 | u32 start_address; | 1216 | u32 start_address; |
1217 | u32 address[] = { | 1217 | u32 address[] = { |
@@ -1234,30 +1234,30 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function) | |||
1234 | u32 tmp_address; | 1234 | u32 tmp_address; |
1235 | unsigned int devfn; | 1235 | unsigned int devfn; |
1236 | 1236 | ||
1237 | debug ("%s - enter\n", __func__); | 1237 | debug("%s - enter\n", __func__); |
1238 | 1238 | ||
1239 | bus = ibmphp_find_res_bus (busno); | 1239 | bus = ibmphp_find_res_bus(busno); |
1240 | if (!bus) { | 1240 | if (!bus) { |
1241 | debug ("cannot find corresponding bus.\n"); | 1241 | debug("cannot find corresponding bus.\n"); |
1242 | return -EINVAL; | 1242 | return -EINVAL; |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | devfn = PCI_DEVFN(device, function); | 1245 | devfn = PCI_DEVFN(device, function); |
1246 | ibmphp_pci_bus->number = busno; | 1246 | ibmphp_pci_bus->number = busno; |
1247 | for (count = 0; address[count]; count++) { /* for 6 BARs */ | 1247 | for (count = 0; address[count]; count++) { /* for 6 BARs */ |
1248 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &start_address); | 1248 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &start_address); |
1249 | 1249 | ||
1250 | /* We can do this here, b/c by that time the device driver of the card has been stopped */ | 1250 | /* We can do this here, b/c by that time the device driver of the card has been stopped */ |
1251 | 1251 | ||
1252 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); | 1252 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); |
1253 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &size); | 1253 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &size); |
1254 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], start_address); | 1254 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], start_address); |
1255 | 1255 | ||
1256 | debug ("start_address is %x\n", start_address); | 1256 | debug("start_address is %x\n", start_address); |
1257 | debug ("busno, device, function %x %x %x\n", busno, device, function); | 1257 | debug("busno, device, function %x %x %x\n", busno, device, function); |
1258 | if (!size) { | 1258 | if (!size) { |
1259 | /* This BAR is not implemented */ | 1259 | /* This BAR is not implemented */ |
1260 | debug ("is this bar no implemented?, count = %d\n", count); | 1260 | debug("is this bar no implemented?, count = %d\n", count); |
1261 | continue; | 1261 | continue; |
1262 | } | 1262 | } |
1263 | tmp_address = start_address; | 1263 | tmp_address = start_address; |
@@ -1267,24 +1267,24 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function) | |||
1267 | size = size & 0xFFFFFFFC; | 1267 | size = size & 0xFFFFFFFC; |
1268 | size = ~size + 1; | 1268 | size = ~size + 1; |
1269 | end_address = start_address + size - 1; | 1269 | end_address = start_address + size - 1; |
1270 | if (ibmphp_find_resource (bus, start_address, &io, IO) < 0) { | 1270 | if (ibmphp_find_resource(bus, start_address, &io, IO) < 0) { |
1271 | err ("cannot find corresponding IO resource to remove\n"); | 1271 | err("cannot find corresponding IO resource to remove\n"); |
1272 | return -EIO; | 1272 | return -EIO; |
1273 | } | 1273 | } |
1274 | debug ("io->start = %x\n", io->start); | 1274 | debug("io->start = %x\n", io->start); |
1275 | temp_end = io->end; | 1275 | temp_end = io->end; |
1276 | start_address = io->end + 1; | 1276 | start_address = io->end + 1; |
1277 | ibmphp_remove_resource (io); | 1277 | ibmphp_remove_resource(io); |
1278 | /* This is needed b/c of the old I/O restrictions in the BIOS */ | 1278 | /* This is needed b/c of the old I/O restrictions in the BIOS */ |
1279 | while (temp_end < end_address) { | 1279 | while (temp_end < end_address) { |
1280 | if (ibmphp_find_resource (bus, start_address, &io, IO) < 0) { | 1280 | if (ibmphp_find_resource(bus, start_address, &io, IO) < 0) { |
1281 | err ("cannot find corresponding IO resource to remove\n"); | 1281 | err("cannot find corresponding IO resource to remove\n"); |
1282 | return -EIO; | 1282 | return -EIO; |
1283 | } | 1283 | } |
1284 | debug ("io->start = %x\n", io->start); | 1284 | debug("io->start = %x\n", io->start); |
1285 | temp_end = io->end; | 1285 | temp_end = io->end; |
1286 | start_address = io->end + 1; | 1286 | start_address = io->end + 1; |
1287 | ibmphp_remove_resource (io); | 1287 | ibmphp_remove_resource(io); |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ | 1290 | /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ |
@@ -1292,29 +1292,29 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function) | |||
1292 | /* This is Memory */ | 1292 | /* This is Memory */ |
1293 | if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { | 1293 | if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { |
1294 | /* pfmem */ | 1294 | /* pfmem */ |
1295 | debug ("start address of pfmem is %x\n", start_address); | 1295 | debug("start address of pfmem is %x\n", start_address); |
1296 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; | 1296 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; |
1297 | 1297 | ||
1298 | if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { | 1298 | if (ibmphp_find_resource(bus, start_address, &pfmem, PFMEM) < 0) { |
1299 | err ("cannot find corresponding PFMEM resource to remove\n"); | 1299 | err("cannot find corresponding PFMEM resource to remove\n"); |
1300 | return -EIO; | 1300 | return -EIO; |
1301 | } | 1301 | } |
1302 | if (pfmem) { | 1302 | if (pfmem) { |
1303 | debug ("pfmem->start = %x\n", pfmem->start); | 1303 | debug("pfmem->start = %x\n", pfmem->start); |
1304 | 1304 | ||
1305 | ibmphp_remove_resource(pfmem); | 1305 | ibmphp_remove_resource(pfmem); |
1306 | } | 1306 | } |
1307 | } else { | 1307 | } else { |
1308 | /* regular memory */ | 1308 | /* regular memory */ |
1309 | debug ("start address of mem is %x\n", start_address); | 1309 | debug("start address of mem is %x\n", start_address); |
1310 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; | 1310 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; |
1311 | 1311 | ||
1312 | if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { | 1312 | if (ibmphp_find_resource(bus, start_address, &mem, MEM) < 0) { |
1313 | err ("cannot find corresponding MEM resource to remove\n"); | 1313 | err("cannot find corresponding MEM resource to remove\n"); |
1314 | return -EIO; | 1314 | return -EIO; |
1315 | } | 1315 | } |
1316 | if (mem) { | 1316 | if (mem) { |
1317 | debug ("mem->start = %x\n", mem->start); | 1317 | debug("mem->start = %x\n", mem->start); |
1318 | 1318 | ||
1319 | ibmphp_remove_resource(mem); | 1319 | ibmphp_remove_resource(mem); |
1320 | } | 1320 | } |
@@ -1329,7 +1329,7 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function) | |||
1329 | return 0; | 1329 | return 0; |
1330 | } | 1330 | } |
1331 | 1331 | ||
1332 | static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) | 1332 | static int unconfigure_boot_bridge(u8 busno, u8 device, u8 function) |
1333 | { | 1333 | { |
1334 | int count; | 1334 | int count; |
1335 | int bus_no, pri_no, sub_no, sec_no = 0; | 1335 | int bus_no, pri_no, sub_no, sec_no = 0; |
@@ -1349,40 +1349,40 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) | |||
1349 | devfn = PCI_DEVFN(device, function); | 1349 | devfn = PCI_DEVFN(device, function); |
1350 | ibmphp_pci_bus->number = busno; | 1350 | ibmphp_pci_bus->number = busno; |
1351 | bus_no = (int) busno; | 1351 | bus_no = (int) busno; |
1352 | debug ("busno is %x\n", busno); | 1352 | debug("busno is %x\n", busno); |
1353 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); | 1353 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); |
1354 | debug ("%s - busno = %x, primary_number = %x\n", __func__, busno, pri_number); | 1354 | debug("%s - busno = %x, primary_number = %x\n", __func__, busno, pri_number); |
1355 | 1355 | ||
1356 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 1356 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
1357 | debug ("sec_number is %x\n", sec_number); | 1357 | debug("sec_number is %x\n", sec_number); |
1358 | sec_no = (int) sec_number; | 1358 | sec_no = (int) sec_number; |
1359 | pri_no = (int) pri_number; | 1359 | pri_no = (int) pri_number; |
1360 | if (pri_no != bus_no) { | 1360 | if (pri_no != bus_no) { |
1361 | err ("primary numbers in our structures and pci config space don't match.\n"); | 1361 | err("primary numbers in our structures and pci config space don't match.\n"); |
1362 | return -EINVAL; | 1362 | return -EINVAL; |
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sub_number); | 1365 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sub_number); |
1366 | sub_no = (int) sub_number; | 1366 | sub_no = (int) sub_number; |
1367 | debug ("sub_no is %d, sec_no is %d\n", sub_no, sec_no); | 1367 | debug("sub_no is %d, sec_no is %d\n", sub_no, sec_no); |
1368 | if (sec_no != sub_number) { | 1368 | if (sec_no != sub_number) { |
1369 | err ("there're more buses behind this bridge. Hot removal is not supported. Please choose another card\n"); | 1369 | err("there're more buses behind this bridge. Hot removal is not supported. Please choose another card\n"); |
1370 | return -ENODEV; | 1370 | return -ENODEV; |
1371 | } | 1371 | } |
1372 | 1372 | ||
1373 | bus = ibmphp_find_res_bus (sec_number); | 1373 | bus = ibmphp_find_res_bus(sec_number); |
1374 | if (!bus) { | 1374 | if (!bus) { |
1375 | err ("cannot find Bus structure for the bridged device\n"); | 1375 | err("cannot find Bus structure for the bridged device\n"); |
1376 | return -EINVAL; | 1376 | return -EINVAL; |
1377 | } | 1377 | } |
1378 | debug("bus->busno is %x\n", bus->busno); | 1378 | debug("bus->busno is %x\n", bus->busno); |
1379 | debug("sec_number is %x\n", sec_number); | 1379 | debug("sec_number is %x\n", sec_number); |
1380 | 1380 | ||
1381 | ibmphp_remove_bus (bus, busno); | 1381 | ibmphp_remove_bus(bus, busno); |
1382 | 1382 | ||
1383 | for (count = 0; address[count]; count++) { | 1383 | for (count = 0; address[count]; count++) { |
1384 | /* for 2 BARs */ | 1384 | /* for 2 BARs */ |
1385 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &start_address); | 1385 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &start_address); |
1386 | 1386 | ||
1387 | if (!start_address) { | 1387 | if (!start_address) { |
1388 | /* This BAR is not implemented */ | 1388 | /* This BAR is not implemented */ |
@@ -1394,14 +1394,14 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) | |||
1394 | if (start_address & PCI_BASE_ADDRESS_SPACE_IO) { | 1394 | if (start_address & PCI_BASE_ADDRESS_SPACE_IO) { |
1395 | /* This is IO */ | 1395 | /* This is IO */ |
1396 | start_address &= PCI_BASE_ADDRESS_IO_MASK; | 1396 | start_address &= PCI_BASE_ADDRESS_IO_MASK; |
1397 | if (ibmphp_find_resource (bus, start_address, &io, IO) < 0) { | 1397 | if (ibmphp_find_resource(bus, start_address, &io, IO) < 0) { |
1398 | err ("cannot find corresponding IO resource to remove\n"); | 1398 | err("cannot find corresponding IO resource to remove\n"); |
1399 | return -EIO; | 1399 | return -EIO; |
1400 | } | 1400 | } |
1401 | if (io) | 1401 | if (io) |
1402 | debug ("io->start = %x\n", io->start); | 1402 | debug("io->start = %x\n", io->start); |
1403 | 1403 | ||
1404 | ibmphp_remove_resource (io); | 1404 | ibmphp_remove_resource(io); |
1405 | 1405 | ||
1406 | /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ | 1406 | /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ |
1407 | } else { | 1407 | } else { |
@@ -1409,24 +1409,24 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) | |||
1409 | if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { | 1409 | if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { |
1410 | /* pfmem */ | 1410 | /* pfmem */ |
1411 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; | 1411 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; |
1412 | if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { | 1412 | if (ibmphp_find_resource(bus, start_address, &pfmem, PFMEM) < 0) { |
1413 | err ("cannot find corresponding PFMEM resource to remove\n"); | 1413 | err("cannot find corresponding PFMEM resource to remove\n"); |
1414 | return -EINVAL; | 1414 | return -EINVAL; |
1415 | } | 1415 | } |
1416 | if (pfmem) { | 1416 | if (pfmem) { |
1417 | debug ("pfmem->start = %x\n", pfmem->start); | 1417 | debug("pfmem->start = %x\n", pfmem->start); |
1418 | 1418 | ||
1419 | ibmphp_remove_resource(pfmem); | 1419 | ibmphp_remove_resource(pfmem); |
1420 | } | 1420 | } |
1421 | } else { | 1421 | } else { |
1422 | /* regular memory */ | 1422 | /* regular memory */ |
1423 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; | 1423 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; |
1424 | if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { | 1424 | if (ibmphp_find_resource(bus, start_address, &mem, MEM) < 0) { |
1425 | err ("cannot find corresponding MEM resource to remove\n"); | 1425 | err("cannot find corresponding MEM resource to remove\n"); |
1426 | return -EINVAL; | 1426 | return -EINVAL; |
1427 | } | 1427 | } |
1428 | if (mem) { | 1428 | if (mem) { |
1429 | debug ("mem->start = %x\n", mem->start); | 1429 | debug("mem->start = %x\n", mem->start); |
1430 | 1430 | ||
1431 | ibmphp_remove_resource(mem); | 1431 | ibmphp_remove_resource(mem); |
1432 | } | 1432 | } |
@@ -1437,11 +1437,11 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) | |||
1437 | } | 1437 | } |
1438 | } /* end of mem */ | 1438 | } /* end of mem */ |
1439 | } /* end of for */ | 1439 | } /* end of for */ |
1440 | debug ("%s - exiting, returning success\n", __func__); | 1440 | debug("%s - exiting, returning success\n", __func__); |
1441 | return 0; | 1441 | return 0; |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | static int unconfigure_boot_card (struct slot *slot_cur) | 1444 | static int unconfigure_boot_card(struct slot *slot_cur) |
1445 | { | 1445 | { |
1446 | u16 vendor_id; | 1446 | u16 vendor_id; |
1447 | u32 class; | 1447 | u32 class; |
@@ -1453,57 +1453,57 @@ static int unconfigure_boot_card (struct slot *slot_cur) | |||
1453 | unsigned int devfn; | 1453 | unsigned int devfn; |
1454 | u8 valid_device = 0x00; /* To see if we are ever able to find valid device and read it */ | 1454 | u8 valid_device = 0x00; /* To see if we are ever able to find valid device and read it */ |
1455 | 1455 | ||
1456 | debug ("%s - enter\n", __func__); | 1456 | debug("%s - enter\n", __func__); |
1457 | 1457 | ||
1458 | device = slot_cur->device; | 1458 | device = slot_cur->device; |
1459 | busno = slot_cur->bus; | 1459 | busno = slot_cur->bus; |
1460 | 1460 | ||
1461 | debug ("b4 for loop, device is %x\n", device); | 1461 | debug("b4 for loop, device is %x\n", device); |
1462 | /* For every function on the card */ | 1462 | /* For every function on the card */ |
1463 | for (function = 0x0; function < 0x08; function++) { | 1463 | for (function = 0x0; function < 0x08; function++) { |
1464 | devfn = PCI_DEVFN(device, function); | 1464 | devfn = PCI_DEVFN(device, function); |
1465 | ibmphp_pci_bus->number = busno; | 1465 | ibmphp_pci_bus->number = busno; |
1466 | 1466 | ||
1467 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); | 1467 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); |
1468 | 1468 | ||
1469 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { | 1469 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { |
1470 | /* found correct device!!! */ | 1470 | /* found correct device!!! */ |
1471 | ++valid_device; | 1471 | ++valid_device; |
1472 | 1472 | ||
1473 | debug ("%s - found correct device\n", __func__); | 1473 | debug("%s - found correct device\n", __func__); |
1474 | 1474 | ||
1475 | /* header: x x x x x x x x | 1475 | /* header: x x x x x x x x |
1476 | * | |___________|=> 1=PPB bridge, 0=normal device, 2=CardBus Bridge | 1476 | * | |___________|=> 1=PPB bridge, 0=normal device, 2=CardBus Bridge |
1477 | * |_=> 0 = single function device, 1 = multi-function device | 1477 | * |_=> 0 = single function device, 1 = multi-function device |
1478 | */ | 1478 | */ |
1479 | 1479 | ||
1480 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); | 1480 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); |
1481 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); | 1481 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); |
1482 | 1482 | ||
1483 | debug ("hdr_type %x, class %x\n", hdr_type, class); | 1483 | debug("hdr_type %x, class %x\n", hdr_type, class); |
1484 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ | 1484 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ |
1485 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { | 1485 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { |
1486 | err ("The device %x function %x is VGA compatible and is not supported for hot removing. Please choose another device.\n", device, function); | 1486 | err("The device %x function %x is VGA compatible and is not supported for hot removing. Please choose another device.\n", device, function); |
1487 | return -ENODEV; | 1487 | return -ENODEV; |
1488 | } else if (class == PCI_CLASS_DISPLAY_VGA) { | 1488 | } else if (class == PCI_CLASS_DISPLAY_VGA) { |
1489 | err ("The device %x function %x is not supported for hot removing. Please choose another device.\n", device, function); | 1489 | err("The device %x function %x is not supported for hot removing. Please choose another device.\n", device, function); |
1490 | return -ENODEV; | 1490 | return -ENODEV; |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | switch (hdr_type) { | 1493 | switch (hdr_type) { |
1494 | case PCI_HEADER_TYPE_NORMAL: | 1494 | case PCI_HEADER_TYPE_NORMAL: |
1495 | rc = unconfigure_boot_device (busno, device, function); | 1495 | rc = unconfigure_boot_device(busno, device, function); |
1496 | if (rc) { | 1496 | if (rc) { |
1497 | err ("was not able to unconfigure device %x func %x on bus %x. bailing out...\n", | 1497 | err("was not able to unconfigure device %x func %x on bus %x. bailing out...\n", |
1498 | device, function, busno); | 1498 | device, function, busno); |
1499 | return rc; | 1499 | return rc; |
1500 | } | 1500 | } |
1501 | function = 0x8; | 1501 | function = 0x8; |
1502 | break; | 1502 | break; |
1503 | case PCI_HEADER_TYPE_MULTIDEVICE: | 1503 | case PCI_HEADER_TYPE_MULTIDEVICE: |
1504 | rc = unconfigure_boot_device (busno, device, function); | 1504 | rc = unconfigure_boot_device(busno, device, function); |
1505 | if (rc) { | 1505 | if (rc) { |
1506 | err ("was not able to unconfigure device %x func %x on bus %x. bailing out...\n", | 1506 | err("was not able to unconfigure device %x func %x on bus %x. bailing out...\n", |
1507 | device, function, busno); | 1507 | device, function, busno); |
1508 | return rc; | 1508 | return rc; |
1509 | } | 1509 | } |
@@ -1511,12 +1511,12 @@ static int unconfigure_boot_card (struct slot *slot_cur) | |||
1511 | case PCI_HEADER_TYPE_BRIDGE: | 1511 | case PCI_HEADER_TYPE_BRIDGE: |
1512 | class >>= 8; | 1512 | class >>= 8; |
1513 | if (class != PCI_CLASS_BRIDGE_PCI) { | 1513 | if (class != PCI_CLASS_BRIDGE_PCI) { |
1514 | err ("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function); | 1514 | err("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function); |
1515 | return -ENODEV; | 1515 | return -ENODEV; |
1516 | } | 1516 | } |
1517 | rc = unconfigure_boot_bridge (busno, device, function); | 1517 | rc = unconfigure_boot_bridge(busno, device, function); |
1518 | if (rc != 0) { | 1518 | if (rc != 0) { |
1519 | err ("was not able to hot-remove PPB properly.\n"); | 1519 | err("was not able to hot-remove PPB properly.\n"); |
1520 | return rc; | 1520 | return rc; |
1521 | } | 1521 | } |
1522 | 1522 | ||
@@ -1525,17 +1525,17 @@ static int unconfigure_boot_card (struct slot *slot_cur) | |||
1525 | case PCI_HEADER_TYPE_MULTIBRIDGE: | 1525 | case PCI_HEADER_TYPE_MULTIBRIDGE: |
1526 | class >>= 8; | 1526 | class >>= 8; |
1527 | if (class != PCI_CLASS_BRIDGE_PCI) { | 1527 | if (class != PCI_CLASS_BRIDGE_PCI) { |
1528 | err ("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function); | 1528 | err("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function); |
1529 | return -ENODEV; | 1529 | return -ENODEV; |
1530 | } | 1530 | } |
1531 | rc = unconfigure_boot_bridge (busno, device, function); | 1531 | rc = unconfigure_boot_bridge(busno, device, function); |
1532 | if (rc != 0) { | 1532 | if (rc != 0) { |
1533 | err ("was not able to hot-remove PPB properly.\n"); | 1533 | err("was not able to hot-remove PPB properly.\n"); |
1534 | return rc; | 1534 | return rc; |
1535 | } | 1535 | } |
1536 | break; | 1536 | break; |
1537 | default: | 1537 | default: |
1538 | err ("MAJOR PROBLEM!!!! Cannot read device's header\n"); | 1538 | err("MAJOR PROBLEM!!!! Cannot read device's header\n"); |
1539 | return -1; | 1539 | return -1; |
1540 | break; | 1540 | break; |
1541 | } /* end of switch */ | 1541 | } /* end of switch */ |
@@ -1543,7 +1543,7 @@ static int unconfigure_boot_card (struct slot *slot_cur) | |||
1543 | } /* end of for */ | 1543 | } /* end of for */ |
1544 | 1544 | ||
1545 | if (!valid_device) { | 1545 | if (!valid_device) { |
1546 | err ("Could not find device to unconfigure. Or could not read the card.\n"); | 1546 | err("Could not find device to unconfigure. Or could not read the card.\n"); |
1547 | return -1; | 1547 | return -1; |
1548 | } | 1548 | } |
1549 | return 0; | 1549 | return 0; |
@@ -1558,7 +1558,7 @@ static int unconfigure_boot_card (struct slot *slot_cur) | |||
1558 | * !!!!!!!!!!!!!!!!!!!!!!!!!FOR BUSES!!!!!!!!!!!! | 1558 | * !!!!!!!!!!!!!!!!!!!!!!!!!FOR BUSES!!!!!!!!!!!! |
1559 | * Returns: 0, -1, -ENODEV | 1559 | * Returns: 0, -1, -ENODEV |
1560 | */ | 1560 | */ |
1561 | int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end) | 1561 | int ibmphp_unconfigure_card(struct slot **slot_cur, int the_end) |
1562 | { | 1562 | { |
1563 | int i; | 1563 | int i; |
1564 | int count; | 1564 | int count; |
@@ -1567,11 +1567,11 @@ int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end) | |||
1567 | struct pci_func *cur_func = NULL; | 1567 | struct pci_func *cur_func = NULL; |
1568 | struct pci_func *temp_func; | 1568 | struct pci_func *temp_func; |
1569 | 1569 | ||
1570 | debug ("%s - enter\n", __func__); | 1570 | debug("%s - enter\n", __func__); |
1571 | 1571 | ||
1572 | if (!the_end) { | 1572 | if (!the_end) { |
1573 | /* Need to unconfigure the card */ | 1573 | /* Need to unconfigure the card */ |
1574 | rc = unconfigure_boot_card (sl); | 1574 | rc = unconfigure_boot_card(sl); |
1575 | if ((rc == -ENODEV) || (rc == -EIO) || (rc == -EINVAL)) { | 1575 | if ((rc == -ENODEV) || (rc == -EIO) || (rc == -EINVAL)) { |
1576 | /* In all other cases, will still need to get rid of func structure if it exists */ | 1576 | /* In all other cases, will still need to get rid of func structure if it exists */ |
1577 | return rc; | 1577 | return rc; |
@@ -1591,34 +1591,34 @@ int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end) | |||
1591 | 1591 | ||
1592 | for (i = 0; i < count; i++) { | 1592 | for (i = 0; i < count; i++) { |
1593 | if (cur_func->io[i]) { | 1593 | if (cur_func->io[i]) { |
1594 | debug ("io[%d] exists\n", i); | 1594 | debug("io[%d] exists\n", i); |
1595 | if (the_end > 0) | 1595 | if (the_end > 0) |
1596 | ibmphp_remove_resource (cur_func->io[i]); | 1596 | ibmphp_remove_resource(cur_func->io[i]); |
1597 | cur_func->io[i] = NULL; | 1597 | cur_func->io[i] = NULL; |
1598 | } | 1598 | } |
1599 | if (cur_func->mem[i]) { | 1599 | if (cur_func->mem[i]) { |
1600 | debug ("mem[%d] exists\n", i); | 1600 | debug("mem[%d] exists\n", i); |
1601 | if (the_end > 0) | 1601 | if (the_end > 0) |
1602 | ibmphp_remove_resource (cur_func->mem[i]); | 1602 | ibmphp_remove_resource(cur_func->mem[i]); |
1603 | cur_func->mem[i] = NULL; | 1603 | cur_func->mem[i] = NULL; |
1604 | } | 1604 | } |
1605 | if (cur_func->pfmem[i]) { | 1605 | if (cur_func->pfmem[i]) { |
1606 | debug ("pfmem[%d] exists\n", i); | 1606 | debug("pfmem[%d] exists\n", i); |
1607 | if (the_end > 0) | 1607 | if (the_end > 0) |
1608 | ibmphp_remove_resource (cur_func->pfmem[i]); | 1608 | ibmphp_remove_resource(cur_func->pfmem[i]); |
1609 | cur_func->pfmem[i] = NULL; | 1609 | cur_func->pfmem[i] = NULL; |
1610 | } | 1610 | } |
1611 | } | 1611 | } |
1612 | 1612 | ||
1613 | temp_func = cur_func->next; | 1613 | temp_func = cur_func->next; |
1614 | kfree (cur_func); | 1614 | kfree(cur_func); |
1615 | cur_func = temp_func; | 1615 | cur_func = temp_func; |
1616 | } | 1616 | } |
1617 | } | 1617 | } |
1618 | 1618 | ||
1619 | sl->func = NULL; | 1619 | sl->func = NULL; |
1620 | *slot_cur = sl; | 1620 | *slot_cur = sl; |
1621 | debug ("%s - exit\n", __func__); | 1621 | debug("%s - exit\n", __func__); |
1622 | return 0; | 1622 | return 0; |
1623 | } | 1623 | } |
1624 | 1624 | ||
@@ -1630,7 +1630,7 @@ int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end) | |||
1630 | * Output: bus added to the correct spot | 1630 | * Output: bus added to the correct spot |
1631 | * 0, -1, error | 1631 | * 0, -1, error |
1632 | */ | 1632 | */ |
1633 | static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct resource_node *mem, struct resource_node *pfmem, u8 parent_busno) | 1633 | static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct resource_node *mem, struct resource_node *pfmem, u8 parent_busno) |
1634 | { | 1634 | { |
1635 | struct range_node *io_range = NULL; | 1635 | struct range_node *io_range = NULL; |
1636 | struct range_node *mem_range = NULL; | 1636 | struct range_node *mem_range = NULL; |
@@ -1639,18 +1639,18 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1639 | 1639 | ||
1640 | /* Trying to find the parent bus number */ | 1640 | /* Trying to find the parent bus number */ |
1641 | if (parent_busno != 0xFF) { | 1641 | if (parent_busno != 0xFF) { |
1642 | cur_bus = ibmphp_find_res_bus (parent_busno); | 1642 | cur_bus = ibmphp_find_res_bus(parent_busno); |
1643 | if (!cur_bus) { | 1643 | if (!cur_bus) { |
1644 | err ("strange, cannot find bus which is supposed to be at the system... something is terribly wrong...\n"); | 1644 | err("strange, cannot find bus which is supposed to be at the system... something is terribly wrong...\n"); |
1645 | return -ENODEV; | 1645 | return -ENODEV; |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | list_add (&bus->bus_list, &cur_bus->bus_list); | 1648 | list_add(&bus->bus_list, &cur_bus->bus_list); |
1649 | } | 1649 | } |
1650 | if (io) { | 1650 | if (io) { |
1651 | io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); | 1651 | io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); |
1652 | if (!io_range) { | 1652 | if (!io_range) { |
1653 | err ("out of system memory\n"); | 1653 | err("out of system memory\n"); |
1654 | return -ENOMEM; | 1654 | return -ENOMEM; |
1655 | } | 1655 | } |
1656 | io_range->start = io->start; | 1656 | io_range->start = io->start; |
@@ -1662,7 +1662,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1662 | if (mem) { | 1662 | if (mem) { |
1663 | mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); | 1663 | mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); |
1664 | if (!mem_range) { | 1664 | if (!mem_range) { |
1665 | err ("out of system memory\n"); | 1665 | err("out of system memory\n"); |
1666 | return -ENOMEM; | 1666 | return -ENOMEM; |
1667 | } | 1667 | } |
1668 | mem_range->start = mem->start; | 1668 | mem_range->start = mem->start; |
@@ -1674,7 +1674,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1674 | if (pfmem) { | 1674 | if (pfmem) { |
1675 | pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); | 1675 | pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); |
1676 | if (!pfmem_range) { | 1676 | if (!pfmem_range) { |
1677 | err ("out of system memory\n"); | 1677 | err("out of system memory\n"); |
1678 | return -ENOMEM; | 1678 | return -ENOMEM; |
1679 | } | 1679 | } |
1680 | pfmem_range->start = pfmem->start; | 1680 | pfmem_range->start = pfmem->start; |
@@ -1691,27 +1691,27 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1691 | * Parameters: bus_number of the primary bus | 1691 | * Parameters: bus_number of the primary bus |
1692 | * Returns: bus_number of the secondary bus or 0xff in case of failure | 1692 | * Returns: bus_number of the secondary bus or 0xff in case of failure |
1693 | */ | 1693 | */ |
1694 | static u8 find_sec_number (u8 primary_busno, u8 slotno) | 1694 | static u8 find_sec_number(u8 primary_busno, u8 slotno) |
1695 | { | 1695 | { |
1696 | int min, max; | 1696 | int min, max; |
1697 | u8 busno; | 1697 | u8 busno; |
1698 | struct bus_info *bus; | 1698 | struct bus_info *bus; |
1699 | struct bus_node *bus_cur; | 1699 | struct bus_node *bus_cur; |
1700 | 1700 | ||
1701 | bus = ibmphp_find_same_bus_num (primary_busno); | 1701 | bus = ibmphp_find_same_bus_num(primary_busno); |
1702 | if (!bus) { | 1702 | if (!bus) { |
1703 | err ("cannot get slot range of the bus from the BIOS\n"); | 1703 | err("cannot get slot range of the bus from the BIOS\n"); |
1704 | return 0xff; | 1704 | return 0xff; |
1705 | } | 1705 | } |
1706 | max = bus->slot_max; | 1706 | max = bus->slot_max; |
1707 | min = bus->slot_min; | 1707 | min = bus->slot_min; |
1708 | if ((slotno > max) || (slotno < min)) { | 1708 | if ((slotno > max) || (slotno < min)) { |
1709 | err ("got the wrong range\n"); | 1709 | err("got the wrong range\n"); |
1710 | return 0xff; | 1710 | return 0xff; |
1711 | } | 1711 | } |
1712 | busno = (u8) (slotno - (u8) min); | 1712 | busno = (u8) (slotno - (u8) min); |
1713 | busno += primary_busno + 0x01; | 1713 | busno += primary_busno + 0x01; |
1714 | bus_cur = ibmphp_find_res_bus (busno); | 1714 | bus_cur = ibmphp_find_res_bus(busno); |
1715 | /* either there is no such bus number, or there are no ranges, which | 1715 | /* either there is no such bus number, or there are no ranges, which |
1716 | * can only happen if we removed the bridged device in previous load | 1716 | * can only happen if we removed the bridged device in previous load |
1717 | * of the driver, and now only have the skeleton bus struct | 1717 | * of the driver, and now only have the skeleton bus struct |