From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Dongwon Kim <dongwon.kim@intel.com>, qemu-devel@nongnu.org
Cc: "Alex Williamson" <alex.williamson@redhat.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Vivek Kasireddy" <vivek.kasireddy@intel.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v3 2/3] ui/console: Introduce dpy_gl_dmabuf_get_fd() helper
Date: Thu, 21 Mar 2024 11:06:34 +0100 [thread overview]
Message-ID: <20240321100635.64950-3-philmd@linaro.org> (raw)
In-Reply-To: <20240321100635.64950-1-philmd@linaro.org>
From: Dongwon Kim <dongwon.kim@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
Message-Id: <20240320034229.3347130-1-dongwon.kim@intel.com>
[PMD: Split patch in 3, part 2/3]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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 a7f6cef26d..1f3d025548 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 edabad64c0..10abeb9780 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1208,6 +1208,15 @@ uint32_t dpy_gl_dmabuf_get_height(QemuDmaBuf *dmabuf)
return 0;
}
+int32_t dpy_gl_dmabuf_get_fd(QemuDmaBuf *dmabuf)
+{
+ if (dmabuf) {
+ return dmabuf->fd;
+ }
+
+ return -1;
+}
+
void dpy_gl_release_dmabuf(QemuConsole *con,
QemuDmaBuf *dmabuf)
{
--
2.41.0
next prev parent reply other threads:[~2024-03-21 10:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-21 10:06 [PATCH v3 0/3] ui/console: initialize QemuDmaBuf in ui/console Philippe Mathieu-Daudé
2024-03-21 10:06 ` [PATCH v3 1/3] ui/console: Introduce dpy_gl_dmabuf_get_height/width() helpers Philippe Mathieu-Daudé
2024-03-21 10:06 ` Philippe Mathieu-Daudé [this message]
2024-03-21 10:06 ` [INCOMPLETE PATCH v3 3/3] ui/console: Introduce dpy_gl_create_dmabuf() helper Philippe Mathieu-Daudé
2024-03-21 23:46 ` 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=20240321100635.64950-3-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=clg@redhat.com \
--cc=dongwon.kim@intel.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vivek.kasireddy@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).