Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2337497imm; Thu, 11 Oct 2018 08:43:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV6078HeNG5qrqN62ypuWXO1DcX3xcoq3WM7yrkS/KaYpuB5EylP/G71T2dNiGoavYqQLfPvb X-Received: by 2002:a62:6143:: with SMTP id v64-v6mr2102957pfb.125.1539272634057; Thu, 11 Oct 2018 08:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539272634; cv=none; d=google.com; s=arc-20160816; b=h1KJzpOhdediAtawWzce/8jF/r3uQq2vJfAR/3kVRqXP+cdXx4vhRxcY/l4VcRiu+Y AJt5OzRK4bpRPXnn3IJVtfUQUuj3IPXjShYDyFvf+Knb7Ezq1CzoLJwrbrTH4EZb8Tw0 Vp4maJSrqhJDXS7yhnKXggA2R5AHPZ/yHJr31Vtc+1wdNbPryVrU/HCpXhWv+DaoKAmA gJoOM65Q3ccrOKANg9RipNFNU6r8M17PlnlUan5++/3K+TcHfhZ8te37rcoc+mo2DW4d tsxhc+VtEro46bJFijm0W/o/vm6x6lsJ+5UpirQcZ14YU7ZcXQxbJk2y9yPMb9GLwGL4 OcCg== 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=ajlrRDMSH//Pph6yZUwWdIHOHsz+2+n4NiQG6lhOVHo=; b=nurNqvkA1W4XsQkP2c/7+ec6meFV5gcf+ofoNctNOJvEc9psL+0swT+pFekccH4yHl 0fwd4pWcjF7FqDjK2BpLDD/4yN3UTDfhwXcbM/sCVr8e2rGiOJAMDkvN2BIGV/+dljm3 WCu4Os+U9vhQyuhYgpLEb6Q5jYeafa5VjGfXh6aPlldybjjQAgemT3+1Vuy7anKHbKh2 qsrGFKhxQT4xXDTsdf0295yF5zmoMNM8OQ6soY2n58ikMK6eeK6t7PWY5UNvKoW8VaRP +IixM+P8UYVsk+itbDETXr19ClWH2pT/0DBZZERUMriakvOtd+xrH7zYPwylKk5CmvFo wXLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YrO2SoTH; 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 8-v6si25102141pgr.205.2018.10.11.08.43.38; Thu, 11 Oct 2018 08:43:54 -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=YrO2SoTH; 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 S1730761AbeJKXKZ (ORCPT + 99 others); Thu, 11 Oct 2018 19:10:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:41704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726700AbeJKXKY (ORCPT ); Thu, 11 Oct 2018 19:10:24 -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 06A5120652; Thu, 11 Oct 2018 15:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539272560; bh=zhSCPTYZWeIWsEGQmVJnrd7RACpXMKdLicsXTn75ZiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YrO2SoTHfjoQAZo7o66uSOyrbg0Qrf/N9xa4uAF2A03buNsQmfDEUfhmusOkeGBkV NBWVgkD71EGAkwG8sn8OU+1E60fOKCC5Hcfjqw4cxYXRS5oiJTNnSi3n+cznIjUGy3 OU1WQsDUFtBgtMdYGJS/SS8xWaUW+K09lN68P9pk= 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.4 07/27] PM / core: Clear the direct_complete flag on errors Date: Thu, 11 Oct 2018 17:34:54 +0200 Message-Id: <20181011152534.375860321@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181011152534.014964888@linuxfoundation.org> References: <20181011152534.014964888@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.4-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 @@ -1355,8 +1355,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 @@ -1368,6 +1370,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; }