Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp622103imu; Wed, 23 Jan 2019 02:41:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN5XvHsiP81V76XT558ine5Z2a/+ZASd6P0WSFfk4FwOxjfoJYbH80XLywc/yAVUA9pYldZ/ X-Received: by 2002:a17:902:28aa:: with SMTP id f39mr1695750plb.297.1548240099376; Wed, 23 Jan 2019 02:41:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548240099; cv=none; d=google.com; s=arc-20160816; b=RiXvexXnfdEMt5J4iHuNT9oyqOlSUyAhCPZxrNvRLj959shFjKAptNv43gpkxXe6P+ osOhzMAd6VeIz4uHxPnUoMcaeWUWcfmz2PbnJ21r93eBFcbS/g/uq4kMIgyDFbj2Kyi9 YA4vF/NgVCEoGK87O01sQtyfU/6xxPrcnCFv5v4L1gRVBW2dkKS3NlVvGVAv2QPFdgFR VR9hSzWcuEmWeABrQ8wXv/rms7Ih3/5OYm6QGSvDM2G39NmMVHadNdycMj8JggTzYCkm g29kYiB7sHQaxbC4rEtqUhpbf8fdxurBFk4GfpkUQ6HnkxCxtB9VJ2jcvyZ/7zG6NkPR hl8A== 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=pg0hX+CA34u3qPWrPjOGvXZCtdevBW0CLcPKrzIur2U=; b=zlCZDt29kHBARkYPhA7jCLYAwOfDVjcckheUMPCXPErl9yCXB61NXqC3bLPoOJO8qR KWS6hfZxEEhNuwfdbVh92mTqLCzlrZFN7bhjB5754AZ2Jp4A4EgoJRsyTR/N3s36DZ7a Cdu7XpIphlKbAUzQYiAJU+hF/TUOD8lxOVvbSfp864G9deJCRN3y/8jFAnAOaXP2j2FX bP0aEwwH+CkCsGV0ttxR8MFCixGPg3m0evQB1hPlt3lu+pwWC3FD7gTG1ylOrnI2yuFc 3709qmoKD20dcpoRXK5I89pPnMsuoziS7sP/IZn799hUgnblawvIhsN9qwYwAgIvfoeF rUIw== 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 h9si18605035pli.418.2019.01.23.02.41.24; Wed, 23 Jan 2019 02:41:39 -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 S1727308AbfAWKjm (ORCPT + 99 others); Wed, 23 Jan 2019 05:39:42 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:44543 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726938AbfAWKjm (ORCPT ); Wed, 23 Jan 2019 05:39:42 -0500 Received: by mail-oi1-f193.google.com with SMTP id m6so1366880oig.11; Wed, 23 Jan 2019 02:39:41 -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=pg0hX+CA34u3qPWrPjOGvXZCtdevBW0CLcPKrzIur2U=; b=oNubL5r2v1NHaX2swzYLQ5FQdQSAI6HgTe52ve3xMBejST0Vr3IrFEX8ch25H7IluO Bbb14DsRHErXkeI8jtnkoZbD/xnXaOL9mjxl5XbnpJkzShBBUi9r9gLnjYB+XNkaM7oT +HMGT3WtIOeXEGtY/pL59F/lK2/3Vg04Xuwn1Dby0O5AzlLVslPTZWm3JAz3kXAW9Zzd jqKe6Lw8bZHEU+bW2CB1k1k544M9A60404GC9RezmYYfJSRDv9gvPxrfd4G3wUM0aZeS JDOopqfDO6IqJHSERvwlxlVPoVaUwoJmt8CAqWTnknwwWeW4JwhbV/IBzUJZcSI/S7G5 cQ7A== X-Gm-Message-State: AJcUukf8iqQiYJThiVzt32pPiyGYE9rXCm+HvNUnEUJP+OUOIwA4khMn DNs9d3iZXfn1/w02QF0CXHuHtB0Jbx8eo3Yxa58= X-Received: by 2002:a54:4d01:: with SMTP id v1mr1006849oix.246.1548239981295; Wed, 23 Jan 2019 02:39:41 -0800 (PST) MIME-Version: 1.0 References: <0036de796308b8919eac74a9a910f0d7b9c0cbf8.1548084260.git.amit.kucheria@linaro.org> <20190123103624.t4b2ij3bfvpezgjf@vireshk-i7> In-Reply-To: <20190123103624.t4b2ij3bfvpezgjf@vireshk-i7> From: "Rafael J. Wysocki" Date: Wed, 23 Jan 2019 11:39:29 +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: 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: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?