Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3215811imu; Mon, 28 Jan 2019 00:30:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN6jquQSZXAq1PMtIWuc0RH6MvCbqtIwPVF1LXEkv2JAOshfOuMfupotS6JBGlUIXRWsDXNp X-Received: by 2002:a62:7f93:: with SMTP id a141mr21174380pfd.96.1548664220498; Mon, 28 Jan 2019 00:30:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548664220; cv=none; d=google.com; s=arc-20160816; b=HERMqxtNqHyII1o3P0iRBIbNKhnkL/sYf45OFZmChCjnER8ePnAluZUO3E4l1tvLdZ VTT71uDpfu0+P+lfOmeIWnNSUMenDJF5+z29GW2b6BOIMKL0zsCJFF7/wiaT+GDUi7Be 1Vo90UVjqfgkIHmS5ccVxQGTCEQXL4Tw1jPi6FdwpS+/JULHGjqE0gNzDj/m4V8MO0Qb p8Ziuj3aQXgzmpAj3PD9PYeoYG1X2UZjyOG3DiYUSflrWIyz+3Rcx/9EtFLoJjfJu/na X5+/pbzLufMNOz6Rfc2GtRkJV6bWEsflQ0guP/DC3jVCCO8Dgvi2zymZZpXRlnet0zXz 6yWQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=xaZLqmjl7uAF/GfT0BEsIeS38dElN6qNBXfpitdP+bw=; b=xFHxbNmbpefJpp1Hs5N7DrlgIl5+zdWaQG/IVGWxh4Wi7kJztOUEbK8235KLNGF52p t5PpGXyDDAKzOnwoDo6Bxqa7Lh+0QFe+gLBezY2RCZrawztoLrIdAxhnzQRONWu8hgmy esC3sprwRFHZLAd3c0SvikQjKrfRkVroxaqGjiL5fO5BFoez5optA4WuJpiLZil5CvSm HlBgPBQZCnKaapFWy/bIhH/1pVhQOF87mZGubJ+bwCr4iyeuMloaB9JZZk9SUjFbf88C bU9EdWbnu4SDvyNvm1olajdpAiMk5lxw5LEy4ac5tV9w4ZHsbxraixeMhP/uExvJ4Q6F zfZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UOkNh2v/"; 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 l22si32694868pgo.411.2019.01.28.00.30.05; Mon, 28 Jan 2019 00:30:20 -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="UOkNh2v/"; 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 S1726917AbfA1I3O (ORCPT + 99 others); Mon, 28 Jan 2019 03:29:14 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34004 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726887AbfA1I3O (ORCPT ); Mon, 28 Jan 2019 03:29:14 -0500 Received: by mail-wm1-f66.google.com with SMTP id y185so9809462wmd.1 for ; Mon, 28 Jan 2019 00:29:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=xaZLqmjl7uAF/GfT0BEsIeS38dElN6qNBXfpitdP+bw=; b=UOkNh2v/GXEzBkzsbrFkR6jHKhSs9Dc4QzFBMvh8oYxHYLwuy4QCnQMbbfHhsoESFB oANeFGXcpn/UcmVAYX0GmTlGL3asGaH9bMUSYlrSaJwwU2O5nIZExtwmtkbB5nF8V4OY /ORG4PTbrhcH+vvs0QmwlbBtVLkuAsK9G1XwU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xaZLqmjl7uAF/GfT0BEsIeS38dElN6qNBXfpitdP+bw=; b=Z+fcaJFDt3wCFyIKka3xXH8sFSg00TxvkW6LOdvht4VHxywl++nICMC5e+ZdPaJ+4T fMhaLPURlEk8gF4lL4Tai/xwXZWI8Gy4hh4CLHoQPmUWaz1+94f7sXC56kkLH5r6n+O7 zxnTRIJnJpmSD8KRygDhaVuiXLb09HmUL7MD/tMGVBA/YS3+JQQJgr8g7VXKzr6XWOrq dqpftNeo9ziWo7G6H5pqUOtvHEHk2wrv7iXaTsMrzjD8ppCYJ9Zr0M/F5DFuzeOvMx1B lY27RkrvFbMBJvXwz6zokC8nUXuElJyBE/tDzUMcBBbT+l6dcXT+kpdSXctuHsJwQTs3 P51g== X-Gm-Message-State: AJcUukeB23Mh+VMPrIf1rIhrAcqACJpNgP2jnCDGmv6lqI0nnZR/O96E E3Vq6+st+p4it2g7dp8luG9psQ== X-Received: by 2002:a1c:c2d4:: with SMTP id s203mr15974313wmf.3.1548664152096; Mon, 28 Jan 2019 00:29:12 -0800 (PST) Received: from [192.168.0.41] (20.36.129.77.rev.sfr.net. [77.129.36.20]) by smtp.googlemail.com with ESMTPSA id h16sm231507479wrb.62.2019.01.28.00.29.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 00:29:11 -0800 (PST) Subject: Re: [PATCH v4 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked To: Amit Kucheria , linux-kernel@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org, viresh.kumar@linaro.org, edubezval@gmail.com, swboyd@chromium.org, dianders@chromium.org, mka@chromium.org, "Rafael J. Wysocki" , "Peter Zijlstra (Intel)" , Tao Wang , Sudeep Holla , linux-pm@vger.kernel.org References: From: Daniel Lezcano Message-ID: <8dc3dcab-c1f5-2f6a-69fd-0283735e6241@linaro.org> Date: Mon, 28 Jan 2019 09:29:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/01/2019 07:41, 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 > --- Reviewed-by: Daniel Lezcano > drivers/cpufreq/cpufreq.c | 9 +++++++++ > include/linux/cpufreq.h | 9 +++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index e35a886e00bc..29ed78b0b77b 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -19,6 +19,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -1318,6 +1319,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) > + policy->cdev = of_cpufreq_cooling_register(policy); > + > pr_debug("initialization complete\n"); > > return 0; > @@ -1405,6 +1409,11 @@ static int cpufreq_offline(unsigned int cpu) > goto unlock; > } > > + if (cpufreq_driver->flags & CPUFREQ_AUTO_REGISTER_COOLING_DEV) { > + cpufreq_cooling_unregister(policy->cdev); > + policy->cdev = NULL; > + } > + > if (cpufreq_driver->stop_cpu) > cpufreq_driver->stop_cpu(policy); > > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > index bd7fbd6a4478..55ca61a64fc2 100644 > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -151,6 +151,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 +389,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); > > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog