From patchwork Tue Oct 5 03:37:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 515229 Delivered-To: patch@linaro.org Received: by 2002:ac0:890a:0:0:0:0:0 with SMTP id 10csp1693486imy; Mon, 4 Oct 2021 20:35:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1GzbWUd+9OO0TaHHRru8XJUMJ8jzHGRQhBhB4yzAYob/gigOTnGv404ctooUDcRj7SsWj X-Received: by 2002:a17:903:1103:b0:12c:59b:dc44 with SMTP id n3-20020a170903110300b0012c059bdc44mr3083193plh.47.1633404959183; Mon, 04 Oct 2021 20:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633404959; cv=none; d=google.com; s=arc-20160816; b=rvaMwo0vc13xdF5Zo7JFpkN2gKXxWUd0TzxRbOqOpkeLBdGofNA6kp70K+Hsru0XWG JEIZKkEuMWWm2uu4J/tsIhMjaqiy46mYNChozwRL3y9UF4KoBbUiFgHZI5eQ7HB7c9RL rIfzQD27Y7fwpCBSyjy2p/qQBy807tr1rMCGUZ8W7l3epnSHERJIh8y1lPaNfZfpag8v 84WHFRASkolilAjhF5KpCfbdrxEhSehYOLnl0pgVjAzv1/is2qD7JLqJyq17kejA8GsC JfHJ7j37gomzbBAzgCIGkzBg5QuQc4rLwPwhtGKSfrfeLrtpuk1amNlYFxYMAKBJmTwa a/aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=n1sIofEKORsTR+BKeozYVhAx4/whk5x8HA7cir8+0Rs=; b=nr1Ec8vsd5A8jq1JHA5eHulx13ojI0VFenlh7ZU/wa0m3hHHtf92z6ejdLBMdSk+PL BrrhTSN76WkH0+3/XcEuavrxguhqLFvTt9uFBURGE7hQqmmHufazMWDYV+o5U2bAiWb3 qw0rd2YLeLRBDtEs3xw5/U93RerVRrItFMc5c83Ru6/m4KS63KOv3jyQYGYv5HMhMJRn olIUPUm6DNx4rkABZJOQZbv7Ko2S5HkCOQ6ydHjak94mGrZDaBNCSADbcpV/4AOGwdll f07ccDTwtnhY3GafKJSlxleitIRJC8QzgZ+qP078W0QmDimR/PVr797+nzylVgfTIgC8 hQVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bqdhqIyb; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d18si19769376pgg.359.2021.10.04.20.35.58; Mon, 04 Oct 2021 20:35:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bqdhqIyb; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230526AbhJEDhq (ORCPT + 17 others); Mon, 4 Oct 2021 23:37:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbhJEDhl (ORCPT ); Mon, 4 Oct 2021 23:37:41 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D0C5C061749 for ; Mon, 4 Oct 2021 20:35:51 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id c6-20020a9d2786000000b005471981d559so24193230otb.5 for ; Mon, 04 Oct 2021 20:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n1sIofEKORsTR+BKeozYVhAx4/whk5x8HA7cir8+0Rs=; b=bqdhqIyb/rrIB3tr4O1+Y5bzOlc/VapTa2T6YM2GSnffpAN6gA5SSi2TG/O83hmClo 482YwpGqNQTJRjUXkEVyCxzeJ/wOKJBNQOCMYEmkefYIypNd7pxu9qyioG/AnIUcy91Y L39eL4FFDO/UZZIP2uL+bLHXDi6Vc0dSghkqO1XCwqJxO7aWShNx7YrjIHfgt+gDnruj 8LLfyLn6Q6vRCuZhEU1mc6F6hjcy1E/ZJQbUF7FLzvae5ISUF7Eoz1F8Uv4osvGOMZFv WdVYuPYZIpNTXsDSejLgSKy5OUd9/RPD1zS73rw6yxh0jU7dbhrPumnMFjDvsNKFXpoH nreA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n1sIofEKORsTR+BKeozYVhAx4/whk5x8HA7cir8+0Rs=; b=r3V1RnKxKivahqe5BoD8TQ3KKnwwW27CX3T5d1jH1K4iZPnCSHioxusA9kFGb1hXXR eCQYCqdxr9iO+5fCj5Yqvhl0s0/JmH+5uvm+kPhILEkHD7hO4rFsx/qVIs7MybJYn5GO aYCyxOxRDH3HC0YqSNNfJCfJcrWeP+kyRrI9E8Jx0PK8o6ZWTfOPJR85/ydDmo8GTrBd OFlWOOP4AHphwkfTbOvzVQwQAldeHa4RpifsFCQ2EXzRdY1xcXel2m6ul+C4NAQb6lsM EPDf6VC4hQgM6fCcjinc8FirTbFB+y7h5kGezC3Bohi64yt78uVyXc7S69TZJcGJ/QaX NnxA== X-Gm-Message-State: AOAM533O/tXEnk3fNwx6MfFCfT+fYaGahY7KR7xLP3QEASLjKbZJhYYI V9NZ6qBBToxIxMxJvaXYwDyhrw== X-Received: by 2002:a05:6830:128d:: with SMTP id z13mr12717938otp.19.1633404950695; Mon, 04 Oct 2021 20:35:50 -0700 (PDT) Received: from localhost.localdomain ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id e16sm3075101oie.17.2021.10.04.20.35.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 20:35:50 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Ulf Hansson , Stephen Boyd , Rajendra Nayak Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] soc: qcom: rpmhpd: Make power_on actually enable the domain Date: Mon, 4 Oct 2021 20:37:32 -0700 Message-Id: <20211005033732.2284447-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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: 279b7e8a62cc ("soc: qcom: rpmhpd: Add RPMh power domain driver") Signed-off-by: Bjorn Andersson --- Changes since v2: - Fixed two spelling mistakes in the commit message - Changed the last hunk to search for first non-zero level, rather than the first non-zero index (i.e. 1) drivers/soc/qcom/rpmhpd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) -- 2.29.2 diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c index e280a8194725..0ca77ed22c6c 100644 --- a/drivers/soc/qcom/rpmhpd.c +++ b/drivers/soc/qcom/rpmhpd.c @@ -30,6 +30,7 @@ * @active_only: True if it represents an Active only peer * @corner: current corner * @active_corner: current active corner + * @enable_corner: lowest non-zero corner * @level: An array of level (vlvl) to corner (hlvl) mappings * derived from cmd-db * @level_count: Number of levels supported by the power domain. max @@ -47,6 +48,7 @@ struct rpmhpd { const bool active_only; unsigned int corner; unsigned int active_corner; + unsigned int enable_corner; u32 level[RPMH_ARC_MAX_LEVELS]; size_t level_count; bool enabled; @@ -401,13 +403,13 @@ static int rpmhpd_aggregate_corner(struct rpmhpd *pd, unsigned int corner) static int rpmhpd_power_on(struct generic_pm_domain *domain) { struct rpmhpd *pd = domain_to_rpmhpd(domain); - int ret = 0; + unsigned int corner; + int ret; mutex_lock(&rpmhpd_lock); - if (pd->corner) - ret = rpmhpd_aggregate_corner(pd, pd->corner); - + corner = max(pd->corner, pd->enable_corner); + ret = rpmhpd_aggregate_corner(pd, corner); if (!ret) pd->enabled = true; @@ -452,6 +454,10 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain, i--; if (pd->enabled) { + /* Ensure that the domain isn't turn off */ + if (i < pd->enable_corner) + i = pd->enable_corner; + ret = rpmhpd_aggregate_corner(pd, i); if (ret) goto out; @@ -488,6 +494,10 @@ static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd) for (i = 0; i < rpmhpd->level_count; i++) { rpmhpd->level[i] = buf[i]; + /* Remember the first corner with non-zero level */ + if (!rpmhpd->level[rpmhpd->enable_corner] && rpmhpd->level[i]) + rpmhpd->enable_corner = i; + /* * The AUX data may be zero padded. These 0 valued entries at * the end of the map must be ignored.