Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1276426rwb; Thu, 22 Sep 2022 12:36:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7e8E2ykuQji332GktoqW8wdM5wyWPv5zPc740GWtDUUi/nv0TfP0SNRL6haSA56ccg4NhP X-Received: by 2002:a05:6a00:24d4:b0:544:abd7:c944 with SMTP id d20-20020a056a0024d400b00544abd7c944mr5335127pfv.44.1663875375985; Thu, 22 Sep 2022 12:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663875375; cv=none; d=google.com; s=arc-20160816; b=ehOGq7wWSiUfKPjlkQbt1F5SSG25Vt4Y+o1gvqJ2hdobL37czz/LlDfqlKlY891rvH eXygDeHCnGnl++7/mp042m75i8I+jG1Ei2dPEi2LSuDtmwqEOHQ8RW0FMjBqwkoDA2mn kxtX1ylLvfmFfuZj9D5xbiJWGCQEhN10mwufpMEr7+TNhaiBlHu03oMAntpO7zf/b05W GsAYMovRMnTTvw9dCTR6vnoQNzZDC7wNMeOaxD+pdJIMXJANdNjIwarIKXTUDOu6t7HT az/HhzEEouz35yBhYDP7P11eq85X9DEyBcH8th+0aasgt5GX4LbDc4PeWj/9aBi9PP48 G6Fw== 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; bh=gxki0hIHlcFHzEotDS8RwoGDa8ETOqC5eq+GhZQJc3M=; b=oIqpYzI2V/3X52MA7pfif1rFt56pozlRT3U9VQFGz+Jw58Ca3y6XZVdfdcYCanv5RV 5ynhap6aQkBS0oiAvciCFW4Zcp5zeNxl8okbYXg3TxPMYUHbEOzFufsz/0UaYAWLg9vj W1rw6A2ck6CMccwM6NfW5KIYx6+bhOvVFpdUS6wamsZOSZAeFHg181pkI4SXitgNqxlr qLbHNajUO0K5yLuCaew+86jlx5vmy62Zk5pyvoP/RpB7BMHRM8snZviKgr9jR5OjP/IC 3VUQHLjIPSI8mZnyM5RbvCJAyBHyC13MFQbNsmZf7iJq2ftiGUnlzHB7tMP2JGR2Z59U vKXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x63-20020a638642000000b00438fe6610fbsi7448002pgd.838.2022.09.22.12.36.02; Thu, 22 Sep 2022 12:36:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231770AbiIVTcP (ORCPT + 99 others); Thu, 22 Sep 2022 15:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231641AbiIVTcN (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 D6BB2F6F6F 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> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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