All of lore.kernel.org
 help / color / mirror / Atom feed
From: dongwon.kim@intel.com
To: qemu-devel@nongnu.org
Cc: philmd@linaro.org, marcandre.lureau@redhat.com
Subject: [PATCH v4 2/3] ui/console: Introduce dpy_gl_dmabuf_get_fd() helper
Date: Thu, 21 Mar 2024 16:42:35 -0700	[thread overview]
Message-ID: <20240321234236.3476163-3-dongwon.kim@intel.com> (raw)
In-Reply-To: <20240321234236.3476163-1-dongwon.kim@intel.com>

From: Dongwon Kim <dongwon.kim@intel.com>

dpy_gl_dmabuf_get_fd() is a helper for retrieving FD of the dmabuf
from QemuDmaBuf struct.

Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 include/ui/console.h | 1 +
 hw/vfio/display.c    | 8 +++++++-
 ui/console.c         | 9 +++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 6064487fc4..d5334a806c 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -360,6 +360,7 @@ void dpy_gl_cursor_position(QemuConsole *con,
                             uint32_t pos_x, uint32_t pos_y);
 uint32_t dpy_gl_dmabuf_get_width(QemuDmaBuf *dmabuf);
 uint32_t dpy_gl_dmabuf_get_height(QemuDmaBuf *dmabuf);
+int32_t dpy_gl_dmabuf_get_fd(QemuDmaBuf *dmabuf);
 void dpy_gl_release_dmabuf(QemuConsole *con,
                            QemuDmaBuf *dmabuf);
 void dpy_gl_update(QemuConsole *con,
diff --git a/hw/vfio/display.c b/hw/vfio/display.c
index c962e5f88f..676b2fc5f3 100644
--- a/hw/vfio/display.c
+++ b/hw/vfio/display.c
@@ -259,9 +259,15 @@ static VFIODMABuf *vfio_display_get_dmabuf(VFIOPCIDevice *vdev,
 
 static void vfio_display_free_one_dmabuf(VFIODisplay *dpy, VFIODMABuf *dmabuf)
 {
+    int fd;
+
     QTAILQ_REMOVE(&dpy->dmabuf.bufs, dmabuf, next);
+    fd = dpy_gl_dmabuf_get_fd(&dmabuf->buf);
+    if (fd > -1) {
+        close(fd);
+    }
+
     dpy_gl_release_dmabuf(dpy->con, &dmabuf->buf);
-    close(dmabuf->buf.fd);
     g_free(dmabuf);
 }
 
diff --git a/ui/console.c b/ui/console.c
index 1d0513a733..69560aac7e 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1504,6 +1504,15 @@ int qemu_console_get_height(QemuConsole *con, int fallback)
     }
 }
 
+int32_t dpy_gl_dmabuf_get_fd(QemuDmaBuf *dmabuf)
+{
+    if (dmabuf) {
+        return dmabuf->fd;
+    }
+
+    return -1;
+}
+
 int qemu_invalidate_text_consoles(void)
 {
     QemuConsole *s;
-- 
2.34.1



  parent reply	other threads:[~2024-03-21 23:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-21 23:42 [PATCH v4 0/3] ui/console: Introduce helpers for creating and dongwon.kim
2024-03-21 23:42 ` [PATCH v4 1/3] ui/console: Introduce dpy_gl_dmabuf_get_height/width() helpers dongwon.kim
2024-03-22  9:05   ` Marc-André Lureau
2024-03-22 16:27     ` Kim, Dongwon
2024-03-21 23:42 ` dongwon.kim [this message]
2024-03-22  9:06   ` [PATCH v4 2/3] ui/console: Introduce dpy_gl_dmabuf_get_fd() helper Marc-André Lureau
2024-03-21 23:42 ` [PATCH v4 3/3] ui/console: Introduce dpy_gl_create_dmabuf() helper dongwon.kim
2024-03-22  9:05   ` Marc-André Lureau
2024-03-22 16:21     ` Kim, Dongwon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240321234236.3476163-3-dongwon.kim@intel.com \
    --to=dongwon.kim@intel.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.