1. 06 10月, 2013 1 次提交
  2. 27 9月, 2013 2 次提交
    • T
      sysfs: remove ktype->namespace() invocations in symlink code · 4b30ee58
      Tejun Heo 提交于
      There's no reason for sysfs to be calling ktype->namespace().  It is
      backwards, obfuscates what's going on and unnecessarily tangles two
      separate layers.
      
      There are two places where symlink code calls ktype->namespace().
      
      * sysfs_do_create_link_sd() calls it to find out the namespace tag of
        the target directory.  Unless symlinking races with cross-namespace
        renaming, this equals @target_sd->s_ns.
      
      * sysfs_rename_link() uses it to find out the new namespace to rename
        to and the new namespace can be different from the existing one.
        The function is renamed to sysfs_rename_link_ns() with an explicit
        @ns argument and the ktype->namespace() invocation is shifted to the
        device layer.
      
      While this patch replaces ktype->namespace() invocation with the
      recorded result in @target_sd, this shouldn't result in any behvior
      difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Kay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b30ee58
    • B
      driver core : Fix use after free of dev->parent in device_shutdown · f123db8e
      Benson Leung 提交于
      The put_device(dev) at the bottom of the loop of device_shutdown
      may result in the dev being cleaned up. In device_create_release,
      the dev is kfreed.
      
      However, device_shutdown attempts to use the dev pointer again after
      put_device by referring to dev->parent.
      
      Copy the parent pointer instead to avoid this condition.
      
      This bug was found on Chromium OS's chromeos-3.8, which is based on v3.8.11.
      See bug report : https://code.google.com/p/chromium/issues/detail?id=297842
      This can easily be reproduced when shutting down with
      hidraw devices that report battery condition.
      Two examples are the HP Bluetooth Mouse X4000b and the Apple Magic Mouse.
      For example, with the magic mouse :
      The dev in question is "hidraw0"
      dev->parent is "magicmouse"
      
      In the course of the shutdown for this device, the input event cleanup calls
      a put on hidraw0, decrementing its reference count.
      When we finally get to put_device(dev) in device_shutdown, kobject_cleanup
      is called and device_create_release does kfree(dev).
      dev->parent is no longer valid, and we may crash in
      put_device(dev->parent).
      
      This change should be applied on any kernel with this change :
      d1c6c030
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NBenson Leung <bleung@chromium.org>
      Reviewed-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f123db8e
  3. 30 8月, 2013 1 次提交
    • R
      driver core / ACPI: Avoid device hot remove locking issues · 5e33bc41
      Rafael J. Wysocki 提交于
      device_hotplug_lock is held around the acpi_bus_trim() call in
      acpi_scan_hot_remove() which generally removes devices (it removes
      ACPI device objects at least, but it may also remove "physical"
      device objects through .detach() callbacks of ACPI scan handlers).
      Thus, potentially, device sysfs attributes are removed under that
      lock and to remove those attributes it is necessary to hold the
      s_active references of their directory entries for writing.
      
      On the other hand, the execution of a .show() or .store() callback
      from a sysfs attribute is carried out with that attribute's s_active
      reference held for reading.  Consequently, if any device sysfs
      attribute that may be removed from within acpi_scan_hot_remove()
      through acpi_bus_trim() has a .store() or .show() callback which
      acquires device_hotplug_lock, the execution of that callback may
      deadlock with the removal of the attribute.  [Unfortunately, the
      "online" device attribute of CPUs and memory blocks is one of them.]
      
      To avoid such deadlocks, make all of the sysfs attribute callbacks
      that need to lock device hotplug, for example store_online(), use
      a special function, lock_device_hotplug_sysfs(), to lock device
      hotplug and return the result of that function immediately if it is
      not zero.  This will cause the s_active reference of the directory
      entry in question to be released and the syscall to be restarted
      if device_hotplug_lock cannot be acquired.
      
      [show_online() actually doesn't need to lock device hotplug, but
      it is useful to serialize it with respect to device_offline() and
      device_online() for the same device (in case user space attempts to
      run them concurrently) which can be done with the help of
      device_lock().]
      Reported-by: NYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Reported-and-tested-by: NGu Zheng <guz.fnst@cn.fujitsu.com>
      Suggested-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NToshi Kani <toshi.kani@hp.com>
      5e33bc41
  4. 28 8月, 2013 1 次提交
  5. 24 8月, 2013 1 次提交
  6. 23 8月, 2013 1 次提交
    • G
      sysfs.h: remove attr_name() macro · 3e1026b3
      Greg Kroah-Hartman 提交于
      Gotta love a macro that doesn't reduce the typing you have to do.
      
      Also, only the driver core, and one network driver uses this.  The
      driver core functions will be going away soon, and I'll convert the
      network driver soon to not need this as well, so delete it for now
      before anyone else gets some bright ideas and wants to use it.
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e1026b3
  7. 22 8月, 2013 1 次提交
  8. 20 8月, 2013 1 次提交
  9. 13 8月, 2013 1 次提交
  10. 27 7月, 2013 2 次提交
  11. 17 7月, 2013 2 次提交
  12. 04 6月, 2013 1 次提交
  13. 22 5月, 2013 2 次提交
  14. 12 5月, 2013 1 次提交
    • R
      Driver core: Add offline/online device operations · 4f3549d7
      Rafael J. Wysocki 提交于
      In some cases, graceful hot-removal of devices is not possible,
      although in principle the devices in question support hotplug.
      For example, that may happen for the last CPU in the system or
      for memory modules holding kernel memory.
      
      In those cases it is nice to be able to check if the given device
      can be gracefully hot-removed before triggering a removal procedure
      that cannot be aborted or reversed.  Unfortunately, however, the
      kernel currently doesn't provide any support for that.
      
      To address that deficiency, introduce support for offline and
      online operations that can be performed on devices, respectively,
      before a hot-removal and in case when it is necessary (or convenient)
      to put a device back online after a successful offline (that has not
      been followed by removal).  The idea is that the offline will fail
      whenever the given device cannot be gracefully removed from the
      system and it will not be allowed to use the device after a
      successful offline (until a subsequent online) in analogy with the
      existing CPU offline/online mechanism.
      
      For now, the offline and online operations are introduced at the
      bus type level, as that should be sufficient for the most urgent use
      cases (CPUs and memory modules).  In the future, however, the
      approach may be extended to cover some more complicated device
      offline/online scenarios involving device drivers etc.
      
      The lock_device_hotplug() and unlock_device_hotplug() functions are
      introduced because subsequent patches need to put larger pieces of
      code under device_hotplug_lock to prevent race conditions between
      device offline and removal from happening.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NToshi Kani <toshi.kani@hp.com>
      4f3549d7
  15. 12 4月, 2013 1 次提交
  16. 08 4月, 2013 1 次提交
    • K
      driver core: add uid and gid to devtmpfs · 3c2670e6
      Kay Sievers 提交于
      Some drivers want to tell userspace what uid and gid should be used for
      their device nodes, so allow that information to percolate through the
      driver core to userspace in order to make this happen.  This means that
      some systems (i.e.  Android and friends) will not need to even run a
      udev-like daemon for their device node manager and can just rely in
      devtmpfs fully, reducing their footprint even more.
      Signed-off-by: NKay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3c2670e6
  17. 16 3月, 2013 1 次提交
  18. 13 3月, 2013 1 次提交
    • T
      driver/base: implement subsys_virtual_register() · d73ce004
      Tejun Heo 提交于
      Kay tells me the most appropriate place to expose workqueues to
      userland would be /sys/devices/virtual/workqueues/WQ_NAME which is
      symlinked to /sys/bus/workqueue/devices/WQ_NAME and that we're lacking
      a way to do that outside of driver core as virtual_device_parent()
      isn't exported and there's no inteface to conveniently create a
      virtual subsystem.
      
      This patch implements subsys_virtual_register() by factoring out
      subsys_register() from subsys_system_register() and using it with
      virtual_device_parent() as the origin directory.  It's identical to
      subsys_system_register() other than the origin directory but we aren't
      gonna restrict the device names which should be used under it.
      
      This will be used to expose workqueue attributes to userland.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      d73ce004
  19. 07 2月, 2013 1 次提交
  20. 18 1月, 2013 3 次提交
  21. 27 11月, 2012 2 次提交
  22. 15 11月, 2012 1 次提交
    • L
      driver core / PM: move the calling to device_pm_remove behind the calling to bus_remove_device · 4b6d1f12
      LongX Zhang 提交于
      We hit an hang issue when removing a mmc device on Medfield Android phone by sysfs interface.
      
      device_pm_remove will call pm_runtime_remove which would disable
      runtime PM of the device. After that pm_runtime_get* or
      pm_runtime_put* will be ignored. So if we disable the runtime PM
      before device really be removed, drivers' _remove callback may
      access HW even pm_runtime_get* fails. That is bad.
      
      Consider below call sequence when removing a device:
      device_del => device_pm_remove
                   => class_intf->remove_dev(dev, class_intf)  => pm_runtime_get_sync/put_sync
                   => bus_remove_device => device_release_driver => pm_runtime_get_sync/put_sync
      
      remove_dev might call pm_runtime_get_sync/put_sync.
      Then, generic device_release_driver also calls pm_runtime_get_sync/put_sync.
      Since device_del => device_pm_remove firstly, later _get_sync wouldn't really wake up the device.
      
      I git log -p to find the patch which moves the calling to device_pm_remove ahead.
      It's below patch:
      
      commit  775b64d2
      Author: Rafael J. Wysocki <rjw@sisk.pl>
      Date:   Sat Jan 12 20:40:46 2008 +0100
      
           PM: Acquire device locks on suspend
      
           This patch reorganizes the way suspend and resume notifications are
           sent to drivers.  The major changes are that now the PM core acquires
           every device semaphore before calling the methods, and calls to
           device_add() during suspends will fail, while calls to device_del()
           during suspends will block.
      
           It also provides a way to safely remove a suspended device with the
           help of the PM core, by using the device_pm_schedule_removal() callback
           introduced specifically for this purpose, and updates two drivers (msr
           and cpuid) that need to use it.
      
      As device_pm_schedule_removal is deleted by another patch, we need also revert other parts of the patch,
      i.e. move the calling of device_pm_remove after the calling to bus_remove_device.
      Signed-off-by: NLongX Zhang <longx.zhang@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      4b6d1f12
  23. 26 10月, 2012 1 次提交
  24. 17 9月, 2012 3 次提交
  25. 19 8月, 2012 1 次提交
  26. 17 8月, 2012 2 次提交
  27. 17 7月, 2012 2 次提交
  28. 12 6月, 2012 1 次提交
  29. 08 5月, 2012 1 次提交