Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3994621imu; Mon, 14 Jan 2019 12:53:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN6UmslU5zwZGdluVdUqRrK3neumqQv/ksmHXlkPG+C5dJCu5eyPI+nVMtHu6Ls0Rw7w2Aww X-Received: by 2002:a63:cc12:: with SMTP id x18mr390601pgf.33.1547499224551; Mon, 14 Jan 2019 12:53:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547499224; cv=none; d=google.com; s=arc-20160816; b=Hqqx1LBopblisww9czbXog7BuLrtbFimwCUssfr2yBV7yIvCcR55gALEsbnO2Mn+u2 02kuzDa1GVr1RglAGRn3Ww5uiW2UKVbx1haPmz7xsM0f813GtBdwJOsswTXhAIM44NQ3 SpxbIYsWGodqIP047QvhOZ0XrZxZYEY2qiocSXt9VQCxiYu0FQc3hapBUe35GiWCbTLQ vJEckWCEAywDHtX6KR/N9izhyQeNmShtCzp0P+XsAjLklaRpZgdoGUokSIV8jNbiE2yF gV2lL596rpNU7ui+2AQOgeS3OiB9L8bEi4i6qtEx/NyyfWtUpOonqiU8gn3s8PyIKsh3 uTKg== 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=e1hQzf8kQPwGBBXZxeEhzx3i1sbMBtFzu/Gc4YZq6XY=; b=zKC57TCKfJDoCv1GZFKnms7P7QxoDbXQxz4yVdJgjHCoiy1J+8e1bbk2cZNgl1xJuO VkZbBIJz9BB4uFl3t+fDR4s6W+AapSAQURbLr8AgXFhA1PmienUvdBDLpv6nEB+UHKPM SsszoUVqPi1UU002+4BQWYh5+Bxei3MW31scMnqST+ARBmMCAr6dihO4AnDFJw+kUeb+ M17w+FnnHQPHVVc20z7T2OhoLm6uLnTS+21Rj6YXFOvM3nE4LYZkuVJ/k3UFaW+JeTwH yKPhuEmVh4X8xX2y5z1yuOYBaJDHcC4EiLoJDiAR7J9rP3gzvU7vMB97kpLWGYL57jwV sEiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PulFaOoj; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 63si1235559pfv.38.2019.01.14.12.53.29; Mon, 14 Jan 2019 12:53:44 -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=@chromium.org header.s=google header.b=PulFaOoj; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727022AbfANUvi (ORCPT + 99 others); Mon, 14 Jan 2019 15:51:38 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35680 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbfANUvh (ORCPT ); Mon, 14 Jan 2019 15:51:37 -0500 Received: by mail-pg1-f195.google.com with SMTP id s198so180379pgs.2 for ; Mon, 14 Jan 2019 12:51:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=e1hQzf8kQPwGBBXZxeEhzx3i1sbMBtFzu/Gc4YZq6XY=; b=PulFaOojxywb0s4CTsuhM1yjWRpethCD8QoP5W93/PNGNgjfPAQwrU5PuYRSVeGEHb ONIkIxo+ahutubjxWnzMjrVYhHmI5u3YEufTKvr1l2e8r2xlyiqbZOOFfxS/EaodNX4q pnUTYt/EFzZIkY0VWxSUOxq8UpD+A+BX8nWPw= 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=e1hQzf8kQPwGBBXZxeEhzx3i1sbMBtFzu/Gc4YZq6XY=; b=YGKm6fJ5cTSvKdzJ0/EbrwymcQqqSfZQ6F6HjZJC2uj6sMYf9e3/j/Tnx7NszebaXo Dg2vNoXovPurBFSNXGxBproa+dD2KhiaQR+bV1D4p4g5bI4u5v0b55MlVS3Wg37Nxf0b uoPmVNcutGU//xuZjoFIWWFHMR6SQobWs6UYc5/Z5T64sjjj+2sXsUoGj+e9n6vJgLVM TkWwnQ45gIrbZqdSQmyBXyEnIa20OxYw47TtDPlUGig1MGn5QG83AqdHO/hQQ+fWqfaU Cq0n/2Wo8omtWJBSHE57gBpu5fl6rPF/Z7njjqnc3z3iAjPIXRdSXmUzCL//xevWb3er Qd+w== X-Gm-Message-State: AJcUukfaKI1jbvO60YOuP2UyhWtsBq+3AIWmoT6l5AEmaHTMZpg7PSVF V1dRPS1xOAsyRE8YtBNPIlg0VhcPPqdI5w== X-Received: by 2002:a62:140a:: with SMTP id 10mr356103pfu.157.1547499096411; Mon, 14 Jan 2019 12:51:36 -0800 (PST) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id h185sm1605257pfg.143.2019.01.14.12.51.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jan 2019 12:51:35 -0800 (PST) Date: Mon, 14 Jan 2019 12:51:35 -0800 From: Matthias Kaehlcke To: Amit Kucheria Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, viresh.kumar@linaro.org, edubezval@gmail.com, swboyd@chromium.org, dianders@chromium.org, "Rafael J. Wysocki" , linux-pm@vger.kernel.org Subject: Re: [PATCH v1 02/10] cpufreq: Add a flag to auto-register a cooling device Message-ID: <20190114205135.GL261387@google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 14, 2019 at 10:04:54PM +0530, 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. > > Suggested-by: Stephen Boyd > Suggested-by: Viresh Kumar > Signed-off-by: Amit Kucheria > --- > drivers/cpufreq/cpufreq.c | 17 +++++++++++++++++ > include/linux/cpufreq.h | 6 ++++++ > 2 files changed, 23 insertions(+) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 6f23ebb395f1..cd6e750d3d82 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > > static LIST_HEAD(cpufreq_policy_list); > > @@ -1318,6 +1319,14 @@ static int cpufreq_online(unsigned int cpu) > if (cpufreq_driver->ready) > cpufreq_driver->ready(policy); > > +#ifdef CONFIG_CPU_THERMAL > + if (cpufreq_driver->flags & CPUFREQ_AUTO_REGISTER_COOLING_DEV) { > + struct thermal_cooling_device **cdev = &policy->cooldev; > + > + *cdev = of_cpufreq_cooling_register(policy); > + } > +#endif > + > pr_debug("initialization complete\n"); > > return 0; > @@ -1411,6 +1420,14 @@ static int cpufreq_offline(unsigned int cpu) > if (has_target()) > cpufreq_exit_governor(policy); > > +#ifdef CONFIG_CPU_THERMAL > + if (cpufreq_driver->flags & CPUFREQ_AUTO_REGISTER_COOLING_DEV) { > + struct thermal_cooling_device **cdev = &policy->cooldev; > + > + cpufreq_cooling_unregister(*cdev); > + } > +#endif > + > /* > * Perform the ->exit() even during light-weight tear-down, > * since this is a core component, and is essential for the > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > index 7d0cf54125fa..70ad02088825 100644 > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -390,6 +390,12 @@ struct cpufreq_driver { > */ > #define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING (1 << 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 (1 << 7) > + > int cpufreq_register_driver(struct cpufreq_driver *driver_data); > int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); Reviewed-by: Matthias Kaehlcke Tested-by: Matthias Kaehlcke