1. 09 3月, 2012 2 次提交
    • G
      driver core: move the deferred probe pointer into the private area · ef8a3fd6
      Greg Kroah-Hartman 提交于
      Nothing outside of the driver core needs to get to the deferred probe
      pointer, so move it inside the private area of 'struct device' so no one
      tries to mess around with it.
      
      Cc: Grant Likely <grant.likely@secretlab.ca>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ef8a3fd6
    • G
      drivercore: Add driver probe deferral mechanism · d1c3414c
      Grant Likely 提交于
      Allow drivers to report at probe time that they cannot get all the resources
      required by the device, and should be retried at a later time.
      
      This should completely solve the problem of getting devices
      initialized in the right order.  Right now this is mostly handled by
      mucking about with initcall ordering which is a complete hack, and
      doesn't even remotely handle the case where device drivers are in
      modules.  This approach completely sidesteps the issues by allowing
      driver registration to occur in any order, and any driver can request
      to be retried after a few more other drivers get probed.
      
      v4: - Integrate Manjunath's addition of a separate workqueue
          - Change -EAGAIN to -EPROBE_DEFER for drivers to trigger deferral
          - Update comment blocks to reflect how the code really works
      v3: - Hold off workqueue scheduling until late_initcall so that the bulk
            of driver probes are complete before we start retrying deferred devices.
          - Tested with simple use cases.  Still needs more testing though.
            Using it to get rid of the gpio early_initcall madness, or to replace
            the ASoC internal probe deferral code would be ideal.
      v2: - added locking so it should no longer be utterly broken in that regard
          - remove device from deferred list at device_del time.
          - Still completely untested with any real use case, but has been
            boot tested.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Dilan Lee <dilee@nvidia.com>
      Cc: Manjunath GKondaiah <manjunath.gkondaiah@linaro.org>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Tony Lindgren <tony@atomide.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Reviewed-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
      Acked-by: NDavid Daney <david.daney@cavium.com>
      Reviewed-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1c3414c
  2. 25 1月, 2012 2 次提交
  3. 04 1月, 2012 1 次提交
  4. 15 12月, 2011 1 次提交
    • K
      driver-core: implement 'sysdev' functionality for regular devices and buses · ca22e56d
      Kay Sievers 提交于
      All sysdev classes and sysdev devices will converted to regular devices
      and buses to properly hook userspace into the event processing.
      
      There is no interesting difference between a 'sysdev' and 'device' which
      would justify to roll an entire own subsystem with different userspace
      export semantics. Userspace relies on events and generic sysfs subsystem
      infrastructure from sysdev devices, which are currently not properly
      available.
      
      Every converted sysdev class will create a regular device with the class
      name in /sys/devices/system and all registered devices will becom a children
      of theses devices.
      
      For compatibility reasons, the sysdev class-wide attributes are created
      at this parent device. (Do not copy that logic for anything new, subsystem-
      wide properties belong to the subsystem, not to some fake parent device
      created in /sys/devices.)
      
      Every sysdev driver is implemented as a simple subsystem interface now,
      and no longer called a driver.
      
      After all sysdev classes are ported to regular driver core entities, the
      sysdev implementation will be entirely removed from the kernel.
      Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      ca22e56d
  5. 08 12月, 2011 1 次提交
    • A
      PM / Driver core: leave runtime PM enabled during system shutdown · fe6b91f4
      Alan Stern 提交于
      Disabling all runtime PM during system shutdown turns out not to be a
      good idea, because some devices may need to be woken up from a
      low-power state at that time.
      
      The whole point of disabling runtime PM for system shutdown was to
      prevent untimely runtime-suspend method calls.  This patch (as1504)
      accomplishes the same result by incrementing the usage count for each
      device and waiting for ongoing runtime-PM callbacks to finish.  This
      is what we already do during system suspend and hibernation, which
      makes sense since the shutdown method is pretty much a legacy analog
      of the pm->poweroff method.
      
      This fixes a recent regression on some OMAP systems introduced by
      commit af8db150 (PM / driver core:
      disable device's runtime PM during shutdown).
      Reported-and-tested-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      fe6b91f4
  6. 16 11月, 2011 1 次提交
    • P
      PM / driver core: disable device's runtime PM during shutdown · af8db150
      Peter Chen 提交于
      There may be an issue when the user issue "reboot/shutdown" command, then
      the device has shut down its hardware, after that, this runtime-pm featured
      device's driver will probably be scheduled to do its suspend routine,
      and at its suspend routine, it may access hardware, but the device has
      already shutdown physically, then the system hang may be occurred.
      
      I ran out this issue using an auto-suspend supported USB devices, like
      3G modem, keyboard. The usb runtime suspend routine may be scheduled
      after the usb controller has been shut down, and the usb runtime suspend
      routine will try to suspend its roothub(controller), it will access
      register, then the system hang occurs as the controller is shutdown.
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      Acked-by: NMing Lei <tom.leiming@gmail.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Cc: stable@kernel.org
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      af8db150
  7. 23 8月, 2011 1 次提交
  8. 23 4月, 2011 1 次提交
  9. 20 4月, 2011 1 次提交
  10. 04 2月, 2011 2 次提交
  11. 08 1月, 2011 1 次提交
  12. 30 11月, 2010 1 次提交
  13. 18 11月, 2010 1 次提交
  14. 23 10月, 2010 3 次提交
    • R
      driver core: fix build for CONFIG_BLOCK not enabled · ead454fe
      Randy Dunlap 提交于
      Fix build errors when CONFIG_BLOCK is not enabled:
      
      drivers/base/core.c: In function 'get_device_parent':
      drivers/base/core.c:634: error: 'block_class' undeclared (first use in this function)
      drivers/base/core.c: In function 'device_add_class_symlinks':
      drivers/base/core.c:723: error: 'block_class' undeclared (first use in this function)
      drivers/base/core.c: In function 'device_remove_class_symlinks':
      drivers/base/core.c:751: error: 'block_class' undeclared (first use in this function)
      Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      ead454fe
    • A
      SYSFS: Allow boot time switching between deprecated and modern sysfs layout · e52eec13
      Andi Kleen 提交于
      I have some systems which need legacy sysfs due to old tools that are
      making assumptions that a directory can never be a symlink to another
      directory, and it's a big hazzle to compile separate kernels for them.
      
      This patch turns CONFIG_SYSFS_DEPRECATED into a run time option
      that can be switched on/off the kernel command line. This way
      the same binary can be used in both cases with just a option
      on the command line.
      
      The old CONFIG_SYSFS_DEPRECATED_V2 option is still there to set
      the default. I kept the weird name to not break existing
      config files.
      
      Also the compat code can be still completely disabled by undefining
      CONFIG_SYSFS_DEPRECATED_SWITCH -- just the optimizer takes
      care of this now instead of lots of ifdefs. This makes the code
      look nicer.
      
      v2: This is an updated version on top of Kay's patch to only
      handle the block devices. I tested it on my old systems
      and that seems to work.
      
      Cc: axboe@kernel.dk
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e52eec13
    • K
      driver core: remove CONFIG_SYSFS_DEPRECATED_V2 but keep it for block devices · 39aba963
      Kay Sievers 提交于
      This patch removes the old CONFIG_SYSFS_DEPRECATED_V2 config option,
      but it keeps the logic around to handle block devices in the old manner
      as some people like to run new kernel versions on old (pre 2007/2008)
      distros.
      Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Stephen Hemminger <shemminger@vyatta.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: "James E.J. Bottomley" <James.Bottomley@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
      Cc: Randy Dunlap <randy.dunlap@oracle.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jaroslav Kysela <perex@perex.cz>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: David Howells <dhowells@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      39aba963
  15. 09 8月, 2010 1 次提交
  16. 06 8月, 2010 1 次提交
  17. 26 7月, 2010 1 次提交
    • E
      Driver-core: Always create class directories for classses that support namespaces. · 24b1442d
      Eric W. Biederman 提交于
      This fixes the regression in 2.6.35-rcX where bluetooth network devices
      would fail to be deleted from sysfs, causing their destruction and
      recreation to fail.  In addition this fixes the mac80211_hwsim driver
      where it would leave around sysfs files when the driver was removed.
      
      This problem is discussed at
        https://bugzilla.kernel.org/show_bug.cgi?id=16257
      
      The reason for the regression is that the network namespace support
      added to sysfs expects and requires that network devices be put in
      directories that can contain only network devices.
      
      Today get_device_parent almost provides that guarantee for all class
      devices, except for a specific exception when the parent of a class
      devices is a class device.  It would be nice to simply remove that
      arguably incorrect special case, but apparently the input devices depend
      on it being there.  So I have only removed it for class devices with
      network namespace support.  Which today are the network devices.
      
      It has been suggested that a better fix would be to change the parent
      device from a class device to a bus device, which in the case of the
      bluetooth driver would change /sys/class/bluetooth to /sys/bus/bluetoth,
      I can not see how we would avoid significant userspace breakage if we
      were to make that change.
      
      Adding an extra directory in the path to the device will also be
      userspace visible but it is much less likely to break things.
      Everything is still accessible from /sys/class (for example), and it
      fixes two bugs.  Adding an extra directory fixes a 3 year old regression
      introduced with the new sysfs layout that makes it impossible to rename
      bnep0 network devices to names that conflict with hci device attributes
      like hci_revsion.  Adding an additional directory removes the new
      failure modes introduced by the network namespace code.
      
      If it weren't for the regession in the renaming of network devices I
      would figure out how to just make the sysfs code deal with this
      configuration of devices.
      
      In summary this patch fixes regressions by changing:
      "/sys/class/bluetooth/hci0/bnep0" to "/sys/class/bluetooth/hci0/net/bnep0".
      Reported-by: NJohannes Berg <johannes@sipsolutions.net>
      Reported-by: NJanusz Krzysztofik <jkrzyszt@tis.icnet.pl>
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      24b1442d
  18. 05 7月, 2010 1 次提交
  19. 22 5月, 2010 7 次提交
  20. 19 3月, 2010 1 次提交
  21. 08 3月, 2010 5 次提交
    • E
      driver core: Use sysfs_rename_link in device_rename · 2354dcc7
      Eric W. Biederman 提交于
      Don't open code the renaming of symlinks in sysfs
      instead use the new helper function sysfs_rename_link
      Acked-by: NTejun Heo <tj@kernel.org>
      Acked-by: NSerge Hallyn <serue@us.ibm.com>
      Signed-off-by: NEric W. Biederman <ebiederm@aristanetworks.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2354dcc7
    • E
      Driver core: Constify struct sysfs_ops in struct kobj_type · 52cf25d0
      Emese Revfy 提交于
      Constify struct sysfs_ops.
      
      This is part of the ops structure constification
      effort started by Arjan van de Ven et al.
      
      Benefits of this constification:
      
       * prevents modification of data that is shared
         (referenced) by many other structure instances
         at runtime
      
       * detects/prevents accidental (but not intentional)
         modification attempts on archs that enforce
         read-only kernel data at runtime
      
       * potentially better optimized code as the compiler
         can assume that the const data cannot be changed
      
       * the compiler/linker move const data into .rodata
         and therefore exclude them from false sharing
      Signed-off-by: NEmese Revfy <re.emese@gmail.com>
      Acked-by: NDavid Teigland <teigland@redhat.com>
      Acked-by: NMatt Domsch <Matt_Domsch@dell.com>
      Acked-by: NMaciej Sosnowski <maciej.sosnowski@intel.com>
      Acked-by: NHans J. Koch <hjk@linutronix.de>
      Acked-by: NPekka Enberg <penberg@cs.helsinki.fi>
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Acked-by: NStephen Hemminger <shemminger@vyatta.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      52cf25d0
    • E
      kobject: Constify struct kset_uevent_ops · 9cd43611
      Emese Revfy 提交于
      Constify struct kset_uevent_ops.
      
      This is part of the ops structure constification
      effort started by Arjan van de Ven et al.
      
      Benefits of this constification:
      
       * prevents modification of data that is shared
         (referenced) by many other structure instances
         at runtime
      
       * detects/prevents accidental (but not intentional)
         modification attempts on archs that enforce
         read-only kernel data at runtime
      
       * potentially better optimized code as the compiler
         can assume that the const data cannot be changed
      
       * the compiler/linker move const data into .rodata
         and therefore exclude them from false sharing
      Signed-off-by: NEmese Revfy <re.emese@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9cd43611
    • K
      Driver-Core: require valid action string in uevent trigger · 3f5468c9
      Kay Sievers 提交于
      No longer fall back to "add" and warn, but always require a valid
      action-string written to the "uevent" file.
      Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3f5468c9
    • T
      driver-core: fix race condition in get_device_parent() · 77d3d7c1
      Tejun Heo 提交于
      sysfs is creating several devices in cuse class concurrently and with
      CONFIG_SYSFS_DEPRECATED turned off, it triggers the following oops.
      
       BUG: unable to handle kernel NULL pointer dereference at 0000000000000038
       IP: [<ffffffff81158b0a>] sysfs_addrm_start+0x4a/0xf0
       PGD 75bb067 PUD 75be067 PMD 0
       Oops: 0000 [#1] PREEMPT SMP
       last sysfs file: /sys/devices/system/cpu/cpu7/topology/core_siblings
       CPU 1
       Modules linked in: cuse fuse
       Pid: 4737, comm: osspd Not tainted 2.6.31-work #77
       RIP: 0010:[<ffffffff81158b0a>]  [<ffffffff81158b0a>] sysfs_addrm_start+0x4a/0xf0
       RSP: 0018:ffff88000042f8f8  EFLAGS: 00010296
       RAX: ffff88000042ffd8 RBX: 0000000000000000 RCX: 0000000000000000
       RDX: 0000000000000000 RSI: ffff880007eef660 RDI: 0000000000000001
       RBP: ffff88000042f918 R08: 0000000000000000 R09: 0000000000000000
       R10: 0000000000000001 R11: ffffffff81158b0a R12: ffff88000042f928
       R13: 00000000fffffff4 R14: 0000000000000000 R15: ffff88000042f9a0
       FS:  00007fe93905a950(0000) GS:ffff880008600000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
       CR2: 0000000000000038 CR3: 00000000077c9000 CR4: 00000000000006e0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
       Process osspd (pid: 4737, threadinfo ffff88000042e000, task ffff880007eef040)
       Stack:
        ffff880005da10e8 0000000011cc8d6e ffff88000042f928 ffff880003d28a28
       <0> ffff88000042f988 ffffffff811592d7 0000000000000000 0000000000000000
       <0> 0000000000000000 0000000000000000 ffff88000042f958 0000000011cc8d6e
       Call Trace:
        [<ffffffff811592d7>] create_dir+0x67/0xe0
        [<ffffffff811593a8>] sysfs_create_dir+0x58/0xb0
        [<ffffffff8128ca7c>] ? kobject_add_internal+0xcc/0x220
        [<ffffffff812942e1>] ? vsnprintf+0x3c1/0xb90
        [<ffffffff8128cab7>] kobject_add_internal+0x107/0x220
        [<ffffffff8128cd37>] kobject_add_varg+0x47/0x80
        [<ffffffff8128ce53>] kobject_add+0x53/0x90
        [<ffffffff81357d84>] device_add+0xd4/0x690
        [<ffffffff81356c2b>] ? dev_set_name+0x4b/0x70
        [<ffffffffa001a884>] cuse_process_init_reply+0x2b4/0x420 [cuse]
        ...
      
      The problem is that kobject_add_internal() first adds a kobject to the
      kset and then try to create sysfs directory for it.  If the creation
      fails, it remove the kobject from the kset.  get_device_parent()
      accesses class_dirs kset while only holding class_dirs.list_lock to
      see whether the cuse class dir exists.  But when it exists, it may not
      have finished initialization yet or may fail and get removed soon.  In
      the above case, the former happened so the second one ends up trying
      to create subdirectory under NULL sysfs_dirent.
      
      Fix it by grabbing a mutex in get_device_parent().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reported-by: NColin Guthrie <cguthrie@mandriva.org>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      77d3d7c1
  22. 24 12月, 2009 3 次提交
  23. 12 12月, 2009 1 次提交