Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp621580pxb; Fri, 13 Aug 2021 02:38:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQic4xACI0Sz19ByZ9pwfFyrx51f92qQt0rHcDotEzorVLIJugqTozwSThUuT2G89oKdj1 X-Received: by 2002:a02:b09e:: with SMTP id v30mr1441424jah.100.1628847537084; Fri, 13 Aug 2021 02:38:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628847537; cv=none; d=google.com; s=arc-20160816; b=hwmscFJ0Y2IIBmi0S1W+fr3NR31hwtsLzXDZtk5AapIlZZAbOCglsoj8GjbclJif/x dGQ239NQU76xue2Wp02Gmq8byLPQFDqQNTwNTze98xC8BXwZ3ZWYXaQP/k18SWX2hlWA yYWM71fS2urWdXjIeLka2ijPSW3ul3RzdmW7RlPAj7xKa2GCJ/fNuBD74wq6iF1IJUrF WYdxm+US6di/okOziwckA8p5AP3IRaCCMIdI3Kus3CNxKYR71HrWqzhnrc6vEoIdKpn+ LhsE18fE4mp7BLptfhyKs8268iptcXGcjL8s93A+NMVYLKBgTM5sihHLRzOU4HZXhQzQ CHOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HMpIgtmYiCu/LwtOQU+Xlub7GvS5zZM7iRjz7c/izMw=; b=yerqMCwp7kDIluiYMvErADOq5v4SWKjYoZse/MtY2aGU92rbTkxW1uTDowGsLpCPFx Inj3XscEgMjOfw6JCNZQWC71nASilbq6dRIZ52tV12OpYQDiovRi7PpBZ5MDKe7QUTbQ nAzbpfK7R/j9MZNee0a9udnmQTtuFOFDz5l1c0goPRR+uoTkzb54palXj3WekpkNXusv xpERetf2VWZJCLN6WZt6DJ6ZsA5b7JvgcOY2dTRpyRdocSXT9sv+Cy3600o6a/+XDj0/ VV51nohMlWBLGCWFB+3z605zzrhtz1sbfAzoXaaLyUJArULMTsi6WouuiMEz2LlxL0cL k1bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FsaIxPhh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si983978jap.5.2021.08.13.02.38.44; Fri, 13 Aug 2021 02:38:57 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FsaIxPhh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239339AbhHMHYG (ORCPT + 99 others); Fri, 13 Aug 2021 03:24:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:43486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238787AbhHMHYF (ORCPT ); Fri, 13 Aug 2021 03:24:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E53056103E; Fri, 13 Aug 2021 07:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628839419; bh=Op1DPt7UoLm4Jfz2g7mIQzK9pON5ZGq4qTreOrFk/m8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FsaIxPhhom0jQ/AqNnv8daSMfvwEbIbS0HThsquNyVmdxm8oUoZTxtMHGUQoLJ++A hX+mkdfu9o7cOfCnI3k8Wx1xoS3fJA4ONUKxHCi7H8r9xKLYzmWx6dnxcZ1R/ktW14 yGBYJpCAUGVW9UsoppIsrK8Y05cGRB+cxvWbB8rs= Date: Fri, 13 Aug 2021 09:23:37 +0200 From: Greg KH To: Prasad Sodagudi Cc: rjw@rjwysocki.net, len.brown@intel.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, pavel@ucw.cz Subject: Re: [PATCH v3] PM: sleep: core: Avoid setting power.must_resume to false Message-ID: References: <1628625938-149376-1-git-send-email-psodagud@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1628625938-149376-1-git-send-email-psodagud@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 10, 2021 at 01:05:38PM -0700, Prasad Sodagudi wrote: > There are variables(power.may_skip_resume and dev->power.must_resume) > and DPM_FLAG_MAY_SKIP_RESUME flags to control the resume of devices after > a system wide suspend transition. > > Setting the DPM_FLAG_MAY_SKIP_RESUME flag means that the driver allows > its "noirq" and "early" resume callbacks to be skipped if the device > can be left in suspend after a system-wide transition into the working > state. PM core determines that the driver's "noirq" and "early" resume > callbacks should be skipped or not with dev_pm_skip_resume() function by > checking power.may_skip_resume variable. > > power.must_resume variable is getting set to false in __device_suspend() > function without checking device's DPM_FLAG_MAY_SKIP_RESUME and > dev->power.usage_count variables. In problematic scenario, where > all the devices in the suspend_late stage are successful and some > device can fail to suspend in suspend_noirq phase. So some devices > successfully suspended in suspend_late stage are not getting chance > to execute __device_suspend_noirq() to set dev->power.must_resume > variable to true and not getting resumed in early_resume phase. > > Add a check for device's DPM_FLAG_MAY_SKIP_RESUME flag before > setting power.must_resume variable in __device_suspend function. > > Fixes: 6e176bf8d461 ("PM: sleep: core: Do not skip callbacks in the resume phase") > Signed-off-by: Prasad Sodagudi > --- > V2 -> V3: Format issues patch posting > V1 -> V2: Fixed indentation and commit text to include scenario > drivers/base/power/main.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c > index d568772..9ee6987 100644 > --- a/drivers/base/power/main.c > +++ b/drivers/base/power/main.c > @@ -1642,7 +1642,11 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) > } > > dev->power.may_skip_resume = true; > - dev->power.must_resume = false; > + if ((atomic_read(&dev->power.usage_count) <= 1) && > + (dev_pm_test_driver_flags(dev, DPM_FLAG_MAY_SKIP_RESUME))) > + dev->power.must_resume = false; > + else > + dev->power.must_resume = true; Again, what happens if the usage_count changes right after reading the value? What protects that from happening? thanks, greg k-h