From patchwork Thu Apr 18 10:27:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 162454 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp563483jan; Thu, 18 Apr 2019 03:28:06 -0700 (PDT) X-Received: by 2002:ac2:4566:: with SMTP id k6mr15240780lfm.22.1555583286018; Thu, 18 Apr 2019 03:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555583286; cv=none; d=google.com; s=arc-20160816; b=KRlaVObF3htHsENxrVcs1oMGiCAz3XNkApFh21f3O6ZrWN3bNPyNYVl4ZqgZwt2SJ0 2Gd/9s9jfmtYbekVnA+YXf5s50U/3Ci6yI4wo7aaBK8UpYoTX1LYCvTdnbtw+cUtKIEh huzSGHEa0DtrVN1ETOQClDzqnn256fYkVOi27WwXbku+qRHYBba5sXSIaHs+8By5M1Tp TMuVcKZl8zHpVVqilMqmb2iNpfhA4c0VRF4hNTN8sdJVsgy+EOr3yEOmczlK02dlfCpx rryZi27WNcXAxrlHwO7Uufy6qYY/kfzYnGgJzoO2+da2j33Izh9ejjBkYoG2oKCu9T/H AKwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BLvAgBQDq6vF0i+wC/iY8ot3SYyciBGpMv8ybloeX/8=; b=fk9XlwU5Oo9FmgKSG7umZRuKMzZ/zqEZmUh3tjdjGj7S/cNtwgAifm5W8Rcl66U04r ll46wijAzLiORqahOyQqH+2LRTDDGnVgwgu9ONkIHByUoh4i0hpaD6Q0KUi8AeFsb1FL zIg+Y6TElZy+rO8ZWLuRheSyN32aBTwCKPOD2S/htrmCMKQY4EUtEyvWzY7V83isxzLw zYnC4vXssEtpiJvJuN3SL7S8ZAnzSZ4ZDlyBxYE5M96R9MSI2cfWaqTz/weaD7SLpj6i qTaOSKooDsriCa9mh9HFyoRlBz0xa8G8ZpZsMdUerjSPBNhabf5qeVhww2OLVwWLM8c2 wdjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UWjsHT1s; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p5sor821877ljg.8.2019.04.18.03.28.05 for (Google Transport Security); Thu, 18 Apr 2019 03:28:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UWjsHT1s; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BLvAgBQDq6vF0i+wC/iY8ot3SYyciBGpMv8ybloeX/8=; b=UWjsHT1soOCJol5kUrl4LvjOrmosF6Qvw1AlY4/rgZDKzdy0IOQ02rKUvJz1QU8gNS auSsccy7TFGnzKgKOC1bfnesKoR5bh0WoCMoy08Rq41b0kX1EP2CTMImfnNm59uHJLoE IZjc9ctIk/jINg1QD2Rf1VzNaJSDu5nibKxED3wklqMYDgxyAEjyzoqKJi0zikzveq+R X58rwBvNBMFh5psCB8ctl8jFZ7i6IkWgd+Hz9ktJ5yIBkuV+BdJFQ01a+bCearHLoCE4 LUcJXp8cIkbUXX2k6QObhuUjUaYTEJjlu/YKbBTRe6e7owNpatgqbz6seu+kgy5pi87T h45A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BLvAgBQDq6vF0i+wC/iY8ot3SYyciBGpMv8ybloeX/8=; b=kq9yXedfQHWg3hTCjTkADi0wD7RMqBZT19bmSkfbKfzOG6lm+byFXdF07xKl1UymAs CerI6JHXZfITXMM8SbL/oI2XmsZs3IF2hjaOagUQSxnGKfXBb290RQoN/NFgtYlBu37M rA4oZaCiRNW3Yk+SjSf9sCStIX8Hv6JTFjhlk2BOZEmphG6CLq6SDmSCwRIZcZwfB6w0 OHJAon9SbgN12+xSIoI4yAjUAb3RxU2dnAWfLxxdMB4H8EhAo3exASvnAS4FgVECR0X5 5jtHbo+iVJqgQQT1ufcvsr64ztlsPmKJEbnbJbeQpAn6JAh2JP8cqnoIzcHggg50BgCt 12cA== X-Gm-Message-State: APjAAAVSo49h0knqTMRwvMIhLi77rwFJmbQX/GQysLHd57lo639lxhx9 qOFWOqkFP9d2kPGWlVSvtWrux1nV X-Google-Smtp-Source: APXvYqxP+kiPYsKyAHgOMKr4NxfGd1gczUvjp0zvE12QTUzn6AhXfh0nI+0yjdus7Gtj4hdq5UvIVA== X-Received: by 2002:a2e:711a:: with SMTP id m26mr50832819ljc.40.1555583285587; Thu, 18 Apr 2019 03:28:05 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id l13sm320409ljj.96.2019.04.18.03.28.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 03:28:04 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Rajendra Nayak , Viresh Kumar , Niklas Cassel , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] PM / Domains: Allow OF lookup for multi PM domain case from ->attach_dev() Date: Thu, 18 Apr 2019 12:27:56 +0200 Message-Id: <20190418102757.1246-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190418102757.1246-1-ulf.hansson@linaro.org> References: <20190418102757.1246-1-ulf.hansson@linaro.org> 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(-) -- 2.17.1 Acked-by: Viresh Kumar Acked-by: Niklas Cassel 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;