Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp632130imu; Wed, 23 Jan 2019 02:55:23 -0800 (PST) X-Google-Smtp-Source: ALg8bN54b9r2TZu8SPHNxfJEbR8Vwwba8tmLb5tfHopaeO7hiNLDhCIF37xAoHSRuwZHCMeK4wXe X-Received: by 2002:a63:8d44:: with SMTP id z65mr1545924pgd.57.1548240923447; Wed, 23 Jan 2019 02:55:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548240923; cv=none; d=google.com; s=arc-20160816; b=JpH3H0TVjRMEuHp8grxw0spIkdNksgq22K+nV1CCZtPadLtmDfpU3ecq8ZkRopDrCQ EXd93wdd9TwJmtl/HMbwju6mlDnTqVsby38jIVdcleX/1u8MusDAusogNd3Uai+0haOW iSBT32HGj9nwTKGmR1w1oCKjP9lwWpLehIt3ZwprLBhv3Tizs4MJu90QbiI2bxec1hFH p863OY/QNDCJQ6a+JchjxLU7acBM/gO/lfQeEeT6ndaxvXmjc0Aaoie0hsQSLA+n669R +uGTnB5gLDDM+iSm3xJklkJPM0NaECpSM6/mdvrkxsYsLp5taZPmcLG/2DMgWANXUQQe p6gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=4ADTjytmAzenk3tWw3iNskI0WI6s+ySevWLD6P1qk9M=; b=pWNw1+73zyrFxIpgC51Jke99zyZV0K8hJwXLum6bXHtsiu/9r7cGaOqeebhk2AnB+A 7IXZlDLHxVgX5x0FJrzihHkHEFM639dwMOMjUuAig/CwCezGWAZZgNnLQBGdLS78ckq5 w+ZVFkx21xMujyva14zOEIVWKlkcbpDNfQqCZLTr0IMJ0jTvvGQqFgHnpet8IvGt+6yE WS49tRFmX21RasRI39ETgrKqISdCRu79nu3KOcVBTmVanBU8wgCwGcN/eEHiWiDGKTeZ QgjH+HO7/veuXJxJYFgkSgIoNdhA5ukeEahDYHyCJuwDpxCTyQu6ZvciyJYrni4GjcW6 sF6w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23si18583617pgi.181.2019.01.23.02.55.07; Wed, 23 Jan 2019 02:55:23 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727546AbfAWKxX (ORCPT + 99 others); Wed, 23 Jan 2019 05:53:23 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:35470 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727207AbfAWKxW (ORCPT ); Wed, 23 Jan 2019 05:53:22 -0500 Received: by mail-oi1-f194.google.com with SMTP id v6so1436996oif.2; Wed, 23 Jan 2019 02:53:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4ADTjytmAzenk3tWw3iNskI0WI6s+ySevWLD6P1qk9M=; b=geWzdI1LRAaY4a6zpKvb6405o7XfrrKthI6GiiREsxEFDsiVXF/OsigqVfJZ0l1vyv KSRJ/fSrMVAj9YKbZyXtjGucqUp4kzkHkJU92SACNcx0sNxl1+EHmdEm8pJeCMLQjGwc +VV41yov91L2NkJQ9udAug7mbSu7kZIBPs7Um0KYHvdhr2xweeq42Uk0WtJP3gFMSE3F MDvKGQB67rNhphHwHYMJw8er8FbLEC7aPBxbxLhBsb1Wl8/jzsBL2S4R3B2nOJ1cDWoj b2Z5U+VrQ/Bl4XiUP/VgYggj4pDzLFD48ynutGJJHfD/dX1RVc2bbMvbguFD0nkEq9MS +ggw== X-Gm-Message-State: AJcUukcLI1ByuVI6unkkfX6t87PYbeGXW+nwcY2wMn69JXuRcuCpQRU9 y+7WfT2W/kwyhYZYtU/wq19S8MLze/uPPpt6N50= X-Received: by 2002:aca:3d42:: with SMTP id k63mr1111959oia.95.1548240801410; Wed, 23 Jan 2019 02:53:21 -0800 (PST) MIME-Version: 1.0 References: <0036de796308b8919eac74a9a910f0d7b9c0cbf8.1548084260.git.amit.kucheria@linaro.org> <20190123103624.t4b2ij3bfvpezgjf@vireshk-i7> <20190123104322.o3whk6rfiaootspn@vireshk-i7> <20190123104403.bl7mdidmvd7c227q@vireshk-i7> In-Reply-To: <20190123104403.bl7mdidmvd7c227q@vireshk-i7> From: "Rafael J. Wysocki" Date: Wed, 23 Jan 2019 11:53:10 +0100 Message-ID: Subject: Re: [PATCH v2 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked To: Viresh Kumar Cc: "Rafael J. Wysocki" , Amit Kucheria , Linux Kernel Mailing List , linux-arm-msm , Eduardo Valentin , Stephen Boyd , Doug Anderson , Matthias Kaehlcke , "Rafael J. Wysocki" , Ingo Molnar , Sudeep Holla , Tao Wang , Linux PM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 23, 2019 at 11:44 AM Viresh Kumar wrote: > > On 23-01-19, 16:13, Viresh Kumar wrote: > > On 23-01-19, 11:39, Rafael J. Wysocki wrote: > > > On Wed, Jan 23, 2019 at 11:36 AM Viresh Kumar wrote: > > > > > > > > On 21-01-19, 21:10, Amit Kucheria wrote: > > > > > @@ -151,6 +152,11 @@ struct cpufreq_policy { > > > > > > > > > > /* For cpufreq driver's internal use */ > > > > > void *driver_data; > > > > > + > > > > > +#ifdef CONFIG_CPU_THERMAL > > > > > + /* Pointer to the cooling device if used for thermal mitigation */ > > > > > + struct thermal_cooling_device *cdev; > > > > > +#endif > > > > > }; > > > > > > > > > > /* Only for ACPI */ > > > > > @@ -386,6 +392,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 +427,19 @@ cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy) > > > > > policy->cpuinfo.max_freq); > > > > > } > > > > > > > > > > +#ifdef CONFIG_CPU_THERMAL > > > > > +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; > > > > > +} > > > > > +#else > > > > > +static inline void register_cooling_device(struct cpufreq_policy *policy) {} > > > > > +static inline void unregister_cooling_device(struct cpufreq_policy *policy) {} > > > > > +#endif > > > > > > > > The whole ifdef hackery here saves space for a pointer per policy. > > > > Just get rid of it, it isn't worth it. > > > > > > Is struct thermal_cooling_device defined if CONFIG_THERMAL is unset? > > > > No and it is defined in thermal.h without any ifdef stuff. > > I meant it is always available and doesn't depend on CONFIG_THERMAL. OK I guess we can live with an extra unused pointer per policy on platforms with CONFIG_CPU_THERMAL unset.