Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp582107pxb; Wed, 27 Oct 2021 08:28:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR5QFsFnITD7Yt54Phcl0imV+YESmQqII/rAUQitPzOxVMc0n3ysVd5W7AT4Ep6afdDpnq X-Received: by 2002:a63:1415:: with SMTP id u21mr19819827pgl.165.1635348530690; Wed, 27 Oct 2021 08:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635348530; cv=none; d=google.com; s=arc-20160816; b=FHF3P2bsUFlsTQ0y33CQ+j/3lNaRZ2FrTcyfQGOZ9EDM0sPD3NrPaK47f99GaIstFg jIBMLHVAgV2lU6abqrIsaPsrJ12DzJvYGr6Eu9JknmeVQRoLk0nLm1O47cZiX2TySQax oa9Qosurxh4NcyZkYVsRkowXs0iGn7QuR3subwyqgeS7XF0u276P9hMdO9gEhZlEp991 hO3iYz+WjCrwiRZy/6PuW1QMmT/EraNIeUIOWnhW/kF6pwweO795eMFRUD6RNK8jLToQ yNXkVTbM5qQ2O7Y3BtqgZDGZkxgHJyRJtHRv95hbYhPt2UvRTPMWvlqrwyJ9BnWqPuGW vneA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=+QyvXc6Ce/f+Q1TlFw+EpeJ7SI3qm9cEmQ7xYaPsxQE=; b=ARjCsLCVHpVpP2qEkrZztdqi4PnoAtkosc25PiniV/AHppWP7cjRrWlPn5oL8c5QHj prVyd2uJFMiWvMm8YVxZgXRN2gfsKpYcWl7oNxx4g2fbdCwYE0ILUFUbE0huDBKk8xrX d4iDCXbPK7JtadTg9msC6Csi0lhMFZKu5BPpuMqbKgIpfuDKlIGb5FfRI8c2bSMRlIJw rkK1U3bxURom9mtt+HAZXwuJVV9GhAmGxklO0Xnjl5qB0LDxWKiLYHcGw9QJjh43+Y9D +OLp6eYGoRBlv4NbpZsVPGy/rLGNt2GIv53IcCBRxTbed2zz8y+lYN+dAW7YA3GRKDYE vtnQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si401902pfi.320.2021.10.27.08.28.37; Wed, 27 Oct 2021 08:28:50 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237704AbhJ0CFC (ORCPT + 99 others); Tue, 26 Oct 2021 22:05:02 -0400 Received: from netrider.rowland.org ([192.131.102.5]:36895 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S237736AbhJ0CFB (ORCPT ); Tue, 26 Oct 2021 22:05:01 -0400 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211026222626.39222-1-ulf.hansson@linaro.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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