Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5249963rwl; Tue, 11 Apr 2023 02:41:07 -0700 (PDT) X-Google-Smtp-Source: AKy350YYTtmcaM7Qgl5g9vVVVC8am/g0Io1Xs9UnLqDM5N4thYk2IPS6iwt/vwsQvwnLMNwx/nvS X-Received: by 2002:a05:6a20:cf49:b0:d3:5224:bbc2 with SMTP id hz9-20020a056a20cf4900b000d35224bbc2mr14715278pzb.42.1681206066872; Tue, 11 Apr 2023 02:41:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681206066; cv=none; d=google.com; s=arc-20160816; b=IzJsGn5QXclG6ddRNaSSsV0gTSdW6092rg/bJYvMiTP63HmLE1OWfhWRc8EOTS0/VL C+dDPFm19V+RzVoHfmzADc/Q4kuKhbVNTw/mZF6pBAoSS9gkkZ0rSvsOJlHUbn84Bqk9 diljZG7wG4ZNgIyZvSScG2bWobiJ2h5HLPRlFS4R8IYH9Yh5MLoFhaNAzFg1Qxu3psO0 roFCZAKImzsrfIov9yF3ft3Qo6i1IZVwxFL4Hme56ADQtXEmM7ZQCQ3POnGmbU7UfKCe 9+H1NsyswQ2/nShWTljuaq9OYbXfqqbj48gHajdx2fRwRU822VWm2tMqDs5sg1HtDzd0 h/Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :dkim-signature:message-id; bh=Fs1b38Apt/S8hzpUzmgWTrC6F4Mp8GMzOlsD5NQnWBc=; b=l9cuydDHG8vCe0kTfT7ml8VQQF7+ZSXyLFqXIEQrZGSvZTjJvvJxQbFi5hfMTAsM6C D6hbru3d+5FWq3hAXCW9AyuQrZ8XyAnEwhSfhW1i2/06Hxi3bUs4xz+rpD5CuXFqfkQX fihTxXH3C6dbwNak2wOM3erGWHkwoqekXXldWd+ivVnDsZtW7LUlnJwQnwbEDWjkF2/C M91zJtumMMUF6Nce3RdQ5tWNlMHomhB7jqgpq7lbUIj95DcNY9YgG+dV1Nv5K3McHzy3 xQT1OQZtQxiBH8BuXlmI7zuENaMt1LYlOmEVULT9MFs5LAo3gAp5VpOEhBazi8Yn+hVf eUsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@puri.sm header.s=comms header.b=WaHYjMko; 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=puri.sm Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j73-20020a638b4c000000b005139713f0ffsi8752921pge.805.2023.04.11.02.40.54; Tue, 11 Apr 2023 02:41:06 -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 header.i=@puri.sm header.s=comms header.b=WaHYjMko; 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=puri.sm Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229655AbjDKJkb (ORCPT + 99 others); Tue, 11 Apr 2023 05:40:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbjDKJkK (ORCPT ); Tue, 11 Apr 2023 05:40:10 -0400 Received: from comms.puri.sm (comms.puri.sm [159.203.221.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3B20272B; Tue, 11 Apr 2023 02:39:40 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 9287AEBCCB; Tue, 11 Apr 2023 02:39:38 -0700 (PDT) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id szR5xkP6yVdK; Tue, 11 Apr 2023 02:39:37 -0700 (PDT) Message-ID: <9ad81a9b2806272c715784985a3e0f52cda159c7.camel@puri.sm> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=puri.sm; s=comms; t=1681205977; bh=78H+kq1MA3qAPgJDeC2Mvq4z8qNyX9HDvr7Gs/K953g=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=WaHYjMkof9EQQ97Wv2wBLHqnSkIyel2UYJzIm86a5VR+SzDZYyRNQXtOkV7rAI1Yq 01mQvKsIpmFPVUYiVQER6KXU85556WQ7x0rNzwHapP41K7fYi40DkKsl8LoeyZPi2U hlxDVVXaXG5cFMtMrz+D60PwM5RrK58ufMTZ5gc9u/3sG6ldEWnGH3Kj/rrxT8NxQF MKb/7mA7BvRqJiKDq0Kqxax2aGzm/Bd/y9G20DIbeeVtLsSPh4bqwIaTYEHWUSEyeW 8pkWRuh8oTclUKBHRnu+9JJI+5ZGFINhfZJg1nFz3/IUjh3QYPUKt+Y9JGLaL2TnBl GNXWB3nLsLgbQ== Subject: Re: [PATCH v1 2/2] media: hi846: preserve the streaming state during system suspend From: Martin Kepplinger To: Laurent Pinchart Cc: mchehab@kernel.org, kernel@puri.sm, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 11 Apr 2023 11:39:32 +0200 In-Reply-To: <20230406013551.GL9915@pendragon.ideasonboard.com> References: <20230405092904.1129395-1-martin.kepplinger@puri.sm> <20230405092904.1129395-3-martin.kepplinger@puri.sm> <20230406013551.GL9915@pendragon.ideasonboard.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1+deb11u1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Am Donnerstag, dem 06.04.2023 um 04:35 +0300 schrieb Laurent Pinchart: > Hi Martin, > > Thank you for the patch. > > On Wed, Apr 05, 2023 at 11:29:04AM +0200, Martin Kepplinger wrote: > > The hi846 driver changed the "streaming" state inside of > > "start/stop_streaming". > > The problem is that inside of the (system) suspend callback, it > > calls > > "stop_streaming" unconditionally. So streaming would always be > > stopped > > when suspending. > > > > That makes sense with runtime pm for example, after s_stream(..., > > 0) but > > does not preserve the "streaming" state during system suspend when > > currently streaming. > > The driver shouldn't need to stop streaming at system suspend time. > It > should have had its .s_stream(0) operation called and shouldn't be > streaming anymore. If that's not the case, there's an issue somewhere > else, which should be fixed. The code that stops streaming at system > suspend and restarts it at system resume should then be dropped from > this driver. > > > Fix this by simply setting the streaming state outside of > > "start/stop_streaming" > > which is s_stream(). > > > > While at it, improve things a bit by not assigning "1", but the > > "enable" > > value we later compare against, and fix one error handling path in > > resume(). > > > > Signed-off-by: Martin Kepplinger > > --- > >  drivers/media/i2c/hi846.c | 8 ++++---- > >  1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/media/i2c/hi846.c b/drivers/media/i2c/hi846.c > > index 0b0eda2e223cd..1ca6e9407d618 100644 > > --- a/drivers/media/i2c/hi846.c > > +++ b/drivers/media/i2c/hi846.c > > @@ -1780,8 +1780,6 @@ static int hi846_start_streaming(struct hi846 > > *hi846) > >                 return ret; > >         } > >   > > -       hi846->streaming = 1; > > - > >         dev_dbg(&client->dev, "%s: started streaming > > successfully\n", __func__); > >   > >         return ret; > > @@ -1793,8 +1791,6 @@ static void hi846_stop_streaming(struct hi846 > > *hi846) > >   > >         if (hi846_write_reg(hi846, HI846_REG_MODE_SELECT, > > HI846_MODE_STANDBY)) > >                 dev_err(&client->dev, "failed to stop stream"); > > - > > -       hi846->streaming = 0; > >  } > >   > >  static int hi846_set_stream(struct v4l2_subdev *sd, int enable) > > @@ -1816,10 +1812,12 @@ static int hi846_set_stream(struct > > v4l2_subdev *sd, int enable) > >                 } > >   > >                 ret = hi846_start_streaming(hi846); > > +               hi846->streaming = enable; > >         } > >   > >         if (!enable || ret) { > >                 hi846_stop_streaming(hi846); > > +               hi846->streaming = 0; > >                 pm_runtime_put(&client->dev); > >         } > >   > > @@ -1898,6 +1896,8 @@ static int __maybe_unused hi846_resume(struct > > device *dev) > >                 if (ret) { > >                         dev_err(dev, "%s: start streaming failed: > > %d\n", > >                                 __func__, ret); > > +                       hi846_stop_streaming(hi846); > > +                       hi846->streaming = 0; > >                         goto error; > >                 } > >         } > hi Laurent, ok I see. My first test without any streaming-state handling in suspend/resume doesn't succeed. But now I know that's the goal and I'll put this on my list to do. Since this driver *already* tracks "streaming", would you be ok with this fix in the meantime? thanks, martin