Skip to contentSkip to conversation

virtio-gpu-udmabuf: create udmabuf for blob even when iov_cnt == 1

PATCH In review Dongwon Kim 2 participants 2 messages Jun 21, 2023 – Jun 26, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-gpu-udmabuf: create udmabuf for blob even when iov_cnt == 1

There were often cases where a scanout blob sometimes has just 1 entry that is linked to many pages in it. So just checking whether iov_cnt is 1 is not enough for screening small, non-scanout blobs. Therefore adding iov_len check as well to make sure it creates an udmabuf only for a scanout blob, which is at least bigger than one page size.

Cc Gerd Hoffmann <[email protected]>
Cc Marc-André Lureau <[email protected]>
Cc Vivek Kasireddy <[email protected]>
---
 hw/display/virtio-gpu-udmabuf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/display/virtio-gpu-udmabuf.c +2 -1
index 69e2cf0bd6..ef1a740de5 100644
@@ -132,7 +132,8 @@ void virtio_gpu_init_udmabuf(struct virtio_gpu_simple_resource *res)
     void *pdata = NULL;
 
     res->dmabuf_fd = -1;
-    if (res->iov_cnt == 1) {
+    if (res->iov_cnt == 1 &&
+        res->iov[0].iov_len < 4096) {
         pdata = res->iov[0].iov_base;
     } else {
         virtio_gpu_create_udmabuf(res);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Dongwon Kim

There were often cases where a scanout blob sometimes has just 1 entry that is linked to many pages in it. So just checking whether iov_cnt is 1 is not enough for screening small, non-scanout blobs. Therefore adding iov_len check as well to make sure it creates an udmabuf only for a scanout blob, which is at least bigger than one page size.

Cc Gerd Hoffmann <[email protected]>
Cc Marc-André Lureau <[email protected]>
Cc Vivek Kasireddy <[email protected]>
Quoted 25 lines
---
 hw/display/virtio-gpu-udmabuf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/display/virtio-gpu-udmabuf.c +2 -1
index 69e2cf0bd6..ef1a740de5 100644
@@ -132,7 +132,8 @@ void virtio_gpu_init_udmabuf(struct
 virtio_gpu_simple_resource *res)
     void *pdata = NULL;
 
     res->dmabuf_fd = -1;
-    if (res->iov_cnt == 1) {
+    if (res->iov_cnt == 1 &&
+        res->iov[0].iov_len < 4096) {
         pdata = res->iov[0].iov_base;
     } else {
         virtio_gpu_create_udmabuf(res);

--
2.34.1

Signature · 1 line
Marc-André Lureau