Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

+282 -768
+1 -3
Documentation/filesystems/sysfs-pci.txt
··· 7 |-- 0000:17:00.0 8 | |-- class 9 | |-- config 10 - | |-- detach_state 11 | |-- device 12 | |-- irq 13 | |-- local_cpus ··· 18 | |-- subsystem_device 19 | |-- subsystem_vendor 20 | `-- vendor 21 - `-- detach_state 22 23 The topmost element describes the PCI domain and bus number. In this case, 24 the domain number is 0000 and the bus number is 17 (both values are in hex). ··· 30 ---- -------- 31 class PCI class (ascii, ro) 32 config PCI config space (binary, rw) 33 - detach_state connection status (bool, rw) 34 device PCI device (ascii, ro) 35 irq IRQ number (ascii, ro) 36 local_cpus nearby CPU mask (cpumask, ro)
··· 7 |-- 0000:17:00.0 8 | |-- class 9 | |-- config 10 | |-- device 11 | |-- irq 12 | |-- local_cpus ··· 19 | |-- subsystem_device 20 | |-- subsystem_vendor 21 | `-- vendor 22 + `-- ... 23 24 The topmost element describes the PCI domain and bus number. In this case, 25 the domain number is 0000 and the bus number is 17 (both values are in hex). ··· 31 ---- -------- 32 class PCI class (ascii, ro) 33 config PCI config space (binary, rw) 34 device PCI device (ascii, ro) 35 irq IRQ number (ascii, ro) 36 local_cpus nearby CPU mask (cpumask, ro)
-21
Documentation/power/devices.txt
··· 207 #READY_AFTER_RESUME 208 # 209 210 - Driver Detach Power Management 211 - 212 - The kernel now supports the ability to place a device in a low-power 213 - state when it is detached from its driver, which happens when its 214 - module is removed. 215 - 216 - Each device contains a 'detach_state' file in its sysfs directory 217 - which can be used to control this state. Reading from this file 218 - displays what the current detach state is set to. This is 0 (On) by 219 - default. A user may write a positive integer value to this file in the 220 - range of 1-4 inclusive. 221 - 222 - A value of 1-3 will indicate the device should be placed in that 223 - low-power state, which will cause ->suspend() to be called for that 224 - device. A value of 4 indicates that the device should be shutdown, so 225 - ->shutdown() will be called for that device. 226 - 227 - The driver is responsible for reinitializing the device when the 228 - module is re-inserted during it's ->probe() (or equivalent) method. 229 - The driver core will not call any extra functions when binding the 230 - device to the driver. 231 232 pm_message_t meaning 233
··· 207 #READY_AFTER_RESUME 208 # 209 210 211 pm_message_t meaning 212
+2 -2
Documentation/powerpc/hvcs.txt
··· 347 looks like the following: 348 349 Pow5:/sys/bus/vio/drivers/hvcs/30000004 # ls 350 - . current_vty devspec name partner_vtys 351 - .. detach_state index partner_clcs vterm_state 352 353 Each entry is provided, by default with a "name" attribute. Reading the 354 "name" attribute will reveal the device type as shown in the following
··· 347 looks like the following: 348 349 Pow5:/sys/bus/vio/drivers/hvcs/30000004 # ls 350 + . current_vty devspec name partner_vtys 351 + .. index partner_clcs vterm_state 352 353 Each entry is provided, by default with a "name" attribute. Reading the 354 "name" attribute will reveal the device type as shown in the following
+1 -1
drivers/base/Makefile
··· 1 # Makefile for the Linux device tree 2 3 - obj-y := core.o sys.o interface.o bus.o \ 4 driver.o class.o class_simple.o platform.o \ 5 cpu.o firmware.o init.o map.o dmapool.o \ 6 attribute_container.o transport_class.o
··· 1 # Makefile for the Linux device tree 2 3 + obj-y := core.o sys.o bus.o \ 4 driver.o class.o class_simple.o platform.o \ 5 cpu.o firmware.o init.o map.o dmapool.o \ 6 attribute_container.o transport_class.o
-1
drivers/base/bus.c
··· 390 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj)); 391 sysfs_remove_link(&dev->kobj, "driver"); 392 list_del_init(&dev->driver_list); 393 - device_detach_shutdown(dev); 394 if (drv->remove) 395 drv->remove(dev); 396 dev->driver = NULL;
··· 390 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj)); 391 sysfs_remove_link(&dev->kobj, "driver"); 392 list_del_init(&dev->driver_list); 393 if (drv->remove) 394 drv->remove(dev); 395 dev->driver = NULL;
-3
drivers/base/core.c
··· 31 #define to_dev(obj) container_of(obj, struct device, kobj) 32 #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) 33 34 - extern struct attribute * dev_default_attrs[]; 35 - 36 static ssize_t 37 dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) 38 { ··· 87 static struct kobj_type ktype_device = { 88 .release = device_release, 89 .sysfs_ops = &dev_sysfs_ops, 90 - .default_attrs = dev_default_attrs, 91 }; 92 93
··· 31 #define to_dev(obj) container_of(obj, struct device, kobj) 32 #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) 33 34 static ssize_t 35 dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) 36 { ··· 89 static struct kobj_type ktype_device = { 90 .release = device_release, 91 .sysfs_ops = &dev_sysfs_ops, 92 }; 93 94
-51
drivers/base/interface.c
··· 1 - /* 2 - * drivers/base/interface.c - common driverfs interface that's exported to 3 - * the world for all devices. 4 - * 5 - * Copyright (c) 2002-3 Patrick Mochel 6 - * Copyright (c) 2002-3 Open Source Development Labs 7 - * 8 - * This file is released under the GPLv2 9 - * 10 - */ 11 - 12 - #include <linux/device.h> 13 - #include <linux/err.h> 14 - #include <linux/stat.h> 15 - #include <linux/string.h> 16 - 17 - /** 18 - * detach_state - control the default power state for the device. 19 - * 20 - * This is the state the device enters when it's driver module is 21 - * unloaded. The value is an unsigned integer, in the range of 0-4. 22 - * '0' indicates 'On', so no action will be taken when the driver is 23 - * unloaded. This is the default behavior. 24 - * '4' indicates 'Off', meaning the driver core will call the driver's 25 - * shutdown method to quiesce the device. 26 - * 1-3 indicate a low-power state for the device to enter via the 27 - * driver's suspend method. 28 - */ 29 - 30 - static ssize_t detach_show(struct device * dev, char * buf) 31 - { 32 - return sprintf(buf, "%u\n", dev->detach_state); 33 - } 34 - 35 - static ssize_t detach_store(struct device * dev, const char * buf, size_t n) 36 - { 37 - u32 state; 38 - state = simple_strtoul(buf, NULL, 10); 39 - if (state > 4) 40 - return -EINVAL; 41 - dev->detach_state = state; 42 - return n; 43 - } 44 - 45 - static DEVICE_ATTR(detach_state, 0644, detach_show, detach_store); 46 - 47 - 48 - struct attribute * dev_default_attrs[] = { 49 - &dev_attr_detach_state.attr, 50 - NULL, 51 - };
···
-11
drivers/base/power/power.h
··· 1 - 2 - 3 - enum { 4 - DEVICE_PM_ON, 5 - DEVICE_PM1, 6 - DEVICE_PM2, 7 - DEVICE_PM3, 8 - DEVICE_PM_OFF, 9 - }; 10 - 11 /* 12 * shutdown.c 13 */ 14 15 - extern int device_detach_shutdown(struct device *); 16 extern void device_shutdown(void); 17 18
··· 1 /* 2 * shutdown.c 3 */ 4 5 extern void device_shutdown(void); 6 7
+10 -1
drivers/base/power/resume.c
··· 22 23 int resume_device(struct device * dev) 24 { 25 - if (dev->bus && dev->bus->resume) 26 return dev->bus->resume(dev); 27 return 0; 28 } 29
··· 22 23 int resume_device(struct device * dev) 24 { 25 + if (dev->power.pm_parent 26 + && dev->power.pm_parent->power.power_state) { 27 + dev_err(dev, "PM: resume from %d, parent %s still %d\n", 28 + dev->power.power_state, 29 + dev->power.pm_parent->bus_id, 30 + dev->power.pm_parent->power.power_state); 31 + } 32 + if (dev->bus && dev->bus->resume) { 33 + dev_dbg(dev,"resuming\n"); 34 return dev->bus->resume(dev); 35 + } 36 return 0; 37 } 38
+4 -19
drivers/base/power/shutdown.c
··· 19 extern struct subsystem devices_subsys; 20 21 22 - int device_detach_shutdown(struct device * dev) 23 - { 24 - if (!dev->detach_state) 25 - return 0; 26 - 27 - if (dev->detach_state == DEVICE_PM_OFF) { 28 - if (dev->driver && dev->driver->shutdown) 29 - dev->driver->shutdown(dev); 30 - return 0; 31 - } 32 - return dpm_runtime_suspend(dev, dev->detach_state); 33 - } 34 - 35 - 36 /** 37 * We handle system devices differently - we suspend and shut them 38 * down last and resume them first. That way, we don't do anything stupid like ··· 38 struct device * dev; 39 40 down_write(&devices_subsys.rwsem); 41 - list_for_each_entry_reverse(dev, &devices_subsys.kset.list, kobj.entry) { 42 - pr_debug("shutting down %s: ", dev->bus_id); 43 if (dev->driver && dev->driver->shutdown) { 44 - pr_debug("Ok\n"); 45 dev->driver->shutdown(dev); 46 - } else 47 - pr_debug("Ignored.\n"); 48 } 49 up_write(&devices_subsys.rwsem); 50
··· 19 extern struct subsystem devices_subsys; 20 21 22 /** 23 * We handle system devices differently - we suspend and shut them 24 * down last and resume them first. That way, we don't do anything stupid like ··· 52 struct device * dev; 53 54 down_write(&devices_subsys.rwsem); 55 + list_for_each_entry_reverse(dev, &devices_subsys.kset.list, 56 + kobj.entry) { 57 if (dev->driver && dev->driver->shutdown) { 58 + dev_dbg(dev, "shutdown\n"); 59 dev->driver->shutdown(dev); 60 + } 61 } 62 up_write(&devices_subsys.rwsem); 63
+15 -2
drivers/base/power/suspend.c
··· 39 { 40 int error = 0; 41 42 - dev_dbg(dev, "suspending\n"); 43 44 dev->power.prev_state = dev->power.power_state; 45 46 - if (dev->bus && dev->bus->suspend && !dev->power.power_state) 47 error = dev->bus->suspend(dev, state); 48 49 return error; 50 }
··· 39 { 40 int error = 0; 41 42 + if (dev->power.power_state) { 43 + dev_dbg(dev, "PM: suspend %d-->%d\n", 44 + dev->power.power_state, state); 45 + } 46 + if (dev->power.pm_parent 47 + && dev->power.pm_parent->power.power_state) { 48 + dev_err(dev, 49 + "PM: suspend %d->%d, parent %s already %d\n", 50 + dev->power.power_state, state, 51 + dev->power.pm_parent->bus_id, 52 + dev->power.pm_parent->power.power_state); 53 + } 54 55 dev->power.prev_state = dev->power.power_state; 56 57 + if (dev->bus && dev->bus->suspend && !dev->power.power_state) { 58 + dev_dbg(dev, "suspending\n"); 59 error = dev->bus->suspend(dev, state); 60 + } 61 62 return error; 63 }
+1 -1
drivers/char/raw.c
··· 122 { 123 struct block_device *bdev = filp->private_data; 124 125 - return blkdev_ioctl(bdev->bd_inode, filp, command, arg); 126 } 127 128 static void bind_device(struct raw_config_request *rq)
··· 122 { 123 struct block_device *bdev = filp->private_data; 124 125 + return blkdev_ioctl(bdev->bd_inode, NULL, command, arg); 126 } 127 128 static void bind_device(struct raw_config_request *rq)
+10 -109
drivers/pci/hotplug.c
··· 52 if ((buffer_size - length <= 0) || (i >= num_envp)) 53 return -ENOMEM; 54 55 envp[i] = NULL; 56 57 return 0; 58 } 59 - 60 - static int pci_visit_bus (struct pci_visit * fn, struct pci_bus_wrapped *wrapped_bus, struct pci_dev_wrapped *wrapped_parent) 61 - { 62 - struct list_head *ln; 63 - struct pci_dev *dev; 64 - struct pci_dev_wrapped wrapped_dev; 65 - int result = 0; 66 - 67 - pr_debug("PCI: Scanning bus %04x:%02x\n", pci_domain_nr(wrapped_bus->bus), 68 - wrapped_bus->bus->number); 69 - 70 - if (fn->pre_visit_pci_bus) { 71 - result = fn->pre_visit_pci_bus(wrapped_bus, wrapped_parent); 72 - if (result) 73 - return result; 74 - } 75 - 76 - ln = wrapped_bus->bus->devices.next; 77 - while (ln != &wrapped_bus->bus->devices) { 78 - dev = pci_dev_b(ln); 79 - ln = ln->next; 80 - 81 - memset(&wrapped_dev, 0, sizeof(struct pci_dev_wrapped)); 82 - wrapped_dev.dev = dev; 83 - 84 - result = pci_visit_dev(fn, &wrapped_dev, wrapped_bus); 85 - if (result) 86 - return result; 87 - } 88 - 89 - if (fn->post_visit_pci_bus) 90 - result = fn->post_visit_pci_bus(wrapped_bus, wrapped_parent); 91 - 92 - return result; 93 - } 94 - 95 - static int pci_visit_bridge (struct pci_visit * fn, 96 - struct pci_dev_wrapped *wrapped_dev, 97 - struct pci_bus_wrapped *wrapped_parent) 98 - { 99 - struct pci_bus *bus; 100 - struct pci_bus_wrapped wrapped_bus; 101 - int result = 0; 102 - 103 - pr_debug("PCI: Scanning bridge %s\n", pci_name(wrapped_dev->dev)); 104 - 105 - if (fn->visit_pci_dev) { 106 - result = fn->visit_pci_dev(wrapped_dev, wrapped_parent); 107 - if (result) 108 - return result; 109 - } 110 - 111 - bus = wrapped_dev->dev->subordinate; 112 - if (bus) { 113 - memset(&wrapped_bus, 0, sizeof(struct pci_bus_wrapped)); 114 - wrapped_bus.bus = bus; 115 - 116 - result = pci_visit_bus(fn, &wrapped_bus, wrapped_dev); 117 - } 118 - return result; 119 - } 120 - 121 - /** 122 - * pci_visit_dev - scans the pci buses. 123 - * @fn: callback functions that are called while visiting 124 - * @wrapped_dev: the device to scan 125 - * @wrapped_parent: the bus where @wrapped_dev is connected to 126 - * 127 - * Every bus and every function is presented to a custom 128 - * function that can act upon it. 129 - */ 130 - int pci_visit_dev(struct pci_visit *fn, struct pci_dev_wrapped *wrapped_dev, 131 - struct pci_bus_wrapped *wrapped_parent) 132 - { 133 - struct pci_dev* dev = wrapped_dev ? wrapped_dev->dev : NULL; 134 - int result = 0; 135 - 136 - if (!dev) 137 - return 0; 138 - 139 - if (fn->pre_visit_pci_dev) { 140 - result = fn->pre_visit_pci_dev(wrapped_dev, wrapped_parent); 141 - if (result) 142 - return result; 143 - } 144 - 145 - switch (dev->class >> 8) { 146 - case PCI_CLASS_BRIDGE_PCI: 147 - result = pci_visit_bridge(fn, wrapped_dev, 148 - wrapped_parent); 149 - if (result) 150 - return result; 151 - break; 152 - default: 153 - pr_debug("PCI: Scanning device %s\n", pci_name(dev)); 154 - if (fn->visit_pci_dev) { 155 - result = fn->visit_pci_dev (wrapped_dev, 156 - wrapped_parent); 157 - if (result) 158 - return result; 159 - } 160 - } 161 - 162 - if (fn->post_visit_pci_dev) 163 - result = fn->post_visit_pci_dev(wrapped_dev, wrapped_parent); 164 - 165 - return result; 166 - } 167 - EXPORT_SYMBOL(pci_visit_dev);
··· 52 if ((buffer_size - length <= 0) || (i >= num_envp)) 53 return -ENOMEM; 54 55 + envp[i++] = scratch; 56 + length += scnprintf (scratch, buffer_size - length, 57 + "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n", 58 + pdev->vendor, pdev->device, 59 + pdev->subsystem_vendor, pdev->subsystem_device, 60 + (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), 61 + (u8)(pdev->class)); 62 + if ((buffer_size - length <= 0) || (i >= num_envp)) 63 + return -ENOMEM; 64 + 65 envp[i] = NULL; 66 67 return 0; 68 }
+1 -1
drivers/pci/hotplug/cpci_hotplug.h
··· 31 #include <linux/types.h> 32 #include <linux/pci.h> 33 34 - /* PICMG 2.12 R2.0 HS CSR bits: */ 35 #define HS_CSR_INS 0x0080 36 #define HS_CSR_EXT 0x0040 37 #define HS_CSR_PI 0x0030
··· 31 #include <linux/types.h> 32 #include <linux/pci.h> 33 34 + /* PICMG 2.1 R2.0 HS CSR bits: */ 35 #define HS_CSR_INS 0x0080 36 #define HS_CSR_EXT 0x0040 37 #define HS_CSR_PI 0x0030
+86 -83
drivers/pci/hotplug/cpci_hotplug_core.c
··· 33 #include <linux/init.h> 34 #include <linux/interrupt.h> 35 #include <linux/smp_lock.h> 36 #include <linux/delay.h> 37 #include "pci_hotplug.h" 38 #include "cpci_hotplug.h" 39 40 - #define DRIVER_VERSION "0.2" 41 #define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>" 42 #define DRIVER_DESC "CompactPCI Hot Plug Core" 43 ··· 54 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 55 56 /* local variables */ 57 - static spinlock_t list_lock; 58 static LIST_HEAD(slot_list); 59 static int slots; 60 int cpci_debug; 61 static struct cpci_hp_controller *controller; 62 static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ ··· 69 static int set_attention_status(struct hotplug_slot *slot, u8 value); 70 static int get_power_status(struct hotplug_slot *slot, u8 * value); 71 static int get_attention_status(struct hotplug_slot *slot, u8 * value); 72 73 static struct hotplug_slot_ops cpci_hotplug_slot_ops = { 74 .owner = THIS_MODULE, ··· 79 .set_attention_status = set_attention_status, 80 .get_power_status = get_power_status, 81 .get_attention_status = get_attention_status, 82 }; 83 84 static int ··· 153 warn("failure to update adapter file"); 154 } 155 156 - slot->extracting = 0; 157 - 158 return retval; 159 } 160 ··· 193 set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) 194 { 195 return cpci_set_attention_status(hotplug_slot->private, status); 196 } 197 198 static void release_slot(struct hotplug_slot *hotplug_slot) ··· 294 } 295 296 /* Add slot to our internal list */ 297 - spin_lock(&list_lock); 298 list_add(&slot->slot_list, &slot_list); 299 slots++; 300 - spin_unlock(&list_lock); 301 } 302 return 0; 303 error_name: ··· 320 struct list_head *next; 321 int status; 322 323 - spin_lock(&list_lock); 324 if(!slots) { 325 - spin_unlock(&list_lock); 326 return -1; 327 } 328 list_for_each_safe(tmp, next, &slot_list) { ··· 340 slots--; 341 } 342 } 343 - spin_unlock(&list_lock); 344 return 0; 345 } 346 ··· 368 } 369 370 /* 371 - * According to PICMG 2.12 R2.0, section 6.3.2, upon 372 * initialization, the system driver shall clear the 373 * INS bits of the cold-inserted devices. 374 */ ··· 380 struct pci_dev* dev; 381 382 dbg("%s - enter", __FUNCTION__); 383 - spin_lock(&list_lock); 384 if(!slots) { 385 - spin_unlock(&list_lock); 386 return -1; 387 } 388 list_for_each(tmp, &slot_list) { ··· 407 } 408 } 409 } 410 - spin_unlock(&list_lock); 411 dbg("%s - exit", __FUNCTION__); 412 return 0; 413 } ··· 419 struct list_head *tmp; 420 int extracted; 421 int inserted; 422 423 - spin_lock(&list_lock); 424 if(!slots) { 425 - spin_unlock(&list_lock); 426 err("no slots registered, shutting down"); 427 return -1; 428 } ··· 433 dbg("%s - looking at slot %s", 434 __FUNCTION__, slot->hotplug_slot->name); 435 if(cpci_check_and_clear_ins(slot)) { 436 - u16 hs_csr; 437 - 438 /* Some broken hardware (e.g. PLX 9054AB) asserts ENUM# twice... */ 439 if(slot->dev) { 440 warn("slot %s already inserted", slot->hotplug_slot->name); ··· 482 483 inserted++; 484 } else if(cpci_check_ext(slot)) { 485 - u16 hs_csr; 486 - 487 /* Process extraction request */ 488 dbg("%s - slot %s extracted", 489 __FUNCTION__, slot->hotplug_slot->name); ··· 494 if(!slot->extracting) { 495 if(update_latch_status(slot->hotplug_slot, 0)) { 496 warn("failure to update latch file"); 497 } 498 slot->extracting = 1; 499 } 500 extracted++; 501 } 502 } 503 - spin_unlock(&list_lock); 504 if(inserted || extracted) { 505 return extracted; 506 } 507 - else { 508 err("cannot find ENUM# source, shutting down"); 509 return -1; 510 } 511 } 512 513 /* This is the interrupt mode worker thread body */ ··· 535 event_thread(void *data) 536 { 537 int rc; 538 - struct slot *slot; 539 - struct list_head *tmp; 540 541 lock_kernel(); 542 daemonize("cpci_hp_eventd"); ··· 548 thread_finished); 549 if(thread_finished || signal_pending(current)) 550 break; 551 - while(controller->ops->query_enum()) { 552 rc = check_slots(); 553 - if (rc > 0) 554 /* Give userspace a chance to handle extraction */ 555 msleep(500); 556 - else if (rc < 0) { 557 dbg("%s - error checking slots", __FUNCTION__); 558 thread_finished = 1; 559 break; 560 } 561 - } 562 - /* Check for someone yanking out a board */ 563 - list_for_each(tmp, &slot_list) { 564 - slot = list_entry(tmp, struct slot, slot_list); 565 - if(slot->extracting) { 566 - /* 567 - * Hmmm, we're likely hosed at this point, should we 568 - * bother trying to tell the driver or not? 569 - */ 570 - err("card in slot %s was improperly removed", 571 - slot->hotplug_slot->name); 572 - if(update_adapter_status(slot->hotplug_slot, 0)) { 573 - warn("failure to update adapter file"); 574 - } 575 - slot->extracting = 0; 576 - } 577 - } 578 579 /* Re-enable ENUM# interrupt */ 580 dbg("%s - re-enabling irq", __FUNCTION__); 581 controller->ops->enable_irq(); 582 } 583 - 584 dbg("%s - event thread signals exit", __FUNCTION__); 585 up(&thread_exit); 586 return 0; ··· 574 poll_thread(void *data) 575 { 576 int rc; 577 - struct slot *slot; 578 - struct list_head *tmp; 579 580 lock_kernel(); 581 daemonize("cpci_hp_polld"); ··· 582 while(1) { 583 if(thread_finished || signal_pending(current)) 584 break; 585 - 586 - while(controller->ops->query_enum()) { 587 - rc = check_slots(); 588 - if(rc > 0) 589 - /* Give userspace a chance to handle extraction */ 590 - msleep(500); 591 - else if (rc < 0) { 592 - dbg("%s - error checking slots", __FUNCTION__); 593 - thread_finished = 1; 594 - break; 595 - } 596 - } 597 - /* Check for someone yanking out a board */ 598 - list_for_each(tmp, &slot_list) { 599 - slot = list_entry(tmp, struct slot, slot_list); 600 - if(slot->extracting) { 601 - /* 602 - * Hmmm, we're likely hosed at this point, should we 603 - * bother trying to tell the driver or not? 604 - */ 605 - err("card in slot %s was improperly removed", 606 - slot->hotplug_slot->name); 607 - if(update_adapter_status(slot->hotplug_slot, 0)) { 608 - warn("failure to update adapter file"); 609 } 610 - slot->extracting = 0; 611 - } 612 } 613 - 614 msleep(100); 615 } 616 dbg("poll thread signals exit"); ··· 668 int status = 0; 669 670 if(controller) { 671 if(!thread_finished) { 672 cpci_stop_thread(); 673 } ··· 695 return -ENODEV; 696 } 697 698 - spin_lock(&list_lock); 699 - if(!slots) { 700 - spin_unlock(&list_lock); 701 return -ENODEV; 702 } 703 - spin_unlock(&list_lock); 704 705 if(first) { 706 status = init_slots(); ··· 731 if(!controller) { 732 return -ENODEV; 733 } 734 - 735 if(controller->irq) { 736 /* Stop enum interrupt processing */ 737 dbg("%s - disabling irq", __FUNCTION__); ··· 753 * Unregister all of our slots with the pci_hotplug subsystem, 754 * and free up all memory that we had allocated. 755 */ 756 - spin_lock(&list_lock); 757 if(!slots) { 758 goto null_cleanup; 759 } ··· 767 kfree(slot); 768 } 769 null_cleanup: 770 - spin_unlock(&list_lock); 771 return; 772 } 773 774 int __init 775 cpci_hotplug_init(int debug) 776 { 777 - spin_lock_init(&list_lock); 778 cpci_debug = debug; 779 - 780 - info(DRIVER_DESC " version: " DRIVER_VERSION); 781 return 0; 782 } 783
··· 33 #include <linux/init.h> 34 #include <linux/interrupt.h> 35 #include <linux/smp_lock.h> 36 + #include <asm/atomic.h> 37 #include <linux/delay.h> 38 #include "pci_hotplug.h" 39 #include "cpci_hotplug.h" 40 41 #define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>" 42 #define DRIVER_DESC "CompactPCI Hot Plug Core" 43 ··· 54 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 55 56 /* local variables */ 57 + static DECLARE_RWSEM(list_rwsem); 58 static LIST_HEAD(slot_list); 59 static int slots; 60 + static atomic_t extracting; 61 int cpci_debug; 62 static struct cpci_hp_controller *controller; 63 static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ ··· 68 static int set_attention_status(struct hotplug_slot *slot, u8 value); 69 static int get_power_status(struct hotplug_slot *slot, u8 * value); 70 static int get_attention_status(struct hotplug_slot *slot, u8 * value); 71 + static int get_adapter_status(struct hotplug_slot *slot, u8 * value); 72 + static int get_latch_status(struct hotplug_slot *slot, u8 * value); 73 74 static struct hotplug_slot_ops cpci_hotplug_slot_ops = { 75 .owner = THIS_MODULE, ··· 76 .set_attention_status = set_attention_status, 77 .get_power_status = get_power_status, 78 .get_attention_status = get_attention_status, 79 + .get_adapter_status = get_adapter_status, 80 + .get_latch_status = get_latch_status, 81 }; 82 83 static int ··· 148 warn("failure to update adapter file"); 149 } 150 151 + if(slot->extracting) { 152 + slot->extracting = 0; 153 + atomic_dec(&extracting); 154 + } 155 return retval; 156 } 157 ··· 186 set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) 187 { 188 return cpci_set_attention_status(hotplug_slot->private, status); 189 + } 190 + 191 + static int 192 + get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value) 193 + { 194 + *value = hotplug_slot->info->adapter_status; 195 + return 0; 196 + } 197 + 198 + static int 199 + get_latch_status(struct hotplug_slot *hotplug_slot, u8 * value) 200 + { 201 + *value = hotplug_slot->info->latch_status; 202 + return 0; 203 } 204 205 static void release_slot(struct hotplug_slot *hotplug_slot) ··· 273 } 274 275 /* Add slot to our internal list */ 276 + down_write(&list_rwsem); 277 list_add(&slot->slot_list, &slot_list); 278 slots++; 279 + up_write(&list_rwsem); 280 } 281 return 0; 282 error_name: ··· 299 struct list_head *next; 300 int status; 301 302 + down_write(&list_rwsem); 303 if(!slots) { 304 + up_write(&list_rwsem); 305 return -1; 306 } 307 list_for_each_safe(tmp, next, &slot_list) { ··· 319 slots--; 320 } 321 } 322 + up_write(&list_rwsem); 323 return 0; 324 } 325 ··· 347 } 348 349 /* 350 + * According to PICMG 2.1 R2.0, section 6.3.2, upon 351 * initialization, the system driver shall clear the 352 * INS bits of the cold-inserted devices. 353 */ ··· 359 struct pci_dev* dev; 360 361 dbg("%s - enter", __FUNCTION__); 362 + down_read(&list_rwsem); 363 if(!slots) { 364 + up_read(&list_rwsem); 365 return -1; 366 } 367 list_for_each(tmp, &slot_list) { ··· 386 } 387 } 388 } 389 + up_read(&list_rwsem); 390 dbg("%s - exit", __FUNCTION__); 391 return 0; 392 } ··· 398 struct list_head *tmp; 399 int extracted; 400 int inserted; 401 + u16 hs_csr; 402 403 + down_read(&list_rwsem); 404 if(!slots) { 405 + up_read(&list_rwsem); 406 err("no slots registered, shutting down"); 407 return -1; 408 } ··· 411 dbg("%s - looking at slot %s", 412 __FUNCTION__, slot->hotplug_slot->name); 413 if(cpci_check_and_clear_ins(slot)) { 414 /* Some broken hardware (e.g. PLX 9054AB) asserts ENUM# twice... */ 415 if(slot->dev) { 416 warn("slot %s already inserted", slot->hotplug_slot->name); ··· 462 463 inserted++; 464 } else if(cpci_check_ext(slot)) { 465 /* Process extraction request */ 466 dbg("%s - slot %s extracted", 467 __FUNCTION__, slot->hotplug_slot->name); ··· 476 if(!slot->extracting) { 477 if(update_latch_status(slot->hotplug_slot, 0)) { 478 warn("failure to update latch file"); 479 + 480 } 481 + atomic_inc(&extracting); 482 slot->extracting = 1; 483 } 484 extracted++; 485 + } else if(slot->extracting) { 486 + hs_csr = cpci_get_hs_csr(slot); 487 + if(hs_csr == 0xffff) { 488 + /* 489 + * Hmmm, we're likely hosed at this point, should we 490 + * bother trying to tell the driver or not? 491 + */ 492 + err("card in slot %s was improperly removed", 493 + slot->hotplug_slot->name); 494 + if(update_adapter_status(slot->hotplug_slot, 0)) { 495 + warn("failure to update adapter file"); 496 + } 497 + slot->extracting = 0; 498 + atomic_dec(&extracting); 499 + } 500 } 501 } 502 + up_read(&list_rwsem); 503 + dbg("inserted=%d, extracted=%d, extracting=%d", 504 + inserted, extracted, atomic_read(&extracting)); 505 if(inserted || extracted) { 506 return extracted; 507 } 508 + else if(!atomic_read(&extracting)) { 509 err("cannot find ENUM# source, shutting down"); 510 return -1; 511 } 512 + return 0; 513 } 514 515 /* This is the interrupt mode worker thread body */ ··· 497 event_thread(void *data) 498 { 499 int rc; 500 501 lock_kernel(); 502 daemonize("cpci_hp_eventd"); ··· 512 thread_finished); 513 if(thread_finished || signal_pending(current)) 514 break; 515 + do { 516 rc = check_slots(); 517 + if (rc > 0) { 518 /* Give userspace a chance to handle extraction */ 519 msleep(500); 520 + } else if (rc < 0) { 521 dbg("%s - error checking slots", __FUNCTION__); 522 thread_finished = 1; 523 break; 524 } 525 + } while(atomic_read(&extracting) != 0); 526 527 /* Re-enable ENUM# interrupt */ 528 dbg("%s - re-enabling irq", __FUNCTION__); 529 controller->ops->enable_irq(); 530 } 531 dbg("%s - event thread signals exit", __FUNCTION__); 532 up(&thread_exit); 533 return 0; ··· 555 poll_thread(void *data) 556 { 557 int rc; 558 559 lock_kernel(); 560 daemonize("cpci_hp_polld"); ··· 565 while(1) { 566 if(thread_finished || signal_pending(current)) 567 break; 568 + if(controller->ops->query_enum()) { 569 + do { 570 + rc = check_slots(); 571 + if(rc > 0) { 572 + /* Give userspace a chance to handle extraction */ 573 + msleep(500); 574 + } else if(rc < 0) { 575 + dbg("%s - error checking slots", __FUNCTION__); 576 + thread_finished = 1; 577 + break; 578 } 579 + } while(atomic_read(&extracting) != 0); 580 } 581 msleep(100); 582 } 583 dbg("poll thread signals exit"); ··· 667 int status = 0; 668 669 if(controller) { 670 + if(atomic_read(&extracting) != 0) { 671 + return -EBUSY; 672 + } 673 if(!thread_finished) { 674 cpci_stop_thread(); 675 } ··· 691 return -ENODEV; 692 } 693 694 + down_read(&list_rwsem); 695 + if(list_empty(&slot_list)) { 696 + up_read(&list_rwsem); 697 return -ENODEV; 698 } 699 + up_read(&list_rwsem); 700 701 if(first) { 702 status = init_slots(); ··· 727 if(!controller) { 728 return -ENODEV; 729 } 730 + if(atomic_read(&extracting) != 0) { 731 + return -EBUSY; 732 + } 733 if(controller->irq) { 734 /* Stop enum interrupt processing */ 735 dbg("%s - disabling irq", __FUNCTION__); ··· 747 * Unregister all of our slots with the pci_hotplug subsystem, 748 * and free up all memory that we had allocated. 749 */ 750 + down_write(&list_rwsem); 751 if(!slots) { 752 goto null_cleanup; 753 } ··· 761 kfree(slot); 762 } 763 null_cleanup: 764 + up_write(&list_rwsem); 765 return; 766 } 767 768 int __init 769 cpci_hotplug_init(int debug) 770 { 771 cpci_debug = debug; 772 return 0; 773 } 774
+26 -328
drivers/pci/hotplug/cpci_hotplug_pci.c
··· 32 #include "pci_hotplug.h" 33 #include "cpci_hotplug.h" 34 35 - #if !defined(MODULE) 36 #define MY_NAME "cpci_hotplug" 37 - #else 38 - #define MY_NAME THIS_MODULE->name 39 - #endif 40 41 extern int cpci_debug; 42 ··· 122 } 123 return hs_csr; 124 } 125 - 126 - #if 0 127 - u16 cpci_set_hs_csr(struct slot* slot, u16 hs_csr) 128 - { 129 - int hs_cap; 130 - u16 new_hs_csr; 131 - 132 - hs_cap = pci_bus_find_capability(slot->bus, 133 - slot->devfn, 134 - PCI_CAP_ID_CHSWP); 135 - if(!hs_cap) { 136 - return 0xFFFF; 137 - } 138 - 139 - /* Write out the new value */ 140 - if(pci_bus_write_config_word(slot->bus, 141 - slot->devfn, 142 - hs_cap + 2, 143 - hs_csr)) { 144 - return 0xFFFF; 145 - } 146 - 147 - /* Read back what we just wrote out */ 148 - if(pci_bus_read_config_word(slot->bus, 149 - slot->devfn, 150 - hs_cap + 2, 151 - &new_hs_csr)) { 152 - return 0xFFFF; 153 - } 154 - return new_hs_csr; 155 - } 156 - #endif 157 158 int cpci_check_and_clear_ins(struct slot* slot) 159 { ··· 225 return -ENODEV; 226 } 227 if((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) { 228 - /* Set LOO */ 229 hs_csr |= HS_CSR_LOO; 230 if(pci_bus_write_config_word(slot->bus, 231 slot->devfn, ··· 256 return -ENODEV; 257 } 258 if(hs_csr & HS_CSR_LOO) { 259 - /* Clear LOO */ 260 hs_csr &= ~HS_CSR_LOO; 261 if(pci_bus_write_config_word(slot->bus, 262 slot->devfn, ··· 274 * Device configuration functions 275 */ 276 277 - static int cpci_configure_dev(struct pci_bus *bus, struct pci_dev *dev) 278 { 279 - u8 irq_pin; 280 - int r; 281 282 - dbg("%s - enter", __FUNCTION__); 283 - 284 - /* NOTE: device already setup from prior scan */ 285 - 286 - /* FIXME: How would we know if we need to enable the expansion ROM? */ 287 - pci_write_config_word(dev, PCI_ROM_ADDRESS, 0x00L); 288 - 289 - /* Assign resources */ 290 - dbg("assigning resources for %02x:%02x.%x", 291 - dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); 292 - for (r = 0; r < 6; r++) { 293 - struct resource *res = dev->resource + r; 294 - if(res->flags) 295 - pci_assign_resource(dev, r); 296 - } 297 - dbg("finished assigning resources for %02x:%02x.%x", 298 - dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); 299 - 300 - /* Does this function have an interrupt at all? */ 301 - dbg("checking for function interrupt"); 302 - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq_pin); 303 - if(irq_pin) { 304 - dbg("function uses interrupt pin %d", irq_pin); 305 - } 306 - 307 - /* 308 - * Need to explicitly set irq field to 0 so that it'll get assigned 309 - * by the pcibios platform dependent code called by pci_enable_device. 310 - */ 311 - dev->irq = 0; 312 - 313 - dbg("enabling device"); 314 - pci_enable_device(dev); /* XXX check return */ 315 - dbg("now dev->irq = %d", dev->irq); 316 - if(irq_pin && dev->irq) { 317 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 318 - } 319 - 320 - /* Can't use pci_insert_device at the moment, do it manually for now */ 321 - pci_proc_attach_device(dev); 322 - dbg("notifying drivers"); 323 - //pci_announce_device_to_drivers(dev); 324 - dbg("%s - exit", __FUNCTION__); 325 - return 0; 326 - } 327 - 328 - static int cpci_configure_bridge(struct pci_bus* bus, struct pci_dev* dev) 329 - { 330 - int rc; 331 - struct pci_bus* child; 332 - struct resource* r; 333 - u8 max, n; 334 - u16 command; 335 - 336 - dbg("%s - enter", __FUNCTION__); 337 - 338 - /* Do basic bridge initialization */ 339 - rc = pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x40); 340 - if(rc) { 341 - printk(KERN_ERR "%s - write of PCI_LATENCY_TIMER failed\n", __FUNCTION__); 342 - } 343 - rc = pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 0x40); 344 - if(rc) { 345 - printk(KERN_ERR "%s - write of PCI_SEC_LATENCY_TIMER failed\n", __FUNCTION__); 346 - } 347 - rc = pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4); 348 - if(rc) { 349 - printk(KERN_ERR "%s - write of PCI_CACHE_LINE_SIZE failed\n", __FUNCTION__); 350 - } 351 - 352 - /* 353 - * Set parent bridge's subordinate field so that configuration space 354 - * access will work in pci_scan_bridge and friends. 355 - */ 356 - max = pci_max_busnr(); 357 - bus->subordinate = max + 1; 358 - pci_write_config_byte(bus->self, PCI_SUBORDINATE_BUS, max + 1); 359 - 360 - /* Scan behind bridge */ 361 - n = pci_scan_bridge(bus, dev, max, 2); 362 - child = pci_find_bus(0, max + 1); 363 - if (!child) 364 - return -ENODEV; 365 - pci_proc_attach_bus(child); 366 - 367 - /* 368 - * Update parent bridge's subordinate field if there were more bridges 369 - * behind the bridge that was scanned. 370 - */ 371 - if(n > max) { 372 - bus->subordinate = n; 373 - pci_write_config_byte(bus->self, PCI_SUBORDINATE_BUS, n); 374 - } 375 - 376 - /* 377 - * Update the bridge resources of the bridge to accommodate devices 378 - * behind it. 379 - */ 380 - pci_bus_size_bridges(child); 381 - pci_bus_assign_resources(child); 382 - 383 - /* Enable resource mapping via command register */ 384 - command = PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY | PCI_COMMAND_SERR; 385 - r = child->resource[0]; 386 - if(r && r->start) { 387 - command |= PCI_COMMAND_IO; 388 - } 389 - r = child->resource[1]; 390 - if(r && r->start) { 391 - command |= PCI_COMMAND_MEMORY; 392 - } 393 - r = child->resource[2]; 394 - if(r && r->start) { 395 - command |= PCI_COMMAND_MEMORY; 396 - } 397 - rc = pci_write_config_word(dev, PCI_COMMAND, command); 398 - if(rc) { 399 - err("Error setting command register"); 400 - return rc; 401 - } 402 - 403 - /* Set bridge control register */ 404 - command = PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR | PCI_BRIDGE_CTL_NO_ISA; 405 - rc = pci_write_config_word(dev, PCI_BRIDGE_CONTROL, command); 406 - if(rc) { 407 - err("Error setting bridge control register"); 408 - return rc; 409 - } 410 - dbg("%s - exit", __FUNCTION__); 411 - return 0; 412 - } 413 - 414 - static int configure_visit_pci_dev(struct pci_dev_wrapped *wrapped_dev, 415 - struct pci_bus_wrapped *wrapped_bus) 416 - { 417 - int rc; 418 - struct pci_dev *dev = wrapped_dev->dev; 419 - struct pci_bus *bus = wrapped_bus->bus; 420 - struct slot* slot; 421 - 422 - dbg("%s - enter", __FUNCTION__); 423 - 424 - /* 425 - * We need to fix up the hotplug representation with the Linux 426 - * representation. 427 - */ 428 - if(wrapped_dev->data) { 429 - slot = (struct slot*) wrapped_dev->data; 430 - slot->dev = dev; 431 - } 432 - 433 - /* If it's a bridge, scan behind it for devices */ 434 if(dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 435 - rc = cpci_configure_bridge(bus, dev); 436 - if(rc) 437 - return rc; 438 - } 439 - 440 - /* Actually configure device */ 441 - if(dev) { 442 - rc = cpci_configure_dev(bus, dev); 443 - if(rc) 444 - return rc; 445 - } 446 - dbg("%s - exit", __FUNCTION__); 447 - return 0; 448 - } 449 - 450 - static int unconfigure_visit_pci_dev_phase2(struct pci_dev_wrapped *wrapped_dev, 451 - struct pci_bus_wrapped *wrapped_bus) 452 - { 453 - struct pci_dev *dev = wrapped_dev->dev; 454 - struct slot* slot; 455 - 456 - dbg("%s - enter", __FUNCTION__); 457 - if(!dev) 458 - return -ENODEV; 459 - 460 - /* Remove the Linux representation */ 461 - if(pci_remove_device_safe(dev)) { 462 - err("Could not remove device\n"); 463 - return -1; 464 - } 465 - 466 - /* 467 - * Now remove the hotplug representation. 468 - */ 469 - if(wrapped_dev->data) { 470 - slot = (struct slot*) wrapped_dev->data; 471 - slot->dev = NULL; 472 - } else { 473 - dbg("No hotplug representation for %02x:%02x.%x", 474 - dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); 475 - } 476 - dbg("%s - exit", __FUNCTION__); 477 - return 0; 478 - } 479 - 480 - static int unconfigure_visit_pci_bus_phase2(struct pci_bus_wrapped *wrapped_bus, 481 - struct pci_dev_wrapped *wrapped_dev) 482 - { 483 - struct pci_bus *bus = wrapped_bus->bus; 484 - struct pci_bus *parent = bus->self->bus; 485 - 486 - dbg("%s - enter", __FUNCTION__); 487 - 488 - /* The cleanup code for proc entries regarding buses should be in the kernel... */ 489 - if(bus->procdir) 490 - dbg("detach_pci_bus %s", bus->procdir->name); 491 - pci_proc_detach_bus(bus); 492 - 493 - /* The cleanup code should live in the kernel... */ 494 - bus->self->subordinate = NULL; 495 - 496 - /* unlink from parent bus */ 497 - list_del(&bus->node); 498 - 499 - /* Now, remove */ 500 - if(bus) 501 - kfree(bus); 502 - 503 - /* Update parent's subordinate field */ 504 - if(parent) { 505 - u8 n = pci_bus_max_busnr(parent); 506 - if(n < parent->subordinate) { 507 - parent->subordinate = n; 508 - pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, n); 509 } 510 } 511 - dbg("%s - exit", __FUNCTION__); 512 - return 0; 513 } 514 - 515 - static struct pci_visit configure_functions = { 516 - .visit_pci_dev = configure_visit_pci_dev, 517 - }; 518 - 519 - static struct pci_visit unconfigure_functions_phase2 = { 520 - .post_visit_pci_bus = unconfigure_visit_pci_bus_phase2, 521 - .post_visit_pci_dev = unconfigure_visit_pci_dev_phase2 522 - }; 523 - 524 525 int cpci_configure_slot(struct slot* slot) 526 { 527 - int rc = 0; 528 529 dbg("%s - enter", __FUNCTION__); 530 ··· 316 slot->dev = pci_find_slot(slot->bus->number, slot->devfn); 317 if(slot->dev == NULL) { 318 err("Could not find PCI device for slot %02x", slot->number); 319 - return 0; 320 - } 321 - } 322 - dbg("slot->dev = %p", slot->dev); 323 - if(slot->dev) { 324 - struct pci_dev *dev; 325 - struct pci_dev_wrapped wrapped_dev; 326 - struct pci_bus_wrapped wrapped_bus; 327 - int i; 328 - 329 - memset(&wrapped_dev, 0, sizeof (struct pci_dev_wrapped)); 330 - memset(&wrapped_bus, 0, sizeof (struct pci_bus_wrapped)); 331 - 332 - for (i = 0; i < 8; i++) { 333 - dev = pci_find_slot(slot->bus->number, 334 - PCI_DEVFN(PCI_SLOT(slot->dev->devfn), i)); 335 - if(!dev) 336 - continue; 337 - wrapped_dev.dev = dev; 338 - wrapped_bus.bus = slot->dev->bus; 339 - if(i) 340 - wrapped_dev.data = NULL; 341 - else 342 - wrapped_dev.data = (void*) slot; 343 - rc = pci_visit_dev(&configure_functions, &wrapped_dev, &wrapped_bus); 344 } 345 } 346 347 - dbg("%s - exit, rc = %d", __FUNCTION__, rc); 348 - return rc; 349 } 350 351 int cpci_unconfigure_slot(struct slot* slot) 352 { 353 - int rc = 0; 354 int i; 355 - struct pci_dev_wrapped wrapped_dev; 356 - struct pci_bus_wrapped wrapped_bus; 357 struct pci_dev *dev; 358 359 dbg("%s - enter", __FUNCTION__); 360 - 361 if(!slot->dev) { 362 err("No device for slot %02x\n", slot->number); 363 return -ENODEV; 364 } 365 366 - memset(&wrapped_dev, 0, sizeof (struct pci_dev_wrapped)); 367 - memset(&wrapped_bus, 0, sizeof (struct pci_bus_wrapped)); 368 - 369 for (i = 0; i < 8; i++) { 370 dev = pci_find_slot(slot->bus->number, 371 PCI_DEVFN(PCI_SLOT(slot->devfn), i)); 372 if(dev) { 373 - wrapped_dev.dev = dev; 374 - wrapped_bus.bus = dev->bus; 375 - if(i) 376 - wrapped_dev.data = NULL; 377 - else 378 - wrapped_dev.data = (void*) slot; 379 - dbg("%s - unconfigure phase 2", __FUNCTION__); 380 - rc = pci_visit_dev(&unconfigure_functions_phase2, 381 - &wrapped_dev, 382 - &wrapped_bus); 383 - if(rc) 384 - break; 385 } 386 } 387 - dbg("%s - exit, rc = %d", __FUNCTION__, rc); 388 - return rc; 389 }
··· 32 #include "pci_hotplug.h" 33 #include "cpci_hotplug.h" 34 35 #define MY_NAME "cpci_hotplug" 36 37 extern int cpci_debug; 38 ··· 126 } 127 return hs_csr; 128 } 129 130 int cpci_check_and_clear_ins(struct slot* slot) 131 { ··· 261 return -ENODEV; 262 } 263 if((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) { 264 hs_csr |= HS_CSR_LOO; 265 if(pci_bus_write_config_word(slot->bus, 266 slot->devfn, ··· 293 return -ENODEV; 294 } 295 if(hs_csr & HS_CSR_LOO) { 296 hs_csr &= ~HS_CSR_LOO; 297 if(pci_bus_write_config_word(slot->bus, 298 slot->devfn, ··· 312 * Device configuration functions 313 */ 314 315 + static void cpci_enable_device(struct pci_dev *dev) 316 { 317 + struct pci_bus *bus; 318 319 + pci_enable_device(dev); 320 if(dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 321 + bus = dev->subordinate; 322 + list_for_each_entry(dev, &bus->devices, bus_list) { 323 + cpci_enable_device(dev); 324 } 325 } 326 } 327 328 int cpci_configure_slot(struct slot* slot) 329 { 330 + unsigned char busnr; 331 + struct pci_bus *child; 332 333 dbg("%s - enter", __FUNCTION__); 334 ··· 588 slot->dev = pci_find_slot(slot->bus->number, slot->devfn); 589 if(slot->dev == NULL) { 590 err("Could not find PCI device for slot %02x", slot->number); 591 + return 1; 592 } 593 } 594 595 + if (slot->dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 596 + pci_read_config_byte(slot->dev, PCI_SECONDARY_BUS, &busnr); 597 + child = pci_add_new_bus(slot->dev->bus, slot->dev, busnr); 598 + pci_do_scan_bus(child); 599 + pci_bus_size_bridges(child); 600 + } 601 + 602 + pci_bus_assign_resources(slot->dev->bus); 603 + 604 + cpci_enable_device(slot->dev); 605 + 606 + dbg("%s - exit", __FUNCTION__); 607 + return 0; 608 } 609 610 int cpci_unconfigure_slot(struct slot* slot) 611 { 612 int i; 613 struct pci_dev *dev; 614 615 dbg("%s - enter", __FUNCTION__); 616 if(!slot->dev) { 617 err("No device for slot %02x\n", slot->number); 618 return -ENODEV; 619 } 620 621 for (i = 0; i < 8; i++) { 622 dev = pci_find_slot(slot->bus->number, 623 PCI_DEVFN(PCI_SLOT(slot->devfn), i)); 624 if(dev) { 625 + pci_remove_bus_device(dev); 626 + slot->dev = NULL; 627 } 628 } 629 + dbg("%s - exit", __FUNCTION__); 630 + return 0; 631 }
+1
drivers/pci/hotplug/pciehp.h
··· 130 u8 slot_bus; /* Bus where the slots handled by this controller sit */ 131 u8 ctrlcap; 132 u16 vendor_id; 133 }; 134 135 struct irq_mapping {
··· 130 u8 slot_bus; /* Bus where the slots handled by this controller sit */ 131 u8 ctrlcap; 132 u16 vendor_id; 133 + u8 cap_base; 134 }; 135 136 struct irq_mapping {
+1 -1
drivers/pci/hotplug/pciehp_core.c
··· 607 static struct pcie_port_service_id port_pci_ids[] = { { 608 .vendor = PCI_ANY_ID, 609 .device = PCI_ANY_ID, 610 - .port_type = PCIE_RC_PORT, 611 .service_type = PCIE_PORT_SERVICE_HP, 612 .driver_data = 0, 613 }, { /* end: all zeroes */ }
··· 607 static struct pcie_port_service_id port_pci_ids[] = { { 608 .vendor = PCI_ANY_ID, 609 .device = PCI_ANY_ID, 610 + .port_type = PCIE_ANY_PORT, 611 .service_type = PCIE_PORT_SERVICE_HP, 612 .driver_data = 0, 613 }, { /* end: all zeroes */ }
+79 -77
drivers/pci/hotplug/pciehp_hpc.c
··· 109 }; 110 static int pcie_cap_base = 0; /* Base of the PCI Express capability item structure */ 111 112 - #define PCIE_CAP_ID ( pcie_cap_base + PCIECAPID ) 113 - #define NXT_CAP_PTR ( pcie_cap_base + NXTCAPPTR ) 114 - #define CAP_REG ( pcie_cap_base + CAPREG ) 115 - #define DEV_CAP ( pcie_cap_base + DEVCAP ) 116 - #define DEV_CTRL ( pcie_cap_base + DEVCTRL ) 117 - #define DEV_STATUS ( pcie_cap_base + DEVSTATUS ) 118 - #define LNK_CAP ( pcie_cap_base + LNKCAP ) 119 - #define LNK_CTRL ( pcie_cap_base + LNKCTRL ) 120 - #define LNK_STATUS ( pcie_cap_base + LNKSTATUS ) 121 - #define SLOT_CAP ( pcie_cap_base + SLOTCAP ) 122 - #define SLOT_CTRL ( pcie_cap_base + SLOTCTRL ) 123 - #define SLOT_STATUS ( pcie_cap_base + SLOTSTATUS ) 124 - #define ROOT_CTRL ( pcie_cap_base + ROOTCTRL ) 125 - #define ROOT_STATUS ( pcie_cap_base + ROOTSTATUS ) 126 127 #define hp_register_read_word(pdev, reg , value) \ 128 pci_read_config_word(pdev, reg, &value) ··· 303 return -1; 304 } 305 306 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 307 if (retval) { 308 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 309 return retval; ··· 317 } 318 319 dbg("%s: Before hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, cmd); 320 - retval = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, cmd | CMD_CMPL_INTR_ENABLE); 321 if (retval) { 322 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 323 return retval; ··· 342 return -1; 343 } 344 345 - retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 346 347 if (retval) { 348 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); ··· 376 return -1; 377 } 378 379 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 380 381 if (retval) { 382 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 383 return retval; 384 } 385 386 - dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__,SLOT_CTRL, slot_ctrl); 387 388 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6; 389 ··· 423 return -1; 424 } 425 426 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 427 428 if (retval) { 429 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 430 return retval; 431 } 432 - dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, slot_ctrl); 433 434 pwr_state = (slot_ctrl & PWR_CTRL) >> 10; 435 ··· 463 return -1; 464 } 465 466 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 467 468 if (retval) { 469 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); ··· 490 return -1; 491 } 492 493 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 494 495 if (retval) { 496 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); ··· 518 return -1; 519 } 520 521 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 522 523 if (retval) { 524 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); ··· 549 err("%s: Invalid HPC slot number!\n", __FUNCTION__); 550 return -1; 551 } 552 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 553 554 if (rc) { 555 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 574 slot_cmd = slot_cmd | HP_INTR_ENABLE; 575 576 pcie_write_cmd(slot, slot_cmd); 577 - dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL, slot_cmd); 578 579 return rc; 580 } ··· 598 return ; 599 } 600 601 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 602 603 if (rc) { 604 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 611 612 pcie_write_cmd(slot, slot_cmd); 613 614 - dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 615 return; 616 } 617 ··· 633 return ; 634 } 635 636 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 637 638 if (rc) { 639 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 646 if (!pciehp_poll_mode) 647 slot_cmd = slot_cmd | HP_INTR_ENABLE; 648 pcie_write_cmd(slot, slot_cmd); 649 - dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL, slot_cmd); 650 651 return; 652 } ··· 669 return ; 670 } 671 672 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 673 674 if (rc) { 675 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 683 slot_cmd = slot_cmd | HP_INTR_ENABLE; 684 pcie_write_cmd(slot, slot_cmd); 685 686 - dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 687 return; 688 } 689 ··· 707 *first_device_num = 0; 708 *num_ctlr_slots = 1; 709 710 - rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP, slot_cap); 711 712 if (rc) { 713 err("%s : hp_register_read_dword SLOT_CAP failed\n", __FUNCTION__); ··· 793 return -1; 794 } 795 796 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 797 798 if (retval) { 799 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 800 return retval; 801 } 802 - dbg("%s: SLOT_CTRL %x, value read %xn", __FUNCTION__, SLOT_CTRL, 803 slot_ctrl); 804 805 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON; ··· 813 err("%s: Write %x command failed!\n", __FUNCTION__, slot_cmd); 814 return -1; 815 } 816 - dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 817 818 DBG_LEAVE_ROUTINE 819 ··· 842 err("%s: Invalid HPC slot number!\n", __FUNCTION__); 843 return -1; 844 } 845 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 846 847 if (retval) { 848 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 849 return retval; 850 } 851 - dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__, SLOT_CTRL, 852 slot_ctrl); 853 854 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF; ··· 862 err("%s: Write command failed!\n", __FUNCTION__); 863 return -1; 864 } 865 - dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 866 867 DBG_LEAVE_ROUTINE 868 ··· 900 return IRQ_NONE; 901 } 902 903 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 904 if (rc) { 905 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 906 return IRQ_NONE; ··· 918 dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc); 919 /* Mask Hot-plug Interrupt Enable */ 920 if (!pciehp_poll_mode) { 921 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 922 if (rc) { 923 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 924 return IRQ_NONE; ··· 928 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 929 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 930 931 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 932 if (rc) { 933 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 934 return IRQ_NONE; 935 } 936 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 937 938 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 939 if (rc) { 940 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 941 return IRQ_NONE; ··· 944 945 /* Clear command complete interrupt caused by this write */ 946 temp_word = 0x1f; 947 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 948 if (rc) { 949 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 950 return IRQ_NONE; ··· 975 976 /* Clear all events after serving them */ 977 temp_word = 0x1F; 978 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 979 if (rc) { 980 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 981 return IRQ_NONE; 982 } 983 /* Unmask Hot-plug Interrupt Enable */ 984 if (!pciehp_poll_mode) { 985 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 986 if (rc) { 987 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 988 return IRQ_NONE; ··· 992 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 993 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE; 994 995 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 996 if (rc) { 997 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 998 return IRQ_NONE; 999 } 1000 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 1001 1002 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1003 if (rc) { 1004 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1005 return IRQ_NONE; ··· 1008 1009 /* Clear command complete interrupt caused by this write */ 1010 temp_word = 0x1F; 1011 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1012 if (rc) { 1013 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1014 return IRQ_NONE; ··· 1038 return -1; 1039 } 1040 1041 - retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP, lnk_cap); 1042 1043 if (retval) { 1044 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); ··· 1079 return -1; 1080 } 1081 1082 - retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP, lnk_cap); 1083 1084 if (retval) { 1085 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); ··· 1141 return -1; 1142 } 1143 1144 - retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 1145 1146 if (retval) { 1147 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); ··· 1182 return -1; 1183 } 1184 1185 - retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 1186 1187 if (retval) { 1188 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); ··· 1292 goto abort_free_ctlr; 1293 } 1294 1295 - pcie_cap_base = cap_base; 1296 1297 dbg("%s: pcie_cap_base %x\n", __FUNCTION__, pcie_cap_base); 1298 1299 - rc = hp_register_read_word(pdev, CAP_REG, cap_reg); 1300 if (rc) { 1301 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1302 goto abort_free_ctlr; 1303 } 1304 - dbg("%s: CAP_REG offset %x cap_reg %x\n", __FUNCTION__, CAP_REG, cap_reg); 1305 1306 - if (((cap_reg & SLOT_IMPL) == 0) || ((cap_reg & DEV_PORT_TYPE) != 0x0040)){ 1307 dbg("%s : This is not a root port or the port is not connected to a slot\n", __FUNCTION__); 1308 goto abort_free_ctlr; 1309 } 1310 1311 - rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP, slot_cap); 1312 if (rc) { 1313 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1314 goto abort_free_ctlr; 1315 } 1316 - dbg("%s: SLOT_CAP offset %x slot_cap %x\n", __FUNCTION__, SLOT_CAP, slot_cap); 1317 1318 if (!(slot_cap & HP_CAP)) { 1319 dbg("%s : This slot is not hot-plug capable\n", __FUNCTION__); 1320 goto abort_free_ctlr; 1321 } 1322 /* For debugging purpose */ 1323 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1324 if (rc) { 1325 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1326 goto abort_free_ctlr; 1327 } 1328 - dbg("%s: SLOT_STATUS offset %x slot_status %x\n", __FUNCTION__, SLOT_STATUS, slot_status); 1329 1330 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 1331 if (rc) { 1332 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1333 goto abort_free_ctlr; 1334 } 1335 - dbg("%s: SLOT_CTRL offset %x slot_ctrl %x\n", __FUNCTION__, SLOT_CTRL, slot_ctrl); 1336 1337 if (first) { 1338 spin_lock_init(&hpc_event_lock); ··· 1373 php_ctlr->num_slots = 1; 1374 1375 /* Mask Hot-plug Interrupt Enable */ 1376 - rc = hp_register_read_word(pdev, SLOT_CTRL, temp_word); 1377 if (rc) { 1378 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1379 goto abort_free_ctlr; 1380 } 1381 1382 - dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, temp_word); 1383 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 1384 1385 - rc = hp_register_write_word(pdev, SLOT_CTRL, temp_word); 1386 if (rc) { 1387 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1388 goto abort_free_ctlr; 1389 } 1390 dbg("%s : Mask HPIE hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, temp_word); 1391 1392 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1393 if (rc) { 1394 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1395 goto abort_free_ctlr; 1396 } 1397 - dbg("%s: Mask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, SLOT_STATUS, slot_status); 1398 1399 temp_word = 0x1F; /* Clear all events */ 1400 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1401 if (rc) { 1402 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1403 goto abort_free_ctlr; 1404 } 1405 - dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS, temp_word); 1406 1407 if (pciehp_poll_mode) {/* Install interrupt polling code */ 1408 /* Install and start the interrupt polling timer */ ··· 1419 } 1420 } 1421 1422 - rc = hp_register_read_word(pdev, SLOT_CTRL, temp_word); 1423 if (rc) { 1424 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1425 goto abort_free_ctlr; 1426 } 1427 - dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, temp_word); 1428 dbg("%s: slot_cap %x\n", __FUNCTION__, slot_cap); 1429 1430 intr_enable = intr_enable | PRSN_DETECT_ENABLE; ··· 1448 dbg("%s: temp_word %x\n", __FUNCTION__, temp_word); 1449 1450 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */ 1451 - rc = hp_register_write_word(pdev, SLOT_CTRL, temp_word); 1452 if (rc) { 1453 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1454 goto abort_free_ctlr; 1455 } 1456 dbg("%s : Unmask HPIE hp_register_write_word SLOT_CTRL with %x\n", __FUNCTION__, temp_word); 1457 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1458 if (rc) { 1459 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1460 goto abort_free_ctlr; 1461 } 1462 dbg("%s: Unmask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, 1463 - SLOT_STATUS, slot_status); 1464 1465 temp_word = 0x1F; /* Clear all events */ 1466 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1467 if (rc) { 1468 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1469 goto abort_free_ctlr; 1470 } 1471 - dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS, temp_word); 1472 1473 /* Add this HPC instance into the HPC list */ 1474 spin_lock(&list_lock);
··· 109 }; 110 static int pcie_cap_base = 0; /* Base of the PCI Express capability item structure */ 111 112 + #define PCIE_CAP_ID(cb) ( cb + PCIECAPID ) 113 + #define NXT_CAP_PTR(cb) ( cb + NXTCAPPTR ) 114 + #define CAP_REG(cb) ( cb + CAPREG ) 115 + #define DEV_CAP(cb) ( cb + DEVCAP ) 116 + #define DEV_CTRL(cb) ( cb + DEVCTRL ) 117 + #define DEV_STATUS(cb) ( cb + DEVSTATUS ) 118 + #define LNK_CAP(cb) ( cb + LNKCAP ) 119 + #define LNK_CTRL(cb) ( cb + LNKCTRL ) 120 + #define LNK_STATUS(cb) ( cb + LNKSTATUS ) 121 + #define SLOT_CAP(cb) ( cb + SLOTCAP ) 122 + #define SLOT_CTRL(cb) ( cb + SLOTCTRL ) 123 + #define SLOT_STATUS(cb) ( cb + SLOTSTATUS ) 124 + #define ROOT_CTRL(cb) ( cb + ROOTCTRL ) 125 + #define ROOT_STATUS(cb) ( cb + ROOTSTATUS ) 126 127 #define hp_register_read_word(pdev, reg , value) \ 128 pci_read_config_word(pdev, reg, &value) ··· 303 return -1; 304 } 305 306 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status); 307 if (retval) { 308 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 309 return retval; ··· 317 } 318 319 dbg("%s: Before hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, cmd); 320 + retval = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), cmd | CMD_CMPL_INTR_ENABLE); 321 if (retval) { 322 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 323 return retval; ··· 342 return -1; 343 } 344 345 + retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(ctrl->cap_base), lnk_status); 346 347 if (retval) { 348 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); ··· 376 return -1; 377 } 378 379 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 380 381 if (retval) { 382 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 383 return retval; 384 } 385 386 + dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__,SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 387 388 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6; 389 ··· 423 return -1; 424 } 425 426 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 427 428 if (retval) { 429 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 430 return retval; 431 } 432 + dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 433 434 pwr_state = (slot_ctrl & PWR_CTRL) >> 10; 435 ··· 463 return -1; 464 } 465 466 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status); 467 468 if (retval) { 469 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); ··· 490 return -1; 491 } 492 493 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status); 494 495 if (retval) { 496 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); ··· 518 return -1; 519 } 520 521 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status); 522 523 if (retval) { 524 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); ··· 549 err("%s: Invalid HPC slot number!\n", __FUNCTION__); 550 return -1; 551 } 552 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 553 554 if (rc) { 555 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 574 slot_cmd = slot_cmd | HP_INTR_ENABLE; 575 576 pcie_write_cmd(slot, slot_cmd); 577 + dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 578 579 return rc; 580 } ··· 598 return ; 599 } 600 601 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 602 603 if (rc) { 604 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 611 612 pcie_write_cmd(slot, slot_cmd); 613 614 + dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 615 return; 616 } 617 ··· 633 return ; 634 } 635 636 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 637 638 if (rc) { 639 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 646 if (!pciehp_poll_mode) 647 slot_cmd = slot_cmd | HP_INTR_ENABLE; 648 pcie_write_cmd(slot, slot_cmd); 649 + dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 650 651 return; 652 } ··· 669 return ; 670 } 671 672 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 673 674 if (rc) { 675 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 683 slot_cmd = slot_cmd | HP_INTR_ENABLE; 684 pcie_write_cmd(slot, slot_cmd); 685 686 + dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 687 return; 688 } 689 ··· 707 *first_device_num = 0; 708 *num_ctlr_slots = 1; 709 710 + rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP(ctrl->cap_base), slot_cap); 711 712 if (rc) { 713 err("%s : hp_register_read_dword SLOT_CAP failed\n", __FUNCTION__); ··· 793 return -1; 794 } 795 796 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 797 798 if (retval) { 799 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 800 return retval; 801 } 802 + dbg("%s: SLOT_CTRL %x, value read %xn", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), 803 slot_ctrl); 804 805 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON; ··· 813 err("%s: Write %x command failed!\n", __FUNCTION__, slot_cmd); 814 return -1; 815 } 816 + dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 817 818 DBG_LEAVE_ROUTINE 819 ··· 842 err("%s: Invalid HPC slot number!\n", __FUNCTION__); 843 return -1; 844 } 845 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 846 847 if (retval) { 848 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 849 return retval; 850 } 851 + dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), 852 slot_ctrl); 853 854 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF; ··· 862 err("%s: Write command failed!\n", __FUNCTION__); 863 return -1; 864 } 865 + dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 866 867 DBG_LEAVE_ROUTINE 868 ··· 900 return IRQ_NONE; 901 } 902 903 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 904 if (rc) { 905 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 906 return IRQ_NONE; ··· 918 dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc); 919 /* Mask Hot-plug Interrupt Enable */ 920 if (!pciehp_poll_mode) { 921 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 922 if (rc) { 923 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 924 return IRQ_NONE; ··· 928 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 929 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 930 931 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 932 if (rc) { 933 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 934 return IRQ_NONE; 935 } 936 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 937 938 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 939 if (rc) { 940 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 941 return IRQ_NONE; ··· 944 945 /* Clear command complete interrupt caused by this write */ 946 temp_word = 0x1f; 947 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 948 if (rc) { 949 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 950 return IRQ_NONE; ··· 975 976 /* Clear all events after serving them */ 977 temp_word = 0x1F; 978 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 979 if (rc) { 980 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 981 return IRQ_NONE; 982 } 983 /* Unmask Hot-plug Interrupt Enable */ 984 if (!pciehp_poll_mode) { 985 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 986 if (rc) { 987 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 988 return IRQ_NONE; ··· 992 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 993 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE; 994 995 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 996 if (rc) { 997 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 998 return IRQ_NONE; 999 } 1000 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 1001 1002 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1003 if (rc) { 1004 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1005 return IRQ_NONE; ··· 1008 1009 /* Clear command complete interrupt caused by this write */ 1010 temp_word = 0x1F; 1011 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 1012 if (rc) { 1013 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1014 return IRQ_NONE; ··· 1038 return -1; 1039 } 1040 1041 + retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP(slot->ctrl->cap_base), lnk_cap); 1042 1043 if (retval) { 1044 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); ··· 1079 return -1; 1080 } 1081 1082 + retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP(slot->ctrl->cap_base), lnk_cap); 1083 1084 if (retval) { 1085 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); ··· 1141 return -1; 1142 } 1143 1144 + retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(slot->ctrl->cap_base), lnk_status); 1145 1146 if (retval) { 1147 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); ··· 1182 return -1; 1183 } 1184 1185 + retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(slot->ctrl->cap_base), lnk_status); 1186 1187 if (retval) { 1188 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); ··· 1292 goto abort_free_ctlr; 1293 } 1294 1295 + ctrl->cap_base = cap_base; 1296 1297 dbg("%s: pcie_cap_base %x\n", __FUNCTION__, pcie_cap_base); 1298 1299 + rc = hp_register_read_word(pdev, CAP_REG(ctrl->cap_base), cap_reg); 1300 if (rc) { 1301 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1302 goto abort_free_ctlr; 1303 } 1304 + dbg("%s: CAP_REG offset %x cap_reg %x\n", __FUNCTION__, CAP_REG(ctrl->cap_base), cap_reg); 1305 1306 + if (((cap_reg & SLOT_IMPL) == 0) || (((cap_reg & DEV_PORT_TYPE) != 0x0040) 1307 + && ((cap_reg & DEV_PORT_TYPE) != 0x0060))) { 1308 dbg("%s : This is not a root port or the port is not connected to a slot\n", __FUNCTION__); 1309 goto abort_free_ctlr; 1310 } 1311 1312 + rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP(ctrl->cap_base), slot_cap); 1313 if (rc) { 1314 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1315 goto abort_free_ctlr; 1316 } 1317 + dbg("%s: SLOT_CAP offset %x slot_cap %x\n", __FUNCTION__, SLOT_CAP(ctrl->cap_base), slot_cap); 1318 1319 if (!(slot_cap & HP_CAP)) { 1320 dbg("%s : This slot is not hot-plug capable\n", __FUNCTION__); 1321 goto abort_free_ctlr; 1322 } 1323 /* For debugging purpose */ 1324 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1325 if (rc) { 1326 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1327 goto abort_free_ctlr; 1328 } 1329 + dbg("%s: SLOT_STATUS offset %x slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), slot_status); 1330 1331 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 1332 if (rc) { 1333 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1334 goto abort_free_ctlr; 1335 } 1336 + dbg("%s: SLOT_CTRL offset %x slot_ctrl %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 1337 1338 if (first) { 1339 spin_lock_init(&hpc_event_lock); ··· 1372 php_ctlr->num_slots = 1; 1373 1374 /* Mask Hot-plug Interrupt Enable */ 1375 + rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1376 if (rc) { 1377 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1378 goto abort_free_ctlr; 1379 } 1380 1381 + dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), temp_word); 1382 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 1383 1384 + rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1385 if (rc) { 1386 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1387 goto abort_free_ctlr; 1388 } 1389 dbg("%s : Mask HPIE hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, temp_word); 1390 1391 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1392 if (rc) { 1393 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1394 goto abort_free_ctlr; 1395 } 1396 + dbg("%s: Mask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base) 1397 + , slot_status); 1398 1399 temp_word = 0x1F; /* Clear all events */ 1400 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 1401 if (rc) { 1402 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1403 goto abort_free_ctlr; 1404 } 1405 + dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), temp_word); 1406 1407 if (pciehp_poll_mode) {/* Install interrupt polling code */ 1408 /* Install and start the interrupt polling timer */ ··· 1417 } 1418 } 1419 1420 + rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1421 if (rc) { 1422 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1423 goto abort_free_ctlr; 1424 } 1425 + dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), temp_word); 1426 dbg("%s: slot_cap %x\n", __FUNCTION__, slot_cap); 1427 1428 intr_enable = intr_enable | PRSN_DETECT_ENABLE; ··· 1446 dbg("%s: temp_word %x\n", __FUNCTION__, temp_word); 1447 1448 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */ 1449 + rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1450 if (rc) { 1451 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1452 goto abort_free_ctlr; 1453 } 1454 dbg("%s : Unmask HPIE hp_register_write_word SLOT_CTRL with %x\n", __FUNCTION__, temp_word); 1455 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1456 if (rc) { 1457 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1458 goto abort_free_ctlr; 1459 } 1460 dbg("%s: Unmask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, 1461 + SLOT_STATUS(ctrl->cap_base), slot_status); 1462 1463 temp_word = 0x1F; /* Clear all events */ 1464 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 1465 if (rc) { 1466 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1467 goto abort_free_ctlr; 1468 } 1469 + dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), temp_word); 1470 1471 /* Add this HPC instance into the HPC list */ 1472 spin_lock(&list_lock);
+1 -1
drivers/pci/hotplug/shpchp_core.c
··· 95 */ 96 static void release_slot(struct hotplug_slot *hotplug_slot) 97 { 98 - struct slot *slot = (struct slot *)hotplug_slot->private; 99 100 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 101
··· 95 */ 96 static void release_slot(struct hotplug_slot *hotplug_slot) 97 { 98 + struct slot *slot = hotplug_slot->private; 99 100 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 101
+15 -15
drivers/pci/hotplug/shpchp_ctrl.c
··· 1885 func = shpchp_slot_find(p_slot->bus, p_slot->device, 0); 1886 if (!func) { 1887 dbg("%s: Error! slot NULL\n", __FUNCTION__); 1888 - return 1; 1889 } 1890 1891 /* Check to see if (latch closed, card present, power off) */ ··· 1894 if (rc || !getstatus) { 1895 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1896 up(&p_slot->ctrl->crit_sect); 1897 - return 1; 1898 } 1899 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1900 if (rc || getstatus) { 1901 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1902 up(&p_slot->ctrl->crit_sect); 1903 - return 1; 1904 } 1905 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1906 if (rc || getstatus) { 1907 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); 1908 up(&p_slot->ctrl->crit_sect); 1909 - return 1; 1910 } 1911 up(&p_slot->ctrl->crit_sect); 1912 ··· 1914 1915 func = shpchp_slot_create(p_slot->bus); 1916 if (func == NULL) 1917 - return 1; 1918 1919 func->bus = p_slot->bus; 1920 func->device = p_slot->device; ··· 1939 /* Setup slot structure with entry for empty slot */ 1940 func = shpchp_slot_create(p_slot->bus); 1941 if (func == NULL) 1942 - return (1); /* Out of memory */ 1943 1944 func->bus = p_slot->bus; 1945 func->device = p_slot->device; ··· 1972 struct pci_func *func; 1973 1974 if (!p_slot->ctrl) 1975 - return 1; 1976 1977 pci_bus = p_slot->ctrl->pci_dev->subordinate; 1978 ··· 1983 if (ret || !getstatus) { 1984 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1985 up(&p_slot->ctrl->crit_sect); 1986 - return 1; 1987 } 1988 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1989 if (ret || getstatus) { 1990 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1991 up(&p_slot->ctrl->crit_sect); 1992 - return 1; 1993 } 1994 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1995 if (ret || !getstatus) { 1996 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); 1997 up(&p_slot->ctrl->crit_sect); 1998 - return 1; 1999 } 2000 up(&p_slot->ctrl->crit_sect); 2001 ··· 2011 /* Check the Class Code */ 2012 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); 2013 if (rc) 2014 - return rc; 2015 2016 if (class_code == PCI_BASE_CLASS_DISPLAY) { 2017 /* Display/Video adapter (not supported) */ ··· 2020 /* See if it's a bridge */ 2021 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); 2022 if (rc) 2023 - return rc; 2024 2025 /* If it's a bridge, check the VGA Enable bit */ 2026 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 2027 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR); 2028 if (rc) 2029 - return rc; 2030 2031 /* If the VGA Enable bit is set, remove isn't supported */ 2032 if (BCR & PCI_BRIDGE_CTL_VGA) { ··· 2042 if ((func != NULL) && !rc) { 2043 rc = remove_board(func, p_slot->ctrl); 2044 } else if (!rc) 2045 - rc = 1; 2046 2047 if (p_slot) 2048 update_slot_info(p_slot); 2049 2050 - return(rc); 2051 } 2052 2053
··· 1885 func = shpchp_slot_find(p_slot->bus, p_slot->device, 0); 1886 if (!func) { 1887 dbg("%s: Error! slot NULL\n", __FUNCTION__); 1888 + return -ENODEV; 1889 } 1890 1891 /* Check to see if (latch closed, card present, power off) */ ··· 1894 if (rc || !getstatus) { 1895 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1896 up(&p_slot->ctrl->crit_sect); 1897 + return -ENODEV; 1898 } 1899 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1900 if (rc || getstatus) { 1901 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1902 up(&p_slot->ctrl->crit_sect); 1903 + return -ENODEV; 1904 } 1905 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1906 if (rc || getstatus) { 1907 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); 1908 up(&p_slot->ctrl->crit_sect); 1909 + return -ENODEV; 1910 } 1911 up(&p_slot->ctrl->crit_sect); 1912 ··· 1914 1915 func = shpchp_slot_create(p_slot->bus); 1916 if (func == NULL) 1917 + return -ENOMEM; 1918 1919 func->bus = p_slot->bus; 1920 func->device = p_slot->device; ··· 1939 /* Setup slot structure with entry for empty slot */ 1940 func = shpchp_slot_create(p_slot->bus); 1941 if (func == NULL) 1942 + return -ENOMEM; /* Out of memory */ 1943 1944 func->bus = p_slot->bus; 1945 func->device = p_slot->device; ··· 1972 struct pci_func *func; 1973 1974 if (!p_slot->ctrl) 1975 + return -ENODEV; 1976 1977 pci_bus = p_slot->ctrl->pci_dev->subordinate; 1978 ··· 1983 if (ret || !getstatus) { 1984 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1985 up(&p_slot->ctrl->crit_sect); 1986 + return -ENODEV; 1987 } 1988 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1989 if (ret || getstatus) { 1990 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1991 up(&p_slot->ctrl->crit_sect); 1992 + return -ENODEV; 1993 } 1994 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1995 if (ret || !getstatus) { 1996 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); 1997 up(&p_slot->ctrl->crit_sect); 1998 + return -ENODEV; 1999 } 2000 up(&p_slot->ctrl->crit_sect); 2001 ··· 2011 /* Check the Class Code */ 2012 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); 2013 if (rc) 2014 + return -ENODEV; 2015 2016 if (class_code == PCI_BASE_CLASS_DISPLAY) { 2017 /* Display/Video adapter (not supported) */ ··· 2020 /* See if it's a bridge */ 2021 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); 2022 if (rc) 2023 + return -ENODEV; 2024 2025 /* If it's a bridge, check the VGA Enable bit */ 2026 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 2027 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR); 2028 if (rc) 2029 + return -ENODEV; 2030 2031 /* If the VGA Enable bit is set, remove isn't supported */ 2032 if (BCR & PCI_BRIDGE_CTL_VGA) { ··· 2042 if ((func != NULL) && !rc) { 2043 rc = remove_board(func, p_slot->ctrl); 2044 } else if (!rc) 2045 + rc = -ENODEV; 2046 2047 if (p_slot) 2048 update_slot_info(p_slot); 2049 2050 + return rc; 2051 } 2052 2053
+12
drivers/pci/pci-sysfs.c
··· 73 return (str - buf); 74 } 75 76 struct device_attribute pci_dev_attrs[] = { 77 __ATTR_RO(resource), 78 __ATTR_RO(vendor), ··· 93 __ATTR_RO(class), 94 __ATTR_RO(irq), 95 __ATTR_RO(local_cpus), 96 __ATTR_NULL, 97 }; 98
··· 73 return (str - buf); 74 } 75 76 + static ssize_t modalias_show(struct device *dev, char *buf) 77 + { 78 + struct pci_dev *pci_dev = to_pci_dev(dev); 79 + 80 + return sprintf(buf, "pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n", 81 + pci_dev->vendor, pci_dev->device, 82 + pci_dev->subsystem_vendor, pci_dev->subsystem_device, 83 + (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8), 84 + (u8)(pci_dev->class)); 85 + } 86 + 87 struct device_attribute pci_dev_attrs[] = { 88 __ATTR_RO(resource), 89 __ATTR_RO(vendor), ··· 82 __ATTR_RO(class), 83 __ATTR_RO(irq), 84 __ATTR_RO(local_cpus), 85 + __ATTR_RO(modalias), 86 __ATTR_NULL, 87 }; 88
-27
drivers/pci/pci.h
··· 32 extern unsigned char pci_bus_max_busnr(struct pci_bus *bus); 33 extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); 34 35 - struct pci_dev_wrapped { 36 - struct pci_dev *dev; 37 - void *data; 38 - }; 39 - 40 - struct pci_bus_wrapped { 41 - struct pci_bus *bus; 42 - void *data; 43 - }; 44 - 45 - struct pci_visit { 46 - int (* pre_visit_pci_bus) (struct pci_bus_wrapped *, 47 - struct pci_dev_wrapped *); 48 - int (* post_visit_pci_bus) (struct pci_bus_wrapped *, 49 - struct pci_dev_wrapped *); 50 - 51 - int (* pre_visit_pci_dev) (struct pci_dev_wrapped *, 52 - struct pci_bus_wrapped *); 53 - int (* visit_pci_dev) (struct pci_dev_wrapped *, 54 - struct pci_bus_wrapped *); 55 - int (* post_visit_pci_dev) (struct pci_dev_wrapped *, 56 - struct pci_bus_wrapped *); 57 - }; 58 - 59 - extern int pci_visit_dev(struct pci_visit *fn, 60 - struct pci_dev_wrapped *wrapped_dev, 61 - struct pci_bus_wrapped *wrapped_parent); 62 extern void pci_remove_legacy_files(struct pci_bus *bus); 63 64 /* Lock for read/write access to pci device and bus lists */
··· 32 extern unsigned char pci_bus_max_busnr(struct pci_bus *bus); 33 extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); 34 35 extern void pci_remove_legacy_files(struct pci_bus *bus); 36 37 /* Lock for read/write access to pci device and bus lists */
+2 -1
drivers/pci/pcie/portdrv_bus.c
··· 39 driver->id_table->vendor != pciedev->id.vendor) || 40 (driver->id_table->device != PCI_ANY_ID && 41 driver->id_table->device != pciedev->id.device) || 42 - driver->id_table->port_type != pciedev->id.port_type || 43 driver->id_table->service_type != pciedev->id.service_type ) 44 return 0; 45
··· 39 driver->id_table->vendor != pciedev->id.vendor) || 40 (driver->id_table->device != PCI_ANY_ID && 41 driver->id_table->device != pciedev->id.device) || 42 + (driver->id_table->port_type != PCIE_ANY_PORT && 43 + driver->id_table->port_type != pciedev->id.port_type) || 44 driver->id_table->service_type != pciedev->id.service_type ) 45 return 0; 46
+9 -1
fs/ext3/super.c
··· 225 int errno) 226 { 227 char nbuf[16]; 228 - const char *errstr = ext3_decode_error(sb, errno, nbuf); 229 230 printk (KERN_CRIT "EXT3-fs error (device %s) in %s: %s\n", 231 sb->s_id, function, errstr); 232
··· 225 int errno) 226 { 227 char nbuf[16]; 228 + const char *errstr; 229 230 + /* Special case: if the error is EROFS, and we're not already 231 + * inside a transaction, then there's really no point in logging 232 + * an error. */ 233 + if (errno == -EROFS && journal_current_handle() == NULL && 234 + (sb->s_flags & MS_RDONLY)) 235 + return; 236 + 237 + errstr = ext3_decode_error(sb, errno, nbuf); 238 printk (KERN_CRIT "EXT3-fs error (device %s) in %s: %s\n", 239 sb->s_id, function, errstr); 240
-3
include/linux/device.h
··· 273 BIOS data relevant to device) */ 274 struct dev_pm_info power; 275 276 - u32 detach_state; /* State to enter when device is 277 - detached from its driver. */ 278 - 279 u64 *dma_mask; /* dma mask (if dma'able device) */ 280 u64 coherent_dma_mask;/* Like dma_mask, but for 281 alloc_coherent mappings as
··· 273 BIOS data relevant to device) */ 274 struct dev_pm_info power; 275 276 u64 *dma_mask; /* dma mask (if dma'able device) */ 277 u64 coherent_dma_mask;/* Like dma_mask, but for 278 alloc_coherent mappings as
+3 -3
kernel/power/main.c
··· 156 goto Unlock; 157 } 158 159 - pr_debug("PM: Preparing system for suspend\n"); 160 if ((error = suspend_prepare(state))) 161 goto Unlock; 162 163 - pr_debug("PM: Entering state.\n"); 164 error = suspend_enter(state); 165 166 - pr_debug("PM: Finishing up.\n"); 167 suspend_finish(state); 168 Unlock: 169 up(&pm_sem);
··· 156 goto Unlock; 157 } 158 159 + pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]); 160 if ((error = suspend_prepare(state))) 161 goto Unlock; 162 163 + pr_debug("PM: Entering %s sleep\n", pm_states[state]); 164 error = suspend_enter(state); 165 166 + pr_debug("PM: Finishing wakeup.\n"); 167 suspend_finish(state); 168 Unlock: 169 up(&pm_sem);
+2 -2
mm/mmap.c
··· 1244 addr = mm->free_area_cache; 1245 1246 /* make sure it can fit in the remaining address space */ 1247 - if (addr >= len) { 1248 vma = find_vma(mm, addr-len); 1249 if (!vma || addr <= vma->vm_start) 1250 /* remember the address as a hint for next time */ ··· 1266 1267 /* try just below the current vma->vm_start */ 1268 addr = vma->vm_start-len; 1269 - } while (len <= vma->vm_start); 1270 1271 /* 1272 * A failed mmap() very likely causes application failure,
··· 1244 addr = mm->free_area_cache; 1245 1246 /* make sure it can fit in the remaining address space */ 1247 + if (addr > len) { 1248 vma = find_vma(mm, addr-len); 1249 if (!vma || addr <= vma->vm_start) 1250 /* remember the address as a hint for next time */ ··· 1266 1267 /* try just below the current vma->vm_start */ 1268 addr = vma->vm_start-len; 1269 + } while (len < vma->vm_start); 1270 1271 /* 1272 * A failed mmap() very likely causes application failure,