Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3045081rdg; Tue, 17 Oct 2023 02:59:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/hAPRGyC92h/tAFEsNSeJaKTkW+0oOhZ1TYRbEFPc6ZpsMNVZroBmT/0/FqpvtxF1MeOs X-Received: by 2002:a05:6a20:2450:b0:14c:c393:692 with SMTP id t16-20020a056a20245000b0014cc3930692mr1907822pzc.7.1697536780494; Tue, 17 Oct 2023 02:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697536780; cv=none; d=google.com; s=arc-20160816; b=GR2uEUrKG/khWOYUJ0fsalfrRH1jk0ZhMzAC04BAWVdfV6t/6VYXaux+zYa5bKrSwb K6gffWrJwDKfODfL78uaefF5BEziKyn4gzw8abiX+F0QsotYrDohuoEK4e9Ne9mQLNYz OxwsLZ+63FYiYVDmQNCMnVDav6fsqmd8ZEBg1mhw6plZEHtLcoVYh5h6crTzM++YRbVV T8DvEZgSLrPL8y1yaVvh8fYS8UIwzKo+35H9FkKitt0pw1U9cOzQ4OAZm17zYqV25S1q OY7E1blZW8hLKYvntpTQmfDmL8BosZReLPrR1pcqSxvceF6AGl16952VH/BAsPDvIpXb r4bg== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=mMSjB1wilmCB+mj6L/QNIk4lfp1e3cxxraKBJAdF7Us=; fh=E5q44kn4SxQjMMnEO9HAgSPsbzWLuOyLsZhTC/T1G5U=; b=V4718IjCkYtVXk80SLs7d/IMSYvSORIJgaRNhHLCx3BJaJfkvl0C9C4PUgJ963tfZ8 FXsE9NBnZlWOSw8iVpMdpYCjTswzK87MdAIOx0QSPcvi9cgWSiGwlnA30IhsBSzjwcQw 1kJswuj9TYFYi0i8nC+3Ip+BJYAKkvO+4rarV6aNlSeNsJ0Kr7FFhCXQebJjm4UAu3eJ tayQxuHHEDQcmg/iiemv1tizdhFEjUfpLPw39KLFquGQYGWI/76MalGq4kWLrDDW97wO AtayfEx1HRKvfZmi14wxBR0AlhWwIP2LyksXt7e9n7E7UBOJ/vQlSlI5WzGzFULjKRbA 7KhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Px3k7uZz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id v202-20020a6361d3000000b005ac341a88ccsi1339100pgb.6.2023.10.17.02.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 02:59:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Px3k7uZz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6237C8029C57; Tue, 17 Oct 2023 02:59:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343529AbjJQJ73 (ORCPT + 99 others); Tue, 17 Oct 2023 05:59:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234802AbjJQJ71 (ORCPT ); Tue, 17 Oct 2023 05:59:27 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 836E8F9; Tue, 17 Oct 2023 02:59:25 -0700 (PDT) Received: from [IPV6:2a01:e0a:120:3210:7205:da49:a7e8:59f8] (unknown [IPv6:2a01:e0a:120:3210:7205:da49:a7e8:59f8]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 8DF1B66072C1; Tue, 17 Oct 2023 10:59:23 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697536764; bh=a5Sv7ioncBaZOFxcfAjDRAD0foGoDHh+LBV8taa+Qz4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Px3k7uZzN9kGzG9Xg2iO78mVd9HTmp+Z9chGKVONZxXA2n1f/p79WJkuf8d11/1Qm PmbASDogOpGc2FRB8Uin7AgX9vy++S8VdiM0dqsLsIrn0L8kfK+8BOncmkJvgm+A0p CsOjq1EAZn7FiOMLMtGqbScXi4YDAhvqmymF1xr15tPQa5El6/lU27chyxptRg9fkq JHpiyJNMHP2UVTUcITlsu3vY/rNhVQmF9FK7Ik8ROYGAInsT91EOpxUAJT6X+GFQjN 3Hez6TtPgGLWvVE8zhGjm4Z9LoYoi/uiqguK6z/ENPB/ez6ixJ65jUzN35w4deqE6R 1Whj2tf7ZABOw== Message-ID: Date: Tue, 17 Oct 2023 11:59:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v11 41/56] media: cedrus: Stop direct calls to queue num_buffers field To: Paul Kocialkowski Cc: 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, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com, 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, Maxime Ripard References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> <20231012114642.19040-42-benjamin.gaignard@collabora.com> Content-Language: en-US From: Benjamin Gaignard In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 17 Oct 2023 02:59:39 -0700 (PDT) Le 17/10/2023 à 10:54, Paul Kocialkowski a écrit : > Hi Benjamin, > > On Thu 12 Oct 23, 13:46, Benjamin Gaignard wrote: >> Use vb2_get_num_buffers() and queue max_num_buffers field >> to avoid using queue num_buffer field directly. > Thanks for the patch, this is indeed a nice cleanup and safer usage. > Maybe the commit message needs to reflect why this change is welcome, > not just what is being changed. I will add this comment in the commit message: This allows us to change how the number of buffers is computed in the futur. > >> Signed-off-by: Benjamin Gaignard >> CC: Maxime Ripard >> CC: Paul Kocialkowski >> --- >> drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 8 ++++++-- >> drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 9 +++++++-- >> 2 files changed, 13 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c >> index dfb401df138a..95e490532a87 100644 >> --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c >> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c >> @@ -653,8 +653,12 @@ static void cedrus_h264_stop(struct cedrus_ctx *ctx) >> >> vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); >> >> - for (i = 0; i < vq->num_buffers; i++) { >> - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); >> + for (i = 0; i < vb2_get_num_buffers(vq); i++) { >> + struct vb2_buffer *vb = vb2_get_buffer(vq, i); >> + >> + if (!vb) >> + continue; > Please add a newline here to be consistent with the other block being changed. > > With this change and the commit log reworked, you can consider this: > Acked-by: Paul Kocialkowski That will be done for the next version. Thanks, Benjamin > > Thanks! > > Paul > >> + buf = vb2_to_cedrus_buffer(vb); >> >> if (buf->codec.h264.mv_col_buf_size > 0) { >> dma_free_attrs(dev->dev, >> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c >> index fc9297232456..52e94c8f2f01 100644 >> --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c >> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c >> @@ -869,8 +869,13 @@ static void cedrus_h265_stop(struct cedrus_ctx *ctx) >> >> vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); >> >> - for (i = 0; i < vq->num_buffers; i++) { >> - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); >> + for (i = 0; i < vb2_get_num_buffers(vq); i++) { >> + struct vb2_buffer *vb = vb2_get_buffer(vq, i); >> + >> + if (!vb) >> + continue; >> + >> + buf = vb2_to_cedrus_buffer(vb); >> >> if (buf->codec.h265.mv_col_buf_size > 0) { >> dma_free_attrs(dev->dev, >> -- >> 2.39.2 >>