From patchwork Wed Jun 7 12:46:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270746 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 448D2C7EE23 for ; Wed, 7 Jun 2023 14:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=us4WRv3we2mz17H8sMzDngCQyDbkH139xgLmeqBpACY=; b=CFkwHNhLTdUW+z rFHE8CgTKSugHAmLjI4DfPz38cCCp5TxscO52CYThtqVjE6U57fLA4Rnle9WTl6WSSLCKGCJO+swB aPIZDSwPm6HEw/WsjNHClFAD6Q6opcJFfNV+8nPgFViCXNxzIjMDNXKyITwUCFBSllUJVe2AlSyVO ApvGNA+5/Ixndl8DEKCPw1HrYOBQZHUokDgH3wzZuQfk8ioiR2AVgTpLh6HprjBHnioLjHlsUPYon eTfzI5yC0EYcssYA81pE9Zdn6d1TM+ovd9x7QGTJyb4Wnf6SOnDBVQJBwj0XDtw6gwG8R55r7/cB3 wUIxa6bgtgptBt/GbvDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tiR-006BBK-0u; Wed, 07 Jun 2023 14:00:47 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZI-005x7R-31 for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:18 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4f63006b4e3so3115120e87.1 for ; Wed, 07 Jun 2023 05:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142035; x=1688734035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U/Lsn91+ee3WkHkcIZxtEhxNatDc00drhhG6bof7lRA=; b=b88t5sq2oobU4xV66g5hQD7/yWbCE3+/kZV4AVkDBxs8BYhtS9SqZhGew6mJ39ScmZ UEfzMVzg2eOs1nm15ycXtIaTxTFCobvHCGqqfYBt2eG++tYgP+wLqJX3ezEz0PWwIiWe caJn4bnpQ3OwmXG6VPSkzTc/iRiFb0n81Fc776q3XBsmgKKLAeHTL56rx7AvAADaghDj AceOHOFeHGf0Mxpl/Uix5o+8bRPHlo5UIbYGSDzX7beL6EYaYpN59GNhyXh8ufhee7k+ sib9eQ2X0qXGziJIPmZlKGWKLpgeyL8BCSfqll2ToTGoQVs4NQOizC9HE5pUB4d38bWj CDxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142035; x=1688734035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U/Lsn91+ee3WkHkcIZxtEhxNatDc00drhhG6bof7lRA=; b=LvFDIRxWstF3swsGE+b3+sObKmX5csJRE7j1X6Ir0K91p7zdKfZzqNeg3teq8w0arg h9IJQxg1uB7hWNS3eQy6cgDTaclPDhOkCY8KXLew5i8zRV0S8l006bgHS9Xis80yN3k9 VS+dpSZKnRj9bwlge30cZq2RsPu4pp3tH9pxdZp+Az3fCmWPUISCibqHzWaoPTrTS79+ Z1ToeChN7GWUK2A/6SJbFN29brmhTfP4PhSK9baMMT2KkfKD3EI84671uc1BNQO6f/x8 sCSD0+1Pv+SUVRlwM8lLsxu2CjhEZ9ijwW56OQ8q+0+Aou5p+7+KqhvVx7fgz+ae7jgB tZqw== X-Gm-Message-State: AC+VfDyfSyKmdhhEnoZV164swSx/rkZ/ovhh37bGKTru4lDMHp/YeRxI 7ttKKPlikdV/jSLpJwtdYlnkxA== X-Google-Smtp-Source: ACHHUZ4PSgErdZ8NJTs0chVMfI9TMPT7A9df2ZIGBR9gdsMW36zPyxZu26pNz17IAR/DKjBDG06eBg== X-Received: by 2002:ac2:4a7c:0:b0:4f3:a99f:1ea7 with SMTP id q28-20020ac24a7c000000b004f3a99f1ea7mr1887107lfp.55.1686142035009; Wed, 07 Jun 2023 05:47:15 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:14 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/16] firmware: arm_scmi: Extend perf support with OPP from genpd providers Date: Wed, 7 Jun 2023 14:46:27 +0200 Message-Id: <20230607124628.157465-16-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054716_976494_E930E615 X-CRM114-Status: GOOD ( 14.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To enable a genpd provider to add OPPs for its attached devices, let's convert into using the dev_pm_opp_add_dynamic() API, in favor of the current dev_pm_opp_add() API. This allows us to specify the frequency, the performance level and the OPP provider type for each OPP that it may be adding. Moreover, to let callers of the ->device_opps_add() ops, to specify the OPP provider let's add a new in-parameter to it. Signed-off-by: Ulf Hansson --- drivers/cpufreq/scmi-cpufreq.c | 2 +- drivers/firmware/arm_scmi/perf.c | 15 ++++++++++----- include/linux/scmi_protocol.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index 78f53e388094..a3f89a4ca899 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -188,7 +188,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) */ nr_opp = dev_pm_opp_get_opp_count(cpu_dev); if (nr_opp <= 0) { - ret = perf_ops->device_opps_add(ph, cpu_dev, domain); + ret = perf_ops->device_opps_add(ph, cpu_dev, domain, false); if (ret) { dev_warn(cpu_dev, "failed to add opps to the device\n"); goto out_free_cpumask; diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 03a496ccc603..b6cebe45fbc8 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -581,21 +581,26 @@ static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph, } static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, - struct device *dev, u32 domain) + struct device *dev, u32 domain, bool genpd) { int idx, ret; - unsigned long freq; + struct dev_pm_opp_data opp_data; struct perf_dom_info *dom; struct scmi_perf_info *pi = ph->get_priv(ph); dom = pi->dom_info + domain; for (idx = 0; idx < dom->opp_count; idx++) { - freq = dom->opp[idx].perf * dom->mult_factor; + memset(&opp_data, 0, sizeof(opp_data)); + opp_data.level = dom->opp[idx].perf; + opp_data.freq = dom->opp[idx].perf * dom->mult_factor; + opp_data.provider = genpd ? DEV_PM_OPP_TYPE_GENPD : + DEV_PM_OPP_TYPE_NONE; - ret = dev_pm_opp_add(dev, freq, 0); + ret = dev_pm_opp_add_dynamic(dev, &opp_data); if (ret) { - dev_warn(dev, "failed to add opp %luHz\n", freq); + dev_warn(dev, "failed to add opp %luHz\n", + opp_data.freq); dev_pm_opp_remove_all_dynamic(dev); return ret; } diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 21aea1b2a355..ec421107f94c 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -136,7 +136,7 @@ struct scmi_perf_proto_ops { int (*transition_latency_get)(const struct scmi_protocol_handle *ph, u32 domain); int (*device_opps_add)(const struct scmi_protocol_handle *ph, - struct device *dev, u32 domain); + struct device *dev, u32 domain, bool genpd); int (*freq_set)(const struct scmi_protocol_handle *ph, u32 domain, unsigned long rate, bool poll); int (*freq_get)(const struct scmi_protocol_handle *ph, u32 domain,