Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2608345pxy; Tue, 3 Aug 2021 10:20:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyELJ1KL7usmpOp1TLivyEkFHqtw+l+7tXwp60JpENRqw+GRHiMeWl71Pr52l7aL7mGo+Bp X-Received: by 2002:a17:906:4751:: with SMTP id j17mr21943984ejs.39.1628011231669; Tue, 03 Aug 2021 10:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628011231; cv=none; d=google.com; s=arc-20160816; b=aUTNJDIYLbpaKaxExZu5Ct1zLBnkKPyPNhkTbm7Vza9EuiO5uDxIo2Wf9d8blqhWa5 YtwAuC7PuCb32YP0T517MiNyOjl7Iit+JDwrkPQ7IJukljuUENk6WWwZGauSbJ4+4aRq jdbRAtwzh5UU77gusap9mD1wW54OMY9pwSNr6hlCsz5NTAV1pXY3iqDQ4DOIUu2tZWYd eOqIz82XtgRIemteyMq1WTGW9HY6V+zdM5DZ6NNX1EGiL1m1P/ovRhJQUA349Xuts63c fL8h1pm19Nrz7S8OkWgz+jz3OW4BxHrEV6ZlwhIlodsck+fgg3KT8M/Icr0AsyaeuFrR DUtw== 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=m0wHbOZUNktMkJ2YU/CIcS2JOSMPI2Qc6p9/uaBrvFg=; b=DPXSbtIQgvyaiogo/fy9kb+DzjeYVipQr/tD87uMlwM+sUHxUQGde/OsaUTMo9+fLY l+uVfXMTbkZ5Z642ok8cyNtkdVRVh8hsvSPRtroNLb4LeP99iyqawNgNWLy9iNSfbBeB xdoL3QuWQSSaLRXMrL7aKGu2QLVBvYLXTJNGY7bL6qb1hzXtLDJStqPwVgFSsQttAcxj 2KgO8POuDgyjwcEKY8mjizZDyLYAffwhfJ/eKTpSbZAGGZt24DMCdCiM0tEkBoL5hqIA DIZzd7MYC3SqXu6wj88lM6kqOWvqqFM1/7lCD3GDFvyYq0rFQDWdyGPi3KKpuC35KENO G46w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LiibfRJw; 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 v6si13438725ejg.102.2021.08.03.10.20.07; Tue, 03 Aug 2021 10:20:31 -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=LiibfRJw; 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 S238205AbhHCRRc (ORCPT + 99 others); Tue, 3 Aug 2021 13:17:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:42726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237782AbhHCRRI (ORCPT ); Tue, 3 Aug 2021 13:17:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E4E6A6024A; Tue, 3 Aug 2021 17:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628011016; bh=BAMrNVzMZWAInL5hwQzL8TACoUeg0SZlB6RB2hYEniU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LiibfRJwiE4CRoYlkKKwCDzkyTl9k+CKMqkkqf/qq0EN7GiJ6cex1FBxaNBVc4pmn 3+yw/+pWoex3nK6vK+KhbfqJBuIwJmBAohrM1pU764qoyq2c0pkL3hMH3C7og5nUFX s2GBCXBvQw9mEd+xj6yNcUZF++3c2oqWfRymvAWQ= Date: Tue, 3 Aug 2021 19:16:54 +0200 From: Greg KH To: Prasad Sodagudi Cc: rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PM: sleep: core: Avoid setting power.must_resume to false Message-ID: References: <1627313074-436260-1-git-send-email-psodagud@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1627313074-436260-1-git-send-email-psodagud@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 26, 2021 at 08:24:34AM -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. This is leading to failure to call > resume handler for some of the devices suspended in early suspend phase. > So check device's DPM_FLAG_MAY_SKIP_RESUME flag before > setting power.must_resume variable. > > Signed-off-by: Prasad Sodagudi > --- > 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..8eebc4d 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))) What is preventing that atomic value from changing _right_ after you just read this? and very odd indentation, checkpatch didn't complain about this? What commit does this fix? Does it need to be backported to older kernels? Wait, how is your "noirq" device even getting called here? Shouldn't __device_suspend_noirq() be called instead? Why isn't that the path for your device? thanks, greg k-h