Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2340755imm; Thu, 11 Oct 2018 08:46:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV60fAxWBL3NuAtXc6C4bcc3JUIsyLNiZEnuqVqwMX+C25UNy36mQel3zrk4VkmFfzIIONBNl X-Received: by 2002:a17:902:7c8b:: with SMTP id y11-v6mr2064655pll.321.1539272816578; Thu, 11 Oct 2018 08:46:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539272816; cv=none; d=google.com; s=arc-20160816; b=dVLHAFAhwYkrMC4ftvNPtILNkNvzEcxxskB/fmZAdIhOHjid8W/cE2iUH1o7hEAiPO PMzUBuo/SrRPORxGCGSmEx0X9+pkSSA9bTUK8bh5FBMxaqUJh8quIka2rCAUb9PGv1xN SCrUqrpLfP0efUbwcJj3lvWVlmFKdU9UuMy+CsOXcMa84inRc7ozF0EqriZXyIXv7oN/ 3zdPQOqlwlrsvnBhobRDiZtWEmsJ1UH7Mks5Mw9kDcBl9IAaHW1RQdxWUw42P4Pn6sse 6Ct8c1E6YavtG6u9O0VU4xTodfUFzLwR9d/qvUCK2P63i9WeZO1G5VfdL1n4ocSmX2Rk cI3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p/HH9yjpeB3y+KEOqtRIVXFXuIV6Q0eZOYd0y+vhJCE=; b=Obu1OrcoPQPqk4ArNhNUgahnG9wxUMKaTm32nvcI1I83YX2KATFleOFbEH9QqsCq5G peKh94fj4BRG2rY+10AtDWYfZMWJntNNFDRh5zrUJu775BcoZiz+i8BWK5Z/bkLZ3A+F c9pa5QZMjKAKopZCKxrQuM7LRRZNxlMzHkP16H82noq0OPWBTqqbahIXcA7sKYLxmNdp SrFzmnG4aixa6FqFn0dsQtsNOMnJT7TqRS47cRsaZjXrLKODT8N/nk/9zCfJ6lJtHfoz wvacSOJmxuzfFCUAe4rKGPXMlVU5SPLJ4BJToyXjR3fXV+ZjWLUG951X5mUzF5uJ6750 sHPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hTtp/ZJo"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3-v6si3297739plk.295.2018.10.11.08.46.41; Thu, 11 Oct 2018 08:46:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hTtp/ZJo"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731327AbeJKXNN (ORCPT + 99 others); Thu, 11 Oct 2018 19:13:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:45686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbeJKXNM (ORCPT ); Thu, 11 Oct 2018 19:13:12 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3507020652; Thu, 11 Oct 2018 15:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539272727; bh=9zMGcOlFgOXMz/9Yd749wfYZm4ziHNzieHNQ+D88j4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hTtp/ZJoUh+CPu4xFrsFyxuCSJXh7e8L+xOoyXJ0HZwVB9ZL2pg1mQu2SxVNB+4k1 56xdC0bPbEf1oa/4z3wycJcv3Xe0Ra7apLFK5d1Qy6coy3QL/ghOJwYCHtpFaGBss1 7Y+rIPmvpxvWhSgIbL6HJ3HalqI4dlmeMVAkZcS8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Cooper , Ulf Hansson , "Rafael J. Wysocki" Subject: [PATCH 4.14 18/45] PM / core: Clear the direct_complete flag on errors Date: Thu, 11 Oct 2018 17:39:45 +0200 Message-Id: <20181011152509.645279281@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181011152508.885515042@linuxfoundation.org> References: <20181011152508.885515042@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rafael J. Wysocki commit 69e445ab8b66a9f30519842ef18be555d3ee9b51 upstream. If __device_suspend() runs asynchronously (in which case the device passed to it is in dpm_suspended_list at that point) and it returns early on an error or pending wakeup, and the power.direct_complete flag has been set for the device already, the subsequent device_resume() will be confused by that and it will call pm_runtime_enable() incorrectly, as runtime PM has not been disabled for the device by __device_suspend(). To avoid that, clear power.direct_complete if __device_suspend() is not going to disable runtime PM for the device before returning. Fixes: aae4518b3124 (PM / sleep: Mechanism to avoid resuming runtime-suspended devices unnecessarily) Reported-by: Al Cooper Tested-by: Al Cooper Reviewed-by: Ulf Hansson Cc: 3.16+ # 3.16+ Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/base/power/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1462,8 +1462,10 @@ static int __device_suspend(struct devic dpm_wait_for_subordinate(dev, async); - if (async_error) + if (async_error) { + dev->power.direct_complete = false; goto Complete; + } /* * If a device configured to wake up the system from sleep states @@ -1475,6 +1477,7 @@ static int __device_suspend(struct devic pm_wakeup_event(dev, 0); if (pm_wakeup_pending()) { + dev->power.direct_complete = false; async_error = -EBUSY; goto Complete; }