Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp49504pxf; Wed, 24 Mar 2021 20:37:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfqrxd5KajsZHO9nJta249cR54k2RLNv5vkfCWn65qBPPyxNlQucDLMk+KGeXhCS1fmOpL X-Received: by 2002:a17:906:75a:: with SMTP id z26mr7020121ejb.22.1616643463363; Wed, 24 Mar 2021 20:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616643463; cv=none; d=google.com; s=arc-20160816; b=QVntqsuSRurLJpV4C9I0T5WoiYvhl0cNG7SCwCybSjXD+XTGLQ63QZrHNX4LcstMM5 ssAcYkcAt0B0cu3wIhJLIImtGunuZl/pZHRFHtoSVDtQ1rmvJfn5gvwEW3VkyQDb+xmT igpJO6rU7UEiuVSXA+cSTfSG/17mVOwNvyLYYinHy5DjTcs5v4RzjHPqF7YBYSYWjoq8 iWlCaFzGTC456cP3I+VG+01XZiBEQ9YiV1ia0gZWFI1oOwoCFkI+179uAkr//SQr9c1o fzsZAtiZaWeek9tsOEtdtj2k+loE+L8X1yy3ZxAH9stPTaVYBD+DxrE5kAYMgEJEDqCD OUMw== 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; bh=u+j4zXPyP+ZvF/yyl64clxGCtgU+OZ3jJJ2ygGOz8z0=; b=DcIGLJ9mQMp3LFRt2sF7t1HIBi9g1rhzkrITOQwBnupy1NBzNYhsHnv09S0eUKuiUX cuCUxvSLqVzeMJnF7Sysv9zFj9P/tbUnsAckaBtctwTtW11nZPLnELyfCOUqI/mskKQX 1rDT87XQKVMg9uaJxrKpOm4cge15FtIr9CHUXotu935SHpJ7ErTs4HkWXBCG5epnw1iR c3H2EEJqRK9lTiK6AiaAD8ERXlos3TjB7+DxUvW0jD8AhKsgqX/1ooZvZu/GoZEj8/2Q IaGSDVuzw1JrqA2p/x0cwo93sraEIjpnWna2gzlF4q75ylc7yAdD4WDrCjo6hVc4oPi0 WMrw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si3082604eds.83.2021.03.24.20.37.20; Wed, 24 Mar 2021 20:37:43 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239199AbhCYASx (ORCPT + 99 others); Wed, 24 Mar 2021 20:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239163AbhCYASf (ORCPT ); Wed, 24 Mar 2021 20:18:35 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C029CC06174A; Wed, 24 Mar 2021 17:18:34 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: koike) with ESMTPSA id 93A621F45EF9 From: Helen Koike To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, kernel@collabora.com, linux-kernel@vger.kernel.org, jc@kynesim.co.uk, laurent.pinchart@ideasonboard.com, dave.stevenson@raspberrypi.org, tfiga@chromium.org, Helen Koike Subject: [PATCH 2/2] media: videobuf2: cleanup size argument from attach_dmabuf() Date: Wed, 24 Mar 2021 21:17:12 -0300 Message-Id: <20210325001712.197837-2-helen.koike@collabora.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210325001712.197837-1-helen.koike@collabora.com> References: <20210325001712.197837-1-helen.koike@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since we always use the size of the underlying buffer for dmabuf, remove the size parameter from the attach_dmabuf() callback. Suggested-by: Hans Verkuil Signed-off-by: Helen Koike --- drivers/media/common/videobuf2/videobuf2-core.c | 2 +- drivers/media/common/videobuf2/videobuf2-dma-contig.c | 7 ++----- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 7 ++----- drivers/media/common/videobuf2/videobuf2-vmalloc.c | 7 ++----- include/media/videobuf2-core.h | 1 - 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 2cbde14af051..86af4f3c72eb 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -1266,7 +1266,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb) /* Acquire each plane's memory */ mem_priv = call_ptr_memop(vb, attach_dmabuf, q->alloc_devs[plane] ? : q->dev, - dbuf, planes[plane].length, q->dma_dir); + dbuf, q->dma_dir); if (IS_ERR(mem_priv)) { dprintk(q, 1, "failed to attach dmabuf\n"); ret = PTR_ERR(mem_priv); diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c index a7f61ba85440..a26aa52f954b 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c @@ -661,14 +661,11 @@ static void vb2_dc_detach_dmabuf(void *mem_priv) } static void *vb2_dc_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, - unsigned long size, enum dma_data_direction dma_dir) + enum dma_data_direction dma_dir) { struct vb2_dc_buf *buf; struct dma_buf_attachment *dba; - if (dbuf->size < size) - return ERR_PTR(-EFAULT); - if (WARN_ON(!dev)) return ERR_PTR(-EINVAL); @@ -686,7 +683,7 @@ static void *vb2_dc_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, } buf->dma_dir = dma_dir; - buf->size = size; + buf->size = dbuf->size; buf->db_attach = dba; return buf; diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c index c5b06a509566..8c006f79bed4 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c @@ -606,7 +606,7 @@ static void vb2_dma_sg_detach_dmabuf(void *mem_priv) } static void *vb2_dma_sg_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, - unsigned long size, enum dma_data_direction dma_dir) + enum dma_data_direction dma_dir) { struct vb2_dma_sg_buf *buf; struct dma_buf_attachment *dba; @@ -614,9 +614,6 @@ static void *vb2_dma_sg_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, if (WARN_ON(!dev)) return ERR_PTR(-EINVAL); - if (dbuf->size < size) - return ERR_PTR(-EFAULT); - buf = kzalloc(sizeof(*buf), GFP_KERNEL); if (!buf) return ERR_PTR(-ENOMEM); @@ -631,7 +628,7 @@ static void *vb2_dma_sg_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, } buf->dma_dir = dma_dir; - buf->size = size; + buf->size = dmabuf->size; buf->db_attach = dba; return buf; diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c b/drivers/media/common/videobuf2/videobuf2-vmalloc.c index 83f95258ec8c..c2d41b375c10 100644 --- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c +++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c @@ -404,20 +404,17 @@ static void vb2_vmalloc_detach_dmabuf(void *mem_priv) } static void *vb2_vmalloc_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, - unsigned long size, enum dma_data_direction dma_dir) + enum dma_data_direction dma_dir) { struct vb2_vmalloc_buf *buf; - if (dbuf->size < size) - return ERR_PTR(-EFAULT); - buf = kzalloc(sizeof(*buf), GFP_KERNEL); if (!buf) return ERR_PTR(-ENOMEM); buf->dbuf = dbuf; buf->dma_dir = dma_dir; - buf->size = size; + buf->size = dbuf->size; return buf; } diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 12955cb460d2..db07001cada8 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -134,7 +134,6 @@ struct vb2_mem_ops { void *(*attach_dmabuf)(struct device *dev, struct dma_buf *dbuf, - unsigned long size, enum dma_data_direction dma_dir); void (*detach_dmabuf)(void *buf_priv); int (*map_dmabuf)(void *buf_priv); -- 2.30.1