Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp218730pxf; Wed, 10 Mar 2021 04:56:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5LfkMYZhrsFa5bT6HCE4wFjFEKzWVPZQn5mXjY4aGaL4Fv6vlHxeUC/lXUeW0XfaKn2+6 X-Received: by 2002:a17:906:11d1:: with SMTP id o17mr3469392eja.517.1615380978664; Wed, 10 Mar 2021 04:56:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615380978; cv=none; d=google.com; s=arc-20160816; b=cBDeqb4Qgp98Gf3FLkR/sp5p/uDmNlZFQhc3tugIa9ZHRoVadddsgupfry6bVnblEG UZw++6ioRfGG8gLfIzEvNiTQTzEnImUFRFtC/+442Qe/D+Twl1vqvShuuvwpxa7F7d4G gTfch4Wu7Nip67sbWfq30voSmwz+rPcxdoN/+OuekKa5xSAKKBV/xQrq/50Cg7Gn9EMo q/G5i8+Vm2b21gwRASgaKSXDsv4woZfVZmhg+8Zdn2XCOo13SQbkRekl5wn5qQz6a/JE RkSeZt/y+65MEGMHhRc4rK2L2inwsWcBxYgke424Jyoy8anxxbxIlwPcwCs3OkZplywA jVrA== 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:dkim-signature; bh=q0RZjiaQJTAPDqED8b/nUGC084kdBQix8hpAZq2KA1A=; b=RfdngCXX+DhYD92ePQ38bJgM5Cur9oKv+vRO7v3NUZHd0kigBqFoiii1YjbkPyt8C3 qDT59BcfKrfPDwcIFpQkDixTfFEQd9pUovfKNVkhoAicd/e1AGYQroCBcttA3RselWgR Ctu6oLE7Z+FdKRKdRP0mKa0/jdlpoLZG49A9R0ZBX0dQyPHMcpMp2gb3CNNrtBttXUzR C4NFEc0n982BnrZCVeFUVneqBbwiLDngkKXDrjcbWxZhENb4hXW3cYH7Ktv6fEQTEJfF O8A/ISpmSqBxQ77IVwThzVqMBf038Zfx7EV8dEqTSoPDxznwqOILXhu0i9+DyRyqbfTO eJwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=GiWiDjE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si10601901edc.448.2021.03.10.04.55.55; Wed, 10 Mar 2021 04:56:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=GiWiDjE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232073AbhCJMzA (ORCPT + 99 others); Wed, 10 Mar 2021 07:55:00 -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