Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp299984imu; Fri, 25 Jan 2019 02:32:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN41btBM/P2prpFqhnNv4o7GBenGtAKyRQQAntc/wVU0p99fbygCUjrA/8vu7/Eb0dRJzBEd X-Received: by 2002:a62:3a04:: with SMTP id h4mr10320930pfa.119.1548412342294; Fri, 25 Jan 2019 02:32:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548412342; cv=none; d=google.com; s=arc-20160816; b=C7WWTKLtN34YG6vqiOocBu2pSScU0A3SHoFVWUvJGiZE2tvF9dE3WGS/W6eoUf6WRq 8esbE/JiynoEHueCKOWxnsbsfdEC+nXE3e+X6zEMrs8Mxj8KP4sTRfXA/BoXDDHsAjYT m5l5gtzRqNv+kOpYAyAIJF/g6S8R7j0kxJrmOCmJhcs2GiUNpiWR2f7MnIxrOVc13P7c wS9PDcmmfYsokL70n+Om5uSTVSsUZJ4I5bwQNcHA7MitRykbfSX6uEfDrj6LcRbSp6pA ARVDnTlKisCbPm5Rw2QQ4hC7P3dmZ5QDGaZvtujNR1rlAQ5h9XX0AHFnY/UT65HOB87w gwtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xV+tXi79UeoN9cizkihtQQPtSlmF7btX28r8UdCBuWA=; b=CPWc3C63nnkrswSrdasqU/IyCrHalt+yEi+gOGjzaMXKOeC6r248b3tUiqH+mq2G7U /WUc8cfwmwV2dLMdMlGgxe3spAIgkgfjf18SM6wZ2U4tucQ3kFww4CW2c1PjFRyTfFcq dKvXnlztLO868YcIKXCfMQuzh12m2oKj25nRC1PlgA2xc7OCy4/hCD4Y/dzPDElpBjqV AzOz1oKB5jgzg9fWhuRGE5AlAtwzjesWJyXSDOrqVtOJZMCd1Td89LZQ4W5/pkhlMm1F Icl52cB3/l5VletjbileVUKVV93T3Fy8DS025G8/vJM3Im7NLj0Gyo3qAs9PIH5y0vLK 0ooA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SoOpm/OG"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g83si25906484pfb.278.2019.01.25.02.32.06; Fri, 25 Jan 2019 02:32:22 -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; dkim=pass header.i=@linaro.org header.s=google header.b="SoOpm/OG"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727781AbfAYKb5 (ORCPT + 99 others); Fri, 25 Jan 2019 05:31:57 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46433 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbfAYKb5 (ORCPT ); Fri, 25 Jan 2019 05:31:57 -0500 Received: by mail-pg1-f196.google.com with SMTP id w7so4039186pgp.13 for ; Fri, 25 Jan 2019 02:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xV+tXi79UeoN9cizkihtQQPtSlmF7btX28r8UdCBuWA=; b=SoOpm/OGfS6HsgV+Dg2Z7/mvSD2gJVhgg7o+UQYQNu5jByf1egOFJAbhvuNVQIgfbl 64UCyEgQkslEc8+nwkIwmYn/+Q2RhOC+/ViPwwKksBv1IBuP5KIsHSSZIO43fCRa/IdG 1dOUi0lryaAChK3spMzg0qeYyIxQnk4jVlrZs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xV+tXi79UeoN9cizkihtQQPtSlmF7btX28r8UdCBuWA=; b=cTTa7aKO3P0WFt8BZiD41Vc79RIGmgzDoN+vaOj8qjO1FPtuvGODif3czaeQNCdt4k 950QdUIkTPmMoFieUOYVPuZlR9xKR1Mz4WQK18duTDk4oxzrVXdxT1xn+WlhTttuqXFD 6dmIGSi3YubK3Cy0uvbylCQ6K+1AkKgsenAJVbnEfRCYxEZ7fejmDrva5jlRlTK5/xHv U+0ql+NyvGrixQLD1wLK1kxWZYYgehh1McA9BubfUHCn6bNsDl+rzbzOp246XvN9q+H+ Cj9I1qKXEIgzVoay/EFyaRO/xF3t/WG23PsNADWuD0KipyAfJQ+yX3pPs62htB07WQO9 SDHQ== X-Gm-Message-State: AJcUukcz3wB45fcs2/uA/jHaGlsGSdVXVbrc/5r6kuO6P8kZfmjDhJBL owl+Ke+UeZOvEvdG1A9qHGSo0g== X-Received: by 2002:a63:4706:: with SMTP id u6mr8943388pga.95.1548412316064; Fri, 25 Jan 2019 02:31:56 -0800 (PST) Received: from localhost ([122.172.102.63]) by smtp.gmail.com with ESMTPSA id k129sm31057848pgk.29.2019.01.25.02.31.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jan 2019 02:31:54 -0800 (PST) Date: Fri, 25 Jan 2019 16:01:52 +0530 From: Viresh Kumar To: Amit Kucheria Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, edubezval@gmail.com, swboyd@chromium.org, dianders@chromium.org, mka@chromium.org, "Rafael J. Wysocki" , "open list:CPU FREQUENCY SCALING FRAMEWORK" Subject: Re: [PATCHv3 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked Message-ID: <20190125103152.7svjfmowgigznipm@vireshk-i7> References: <73e091e2d56d9fa6eb94feaed9fc2be30bf6da20.1548398851.git.amit.kucheria@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <73e091e2d56d9fa6eb94feaed9fc2be30bf6da20.1548398851.git.amit.kucheria@linaro.org> User-Agent: NeoMutt/20180323-120-3dd1ac Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25-01-19, 12:32, 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. > > In order to allow this, we add a struct thermal_cooling_device pointer > to struct cpufreq_policy so that drivers don't need to store it in a > private data structure. > > Suggested-by: Stephen Boyd > Suggested-by: Viresh Kumar > Signed-off-by: Amit Kucheria > Reviewed-by: Matthias Kaehlcke > Tested-by: Matthias Kaehlcke > --- > drivers/cpufreq/cpufreq.c | 6 ++++++ > include/linux/cpufreq.h | 21 +++++++++++++++++++++ > 2 files changed, 27 insertions(+) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index e35a886e00bc..cf1be057caf4 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -1318,6 +1318,9 @@ static int cpufreq_online(unsigned int cpu) > if (cpufreq_driver->ready) > cpufreq_driver->ready(policy); > > + if (cpufreq_driver->flags & CPUFREQ_AUTO_REGISTER_COOLING_DEV) > + register_cooling_device(policy); > + > pr_debug("initialization complete\n"); > > return 0; > @@ -1405,6 +1408,9 @@ static int cpufreq_offline(unsigned int cpu) > goto unlock; > } > > + if (cpufreq_driver->flags & CPUFREQ_AUTO_REGISTER_COOLING_DEV) > + unregister_cooling_device(policy); > + > if (cpufreq_driver->stop_cpu) > cpufreq_driver->stop_cpu(policy); > > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > index bd7fbd6a4478..c7eb59b8ce94 100644 > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -13,6 +13,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -151,6 +152,9 @@ struct cpufreq_policy { > > /* For cpufreq driver's internal use */ > void *driver_data; > + > + /* Pointer to the cooling device if used for thermal mitigation */ > + struct thermal_cooling_device *cdev; > }; > > /* Only for ACPI */ > @@ -386,6 +390,12 @@ struct cpufreq_driver { > */ > #define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING BIT(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 BIT(7) > + > int cpufreq_register_driver(struct cpufreq_driver *driver_data); > int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); > > @@ -415,6 +425,17 @@ cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy) > policy->cpuinfo.max_freq); > } > > +static inline void register_cooling_device(struct cpufreq_policy *policy) > +{ > + policy->cdev = of_cpufreq_cooling_register(policy); > +} > + > +static inline void unregister_cooling_device(struct cpufreq_policy *policy) > +{ > + cpufreq_cooling_unregister(policy->cdev); > + policy->cdev = NULL; > +} I thought that we discussed over chat that you wouldn't add any wrapper routines. How do you see these getting used ? I will suggest that this should be open coded in the core itself. -- viresh