Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp346191imw; Fri, 8 Jul 2022 04:11:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sxkPfemdOqYsVDx9yhDU/Q+5beoZusuZ9owhZimYPTXP1FtqLWYJCwN1vnurE4UOOB8DL4 X-Received: by 2002:a17:902:e80c:b0:16c:28a6:8aa0 with SMTP id u12-20020a170902e80c00b0016c28a68aa0mr867293plg.119.1657278717081; Fri, 08 Jul 2022 04:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657278717; cv=none; d=google.com; s=arc-20160816; b=O6hGX4hBzUyT4514EUD5Fnr21Rcw36WNeGG7IyOzUPFCnzRlQjlhXgRuLWM3QUg4LZ r+EBPHSsxp5Mztzxfj6I/7WVvbyQ7p5mOJ2GfBVshTbdupok4bovNey3KAJOTPVdhpTR LVbxhTWpjYX1YT9/H7/aH/VERrQ1gNnWuadnqlEGyGjHPD1F6rzkG1a2gtx+pFuxQYhv Gyv/e7GHGFqDh0EHx37CP57OTfchXMGjj/tYnVCtiEKEaFCXYkedNBKjRAFzF19oOYI2 TGzy+Ouj9b+l5yxPPN16S8Sha612ZWq2VueJAJmS8/s6C994wzgK+f1WYeykyHUh+pJl MLWg== 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 :dkim-signature; bh=hVRYG3p50qnDjZtNI+vfDnB95JRUiYZHlJYn4fjg5XI=; b=WWBbmekRC9IusWbzkOV2nIErOEdugDTU5Hw45qs26OyR7Px9zfN9QjGGxrVPKoI3Yk tdfl+3PeHVCDhy4XRfi2Ry+5zR7zmS8ddElQkQzCJLg8S0jIVUFY0u1IOZUNf82OKOtA 2HWze918FqwKY8/cdrxekFcQw2HBU9GVuP9WfyKy4NFNspUJ8plkJy7MRyuFRdvDi2Ke udkkPBO82CmPr0EYQnC8bLaXFmm376sNF+axnCXX4nvgHknUYHLJZqDE21c90pnvFQI8 GlzBY1AUvRfQE3xpQpX8VEbLjrRlzlPTJd9Um6IUOLEq9bTwMKzGTBdoblbk7fV78QWR sqGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=oLf7m50d; 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=axis.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bj19-20020a056a02019300b00408e3bbb7dbsi63248614pgb.100.2022.07.08.04.11.43; Fri, 08 Jul 2022 04:11:57 -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; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=oLf7m50d; 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=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238042AbiGHLEA (ORCPT + 99 others); Fri, 8 Jul 2022 07:04:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238036AbiGHLD7 (ORCPT ); Fri, 8 Jul 2022 07:03:59 -0400 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 640242A95A; Fri, 8 Jul 2022 04:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1657278238; x=1688814238; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=hVRYG3p50qnDjZtNI+vfDnB95JRUiYZHlJYn4fjg5XI=; b=oLf7m50dZHcCbEkrUM1CNHA52EB+8+aZG9yXBlytJ1xCmRukEr4H1F6Q Buj6VynI+8iwtjP3aVljzBN0QejvLnrx/Epooyzw0ejUkby/VD29PJxyw OJmEPej4M0r/GrBnbfCuAxVTHwUQ6IKokoZNqjOSmhcNpyqDIXh+07O1V 1ZJN+pFZM+UE/QD5aujiOQS9SYN9w0D7iSREUUhFrWznK7eieVPhv0TQA fQRMW1dJaEXbd0HxV7s5SKCP6mJGkGxEYbVd0f7AhCF1HRkNxUKH56NoC /vpUx+p366asFk2Dqrrnf5Zk+fovrHWZAh24u/7ycd5KBLC/xsqq3j7PD Q==; Date: Fri, 8 Jul 2022 13:03:26 +0200 From: Vincent Whitchurch To: Oliver Neukum , "rafael.j.wysocki@intel.com" CC: "jic23@kernel.org" , "linux-pm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-iio@vger.kernel.org" Subject: Re: PM runtime_error handling missing in many drivers? Message-ID: <20220708110325.GA5307@axis.com> References: <20220620144231.GA23345@axis.com> <5caa944f-c841-6f74-8e43-a278b2b93b06@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <5caa944f-c841-6f74-8e43-a278b2b93b06@suse.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Tue, Jun 21, 2022 at 11:38:33AM +0200, Oliver Neukum wrote: > On 20.06.22 16:42, Vincent Whitchurch wrote: > > [110778.050000][ T27] rpm_resume: 0-0009 flags-4 cnt-1 dep-0 auto-1 p-0 irq-0 child-0 > > [110778.050000][ T27] rpm_return_int: rpm_resume+0x24d/0x11d0:0-0009 ret=-22 > > > > The following patch fixes the issue on vcnl4000, but is this the right in the > > fix? And, unless I'm missing something, there are dozens of drivers > > with the same problem. > > Yes. The point of pm_runtime_resume_and_get() is to remove the need > for handling errors when the resume fails. So I fail to see why a > permanent record of a failure makes sense for this API. I don't understand it either. > > diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c > > index e02e92bc2928..082b8969fe2f 100644 > > --- a/drivers/iio/light/vcnl4000.c > > +++ b/drivers/iio/light/vcnl4000.c > > @@ -414,6 +414,8 @@ static int vcnl4000_set_pm_runtime_state(struct vcnl4000_data *data, bool on) > > > > if (on) { > > ret = pm_runtime_resume_and_get(dev); > > + if (ret) > > + pm_runtime_set_suspended(dev); > > } else { > > pm_runtime_mark_last_busy(dev); > > ret = pm_runtime_put_autosuspend(dev); > > If you need to add this to every driver, you can just as well add it to > pm_runtime_resume_and_get() to avoid the duplication. Yes, the documentation says that the error should be cleared, but it's unclear why the driver is expected to do it. From the documentation it looks the driver is supposed to choose between pm_runtime_set_active() and pm_runtime_set_suspended() to clear the error, but how/why is this choice supposed to be made in the driver when the driver doesn't know more than the framework about the status of the device? Perhaps Rafael can shed some light on this. > But I am afraid we need to ask a deeper question. Is there a point > in recording failures to resume? The error code is reported back. > If a driver wishes to act upon it, it can. The core really only > uses the result to block new PM operations. > But nobody requests a resume unless it is necessary. Thus I fail > to see the point of checking this flag in resume as opposed to > suspend. If we fail, we fail, why not retry? It seems to me that the > record should be used only during runtime suspend. I guess this is also a question for Rafael. Even if the error recording is removed from runtime_resume and only done on suspend failures, all these drivers still have the problem of not clearing the error, since the next resume will fail if that is not done. > And as an immediate band aid, some errors like ENOMEM should > never be recorded.