Skip to contentSkip to conversation

sample/mdev/mbochs: remove mbochs_kmap_atomic_dmabuf

PATCH In review Gerd Hoffmann 3 participants 7 messages Jun 25, 2018 – Jun 27, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 sample/mdev/mbochs: remove mbochs_kmap_atomic_dmabuf

Atomic mapping interface for dmabufs will be removed.

---
 samples/vfio-mdev/mbochs.c | 10 ----------
 1 file changed, 10 deletions(-)
samples/vfio-mdev/mbochs.c +0 -10
index 2960e26c6e..aa25cda21d 100644
@@ -803,15 +803,6 @@ static void mbochs_release_dmabuf(struct dma_buf *buf)
 	mutex_unlock(&mdev_state->ops_lock);
 }
 
-static void *mbochs_kmap_atomic_dmabuf(struct dma_buf *buf,
-				       unsigned long page_num)
-{
-	struct mbochs_dmabuf *dmabuf = buf->priv;
-	struct page *page = dmabuf->pages[page_num];
-
-	return kmap_atomic(page);
-}
-
 static void *mbochs_kmap_dmabuf(struct dma_buf *buf, unsigned long page_num)
 {
 	struct mbochs_dmabuf *dmabuf = buf->priv;
@@ -824,7 +815,6 @@ 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_atomic	  = mbochs_kmap_atomic_dmabuf,
 	.map		  = mbochs_kmap_dmabuf,
 	.mmap		  = mbochs_mmap_dmabuf,
 };
Signature · 6 lines
2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/2 sample/mdev/mbochs: add mbochs_kunmap_dmabuf

There is no default implementation for dma_buf_ops->unmap. So add a function unmapping the page, otherwise we'll leak them.

---
 samples/vfio-mdev/mbochs.c | 7 +++++++
 1 file changed, 7 insertions(+)
samples/vfio-mdev/mbochs.c +7 -0
index aa25cda21d..85ac603769 100644
@@ -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,
 };
 
Signature · 6 lines
2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 1/2
#5 lore raw
In reply to Gerd Hoffmann

Am 25.06.2018 08:45 schrieb Gerd Hoffmann <[email protected]>:
Atomic mapping interface for dmabufs will be removed.

---
 samples/vfio-mdev/mbochs.c | 10 ----------
 1 file changed, 10 deletions(-)
samples/vfio-mdev/mbochs.c +0 -10
index 2960e26c6e..aa25cda21d 100644
@@ -803,15 +803,6 @@ static void mbochs_release_dmabuf(struct dma_buf *buf)
         mutex_unlock(&mdev_state->ops_lock);
 }
 
-static void *mbochs_kmap_atomic_dmabuf(struct dma_buf *buf,
-                                      unsigned long page_num)
-{
-       struct mbochs_dmabuf *dmabuf = buf->priv;
-       struct page *page = dmabuf->pages[page_num];
-
-       return kmap_atomic(page);
-}
-
 static void *mbochs_kmap_dmabuf(struct dma_buf *buf, unsigned long page_num)
 {
         struct mbochs_dmabuf *dmabuf = buf->priv;
@@ -824,7 +815,6 @@ 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_atomic       = mbochs_kmap_atomic_dmabuf,
         .map              = mbochs_kmap_dmabuf,
         .mmap             = mbochs_mmap_dmabuf,
 };

--
2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
In reply to Gerd Hoffmann
Quoted 3 lines · On Mon, 25 Jun 2018 08:44:51 +0200 Gerd Hoffmann <[email protected]> wrote:

Atomic mapping interface for dmabufs will be removed.

Fixes f664a5269542 ("dma-buf: remove kmap_atomic interface")

Though really the above commit needs to be updated to include this fix to preserve bisection since the mbochs sample driver is already upstream, suggests we only compile tested removing kmap_atomic without looking for other users. drm folks, please update. Thanks,

Alex

Quoted 25 lines
---
 samples/vfio-mdev/mbochs.c | 10 ----------
 1 file changed, 10 deletions(-)
samples/vfio-mdev/mbochs.c +0 -9
index 2960e26c6e..aa25cda21d 100644
@@ -803,15 +803,6 @@ static void mbochs_release_dmabuf(struct dma_buf *buf)
 	mutex_unlock(&mdev_state->ops_lock);
 }
 
-static void *mbochs_kmap_atomic_dmabuf(struct dma_buf *buf,
-				       unsigned long page_num)
-{
-	struct mbochs_dmabuf *dmabuf = buf->priv;
-	struct page *page = dmabuf->pages[page_num];
-
-	return kmap_atomic(page);
-}
-
 static void *mbochs_kmap_dmabuf(struct dma_buf *buf, unsigned long page_num)
 {
 	struct mbochs_dmabuf *dmabuf = buf->priv;

samples/vfio-mdev/mbochs.c static struct dma_buf_ops mbochs_dmabuf_ops = { · line 820

Quoted 7 lines
samples/vfio-mdev/mbochs.c +0 -1
@@ -824,7 +815,6 @@ 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_atomic	  = mbochs_kmap_atomic_dmabuf,
 	.map		  = mbochs_kmap_dmabuf,
 	.mmap		  = mbochs_mmap_dmabuf,
 };

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

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

In reply to Gerd Hoffmann
Quoted 21 lines · On Mon, 25 Jun 2018 08:44:52 +0200 Gerd Hoffmann <[email protected]> wrote:

There is no default implementation for dma_buf_ops->unmap. So add a function unmapping the page, otherwise we'll leak them.

---
 samples/vfio-mdev/mbochs.c | 7 +++++++
 1 file changed, 7 insertions(+)
samples/vfio-mdev/mbochs.c +5 -0
index aa25cda21d..85ac603769 100644
@@ -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);
+}

samples/vfio-mdev/mbochs.c static void *mbochs_kmap_dmabuf(struct dma_buf *buf, unsigned long page_num) · line 828

Quoted 10 lines
samples/vfio-mdev/mbochs.c +2 -0
+
 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
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

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

Quoted 7 lines

samples/vfio-mdev/mbochs.c static void *mbochs_kmap_dmabuf(struct dma_buf *buf, unsigned long page_num) · line 827

Quoted 5 lines
samples/vfio-mdev/mbochs.c +1 -0
 	.map		  = mbochs_kmap_dmabuf,
+	.unmap		  = mbochs_kunmap_dmabuf,
 	.mmap		  = mbochs_mmap_dmabuf,
 };

Is this a fix for v4.18?

Yes.

Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

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

Quoted 15 lines · On Tue, 26 Jun 2018 09:32:33 +0200 Gerd Hoffmann <[email protected]> wrote:
Quoted 7 lines

samples/vfio-mdev/mbochs.c static void *mbochs_kmap_dmabuf(struct dma_buf *buf, unsigned long page_num) · line 827

Quoted 5 lines
samples/vfio-mdev/mbochs.c +1 -0
 	.map		  = mbochs_kmap_dmabuf,
+	.unmap		  = mbochs_kunmap_dmabuf,
 	.mmap		  = mbochs_mmap_dmabuf,
 };

Is this a fix for v4.18?

Yes.

Quoted 4 lines

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?

Quoted 6 lines

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
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel