Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp931711pxb; Thu, 4 Feb 2021 00:18:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkeIOIFbZAtLCLJQ8m4+1OpQdDvMeBKfm+t26v4A7vLQyrkOySR3t2xmQCrNKZxDJhDo93 X-Received: by 2002:a17:906:f6c7:: with SMTP id jo7mr7185581ejb.178.1612426719605; Thu, 04 Feb 2021 00:18:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612426719; cv=none; d=google.com; s=arc-20160816; b=TwfNKmGyAqv5+50raq1BY0YBPX4YaE5i94LbFpnYjsMRJtinvR1Obk8/AkEbjuAQnu RCqmzMsUWkjZ4QtrZZwU4uMXQM1oM28gWF4xwkXOFStiKRjImMJPx1/HFBb/S/2DNL4/ Ydvaw7ytTlJqEI1112A2xYM+ErIEhtV185K7Y6qRqR1WEDp3N4LVX2OPHGuFIw65PSWu lxw1xJhJQXz5O38DScp1AjYdV5B3AHzAAD01ZS0TZpxk5cKfb1bd0s2gG8sH7rfQbT2Y 9Se2Ok/NKkCkFrxHmE4HUd9A9zthdrY6zRG2rch2OWQ9czbMLug/F7B6RBFiJOB7zXkU PpIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BUo70dpbWZG2th1HyMSGNG98xfWBgw6XoNhP4iRnwRU=; b=za5Yx2AWYVmJNIeOiV/BvsyH9QDvIN4E1d56rAEI5jKcPKVcz7Nzj7b6uvJjBDdOUh pG+wnVvxZ3cb3F5JR3C+17FuRlfuDePl0yG1tmG4f+v27cxsSORd9CzXadU6CiW9Trto NMfiTKsTpZA7BGgNu7sUFRDQlT7PrBdRMUBOr5dU5RtJA8GPxueFeZxXqALeWhZcKboW 7kQRQjv9o9M6ZJD/DTyPZ3Qm1vFMZBih9otwtK1kZD/OoTEDlbZlU5X38rJqQN7hidvF CnS+1m7BNEFb/3LicjkWqWStW7nNhwwon/8RQC2cgJyBD1a+0mXoCG8TXudtIlwoOPV2 ciWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FlecxtCo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s10si2868636edd.231.2021.02.04.00.18.14; Thu, 04 Feb 2021 00:18:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FlecxtCo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234895AbhBDIPd (ORCPT + 99 others); Thu, 4 Feb 2021 03:15:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234881AbhBDIPS (ORCPT ); Thu, 4 Feb 2021 03:15:18 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CD2EC06178B for ; Thu, 4 Feb 2021 00:14:34 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id fa16so828554pjb.1 for ; Thu, 04 Feb 2021 00:14:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BUo70dpbWZG2th1HyMSGNG98xfWBgw6XoNhP4iRnwRU=; b=FlecxtCo1Sa+T60LAKIz04wg5u7FUSFpjvYDenVMCaVVTpYbFIQ1j7HOvvpOdOiL/K QyN3GuJ1tBXy2TswFsx8eyUT+AeSg4puA72D1LFhXYI9VR9mEbytlcrSmxSjOIJzzLPd YUikBNf0rUIs+Vd+NxiNHuKck5lXplDsXvzBE= 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=BUo70dpbWZG2th1HyMSGNG98xfWBgw6XoNhP4iRnwRU=; b=mCJ8jd36L8sB1rADdJtHot/Mb2KqvU3KMrMOZZKQ+oHtNX/klhMnYYjTZmdIyDyf7B oOwnt6uNBJa3vqqpIjjb/eP8NuIXrnl2UeK+++hTMKiucHbBgi1jL6F6NyKS9IBpRqr0 qIyPlGnc5T6fqNMXnovn9Z4+9unV6b1SXSxylvuOJ0RBIrE40O3XSriUGAU6A/DZ9yXn 9NcZjWGaT29Z7tchtqCfRDBEYsF1lmG9Hzx3lGljq1X3u3P+ADE6f8/WhnW0aqswfWwQ HDI+eEOxe/Gd8AaO6V3UPRuIxZe3lTSOwZFN7223hnvpTBqgp3FbahJSn9tnX/0uyMta X9Og== X-Gm-Message-State: AOAM531/nYRUHZFgW57XHbeSLAS47ewrhYbsc3NlrRf06L6dXrVt+EDc 3ehWyO/0p/Ds2LGzt/4Q9L4VUA== X-Received: by 2002:a17:902:ff0a:b029:e1:93ab:1e7b with SMTP id f10-20020a170902ff0ab02900e193ab1e7bmr7053319plj.61.1612426473736; Thu, 04 Feb 2021 00:14:33 -0800 (PST) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:ed70:6d43:9c6a:2e22]) by smtp.gmail.com with ESMTPSA id e3sm5091258pgs.60.2021.02.04.00.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 00:14:33 -0800 (PST) From: Hsin-Yi Wang To: Viresh Kumar , linux-pm@vger.kernel.org Cc: Nishanth Menon , Stephen Boyd , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Saravana Kannan Subject: [PATCH v6 2/3] PM / devfreq: Cache OPP table reference in devfreq Date: Thu, 4 Feb 2021 16:14:23 +0800 Message-Id: <20210204081424.2219311-3-hsinyi@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210204081424.2219311-1-hsinyi@chromium.org> References: <20210204081424.2219311-1-hsinyi@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Saravana Kannan The OPP table can be used often in devfreq. Trying to get it each time can be expensive, so cache it in the devfreq struct. Signed-off-by: Saravana Kannan Reviewed-by: Chanwoo Choi Acked-by: MyungJoo Ham Signed-off-by: Hsin-Yi Wang --- drivers/devfreq/devfreq.c | 6 ++++++ include/linux/devfreq.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 6aa10de792b33..a5899c9ae16fc 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -757,6 +757,8 @@ static void devfreq_dev_release(struct device *dev) if (devfreq->profile->exit) devfreq->profile->exit(devfreq->dev.parent); + if (devfreq->opp_table) + dev_pm_opp_put_opp_table(devfreq->opp_table); mutex_destroy(&devfreq->lock); kfree(devfreq); } @@ -844,6 +846,10 @@ struct devfreq *devfreq_add_device(struct device *dev, } devfreq->suspend_freq = dev_pm_opp_get_suspend_opp_freq(dev); + devfreq->opp_table = dev_pm_opp_get_opp_table(dev); + if (IS_ERR(devfreq->opp_table)) + devfreq->opp_table = NULL; + atomic_set(&devfreq->suspend_count, 0); dev_set_name(&devfreq->dev, "%s", dev_name(dev)); diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index b6d3bae1c74d8..26ea0850be9bb 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -137,6 +137,7 @@ struct devfreq_stats { * using devfreq. * @profile: device-specific devfreq profile * @governor: method how to choose frequency based on the usage. + * @opp_table: Reference to OPP table of dev.parent, if one exists. * @nb: notifier block used to notify devfreq object that it should * reevaluate operable frequencies. Devfreq users may use * devfreq.nb to the corresponding register notifier call chain. @@ -173,6 +174,7 @@ struct devfreq { struct device dev; struct devfreq_dev_profile *profile; const struct devfreq_governor *governor; + struct opp_table *opp_table; struct notifier_block nb; struct delayed_work work; -- 2.30.0.365.g02bc693789-goog