Diff markup
1 /* 1 /*
2 * Interface for Dynamic Logical Partitioning 2 * Interface for Dynamic Logical Partitioning of I/O Slots on
3 * RPA-compliant PPC64 platform. 3 * RPA-compliant PPC64 platform.
4 * 4 *
5 * John Rose <johnrose@austin.ibm.com> 5 * John Rose <johnrose@austin.ibm.com>
6 * Linda Xie <lxie@us.ibm.com> 6 * Linda Xie <lxie@us.ibm.com>
7 * 7 *
8 * October 2003 8 * October 2003
9 * 9 *
10 * Copyright (C) 2003 IBM. 10 * Copyright (C) 2003 IBM.
11 * 11 *
12 * This program is free software; you can 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU G 13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foun 14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) 15 * 2 of the License, or (at your option) any later version.
16 */ 16 */
>> 17
>> 18 #undef DEBUG
>> 19
17 #include <linux/init.h> 20 #include <linux/init.h>
18 #include <linux/pci.h> 21 #include <linux/pci.h>
19 #include <linux/string.h> 22 #include <linux/string.h>
20 23
21 #include <asm/pci-bridge.h> 24 #include <asm/pci-bridge.h>
22 #include <linux/mutex.h> 25 #include <linux/mutex.h>
23 #include <asm/rtas.h> 26 #include <asm/rtas.h>
24 #include <asm/vio.h> 27 #include <asm/vio.h>
25 28
26 #include "../pci.h" 29 #include "../pci.h"
27 #include "rpaphp.h" 30 #include "rpaphp.h"
28 #include "rpadlpar.h" 31 #include "rpadlpar.h"
29 32
30 static DEFINE_MUTEX(rpadlpar_mutex); 33 static DEFINE_MUTEX(rpadlpar_mutex);
31 34
32 #define DLPAR_MODULE_NAME "rpadlpar_io" 35 #define DLPAR_MODULE_NAME "rpadlpar_io"
33 36
34 #define NODE_TYPE_VIO 1 37 #define NODE_TYPE_VIO 1
35 #define NODE_TYPE_SLOT 2 38 #define NODE_TYPE_SLOT 2
36 #define NODE_TYPE_PHB 3 39 #define NODE_TYPE_PHB 3
37 40
38 static struct device_node *find_vio_slot_node( 41 static struct device_node *find_vio_slot_node(char *drc_name)
39 { 42 {
40 struct device_node *parent = of_find_n 43 struct device_node *parent = of_find_node_by_name(NULL, "vdevice");
41 struct device_node *dn = NULL; 44 struct device_node *dn = NULL;
42 char *name; 45 char *name;
43 int rc; 46 int rc;
44 47
45 if (!parent) 48 if (!parent)
46 return NULL; 49 return NULL;
47 50
48 while ((dn = of_get_next_child(parent, 51 while ((dn = of_get_next_child(parent, dn))) {
49 rc = rpaphp_get_drc_props(dn, 52 rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL);
50 if ((rc == 0) && (!strcmp(drc_ 53 if ((rc == 0) && (!strcmp(drc_name, name)))
51 break; 54 break;
52 } 55 }
53 56
54 return dn; 57 return dn;
55 } 58 }
56 59
57 /* Find dlpar-capable pci node that contains t 60 /* Find dlpar-capable pci node that contains the specified name and type */
58 static struct device_node *find_php_slot_pci_n 61 static struct device_node *find_php_slot_pci_node(char *drc_name,
59 62 char *drc_type)
60 { 63 {
61 struct device_node *np = NULL; 64 struct device_node *np = NULL;
62 char *name; 65 char *name;
63 char *type; 66 char *type;
64 int rc; 67 int rc;
65 68
66 while ((np = of_find_node_by_name(np, 69 while ((np = of_find_node_by_name(np, "pci"))) {
67 rc = rpaphp_get_drc_props(np, 70 rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL);
68 if (rc == 0) 71 if (rc == 0)
69 if (!strcmp(drc_name, 72 if (!strcmp(drc_name, name) && !strcmp(drc_type, type))
70 break; 73 break;
71 } 74 }
72 75
73 return np; 76 return np;
74 } 77 }
75 78
76 static struct device_node *find_dlpar_node(cha 79 static struct device_node *find_dlpar_node(char *drc_name, int *node_type)
77 { 80 {
78 struct device_node *dn; 81 struct device_node *dn;
79 82
80 dn = find_php_slot_pci_node(drc_name, 83 dn = find_php_slot_pci_node(drc_name, "SLOT");
81 if (dn) { 84 if (dn) {
82 *node_type = NODE_TYPE_SLOT; 85 *node_type = NODE_TYPE_SLOT;
83 return dn; 86 return dn;
84 } 87 }
85 88
86 dn = find_php_slot_pci_node(drc_name, 89 dn = find_php_slot_pci_node(drc_name, "PHB");
87 if (dn) { 90 if (dn) {
88 *node_type = NODE_TYPE_PHB; 91 *node_type = NODE_TYPE_PHB;
89 return dn; 92 return dn;
90 } 93 }
91 94
92 dn = find_vio_slot_node(drc_name); 95 dn = find_vio_slot_node(drc_name);
93 if (dn) { 96 if (dn) {
94 *node_type = NODE_TYPE_VIO; 97 *node_type = NODE_TYPE_VIO;
95 return dn; 98 return dn;
96 } 99 }
97 100
98 return NULL; 101 return NULL;
99 } 102 }
100 103
101 /** 104 /**
102 * find_php_slot - return hotplug slot structu 105 * find_php_slot - return hotplug slot structure for device node
103 * @dn: target &device_node 106 * @dn: target &device_node
104 * 107 *
105 * This routine will return the hotplug slot s 108 * This routine will return the hotplug slot structure
106 * for a given device node. Note that built-in 109 * for a given device node. Note that built-in PCI slots
107 * may be dlpar-able, but not hot-pluggable, s 110 * may be dlpar-able, but not hot-pluggable, so this routine
108 * will return NULL for built-in PCI slots. 111 * will return NULL for built-in PCI slots.
109 */ 112 */
110 static struct slot *find_php_slot(struct devic 113 static struct slot *find_php_slot(struct device_node *dn)
111 { 114 {
112 struct list_head *tmp, *n; 115 struct list_head *tmp, *n;
113 struct slot *slot; 116 struct slot *slot;
114 117
115 list_for_each_safe(tmp, n, &rpaphp_slo 118 list_for_each_safe(tmp, n, &rpaphp_slot_head) {
116 slot = list_entry(tmp, struct 119 slot = list_entry(tmp, struct slot, rpaphp_slot_list);
117 if (slot->dn == dn) 120 if (slot->dn == dn)
118 return slot; 121 return slot;
119 } 122 }
120 123
121 return NULL; 124 return NULL;
122 } 125 }
123 126
124 static struct pci_dev *dlpar_find_new_dev(stru 127 static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent,
125 struct 128 struct device_node *dev_dn)
126 { 129 {
127 struct pci_dev *tmp = NULL; 130 struct pci_dev *tmp = NULL;
128 struct device_node *child_dn; 131 struct device_node *child_dn;
129 132
130 list_for_each_entry(tmp, &parent->devi 133 list_for_each_entry(tmp, &parent->devices, bus_list) {
131 child_dn = pci_device_to_OF_no 134 child_dn = pci_device_to_OF_node(tmp);
132 if (child_dn == dev_dn) 135 if (child_dn == dev_dn)
133 return tmp; 136 return tmp;
134 } 137 }
135 return NULL; 138 return NULL;
136 } 139 }
137 140
138 static void dlpar_pci_add_bus(struct device_no 141 static void dlpar_pci_add_bus(struct device_node *dn)
139 { 142 {
140 struct pci_dn *pdn = PCI_DN(dn); 143 struct pci_dn *pdn = PCI_DN(dn);
141 struct pci_controller *phb = pdn->phb; 144 struct pci_controller *phb = pdn->phb;
142 struct pci_dev *dev = NULL; 145 struct pci_dev *dev = NULL;
143 146
144 eeh_add_device_tree_early(dn); 147 eeh_add_device_tree_early(dn);
145 148
146 /* Add EADS device to PHB bus, adding 149 /* Add EADS device to PHB bus, adding new entry to bus->devices */
147 dev = of_create_pci_dev(dn, phb->bus, 150 dev = of_create_pci_dev(dn, phb->bus, pdn->devfn);
148 if (!dev) { 151 if (!dev) {
149 printk(KERN_ERR "%s: failed to 152 printk(KERN_ERR "%s: failed to create pci dev for %s\n",
150 __FUNCTION__, !! 153 __func__, dn->full_name);
151 return; 154 return;
152 } 155 }
153 156
>> 157 /* Scan below the new bridge */
154 if (dev->hdr_type == PCI_HEADER_TYPE_B 158 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
155 dev->hdr_type == PCI_HEADER_TYPE_C 159 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
156 of_scan_pci_bridge(dn, dev); 160 of_scan_pci_bridge(dn, dev);
157 161
158 pcibios_fixup_new_pci_devices(dev->sub <<
159 <<
160 /* Claim new bus resources */ <<
161 pcibios_claim_one_bus(dev->bus); <<
162 <<
163 /* Map IO space for child bus, which m 162 /* Map IO space for child bus, which may or may not succeed */
164 pcibios_map_io_space(dev->subordinate) 163 pcibios_map_io_space(dev->subordinate);
165 164
166 /* Add new devices to global lists. R !! 165 /* Finish adding it : resource allocation, adding devices, etc...
167 pci_bus_add_devices(phb->bus); !! 166 * Note that we need to perform the finish pass on the -parent-
>> 167 * bus of the EADS bridge so the bridge device itself gets
>> 168 * properly added
>> 169 */
>> 170 pcibios_finish_adding_to_bus(phb->bus);
168 } 171 }
169 172
170 static int dlpar_add_pci_slot(char *drc_name, 173 static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn)
171 { 174 {
172 struct pci_dev *dev; 175 struct pci_dev *dev;
173 struct pci_controller *phb; 176 struct pci_controller *phb;
174 177
175 if (pcibios_find_pci_bus(dn)) 178 if (pcibios_find_pci_bus(dn))
176 return -EINVAL; 179 return -EINVAL;
177 180
178 /* Add pci bus */ 181 /* Add pci bus */
179 dlpar_pci_add_bus(dn); 182 dlpar_pci_add_bus(dn);
180 183
181 /* Confirm new bridge dev was created 184 /* Confirm new bridge dev was created */
182 phb = PCI_DN(dn)->phb; 185 phb = PCI_DN(dn)->phb;
183 dev = dlpar_find_new_dev(phb->bus, dn) 186 dev = dlpar_find_new_dev(phb->bus, dn);
184 187
185 if (!dev) { 188 if (!dev) {
186 printk(KERN_ERR "%s: unable to !! 189 printk(KERN_ERR "%s: unable to add bus %s\n", __func__,
187 drc_name); 190 drc_name);
188 return -EIO; 191 return -EIO;
189 } 192 }
190 193
191 if (dev->hdr_type != PCI_HEADER_TYPE_B 194 if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
192 printk(KERN_ERR "%s: unexpecte 195 printk(KERN_ERR "%s: unexpected header type %d, unable to add bus %s\n",
193 __FUNCTION__, dev->hdr !! 196 __func__, dev->hdr_type, drc_name);
194 return -EIO; 197 return -EIO;
195 } 198 }
196 199
197 /* Add hotplug slot */ 200 /* Add hotplug slot */
198 if (rpaphp_add_slot(dn)) { 201 if (rpaphp_add_slot(dn)) {
199 printk(KERN_ERR "%s: unable to 202 printk(KERN_ERR "%s: unable to add hotplug slot %s\n",
200 __FUNCTION__, drc_name !! 203 __func__, drc_name);
201 return -EIO; 204 return -EIO;
202 } 205 }
203 return 0; 206 return 0;
204 } 207 }
205 208
206 static int dlpar_remove_root_bus(struct pci_co <<
207 { <<
208 struct pci_bus *phb_bus; <<
209 int rc; <<
210 <<
211 phb_bus = phb->bus; <<
212 if (!(list_empty(&phb_bus->children) & <<
213 list_empty(&phb_bus->devices))) <<
214 return -EBUSY; <<
215 } <<
216 <<
217 rc = pcibios_remove_root_bus(phb); <<
218 if (rc) <<
219 return -EIO; <<
220 <<
221 device_unregister(phb_bus->bridge); <<
222 pci_remove_bus(phb_bus); <<
223 <<
224 return 0; <<
225 } <<
226 <<
227 static int dlpar_remove_phb(char *drc_name, st 209 static int dlpar_remove_phb(char *drc_name, struct device_node *dn)
228 { 210 {
229 struct slot *slot; 211 struct slot *slot;
230 struct pci_dn *pdn; 212 struct pci_dn *pdn;
231 int rc = 0; 213 int rc = 0;
232 214
233 if (!pcibios_find_pci_bus(dn)) 215 if (!pcibios_find_pci_bus(dn))
234 return -EINVAL; 216 return -EINVAL;
235 217
236 /* If pci slot is hotplugable, use hot 218 /* If pci slot is hotplugable, use hotplug to remove it */
237 slot = find_php_slot(dn); 219 slot = find_php_slot(dn);
238 if (slot) { !! 220 if (slot && rpaphp_deregister_slot(slot)) {
239 if (rpaphp_deregister_slot(slo !! 221 printk(KERN_ERR "%s: unable to remove hotplug slot %s\n",
240 printk(KERN_ERR !! 222 __func__, drc_name);
241 "%s: unable to !! 223 return -EIO;
242 __FUNCTION__, <<
243 return -EIO; <<
244 } <<
245 } 224 }
246 225
247 pdn = dn->data; 226 pdn = dn->data;
248 BUG_ON(!pdn || !pdn->phb); 227 BUG_ON(!pdn || !pdn->phb);
249 rc = dlpar_remove_root_bus(pdn->phb); !! 228 rc = remove_phb_dynamic(pdn->phb);
250 if (rc < 0) 229 if (rc < 0)
251 return rc; 230 return rc;
252 231
253 pdn->phb = NULL; 232 pdn->phb = NULL;
254 233
255 return 0; 234 return 0;
256 } 235 }
257 236
258 static int dlpar_add_phb(char *drc_name, struc 237 static int dlpar_add_phb(char *drc_name, struct device_node *dn)
259 { 238 {
260 struct pci_controller *phb; 239 struct pci_controller *phb;
261 240
262 if (PCI_DN(dn) && PCI_DN(dn)->phb) { 241 if (PCI_DN(dn) && PCI_DN(dn)->phb) {
263 /* PHB already exists */ 242 /* PHB already exists */
264 return -EINVAL; 243 return -EINVAL;
265 } 244 }
266 245
267 phb = init_phb_dynamic(dn); 246 phb = init_phb_dynamic(dn);
268 if (!phb) 247 if (!phb)
269 return -EIO; 248 return -EIO;
270 249
271 if (rpaphp_add_slot(dn)) { 250 if (rpaphp_add_slot(dn)) {
272 printk(KERN_ERR "%s: unable to 251 printk(KERN_ERR "%s: unable to add hotplug slot %s\n",
273 __FUNCTION__, drc_name !! 252 __func__, drc_name);
274 return -EIO; 253 return -EIO;
275 } 254 }
276 return 0; 255 return 0;
277 } 256 }
278 257
279 static int dlpar_add_vio_slot(char *drc_name, 258 static int dlpar_add_vio_slot(char *drc_name, struct device_node *dn)
280 { 259 {
281 if (vio_find_node(dn)) 260 if (vio_find_node(dn))
282 return -EINVAL; 261 return -EINVAL;
283 262
284 if (!vio_register_device_node(dn)) { 263 if (!vio_register_device_node(dn)) {
285 printk(KERN_ERR 264 printk(KERN_ERR
286 "%s: failed to registe 265 "%s: failed to register vio node %s\n",
287 __FUNCTION__, drc_name !! 266 __func__, drc_name);
288 return -EIO; 267 return -EIO;
289 } 268 }
290 return 0; 269 return 0;
291 } 270 }
292 271
293 /** 272 /**
294 * dlpar_add_slot - DLPAR add an I/O Slot 273 * dlpar_add_slot - DLPAR add an I/O Slot
295 * @drc_name: drc-name of newly added slot 274 * @drc_name: drc-name of newly added slot
296 * 275 *
297 * Make the hotplug module and the kernel awar 276 * Make the hotplug module and the kernel aware of a newly added I/O Slot.
298 * Return Codes: 277 * Return Codes:
299 * 0 Success 278 * 0 Success
300 * -ENODEV Not a valid drc_name 279 * -ENODEV Not a valid drc_name
301 * -EINVAL Slot already added 280 * -EINVAL Slot already added
302 * -ERESTARTSYS Signalled before obtai 281 * -ERESTARTSYS Signalled before obtaining lock
303 * -EIO Internal PCI Error 282 * -EIO Internal PCI Error
304 */ 283 */
305 int dlpar_add_slot(char *drc_name) 284 int dlpar_add_slot(char *drc_name)
306 { 285 {
307 struct device_node *dn = NULL; 286 struct device_node *dn = NULL;
308 int node_type; 287 int node_type;
309 int rc = -EIO; 288 int rc = -EIO;
310 289
311 if (mutex_lock_interruptible(&rpadlpar 290 if (mutex_lock_interruptible(&rpadlpar_mutex))
312 return -ERESTARTSYS; 291 return -ERESTARTSYS;
313 292
314 /* Find newly added node */ 293 /* Find newly added node */
315 dn = find_dlpar_node(drc_name, &node_t 294 dn = find_dlpar_node(drc_name, &node_type);
316 if (!dn) { 295 if (!dn) {
317 rc = -ENODEV; 296 rc = -ENODEV;
318 goto exit; 297 goto exit;
319 } 298 }
320 299
321 switch (node_type) { 300 switch (node_type) {
322 case NODE_TYPE_VIO: 301 case NODE_TYPE_VIO:
323 rc = dlpar_add_vio_slo 302 rc = dlpar_add_vio_slot(drc_name, dn);
324 break; 303 break;
325 case NODE_TYPE_SLOT: 304 case NODE_TYPE_SLOT:
326 rc = dlpar_add_pci_slo 305 rc = dlpar_add_pci_slot(drc_name, dn);
327 break; 306 break;
328 case NODE_TYPE_PHB: 307 case NODE_TYPE_PHB:
329 rc = dlpar_add_phb(drc 308 rc = dlpar_add_phb(drc_name, dn);
330 break; 309 break;
331 } 310 }
332 311
333 printk(KERN_INFO "%s: slot %s added\n" 312 printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name);
334 exit: 313 exit:
335 mutex_unlock(&rpadlpar_mutex); 314 mutex_unlock(&rpadlpar_mutex);
336 return rc; 315 return rc;
337 } 316 }
338 317
339 /** 318 /**
340 * dlpar_remove_vio_slot - DLPAR remove a virt 319 * dlpar_remove_vio_slot - DLPAR remove a virtual I/O Slot
341 * @drc_name: drc-name of newly added slot 320 * @drc_name: drc-name of newly added slot
342 * @dn: &device_node 321 * @dn: &device_node
343 * 322 *
344 * Remove the kernel and hotplug representatio 323 * Remove the kernel and hotplug representations of an I/O Slot.
345 * Return Codes: 324 * Return Codes:
346 * 0 Success 325 * 0 Success
347 * -EINVAL Vio dev doesn't exist 326 * -EINVAL Vio dev doesn't exist
348 */ 327 */
349 static int dlpar_remove_vio_slot(char *drc_nam 328 static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn)
350 { 329 {
351 struct vio_dev *vio_dev; 330 struct vio_dev *vio_dev;
352 331
353 vio_dev = vio_find_node(dn); 332 vio_dev = vio_find_node(dn);
354 if (!vio_dev) 333 if (!vio_dev)
355 return -EINVAL; 334 return -EINVAL;
356 335
357 vio_unregister_device(vio_dev); 336 vio_unregister_device(vio_dev);
358 return 0; 337 return 0;
359 } 338 }
360 339
361 /** 340 /**
362 * dlpar_remove_pci_slot - DLPAR remove a PCI 341 * dlpar_remove_pci_slot - DLPAR remove a PCI I/O Slot
363 * @drc_name: drc-name of newly added slot 342 * @drc_name: drc-name of newly added slot
364 * @dn: &device_node 343 * @dn: &device_node
365 * 344 *
366 * Remove the kernel and hotplug representatio 345 * Remove the kernel and hotplug representations of a PCI I/O Slot.
367 * Return Codes: 346 * Return Codes:
368 * 0 Success 347 * 0 Success
369 * -ENODEV Not a valid drc_name 348 * -ENODEV Not a valid drc_name
370 * -EIO Internal PCI Error 349 * -EIO Internal PCI Error
371 */ 350 */
372 int dlpar_remove_pci_slot(char *drc_name, stru 351 int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
373 { 352 {
374 struct pci_bus *bus; 353 struct pci_bus *bus;
375 struct slot *slot; 354 struct slot *slot;
376 355
377 bus = pcibios_find_pci_bus(dn); 356 bus = pcibios_find_pci_bus(dn);
378 if (!bus) 357 if (!bus)
379 return -EINVAL; 358 return -EINVAL;
380 359
381 /* If pci slot is hotplugable, use hot !! 360 pr_debug("PCI: Removing PCI slot below EADS bridge %s\n",
>> 361 bus->self ? pci_name(bus->self) : "<!PHB!>");
>> 362
382 slot = find_php_slot(dn); 363 slot = find_php_slot(dn);
383 if (slot) { 364 if (slot) {
>> 365 pr_debug("PCI: Removing hotplug slot for %04x:%02x...\n",
>> 366 pci_domain_nr(bus), bus->number);
>> 367
384 if (rpaphp_deregister_slot(slo 368 if (rpaphp_deregister_slot(slot)) {
385 printk(KERN_ERR 369 printk(KERN_ERR
386 "%s: unable to 370 "%s: unable to remove hotplug slot %s\n",
387 __FUNCTION__, !! 371 __func__, drc_name);
388 return -EIO; 372 return -EIO;
389 } 373 }
390 } else !! 374 }
391 pcibios_remove_pci_devices(bus !! 375
>> 376 /* Remove all devices below slot */
>> 377 pcibios_remove_pci_devices(bus);
392 378
>> 379 /* Unmap PCI IO space */
393 if (pcibios_unmap_io_space(bus)) { 380 if (pcibios_unmap_io_space(bus)) {
394 printk(KERN_ERR "%s: failed to 381 printk(KERN_ERR "%s: failed to unmap bus range\n",
395 __FUNCTION__); !! 382 __func__);
396 return -ERANGE; 383 return -ERANGE;
397 } 384 }
398 385
>> 386 /* Remove the EADS bridge device itself */
399 BUG_ON(!bus->self); 387 BUG_ON(!bus->self);
>> 388 pr_debug("PCI: Now removing bridge device %s\n", pci_name(bus->self));
>> 389 eeh_remove_bus_device(bus->self);
400 pci_remove_bus_device(bus->self); 390 pci_remove_bus_device(bus->self);
>> 391
401 return 0; 392 return 0;
402 } 393 }
403 394
404 /** 395 /**
405 * dlpar_remove_slot - DLPAR remove an I/O Slo 396 * dlpar_remove_slot - DLPAR remove an I/O Slot
406 * @drc_name: drc-name of newly added slot 397 * @drc_name: drc-name of newly added slot
407 * 398 *
408 * Remove the kernel and hotplug representatio 399 * Remove the kernel and hotplug representations of an I/O Slot.
409 * Return Codes: 400 * Return Codes:
410 * 0 Success 401 * 0 Success
411 * -ENODEV Not a valid drc_name 402 * -ENODEV Not a valid drc_name
412 * -EINVAL Slot already removed 403 * -EINVAL Slot already removed
413 * -ERESTARTSYS Signalled before obtai 404 * -ERESTARTSYS Signalled before obtaining lock
414 * -EIO Internal Error 405 * -EIO Internal Error
415 */ 406 */
416 int dlpar_remove_slot(char *drc_name) 407 int dlpar_remove_slot(char *drc_name)
417 { 408 {
418 struct device_node *dn; 409 struct device_node *dn;
419 int node_type; 410 int node_type;
420 int rc = 0; 411 int rc = 0;
421 412
422 if (mutex_lock_interruptible(&rpadlpar 413 if (mutex_lock_interruptible(&rpadlpar_mutex))
423 return -ERESTARTSYS; 414 return -ERESTARTSYS;
424 415
425 dn = find_dlpar_node(drc_name, &node_t 416 dn = find_dlpar_node(drc_name, &node_type);
426 if (!dn) { 417 if (!dn) {
427 rc = -ENODEV; 418 rc = -ENODEV;
428 goto exit; 419 goto exit;
429 } 420 }
430 421
431 switch (node_type) { 422 switch (node_type) {
432 case NODE_TYPE_VIO: 423 case NODE_TYPE_VIO:
433 rc = dlpar_remove_vio_ 424 rc = dlpar_remove_vio_slot(drc_name, dn);
434 break; 425 break;
435 case NODE_TYPE_PHB: 426 case NODE_TYPE_PHB:
436 rc = dlpar_remove_phb( 427 rc = dlpar_remove_phb(drc_name, dn);
437 break; 428 break;
438 case NODE_TYPE_SLOT: 429 case NODE_TYPE_SLOT:
439 rc = dlpar_remove_pci_ 430 rc = dlpar_remove_pci_slot(drc_name, dn);
440 break; 431 break;
441 } 432 }
442 printk(KERN_INFO "%s: slot %s removed\ 433 printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name);
443 exit: 434 exit:
444 mutex_unlock(&rpadlpar_mutex); 435 mutex_unlock(&rpadlpar_mutex);
445 return rc; 436 return rc;
446 } 437 }
447 438
448 static inline int is_dlpar_capable(void) 439 static inline int is_dlpar_capable(void)
449 { 440 {
450 int rc = rtas_token("ibm,configure-con 441 int rc = rtas_token("ibm,configure-connector");
451 442
452 return (int) (rc != RTAS_UNKNOWN_SERVI 443 return (int) (rc != RTAS_UNKNOWN_SERVICE);
453 } 444 }
454 445
455 int __init rpadlpar_io_init(void) 446 int __init rpadlpar_io_init(void)
456 { 447 {
457 int rc = 0; 448 int rc = 0;
458 449
459 if (!is_dlpar_capable()) { 450 if (!is_dlpar_capable()) {
460 printk(KERN_WARNING "%s: parti 451 printk(KERN_WARNING "%s: partition not DLPAR capable\n",
461 __FUNCTION__); !! 452 __func__);
462 return -EPERM; 453 return -EPERM;
463 } 454 }
464 455
465 rc = dlpar_sysfs_init(); 456 rc = dlpar_sysfs_init();
466 return rc; 457 return rc;
467 } 458 }
468 459
469 void rpadlpar_io_exit(void) 460 void rpadlpar_io_exit(void)
470 { 461 {
471 dlpar_sysfs_exit(); 462 dlpar_sysfs_exit();
472 return; 463 return;
473 } 464 }
474 465
475 module_init(rpadlpar_io_init); 466 module_init(rpadlpar_io_init);
476 module_exit(rpadlpar_io_exit); 467 module_exit(rpadlpar_io_exit);
477 MODULE_LICENSE("GPL"); 468 MODULE_LICENSE("GPL");
478 469
|
This page was automatically generated by the
LXR engine.
|