From patchwork Sat Jul 3 00:54:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 469868 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1882311jao; Fri, 2 Jul 2021 17:55:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx37gpxu1tRJtZFWBADHLrNxP7J5kCZILmPXjdCe5rRnepIy20kenddQY0pJ32rGbUh2BYU X-Received: by 2002:a17:907:3ea5:: with SMTP id hs37mr2406396ejc.473.1625273747306; Fri, 02 Jul 2021 17:55:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625273747; cv=none; d=google.com; s=arc-20160816; b=z1wh7WEZzjn1O/onCz+Ls93NNWVNLw4rPlAf/+LEBuVKkA6xfoMPlJGk7d98DiEj7S bput1lbLxQdj6leBa8jv6Ex6P727mJ5MtYYNJuXN1z6bhIf/5I4dMSRITXCI7l0vb5yw +OZOFMwJvIVLpAGQpONWL8nIu7fNVzRxktHpZz1owROHdwy2kYDl/1q/uO9w+DyDyE8t cT4tC8xC7wL154zBXR3h9hD2uOFXGmGOpfbvsSRNAzom3zu+ZjpeCe4Bn42pd2PzjR1e 2PyxypB00ebIwNnV+sQ1/wwo/2/5IsHeTce/lcS7qJb3ydmyRejHt5dom0IS+VVdE6vt sMBQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GIcS8obOc85rCVwddJOC5Q1ZEP41KlN6e1ByEjBZDh4=; b=BfICKDPvv6sL5Zc4TX+q41LIBj8UUeeKQbZENH/KILahFFtPN1UvmdJm7X/YGqISun utoCu7w+0mkZnSn5GRnBwBhwWxck3xpwoAYzrQGvulDQZgAOC4dYCi5ME2jcNfAz00kn 2YxRnZEmI+B+IJbHPV4MZwTjHdvptdVBGJv6RLWgVt+6dn2YRQRhYxQXoZyDZ7bSps72 olTtO+jFhs0qTZxzeuyAjV75GS+CXt8AM2dYgd81cyf3L1C2vt5TKtcUY4zp3RB376Cs uCFGPxx1PEi83ulAhW2fR2MpsLQfuSbxv6z0qAgMUz+A91NDylEZXd2kDvzTfa30RVlj E0oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cz5eKLT3; 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 c16si4841278edw.522.2021.07.02.17.55.47; Fri, 02 Jul 2021 17:55:47 -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=cz5eKLT3; 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 S230118AbhGCA6L (ORCPT + 17 others); Fri, 2 Jul 2021 20:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbhGCA6K (ORCPT ); Fri, 2 Jul 2021 20:58:10 -0400 Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA309C061764 for ; Fri, 2 Jul 2021 17:55:36 -0700 (PDT) Received: by mail-oo1-xc30.google.com with SMTP id e1-20020a0568200601b029024ea261f0ccso2673171oow.2 for ; Fri, 02 Jul 2021 17:55:36 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=GIcS8obOc85rCVwddJOC5Q1ZEP41KlN6e1ByEjBZDh4=; b=cz5eKLT3Mfrcuw1d0gVATA1CPxF1lmHeSbzucy21fRc7wAiMSeA5aKFpxzC1DscteG 7wwpeQ/QlyjZWtlJXwJs8hVrKESzg3wcNMHubg7U8FXTsjDxWpkMze0d+ZwD9w4KGpd5 6kQ/QbNLv7IRCihTxzIrWqS+2XHToTvZPYOGjifwjwUBoTQDonkjtzD9XMpSUZC06s/R CQwVgum+qDGNqm1qbPoIAy4pth+iXmmy2H+Zfv4YtqKfdm26lC5vjHrvzeOIiBhH3SPx +GUnbzr1bMSbArumnNjSCJI2SVg+uW7BsyDXJRpfSv3pcKlgGwFYS5aCciEhCoYfubK9 Gmiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GIcS8obOc85rCVwddJOC5Q1ZEP41KlN6e1ByEjBZDh4=; b=ZiZdgh7RdcPwWn589jT0UupArCYtFCP81YNcbcDCeAbZMIKwionJdgkKZo8eFKDdFj yHq2aYcxp1Sujnv7DUwkGw2jL/rVvMpbXWTl6ZRhPXIq7ick4UZmJDVrDYwtMIPkSzbJ Aw+OpoiLqYqNiIyWcPlZHyhCJyDtezqYi8ah5y4rOgcdNvB+rbisIZBHcflN2jfN0WpV IFAOIm41lAMGXmtkK3t42F0dlQ3i22HA2E4YJnMisVksYXiyOaNTeTDhOWyMToW5XNjw jJM5DS/c4YgcD2G1+4v3XYWn39YgKE23vI/lXMQJCAx4worXTg6JsEijS+dHgsvLEglZ +JqA== X-Gm-Message-State: AOAM532gMM0OsR6PhZICIFPzJ1HJaKid4ZyI7P7SVO95zOX4hrWaoT// pwAjTgJAhYepFg6SW2+zdaJgNA== X-Received: by 2002:a4a:5e81:: with SMTP id h123mr1859650oob.11.1625273735844; Fri, 02 Jul 2021 17:55:35 -0700 (PDT) Received: from localhost.localdomain (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id o6sm1057170oib.3.2021.07.02.17.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 17:55:35 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Ulf Hansson , Stephen Boyd , Rajendra Nayak , Dmitry Baryshkov Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] soc: qcom: rpmhpd: Use corner in power_off Date: Fri, 2 Jul 2021 17:54:15 -0700 Message-Id: <20210703005416.2668319-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210703005416.2668319-1-bjorn.andersson@linaro.org> References: <20210703005416.2668319-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org rpmhpd_aggregate_corner() takes a corner as parameter, but in rpmhpd_power_off() the code requests the level of the first corner instead. In all (known) current cases the first corner has level 0, so this change should be a nop, but in case that there's a power domain with a non-zero lowest level this makes sure that rpmhpd_power_off() actually requests the lowest level - which is the closest to "power off" we can get. While touching the code, also skip the unnecessary zero-initialization of "ret". Fixes: 279b7e8a62cc ("soc: qcom: rpmhpd: Add RPMh power domain driver") Signed-off-by: Bjorn Andersson --- drivers/soc/qcom/rpmhpd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.29.2 Reviewed-by: Rajendra Nayak Reviewed-by: Stephen Boyd Reviewed-by: Sibi Sankar Tested-by: Sibi Sankar diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c index 2daa17ba54a3..fa209b479ab3 100644 --- a/drivers/soc/qcom/rpmhpd.c +++ b/drivers/soc/qcom/rpmhpd.c @@ -403,12 +403,11 @@ static int rpmhpd_power_on(struct generic_pm_domain *domain) static int rpmhpd_power_off(struct generic_pm_domain *domain) { struct rpmhpd *pd = domain_to_rpmhpd(domain); - int ret = 0; + int ret; mutex_lock(&rpmhpd_lock); - ret = rpmhpd_aggregate_corner(pd, pd->level[0]); - + ret = rpmhpd_aggregate_corner(pd, 0); if (!ret) pd->enabled = false; From patchwork Sat Jul 3 00:54:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 469867 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1882306jao; Fri, 2 Jul 2021 17:55:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcsSHora1VE7rdGoyyoi1KuHto4vaKRdVDy//VQvS33AxZt7g6/et70L5e1DOm8M+F/DnG X-Received: by 2002:a17:907:868d:: with SMTP id qa13mr2468784ejc.173.1625273746849; Fri, 02 Jul 2021 17:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625273746; cv=none; d=google.com; s=arc-20160816; b=0lcEbL9Riob7B7xcZubvmfhlhPRJIfWDcv37+YAZzRQmUpoLqPfLBIxUKIc7rVA/Ym NSMyqT3HYc/YlB3YwZh/89lQy4t49ABKXeHFKDp9LPPdbvBix+vt3N6L3Zwkh+0TXJ5u n/TMAcFO4HJQD3JaUB7mcPXaeDqrI++fHk6LBUqzpczMBCkLcym2TX+zgv8HvfCTuG27 Ugc5O9XJ0D3GS6Sb5TkkfGv6pTAzcoIMAAJjTYGpjJibkfRffJ2TBVa3fOmQDcnBcNXk 4e/up2v4iAA6tttL9RxDKdgD/cybaS+/Lwhkwpy8rfiAXMiNoC1M0klY2jB5A1Vvnsay qVtA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YCuLYJ5O0b8LBoAKT9/3WK6Ifs6SJmLEad6FyRxEfNk=; b=vpeQgXPI283//B/7gc0THYPY+6lWGAsJGvRgSN32PhdDh5HYC1MQOzP8wR4UxV+8YB GIqGypMTZpojjMRsVyopP3DTlx/6n1KDCKyifv76IhAXi4EWMumH4rWrtKL13bFJkmKa jBtCrRNWH33B+GQFCrFDm/qk9AFgJWA/8VhsLs3XFOr50diYxDNaur4Om6h8eXeNLyAK mr3BVovEdp+KxnU5SA++qfYoHACuFlhWXlsq8+3ORTwjlA5/OX55EQu6dc/8NlcfjFCm Fww6YCuwOoJr9aEPl3JnslMWGEUyyI0wourQo3STyQNVbA6Q5QqonTPyVuJg7hzOxnSE 1Jwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BCHDgJOZ; 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 c16si4841278edw.522.2021.07.02.17.55.46; Fri, 02 Jul 2021 17:55:46 -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=BCHDgJOZ; 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 S230127AbhGCA6L (ORCPT + 17 others); Fri, 2 Jul 2021 20:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbhGCA6L (ORCPT ); Fri, 2 Jul 2021 20:58:11 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29482C061765 for ; Fri, 2 Jul 2021 17:55:38 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id r4-20020a0568301204b029047d1030ef5cso4951542otp.12 for ; Fri, 02 Jul 2021 17:55:38 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=YCuLYJ5O0b8LBoAKT9/3WK6Ifs6SJmLEad6FyRxEfNk=; b=BCHDgJOZWoDZ1eJhju4Z3/1I4vL+iVH2EfJbus2ZBbVu+Q8zSdQDpeBvIWV8bw7M4O R5g82z+ftlIV2p4WSfd3kZlD7JCR2ajSkzdG/qjx74efWiwFywsTX/L0EgSGWqghrDZe hMB0vBZVrluFKVTly9hk7h8OQ+NAoCgR/F5FdzdQl/TIMwGCSwdGiOCXmFIqhB2SDX5d c+Ghs5j5apHbMOvvID+hozXCDObLXVZn+ULPT4MFbXUJBN4kuE4SDBgHe1Oujau8qI9I 5IXsFDNvL8fu4Ven6tQSFt639OMxkcCMtWcoh4xuBIzhAOaUIz3I8QuS8ZygH6AXQSbU 4H0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YCuLYJ5O0b8LBoAKT9/3WK6Ifs6SJmLEad6FyRxEfNk=; b=ELkzg1aWWdtCAHMNw05FSiJ4YtbZujxaBTU8sYuyJFCmJYNvuerb+WL0vUJwyAfl/O 75ExEoodnxDUTpgxvwIZlR1bdSxuMnkvijpB9qeGU8GFaG7PNpbhV5hCLgHXimYn3CDx 4V6pajNcJ/uhDWcqs85pKEIzFzsNJrJcSG2XjywAWkpOcKYaJOzWhQbvOgq56OIjG27L Xp/zxoW2PA/pX8W+7yoaGpdxGPnS3Wr/4MnMd1PZojZKw3OICYpDHT51jTnrUDzacJDD WvmQgxFcBu3/R19ckpyKm3vKHuRiER4o75mC6lskWoa97fepdYAjIrMpwk7Qg8RtvZn9 oKRA== X-Gm-Message-State: AOAM531bzIMm/s8nhG4JH6Ji8Zm1W9UzRPeqtrn2Nl/h4iZNIuDa0heU A6k2h3AyELmCxo8vWDBcs17JUA== X-Received: by 2002:a9d:5d11:: with SMTP id b17mr1651104oti.216.1625273736714; Fri, 02 Jul 2021 17:55:36 -0700 (PDT) Received: from localhost.localdomain (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id o6sm1057170oib.3.2021.07.02.17.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 17:55:36 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Ulf Hansson , Stephen Boyd , Rajendra Nayak , Dmitry Baryshkov Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] soc: qcom: rpmhpd: Make power_on actually enable the domain Date: Fri, 2 Jul 2021 17:54:16 -0700 Message-Id: <20210703005416.2668319-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210703005416.2668319-1-bjorn.andersson@linaro.org> References: <20210703005416.2668319-1-bjorn.andersson@linaro.org> 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 performace 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 turn 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 --- drivers/soc/qcom/rpmhpd.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.29.2 diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c index fa209b479ab3..29a339942301 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; @@ -385,13 +387,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; @@ -472,6 +474,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 non-zero corner */ + if (!rpmhpd->enable_corner) + rpmhpd->enable_corner = i; + /* * The AUX data may be zero padded. These 0 valued entries at * the end of the map must be ignored.