1. 14 12月, 2018 2 次提交
    • V
      PM / Domains: Propagate performance state updates · 18edf49c
      Viresh Kumar 提交于
      Currently a genpd only handles the performance state requirements from
      the devices under its control. This commit extends that to also handle
      the performance state requirement(s) put on the master genpd by its
      sub-domains. There is a separate value required for each master that
      the genpd has and so a new field is added to the struct gpd_link
      (link->performance_state), which represents the link between a genpd and
      its master. The struct gpd_link also got another field
      prev_performance_state, which is used by genpd core as a temporary
      variable during transitions.
      
      On a call to dev_pm_genpd_set_performance_state(), the genpd core first
      updates the performance state of the masters of the device's genpd and
      then updates the performance state of the genpd. The masters do the same
      and propagate performance state updates to their masters before updating
      their own. The performance state transition from genpd to its master is
      done with the help of dev_pm_opp_xlate_performance_state(), which looks
      at the OPP tables of both the domains to translate the state.
      Tested-by: NRajendra Nayak <rnayak@codeaurora.org>
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      18edf49c
    • V
      PM / Domains: Save OPP table pointer in genpd · 1067ae3e
      Viresh Kumar 提交于
      dev_pm_genpd_set_performance_state() will be required to call
      dev_pm_opp_xlate_performance_state() going forward to translate from
      performance state of a sub-domain to performance state of its master.
      And dev_pm_opp_xlate_performance_state() needs pointers to the OPP
      tables of both genpd and its master.
      
      Lets fetch and save them while the OPP tables are added. Fetching the
      OPP tables should never fail as we just added the OPP tables and so add
      a WARN_ON() for such a bug instead of full error paths.
      Tested-by: NRajendra Nayak <rnayak@codeaurora.org>
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      1067ae3e
  2. 05 11月, 2018 2 次提交
  3. 18 10月, 2018 1 次提交
  4. 09 7月, 2018 2 次提交
  5. 25 6月, 2018 2 次提交
  6. 06 6月, 2018 2 次提交
    • U
      PM / Domains: Add dev_pm_domain_attach_by_id() to manage multi PM domains · 82e12d9e
      Ulf Hansson 提交于
      The existing dev_pm_domain_attach() function, allows a single PM domain to
      be attached per device. To be able to support devices that are partitioned
      across multiple PM domains, let's introduce a new interface,
      dev_pm_domain_attach_by_id().
      
      The dev_pm_domain_attach_by_id() returns a new allocated struct device with
      the corresponding attached PM domain. This enables for example a driver to
      operate on the new device from a power management point of view. The driver
      may then also benefit from using the received device, to set up so called
      device-links towards its original device. Depending on the situation, these
      links may then be dynamically changed.
      
      The new interface is typically called by drivers during their probe phase,
      in case they manages devices which uses multiple PM domains. If that is the
      case, the driver also becomes responsible of managing the detaching of the
      PM domains, which typically should be done at the remove phase. Detaching
      is done by calling the existing dev_pm_domain_detach() function and for
      each of the received devices from dev_pm_domain_attach_by_id().
      
      Note, currently its only genpd that supports multiple PM domains per
      device, but dev_pm_domain_attach_by_id() can easily by extended to cover
      other PM domain types, if/when needed.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Acked-by: NJon Hunter <jonathanh@nvidia.com>
      Tested-by: NJon Hunter <jonathanh@nvidia.com>
      Reviewed-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      82e12d9e
    • U
      PM / Domains: Add support for multi PM domains per device to genpd · 3c095f32
      Ulf Hansson 提交于
      To support devices being partitioned across multiple PM domains, let's
      begin with extending genpd to cope with these kind of configurations.
      
      Therefore, add a new exported function genpd_dev_pm_attach_by_id(), which
      is similar to the existing genpd_dev_pm_attach(), but with the difference
      that it allows its callers to provide an index to the PM domain that it
      wants to attach.
      
      Note that, genpd_dev_pm_attach_by_id() shall only be called by the driver
      core / PM core, similar to how the existing dev_pm_domain_attach() makes
      use of genpd_dev_pm_attach(). However, this is implemented by following
      changes on top.
      
      Because, only one PM domain can be attached per device, genpd needs to
      create a virtual device that it can attach/detach instead. More precisely,
      let the new function genpd_dev_pm_attach_by_id() register a virtual struct
      device via calling device_register(). Then let it attach this device to the
      corresponding PM domain, rather than the one that is provided by the
      caller. The actual attaching is done via re-using the existing genpd OF
      functions.
      
      At successful attachment, genpd_dev_pm_attach_by_id() returns the created
      virtual device, which allows the caller to operate on it to deal with power
      management. Following changes on top, provides more details in this
      regards.
      
      To deal with detaching of a PM domain for the multiple PM domains case,
      let's also extend the existing genpd_dev_pm_detach() function, to cover the
      cleanup of the created virtual device, via make it call device_unregister()
      on it. In this way, there is no need to introduce a new function to deal
      with detach for the multiple PM domain case, but instead the existing one
      is re-used.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Acked-by: NJon Hunter <jonathanh@nvidia.com>
      Tested-by: NJon Hunter <jonathanh@nvidia.com>
      Reviewed-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      3c095f32
  7. 30 5月, 2018 3 次提交
  8. 15 5月, 2018 1 次提交
    • U
      PM / Domains: Allow a better error handling of dev_pm_domain_attach() · 919b7308
      Ulf Hansson 提交于
      The callers of dev_pm_domain_attach() currently checks the returned error
      code for -EPROBE_DEFER and needs to ignore other error codes. This is an
      unnecessary limitation, which also leads to a rather strange behaviour in
      the error path.
      
      Address this limitation, by changing the return codes from
      acpi_dev_pm_attach() and genpd_dev_pm_attach(). More precisely, let them
      return 0, when no PM domain is needed for the device and then return 1, in
      case the device was successfully attached to its PM domain. In this way,
      dev_pm_domain_attach(), gets a better understanding of what happens in the
      attach attempts and also allowing its caller to better act on real errors
      codes.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      919b7308
  9. 09 5月, 2018 2 次提交
    • V
      PM / Domain: Implement of_genpd_opp_to_performance_state() · 6e41766a
      Viresh Kumar 提交于
      This implements of_genpd_opp_to_performance_state() which can be used
      from the device drivers or the OPP core to find the performance state
      encoded in the "required-opps" property of a node. Normally this would
      be called only once for each OPP of the device for which the OPP table
      of the device is getting generated.
      
      Different platforms may encode the performance state differently using
      the OPP table (they may simply return value of opp-hz or opp-microvolt,
      or apply some algorithm on top of those values) and so a new callback
      ->opp_to_performance_state() is implemented to allow platform specific
      drivers to convert the power domain OPP to a performance state value.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      6e41766a
    • V
      PM / Domain: Add struct device to genpd · 401ea157
      Viresh Kumar 提交于
      The power-domain core would be using the OPP core going forward and the
      OPP core has the basic requirement of a device structure for its working.
      
      Add a struct device to the genpd structure. This doesn't register the
      device with device core as the "dev" pointer is mostly used by the OPP
      core as a cookie for now and registering the device is not mandatory.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      401ea157
  10. 08 11月, 2017 2 次提交
  11. 14 10月, 2017 1 次提交
    • V
      PM / Domains: Add support to select performance-state of domains · 42f6284a
      Viresh Kumar 提交于
      Some platforms have the capability to configure the performance state of
      PM domains. This patch enhances the genpd core to support such
      platforms.
      
      The performance levels (within the genpd core) are identified by
      positive integer values, a lower value represents lower performance
      state.
      
      This patch adds a new genpd API, which is called by user drivers (like
      OPP framework):
      
      - int dev_pm_genpd_set_performance_state(struct device *dev,
      					 unsigned int state);
      
        This updates the performance state constraint of the device on its PM
        domain. On success, the genpd will have its performance state set to a
        value which is >= "state" passed to this routine. The genpd core calls
        the genpd->set_performance_state() callback, if implemented,
        else -ENODEV is returned to the caller.
      
      The PM domain drivers need to implement the following callback if they
      want to support performance states.
      
      - int (*set_performance_state)(struct generic_pm_domain *genpd,
      			       unsigned int state);
      
        This is called internally by the genpd core on several occasions. The
        genpd core passes the genpd pointer and the aggregate of the
        performance states of the devices supported by that genpd to this
        callback. This callback must update the performance state of the genpd
        (in a platform dependent way).
      
      The power domains can avoid supplying above callback, if they don't
      support setting performance-states.
      
      Currently we aren't propagating performance state changes of a subdomain
      to its masters as we don't have hardware that needs it right now. Over
      that, the performance states of subdomain and its masters may not have
      one-to-one mapping and would require additional information. We can get
      back to this once we have hardware that needs it.
      Tested-by: NRajendra Nayak <rnayak@codeaurora.org>
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      42f6284a
  12. 25 7月, 2017 1 次提交
  13. 13 6月, 2017 1 次提交
  14. 04 4月, 2017 1 次提交
  15. 29 3月, 2017 1 次提交
    • U
      PM / Domains: Enable users of genpd to specify always on PM domains · ffaa42e8
      Ulf Hansson 提交于
      The current way to implement an always on PM domain consists of returning
      -EBUSY from the ->power_off() callback. This is a bit different compared to
      using the always on genpd governor, which prevents the PM domain from being
      powered off via runtime suspend, but not via system suspend.
      
      The approach to return -EBUSY from the ->power_off() callback to support
      always on PM domains in genpd is suboptimal. That is because it requires
      genpd to follow the regular execution path of the power off sequence, which
      ends by invoking the ->power_off() callback.
      
      To enable genpd to early abort the power off sequence for always on PM
      domains, it needs static information about these configurations. Therefore
      let's add a new genpd configuration flag, GENPD_FLAG_ALWAYS_ON.
      
      Users of the new GENPD_FLAG_ALWAYS_ON flag, are by genpd required to make
      sure the PM domain is powered on before calling pm_genpd_init(). Moreover,
      users don't need to implement the ->power_off() callback, as genpd doesn't
      ever invoke it.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: NViresh Kumar <viresh.kumar@linaro.org>
      Reviewed-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: NBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ffaa42e8
  16. 09 2月, 2017 1 次提交
  17. 22 10月, 2016 6 次提交
  18. 13 9月, 2016 6 次提交
    • 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: 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
  19. 29 6月, 2016 1 次提交
  20. 16 6月, 2016 1 次提交
    • U
      PM / Domains: Allow genpd to power on during system PM phases · 39dd0f23
      Ulf Hansson 提交于
      If a PM domain is powered off when the first device starts its system PM
      prepare phase, genpd prevents any further attempts to power on the PM
      domain during the following system PM phases. Not until the system PM
      complete phase is finalized for all devices in the PM domain, genpd again
      allows it to be powered on.
      
      This behaviour needs to be changed, as a subsystem/driver for a device in
      the same PM domain may still need to be able to serve requests in some of
      the system PM phases. Accordingly, it may need to runtime resume its
      device and thus also request the corresponding PM domain to be powered on.
      
      To deal with these scenarios, let's make the device operational in the
      system PM prepare phase by runtime resuming it, no matter if the PM domain
      is powered on or off. Changing this also enables us to remove genpd's
      suspend_power_off flag, as it's being used to track this condition.
      Additionally, we must allow the PM domain to be powered on via runtime PM
      during the system PM phases.
      
      This change also requires a fix in the AMD ACP (Audio CoProcessor) drm
      driver. It registers a genpd to model the ACP as a PM domain, but
      unfortunately it's also abuses genpd's "internal" suspend_power_off flag
      to deal with a corner case at system PM resume.
      
      More precisely, the so called SMU block powers on the ACP at system PM
      resume, unconditionally if it's being used or not. This may lead to that
      genpd's internal status of the power state, may not correctly reflect the
      power state of the HW after a system PM resume.
      
      Because of changing the behaviour of genpd, by runtime resuming devices in
      the prepare phase, the AMD ACP drm driver no longer have to deal with this
      corner case. So let's just drop the related code in this driver.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: NKevin Hilman <khilman@baylibre.com>
      Acked-by: NMaruthi Bayyavarapu <maruthi.bayyavarapu@amd.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      39dd0f23
  21. 22 4月, 2016 1 次提交