From patchwork Mon Jan 18 00:55:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026065 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 ADBBCC433E0 for ; Mon, 18 Jan 2021 00:56:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E97F2250F for ; Mon, 18 Jan 2021 00:56:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730132AbhARA40 (ORCPT ); Sun, 17 Jan 2021 19:56:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730234AbhARA4R (ORCPT ); Sun, 17 Jan 2021 19:56:17 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53774C061574; Sun, 17 Jan 2021 16:55:37 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id x20so21600566lfe.12; Sun, 17 Jan 2021 16:55:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+a0TnX2ybR+9zT3v5f4ICq5eAhyFrIALU+uTlPBGTCA=; b=CtxxSCvcUvDVc5k8siym1L1Xn7APGDTcrMhrLOFN2UQetgZ7xyxXaxg6eSSHZsKb8A 6Ccdfc6/+YOSmbJZnNxiLBfBZP4ZEOjIUtrPVZKe9qcKvL1dbJf/hX9DZjhqbr/7c+TD ePsSN9B7c6DQmA2m25xvJCJEFYn//ffKWLDM6dW/fhyWTkSdV3PhVEvXy+7YJRjvdrck KLpCWaSmYbL1SbHtXrUGpm5k2KriF8Gj62xST9Q69wUDWxrKAHSoqRLZCUP6sUAjTz56 dpTIFnodEmHhGVF57TBBGf2ZGt2lC+ZW3PO+pdbe5UURg/2IuG16m28h+oOVAT/sou5i YcbA== 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=+a0TnX2ybR+9zT3v5f4ICq5eAhyFrIALU+uTlPBGTCA=; b=Ux+4C/Jc4/LHXrIs5DEKkKauUG1SgQsmK6rH/Ljrh5a0NbKO0sS4aqJpEobaJF0met nj8L3DhfOHOAIazkRka3CNabUKKk0JnkuYZ1r9CjvbpXGfxi5taZuyykvfy/Ijb8sy6B G5oc8Dqa7F8PgXtxHWoZAgUcTT0Y1GDqS/20LKZf/lJliyDIBUoFoiVmalfAT/2JWN0H mQzrDpHxU+Imsq8DV8r4xqahPCOjhmWBtwKHHv1N5JGSUVZAc2mqBTGwGc8LHsiNXHKE bplmIw2vvoi3NIOE+X9PtOnoWIuxTxL0yRVisB0AAviG9eM8fX6LuhyhgSOHqzVu/sdv rVnA== X-Gm-Message-State: AOAM530TouF9+g7Skrswpby8TKVX556Qk1NzubSRgwxVH/poZXIVpKlY DaoXPXP+ketIcmXeYegCgPUfD+dbHf8= X-Google-Smtp-Source: ABdhPJx5WCEh/lj3K7rWyUD+Rzb3nCDmTazV0J0o5LiH8805KR36AAf7zFIST3A2ciVyrfS08FtVPg== X-Received: by 2002:a19:7507:: with SMTP id y7mr8737220lfe.554.1610931335896; Sun, 17 Jan 2021 16:55:35 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:35 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 01/12] opp: Fix adding OPP entries in a wrong order if rate is unavailable Date: Mon, 18 Jan 2021 03:55:13 +0300 Message-Id: <20210118005524.27787-2-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Fix adding OPP entries in a wrong (opposite) order if OPP rate is unavailable. The OPP comparison was erroneously skipped, thus OPPs were left unsorted. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Tested-by: Matt Merhar Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index dfc4208d3f87..48618ff3e99e 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1527,12 +1527,10 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, mutex_lock(&opp_table->lock); head = &opp_table->opp_list; - if (likely(!rate_not_available)) { - ret = _opp_is_duplicate(dev, new_opp, opp_table, &head); - if (ret) { - mutex_unlock(&opp_table->lock); - return ret; - } + ret = _opp_is_duplicate(dev, new_opp, opp_table, &head); + if (ret) { + mutex_unlock(&opp_table->lock); + return ret; } list_add(&new_opp->node, head); From patchwork Mon Jan 18 00:55:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026067 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 DCEFEC43381 for ; Mon, 18 Jan 2021 00:56:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB0302245C for ; Mon, 18 Jan 2021 00:56:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729629AbhARA4Z (ORCPT ); Sun, 17 Jan 2021 19:56:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730236AbhARA4S (ORCPT ); Sun, 17 Jan 2021 19:56:18 -0500 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 4463BC061575; Sun, 17 Jan 2021 16:55:38 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id o13so21663619lfr.3; Sun, 17 Jan 2021 16:55:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rAaB+AsgYLTzk06vBkAuHfvf1ltC1dHjM1bYPxIHb7s=; b=J8mEDAPD0EcjLZcMHcAbJjC9hcLy2rm3SN4E+ax3mPVISyzsIvu2oyAzOXKm+OsYsR xlDG8twVdSdGLBsJiNT7uZajZpf587v+kNzZLHB9tvKO6/WRp4DQGIwArMIdPo6QUdMV 2SCzwCcA5MTFmI5moEAfwhi1XBcJTFCfLdBh4K8Sk+gccojEoqtNmfbBQB3/Pnb+c45T THHS0M8lZMUxc64y+gDzpUpE85XH+WRsvev62fe2JiXOBPLzSaAtXUXcZLfROF2GUgh6 Eaoj9kwThdJzSS7N39fznjc4eZhqKY/Uogu4SkqjPP6fs83Fwxyj5XI8EZK98SmlIylW GDsA== 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=rAaB+AsgYLTzk06vBkAuHfvf1ltC1dHjM1bYPxIHb7s=; b=g0Kzq3kWOUQH4buMYazb9GcgcRhtg8/gxEe5thz/8wazTuvOd8pbcKr6UeR7YTBDQa 1S6L5NeJDjXsjdwgFXenq6RkbM4HjeSWjp7mVwZkMHdP9dM/DXc+B3Zwq60q5p+312wi fbcOlYUQz78NH6IIUfu/zHMZ3M4DA2hJ0pZbwKXL5+y6mmK76XAC66YIuHNNkdJEVe34 DSaZs0UgkGGHR5Nnawm56DyblglyilSPXRNJAAJ4d//nbVs9kAQcaViTfnEQBnq6ldfP dfkt7o9PrbJu2ozHnNzyUqZF3Fujdj4r3ZhjfYwiX+aDA0t16CN66iEBMal5IGGQt6I8 u1zQ== X-Gm-Message-State: AOAM531Rdtbi2nWf3gQVjcHoFCADnXzuozzhFTqGnjV3HClBVrCT9h34 ofiWYKZp7QAmkNKX9mepSJs= X-Google-Smtp-Source: ABdhPJw12X/R94f7RMUuVxwu0L5qc00LFbojuOSNdaocbFYaM6tX343QCGjKtw2Pd3f4sYOjm5O9Jw== X-Received: by 2002:a19:c001:: with SMTP id q1mr9766157lff.55.1610931336835; Sun, 17 Jan 2021 16:55:36 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:36 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 02/12] opp: Filter out OPPs based on availability of a required-OPP Date: Mon, 18 Jan 2021 03:55:14 +0300 Message-Id: <20210118005524.27787-3-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org A required OPP may not be available, and thus, all OPPs which are using this required OPP should be unavailable too. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Tested-by: Matt Merhar Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 48618ff3e99e..7b4d07279638 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1522,6 +1522,7 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *opp_table, bool rate_not_available) { struct list_head *head; + unsigned int i; int ret; mutex_lock(&opp_table->lock); @@ -1547,6 +1548,16 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, __func__, new_opp->rate); } + for (i = 0; i < opp_table->required_opp_count; i++) { + if (new_opp->required_opps[i]->available) + continue; + + new_opp->available = false; + dev_warn(dev, "%s: OPP not supported by required OPP %pOF (%lu)\n", + __func__, new_opp->required_opps[i]->np, new_opp->rate); + break; + } + return 0; } From patchwork Mon Jan 18 00:55:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026071 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 2351DC433DB for ; Mon, 18 Jan 2021 00:57:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBE192256F for ; Mon, 18 Jan 2021 00:57:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730324AbhARA4w (ORCPT ); Sun, 17 Jan 2021 19:56:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730186AbhARA4T (ORCPT ); Sun, 17 Jan 2021 19:56:19 -0500 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42253C061757; Sun, 17 Jan 2021 16:55:39 -0800 (PST) Received: by mail-lj1-x22a.google.com with SMTP id n8so7709970ljg.3; Sun, 17 Jan 2021 16:55:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oWDHn2kHepqBlhfwoh/fWAV+Z/o0dseWB+wQwSbUTtY=; b=mzEe1X1FOiyM2KN66Sqw8MM4IaAXnqe/GZ80PpC1BblpLlCv2w4uE5Mb/pMIIGoh3P BXqvFO9fuGnLsxJuwyFmtyHbekfZbeRTw4C24K4tp0LUcQXo4UZByKtdlf3unsj/LcLq Y7QPHiMyGihaWZJn/MmNAArw8Ej9PH02ZvD0vFxqyaPAx7FO/5UtlhXJGG9+GhbG8Y2Z s4IVr9huD7p0gBcPt6HwQZBQ8rTzefpi/xtzCOA5o5BbHGbHJhMFPMmRcpVyruLq5Chb IeSJSwpQ89/PRIRjzPY1BcnM/ZRkGaiIAVV3+Nakj8WTuXv2bAe3W7v7FuvicN2k95k6 8ayQ== 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=oWDHn2kHepqBlhfwoh/fWAV+Z/o0dseWB+wQwSbUTtY=; b=HFplaadYI4fy9SNYIjlz+P8/o2Yxq4iOPof2dwxFh0q6feTcryzbXWqCxXBPRR5Pgs YiSV3Cb1Ivv3vNgNdeKKzdp0L15y0gJrWDIs5KdgXNjBaAeSuV6wgJjr9p+jOZbZmsPt OLHVTZLzGhTlKQI/vWGxg/phXwxwUr/GIL67XPwpKlrhlAwPvVS7raawOskUGkWg/Oz+ SssLLuiTnJMKxkDJd0GI6jX0ThQ52bV2db6SJKzgV4WbK1kdih35hNtRDU/DG8MAuNTH rYXuVg9Lje2J7duvtnAAhxXXO/DLUQoWyVE/EP2x/atnUr8qYZUTohrwsByr6GFFpYQ/ MFLg== X-Gm-Message-State: AOAM532qWQ8ecgV3uuXu5dHa1OcYfH32pJ3LQR1Owqi0CvMAAeUmvFSz QSxeSwQRobV+S070eQlG2OU= X-Google-Smtp-Source: ABdhPJy+hz3BIUUk1wNYjcQ0h/81YCFl5L/xhHLYcQJRmIeC49DpfG8263aOYLk7r+GHlmSiKHkxTg== X-Received: by 2002:a05:651c:2005:: with SMTP id s5mr9014741ljo.152.1610931337792; Sun, 17 Jan 2021 16:55:37 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:37 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 03/12] opp: Correct debug message in _opp_add_static_v2() Date: Mon, 18 Jan 2021 03:55:15 +0300 Message-Id: <20210118005524.27787-4-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The debug message always prints rate=0 instead of a proper value, fix it. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Tested-by: Matt Merhar Signed-off-by: Dmitry Osipenko --- drivers/opp/of.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 50df483c7dc3..63b16cdba5ea 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -755,7 +755,6 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, struct device *dev, struct device_node *np) { struct dev_pm_opp *new_opp; - u64 rate = 0; u32 val; int ret; bool rate_not_available = false; @@ -772,7 +771,8 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, /* Check if the OPP supports hardware's hierarchy of versions or not */ if (!_opp_is_supported(dev, opp_table, np)) { - dev_dbg(dev, "OPP not supported by hardware: %llu\n", rate); + dev_dbg(dev, "OPP not supported by hardware: %lu\n", + new_opp->rate); goto free_opp; } From patchwork Mon Jan 18 00:55:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026069 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=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, 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 CC1A6C433E0 for ; Mon, 18 Jan 2021 00:56:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A24BC20758 for ; Mon, 18 Jan 2021 00:56:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730355AbhARA4f (ORCPT ); Sun, 17 Jan 2021 19:56:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730258AbhARA4U (ORCPT ); Sun, 17 Jan 2021 19:56:20 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20D98C0613C1; Sun, 17 Jan 2021 16:55:40 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id o13so21663708lfr.3; Sun, 17 Jan 2021 16:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ORGCA2NNYd6672ynomRyYjTRM+EXXCwELHNI7EanuCU=; b=pN9Mjcz0nokQWkTvVfz5+Lt8ICl1kGOENr5AdsNb5nYEy+cYI29WvO/meLDMeXjM/F Z/IvMq03D3bXqal8c246kwJ/I+Ut6Y4FNjBZ0Fq/4z+xOIhM/72sPt+kTtYmPR9+mP1v J/59PY0byw7OoPppfK35xDgCm/r6KOZ4QLAlrefk4dl8/Y3dJaAOT4z2A72zJsE63czq t4NzHv6tJlZaBr7m2HoGlLRwr4FLslBNvyBAmV6OHl8sooCnlMxd9KfOjkfoO+GpsOWY al79hbQGZD8QxjDPUB8y9ZTDT8H4+drv/yFf2RWnb/+UleSq4FIhZvuDRR1Hjoq+9i7G FiyA== 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=ORGCA2NNYd6672ynomRyYjTRM+EXXCwELHNI7EanuCU=; b=pS1B58/gHEZSt9e6oAJutX+nUDp0RT2QNkHSmQvW9WtB+tBkXwSAg5RyOSx429m5Pg LeVWdbdZBm/CjByOY5i7iKBz2cm8dHKs1WRuX8Hl39T6Vz6weYrgeEw49n4mSW+PLIbK Zea04ulfs+oZJ/9+FC1luDvcPEGidD+7WfeCumhGhgJndPHYXDBI7ZRwe0lk6FqmB99v 2cIWSo8r9F+BOMMO2+7zr8L82WMh0C4uR47V2FHJAt8Bdejd12edwtBpR5BdED6KZQds dyha/WrAVx1Z/YAZNCjo6TU7wYvPgoMaAceYn8iSM643nxwkfCc/Armoe/avSv29AEOI yg3g== X-Gm-Message-State: AOAM530iR18J2+KgJYNTg+lnaQgYFRS9WBOIx3vSLq/CmE793oxtjCfb OVp5IQPMfLjirVdXy8L/oYQ= X-Google-Smtp-Source: ABdhPJxMSTh9dMUpjPVmeMl/WvlsAqwhhMIuN747VN0oDre3vhFgUw/zEZw8Jd31NCMx+KK/qnnQQQ== X-Received: by 2002:ac2:5ec1:: with SMTP id d1mr9620671lfq.589.1610931338709; Sun, 17 Jan 2021 16:55:38 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:38 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 04/12] opp: Add dev_pm_opp_sync_regulators() Date: Mon, 18 Jan 2021 03:55:16 +0300 Message-Id: <20210118005524.27787-5-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Extend OPP API with dev_pm_opp_sync_regulators() function, which syncs voltage state of regulators. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Tested-by: Matt Merhar Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 45 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 51 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 7b4d07279638..99d18befc209 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2686,3 +2686,48 @@ void dev_pm_opp_remove_table(struct device *dev) dev_pm_opp_put_opp_table(opp_table); } EXPORT_SYMBOL_GPL(dev_pm_opp_remove_table); + +/** + * dev_pm_opp_sync_regulators() - Sync state of voltage regulators + * @dev: device for which we do this operation + * + * Sync voltage state of the OPP table regulators. + * + * Return: 0 on success or a negative error value. + */ +int dev_pm_opp_sync_regulators(struct device *dev) +{ + struct opp_table *opp_table; + struct regulator *reg; + int i, ret = 0; + + /* Device may not have OPP table */ + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) + return 0; + + /* Regulator may not be required for the device */ + if (!opp_table->regulators) + goto put_table; + + mutex_lock(&opp_table->lock); + + /* Nothing to sync if voltage wasn't changed */ + if (!opp_table->enabled) + goto unlock; + + for (i = 0; i < opp_table->regulator_count; i++) { + reg = opp_table->regulators[i]; + ret = regulator_sync_voltage(reg); + if (ret) + break; + } +unlock: + mutex_unlock(&opp_table->lock); +put_table: + /* Drop reference taken by _find_opp_table() */ + dev_pm_opp_put_opp_table(opp_table); + + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_sync_regulators); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index c24bd34339d7..1c3a09cc8dcd 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -162,6 +162,7 @@ int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cp int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); void dev_pm_opp_remove_table(struct device *dev); void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask); +int dev_pm_opp_sync_regulators(struct device *dev); #else static inline struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) { @@ -398,6 +399,11 @@ static inline void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask { } +static inline int dev_pm_opp_sync_regulators(struct device *dev) +{ + return -ENOTSUPP; +} + #endif /* CONFIG_PM_OPP */ #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) From patchwork Mon Jan 18 00:55:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026077 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 42461C433DB for ; Mon, 18 Jan 2021 01:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00F9820758 for ; Mon, 18 Jan 2021 01:04:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730466AbhARA5J (ORCPT ); Sun, 17 Jan 2021 19:57:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730400AbhARA5C (ORCPT ); Sun, 17 Jan 2021 19:57:02 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1006DC0613CF; Sun, 17 Jan 2021 16:55:41 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id o19so21662780lfo.1; Sun, 17 Jan 2021 16:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sBN+qDoZ+2xkp7oR26gY6Zqd1Sn2t+N/0CHYfu4wuTs=; b=N0kolekTv77LULSo5h6UrdruKTf1gLmyDoikAjHTHvjvlGzKnBG70ARv3fuLhBY164 2VEgD1/OEx/MBrvW9vhJ46zvVywamJBUQrGKbCXVa1obaxq8HsxMjLZri8mGU0EF/542 VUwmJ0Vr9Ji1kpXYQhkZs8WzOM8aCsLB78OrlJxx7P8KxF5R4z+y/oBsn1fhDuX7qvhr 1Ks13u1w3TzEZhUsnbXL6/YGAD7l4+okG5WAaHDSWkjHF+0cI8H8Z+Powu+5yv61WvJZ /F9bxBRuvFCrHRd3v3YorqJSZa6INnexi2Mu1WOPn4Rw9ppIrxJAdlhYxU6UuE3JJXNZ JFxA== 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=sBN+qDoZ+2xkp7oR26gY6Zqd1Sn2t+N/0CHYfu4wuTs=; b=HOU7/f1oNe8jXS4MlWdkrJYpdalyWN6BCw9hcUqE55f8pVtL3ZZjVTFMn6qrr5oipg 7RKwUoW/TEIF2cXx2S6+uxGPMIHt9pTKcBXPZRayLBVSnEC+QlueCCd3dN47bSzJwDbe kpDAoclol2tsaSdMpZ2Buqs8spfTRFe6bgMndING2l8EytTLHpqZsw6RE4X05Su8JV9F DeX0iranEzAjmgdjajfylSzJ3K2TUW2jLSWM4zHh6/lFcBZbcqwjKrscF30plovRv7I4 BJAqbTjj+0gxYtKOlHm3l/4u5D77TLxrI/rn3LUaySD8PeQqhjpksAVI8okJfEI9kEy/ L+Dg== X-Gm-Message-State: AOAM532M5n3Y+p5ir1ReXZ0XzTkhGD6bl9I1wRL7xvv+Y9KgIiSazRnu UkeDJcwH7FdGw/FFIbLCYH6XloWLyXE= X-Google-Smtp-Source: ABdhPJwxl910tMjxSVp26/+RBgN0gD4sr24MoLEbRgE8/1QfcPtpCWGwLKnAJsKiMRA4dczyQbE+mw== X-Received: by 2002:ac2:5201:: with SMTP id a1mr8388633lfl.515.1610931339627; Sun, 17 Jan 2021 16:55:39 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:39 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 05/12] opp: Add dev_pm_opp_set_voltage() Date: Mon, 18 Jan 2021 03:55:17 +0300 Message-Id: <20210118005524.27787-6-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add dev_pm_opp_set_voltage() which allows OPP table users to set voltage in accordance to a given OPP. In particular this is needed for driving voltage of a generic power domain which uses OPPs and doesn't have a clock. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Tested-by: Matt Merhar Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 55 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 +++++ 2 files changed, 61 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 99d18befc209..341484d58e6c 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2731,3 +2731,58 @@ int dev_pm_opp_sync_regulators(struct device *dev) return ret; } EXPORT_SYMBOL_GPL(dev_pm_opp_sync_regulators); + +/** + * dev_pm_opp_set_voltage() - Change voltage of regulators + * @dev: device for which we do this operation + * @opp: opp based on which the voltages are to be configured + * + * Change voltage of the OPP table regulators. + * + * Return: 0 on success or a negative error value. + */ +int dev_pm_opp_set_voltage(struct device *dev, struct dev_pm_opp *opp) +{ + struct opp_table *opp_table; + struct regulator *reg; + int ret = 0; + + /* Device may not have OPP table */ + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) + return 0; + + /* Regulator may not be required for the device */ + if (!opp_table->regulators) + goto put_table; + + /* This function only supports single regulator per device */ + if (WARN_ON(opp_table->regulator_count > 1)) { + dev_err(dev, "multiple regulators are not supported\n"); + ret = -EINVAL; + goto put_table; + } + + mutex_lock(&opp_table->lock); + + reg = opp_table->regulators[0]; + ret = _set_opp_voltage(dev, reg, opp->supplies); + + if (!opp_table->enabled) { + ret = regulator_enable(reg); + if (ret < 0) { + dev_warn(dev, "Failed to enable regulator: %d", ret); + goto unlock; + } + + opp_table->enabled = true; + } +unlock: + mutex_unlock(&opp_table->lock); +put_table: + /* Drop reference taken by _find_opp_table() */ + dev_pm_opp_put_opp_table(opp_table); + + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_set_voltage); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 1c3a09cc8dcd..f344be844bde 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -163,6 +163,7 @@ int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) void dev_pm_opp_remove_table(struct device *dev); void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask); int dev_pm_opp_sync_regulators(struct device *dev); +int dev_pm_opp_set_voltage(struct device *dev, struct dev_pm_opp *opp); #else static inline struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) { @@ -404,6 +405,11 @@ static inline int dev_pm_opp_sync_regulators(struct device *dev) return -ENOTSUPP; } +static inline int dev_pm_opp_set_voltage(struct device *dev, struct dev_pm_opp *opp) +{ + return -ENOTSUPP; +} + #endif /* CONFIG_PM_OPP */ #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) From patchwork Mon Jan 18 00:55:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026075 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 7C4D2C433DB for ; Mon, 18 Jan 2021 00:58:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 425352250F for ; Mon, 18 Jan 2021 00:58:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730487AbhARA5N (ORCPT ); Sun, 17 Jan 2021 19:57:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730408AbhARA5C (ORCPT ); Sun, 17 Jan 2021 19:57:02 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01CA0C0613D3; Sun, 17 Jan 2021 16:55:42 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id h205so21609486lfd.5; Sun, 17 Jan 2021 16:55:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jRak0qcqqausNC3NGuy0ldW/i7K4KUMaot2CO2ZPoQ0=; b=lOxmMs0fqu7dVZvkuoJjfriNTe8c/8xjGC1MS5KGI8dd4cb0OrYRLx0sZjDokLaOWk E4s0TG8ODa8TPN1+rsTxxprtHy/M8ooXQkh5JmJsGOb8VOCXXqckAH/p7LitYoewVb+Y 05rXkUK7UAp2oftsYc5nP8GTb2ReEPPiNo8hg3NlAUKdwzrnFuhbmB4wARYhPJGWCFtE iHV1mxMs2m58FJkEHlZ25o8EoAfIgDIPAn76ubde5oNoBXu7tQNL3eS1SqMLVpJyKULg abugoTWTn4ftiS8cL3k0oNcF4RpH237b68fd9bHokhWKtHy0+6tujondOQ3NmaeXOAg0 Ge3A== 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=jRak0qcqqausNC3NGuy0ldW/i7K4KUMaot2CO2ZPoQ0=; b=SCNqfdANDpsZFSyyZ31cx3Dixl9INlkCqbFPh6CKCGOKy+S5ma9XuLGY/tqOT1UyuE DauHiXdAIPqFtk900QQkqyue3PwAgzlO9TtFaA4gMf+UqyWNnkk1c2vlcVp02JAir3/Z 2QwwpS//Ed7Ch0/nACYKZ+irG5HQIdewrdhWYIc7ocBIP6T2jnTuIQ6p1b+6XH/UYl+0 UpNs59/yJ0i1ihuHk1AW4eXQb6GbAZIepSXHjyKaq+kuBcsk2F6gdeaM8vQWdrJXa4Ur KC7zdoFQesLkM+ICN8QsZVo/TqjSOKDKduYPeeB83MJkceNRcEwGrMqg+ScUV/vfKJ0D LbsA== X-Gm-Message-State: AOAM530ln5pG3WwIJ/JWAre8l8KIGbEbnC7CVQCB6XwHfRj3pPJGUmnp maGzyIbcHIBwogYwBkQSF3U= X-Google-Smtp-Source: ABdhPJywi9C7D5cjHUIqLpL2/PD7TA/ggulSm5IBkDuPAlvT/JZ2mdGO2c8E6bK6smkdYH7D6qg2CA== X-Received: by 2002:a05:6512:68d:: with SMTP id t13mr8416239lfe.472.1610931340575; Sun, 17 Jan 2021 16:55:40 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:40 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 06/12] opp: Add dev_pm_opp_find_level_ceil() Date: Mon, 18 Jan 2021 03:55:18 +0300 Message-Id: <20210118005524.27787-7-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add a ceil version of the dev_pm_opp_find_level(). It's handy to have if levels don't start from 0 in OPP table and zero usually means a minimal level. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Tested-by: Matt Merhar Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 49 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 8 +++++++ 2 files changed, 57 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 341484d58e6c..df0969002555 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -449,6 +449,55 @@ struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, } EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_exact); +/** + * dev_pm_opp_find_level_ceil() - search for an rounded up level + * @dev: device for which we do this operation + * @level: level to search for + * + * Return: Searches for rounded up match in the opp table and returns pointer + * to the matching opp if found, else returns ERR_PTR in case of error and + * should be handled using IS_ERR. Error return values can be: + * EINVAL: for bad pointer + * ERANGE: no match found for search + * ENODEV: if device not found in list of registered devices + * + * The callers are required to call dev_pm_opp_put() for the returned OPP after + * use. + */ +struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev, + unsigned int *level) +{ + struct opp_table *opp_table; + struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); + + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) { + int r = PTR_ERR(opp_table); + + dev_err(dev, "%s: OPP table not found (%d)\n", __func__, r); + return ERR_PTR(r); + } + + mutex_lock(&opp_table->lock); + + list_for_each_entry(temp_opp, &opp_table->opp_list, node) { + if (temp_opp->available && temp_opp->level >= *level) { + opp = temp_opp; + *level = opp->level; + + /* Increment the reference count of OPP */ + dev_pm_opp_get(opp); + break; + } + } + + mutex_unlock(&opp_table->lock); + dev_pm_opp_put_opp_table(opp_table); + + return opp; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_ceil); + static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table, unsigned long *freq) { diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index f344be844bde..b7dc993487c7 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -111,6 +111,8 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, bool available); struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, unsigned int level); +struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev, + unsigned int *level); struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, unsigned long *freq); @@ -234,6 +236,12 @@ static inline struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, return ERR_PTR(-ENOTSUPP); } +static inline struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev, + unsigned int *level) +{ + return ERR_PTR(-ENOTSUPP); +} + static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, unsigned long *freq) { From patchwork Mon Jan 18 00:55:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026087 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 80FD5C43381 for ; Mon, 18 Jan 2021 01:05:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5711720759 for ; Mon, 18 Jan 2021 01:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730797AbhARBF1 (ORCPT ); Sun, 17 Jan 2021 20:05:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730435AbhARA5E (ORCPT ); Sun, 17 Jan 2021 19:57:04 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09141C0613D6; Sun, 17 Jan 2021 16:55:43 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id 23so21606921lfg.10; Sun, 17 Jan 2021 16:55:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d8BYKrVjCHK2ATkUn9Bn3mODsj1VGuehzu+tpszr3yE=; b=RVZ6+QUecC4p1baC6nkw1UzPNHHeQQMMmFiEOBBXGz1hfh/BWaj0eD2AY+hfFcsBM2 uzfzOk/00N+NJataeb92ZCWAbHC9a5wJ/4sj3KsMyFKIptEEhSQOjv36HLUjsw6mw9uE gadSVo7rh9cuTbwNPKOnZR78leJuri0vgA8F2N0n8lWhFC7rF1kMv4d7uvmYpQyDoNFe mtsfXXNkXwmh4WIvmWmgBio0u4vr/awNFzT5P6Rd1Xly6GAyVTN5y9NiA9Y5HB7Wv/Z7 +L0PgnjEnuVhZWwlPG8N+hIJfAGlv4lCGmZU0qHyaE8taXV9HofVPrueJr0HbgMEGMwV w4Xw== 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=d8BYKrVjCHK2ATkUn9Bn3mODsj1VGuehzu+tpszr3yE=; b=Wp9kBDnjlDJbvMbZPJMEQ+acij6uGOL/T+QQooRm+oZrIa9P2VzFnBqNhl94f3Oc6s cZlfyVT8t6VKdtL4GJY9gSIyH/JTwTHaqElMrBRPFIAfcYIq2WHbKm4GJB6kRQcK5fHM Cdt5tewCLQir4a2NDIqpEqQ8el7HOsRuH7kCgflE+JlO2xeoBoyEEDLZRJgtbg+ztFIl gW5gLacmMtmjiqO5GOgvOMyk0S0jb70wJYrGNdaEUOHS4qujxWJSbUafyql8+B+kXs+I Bu6MnM+Px1qK/IfIAavFg7D9MoA3clSMA13MCdcMQ0dmXAqKhDnLHAGqebfFfaMlW/XV dhFg== X-Gm-Message-State: AOAM5303NvpmrDAV0+qui1/8HKuXRKfB14ScLhKOl3RIsrobcdCpNjZG uitN17zjBXOJCsrs6aZU0bM= X-Google-Smtp-Source: ABdhPJxkBnLKRUA5i2l0ufZhrcFnHI8gJ0IfG7hUjISt1Y5rErImhyYEtzRaG3xwQVMO5IZkDjePMA== X-Received: by 2002:a19:6901:: with SMTP id e1mr9465665lfc.461.1610931341578; Sun, 17 Jan 2021 16:55:41 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:41 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 07/12] opp: Add dev_pm_opp_get_required_pstate() Date: Mon, 18 Jan 2021 03:55:19 +0300 Message-Id: <20210118005524.27787-8-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add dev_pm_opp_get_required_pstate() which allows OPP users to retrieve required performance state of a given OPP. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Tested-by: Matt Merhar Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 22 ++++++++++++++++++++++ include/linux/pm_opp.h | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index df0969002555..fde2ec00ab0e 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -145,6 +145,28 @@ unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_level); +/** + * dev_pm_opp_get_required_pstate() - Gets the required performance state + * corresponding to an available opp + * @opp: opp for which performance state has to be returned for + * @index: index of the required opp + * + * Return: performance state read from device tree corresponding to the + * required opp, else return 0. + */ +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index) +{ + if (IS_ERR_OR_NULL(opp) || !opp->available || + index >= opp->opp_table->required_opp_count) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + return opp->required_opps[index]->pstate; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_required_pstate); + /** * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not * @opp: opp for which turbo mode is being verified diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index b7dc993487c7..e072148ae0e1 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -98,6 +98,9 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index); + bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); int dev_pm_opp_get_opp_count(struct device *dev); @@ -194,6 +197,13 @@ static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) return 0; } +static inline +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index) +{ + return 0; +} + static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) { return false; From patchwork Mon Jan 18 00:55:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026089 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 C408AC433E9 for ; Mon, 18 Jan 2021 01:05:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E33E207AE for ; Mon, 18 Jan 2021 01:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730539AbhARBF0 (ORCPT ); Sun, 17 Jan 2021 20:05:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730433AbhARA5E (ORCPT ); Sun, 17 Jan 2021 19:57:04 -0500 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 DE51CC0613ED; Sun, 17 Jan 2021 16:55:43 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id o13so21663816lfr.3; Sun, 17 Jan 2021 16:55:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vgDoSUPRoPUFpDdr936+57Rv3VyE6xZwg/R405Zj7FM=; b=Q9Xr1KYDDf/wQO0QAAoJdCsR2X3CU7X12Zn+9x7ok8bjlryXvSfBcnYhXSGFpEjT/B nDqZ6GJkMxI8xISHL/hgL9NIDd+mI7Lv+cPCvTPFQwPfOcZsmDKiPAk0njQJyGJTqSA8 MlsZtl7ST3Wj/kG9MNcptgsppWrwLTRsEEZsmApI0JimIQoGoOrI/KL3spNwUAdVyMTn 1OqS/98Hg8uVZIKW0nuwpSQh7rly8krNrgY4RjNORxzmsQFgEfMZGMlESAUqBRB0XpW7 UshUuvEtwfV7valYKFBhg18jtXBcOkMIu99RrZWqHhCxlpXHGv+d/h3LYmYgt6RUndGj U5VQ== 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=vgDoSUPRoPUFpDdr936+57Rv3VyE6xZwg/R405Zj7FM=; b=HUBqg7V+b8IqLvuwJC633ZsV/ID6nRUwxevu/CDaymfM2O94+sKNdwMclIljClnoHY hR6g+qQCdBQ56AuftQAhn+yRtvy9EU4Nuu7aMpqKYYa5oeZ3EvLuY3eA6K0UDbzp6cvI G/Qunpfm8tpDNaXXb1OYzJt9iWEewgLw2aiAkAdxpbIj3vz8XeD0nK54b+zUwhmnnWMq ueKXvXH0ZoCe5xojpXgbbDPVzq6Hh2zbJDCtYB9FyK7hjUXRKl8bKnZz3qMpDVOuIMJC I8jB3RUzIGZZfjK83NG7pDwnHaQLeN7qUn286W4jvEWy5NSo9UrAsp6Yq9ANcKRiBUHH cywg== X-Gm-Message-State: AOAM531iBOTfLZdWYzFBuNKbR3+6+8F7bcBRzbJwyC00k3ByUxPLEIF9 KeV/KM9alwNh9A9zs3Rub3s= X-Google-Smtp-Source: ABdhPJyVyFQhDEzOgofsjcTMdMzB3JK/5khRhA4EtPdSZyVBvc2EQbXNf/IfFQoYpIg2bvHagCpgag== X-Received: by 2002:a19:6459:: with SMTP id b25mr9607365lfj.635.1610931342481; Sun, 17 Jan 2021 16:55:42 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:42 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 08/12] opp: Add devm_pm_opp_register_set_opp_helper Date: Mon, 18 Jan 2021 03:55:20 +0300 Message-Id: <20210118005524.27787-9-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add resource-managed version of dev_pm_opp_register_set_opp_helper(). Tested-by: Peter Geis Tested-by: Nicolas Chauvet Tested-by: Matt Merhar Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 8 ++++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index fde2ec00ab0e..8e0d2193fd5f 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2857,3 +2857,37 @@ int dev_pm_opp_set_voltage(struct device *dev, struct dev_pm_opp *opp) return ret; } EXPORT_SYMBOL_GPL(dev_pm_opp_set_voltage); + +static void devm_pm_opp_unregister_set_opp_helper(void *data) +{ + dev_pm_opp_unregister_set_opp_helper(data); +} + +/** + * devm_pm_opp_register_set_opp_helper() - Register custom set OPP helper + * @dev: Device for which the helper is getting registered. + * @set_opp: Custom set OPP helper. + * + * This is a resource-managed version of dev_pm_opp_register_set_opp_helper(). + * + * Return: pointer to 'struct opp_table' on success and errorno otherwise. + */ +struct opp_table * +devm_pm_opp_register_set_opp_helper(struct device *dev, + int (*set_opp)(struct dev_pm_set_opp_data *data)) +{ + struct opp_table *opp_table; + int err; + + opp_table = dev_pm_opp_register_set_opp_helper(dev, set_opp); + if (IS_ERR(opp_table)) + return opp_table; + + err = devm_add_action_or_reset(dev, devm_pm_opp_unregister_set_opp_helper, + opp_table); + if (err) + return ERR_PTR(err); + + return opp_table; +} +EXPORT_SYMBOL_GPL(devm_pm_opp_register_set_opp_helper); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index e072148ae0e1..6de5853aaada 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -169,6 +169,7 @@ void dev_pm_opp_remove_table(struct device *dev); void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask); int dev_pm_opp_sync_regulators(struct device *dev); int dev_pm_opp_set_voltage(struct device *dev, struct dev_pm_opp *opp); +struct opp_table *devm_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)); #else static inline struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) { @@ -428,6 +429,13 @@ static inline int dev_pm_opp_set_voltage(struct device *dev, struct dev_pm_opp * return -ENOTSUPP; } +static inline struct opp_table * +devm_pm_opp_register_set_opp_helper(struct device *dev, + int (*set_opp)(struct dev_pm_set_opp_data *data)) +{ + return ERR_PTR(-ENOTSUPP); +} + #endif /* CONFIG_PM_OPP */ #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) From patchwork Mon Jan 18 00:55:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026081 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 BD45CC4332D for ; Mon, 18 Jan 2021 01:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8430B2250F for ; Mon, 18 Jan 2021 01:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730620AbhARBDt (ORCPT ); Sun, 17 Jan 2021 20:03:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730436AbhARA5E (ORCPT ); Sun, 17 Jan 2021 19:57:04 -0500 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 C93B3C061786; Sun, 17 Jan 2021 16:55:44 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id m25so21599203lfc.11; Sun, 17 Jan 2021 16:55:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QLPIfKPwYX5SNI2taLqEpDVVxuBGhm+P/85rwSfPkA8=; b=NLXB4ayekAjXRjsu8jPpTl41qXyhkUxkvb9o9/yqhHOEvKgQLslVlGJTIkcv43BLPo ckHAExViue2jU8DBzie491RWKnMhqsXdxS/tDTZFx7xVk/k19DCpdQlaHfuJxmXLOpSc YBwjBXA+lsfIwLDjyPvGlefi1VSwyManWxk8a8Zmr1luEFR4xjvf7lus6NkMwC2U9CPX f6XJ380gSwfeXvIGk0xlB90wG82wDFtwr9ep+4SNtUrodQrRXq4l0ZmTw8dAW0IHokTh 7LfFYxibouKAHxYMZu8BQqEJ+x7Oi5ytajf/nTVjyafFf8YYMZP98bM1Z9v9fPEKaBvx mJkg== 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=QLPIfKPwYX5SNI2taLqEpDVVxuBGhm+P/85rwSfPkA8=; b=lge/uy+7m9Rey0rinBnAnqCt8/4ZPq+wHkoasRBr7+eEzOOFeYurnzN3Qt1PV1xTiw g7Enj4Z4M2cYtpY3xm8cPO/o4yVeLLOFLTMg+7xFWZhrMaX2GoO5VQiLJ4BLFXFKXN5y 8sigVrRHaP0DsrmAucKob1N0XAG9BmVPdLPVqIb+6YyPyRxcn9LDz9RX393evsOHuUgS 7t4G33z0tZGlZ+jBp4cM0JBBR+2iCXQCQmgblT9xR8p4b/VOpzfY7LYYa8zfD5106QoW JTUfQKG4obLsaaAteC8bz3Yq4yYbOKuSJaEVjw9n8RfB7xC/km+AEQdRmo0xIrI27KIz cFyg== X-Gm-Message-State: AOAM530UBmROfCX2ARtpVVgHHxUCpJTuq4RC581Ci8v404TWzxmxsJZ1 Vm67R/fsktwwt7P8h+ZjQ8I= X-Google-Smtp-Source: ABdhPJycsd/DptfAMvflHjHcqyL5YTSyHEYOaBxhLvtXy18zfMIe8CFN1aBbB4IBWFgNf3huq4l9+A== X-Received: by 2002:a19:651a:: with SMTP id z26mr9970794lfb.306.1610931343400; Sun, 17 Jan 2021 16:55:43 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:43 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 09/12] opp: Add devm_pm_opp_attach_genpd Date: Mon, 18 Jan 2021 03:55:21 +0300 Message-Id: <20210118005524.27787-10-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add resource-managed version of dev_pm_opp_attach_genpd(). Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 8 ++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 8e0d2193fd5f..49419ab9fbb4 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2891,3 +2891,38 @@ devm_pm_opp_register_set_opp_helper(struct device *dev, return opp_table; } EXPORT_SYMBOL_GPL(devm_pm_opp_register_set_opp_helper); + +static void devm_pm_opp_detach_genpd(void *data) +{ + dev_pm_opp_detach_genpd(data); +} + +/** + * devm_pm_opp_attach_genpd - Attach genpd(s) for the device and save virtual device pointer + * @dev: Consumer device for which the genpd is getting attached. + * @names: Null terminated array of pointers containing names of genpd to attach. + * @virt_devs: Pointer to return the array of virtual devices. + * + * This is a resource-managed version of dev_pm_opp_attach_genpd(). + * + * Return: pointer to 'struct opp_table' on success and errorno otherwise. + */ +struct opp_table * +devm_pm_opp_attach_genpd(struct device *dev, const char **names, + struct device ***virt_devs) +{ + struct opp_table *opp_table; + int err; + + opp_table = dev_pm_opp_attach_genpd(dev, names, virt_devs); + if (IS_ERR(opp_table)) + return opp_table; + + err = devm_add_action_or_reset(dev, devm_pm_opp_detach_genpd, + opp_table); + if (err) + return ERR_PTR(err); + + return opp_table; +} +EXPORT_SYMBOL_GPL(devm_pm_opp_attach_genpd); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 6de5853aaada..eefd0b15890c 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -170,6 +170,7 @@ void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask); int dev_pm_opp_sync_regulators(struct device *dev); int dev_pm_opp_set_voltage(struct device *dev, struct dev_pm_opp *opp); struct opp_table *devm_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)); +struct opp_table *devm_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs); #else static inline struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) { @@ -436,6 +437,13 @@ devm_pm_opp_register_set_opp_helper(struct device *dev, return ERR_PTR(-ENOTSUPP); } +static inline struct opp_table * +devm_pm_opp_attach_genpd(struct device *dev, const char **names, + struct device ***virt_devs) +{ + return ERR_PTR(-ENOTSUPP); +} + #endif /* CONFIG_PM_OPP */ #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) From patchwork Mon Jan 18 00:55:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026083 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 76D83C433E9 for ; Mon, 18 Jan 2021 01:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A81622510 for ; Mon, 18 Jan 2021 01:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730575AbhARBDs (ORCPT ); Sun, 17 Jan 2021 20:03:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730443AbhARA5E (ORCPT ); Sun, 17 Jan 2021 19:57:04 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0757C061793; Sun, 17 Jan 2021 16:55:45 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id o17so21664235lfg.4; Sun, 17 Jan 2021 16:55:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O6f4AT9gcxWNNircaoBevbJDLZI+952qLRubU5cLyss=; b=eSKqqMSDOvQeXnobkQTCgrR4K2CZ2qceg2wO0+KgZiE9NZwyAabQTo7cKFt5QD/+rj r0UB73EjUhG9ytlcmcq8aUzsOJaNOmKeGWOqsC4eD1nBJt6ZkghcH1rFhd1AHTMkNSrN HHVQAkgS5c4VOJzjtFwfyvlb4dPKcTRBvWSm3bRIoA7SRIvs7FW1xFTa/duWQjoTkjhT xnpcO0qMZtFYarPZP5pfgOoTR94neVNrPBgadF7uUxlhVdHitqTSLoqW6ShQjJKPj61N CBLlSK75GcyD11Az914vVo55RVYkkup3XwsAZsyAeYo7RO6Ip6dPNLY35l7EhXe8iUU3 K5MA== 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=O6f4AT9gcxWNNircaoBevbJDLZI+952qLRubU5cLyss=; b=pn3TZeICaer9vbuD5t/1FmPyOrBIeQrOr1kVHDsZ72TIJOTC7TlWA+1N9oli2QLNTw FgSgMJFIoMyFjwJCFGBJTmqb5/tH7VnIlwEJJau6bzyjI5Ysju6KaR4PlqAJYItbTzXb L0uA13KRmFBwa6U1zaUz0PWrkc69Cgf+IoWgl+ouEf2ZtCPfhxHOr5aYrA79KXwz3AdF 7NdCaCsECeWFFLGgRq9Vf5Ik8apLjIOO2FCWRhbJjbB1lej3/Dvl+iXraxYkqMIQ5epT 8cds7Wk2p2XRtiTVY7+iqIE37AAjExLIAznKCFRFDzDR/IaK8xdx4l2nMyn7GP7tzmQv 5Unw== X-Gm-Message-State: AOAM530njvXUVaQJStx6iGvGamr04VWTJSv7dvHjN+qbTMPYJeN+YRzl PZuUxt21PAiT/hSx+lnSQBk= X-Google-Smtp-Source: ABdhPJz4crxlKxPiY08WnbMui0nzQ9K9CkptpbVwjYoxsedY3zylazSoo5E3coxlZPp9Za84mixEoQ== X-Received: by 2002:a19:810:: with SMTP id 16mr10532223lfi.233.1610931344312; Sun, 17 Jan 2021 16:55:44 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:43 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 10/12] opp: Support set_opp() customization without requiring to use regulators Date: Mon, 18 Jan 2021 03:55:22 +0300 Message-Id: <20210118005524.27787-11-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Support set_opp() customization without requiring to use regulators. This is needed by drivers which want to use dev_pm_opp_set_rate() for changing rates of a multiple clocks and don't need to touch regulator. One example is NVIDIA Tegra30/114 SoCs which have two sibling 3D hardware units which should be use to the same clock rate, meanwhile voltage scaling is done using a power domain. In this case OPP table doesn't have a regulator, causing a NULL dereference in _set_opp_custom(). Tested-by: Peter Geis Tested-by: Nicolas Chauvet Tested-by: Matt Merhar Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 46 +++++++++++++++++++++++++++++++++++------- include/linux/pm_opp.h | 3 +++ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 49419ab9fbb4..7726c4c40b53 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -829,16 +829,21 @@ static int _set_opp_custom(const struct opp_table *opp_table, struct dev_pm_opp_supply *new_supply) { struct dev_pm_set_opp_data *data; - int size; + int size, count; + + if (opp_table->regulators) + count = opp_table->regulator_count; + else + count = 0; data = opp_table->set_opp_data; data->regulators = opp_table->regulators; - data->regulator_count = opp_table->regulator_count; + data->regulator_count = count; data->clk = opp_table->clk; data->dev = dev; data->old_opp.rate = old_freq; - size = sizeof(*old_supply) * opp_table->regulator_count; + size = sizeof(*old_supply) * count; if (!old_supply) memset(data->old_opp.supplies, 0, size); else @@ -1860,8 +1865,14 @@ static int _allocate_set_opp_data(struct opp_table *opp_table) struct dev_pm_set_opp_data *data; int len, count = opp_table->regulator_count; - if (WARN_ON(!opp_table->regulators)) - return -EINVAL; + /* just bump the refcount if already allocated */ + if (opp_table->set_opp_data) { + kref_get(&opp_table->set_opp_data->kref); + return 0; + } + + /* allocate maximum number of regulators, for simplicity */ + count = max(count, 1); /* space for set_opp_data */ len = sizeof(*data); @@ -1873,6 +1884,7 @@ static int _allocate_set_opp_data(struct opp_table *opp_table) if (!data) return -ENOMEM; + kref_init(&data->kref); data->old_opp.supplies = (void *)(data + 1); data->new_opp.supplies = data->old_opp.supplies + count; @@ -1881,10 +1893,17 @@ static int _allocate_set_opp_data(struct opp_table *opp_table) return 0; } +static void _release_set_opp_data(struct kref *kref) +{ + kfree(container_of(kref, struct dev_pm_set_opp_data, kref)); +} + static void _free_set_opp_data(struct opp_table *opp_table) { - kfree(opp_table->set_opp_data); - opp_table->set_opp_data = NULL; + struct dev_pm_set_opp_data *data = opp_table->set_opp_data; + + if (kref_put(&data->kref, _release_set_opp_data)) + opp_table->set_opp_data = NULL; } /** @@ -2182,6 +2201,7 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)) { struct opp_table *opp_table; + int ret; if (!set_opp) return ERR_PTR(-EINVAL); @@ -2196,11 +2216,21 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, return ERR_PTR(-EBUSY); } + /* Allocate block to pass to set_opp() routines */ + ret = _allocate_set_opp_data(opp_table); + if (ret) + goto err; + /* Another CPU that shares the OPP table has set the helper ? */ if (!opp_table->set_opp) opp_table->set_opp = set_opp; return opp_table; + +err: + dev_pm_opp_put_opp_table(opp_table); + + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(dev_pm_opp_register_set_opp_helper); @@ -2219,6 +2249,8 @@ void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table) /* Make sure there are no concurrent readers while updating opp_table */ WARN_ON(!list_empty(&opp_table->opp_list)); + _free_set_opp_data(opp_table); + opp_table->set_opp = NULL; dev_pm_opp_put_opp_table(opp_table); } diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index eefd0b15890c..c98fd2add563 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -13,6 +13,7 @@ #include #include +#include #include struct clk; @@ -74,6 +75,7 @@ struct dev_pm_opp_info { * @regulator_count: Number of regulators * @clk: Pointer to clk * @dev: Pointer to the struct device + * @kref: Reference counter * * This structure contains all information required for setting an OPP. */ @@ -85,6 +87,7 @@ struct dev_pm_set_opp_data { unsigned int regulator_count; struct clk *clk; struct device *dev; + struct kref kref; }; #if defined(CONFIG_PM_OPP) From patchwork Mon Jan 18 00:55:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026079 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 5EA67C433E6 for ; Mon, 18 Jan 2021 01:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C6F12250F for ; Mon, 18 Jan 2021 01:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730501AbhARBDr (ORCPT ); Sun, 17 Jan 2021 20:03:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730474AbhARA5L (ORCPT ); Sun, 17 Jan 2021 19:57:11 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4E32C061794; Sun, 17 Jan 2021 16:55:46 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id v67so21647376lfa.0; Sun, 17 Jan 2021 16:55:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eyHjrNQl/VVrQYVoDFRcSB8NEQfl0N78N+dBhjN9Zys=; b=psNQNKmUoSfKuU+xSOgLca9Qq1fOHDpSogTRlMAdEzHSCYtMqCY7Ix6sBrZp25T3nX Dv6Ij+JIUWFT3VT8YH0wwz6Kzf5D3336nOxrSt6jLTFH9Oc5XCKfB+lpjAIk+GI35272 GuB51X14qvv1Zzjd0ZvmGKlyKYEucxnfEvuHD8oQ3Hsr3CMJYGqY9+tfe99QikHpO2Nk rdb5ZIVU1X0FyIf/2Bs0YNSfAzz2PyBlxy9n5ncmbk8BtENuhRVks1fyxw93xCIA06zO NQmQhnHHbH7k8UwCCwqnQqiZOm2pijSAsehsRTQ6xXBZy8t4rNU7eajHsFY8HTWCokcu 0bgA== 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=eyHjrNQl/VVrQYVoDFRcSB8NEQfl0N78N+dBhjN9Zys=; b=bVVD7i42hMHyienreAsGpkaxDIJsnwAe1M6WyMcGHTpLS5SowhlCsJnIScJthGc3X2 H2muwkbfg4taraQiq8hxMO2rzyBp9eX9iBgbm2jjo7uK6YCHERQiNA81bbz8GwDJxaEC tYZFmZvFpY4/wz10Ixlcip93CP5g9wdrGCW7MP4WUwRxjd65XAY060Zv7Zv9vyrU/KvW lotNDDSZlDgr6mrFzvkW4JUZ2kOQOkUXMFGJ7kZYC+JNLDRm8/GHJ3uNwU1U5ExrWu93 C1yZIq97qBdvU4U3y25GUOZ57aCHl3ra+IWpYjQ4SyVVKPRBcB2yPTBnXOePQTnYcPqt r+Iw== X-Gm-Message-State: AOAM533LGoVmiJsUA8i1bAohofTscw5ysug6IK3GhNexe76I8nLpzEvK xn9XhS3nbYbb3+G64ieJYRU= X-Google-Smtp-Source: ABdhPJxpt1/bY2Bpgu/+DdlT0QMvUKw1/40EKNh5JrhRE+VL03Op2xfEkTbvFrbVfBuPFYtUSjFmkw== X-Received: by 2002:ac2:5e2a:: with SMTP id o10mr10371041lfg.481.1610931345348; Sun, 17 Jan 2021 16:55:45 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:44 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 11/12] opp: Handle missing OPP table in dev_pm_opp_xlate_performance_state() Date: Mon, 18 Jan 2021 03:55:23 +0300 Message-Id: <20210118005524.27787-12-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org NVIDIA Tegra SoCs have a power domains topology such that child domains only clamp a power rail, while parent domain controls shared performance state of the multiple child domains. In this case child's domain doesn't need to have OPP table. Hence we want to allow children power domains to pass performance state to the parent domain if child's domain doesn't have OPP table. The dev_pm_opp_xlate_performance_state() gets src_table=NULL if a child power domain doesn't have OPP table and in this case we should pass the performance state to the parent domain. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Tested-by: Matt Merhar Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 7726c4c40b53..ca8c6acc29f4 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2419,7 +2419,7 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, * and so none of them have the "required-opps" property set. Return the * pstate of the src_table as it is in such cases. */ - if (!src_table->required_opp_count) + if (!src_table || !src_table->required_opp_count) return pstate; for (i = 0; i < src_table->required_opp_count; i++) { From patchwork Mon Jan 18 00:55:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12026085 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 E92FDC433E0 for ; Mon, 18 Jan 2021 01:04:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C26922137B for ; Mon, 18 Jan 2021 01:04:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729919AbhARBDq (ORCPT ); Sun, 17 Jan 2021 20:03:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730472AbhARA5L (ORCPT ); Sun, 17 Jan 2021 19:57:11 -0500 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B18D1C061795; Sun, 17 Jan 2021 16:55:47 -0800 (PST) Received: by mail-lj1-x22b.google.com with SMTP id w26so16519202ljo.4; Sun, 17 Jan 2021 16:55:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DilXPRI3TRJmzULgddpAwxGtKs9uc5bXa700Snpt8eg=; b=jkazrJTlp36hPiUFrC7+kV3l/6K9OcH+n0l0ToQZJatwEfH45vuOuQHKdbSx5Agt/m Zkx4gfKuxm8joxqX1fCVKjv7tfssLoyYjVBzVbctl4sHyY31hy2etFKh5TVmGHunzGVI wPoW89LcSShSPDDGOzHRofjldjka5fVLPMgggkwnu1crxdMRmSPz8+dz2F4YrHWV2RrJ jCeJtjFJV+hsdcu0GYJJYVIBKfiiKP4ggQ0wjotl4yJ1RhXZEuWz7fmiQlkPh4hkgIwV /gD6sxhVwLpG9Sq+P0k6ktUIuGfpb1HLxo129X+uf5ZDsRhPvKjZQKfkTICNf9HtvS0R hK8w== 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=DilXPRI3TRJmzULgddpAwxGtKs9uc5bXa700Snpt8eg=; b=YejkF1/uF7f5rPtNmCHgCRruilv7dIfoQP0fODcbnbKZJKfccrV9dvxoCuK2pgx7hD /o4AqqTefUQIg27O19FYvBU9jVGO2ku5D6aOmQ4OGgSJatFdkUggOI7Ep+wtq7Z1tXRk lVMwTQPQPuFaKOfSsTS6HtCfpo3kotzadMW4KrxN6553/SC83WWqEF+VMTLcAJ+oAfNB MeyLg8aE5W4Nfs8T2IecvGIzRD1sP4k1FwUq7nzdKZhRUg86XyUFPdJLByHwH9neewpG Jh9mXSoN9T/1FP4pGAyUHD8bsDbjv4TMm4jXbLjFd5qHf0RzyfQ8lhtBuo5y3DKoja2r uSDw== X-Gm-Message-State: AOAM531yrYcu1sFMV1B44rv5e3BMCdEPq9TQywIgIHh+gokh92aci7QK qyvHQ4w6YAZ9HVCbsFFzL5Fv2+Wcjps= X-Google-Smtp-Source: ABdhPJwJPyNTEMevAfSEECE2toaXbJUsIn96iIntXcmUHGkNfR12JhXMpsdGv6/2GG1f0eSXZU1wzA== X-Received: by 2002:a2e:9497:: with SMTP id c23mr9805613ljh.362.1610931346276; Sun, 17 Jan 2021 16:55:46 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id m24sm1484553ljj.62.2021.01.17.16.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 16:55:45 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Peter Geis , Nicolas Chauvet , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Nishanth Menon , Yangtao Li , Matt Merhar Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 12/12] opp: Print OPP level in debug message of _opp_add_static_v2() Date: Mon, 18 Jan 2021 03:55:24 +0300 Message-Id: <20210118005524.27787-13-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118005524.27787-1-digetx@gmail.com> References: <20210118005524.27787-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Print OPP level in debug message of _opp_add_static_v2(). This helps to chase GENPD bugs. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Tested-by: Matt Merhar Signed-off-by: Dmitry Osipenko --- drivers/opp/of.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 63b16cdba5ea..758730d070da 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -822,10 +822,11 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, if (new_opp->clock_latency_ns > opp_table->clock_latency_ns_max) opp_table->clock_latency_ns_max = new_opp->clock_latency_ns; - pr_debug("%s: turbo:%d rate:%lu uv:%lu uvmin:%lu uvmax:%lu latency:%lu\n", + pr_debug("%s: turbo:%d rate:%lu uv:%lu uvmin:%lu uvmax:%lu latency:%lu level:%u\n", __func__, new_opp->turbo, new_opp->rate, new_opp->supplies[0].u_volt, new_opp->supplies[0].u_volt_min, - new_opp->supplies[0].u_volt_max, new_opp->clock_latency_ns); + new_opp->supplies[0].u_volt_max, new_opp->clock_latency_ns, + new_opp->level); /* * Notify the changes in the availability of the operable