diff mbox

[2/2] sample/mdev/mbochs: add mbochs_kunmap_dmabuf

Message ID 20180625064453.19768-2-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gerd Hoffmann June 25, 2018, 6:44 a.m. UTC
There is no default implementation for dma_buf_ops->unmap.
So add a function unmapping the page, otherwise we'll leak them.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 samples/vfio-mdev/mbochs.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Alex Williamson June 26, 2018, 7:20 a.m. UTC | #1
On Mon, 25 Jun 2018 08:44:52 +0200
Gerd Hoffmann <kraxel@redhat.com> wrote:

> There is no default implementation for dma_buf_ops->unmap.
> So add a function unmapping the page, otherwise we'll leak them.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  samples/vfio-mdev/mbochs.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
> index aa25cda21d..85ac603769 100644
> --- a/samples/vfio-mdev/mbochs.c
> +++ b/samples/vfio-mdev/mbochs.c
> @@ -811,11 +811,18 @@ static void *mbochs_kmap_dmabuf(struct dma_buf *buf, unsigned long page_num)
>  	return kmap(page);
>  }
>  
> +static void mbochs_kunmap_dmabuf(struct dma_buf *buf, unsigned long page_num,
> +				 void *vaddr)
> +{
> +	kunmap(vaddr);
> +}
> +
>  static struct dma_buf_ops mbochs_dmabuf_ops = {
>  	.map_dma_buf	  = mbochs_map_dmabuf,
>  	.unmap_dma_buf	  = mbochs_unmap_dmabuf,
>  	.release	  = mbochs_release_dmabuf,
>  	.map		  = mbochs_kmap_dmabuf,
> +	.unmap		  = mbochs_kunmap_dmabuf,
>  	.mmap		  = mbochs_mmap_dmabuf,
>  };
>  

Is this a fix for v4.18?  AFAICT, the kmap_atomic removal is only in
next, not yet upstream and hopefully includes this sample driver before
hitting mainline.  Should we therefore have a v4.18-rc based patch for
this to include before v4.18 to resolve this?  Thanks,

Alex
Gerd Hoffmann June 26, 2018, 7:32 a.m. UTC | #2
> >  	.map		  = mbochs_kmap_dmabuf,
> > +	.unmap		  = mbochs_kunmap_dmabuf,
> >  	.mmap		  = mbochs_mmap_dmabuf,
> >  };
> >  
> 
> Is this a fix for v4.18?

Yes.

> AFAICT, the kmap_atomic removal is only in
> next, not yet upstream and hopefully includes this sample driver before
> hitting mainline.  Should we therefore have a v4.18-rc based patch for
> this to include before v4.18 to resolve this?

The kmap_atomic interface will be removed in 4.19 because nobody uses
it, so dropping the mbochs implementation already in 4.18 should not
cause any issues.

So just queue both for 4.18 would be the easiest way do deal with the
dependency I think.

cheers,
  Gerd
Alex Williamson June 27, 2018, 1:55 a.m. UTC | #3
On Tue, 26 Jun 2018 09:32:33 +0200
Gerd Hoffmann <kraxel@redhat.com> wrote:

> > >  	.map		  = mbochs_kmap_dmabuf,
> > > +	.unmap		  = mbochs_kunmap_dmabuf,
> > >  	.mmap		  = mbochs_mmap_dmabuf,
> > >  };
> > >    
> > 
> > Is this a fix for v4.18?  
> 
> Yes.
> 
> > AFAICT, the kmap_atomic removal is only in
> > next, not yet upstream and hopefully includes this sample driver before
> > hitting mainline.  Should we therefore have a v4.18-rc based patch for
> > this to include before v4.18 to resolve this?  
> 
> The kmap_atomic interface will be removed in 4.19 because nobody uses
> it, so dropping the mbochs implementation already in 4.18 should not
> cause any issues.
> 
> So just queue both for 4.18 would be the easiest way do deal with the
> dependency I think.

Ok, so I'll drop the fixes tag and apply both to my for-linus branch
for v4.18 and then Christian won't need to include it for the v4.19
patch.  Thanks,

Alex
diff mbox

Patch

diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
index aa25cda21d..85ac603769 100644
--- a/samples/vfio-mdev/mbochs.c
+++ b/samples/vfio-mdev/mbochs.c
@@ -811,11 +811,18 @@  static void *mbochs_kmap_dmabuf(struct dma_buf *buf, unsigned long page_num)
 	return kmap(page);
 }
 
+static void mbochs_kunmap_dmabuf(struct dma_buf *buf, unsigned long page_num,
+				 void *vaddr)
+{
+	kunmap(vaddr);
+}
+
 static struct dma_buf_ops mbochs_dmabuf_ops = {
 	.map_dma_buf	  = mbochs_map_dmabuf,
 	.unmap_dma_buf	  = mbochs_unmap_dmabuf,
 	.release	  = mbochs_release_dmabuf,
 	.map		  = mbochs_kmap_dmabuf,
+	.unmap		  = mbochs_kunmap_dmabuf,
 	.mmap		  = mbochs_mmap_dmabuf,
 };