Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2350859rdg; Mon, 16 Oct 2023 01:13:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXhltZadS/IRxdXejnT+iryeDYV6xajJQA7Zkai4nR9Djj2N8IFWFW/nkUhuWBuELc1BUW X-Received: by 2002:a05:6a00:8c7:b0:68a:4d66:caf with SMTP id s7-20020a056a0008c700b0068a4d660cafmr37945236pfu.34.1697444028998; Mon, 16 Oct 2023 01:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697444028; cv=none; d=google.com; s=arc-20160816; b=YBaAbNKhjn/Z48wXvXYiGaUX7STqUWoj5H4EoHYQfJkEH64pYIh8kHgzlL+BGqXGbd naK8NMFTdpFC1D7MPZf8bYho9OU3LA2grXZB9xAkXh7/ivd3PbTCErXtbrdbUcPRquOc 92zWRS9Y3TcU2Ujc+1tYTnc6VDNO3Q96InC1vmxDha8V7/c3jDnUf4myrNKuIbNi3S7U SFqYAijJK1Vv5tlasTBDfFoho+x3VlGjGu7HY79pUEXLHCnffBbQa+V7QHDLBl3XsUAm PdlefqzzWUmAlevhxCU8M150hQPkyAYXOfErjnps+E2l/SBLblqbUdEWElYcjipPVeZT CWfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=CqnU8bzDLA3S7gsHpvFSVGAB1w5LghPOLGZZKl+x6H0=; fh=VbJAn/meYsLCq7HM7oHulZ2RTSfWModKXRJ6T0fFX4E=; b=0qDjUBNiMnBaG7nfAjjMEJqnvSKJcpzopSWG5nBT6R0xMeoL6kKoZG/T3MCShZHili zwzPyx/ymrRvU66FLs5HbUz7rhDaO1cTaQw4GkLLgSoVlN384EXSMdz+vEhPRaCToq7a ehCQy1ezMm5QWnR+gmBVnXDoRPntNIJmYB8Xg0oYC4JJ4hDRkYDzroYxrCtxVyEUJ6N0 tT49rd5T6vlaKsFz2iiulEUxVB1GcnfnPWyvjVijHUxajsOODs+DzpwOuU9s2Nj33rLz fXV9xoX4gDIiN/swtayR87HuIn3/y7ybYEvoPlrASozrzZvdOPGSbRAEgmnMqR4Y0x79 d+Aw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ca8-20020a056a02068800b00578b9757214si6069164pgb.163.2023.10.16.01.13.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 01:13:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 28F988031ACC; Mon, 16 Oct 2023 01:13:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230143AbjJPINf (ORCPT + 99 others); Mon, 16 Oct 2023 04:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbjJPINd (ORCPT ); Mon, 16 Oct 2023 04:13:33 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17F31A1; Mon, 16 Oct 2023 01:13:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73DC4C433C7; Mon, 16 Oct 2023 08:13:28 +0000 (UTC) Message-ID: Date: Mon, 16 Oct 2023 10:13:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v11 09/56] media: amphion: Use vb2_get_buffer() instead of directly access to buffers array Content-Language: en-US, nl To: Benjamin Gaignard , mchehab@kernel.org, tfiga@chromium.org, m.szyprowski@samsung.com, ming.qian@nxp.com, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, gregkh@linuxfoundation.org, nicolas.dufresne@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, kernel@collabora.com, Zhou Peng References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> <20231012114642.19040-10-benjamin.gaignard@collabora.com> From: Hans Verkuil In-Reply-To: <20231012114642.19040-10-benjamin.gaignard@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 01:13:46 -0700 (PDT) On 12/10/2023 13:45, Benjamin Gaignard wrote: > Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array. > This could allow to change the type bufs[] field of vb2_buffer structure if > needed. Awkward phrasing, and bufs is part of vb2_queue, not vb2_buffer. How about: Use vb2_get_buffer() instead of direct access to the vb2_queue bufs array. This allows us to change the type of the bufs in the future. The same text is used in other driver patches, so please update it there as well. Regards, Hans > After each call to vb2_get_buffer() we need to be sure that we get > a valid pointer so check the return value of all of them. > > Signed-off-by: Benjamin Gaignard > CC: Ming Qian > CC: Zhou Peng > --- > drivers/media/platform/amphion/vpu_dbg.c | 22 ++++++++++++++++++---- > 1 file changed, 18 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c > index 982c2c777484..a462d6fe4ea9 100644 > --- a/drivers/media/platform/amphion/vpu_dbg.c > +++ b/drivers/media/platform/amphion/vpu_dbg.c > @@ -140,11 +140,18 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) > > vq = v4l2_m2m_get_src_vq(inst->fh.m2m_ctx); > for (i = 0; i < vq->num_buffers; i++) { > - struct vb2_buffer *vb = vq->bufs[i]; > - struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); > + struct vb2_buffer *vb; > + struct vb2_v4l2_buffer *vbuf; > + > + vb = vb2_get_buffer(vq, i); > + if (!vb) > + continue; > > if (vb->state == VB2_BUF_STATE_DEQUEUED) > continue; > + > + vbuf = to_vb2_v4l2_buffer(vb); > + > num = scnprintf(str, sizeof(str), > "output [%2d] state = %10s, %8s\n", > i, vb2_stat_name[vb->state], > @@ -155,11 +162,18 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) > > vq = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); > for (i = 0; i < vq->num_buffers; i++) { > - struct vb2_buffer *vb = vq->bufs[i]; > - struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); > + struct vb2_buffer *vb; > + struct vb2_v4l2_buffer *vbuf; > + > + vb = vb2_get_buffer(vq, i); > + if (!vb) > + continue; > > if (vb->state == VB2_BUF_STATE_DEQUEUED) > continue; > + > + vbuf = to_vb2_v4l2_buffer(vb); > + > num = scnprintf(str, sizeof(str), > "capture[%2d] state = %10s, %8s\n", > i, vb2_stat_name[vb->state], Regards, Hans