Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1716712ybh; Fri, 13 Mar 2020 06:15:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuFxEAHpHrosW04mYgP25Kv+Ui3rRc4AL79DdfmO3AuKUwaIg1cv8WjYy5ukRcsd/Sq/b4I X-Received: by 2002:a9d:2f44:: with SMTP id h62mr10608521otb.189.1584105304830; Fri, 13 Mar 2020 06:15:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584105304; cv=none; d=google.com; s=arc-20160816; b=FeEX77kJEJlbdLLnQc9bM50sLr6tqJOjwEBZOTiR4i3upx8RPyahCMRn3eh9AaHdGx PmWXcR3ayiFIsE5dM+72udRUdy6C2DAzzusr9Ng8151GPA2vP+S1KNzPS8Okhgp2zSmX e+YC/05VcBI9AxcGbJWNJFz9ud3GNXn63HYwMoIVSPF0U6vzycwtQJsmz3AZY1GNIOXZ oSFA+7oFINrFj90DPB3TBEyJtQ8qg9FaXcvocM0nbACJUXAsRxScpPi5/VDKFvgCs/AO wKUW7c+V2VB20q31xEJ0pe3wWO+zmTowkGmyVOp+TAEm45cmAFeegx9fVlTzCrSgYjEG RGdw== 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:dkim-signature; bh=r5nej1zKnErVM5m54Oa8OEYdJkqeTYbYSG60lIVS6MM=; b=gO7OTgjXlt/CpbKqEFXV7ztwXT6n4UejtK7AU+EudI7yaJH8yVmv1RwexCyIqYb8BE L1Pcc1ckFdEdmJG2pfIzU4coYzN0LO/6YKpz/m78GlpsSFttkR89HHZFyjUVHE5duS5x 24dbjUejbCwC9KQHAY7qtw/MxisHbUyRV3LxJCM4spx1m+AngqG3nrG848vhdElaXOml qTSi6pAxn0GVyi1EjsmPmgDGr/wDT93/zqDC9lZ3I8yZy/PGGiZ4Kl5tdOXJZViuOHlg dChlCA4sDYoUZT3oLHldYLn1ArBPW3TBsINHMlny8Nc5XNJtXGwzhOl36yU6YkhuYxiW ORuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AlM5pRFd; 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 j192si4427197oih.233.2020.03.13.06.14.48; Fri, 13 Mar 2020 06:15:04 -0700 (PDT) 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=AlM5pRFd; 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 S1726752AbgCMNOR (ORCPT + 99 others); Fri, 13 Mar 2020 09:14:17 -0400 Received: from mail-vk1-f195.google.com ([209.85.221.195]:34652 "EHLO mail-vk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbgCMNOR (ORCPT ); Fri, 13 Mar 2020 09:14:17 -0400 Received: by mail-vk1-f195.google.com with SMTP id w67so2608023vkf.1 for ; Fri, 13 Mar 2020 06:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=r5nej1zKnErVM5m54Oa8OEYdJkqeTYbYSG60lIVS6MM=; b=AlM5pRFdaXDjEYep11vgb+5n8li/qmCjD7OTv2H8gwaG4LR5CLy7UD/hPFTWaKbdLn qpUzrJj65b/u5moBdm1Z8zmDvNtnwbfkpurjBgjpSiD6fvuyec4p3KZ0lsqQg+hXdk/I x94A/LTz7EzPkaIo9LSAQO93wnDnBB7pfQpQ1fSINeagF4IHQnN9s+EENifH2Bopa43O ocHMUFUw+q1QqiMvnKdzGmhuaF8ypliYhDnspbR0eAHkIbPN1MYe/mnci5D0ZKusbmol nqei0veUc+3zGDmKDx9i5aJ1ca8D9rH9VBRQO5koUw+rEv+o7V2BwR8Phon75UtiGia5 sdhw== 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=r5nej1zKnErVM5m54Oa8OEYdJkqeTYbYSG60lIVS6MM=; b=XnHk9voI4Cl2gfUNca32DJffIttoGfEgWKPN1RIu11SxARWOGE0W93RXw0vPhoTLRk fLhtuPmHPQBgsjxxn0tSe+YgPoejLtdi3u1RT8L+jDX7nwD3j6t7okdCl/EC8udZ0rEd 8MHOsUdOuSm56lSm8FAWUm3JBedPCD64pxKlw/ESUB0PjpynKbWskA/uJxUj2Twa8zfx XFsM6TTJ7MtvIWABCg0S96iawVq6kRh8gphctDQlRJC1q5ix1Dx7Vrh2Q5fnpB/VxJgl 4Lge7vpUpXc4AbjIV3SeB1ne+PvrXA1KtpQbqimvbqL0+kfktxUuGzCmfgpKeswD5E+a TYDg== X-Gm-Message-State: ANhLgQ3Ibobvst50CbFxV4nD5BtYjEMUEc4hHxWw8jOci9XJPTACPwrE zGnXR+TNkPfCTBf+08UMPWRDE63Ov6BQBeCXeErWIg== X-Received: by 2002:a1f:52c5:: with SMTP id g188mr8502433vkb.25.1584105255211; Fri, 13 Mar 2020 06:14:15 -0700 (PDT) MIME-Version: 1.0 References: <1574254593-16078-1-git-send-email-thara.gopinath@linaro.org> <1574254593-16078-5-git-send-email-thara.gopinath@linaro.org> In-Reply-To: From: Ulf Hansson Date: Fri, 13 Mar 2020 14:13:37 +0100 Message-ID: Subject: Re: [Patch v4 4/7] thermal: Add generic power domain warming device driver. To: Thara Gopinath Cc: Eduardo Valentin , Zhang Rui , Daniel Lezcano , Bjorn Andersson , Andy Gross , Amit Kucheria , Mark Rutland , "Rafael J. Wysocki" , Linux PM , DTML , linux-arm-msm , Linux Kernel Mailing List 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 [...] > >> +static struct thermal_cooling_device_ops pd_warming_device_ops = { > >> + .get_max_state = ::pd_wdev_get_max_state, > >> + .get_cur_state = pd_wdev_get_cur_state, > >> + .set_cur_state = pd_wdev_set_cur_state, > >> +}; > >> + > >> +struct thermal_cooling_device * > >> +pwr_domain_warming_register(struct device *parent, char *pd_name, int pd_id) > > > > Maybe rename this to: thermal_of_pd_warming_register() > > How about pd_of_warming_register? It is consistent with other cooling > device register like cpuidle_of_cooling_register and > cpufreq_of_cooling_register. Well, we actually have the following: of_devfreq_cooling_register() of_cpufreq_cooling_register() cpuidle_of_cooling_register() So maybe this is the most consistent. :-) of_pd_warming_register() > > > Moreover, I think you could replace the "struct device *parent", with > > a "struct device_node *node" as in-parameter. That's all you need, > > right? > > You mean pd_wdev->dev.parent need not be populated ? The device > in this case will be created under /sys/devices which I do not think > is the correct. Good point! > With a parent device specified, the power controller that resides the > power domain that can act as the warming dev, becomes the parent of the > warming dev. In case of this patch series, for the mx warming dev, > 179c0000.rsc/179c0000.rsc\:power-controller/ becomes the parent.(The > device will be created under > /sys/devices/platform/soc\@0/179c0000.rsc/179c0000.rsc\:power-controller/) > > Other way might be to register the warming device under virtual devices > as a new category of devices. No, that sounds wrong. Another option is to create a specific bus type for these new pd_warming devices. But I admit that sounds a bit too much, let's assign a parent. > > I prefer to keep it as a child of the power controller device, but I am > open to explore other options and to re-do this bit. What do you think? Sure, sorry for the noise. > > > > >> +{ > >> + struct pd_warming_device *pd_wdev; > >> + struct of_phandle_args pd_args; > >> + int ret; > >> + > >> + pd_wdev = kzalloc(sizeof(*pd_wdev), GFP_KERNEL); > >> + if (!pd_wdev) > >> + return ERR_PTR(-ENOMEM); > >> + > >> + dev_set_name(&pd_wdev->dev, "%s_warming_dev", pd_name); > > > > Perhaps skip the in-param *pd_name and make use of the suggested > > "struct device_node *node", the index and something with "warming...", > > when setting the name. > > Won't the index have to be in-param in this case ? Isn't that already the case? Huh, long time since I reviewed this. > > > > > Just an idea, as to simplify for the caller. > > > >> + pd_wdev->dev.parent = parent; > > > > This isn't needed, I think. So ignore this comment, as discussed above. > > > >> + > >> + ret = device_register(&pd_wdev->dev); > >> + if (ret) > >> + goto error; > >> + > >> + pd_args.np = parent->of_node; > >> + pd_args.args[0] = pd_id; > >> + pd_args.args_count = 1; > >> + > >> + ret = of_genpd_add_device(&pd_args, &pd_wdev->dev); > >> + > > > > White space. > > Will fix it. > > > > >> + if (ret) > >> + goto error; > >> + > >> + ret = dev_pm_genpd_performance_state_count(&pd_wdev->dev); > >> + if (ret < 0) > >> + goto error; > >> + > >> + pd_wdev->max_state = ret - 1; > >> + pm_runtime_enable(&pd_wdev->dev); > >> + pd_wdev->runtime_resumed = false; > >> + > >> + pd_wdev->cdev = thermal_of_cooling_device_parent_register > >> + (NULL, parent, pd_name, pd_wdev, > >> + &pd_warming_device_ops); > > > > As stated in patch3, I don't get it why you need to use this new API > > for "parents". > > I agree with you. I cannot re-collect my thought process for this API. > I compiled and tested using the regular API and everything works fine. > I will drop patch 3 and use the thermal_of_cooling_device_register here. Great, one confusing piece seems to go away then. :-) > > > > >> + if (IS_ERR(pd_wdev->cdev)) { > >> + pr_err("unable to register %s cooling device\n", pd_name); > >> + pm_runtime_disable(&pd_wdev->dev); > >> + ret = PTR_ERR(pd_wdev->cdev); > >> + goto error; > >> + } > >> + > >> + return pd_wdev->cdev; > >> +error: > >> + put_device(&pd_wdev->dev); > > > > If device_register() succeeds you need to call device_unregister(), > > rather than put_device() as a part of the error handling. > > Will fix this. > > > > >> + kfree(pd_wdev); > > > > You need a ->release() callback to manage kfree(), after you called > > device_register(). > > mm?? I did not get this. What release callback? You mean for power > controller driver to call ? No, this how life cycle management of devices should be implemented. Have a look at genpd_release_dev() - and see how that is being used for genpd's virtual devices, that should explain more. > > > > >> + return ERR_PTR(ret); > > > > Another thing is missing in the error path, which is to remove the > > device for the genpd. I think calling pm_genpd_remove_device() should > > work fine here. > > I will fix this. I am thinking this will be be needed in > pwr_domain_warming_unregister as well. Yep. Kind regards Uffe