]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
PM / Domains: Fix error path during attach in genpd
authorUlf Hansson <ulf.hansson@linaro.org>
Thu, 26 Apr 2018 08:53:00 +0000 (10:53 +0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 14 Jan 2019 09:28:55 +0000 (09:28 +0000)
BugLink: http://bugs.launchpad.net/bugs/1807469
commit 72038df3c580c4c326b83c86149d7ac34007532a upstream.

In case the PM domain fails to be powered on in genpd_dev_pm_attach(), it
returns -EPROBE_DEFER, but keeping the device attached to its PM domain.
This leads to problems when the next attempt to attach is re-tried. More
precisely, in that situation an -EEXIST error code is returned, because the
device already has its PM domain pointer assigned, from the first attempt.

Now, because of the sloppy error handling by the existing callers of
dev_pm_domain_attach(), probing is allowed to continue when -EEXIST is
returned. However, in such case there are no guarantees that the PM domain
is powered on by genpd, which may lead to hangs when buses/drivers tried to
access their devices.

Let's fix this behaviour, simply by detaching the device when powering on
fails in genpd_dev_pm_attach().

Cc: v4.11+ <stable@vger.kernel.org> # v4.11+
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/base/power/domain.c

index 2f7cf8b73e412facef16f91a6b0510f9c640ae1e..b69edad3e936862b702c2693ced8dd283464ddff 100644 (file)
@@ -2253,6 +2253,9 @@ int genpd_dev_pm_attach(struct device *dev)
        genpd_lock(pd);
        ret = genpd_power_on(pd, 0);
        genpd_unlock(pd);
+
+       if (ret)
+               genpd_remove_device(pd, dev);
 out:
        return ret ? -EPROBE_DEFER : 0;
 }