Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3240205imu; Mon, 28 Jan 2019 01:03:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN424Lb32OfR7Esb9VZiquUquNwi3BCKgw9DbxELX7Aa8DMnnzFhRUqGL3hGbgXdWIhHEKOb X-Received: by 2002:a62:a209:: with SMTP id m9mr21459076pff.218.1548666237850; Mon, 28 Jan 2019 01:03:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548666237; cv=none; d=google.com; s=arc-20160816; b=RrpkE3H0o1eLXKOwFyyU3CAHryHjR6ny48ugl5aZ+4BH+NTCPWsQCSK2j+aJE1ZgWa lvvLa9fPgUZOz1JTrH/dEcLwYGeagk5FigfBaFdW6a3I61i5VV7i0hjamxgxMC+rVAcK CIC76lfzvYT1jIdEyZ5BKPEcCo3HoUrGg4tghOk+HhkH/PnzFjLpyB72DWmphC+aYXko +5ahSnxkcyKG8U4NQXBGcEhOEgKRh2cNa4Qym+YZd/MvonHUZ4r42kgAOmeeD0nzfoER jo3dgQQF/srMNKijuD1IN4EceW5FUCcA1FrSHZJcxZWvE/U9tyW1pLyWaRkzFFfKy19D rgnQ== 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=1nBaz/Bcq4l4WiiSXb0gHk8bFRn3sHCY5t8JqU4juzc=; b=cDrRkXOwfKYts5wjswAsgbsZvH3wYFnnVamem7JantRqs3TUdL5AKUDk2gr2qTz8b8 55eP7nFquOSlKaPajepzX6pGsmRcpbhNTnDkJbAQ7NkbGjPQM9lJC3rvwBS+oqfq9nLU l+Wc9WSfelj5Q4Ng7X/SBH0uL8q/T5EIVfrsbtaIthdF4Ld4NZXJaDmwmLP6kzKDJXcI dcGb4sAtlSlsKr3cvJ620N48WLfXxiqJR61HYoT/yyYCwJt2XsaSTCL3WTlxN/i554N7 V1jpeQtBIZIgTne5MSh3k5Ifxsp/ICGnnFbutVXuUF18iw00v6lsVKVbeIHEYloHEOIp 6l3g== 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 d189si34446974pfa.70.2019.01.28.01.03.42; Mon, 28 Jan 2019 01:03:57 -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 S1726695AbfA1JDc (ORCPT + 99 others); Mon, 28 Jan 2019 04:03:32 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:44617 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726415AbfA1JDc (ORCPT ); Mon, 28 Jan 2019 04:03:32 -0500 Received: by mail-ot1-f67.google.com with SMTP id g16so9979783otg.11; Mon, 28 Jan 2019 01:03:31 -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=1nBaz/Bcq4l4WiiSXb0gHk8bFRn3sHCY5t8JqU4juzc=; b=Uv7vX3oCF+/XqgdFQehqDoPrZjsOxN6xaQ8u260Z6QbDrn1q+vktljxq6jeL0uS64c PeZuwvcHEyxQxTd1KABmSfWEn7w0eijh965F6PJSZleDIZDwCW0AZeht9wP4qZOKzUL0 BwS9csM8fXrx5Har9AGhwyOvENl5mJO9rk+r+EIp5IJaHiZCo1Kfy7zLIeaLuX250YoX OgeYk33r/3gcbw6d3Mso1BCBTMLBXPBNgTgYpUJ8j/tv24M5hID982/A0ebvjXAdIXcU sJOve3A4QlnrHfSq5ALr3MJYGh5DL+pBhZ6rhMtcKfbInwBv6VOTrAdkRbR66iLX2MhW zXvg== X-Gm-Message-State: AJcUuke3tR2gMGBVp7pwqF8FNoQWHbEqvP3H6A3jHIM3PbzCkhFI9Txu eveuLKVIaQ0u1CIqGgdmX4ZsGXyjJeETGfXR+TQ= X-Received: by 2002:a9d:4c84:: with SMTP id m4mr14110828otf.124.1548666211031; Mon, 28 Jan 2019 01:03:31 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 28 Jan 2019 10:03:19 +0100 Message-ID: Subject: Re: [PATCH v4 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked To: Amit Kucheria Cc: Linux Kernel Mailing List , linux-arm-msm , Viresh Kumar , Eduardo Valentin , Stephen Boyd , Doug Anderson , Matthias Kaehlcke , "Rafael J. Wysocki" , "Peter Zijlstra (Intel)" , Tao Wang , Sudeep Holla , 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 Mon, Jan 28, 2019 at 7:44 AM 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 | 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) It would be good to use IS_ENABLED(CONFIG_CPU_THERMAL) here and below as a hint for the compiler. > + 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); >