Skip to content

Commit

Permalink
Merge tag 'pm-5.14-rc8' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
 "These fix two issues introduced during this cycle, one of which is a
  regression and the other one affects new code.

  Specifics:

   - Prevent the operating performance points (OPP) code from crashing
     when some entries in the table of required OPPs are set to error
     pointer values (Marijn Suijten)

   - Prevent the generic power domains (genpd) framework from
     incorrectly overriding the performance state of a device set by its
     driver while it is runtime-suspended or when runtime PM of it is
     disabled (Dmitry Osipenko)"

* tag 'pm-5.14-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  PM: domains: Improve runtime PM performance state handling
  opp: core: Check for pending links before reading required_opp pointers
  • Loading branch information
Linus Torvalds committed Aug 27, 2021
2 parents 425bec0 + 7ee5fd1 commit c0006dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ static void genpd_restore_performance_state(struct device *dev,
int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
{
struct generic_pm_domain *genpd;
int ret;
int ret = 0;

genpd = dev_to_genpd_safe(dev);
if (!genpd)
Expand All @@ -446,7 +446,13 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
return -EINVAL;

genpd_lock(genpd);
ret = genpd_set_performance_state(dev, state);
if (pm_runtime_suspended(dev)) {
dev_gpd_data(dev)->rpm_pstate = state;
} else {
ret = genpd_set_performance_state(dev, state);
if (!ret)
dev_gpd_data(dev)->rpm_pstate = 0;
}
genpd_unlock(genpd);

return ret;
Expand Down
8 changes: 4 additions & 4 deletions drivers/opp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,10 @@ static int _set_required_opps(struct device *dev,
if (!required_opp_tables)
return 0;

/* required-opps not fully initialized yet */
if (lazy_linking_pending(opp_table))
return -EBUSY;

/*
* We only support genpd's OPPs in the "required-opps" for now, as we
* don't know much about other use cases. Error out if the required OPP
Expand All @@ -903,10 +907,6 @@ static int _set_required_opps(struct device *dev,
return -ENOENT;
}

/* required-opps not fully initialized yet */
if (lazy_linking_pending(opp_table))
return -EBUSY;

/* Single genpd case */
if (!genpd_virt_devs)
return _set_required_opp(dev, dev, opp, 0);
Expand Down

0 comments on commit c0006dc

Please sign in to comment.