Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1175320rwb; Fri, 23 Sep 2022 09:06:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6kVia2QtXQrlPIqfz2dcqSrzrvbf7Vw2Gw9fLx9hJ+CncIwVWV5J5IFNaU1+Clq2UZqUit X-Received: by 2002:a05:6a00:4006:b0:53e:815a:ff71 with SMTP id by6-20020a056a00400600b0053e815aff71mr9771356pfb.4.1663949196592; Fri, 23 Sep 2022 09:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663949196; cv=none; d=google.com; s=arc-20160816; b=NgFHwBiTGYNT5QxAAzHPmDRlqwJNUqFL/CALC9lHmo4XVW63lKjAp1loQ/d0W1nNld /jNDG7kiSXePlF1GCFSUHr5MmKcIllJxtoQdn2T06q9o9NDfbgwoyZfA84NtuJagZgRx POVq263TXcuNRAxYXabYl+7ivd13v/33D8aijrKLk6FUmJmjM//nhG5XOz4yiG0U6IhV tsKO5T7eIVPGTpNXf15VWzCviOR4u8s/VicV/SZw35G1Gvmfc/CZqDNhkXWbN+xCezcy kBHg+TtYd5R8yFWa+3rN5WVr3dtZxhDe5eh3Td4CLv6Pw/jmuPE5J9SfcxZesrAVE1yO wWhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=0dJpb5MWD5OFoxFjAN4WXBXMWt5frU6fa7KgoPfQt1I=; b=ylFhKSjH1d5JABGyjvh4TsYtbec/gaKJJb/MEJ3Ss+KzBsGoaiPAZ2kuh8Y9wUd0MU xXnH2MbSmWIDx+ZMZQTty7J+Gctr0udxB+0sb7/TRlk8mIoPevS0UaFzy1tFlqFUQwqP UOVYlUhWNamWy0SwuyRaJ6YQ8NduZD75bTstkb0HhMl130F7YGbinOgVHREDge37lVaV D4Rqdg12zMh64g5kIm797xs39UAJ4mAb8CaaxyLpdF8RsrqYIM0K7xypEyfLfCXH9tVw ZyI64T+b6ipivrQDBilLxIQeWp76WeQTRxCLzxyvj42eaEoIu65QETnUluVQIofTi3Nj z/gQ== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k1-20020aa788c1000000b00552a97ebc29si11166230pff.115.2022.09.23.09.06.23; Fri, 23 Sep 2022 09:06:36 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231653AbiIWPxO (ORCPT + 99 others); Fri, 23 Sep 2022 11:53:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231235AbiIWPxL (ORCPT ); Fri, 23 Sep 2022 11:53:11 -0400 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F33D13E7F2; Fri, 23 Sep 2022 08:53:10 -0700 (PDT) Received: by mail-qt1-f181.google.com with SMTP id b23so271201qtr.13; Fri, 23 Sep 2022 08:53:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=0dJpb5MWD5OFoxFjAN4WXBXMWt5frU6fa7KgoPfQt1I=; b=buOuEYXhTB4fIN/oM539S0Tg9+hJd9TzWQNViMD1KYsQrUM1JgXcc8olMG4tR4CSb2 YzqG2cHC4fyE36gwF+hA+mWi4JYZLrHz2O0s6P6eG5v3mEpEXAxAa8PpWlSe5DfszlVW FWsq6H/WlprzfMA6KWtq5bYH2puhhh5tVd7HaTf4/4yPhdTGCS7fSu/CmDmIMgVmfgSg A40OUQKLDNdVG1aCaD1tiFB7koUYLIVueFBKyjl3/yEOFjqwM3gwFiohg4METlNAlZ5J 0CFCROlu5uMKTxZydgSEntkRdhC2OuNFH7l+/Iv91Mz4kDygf1hSagOfNyeDrnvsJCrw D3CQ== X-Gm-Message-State: ACrzQf36GT8RUQcjgJuiOTr3VEFmGAY1Fghnnq+CvwUZJBLgRJ3FbZng JLZyVoSH4JfjA3Emy3n1NkRWEGm5+8snKaJJcds= X-Received: by 2002:a05:622a:11c8:b0:35c:e912:a8ea with SMTP id n8-20020a05622a11c800b0035ce912a8eamr7790926qtk.17.1663948389073; Fri, 23 Sep 2022 08:53:09 -0700 (PDT) MIME-Version: 1.0 References: <12079576.O9o76ZdvQC@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 23 Sep 2022 17:52:58 +0200 Message-ID: Subject: Re: [PATCH] PM: runtime: Return -EINPROGRESS from rpm_resume() in the RPM_NOWAIT case To: Ulf Hansson Cc: "Rafael J. Wysocki" , Linux PM , Douglas Anderson , LKML , Alan Stern Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, 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 Fri, Sep 23, 2022 at 3:26 PM Ulf Hansson wrote: > > On Thu, 22 Sept 2022 at 20:04, 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. > > Sounds like there are additional improvements that can be made around > this, right? This allows RPM_NOWAIT to be used in places where the caller doesn't want to wait, because it might deadlock or similar, but they still need to know whether or not the device can be accessed safely. Or do you mean something else? > > > > Signed-off-by: Rafael J. Wysocki > > Looks good to me! > > Reviewed-by: Ulf Hansson Thanks! > > --- > > 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)) { > > - 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; > > } > > > > > > > >