From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A3EFEB64DA for ; Mon, 26 Jun 2023 13:44:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229768AbjFZNoo (ORCPT ); Mon, 26 Jun 2023 09:44:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbjFZNon (ORCPT ); Mon, 26 Jun 2023 09:44:43 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65257E72 for ; Mon, 26 Jun 2023 06:44:42 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4f8689fbf59so5411071e87.0 for ; Mon, 26 Jun 2023 06:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687787080; x=1690379080; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Z182+Q4uKJie6Rxr4pwKFm/7JzYn7OU/lRN6E75YsLU=; b=eXQV8HOG8X7LkEP0FGaLvSgKFbx5frQztyredVZnH3azpB0e/MWxX/OvIesjczaWTD sbyN1HTNgbA98LWHmikLcIJuJ88TSUAAGZns00Lo4oboSKnvQQoFooYapW04pDeIipeB xl8pyVivBRsCC1akqSDBp76Ut37ukgIFoDPVWTe8WSQuf6VGvXZNyraZGv5uodCCnahk C9Lb/dkyYimWqVtCR3aKir/5u/0FJQkKygo9pXK4/CrE3jLXKfXPsP6oK9UuqfLGzzgJ Em2yzd089u1gW8F1VvTEH1xwgUJI7nf4nlFAIAHqzjkvbGoqu8dmpR9y8H7jKRzVcpwI aWDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687787080; x=1690379080; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Z182+Q4uKJie6Rxr4pwKFm/7JzYn7OU/lRN6E75YsLU=; b=BS8A6WWibN0Aon2jl0lVUmZ1iDWKbFZAzMx501gIBskNffVt+AG1vXRh7oiNOwH06e fw4YDJHkR4PQCgEexCe37SA51AIn+LkFzYvnBau7riqvtVRnmNUI5WJUYSnKsSZK+QbG 82MQpuRMDBPMjIMqkFz/o5jFSo8wXov9EiVYGP0goXcEOCYbCzx3Du/1cy6hOFGb3HV6 rxHFCkuH58xY8N9DpufSNSpw7YTrMe0sUGjfpQROIkSSg6LCbKt8wFst11YK+DhUPR2D DKA3ZtayxYZpEZ0eM2DQRJOvijDSB/wiUSKXpsfra7SL0k5QBgyw7HZDWNQMTlOGEIV8 B9qA== X-Gm-Message-State: AC+VfDzZn8S0x48pSeqmSXbIiSE4QER3Ag6E44PnB96eCeeSJM1vOzWW yGT4vhru10RGqxgbEYQP7SXTq+GSw7xf0OxPipQ= X-Google-Smtp-Source: ACHHUZ4tMRepmhfl1tjS3N4io66eAdL2IcMharuAdzXvUqx4OEu4BAmMjhy8W1VXaGhJtB56aq84oA== X-Received: by 2002:a05:6512:33c7:b0:4f8:4b19:9533 with SMTP id d7-20020a05651233c700b004f84b199533mr9837735lfg.19.1687787080554; Mon, 26 Jun 2023 06:44:40 -0700 (PDT) Received: from ?IPV6:2001:14ba:a0db:1f00::8a5? (dzdqv0yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a0db:1f00::8a5]) by smtp.gmail.com with ESMTPSA id d30-20020ac25ede000000b004f252003071sm1126500lfq.37.2023.06.26.06.44.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Jun 2023 06:44:39 -0700 (PDT) Message-ID: Date: Mon, 26 Jun 2023 16:44:39 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v2 06/26] interconnect: icc-clk: add support for scaling using OPP Content-Language: en-GB To: Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andy Gross , Bjorn Andersson , Ilia Lin , Viresh Kumar , Nishanth Menon , Stephen Boyd , Michael Turquette , "Rafael J. Wysocki" , Georgi Djakov Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, Christian Marangi , Stephan Gerhold References: <20230625202547.174647-1-dmitry.baryshkov@linaro.org> <20230625202547.174647-7-dmitry.baryshkov@linaro.org> From: Dmitry Baryshkov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org On 26/06/2023 14:28, Konrad Dybcio wrote: > On 25.06.2023 22:25, Dmitry Baryshkov wrote: >> Sometimes it might be required to scale the clock using the OPP >> framework (e.g. to scale regulators following the required clock rate). >> Extend the interconnec > 't' > >> -clk framework to handle OPP case in addition to >> scaling the clock. >> >> Signed-off-by: Dmitry Baryshkov >> --- > I think we should check for OPP at the icc-clk registration time, > instead of passing it as a parameter, e.g.: > > qn.opp = IS_ERR(dev_pm_opp_get_opp_count) > > Not sure if there's a more idiomatic way. No. icc-clk is not limited to a single clock->icc conversion. So it is possible to create several interconnect links, only one of which should be the OPP-based one. > > Konrad >> drivers/interconnect/icc-clk.c | 13 +++++++++++-- >> include/linux/interconnect-clk.h | 1 + >> 2 files changed, 12 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/interconnect/icc-clk.c b/drivers/interconnect/icc-clk.c >> index 4d43ebff4257..c7962acdcee7 100644 >> --- a/drivers/interconnect/icc-clk.c >> +++ b/drivers/interconnect/icc-clk.c >> @@ -7,10 +7,13 @@ >> #include >> #include >> #include >> +#include >> >> struct icc_clk_node { >> + struct device *dev; >> struct clk *clk; >> bool enabled; >> + bool opp; >> }; >> >> struct icc_clk_provider { >> @@ -25,12 +28,16 @@ struct icc_clk_provider { >> static int icc_clk_set(struct icc_node *src, struct icc_node *dst) >> { >> struct icc_clk_node *qn = src->data; >> + unsigned long rate = icc_units_to_bps(src->peak_bw); >> int ret; >> >> if (!qn || !qn->clk) >> return 0; >> >> - if (!src->peak_bw) { >> + if (qn->opp) >> + return dev_pm_opp_set_rate(qn->dev, rate); >> + >> + if (!rate) { >> if (qn->enabled) >> clk_disable_unprepare(qn->clk); >> qn->enabled = false; >> @@ -45,7 +52,7 @@ static int icc_clk_set(struct icc_node *src, struct icc_node *dst) >> qn->enabled = true; >> } >> >> - return clk_set_rate(qn->clk, icc_units_to_bps(src->peak_bw)); >> + return clk_set_rate(qn->clk, rate); >> } >> >> static int icc_clk_get_bw(struct icc_node *node, u32 *avg, u32 *peak) >> @@ -106,7 +113,9 @@ struct icc_provider *icc_clk_register(struct device *dev, >> icc_provider_init(provider); >> >> for (i = 0, j = 0; i < num_clocks; i++) { >> + qp->clocks[i].dev = dev; >> qp->clocks[i].clk = data[i].clk; >> + qp->clocks[i].opp = data[i].opp; >> >> node = icc_node_create(first_id + j); >> if (IS_ERR(node)) { >> diff --git a/include/linux/interconnect-clk.h b/include/linux/interconnect-clk.h >> index 0cd80112bea5..c695e5099901 100644 >> --- a/include/linux/interconnect-clk.h >> +++ b/include/linux/interconnect-clk.h >> @@ -11,6 +11,7 @@ struct device; >> struct icc_clk_data { >> struct clk *clk; >> const char *name; >> + bool opp; >> }; >> >> struct icc_provider *icc_clk_register(struct device *dev, -- With best wishes Dmitry