1. 01 11月, 2016 3 次提交
    • 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
      PM / sleep: Make async suspend/resume of devices use device links · 8c73b428
      Rafael J. Wysocki 提交于
      Make the device suspend/resume part of the core system
      suspend/resume code use device links to ensure that supplier
      and consumer devices will be suspended and resumed in the right
      order in case of async suspend/resume.
      
      The idea, roughly, is to use dpm_wait() to wait for all consumers
      before a supplier device suspend and to wait for all suppliers
      before a consumer device resume.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c73b428
    • 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
  2. 28 10月, 2016 1 次提交
  3. 27 10月, 2016 1 次提交
  4. 08 10月, 2016 1 次提交
  5. 28 9月, 2016 2 次提交
  6. 27 9月, 2016 1 次提交
  7. 26 9月, 2016 1 次提交
    • D
      PM / OPP: Don't support OPP if it provides supported-hw but platform does not · a4ee4545
      Dave Gerlach 提交于
      The OPP framework allows each OPP to set a opp-supported-hw property
      which provides values that are matched against supported_hw values
      provided by the platform to limit support for certain OPPs on specific
      hardware. Currently, if the platform does not set supported_hw values,
      all OPPs are interpreted as supported, even if they have provided their
      own opp-supported-hw values.
      
      If an OPP has provided opp-supported-hw, it is indicating that there is
      some specific hardware configuration it is supported by. These constraints
      should be honored, and if no supported_hw has been provided by the
      platform, there is no way to determine if that OPP is actually supported,
      so it should be marked as not supported.
      Signed-off-by: NDave Gerlach <d-gerlach@ti.com>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      a4ee4545
  8. 24 9月, 2016 4 次提交
  9. 22 9月, 2016 1 次提交
  10. 17 9月, 2016 2 次提交
  11. 16 9月, 2016 3 次提交
    • T
      regmap: Add missing little endian functions · 55562449
      Tony Lindgren 提交于
      This with the longer read and write masks allow supporting more
      exotic devices. For example a little endian SPI device:
      
      static const struct regmap_config foo_regmap_config = {
      	.reg_bits = 16,
      	.reg_stride = 4,
      	.val_bits = 16,
      	.write_flag_mask = 0x8000,
      	.reg_format_endian = REGMAP_ENDIAN_LITTLE,
      	.val_format_endian = REGMAP_ENDIAN_LITTLE,
      	...
      };
      Signed-off-by: NTony Lindgren <tony@atomide.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      55562449
    • T
      regmap: Allow longer flag masks for read and write · f50e38c9
      Tony Lindgren 提交于
      We currently only support masking the top bit for read and write
      flags. Let's make the mask unsigned long and mask the bytes based
      on the configured register length to make things more generic.
      
      This allows using regmap for more exotic combinations like SPI
      devices that need little endian addressing.
      Signed-off-by: NTony Lindgren <tony@atomide.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      f50e38c9
    • P
      PM / runtime: Use _rcuidle for runtime suspend tracepoints · 77893577
      Paul E. McKenney 提交于
      Further testing with false negatives suppressed by commit 293e2421
      ("rcu: Remove superfluous versions of rcu_read_lock_sched_held()")
      identified a few more unprotected uses of RCU from the idle loop.
      Because RCU actively ignores idle-loop code (for energy-efficiency
      reasons, among other things), using RCU from the idle loop can result
      in too-short grace periods, in turn resulting in arbitrary misbehavior.
      
      The affected function is rpm_suspend().
      
      The resulting lockdep-RCU splat is as follows:
      
      ------------------------------------------------------------------------
      
      Warning from omap3
      
      ===============================
      [ INFO: suspicious RCU usage. ]
      4.6.0-rc5-next-20160426+ #1112 Not tainted
      -------------------------------
      include/trace/events/rpm.h:63 suspicious rcu_dereference_check() usage!
      
      other info that might help us debug this:
      
      RCU used illegally from idle CPU!
      rcu_scheduler_active = 1, debug_locks = 0
      RCU used illegally from extended quiescent state!
      1 lock held by swapper/0/0:
       #0:  (&(&dev->power.lock)->rlock){-.-...}, at: [<c052ee24>] __pm_runtime_suspend+0x54/0x84
      
      stack backtrace:
      CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.6.0-rc5-next-20160426+ #1112
      Hardware name: Generic OMAP36xx (Flattened Device Tree)
      [<c0110308>] (unwind_backtrace) from [<c010c3a8>] (show_stack+0x10/0x14)
      [<c010c3a8>] (show_stack) from [<c047fec8>] (dump_stack+0xb0/0xe4)
      [<c047fec8>] (dump_stack) from [<c052d7b4>] (rpm_suspend+0x604/0x7e4)
      [<c052d7b4>] (rpm_suspend) from [<c052ee34>] (__pm_runtime_suspend+0x64/0x84)
      [<c052ee34>] (__pm_runtime_suspend) from [<c04bf3bc>] (omap2_gpio_prepare_for_idle+0x5c/0x70)
      [<c04bf3bc>] (omap2_gpio_prepare_for_idle) from [<c01255e8>] (omap_sram_idle+0x140/0x244)
      [<c01255e8>] (omap_sram_idle) from [<c0126b48>] (omap3_enter_idle_bm+0xfc/0x1ec)
      [<c0126b48>] (omap3_enter_idle_bm) from [<c0601db8>] (cpuidle_enter_state+0x80/0x3d4)
      [<c0601db8>] (cpuidle_enter_state) from [<c0183c74>] (cpu_startup_entry+0x198/0x3a0)
      [<c0183c74>] (cpu_startup_entry) from [<c0b00c0c>] (start_kernel+0x354/0x3c8)
      [<c0b00c0c>] (start_kernel) from [<8000807c>] (0x8000807c)
      
      ------------------------------------------------------------------------
      Reported-by: NTony Lindgren <tony@atomide.com>
      Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Tested-by: NTony Lindgren <tony@atomide.com>
      Tested-by: NGuenter Roeck <linux@roeck-us.net>
      [ rjw: Subject ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      77893577
  12. 15 9月, 2016 1 次提交
  13. 14 9月, 2016 1 次提交
    • D
      driver: base: pinctrl: return error from pinctrl_bind_pins() · eb4ec68a
      Deepak 提交于
      strict pin controller returns -EINVAL in case of pin request which
      is already claimed by somebody else.
      Following is the sequence of calling pin_request() from
      pinctrl_bind_pins():-
      pinctrl_bind_pins()->pinctrl_select_state()->pinmux_enable_setting()->
      pin_request()
      
      But pinctrl_bind_pins() only returns -EPROBE_DEFER which makes device
      driver probe successful even if the pin request is rejected by the pin
      controller subsystem.
      
      This commit modifies pinctrl_bind_pins() to return error if the pin is
      rejected by pin control subsystem.
      Signed-off-by: NDeepak Das <deepak_das@mentor.com>
      [Rewrote to be cleaner]
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      eb4ec68a
  14. 13 9月, 2016 8 次提交
    • J
      PM / Domains: Add support for removing nested PM domains by provider · 17926551
      Jon Hunter 提交于
      If a device supports PM domains that are subdomains of another PM
      domain, then the PM domains should be removed in reverse order to
      ensure that the subdomains are removed first. Furthermore, if there is
      more than one provider, then there needs to be a way to remove the
      domains in reverse order for a specific provider.
      
      Add the function of_genpd_remove_last() to remove the last PM domain
      added by a given PM domain provider and return the generic_pm_domain
      structure for the PM domain that was removed.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      17926551
    • J
      PM / Domains: Add support for removing PM domains · 3fe57710
      Jon Hunter 提交于
      The genpd framework allows users to add PM domains via the pm_genpd_init()
      function, however, there is no corresponding function to remove a PM
      domain. For most devices this may be fine as the PM domains are never
      removed, however, for devices that wish to populate the PM domains from
      within a driver, having the ability to remove a PM domain if the probing
      of the device fails or the driver is unloaded is necessary.
      
      Add the function pm_genpd_remove() to remove a PM domain by referencing
      it's generic_pm_domain structure. Note that the bulk of the code that
      removes the PM domain is placed in a separate local function
      genpd_remove() (which is called by pm_genpd_remove()). The code is
      structured in this way to prepare for adding another function to remove
      a PM domain by provider that will also call genpd_remove(). Note that
      users of genpd_remove() must call this function with the mutex,
      gpd_list_lock, held.
      
      PM domains can only be removed if the associated provider has been
      removed, they are not a parent domain to another PM domain and have no
      devices associated with them.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      3fe57710
    • J
      PM / Domains: Store the provider in the PM domain structure · de0aa06d
      Jon Hunter 提交于
      It is possible that a device has more than one provider of PM domains
      and to support the removal of a PM domain by provider, it is necessary
      to store a reference to the provider in the PM domain structure.
      Therefore, store a reference to the firmware node handle in the PM
      domain structure and populate it when providers (only device-tree based
      providers are currently supported by PM domains) are registered.
      
      Please note that when removing PM domains, it is necessary to verify
      that the PM domain provider has been removed from the list of providers
      before the PM domain can be removed. To do this add another member to
      the PM domain structure that indicates if the provider is present and
      set this member accordingly when providers are added and removed.
      
      Initialise the 'provider' and 'has_provider' members of the
      generic_pm_domain structure when a PM domains is added by calling
      pm_genpd_init().
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      de0aa06d
    • J
      PM / Domains: Prepare for adding support to remove PM domains · 19efa5ff
      Jon Hunter 提交于
      In order to remove PM domains safely from the list of PM domains,
      it is necessary to adding locking for the PM domain list around any
      places where devices or subdomains are added to a PM domain.
      
      There are places where a reference to a PM domain is obtained via
      calling of_genpd_get_from_provider() before adding the device or the
      subdomain. In these cases a lock for the PM domain list needs to be
      held around the call to of_genpd_get_from_provider() and the call to
      add the device/subdomain. To avoid deadlocks by multiple attempts to
      obtain the PM domain list lock, add functions genpd_add_device() and
      genpd_add_subdomain() which require the user to hold the PM domain
      list lock when calling.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      19efa5ff
    • J
      PM / Domains: Verify the PM domain is present when adding a provider · 0159ec67
      Jon Hunter 提交于
      When a PM domain provider is added, there is currently no way to tell if
      any PM domains associated with the provider are present. Naturally, the
      PM domain provider should not be registered if the PM domains have not
      been added. Nonetheless, verify that the PM domain(s) associated with a
      provider are present when registering the PM domain provider.
      
      This change adds a dependency on the function pm_genpd_present() when
      CONFIG_PM_GENERIC_DOMAINS_OF is enabled and so ensure this function is
      available when CONFIG_PM_GENERIC_DOMAINS_OF selected.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0159ec67
    • J
      PM / Domains: Don't expose xlate and provider helper functions · 892ebdcc
      Jon Hunter 提交于
      Functions __of_genpd_xlate_simple(), __of_genpd_xlate_onecell() and
      __of_genpd_add_provider() are not used outside of the core generic PM
      domain code. Therefore, reduce the number of APIs exposed by making
      these static. At the same time don't expose the typedef for
      genpd_xlate_t either and make this a local definition as well.
      
      The functions are renamed to follow the naming conventions for static
      functions in the generic PM domain core.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      892ebdcc
    • J
      PM / Domains: Don't expose generic_pm_domain structure to clients · f58d4e5a
      Jon Hunter 提交于
      There should be no need to expose the generic_pm_domain structure to
      clients and this eliminates the need to implement reference counting for
      any external reference to a PM domain. Therefore, make the functions
      pm_genpd_lookup_dev() and of_genpd_get_from_provider() private to the
      PM domain core. The functions are renamed in accordance with the naming
      conventions for genpd static functions.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f58d4e5a
    • J
      PM / Domains: Add new helper functions for device-tree · ec69572b
      Jon Hunter 提交于
      Ideally, if we are returning a reference to a PM domain via a call to
      of_genpd_get_from_provider(), then we should keep track of such
      references via a reference count. The reference count could then be used
      to determine if a PM domain can be safely removed. Alternatively, it is
      possible to avoid such external references by providing APIs to access
      the PM domain and hence, eliminate any calls to
      of_genpd_get_from_provider().
      
      Add new helper functions for adding a device and a subdomain to a PM
      domain when using device-tree, so that external calls to
      of_genpd_get_from_provider() can be removed.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ec69572b
  15. 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
  16. 31 8月, 2016 9 次提交