1. 16 9月, 2009 1 次提交
  2. 23 8月, 2009 1 次提交
    • R
      PM: Introduce core framework for run-time PM of I/O devices (rev. 17) · 5e928f77
      Rafael J. Wysocki 提交于
      Introduce a core framework for run-time power management of I/O
      devices.  Add device run-time PM fields to 'struct dev_pm_info'
      and device run-time PM callbacks to 'struct dev_pm_ops'.  Introduce
      a run-time PM workqueue and define some device run-time PM helper
      functions at the core level.  Document all these things.
      
      Special thanks to Alan Stern for his help with the design and
      multiple detailed reviews of the pereceding versions of this patch
      and to Magnus Damm for testing feedback.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NMagnus Damm <damm@igel.co.jp>
      5e928f77
  3. 16 6月, 2009 2 次提交
  4. 22 4月, 2009 1 次提交
    • A
      driver synchronization: make scsi_wait_scan more advanced · d4d5291c
      Arjan van de Ven 提交于
      There is currently only one way for userspace to say "wait for my storage
      device to get ready for the modules I just loaded": to load the
      scsi_wait_scan module. Expectations of userspace are that once this
      module is loaded, all the (storage) devices for which the drivers
      were loaded before the module load are present.
      
      Now, there are some issues with the implementation, and the async
      stuff got caught in the middle of this: The existing code only
      waits for the scsy async probing to finish, but it did not take
      into account at all that probing might not have begun yet.
      (Russell ran into this problem on his computer and the fix works for him)
      
      This patch fixes this more thoroughly than the previous "fix", which
      had some bad side effects (namely, for kernel code that wanted to wait for
      the scsi scan it would also do an async sync, which would deadlock if you did
      it from async context already.. there's a report about that on lkml):
      The patch makes the module first wait for all device driver probes, and then it
      will wait for the scsi parallel scan to finish.
      Signed-off-by: NArjan van de Ven <arjan@linux.intel.com>
      Tested-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d4d5291c
  5. 25 3月, 2009 3 次提交
  6. 22 2月, 2009 1 次提交
  7. 10 1月, 2009 1 次提交
  8. 07 1月, 2009 3 次提交
  9. 17 10月, 2008 1 次提交
    • A
      device model: Do a quickcheck for driver binding before doing an expensive check · 6cd49586
      Arjan van de Ven 提交于
      This patch adds a quick check for the driver<->device match before
      taking the locks and doin gthe expensive checks. Taking the lock hurts
      in asynchronous boot context where the device lock gets hit; one of the
      init functions takes the lock and goes to do an expensive hardware init;
      the other init functions walk the same PCI list and get stuck on the
      lock as a result.
      
      For the common case, we can know there's no chance whatsoever of a match
      if the device isn't in the drivers ID table... so this patch does that
      check as a best-effort-avoid-the-lock approach.
      
      Bootcharts for before and after can be seen at
      http://www.fenrus.org/before.svg
      http://www.fenrus.org/after.svg
      
      Note the long time "agp_ali_init" takes in the first graph; my laptop
      doesn't even have an ALI chip in it!  (the bootgraphs look a bit
      dissimilar, but that's the point, the first one has a bunch of arbitrary
      delays in it that cause it to look very different)
      
      This reduces my kernel boot time by about 20%
      Signed-off-by: NArjan van de Ven <arjan@linux.intel.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6cd49586
  10. 20 4月, 2008 1 次提交
  11. 25 1月, 2008 5 次提交
    • G
      Driver core: coding style fixes · 4a3ad20c
      Greg Kroah-Hartman 提交于
      Fix up a number of coding style issues in the drivers/base/ directory
      that have annoyed me over the years.  checkpatch.pl is now very happy.
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      4a3ad20c
    • A
      Driver core: fix race in __device_release_driver · ef2c5174
      Alan Stern 提交于
      This patch (as1013) was suggested by David Woodhouse; it fixes a race
      in the driver core.  If a device is unregistered at the same time as
      its driver is unloaded, the driver's code pages may be unmapped while
      the remove method is still running.  The calls to get_driver() and
      put_driver() were intended to prevent this, but they don't work if the
      driver's module count has already dropped to 0.
      
      Instead, the patch keeps the device on the driver's list until after
      the remove method has returned.  This forces the necessary
      synchronization to occur.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      ef2c5174
    • G
      Driver core: clean up debugging messages · 7dc72b28
      Greg Kroah-Hartman 提交于
      The driver core debugging messages are a mess.  This provides a unified
      message that makes them actually useful.
      
      The format for new kobject debug messages should be:
      	driver/bus/class: 'OBJECT_NAME': FUNCTION_NAME: message.\n
      
      Note, the class code is not changed in this patch due to pending patches
      in my queue that this would conflict with.  A later patch will clean
      them up.
      
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7dc72b28
    • G
      Driver core: move the static kobject out of struct driver · e5dd1278
      Greg Kroah-Hartman 提交于
      This patch removes the kobject, and a few other driver-core-only fields
      out of struct driver and into the driver core only.  Now drivers can be
      safely create on the stack or statically (like they currently are.)
      
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e5dd1278
    • G
      driver core: remove fields from struct bus_type · c6f7e72a
      Greg Kroah-Hartman 提交于
      struct bus_type is static everywhere in the kernel.  This moves the
      kobject in the structure out of it, and a bunch of other private only to
      the driver core fields are now moved to a private structure.  This lets
      us dynamically create the backing kobject properly and gives us the
      chance to be able to document to users exactly how to use the struct
      bus_type as there are no fields they can improperly access.
      
      Thanks to Kay for the build fixes on this patch.
      
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      c6f7e72a
  12. 12 7月, 2007 2 次提交
  13. 09 6月, 2007 1 次提交
  14. 03 5月, 2007 1 次提交
  15. 28 4月, 2007 2 次提交
  16. 10 2月, 2007 1 次提交
    • T
      devres: device resource management · 9ac7849e
      Tejun Heo 提交于
      Implement device resource management, in short, devres.  A device
      driver can allocate arbirary size of devres data which is associated
      with a release function.  On driver detach, release function is
      invoked on the devres data, then, devres data is freed.
      
      devreses are typed by associated release functions.  Some devreses are
      better represented by single instance of the type while others need
      multiple instances sharing the same release function.  Both usages are
      supported.
      
      devreses can be grouped using devres group such that a device driver
      can easily release acquired resources halfway through initialization
      or selectively release resources (e.g. resources for port 1 out of 4
      ports).
      
      This patch adds devres core including documentation and the following
      managed interfaces.
      
      * alloc/free	: devm_kzalloc(), devm_kzfree()
      * IO region	: devm_request_region(), devm_release_region()
      * IRQ		: devm_request_irq(), devm_free_irq()
      * DMA		: dmam_alloc_coherent(), dmam_free_coherent(),
      		  dmam_declare_coherent_memory(), dmam_pool_create(),
      		  dmam_pool_destroy()
      * PCI		: pcim_enable_device(), pcim_pin_device(), pci_is_managed()
      * iomap		: devm_ioport_map(), devm_ioport_unmap(), devm_ioremap(),
      		  devm_ioremap_nocache(), devm_iounmap(), pcim_iomap_table(),
      		  pcim_iomap(), pcim_iounmap()
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NJeff Garzik <jeff@garzik.org>
      9ac7849e
  17. 08 2月, 2007 2 次提交
  18. 02 12月, 2006 2 次提交
    • K
      Driver core: fix "driver" symlink timing · 1901fb26
      Kay Sievers 提交于
      Create the "driver" link before the child device may be created by
      the probing logic. This makes it possible for userspace (udev), to
      determine the driver property of the parent device, at the time the
      child device is created.
      Signed-off-by: NKay Sievers <kay.sievers@novell.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      1901fb26
    • B
      Driver core: add notification of bus events · 116af378
      Benjamin Herrenschmidt 提交于
      I finally did as you suggested and added the notifier to the struct
      bus_type itself. There are still problems to be expected is something
      attaches to a bus type where the code can hook in different struct
      device sub-classes (which is imho a big bogosity but I won't even try to
      argue that case now) but it will solve nicely a number of issues I've
      had so far.
      
      That also means that clients interested in registering for such
      notifications have to do it before devices are added and after bus types
      are registered. Fortunately, most bus types that matter for the various
      usage scenarios I have in mind are registerd at postcore_initcall time,
      which means I have a really nice spot at arch_initcall time to add my
      notifiers.
      
      There are 4 notifications provided. Device being added (before hooked to
      the bus) and removed (failure of previous case or after being unhooked
      from the bus), along with driver being bound to a device and about to be
      unbound.
      
      The usage I have for these are:
      
       - The 2 first ones are used to maintain a struct device_ext that is
      hooked to struct device.firmware_data. This structure contains for now a
      pointer to the Open Firmware node related to the device (if any), the
      NUMA node ID (for quick access to it) and the DMA operations pointers &
      iommu table instance for DMA to/from this device. For bus types I own
      (like IBM VIO or EBUS), I just maintain that structure directly from the
      bus code when creating the devices. But for bus types managed by generic
      code like PCI or platform (actually, of_platform which is a variation of
      platform linked to Open Firmware device-tree), I need this notifier.
      
       - The other two ones have a completely different usage scenario. I have
      cases where multiple devices and their drivers depend on each other. For
      example, the IBM EMAC network driver needs to attach to a MAL DMA engine
      which is a separate device, and a PHY interface which is also a separate
      device. They are all of_platform_device's (well, about to be with my
      upcoming patches) but there is no say in what precise order the core
      will "probe" them and instanciate the various modules. The solution I
      found for that is to have the drivers for emac to use multithread_probe,
      and wait for a driver to be bound to the target MAL and PHY control
      devices (the device-tree contains reference to the MAL and PHY interface
      nodes, which I can then match to of_platform_devices). Right now, I've
      been polling, but with that notifier, I can more cleanly wait (with a
      timeout of course).
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      116af378
  19. 28 10月, 2006 1 次提交
    • A
      [PATCH] drivers: wait for threaded probes between initcall levels · 735a7ffb
      Andrew Morton 提交于
      The multithreaded-probing code has a problem: after one initcall level (eg,
      core_initcall) has been processed, we will then start processing the next
      level (postcore_initcall) while the kernel threads which are handling
      core_initcall are still executing.  This breaks the guarantees which the
      layered initcalls previously gave us.
      
      IOW, we want to be multithreaded _within_ an initcall level, but not between
      different levels.
      
      Fix that up by causing the probing code to wait for all outstanding probes at
      one level to complete before we start processing the next level.
      
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      735a7ffb
  20. 19 10月, 2006 2 次提交
  21. 26 9月, 2006 3 次提交
    • A
      Driver core: Fix potential deadlock in driver core · f2eaae19
      Alan Stern 提交于
      There is a potential deadlock in the driver core.  It boils down to
      the fact that bus_remove_device() calls klist_remove() instead of
      klist_del(), thereby waiting until the reference count of the
      klist_node in the bus's klist of devices drops to 0.  The refcount
      can't reach 0 so long as a modprobe process is trying to bind a new
      driver to the device being removed, by calling __driver_attach().  The
      problem is that __driver_attach() tries to acquire the device's
      parent's semaphore, but the caller of bus_remove_device() is quite
      likely to own that semaphore already.
      
      It isn't sufficient just to replace klist_remove() with klist_del().
      Doing so runs the risk that the device would remain on the bus's klist
      of devices for some time, and so could be bound to another driver even
      after it was unregistered.  What's needed is a new way to distinguish
      whether or not a device is registered, based on a criterion other than
      whether its klist_node is linked into the bus's klist of devices.  That
      way driver binding can fail when the device is unregistered, even if
      it is still linked into the klist.
      
      This patch (as782) implements the solution, by adding a new bitflag to
      indiate when a struct device is registered, by testing the flag before
      allowing a driver to bind a device, and by changing the definition of
      the device_is_registered() inline.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f2eaae19
    • G
      Driver Core: add ability for drivers to do a threaded probe · d779249e
      Greg Kroah-Hartman 提交于
      This adds the infrastructure for drivers to do a threaded probe, and
      waits at init time for all currently outstanding probes to complete.
      
      A new kernel thread will be created when the probe() function for the
      driver is called, if the multithread_probe bit is set in the driver
      saying it can support this kind of operation.
      
      I have tested this with USB and PCI, and it works, and shaves off a lot
      of time in the boot process, but there are issues with finding root boot
      disks, and some USB drivers assume that this can never happen, so it is
      currently not enabled for any bus type.  Individual drivers can enable
      this right now if they wish, and bus authors can selectivly turn it on
      as well, once they determine that their subsystem will work properly
      with it.
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d779249e
    • A
      drivers/base: check errors · f86db396
      Andrew Morton 提交于
      Add lots of return-value checking.
      
      <pcornelia.huck@de.ibm.com>: fix bus_rescan_devices()]
      Cc: "Randy.Dunlap" <rdunlap@xenotime.net>
      Signed-off-by: NCornelia Huck <cornelia.huck@de.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f86db396
  22. 15 4月, 2006 1 次提交
  23. 14 1月, 2006 1 次提交
  24. 05 1月, 2006 1 次提交
    • A
      [PATCH] Hold the device's parent's lock during probe and remove · bf74ad5b
      Alan Stern 提交于
      This patch (as604) makes the driver core hold a device's parent's lock
      as well as the device's lock during calls to the probe and remove
      methods in a driver.  This facility is needed by USB device drivers,
      owing to the peculiar way USB devices work:
      
      	A device provides multiple interfaces, and drivers are bound
      	to interfaces rather than to devices;
      
      	Nevertheless a reset, reset-configuration, suspend, or resume
      	affects the entire device and requires the caller to hold the
      	lock for the device, not just a lock for one of the interfaces.
      
      Since a USB driver's probe method is always called with the interface
      lock held, the locking order rules (always lock parent before child)
      prevent these methods from acquiring the device lock.  The solution
      provided here is to call all probe and remove methods, for all devices
      (not just USB), with the parent lock already acquired.
      
      Although currently only the USB subsystem requires these changes, people
      have mentioned in prior discussion that the overhead of acquiring an
      extra semaphore in all the prove/remove sequences is not overly large.
      
      Up to now, the USB core has been using its own set of private
      semaphores.  A followup patch will remove them, relying entirely on the
      device semaphores provided by the driver core.
      
      The code paths affected by this patch are:
      
      	device_add and device_del: The USB core already holds the parent
      	lock, so no actual change is needed.
      
      	driver_register and driver_unregister: The driver core will now
      	lock both the parent and the device before probing or removing.
      
      	driver_bind and driver_unbind (in sysfs): These routines will
      	now lock both the parent and the device before binding or
      	unbinding.
      
      	bus_rescan_devices: The helper routine will lock the parent
      	before probing a device.
      
      I have not tested this patch for conflicts with other subsystems.  As
      far as I can see, the only possibility of conflict would lie in the
      bus_rescan_devices pathway, and it seems pretty remote.  Nevertheless,
      it would be good for this to get a lot of testing in -mm.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      bf74ad5b