[v7,06/49] media: mediatek: vdec: Use vb2_get_buffer() instead of directly access to buffers array
Message ID | 20230914133323.198857-7-benjamin.gaignard@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp497862vqi; Thu, 14 Sep 2023 10:11:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlVJhxjXsmGAYbcm++XWU3mZSr0S7rhiUAHJOMtUnTI1uOwYMuzRQJb9iacs/9c8kkgAlz X-Received: by 2002:a17:90b:198:b0:274:8eda:4cbb with SMTP id t24-20020a17090b019800b002748eda4cbbmr513209pjs.45.1694711492144; Thu, 14 Sep 2023 10:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694711492; cv=none; d=google.com; s=arc-20160816; b=Iv5QDWRxq7X3PCslxvANTUQDl+HMsAQUQJ0/tjUqUlJ+KOR41RtYb//hzDZRPSnNLG YK9Wr7YSEYqKpD7VodPQWzFILj1x5VU5OzWfTjw048E7/Eu9mPhTQILGYUE0UyT/nYzB P8Gs9Ct6ZvoOuicSj5XBpf5fhmrhTDUfjvY3WzqefLw+HzHVdh9JMGcW+VOBjEM/DJTE dF2BI0iPIARQ77Gnh+OjuZQVWklgeLnxkM07yT/0w1sltSDwdXQTu+Nm3BSCJ/IhRntF 4UktsA+G2UBhyyscwvOnpmmwSFE0VXmkay1HDEz2FDUyHSfMmCkkPcIbGBVXx0BnUky6 8p/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rxTytmhcaGqQ6TxTLxs63nIblD5Z31IleixuR2BXvZs=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=mPjCQXv83B7jXTa+lOeBnqwtukvuQ/TpOTjF8j4fvdLzru9HLIYqh1SwDCoqqffrz3 1HyR94T2khFV8sez2MRIA+YRplkGnMyNxzlzCPZoTIrrZp5l3mVuwztLlkxV19CDigBC 47joempq7zydAmzeEOAk5yAfInfKhRgWUgK69fqJTt2fadb/rfaQeSW3UblKGzOifn5n 7xVVqXqio3Wjdil+EpSrxOtA1p6G8pb7cRu0OUzX6d56q/MQ1x+5y2wgjttkuj4+jx9t Pd2ciyk/7MtmlDqiMTbbGR1TdZwrtUkXVc1VjpdhRqLpnABlNQoSH1EGaoT0FqWalz12 lMgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="XN/Q+/iA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id nn7-20020a17090b38c700b00262f798b614si2083665pjb.51.2023.09.14.10.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:11:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="XN/Q+/iA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id C0EDF817C8BD; Thu, 14 Sep 2023 06:34:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239192AbjINNdv (ORCPT <rfc822;chrisfriedt@gmail.com> + 35 others); Thu, 14 Sep 2023 09:33:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239048AbjINNdk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 14 Sep 2023 09:33:40 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D27BA1BF8; Thu, 14 Sep 2023 06:33:35 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 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 59CAF6607353; Thu, 14 Sep 2023 14:33:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698414; bh=AbX8Bj09PnboIxD2raU5YodRf5hnpL4JGOUWd895O1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XN/Q+/iALI6AW7uPf90PA2TdnOCcG33rAlL1rqHy233ECFSiPczeq4v0XzrewUgd6 GqcbSEV0LgKkVae73L03deGPPLq6/msINwJr0vurc3+INW+cjYi+mkj6HYPwR4QqPo lgnB5Q6GJITzVz6M93QwB6TgMVKQDvFWMzDbH2oBo9ZDtvK4cvciLgtBPRyJ2wdd9B bAzQATMxvjgsZB/1kzvGJsUeLGFZpkz/WNQZY2Cdau7i1ueOhD5LDcl0AMatccSEac 5lTUXdDQVmS7mmUAtJFnr5JpawkIFkTkviEZfBAtHdGKxn2piY/FaE9UMW8FOx/X0+ qGS1RTRASbXSQ== From: Benjamin Gaignard <benjamin.gaignard@collabora.com> To: 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 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, Benjamin Gaignard <benjamin.gaignard@collabora.com> Subject: [PATCH v7 06/49] media: mediatek: vdec: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 14 Sep 2023 15:32:40 +0200 Message-Id: <20230914133323.198857-7-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:12 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777033797886948084 X-GMAIL-MSGID: 1777033797886948084 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Sept. 14, 2023, 1:32 p.m. UTC
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.
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 <benjamin.gaignard@collabora.com>
---
.../platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 14/09/2023 15:32, 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. > 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 <benjamin.gaignard@collabora.com> > --- > .../platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c > index e393e3e668f8..3d2ae0e1b5b6 100644 > --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c > +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c > @@ -1696,7 +1696,7 @@ static int vdec_vp9_slice_setup_core_buffer(struct vdec_vp9_slice_instance *inst > > /* update internal buffer's width/height */ > for (i = 0; i < vq->num_buffers; i++) { > - if (vb == vq->bufs[i]) { > + if (vb == vb2_get_buffer(vq, i)) { The original code here is silly... > instance->dpb[i].width = w; > instance->dpb[i].height = h; > break; ...This can just be changed to: instance->dpb[vb->index].width = w; instance->dpb[vb->index].height = h; No need to loop. Regards, Hans
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c index e393e3e668f8..3d2ae0e1b5b6 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c @@ -1696,7 +1696,7 @@ static int vdec_vp9_slice_setup_core_buffer(struct vdec_vp9_slice_instance *inst /* update internal buffer's width/height */ for (i = 0; i < vq->num_buffers; i++) { - if (vb == vq->bufs[i]) { + if (vb == vb2_get_buffer(vq, i)) { instance->dpb[i].width = w; instance->dpb[i].height = h; break;