From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F98BC433EF for ; Wed, 27 Oct 2021 02:04:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 10C79610A0 for ; Wed, 27 Oct 2021 02:04:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 10C79610A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=y9K1maPhbszXEJdyHHPhRS0Ug3xyo5cpovIX6rJa5o4=; b=WgAOybetu+flHG jH1V8RVUY0f3h0rhQoo8vj22ojoYrku5aPdE0v4Uf3SOb5dw6WuNoqPnvFfZ8DnR079qbMVjO4J15 Egn4gBTlkYOkvUAHgmwI3Q45ClrEp2zNSWQlFikdyuDC3ySkZY0YY0XGPUHmjcOtX5Nm5x51xwJWb 2nwSSODd6Ak0jO9d7WNQguSD7UmrziHKJhmhE97xwhSkT6edobSKh6BKqwHbdun2tePyIgK5DOo1V VmI24E1M5fm4yBg8mKVhHEJCnsWVznchDNQOiCkU07T/5uSxvQwbDfz6RK7y/8Hum8l58J+b1dik7 AJdDao3Xw8lneNfPnfeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfYH4-003Xjh-D9; Wed, 27 Oct 2021 02:02:42 +0000 Received: from netrider.rowland.org ([192.131.102.5]) by bombadil.infradead.org with smtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfYH1-003XjH-3l for linux-arm-kernel@lists.infradead.org; Wed, 27 Oct 2021 02:02:40 +0000 Received: (qmail 1306909 invoked by uid 1000); 26 Oct 2021 22:02:35 -0400 Date: Tue, 26 Oct 2021 22:02:35 -0400 From: Alan Stern To: Ulf Hansson Cc: "Rafael J . Wysocki" , "Rafael J . Wysocki" , linux-pm@vger.kernel.org, Kevin Hilman , Maulik Shah , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PM: runtime: Allow rpm_resume() to succeed when runtime PM is disabled Message-ID: <20211027020235.GA1306582@rowland.harvard.edu> References: <20211026222626.39222-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211026222626.39222-1-ulf.hansson@linaro.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211026_190239_347029_5F61DA67 X-CRM114-Status: GOOD ( 26.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 27, 2021 at 12:26:26AM +0200, Ulf Hansson wrote: > During system suspend, the PM core sets dev->power.is_suspended for the > device that is being suspended. This flag is also being used in > rpm_resume(), to allow it to succeed by returning 1, assuming that runtime > PM has been disabled and the runtime PM status is RPM_ACTIVE, for the > device. > > To make this behaviour a bit more useful, let's drop the check for the > dev->power.is_suspended flag in rpm_resume(), as it doesn't really need to > be limited to this anyway. > > Signed-off-by: Ulf Hansson > --- > drivers/base/power/runtime.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c > index ec94049442b9..fadc278e3a66 100644 > --- a/drivers/base/power/runtime.c > +++ b/drivers/base/power/runtime.c > @@ -742,8 +742,8 @@ static int rpm_resume(struct device *dev, int rpmflags) > repeat: > if (dev->power.runtime_error) > retval = -EINVAL; > - else if (dev->power.disable_depth == 1 && dev->power.is_suspended > - && dev->power.runtime_status == RPM_ACTIVE) > + else if (dev->power.disable_depth > 0 && > + dev->power.runtime_status == RPM_ACTIVE) IIRC there was a good reason why the original code checked for disable_depth == 1 rather than > 0. But I don't remember exactly what the reason was. Maybe it had something to do with the fact that during a system sleep __device_suspend_late calls __pm_runtime_disable, and the code was checking that there were no other disables in effect. This is related to the documented behavior of rpm_resume (it's supposed to fail with -EACCES if the device is disabled for runtime PM, no matter what power state the device is in). That probably is also the explanation for why dev->power.is_suspended gets checked: It's how the code tells whether a system sleep is in progress. So overall, I suspect this change should not be made. But some other improvement (like a nice comment) might be in order. Alan Stern _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel