1. 31 1月, 2019 4 次提交
  2. 19 12月, 2018 1 次提交
  3. 06 12月, 2018 1 次提交
  4. 12 11月, 2018 2 次提交
  5. 08 9月, 2018 2 次提交
  6. 10 7月, 2018 2 次提交
    • R
      driver core: Partially revert "driver core: correct device's shutdown order" · 722e5f2b
      Rafael J. Wysocki 提交于
      Commit 52cdbdd4 (driver core: correct device's shutdown order)
      introduced a regression by breaking device shutdown on some systems.
      
      Namely, the devices_kset_move_last() call in really_probe() added by
      that commit is a mistake as it may cause parents to follow children
      in the devices_kset list which then causes shutdown to fail.  For
      example, if a device has children before really_probe() is called
      for it (which is not uncommon), that call will cause it to be
      reordered after the children in the devices_kset list and the
      ordering of that list will not reflect the correct device shutdown
      order any more.
      
      Also it causes the devices_kset list to be constantly reordered
      until all drivers have been probed which is totally pointless
      overhead in the majority of cases and it only covered an issue
      with system shutdown, while system-wide suspend/resume potentially
      had the same issue on the affected platforms (which was not covered).
      
      Moreover, the shutdown issue originally addressed by the change in
      really_probe() made by commit 52cdbdd4 is not present in 4.18-rc
      any more, since dra7 started to use the sdhci-omap driver which
      doesn't disable any regulators during shutdown, so the really_probe()
      part of commit 52cdbdd4 can be safely reverted.  [The original
      issue was related to the omap_hsmmc driver used by dra7 previously.]
      
      For the above reasons, revert the really_probe() modifications made
      by commit 52cdbdd4.
      
      The other code changes made by commit 52cdbdd4 are useful and
      they need not be reverted.
      
      Fixes: 52cdbdd4 (driver core: correct device's shutdown order)
      Link: https://lore.kernel.org/lkml/CAFgQCTt7VfqM=UyCnvNFxrSw8Z6cUtAi3HUwR4_xPAc03SgHjQ@mail.gmail.com/Reported-by: NPingfan Liu <kernelfans@gmail.com>
      Tested-by: NPingfan Liu <kernelfans@gmail.com>
      Reviewed-by: NKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      722e5f2b
    • R
      driver core: allow stopping deferred probe after init · 25b4e70d
      Rob Herring 提交于
      Deferred probe will currently wait forever on dependent devices to probe,
      but sometimes a driver will never exist. It's also not always critical for
      a driver to exist. Platforms can rely on default configuration from the
      bootloader or reset defaults for things such as pinctrl and power domains.
      This is often the case with initial platform support until various drivers
      get enabled. There's at least 2 scenarios where deferred probe can render
      a platform broken. Both involve using a DT which has more devices and
      dependencies than the kernel supports. The 1st case is a driver may be
      disabled in the kernel config. The 2nd case is the kernel version may
      simply not have the dependent driver. This can happen if using a newer DT
      (provided by firmware perhaps) with a stable kernel version. Deferred
      probe issues can be difficult to debug especially if the console has
      dependencies or userspace fails to boot to a shell.
      
      There are also cases like IOMMUs where only built-in drivers are
      supported, so deferring probe after initcalls is not needed. The IOMMU
      subsystem implemented its own mechanism to handle this using OF_DECLARE
      linker sections.
      
      This commit adds makes ending deferred probe conditional on initcalls
      being completed or a debug timeout. Subsystems or drivers may opt-in by
      calling driver_deferred_probe_check_init_done() instead of
      unconditionally returning -EPROBE_DEFER. They may use additional
      information from DT or kernel's config to decide whether to continue to
      defer probe or not.
      
      The timeout mechanism is intended for debug purposes and WARNs loudly.
      The remaining deferred probe pending list will also be dumped after the
      timeout. Not that this timeout won't work for the console which needs
      to be enabled before userspace starts. However, if the console's
      dependencies are resolved, then the kernel log will be printed (as
      opposed to no output).
      
      Cc: Alexander Graf <agraf@suse.de>
      Signed-off-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25b4e70d
  7. 08 7月, 2018 1 次提交
    • J
      driver core: add a debugfs entry to show deferred devices · 28af109a
      Javier Martinez Canillas 提交于
      With Device Trees (DT), the dependencies of the devices are defined in the
      DT, then the drivers parse that information to lookup the needed resources
      that have as dependencies.
      
      Since drivers and devices are registered in a non-deterministic way, it is
      possible that a device that is a dependency has not been registered yet by
      the time that is looked up.
      
      In this case the driver that requires this dependency cannot probe and has
      to defer it. So the driver core adds it to a list of deferred devices that
      is iterated again every time that a new driver is probed successfully.
      
      For debugging purposes it may be useful to know what are the devices whose
      probe function was deferred. Add a debugfs entry showing that information.
      
        $ cat /sys/kernel/debug/devices_deferred
        48070000.i2c:twl@48:bci
        musb-hdrc.0.auto
        omapdrm.0
      
      This information could be obtained partially by enabling debugging, but it
      means that the kernel log has to be parsed and the probe deferral balanced
      with the successes. This can be error probe and has to be done in a ad-hoc
      manner by everyone who needs to debug these kind of issues.
      
      Since the information is already known by the kernel, just show it to make
      it easier to debug.
      Signed-off-by: NJavier Martinez Canillas <javierm@redhat.com>
      Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
      Reviewed-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28af109a
  8. 06 7月, 2018 1 次提交
  9. 12 6月, 2018 1 次提交
  10. 31 5月, 2018 1 次提交
    • M
      driver core: hold dev's parent lock when needed · 8c97a46a
      Martin Liu 提交于
      SoC have internal I/O buses that can't be proved for devices. The
      devices on the buses can be accessed directly without additinal
      configuration required. This type of bus is represented as
      "simple-bus". In some platforms, we name "soc" with "simple-bus"
      attribute and many devices are hooked under it described in DT
      (device tree).
      
      In commit bf74ad5b ("Hold the device's parent's lock during
      probe and remove") to solve USB subsystem lock sequence since
      USB device's characteristic. Thus "soc" needs to be locked
      whenever a device and driver's probing happen under "soc" bus.
      During this period, an async driver tries to probe a device which
      is under the "soc" bus would be blocked until previous driver
      finish the probing and release "soc" lock. And the next probing
      under the "soc" bus need to wait for async finish. Because of
      that, driver's async probe for init time improvement will be
      shadowed.
      
      Since many devices don't have USB devices' characteristic, they
      actually don't need parent's lock. Thus, we introduce a lock flag
      in bus_type struct and driver core would lock the parent lock base
      on the flag. For USB, we set this flag in usb_bus_type to keep
      original lock behavior in driver core.
      
      Async probe could have more benefit after this patch.
      Signed-off-by: NMartin Liu <liumartin@google.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c97a46a
  11. 27 5月, 2018 1 次提交
    • U
      PM / runtime: Fixup reference counting of device link suppliers at probe · 1e837861
      Ulf Hansson 提交于
      In the driver core, before it invokes really_probe() it runtime resumes the
      suppliers for the device via calling pm_runtime_get_suppliers(), which also
      increases the runtime PM usage count for each of the available supplier.
      
      This makes sense, as to be able to allow the consumer device to be probed
      by its driver. However, if the driver decides to add a new supplier link
      during ->probe(), hence updating the list of suppliers, the following call
      to pm_runtime_put_suppliers(), invoked after really_probe() in the driver
      core, we get into trouble.
      
      More precisely, pm_runtime_put() gets called also for the new supplier(s),
      which is wrong as the driver core, didn't trigger pm_runtime_get_sync() to
      be called for it in the first place. In other words, the new supplier may
      be runtime suspended even in cases when it shouldn't.
      
      Fix this behaviour, by runtime resume suppliers according to the same
      conditions as managed by the runtime PM core, when runtime resume callbacks
      are being invoked.
      
      Additionally, don't try to runtime suspend any of the suppliers after
      really_probe(), but instead rely on that to happen via the consumer device,
      when it becomes runtime suspended.
      
      Fixes: 21d5c57b (PM / runtime: Use device links)
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      1e837861
  12. 24 4月, 2018 1 次提交
  13. 24 3月, 2018 1 次提交
  14. 23 1月, 2018 1 次提交
  15. 08 12月, 2017 2 次提交
    • G
      driver core: Remove redundant license text · 32825709
      Greg Kroah-Hartman 提交于
      Now that the SPDX tag is in all driver core files, that identifies the
      license in a specific and legally-defined manner.  So the extra GPL text
      wording can be removed as it is no longer needed at all.
      
      This is done on a quest to remove the 700+ different ways that files in
      the kernel describe the GPL license text.  And there's unneeded stuff
      like the address (sometimes incorrect) for the FSF which is never
      needed.
      
      No copyright headers or other non-license-description text was removed.
      
      Cc: Johannes Berg <johannes@sipsolutions.net>
      Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      32825709
    • G
      driver core: add SPDX identifiers to all driver core files · 989d42e8
      Greg Kroah-Hartman 提交于
      It's good to have SPDX identifiers in all files to make it easier to
      audit the kernel tree for correct licenses.
      
      Update the driver core files files with the correct SPDX license
      identifier based on the license text in the file itself.  The SPDX
      identifier is a legally binding shorthand, which can be used instead of
      the full boiler plate text.
      
      This work is based on a script and data from Thomas Gleixner, Philippe
      Ombredanne, and Kate Stewart.
      
      Cc: Johannes Berg <johannes@sipsolutions.net>
      Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
      Cc: William Breathitt Gray <vilhelm.gray@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      989d42e8
  16. 08 11月, 2017 1 次提交
  17. 06 11月, 2017 1 次提交
    • R
      PM / core: Add NEVER_SKIP and SMART_PREPARE driver flags · 08810a41
      Rafael J. Wysocki 提交于
      The motivation for this change is to provide a way to work around
      a problem with the direct-complete mechanism used for avoiding
      system suspend/resume handling for devices in runtime suspend.
      
      The problem is that some middle layer code (the PCI bus type and
      the ACPI PM domain in particular) returns positive values from its
      system suspend ->prepare callbacks regardless of whether the driver's
      ->prepare returns a positive value or 0, which effectively prevents
      drivers from being able to control the direct-complete feature.
      Some drivers need that control, however, and the PCI bus type has
      grown its own flag to deal with this issue, but since it is not
      limited to PCI, it is better to address it by adding driver flags at
      the core level.
      
      To that end, add a driver_flags field to struct dev_pm_info for flags
      that can be set by device drivers at the probe time to inform the PM
      core and/or bus types, PM domains and so on on the capabilities and/or
      preferences of device drivers.  Also add two static inline helpers
      for setting that field and testing it against a given set of flags
      and make the driver core clear it automatically on driver remove
      and probe failures.
      
      Define and document two PM driver flags related to the direct-
      complete feature: NEVER_SKIP and SMART_PREPARE that can be used,
      respectively, to indicate to the PM core that the direct-complete
      mechanism should never be used for the device and to inform the
      middle layer code (bus types, PM domains etc) that it can only
      request the PM core to use the direct-complete mechanism for
      the device (by returning a positive value from its ->prepare
      callback) if it also has been requested by the driver.
      
      While at it, make the core check pm_runtime_suspended() when
      setting power.direct_complete so that it doesn't need to be
      checked by ->prepare callbacks.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      08810a41
  18. 04 8月, 2017 1 次提交
    • T
      initcall_debug: add deferred probe times · 1f5000bd
      Todd Poynor 提交于
      initcall_debug attributes all deferred device probe retries for the
      late_initcall level to function deferred_probe_initcall.  Add logs of
      the individual device probe routines called, to identify which drivers
      are executing for how long during the initcall path.  Deferred probes
      that occur after initcall processing are not shown.
      
      Example log messages added:
      
      [    0.505119] deferred probe my-sound-device @ 6
      [    0.517656] deferred probe my-sound-device returned after 1227 usecs
      Signed-off-by: NTodd Poynor <toddpoynor@google.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f5000bd
  19. 22 7月, 2017 1 次提交
    • D
      driver core: emit uevents when device is bound to a driver · 1455cf8d
      Dmitry Torokhov 提交于
      There are certain touch controllers that may come up in either normal
      (application) or boot mode, depending on whether firmware/configuration is
      corrupted when they are powered on. In boot mode the kernel does not create
      input device instance (because it does not necessarily know the
      characteristics of the input device in question).
      
      Another number of controllers does not store firmware in a non-volatile
      memory, and they similarly need to have firmware loaded before input device
      instance is created. There are also other types of devices with similar
      behavior.
      
      There is a desire to be able to trigger firmware loading via udev, but it
      has to happen only when driver is bound to a physical device (i2c or spi).
      These udev actions can not use ADD events, as those happen too early, so we
      are introducing BIND and UNBIND events that are emitted at the right
      moment.
      
      Also, many drivers create additional driver-specific device attributes
      when binding to the device, to provide userspace with additional controls.
      The new events allow userspace to adjust these driver-specific attributes
      without worrying that they are not there yet.
      Signed-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1455cf8d
  20. 20 4月, 2017 1 次提交
  21. 14 1月, 2017 1 次提交
  22. 11 11月, 2016 1 次提交
  23. 01 11月, 2016 2 次提交
    • R
      PM / runtime: Use device links · 21d5c57b
      Rafael J. Wysocki 提交于
      Modify the runtime PM framework to use device links to ensure that
      supplier devices will not be suspended if any of their consumer
      devices are active.
      
      The idea is to reference count suppliers on the consumer's resume
      and drop references to them on its suspend.  The information on
      whether or not the supplier has been reference counted by the
      consumer's (runtime) resume is stored in a new field (rpm_active)
      in the link object for each link.
      
      It may be necessary to clean up those references when the
      supplier is unbinding and that's why the links whose status is
      DEVICE_LINK_SUPPLIER_UNBIND are skipped by the runtime suspend
      and resume code.
      
      The above means that if the consumer device is probed in the
      runtime-active state, the supplier has to be resumed and reference
      counted by device_link_add() so the code works as expected on its
      (runtime) suspend.  There is a new flag, DEVICE_LINK_RPM_ACTIVE,
      to tell device_link_add() about that (in which case the caller
      is responsible for making sure that the consumer really will
      be runtime-active when runtime PM is enabled for it).
      
      The other new link flag, DEVICE_LINK_PM_RUNTIME, tells the core
      whether or not the link should be used for runtime PM at all.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21d5c57b
    • R
      driver core: Functional dependencies tracking support · 9ed98953
      Rafael J. Wysocki 提交于
      Currently, there is a problem with taking functional dependencies
      between devices into account.
      
      What I mean by a "functional dependency" is when the driver of device
      B needs device A to be functional and (generally) its driver to be
      present in order to work properly.  This has certain consequences
      for power management (suspend/resume and runtime PM ordering) and
      shutdown ordering of these devices.  In general, it also implies that
      the driver of A needs to be working for B to be probed successfully
      and it cannot be unbound from the device before the B's driver.
      
      Support for representing those functional dependencies between
      devices is added here to allow the driver core to track them and act
      on them in certain cases where applicable.
      
      The argument for doing that in the driver core is that there are
      quite a few distinct use cases involving device dependencies, they
      are relatively hard to get right in a driver (if one wants to
      address all of them properly) and it only gets worse if multiplied
      by the number of drivers potentially needing to do it.  Morever, at
      least one case (asynchronous system suspend/resume) cannot be handled
      in a single driver at all, because it requires the driver of A to
      wait for B to suspend (during system suspend) and the driver of B to
      wait for A to resume (during system resume).
      
      For this reason, represent dependencies between devices as "links",
      with the help of struct device_link objects each containing pointers
      to the "linked" devices, a list node for each of them, status
      information, flags, and an RCU head for synchronization.
      
      Also add two new list heads, representing the lists of links to the
      devices that depend on the given one (consumers) and to the devices
      depended on by it (suppliers), and a "driver presence status" field
      (needed for figuring out initial states of device links) to struct
      device.
      
      The entire data structure consisting of all of the lists of link
      objects for all devices is protected by a mutex (for link object
      addition/removal and for list walks during device driver probing
      and removal) and by SRCU (for list walking in other case that will
      be introduced by subsequent change sets).  If CONFIG_SRCU is not
      selected, however, an rwsem is used for protecting the entire data
      structure.
      
      In addition, each link object has an internal status field whose
      value reflects whether or not drivers are bound to the devices
      pointed to by the link or probing/removal of their drivers is in
      progress etc.  That field is only modified under the device links
      mutex, but it may be read outside of it in some cases (introduced by
      subsequent change sets), so modifications of it are annotated with
      WRITE_ONCE().
      
      New links are added by calling device_link_add() which takes three
      arguments: pointers to the devices in question and flags.  In
      particular, if DL_FLAG_STATELESS is set in the flags, the link status
      is not to be taken into account for this link and the driver core
      will not manage it.  In turn, if DL_FLAG_AUTOREMOVE is set in the
      flags, the driver core will remove the link automatically when the
      consumer device driver unbinds from it.
      
      One of the actions carried out by device_link_add() is to reorder
      the lists used for device shutdown and system suspend/resume to
      put the consumer device along with all of its children and all of
      its consumers (and so on, recursively) to the ends of those lists
      in order to ensure the right ordering between all of the supplier
      and consumer devices.
      
      For this reason, it is not possible to create a link between two
      devices if the would-be supplier device already depends on the
      would-be consumer device as either a direct descendant of it or a
      consumer of one of its direct descendants or one of its consumers
      and so on.
      
      There are two types of link objects, persistent and non-persistent.
      The persistent ones stay around until one of the target devices is
      deleted, while the non-persistent ones are removed automatically when
      the consumer driver unbinds from its device (ie. they are assumed to
      be valid only as long as the consumer device has a driver bound to
      it).  Persistent links are created by default and non-persistent
      links are created when the DL_FLAG_AUTOREMOVE flag is passed
      to device_link_add().
      
      Both persistent and non-persistent device links can be deleted
      with an explicit call to device_link_del().
      
      Links created without the DL_FLAG_STATELESS flag set are managed
      by the driver core using a simple state machine.  There are 5 states
      each link can be in: DORMANT (unused), AVAILABLE (the supplier driver
      is present and functional), CONSUMER_PROBE (the consumer driver is
      probing), ACTIVE (both supplier and consumer drivers are present and
      functional), and SUPPLIER_UNBIND (the supplier driver is unbinding).
      The driver core updates the link state automatically depending on
      what happens to the linked devices and for each link state specific
      actions are taken in addition to that.
      
      For example, if the supplier driver unbinds from its device, the
      driver core will also unbind the drivers of all of its consumers
      automatically under the assumption that they cannot function
      properly without the supplier.  Analogously, the driver core will
      only allow the consumer driver to bind to its device if the
      supplier driver is present and functional (ie. the link is in
      the AVAILABLE state).  If that's not the case, it will rely on
      the existing deferred probing mechanism to wait for the supplier
      driver to become available.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ed98953
  24. 31 10月, 2016 2 次提交
  25. 28 10月, 2016 1 次提交
  26. 02 9月, 2016 1 次提交
    • B
      device core: Remove deprecated create_singlethread_workqueue · 2c507e46
      Bhaktipriya Shridhar 提交于
      The workqueue "deferred_wq" queues a single work item
      &deferred_probe_work and hence doesn't require ordering.
      It is involved in probing devices and is not being used on a memory
      reclaim path. Hence, it has been converted to use system_wq.
      
      System workqueues have been able to handle high level of concurrency
      for a long time now and hence it's not required to have a singlethreaded
      workqueue just to gain concurrency. Unlike a dedicated per-cpu workqueue
      created with create_singlethread_workqueue(), system_wq allows multiple
      work items to overlap executions even on the same CPU; however, a
      per-cpu workqueue doesn't have any CPU locality or global ordering
      guarantee unless the target CPU is explicitly specified and thus the
      increase of local concurrency shouldn't make any difference.
      
      The work item has been flushed in driver_probe_done() to ensure that
      there are no pending tasks while disconnecting the driver.
      Signed-off-by: NBhaktipriya Shridhar <bhaktipriya96@gmail.com>
      Acked-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c507e46
  27. 31 8月, 2016 1 次提交
  28. 03 5月, 2016 1 次提交
    • G
      Revert "base: dd: don't remove driver_data in -EPROBE_DEFER case" · c6e360a0
      Greg Kroah-Hartman 提交于
      This reverts commit ded9db38.
      
      Thierry Reding writes:
      	This causes a boot regression on at least one board, caused by
      	one of the drivers looking at driver data to check whether or
      	not the driver has properly loaded. If the code encounters a
      	non-NULL pointer it tries to dereference it, but because it's
      	already been freed there is no memory backing it and things
      	crash.
      
      	I don't think keeping stale pointers around is a good idea. The
      	whole point of setting this to NULL in the core is so that probe
      	failures result in the same starting conditions no matter what.
      
      	Can we please get this reverted?
      Reported-by: NThierry Reding <thierry.reding@gmail.com>
      Cc: Yi Zhang <yizhang_hust@163.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6e360a0
  29. 02 5月, 2016 1 次提交
  30. 17 2月, 2016 1 次提交
  31. 12 1月, 2016 1 次提交