From mboxrd@z Thu Jan 1 00:00:00 1970 From: Niklas Cassel Subject: Re: [PATCH 2/3] PM / Domains: Allow OF lookup for multi PM domain case from ->attach_dev() Date: Wed, 24 Apr 2019 13:28:31 +0200 Message-ID: <20190424112831.GB30710@centauri.ideon.se> 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 Return-path: Content-Disposition: inline In-Reply-To: <20190418102757.1246-3-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org To: Ulf Hansson Cc: "Rafael J . Wysocki" , linux-pm@vger.kernel.org, Greg Kroah-Hartman , Jon Hunter , Rajendra Nayak , Viresh Kumar , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org List-Id: linux-pm@vger.kernel.org On Thu, Apr 18, 2019 at 12:27:56PM +0200, 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; > -- > 2.17.1 > Acked-by: Niklas Cassel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E69BBC10F11 for ; Wed, 24 Apr 2019 11:28:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B5E5F21773 for ; Wed, 24 Apr 2019 11:28:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QJELUQ7D"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CfOV/TLn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5E5F21773 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XIyvjoLEuIeTi+Z1+YCXRcTF7iPg8R6Y4unvfKnHGJw=; b=QJELUQ7DFyM2/u lF0uIkhB/8KR3M1egmJ80DBTigyBPmgGG4UB0nYe9jI488RbaTpBTlKhkoFLvD9zkf+CcOi97UR+6 +iHuYax13NSloO4LsE/DbB4GxWFVm9DppyWlCwcD9WvxBstTVhfBkb5NAQ2I3vkQcRV/BIbFSBbxS Ck6Un1TZi/M3xmIF43/rzXR8m2LZUXzlpXmF4XdJFFR839diqmoItQzHhe+4nWHeITyHL3nfTP4xg JRLp+Ah+oY0Upud1WBgvfBKJvK11ZTe5rMKVOl7p6BBiCx7gADVTAaPRLaO1li9EQb4cigtLelUYL qHRRvJt+AWRiV+AUC1HA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJG4z-0000ht-Nx; Wed, 24 Apr 2019 11:28:45 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJG4v-0000gC-J9 for linux-arm-kernel@lists.infradead.org; Wed, 24 Apr 2019 11:28:42 +0000 Received: by mail-lf1-x141.google.com with SMTP id v1so1909038lfg.5 for ; Wed, 24 Apr 2019 04:28:41 -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=JLAt8vXpMzvmVMwhnN+jHxhJwJGzPfS5OLUsC0yAZUA=; b=CfOV/TLnhnkg1juwsOsG01zyv6OsZwNul3cYLmIlKkBzEQNPYchHfDfrA1XG8UFTZg Zisj5nIZLhM5tsg9LCkTabeJAL5U33AcPixX04OkFH2k3arFVBKKp+2akXurJEtquQUy GuvVvkrTVxnu7DUYUqccHH4sT3+2335dtWIAIpfiCRNtZucw1BbUXUwGPq/BheyfH1Eq i+P6br0gOv+2BaX+ESt1RsRyC1Kn+sKjV5oxki+OrER8yjkdywfBuT+NEEhbzwG6raKa 0SQ2cX5uNo+4DKF4BKovq2QuYusUJyWNjlNDpn3kyxrCuEHFV47CrLGFnz4A0rv6vhWr fpiw== 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=JLAt8vXpMzvmVMwhnN+jHxhJwJGzPfS5OLUsC0yAZUA=; b=izZrRdOrGGZCtL48B0mi3vaJhyH+UzXfPxzlsXxEYqd5+CUhQj18yEolF+IopRiA5s 4e4OLHgK8vepqlXUzL9O0psnyg0B1fy39HX1V4jJyIlfkDxm4bJoUzd59lB799Lo8DPw iMbeEbMVK8nDigrFSshzAlg58IjvwslyIE+iIo0WQxXSO7EYMKCDq85cTy/21tAC7GTa 1flnO2r+uoY24Li3oPRwkFCzpbB50xvDp4gpvKT70PYlCEnbQDpxz1sF0hX9+gwmtzcb 74m6l50VqU3vhTWGik6NnC4J0a3GWbekAKTXXObJbYSMsbsNIl4+MC2D/KeA5+yt5aW1 5CNA== X-Gm-Message-State: APjAAAUylLwgnb92WEUTbgSAb1RAZC7wDjN4p7bOLYe56C4EXGc1uKZu pzxm9QtbEfxGP3BQgnf2jVBpCQ== X-Google-Smtp-Source: APXvYqyXYE+d2mJ/Y3bIRxfDu7tFy+jH5o51AUMUHYw2Dw0uZUcir5eojjpE21qgwwPUcicQTdEiCw== X-Received: by 2002:a19:4b51:: with SMTP id y78mr16907674lfa.152.1556105319570; Wed, 24 Apr 2019 04:28:39 -0700 (PDT) Received: from centauri.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id g5sm1179521ljk.59.2019.04.24.04.28.38 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Apr 2019 04:28:38 -0700 (PDT) Date: Wed, 24 Apr 2019 13:28:31 +0200 From: Niklas Cassel To: Ulf Hansson Subject: Re: [PATCH 2/3] PM / Domains: Allow OF lookup for multi PM domain case from ->attach_dev() Message-ID: <20190424112831.GB30710@centauri.ideon.se> References: <20190418102757.1246-1-ulf.hansson@linaro.org> <20190418102757.1246-3-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190418102757.1246-3-ulf.hansson@linaro.org> User-Agent: Mutt/1.11.3 (2019-02-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190424_042841_627356_D9BE1E64 X-CRM114-Status: GOOD ( 20.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rajendra Nayak , linux-pm@vger.kernel.org, Greg Kroah-Hartman , Kevin Hilman , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Jon Hunter , Viresh Kumar , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 18, 2019 at 12:27:56PM +0200, 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; > -- > 2.17.1 > Acked-by: Niklas Cassel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel