Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2748011pxa; Tue, 25 Aug 2020 02:02:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiWlLAEqyDVaTrSltZJ0Ol4GYlFXZiZpsjsMjLH3qAt26MiEuYOXqcoEh9300/zmZSK4sk X-Received: by 2002:a17:906:29cc:: with SMTP id y12mr9431013eje.212.1598346131162; Tue, 25 Aug 2020 02:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598346131; cv=none; d=google.com; s=arc-20160816; b=BJd0EBxfVdSupe3WRLiZdmkJ/283yMEjf5clFLJw6lFxDvhqh5xaRee4ABjg9ytJAe Q2yCq/nhCOUOZhPXPxiTt4ZDZO2oa9EAIO7yIWZ9xyf4d1wijHlnPsfAXrJUPu0YwOT5 IBiTCQ1YovQBuBynwmmwJWzqAjvu7/ECvj+bSKfbrdWF6be9fslJ6yFyqafiE6I8Mp95 KkJV4aJjdJqNHhWZ40waNjxN2uA5vjvy2cf3yFkWnCVmxYeggrZPDqDvT4QEmvMUCCDa gFBhgKN9Azt1v/5b2mdQZWYnYxrxOYjdQ6S0L2tbgpyAEXgMDqP0E4acItJPJ+COIg3v QQdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=N4MOIAhJ7IDpQKRVMkXvc+KbOjAKeaPaI3dLvUlfRuA=; b=rWE9AHmojDhJRtZz/RTg/z0Bp0YOXG6EYz5rTgEgSMseatKR3CFGmzIhbam92mQw7K vuSbyQVEAeyDqcU8LxdOdtfASAE4NOKDj0GEj5CHipGSNqxzdgqXUnImQftxVnaOnpnL ijqPIgTraXUIe1qGtW+BnP5Xt+gJgJ/bFd74RNF7meF5agZ4X7nAnJSLqS2pfDicO7ln VKG8BtJtw9GlDS/FNIi2KCOI4PT8gL7afz0/IO/Xzv0/sgW1DXeKdJPGe0BdbTkeGwnQ 9Sz7xyY2WmOwXTsi72/8lcd8RBFvvmMwMQ4qHe0Fxyzm9wpxCnpPn5EZFDhnjtn0BhKF KYzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u17si8302783ejt.560.2020.08.25.02.01.47; Tue, 25 Aug 2020 02:02:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728749AbgHYIWb (ORCPT + 99 others); Tue, 25 Aug 2020 04:22:31 -0400 Received: from mga11.intel.com ([192.55.52.93]:59286 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbgHYIW3 (ORCPT ); Tue, 25 Aug 2020 04:22:29 -0400 IronPort-SDR: +uvwERLmVArAAaOMKDcOu7+R8IaZgBeZdq06o+Z1oS586d4US5i6CwnDHi/3C5hF8J0xqzudpH tu1W9D3lb8Dw== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="153637398" X-IronPort-AV: E=Sophos;i="5.76,351,1592895600"; d="scan'208";a="153637398" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2020 01:22:28 -0700 IronPort-SDR: 0ShbA1Ett/jB2ldH4FHGwyu6LSx4xmAZ4qy2+qLFaPU236w4oBROoZWlPtWCntXpEi2v7yCrgB z0g3a3U2lBFg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,351,1592895600"; d="scan'208";a="402643628" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.163]) by fmsmga001.fm.intel.com with SMTP; 25 Aug 2020 01:22:25 -0700 Received: by lahna (sSMTP sendmail emulation); Tue, 25 Aug 2020 11:22:24 +0300 Date: Tue, 25 Aug 2020 11:22:24 +0300 From: Mika Westerberg To: "Rafael J. Wysocki" Cc: Linux PM , LKML , Linux ACPI , Greg Kroah-Hartman , "Rafael J. Wysocki" , Alan Stern , Utkarsh H Patel , Pengfei Xu Subject: Re: [PATCH v2] PM: sleep: core: Fix the handling of pending runtime resume requests Message-ID: <20200825082224.GX1375436@lahna.fi.intel.com> References: <1954100.8R8RjBe1nF@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1954100.8R8RjBe1nF@kreacher> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rafael, On Mon, Aug 24, 2020 at 07:35:31PM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > It has been reported that system-wide suspend may be aborted in the > absence of any wakeup events due to unforseen interactions of it with > the runtume PM framework. > > One failing scenario is when there are multiple devices sharing an > ACPI power resource and runtime-resume needs to be carried out for > one of them during system-wide suspend (for example, because it needs > to be reconfigured before the whole system goes to sleep). In that > case, the runtime-resume of that device involves turning the ACPI > power resource "on" which in turn causes runtime-resume requests > to be queued up for all of the other devices sharing it. Those > requests go to the runtime PM workqueue which is frozen during > system-wide suspend, so they are not actually taken care of until > the resume of the whole system, but the pm_runtime_barrier() > call in __device_suspend() sees them and triggers system wakeup > events for them which then cause the system-wide suspend to be > aborted if wakeup source objects are in active use. > > Of course, the logic that leads to triggering those wakeup events is > questionable in the first place, because clearly there are cases in > which a pending runtime resume request for a device is not connected > to any real wakeup events in any way (like the one above). Moreover, > it is racy, because the device may be resuming already by the time > the pm_runtime_barrier() runs and so if the driver doesn't take care > of signaling the wakeup event as appropriate, it will be lost. > However, if the driver does take care of that, the extra > pm_wakeup_event() call in the core is redundant. > > Accordingly, drop the conditional pm_wakeup_event() call fron > __device_suspend() and make the latter call pm_runtime_barrier() > alone. Also modify the comment next to that call to reflect the new > code and extend it to mention the need to avoid unwanted interactions > between runtime PM and system-wide device suspend callbacks. > > Fixes: 1e2ef05bb8cf8 ("PM: Limit race conditions between runtime PM and system sleep (v2)") > Reported-by: Mika Westerberg I guess the more correct here is Reported-by: Utkarsh H Patel > Signed-off-by: Rafael J. Wysocki I also got confirmation that this fixes the reported issue and did not seem to cause regressions either :) Please add the following tags: Tested-by: Utkarsh H Patel Tested-by: Pengfei Xu Thanks for fixing this!