Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1306761imu; Wed, 16 Jan 2019 16:52:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN7bozd3rePsVg1dwgMnDmCHX/jxDPu7rZf1YRa0hZp4rrYvOWGdn8XaYHItpNzF/3OnRUJR X-Received: by 2002:a17:902:9006:: with SMTP id a6mr12667273plp.334.1547686355051; Wed, 16 Jan 2019 16:52:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547686355; cv=none; d=google.com; s=arc-20160816; b=pY1n2CrByGPr9+lsaXqobMJjgYExX4o06XR/H1x2s16BPmp1m2wT/6SIcpoVc44kgl fInI9etZ5e7JgU4GPB8Rd6sFPpc0YKK1m78hJjmGsHoxN2TaNVRa33EwyZMuTFZu/ukR Xo5oseiil1TzU2v80nzN+vuMMxfmEMysT9ClQxQZB2yL4OcbA369kygsYa+WMe80CyMU ruz+EV6wtMTtaSjMC9ZRFBTMS43ZSgxu81cHqkN2rc8XQQIU8qUBNf7xHg0fto3+kNGf U7M3OWVdWWEkSsM2jBpBYncK7elvy7lVxZK95l526rUN8Sz3lEcK+MWHZtbQcYmcuXZf Ek7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BQK1HkmJgwC0vvBDHXL1Lh2aGTGgND6t33rbirqJAU4=; b=B90y39VQsUCs7G+NU3HstGrXPw4Z5+Z3HB/5F88KphMAnFMOYHe+vABnxTj2gw2UAK B0wUzaVnfFMQXEZsZURs81SK/dXgO5xMWUhnQVpRSkDhI0pFhY4EAgvDrjlgGP4aJ7zG bCvonmfInwG3m8a8i6MslyAH5DpuGtPVfB1b9cvCwMBZqnC1W57zzCulmnV7E4FDE3ME mUcngWPX7HTAxD5DIYpALxR6/oi8Z+TlL7XVF713gejeVu/9GFhNAeZNCKpknG10XNWC q9zn/B3A/mji9jD7piQRBIC18SyboVyLh60EjYIx+6FFKMhtDb5psI1w1wj/5AKzDEu6 4XZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f82si8043222pfa.221.2019.01.16.16.52.16; Wed, 16 Jan 2019 16:52:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731648AbfAPXEO (ORCPT + 99 others); Wed, 16 Jan 2019 18:04:14 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:47190 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729036AbfAPXEA (ORCPT ); Wed, 16 Jan 2019 18:04:00 -0500 Received: from 79.184.255.239.ipv4.supernova.orange.pl (79.184.255.239) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.183) id aa233e5c9ecb1854; Thu, 17 Jan 2019 00:03:55 +0100 From: "Rafael J. Wysocki" To: Amit Kucheria Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, viresh.kumar@linaro.org, edubezval@gmail.com, swboyd@chromium.org, dianders@chromium.org, mka@chromium.org, linux-pm@vger.kernel.org Subject: Re: [PATCH v1 02/10] cpufreq: Add a flag to auto-register a cooling device Date: Thu, 17 Jan 2019 00:03:03 +0100 Message-ID: <15792961.Mmjk2FNQN5@aspire.rjw.lan> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, January 14, 2019 5:34:54 PM CET Amit Kucheria wrote: > All cpufreq drivers do similar things to register as a cooling device. > Provide a cpufreq driver flag so drivers can just ask the cpufreq core > to register the cooling device on their behalf. This allows us to get > rid of duplicated code in the drivers. > > Suggested-by: Stephen Boyd > Suggested-by: Viresh Kumar > Signed-off-by: Amit Kucheria > --- > drivers/cpufreq/cpufreq.c | 17 +++++++++++++++++ > include/linux/cpufreq.h | 6 ++++++ > 2 files changed, 23 insertions(+) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 6f23ebb395f1..cd6e750d3d82 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > > static LIST_HEAD(cpufreq_policy_list); > > @@ -1318,6 +1319,14 @@ static int cpufreq_online(unsigned int cpu) > if (cpufreq_driver->ready) > cpufreq_driver->ready(policy); > > +#ifdef CONFIG_CPU_THERMAL > + if (cpufreq_driver->flags & CPUFREQ_AUTO_REGISTER_COOLING_DEV) { > + struct thermal_cooling_device **cdev = &policy->cooldev; > + > + *cdev = of_cpufreq_cooling_register(policy); What would be wrong with policy->cooldev = of_cpufreq_cooling_register(policy); > + } > +#endif Please remove the #ifdefs from cpufreq_online() and cpufreq_offline(). Use wrappers that would become empty stubs for CONFIG_CPU_THERMAL unset. > + > pr_debug("initialization complete\n"); > > return 0; > @@ -1411,6 +1420,14 @@ static int cpufreq_offline(unsigned int cpu) > if (has_target()) > cpufreq_exit_governor(policy); > > +#ifdef CONFIG_CPU_THERMAL > + if (cpufreq_driver->flags & CPUFREQ_AUTO_REGISTER_COOLING_DEV) { > + struct thermal_cooling_device **cdev = &policy->cooldev; > + > + cpufreq_cooling_unregister(*cdev); Again, why don't you simply pass policy->cooldev here? Also, would it make sense to clear policy->cooldev at this point? It points to freed memory after cpufreq_cooling_unregister(). > + } > +#endif > + > /* > * Perform the ->exit() even during light-weight tear-down, > * since this is a core component, and is essential for the > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > index 7d0cf54125fa..70ad02088825 100644 > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -390,6 +390,12 @@ struct cpufreq_driver { > */ > #define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING (1 << 6) > > +/* > + * Set by drivers that want the core to automatically register the cpufreq > + * driver as a thermal cooling device > + */ > +#define CPUFREQ_AUTO_REGISTER_COOLING_DEV (1 << 7) > + > int cpufreq_register_driver(struct cpufreq_driver *driver_data); > int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); > >