Skip to content

Commit 503d6e5

Browse files
anderssongregkh
authored andcommitted
soc: qcom: rpmhpd: Make power_on actually enable the domain
[ Upstream commit e3e56c0 ] The general expectation is that powering on a power-domain should make the power domain deliver some power, and if a specific performance state is needed further requests has to be made. But in contrast with other power-domain implementations (e.g. rpmpd) the RPMh does not have an interface to enable the power, so the driver has to vote for a particular corner (performance level) in rpmh_power_on(). But the corner is never initialized, so a typical request to simply enable the power domain would not actually turn on the hardware. Further more, when no more clients vote for a performance state (i.e. the aggregated vote is 0) the power domain would be turned off. Fix both of these issues by always voting for a corner with non-zero value, when the power domain is enabled. The tracking of the lowest non-zero corner is performed to handle the corner case if there's ever a domain with a non-zero lowest corner, in which case both rpmh_power_on() and rpmh_rpmhpd_set_performance_state() would be allowed to use this lowest corner. Fixes: 279b7e8 ("soc: qcom: rpmhpd: Add RPMh power domain driver") Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20211005033732.2284447-1-bjorn.andersson@linaro.org Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 81e37cf commit 503d6e5

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎drivers/soc/qcom/rpmhpd.c‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
* @active_only: True if it represents an Active only peer
3131
* @corner: current corner
3232
* @active_corner: current active corner
33+
* @enable_corner: lowest non-zero corner
3334
* @level: An array of level (vlvl) to corner (hlvl) mappings
3435
* derived from cmd-db
3536
* @level_count: Number of levels supported by the power domain. max
@@ -47,6 +48,7 @@ struct rpmhpd {
4748
const bool active_only;
4849
unsigned int corner;
4950
unsigned int active_corner;
51+
unsigned int enable_corner;
5052
u32 level[RPMH_ARC_MAX_LEVELS];
5153
size_t level_count;
5254
bool enabled;
@@ -295,13 +297,13 @@ static int rpmhpd_aggregate_corner(struct rpmhpd *pd, unsigned int corner)
295297
static int rpmhpd_power_on(struct generic_pm_domain *domain)
296298
{
297299
struct rpmhpd *pd = domain_to_rpmhpd(domain);
298-
int ret = 0;
300+
unsigned int corner;
301+
int ret;
299302

300303
mutex_lock(&rpmhpd_lock);
301304

302-
if (pd->corner)
303-
ret = rpmhpd_aggregate_corner(pd, pd->corner);
304-
305+
corner = max(pd->corner, pd->enable_corner);
306+
ret = rpmhpd_aggregate_corner(pd, corner);
305307
if (!ret)
306308
pd->enabled = true;
307309

@@ -346,6 +348,10 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain,
346348
i--;
347349

348350
if (pd->enabled) {
351+
/* Ensure that the domain isn't turn off */
352+
if (i < pd->enable_corner)
353+
i = pd->enable_corner;
354+
349355
ret = rpmhpd_aggregate_corner(pd, i);
350356
if (ret)
351357
goto out;
@@ -382,6 +388,10 @@ static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd)
382388
for (i = 0; i < rpmhpd->level_count; i++) {
383389
rpmhpd->level[i] = buf[i];
384390

391+
/* Remember the first corner with non-zero level */
392+
if (!rpmhpd->level[rpmhpd->enable_corner] && rpmhpd->level[i])
393+
rpmhpd->enable_corner = i;
394+
385395
/*
386396
* The AUX data may be zero padded. These 0 valued entries at
387397
* the end of the map must be ignored.

0 commit comments

Comments
 (0)