Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2168172yba; Mon, 22 Apr 2019 01:30:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLbSaPXbxwytGbUh5ijnRgtDwrlDDxKHBaAGSDQNrBMX/4HAAq0QBISheVFUtKHwVbT1VR X-Received: by 2002:a63:8c7:: with SMTP id 190mr11475139pgi.447.1555921842538; Mon, 22 Apr 2019 01:30:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555921842; cv=none; d=google.com; s=arc-20160816; b=0Sq3CrARGOAMjdpREiPpSftoRLUBi72iaAukCFk+wWYkTIoUR4vfsp7qSAzl3fKZSu +a9FAwNtiW6CKmBYt76wZBOlyhQF+qdHQlLcWUl9nB8CAGs0zCWOwELkHjb/Uo6+2G6V Lr77Gjnv39X1XYhwS8oGzWKGTEtiHCtxI9vLvg9g0oI+DIVOs5BUPefvCRjx1ws0H2e3 /JFWxdy/hQSb0BG2vaW8NeE/Ql2TGfxN903P5aviAX3YqVq3D9wqS4K5/k+UgHpk2mwj BM6VFC4unwjngxkkBd8eSxDzLYRdsrH9GUYyWBVoVOJX2xM+PisF9OWLvv1NyGolFOpm jhbw== 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=m3PGwlPpsgyUOyS06ZuqKyJ0QDPzAiZx9VGT4pfrN3k=; b=RvYlSKGX6tRR/rNTaQ/0YNmcDIKcEY1BGpOPLD+6AB1NmxwYf5j9qv0YttZdQhtpcm Spq6aCqG/rUhqhVQhAc4W1ny/ZdWUmRsrF8NYqzKFVdRh3efP0KXEMJBqtx0VUidXYhY 3d8Q+/LUvqp+P9d2A/BRIchS4t7uhSoaoalpEdjqi7r8NmdHNzRnHIop4IdQyeMatw5/ xbE1usu2YobPbXV6Cr4njLiGvMO4dzs65bfoJdVY8TqsnfDUQ53RdpKjSOhj75F+UsoV f2aeyXqcVOzRUHYItxck1rGf+F4M68EwIDvDuqu9Xx+dXi1aaAwj3v+aHLdvT1fwvoWL gq+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kt5S6/He"; 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 j11si12708304pff.216.2019.04.22.01.30.27; Mon, 22 Apr 2019 01:30:42 -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="kt5S6/He"; 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 S1726915AbfDVI3W (ORCPT + 99 others); Mon, 22 Apr 2019 04:29:22 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44005 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbfDVI3V (ORCPT ); Mon, 22 Apr 2019 04:29:21 -0400 Received: by mail-pf1-f194.google.com with SMTP id c8so5371081pfd.10 for ; Mon, 22 Apr 2019 01:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=m3PGwlPpsgyUOyS06ZuqKyJ0QDPzAiZx9VGT4pfrN3k=; b=kt5S6/HeQFZb+baPgbDeRQaq1ulahzGuOJnfMnVqlAYkPa40GW9OGm16ZSxpA2MUnJ lNs6EDNHvDKLFg/4kSqJ2Pe3h/f7VlQolgDk0vNgRhpN652pH5h4QgqKT3eUR1+gzcVE IAR7ogU6SG981PUrqZ22F7evcnHNurzPUZM4eb/WD4ZRLgNSFbIsIt2SR/R6bAQNmXbs IgXv4SEq/uto1skDWV7yGjZXledAxnAB3ja2HyIUvxMrE/BmZ1f3WM/f4haDiPfxLF6O uihHbqwPwkav1cMfssJkrGMh+6yzE9wspUz8yk+hPtf54QnWZN+yFyG5Y6fAYk9IrzqA MKOw== 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=m3PGwlPpsgyUOyS06ZuqKyJ0QDPzAiZx9VGT4pfrN3k=; b=IPDfT3V5pNehHmLMwPk/yU4KWNWDbM8DLeQ2jZJqJhhSCvlAdbKqh2NWMNZdERO9/e UY6yXHsXOC5xpDE+N8be1ytUS+eiP8JZnBpJtotfDJyAsZEWUWWiDnyjxfnXPj0Gmhqu +b5ElytOHxo45aLKdLn/mLUzwPawm7wwfQGe9clU12Z9OnHtmA9CDCCzrGkUKnb6WoXO nDV2iuxWAK4L+QVKq4TLkgSghaD41tzXZ8NtDXtJkFwDaPGdzXC4ut7bD6b/iwi0zU+w Za+u3B1RiRzQ4WwOA+kfpZzegAV6Y2Kq/f7RT2FkcmdoSA+OQIxaGh2EJywtEiJbfyrt GBjw== X-Gm-Message-State: APjAAAVAQS066uEjjRHZQyLKj8iCyBKltmRlNmeSCMPWq6QBQ/edoZh5 eHlVEVz/8GtKjVXMQCGeF31fRjpR0tk= X-Received: by 2002:a62:1b03:: with SMTP id b3mr19112503pfb.150.1555921761145; Mon, 22 Apr 2019 01:29:21 -0700 (PDT) Received: from localhost ([122.166.139.136]) by smtp.gmail.com with ESMTPSA id d38sm14812418pgd.40.2019.04.22.01.29.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Apr 2019 01:29:19 -0700 (PDT) Date: Mon, 22 Apr 2019 13:59:17 +0530 From: Viresh Kumar To: Ulf Hansson Cc: "Rafael J . Wysocki" , linux-pm@vger.kernel.org, Greg Kroah-Hartman , Jon Hunter , Rajendra Nayak , Niklas Cassel , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 2/3] PM / Domains: Allow OF lookup for multi PM domain case from ->attach_dev() Message-ID: <20190422082917.3yaxzyg643sdjsji@vireshk-i7> References: <20190418102757.1246-1-ulf.hansson@linaro.org> <20190418102757.1246-3-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190418102757.1246-3-ulf.hansson@linaro.org> User-Agent: NeoMutt/20180323-120-3dd1ac Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18-04-19, 12:27, Ulf Hansson wrote: > A genpd provider that uses the ->attach_dev() callback to lookup resources > for a device, fails to do so when the device has multiple PM domains. This > is because when genpd invokes the ->attach_dev() callback, it passes the > allocated virtual device as the in-parameter. > > To address this problem, let's simply assign the dev->of_node for the > virtual device, based upon the original device's OF node. > > Signed-off-by: Ulf Hansson > --- > drivers/base/power/domain.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > index 7fec69aebf46..801f31c87d16 100644 > --- a/drivers/base/power/domain.c > +++ b/drivers/base/power/domain.c > @@ -2345,6 +2345,7 @@ EXPORT_SYMBOL_GPL(of_genpd_remove_last); > > static void genpd_release_dev(struct device *dev) > { > + of_node_put(dev->of_node); > kfree(dev); > } > > @@ -2406,14 +2407,14 @@ static void genpd_dev_pm_sync(struct device *dev) > genpd_queue_power_off_work(pd); > } > > -static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np, > - unsigned int index, bool power_on) > +static int __genpd_dev_pm_attach(struct device *dev, unsigned int index, > + bool power_on) > { > struct of_phandle_args pd_args; > struct generic_pm_domain *pd; > int ret; > > - ret = of_parse_phandle_with_args(np, "power-domains", > + ret = of_parse_phandle_with_args(dev->of_node, "power-domains", > "#power-domain-cells", index, &pd_args); > if (ret < 0) > return ret; > @@ -2481,7 +2482,7 @@ int genpd_dev_pm_attach(struct device *dev) > "#power-domain-cells") != 1) > return 0; > > - return __genpd_dev_pm_attach(dev, dev->of_node, 0, true); > + return __genpd_dev_pm_attach(dev, 0, true); > } > EXPORT_SYMBOL_GPL(genpd_dev_pm_attach); > > @@ -2525,6 +2526,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, > dev_set_name(virt_dev, "genpd:%u:%s", index, dev_name(dev)); > virt_dev->bus = &genpd_bus_type; > virt_dev->release = genpd_release_dev; > + virt_dev->of_node = of_node_get(dev->of_node); > > ret = device_register(virt_dev); > if (ret) { > @@ -2533,7 +2535,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, > } > > /* Try to attach the device to the PM domain at the specified index. */ > - ret = __genpd_dev_pm_attach(virt_dev, dev->of_node, index, false); > + ret = __genpd_dev_pm_attach(virt_dev, index, false); > if (ret < 1) { > device_unregister(virt_dev); > return ret ? ERR_PTR(ret) : NULL; Acked-by: Viresh Kumar -- viresh