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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DC1DC433E9 for ; Wed, 10 Mar 2021 12:55:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DC7164FF4 for ; Wed, 10 Mar 2021 12:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232218AbhCJMzB (ORCPT ); Wed, 10 Mar 2021 07:55:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232670AbhCJMyp (ORCPT ); Wed, 10 Mar 2021 07:54:45 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20B18C061760; Wed, 10 Mar 2021 04:54:45 -0800 (PST) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6DA07F3; Wed, 10 Mar 2021 13:54:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615380883; bh=AKDc93kPppbQm2s1LhaPE4diJCM4JVJyE35igq3i9m8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GiWiDjE193dm0IRINivAuFIfQU2gw1MKIhW4F8sDpPBAtouhimiZaHDDnBbG+gr+j cgfwVqtitWeeYKgk99YgP0rgL4vR/l6CwxJOjG4Vm35us+YociIK7++tE5/u+YEWs4 7GV/0vytF4swcIRIq+iuPtN90aJDp7lwLOr6pusM= Date: Wed, 10 Mar 2021 14:54:11 +0200 From: Laurent Pinchart To: "Lad, Prabhakar" Cc: Lad Prabhakar , Dave Stevenson , Mauro Carvalho Chehab , Pavel Machek , Andrey Konovalov , Sakari Ailus , Jacopo Mondi , Hans Verkuil , linux-media , LKML , Linux-Renesas , Biju Das Subject: Re: [PATCH 2/3] media: i2c: imx219: Serialize during stream start/stop Message-ID: References: <20210310122014.28353-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20210310122014.28353-3-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prabhakar, On Wed, Mar 10, 2021 at 12:46:39PM +0000, Lad, Prabhakar wrote: > On Wed, Mar 10, 2021 at 12:40 PM Laurent Pinchart wrote: > > On Wed, Mar 10, 2021 at 12:20:13PM +0000, Lad Prabhakar wrote: > > > Serialize during stream start/stop in suspend/resume callbacks. > > > > Could you please explain why this is needed ? > > > The streaming variable in this driver has serialized access, but this > wasn't taken care during suspend/resume callbacks. But nothing that touches the streaming variable can run concurrently to suspend/resume, isn't it ? I'm actually even quite dubious about the need to start and stop streaming during resume and suspend, the driver using the subdev should start/stop the whole video pipeline at suspend/resume time. > > > Signed-off-by: Lad Prabhakar > > > --- > > > drivers/media/i2c/imx219.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c > > > index f0cf1985a4dc..87c021de1460 100644 > > > --- a/drivers/media/i2c/imx219.c > > > +++ b/drivers/media/i2c/imx219.c > > > @@ -1172,8 +1172,10 @@ static int __maybe_unused imx219_suspend(struct device *dev) > > > struct v4l2_subdev *sd = dev_get_drvdata(dev); > > > struct imx219 *imx219 = to_imx219(sd); > > > > > > + mutex_lock(&imx219->mutex); > > > if (imx219->streaming) > > > imx219_stop_streaming(imx219); > > > + mutex_unlock(&imx219->mutex); > > > > > > return 0; > > > } > > > @@ -1184,11 +1186,13 @@ static int __maybe_unused imx219_resume(struct device *dev) > > > struct imx219 *imx219 = to_imx219(sd); > > > int ret; > > > > > > + mutex_lock(&imx219->mutex); > > > if (imx219->streaming) { > > > ret = imx219_start_streaming(imx219); > > > if (ret) > > > goto error; > > > } > > > + mutex_unlock(&imx219->mutex); > > > > > > return 0; > > > > > > @@ -1197,6 +1201,7 @@ static int __maybe_unused imx219_resume(struct device *dev) > > > imx219->streaming = false; > > > __v4l2_ctrl_grab(imx219->vflip, false); > > > __v4l2_ctrl_grab(imx219->hflip, false); > > > + mutex_unlock(&imx219->mutex); > > > > > > return ret; > > > } -- Regards, Laurent Pinchart