Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6:
debugfs: fix sparse warnings
Driver core: Fix cleanup when failing device_add().
driver core: Remove dpm_sysfs_remove() from error path of device_add()
PM: fix new mutex-locking bug in the PM core
PM: Do not acquire device semaphores upfront during suspend
kobject: properly initialize ksets
sysfs: CONFIG_SYSFS_DEPRECATED fix
driver core: fix up Kconfig text for CONFIG_SYSFS_DEPRECATED

+39 -116
+3 -11
drivers/base/core.c
··· 621 621 static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir) 622 622 { 623 623 /* see if we live in a "glue" directory */ 624 - if (!dev->class || glue_dir->kset != &dev->class->class_dirs) 624 + if (!glue_dir || !dev->class || 625 + glue_dir->kset != &dev->class->class_dirs) 625 626 return; 626 627 627 628 kobject_put(glue_dir); ··· 771 770 struct class_interface *class_intf; 772 771 int error; 773 772 774 - error = pm_sleep_lock(); 775 - if (error) { 776 - dev_warn(dev, "Suspicious %s during suspend\n", __FUNCTION__); 777 - dump_stack(); 778 - return error; 779 - } 780 - 781 773 dev = get_device(dev); 782 774 if (!dev || !strlen(dev->bus_id)) { 783 775 error = -EINVAL; 784 - goto Error; 776 + goto Done; 785 777 } 786 778 787 779 pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); ··· 837 843 } 838 844 Done: 839 845 put_device(dev); 840 - pm_sleep_unlock(); 841 846 return error; 842 847 BusError: 843 848 device_pm_remove(dev); 844 - dpm_sysfs_remove(dev); 845 849 PMError: 846 850 if (dev->bus) 847 851 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
+17 -91
drivers/base/power/main.c
··· 48 48 */ 49 49 50 50 LIST_HEAD(dpm_active); 51 - static LIST_HEAD(dpm_locked); 52 51 static LIST_HEAD(dpm_off); 53 52 static LIST_HEAD(dpm_off_irq); 54 53 static LIST_HEAD(dpm_destroy); ··· 80 81 */ 81 82 void device_pm_remove(struct device *dev) 82 83 { 83 - /* 84 - * If this function is called during a suspend, it will be blocked, 85 - * because we're holding the device's semaphore at that time, which may 86 - * lead to a deadlock. In that case we want to print a warning. 87 - * However, it may also be called by unregister_dropped_devices() with 88 - * the device's semaphore released, in which case the warning should 89 - * not be printed. 90 - */ 91 - if (down_trylock(&dev->sem)) { 92 - if (down_read_trylock(&pm_sleep_rwsem)) { 93 - /* No suspend in progress, wait on dev->sem */ 94 - down(&dev->sem); 95 - up_read(&pm_sleep_rwsem); 96 - } else { 97 - /* Suspend in progress, we may deadlock */ 98 - dev_warn(dev, "Suspicious %s during suspend\n", 99 - __FUNCTION__); 100 - dump_stack(); 101 - /* The user has been warned ... */ 102 - down(&dev->sem); 103 - } 104 - } 105 84 pr_debug("PM: Removing info for %s:%s\n", 106 85 dev->bus ? dev->bus->name : "No Bus", 107 86 kobject_name(&dev->kobj)); ··· 87 110 dpm_sysfs_remove(dev); 88 111 list_del_init(&dev->power.entry); 89 112 mutex_unlock(&dpm_list_mtx); 90 - up(&dev->sem); 91 113 } 92 114 93 115 /** ··· 206 230 TRACE_DEVICE(dev); 207 231 TRACE_RESUME(0); 208 232 233 + down(&dev->sem); 234 + 209 235 if (dev->bus && dev->bus->resume) { 210 236 dev_dbg(dev,"resuming\n"); 211 237 error = dev->bus->resume(dev); ··· 222 244 dev_dbg(dev,"class resume\n"); 223 245 error = dev->class->resume(dev); 224 246 } 247 + 248 + up(&dev->sem); 225 249 226 250 TRACE_RESUME(error); 227 251 return error; ··· 246 266 struct list_head *entry = dpm_off.next; 247 267 struct device *dev = to_device(entry); 248 268 249 - list_move_tail(entry, &dpm_locked); 269 + list_move_tail(entry, &dpm_active); 250 270 mutex_unlock(&dpm_list_mtx); 251 271 resume_device(dev); 252 272 mutex_lock(&dpm_list_mtx); 253 - } 254 - mutex_unlock(&dpm_list_mtx); 255 - } 256 - 257 - /** 258 - * unlock_all_devices - Release each device's semaphore 259 - * 260 - * Go through the dpm_off list. Put each device on the dpm_active 261 - * list and unlock it. 262 - */ 263 - static void unlock_all_devices(void) 264 - { 265 - mutex_lock(&dpm_list_mtx); 266 - while (!list_empty(&dpm_locked)) { 267 - struct list_head *entry = dpm_locked.prev; 268 - struct device *dev = to_device(entry); 269 - 270 - list_move(entry, &dpm_active); 271 - up(&dev->sem); 272 273 } 273 274 mutex_unlock(&dpm_list_mtx); 274 275 } ··· 266 305 struct list_head *entry = dpm_destroy.next; 267 306 struct device *dev = to_device(entry); 268 307 269 - up(&dev->sem); 270 308 mutex_unlock(&dpm_list_mtx); 271 309 /* This also removes the device from the list */ 272 310 device_unregister(dev); ··· 284 324 { 285 325 might_sleep(); 286 326 dpm_resume(); 287 - unlock_all_devices(); 288 327 unregister_dropped_devices(); 289 328 up_write(&pm_sleep_rwsem); 290 329 } ··· 347 388 struct list_head *entry = dpm_off.prev; 348 389 struct device *dev = to_device(entry); 349 390 350 - list_del_init(&dev->power.entry); 351 391 error = suspend_device_late(dev, state); 352 392 if (error) { 353 393 printk(KERN_ERR "Could not power down device %s: " 354 394 "error %d\n", 355 395 kobject_name(&dev->kobj), error); 356 - if (list_empty(&dev->power.entry)) 357 - list_add(&dev->power.entry, &dpm_off); 358 396 break; 359 397 } 360 - if (list_empty(&dev->power.entry)) 361 - list_add(&dev->power.entry, &dpm_off_irq); 398 + if (!list_empty(&dev->power.entry)) 399 + list_move(&dev->power.entry, &dpm_off_irq); 362 400 } 363 401 364 402 if (!error) ··· 374 418 static int suspend_device(struct device *dev, pm_message_t state) 375 419 { 376 420 int error = 0; 421 + 422 + down(&dev->sem); 377 423 378 424 if (dev->power.power_state.event) { 379 425 dev_dbg(dev, "PM: suspend %d-->%d\n", ··· 399 441 error = dev->bus->suspend(dev, state); 400 442 suspend_report_result(dev->bus->suspend, error); 401 443 } 444 + 445 + up(&dev->sem); 446 + 402 447 return error; 403 448 } 404 449 ··· 422 461 int error = 0; 423 462 424 463 mutex_lock(&dpm_list_mtx); 425 - while (!list_empty(&dpm_locked)) { 426 - struct list_head *entry = dpm_locked.prev; 464 + while (!list_empty(&dpm_active)) { 465 + struct list_head *entry = dpm_active.prev; 427 466 struct device *dev = to_device(entry); 428 467 429 - list_del_init(&dev->power.entry); 430 468 mutex_unlock(&dpm_list_mtx); 431 469 error = suspend_device(dev, state); 470 + mutex_lock(&dpm_list_mtx); 432 471 if (error) { 433 472 printk(KERN_ERR "Could not suspend device %s: " 434 473 "error %d%s\n", ··· 437 476 (error == -EAGAIN ? 438 477 " (please convert to suspend_late)" : 439 478 "")); 440 - mutex_lock(&dpm_list_mtx); 441 - if (list_empty(&dev->power.entry)) 442 - list_add(&dev->power.entry, &dpm_locked); 443 479 break; 444 480 } 445 - mutex_lock(&dpm_list_mtx); 446 - if (list_empty(&dev->power.entry)) 447 - list_add(&dev->power.entry, &dpm_off); 481 + if (!list_empty(&dev->power.entry)) 482 + list_move(&dev->power.entry, &dpm_off); 448 483 } 449 484 mutex_unlock(&dpm_list_mtx); 450 485 451 486 return error; 452 - } 453 - 454 - /** 455 - * lock_all_devices - Acquire every device's semaphore 456 - * 457 - * Go through the dpm_active list. Carefully lock each device's 458 - * semaphore and put it in on the dpm_locked list. 459 - */ 460 - static void lock_all_devices(void) 461 - { 462 - mutex_lock(&dpm_list_mtx); 463 - while (!list_empty(&dpm_active)) { 464 - struct list_head *entry = dpm_active.next; 465 - struct device *dev = to_device(entry); 466 - 467 - /* Required locking order is dev->sem first, 468 - * then dpm_list_mutex. Hence this awkward code. 469 - */ 470 - get_device(dev); 471 - mutex_unlock(&dpm_list_mtx); 472 - down(&dev->sem); 473 - mutex_lock(&dpm_list_mtx); 474 - 475 - if (list_empty(entry)) 476 - up(&dev->sem); /* Device was removed */ 477 - else 478 - list_move_tail(entry, &dpm_locked); 479 - put_device(dev); 480 - } 481 - mutex_unlock(&dpm_list_mtx); 482 487 } 483 488 484 489 /** ··· 460 533 461 534 might_sleep(); 462 535 down_write(&pm_sleep_rwsem); 463 - lock_all_devices(); 464 536 error = dpm_suspend(state); 465 537 if (error) 466 538 device_resume();
+1 -1
drivers/usb/core/usb.c
··· 233 233 * singlethreaded. Its job doesn't justify running on more 234 234 * than one CPU. 235 235 */ 236 - ksuspend_usb_wq = create_singlethread_workqueue("ksuspend_usbd"); 236 + ksuspend_usb_wq = create_freezeable_workqueue("ksuspend_usbd"); 237 237 if (!ksuspend_usb_wq) 238 238 return -ENOMEM; 239 239 return 0;
-4
fs/debugfs/inode.c
··· 29 29 30 30 #define DEBUGFS_MAGIC 0x64626720 31 31 32 - /* declared over in file.c */ 33 - extern struct file_operations debugfs_file_operations; 34 - extern struct inode_operations debugfs_link_operations; 35 - 36 32 static struct vfsmount *debugfs_mount; 37 33 static int debugfs_mount_count; 38 34
+5
include/linux/debugfs.h
··· 27 27 }; 28 28 29 29 #if defined(CONFIG_DEBUG_FS) 30 + 31 + /* declared over in file.c */ 32 + extern const struct file_operations debugfs_file_operations; 33 + extern const struct inode_operations debugfs_link_operations; 34 + 30 35 struct dentry *debugfs_create_file(const char *name, mode_t mode, 31 36 struct dentry *parent, void *data, 32 37 const struct file_operations *fops);
+8 -3
init/Kconfig
··· 382 382 sure you need the memory resource controller. 383 383 384 384 config SYSFS_DEPRECATED 385 + bool 386 + 387 + config SYSFS_DEPRECATED_V2 385 388 bool "Create deprecated sysfs files" 386 389 depends on SYSFS 387 390 default y 391 + select SYSFS_DEPRECATED 388 392 help 389 393 This option creates deprecated symlinks such as the 390 394 "device"-link, the <subsystem>:<name>-link, and the ··· 401 397 402 398 If enabled, this option will also move any device structures 403 399 that belong to a class, back into the /sys/class hierarchy, in 404 - order to support older versions of udev. 400 + order to support older versions of udev and some userspace 401 + programs. 405 402 406 - If you are using a distro that was released in 2006 or later, 407 - it should be safe to say N here. 403 + If you are using a distro with the most recent userspace 404 + packages, it should be safe to say N here. 408 405 409 406 config PROC_PID_CPUSET 410 407 bool "Include legacy /proc/<pid>/cpuset file"
+5 -6
lib/kobject.c
··· 153 153 return; 154 154 kref_init(&kobj->kref); 155 155 INIT_LIST_HEAD(&kobj->entry); 156 + kobj->state_in_sysfs = 0; 157 + kobj->state_add_uevent_sent = 0; 158 + kobj->state_remove_uevent_sent = 0; 159 + kobj->state_initialized = 1; 156 160 } 157 161 158 162 ··· 293 289 dump_stack(); 294 290 } 295 291 296 - kref_init(&kobj->kref); 297 - INIT_LIST_HEAD(&kobj->entry); 292 + kobject_init_internal(kobj); 298 293 kobj->ktype = ktype; 299 - kobj->state_in_sysfs = 0; 300 - kobj->state_add_uevent_sent = 0; 301 - kobj->state_remove_uevent_sent = 0; 302 - kobj->state_initialized = 1; 303 294 return; 304 295 305 296 error: