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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B7A0ECAAD8 for ; Thu, 22 Sep 2022 19:32:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229864AbiIVTcO (ORCPT ); Thu, 22 Sep 2022 15:32:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231621AbiIVTcN (ORCPT ); Thu, 22 Sep 2022 15:32:13 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id D6C25108091 for ; Thu, 22 Sep 2022 12:32:11 -0700 (PDT) Received: (qmail 271474 invoked by uid 1000); 22 Sep 2022 15:32:11 -0400 Date: Thu, 22 Sep 2022 15:32:11 -0400 From: Alan Stern To: "Rafael J. Wysocki" Cc: Linux PM , Douglas Anderson , LKML , Ulf Hansson Subject: Re: [PATCH] PM: runtime: Return -EINPROGRESS from rpm_resume() in the RPM_NOWAIT case Message-ID: References: <12079576.O9o76ZdvQC@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <12079576.O9o76ZdvQC@kreacher> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Thu, Sep 22, 2022 at 08:04:40PM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > The prospective callers of rpm_resume() passing RPM_NOWAIT to it may > be confused when it returns 0 without actually resuming the device > which may happen if the device is suspending at the given time and it > will only resume when the suspend in progress has completed. To avoid > that confusion, return -EINPROGRESS from rpm_resume() in that case. > > Since none of the current callers passing RPM_NOWAIT to rpm_resume() > check its return value, this change has no functional impact. > > Signed-off-by: Rafael J. Wysocki > --- > drivers/base/power/runtime.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > Index: linux-pm/drivers/base/power/runtime.c > =================================================================== > --- linux-pm.orig/drivers/base/power/runtime.c > +++ linux-pm/drivers/base/power/runtime.c > @@ -792,10 +792,13 @@ static int rpm_resume(struct device *dev > DEFINE_WAIT(wait); > > if (rpmflags & (RPM_ASYNC | RPM_NOWAIT)) { Hmmm, and what if a caller sets both of these flags? I guess in that case he gets what he deserves. > - if (dev->power.runtime_status == RPM_SUSPENDING) > + if (dev->power.runtime_status == RPM_SUSPENDING) { > dev->power.deferred_resume = true; > - else > + if (rpmflags & RPM_NOWAIT) > + retval = -EINPROGRESS; > + } else { > retval = -EINPROGRESS; > + } > goto out; > } Acked-by: Alan Stern