Received: by 10.223.176.5 with SMTP id f5csp484592wra; Wed, 7 Feb 2018 02:35:37 -0800 (PST) X-Google-Smtp-Source: AH8x224mDDADgRM+twwAc0vBo+v1cTsW3MmBlUwtxS6iW0CVgWDwsKE0+atko3kOWseThnhYNRKN X-Received: by 2002:a17:902:507:: with SMTP id 7-v6mr5566819plf.0.1517999737836; Wed, 07 Feb 2018 02:35:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517999737; cv=none; d=google.com; s=arc-20160816; b=U5shgpHlYknIeu6kJZOl1XwOw/L0OUFXMESoVfJBqgO+lIfabfPtBubwxEdd2UnO68 qpCcwhUaLS+h1+AMKfHiPbggGQD7Q0yegsAKqWsuvWEkqEsG8WlnfjDhTpSNUjNPIEBd szSIsMkG5kjL2bZV6LEXvlxWi7k2w9C56IDjx3IHk/ktmpbyNsNzv2PRf7Qa1ET7qd1u en+7SNHjm6LhOFuEbH9W3rGLnJRVdfJ+CtrpjepNUVBTkUTjk3L8uL4GdmqP+tXX/+Mn K7ZcWk25FluNJe2o56Cwf1sWU1jWu0z0T6zmgwwm6iP/0Fm5yJxBt36lyLZ8lOrXW8vA SmGw== 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 :arc-authentication-results; bh=P1G3KgKZIdzIM/WtzbG1eksYeg/jm+a4Sj3SoPwVP6o=; b=BiTt+SxGIyGpiosV1HFYPPVbJDG47JumBVikCzPkewIUeXMUpjZ+eR4aFlLUljHos4 q1kkrhqU5ux4XUnwEUoIKxCliITRYByjfGFYfy/aebF+VilIENMhnkgCxd2rtcORoBk5 zH07jUT33RVRhbHjJagq0wkA5cSQJ1mhCpQ9WaFRhaFNhXXvlkhhEAf4xqxLrh752fdO dYA/tZ4NuvS0PlG8ltROkrCj/f8OYFP885hvpNH9QPvSTneX3hLqT0Xyr30nA//IJ6hn NU5t1HA5cD4L6Mve4J3QY6RgzC8GNPKn32NA5tVQxAvPIwTKQ/x97/SeeYtrHRazYKsA m7AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VoljhEp3; 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 c11-v6si872588pls.801.2018.02.07.02.35.24; Wed, 07 Feb 2018 02:35:37 -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=VoljhEp3; 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 S1753814AbeBGKel (ORCPT + 99 others); Wed, 7 Feb 2018 05:34:41 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36503 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753424AbeBGKej (ORCPT ); Wed, 7 Feb 2018 05:34:39 -0500 Received: by mail-wm0-f68.google.com with SMTP id f3so2342511wmc.1 for ; Wed, 07 Feb 2018 02:34:38 -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=P1G3KgKZIdzIM/WtzbG1eksYeg/jm+a4Sj3SoPwVP6o=; b=VoljhEp31HnvdlLj2xwI7lN72L4UczdV6VQvgka8bxSs+mduX/UTE91fgXjOIKvlXl O5DUv4cDOovo2aw12NZ7UoOoVrl7DzlkU6Xj0HxFbtbmYnpw/sRbWF23owPdcb0UZI5A CPqbBNaP7iSAi+iuKKse/JY2HrLo/ma1S2X5s= 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=P1G3KgKZIdzIM/WtzbG1eksYeg/jm+a4Sj3SoPwVP6o=; b=edRwc2F0izgyssIiz6n9Vbsj5cQh8guRYQQrdB3stPQd3yW1kACqDqwA6c2kV5XfxH WjVt+abrxxgUFxI7EEeFDigyt0Ji0CPovd7yIn8Mece8X5feIQKHeM43kGvRY0xW/384 ZEXxDqRYA7qnEGyT2nLMsifDdw20yPvxHAddkWC3LpAmbRtVdCmMSdIkw8kc4OCadqmM JWoLd+QNVMaprp3YFql2k5FYT80n8kyn1S8jczTYMUFQLoIGHp5uGmeD0TRhJTh+n1pa NdGag8TdI60C0kYgXGNmHrreGdfF9m9g6Yl+rCDY0W4uEqgSenNUqNVUy4EHuxH+G/3p cllQ== X-Gm-Message-State: APf1xPC18lKq99s/q1eZ0/OnmFVGN6YbGeO0hmhuXx1UcKcnSqRVwk7n ydSgGi989SI8WV45wy13K4u90g== X-Received: by 10.28.231.8 with SMTP id e8mr4033596wmh.148.1517999677615; Wed, 07 Feb 2018 02:34:37 -0800 (PST) Received: from [192.168.1.75] (lft31-1-88-121-166-205.fbx.proxad.net. [88.121.166.205]) by smtp.googlemail.com with ESMTPSA id q195sm2283430wmb.33.2018.02.07.02.34.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Feb 2018 02:34:36 -0800 (PST) Subject: Re: [PATCH 5/8] thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver To: Viresh Kumar Cc: edubezval@gmail.com, kevin.wangtao@linaro.org, leo.yan@linaro.org, vincent.guittot@linaro.org, amit.kachhap@gmail.com, linux-kernel@vger.kernel.org, Zhang Rui , Javi Merino , "open list:THERMAL" References: <1516721671-16360-1-git-send-email-daniel.lezcano@linaro.org> <1516721671-16360-6-git-send-email-daniel.lezcano@linaro.org> <20180207091231.GQ28462@vireshk-i7> From: Daniel Lezcano Message-ID: <54759b82-29e9-f376-bbe8-dcf683ed0cce@linaro.org> Date: Wed, 7 Feb 2018 11:34:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180207091231.GQ28462@vireshk-i7> 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 Hi Viresh, thanks for reviewing. On 07/02/2018 10:12, Viresh Kumar wrote: > On 23-01-18, 16:34, Daniel Lezcano wrote: >> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c > >> +/** >> + * cpuidle_cooling_ops - thermal cooling device ops >> + */ >> +static struct thermal_cooling_device_ops cpuidle_cooling_ops = { >> + .get_max_state = cpuidle_cooling_get_max_state, >> + .get_cur_state = cpuidle_cooling_get_cur_state, >> + .set_cur_state = cpuidle_cooling_set_cur_state, >> +}; >> + >> +/** >> + * cpuidle_cooling_release - Kref based release helper >> + * @kref: a pointer to the kref structure >> + * >> + * This function is automatically called by the kref_put function when >> + * the idle cooling device refcount reaches zero. At this point, we >> + * have the guarantee the structure is no longer in use and we can >> + * safely release all the ressources. >> + */ > > Don't really need doc style comments for internal routines. From Documentation/doc-guide/kernel-doc.rst: "We also recommend providing kernel-doc formatted documentation for private (file "static") routines, for consistency of kernel source code layout. But this is lower priority and at the discretion of the MAINTAINER of that kernel source file." Vote is open :) >> +static void __init cpuidle_cooling_release(struct kref *kref) >> +{ >> + struct cpuidle_cooling_device *idle_cdev = >> + container_of(kref, struct cpuidle_cooling_device, kref); >> + >> + thermal_cooling_device_unregister(idle_cdev->cdev); >> + kfree(idle_cdev->waitq); >> + kfree(idle_cdev->tsk); >> + kfree(idle_cdev); > > What about list-del here (cpuidle_cdev_list) ? Yes, thanks for pointing this. I have to convert the calling loop with the 'safe' list variant. >> +} >> + >> +/** >> + * cpuidle_cooling_register - Idle cooling device initialization function >> + * >> + * This function is in charge of creating a cooling device per cluster >> + * and register it to thermal framework. For this we rely on the >> + * topology as there is nothing yet describing better the idle state >> + * power domains. >> + * >> + * For each first CPU of the cluster's cpumask, we allocate the idle >> + * cooling device, initialize the general fields and then we initialze >> + * the rest in a per cpu basis. >> + * >> + * Returns zero on success, < 0 otherwise. >> + */ >> +int cpuidle_cooling_register(void) >> +{ >> + struct cpuidle_cooling_device *idle_cdev = NULL; >> + struct thermal_cooling_device *cdev; >> + struct task_struct *tsk; >> + struct device_node *np; >> + cpumask_t *cpumask; >> + char dev_name[THERMAL_NAME_LENGTH]; >> + int weight; >> + int ret = -ENOMEM, cpu; >> + int index = 0; >> + >> + for_each_possible_cpu(cpu) { >> + > > Perhaps this is coding choice, but just for the sake of consistency in > this driver should we remove such empty lines at the beginning of a > blocks ? Yes, it is coding choice. I'm in favor of separated blocks. I can remove the lines if that hurts. >> + cpumask = topology_core_cpumask(cpu); >> + weight = cpumask_weight(cpumask); >> + >> + /* >> + * This condition makes the first cpu belonging to the >> + * cluster to create a cooling device and allocates >> + * the structure. Others CPUs belonging to the same >> + * cluster will just increment the refcount on the >> + * cooling device structure and initialize it. >> + */ >> + if (cpu == cpumask_first(cpumask)) { >> + > > Like here as well. Ok. [ ... ] >> + pr_err("Failed to create idle cooling device (%d)\n", ret); >> + >> + return ret; >> +} > > What about cpuidle_cooling_unregister() ? The unregister function is not needed because cpuidle can't be unloaded. The cpuidle cooling device is registered after the cpuidle successfully initialized itself, there is no error path. >> +#endif >> diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h >> index d4292eb..2b5950b 100644 >> --- a/include/linux/cpu_cooling.h >> +++ b/include/linux/cpu_cooling.h >> @@ -45,6 +45,7 @@ struct thermal_cooling_device * >> cpufreq_power_cooling_register(struct cpufreq_policy *policy, >> u32 capacitance, get_static_t plat_static_func); >> >> +extern int cpuidle_cooling_register(void); >> /** >> * of_cpufreq_cooling_register - create cpufreq cooling device based on DT. >> * @np: a valid struct device_node to the cooling device device tree node. >> @@ -118,6 +119,11 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) >> { >> return; >> } >> + >> +static inline int cpuidle_cooling_register(void) > > You need to use the new macros of cpufreq and cpuidle here as well, > else you will see compile time errors with some configurations. Ok, I thought I tried the different combinations but I will double check. Thanks -- Daniel >> +{ >> + return 0; >> +} >> #endif /* CONFIG_CPU_THERMAL */ >> >> #endif /* __CPU_COOLING_H__ */ >> -- >> 2.7.4 > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog