dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Stone <daniels@collabora.com>
To: dri-devel@lists.freedesktop.org
Cc: Dave Airlie <airlied@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	virtualization@lists.linux-foundation.org
Subject: [PATCH 03/24] drm/virtio: Place GEM BOs in drm_framebuffer
Date: Fri, 30 Mar 2018 15:11:17 +0100	[thread overview]
Message-ID: <20180330141138.28987-3-daniels@collabora.com> (raw)
In-Reply-To: <20180330141138.28987-1-daniels@collabora.com>

Since drm_framebuffer can now store GEM objects directly, place them
there rather than in our own subclass. As this makes the framebuffer
create_handle and destroy functions the same as the GEM framebuffer
helper, we can reuse those.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
---
 drivers/gpu/drm/virtio/virtgpu_display.c | 30 +++++-------------------------
 drivers/gpu/drm/virtio/virtgpu_drv.h     |  1 -
 drivers/gpu/drm/virtio/virtgpu_fb.c      |  8 ++++----
 drivers/gpu/drm/virtio/virtgpu_plane.c   |  4 ++--
 4 files changed, 11 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index 8cc8c34d67f5..af542f1216f9 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -28,6 +28,7 @@
 #include "virtgpu_drv.h"
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 
 #define XRES_MIN    32
 #define YRES_MIN    32
@@ -48,16 +49,6 @@ static const struct drm_crtc_funcs virtio_gpu_crtc_funcs = {
 	.atomic_destroy_state   = drm_atomic_helper_crtc_destroy_state,
 };
 
-static void virtio_gpu_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-	struct virtio_gpu_framebuffer *virtio_gpu_fb
-		= to_virtio_gpu_framebuffer(fb);
-
-	drm_gem_object_put_unlocked(virtio_gpu_fb->obj);
-	drm_framebuffer_cleanup(fb);
-	kfree(virtio_gpu_fb);
-}
-
 static int
 virtio_gpu_framebuffer_surface_dirty(struct drm_framebuffer *fb,
 				     struct drm_file *file_priv,
@@ -71,20 +62,9 @@ virtio_gpu_framebuffer_surface_dirty(struct drm_framebuffer *fb,
 	return virtio_gpu_surface_dirty(virtio_gpu_fb, clips, num_clips);
 }
 
-static int
-virtio_gpu_framebuffer_create_handle(struct drm_framebuffer *fb,
-				     struct drm_file *file_priv,
-				     unsigned int *handle)
-{
-	struct virtio_gpu_framebuffer *virtio_gpu_fb =
-		to_virtio_gpu_framebuffer(fb);
-
-	return drm_gem_handle_create(file_priv, virtio_gpu_fb->obj, handle);
-}
-
 static const struct drm_framebuffer_funcs virtio_gpu_fb_funcs = {
-	.create_handle = virtio_gpu_framebuffer_create_handle,
-	.destroy = virtio_gpu_user_framebuffer_destroy,
+	.create_handle = drm_gem_fb_create_handle,
+	.destroy = drm_gem_fb_destroy,
 	.dirty = virtio_gpu_framebuffer_surface_dirty,
 };
 
@@ -97,7 +77,7 @@ virtio_gpu_framebuffer_init(struct drm_device *dev,
 	int ret;
 	struct virtio_gpu_object *bo;
 
-	vgfb->obj = obj;
+	vgfb->base.obj[0] = obj;
 
 	bo = gem_to_virtio_gpu_obj(obj);
 
@@ -105,7 +85,7 @@ virtio_gpu_framebuffer_init(struct drm_device *dev,
 
 	ret = drm_framebuffer_init(dev, &vgfb->base, &virtio_gpu_fb_funcs);
 	if (ret) {
-		vgfb->obj = NULL;
+		vgfb->base.obj[0] = NULL;
 		return ret;
 	}
 
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index d25c8ca224aa..65605e207bbe 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -124,7 +124,6 @@ struct virtio_gpu_output {
 
 struct virtio_gpu_framebuffer {
 	struct drm_framebuffer base;
-	struct drm_gem_object *obj;
 	int x1, y1, x2, y2; /* dirty rect */
 	spinlock_t dirty_lock;
 	uint32_t hw_res_handle;
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c
index 8af69ab58b89..a121b1c79522 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -46,7 +46,7 @@ static int virtio_gpu_dirty_update(struct virtio_gpu_framebuffer *fb,
 	int bpp = fb->base.format->cpp[0];
 	int x2, y2;
 	unsigned long flags;
-	struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(fb->obj);
+	struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(fb->base.obj[0]);
 
 	if ((width <= 0) ||
 	    (x + width > fb->base.width) ||
@@ -121,7 +121,7 @@ int virtio_gpu_surface_dirty(struct virtio_gpu_framebuffer *vgfb,
 			     unsigned int num_clips)
 {
 	struct virtio_gpu_device *vgdev = vgfb->base.dev->dev_private;
-	struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(vgfb->obj);
+	struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(vgfb->base.obj[0]);
 	struct drm_clip_rect norect;
 	struct drm_clip_rect *clips_ptr;
 	int left, right, top, bottom;
@@ -305,8 +305,8 @@ static int virtio_gpu_fbdev_destroy(struct drm_device *dev,
 
 	drm_fb_helper_unregister_fbi(&vgfbdev->helper);
 
-	if (vgfb->obj)
-		vgfb->obj = NULL;
+	if (vgfb->base.obj[0])
+		vgfb->base.obj[0] = NULL;
 	drm_fb_helper_fini(&vgfbdev->helper);
 	drm_framebuffer_cleanup(&vgfb->base);
 
diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
index 71ba455af915..dc5b5b2b7aab 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -154,7 +154,7 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
 
 	if (plane->state->fb) {
 		vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
-		bo = gem_to_virtio_gpu_obj(vgfb->obj);
+		bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]);
 		handle = bo->hw_res_handle;
 		if (bo->dumb) {
 			virtio_gpu_cmd_transfer_to_host_2d
@@ -208,7 +208,7 @@ static void virtio_gpu_cursor_plane_update(struct drm_plane *plane,
 
 	if (plane->state->fb) {
 		vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
-		bo = gem_to_virtio_gpu_obj(vgfb->obj);
+		bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]);
 		handle = bo->hw_res_handle;
 	} else {
 		handle = 0;
-- 
2.16.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-03-30 14:11 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-30 14:11 [PATCH 00/24] drm_framebuffer boilerplate removal Daniel Stone
2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
2018-03-30 14:11   ` [PATCH 02/24] drm/cirrus: cirrus_framebuffer -> drm_framebuffer Daniel Stone
2018-05-17 14:25     ` Thierry Reding
2018-03-30 14:11   ` Daniel Stone [this message]
2018-05-17 14:29     ` [PATCH 03/24] drm/virtio: Place GEM BOs in drm_framebuffer Thierry Reding
2018-03-30 14:11   ` [PATCH 04/24] drm/rockchip: " Daniel Stone
2018-05-17 13:57     ` Sean Paul
2018-05-17 14:47     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 05/24] drm/rockchip: rockchip_drm_fb -> drm_framebuffer Daniel Stone
2018-05-17 13:08     ` Daniel Stone
2018-05-17 13:42       ` Heiko Stübner
2018-05-17 14:09         ` Daniel Stone
2018-05-17 13:56     ` Sean Paul
2018-05-17 14:46     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 06/24] drm/omap: Move GEM BO to drm_framebuffer Daniel Stone
2018-03-30 20:54     ` Sebastian Reichel
2018-05-17 14:47     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 07/24] drm/omap: Move buffer pitch/offset " Daniel Stone
2018-03-30 20:53     ` Sebastian Reichel
2018-05-17 13:13       ` Daniel Stone
2018-05-17 14:49     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 08/24] drm/mtk: Promote impossible internal error to WARN_ON Daniel Stone
2018-05-17 13:58     ` Sean Paul
2018-05-17 14:55       ` Thierry Reding
2018-05-18  8:06         ` CK Hu
2018-03-30 14:11   ` [PATCH 09/24] drm/mtk: Move GEM BO to drm_framebuffer Daniel Stone
2018-05-17 13:59     ` Sean Paul
2018-05-17 14:55     ` Thierry Reding
2018-05-18  8:32     ` CK Hu
2018-03-30 14:11   ` [PATCH 10/24] drm/mtk: mtk_drm_fb -> drm_framebuffer Daniel Stone
2018-05-17 13:13     ` Daniel Stone
2018-05-17 13:59     ` Sean Paul
2018-05-17 14:56     ` Thierry Reding
2018-05-18  8:37     ` CK Hu
2018-03-30 14:11   ` [PATCH 11/24] drm/tegra: Remove duplicate framebuffer num_planes Daniel Stone
2018-03-30 14:11   ` [PATCH 12/24] drm/tegra: Move GEM BOs to drm_framebuffer Daniel Stone
2018-03-30 14:11   ` [PATCH 13/24] drm/tegra: tegra_fb -> drm_framebuffer Daniel Stone
2018-05-17 13:11     ` Daniel Stone
2018-05-17 13:46       ` Thierry Reding
2018-03-30 14:11   ` [PATCH 14/24] drm/tegra: Move fbdev unmap special case Daniel Stone
2018-03-30 14:11   ` [PATCH 15/24] drm/tegra: Use drm_gem_fb_destroy Daniel Stone
2018-03-30 14:11   ` [PATCH 16/24] drm/exynos: Move GEM BOs to drm_framebuffer Daniel Stone
2018-04-13  8:55     ` Inki Dae
2018-04-13 10:13       ` Daniel Stone
2018-03-30 14:11   ` [PATCH 17/24] drm/exynos: Move dma_addr out of exynos_drm_fb Daniel Stone
2018-03-30 14:11   ` [PATCH 18/24] drm/exynos: exynos_drm_fb -> drm_framebuffer Daniel Stone
2018-03-30 14:11   ` [PATCH 19/24] drm/armada: Move GEM BO to drm_framebuffer Daniel Stone
2018-05-17 13:15     ` Daniel Stone
2018-05-17 15:26       ` Russell King - ARM Linux
2018-05-17 15:41         ` Daniel Stone
2018-06-26 14:49           ` Russell King - ARM Linux
2018-06-27 10:40             ` Daniel Stone
2018-05-17 14:57     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 20/24] drm/gma500: " Daniel Stone
2018-05-17 15:03     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 21/24] drm/msm: Move GEM BOs " Daniel Stone
2018-05-17 13:12     ` Daniel Stone
2018-05-17 15:05     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 22/24] drm/radeon: Move GEM BO " Daniel Stone
     [not found]     ` <20180330141138.28987-22-daniels-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2018-05-17 15:06       ` Thierry Reding
     [not found]   ` <20180330141138.28987-1-daniels-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2018-03-30 14:11     ` [PATCH 23/24] drm/radeon: radeon_framebuffer -> drm_framebuffer Daniel Stone
2018-05-17 15:07       ` Thierry Reding
2018-03-30 14:11   ` [PATCH 24/24] drm/amdgpu: Move GEM BO to drm_framebuffer Daniel Stone
2018-05-17 15:08     ` Thierry Reding
2018-05-17 13:54   ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Thierry Reding
2018-03-30 14:47 ` [PATCH 00/24] drm_framebuffer boilerplate removal Alex Deucher
2018-03-30 15:00   ` Daniel Stone
     [not found]     ` <CAPj87rOfg18u1xBioeu1D0MoD4My2rZy1Nw3yfA4DhdX2R7g7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-03-30 15:03       ` Alex Deucher

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=20180330141138.28987-3-daniels@collabora.com \
    --to=daniels@collabora.com \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=virtualization@lists.linux-foundation.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 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).