From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Christian_K=c3=b6nig?= Subject: Re: [PATCH] dma-buf: Make mmap callback actually optional Date: Mon, 1 Apr 2019 15:38:36 +0200 Message-ID: <24aa0897-8f23-f747-d9a4-d5272f37beea@gmail.com> References: <20190329165201.16233-1-afd@ti.com> Reply-To: christian.koenig@amd.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20190329165201.16233-1-afd@ti.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: "Andrew F. Davis" , Sumit Semwal Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org Am 29.03.19 um 17:52 schrieb Andrew F. Davis: > The docs state the callback is optional but it is not, make it optional. > > Signed-off-by: Andrew F. Davis Reviewed-by: Christian König > --- > drivers/dma-buf/dma-buf.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > index 7c858020d14b..4d4ae9fe9ac8 100644 > --- a/drivers/dma-buf/dma-buf.c > +++ b/drivers/dma-buf/dma-buf.c > @@ -90,6 +90,10 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma) > > dmabuf = file->private_data; > > + /* check if buffer supports mmap */ > + if (!dmabuf->ops->mmap) > + return -EINVAL; > + > /* check for overflowing the buffer's size */ > if (vma->vm_pgoff + vma_pages(vma) > > dmabuf->size >> PAGE_SHIFT) > @@ -404,8 +408,7 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info) > || !exp_info->ops > || !exp_info->ops->map_dma_buf > || !exp_info->ops->unmap_dma_buf > - || !exp_info->ops->release > - || !exp_info->ops->mmap)) { > + || !exp_info->ops->release)) { > return ERR_PTR(-EINVAL); > } > > @@ -906,6 +909,10 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma, > if (WARN_ON(!dmabuf || !vma)) > return -EINVAL; > > + /* check if buffer supports mmap */ > + if (!dmabuf->ops->mmap) > + return -EINVAL; > + > /* check for offset overflow */ > if (pgoff + vma_pages(vma) < pgoff) > return -EOVERFLOW;