From patchwork Thu Jan 21 11:17:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035629 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 885AAC433DB for ; Thu, 21 Jan 2021 11:21:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44554238E2 for ; Thu, 21 Jan 2021 11:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729177AbhAULUn (ORCPT ); Thu, 21 Jan 2021 06:20:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726959AbhAULUk (ORCPT ); Thu, 21 Jan 2021 06:20:40 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72923C0613D6 for ; Thu, 21 Jan 2021 03:18:45 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id p18so1137020pgm.11 for ; Thu, 21 Jan 2021 03:18:45 -0800 (PST) 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=DAtjI7/BPs0IoV2iaS54lmWpFTE0HbF0Es/G22rWt3g=; b=ZpmS5LN1rts74B7Ode0O1RTIMsoc8Gi0J/g/qdh4T4B+Pl5+6gDcpGtwEy3pxwaa1n KJMIk8ywsFR4wtEZeD3cynSaQbttOpg++x8NwKSnz5NE2yMDL+xniSZ2kjT0faYRi5pL M+Ww1NxEYcW6YGEkuuNHvtUhb0dRL8IgsIE9SQlSprdhSHMaSGscj1dOZ0pc7bkhMeRY 40VDRsunRhdrZp8VxhHfj0mrnlOz/vOMk0C1DUU9eLTtmhKiclL+GWz1UIm6g+zTmw1Y u2QUTm7Kird1vwS6WBpw7kK7Uo1YQ75ztHo2FgLS8AEfwPTzQ4+ugUeRvnqx9lyoBgi/ jm/Q== 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=DAtjI7/BPs0IoV2iaS54lmWpFTE0HbF0Es/G22rWt3g=; b=ijPQyDlKQjPRtAGZnzgIeTPIuozm6GO4mI2J9X92BkLIDdDdLlzCOaQ6BQWi7cWXzC XNM3ZTqQGBZClAXRtbHLn1e+RLpIp9I9jAdCuBhZxcMUTrJoNJVevwHrRKtc63jDFblX AZ3+5O2Ae+lVVgzePcdtngyTsbw7EkSyLalYupFUioKU0VC1voNQOGwVpGF9V/3WQC4/ DekORWZbNus3CI4Ltw81qQnDzBctCQ3GPaUE0zWOSku5QgGv58iF1OUvsw1h/XQzBdzp rLcQko8dXEAP8G6bQsi/J96VbZJtY/v/439ek1n+0GMtpmWniEY9RV6g6CDeXQPtihCx 0Grw== X-Gm-Message-State: AOAM531zfKpP3XsKZDc9Wl5WHKSftf8HQEX507m5bfbNRHycRqkPEJ60 ECxgRBIy9J65IAoHShmcBu4Arg== X-Google-Smtp-Source: ABdhPJyts296w7aWmAZLnK+2Ns297gN4vfmOwF34Q5MA6SM/rmkzGZINgd1d7pMVUGniT2QI9Kk1mQ== X-Received: by 2002:a05:6a00:a8d:b029:1ba:71d1:fe3c with SMTP id b13-20020a056a000a8db02901ba71d1fe3cmr9122927pfl.51.1611227909301; Thu, 21 Jan 2021 03:18:29 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id u1sm5595280pjr.51.2021.01.21.03.18.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:18:28 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 01/13] opp: Rename _opp_set_rate_zero() Date: Thu, 21 Jan 2021 16:47:41 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This routine has nothing to do with frequency, it just disables all the resources previously enabled. Rename it to match its purpose. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index aea0b9d7203c..9ec8e42981d0 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -943,7 +943,7 @@ int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_set_bw); -static int _opp_set_rate_zero(struct device *dev, struct opp_table *opp_table) +static int _disable_opp_table(struct device *dev, struct opp_table *opp_table) { int ret; @@ -997,7 +997,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) } if (unlikely(!target_freq)) { - ret = _opp_set_rate_zero(dev, opp_table); + ret = _disable_opp_table(dev, opp_table); goto put_opp_table; } From patchwork Thu Jan 21 11:17:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035631 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD1F4C433E6 for ; Thu, 21 Jan 2021 11:21:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6726F238E3 for ; Thu, 21 Jan 2021 11:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729908AbhAULUp (ORCPT ); Thu, 21 Jan 2021 06:20:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728846AbhAULUn (ORCPT ); Thu, 21 Jan 2021 06:20:43 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6184CC061793 for ; Thu, 21 Jan 2021 03:18:48 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id y8so1097787plp.8 for ; Thu, 21 Jan 2021 03:18:48 -0800 (PST) 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=t5BvkMjuaVY08gUJbMK2zLQ+31ycbwXJT/Kur/3Z95w=; b=F1sJbjeFjLx44rMNM9VXJT1VmL0MJFDwx3vGHr2mL8qHmnto11WjN8OD6D0Tyl/3vP yxjF81dLQrtt3ea+reaI7O2lR4kp3WgLQ2E6yT65oolB8vJLDeETZLwZ8AT+H4p8KKFM eVMKCCkc3lJqxoLslpyYIPktsJtfe5IAPrM3JkeG+gRiiPJgp7Ea+eeujptT99yVRHvE 3w0lz9qDfeIR6CqQj7nyk17ZQYSS2gaCG++MImOdhNGYBOSZMr3IFxb3hxWFMP1rpLwi t0cbvWkGBBmFxH5Ts7PPu2urw4C14l638fkduz4HQve/esYKhJsb+KyPYqvVC6MIXtUr 81tQ== 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=t5BvkMjuaVY08gUJbMK2zLQ+31ycbwXJT/Kur/3Z95w=; b=gqbFlJtBRRVDsJ3Oy6LfxIlVwNOGIAzrmS1DnP9sd6iroI8F++tQhKlqh4Z9GaK+zT x3D750cZzfskAQo/YHSKuHAunQ7j78M7R3wiCLCB363myOhSYmRi9eKzjunTHbm1ZR2r 9YpRa+t/WRT8nKubIJTTLW5N81TX0ubxAOF6UCHf9zK8EA8biVkZPD+ZM1+vZ3Ip9yPc 2kTe40podliXwxCfOrJq8TNVoXeYhXfcudzWWRFjcpDJG/EJip3J5LDnurCFr44JkT4p +lunT/3IBl+l57znNk25u7DUUwWJDsso5VqbkBHlkVKdrBFK4kdktkGqGLLmVbEjx8Vn 6Y6A== X-Gm-Message-State: AOAM531YTxTFihx6HSDIm5W6WChbnpmqf8di1g9UvD6JcILPK+kdswEI VtvFHUDuL6yElUnkJieaJ3BUSA== X-Google-Smtp-Source: ABdhPJz7q/I5ANoKOSZSRSNYadjp4zVir7HUG9/UL0WMu7ayW5Oc9Bj7FnQUI7AdPHyZwNvg7ZPdOg== X-Received: by 2002:a17:90a:9eb:: with SMTP id 98mr4799013pjo.40.1611227927908; Thu, 21 Jan 2021 03:18:47 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id d22sm5661965pjv.11.2021.01.21.03.18.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:18:47 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 02/13] opp: No need to check clk for errors Date: Thu, 21 Jan 2021 16:47:42 +0530 Message-Id: <26fe0df01647061cee8278af64a86610d65711f6.1611227342.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Clock is not optional for users who call into dev_pm_opp_set_rate(). Remove the unnecessary checks. While at it also drop the local variable for clk and use opp_table->clk instead. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 9ec8e42981d0..cb5b67ccf5cf 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -987,7 +987,6 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) struct opp_table *opp_table; unsigned long freq, old_freq, temp_freq; struct dev_pm_opp *old_opp, *opp; - struct clk *clk; int ret; opp_table = _find_opp_table(dev); @@ -1001,19 +1000,11 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) goto put_opp_table; } - clk = opp_table->clk; - if (IS_ERR(clk)) { - dev_err(dev, "%s: No clock available for the device\n", - __func__); - ret = PTR_ERR(clk); - goto put_opp_table; - } - - freq = clk_round_rate(clk, target_freq); + freq = clk_round_rate(opp_table->clk, target_freq); if ((long)freq <= 0) freq = target_freq; - old_freq = clk_get_rate(clk); + old_freq = clk_get_rate(opp_table->clk); /* Return early if nothing to do */ if (opp_table->enabled && old_freq == freq) { @@ -1031,7 +1022,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) * equivalent to a clk_set_rate() */ if (!_get_opp_count(opp_table)) { - ret = _generic_set_opp_clk_only(dev, clk, freq); + ret = _generic_set_opp_clk_only(dev, opp_table->clk, freq); goto put_opp_table; } @@ -1071,7 +1062,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) opp->supplies); } else { /* Only frequency scaling */ - ret = _generic_set_opp_clk_only(dev, clk, freq); + ret = _generic_set_opp_clk_only(dev, opp_table->clk, freq); } /* Scaling down? Configure required OPPs after frequency */ From patchwork Thu Jan 21 11:17:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035755 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42597C433E0 for ; Thu, 21 Jan 2021 11:58:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE3002395B for ; Thu, 21 Jan 2021 11:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730032AbhAUL6J (ORCPT ); Thu, 21 Jan 2021 06:58:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726959AbhAULUp (ORCPT ); Thu, 21 Jan 2021 06:20:45 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BF79C061794 for ; Thu, 21 Jan 2021 03:18:52 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id x20so1455715pjh.3 for ; Thu, 21 Jan 2021 03:18:52 -0800 (PST) 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=YF247aIKbCY2/r4PGlk3GxBCCQW3KMMZcpJEZOc5/Q0=; b=q4aQO8etJergPAghmEtuVxVLdykQPpd3HcPHMD6EQfoX4tjuP7MhEF6K18XC4Inuvs RKy9SstcZSdr5meQkznW9PfhKeD+22MQjTjs4PHJH9L58N3mnjyCGPezVaH7gzv1IJhs bT8Lesss5bsMcmN703omHfIN795Q3hMsxgr9GzjVPd43t1fDQ4eATXjN6CiHR+qCOpzC 8WvFnYva6RL0BKdBzgnMwkV+jxxe4VLJOt1F2Jbz//EiJliXk3CRa8qY5cwHxmXPFaho DxRROl7t7RugdR/omHIBFABHDp6JPTYdUWtoOf4Stb2KFicJr+1c4y7rqExGmMRTsAS4 tcaA== 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=YF247aIKbCY2/r4PGlk3GxBCCQW3KMMZcpJEZOc5/Q0=; b=EcSbPH5lSWjlthIekLhiLgQ4GfuCj2vby5ennTLPhwTjcypFyWucLE1pQXOmAr3zcY aA0tDHoU45MUS6LJ/vWW0/oOVDs7r1lY7j91H0d5QtCVnSs8WPAZrpHjiNnl2qq1wKFp nS/NouHt7ceJXmSV5e6efmOZK8CRD1p9vAwsDdAOWI7M5fOyaqM2klOtDL1mVmjgJYyY g4U890r6j6+DGMZC3l2ad7hr47MxK3lQTNC9IXO5WpLvzFatR8YjRVKd1u/wf7S4qf4X eC9bqihA1I2J6A8gc6WTvlpySEPerwN3vlccHjJN1VBMK3Ocb+0G91k5WfZYC9LxMqfL R27w== X-Gm-Message-State: AOAM530Y52AjlsJ1usJ3kH1eydlMF44MZysIpIj9dsfbMnbAo+ABJsvw D2Os3YNqNxbRwfLIO1i+Xj5ecQ== X-Google-Smtp-Source: ABdhPJwfrY+H9LpE/xzRxcE/UG1SyICoTj1JCeeOTMnUNb06bH1CDejbbABKsIFbSOnrOGELyi32/w== X-Received: by 2002:a17:902:c509:b029:de:c3c7:9433 with SMTP id o9-20020a170902c509b02900dec3c79433mr14234653plx.71.1611227931401; Thu, 21 Jan 2021 03:18:51 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id z13sm5392343pgf.89.2021.01.21.03.18.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:18:50 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 03/13] opp: Keep track of currently programmed OPP Date: Thu, 21 Jan 2021 16:47:43 +0530 Message-Id: <96b57316a2a307a5cc5ff7302b3cd0084123a2ed.1611227342.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The dev_pm_opp_set_rate() helper needs to know the currently programmed OPP to make few decisions and currently we try to find it on every invocation of this routine. Lets start keeping track of the current_opp programmed for the devices of the opp table, that will be quite useful going forward. If we fail to find the current OPP, we pick the first one available in the list, as the list is in ascending order of frequencies, level, or bandwidth and that's the best guess we can make anyway. Note that we used to do the frequency comparison a bit early in dev_pm_opp_set_rate() previously, and now instead we check the target opp, which shall be more accurate anyway. We need to make sure that current_opp's memory doesn't get freed while it is being used and so we keep a reference of it until the time it is used. Now that current_opp will always be set, we can drop some unnecessary checks as well. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 83 +++++++++++++++++++++++++++++----------------- drivers/opp/opp.h | 2 ++ 2 files changed, 55 insertions(+), 30 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index cb5b67ccf5cf..4ee598344e6a 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -788,8 +788,7 @@ static int _generic_set_opp_regulator(struct opp_table *opp_table, __func__, old_freq); restore_voltage: /* This shouldn't harm even if the voltages weren't updated earlier */ - if (old_supply) - _set_opp_voltage(dev, reg, old_supply); + _set_opp_voltage(dev, reg, old_supply); return ret; } @@ -839,10 +838,7 @@ static int _set_opp_custom(const struct opp_table *opp_table, data->old_opp.rate = old_freq; size = sizeof(*old_supply) * opp_table->regulator_count; - if (!old_supply) - memset(data->old_opp.supplies, 0, size); - else - memcpy(data->old_opp.supplies, old_supply, size); + memcpy(data->old_opp.supplies, old_supply, size); data->new_opp.rate = freq; memcpy(data->new_opp.supplies, new_supply, size); @@ -943,6 +939,31 @@ int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_set_bw); +static void _find_current_opp(struct device *dev, struct opp_table *opp_table) +{ + struct dev_pm_opp *opp = ERR_PTR(-ENODEV); + unsigned long freq; + + if (!IS_ERR(opp_table->clk)) { + freq = clk_get_rate(opp_table->clk); + opp = _find_freq_ceil(opp_table, &freq); + } + + /* + * Unable to find the current OPP ? Pick the first from the list since + * it is in ascending order, otherwise rest of the code will need to + * make special checks to validate current_opp. + */ + if (IS_ERR(opp)) { + mutex_lock(&opp_table->lock); + opp = list_first_entry(&opp_table->opp_list, struct dev_pm_opp, node); + dev_pm_opp_get(opp); + mutex_unlock(&opp_table->lock); + } + + opp_table->current_opp = opp; +} + static int _disable_opp_table(struct device *dev, struct opp_table *opp_table) { int ret; @@ -1004,16 +1025,6 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) if ((long)freq <= 0) freq = target_freq; - old_freq = clk_get_rate(opp_table->clk); - - /* Return early if nothing to do */ - if (opp_table->enabled && old_freq == freq) { - dev_dbg(dev, "%s: old/new frequencies (%lu Hz) are same, nothing to do\n", - __func__, freq); - ret = 0; - goto put_opp_table; - } - /* * For IO devices which require an OPP on some platforms/SoCs * while just needing to scale the clock on some others @@ -1026,12 +1037,9 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) goto put_opp_table; } - temp_freq = old_freq; - old_opp = _find_freq_ceil(opp_table, &temp_freq); - if (IS_ERR(old_opp)) { - dev_err(dev, "%s: failed to find current OPP for freq %lu (%ld)\n", - __func__, old_freq, PTR_ERR(old_opp)); - } + /* Find the currently set OPP if we don't know already */ + if (unlikely(!opp_table->current_opp)) + _find_current_opp(dev, opp_table); temp_freq = freq; opp = _find_freq_ceil(opp_table, &temp_freq); @@ -1039,7 +1047,17 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) ret = PTR_ERR(opp); dev_err(dev, "%s: failed to find OPP for freq %lu (%d)\n", __func__, freq, ret); - goto put_old_opp; + goto put_opp_table; + } + + old_opp = opp_table->current_opp; + old_freq = old_opp->rate; + + /* Return early if nothing to do */ + if (opp_table->enabled && old_opp == opp) { + dev_dbg(dev, "%s: OPPs are same, nothing to do\n", __func__); + ret = 0; + goto put_opp; } dev_dbg(dev, "%s: switching OPP: %lu Hz --> %lu Hz\n", __func__, @@ -1054,11 +1072,10 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) if (opp_table->set_opp) { ret = _set_opp_custom(opp_table, dev, old_freq, freq, - IS_ERR(old_opp) ? NULL : old_opp->supplies, - opp->supplies); + old_opp->supplies, opp->supplies); } else if (opp_table->regulators) { ret = _generic_set_opp_regulator(opp_table, dev, old_freq, freq, - IS_ERR(old_opp) ? NULL : old_opp->supplies, + old_opp->supplies, opp->supplies); } else { /* Only frequency scaling */ @@ -1074,15 +1091,18 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) if (!ret) { ret = _set_opp_bw(opp_table, opp, dev, false); - if (!ret) + if (!ret) { opp_table->enabled = true; + dev_pm_opp_put(old_opp); + + /* Make sure current_opp doesn't get freed */ + dev_pm_opp_get(opp); + opp_table->current_opp = opp; + } } put_opp: dev_pm_opp_put(opp); -put_old_opp: - if (!IS_ERR(old_opp)) - dev_pm_opp_put(old_opp); put_opp_table: dev_pm_opp_put_opp_table(opp_table); return ret; @@ -1276,6 +1296,9 @@ static void _opp_table_kref_release(struct kref *kref) list_del(&opp_table->node); mutex_unlock(&opp_table_lock); + if (opp_table->current_opp) + dev_pm_opp_put(opp_table->current_opp); + _of_clear_opp_table(opp_table); /* Release clk */ diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 4408cfcb0f31..359fd89d5770 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -135,6 +135,7 @@ enum opp_table_access { * @clock_latency_ns_max: Max clock latency in nanoseconds. * @parsed_static_opps: Count of devices for which OPPs are initialized from DT. * @shared_opp: OPP is shared between multiple devices. + * @current_opp: Currently configured OPP for the table. * @suspend_opp: Pointer to OPP to be used during device suspend. * @genpd_virt_dev_lock: Mutex protecting the genpd virtual device pointers. * @genpd_virt_devs: List of virtual devices for multiple genpd support. @@ -183,6 +184,7 @@ struct opp_table { unsigned int parsed_static_opps; enum opp_table_access shared_opp; + struct dev_pm_opp *current_opp; struct dev_pm_opp *suspend_opp; struct mutex genpd_virt_dev_lock; From patchwork Thu Jan 21 11:17:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035753 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D61DC433DB for ; Thu, 21 Jan 2021 11:58:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C00492395A for ; Thu, 21 Jan 2021 11:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730660AbhAUL6I (ORCPT ); Thu, 21 Jan 2021 06:58:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729820AbhAULUp (ORCPT ); Thu, 21 Jan 2021 06:20:45 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30BF5C061798 for ; Thu, 21 Jan 2021 03:18:55 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id be12so1115138plb.4 for ; Thu, 21 Jan 2021 03:18:55 -0800 (PST) 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=yGSozZ62BYCUnvHz15lG2EnbQmWJ88vlwijLJGHrCgo=; b=jMznsEDClSg4+xGGHd4ynKf8aBhP9BTp/c1fcRIW0bwCmouHvmrSfMLRDtlokUPLPV 7uZ6cisbhC2/bCQhc1Sf8gCz0qzy7gUIZQPY641HZOSD9Ne58dPVd1v3P52FQQFJDQ5r BIEh2MsMfTZXAeF2tHcy4OjrZF5MSsSSxlisois1xZMV8twzKfyA/YgxLL7chity4eV6 HqMTn0S0YphcvWIdJERsciBUfz3VyFW4wXWKZaGZwJW8ZeXt2D84zqcdL5KTQc00Owqp EKOGoSCDNRgLk8dZXgxqPtahXM2N2MsO9eo7nghpRuI4W7dDgRIhCNczCqPqveO8WmTe iNTA== 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=yGSozZ62BYCUnvHz15lG2EnbQmWJ88vlwijLJGHrCgo=; b=Ij0IynPHyPEfb67kUA/hjhinZzWKmWju0Ta2EWljmxjEZkijMrkGuZuqbn1hbXSA2p Kx09HKFMBvmt9qs8VJB7gdFRPGMdIvSqGpGiGdht9vsgFPaMUdogx6pMKl+ztUWyd9PE GFlkNQZMrHGOVH+IcL05q8gesbuM3TfQSPHC4zRuoJtHQi3R4UFm1L6DPc6m3BvcRLu2 ELDSbsZJvouLr2fBzyckvIzZXJaCSPBHpRR7Eu9Mq2E9k8aqhA1I1qVsDeL2TBkrRbwL r9iDk3LUszJLq5Eiz1bAE5ugChteO1Y7iZsJwLGdYc08Sz8zqFuE/HmGVTDWky5+//eJ wIfA== X-Gm-Message-State: AOAM530dRGw3b1BCX8KJI2rbiOqbzvawWr4JlQg4yifNFTz1q/PaAQrd 9IcpoyB36Hp5l7/parOEo+6Y/A== X-Google-Smtp-Source: ABdhPJxCDceYWRati28gRyR2MZg5jIN0/VdJ4+0q1+AusUpULOSN9NiaiWRtWjYKJucbY9Swc+dQTw== X-Received: by 2002:a17:90a:2947:: with SMTP id x7mr11321170pjf.157.1611227934689; Thu, 21 Jan 2021 03:18:54 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id g5sm5980697pfb.194.2021.01.21.03.18.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:18:54 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 04/13] opp: Split _set_opp() out of dev_pm_opp_set_rate() Date: Thu, 21 Jan 2021 16:47:44 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The _set_opp() helper will be used for devices which don't change their frequency (like power domains, etc.) later on, prepare for that by breaking the generic part out of dev_pm_opp_set_rate(). Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 126 +++++++++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 55 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 4ee598344e6a..5313dc322bdd 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -992,72 +992,27 @@ static int _disable_opp_table(struct device *dev, struct opp_table *opp_table) return ret; } -/** - * dev_pm_opp_set_rate() - Configure new OPP based on frequency - * @dev: device for which we do this operation - * @target_freq: frequency to achieve - * - * This configures the power-supplies to the levels specified by the OPP - * corresponding to the target_freq, and programs the clock to a value <= - * target_freq, as rounded by clk_round_rate(). Device wanting to run at fmax - * provided by the opp, should have already rounded to the target OPP's - * frequency. - */ -int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) +static int _set_opp(struct device *dev, struct opp_table *opp_table, + struct dev_pm_opp *opp, unsigned long freq) { - struct opp_table *opp_table; - unsigned long freq, old_freq, temp_freq; - struct dev_pm_opp *old_opp, *opp; + struct dev_pm_opp *old_opp; + unsigned long old_freq; int ret; - opp_table = _find_opp_table(dev); - if (IS_ERR(opp_table)) { - dev_err(dev, "%s: device opp doesn't exist\n", __func__); - return PTR_ERR(opp_table); - } - - if (unlikely(!target_freq)) { - ret = _disable_opp_table(dev, opp_table); - goto put_opp_table; - } - - freq = clk_round_rate(opp_table->clk, target_freq); - if ((long)freq <= 0) - freq = target_freq; - - /* - * For IO devices which require an OPP on some platforms/SoCs - * while just needing to scale the clock on some others - * we look for empty OPP tables with just a clock handle and - * scale only the clk. This makes dev_pm_opp_set_rate() - * equivalent to a clk_set_rate() - */ - if (!_get_opp_count(opp_table)) { - ret = _generic_set_opp_clk_only(dev, opp_table->clk, freq); - goto put_opp_table; - } + if (unlikely(!opp)) + return _disable_opp_table(dev, opp_table); /* Find the currently set OPP if we don't know already */ if (unlikely(!opp_table->current_opp)) _find_current_opp(dev, opp_table); - temp_freq = freq; - opp = _find_freq_ceil(opp_table, &temp_freq); - if (IS_ERR(opp)) { - ret = PTR_ERR(opp); - dev_err(dev, "%s: failed to find OPP for freq %lu (%d)\n", - __func__, freq, ret); - goto put_opp_table; - } - old_opp = opp_table->current_opp; old_freq = old_opp->rate; /* Return early if nothing to do */ if (opp_table->enabled && old_opp == opp) { dev_dbg(dev, "%s: OPPs are same, nothing to do\n", __func__); - ret = 0; - goto put_opp; + return 0; } dev_dbg(dev, "%s: switching OPP: %lu Hz --> %lu Hz\n", __func__, @@ -1067,7 +1022,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) if (freq >= old_freq) { ret = _set_required_opps(dev, opp_table, opp, true); if (ret) - goto put_opp; + return ret; } if (opp_table->set_opp) { @@ -1101,8 +1056,69 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) } } -put_opp: - dev_pm_opp_put(opp); + return ret; +} + +/** + * dev_pm_opp_set_rate() - Configure new OPP based on frequency + * @dev: device for which we do this operation + * @target_freq: frequency to achieve + * + * This configures the power-supplies to the levels specified by the OPP + * corresponding to the target_freq, and programs the clock to a value <= + * target_freq, as rounded by clk_round_rate(). Device wanting to run at fmax + * provided by the opp, should have already rounded to the target OPP's + * frequency. + */ +int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) +{ + struct opp_table *opp_table; + unsigned long freq = 0, temp_freq; + struct dev_pm_opp *opp = NULL; + int ret; + + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) { + dev_err(dev, "%s: device's opp table doesn't exist\n", __func__); + return PTR_ERR(opp_table); + } + + if (target_freq) { + /* + * For IO devices which require an OPP on some platforms/SoCs + * while just needing to scale the clock on some others + * we look for empty OPP tables with just a clock handle and + * scale only the clk. This makes dev_pm_opp_set_rate() + * equivalent to a clk_set_rate() + */ + if (!_get_opp_count(opp_table)) { + ret = _generic_set_opp_clk_only(dev, opp_table->clk, target_freq); + goto put_opp_table; + } + + freq = clk_round_rate(opp_table->clk, target_freq); + if ((long)freq <= 0) + freq = target_freq; + + /* + * The clock driver may support finer resolution of the + * frequencies than the OPP table, don't update the frequency we + * pass to clk_set_rate() here. + */ + temp_freq = freq; + opp = _find_freq_ceil(opp_table, &temp_freq); + if (IS_ERR(opp)) { + ret = PTR_ERR(opp); + dev_err(dev, "%s: failed to find OPP for freq %lu (%d)\n", + __func__, freq, ret); + goto put_opp_table; + } + } + + ret = _set_opp(dev, opp_table, opp, freq); + + if (opp) + dev_pm_opp_put(opp); put_opp_table: dev_pm_opp_put_opp_table(opp_table); return ret; From patchwork Thu Jan 21 11:17:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035751 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66136C433DB for ; Thu, 21 Jan 2021 11:57:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 20D312399A for ; Thu, 21 Jan 2021 11:57:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730547AbhAUL5r (ORCPT ); Thu, 21 Jan 2021 06:57:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729917AbhAULUp (ORCPT ); Thu, 21 Jan 2021 06:20:45 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ECFDC061796 for ; Thu, 21 Jan 2021 03:18:58 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id 31so1087606plb.10 for ; Thu, 21 Jan 2021 03:18:58 -0800 (PST) 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=3q4F6fqDBoI1WPbxX2i+8B6qqJAH4SxSEXz0WavjCuM=; b=KPZnAalZ+8zh6lvLMEBZSaMYyoeR8ZqD+umfJrUDLFjwJNX85Vj//MjvUfsCfe4VG6 zKZO18Ju7We5Q6IR7a/brqg4Yzjak5tSdoj+mMXoDEVoXWX08XLn+sjhivh9BE3dRwSX QXCJqmndJOHaPcru83M8zwkDEUVdie1rf6cTkwbUa78Mgj/6MxJ2LSWxrWdqSYThvKOq r17YUw9fmG7ac37k3QCpx4YN2oOBIfW0hoD3VuDM1g9/1ugSVV76bn6Ob28gVnq8QBZy /+UdVCvOpk7f/0TsQnrR49jopuOeRInCBYSPualUNh3IcWLrI+PCvaztx4uXMBcNPCir Zf3g== 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=3q4F6fqDBoI1WPbxX2i+8B6qqJAH4SxSEXz0WavjCuM=; b=AYt45uzkvGdiZbZgGnNp6dXFNYzzPcsaxuvkgB7tbhxQ2EBsauKFwUbmA2p16DT9sV IyWo3L/mhO2q6ouRPBMaHETUdESt6Gfo5KD52hD73tL0E9VR6xa6iepgqmgpEWA2w7dI GJmVF48OHl+2T+mAYpKflbpgnYGL2YIC6fabEx7Mmc/PFtpKnmQ5SWeO/ldC9qWhB5m5 vZ/8JCfmhzgKSpS8LcR2gOJ5Q90rF7AFadRvRTyEMSwlQ0V0fv8pZTbPlhuDU6ADWHCL L73VXf/SmGLGvH8vko0KRyjgWGyKXt8bJOVuS9MafVgrQmb445T8mPttesTkFuU0DQy6 no0A== X-Gm-Message-State: AOAM532WLY6GYU/yUOaNIM5xUrv7XNCrAgeqHXbkqrGr9gkjdqcGUACu LVI9ltVuhNSOGe726YQJeOfgnA== X-Google-Smtp-Source: ABdhPJz22P2tWFOkcUwHY7BKv4TTjLUXRNax4HNk+svmsc6qCNBAsLI0X0TzxbDx9sH5y/pVn2KIZg== X-Received: by 2002:a17:90a:ea02:: with SMTP id w2mr11249229pjy.228.1611227937583; Thu, 21 Jan 2021 03:18:57 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id c5sm5779986pjo.4.2021.01.21.03.18.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:18:57 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 05/13] opp: Allow _set_opp() to work for non-freq devices Date: Thu, 21 Jan 2021 16:47:45 +0530 Message-Id: <2f0956ab1ed075bc8551f68921791ecbc6032f83.1611227342.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The _set_opp() helper will be used for devices which don't change frequency (like power domains, etc.) later on, prepare for that by not relying on frequency for making decisions here. While at it, also update the debug print to contain all relevant information. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 5313dc322bdd..64424dbd23c1 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -997,7 +997,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, { struct dev_pm_opp *old_opp; unsigned long old_freq; - int ret; + int scaling_down, ret; if (unlikely(!opp)) return _disable_opp_table(dev, opp_table); @@ -1015,11 +1015,17 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, return 0; } - dev_dbg(dev, "%s: switching OPP: %lu Hz --> %lu Hz\n", __func__, - old_freq, freq); + dev_dbg(dev, "%s: switching OPP: Freq %lu -> %lu Hz, Level %u -> %u, Bw %u -> %u\n", + __func__, old_freq, freq, old_opp->level, opp->level, + old_opp->bandwidth ? old_opp->bandwidth[0].peak : 0, + opp->bandwidth ? opp->bandwidth[0].peak : 0); + + scaling_down = _opp_compare_key(old_opp, opp); + if (scaling_down == -1) + scaling_down = 0; /* Scaling up? Configure required OPPs before frequency */ - if (freq >= old_freq) { + if (!scaling_down) { ret = _set_required_opps(dev, opp_table, opp, true); if (ret) return ret; @@ -1038,7 +1044,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, } /* Scaling down? Configure required OPPs after frequency */ - if (!ret && freq < old_freq) { + if (!ret && scaling_down) { ret = _set_required_opps(dev, opp_table, opp, false); if (ret) dev_err(dev, "Failed to set required opps: %d\n", ret); From patchwork Thu Jan 21 11:17:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035723 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7272DC433E6 for ; Thu, 21 Jan 2021 11:47:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 275AD239A4 for ; Thu, 21 Jan 2021 11:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730076AbhAULrd (ORCPT ); Thu, 21 Jan 2021 06:47:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730071AbhAULVW (ORCPT ); Thu, 21 Jan 2021 06:21:22 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41D92C06179C for ; Thu, 21 Jan 2021 03:19:01 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id u4so1449253pjn.4 for ; Thu, 21 Jan 2021 03:19:01 -0800 (PST) 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=xAKTZkyycba98JIw9o5yBKGTgq6RnpydF9Cba6DEkjM=; b=IE5cB3XUcMOfllNnwGT/K8+FysNlnl6CN4kmfCqtdtbsK6nqdVZB37NlyY+ocle3C1 BJSbgqiGQ1RcwE/02b9qpjDCWn+//56RBxiUS9lahW8NTBSWgTBU14p8ehtxYGrcFw3J m/iaGhrrFw77+W7wq4k/oNokc2iEHPCcYeFueag/GTYWb6dV+LWnlQ/5a/f/SvRNvuAa 3mjYP0rSx6c28PV2w4lAxljy/w3tDI4ULO6U74GbojEyPdXiDKRg6rLHLaz5qqU53StK n7sGL3faxA9KaPvLiYX4EdAkbRVZqJB3aSLBngSk/QRb7gStOyskUpFzy1eTnLGF7TZj /vew== 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=xAKTZkyycba98JIw9o5yBKGTgq6RnpydF9Cba6DEkjM=; b=U4LZHWSGg0QPPmiMPH87/2OkD9gqu/1r4bejSRcYu2uTNsGfG9tWaE1j1p5T2DlbEw rxzpNdRyqz+KP5DoMuvuYNlWc6ug/2rSt0AzX4+1SXETojmL4n3KqDLy6JcJKHBMZacD i0bLRb887KGIoynRFgGjHCn1IfkJrsWP8UPyRvMAU1XYFwe6zqnWhfzsRZOAoMWzWqqX kTkEeP+uXaGJ/CKPpOMYSYKiloDmLkfhDHKGDhAqzzZiiHQgQX57jAliXs8x3OIrx8SK S3m740Q4KOi9nwjKuzAKXFnVIkLc6LEzoyQBDoe24KwnS520U3AhHgVv0fof3xwYpqdT qZvA== X-Gm-Message-State: AOAM533bILU421BQ1Fm2kr+g0P4ISIFxH6MST7haIv5bcW2YmWRJjUf3 Wf7is+NUzDWKt2O4ZggrJPWq4Q== X-Google-Smtp-Source: ABdhPJzh80hJitJKGsChrc0Eudj2IFABV8NGgEDM/wNUy0FrILeXFQbCYrIaBzthFQDqE04LoZxRUw== X-Received: by 2002:a17:90a:fd0b:: with SMTP id cv11mr11277904pjb.26.1611227940577; Thu, 21 Jan 2021 03:19:00 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id l12sm2255450pjg.54.2021.01.21.03.18.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:19:00 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 06/13] opp: Allow _generic_set_opp_regulator() to work for non-freq devices Date: Thu, 21 Jan 2021 16:47:46 +0530 Message-Id: <8f2d26305f38b52ebc46f2b0d4620e1e578fa2f2.1611227342.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The _generic_set_opp_regulator() helper will be used for devices which don't change frequency (like power domains, etc.) later on, prepare for that by not relying on frequency for making decisions here. While at it, update its parameters to pass only what is necessary. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 64424dbd23c1..a96ffd9051b1 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -737,12 +737,12 @@ static inline int _generic_set_opp_clk_only(struct device *dev, struct clk *clk, static int _generic_set_opp_regulator(struct opp_table *opp_table, struct device *dev, - unsigned long old_freq, + struct dev_pm_opp *opp, unsigned long freq, - struct dev_pm_opp_supply *old_supply, - struct dev_pm_opp_supply *new_supply) + int scaling_down) { struct regulator *reg = opp_table->regulators[0]; + struct dev_pm_opp *old_opp = opp_table->current_opp; int ret; /* This function only supports single regulator per device */ @@ -752,8 +752,8 @@ static int _generic_set_opp_regulator(struct opp_table *opp_table, } /* Scaling up? Scale voltage before frequency */ - if (freq >= old_freq) { - ret = _set_opp_voltage(dev, reg, new_supply); + if (!scaling_down) { + ret = _set_opp_voltage(dev, reg, opp->supplies); if (ret) goto restore_voltage; } @@ -764,8 +764,8 @@ static int _generic_set_opp_regulator(struct opp_table *opp_table, goto restore_voltage; /* Scaling down? Scale voltage after frequency */ - if (freq < old_freq) { - ret = _set_opp_voltage(dev, reg, new_supply); + if (scaling_down) { + ret = _set_opp_voltage(dev, reg, opp->supplies); if (ret) goto restore_freq; } @@ -783,12 +783,12 @@ static int _generic_set_opp_regulator(struct opp_table *opp_table, return 0; restore_freq: - if (_generic_set_opp_clk_only(dev, opp_table->clk, old_freq)) + if (_generic_set_opp_clk_only(dev, opp_table->clk, old_opp->rate)) dev_err(dev, "%s: failed to restore old-freq (%lu Hz)\n", - __func__, old_freq); + __func__, old_opp->rate); restore_voltage: /* This shouldn't harm even if the voltages weren't updated earlier */ - _set_opp_voltage(dev, reg, old_supply); + _set_opp_voltage(dev, reg, old_opp->supplies); return ret; } @@ -1035,9 +1035,8 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, ret = _set_opp_custom(opp_table, dev, old_freq, freq, old_opp->supplies, opp->supplies); } else if (opp_table->regulators) { - ret = _generic_set_opp_regulator(opp_table, dev, old_freq, freq, - old_opp->supplies, - opp->supplies); + ret = _generic_set_opp_regulator(opp_table, dev, opp, freq, + scaling_down); } else { /* Only frequency scaling */ ret = _generic_set_opp_clk_only(dev, opp_table->clk, freq); From patchwork Thu Jan 21 11:17:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035721 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A10AC433E0 for ; Thu, 21 Jan 2021 11:47:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF8EB23975 for ; Thu, 21 Jan 2021 11:47:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730147AbhAULr2 (ORCPT ); Thu, 21 Jan 2021 06:47:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730076AbhAULVX (ORCPT ); Thu, 21 Jan 2021 06:21:23 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27548C06179F for ; Thu, 21 Jan 2021 03:19:04 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id c132so1166535pga.3 for ; Thu, 21 Jan 2021 03:19:04 -0800 (PST) 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=CYbzCFVCi3fEgZJohV5hqu59RAY6Et7w7QbAOId9XrY=; b=lMZb9UiNz5IoKRjlVfTRbe5AbsFjgYug6+3rBQBORQMTS2UMUtLozNugVAnuXzVu8y EYEMj8NSmofsA6xXlvjPMTlIYrPcpAfABG+1v1OmZz7r9X5YWSkh16Cxrsokim45C5sJ tUjvk+6bmsgYppq/z+2OjYh9iv2r6nSz0qXHsQ+GHP9yy0kYl4kID2DhPeeyCjK4vjlb Icdu8T9ko+aqp872q9wMRgxdPOSbnY8xrtxNYrFWzjrxlAklUobL0Gl0pA9p1ggkdKGE zQrS52KKBl/kFz3wQD/xWCCxYLYBNGWJvjbTLdPsvcwnxS60d3h0uiITwge2NEyNxN4s 6jvA== 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=CYbzCFVCi3fEgZJohV5hqu59RAY6Et7w7QbAOId9XrY=; b=RHsda/T8lVJigRUInunsCkeUMXJUn7ZFF74HgfK5rsN109Rq7bJow6ncggTvJivUC7 3XQWEllzlvhDxSXVHbUEewv+D6q44aw7anUR08X5nDL/chyhTr7ScymTmzNh6z0OTVid 6qlXo+Xlc6YCbTQODulPhCbH++zYDN3jqD5Nr+zQLx2TQTQB34E3UmIwVcgi0gisOyre 1y1ksTDeHbIkaK2PHq6Jet33FgM7zz2e0kGQtt7j3W/He/Uw0L+2Px7UyPHAQRjUaU+A ESXd+sbElp35wkpyW7ytsBfcP73uF1mNS6TEgI/duus2T+JC7hPZcWvEiZoMzJ7TDO7o Og3A== X-Gm-Message-State: AOAM532Hnr8pK8+QpUn4C245P9iw9E7Zcsvsz0lN6ZMHd3P1M40+jUww txpbeRW/JZeu+3JZdiGQPWZoJQ== X-Google-Smtp-Source: ABdhPJyEgpWlB1DXX6+xj9reAgkGRUJ/18nmuXm2a77WwY0rHW9XG4b7O5gR3XoNa+V5ylK4UmmqzA== X-Received: by 2002:a63:d42:: with SMTP id 2mr8226764pgn.236.1611227943683; Thu, 21 Jan 2021 03:19:03 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id w21sm4497087pff.220.2021.01.21.03.19.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:19:03 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 07/13] opp: Allow _generic_set_opp_clk_only() to work for non-freq devices Date: Thu, 21 Jan 2021 16:47:47 +0530 Message-Id: <1585f6c21ea8aee64fe4da0bf72b36ea4d74a779.1611227342.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In order to avoid conditional statements at the caller site, this patch updates _generic_set_opp_clk_only() to work for devices that don't change frequency (like power domains, etc.). Return 0 if the clk pointer passed to this routine is not valid. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index a96ffd9051b1..6b09d468d37a 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -726,6 +726,10 @@ static inline int _generic_set_opp_clk_only(struct device *dev, struct clk *clk, { int ret; + /* We may reach here for devices which don't change frequency */ + if (unlikely(!clk)) + return 0; + ret = clk_set_rate(clk, freq); if (ret) { dev_err(dev, "%s: failed to set clock rate: %d\n", __func__, From patchwork Thu Jan 21 11:17:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035717 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D745C433E9 for ; Thu, 21 Jan 2021 11:47:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01BCD2395A for ; Thu, 21 Jan 2021 11:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730494AbhAULrH (ORCPT ); Thu, 21 Jan 2021 06:47:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730223AbhAULVe (ORCPT ); Thu, 21 Jan 2021 06:21:34 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23C42C0617A1 for ; Thu, 21 Jan 2021 03:19:07 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id w18so1302910pfu.9 for ; Thu, 21 Jan 2021 03:19:07 -0800 (PST) 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=QsvG3t6xFRgx0s76cOQVzbYkqHL9lM3bJ086HXut2lo=; b=W8sAOHZXGjGsUHf8lA5IP8zqppO9iNNGBAO/qkfocVkFGmZSsW/naH1YNTl0xP/gTa gY50hBXssIxtuU2G59zExSMtcwVt7utDVVzmh6u9fjrD+gxfwmaw+ao5wN7cr/pBoIw3 oRUkfsAVRcuJw664wy7zI0ZnVC2itA4TtpRfrtC0Gl5gtFhl4IOvROR/LH20rudx7rlv gWtqNMLBkoXlXYJmuXSwOzf/XejjXh9qiAA0ZlrkJH/afNscVDAJM3rbqNgElgUCPqRm UBPCokJYgpbAq0qwbubfijtQgJxq9EDuL0R+iegFbZcUTi60rDsqp0znC1i8ZppPwSnH /QqA== 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=QsvG3t6xFRgx0s76cOQVzbYkqHL9lM3bJ086HXut2lo=; b=cKqX6LzbRNUn2S3TGyJ5kjauaIydodz+Pi0HjjqPn+hXlwZYeSGnOT5Nt8GPFyXBm3 pNqgUXXUnh1zuecZCRZanakqelXcGsH+w26LoGab3iiPeJowU4BUiJ3cBHL+3IVA7hzr xzdujxLV5NYKLjpIMtr9UAaMYma/MIn95u8i5dTtbk4cFtAUNQsQbJ3DA7nAcXnJGJUb CKerYwDcD2HOUC99tjre/uTSGV7z0iWozm5Sd0EhcyRYt4+21ADIbdxIA6ZASlXhYDS+ TqKH6Ey1/AecleD4Lw0jhfbGdrSGkyrJed2AmKC/Yqerc+ixZICSDS3PxzF3I3Y9h0Bx jH/g== X-Gm-Message-State: AOAM530xOKwH4DeOIbL5BLWmFHF6pdnK/yZ7BTU6Q5xEgr0IfL+acNOp CYQoxiqCJkgw92mIaFZZtKWqfw== X-Google-Smtp-Source: ABdhPJy5sX9QMNxrrbhz8F+SIc0A20khl+IXc6z8UY/zsrD3/92c9hrmIh3MhaQyDhyT3bApnJ9r9g== X-Received: by 2002:a65:6542:: with SMTP id a2mr13920489pgw.148.1611227946652; Thu, 21 Jan 2021 03:19:06 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id gk2sm5826702pjb.6.2021.01.21.03.19.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:19:06 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 08/13] opp: Update parameters of _set_opp_custom() Date: Thu, 21 Jan 2021 16:47:48 +0530 Message-Id: <296a3a64a673ed3eb261a6fc06f4dfd90dbca479.1611227342.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Drop the unnecessary parameters and follow the pattern from _generic_set_opp_regulator(). While at it, also remove the local variable old_freq. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 6b09d468d37a..3500cc9de66b 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -826,11 +826,10 @@ static int _set_opp_bw(const struct opp_table *opp_table, } static int _set_opp_custom(const struct opp_table *opp_table, - struct device *dev, unsigned long old_freq, - unsigned long freq, - struct dev_pm_opp_supply *old_supply, - struct dev_pm_opp_supply *new_supply) + struct device *dev, struct dev_pm_opp *opp, + unsigned long freq) { + struct dev_pm_opp *old_opp = opp_table->current_opp; struct dev_pm_set_opp_data *data; int size; @@ -840,12 +839,12 @@ static int _set_opp_custom(const struct opp_table *opp_table, data->clk = opp_table->clk; data->dev = dev; - data->old_opp.rate = old_freq; - size = sizeof(*old_supply) * opp_table->regulator_count; - memcpy(data->old_opp.supplies, old_supply, size); + data->old_opp.rate = old_opp->rate; + size = sizeof(*old_opp->supplies) * opp_table->regulator_count; + memcpy(data->old_opp.supplies, old_opp->supplies, size); data->new_opp.rate = freq; - memcpy(data->new_opp.supplies, new_supply, size); + memcpy(data->new_opp.supplies, opp->supplies, size); return opp_table->set_opp(data); } @@ -1000,7 +999,6 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, struct dev_pm_opp *opp, unsigned long freq) { struct dev_pm_opp *old_opp; - unsigned long old_freq; int scaling_down, ret; if (unlikely(!opp)) @@ -1011,7 +1009,6 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, _find_current_opp(dev, opp_table); old_opp = opp_table->current_opp; - old_freq = old_opp->rate; /* Return early if nothing to do */ if (opp_table->enabled && old_opp == opp) { @@ -1020,7 +1017,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, } dev_dbg(dev, "%s: switching OPP: Freq %lu -> %lu Hz, Level %u -> %u, Bw %u -> %u\n", - __func__, old_freq, freq, old_opp->level, opp->level, + __func__, old_opp->rate, freq, old_opp->level, opp->level, old_opp->bandwidth ? old_opp->bandwidth[0].peak : 0, opp->bandwidth ? opp->bandwidth[0].peak : 0); @@ -1036,8 +1033,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, } if (opp_table->set_opp) { - ret = _set_opp_custom(opp_table, dev, old_freq, freq, - old_opp->supplies, opp->supplies); + ret = _set_opp_custom(opp_table, dev, opp, freq); } else if (opp_table->regulators) { ret = _generic_set_opp_regulator(opp_table, dev, opp, freq, scaling_down); From patchwork Thu Jan 21 11:17:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035633 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A86C4C433E0 for ; Thu, 21 Jan 2021 11:21:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5217E23444 for ; Thu, 21 Jan 2021 11:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729925AbhAULVQ (ORCPT ); Thu, 21 Jan 2021 06:21:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728983AbhAULVA (ORCPT ); Thu, 21 Jan 2021 06:21:00 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F8A2C0617A2 for ; Thu, 21 Jan 2021 03:19:10 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id v19so1132993pgj.12 for ; Thu, 21 Jan 2021 03:19:10 -0800 (PST) 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=ztcbVczwcxvX+Nme8Zu1bVyHZiwA0aS5UzQfgwSCEM4=; b=uvEyLQq53T//ZW0fW9IuJXmQ0IpdbzBOHOZkvCWGZ4qs23KbdM1qBbTqsBvRapbFjQ GFTzRYWISYJfZppc2Zk7RHboU5zZ4TVr9NOy3uFsFZN3WNsrlkPVDczNsuKmY3q5BE+B WJn2+aBHGJLNiN6/ELjw0OPDd33iZ3H6kAA4chYfT/sr2Gd/6TnwEmeW8lfDuPWeru/u C7NgP8XEQydN5j4ZOwOQDckF78X8cApKr6rG9CXIybnq9UjECRHrVggyvlYqLI+ZC7T7 3ywLOkm13JVjMF9xUIgRTuNR6fYT/JHPI2hQ8dokW8N1jPAkvjp3iKDDfY80HBbwF3Xp Or9Q== 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=ztcbVczwcxvX+Nme8Zu1bVyHZiwA0aS5UzQfgwSCEM4=; b=XY2WpXdeAJFqSDrR5LecaDLFgGXTKv7zZ4fMT6+ZBRen5H6rdj6qzd6yv8U8CBbx6F zuee4/8/pl/eU7mo34FSYXRE0bWXA5tI29ciPL7edL7PgWkgnFJa27sPuODVvA+G599p H3kxyG6dB39xTxXqek7ZlRoG74mBl9RNT1HWfSBsi7B5NmCzYnvNOOsQA3hQL5MJZ2eS 5GLzb1e8y42D+7KILx87MXqcmFuA37sYlY60ndVCLZvzpjziwrPTk+UZUVJ8vYKdUpBH K8mFT2NNhLwCG0DvL3L4k/oyLPBq6MSUMwlU+BiorMfXBn+hVzVz0xFMNcBJs3vFdjMc mhfQ== X-Gm-Message-State: AOAM532ZWH8dZVllz63ly/l/7l0te2jSKkg4QuIHZFgr8YyfcYBZgWoi kpugOCfjDUElAzVwhE91ihvdpA== X-Google-Smtp-Source: ABdhPJz5dsmD2BduPt5SpiKRdA3AKAE60DsVpNwYRtx4HLW3+yCJkDvh+JXODFHsTDqqF3ffOKvzYw== X-Received: by 2002:a63:d446:: with SMTP id i6mr14020045pgj.446.1611227949698; Thu, 21 Jan 2021 03:19:09 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id u189sm5203484pfb.51.2021.01.21.03.19.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:19:09 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 09/13] opp: Implement dev_pm_opp_set_opp() Date: Thu, 21 Jan 2021 16:47:49 +0530 Message-Id: <7d62f63ac64e59ee3327789ff1bc9cebc2da6944.1611227342.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The new helper dev_pm_opp_set_opp() can be used for configuring the devices for a particular OPP and can be used by different type of devices, even the ones which don't change frequency (like power domains). Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 28 ++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 3500cc9de66b..5a367ef02b92 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1130,6 +1130,34 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) } EXPORT_SYMBOL_GPL(dev_pm_opp_set_rate); +/** + * dev_pm_opp_set_opp() - Configure device for OPP + * @dev: device for which we do this operation + * @opp: OPP to set to + * + * This configures the device based on the properties of the OPP passed to this + * routine. + * + * Return: 0 on success, a negative error number otherwise. + */ +int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp) +{ + struct opp_table *opp_table; + int ret; + + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) { + dev_err(dev, "%s: device opp doesn't exist\n", __func__); + return PTR_ERR(opp_table); + } + + ret = _set_opp(dev, opp_table, opp, opp->rate); + dev_pm_opp_put_opp_table(opp_table); + + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_set_opp); + /* OPP-dev Helpers */ static void _remove_opp_dev(struct opp_device *opp_dev, struct opp_table *opp_table) diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index f8e9a8e3eb59..2d8a706f8d00 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -158,6 +158,7 @@ void dev_pm_opp_detach_genpd(struct opp_table *opp_table); struct opp_table *devm_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs); int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); +int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp); int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp); int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); @@ -376,6 +377,11 @@ static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_f return -ENOTSUPP; } +static inline int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp) +{ + return -ENOTSUPP; +} + static inline int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) { return -EOPNOTSUPP; From patchwork Thu Jan 21 11:17:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035679 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 995A3C433E0 for ; Thu, 21 Jan 2021 11:22:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B58A238E1 for ; Thu, 21 Jan 2021 11:22:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730227AbhAULWf (ORCPT ); Thu, 21 Jan 2021 06:22:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730199AbhAULVe (ORCPT ); Thu, 21 Jan 2021 06:21:34 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F073C0617A5 for ; Thu, 21 Jan 2021 03:19:13 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id t6so1129168plq.1 for ; Thu, 21 Jan 2021 03:19:13 -0800 (PST) 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=jQe2wetugU1pRDNoKc4LJOQOkvxp53VsnbiI6RDAfCk=; b=JWhI8jHACexdhKZNQAB1k51Ex/gbBkuWtH4b7zMRmysDqXvSdtCk6gcqxtwhoC5lIf nlR6DkSOZnJL4r0XDi8JDy0lYfZKXQrzUKPm1HY31puRm3boWLqQAxaOgLMGiVuVStDd uIF6RYV1mDZ+GATOjv4zbSw8OjxDRRXYlTiakQgfcmprBexc9p5d5Awrkut673Bj1yZt OuWYzZ3b+q4rFTbTDdO/JhfOa38uQLNYS4HkYy/Rq3znUWIO/1glthWAlFBnrHG/UvWM G2q8Z1UyJu0RnmG0fKq0oQ9Hpv2eSuTGnzuTBS+kW2v9C4eZe8BBs7GQUA4Vm970BeRI AD6g== 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=jQe2wetugU1pRDNoKc4LJOQOkvxp53VsnbiI6RDAfCk=; b=NXZ5fMMhEG2wrU+eaBtHgdbKbYyF/aeCjL2S2ddlSZZxLRQdVPDQEYp/lASjYpjh+B hZVwD+vMZz6mNvVUd+aXf5DAlM0S6z85K198gqexCJtxwPVcwsR43kKSz285u8qeU7s6 q/pJZTBGUiyJZJwfg+xh0+21qk4ECTWOt8bLx87RHAMdQc/CvRDj2RVKYOSa1EUO67bz jQGmkNXad+jd5E1/5Czco3NU5IiGwyqsEOUgHQ8sXWqWPmBj+iKThu7WgUQ5uiyHD/ff 3Tvgo0Oi6iN29Jh8CrOXosDR7qhWUDM0K9NpuD/gMXiv/Bs7SRACdozKLdRcvep7YrHp xhDw== X-Gm-Message-State: AOAM532UOeTSc9UgzCtbbaKri4n1i76Mwha1uypLCbYyR8C9zcddSbX/ /BacBse6Ep5GNrefwloVz0yWag== X-Google-Smtp-Source: ABdhPJwNGwquTz5sTXjGQEvngNm64YXcGIcif0MXJgKVuRrhGd2tEwCjRjeCSGHJBffSlK3NCPp/8w== X-Received: by 2002:a17:902:e8cf:b029:de:a91c:5ec9 with SMTP id v15-20020a170902e8cfb02900dea91c5ec9mr14575866plg.27.1611227952607; Thu, 21 Jan 2021 03:19:12 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id z13sm5393490pgf.89.2021.01.21.03.19.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:19:12 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Andy Gross , Bjorn Andersson , "Rafael J. Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 10/13] cpufreq: qcom: Migrate to dev_pm_opp_set_opp() Date: Thu, 21 Jan 2021 16:47:50 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org dev_pm_opp_set_bw() is getting removed and dev_pm_opp_set_opp() should be used instead. Migrate to the new API. Signed-off-by: Viresh Kumar --- drivers/cpufreq/qcom-cpufreq-hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 9ed5341dc515..7df18903b66c 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -54,7 +54,7 @@ static int qcom_cpufreq_set_bw(struct cpufreq_policy *policy, if (IS_ERR(opp)) return PTR_ERR(opp); - ret = dev_pm_opp_set_bw(dev, opp); + ret = dev_pm_opp_set_opp(dev, opp); dev_pm_opp_put(opp); return ret; } From patchwork Thu Jan 21 11:17:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035677 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86143C433DB for ; Thu, 21 Jan 2021 11:21:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 368A2238E1 for ; Thu, 21 Jan 2021 11:21:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729924AbhAULVe (ORCPT ); Thu, 21 Jan 2021 06:21:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729923AbhAULVN (ORCPT ); Thu, 21 Jan 2021 06:21:13 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05213C0617A7 for ; Thu, 21 Jan 2021 03:19:16 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id b8so1133442plx.0 for ; Thu, 21 Jan 2021 03:19:16 -0800 (PST) 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=sc4RKhDP//JPOMDhY7YCUQxeEMkiC/uPecJg02H/C7o=; b=l+IAUYm7EFFo4t2J9K9y1homcgzoofuLPhJewoVATAFKtJg6FXyHwS2xW0rpFUTRHV 0VKWEJvRNqSxZWuzsLNt/c0JLq2Cpa0y6HOD3slSw3e3u01OJT4ei9LtHA+9mAS4E+e0 ZrW068O3VrMsNGnFvp6u2l0/u9WAI8YevpehexN1DMnm1c3YG//LXbjknAvqtN/oOpFH EZ1gSzViZvXX1doq/J5KOHLewT76zw0MOY/tM6Mvx2FezcifiP/0cHUjZ5pGAhTd2XYC UIlHo2ZP06GzddxHR81p+DeIXuMc4gRZzrAoMDgmg0JP7gIK5KRDPPgZxZUKYZhtePem HQ0Q== 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=sc4RKhDP//JPOMDhY7YCUQxeEMkiC/uPecJg02H/C7o=; b=lVJDvLohhI1HPUi0o5QJ1UyWqrE8Bvknfk7VMvhfIuP2AcBEy8UG9hTgVnd+zK0p24 Oc0ZmKkwuZ3HcdGhmSyXZqEQwT5j0R+V/SmVszgjnioqAIP18r5g1Fo3B29HGCz0GqWP oY3urELMiC0svLePc0JyPn+vHcodECN3vTC+RTigjv/lOLIyKD/DZLA7fyXPlGeZn4Hg KLPdB9NnF0g5rhhT2mbLoQ7rKBrPKkSVdf5AgRNQnz8PxL670N5BCqm6HWwyB/PtM9JX 80qWJpMJioctF1w63d+gyIwgvJ0Gxp8BWBuUdjMq28PUUbp1AQIxLH0IIlc1PIm9qhde jQ7w== X-Gm-Message-State: AOAM532itKeftlXfhKq/pDQBNqp8tApoG3fXbwEK1tBipQMPHko/aQJh 8AbKnD2t4XoCVCVN8iziWgAm9A== X-Google-Smtp-Source: ABdhPJyINtEI3nSzz0ay/vase6wWA+XDS1j1/V24hIEgbqObHoCTROQExJ2ifEGydCT5glp9WAX8vw== X-Received: by 2002:a17:90a:ad48:: with SMTP id w8mr11326968pjv.48.1611227955542; Thu, 21 Jan 2021 03:19:15 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id ge16sm5827745pjb.41.2021.01.21.03.19.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:19:14 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Thierry Reding , Jonathan Hunter Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Stephen Boyd , Nishanth Menon , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: [PATCH 11/13] devfreq: tegra30: Migrate to dev_pm_opp_set_opp() Date: Thu, 21 Jan 2021 16:47:51 +0530 Message-Id: <3345fd49f7987d022f4f61edb6c44f230f7354c4.1611227342.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org dev_pm_opp_set_bw() is getting removed and dev_pm_opp_set_opp() should be used instead. Migrate to the new API. Signed-off-by: Viresh Kumar --- drivers/devfreq/tegra30-devfreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c index 117cad7968ab..d2477d7d1f66 100644 --- a/drivers/devfreq/tegra30-devfreq.c +++ b/drivers/devfreq/tegra30-devfreq.c @@ -647,7 +647,7 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq, return PTR_ERR(opp); } - ret = dev_pm_opp_set_bw(dev, opp); + ret = dev_pm_opp_set_opp(dev, opp); dev_pm_opp_put(opp); return ret; From patchwork Thu Jan 21 11:17:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035719 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C93CC433E0 for ; Thu, 21 Jan 2021 11:47:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E4E5238E2 for ; Thu, 21 Jan 2021 11:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730084AbhAULVX (ORCPT ); Thu, 21 Jan 2021 06:21:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729924AbhAULVN (ORCPT ); Thu, 21 Jan 2021 06:21:13 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0F22C0617B1 for ; Thu, 21 Jan 2021 03:19:18 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id c132so1166897pga.3 for ; Thu, 21 Jan 2021 03:19:18 -0800 (PST) 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=lxCu1KRXdVN3L+OkUbo1cLFCc74qHBWwsGsHoVvYmGQ=; b=a87cJbhAisItlTCiddZHPHEtszqt8a4bVO1biv2X4xyyxixy0vT9T72gtaa3iyj1/S 0BYSnHb7hnb7XQ1rwlEu5cBS3rWsXlBuzJ4FCOmHrteZ986iw9RUbu7t7crDd55rb+q0 KYQl0KVBN5AykV+JO3HcTaywDinFAvXk5RBBj+bYE7h3h/GJhlpuhndjXEI073NQmGYd F8sCiXjYnLCSEiHzao8Cj5NEiGNRRhnEQY8ln7F6+OXeYTrLLExrly2aWRCNqMuVgIyM o+ZW521aJNq2QMtttfOcvWZ9gEK/aMtc7HonSr2L7N/XYDiInAo5mzdEK+TIZbY9C/Xa SMRg== 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=lxCu1KRXdVN3L+OkUbo1cLFCc74qHBWwsGsHoVvYmGQ=; b=UqyYkoejCmHebJtXKFyJlsA7NESsFiCX57Bn8el+ojxreEOzjaPKFlDnsBUftzB5MO Ur+IfDTqU05RMvhop0ccXpIDzTAMJEuUUxCuy/kJ0e9gjidPTz7+tJPcVrdrb/4uJ83P ID7YcvmepzNbOtAcgqU4yl1l+aAF81TDSSWzGgYpPHp6Kq/WomiibInYqBzTrDBNTCcL /CtDgvbaOk8o+EWDwY10Mlg1ZKtMq4ghQINqykWkA9QjzQxnBlumeQvsvhsF7pA3A65v cFwdKlXo+75mDLv3yFVSWxPN6xGAEovi/oSttmeUSgO3Sv3fs+jKYdNrBfAk9yMQIkZR CF4w== X-Gm-Message-State: AOAM532/PX0ixJHyZIBjAF1j3jtKwcz5sF7j4UCm1QTBdX6g/uC3cpqO pNxBhDTjVERmo/6WJKQXmRsu5w== X-Google-Smtp-Source: ABdhPJxRoJPh+zCGLlNXEzcomeslehl5ItANfOXfCWt+o9vxW4dTT0mgqMj6QlfqpWP4MwpTT0cTAw== X-Received: by 2002:a65:4083:: with SMTP id t3mr14089089pgp.150.1611227958549; Thu, 21 Jan 2021 03:19:18 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id f36sm6098298pjk.52.2021.01.21.03.19.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:19:17 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Rob Clark , Sean Paul Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Stephen Boyd , Nishanth Menon , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH 12/13] drm: msm: Migrate to dev_pm_opp_set_opp() Date: Thu, 21 Jan 2021 16:47:52 +0530 Message-Id: <8d10f850eead0e91b1a0e20bd2ae449f4f4f8bb3.1611227342.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org dev_pm_opp_set_bw() is getting removed and dev_pm_opp_set_opp() should be used instead. Migrate to the new API. Signed-off-by: Viresh Kumar --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index e6703ae98760..05e0ef58fe32 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -134,7 +134,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp) if (!gmu->legacy) { a6xx_hfi_set_freq(gmu, perf_index); - dev_pm_opp_set_bw(&gpu->pdev->dev, opp); + dev_pm_opp_set_opp(&gpu->pdev->dev, opp); pm_runtime_put(gmu->dev); return; } @@ -158,7 +158,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp) if (ret) dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret); - dev_pm_opp_set_bw(&gpu->pdev->dev, opp); + dev_pm_opp_set_opp(&gpu->pdev->dev, opp); pm_runtime_put(gmu->dev); } @@ -866,7 +866,7 @@ static void a6xx_gmu_set_initial_bw(struct msm_gpu *gpu, struct a6xx_gmu *gmu) if (IS_ERR_OR_NULL(gpu_opp)) return; - dev_pm_opp_set_bw(&gpu->pdev->dev, gpu_opp); + dev_pm_opp_set_opp(&gpu->pdev->dev, gpu_opp); dev_pm_opp_put(gpu_opp); } @@ -1072,7 +1072,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu) a6xx_gmu_shutdown(gmu); /* Remove the bus vote */ - dev_pm_opp_set_bw(&gpu->pdev->dev, NULL); + dev_pm_opp_set_opp(&gpu->pdev->dev, NULL); /* * Make sure the GX domain is off before turning off the GMU (CX) From patchwork Thu Jan 21 11:17:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12035725 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEA76C433E0 for ; Thu, 21 Jan 2021 11:48:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5970B2395A for ; Thu, 21 Jan 2021 11:48:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729740AbhAULsK (ORCPT ); Thu, 21 Jan 2021 06:48:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729851AbhAULVM (ORCPT ); Thu, 21 Jan 2021 06:21:12 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1549EC0617BA for ; Thu, 21 Jan 2021 03:19:22 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id g15so1461707pjd.2 for ; Thu, 21 Jan 2021 03:19:22 -0800 (PST) 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=tpbd5REqcbcRMd0xcpf9T6/Cw9coNwWGEmGNqj2MIho=; b=cQ5rRy39r5+ufO+3BswxSSkFJ7+Jpm6N1g2Hni+fnN4oxrLV9pPReJ1frk5GKLuUml f+U1YMG533Xe2z8g69+kCFjMwktlTruBmh0C3cLNfwpeEOXXKu5j6AvKTUX4JExQxbtp IycMCPFvd8AB6R3DAEhE4y+LNhWYguX9xhl/bhiDNtGU+hPTm95rvzqFxoYTUl7ZArFg xQqneH2veT3wjgjuoC5folDhjA+5nktphXldfMpVgci8UVrjbj0twVuNKYpnkOxc6p2n ZODeYkUs9DjKiBV3Z+V9zOrDpDgz4n3CnatGQIqOezN3qBCn3geZ7pFlKDH83G2zIuov Gdcg== 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=tpbd5REqcbcRMd0xcpf9T6/Cw9coNwWGEmGNqj2MIho=; b=h8n2E/YzKlgpKigSS47hNDjdjUGgDFCQEx7b6EF5c96u4V7ELdmnXSDvJc3HruJSUx Ls68BPm4GZASjUrlAO7/2qxYiR8kiYx7udOdvQlB8ccrg5lIV61FZjh2oafde7EnLVqL YhJywppGWIgsjjaJeoou1kC1xxmQnl0Pf9rgUfzvDzfqYXv8xHiQRXqlyqi4nv4eC0Ku PAdXJiKyA5hs9krGHQbCKOmwJOQCTI0yJghRiarmmPQSAWpYYYwdQUUKIMevqE82Z32y PMM2Ngg3ToIE+kG6gT2Wj/B2lnK9rlmfNDAgzyiKxd0cEhxzLi9l6VJwkON4jiPppeYa OlJA== X-Gm-Message-State: AOAM532f0tAI53mKe7r8XgzH0FcFd83gOQ9PrpvZzTscXDK/7ih23F4Y 1m4krdyz33eHvhqvRKyg25tOEQ== X-Google-Smtp-Source: ABdhPJwFngayl7Kb87/6CN0WzGWc0iYnvTw6xgMXD3fCZ+Ox7Ja9cmNj8T9QjiUNNOF7BbJad6fLcA== X-Received: by 2002:a17:902:a412:b029:db:cf5a:8427 with SMTP id p18-20020a170902a412b02900dbcf5a8427mr14517166plq.48.1611227961615; Thu, 21 Jan 2021 03:19:21 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id fs21sm5401300pjb.30.2021.01.21.03.19.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:19:21 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 13/13] opp: Remove dev_pm_opp_set_bw() Date: Thu, 21 Jan 2021 16:47:53 +0530 Message-Id: <45684bf5b7b9004808d412f8d749c536970fe165.1611227342.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org All the users have migrated to dev_pm_opp_set_opp() now, get rid of the duplicate API, dev_pm_opp_set_bw(), which only performs a part of the new API. While at it, remove the unnecessary parameter to _set_opp_bw(). Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 41 +++++------------------------------------ include/linux/pm_opp.h | 6 ------ 2 files changed, 5 insertions(+), 42 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 5a367ef02b92..d8ca15d96ce9 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -798,7 +798,7 @@ static int _generic_set_opp_regulator(struct opp_table *opp_table, } static int _set_opp_bw(const struct opp_table *opp_table, - struct dev_pm_opp *opp, struct device *dev, bool remove) + struct dev_pm_opp *opp, struct device *dev) { u32 avg, peak; int i, ret; @@ -807,7 +807,7 @@ static int _set_opp_bw(const struct opp_table *opp_table, return 0; for (i = 0; i < opp_table->path_count; i++) { - if (remove) { + if (!opp) { avg = 0; peak = 0; } else { @@ -817,7 +817,7 @@ static int _set_opp_bw(const struct opp_table *opp_table, ret = icc_set_bw(opp_table->paths[i], avg, peak); if (ret) { dev_err(dev, "Failed to %s bandwidth[%d]: %d\n", - remove ? "remove" : "set", i, ret); + opp ? "set" : "remove", i, ret); return ret; } } @@ -911,37 +911,6 @@ static int _set_required_opps(struct device *dev, return ret; } -/** - * dev_pm_opp_set_bw() - sets bandwidth levels corresponding to an opp - * @dev: device for which we do this operation - * @opp: opp based on which the bandwidth levels are to be configured - * - * This configures the bandwidth to the levels specified by the OPP. However - * if the OPP specified is NULL the bandwidth levels are cleared out. - * - * Return: 0 on success or a negative error value. - */ -int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) -{ - struct opp_table *opp_table; - int ret; - - opp_table = _find_opp_table(dev); - if (IS_ERR(opp_table)) { - dev_err(dev, "%s: device opp table doesn't exist\n", __func__); - return PTR_ERR(opp_table); - } - - if (opp) - ret = _set_opp_bw(opp_table, opp, dev, false); - else - ret = _set_opp_bw(opp_table, NULL, dev, true); - - dev_pm_opp_put_opp_table(opp_table); - return ret; -} -EXPORT_SYMBOL_GPL(dev_pm_opp_set_bw); - static void _find_current_opp(struct device *dev, struct opp_table *opp_table) { struct dev_pm_opp *opp = ERR_PTR(-ENODEV); @@ -982,7 +951,7 @@ static int _disable_opp_table(struct device *dev, struct opp_table *opp_table) if (!_get_opp_count(opp_table)) return 0; - ret = _set_opp_bw(opp_table, NULL, dev, true); + ret = _set_opp_bw(opp_table, NULL, dev); if (ret) return ret; @@ -1050,7 +1019,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, } if (!ret) { - ret = _set_opp_bw(opp_table, opp, dev, false); + ret = _set_opp_bw(opp_table, opp, dev); if (!ret) { opp_table->enabled = true; dev_pm_opp_put(old_opp); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 2d8a706f8d00..891276b46e97 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -159,7 +159,6 @@ struct opp_table *devm_pm_opp_attach_genpd(struct device *dev, const char **name int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp); -int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp); int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); void dev_pm_opp_remove_table(struct device *dev); @@ -382,11 +381,6 @@ static inline int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp) return -ENOTSUPP; } -static inline int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) -{ - return -EOPNOTSUPP; -} - static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask) { return -ENOTSUPP;