Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3067858imu; Sun, 9 Dec 2018 16:32:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/UZBvwYnezaWCSH6ZNb7Qz+WpmZLvFKM29uGSuL8Zw4UEjhphW1zQCyiPe9J/+FeAEuveU4 X-Received: by 2002:a62:5486:: with SMTP id i128mr10124872pfb.215.1544401944197; Sun, 09 Dec 2018 16:32:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544401944; cv=none; d=google.com; s=arc-20160816; b=M1cZeayMf0g+N9WKjRab3+ACtDhjbIsQJKyYVZjZeAI/KxH5DcdqIMnszH9ZQ3/Lnh cDUFp6NhkG8O0Xa5IgzvxXs6h72+cjxmKEPmVWALfO4VMyr8vREBxgn0gUvmsYzIQJA8 6N6Auq89tLEYpgT8MNpGyXBugqSAkAAGHrV9A1J6JCEIE8fNWdD/1+9u+d/W4rzf6PNB gZxA9B8i+oDy5gty0OeAobxgv2/8HT/PMZonwABsd2dYta0d5fQ6JNJE2VETjqfztJWz t4GWkDAjzx43/5x2iYy+z1v/t+tQ0/bon4Se8aHK3yyyGQTcGeZGz/5obi6RWtEj+Q1I YOWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=2QZ0TW2wEfmZsctDHVs4xAVmpNQLxGTeEU6//bQ134M=; b=uymgLTlAuLf3msUdu+skUuuBHizXp7zbNOhJTigQjSfhDrKPnl3JNooitYuZWshdz5 j897K+hP73uP8+54Zr3R6WCKt2/vv01p2/fSEisaTXFU0qJDnfED0rMBWizZfJftRZfd WsU16uOw2OtnXgY19eD0ihJ0ZXC6KziXCpSIGlmqN5y8J6pOEkYd7tv4jjWdf/1CILyq 6MhrgO9wQGFirXee2egVilFHxzBtfJPS3/4MxHHZPXxziVMk2Ftxp7afy2EbJ/IF2uKP XnYMrBkwzmskBJpuy4HVSp09aA9XrdNeSylGbFf/o0VNUcKqNcMz8yAaesDNhdg5CVWj G1tg== ARC-Authentication-Results: i=1; mx.google.com; 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 191si8126978pgd.228.2018.12.09.16.32.09; Sun, 09 Dec 2018 16:32:24 -0800 (PST) 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; 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 S1727914AbeLIWVP (ORCPT + 99 others); Sun, 9 Dec 2018 17:21:15 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35336 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbeLIVzX (ORCPT ); Sun, 9 Dec 2018 16:55:23 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW72n-0002ic-A3; Sun, 09 Dec 2018 21:55:21 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72k-0003eP-HV; Sun, 09 Dec 2018 21:55:18 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Al Cooper" , "Rafael J. Wysocki" , "Ulf Hansson" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 293/328] PM / core: Clear the direct_complete flag on errors In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 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 Signed-off-by: Rafael J. Wysocki Signed-off-by: Ben Hutchings --- 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 @@ -1336,8 +1336,10 @@ static int __device_suspend(struct devic dpm_wait_for_children(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 @@ -1349,6 +1351,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; }