From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 9AA4EC433DB for ; Thu, 4 Feb 2021 08:15:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E30664F60 for ; Thu, 4 Feb 2021 08:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234900AbhBDIPl (ORCPT ); Thu, 4 Feb 2021 03:15:41 -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-Google-Smtp-Source: ABdhPJyLVYwTNg/1U1PuYTKS194UmkYqIiYCE7tXra2V9O4uvRFIUJrdzMjGLzfJLUnJ8pgOSeYavA== 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