Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A86B2C433EF for ; Mon, 27 Jun 2022 11:31:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Q+ZEW0L95+p2KE6Fj4BZXi8ihSV455NQgJSpPT82hOU=; b=IhNr23eCLWHJAI ScFlPOO5xOspOCaZNEIdU0NO7lOfh+k094KCPimSoYxk0YGEntlP3/DNztKmjTP7+KzZYcrqPfnnE YwiUCAaTwtQRK2LryKYpglb5sdFV4oJDJtVnNjNeNYP+HGc+LcTjtLeGyI5GTn/H9+QMDd974txu0 rTAd1fLmeouUqx9+MEGc2vD9zdm6KmRm0RZJs5td1h0QaW23cwfo/nKEcvmpJwOCq9tDaVLgqlQEv 7oLjadoaq7788OicBFwMDosZV9OLHkd7KbE6UsNlbe+3MNWlCTM/CmWtDRbLAh1C/44x24RwWcpTM ielcH8KonnYUZV2/sBmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5mwv-000Vxh-9M; Mon, 27 Jun 2022 11:30:37 +0000 Received: from phobos.denx.de ([85.214.62.61]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5mwr-000Vtt-39 for linux-arm-kernel@lists.infradead.org; Mon, 27 Jun 2022 11:30:34 +0000 Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id C7A6C83C70; Mon, 27 Jun 2022 13:30:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1656329430; bh=PNJWeluzCFC9fqpkPX1hueWxRzJxtppdWn2vMDgtqVo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=CX2LJjcpznGAa8VOWJF2DVYDku4/vBrvAw7aFP5BIMpfXZWho1Tv2Gwgks4Y9lKZj Kvohc3LTldK9Qq7ngliBJ+GBOuSY69eP1J07uYJHaSYJo2TETEmUsut5MVBnS4rGn5 VAZ2h5QO80Ra2BBUCelZWXZDEx3My44KTc0IRxolkdIZeqVZcCVuglCJtm+phDfw6v kqLWsSVSL1ApkMDx+B7+zWHybHKcNkl1+gQIXXuj13oPDGJvc8H5Mx6d4BgwC2aPzb EItwg10yWbLBswty/k73cIKmzxuYX8Cw8B6CBeSvI7RCuw42V6wxk0T5XlzZxHnAiU yAKHYZK+ahZ7Q== Message-ID: <39657445-e5ac-bfd6-c122-b18088fa4b41@denx.de> Date: Mon, 27 Jun 2022 13:30:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] media: stm32: dcmi: Switch to __v4l2_subdev_state_alloc() Content-Language: en-US To: Hugues FRUCHET , Tomi Valkeinen , Laurent Pinchart Cc: linux-media@vger.kernel.org, Alain Volmat , Alexandre Torgue , Amelie DELAUNAY , Philippe CORNU , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org References: <20220618222442.478285-1-marex@denx.de> <0dc2d603-586e-be49-8f8d-1f52f1915813@ideasonboard.com> <4d5b5c59-f3d5-ad5a-ae61-73277b4adefa@denx.de> <5ee6c0c0-8ab0-561c-e1f6-b26e4ec438af@foss.st.com> From: Marek Vasut In-Reply-To: <5ee6c0c0-8ab0-561c-e1f6-b26e4ec438af@foss.st.com> X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220627_043033_564199_FAE9ACA1 X-CRM114-Status: GOOD ( 19.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 6/27/22 11:14, Hugues FRUCHET wrote: > Hi Marek, Hi, >>>> On Sun, Jun 19, 2022 at 12:24:42AM +0200, Marek Vasut wrote: >>>>> Any local subdev state should be allocated and free'd using >>>>> __v4l2_subdev_state_alloc()/__v4l2_subdev_state_free(), which >>>>> takes care of calling .init_cfg() subdev op. Without this, >>>>> subdev internal state might be uninitialized by the time >>>>> any other subdev op is called. >>> >>> Does this fix a bug you have? >> >> Yes > > Which bug did you encounter exactly ? The DCMI driver does set_fmt subdev call on the sensor driver instance. The mt9p031 sensor driver set_fmt depends on crop rectangle to be initialized _before_ set_fmt subdev call is made. Currently this initialization is done in open callback, which is too late, so when the DCMI does set_fmt subdev call, it operates on uninitialized private data. There is patch to mt9p031 driver which move the initialization to the right place in .init_cfg: [PATCH v2] media: mt9p031: Move open subdev op init code into init_cfg However, the .init_cfg is not called by DCMI right now. For that to be called in the right place, __v4l2_subdev_state_alloc() must be added, hence this patch. You won't trigger the problem on OV5640 because that one driver does not implement .init_cfg v4l2_subdev_ops . > This is strange that we have not yet encounter any problems around that > through our tests campaigns... or we have to enforce with a new test, so > better to know what your problem was exactly. You need a sensor driver which implements struct v4l2_subdev_ops .init_cfg and then have something in set_fmt depend on the initialization done in the .init_cfg callback . Then you would see the problem. >>> Wasn't this broken even before the active state, as init_cfg was not >>> called? >> >> Yes, this was always broken. I suspect nobody tested this mode of >> operation before. In my case, I have this DCMI driver connected >> directly to MT9P006 sensor. > > As far as I see, MT9P006 sensor is a 12 bits parallel interface sensor. > I don't see the difference with our OV5640 used in parallel mode which > is a mainline config on our side, so one more time I wonder what the > problem was. See above. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel