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: 8782851 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C62E79F659 for ; Fri, 8 Apr 2016 11:10:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE8E520222 for ; Fri, 8 Apr 2016 11:10:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D4A620295 for ; Fri, 8 Apr 2016 11:10:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757969AbcDHLKa (ORCPT ); Fri, 8 Apr 2016 07:10:30 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:33151 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756517AbcDHLK3 (ORCPT ); Fri, 8 Apr 2016 07:10:29 -0400 Received: by mail-lb0-f174.google.com with SMTP id u8so67234445lbk.0 for ; Fri, 08 Apr 2016 04:10:28 -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=QihoViJJ98+ZErNeGVPpwtLGli8ftJ08/uIDlPFtfpN9JSok4/s/HrXtDpzS/QP9AK QjBd5H3tNPlpbHYpyIhj0js75+JvQ25gg5iHRKXJuGS0lj9uQbU96wpuQveuuc6h8VWD RUnT8n45EznWCOGAaFYHME9CjP4AozbZESO6uWWW7yW2r8h9hcE3oQtt6dp5scsyq/AH sDZw6C0APik9B+DnnHOeD1W+nLLVggrFDKrfiqct5c/ad5X5+xZ9KT+7BPcydEgfx41z QClcBMhXDiQo+GCLXECn9aHfl0WiRR4HhX/DkpNPrnJtoPVbhKNyH2Aewb1ihHDtqIIH Yh0w== X-Gm-Message-State: AD7BkJKXwIz/WZkB0UqxdQtBYi75qUjiyHNj/8jYjwJU9OYR6IbjOLQMTELL12MddcudLCgJ X-Received: by 10.112.132.36 with SMTP id or4mr3316258lbb.71.1460113827722; Fri, 08 Apr 2016 04:10:27 -0700 (PDT) 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 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Linus Walleij --- drivers/base/power/runtime.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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);