From patchwork Thu Feb 4 08:14:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 376631 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=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 A2BF7C433E0 for ; Thu, 4 Feb 2021 08:15:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62DDF64F7C for ; Thu, 4 Feb 2021 08:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234886AbhBDIPT (ORCPT ); Thu, 4 Feb 2021 03:15:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234877AbhBDIPS (ORCPT ); Thu, 4 Feb 2021 03:15:18 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BE61C06178A for ; Thu, 4 Feb 2021 00:14:34 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id s24so1259722pjp.5 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=lGBO/9cydRkCToKD8UcOiorRDOn3sjBNU1b+Zz+t1/fTakgNe6co3zHIrElOcZxgyd 3/J+O3R9cz+AoyUU4k8XfO8vkyrxyGLpGuXhSXBXkc0swuqTYDkpKflromkpvy8t36d6 YfHE+My/a15dTTw2wiVq66wpkf3LWLlbMqgV8s+VsHnW3vgNXKrBgBCB99HPrTcCPddR nIfI2X03Je83Gnf7W58e2BXCSxfIZNwiHqq9SpAqMp7OHVCXPzPeUJRZ7FGUCrToOoQN 2NsuJJ5G3LIahKhmw02g7Flub5EqMwzrzGBF5ydUKoTUYUnk5j1h69CvoyAwJaaIa0Gh S80A== X-Gm-Message-State: AOAM533awXE3N4WA1ESASz06psb79IeuoqPxo5NBKDZ0meRmsrEfpLFo xdtdmvcbKO5/31DOk9FM/ofwJY1i4PmDxQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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;