From patchwork Fri Apr 8 11:10:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 65394 Delivered-To: patches@linaro.org Received: by 10.112.228.228 with SMTP id sl4csp1511lbc; Fri, 8 Apr 2016 04:10:28 -0700 (PDT) X-Received: by 10.25.147.77 with SMTP id v74mr3562358lfd.19.1460113828109; Fri, 08 Apr 2016 04:10:28 -0700 (PDT) Return-Path: Received: from mail-lb0-x22e.google.com (mail-lb0-x22e.google.com. [2a00:1450:4010:c04::22e]) by mx.google.com with ESMTPS id k66si6675149lfi.38.2016.04.08.04.10.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Apr 2016 04:10:28 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c04::22e as permitted sender) client-ip=2a00:1450:4010:c04::22e; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c04::22e as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lb0-x22e.google.com with SMTP id vo2so67241578lbb.1 for ; Fri, 08 Apr 2016 04:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=NMtBU9bARcBSS2Mv7BPSvf9isZqzECBzzHAml57jn/4=; b=JZw6EN2EtDTm6jhGo+qJ3hhz6pmd10c1QXaFQZJL7ZI105Rm0rDH83Z9IDQnp9/L5v YR3jZhns5jX2HtB7DQ7+ctky07FBWNrpgPXXRSRK/wIz7VevsL9TS4Xj04ub4oF3Z31i ZmOI7bHctTpAY1+/umQuEubEzq92mtk3KQ7Xc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=NMtBU9bARcBSS2Mv7BPSvf9isZqzECBzzHAml57jn/4=; b=IiyQsDcfmEqwpi0JOsp//4nIE2BdUXICQRMINX6QAXFdqocvr3g8TICcJRlt/+sqny FsOOlLEEc80HvhJOJH2amkYEgQBKCxrs1zXAVYo51awZlN8G4PXyTCWIqkz50KN7lSfS GOvZ7kU7p6sH4pjofj1RONf/HN1JrPz6BEpSXdrVcXAm9AVQT4buK8Tt+IJJzhDKoMBZ 4BExTYNoFGLYgUYbV0cSTvGRhBoXdKxyeDEzir+ifk4yFQb5I/eus5qjaq4kWJfJ1Sib O0t/BMd4GufjpgXlACxqJ0cxfrmOoFTRkperQPRvRTS5RAL/6hyYPqCNIA9NRbe5VMzI 7reA== X-Gm-Message-State: AD7BkJITKo+78CMeYuKORynSp7oLMVzpm/1WmJKlXEtOFqjHwahNvrKEm2Mvcb8SP0ginjm8T3k= X-Received: by 10.112.132.36 with SMTP id or4mr3316258lbb.71.1460113827722; Fri, 08 Apr 2016 04:10:27 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-128-67.na.cust.bahnhof.se. [155.4.128.67]) by smtp.gmail.com with ESMTPSA id sv1sm1923549lbb.26.2016.04.08.04.10.25 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 08 Apr 2016 04:10:26 -0700 (PDT) From: Ulf Hansson To: "Rafael J. Wysocki" , linux-pm@vger.kernel.org Cc: Alan Stern , Kevin Hilman , Len Brown , Pavel Machek , Linus Walleij , Ulf Hansson Subject: [PATCH] PM / Runtime: Fix error path in pm_runtime_force_resume() Date: Fri, 8 Apr 2016 13:10:23 +0200 Message-Id: <1460113823-32290-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 As pm_runtime_set_active() may fail because the device's parent isn't active, we can end up executing the ->runtime_resume() callback for the device when it isn't allowed. Fix this by invoking pm_runtime_set_active() before running the callback and let's also deal with the error code. Fixes: 37f204164dfb ("PM: Add pm_runtime_suspend|resume_force functions") Signed-off-by: Ulf Hansson --- drivers/base/power/runtime.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 1.9.1 Reviewed-by: Linus Walleij diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 4c70550..b746904 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1506,11 +1506,16 @@ int pm_runtime_force_resume(struct device *dev) goto out; } - ret = callback(dev); + ret = pm_runtime_set_active(dev); if (ret) goto out; - pm_runtime_set_active(dev); + ret = callback(dev); + if (ret) { + pm_runtime_set_suspended(dev); + goto out; + } + pm_runtime_mark_last_busy(dev); out: pm_runtime_enable(dev);