From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: David Airlie <airlied@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Gurchetan Singh <gurchetansingh@chromium.org>,
Chia-I Wu <olvaffe@gmail.com>,
Vivek Kasireddy <vivek.kasireddy@intel.com>,
Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev,
linux-kernel@vger.kernel.org, kernel@collabora.com
Subject: [PATCH v1 2/2] drm/virtio: Fix missed dmabuf unpinning in error path of prepare_fb()
Date: Wed, 26 Mar 2025 04:49:02 +0300 [thread overview]
Message-ID: <20250326014902.379339-2-dmitry.osipenko@collabora.com> (raw)
In-Reply-To: <20250326014902.379339-1-dmitry.osipenko@collabora.com>
Unpin imported dmabuf on fence allocation failure in prepare_fb().
Fixes: 4a696a2ee646 ("drm/virtio: Add prepare and cleanup routines for imported dmabuf obj")
Cc: <stable@vger.kernel.org> # v6.14+
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_plane.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
index a6f5a78f436a..dc1d91639931 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -342,6 +342,16 @@ static int virtio_gpu_prepare_imported_obj(struct drm_plane *plane,
return ret;
}
+static void virtio_gpu_cleanup_imported_obj(struct drm_gem_object *obj)
+{
+ struct dma_buf_attachment *attach = obj->import_attach;
+ struct dma_resv *resv = attach->dmabuf->resv;
+
+ dma_resv_lock(resv, NULL);
+ dma_buf_unpin(attach);
+ dma_resv_unlock(resv);
+}
+
static int virtio_gpu_plane_prepare_fb(struct drm_plane *plane,
struct drm_plane_state *new_state)
{
@@ -376,23 +386,16 @@ static int virtio_gpu_plane_prepare_fb(struct drm_plane *plane,
vgplane_st->fence = virtio_gpu_fence_alloc(vgdev,
vgdev->fence_drv.context,
0);
- if (!vgplane_st->fence)
+ if (!vgplane_st->fence) {
+ if (obj->import_attach)
+ virtio_gpu_cleanup_imported_obj(obj);
return -ENOMEM;
+ }
}
return 0;
}
-static void virtio_gpu_cleanup_imported_obj(struct drm_gem_object *obj)
-{
- struct dma_buf_attachment *attach = obj->import_attach;
- struct dma_resv *resv = attach->dmabuf->resv;
-
- dma_resv_lock(resv, NULL);
- dma_buf_unpin(attach);
- dma_resv_unlock(resv);
-}
-
static void virtio_gpu_plane_cleanup_fb(struct drm_plane *plane,
struct drm_plane_state *state)
{
--
2.49.0
next prev parent reply other threads:[~2025-03-26 1:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 1:49 [PATCH v1 1/2] drm/virtio: Don't attach GEM to a non-created context in gem_object_open() Dmitry Osipenko
2025-03-26 1:49 ` Dmitry Osipenko [this message]
2025-03-26 5:14 ` [PATCH v1 2/2] drm/virtio: Fix missed dmabuf unpinning in error path of prepare_fb() Kasireddy, Vivek
2025-03-26 11:54 ` Dmitry Osipenko
2025-03-27 7:14 ` Kasireddy, Vivek
2025-03-28 1:35 ` Dmitry Osipenko
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=20250326014902.379339-2-dmitry.osipenko@collabora.com \
--to=dmitry.osipenko@collabora.com \
--cc=airlied@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@chromium.org \
--cc=kernel@collabora.com \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olvaffe@gmail.com \
--cc=pierre-eric.pelloux-prayer@amd.com \
--cc=virtualization@lists.linux.dev \
--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