• Ulf Hansson's avatar
    PM / Domains: Fix error path during attach in genpd · b7ac0389
    Ulf Hansson authored
    commit 72038df3 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: default avatarUlf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    b7ac0389
domain.c 64.6 KB