All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/24] drm_framebuffer boilerplate removal
@ 2018-03-30 14:11 Daniel Stone
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                   ` (2 more replies)
  0 siblings, 3 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel
  Cc: open list:VIRTIO CORE, NET...,
	Thierry Reding, Gerd Hoffmann, Russell King, Tomi Valkeinen,
	Kyungmin Park, David Lechner, linux-arm-msm, intel-gfx,
	Rodrigo Vivi, Dave Airlie, linux-tegra, amd-gfx mailing list,
	Seung-Woo Kim, Alex Deucher, Christian König

Hi,
I've been working on a getfb2[0] ioctl, which amongst other things
supports multi-planar framebuffers as well as modifiers. getfb
currently calls the framebuffer's handle_create hook, which doesn't
support multiple planes.

Thanks to Noralf's recent work, drivers can just store GEM objects
directly in drm_framebuffer. I use this directly in getfb2: we need
direct access to the GEM objects and not a vfunc in order to not hand
out duplicate GEM names for the same object.

This series converts all drivers except for nouveau, which was a
little too non-trivial for my comfort, to storing GEM objects directly
in drm_framebuffer. For those drivers whose driver_framebuffer struct
was nothing but drm_framebuffer + BO, it deletes the driver-specific
struct. It also makes use of Noralf's generic framebuffer helpers for
create_handle and destroy where possible.

I don't have the hardware for most of these drivers, so have had to
settle for just staring really hard at the diff.

I intend to remove create_handle when all drivers are converted over
to placing BOs directly inside drm_framebuffer. For most drivers
there's a relatively easy conversion to using the helpers for
basically all framebuffer handling and fbdev emulation as well, though
that's a bit further than I was willing to go without hardware to test
on ...

Cheers,
Daniel

[0]: https://lists.freedesktop.org/archives/dri-devel/2018-March/170512.html
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer
  2018-03-30 14:11 [PATCH 00/24] drm_framebuffer boilerplate removal Daniel Stone
@ 2018-03-30 14:11 ` Daniel Stone
  2018-03-30 14:11   ` [PATCH 02/24] drm/cirrus: cirrus_framebuffer -> drm_framebuffer Daniel Stone
                     ` (24 more replies)
  2018-03-30 14:47 ` [PATCH 00/24] drm_framebuffer boilerplate removal Alex Deucher
  2018-03-30 14:47 ` Alex Deucher
  2 siblings, 25 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: Dave Airlie, Gerd Hoffmann, virtualization

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/cirrus/cirrus_drv.h   |  1 -
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  8 ++++----
 drivers/gpu/drm/cirrus/cirrus_main.c  | 25 ++++---------------------
 drivers/gpu/drm/cirrus/cirrus_mode.c  |  4 ++--
 4 files changed, 10 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h b/drivers/gpu/drm/cirrus/cirrus_drv.h
index be2d7e488062..70b23629be0a 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -119,7 +119,6 @@ struct cirrus_connector {
 
 struct cirrus_framebuffer {
 	struct drm_framebuffer		base;
-	struct drm_gem_object *obj;
 };
 
 struct cirrus_mc {
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 32fbfba2c623..a74d32846958 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -29,7 +29,7 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev,
 	int x2, y2;
 	unsigned long flags;
 
-	obj = afbdev->gfb.obj;
+	obj = afbdev->gfb.base.obj[0];
 	bo = gem_to_cirrus_bo(obj);
 
 	/*
@@ -250,9 +250,9 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,
 
 	drm_fb_helper_unregister_fbi(&gfbdev->helper);
 
-	if (gfb->obj) {
-		drm_gem_object_put_unlocked(gfb->obj);
-		gfb->obj = NULL;
+	if (gfb->base.obj[0]) {
+		drm_gem_object_put_unlocked(gfb->base.obj[0]);
+		gfb->base.obj[0] = NULL;
 	}
 
 	vfree(gfbdev->sysram);
diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c b/drivers/gpu/drm/cirrus/cirrus_main.c
index 26df1e8cd490..f1ee4139ff19 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -10,30 +10,13 @@
  */
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 
 #include "cirrus_drv.h"
 
-static int cirrus_create_handle(struct drm_framebuffer *fb,
-				struct drm_file* file_priv,
-				unsigned int* handle)
-{
-	struct cirrus_framebuffer *cirrus_fb = to_cirrus_framebuffer(fb);
-
-	return drm_gem_handle_create(file_priv, cirrus_fb->obj, handle);
-}
-
-static void cirrus_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-	struct cirrus_framebuffer *cirrus_fb = to_cirrus_framebuffer(fb);
-
-	drm_gem_object_put_unlocked(cirrus_fb->obj);
-	drm_framebuffer_cleanup(fb);
-	kfree(fb);
-}
-
 static const struct drm_framebuffer_funcs cirrus_fb_funcs = {
-	.create_handle = cirrus_create_handle,
-	.destroy = cirrus_user_framebuffer_destroy,
+	.create_handle = drm_gem_fb_create_handle,
+	.destroy = drm_gem_fb_destroy,
 };
 
 int cirrus_framebuffer_init(struct drm_device *dev,
@@ -44,7 +27,7 @@ int cirrus_framebuffer_init(struct drm_device *dev,
 	int ret;
 
 	drm_helper_mode_fill_fb_struct(dev, &gfb->base, mode_cmd);
-	gfb->obj = obj;
+	gfb->base.obj[0] = obj;
 	ret = drm_framebuffer_init(dev, &gfb->base, &cirrus_fb_funcs);
 	if (ret) {
 		DRM_ERROR("drm_framebuffer_init failed: %d\n", ret);
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c
index c91b9b054e3f..91b9c42013ff 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -110,7 +110,7 @@ static int cirrus_crtc_do_set_base(struct drm_crtc *crtc,
 	/* push the previous fb to system ram */
 	if (!atomic && fb) {
 		cirrus_fb = to_cirrus_framebuffer(fb);
-		obj = cirrus_fb->obj;
+		obj = cirrus_fb->base.obj[0];
 		bo = gem_to_cirrus_bo(obj);
 		ret = cirrus_bo_reserve(bo, false);
 		if (ret)
@@ -120,7 +120,7 @@ static int cirrus_crtc_do_set_base(struct drm_crtc *crtc,
 	}
 
 	cirrus_fb = to_cirrus_framebuffer(crtc->primary->fb);
-	obj = cirrus_fb->obj;
+	obj = cirrus_fb->base.obj[0];
 	bo = gem_to_cirrus_bo(obj);
 
 	ret = cirrus_bo_reserve(bo, false);
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 02/24] drm/cirrus: cirrus_framebuffer -> drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-05-17 14:25     ` Thierry Reding
  2018-05-17 14:25     ` Thierry Reding
  2018-03-30 14:11   ` [PATCH 03/24] drm/virtio: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (23 subsequent siblings)
  24 siblings, 2 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: Dave Airlie, Gerd Hoffmann, virtualization

Now cirrus_framebuffer is just an empty wrapper around drm_framebuffer,
we can drop it.

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/cirrus/cirrus_drv.h   |  9 ++-------
 drivers/gpu/drm/cirrus/cirrus_fbdev.c | 20 ++++++++++----------
 drivers/gpu/drm/cirrus/cirrus_main.c  | 20 ++++++++++----------
 drivers/gpu/drm/cirrus/cirrus_mode.c  | 12 +++---------
 4 files changed, 25 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h b/drivers/gpu/drm/cirrus/cirrus_drv.h
index 70b23629be0a..ce9db7aab225 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -92,7 +92,6 @@
 
 #define to_cirrus_crtc(x) container_of(x, struct cirrus_crtc, base)
 #define to_cirrus_encoder(x) container_of(x, struct cirrus_encoder, base)
-#define to_cirrus_framebuffer(x) container_of(x, struct cirrus_framebuffer, base)
 
 struct cirrus_crtc {
 	struct drm_crtc			base;
@@ -117,10 +116,6 @@ struct cirrus_connector {
 	struct drm_connector		base;
 };
 
-struct cirrus_framebuffer {
-	struct drm_framebuffer		base;
-};
-
 struct cirrus_mc {
 	resource_size_t			vram_size;
 	resource_size_t			vram_base;
@@ -151,7 +146,7 @@ struct cirrus_device {
 
 struct cirrus_fbdev {
 	struct drm_fb_helper helper;
-	struct cirrus_framebuffer gfb;
+	struct drm_framebuffer gfb;
 	void *sysram;
 	int size;
 	int x1, y1, x2, y2; /* dirty rect */
@@ -197,7 +192,7 @@ int cirrus_dumb_create(struct drm_file *file,
 		       struct drm_mode_create_dumb *args);
 
 int cirrus_framebuffer_init(struct drm_device *dev,
-			   struct cirrus_framebuffer *gfb,
+			    struct drm_framebuffer *gfb,
 			    const struct drm_mode_fb_cmd2 *mode_cmd,
 			    struct drm_gem_object *obj);
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index a74d32846958..b643ac92801c 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -22,14 +22,14 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev,
 	struct drm_gem_object *obj;
 	struct cirrus_bo *bo;
 	int src_offset, dst_offset;
-	int bpp = afbdev->gfb.base.format->cpp[0];
+	int bpp = afbdev->gfb.format->cpp[0];
 	int ret = -EBUSY;
 	bool unmap = false;
 	bool store_for_later = false;
 	int x2, y2;
 	unsigned long flags;
 
-	obj = afbdev->gfb.base.obj[0];
+	obj = afbdev->gfb.obj[0];
 	bo = gem_to_cirrus_bo(obj);
 
 	/*
@@ -82,7 +82,7 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev,
 	}
 	for (i = y; i < y + height; i++) {
 		/* assume equal stride for now */
-		src_offset = dst_offset = i * afbdev->gfb.base.pitches[0] + (x * bpp);
+		src_offset = dst_offset = i * afbdev->gfb.pitches[0] + (x * bpp);
 		memcpy_toio(bo->kmap.virtual + src_offset, afbdev->sysram + src_offset, width * bpp);
 
 	}
@@ -204,7 +204,7 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
 	gfbdev->sysram = sysram;
 	gfbdev->size = size;
 
-	fb = &gfbdev->gfb.base;
+	fb = &gfbdev->gfb;
 	if (!fb) {
 		DRM_INFO("fb is NULL\n");
 		return -EINVAL;
@@ -246,19 +246,19 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
 static int cirrus_fbdev_destroy(struct drm_device *dev,
 				struct cirrus_fbdev *gfbdev)
 {
-	struct cirrus_framebuffer *gfb = &gfbdev->gfb;
+	struct drm_framebuffer *gfb = &gfbdev->gfb;
 
 	drm_fb_helper_unregister_fbi(&gfbdev->helper);
 
-	if (gfb->base.obj[0]) {
-		drm_gem_object_put_unlocked(gfb->base.obj[0]);
-		gfb->base.obj[0] = NULL;
+	if (gfb->obj[0]) {
+		drm_gem_object_put_unlocked(gfb->obj[0]);
+		gfb->obj[0] = NULL;
 	}
 
 	vfree(gfbdev->sysram);
 	drm_fb_helper_fini(&gfbdev->helper);
-	drm_framebuffer_unregister_private(&gfb->base);
-	drm_framebuffer_cleanup(&gfb->base);
+	drm_framebuffer_unregister_private(gfb);
+	drm_framebuffer_cleanup(gfb);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c b/drivers/gpu/drm/cirrus/cirrus_main.c
index f1ee4139ff19..60d54e10a34d 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -20,15 +20,15 @@ static const struct drm_framebuffer_funcs cirrus_fb_funcs = {
 };
 
 int cirrus_framebuffer_init(struct drm_device *dev,
-			    struct cirrus_framebuffer *gfb,
+			    struct drm_framebuffer *gfb,
 			    const struct drm_mode_fb_cmd2 *mode_cmd,
 			    struct drm_gem_object *obj)
 {
 	int ret;
 
-	drm_helper_mode_fill_fb_struct(dev, &gfb->base, mode_cmd);
-	gfb->base.obj[0] = obj;
-	ret = drm_framebuffer_init(dev, &gfb->base, &cirrus_fb_funcs);
+	drm_helper_mode_fill_fb_struct(dev, gfb, mode_cmd);
+	gfb->obj[0] = obj;
+	ret = drm_framebuffer_init(dev, gfb, &cirrus_fb_funcs);
 	if (ret) {
 		DRM_ERROR("drm_framebuffer_init failed: %d\n", ret);
 		return ret;
@@ -43,7 +43,7 @@ cirrus_user_framebuffer_create(struct drm_device *dev,
 {
 	struct cirrus_device *cdev = dev->dev_private;
 	struct drm_gem_object *obj;
-	struct cirrus_framebuffer *cirrus_fb;
+	struct drm_framebuffer *fb;
 	u32 bpp;
 	int ret;
 
@@ -57,19 +57,19 @@ cirrus_user_framebuffer_create(struct drm_device *dev,
 	if (obj == NULL)
 		return ERR_PTR(-ENOENT);
 
-	cirrus_fb = kzalloc(sizeof(*cirrus_fb), GFP_KERNEL);
-	if (!cirrus_fb) {
+	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+	if (!fb) {
 		drm_gem_object_put_unlocked(obj);
 		return ERR_PTR(-ENOMEM);
 	}
 
-	ret = cirrus_framebuffer_init(dev, cirrus_fb, mode_cmd, obj);
+	ret = cirrus_framebuffer_init(dev, fb, mode_cmd, obj);
 	if (ret) {
 		drm_gem_object_put_unlocked(obj);
-		kfree(cirrus_fb);
+		kfree(fb);
 		return ERR_PTR(ret);
 	}
-	return &cirrus_fb->base;
+	return fb;
 }
 
 static const struct drm_mode_config_funcs cirrus_mode_funcs = {
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 91b9c42013ff..b529f8c8e2a6 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -101,17 +101,13 @@ static int cirrus_crtc_do_set_base(struct drm_crtc *crtc,
 				int x, int y, int atomic)
 {
 	struct cirrus_device *cdev = crtc->dev->dev_private;
-	struct drm_gem_object *obj;
-	struct cirrus_framebuffer *cirrus_fb;
 	struct cirrus_bo *bo;
 	int ret;
 	u64 gpu_addr;
 
 	/* push the previous fb to system ram */
 	if (!atomic && fb) {
-		cirrus_fb = to_cirrus_framebuffer(fb);
-		obj = cirrus_fb->base.obj[0];
-		bo = gem_to_cirrus_bo(obj);
+		bo = gem_to_cirrus_bo(fb->obj[0]);
 		ret = cirrus_bo_reserve(bo, false);
 		if (ret)
 			return ret;
@@ -119,9 +115,7 @@ static int cirrus_crtc_do_set_base(struct drm_crtc *crtc,
 		cirrus_bo_unreserve(bo);
 	}
 
-	cirrus_fb = to_cirrus_framebuffer(crtc->primary->fb);
-	obj = cirrus_fb->base.obj[0];
-	bo = gem_to_cirrus_bo(obj);
+	bo = gem_to_cirrus_bo(crtc->primary->fb->obj[0]);
 
 	ret = cirrus_bo_reserve(bo, false);
 	if (ret)
@@ -133,7 +127,7 @@ static int cirrus_crtc_do_set_base(struct drm_crtc *crtc,
 		return ret;
 	}
 
-	if (&cdev->mode_info.gfbdev->gfb == cirrus_fb) {
+	if (&cdev->mode_info.gfbdev->gfb == crtc->primary->fb) {
 		/* if pushing console in kmap it */
 		ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
 		if (ret)
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 03/24] drm/virtio: Place GEM BOs in drm_framebuffer
  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-03-30 14:11   ` Daniel Stone
  2018-05-17 14:29     ` Thierry Reding
  2018-05-17 14:29     ` Thierry Reding
  2018-03-30 14:11   ` [PATCH 04/24] drm/rockchip: " Daniel Stone
                     ` (22 subsequent siblings)
  24 siblings, 2 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: Dave Airlie, Gerd Hoffmann, virtualization

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 04/24] drm/rockchip: Place GEM BOs in drm_framebuffer
  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-03-30 14:11   ` [PATCH 03/24] drm/virtio: Place GEM BOs in drm_framebuffer Daniel Stone
@ 2018-03-30 14:11   ` 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
                     ` (21 subsequent siblings)
  24 siblings, 2 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel

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: Sandy Huang <hjc@rock-chips.com>
Cc: Heiko Stübner <heiko@sntech.de>
---
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 36 +++++-------------------------
 1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
index e266539e04e5..d7083c07c294 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
@@ -18,6 +18,7 @@
 #include <drm/drm_atomic.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 
 #include "rockchip_drm_drv.h"
 #include "rockchip_drm_fb.h"
@@ -28,40 +29,15 @@
 
 struct rockchip_drm_fb {
 	struct drm_framebuffer fb;
-	struct drm_gem_object *obj[ROCKCHIP_MAX_FB_BUFFER];
 };
 
 struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,
 					       unsigned int plane)
 {
-	struct rockchip_drm_fb *rk_fb = to_rockchip_fb(fb);
-
 	if (plane >= ROCKCHIP_MAX_FB_BUFFER)
 		return NULL;
 
-	return rk_fb->obj[plane];
-}
-
-static void rockchip_drm_fb_destroy(struct drm_framebuffer *fb)
-{
-	struct rockchip_drm_fb *rockchip_fb = to_rockchip_fb(fb);
-	int i;
-
-	for (i = 0; i < ROCKCHIP_MAX_FB_BUFFER; i++)
-		drm_gem_object_put_unlocked(rockchip_fb->obj[i]);
-
-	drm_framebuffer_cleanup(fb);
-	kfree(rockchip_fb);
-}
-
-static int rockchip_drm_fb_create_handle(struct drm_framebuffer *fb,
-					 struct drm_file *file_priv,
-					 unsigned int *handle)
-{
-	struct rockchip_drm_fb *rockchip_fb = to_rockchip_fb(fb);
-
-	return drm_gem_handle_create(file_priv,
-				     rockchip_fb->obj[0], handle);
+	return fb->obj[plane];
 }
 
 static int rockchip_drm_fb_dirty(struct drm_framebuffer *fb,
@@ -75,9 +51,9 @@ static int rockchip_drm_fb_dirty(struct drm_framebuffer *fb,
 }
 
 static const struct drm_framebuffer_funcs rockchip_drm_fb_funcs = {
-	.destroy	= rockchip_drm_fb_destroy,
-	.create_handle	= rockchip_drm_fb_create_handle,
-	.dirty		= rockchip_drm_fb_dirty,
+	.destroy       = drm_gem_fb_destroy,
+	.create_handle = drm_gem_fb_create_handle,
+	.dirty	       = rockchip_drm_fb_dirty,
 };
 
 static struct rockchip_drm_fb *
@@ -95,7 +71,7 @@ rockchip_fb_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cm
 	drm_helper_mode_fill_fb_struct(dev, &rockchip_fb->fb, mode_cmd);
 
 	for (i = 0; i < num_planes; i++)
-		rockchip_fb->obj[i] = obj[i];
+		rockchip_fb->fb.obj[i] = obj[i];
 
 	ret = drm_framebuffer_init(dev, &rockchip_fb->fb,
 				   &rockchip_drm_fb_funcs);
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 05/24] drm/rockchip: rockchip_drm_fb -> drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (2 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 04/24] drm/rockchip: " Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-05-17 13:08     ` Daniel Stone
                       ` (2 more replies)
  2018-03-30 14:11   ` [PATCH 06/24] drm/omap: Move GEM BO to drm_framebuffer Daniel Stone
                     ` (20 subsequent siblings)
  24 siblings, 3 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel

Now that rockchip_drm_fb is just a wrapper around drm_framebuffer, we
can remove it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Heiko Stübner <heiko@sntech.de>
---
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c  | 54 ++++++++++-------------------
 drivers/gpu/drm/rockchip/rockchip_drm_fb.h  |  3 --
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  4 +--
 3 files changed, 21 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
index d7083c07c294..a4d0a00abcd9 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
@@ -25,21 +25,6 @@
 #include "rockchip_drm_gem.h"
 #include "rockchip_drm_psr.h"
 
-#define to_rockchip_fb(x) container_of(x, struct rockchip_drm_fb, fb)
-
-struct rockchip_drm_fb {
-	struct drm_framebuffer fb;
-};
-
-struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,
-					       unsigned int plane)
-{
-	if (plane >= ROCKCHIP_MAX_FB_BUFFER)
-		return NULL;
-
-	return fb->obj[plane];
-}
-
 static int rockchip_drm_fb_dirty(struct drm_framebuffer *fb,
 				 struct drm_file *file,
 				 unsigned int flags, unsigned int color,
@@ -56,41 +41,40 @@ static const struct drm_framebuffer_funcs rockchip_drm_fb_funcs = {
 	.dirty	       = rockchip_drm_fb_dirty,
 };
 
-static struct rockchip_drm_fb *
+static struct drm_framebuffer *
 rockchip_fb_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd,
 		  struct drm_gem_object **obj, unsigned int num_planes)
 {
-	struct rockchip_drm_fb *rockchip_fb;
+	struct drm_framebuffer *fb;
 	int ret;
 	int i;
 
-	rockchip_fb = kzalloc(sizeof(*rockchip_fb), GFP_KERNEL);
-	if (!rockchip_fb)
+	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+	if (!fb)
 		return ERR_PTR(-ENOMEM);
 
-	drm_helper_mode_fill_fb_struct(dev, &rockchip_fb->fb, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
 
 	for (i = 0; i < num_planes; i++)
-		rockchip_fb->fb.obj[i] = obj[i];
+		fb->obj[i] = obj[i];
 
-	ret = drm_framebuffer_init(dev, &rockchip_fb->fb,
-				   &rockchip_drm_fb_funcs);
+	ret = drm_framebuffer_init(dev, fb, &rockchip_drm_fb_funcs);
 	if (ret) {
 		DRM_DEV_ERROR(dev->dev,
 			      "Failed to initialize framebuffer: %d\n",
 			      ret);
-		kfree(rockchip_fb);
+		kfree(fb);
 		return ERR_PTR(ret);
 	}
 
-	return rockchip_fb;
+	return fb;
 }
 
 static struct drm_framebuffer *
 rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
 			const struct drm_mode_fb_cmd2 *mode_cmd)
 {
-	struct rockchip_drm_fb *rockchip_fb;
+	struct drm_framebuffer *fb;
 	struct drm_gem_object *objs[ROCKCHIP_MAX_FB_BUFFER];
 	struct drm_gem_object *obj;
 	unsigned int hsub;
@@ -129,13 +113,13 @@ rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
 		objs[i] = obj;
 	}
 
-	rockchip_fb = rockchip_fb_alloc(dev, mode_cmd, objs, i);
-	if (IS_ERR(rockchip_fb)) {
-		ret = PTR_ERR(rockchip_fb);
+	fb = rockchip_fb_alloc(dev, mode_cmd, objs, i);
+	if (IS_ERR(fb)) {
+		ret = PTR_ERR(fb);
 		goto err_gem_object_unreference;
 	}
 
-	return &rockchip_fb->fb;
+	return fb;
 
 err_gem_object_unreference:
 	for (i--; i >= 0; i--)
@@ -159,13 +143,13 @@ rockchip_drm_framebuffer_init(struct drm_device *dev,
 			      const struct drm_mode_fb_cmd2 *mode_cmd,
 			      struct drm_gem_object *obj)
 {
-	struct rockchip_drm_fb *rockchip_fb;
+	struct drm_framebuffer *fb;
 
-	rockchip_fb = rockchip_fb_alloc(dev, mode_cmd, &obj, 1);
-	if (IS_ERR(rockchip_fb))
-		return ERR_CAST(rockchip_fb);
+	fb = rockchip_fb_alloc(dev, mode_cmd, &obj, 1);
+	if (IS_ERR(fb))
+		return ERR_CAST(fb);
 
-	return &rockchip_fb->fb;
+	return fb;
 }
 
 void rockchip_drm_mode_config_init(struct drm_device *dev)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.h b/drivers/gpu/drm/rockchip/rockchip_drm_fb.h
index 2fe47f1ee98f..f1265cb1aee8 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.h
@@ -22,7 +22,4 @@ rockchip_drm_framebuffer_init(struct drm_device *dev,
 void rockchip_drm_framebuffer_fini(struct drm_framebuffer *fb);
 
 void rockchip_drm_mode_config_init(struct drm_device *dev);
-
-struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,
-					       unsigned int plane);
 #endif /* _ROCKCHIP_DRM_FB_H */
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 53d4afe15278..43d191d42087 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -724,7 +724,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 		return;
 	}
 
-	obj = rockchip_fb_get_gem_obj(fb, 0);
+	obj = fb->obj[0];
 	rk_obj = to_rockchip_obj(obj);
 
 	actual_w = drm_rect_width(src) >> 16;
@@ -754,7 +754,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 		int vsub = drm_format_vert_chroma_subsampling(fb->format->format);
 		int bpp = fb->format->cpp[1];
 
-		uv_obj = rockchip_fb_get_gem_obj(fb, 1);
+		uv_obj = fb->obj[1];
 		rk_uv_obj = to_rockchip_obj(uv_obj);
 
 		offset = (src->x1 >> 16) * bpp / hsub;
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 06/24] drm/omap: Move GEM BO to drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (3 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 05/24] drm/rockchip: rockchip_drm_fb -> drm_framebuffer Daniel Stone
@ 2018-03-30 14:11   ` 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
                     ` (19 subsequent siblings)
  24 siblings, 2 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

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: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/omap_fb.c | 60 ++++++++++-----------------------------
 1 file changed, 15 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 5fd22ca73913..3d6b6f3d6808 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -19,6 +19,7 @@
 
 #include <drm/drm_crtc.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 
 #include "omap_dmm_tiler.h"
 #include "omap_drv.h"
@@ -51,7 +52,6 @@ static const u32 formats[] = {
 
 /* per-plane info for the fb: */
 struct plane {
-	struct drm_gem_object *bo;
 	u32 pitch;
 	u32 offset;
 	dma_addr_t dma_addr;
@@ -68,36 +68,9 @@ struct omap_framebuffer {
 	struct mutex lock;
 };
 
-static int omap_framebuffer_create_handle(struct drm_framebuffer *fb,
-		struct drm_file *file_priv,
-		unsigned int *handle)
-{
-	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	return drm_gem_handle_create(file_priv,
-			omap_fb->planes[0].bo, handle);
-}
-
-static void omap_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int i, n = fb->format->num_planes;
-
-	DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
-
-	drm_framebuffer_cleanup(fb);
-
-	for (i = 0; i < n; i++) {
-		struct plane *plane = &omap_fb->planes[i];
-
-		drm_gem_object_unreference_unlocked(plane->bo);
-	}
-
-	kfree(omap_fb);
-}
-
 static const struct drm_framebuffer_funcs omap_framebuffer_funcs = {
-	.create_handle = omap_framebuffer_create_handle,
-	.destroy = omap_framebuffer_destroy,
+	.create_handle = drm_gem_fb_create_handle,
+	.destroy = drm_gem_fb_destroy,
 };
 
 static u32 get_linear_addr(struct plane *plane,
@@ -114,10 +87,7 @@ static u32 get_linear_addr(struct plane *plane,
 
 bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb)
 {
-	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	struct plane *plane = &omap_fb->planes[0];
-
-	return omap_gem_flags(plane->bo) & OMAP_BO_TILED;
+	return omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED;
 }
 
 /* Note: DRM rotates counter-clockwise, TILER & DSS rotates clockwise */
@@ -176,7 +146,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 	x = state->src_x >> 16;
 	y = state->src_y >> 16;
 
-	if (omap_gem_flags(plane->bo) & OMAP_BO_TILED) {
+	if (omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED) {
 		u32 w = state->src_w >> 16;
 		u32 h = state->src_h >> 16;
 
@@ -201,12 +171,12 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 			x += w - 1;
 
 		/* Note: x and y are in TILER units, not pixels */
-		omap_gem_rotated_dma_addr(plane->bo, orient, x, y,
+		omap_gem_rotated_dma_addr(fb->obj[0], orient, x, y,
 					  &info->paddr);
 		info->rotation_type = OMAP_DSS_ROT_TILER;
 		info->rotation = state->rotation ?: DRM_MODE_ROTATE_0;
 		/* Note: stride in TILER units, not pixels */
-		info->screen_width  = omap_gem_tiled_stride(plane->bo, orient);
+		info->screen_width  = omap_gem_tiled_stride(fb->obj[0], orient);
 	} else {
 		switch (state->rotation & DRM_MODE_ROTATE_MASK) {
 		case 0:
@@ -234,8 +204,8 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 		plane = &omap_fb->planes[1];
 
 		if (info->rotation_type == OMAP_DSS_ROT_TILER) {
-			WARN_ON(!(omap_gem_flags(plane->bo) & OMAP_BO_TILED));
-			omap_gem_rotated_dma_addr(plane->bo, orient, x/2, y/2,
+			WARN_ON(!(omap_gem_flags(fb->obj[1]) & OMAP_BO_TILED));
+			omap_gem_rotated_dma_addr(fb->obj[1], orient, x/2, y/2,
 						  &info->p_uv_addr);
 		} else {
 			info->p_uv_addr = get_linear_addr(plane, format, 1, x, y);
@@ -261,10 +231,10 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 
 	for (i = 0; i < n; i++) {
 		struct plane *plane = &omap_fb->planes[i];
-		ret = omap_gem_pin(plane->bo, &plane->dma_addr);
+		ret = omap_gem_pin(fb->obj[i], &plane->dma_addr);
 		if (ret)
 			goto fail;
-		omap_gem_dma_sync_buffer(plane->bo, DMA_TO_DEVICE);
+		omap_gem_dma_sync_buffer(fb->obj[i], DMA_TO_DEVICE);
 	}
 
 	omap_fb->pin_count++;
@@ -276,7 +246,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 fail:
 	for (i--; i >= 0; i--) {
 		struct plane *plane = &omap_fb->planes[i];
-		omap_gem_unpin(plane->bo);
+		omap_gem_unpin(fb->obj[i]);
 		plane->dma_addr = 0;
 	}
 
@@ -302,7 +272,7 @@ void omap_framebuffer_unpin(struct drm_framebuffer *fb)
 
 	for (i = 0; i < n; i++) {
 		struct plane *plane = &omap_fb->planes[i];
-		omap_gem_unpin(plane->bo);
+		omap_gem_unpin(fb->obj[i]);
 		plane->dma_addr = 0;
 	}
 
@@ -349,7 +319,7 @@ void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 		struct plane *plane = &omap_fb->planes[i];
 		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
 				i, plane->offset, plane->pitch);
-		omap_gem_describe(plane->bo, m);
+		omap_gem_describe(fb->obj[i], m);
 	}
 }
 #endif
@@ -454,7 +424,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
 			goto fail;
 		}
 
-		plane->bo     = bos[i];
+		fb->obj[i]    = bos[i];
 		plane->offset = mode_cmd->offsets[i];
 		plane->pitch  = pitch;
 		plane->dma_addr  = 0;
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 07/24] drm/omap: Move buffer pitch/offset to drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (4 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 06/24] drm/omap: Move GEM BO to drm_framebuffer Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-03-30 20:53     ` Sebastian Reichel
  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
                     ` (18 subsequent siblings)
  24 siblings, 2 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

drm_framebuffer already holds per-plane pitch and offsets, which is
filled out for us when we create the framebuffer. Nuke our local copy in
the plane struct.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/omap_fb.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 3d6b6f3d6808..9d75eab0d164 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -52,8 +52,6 @@ static const u32 formats[] = {
 
 /* per-plane info for the fb: */
 struct plane {
-	u32 pitch;
-	u32 offset;
 	dma_addr_t dma_addr;
 };
 
@@ -73,14 +71,16 @@ static const struct drm_framebuffer_funcs omap_framebuffer_funcs = {
 	.destroy = drm_gem_fb_destroy,
 };
 
-static u32 get_linear_addr(struct plane *plane,
+static u32 get_linear_addr(struct drm_framebuffer *fb,
 		const struct drm_format_info *format, int n, int x, int y)
 {
+	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
+	struct plane *plane = &omap_fb->planes[n];
 	u32 offset;
 
-	offset = plane->offset
+	offset = fb->offsets[n]
 	       + (x * format->cpp[n] / (n == 0 ? 1 : format->hsub))
-	       + (y * plane->pitch / (n == 0 ? 1 : format->vsub));
+	       + (y * fb->pitches[n] / (n == 0 ? 1 : format->vsub));
 
 	return plane->dma_addr + offset;
 }
@@ -191,10 +191,10 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 			break;
 		}
 
-		info->paddr         = get_linear_addr(plane, format, 0, x, y);
+		info->paddr         = get_linear_addr(fb, format, 0, x, y);
 		info->rotation_type = OMAP_DSS_ROT_NONE;
 		info->rotation      = DRM_MODE_ROTATE_0;
-		info->screen_width  = plane->pitch;
+		info->screen_width  = fb->pitches[0];
 	}
 
 	/* convert to pixels: */
@@ -208,7 +208,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 			omap_gem_rotated_dma_addr(fb->obj[1], orient, x/2, y/2,
 						  &info->p_uv_addr);
 		} else {
-			info->p_uv_addr = get_linear_addr(plane, format, 1, x, y);
+			info->p_uv_addr = get_linear_addr(fb, format, 1, x, y);
 		}
 	} else {
 		info->p_uv_addr = 0;
@@ -309,16 +309,14 @@ struct drm_connector *omap_framebuffer_get_next_connector(
 #ifdef CONFIG_DEBUG_FS
 void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 {
-	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
 	int i, n = fb->format->num_planes;
 
 	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
 			(char *)&fb->format->format);
 
 	for (i = 0; i < n; i++) {
-		struct plane *plane = &omap_fb->planes[i];
 		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
-				i, plane->offset, plane->pitch);
+				i, fb->offsets[n], fb->pitches[i]);
 		omap_gem_describe(fb->obj[i], m);
 	}
 }
@@ -425,8 +423,6 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
 		}
 
 		fb->obj[i]    = bos[i];
-		plane->offset = mode_cmd->offsets[i];
-		plane->pitch  = pitch;
 		plane->dma_addr  = 0;
 	}
 
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 08/24] drm/mtk: Promote impossible internal error to WARN_ON
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (5 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 07/24] drm/omap: Move buffer pitch/offset " Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-05-17 13:58     ` Sean Paul
  2018-03-30 14:11   ` [PATCH 09/24] drm/mtk: Move GEM BO to drm_framebuffer Daniel Stone
                     ` (17 subsequent siblings)
  24 siblings, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel

A FB with no object is something we should be shouting very loudly
about, not quietly logging as debug.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: CK Hu <ck.hu@mediatek.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/gpu/drm/mediatek/mtk_drm_plane.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index 2f4b0ffee598..ac010365d88b 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -95,10 +95,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
 	if (!fb)
 		return 0;
 
-	if (!mtk_fb_get_gem_obj(fb)) {
-		DRM_DEBUG_KMS("buffer is null\n");
-		return -EFAULT;
-	}
+	WARN_ON(!mtk_fb_get_gem_obj(fb));
 
 	if (!state->crtc)
 		return 0;
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 09/24] drm/mtk: Move GEM BO to drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (6 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 08/24] drm/mtk: Promote impossible internal error to WARN_ON Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-05-17 13:59     ` Sean Paul
                       ` (2 more replies)
  2018-03-30 14:11   ` [PATCH 10/24] drm/mtk: mtk_drm_fb -> drm_framebuffer Daniel Stone
                     ` (16 subsequent siblings)
  24 siblings, 3 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel

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: CK Hu <ck.hu@mediatek.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/gpu/drm/mediatek/mtk_drm_fb.c    | 38 +++++---------------------------
 drivers/gpu/drm/mediatek/mtk_drm_fb.h    |  1 -
 drivers/gpu/drm/mediatek/mtk_drm_plane.c |  4 ++--
 3 files changed, 7 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
index 0d8d506695f9..f130e37123b5 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
@@ -15,6 +15,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_gem.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 #include <linux/dma-buf.h>
 #include <linux/reservation.h>
 
@@ -30,42 +31,13 @@
  */
 struct mtk_drm_fb {
 	struct drm_framebuffer	base;
-	/* For now we only support a single plane */
-	struct drm_gem_object	*gem_obj;
 };
 
 #define to_mtk_fb(x) container_of(x, struct mtk_drm_fb, base)
 
-struct drm_gem_object *mtk_fb_get_gem_obj(struct drm_framebuffer *fb)
-{
-	struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb);
-
-	return mtk_fb->gem_obj;
-}
-
-static int mtk_drm_fb_create_handle(struct drm_framebuffer *fb,
-				    struct drm_file *file_priv,
-				    unsigned int *handle)
-{
-	struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb);
-
-	return drm_gem_handle_create(file_priv, mtk_fb->gem_obj, handle);
-}
-
-static void mtk_drm_fb_destroy(struct drm_framebuffer *fb)
-{
-	struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb);
-
-	drm_framebuffer_cleanup(fb);
-
-	drm_gem_object_put_unlocked(mtk_fb->gem_obj);
-
-	kfree(mtk_fb);
-}
-
 static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = {
-	.create_handle = mtk_drm_fb_create_handle,
-	.destroy = mtk_drm_fb_destroy,
+	.create_handle = drm_gem_fb_create_handle,
+	.destroy = drm_gem_fb_destroy,
 };
 
 static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev,
@@ -84,7 +56,7 @@ static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev,
 
 	drm_helper_mode_fill_fb_struct(dev, &mtk_fb->base, mode);
 
-	mtk_fb->gem_obj = obj;
+	mtk_fb->base.obj[0] = obj;
 
 	ret = drm_framebuffer_init(dev, &mtk_fb->base, &mtk_drm_fb_funcs);
 	if (ret) {
@@ -110,7 +82,7 @@ int mtk_fb_wait(struct drm_framebuffer *fb)
 	if (!fb)
 		return 0;
 
-	gem = mtk_fb_get_gem_obj(fb);
+	gem = fb->obj[0];
 	if (!gem || !gem->dma_buf || !gem->dma_buf->resv)
 		return 0;
 
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.h b/drivers/gpu/drm/mediatek/mtk_drm_fb.h
index 9b2ae345a4e9..7f976b196a15 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_fb.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.h
@@ -14,7 +14,6 @@
 #ifndef MTK_DRM_FB_H
 #define MTK_DRM_FB_H
 
-struct drm_gem_object *mtk_fb_get_gem_obj(struct drm_framebuffer *fb);
 int mtk_fb_wait(struct drm_framebuffer *fb);
 struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
 					       struct drm_file *file,
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index ac010365d88b..5370f926e63d 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -95,7 +95,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
 	if (!fb)
 		return 0;
 
-	WARN_ON(!mtk_fb_get_gem_obj(fb));
+	WARN_ON(!fb->obj[0]);
 
 	if (!state->crtc)
 		return 0;
@@ -124,7 +124,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
 	if (!crtc || WARN_ON(!fb))
 		return;
 
-	gem = mtk_fb_get_gem_obj(fb);
+	gem = fb->obj[0];
 	mtk_gem = to_mtk_gem_obj(gem);
 	addr = mtk_gem->dma_addr;
 	pitch = fb->pitches[0];
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 10/24] drm/mtk: mtk_drm_fb -> drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (7 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 09/24] drm/mtk: Move GEM BO to drm_framebuffer Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-05-17 13:13     ` Daniel Stone
                       ` (3 more replies)
  2018-03-30 14:11   ` [PATCH 11/24] drm/tegra: Remove duplicate framebuffer num_planes Daniel Stone
                     ` (15 subsequent siblings)
  24 siblings, 4 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel

Now that mtk_drm_fb is an empty wrapper around drm_framebuffer, we can
just delete it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: CK Hu <ck.hu@mediatek.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/gpu/drm/mediatek/mtk_drm_fb.c | 40 ++++++++++++-----------------------
 1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
index f130e37123b5..be5f6f1daf55 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
@@ -23,49 +23,37 @@
 #include "mtk_drm_fb.h"
 #include "mtk_drm_gem.h"
 
-/*
- * mtk specific framebuffer structure.
- *
- * @fb: drm framebuffer object.
- * @gem_obj: array of gem objects.
- */
-struct mtk_drm_fb {
-	struct drm_framebuffer	base;
-};
-
-#define to_mtk_fb(x) container_of(x, struct mtk_drm_fb, base)
-
 static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = {
 	.create_handle = drm_gem_fb_create_handle,
 	.destroy = drm_gem_fb_destroy,
 };
 
-static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev,
+static struct drm_framebuffer *mtk_drm_framebuffer_init(struct drm_device *dev,
 					const struct drm_mode_fb_cmd2 *mode,
 					struct drm_gem_object *obj)
 {
-	struct mtk_drm_fb *mtk_fb;
+	struct drm_framebuffer *fb;
 	int ret;
 
 	if (drm_format_num_planes(mode->pixel_format) != 1)
 		return ERR_PTR(-EINVAL);
 
-	mtk_fb = kzalloc(sizeof(*mtk_fb), GFP_KERNEL);
-	if (!mtk_fb)
+	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+	if (!fb)
 		return ERR_PTR(-ENOMEM);
 
-	drm_helper_mode_fill_fb_struct(dev, &mtk_fb->base, mode);
+	drm_helper_mode_fill_fb_struct(dev, fb, mode);
 
-	mtk_fb->base.obj[0] = obj;
+	fb->obj[0] = obj;
 
-	ret = drm_framebuffer_init(dev, &mtk_fb->base, &mtk_drm_fb_funcs);
+	ret = drm_framebuffer_init(dev, fb, &mtk_drm_fb_funcs);
 	if (ret) {
 		DRM_ERROR("failed to initialize framebuffer\n");
-		kfree(mtk_fb);
+		kfree(fb);
 		return ERR_PTR(ret);
 	}
 
-	return mtk_fb;
+	return fb;
 }
 
 /*
@@ -100,7 +88,7 @@ struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
 					       struct drm_file *file,
 					       const struct drm_mode_fb_cmd2 *cmd)
 {
-	struct mtk_drm_fb *mtk_fb;
+	struct drm_framebuffer *fb;
 	struct drm_gem_object *gem;
 	unsigned int width = cmd->width;
 	unsigned int height = cmd->height;
@@ -123,13 +111,13 @@ struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
 		goto unreference;
 	}
 
-	mtk_fb = mtk_drm_framebuffer_init(dev, cmd, gem);
-	if (IS_ERR(mtk_fb)) {
-		ret = PTR_ERR(mtk_fb);
+	fb = mtk_drm_framebuffer_init(dev, cmd, gem);
+	if (IS_ERR(fb)) {
+		ret = PTR_ERR(fb);
 		goto unreference;
 	}
 
-	return &mtk_fb->base;
+	return fb;
 
 unreference:
 	drm_gem_object_put_unlocked(gem);
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 11/24] drm/tegra: Remove duplicate framebuffer num_planes
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (8 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 10/24] drm/mtk: mtk_drm_fb -> drm_framebuffer Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-03-30 14:11   ` [PATCH 12/24] drm/tegra: Move GEM BOs to drm_framebuffer Daniel Stone
                     ` (14 subsequent siblings)
  24 siblings, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-tegra, Thierry Reding

drm_framebuffer already stores num_planes for us.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org
---
 drivers/gpu/drm/tegra/drm.h | 1 -
 drivers/gpu/drm/tegra/fb.c  | 6 ++----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index 4f41aaec8530..79340fb1de43 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -32,7 +32,6 @@ struct reset_control;
 struct tegra_fb {
 	struct drm_framebuffer base;
 	struct tegra_bo **planes;
-	unsigned int num_planes;
 };
 
 #ifdef CONFIG_DRM_FBDEV_EMULATION
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index e69434909a42..75badf371721 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -107,7 +107,7 @@ static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)
 	struct tegra_fb *fb = to_tegra_fb(framebuffer);
 	unsigned int i;
 
-	for (i = 0; i < fb->num_planes; i++) {
+	for (i = 0; i < framebuffer->format->num_planes; i++) {
 		struct tegra_bo *bo = fb->planes[i];
 
 		if (bo) {
@@ -155,11 +155,9 @@ static struct tegra_fb *tegra_fb_alloc(struct drm_device *drm,
 		return ERR_PTR(-ENOMEM);
 	}
 
-	fb->num_planes = num_planes;
-
 	drm_helper_mode_fill_fb_struct(drm, &fb->base, mode_cmd);
 
-	for (i = 0; i < fb->num_planes; i++)
+	for (i = 0; i < fb->base.format->num_planes; i++)
 		fb->planes[i] = planes[i];
 
 	err = drm_framebuffer_init(drm, &fb->base, &tegra_fb_funcs);
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 12/24] drm/tegra: Move GEM BOs to drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (9 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 11/24] drm/tegra: Remove duplicate framebuffer num_planes Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-03-30 14:11   ` [PATCH 13/24] drm/tegra: tegra_fb -> drm_framebuffer Daniel Stone
                     ` (13 subsequent siblings)
  24 siblings, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-tegra, Thierry Reding

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 function the same as the GEM framebuffer helper, we
can reuse that.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org
---
 drivers/gpu/drm/tegra/drm.h |  1 -
 drivers/gpu/drm/tegra/fb.c  | 37 ++++++++-----------------------------
 2 files changed, 8 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index 79340fb1de43..025e011d74af 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -31,7 +31,6 @@ struct reset_control;
 
 struct tegra_fb {
 	struct drm_framebuffer base;
-	struct tegra_bo **planes;
 };
 
 #ifdef CONFIG_DRM_FBDEV_EMULATION
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 75badf371721..5bc8f968284c 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -14,6 +14,7 @@
 
 #include "drm.h"
 #include "gem.h"
+#include <drm/drm_gem_framebuffer_helper.h>
 
 static inline struct tegra_fb *to_tegra_fb(struct drm_framebuffer *fb)
 {
@@ -30,19 +31,14 @@ static inline struct tegra_fbdev *to_tegra_fbdev(struct drm_fb_helper *helper)
 struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
 				    unsigned int index)
 {
-	struct tegra_fb *fb = to_tegra_fb(framebuffer);
-
-	if (index >= framebuffer->format->num_planes)
-		return NULL;
-
-	return fb->planes[index];
+	return to_tegra_bo(drm_gem_fb_get_obj(framebuffer, index));
 }
 
 bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer)
 {
-	struct tegra_fb *fb = to_tegra_fb(framebuffer);
+	struct tegra_bo *bo = tegra_fb_get_plane(framebuffer, 0);
 
-	if (fb->planes[0]->flags & TEGRA_BO_BOTTOM_UP)
+	if (bo->flags & TEGRA_BO_BOTTOM_UP)
 		return true;
 
 	return false;
@@ -51,8 +47,7 @@ bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer)
 int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
 			struct tegra_bo_tiling *tiling)
 {
-	struct tegra_fb *fb = to_tegra_fb(framebuffer);
-	uint64_t modifier = fb->base.modifier;
+	uint64_t modifier = framebuffer->modifier;
 
 	switch (modifier) {
 	case DRM_FORMAT_MOD_LINEAR:
@@ -108,7 +103,7 @@ static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)
 	unsigned int i;
 
 	for (i = 0; i < framebuffer->format->num_planes; i++) {
-		struct tegra_bo *bo = fb->planes[i];
+		struct tegra_bo *bo = tegra_fb_get_plane(framebuffer, i);
 
 		if (bo) {
 			if (bo->pages)
@@ -119,21 +114,12 @@ static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)
 	}
 
 	drm_framebuffer_cleanup(framebuffer);
-	kfree(fb->planes);
 	kfree(fb);
 }
 
-static int tegra_fb_create_handle(struct drm_framebuffer *framebuffer,
-				  struct drm_file *file, unsigned int *handle)
-{
-	struct tegra_fb *fb = to_tegra_fb(framebuffer);
-
-	return drm_gem_handle_create(file, &fb->planes[0]->gem, handle);
-}
-
 static const struct drm_framebuffer_funcs tegra_fb_funcs = {
 	.destroy = tegra_fb_destroy,
-	.create_handle = tegra_fb_create_handle,
+	.create_handle = drm_gem_fb_create_handle,
 };
 
 static struct tegra_fb *tegra_fb_alloc(struct drm_device *drm,
@@ -149,22 +135,15 @@ static struct tegra_fb *tegra_fb_alloc(struct drm_device *drm,
 	if (!fb)
 		return ERR_PTR(-ENOMEM);
 
-	fb->planes = kzalloc(num_planes * sizeof(*planes), GFP_KERNEL);
-	if (!fb->planes) {
-		kfree(fb);
-		return ERR_PTR(-ENOMEM);
-	}
-
 	drm_helper_mode_fill_fb_struct(drm, &fb->base, mode_cmd);
 
 	for (i = 0; i < fb->base.format->num_planes; i++)
-		fb->planes[i] = planes[i];
+		fb->base.obj[i] = &planes[i]->gem;
 
 	err = drm_framebuffer_init(drm, &fb->base, &tegra_fb_funcs);
 	if (err < 0) {
 		dev_err(drm->dev, "failed to initialize framebuffer: %d\n",
 			err);
-		kfree(fb->planes);
 		kfree(fb);
 		return ERR_PTR(err);
 	}
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 13/24] drm/tegra: tegra_fb -> drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (10 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 12/24] drm/tegra: Move GEM BOs to drm_framebuffer Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-05-17 13:11     ` Daniel Stone
  2018-03-30 14:11   ` [PATCH 14/24] drm/tegra: Move fbdev unmap special case Daniel Stone
                     ` (12 subsequent siblings)
  24 siblings, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-tegra, Thierry Reding

Since tegra_fb is now the same as drm_framebuffer, we can just replace
the type completely.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org
---
 drivers/gpu/drm/tegra/drm.h |  6 +-----
 drivers/gpu/drm/tegra/fb.c  | 34 ++++++++++++++--------------------
 2 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index 025e011d74af..f1fc2cfc8f02 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -29,14 +29,10 @@
 
 struct reset_control;
 
-struct tegra_fb {
-	struct drm_framebuffer base;
-};
-
 #ifdef CONFIG_DRM_FBDEV_EMULATION
 struct tegra_fbdev {
 	struct drm_fb_helper base;
-	struct tegra_fb *fb;
+	struct drm_framebuffer *fb;
 };
 #endif
 
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 5bc8f968284c..57da9683a713 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -16,11 +16,6 @@
 #include "gem.h"
 #include <drm/drm_gem_framebuffer_helper.h>
 
-static inline struct tegra_fb *to_tegra_fb(struct drm_framebuffer *fb)
-{
-	return container_of(fb, struct tegra_fb, base);
-}
-
 #ifdef CONFIG_DRM_FBDEV_EMULATION
 static inline struct tegra_fbdev *to_tegra_fbdev(struct drm_fb_helper *helper)
 {
@@ -99,7 +94,6 @@ int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
 
 static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)
 {
-	struct tegra_fb *fb = to_tegra_fb(framebuffer);
 	unsigned int i;
 
 	for (i = 0; i < framebuffer->format->num_planes; i++) {
@@ -114,7 +108,7 @@ static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)
 	}
 
 	drm_framebuffer_cleanup(framebuffer);
-	kfree(fb);
+	kfree(framebuffer);
 }
 
 static const struct drm_framebuffer_funcs tegra_fb_funcs = {
@@ -122,12 +116,12 @@ static const struct drm_framebuffer_funcs tegra_fb_funcs = {
 	.create_handle = drm_gem_fb_create_handle,
 };
 
-static struct tegra_fb *tegra_fb_alloc(struct drm_device *drm,
-				       const struct drm_mode_fb_cmd2 *mode_cmd,
-				       struct tegra_bo **planes,
-				       unsigned int num_planes)
+static struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm,
+					      const struct drm_mode_fb_cmd2 *mode_cmd,
+					      struct tegra_bo **planes,
+					      unsigned int num_planes)
 {
-	struct tegra_fb *fb;
+	struct drm_framebuffer *fb;
 	unsigned int i;
 	int err;
 
@@ -135,12 +129,12 @@ static struct tegra_fb *tegra_fb_alloc(struct drm_device *drm,
 	if (!fb)
 		return ERR_PTR(-ENOMEM);
 
-	drm_helper_mode_fill_fb_struct(drm, &fb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(drm, fb, mode_cmd);
 
-	for (i = 0; i < fb->base.format->num_planes; i++)
-		fb->base.obj[i] = &planes[i]->gem;
+	for (i = 0; i < fb->format->num_planes; i++)
+		fb->obj[i] = &planes[i]->gem;
 
-	err = drm_framebuffer_init(drm, &fb->base, &tegra_fb_funcs);
+	err = drm_framebuffer_init(drm, fb, &tegra_fb_funcs);
 	if (err < 0) {
 		dev_err(drm->dev, "failed to initialize framebuffer: %d\n",
 			err);
@@ -158,7 +152,7 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
 	unsigned int hsub, vsub, i;
 	struct tegra_bo *planes[4];
 	struct drm_gem_object *gem;
-	struct tegra_fb *fb;
+	struct drm_framebuffer *fb;
 	int err;
 
 	hsub = drm_format_horz_chroma_subsampling(cmd->pixel_format);
@@ -194,7 +188,7 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
 		goto unreference;
 	}
 
-	return &fb->base;
+	return fb;
 
 unreference:
 	while (i--)
@@ -275,7 +269,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
 		return PTR_ERR(fbdev->fb);
 	}
 
-	fb = &fbdev->fb->base;
+	fb = fbdev->fb;
 	helper->fb = fb;
 	helper->fbdev = info;
 
@@ -376,7 +370,7 @@ static void tegra_fbdev_exit(struct tegra_fbdev *fbdev)
 	drm_fb_helper_unregister_fbi(&fbdev->base);
 
 	if (fbdev->fb)
-		drm_framebuffer_remove(&fbdev->fb->base);
+		drm_framebuffer_remove(fbdev->fb);
 
 	drm_fb_helper_fini(&fbdev->base);
 	tegra_fbdev_free(fbdev);
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 14/24] drm/tegra: Move fbdev unmap special case
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (11 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 13/24] drm/tegra: tegra_fb -> drm_framebuffer Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-03-30 14:11   ` [PATCH 15/24] drm/tegra: Use drm_gem_fb_destroy Daniel Stone
                     ` (11 subsequent siblings)
  24 siblings, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-tegra, Thierry Reding

User framebuffers are created with either bo->pages or bo->vaddr set,
depending on whether or not an IOMMU is present. On the other hand, the
framebuffer created for fbdev emulation has a vaddr mapping made if
bo->pages is set after creation. This is set up in fbdev probe.

Remove the special case unmapping from the general-purpose framebuffer
destroy, and move it to fbdev teardown.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org
---
 drivers/gpu/drm/tegra/fb.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 57da9683a713..709aa6ef171a 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -99,12 +99,8 @@ static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)
 	for (i = 0; i < framebuffer->format->num_planes; i++) {
 		struct tegra_bo *bo = tegra_fb_get_plane(framebuffer, i);
 
-		if (bo) {
-			if (bo->pages)
-				vunmap(bo->vaddr);
-
+		if (bo)
 			drm_gem_object_put_unlocked(&bo->gem);
-		}
 	}
 
 	drm_framebuffer_cleanup(framebuffer);
@@ -369,8 +365,17 @@ static void tegra_fbdev_exit(struct tegra_fbdev *fbdev)
 {
 	drm_fb_helper_unregister_fbi(&fbdev->base);
 
-	if (fbdev->fb)
+	if (fbdev->fb) {
+		struct tegra_bo *bo = tegra_fb_get_plane(fbdev->fb, 0);
+
+		/* Undo the special mapping we made in fbdev probe. */
+		if (bo && bo->pages) {
+			vunmap(bo->vaddr);
+			bo->vaddr = 0;
+		}
+
 		drm_framebuffer_remove(fbdev->fb);
+	}
 
 	drm_fb_helper_fini(&fbdev->base);
 	tegra_fbdev_free(fbdev);
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 15/24] drm/tegra: Use drm_gem_fb_destroy
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (12 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 14/24] drm/tegra: Move fbdev unmap special case Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-03-30 14:11   ` [PATCH 16/24] drm/exynos: Move GEM BOs to drm_framebuffer Daniel Stone
                     ` (10 subsequent siblings)
  24 siblings, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-tegra, Thierry Reding

Now that our destroy function is the same as the helper, use that
directly.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org
---
 drivers/gpu/drm/tegra/fb.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 709aa6ef171a..4c22cdded3c2 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -92,23 +92,8 @@ int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
 	return 0;
 }
 
-static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)
-{
-	unsigned int i;
-
-	for (i = 0; i < framebuffer->format->num_planes; i++) {
-		struct tegra_bo *bo = tegra_fb_get_plane(framebuffer, i);
-
-		if (bo)
-			drm_gem_object_put_unlocked(&bo->gem);
-	}
-
-	drm_framebuffer_cleanup(framebuffer);
-	kfree(framebuffer);
-}
-
 static const struct drm_framebuffer_funcs tegra_fb_funcs = {
-	.destroy = tegra_fb_destroy,
+	.destroy = drm_gem_fb_destroy,
 	.create_handle = drm_gem_fb_create_handle,
 };
 
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 16/24] drm/exynos: Move GEM BOs to drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (13 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 15/24] drm/tegra: Use drm_gem_fb_destroy Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-04-13  8:55     ` Inki Dae
  2018-03-30 14:11   ` [PATCH 17/24] drm/exynos: Move dma_addr out of exynos_drm_fb Daniel Stone
                     ` (9 subsequent siblings)
  24 siblings, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: Kyungmin Park, Seung-Woo Kim

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: Inki Dae <inki.dae@samsung.com>
Cc: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_fb.c | 39 ++++------------------------------
 1 file changed, 4 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index 2379d732da67..d874c2d50ab6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -18,6 +18,7 @@
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 #include <uapi/drm/exynos_drm.h>
 
 #include "exynos_drm_drv.h"
@@ -36,7 +37,6 @@
  */
 struct exynos_drm_fb {
 	struct drm_framebuffer	fb;
-	struct exynos_drm_gem	*exynos_gem[MAX_FB_BUFFER];
 	dma_addr_t			dma_addr[MAX_FB_BUFFER];
 };
 
@@ -66,40 +66,9 @@ static int check_fb_gem_memory_type(struct drm_device *drm_dev,
 	return 0;
 }
 
-static void exynos_drm_fb_destroy(struct drm_framebuffer *fb)
-{
-	struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb);
-	unsigned int i;
-
-	drm_framebuffer_cleanup(fb);
-
-	for (i = 0; i < ARRAY_SIZE(exynos_fb->exynos_gem); i++) {
-		struct drm_gem_object *obj;
-
-		if (exynos_fb->exynos_gem[i] == NULL)
-			continue;
-
-		obj = &exynos_fb->exynos_gem[i]->base;
-		drm_gem_object_unreference_unlocked(obj);
-	}
-
-	kfree(exynos_fb);
-	exynos_fb = NULL;
-}
-
-static int exynos_drm_fb_create_handle(struct drm_framebuffer *fb,
-					struct drm_file *file_priv,
-					unsigned int *handle)
-{
-	struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb);
-
-	return drm_gem_handle_create(file_priv,
-				     &exynos_fb->exynos_gem[0]->base, handle);
-}
-
 static const struct drm_framebuffer_funcs exynos_drm_fb_funcs = {
-	.destroy	= exynos_drm_fb_destroy,
-	.create_handle	= exynos_drm_fb_create_handle,
+	.destroy	= drm_gem_fb_destroy,
+	.create_handle	= drm_gem_fb_create_handle,
 };
 
 struct drm_framebuffer *
@@ -121,7 +90,7 @@ exynos_drm_framebuffer_init(struct drm_device *dev,
 		if (ret < 0)
 			goto err;
 
-		exynos_fb->exynos_gem[i] = exynos_gem[i];
+		exynos_fb->fb.obj[i] = &exynos_gem[i]->base;
 		exynos_fb->dma_addr[i] = exynos_gem[i]->dma_addr
 						+ mode_cmd->offsets[i];
 	}
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 17/24] drm/exynos: Move dma_addr out of exynos_drm_fb
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (14 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 16/24] drm/exynos: Move GEM BOs to drm_framebuffer Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-03-30 14:11   ` [PATCH 18/24] drm/exynos: exynos_drm_fb -> drm_framebuffer Daniel Stone
                     ` (8 subsequent siblings)
  24 siblings, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: Kyungmin Park, Seung-Woo Kim

This can be calculated from the GEM BO DMA address as well as the offset
stored in the base framebuffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_fb.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index d874c2d50ab6..8be6263929b7 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -37,7 +37,6 @@
  */
 struct exynos_drm_fb {
 	struct drm_framebuffer	fb;
-	dma_addr_t			dma_addr[MAX_FB_BUFFER];
 };
 
 static int check_fb_gem_memory_type(struct drm_device *drm_dev,
@@ -91,8 +90,6 @@ exynos_drm_framebuffer_init(struct drm_device *dev,
 			goto err;
 
 		exynos_fb->fb.obj[i] = &exynos_gem[i]->base;
-		exynos_fb->dma_addr[i] = exynos_gem[i]->dma_addr
-						+ mode_cmd->offsets[i];
 	}
 
 	drm_helper_mode_fill_fb_struct(dev, &exynos_fb->fb, mode_cmd);
@@ -160,12 +157,13 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
 
 dma_addr_t exynos_drm_fb_dma_addr(struct drm_framebuffer *fb, int index)
 {
-	struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb);
+	struct exynos_drm_gem *exynos_gem;
 
 	if (WARN_ON_ONCE(index >= MAX_FB_BUFFER))
 		return 0;
 
-	return exynos_fb->dma_addr[index];
+	exynos_gem = to_exynos_gem(fb->obj[index]);
+	return exynos_gem->dma_addr + fb->offsets[index];
 }
 
 static struct drm_mode_config_helper_funcs exynos_drm_mode_config_helpers = {
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 18/24] drm/exynos: exynos_drm_fb -> drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (15 preceding siblings ...)
  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   ` Daniel Stone
  2018-03-30 14:11   ` [PATCH 19/24] drm/armada: Move GEM BO to drm_framebuffer Daniel Stone
                     ` (7 subsequent siblings)
  24 siblings, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: Kyungmin Park, Seung-Woo Kim

Now exynos_drm_fb is just an empty wrapper around drm_framebuffer, we
can drop it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_fb.c | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index 8be6263929b7..7fcc1a7ab1a0 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -27,18 +27,6 @@
 #include "exynos_drm_iommu.h"
 #include "exynos_drm_crtc.h"
 
-#define to_exynos_fb(x)	container_of(x, struct exynos_drm_fb, fb)
-
-/*
- * exynos specific framebuffer structure.
- *
- * @fb: drm framebuffer obejct.
- * @exynos_gem: array of exynos specific gem object containing a gem object.
- */
-struct exynos_drm_fb {
-	struct drm_framebuffer	fb;
-};
-
 static int check_fb_gem_memory_type(struct drm_device *drm_dev,
 				    struct exynos_drm_gem *exynos_gem)
 {
@@ -76,12 +64,12 @@ exynos_drm_framebuffer_init(struct drm_device *dev,
 			    struct exynos_drm_gem **exynos_gem,
 			    int count)
 {
-	struct exynos_drm_fb *exynos_fb;
+	struct drm_framebuffer *fb;
 	int i;
 	int ret;
 
-	exynos_fb = kzalloc(sizeof(*exynos_fb), GFP_KERNEL);
-	if (!exynos_fb)
+	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+	if (!fb)
 		return ERR_PTR(-ENOMEM);
 
 	for (i = 0; i < count; i++) {
@@ -89,21 +77,21 @@ exynos_drm_framebuffer_init(struct drm_device *dev,
 		if (ret < 0)
 			goto err;
 
-		exynos_fb->fb.obj[i] = &exynos_gem[i]->base;
+		fb->obj[i] = &exynos_gem[i]->base;
 	}
 
-	drm_helper_mode_fill_fb_struct(dev, &exynos_fb->fb, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
 
-	ret = drm_framebuffer_init(dev, &exynos_fb->fb, &exynos_drm_fb_funcs);
+	ret = drm_framebuffer_init(dev, fb, &exynos_drm_fb_funcs);
 	if (ret < 0) {
 		DRM_ERROR("failed to initialize framebuffer\n");
 		goto err;
 	}
 
-	return &exynos_fb->fb;
+	return fb;
 
 err:
-	kfree(exynos_fb);
+	kfree(fb);
 	return ERR_PTR(ret);
 }
 
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 19/24] drm/armada: Move GEM BO to drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (16 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 18/24] drm/exynos: exynos_drm_fb -> drm_framebuffer Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-05-17 13:15     ` Daniel Stone
  2018-05-17 14:57     ` Thierry Reding
  2018-03-30 14:11   ` [PATCH 20/24] drm/gma500: " Daniel Stone
                     ` (6 subsequent siblings)
  24 siblings, 2 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: Russell King

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: Russell King <linux@armlinux.org.uk>
---
 drivers/gpu/drm/armada/armada_fb.c | 23 ++++-------------------
 drivers/gpu/drm/armada/armada_fb.h |  3 +--
 2 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_fb.c b/drivers/gpu/drm/armada/armada_fb.c
index ac92bce07ecd..edd15126bde9 100644
--- a/drivers/gpu/drm/armada/armada_fb.c
+++ b/drivers/gpu/drm/armada/armada_fb.c
@@ -7,30 +7,15 @@
  */
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 #include "armada_drm.h"
 #include "armada_fb.h"
 #include "armada_gem.h"
 #include "armada_hw.h"
 
-static void armada_fb_destroy(struct drm_framebuffer *fb)
-{
-	struct armada_framebuffer *dfb = drm_fb_to_armada_fb(fb);
-
-	drm_framebuffer_cleanup(&dfb->fb);
-	drm_gem_object_put_unlocked(&dfb->obj->obj);
-	kfree(dfb);
-}
-
-static int armada_fb_create_handle(struct drm_framebuffer *fb,
-	struct drm_file *dfile, unsigned int *handle)
-{
-	struct armada_framebuffer *dfb = drm_fb_to_armada_fb(fb);
-	return drm_gem_handle_create(dfile, &dfb->obj->obj, handle);
-}
-
 static const struct drm_framebuffer_funcs armada_fb_funcs = {
-	.destroy	= armada_fb_destroy,
-	.create_handle	= armada_fb_create_handle,
+	.destroy	= drm_gem_fb_destroy,
+	.create_handle	= drm_gem_fb_create_handle,
 };
 
 struct armada_framebuffer *armada_framebuffer_create(struct drm_device *dev,
@@ -78,7 +63,7 @@ struct armada_framebuffer *armada_framebuffer_create(struct drm_device *dev,
 
 	dfb->fmt = format;
 	dfb->mod = config;
-	dfb->obj = obj;
+	dfb->fb.obj[0] = &obj->obj;
 
 	drm_helper_mode_fill_fb_struct(dev, &dfb->fb, mode);
 
diff --git a/drivers/gpu/drm/armada/armada_fb.h b/drivers/gpu/drm/armada/armada_fb.h
index 48073c4f54d8..5c130ff5da77 100644
--- a/drivers/gpu/drm/armada/armada_fb.h
+++ b/drivers/gpu/drm/armada/armada_fb.h
@@ -10,13 +10,12 @@
 
 struct armada_framebuffer {
 	struct drm_framebuffer	fb;
-	struct armada_gem_object *obj;
 	uint8_t			fmt;
 	uint8_t			mod;
 };
 #define drm_fb_to_armada_fb(dfb) \
 	container_of(dfb, struct armada_framebuffer, fb)
-#define drm_fb_obj(fb) drm_fb_to_armada_fb(fb)->obj
+#define drm_fb_obj(fb) drm_to_armada_gem((fb)->obj[0])
 
 struct armada_framebuffer *armada_framebuffer_create(struct drm_device *,
 	const struct drm_mode_fb_cmd2 *, struct armada_gem_object *);
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 20/24] drm/gma500: Move GEM BO to drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (17 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 19/24] drm/armada: Move GEM BO to drm_framebuffer Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
  2018-05-17 15:03     ` Thierry Reding
  2018-03-30 14:11   ` [PATCH 21/24] drm/msm: Move GEM BOs " Daniel Stone
                     ` (5 subsequent siblings)
  24 siblings, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel

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: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
---
 drivers/gpu/drm/gma500/accel_2d.c      |  2 +-
 drivers/gpu/drm/gma500/framebuffer.c   | 62 ++++++----------------------------
 drivers/gpu/drm/gma500/framebuffer.h   |  1 -
 drivers/gpu/drm/gma500/gma_display.c   | 10 +++---
 drivers/gpu/drm/gma500/gtt.h           |  2 ++
 drivers/gpu/drm/gma500/oaktrail_crtc.c |  3 +-
 6 files changed, 20 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/gma500/accel_2d.c b/drivers/gpu/drm/gma500/accel_2d.c
index c51d9259c7a7..204c8e452eb7 100644
--- a/drivers/gpu/drm/gma500/accel_2d.c
+++ b/drivers/gpu/drm/gma500/accel_2d.c
@@ -251,7 +251,7 @@ static void psbfb_copyarea_accel(struct fb_info *info,
 	if (!fb)
 		return;
 
-	offset = psbfb->gtt->offset;
+	offset = to_gtt_range(fb->obj[0])->offset;
 	stride = fb->pitches[0];
 
 	switch (fb->format->depth) {
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index cb0a2ae916e0..8fa4ef192c1e 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -33,6 +33,7 @@
 #include <drm/drm.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 
 #include "psb_drv.h"
 #include "psb_intel_reg.h"
@@ -40,14 +41,9 @@
 #include "framebuffer.h"
 #include "gtt.h"
 
-static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb);
-static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
-					      struct drm_file *file_priv,
-					      unsigned int *handle);
-
 static const struct drm_framebuffer_funcs psb_fb_funcs = {
-	.destroy = psb_user_framebuffer_destroy,
-	.create_handle = psb_user_framebuffer_create_handle,
+	.destroy = drm_gem_fb_destroy,
+	.create_handle = drm_gem_fb_create_handle,
 };
 
 #define CMAP_TOHW(_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16)
@@ -96,17 +92,18 @@ static int psbfb_pan(struct fb_var_screeninfo *var, struct fb_info *info)
 	struct psb_fbdev *fbdev = info->par;
 	struct psb_framebuffer *psbfb = &fbdev->pfb;
 	struct drm_device *dev = psbfb->base.dev;
+	struct gtt_range *gtt = to_gtt_range(psbfb->base.obj[0]);
 
 	/*
 	 *	We have to poke our nose in here. The core fb code assumes
 	 *	panning is part of the hardware that can be invoked before
 	 *	the actual fb is mapped. In our case that isn't quite true.
 	 */
-	if (psbfb->gtt->npage) {
+	if (gtt->npage) {
 		/* GTT roll shifts in 4K pages, we need to shift the right
 		   number of pages */
 		int pages = info->fix.line_length >> 12;
-		psb_gtt_roll(dev, psbfb->gtt, var->yoffset * pages);
+		psb_gtt_roll(dev, gtt, var->yoffset * pages);
 	}
         return 0;
 }
@@ -117,13 +114,14 @@ static int psbfb_vm_fault(struct vm_fault *vmf)
 	struct psb_framebuffer *psbfb = vma->vm_private_data;
 	struct drm_device *dev = psbfb->base.dev;
 	struct drm_psb_private *dev_priv = dev->dev_private;
+	struct gtt_range *gtt = to_gtt_range(psbfb->base.obj[0]);
 	int page_num;
 	int i;
 	unsigned long address;
 	int ret;
 	unsigned long pfn;
 	unsigned long phys_addr = (unsigned long)dev_priv->stolen_base +
-				  psbfb->gtt->offset;
+				  gtt->offset;
 
 	page_num = vma_pages(vma);
 	address = vmf->address - (vmf->pgoff << PAGE_SHIFT);
@@ -246,7 +244,7 @@ static int psb_framebuffer_init(struct drm_device *dev,
 		return -EINVAL;
 
 	drm_helper_mode_fill_fb_struct(dev, &fb->base, mode_cmd);
-	fb->gtt = gt;
+	fb->base.obj[0] = &gt->gem;
 	ret = drm_framebuffer_init(dev, &fb->base, &psb_fb_funcs);
 	if (ret) {
 		dev_err(dev->dev, "framebuffer init failed: %d\n", ret);
@@ -518,8 +516,8 @@ static int psb_fbdev_destroy(struct drm_device *dev, struct psb_fbdev *fbdev)
 	drm_framebuffer_unregister_private(&psbfb->base);
 	drm_framebuffer_cleanup(&psbfb->base);
 
-	if (psbfb->gtt)
-		drm_gem_object_unreference_unlocked(&psbfb->gtt->gem);
+	if (psbfb->base.obj[0])
+		drm_gem_object_unreference_unlocked(psbfb->base.obj[0]);
 	return 0;
 }
 
@@ -576,44 +574,6 @@ static void psb_fbdev_fini(struct drm_device *dev)
 	dev_priv->fbdev = NULL;
 }
 
-/**
- *	psb_user_framebuffer_create_handle - add hamdle to a framebuffer
- *	@fb: framebuffer
- *	@file_priv: our DRM file
- *	@handle: returned handle
- *
- *	Our framebuffer object is a GTT range which also contains a GEM
- *	object. We need to turn it into a handle for userspace. GEM will do
- *	the work for us
- */
-static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
-					      struct drm_file *file_priv,
-					      unsigned int *handle)
-{
-	struct psb_framebuffer *psbfb = to_psb_fb(fb);
-	struct gtt_range *r = psbfb->gtt;
-	return drm_gem_handle_create(file_priv, &r->gem, handle);
-}
-
-/**
- *	psb_user_framebuffer_destroy	-	destruct user created fb
- *	@fb: framebuffer
- *
- *	User framebuffers are backed by GEM objects so all we have to do is
- *	clean up a bit and drop the reference, GEM will handle the fallout
- */
-static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-	struct psb_framebuffer *psbfb = to_psb_fb(fb);
-	struct gtt_range *r = psbfb->gtt;
-
-	/* Let DRM do its clean up */
-	drm_framebuffer_cleanup(fb);
-	/*  We are no longer using the resource in GEM */
-	drm_gem_object_unreference_unlocked(&r->gem);
-	kfree(fb);
-}
-
 static const struct drm_mode_config_funcs psb_mode_funcs = {
 	.fb_create = psb_user_framebuffer_create,
 	.output_poll_changed = drm_fb_helper_output_poll_changed,
diff --git a/drivers/gpu/drm/gma500/framebuffer.h b/drivers/gpu/drm/gma500/framebuffer.h
index 395f20b07aab..23dc3c5f8f0d 100644
--- a/drivers/gpu/drm/gma500/framebuffer.h
+++ b/drivers/gpu/drm/gma500/framebuffer.h
@@ -31,7 +31,6 @@ struct psb_framebuffer {
 	struct drm_framebuffer base;
 	struct address_space *addr_space;
 	struct fb_info *fbdev;
-	struct gtt_range *gtt;
 };
 
 struct psb_fbdev {
diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index f3c48a2be71b..c8f071c47daf 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -60,7 +60,7 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
 	struct drm_framebuffer *fb = crtc->primary->fb;
-	struct psb_framebuffer *psbfb = to_psb_fb(fb);
+	struct gtt_range *gtt = to_gtt_range(fb->obj[0]);
 	int pipe = gma_crtc->pipe;
 	const struct psb_offset *map = &dev_priv->regmap[pipe];
 	unsigned long start, offset;
@@ -78,10 +78,10 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 
 	/* We are displaying this buffer, make sure it is actually loaded
 	   into the GTT */
-	ret = psb_gtt_pin(psbfb->gtt);
+	ret = psb_gtt_pin(gtt);
 	if (ret < 0)
 		goto gma_pipe_set_base_exit;
-	start = psbfb->gtt->offset;
+	start = gtt->offset;
 	offset = y * fb->pitches[0] + x * fb->format->cpp[0];
 
 	REG_WRITE(map->stride, fb->pitches[0]);
@@ -129,7 +129,7 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 gma_pipe_cleaner:
 	/* If there was a previous display we can now unpin it */
 	if (old_fb)
-		psb_gtt_unpin(to_psb_fb(old_fb)->gtt);
+		psb_gtt_unpin(to_gtt_range(old_fb->obj[0]));
 
 gma_pipe_set_base_exit:
 	gma_power_end(dev);
@@ -491,7 +491,7 @@ void gma_crtc_disable(struct drm_crtc *crtc)
 	crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
 
 	if (crtc->primary->fb) {
-		gt = to_psb_fb(crtc->primary->fb)->gtt;
+		gt = to_gtt_range(crtc->primary->fb->obj[0]);
 		psb_gtt_unpin(gt);
 	}
 }
diff --git a/drivers/gpu/drm/gma500/gtt.h b/drivers/gpu/drm/gma500/gtt.h
index cdbb350c9d5d..cb0c3a2a1fd4 100644
--- a/drivers/gpu/drm/gma500/gtt.h
+++ b/drivers/gpu/drm/gma500/gtt.h
@@ -53,6 +53,8 @@ struct gtt_range {
 	int roll;			/* Roll applied to the GTT entries */
 };
 
+#define to_gtt_range(x) container_of(x, struct gtt_range, gem)
+
 extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
 					     const char *name, int backed,
 					     u32 align);
diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
index 0fff269d3fe6..1b7fd6a9d8a5 100644
--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
+++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
@@ -600,7 +600,6 @@ static int oaktrail_pipe_set_base(struct drm_crtc *crtc,
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
 	struct drm_framebuffer *fb = crtc->primary->fb;
-	struct psb_framebuffer *psbfb = to_psb_fb(fb);
 	int pipe = gma_crtc->pipe;
 	const struct psb_offset *map = &dev_priv->regmap[pipe];
 	unsigned long start, offset;
@@ -617,7 +616,7 @@ static int oaktrail_pipe_set_base(struct drm_crtc *crtc,
 	if (!gma_power_begin(dev, true))
 		return 0;
 
-	start = psbfb->gtt->offset;
+	start = to_gtt_range(fb->obj[0])->offset;
 	offset = y * fb->pitches[0] + x * fb->format->cpp[0];
 
 	REG_WRITE(map->stride, fb->pitches[0]);
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 21/24] drm/msm: Move GEM BOs to drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (18 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 20/24] drm/gma500: " Daniel Stone
@ 2018-03-30 14:11   ` 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
                     ` (4 subsequent siblings)
  24 siblings, 2 replies; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm

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 function the same as the GEM framebuffer helper, we
can reuse that.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Rob Clark <robdclark@gmail.com>
Cc: linux-arm-msm@vger.kernel.org
---
 drivers/gpu/drm/msm/msm_fb.c | 54 +++++++++-----------------------------------
 1 file changed, 11 insertions(+), 43 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index 0e0c87252ab0..dfa0e05b21b8 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -17,6 +17,7 @@
 
 #include <drm/drm_crtc.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 
 #include "msm_drv.h"
 #include "msm_kms.h"
@@ -25,49 +26,20 @@
 struct msm_framebuffer {
 	struct drm_framebuffer base;
 	const struct msm_format *format;
-	struct drm_gem_object *planes[MAX_PLANE];
 };
 #define to_msm_framebuffer(x) container_of(x, struct msm_framebuffer, base)
 
 static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
 		const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
 
-static int msm_framebuffer_create_handle(struct drm_framebuffer *fb,
-		struct drm_file *file_priv,
-		unsigned int *handle)
-{
-	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	return drm_gem_handle_create(file_priv,
-			msm_fb->planes[0], handle);
-}
-
-static void msm_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	int i, n = fb->format->num_planes;
-
-	DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
-
-	drm_framebuffer_cleanup(fb);
-
-	for (i = 0; i < n; i++) {
-		struct drm_gem_object *bo = msm_fb->planes[i];
-
-		drm_gem_object_put_unlocked(bo);
-	}
-
-	kfree(msm_fb);
-}
-
 static const struct drm_framebuffer_funcs msm_framebuffer_funcs = {
-	.create_handle = msm_framebuffer_create_handle,
-	.destroy = msm_framebuffer_destroy,
+	.create_handle = drm_gem_fb_create_handle,
+	.destroy = drm_gem_fb_destroy,
 };
 
 #ifdef CONFIG_DEBUG_FS
 void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 {
-	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
 	int i, n = fb->format->num_planes;
 
 	seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n",
@@ -77,7 +49,7 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 	for (i = 0; i < n; i++) {
 		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
 				i, fb->offsets[i], fb->pitches[i]);
-		msm_gem_describe(msm_fb->planes[i], m);
+		msm_gem_describe(fb->obj[i], m);
 	}
 }
 #endif
@@ -90,12 +62,11 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 int msm_framebuffer_prepare(struct drm_framebuffer *fb,
 		struct msm_gem_address_space *aspace)
 {
-	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
 	int ret, i, n = fb->format->num_planes;
 	uint64_t iova;
 
 	for (i = 0; i < n; i++) {
-		ret = msm_gem_get_iova(msm_fb->planes[i], aspace, &iova);
+		ret = msm_gem_get_iova(fb->obj[i], aspace, &iova);
 		DBG("FB[%u]: iova[%d]: %08llx (%d)", fb->base.id, i, iova, ret);
 		if (ret)
 			return ret;
@@ -107,26 +78,23 @@ int msm_framebuffer_prepare(struct drm_framebuffer *fb,
 void msm_framebuffer_cleanup(struct drm_framebuffer *fb,
 		struct msm_gem_address_space *aspace)
 {
-	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
 	int i, n = fb->format->num_planes;
 
 	for (i = 0; i < n; i++)
-		msm_gem_put_iova(msm_fb->planes[i], aspace);
+		msm_gem_put_iova(fb->obj[i], aspace);
 }
 
 uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb,
 		struct msm_gem_address_space *aspace, int plane)
 {
-	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	if (!msm_fb->planes[plane])
+	if (!fb->obj[plane])
 		return 0;
-	return msm_gem_iova(msm_fb->planes[plane], aspace) + fb->offsets[plane];
+	return msm_gem_iova(fb->obj[plane], aspace) + fb->offsets[plane];
 }
 
 struct drm_gem_object *msm_framebuffer_bo(struct drm_framebuffer *fb, int plane)
 {
-	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	return msm_fb->planes[plane];
+	return drm_gem_fb_get_obj(fb, plane);
 }
 
 const struct msm_format *msm_framebuffer_format(struct drm_framebuffer *fb)
@@ -201,7 +169,7 @@ static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
 
 	msm_fb->format = format;
 
-	if (n > ARRAY_SIZE(msm_fb->planes)) {
+	if (n > ARRAY_SIZE(fb->obj)) {
 		ret = -EINVAL;
 		goto fail;
 	}
@@ -220,7 +188,7 @@ static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
 			goto fail;
 		}
 
-		msm_fb->planes[i] = bos[i];
+		msm_fb->base.obj[i] = bos[i];
 	}
 
 	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 22/24] drm/radeon: Move GEM BO to drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (19 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 21/24] drm/msm: Move GEM BOs " Daniel Stone
@ 2018-03-30 14:11   ` Daniel Stone
       [not found]     ` <20180330141138.28987-22-daniels-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
       [not found]   ` <20180330141138.28987-1-daniels-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
                     ` (3 subsequent siblings)
  24 siblings, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Christian König, amd-gfx

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: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: David (ChunMing) Zhou <David1.Zhou@amd.com>
Cc: amd-gfx@lists.freedesktop.org
---
 drivers/gpu/drm/radeon/atombios_crtc.c      | 10 +++++-----
 drivers/gpu/drm/radeon/radeon_device.c      |  4 ++--
 drivers/gpu/drm/radeon/radeon_display.c     | 31 +++++++----------------------
 drivers/gpu/drm/radeon/radeon_fb.c          |  8 ++++----
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 11 ++++------
 drivers/gpu/drm/radeon/radeon_mode.h        |  1 -
 6 files changed, 22 insertions(+), 43 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 02baaaf20e9d..028a811c1462 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1176,7 +1176,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 	/* If atomic, assume fb object is pinned & idle & fenced and
 	 * just update base pointers
 	 */
-	obj = radeon_fb->obj;
+	obj = radeon_fb->base.obj[0];
 	rbo = gem_to_radeon_bo(obj);
 	r = radeon_bo_reserve(rbo, false);
 	if (unlikely(r != 0))
@@ -1442,7 +1442,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 
 	if (!atomic && fb && fb != crtc->primary->fb) {
 		radeon_fb = to_radeon_framebuffer(fb);
-		rbo = gem_to_radeon_bo(radeon_fb->obj);
+		rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
 		r = radeon_bo_reserve(rbo, false);
 		if (unlikely(r != 0))
 			return r;
@@ -1490,7 +1490,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 		target_fb = crtc->primary->fb;
 	}
 
-	obj = radeon_fb->obj;
+	obj = radeon_fb->base.obj[0];
 	rbo = gem_to_radeon_bo(obj);
 	r = radeon_bo_reserve(rbo, false);
 	if (unlikely(r != 0))
@@ -1642,7 +1642,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 
 	if (!atomic && fb && fb != crtc->primary->fb) {
 		radeon_fb = to_radeon_framebuffer(fb);
-		rbo = gem_to_radeon_bo(radeon_fb->obj);
+		rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
 		r = radeon_bo_reserve(rbo, false);
 		if (unlikely(r != 0))
 			return r;
@@ -2153,7 +2153,7 @@ static void atombios_crtc_disable(struct drm_crtc *crtc)
 		struct radeon_bo *rbo;
 
 		radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
-		rbo = gem_to_radeon_bo(radeon_fb->obj);
+		rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
 		r = radeon_bo_reserve(rbo, false);
 		if (unlikely(r))
 			DRM_ERROR("failed to reserve rbo before unpin\n");
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index e415d2c097a7..30c5bc20a60b 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1599,10 +1599,10 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,
 			}
 		}
 
-		if (rfb == NULL || rfb->obj == NULL) {
+		if (rfb == NULL || rfb->base.obj[0] == NULL) {
 			continue;
 		}
-		robj = gem_to_radeon_bo(rfb->obj);
+		robj = gem_to_radeon_bo(rfb->base.obj[0]);
 		/* don't unpin kernel fb objects */
 		if (!radeon_fbdev_robj_is_fb(rdev, robj)) {
 			r = radeon_bo_reserve(robj, false);
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 26129b2b082d..dc300128283d 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -32,6 +32,7 @@
 
 #include <linux/pm_runtime.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_plane_helper.h>
 #include <drm/drm_edid.h>
@@ -502,14 +503,14 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc,
 
 	/* schedule unpin of the old buffer */
 	old_radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
-	obj = old_radeon_fb->obj;
+	obj = old_radeon_fb->base.obj[0];
 
 	/* take a reference to the old object */
 	drm_gem_object_get(obj);
 	work->old_rbo = gem_to_radeon_bo(obj);
 
 	new_radeon_fb = to_radeon_framebuffer(fb);
-	obj = new_radeon_fb->obj;
+	obj = new_radeon_fb->base.obj[0];
 	new_rbo = gem_to_radeon_bo(obj);
 
 	/* pin the new buffer */
@@ -1285,27 +1286,9 @@ void radeon_compute_pll_legacy(struct radeon_pll *pll,
 
 }
 
-static void radeon_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-	struct radeon_framebuffer *radeon_fb = to_radeon_framebuffer(fb);
-
-	drm_gem_object_put_unlocked(radeon_fb->obj);
-	drm_framebuffer_cleanup(fb);
-	kfree(radeon_fb);
-}
-
-static int radeon_user_framebuffer_create_handle(struct drm_framebuffer *fb,
-						  struct drm_file *file_priv,
-						  unsigned int *handle)
-{
-	struct radeon_framebuffer *radeon_fb = to_radeon_framebuffer(fb);
-
-	return drm_gem_handle_create(file_priv, radeon_fb->obj, handle);
-}
-
 static const struct drm_framebuffer_funcs radeon_fb_funcs = {
-	.destroy = radeon_user_framebuffer_destroy,
-	.create_handle = radeon_user_framebuffer_create_handle,
+	.destroy = drm_gem_fb_destroy,
+	.create_handle = drm_gem_fb_create_handle,
 };
 
 int
@@ -1315,11 +1298,11 @@ radeon_framebuffer_init(struct drm_device *dev,
 			struct drm_gem_object *obj)
 {
 	int ret;
-	rfb->obj = obj;
+	rfb->base.obj[0] = obj;
 	drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
 	ret = drm_framebuffer_init(dev, &rfb->base, &radeon_fb_funcs);
 	if (ret) {
-		rfb->obj = NULL;
+		rfb->base.obj[0] = NULL;
 		return ret;
 	}
 	return 0;
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index 57c5404a1654..6cd99f6a4305 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -312,9 +312,9 @@ static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfb
 
 	drm_fb_helper_unregister_fbi(&rfbdev->helper);
 
-	if (rfb->obj) {
-		radeonfb_destroy_pinned_object(rfb->obj);
-		rfb->obj = NULL;
+	if (rfb->base.obj[0]) {
+		radeonfb_destroy_pinned_object(rfb->base.obj[0]);
+		rfb->base.obj[0] = NULL;
 		drm_framebuffer_unregister_private(&rfb->base);
 		drm_framebuffer_cleanup(&rfb->base);
 	}
@@ -400,7 +400,7 @@ bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj)
 	if (!rdev->mode_info.rfbdev)
 		return false;
 
-	if (robj == gem_to_radeon_bo(rdev->mode_info.rfbdev->rfb.obj))
+	if (robj == gem_to_radeon_bo(rdev->mode_info.rfbdev->rfb.base.obj[0]))
 		return true;
 	return false;
 }
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index 1f1856e0b1e0..50b3f556845a 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -423,7 +423,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 	}
 
 	/* Pin framebuffer & get tilling informations */
-	obj = radeon_fb->obj;
+	obj = radeon_fb->base.obj[0];
 	rbo = gem_to_radeon_bo(obj);
 retry:
 	r = radeon_bo_reserve(rbo, false);
@@ -451,7 +451,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 			struct radeon_bo *old_rbo;
 			unsigned long nsize, osize;
 
-			old_rbo = gem_to_radeon_bo(to_radeon_framebuffer(fb)->obj);
+			old_rbo = gem_to_radeon_bo(fb->obj[0]);
 			osize = radeon_bo_size(old_rbo);
 			nsize = radeon_bo_size(rbo);
 			if (nsize <= osize && !radeon_bo_reserve(old_rbo, false)) {
@@ -558,8 +558,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(RADEON_CRTC_PITCH + radeon_crtc->crtc_offset, crtc_pitch);
 
 	if (!atomic && fb && fb != crtc->primary->fb) {
-		radeon_fb = to_radeon_framebuffer(fb);
-		rbo = gem_to_radeon_bo(radeon_fb->obj);
+		rbo = gem_to_radeon_bo(fb->obj[0]);
 		r = radeon_bo_reserve(rbo, false);
 		if (unlikely(r != 0))
 			return r;
@@ -1093,11 +1092,9 @@ static void radeon_crtc_disable(struct drm_crtc *crtc)
 	radeon_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
 	if (crtc->primary->fb) {
 		int r;
-		struct radeon_framebuffer *radeon_fb;
 		struct radeon_bo *rbo;
 
-		radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
-		rbo = gem_to_radeon_bo(radeon_fb->obj);
+		rbo = gem_to_radeon_bo(crtc->primary->fb->obj[0]);
 		r = radeon_bo_reserve(rbo, false);
 		if (unlikely(r))
 			DRM_ERROR("failed to reserve rbo before unpin\n");
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index 3243e5e01432..cd93c80332f7 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -576,7 +576,6 @@ struct radeon_connector {
 
 struct radeon_framebuffer {
 	struct drm_framebuffer base;
-	struct drm_gem_object *obj;
 };
 
 #define ENCODER_MODE_IS_DP(em) (((em) == ATOM_ENCODER_MODE_DP) || \
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 23/24] drm/radeon: radeon_framebuffer -> drm_framebuffer
       [not found]   ` <20180330141138.28987-1-daniels-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
@ 2018-03-30 14:11     ` Daniel Stone
  2018-05-17 15:07       ` Thierry Reding
  0 siblings, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Alex Deucher, David Zhou, Christian König,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: David (ChunMing) Zhou <David1.Zhou@amd.com>
Cc: amd-gfx@lists.freedesktop.org
---
 drivers/gpu/drm/radeon/atombios_crtc.c      | 32 ++++++++---------------------
 drivers/gpu/drm/radeon/radeon_device.c      |  6 +++---
 drivers/gpu/drm/radeon/radeon_display.c     | 30 ++++++++++++---------------
 drivers/gpu/drm/radeon/radeon_fb.c          | 20 +++++++++---------
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 11 +++-------
 drivers/gpu/drm/radeon/radeon_mode.h        |  7 +------
 6 files changed, 39 insertions(+), 67 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 028a811c1462..efbd5816082d 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1145,7 +1145,6 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
 	struct drm_device *dev = crtc->dev;
 	struct radeon_device *rdev = dev->dev_private;
-	struct radeon_framebuffer *radeon_fb;
 	struct drm_framebuffer *target_fb;
 	struct drm_gem_object *obj;
 	struct radeon_bo *rbo;
@@ -1164,19 +1163,15 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 		return 0;
 	}
 
-	if (atomic) {
-		radeon_fb = to_radeon_framebuffer(fb);
+	if (atomic)
 		target_fb = fb;
-	}
-	else {
-		radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
+	else
 		target_fb = crtc->primary->fb;
-	}
 
 	/* If atomic, assume fb object is pinned & idle & fenced and
 	 * just update base pointers
 	 */
-	obj = radeon_fb->base.obj[0];
+	obj = target_fb->obj[0];
 	rbo = gem_to_radeon_bo(obj);
 	r = radeon_bo_reserve(rbo, false);
 	if (unlikely(r != 0))
@@ -1441,8 +1436,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(EVERGREEN_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 0);
 
 	if (!atomic && fb && fb != crtc->primary->fb) {
-		radeon_fb = to_radeon_framebuffer(fb);
-		rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
+		rbo = gem_to_radeon_bo(fb->obj[0]);
 		r = radeon_bo_reserve(rbo, false);
 		if (unlikely(r != 0))
 			return r;
@@ -1463,7 +1457,6 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
 	struct drm_device *dev = crtc->dev;
 	struct radeon_device *rdev = dev->dev_private;
-	struct radeon_framebuffer *radeon_fb;
 	struct drm_gem_object *obj;
 	struct radeon_bo *rbo;
 	struct drm_framebuffer *target_fb;
@@ -1481,16 +1474,12 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 		return 0;
 	}
 
-	if (atomic) {
-		radeon_fb = to_radeon_framebuffer(fb);
+	if (atomic)
 		target_fb = fb;
-	}
-	else {
-		radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
+	else
 		target_fb = crtc->primary->fb;
-	}
 
-	obj = radeon_fb->base.obj[0];
+	obj = target_fb->obj[0];
 	rbo = gem_to_radeon_bo(obj);
 	r = radeon_bo_reserve(rbo, false);
 	if (unlikely(r != 0))
@@ -1641,8 +1630,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 3);
 
 	if (!atomic && fb && fb != crtc->primary->fb) {
-		radeon_fb = to_radeon_framebuffer(fb);
-		rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
+		rbo = gem_to_radeon_bo(fb->obj[0]);
 		r = radeon_bo_reserve(rbo, false);
 		if (unlikely(r != 0))
 			return r;
@@ -2149,11 +2137,9 @@ static void atombios_crtc_disable(struct drm_crtc *crtc)
 	atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
 	if (crtc->primary->fb) {
 		int r;
-		struct radeon_framebuffer *radeon_fb;
 		struct radeon_bo *rbo;
 
-		radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
-		rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
+		rbo = gem_to_radeon_bo(crtc->primary->fb->obj[0]);
 		r = radeon_bo_reserve(rbo, false);
 		if (unlikely(r))
 			DRM_ERROR("failed to reserve rbo before unpin\n");
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 30c5bc20a60b..90e17e29e12a 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1587,7 +1587,7 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,
 	/* unpin the front buffers and cursors */
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
 		struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-		struct radeon_framebuffer *rfb = to_radeon_framebuffer(crtc->primary->fb);
+		struct drm_framebuffer *fb = crtc->primary->fb;
 		struct radeon_bo *robj;
 
 		if (radeon_crtc->cursor_bo) {
@@ -1599,10 +1599,10 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,
 			}
 		}
 
-		if (rfb == NULL || rfb->base.obj[0] == NULL) {
+		if (fb == NULL || fb->obj[0] == NULL) {
 			continue;
 		}
-		robj = gem_to_radeon_bo(rfb->base.obj[0]);
+		robj = gem_to_radeon_bo(fb->obj[0]);
 		/* don't unpin kernel fb objects */
 		if (!radeon_fbdev_robj_is_fb(rdev, robj)) {
 			r = radeon_bo_reserve(robj, false);
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index dc300128283d..9d3ac8b981da 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -479,8 +479,6 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	struct radeon_device *rdev = dev->dev_private;
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-	struct radeon_framebuffer *old_radeon_fb;
-	struct radeon_framebuffer *new_radeon_fb;
 	struct drm_gem_object *obj;
 	struct radeon_flip_work *work;
 	struct radeon_bo *new_rbo;
@@ -502,15 +500,13 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc,
 	work->async = (page_flip_flags & DRM_MODE_PAGE_FLIP_ASYNC) != 0;
 
 	/* schedule unpin of the old buffer */
-	old_radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
-	obj = old_radeon_fb->base.obj[0];
+	obj = crtc->primary->fb->obj[0];
 
 	/* take a reference to the old object */
 	drm_gem_object_get(obj);
 	work->old_rbo = gem_to_radeon_bo(obj);
 
-	new_radeon_fb = to_radeon_framebuffer(fb);
-	obj = new_radeon_fb->base.obj[0];
+	obj = fb->obj[0];
 	new_rbo = gem_to_radeon_bo(obj);
 
 	/* pin the new buffer */
@@ -1293,16 +1289,16 @@ static const struct drm_framebuffer_funcs radeon_fb_funcs = {
 
 int
 radeon_framebuffer_init(struct drm_device *dev,
-			struct radeon_framebuffer *rfb,
+			struct drm_framebuffer *fb,
 			const struct drm_mode_fb_cmd2 *mode_cmd,
 			struct drm_gem_object *obj)
 {
 	int ret;
-	rfb->base.obj[0] = obj;
-	drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
-	ret = drm_framebuffer_init(dev, &rfb->base, &radeon_fb_funcs);
+	fb->obj[0] = obj;
+	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
+	ret = drm_framebuffer_init(dev, fb, &radeon_fb_funcs);
 	if (ret) {
-		rfb->base.obj[0] = NULL;
+		fb->obj[0] = NULL;
 		return ret;
 	}
 	return 0;
@@ -1314,7 +1310,7 @@ radeon_user_framebuffer_create(struct drm_device *dev,
 			       const struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	struct drm_gem_object *obj;
-	struct radeon_framebuffer *radeon_fb;
+	struct drm_framebuffer *fb;
 	int ret;
 
 	obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
@@ -1330,20 +1326,20 @@ radeon_user_framebuffer_create(struct drm_device *dev,
 		return ERR_PTR(-EINVAL);
 	}
 
-	radeon_fb = kzalloc(sizeof(*radeon_fb), GFP_KERNEL);
-	if (radeon_fb == NULL) {
+	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+	if (fb == NULL) {
 		drm_gem_object_put_unlocked(obj);
 		return ERR_PTR(-ENOMEM);
 	}
 
-	ret = radeon_framebuffer_init(dev, radeon_fb, mode_cmd, obj);
+	ret = radeon_framebuffer_init(dev, fb, mode_cmd, obj);
 	if (ret) {
-		kfree(radeon_fb);
+		kfree(fb);
 		drm_gem_object_put_unlocked(obj);
 		return ERR_PTR(ret);
 	}
 
-	return &radeon_fb->base;
+	return fb;
 }
 
 static const struct drm_mode_config_funcs radeon_mode_funcs = {
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index 6cd99f6a4305..1179034024ae 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -43,7 +43,7 @@
  */
 struct radeon_fbdev {
 	struct drm_fb_helper helper;
-	struct radeon_framebuffer rfb;
+	struct drm_framebuffer fb;
 	struct radeon_device *rdev;
 };
 
@@ -246,13 +246,13 @@ static int radeonfb_create(struct drm_fb_helper *helper,
 
 	info->par = rfbdev;
 
-	ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->rfb, &mode_cmd, gobj);
+	ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->fb, &mode_cmd, gobj);
 	if (ret) {
 		DRM_ERROR("failed to initialize framebuffer %d\n", ret);
 		goto out;
 	}
 
-	fb = &rfbdev->rfb.base;
+	fb = &rfbdev->fb;
 
 	/* setup helper */
 	rfbdev->helper.fb = fb;
@@ -308,15 +308,15 @@ static int radeonfb_create(struct drm_fb_helper *helper,
 
 static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfbdev)
 {
-	struct radeon_framebuffer *rfb = &rfbdev->rfb;
+	struct drm_framebuffer *fb = &rfbdev->fb;
 
 	drm_fb_helper_unregister_fbi(&rfbdev->helper);
 
-	if (rfb->base.obj[0]) {
-		radeonfb_destroy_pinned_object(rfb->base.obj[0]);
-		rfb->base.obj[0] = NULL;
-		drm_framebuffer_unregister_private(&rfb->base);
-		drm_framebuffer_cleanup(&rfb->base);
+	if (fb->obj[0]) {
+		radeonfb_destroy_pinned_object(fb->obj[0]);
+		fb->obj[0] = NULL;
+		drm_framebuffer_unregister_private(fb);
+		drm_framebuffer_cleanup(fb);
 	}
 	drm_fb_helper_fini(&rfbdev->helper);
 
@@ -400,7 +400,7 @@ bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj)
 	if (!rdev->mode_info.rfbdev)
 		return false;
 
-	if (robj == gem_to_radeon_bo(rdev->mode_info.rfbdev->rfb.base.obj[0]))
+	if (robj == gem_to_radeon_bo(rdev->mode_info.rfbdev->fb.obj[0]))
 		return true;
 	return false;
 }
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index 50b3f556845a..35a205ae4318 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -374,7 +374,6 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	struct radeon_device *rdev = dev->dev_private;
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-	struct radeon_framebuffer *radeon_fb;
 	struct drm_framebuffer *target_fb;
 	struct drm_gem_object *obj;
 	struct radeon_bo *rbo;
@@ -393,14 +392,10 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 		return 0;
 	}
 
-	if (atomic) {
-		radeon_fb = to_radeon_framebuffer(fb);
+	if (atomic)
 		target_fb = fb;
-	}
-	else {
-		radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
+	else
 		target_fb = crtc->primary->fb;
-	}
 
 	switch (target_fb->format->cpp[0] * 8) {
 	case 8:
@@ -423,7 +418,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 	}
 
 	/* Pin framebuffer & get tilling informations */
-	obj = radeon_fb->base.obj[0];
+	obj = target_fb->obj[0];
 	rbo = gem_to_radeon_bo(obj);
 retry:
 	r = radeon_bo_reserve(rbo, false);
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index cd93c80332f7..fd470d6bf3f4 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -46,7 +46,6 @@ struct radeon_device;
 #define to_radeon_crtc(x) container_of(x, struct radeon_crtc, base)
 #define to_radeon_connector(x) container_of(x, struct radeon_connector, base)
 #define to_radeon_encoder(x) container_of(x, struct radeon_encoder, base)
-#define to_radeon_framebuffer(x) container_of(x, struct radeon_framebuffer, base)
 
 #define RADEON_MAX_HPD_PINS 7
 #define RADEON_MAX_CRTCS 6
@@ -574,10 +573,6 @@ struct radeon_connector {
 	int enabled_attribs;
 };
 
-struct radeon_framebuffer {
-	struct drm_framebuffer base;
-};
-
 #define ENCODER_MODE_IS_DP(em) (((em) == ATOM_ENCODER_MODE_DP) || \
 				((em) == ATOM_ENCODER_MODE_DP_MST))
 
@@ -931,7 +926,7 @@ radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc);
 extern void
 radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on);
 int radeon_framebuffer_init(struct drm_device *dev,
-			     struct radeon_framebuffer *rfb,
+			     struct drm_framebuffer *rfb,
 			     const struct drm_mode_fb_cmd2 *mode_cmd,
 			     struct drm_gem_object *obj);
 
-- 
2.16.2

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 24/24] drm/amdgpu: Move GEM BO to drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (21 preceding siblings ...)
       [not found]   ` <20180330141138.28987-1-daniels-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
@ 2018-03-30 14:11   ` 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-05-17 13:54   ` Thierry Reding
  24 siblings, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 14:11 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Christian König, amd-gfx

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: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: David (ChunMing) Zhou <David1.Zhou@amd.com>
Cc: amd-gfx@lists.freedesktop.org
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |  6 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 36 +++++------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 +++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h          |  1 -
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c            | 17 ++++-------
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c            | 17 ++++-------
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c             | 17 ++++-------
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c             | 17 ++++-------
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c          |  4 +--
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 +++----
 10 files changed, 40 insertions(+), 96 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 34af664b9f93..fbc0676c6bcc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2539,7 +2539,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
 	/* unpin the front buffers and cursors */
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
 		struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-		struct amdgpu_framebuffer *rfb = to_amdgpu_framebuffer(crtc->primary->fb);
+		struct drm_framebuffer *fb = crtc->primary->fb;
 		struct amdgpu_bo *robj;
 
 		if (amdgpu_crtc->cursor_bo) {
@@ -2551,10 +2551,10 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
 			}
 		}
 
-		if (rfb == NULL || rfb->obj == NULL) {
+		if (fb == NULL || fb->obj[0] == NULL) {
 			continue;
 		}
-		robj = gem_to_amdgpu_bo(rfb->obj);
+		robj = gem_to_amdgpu_bo(fb->obj[0]);
 		/* don't unpin kernel fb objects */
 		if (!amdgpu_fbdev_robj_is_fb(adev, robj)) {
 			r = amdgpu_bo_reserve(robj, true);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 93f700ab1bfb..b83ae998fe27 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -35,6 +35,7 @@
 #include <linux/pm_runtime.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_fb_helper.h>
 
 static void amdgpu_display_flip_callback(struct dma_fence *f,
@@ -151,8 +152,6 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	struct amdgpu_device *adev = dev->dev_private;
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	struct amdgpu_framebuffer *old_amdgpu_fb;
-	struct amdgpu_framebuffer *new_amdgpu_fb;
 	struct drm_gem_object *obj;
 	struct amdgpu_flip_work *work;
 	struct amdgpu_bo *new_abo;
@@ -174,15 +173,13 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
 	work->async = (page_flip_flags & DRM_MODE_PAGE_FLIP_ASYNC) != 0;
 
 	/* schedule unpin of the old buffer */
-	old_amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
-	obj = old_amdgpu_fb->obj;
+	obj = crtc->primary->fb->obj[0];
 
 	/* take a reference to the old object */
 	work->old_abo = gem_to_amdgpu_bo(obj);
 	amdgpu_bo_ref(work->old_abo);
 
-	new_amdgpu_fb = to_amdgpu_framebuffer(fb);
-	obj = new_amdgpu_fb->obj;
+	obj = fb->obj[0];
 	new_abo = gem_to_amdgpu_bo(obj);
 
 	/* pin the new buffer */
@@ -482,28 +479,9 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
 	return true;
 }
 
-static void amdgpu_display_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-	struct amdgpu_framebuffer *amdgpu_fb = to_amdgpu_framebuffer(fb);
-
-	drm_gem_object_put_unlocked(amdgpu_fb->obj);
-	drm_framebuffer_cleanup(fb);
-	kfree(amdgpu_fb);
-}
-
-static int amdgpu_display_user_framebuffer_create_handle(
-			struct drm_framebuffer *fb,
-			struct drm_file *file_priv,
-			unsigned int *handle)
-{
-	struct amdgpu_framebuffer *amdgpu_fb = to_amdgpu_framebuffer(fb);
-
-	return drm_gem_handle_create(file_priv, amdgpu_fb->obj, handle);
-}
-
 static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
-	.destroy = amdgpu_display_user_framebuffer_destroy,
-	.create_handle = amdgpu_display_user_framebuffer_create_handle,
+	.destroy = drm_gem_fb_destroy,
+	.create_handle = drm_gem_fb_create_handle,
 };
 
 uint32_t amdgpu_display_framebuffer_domains(struct amdgpu_device *adev)
@@ -526,11 +504,11 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
 				    struct drm_gem_object *obj)
 {
 	int ret;
-	rfb->obj = obj;
+	rfb->base.obj[0] = obj;
 	drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
 	ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
 	if (ret) {
-		rfb->obj = NULL;
+		rfb->base.obj[0] = NULL;
 		return ret;
 	}
 	return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index 12063019751b..ff89e84b34ce 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -292,9 +292,9 @@ static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev *rfb
 
 	drm_fb_helper_unregister_fbi(&rfbdev->helper);
 
-	if (rfb->obj) {
-		amdgpufb_destroy_pinned_object(rfb->obj);
-		rfb->obj = NULL;
+	if (rfb->base.obj[0]) {
+		amdgpufb_destroy_pinned_object(rfb->base.obj[0]);
+		rfb->base.obj[0] = NULL;
 		drm_framebuffer_unregister_private(&rfb->base);
 		drm_framebuffer_cleanup(&rfb->base);
 	}
@@ -377,7 +377,7 @@ int amdgpu_fbdev_total_size(struct amdgpu_device *adev)
 	if (!adev->mode_info.rfbdev)
 		return 0;
 
-	robj = gem_to_amdgpu_bo(adev->mode_info.rfbdev->rfb.obj);
+	robj = gem_to_amdgpu_bo(adev->mode_info.rfbdev->rfb.base.obj[0]);
 	size += amdgpu_bo_size(robj);
 	return size;
 }
@@ -386,7 +386,7 @@ bool amdgpu_fbdev_robj_is_fb(struct amdgpu_device *adev, struct amdgpu_bo *robj)
 {
 	if (!adev->mode_info.rfbdev)
 		return false;
-	if (robj == gem_to_amdgpu_bo(adev->mode_info.rfbdev->rfb.obj))
+	if (robj == gem_to_amdgpu_bo(adev->mode_info.rfbdev->rfb.base.obj[0]))
 		return true;
 	return false;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index d6416ee52e32..b9e9e8b02fb7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -308,7 +308,6 @@ struct amdgpu_display_funcs {
 
 struct amdgpu_framebuffer {
 	struct drm_framebuffer base;
-	struct drm_gem_object *obj;
 
 	/* caching for later use */
 	uint64_t address;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 452f88ea46a2..ada241bfeee9 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -1823,7 +1823,6 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 	struct drm_device *dev = crtc->dev;
 	struct amdgpu_device *adev = dev->dev_private;
-	struct amdgpu_framebuffer *amdgpu_fb;
 	struct drm_framebuffer *target_fb;
 	struct drm_gem_object *obj;
 	struct amdgpu_bo *abo;
@@ -1842,18 +1841,15 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 		return 0;
 	}
 
-	if (atomic) {
-		amdgpu_fb = to_amdgpu_framebuffer(fb);
+	if (atomic)
 		target_fb = fb;
-	} else {
-		amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
+	else
 		target_fb = crtc->primary->fb;
-	}
 
 	/* If atomic, assume fb object is pinned & idle & fenced and
 	 * just update base pointers
 	 */
-	obj = amdgpu_fb->obj;
+	obj = target_fb->obj[0];
 	abo = gem_to_amdgpu_bo(obj);
 	r = amdgpu_bo_reserve(abo, false);
 	if (unlikely(r != 0))
@@ -2043,8 +2039,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(mmMASTER_UPDATE_MODE + amdgpu_crtc->crtc_offset, 0);
 
 	if (!atomic && fb && fb != crtc->primary->fb) {
-		amdgpu_fb = to_amdgpu_framebuffer(fb);
-		abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
+		abo = gem_to_amdgpu_bo(fb->obj[0]);
 		r = amdgpu_bo_reserve(abo, true);
 		if (unlikely(r != 0))
 			return r;
@@ -2526,11 +2521,9 @@ static void dce_v10_0_crtc_disable(struct drm_crtc *crtc)
 	dce_v10_0_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
 	if (crtc->primary->fb) {
 		int r;
-		struct amdgpu_framebuffer *amdgpu_fb;
 		struct amdgpu_bo *abo;
 
-		amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
-		abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
+		abo = gem_to_amdgpu_bo(crtc->primary->fb->obj[0]);
 		r = amdgpu_bo_reserve(abo, true);
 		if (unlikely(r))
 			DRM_ERROR("failed to reserve abo before unpin\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index a7c1c584a191..d3ae508b2a92 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -1862,7 +1862,6 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 	struct drm_device *dev = crtc->dev;
 	struct amdgpu_device *adev = dev->dev_private;
-	struct amdgpu_framebuffer *amdgpu_fb;
 	struct drm_framebuffer *target_fb;
 	struct drm_gem_object *obj;
 	struct amdgpu_bo *abo;
@@ -1881,18 +1880,15 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 		return 0;
 	}
 
-	if (atomic) {
-		amdgpu_fb = to_amdgpu_framebuffer(fb);
+	if (atomic)
 		target_fb = fb;
-	} else {
-		amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
+	else
 		target_fb = crtc->primary->fb;
-	}
 
 	/* If atomic, assume fb object is pinned & idle & fenced and
 	 * just update base pointers
 	 */
-	obj = amdgpu_fb->obj;
+	obj = target_fb->obj[0];
 	abo = gem_to_amdgpu_bo(obj);
 	r = amdgpu_bo_reserve(abo, false);
 	if (unlikely(r != 0))
@@ -2082,8 +2078,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(mmCRTC_MASTER_UPDATE_MODE + amdgpu_crtc->crtc_offset, 0);
 
 	if (!atomic && fb && fb != crtc->primary->fb) {
-		amdgpu_fb = to_amdgpu_framebuffer(fb);
-		abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
+		abo = gem_to_amdgpu_bo(fb->obj[0]);
 		r = amdgpu_bo_reserve(abo, true);
 		if (unlikely(r != 0))
 			return r;
@@ -2601,11 +2596,9 @@ static void dce_v11_0_crtc_disable(struct drm_crtc *crtc)
 	dce_v11_0_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
 	if (crtc->primary->fb) {
 		int r;
-		struct amdgpu_framebuffer *amdgpu_fb;
 		struct amdgpu_bo *abo;
 
-		amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
-		abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
+		abo = gem_to_amdgpu_bo(crtc->primary->fb->obj[0]);
 		r = amdgpu_bo_reserve(abo, true);
 		if (unlikely(r))
 			DRM_ERROR("failed to reserve abo before unpin\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index 9f67b7fd3487..394cc1e8fe20 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -1780,7 +1780,6 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 	struct drm_device *dev = crtc->dev;
 	struct amdgpu_device *adev = dev->dev_private;
-	struct amdgpu_framebuffer *amdgpu_fb;
 	struct drm_framebuffer *target_fb;
 	struct drm_gem_object *obj;
 	struct amdgpu_bo *abo;
@@ -1798,18 +1797,15 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,
 		return 0;
 	}
 
-	if (atomic) {
-		amdgpu_fb = to_amdgpu_framebuffer(fb);
+	if (atomic)
 		target_fb = fb;
-	} else {
-		amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
+	else
 		target_fb = crtc->primary->fb;
-	}
 
 	/* If atomic, assume fb object is pinned & idle & fenced and
 	 * just update base pointers
 	 */
-	obj = amdgpu_fb->obj;
+	obj = target_fb->obj[0];
 	abo = gem_to_amdgpu_bo(obj);
 	r = amdgpu_bo_reserve(abo, false);
 	if (unlikely(r != 0))
@@ -1978,8 +1974,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(mmMASTER_UPDATE_MODE + amdgpu_crtc->crtc_offset, 0);
 
 	if (!atomic && fb && fb != crtc->primary->fb) {
-		amdgpu_fb = to_amdgpu_framebuffer(fb);
-		abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
+		abo = gem_to_amdgpu_bo(fb->obj[0]);
 		r = amdgpu_bo_reserve(abo, true);
 		if (unlikely(r != 0))
 			return r;
@@ -2414,11 +2409,9 @@ static void dce_v6_0_crtc_disable(struct drm_crtc *crtc)
 	dce_v6_0_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
 	if (crtc->primary->fb) {
 		int r;
-		struct amdgpu_framebuffer *amdgpu_fb;
 		struct amdgpu_bo *abo;
 
-		amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
-		abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
+		abo = gem_to_amdgpu_bo(crtc->primary->fb->obj[0]);
 		r = amdgpu_bo_reserve(abo, true);
 		if (unlikely(r))
 			DRM_ERROR("failed to reserve abo before unpin\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index f55422cbd77a..c9b9ab8f1b05 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -1754,7 +1754,6 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 	struct drm_device *dev = crtc->dev;
 	struct amdgpu_device *adev = dev->dev_private;
-	struct amdgpu_framebuffer *amdgpu_fb;
 	struct drm_framebuffer *target_fb;
 	struct drm_gem_object *obj;
 	struct amdgpu_bo *abo;
@@ -1773,18 +1772,15 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 		return 0;
 	}
 
-	if (atomic) {
-		amdgpu_fb = to_amdgpu_framebuffer(fb);
+	if (atomic)
 		target_fb = fb;
-	} else {
-		amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
+	else
 		target_fb = crtc->primary->fb;
-	}
 
 	/* If atomic, assume fb object is pinned & idle & fenced and
 	 * just update base pointers
 	 */
-	obj = amdgpu_fb->obj;
+	obj = target_fb->obj[0];
 	abo = gem_to_amdgpu_bo(obj);
 	r = amdgpu_bo_reserve(abo, false);
 	if (unlikely(r != 0))
@@ -1955,8 +1951,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(mmMASTER_UPDATE_MODE + amdgpu_crtc->crtc_offset, 0);
 
 	if (!atomic && fb && fb != crtc->primary->fb) {
-		amdgpu_fb = to_amdgpu_framebuffer(fb);
-		abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
+		abo = gem_to_amdgpu_bo(fb->obj[0]);
 		r = amdgpu_bo_reserve(abo, true);
 		if (unlikely(r != 0))
 			return r;
@@ -2430,11 +2425,9 @@ static void dce_v8_0_crtc_disable(struct drm_crtc *crtc)
 	dce_v8_0_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
 	if (crtc->primary->fb) {
 		int r;
-		struct amdgpu_framebuffer *amdgpu_fb;
 		struct amdgpu_bo *abo;
 
-		amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
-		abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
+		abo = gem_to_amdgpu_bo(crtc->primary->fb->obj[0]);
 		r = amdgpu_bo_reserve(abo, true);
 		if (unlikely(r))
 			DRM_ERROR("failed to reserve abo before unpin\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index b51f05dc9582..89b2286a9d6b 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -168,11 +168,9 @@ static void dce_virtual_crtc_disable(struct drm_crtc *crtc)
 	dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
 	if (crtc->primary->fb) {
 		int r;
-		struct amdgpu_framebuffer *amdgpu_fb;
 		struct amdgpu_bo *abo;
 
-		amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
-		abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
+		abo = gem_to_amdgpu_bo(crtc->primary->fb->obj[0]);
 		r = amdgpu_bo_reserve(abo, true);
 		if (unlikely(r))
 			DRM_ERROR("failed to reserve abo before unpin\n");
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index e42a28e3adc5..baeea5ae4dd7 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1820,7 +1820,7 @@ static bool fill_rects_from_plane_state(const struct drm_plane_state *state,
 static int get_fb_info(const struct amdgpu_framebuffer *amdgpu_fb,
 		       uint64_t *tiling_flags)
 {
-	struct amdgpu_bo *rbo = gem_to_amdgpu_bo(amdgpu_fb->obj);
+	struct amdgpu_bo *rbo = gem_to_amdgpu_bo(amdgpu_fb->base.obj[0]);
 	int r = amdgpu_bo_reserve(rbo, false);
 
 	if (unlikely(r)) {
@@ -3029,8 +3029,7 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 	}
 
 	afb = to_amdgpu_framebuffer(new_state->fb);
-
-	obj = afb->obj;
+	obj = new_state->fb->obj[0];
 	rbo = gem_to_amdgpu_bo(obj);
 	adev = amdgpu_ttm_adev(rbo->tbo.bdev);
 	r = amdgpu_bo_reserve(rbo, false);
@@ -3094,14 +3093,12 @@ static void dm_plane_helper_cleanup_fb(struct drm_plane *plane,
 				       struct drm_plane_state *old_state)
 {
 	struct amdgpu_bo *rbo;
-	struct amdgpu_framebuffer *afb;
 	int r;
 
 	if (!old_state->fb)
 		return;
 
-	afb = to_amdgpu_framebuffer(old_state->fb);
-	rbo = gem_to_amdgpu_bo(afb->obj);
+	rbo = gem_to_amdgpu_bo(old_state->fb->obj[0]);
 	r = amdgpu_bo_reserve(rbo, false);
 	if (unlikely(r)) {
 		DRM_ERROR("failed to reserve rbo before unpin\n");
@@ -3897,7 +3894,7 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc,
 	int r, vpos, hpos;
 	struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 	struct amdgpu_framebuffer *afb = to_amdgpu_framebuffer(fb);
-	struct amdgpu_bo *abo = gem_to_amdgpu_bo(afb->obj);
+	struct amdgpu_bo *abo = gem_to_amdgpu_bo(fb->obj[0]);
 	struct amdgpu_device *adev = crtc->dev->dev_private;
 	bool async_flip = (crtc->state->pageflip_flags & DRM_MODE_PAGE_FLIP_ASYNC) != 0;
 	struct dc_flip_addrs addr = { {0} };
-- 
2.16.2

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

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* Re: [PATCH 00/24] drm_framebuffer boilerplate removal
  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:47 ` [PATCH 00/24] drm_framebuffer boilerplate removal Alex Deucher
@ 2018-03-30 14:47 ` Alex Deucher
  2018-03-30 15:00   ` Daniel Stone
  2 siblings, 1 reply; 73+ messages in thread
From: Alex Deucher @ 2018-03-30 14:47 UTC (permalink / raw)
  To: Daniel Stone
  Cc: dri-devel, open list:VIRTIO CORE, NET...,
	Thierry Reding, amd-gfx mailing list, Russell King,
	Tomi Valkeinen, Dave Airlie, David Lechner, linux-arm-msm,
	intel-gfx, Rodrigo Vivi, linux-tegra, Seung-Woo Kim,
	Kyungmin Park, Alex Deucher, Christian König, Gerd Hoffmann

On Fri, Mar 30, 2018 at 10:11 AM, Daniel Stone <daniels@collabora.com> wrote:
> Hi,
> I've been working on a getfb2[0] ioctl, which amongst other things
> supports multi-planar framebuffers as well as modifiers. getfb
> currently calls the framebuffer's handle_create hook, which doesn't
> support multiple planes.
>
> Thanks to Noralf's recent work, drivers can just store GEM objects
> directly in drm_framebuffer. I use this directly in getfb2: we need
> direct access to the GEM objects and not a vfunc in order to not hand
> out duplicate GEM names for the same object.
>
> This series converts all drivers except for nouveau, which was a
> little too non-trivial for my comfort, to storing GEM objects directly
> in drm_framebuffer. For those drivers whose driver_framebuffer struct
> was nothing but drm_framebuffer + BO, it deletes the driver-specific
> struct. It also makes use of Noralf's generic framebuffer helpers for
> create_handle and destroy where possible.
>
> I don't have the hardware for most of these drivers, so have had to
> settle for just staring really hard at the diff.
>
> I intend to remove create_handle when all drivers are converted over
> to placing BOs directly inside drm_framebuffer. For most drivers
> there's a relatively easy conversion to using the helpers for
> basically all framebuffer handling and fbdev emulation as well, though
> that's a bit further than I was willing to go without hardware to test
> on ...

Series is:
Acked-by: Alex Deucher <alexander.deucher@amd.com>

>
> Cheers,
> Daniel
>
> [0]: https://lists.freedesktop.org/archives/dri-devel/2018-March/170512.html
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 00/24] drm_framebuffer boilerplate removal
  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:47 ` Alex Deucher
  2018-03-30 14:47 ` Alex Deucher
  2 siblings, 0 replies; 73+ messages in thread
From: Alex Deucher @ 2018-03-30 14:47 UTC (permalink / raw)
  To: Daniel Stone
  Cc: Heiko Stübner, Joonas Lahtinen, dri-devel,
	open list:VIRTIO CORE, NET...,
	Thierry Reding, amd-gfx mailing list, David (ChunMing) Zhou,
	Joonyoung Shim, Russell King, Patrik Jakobsson, Tomi Valkeinen,
	CK Hu, Dave Airlie, Rob Clark, David Lechner, linux-arm-msm,
	intel-gfx, Jani Nikula, Inki Dae, Rodrigo Vivi

On Fri, Mar 30, 2018 at 10:11 AM, Daniel Stone <daniels@collabora.com> wrote:
> Hi,
> I've been working on a getfb2[0] ioctl, which amongst other things
> supports multi-planar framebuffers as well as modifiers. getfb
> currently calls the framebuffer's handle_create hook, which doesn't
> support multiple planes.
>
> Thanks to Noralf's recent work, drivers can just store GEM objects
> directly in drm_framebuffer. I use this directly in getfb2: we need
> direct access to the GEM objects and not a vfunc in order to not hand
> out duplicate GEM names for the same object.
>
> This series converts all drivers except for nouveau, which was a
> little too non-trivial for my comfort, to storing GEM objects directly
> in drm_framebuffer. For those drivers whose driver_framebuffer struct
> was nothing but drm_framebuffer + BO, it deletes the driver-specific
> struct. It also makes use of Noralf's generic framebuffer helpers for
> create_handle and destroy where possible.
>
> I don't have the hardware for most of these drivers, so have had to
> settle for just staring really hard at the diff.
>
> I intend to remove create_handle when all drivers are converted over
> to placing BOs directly inside drm_framebuffer. For most drivers
> there's a relatively easy conversion to using the helpers for
> basically all framebuffer handling and fbdev emulation as well, though
> that's a bit further than I was willing to go without hardware to test
> on ...

Series is:
Acked-by: Alex Deucher <alexander.deucher@amd.com>

>
> Cheers,
> Daniel
>
> [0]: https://lists.freedesktop.org/archives/dri-devel/2018-March/170512.html
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 00/24] drm_framebuffer boilerplate removal
  2018-03-30 14:47 ` Alex Deucher
@ 2018-03-30 15:00   ` Daniel Stone
       [not found]     ` <CAPj87rOfg18u1xBioeu1D0MoD4My2rZy1Nw3yfA4DhdX2R7g7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-03-30 15:00 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Alex Deucher, amd-gfx mailing list, dri-devel, Christian König

Hi Alex,

On 30 March 2018 at 15:47, Alex Deucher <alexdeucher@gmail.com> wrote:
> On Fri, Mar 30, 2018 at 10:11 AM, Daniel Stone <daniels@collabora.com> wrote:
>> I intend to remove create_handle when all drivers are converted over
>> to placing BOs directly inside drm_framebuffer. For most drivers
>> there's a relatively easy conversion to using the helpers for
>> basically all framebuffer handling and fbdev emulation as well, though
>> that's a bit further than I was willing to go without hardware to test
>> on ...
>
> Series is:
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Thanks a lot for the review! Are you taking the radeon/amdgpu patches
through your tree? They don't have any dependencies on core code.

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 00/24] drm_framebuffer boilerplate removal
       [not found]     ` <CAPj87rOfg18u1xBioeu1D0MoD4My2rZy1Nw3yfA4DhdX2R7g7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2018-03-30 15:03       ` Alex Deucher
  0 siblings, 0 replies; 73+ messages in thread
From: Alex Deucher @ 2018-03-30 15:03 UTC (permalink / raw)
  To: Daniel Stone
  Cc: Alex Deucher, amd-gfx mailing list, dri-devel, Christian König

On Fri, Mar 30, 2018 at 11:00 AM, Daniel Stone <daniels@collabora.com> wrote:
> Hi Alex,
>
> On 30 March 2018 at 15:47, Alex Deucher <alexdeucher@gmail.com> wrote:
>> On Fri, Mar 30, 2018 at 10:11 AM, Daniel Stone <daniels@collabora.com> wrote:
>>> I intend to remove create_handle when all drivers are converted over
>>> to placing BOs directly inside drm_framebuffer. For most drivers
>>> there's a relatively easy conversion to using the helpers for
>>> basically all framebuffer handling and fbdev emulation as well, though
>>> that's a bit further than I was willing to go without hardware to test
>>> on ...
>>
>> Series is:
>> Acked-by: Alex Deucher <alexander.deucher@amd.com>
>
> Thanks a lot for the review! Are you taking the radeon/amdgpu patches
> through your tree? They don't have any dependencies on core code.

Sure.  I'll grab them now.

Alex
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 07/24] drm/omap: Move buffer pitch/offset to drm_framebuffer
  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
  1 sibling, 1 reply; 73+ messages in thread
From: Sebastian Reichel @ 2018-03-30 20:53 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 3698 bytes --]

Hi,

On Fri, Mar 30, 2018 at 03:11:21PM +0100, Daniel Stone wrote:
> drm_framebuffer already holds per-plane pitch and offsets, which is
> filled out for us when we create the framebuffer. Nuke our local copy in
> the plane struct.
> 
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

> ---
>  drivers/gpu/drm/omapdrm/omap_fb.c | 22 +++++++++-------------
>  1 file changed, 9 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
> index 3d6b6f3d6808..9d75eab0d164 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fb.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fb.c
> @@ -52,8 +52,6 @@ static const u32 formats[] = {
>  
>  /* per-plane info for the fb: */
>  struct plane {
> -	u32 pitch;
> -	u32 offset;
>  	dma_addr_t dma_addr;
>  };
>  
> @@ -73,14 +71,16 @@ static const struct drm_framebuffer_funcs omap_framebuffer_funcs = {
>  	.destroy = drm_gem_fb_destroy,
>  };
>  
> -static u32 get_linear_addr(struct plane *plane,
> +static u32 get_linear_addr(struct drm_framebuffer *fb,
>  		const struct drm_format_info *format, int n, int x, int y)
>  {
> +	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
> +	struct plane *plane = &omap_fb->planes[n];
>  	u32 offset;
>  
> -	offset = plane->offset
> +	offset = fb->offsets[n]
>  	       + (x * format->cpp[n] / (n == 0 ? 1 : format->hsub))
> -	       + (y * plane->pitch / (n == 0 ? 1 : format->vsub));
> +	       + (y * fb->pitches[n] / (n == 0 ? 1 : format->vsub));
>  
>  	return plane->dma_addr + offset;
>  }
> @@ -191,10 +191,10 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
>  			break;
>  		}
>  
> -		info->paddr         = get_linear_addr(plane, format, 0, x, y);
> +		info->paddr         = get_linear_addr(fb, format, 0, x, y);
>  		info->rotation_type = OMAP_DSS_ROT_NONE;
>  		info->rotation      = DRM_MODE_ROTATE_0;
> -		info->screen_width  = plane->pitch;
> +		info->screen_width  = fb->pitches[0];
>  	}
>  
>  	/* convert to pixels: */
> @@ -208,7 +208,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
>  			omap_gem_rotated_dma_addr(fb->obj[1], orient, x/2, y/2,
>  						  &info->p_uv_addr);
>  		} else {
> -			info->p_uv_addr = get_linear_addr(plane, format, 1, x, y);
> +			info->p_uv_addr = get_linear_addr(fb, format, 1, x, y);
>  		}
>  	} else {
>  		info->p_uv_addr = 0;
> @@ -309,16 +309,14 @@ struct drm_connector *omap_framebuffer_get_next_connector(
>  #ifdef CONFIG_DEBUG_FS
>  void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
>  {
> -	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
>  	int i, n = fb->format->num_planes;
>  
>  	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
>  			(char *)&fb->format->format);
>  
>  	for (i = 0; i < n; i++) {
> -		struct plane *plane = &omap_fb->planes[i];
>  		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
> -				i, plane->offset, plane->pitch);
> +				i, fb->offsets[n], fb->pitches[i]);
>  		omap_gem_describe(fb->obj[i], m);
>  	}
>  }
> @@ -425,8 +423,6 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
>  		}
>  
>  		fb->obj[i]    = bos[i];
> -		plane->offset = mode_cmd->offsets[i];
> -		plane->pitch  = pitch;
>  		plane->dma_addr  = 0;
>  	}
>  
> -- 
> 2.16.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 06/24] drm/omap: Move GEM BO to drm_framebuffer
  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
  1 sibling, 0 replies; 73+ messages in thread
From: Sebastian Reichel @ 2018-03-30 20:54 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 6329 bytes --]

Hi,

On Fri, Mar 30, 2018 at 03:11:20PM +0100, Daniel Stone wrote:
> 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: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/omap_fb.c | 60 ++++++++++-----------------------------
>  1 file changed, 15 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
> index 5fd22ca73913..3d6b6f3d6808 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fb.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fb.c
> @@ -19,6 +19,7 @@
>  
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_gem_framebuffer_helper.h>
>  
>  #include "omap_dmm_tiler.h"
>  #include "omap_drv.h"
> @@ -51,7 +52,6 @@ static const u32 formats[] = {
>  
>  /* per-plane info for the fb: */
>  struct plane {
> -	struct drm_gem_object *bo;
>  	u32 pitch;
>  	u32 offset;
>  	dma_addr_t dma_addr;
> @@ -68,36 +68,9 @@ struct omap_framebuffer {
>  	struct mutex lock;
>  };
>  
> -static int omap_framebuffer_create_handle(struct drm_framebuffer *fb,
> -		struct drm_file *file_priv,
> -		unsigned int *handle)
> -{
> -	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
> -	return drm_gem_handle_create(file_priv,
> -			omap_fb->planes[0].bo, handle);
> -}
> -
> -static void omap_framebuffer_destroy(struct drm_framebuffer *fb)
> -{
> -	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
> -	int i, n = fb->format->num_planes;
> -
> -	DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
> -
> -	drm_framebuffer_cleanup(fb);
> -
> -	for (i = 0; i < n; i++) {
> -		struct plane *plane = &omap_fb->planes[i];
> -
> -		drm_gem_object_unreference_unlocked(plane->bo);
> -	}
> -
> -	kfree(omap_fb);
> -}
> -
>  static const struct drm_framebuffer_funcs omap_framebuffer_funcs = {
> -	.create_handle = omap_framebuffer_create_handle,
> -	.destroy = omap_framebuffer_destroy,
> +	.create_handle = drm_gem_fb_create_handle,
> +	.destroy = drm_gem_fb_destroy,
>  };
>  
>  static u32 get_linear_addr(struct plane *plane,
> @@ -114,10 +87,7 @@ static u32 get_linear_addr(struct plane *plane,
>  
>  bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb)
>  {
> -	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
> -	struct plane *plane = &omap_fb->planes[0];
> -
> -	return omap_gem_flags(plane->bo) & OMAP_BO_TILED;
> +	return omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED;
>  }
>  
>  /* Note: DRM rotates counter-clockwise, TILER & DSS rotates clockwise */
> @@ -176,7 +146,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
>  	x = state->src_x >> 16;
>  	y = state->src_y >> 16;
>  
> -	if (omap_gem_flags(plane->bo) & OMAP_BO_TILED) {
> +	if (omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED) {
>  		u32 w = state->src_w >> 16;
>  		u32 h = state->src_h >> 16;
>  
> @@ -201,12 +171,12 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
>  			x += w - 1;
>  
>  		/* Note: x and y are in TILER units, not pixels */
> -		omap_gem_rotated_dma_addr(plane->bo, orient, x, y,
> +		omap_gem_rotated_dma_addr(fb->obj[0], orient, x, y,
>  					  &info->paddr);
>  		info->rotation_type = OMAP_DSS_ROT_TILER;
>  		info->rotation = state->rotation ?: DRM_MODE_ROTATE_0;
>  		/* Note: stride in TILER units, not pixels */
> -		info->screen_width  = omap_gem_tiled_stride(plane->bo, orient);
> +		info->screen_width  = omap_gem_tiled_stride(fb->obj[0], orient);
>  	} else {
>  		switch (state->rotation & DRM_MODE_ROTATE_MASK) {
>  		case 0:
> @@ -234,8 +204,8 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
>  		plane = &omap_fb->planes[1];
>  
>  		if (info->rotation_type == OMAP_DSS_ROT_TILER) {
> -			WARN_ON(!(omap_gem_flags(plane->bo) & OMAP_BO_TILED));
> -			omap_gem_rotated_dma_addr(plane->bo, orient, x/2, y/2,
> +			WARN_ON(!(omap_gem_flags(fb->obj[1]) & OMAP_BO_TILED));
> +			omap_gem_rotated_dma_addr(fb->obj[1], orient, x/2, y/2,
>  						  &info->p_uv_addr);
>  		} else {
>  			info->p_uv_addr = get_linear_addr(plane, format, 1, x, y);
> @@ -261,10 +231,10 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
>  
>  	for (i = 0; i < n; i++) {
>  		struct plane *plane = &omap_fb->planes[i];
> -		ret = omap_gem_pin(plane->bo, &plane->dma_addr);
> +		ret = omap_gem_pin(fb->obj[i], &plane->dma_addr);
>  		if (ret)
>  			goto fail;
> -		omap_gem_dma_sync_buffer(plane->bo, DMA_TO_DEVICE);
> +		omap_gem_dma_sync_buffer(fb->obj[i], DMA_TO_DEVICE);
>  	}
>  
>  	omap_fb->pin_count++;
> @@ -276,7 +246,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
>  fail:
>  	for (i--; i >= 0; i--) {
>  		struct plane *plane = &omap_fb->planes[i];
> -		omap_gem_unpin(plane->bo);
> +		omap_gem_unpin(fb->obj[i]);
>  		plane->dma_addr = 0;
>  	}
>  
> @@ -302,7 +272,7 @@ void omap_framebuffer_unpin(struct drm_framebuffer *fb)
>  
>  	for (i = 0; i < n; i++) {
>  		struct plane *plane = &omap_fb->planes[i];
> -		omap_gem_unpin(plane->bo);
> +		omap_gem_unpin(fb->obj[i]);
>  		plane->dma_addr = 0;
>  	}
>  
> @@ -349,7 +319,7 @@ void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
>  		struct plane *plane = &omap_fb->planes[i];
>  		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
>  				i, plane->offset, plane->pitch);
> -		omap_gem_describe(plane->bo, m);
> +		omap_gem_describe(fb->obj[i], m);
>  	}
>  }
>  #endif
> @@ -454,7 +424,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
>  			goto fail;
>  		}
>  
> -		plane->bo     = bos[i];
> +		fb->obj[i]    = bos[i];
>  		plane->offset = mode_cmd->offsets[i];
>  		plane->pitch  = pitch;
>  		plane->dma_addr  = 0;
> -- 
> 2.16.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 16/24] drm/exynos: Move GEM BOs to drm_framebuffer
  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
  0 siblings, 1 reply; 73+ messages in thread
From: Inki Dae @ 2018-04-13  8:55 UTC (permalink / raw)
  To: Daniel Stone, dri-devel; +Cc: Kyungmin Park, Seung-Woo Kim

Hi Daniel,

2018년 03월 30일 23:11에 Daniel Stone 이(가) 쓴 글:
> 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.

Looks good and I will apply it including other two patches - 17 and 18 - after test.

Thanks,
Inki Dae

> 
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: Inki Dae <inki.dae@samsung.com>
> Cc: Joonyoung Shim <jy0922.shim@samsung.com>
> Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_fb.c | 39 ++++------------------------------
>  1 file changed, 4 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c
> index 2379d732da67..d874c2d50ab6 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_atomic.h>
>  #include <drm/drm_atomic_helper.h>
> +#include <drm/drm_gem_framebuffer_helper.h>
>  #include <uapi/drm/exynos_drm.h>
>  
>  #include "exynos_drm_drv.h"
> @@ -36,7 +37,6 @@
>   */
>  struct exynos_drm_fb {
>  	struct drm_framebuffer	fb;
> -	struct exynos_drm_gem	*exynos_gem[MAX_FB_BUFFER];
>  	dma_addr_t			dma_addr[MAX_FB_BUFFER];
>  };
>  
> @@ -66,40 +66,9 @@ static int check_fb_gem_memory_type(struct drm_device *drm_dev,
>  	return 0;
>  }
>  
> -static void exynos_drm_fb_destroy(struct drm_framebuffer *fb)
> -{
> -	struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb);
> -	unsigned int i;
> -
> -	drm_framebuffer_cleanup(fb);
> -
> -	for (i = 0; i < ARRAY_SIZE(exynos_fb->exynos_gem); i++) {
> -		struct drm_gem_object *obj;
> -
> -		if (exynos_fb->exynos_gem[i] == NULL)
> -			continue;
> -
> -		obj = &exynos_fb->exynos_gem[i]->base;
> -		drm_gem_object_unreference_unlocked(obj);
> -	}
> -
> -	kfree(exynos_fb);
> -	exynos_fb = NULL;
> -}
> -
> -static int exynos_drm_fb_create_handle(struct drm_framebuffer *fb,
> -					struct drm_file *file_priv,
> -					unsigned int *handle)
> -{
> -	struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb);
> -
> -	return drm_gem_handle_create(file_priv,
> -				     &exynos_fb->exynos_gem[0]->base, handle);
> -}
> -
>  static const struct drm_framebuffer_funcs exynos_drm_fb_funcs = {
> -	.destroy	= exynos_drm_fb_destroy,
> -	.create_handle	= exynos_drm_fb_create_handle,
> +	.destroy	= drm_gem_fb_destroy,
> +	.create_handle	= drm_gem_fb_create_handle,
>  };
>  
>  struct drm_framebuffer *
> @@ -121,7 +90,7 @@ exynos_drm_framebuffer_init(struct drm_device *dev,
>  		if (ret < 0)
>  			goto err;
>  
> -		exynos_fb->exynos_gem[i] = exynos_gem[i];
> +		exynos_fb->fb.obj[i] = &exynos_gem[i]->base;
>  		exynos_fb->dma_addr[i] = exynos_gem[i]->dma_addr
>  						+ mode_cmd->offsets[i];
>  	}
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 16/24] drm/exynos: Move GEM BOs to drm_framebuffer
  2018-04-13  8:55     ` Inki Dae
@ 2018-04-13 10:13       ` Daniel Stone
  0 siblings, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-04-13 10:13 UTC (permalink / raw)
  To: Inki Dae; +Cc: Kyungmin Park, Seung-Woo Kim, Daniel Stone, dri-devel

Hi Inki,

On 13 April 2018 at 10:55, Inki Dae <inki.dae@samsung.com> wrote:
> 2018년 03월 30일 23:11에 Daniel Stone 이(가) 쓴 글:
>> 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.
>
> Looks good and I will apply it including other two patches - 17 and 18 - after test.

Great news, thankyou. :)

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 05/24] drm/rockchip: rockchip_drm_fb -> drm_framebuffer
  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 13:56     ` Sean Paul
  2018-05-17 14:46     ` Thierry Reding
  2 siblings, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-05-17 13:08 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel

On 30 March 2018 at 15:11, Daniel Stone <daniels@collabora.com> wrote:
> Now that rockchip_drm_fb is just a wrapper around drm_framebuffer, we
> can remove it.
>
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: Sandy Huang <hjc@rock-chips.com>
> Cc: Heiko Stübner <heiko@sntech.de>

Ping?

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 13/24] drm/tegra: tegra_fb -> drm_framebuffer
  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
  0 siblings, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-05-17 13:11 UTC (permalink / raw)
  To: Daniel Stone; +Cc: linux-tegra, Thierry Reding, dri-devel

Hi Thierry,

On 30 March 2018 at 15:11, Daniel Stone <daniels@collabora.com> wrote:
> Since tegra_fb is now the same as drm_framebuffer, we can just replace
> the type completely.
>
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: linux-tegra@vger.kernel.org

Did this still need some more testing, or is it OK to apply?

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 21/24] drm/msm: Move GEM BOs to drm_framebuffer
  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
  1 sibling, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-05-17 13:12 UTC (permalink / raw)
  To: Daniel Stone; +Cc: linux-arm-msm, dri-devel

Hi Rob,

On 30 March 2018 at 15:11, Daniel Stone <daniels@collabora.com> wrote:
> 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 function the same as the GEM framebuffer helper, we
> can reuse that.

I didn't get to removing msm_framebuffer completely, because the
cleanup was a bit too painful. It still seems like a useful cleanup
though - could you please take a look?

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 07/24] drm/omap: Move buffer pitch/offset to drm_framebuffer
  2018-03-30 20:53     ` Sebastian Reichel
@ 2018-05-17 13:13       ` Daniel Stone
  0 siblings, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-05-17 13:13 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Tomi Valkeinen, Daniel Stone, dri-devel

On 30 March 2018 at 21:53, Sebastian Reichel
<sebastian.reichel@collabora.co.uk> wrote:
> On Fri, Mar 30, 2018 at 03:11:21PM +0100, Daniel Stone wrote:
>> drm_framebuffer already holds per-plane pitch and offsets, which is
>> filled out for us when we create the framebuffer. Nuke our local copy in
>> the plane struct.
>>
>> Signed-off-by: Daniel Stone <daniels@collabora.com>
>> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
>
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

Thanks Sebastian! Tomi, are you planning to take this through drm-tip
if you're happy with it?

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 10/24] drm/mtk: mtk_drm_fb -> drm_framebuffer
  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
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-05-17 13:13 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel

Hi CK, Philipp,

On 30 March 2018 at 15:11, Daniel Stone <daniels@collabora.com> wrote:
> Now that mtk_drm_fb is an empty wrapper around drm_framebuffer, we can
> just delete it.

Did you get a chance to look at these three patches for Mediatek?

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 19/24] drm/armada: Move GEM BO to drm_framebuffer
  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 14:57     ` Thierry Reding
  1 sibling, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-05-17 13:15 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Russell King, dri-devel

Hi Russell,

On 30 March 2018 at 15:11, Daniel Stone <daniels@collabora.com> wrote:
> 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.

Ping - have you had a chance to look at this?

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 05/24] drm/rockchip: rockchip_drm_fb -> drm_framebuffer
  2018-05-17 13:08     ` Daniel Stone
@ 2018-05-17 13:42       ` Heiko Stübner
  2018-05-17 14:09         ` Daniel Stone
  0 siblings, 1 reply; 73+ messages in thread
From: Heiko Stübner @ 2018-05-17 13:42 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Daniel Stone, dri-devel

Hi Daniel,

Am Donnerstag, 17. Mai 2018, 15:08:15 CEST schrieb Daniel Stone:
> On 30 March 2018 at 15:11, Daniel Stone <daniels@collabora.com> wrote:
> > Now that rockchip_drm_fb is just a wrapper around drm_framebuffer, we
> > can remove it.
> > 
> > Signed-off-by: Daniel Stone <daniels@collabora.com>
> > Cc: Sandy Huang <hjc@rock-chips.com>
> > Cc: Heiko Stübner <heiko@sntech.de>
> 
> Ping?

I only see the cover-letter (not listing all patches of the series)
plus patches 4+5 of the series, nothing else.

Both patches seem to reference other previous patches (1-3?)
so could you point me at mboxes [patchwork] for those?


Thanks
Heiko


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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 13/24] drm/tegra: tegra_fb -> drm_framebuffer
  2018-05-17 13:11     ` Daniel Stone
@ 2018-05-17 13:46       ` Thierry Reding
  0 siblings, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 13:46 UTC (permalink / raw)
  To: Daniel Stone; +Cc: linux-tegra, Daniel Stone, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 632 bytes --]

On Thu, May 17, 2018 at 02:11:16PM +0100, Daniel Stone wrote:
> Hi Thierry,
> 
> On 30 March 2018 at 15:11, Daniel Stone <daniels@collabora.com> wrote:
> > Since tegra_fb is now the same as drm_framebuffer, we can just replace
> > the type completely.
> >
> > Signed-off-by: Daniel Stone <daniels@collabora.com>
> > Cc: Thierry Reding <thierry.reding@gmail.com>
> > Cc: linux-tegra@vger.kernel.org
> 
> Did this still need some more testing, or is it OK to apply?

Sorry, this completely fell off the table. I've tested patches 11-15 and
they work fine. Applied all of them to drm/tegra/for-next.

Thanks,
Thierry

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (23 preceding siblings ...)
  2018-05-17 13:54   ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Thierry Reding
@ 2018-05-17 13:54   ` Thierry Reding
  24 siblings, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 13:54 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Dave Airlie, dri-devel, virtualization


[-- Attachment #1.1: Type: text/plain, Size: 842 bytes --]

On Fri, Mar 30, 2018 at 03:11:15PM +0100, Daniel Stone wrote:
> 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/cirrus/cirrus_drv.h   |  1 -
>  drivers/gpu/drm/cirrus/cirrus_fbdev.c |  8 ++++----
>  drivers/gpu/drm/cirrus/cirrus_main.c  | 25 ++++---------------------
>  drivers/gpu/drm/cirrus/cirrus_mode.c  |  4 ++--
>  4 files changed, 10 insertions(+), 28 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer
  2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
                     ` (22 preceding siblings ...)
  2018-03-30 14:11   ` [PATCH 24/24] drm/amdgpu: Move GEM BO to drm_framebuffer Daniel Stone
@ 2018-05-17 13:54   ` Thierry Reding
  2018-05-17 13:54   ` Thierry Reding
  24 siblings, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 13:54 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Dave Airlie, Gerd Hoffmann, dri-devel, virtualization


[-- Attachment #1.1: Type: text/plain, Size: 842 bytes --]

On Fri, Mar 30, 2018 at 03:11:15PM +0100, Daniel Stone wrote:
> 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/cirrus/cirrus_drv.h   |  1 -
>  drivers/gpu/drm/cirrus/cirrus_fbdev.c |  8 ++++----
>  drivers/gpu/drm/cirrus/cirrus_main.c  | 25 ++++---------------------
>  drivers/gpu/drm/cirrus/cirrus_mode.c  |  4 ++--
>  4 files changed, 10 insertions(+), 28 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 05/24] drm/rockchip: rockchip_drm_fb -> drm_framebuffer
  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:56     ` Sean Paul
  2018-05-17 14:46     ` Thierry Reding
  2 siblings, 0 replies; 73+ messages in thread
From: Sean Paul @ 2018-05-17 13:56 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel

On Fri, Mar 30, 2018 at 03:11:19PM +0100, Daniel Stone wrote:
> Now that rockchip_drm_fb is just a wrapper around drm_framebuffer, we
> can remove it.
> 
> Signed-off-by: Daniel Stone <daniels@collabora.com>

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> Cc: Sandy Huang <hjc@rock-chips.com>
> Cc: Heiko Stübner <heiko@sntech.de>
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.c  | 54 ++++++++++-------------------
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.h  |  3 --
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  4 +--
>  3 files changed, 21 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> index d7083c07c294..a4d0a00abcd9 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> @@ -25,21 +25,6 @@
>  #include "rockchip_drm_gem.h"
>  #include "rockchip_drm_psr.h"
>  
> -#define to_rockchip_fb(x) container_of(x, struct rockchip_drm_fb, fb)
> -
> -struct rockchip_drm_fb {
> -	struct drm_framebuffer fb;
> -};
> -
> -struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,
> -					       unsigned int plane)
> -{
> -	if (plane >= ROCKCHIP_MAX_FB_BUFFER)
> -		return NULL;
> -
> -	return fb->obj[plane];
> -}
> -
>  static int rockchip_drm_fb_dirty(struct drm_framebuffer *fb,
>  				 struct drm_file *file,
>  				 unsigned int flags, unsigned int color,
> @@ -56,41 +41,40 @@ static const struct drm_framebuffer_funcs rockchip_drm_fb_funcs = {
>  	.dirty	       = rockchip_drm_fb_dirty,
>  };
>  
> -static struct rockchip_drm_fb *
> +static struct drm_framebuffer *
>  rockchip_fb_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd,
>  		  struct drm_gem_object **obj, unsigned int num_planes)
>  {
> -	struct rockchip_drm_fb *rockchip_fb;
> +	struct drm_framebuffer *fb;
>  	int ret;
>  	int i;
>  
> -	rockchip_fb = kzalloc(sizeof(*rockchip_fb), GFP_KERNEL);
> -	if (!rockchip_fb)
> +	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
> +	if (!fb)
>  		return ERR_PTR(-ENOMEM);
>  
> -	drm_helper_mode_fill_fb_struct(dev, &rockchip_fb->fb, mode_cmd);
> +	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
>  
>  	for (i = 0; i < num_planes; i++)
> -		rockchip_fb->fb.obj[i] = obj[i];
> +		fb->obj[i] = obj[i];
>  
> -	ret = drm_framebuffer_init(dev, &rockchip_fb->fb,
> -				   &rockchip_drm_fb_funcs);
> +	ret = drm_framebuffer_init(dev, fb, &rockchip_drm_fb_funcs);
>  	if (ret) {
>  		DRM_DEV_ERROR(dev->dev,
>  			      "Failed to initialize framebuffer: %d\n",
>  			      ret);
> -		kfree(rockchip_fb);
> +		kfree(fb);
>  		return ERR_PTR(ret);
>  	}
>  
> -	return rockchip_fb;
> +	return fb;
>  }
>  
>  static struct drm_framebuffer *
>  rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
>  			const struct drm_mode_fb_cmd2 *mode_cmd)
>  {
> -	struct rockchip_drm_fb *rockchip_fb;
> +	struct drm_framebuffer *fb;
>  	struct drm_gem_object *objs[ROCKCHIP_MAX_FB_BUFFER];
>  	struct drm_gem_object *obj;
>  	unsigned int hsub;
> @@ -129,13 +113,13 @@ rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
>  		objs[i] = obj;
>  	}
>  
> -	rockchip_fb = rockchip_fb_alloc(dev, mode_cmd, objs, i);
> -	if (IS_ERR(rockchip_fb)) {
> -		ret = PTR_ERR(rockchip_fb);
> +	fb = rockchip_fb_alloc(dev, mode_cmd, objs, i);
> +	if (IS_ERR(fb)) {
> +		ret = PTR_ERR(fb);
>  		goto err_gem_object_unreference;
>  	}
>  
> -	return &rockchip_fb->fb;
> +	return fb;
>  
>  err_gem_object_unreference:
>  	for (i--; i >= 0; i--)
> @@ -159,13 +143,13 @@ rockchip_drm_framebuffer_init(struct drm_device *dev,
>  			      const struct drm_mode_fb_cmd2 *mode_cmd,
>  			      struct drm_gem_object *obj)
>  {
> -	struct rockchip_drm_fb *rockchip_fb;
> +	struct drm_framebuffer *fb;
>  
> -	rockchip_fb = rockchip_fb_alloc(dev, mode_cmd, &obj, 1);
> -	if (IS_ERR(rockchip_fb))
> -		return ERR_CAST(rockchip_fb);
> +	fb = rockchip_fb_alloc(dev, mode_cmd, &obj, 1);
> +	if (IS_ERR(fb))
> +		return ERR_CAST(fb);
>  
> -	return &rockchip_fb->fb;
> +	return fb;
>  }
>  
>  void rockchip_drm_mode_config_init(struct drm_device *dev)
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.h b/drivers/gpu/drm/rockchip/rockchip_drm_fb.h
> index 2fe47f1ee98f..f1265cb1aee8 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.h
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.h
> @@ -22,7 +22,4 @@ rockchip_drm_framebuffer_init(struct drm_device *dev,
>  void rockchip_drm_framebuffer_fini(struct drm_framebuffer *fb);
>  
>  void rockchip_drm_mode_config_init(struct drm_device *dev);
> -
> -struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,
> -					       unsigned int plane);
>  #endif /* _ROCKCHIP_DRM_FB_H */
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index 53d4afe15278..43d191d42087 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -724,7 +724,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
>  		return;
>  	}
>  
> -	obj = rockchip_fb_get_gem_obj(fb, 0);
> +	obj = fb->obj[0];
>  	rk_obj = to_rockchip_obj(obj);
>  
>  	actual_w = drm_rect_width(src) >> 16;
> @@ -754,7 +754,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
>  		int vsub = drm_format_vert_chroma_subsampling(fb->format->format);
>  		int bpp = fb->format->cpp[1];
>  
> -		uv_obj = rockchip_fb_get_gem_obj(fb, 1);
> +		uv_obj = fb->obj[1];
>  		rk_uv_obj = to_rockchip_obj(uv_obj);
>  
>  		offset = (src->x1 >> 16) * bpp / hsub;
> -- 
> 2.16.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 04/24] drm/rockchip: Place GEM BOs in drm_framebuffer
  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
  1 sibling, 0 replies; 73+ messages in thread
From: Sean Paul @ 2018-05-17 13:57 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel

On Fri, Mar 30, 2018 at 03:11:18PM +0100, Daniel Stone wrote:
> 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>

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> Cc: Sandy Huang <hjc@rock-chips.com>
> Cc: Heiko Stübner <heiko@sntech.de>
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 36 +++++-------------------------
>  1 file changed, 6 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> index e266539e04e5..d7083c07c294 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_atomic.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_gem_framebuffer_helper.h>
>  
>  #include "rockchip_drm_drv.h"
>  #include "rockchip_drm_fb.h"
> @@ -28,40 +29,15 @@
>  
>  struct rockchip_drm_fb {
>  	struct drm_framebuffer fb;
> -	struct drm_gem_object *obj[ROCKCHIP_MAX_FB_BUFFER];
>  };
>  
>  struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,
>  					       unsigned int plane)
>  {
> -	struct rockchip_drm_fb *rk_fb = to_rockchip_fb(fb);
> -
>  	if (plane >= ROCKCHIP_MAX_FB_BUFFER)
>  		return NULL;
>  
> -	return rk_fb->obj[plane];
> -}
> -
> -static void rockchip_drm_fb_destroy(struct drm_framebuffer *fb)
> -{
> -	struct rockchip_drm_fb *rockchip_fb = to_rockchip_fb(fb);
> -	int i;
> -
> -	for (i = 0; i < ROCKCHIP_MAX_FB_BUFFER; i++)
> -		drm_gem_object_put_unlocked(rockchip_fb->obj[i]);
> -
> -	drm_framebuffer_cleanup(fb);
> -	kfree(rockchip_fb);
> -}
> -
> -static int rockchip_drm_fb_create_handle(struct drm_framebuffer *fb,
> -					 struct drm_file *file_priv,
> -					 unsigned int *handle)
> -{
> -	struct rockchip_drm_fb *rockchip_fb = to_rockchip_fb(fb);
> -
> -	return drm_gem_handle_create(file_priv,
> -				     rockchip_fb->obj[0], handle);
> +	return fb->obj[plane];
>  }
>  
>  static int rockchip_drm_fb_dirty(struct drm_framebuffer *fb,
> @@ -75,9 +51,9 @@ static int rockchip_drm_fb_dirty(struct drm_framebuffer *fb,
>  }
>  
>  static const struct drm_framebuffer_funcs rockchip_drm_fb_funcs = {
> -	.destroy	= rockchip_drm_fb_destroy,
> -	.create_handle	= rockchip_drm_fb_create_handle,
> -	.dirty		= rockchip_drm_fb_dirty,
> +	.destroy       = drm_gem_fb_destroy,
> +	.create_handle = drm_gem_fb_create_handle,
> +	.dirty	       = rockchip_drm_fb_dirty,
>  };
>  
>  static struct rockchip_drm_fb *
> @@ -95,7 +71,7 @@ rockchip_fb_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cm
>  	drm_helper_mode_fill_fb_struct(dev, &rockchip_fb->fb, mode_cmd);
>  
>  	for (i = 0; i < num_planes; i++)
> -		rockchip_fb->obj[i] = obj[i];
> +		rockchip_fb->fb.obj[i] = obj[i];
>  
>  	ret = drm_framebuffer_init(dev, &rockchip_fb->fb,
>  				   &rockchip_drm_fb_funcs);
> -- 
> 2.16.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 08/24] drm/mtk: Promote impossible internal error to WARN_ON
  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
  0 siblings, 1 reply; 73+ messages in thread
From: Sean Paul @ 2018-05-17 13:58 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel

On Fri, Mar 30, 2018 at 03:11:22PM +0100, Daniel Stone wrote:
> A FB with no object is something we should be shouting very loudly
> about, not quietly logging as debug.
> 
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: CK Hu <ck.hu@mediatek.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_plane.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> index 2f4b0ffee598..ac010365d88b 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> @@ -95,10 +95,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
>  	if (!fb)
>  		return 0;
>  
> -	if (!mtk_fb_get_gem_obj(fb)) {
> -		DRM_DEBUG_KMS("buffer is null\n");
> -		return -EFAULT;
> -	}
> +	WARN_ON(!mtk_fb_get_gem_obj(fb));

We should presumably still bail out with an error, no?

>  
>  	if (!state->crtc)
>  		return 0;
> -- 
> 2.16.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 09/24] drm/mtk: Move GEM BO to drm_framebuffer
  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
  2 siblings, 0 replies; 73+ messages in thread
From: Sean Paul @ 2018-05-17 13:59 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel

On Fri, Mar 30, 2018 at 03:11:23PM +0100, Daniel Stone wrote:
> 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>

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> Cc: CK Hu <ck.hu@mediatek.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_fb.c    | 38 +++++---------------------------
>  drivers/gpu/drm/mediatek/mtk_drm_fb.h    |  1 -
>  drivers/gpu/drm/mediatek/mtk_drm_plane.c |  4 ++--
>  3 files changed, 7 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> index 0d8d506695f9..f130e37123b5 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> @@ -15,6 +15,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem.h>
> +#include <drm/drm_gem_framebuffer_helper.h>
>  #include <linux/dma-buf.h>
>  #include <linux/reservation.h>
>  
> @@ -30,42 +31,13 @@
>   */
>  struct mtk_drm_fb {
>  	struct drm_framebuffer	base;
> -	/* For now we only support a single plane */
> -	struct drm_gem_object	*gem_obj;
>  };
>  
>  #define to_mtk_fb(x) container_of(x, struct mtk_drm_fb, base)
>  
> -struct drm_gem_object *mtk_fb_get_gem_obj(struct drm_framebuffer *fb)
> -{
> -	struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb);
> -
> -	return mtk_fb->gem_obj;
> -}
> -
> -static int mtk_drm_fb_create_handle(struct drm_framebuffer *fb,
> -				    struct drm_file *file_priv,
> -				    unsigned int *handle)
> -{
> -	struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb);
> -
> -	return drm_gem_handle_create(file_priv, mtk_fb->gem_obj, handle);
> -}
> -
> -static void mtk_drm_fb_destroy(struct drm_framebuffer *fb)
> -{
> -	struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb);
> -
> -	drm_framebuffer_cleanup(fb);
> -
> -	drm_gem_object_put_unlocked(mtk_fb->gem_obj);
> -
> -	kfree(mtk_fb);
> -}
> -
>  static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = {
> -	.create_handle = mtk_drm_fb_create_handle,
> -	.destroy = mtk_drm_fb_destroy,
> +	.create_handle = drm_gem_fb_create_handle,
> +	.destroy = drm_gem_fb_destroy,
>  };
>  
>  static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev,
> @@ -84,7 +56,7 @@ static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev,
>  
>  	drm_helper_mode_fill_fb_struct(dev, &mtk_fb->base, mode);
>  
> -	mtk_fb->gem_obj = obj;
> +	mtk_fb->base.obj[0] = obj;
>  
>  	ret = drm_framebuffer_init(dev, &mtk_fb->base, &mtk_drm_fb_funcs);
>  	if (ret) {
> @@ -110,7 +82,7 @@ int mtk_fb_wait(struct drm_framebuffer *fb)
>  	if (!fb)
>  		return 0;
>  
> -	gem = mtk_fb_get_gem_obj(fb);
> +	gem = fb->obj[0];
>  	if (!gem || !gem->dma_buf || !gem->dma_buf->resv)
>  		return 0;
>  
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.h b/drivers/gpu/drm/mediatek/mtk_drm_fb.h
> index 9b2ae345a4e9..7f976b196a15 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.h
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.h
> @@ -14,7 +14,6 @@
>  #ifndef MTK_DRM_FB_H
>  #define MTK_DRM_FB_H
>  
> -struct drm_gem_object *mtk_fb_get_gem_obj(struct drm_framebuffer *fb);
>  int mtk_fb_wait(struct drm_framebuffer *fb);
>  struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
>  					       struct drm_file *file,
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> index ac010365d88b..5370f926e63d 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> @@ -95,7 +95,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
>  	if (!fb)
>  		return 0;
>  
> -	WARN_ON(!mtk_fb_get_gem_obj(fb));
> +	WARN_ON(!fb->obj[0]);
>  
>  	if (!state->crtc)
>  		return 0;
> @@ -124,7 +124,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
>  	if (!crtc || WARN_ON(!fb))
>  		return;
>  
> -	gem = mtk_fb_get_gem_obj(fb);
> +	gem = fb->obj[0];
>  	mtk_gem = to_mtk_gem_obj(gem);
>  	addr = mtk_gem->dma_addr;
>  	pitch = fb->pitches[0];
> -- 
> 2.16.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 10/24] drm/mtk: mtk_drm_fb -> drm_framebuffer
  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
  3 siblings, 0 replies; 73+ messages in thread
From: Sean Paul @ 2018-05-17 13:59 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel

On Fri, Mar 30, 2018 at 03:11:24PM +0100, Daniel Stone wrote:
> Now that mtk_drm_fb is an empty wrapper around drm_framebuffer, we can
> just delete it.
> 
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: CK Hu <ck.hu@mediatek.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> ---
>  drivers/gpu/drm/mediatek/mtk_drm_fb.c | 40 ++++++++++++-----------------------
>  1 file changed, 14 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> index f130e37123b5..be5f6f1daf55 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> @@ -23,49 +23,37 @@
>  #include "mtk_drm_fb.h"
>  #include "mtk_drm_gem.h"
>  
> -/*
> - * mtk specific framebuffer structure.
> - *
> - * @fb: drm framebuffer object.
> - * @gem_obj: array of gem objects.
> - */
> -struct mtk_drm_fb {
> -	struct drm_framebuffer	base;
> -};
> -
> -#define to_mtk_fb(x) container_of(x, struct mtk_drm_fb, base)
> -
>  static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = {
>  	.create_handle = drm_gem_fb_create_handle,
>  	.destroy = drm_gem_fb_destroy,
>  };
>  
> -static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev,
> +static struct drm_framebuffer *mtk_drm_framebuffer_init(struct drm_device *dev,
>  					const struct drm_mode_fb_cmd2 *mode,
>  					struct drm_gem_object *obj)
>  {
> -	struct mtk_drm_fb *mtk_fb;
> +	struct drm_framebuffer *fb;
>  	int ret;
>  
>  	if (drm_format_num_planes(mode->pixel_format) != 1)
>  		return ERR_PTR(-EINVAL);
>  
> -	mtk_fb = kzalloc(sizeof(*mtk_fb), GFP_KERNEL);
> -	if (!mtk_fb)
> +	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
> +	if (!fb)
>  		return ERR_PTR(-ENOMEM);
>  
> -	drm_helper_mode_fill_fb_struct(dev, &mtk_fb->base, mode);
> +	drm_helper_mode_fill_fb_struct(dev, fb, mode);
>  
> -	mtk_fb->base.obj[0] = obj;
> +	fb->obj[0] = obj;
>  
> -	ret = drm_framebuffer_init(dev, &mtk_fb->base, &mtk_drm_fb_funcs);
> +	ret = drm_framebuffer_init(dev, fb, &mtk_drm_fb_funcs);
>  	if (ret) {
>  		DRM_ERROR("failed to initialize framebuffer\n");
> -		kfree(mtk_fb);
> +		kfree(fb);
>  		return ERR_PTR(ret);
>  	}
>  
> -	return mtk_fb;
> +	return fb;
>  }
>  
>  /*
> @@ -100,7 +88,7 @@ struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
>  					       struct drm_file *file,
>  					       const struct drm_mode_fb_cmd2 *cmd)
>  {
> -	struct mtk_drm_fb *mtk_fb;
> +	struct drm_framebuffer *fb;
>  	struct drm_gem_object *gem;
>  	unsigned int width = cmd->width;
>  	unsigned int height = cmd->height;
> @@ -123,13 +111,13 @@ struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
>  		goto unreference;
>  	}
>  
> -	mtk_fb = mtk_drm_framebuffer_init(dev, cmd, gem);
> -	if (IS_ERR(mtk_fb)) {
> -		ret = PTR_ERR(mtk_fb);
> +	fb = mtk_drm_framebuffer_init(dev, cmd, gem);
> +	if (IS_ERR(fb)) {
> +		ret = PTR_ERR(fb);
>  		goto unreference;
>  	}
>  
> -	return &mtk_fb->base;
> +	return fb;
>  
>  unreference:
>  	drm_gem_object_put_unlocked(gem);
> -- 
> 2.16.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 05/24] drm/rockchip: rockchip_drm_fb -> drm_framebuffer
  2018-05-17 13:42       ` Heiko Stübner
@ 2018-05-17 14:09         ` Daniel Stone
  0 siblings, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-05-17 14:09 UTC (permalink / raw)
  To: Heiko Stübner; +Cc: dri-devel

Hi Heiko,

On 17 May 2018 at 14:42, Heiko Stübner <heiko@sntech.de> wrote:
> Am Donnerstag, 17. Mai 2018, 15:08:15 CEST schrieb Daniel Stone:
>> On 30 March 2018 at 15:11, Daniel Stone <daniels@collabora.com> wrote:
>> > Now that rockchip_drm_fb is just a wrapper around drm_framebuffer, we
>> > can remove it.
>> >
>> > Signed-off-by: Daniel Stone <daniels@collabora.com>
>> > Cc: Sandy Huang <hjc@rock-chips.com>
>> > Cc: Heiko Stübner <heiko@sntech.de>
>>
>> Ping?
>
> I only see the cover-letter (not listing all patches of the series)
> plus patches 4+5 of the series, nothing else.
>
> Both patches seem to reference other previous patches (1-3?)
> so could you point me at mboxes [patchwork] for those?

The series is available at:
https://patchwork.freedesktop.org/series/40944/

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 02/24] drm/cirrus: cirrus_framebuffer -> drm_framebuffer
  2018-03-30 14:11   ` [PATCH 02/24] drm/cirrus: cirrus_framebuffer -> drm_framebuffer Daniel Stone
  2018-05-17 14:25     ` Thierry Reding
@ 2018-05-17 14:25     ` Thierry Reding
  1 sibling, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:25 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Dave Airlie, dri-devel, virtualization


[-- Attachment #1.1: Type: text/plain, Size: 713 bytes --]

On Fri, Mar 30, 2018 at 03:11:16PM +0100, Daniel Stone wrote:
> Now cirrus_framebuffer is just an empty wrapper around drm_framebuffer,
> we can drop it.
> 
> 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/cirrus/cirrus_drv.h   |  9 ++-------
>  drivers/gpu/drm/cirrus/cirrus_fbdev.c | 20 ++++++++++----------
>  drivers/gpu/drm/cirrus/cirrus_main.c  | 20 ++++++++++----------
>  drivers/gpu/drm/cirrus/cirrus_mode.c  | 12 +++---------
>  4 files changed, 25 insertions(+), 36 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 02/24] drm/cirrus: cirrus_framebuffer -> drm_framebuffer
  2018-03-30 14:11   ` [PATCH 02/24] drm/cirrus: cirrus_framebuffer -> drm_framebuffer Daniel Stone
@ 2018-05-17 14:25     ` Thierry Reding
  2018-05-17 14:25     ` Thierry Reding
  1 sibling, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:25 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Dave Airlie, Gerd Hoffmann, dri-devel, virtualization


[-- Attachment #1.1: Type: text/plain, Size: 713 bytes --]

On Fri, Mar 30, 2018 at 03:11:16PM +0100, Daniel Stone wrote:
> Now cirrus_framebuffer is just an empty wrapper around drm_framebuffer,
> we can drop it.
> 
> 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/cirrus/cirrus_drv.h   |  9 ++-------
>  drivers/gpu/drm/cirrus/cirrus_fbdev.c | 20 ++++++++++----------
>  drivers/gpu/drm/cirrus/cirrus_main.c  | 20 ++++++++++----------
>  drivers/gpu/drm/cirrus/cirrus_mode.c  | 12 +++---------
>  4 files changed, 25 insertions(+), 36 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 03/24] drm/virtio: Place GEM BOs in drm_framebuffer
  2018-03-30 14:11   ` [PATCH 03/24] drm/virtio: Place GEM BOs in drm_framebuffer Daniel Stone
  2018-05-17 14:29     ` Thierry Reding
@ 2018-05-17 14:29     ` Thierry Reding
  1 sibling, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:29 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Dave Airlie, dri-devel, virtualization


[-- Attachment #1.1: Type: text/plain, Size: 859 bytes --]

On Fri, Mar 30, 2018 at 03:11:17PM +0100, Daniel Stone wrote:
> 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(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 03/24] drm/virtio: Place GEM BOs in drm_framebuffer
  2018-03-30 14:11   ` [PATCH 03/24] drm/virtio: Place GEM BOs in drm_framebuffer Daniel Stone
@ 2018-05-17 14:29     ` Thierry Reding
  2018-05-17 14:29     ` Thierry Reding
  1 sibling, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:29 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Dave Airlie, Gerd Hoffmann, dri-devel, virtualization


[-- Attachment #1.1: Type: text/plain, Size: 859 bytes --]

On Fri, Mar 30, 2018 at 03:11:17PM +0100, Daniel Stone wrote:
> 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(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 05/24] drm/rockchip: rockchip_drm_fb -> drm_framebuffer
  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:56     ` Sean Paul
@ 2018-05-17 14:46     ` Thierry Reding
  2 siblings, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:46 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 3604 bytes --]

On Fri, Mar 30, 2018 at 03:11:19PM +0100, Daniel Stone wrote:
> Now that rockchip_drm_fb is just a wrapper around drm_framebuffer, we
> can remove it.
> 
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: Sandy Huang <hjc@rock-chips.com>
> Cc: Heiko Stübner <heiko@sntech.de>
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.c  | 54 ++++++++++-------------------
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.h  |  3 --
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  4 +--
>  3 files changed, 21 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> index d7083c07c294..a4d0a00abcd9 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> @@ -25,21 +25,6 @@
>  #include "rockchip_drm_gem.h"
>  #include "rockchip_drm_psr.h"
>  
> -#define to_rockchip_fb(x) container_of(x, struct rockchip_drm_fb, fb)
> -
> -struct rockchip_drm_fb {
> -	struct drm_framebuffer fb;
> -};
> -
> -struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,
> -					       unsigned int plane)
> -{
> -	if (plane >= ROCKCHIP_MAX_FB_BUFFER)
> -		return NULL;
> -
> -	return fb->obj[plane];
> -}
> -
>  static int rockchip_drm_fb_dirty(struct drm_framebuffer *fb,
>  				 struct drm_file *file,
>  				 unsigned int flags, unsigned int color,
> @@ -56,41 +41,40 @@ static const struct drm_framebuffer_funcs rockchip_drm_fb_funcs = {
>  	.dirty	       = rockchip_drm_fb_dirty,
>  };
>  
> -static struct rockchip_drm_fb *
> +static struct drm_framebuffer *
>  rockchip_fb_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd,
>  		  struct drm_gem_object **obj, unsigned int num_planes)
>  {
> -	struct rockchip_drm_fb *rockchip_fb;
> +	struct drm_framebuffer *fb;
>  	int ret;
>  	int i;
>  
> -	rockchip_fb = kzalloc(sizeof(*rockchip_fb), GFP_KERNEL);
> -	if (!rockchip_fb)
> +	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
> +	if (!fb)
>  		return ERR_PTR(-ENOMEM);
>  
> -	drm_helper_mode_fill_fb_struct(dev, &rockchip_fb->fb, mode_cmd);
> +	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
>  
>  	for (i = 0; i < num_planes; i++)
> -		rockchip_fb->fb.obj[i] = obj[i];
> +		fb->obj[i] = obj[i];
>  
> -	ret = drm_framebuffer_init(dev, &rockchip_fb->fb,
> -				   &rockchip_drm_fb_funcs);
> +	ret = drm_framebuffer_init(dev, fb, &rockchip_drm_fb_funcs);
>  	if (ret) {
>  		DRM_DEV_ERROR(dev->dev,
>  			      "Failed to initialize framebuffer: %d\n",
>  			      ret);
> -		kfree(rockchip_fb);
> +		kfree(fb);
>  		return ERR_PTR(ret);
>  	}
>  
> -	return rockchip_fb;
> +	return fb;
>  }
>  
>  static struct drm_framebuffer *
>  rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
>  			const struct drm_mode_fb_cmd2 *mode_cmd)
>  {
> -	struct rockchip_drm_fb *rockchip_fb;
> +	struct drm_framebuffer *fb;
>  	struct drm_gem_object *objs[ROCKCHIP_MAX_FB_BUFFER];

The use of the ROCKCHIP_MAX_FB_BUFFER seems somewhat misguided here.
What if a given pixel format requires 4 planes? This function will just
silently ignore the last plane. Not sure that's a good idea. Currently I
don't know of any formats that require 4 planes, so this is probably not
an issue, but there's also no reason to limit this to anything less than
the 4 planes that's baked into the KMS ABI everywhere.

Anyway, just a random comment and it doesn't have anything to do with
this series, so:

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 04/24] drm/rockchip: Place GEM BOs in drm_framebuffer
  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
  1 sibling, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:47 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 643 bytes --]

On Fri, Mar 30, 2018 at 03:11:18PM +0100, Daniel Stone wrote:
> 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: Sandy Huang <hjc@rock-chips.com>
> Cc: Heiko Stübner <heiko@sntech.de>
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 36 +++++-------------------------
>  1 file changed, 6 insertions(+), 30 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 06/24] drm/omap: Move GEM BO to drm_framebuffer
  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
  1 sibling, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:47 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 610 bytes --]

On Fri, Mar 30, 2018 at 03:11:20PM +0100, Daniel Stone wrote:
> 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: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_fb.c | 60 ++++++++++-----------------------------
>  1 file changed, 15 insertions(+), 45 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 07/24] drm/omap: Move buffer pitch/offset to drm_framebuffer
  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 14:49     ` Thierry Reding
  1 sibling, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:49 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Tomi Valkeinen, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 514 bytes --]

On Fri, Mar 30, 2018 at 03:11:21PM +0100, Daniel Stone wrote:
> drm_framebuffer already holds per-plane pitch and offsets, which is
> filled out for us when we create the framebuffer. Nuke our local copy in
> the plane struct.
> 
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_fb.c | 22 +++++++++-------------
>  1 file changed, 9 insertions(+), 13 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 08/24] drm/mtk: Promote impossible internal error to WARN_ON
  2018-05-17 13:58     ` Sean Paul
@ 2018-05-17 14:55       ` Thierry Reding
  2018-05-18  8:06         ` CK Hu
  0 siblings, 1 reply; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:55 UTC (permalink / raw)
  To: Sean Paul; +Cc: Daniel Stone, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1469 bytes --]

On Thu, May 17, 2018 at 09:58:19AM -0400, Sean Paul wrote:
> On Fri, Mar 30, 2018 at 03:11:22PM +0100, Daniel Stone wrote:
> > A FB with no object is something we should be shouting very loudly
> > about, not quietly logging as debug.
> > 
> > Signed-off-by: Daniel Stone <daniels@collabora.com>
> > Cc: CK Hu <ck.hu@mediatek.com>
> > Cc: Philipp Zabel <p.zabel@pengutronix.de>
> > ---
> >  drivers/gpu/drm/mediatek/mtk_drm_plane.c | 5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> > index 2f4b0ffee598..ac010365d88b 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> > @@ -95,10 +95,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
> >  	if (!fb)
> >  		return 0;
> >  
> > -	if (!mtk_fb_get_gem_obj(fb)) {
> > -		DRM_DEBUG_KMS("buffer is null\n");
> > -		return -EFAULT;
> > -	}
> > +	WARN_ON(!mtk_fb_get_gem_obj(fb));
> 
> We should presumably still bail out with an error, no?

I think we should just remove this WARN_ON(). Under what circumstances
would this case even happen? If the GEM object for a framebuffer doesn't
exist, then mtk_drm_mode_fb_create() will fail and no pointer to struct
drm_framebuffer will ever be returned. After that, the GEM object is
guaranteed to be there, so the above is effectively dead code.

Thierry

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 09/24] drm/mtk: Move GEM BO to drm_framebuffer
  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
  2 siblings, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:55 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 751 bytes --]

On Fri, Mar 30, 2018 at 03:11:23PM +0100, Daniel Stone wrote:
> 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: CK Hu <ck.hu@mediatek.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_fb.c    | 38 +++++---------------------------
>  drivers/gpu/drm/mediatek/mtk_drm_fb.h    |  1 -
>  drivers/gpu/drm/mediatek/mtk_drm_plane.c |  4 ++--
>  3 files changed, 7 insertions(+), 36 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 10/24] drm/mtk: mtk_drm_fb -> drm_framebuffer
  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
  3 siblings, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:56 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 491 bytes --]

On Fri, Mar 30, 2018 at 03:11:24PM +0100, Daniel Stone wrote:
> Now that mtk_drm_fb is an empty wrapper around drm_framebuffer, we can
> just delete it.
> 
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: CK Hu <ck.hu@mediatek.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_fb.c | 40 ++++++++++++-----------------------
>  1 file changed, 14 insertions(+), 26 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 19/24] drm/armada: Move GEM BO to drm_framebuffer
  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 14:57     ` Thierry Reding
  1 sibling, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 14:57 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Russell King, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 641 bytes --]

On Fri, Mar 30, 2018 at 03:11:33PM +0100, Daniel Stone wrote:
> 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: Russell King <linux@armlinux.org.uk>
> ---
>  drivers/gpu/drm/armada/armada_fb.c | 23 ++++-------------------
>  drivers/gpu/drm/armada/armada_fb.h |  3 +--
>  2 files changed, 5 insertions(+), 21 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 20/24] drm/gma500: Move GEM BO to drm_framebuffer
  2018-03-30 14:11   ` [PATCH 20/24] drm/gma500: " Daniel Stone
@ 2018-05-17 15:03     ` Thierry Reding
  0 siblings, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 15:03 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 878 bytes --]

On Fri, Mar 30, 2018 at 03:11:34PM +0100, Daniel Stone wrote:
> 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: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> ---
>  drivers/gpu/drm/gma500/accel_2d.c      |  2 +-
>  drivers/gpu/drm/gma500/framebuffer.c   | 62 ++++++----------------------------
>  drivers/gpu/drm/gma500/framebuffer.h   |  1 -
>  drivers/gpu/drm/gma500/gma_display.c   | 10 +++---
>  drivers/gpu/drm/gma500/gtt.h           |  2 ++
>  drivers/gpu/drm/gma500/oaktrail_crtc.c |  3 +-
>  6 files changed, 20 insertions(+), 60 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 21/24] drm/msm: Move GEM BOs to drm_framebuffer
  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
  1 sibling, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 15:05 UTC (permalink / raw)
  To: Daniel Stone; +Cc: linux-arm-msm, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 626 bytes --]

On Fri, Mar 30, 2018 at 03:11:35PM +0100, Daniel Stone wrote:
> 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 function the same as the GEM framebuffer helper, we
> can reuse that.
> 
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: linux-arm-msm@vger.kernel.org
> ---
>  drivers/gpu/drm/msm/msm_fb.c | 54 +++++++++-----------------------------------
>  1 file changed, 11 insertions(+), 43 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 22/24] drm/radeon: Move GEM BO to drm_framebuffer
       [not found]     ` <20180330141138.28987-22-daniels-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
@ 2018-05-17 15:06       ` Thierry Reding
  0 siblings, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 15:06 UTC (permalink / raw)
  To: Daniel Stone
  Cc: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	Christian König, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 1201 bytes --]

On Fri, Mar 30, 2018 at 03:11:36PM +0100, Daniel Stone wrote:
> 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-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
> Cc: Alex Deucher <alexander.deucher-5C7GfCeVMHo@public.gmane.org>
> Cc: Christian König <christian.koenig-5C7GfCeVMHo@public.gmane.org>
> Cc: David (ChunMing) Zhou <David1.Zhou-5C7GfCeVMHo@public.gmane.org>
> Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> ---
>  drivers/gpu/drm/radeon/atombios_crtc.c      | 10 +++++-----
>  drivers/gpu/drm/radeon/radeon_device.c      |  4 ++--
>  drivers/gpu/drm/radeon/radeon_display.c     | 31 +++++++----------------------
>  drivers/gpu/drm/radeon/radeon_fb.c          |  8 ++++----
>  drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 11 ++++------
>  drivers/gpu/drm/radeon/radeon_mode.h        |  1 -
>  6 files changed, 22 insertions(+), 43 deletions(-)

Reviewed-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 23/24] drm/radeon: radeon_framebuffer -> drm_framebuffer
  2018-03-30 14:11     ` [PATCH 23/24] drm/radeon: radeon_framebuffer -> drm_framebuffer Daniel Stone
@ 2018-05-17 15:07       ` Thierry Reding
  0 siblings, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 15:07 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Alex Deucher, amd-gfx, Christian König, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1090 bytes --]

On Fri, Mar 30, 2018 at 03:11:37PM +0100, Daniel Stone wrote:
> 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: Alex Deucher <alexander.deucher@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: David (ChunMing) Zhou <David1.Zhou@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> ---
>  drivers/gpu/drm/radeon/atombios_crtc.c      | 32 ++++++++---------------------
>  drivers/gpu/drm/radeon/radeon_device.c      |  6 +++---
>  drivers/gpu/drm/radeon/radeon_display.c     | 30 ++++++++++++---------------
>  drivers/gpu/drm/radeon/radeon_fb.c          | 20 +++++++++---------
>  drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 11 +++-------
>  drivers/gpu/drm/radeon/radeon_mode.h        |  7 +------
>  6 files changed, 39 insertions(+), 67 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 24/24] drm/amdgpu: Move GEM BO to drm_framebuffer
  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
  0 siblings, 0 replies; 73+ messages in thread
From: Thierry Reding @ 2018-05-17 15:08 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Alex Deucher, amd-gfx, Christian König, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1359 bytes --]

On Fri, Mar 30, 2018 at 03:11:38PM +0100, Daniel Stone wrote:
> 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: Alex Deucher <alexander.deucher@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: David (ChunMing) Zhou <David1.Zhou@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |  6 ++--
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 36 +++++------------------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 +++----
>  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h          |  1 -
>  drivers/gpu/drm/amd/amdgpu/dce_v10_0.c            | 17 ++++-------
>  drivers/gpu/drm/amd/amdgpu/dce_v11_0.c            | 17 ++++-------
>  drivers/gpu/drm/amd/amdgpu/dce_v6_0.c             | 17 ++++-------
>  drivers/gpu/drm/amd/amdgpu/dce_v8_0.c             | 17 ++++-------
>  drivers/gpu/drm/amd/amdgpu/dce_virtual.c          |  4 +--
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 +++----
>  10 files changed, 40 insertions(+), 96 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 19/24] drm/armada: Move GEM BO to drm_framebuffer
  2018-05-17 13:15     ` Daniel Stone
@ 2018-05-17 15:26       ` Russell King - ARM Linux
  2018-05-17 15:41         ` Daniel Stone
  0 siblings, 1 reply; 73+ messages in thread
From: Russell King - ARM Linux @ 2018-05-17 15:26 UTC (permalink / raw)
  To: Daniel Stone; +Cc: Daniel Stone, dri-devel

On Thu, May 17, 2018 at 02:15:40PM +0100, Daniel Stone wrote:
> Hi Russell,
> 
> On 30 March 2018 at 15:11, Daniel Stone <daniels@collabora.com> wrote:
> > 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.
> 
> Ping - have you had a chance to look at this?

I haven't, I've not moved any of my trees off 4.16 yet as I've been
away on vacation, and also busy dealing with Spectre for 32-bit ARM.

From a quick look, it seems fine, and as I guess the autobuilders
haven't complained, it probably builds okay.  So it can probably
be merged without much risk - if there are any problems I'll sort it
out later.

Acked-by: Russell King <rmk+kernel@armlinux.org.uk>

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 19/24] drm/armada: Move GEM BO to drm_framebuffer
  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
  0 siblings, 1 reply; 73+ messages in thread
From: Daniel Stone @ 2018-05-17 15:41 UTC (permalink / raw)
  To: Russell King - ARM Linux; +Cc: dri-devel

On 17 May 2018 at 16:26, Russell King - ARM Linux <linux@armlinux.org.uk> wrote:
> On Thu, May 17, 2018 at 02:15:40PM +0100, Daniel Stone wrote:
>> On 30 March 2018 at 15:11, Daniel Stone <daniels@collabora.com> wrote:
>> > 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.
>>
>> Ping - have you had a chance to look at this?
>
> I haven't, I've not moved any of my trees off 4.16 yet as I've been
> away on vacation, and also busy dealing with Spectre for 32-bit ARM.
>
> From a quick look, it seems fine, and as I guess the autobuilders
> haven't complained, it probably builds okay.  So it can probably
> be merged without much risk - if there are any problems I'll sort it
> out later.

Thanks Russell. I did do a build test locally as well which had no
complaints. I'll merge this through drm-misc.

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 08/24] drm/mtk: Promote impossible internal error to WARN_ON
  2018-05-17 14:55       ` Thierry Reding
@ 2018-05-18  8:06         ` CK Hu
  0 siblings, 0 replies; 73+ messages in thread
From: CK Hu @ 2018-05-18  8:06 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Daniel Stone, dri-devel

On Thu, 2018-05-17 at 16:55 +0200, Thierry Reding wrote:
> On Thu, May 17, 2018 at 09:58:19AM -0400, Sean Paul wrote:
> > On Fri, Mar 30, 2018 at 03:11:22PM +0100, Daniel Stone wrote:
> > > A FB with no object is something we should be shouting very loudly
> > > about, not quietly logging as debug.
> > > 
> > > Signed-off-by: Daniel Stone <daniels@collabora.com>
> > > Cc: CK Hu <ck.hu@mediatek.com>
> > > Cc: Philipp Zabel <p.zabel@pengutronix.de>
> > > ---
> > >  drivers/gpu/drm/mediatek/mtk_drm_plane.c | 5 +----
> > >  1 file changed, 1 insertion(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> > > index 2f4b0ffee598..ac010365d88b 100644
> > > --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> > > +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> > > @@ -95,10 +95,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
> > >  	if (!fb)
> > >  		return 0;
> > >  
> > > -	if (!mtk_fb_get_gem_obj(fb)) {
> > > -		DRM_DEBUG_KMS("buffer is null\n");
> > > -		return -EFAULT;
> > > -	}
> > > +	WARN_ON(!mtk_fb_get_gem_obj(fb));
> > 
> > We should presumably still bail out with an error, no?
> 
> I think we should just remove this WARN_ON(). Under what circumstances
> would this case even happen? If the GEM object for a framebuffer doesn't
> exist, then mtk_drm_mode_fb_create() will fail and no pointer to struct
> drm_framebuffer will ever be returned. After that, the GEM object is
> guaranteed to be there, so the above is effectively dead code.
> 
> Thierry

I agree with Thierry. The case should not happen. So just remove this
checking.

Regards,
CK

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


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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 09/24] drm/mtk: Move GEM BO to drm_framebuffer
  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
  2 siblings, 0 replies; 73+ messages in thread
From: CK Hu @ 2018-05-18  8:32 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel

On Fri, 2018-03-30 at 22:11 +0800, Daniel Stone wrote:
> 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.
> 

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: CK Hu <ck.hu@mediatek.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_fb.c    | 38 +++++---------------------------
>  drivers/gpu/drm/mediatek/mtk_drm_fb.h    |  1 -
>  drivers/gpu/drm/mediatek/mtk_drm_plane.c |  4 ++--
>  3 files changed, 7 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> index 0d8d506695f9..f130e37123b5 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> @@ -15,6 +15,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem.h>
> +#include <drm/drm_gem_framebuffer_helper.h>
>  #include <linux/dma-buf.h>
>  #include <linux/reservation.h>
>  
> @@ -30,42 +31,13 @@
>   */
>  struct mtk_drm_fb {
>  	struct drm_framebuffer	base;
> -	/* For now we only support a single plane */
> -	struct drm_gem_object	*gem_obj;
>  };
>  
>  #define to_mtk_fb(x) container_of(x, struct mtk_drm_fb, base)
>  
> -struct drm_gem_object *mtk_fb_get_gem_obj(struct drm_framebuffer *fb)
> -{
> -	struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb);
> -
> -	return mtk_fb->gem_obj;
> -}
> -
> -static int mtk_drm_fb_create_handle(struct drm_framebuffer *fb,
> -				    struct drm_file *file_priv,
> -				    unsigned int *handle)
> -{
> -	struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb);
> -
> -	return drm_gem_handle_create(file_priv, mtk_fb->gem_obj, handle);
> -}
> -
> -static void mtk_drm_fb_destroy(struct drm_framebuffer *fb)
> -{
> -	struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb);
> -
> -	drm_framebuffer_cleanup(fb);
> -
> -	drm_gem_object_put_unlocked(mtk_fb->gem_obj);
> -
> -	kfree(mtk_fb);
> -}
> -
>  static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = {
> -	.create_handle = mtk_drm_fb_create_handle,
> -	.destroy = mtk_drm_fb_destroy,
> +	.create_handle = drm_gem_fb_create_handle,
> +	.destroy = drm_gem_fb_destroy,
>  };
>  
>  static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev,
> @@ -84,7 +56,7 @@ static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev,
>  
>  	drm_helper_mode_fill_fb_struct(dev, &mtk_fb->base, mode);
>  
> -	mtk_fb->gem_obj = obj;
> +	mtk_fb->base.obj[0] = obj;
>  
>  	ret = drm_framebuffer_init(dev, &mtk_fb->base, &mtk_drm_fb_funcs);
>  	if (ret) {
> @@ -110,7 +82,7 @@ int mtk_fb_wait(struct drm_framebuffer *fb)
>  	if (!fb)
>  		return 0;
>  
> -	gem = mtk_fb_get_gem_obj(fb);
> +	gem = fb->obj[0];
>  	if (!gem || !gem->dma_buf || !gem->dma_buf->resv)
>  		return 0;
>  
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.h b/drivers/gpu/drm/mediatek/mtk_drm_fb.h
> index 9b2ae345a4e9..7f976b196a15 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.h
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.h
> @@ -14,7 +14,6 @@
>  #ifndef MTK_DRM_FB_H
>  #define MTK_DRM_FB_H
>  
> -struct drm_gem_object *mtk_fb_get_gem_obj(struct drm_framebuffer *fb);
>  int mtk_fb_wait(struct drm_framebuffer *fb);
>  struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
>  					       struct drm_file *file,
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> index ac010365d88b..5370f926e63d 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> @@ -95,7 +95,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
>  	if (!fb)
>  		return 0;
>  
> -	WARN_ON(!mtk_fb_get_gem_obj(fb));
> +	WARN_ON(!fb->obj[0]);
>  
>  	if (!state->crtc)
>  		return 0;
> @@ -124,7 +124,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
>  	if (!crtc || WARN_ON(!fb))
>  		return;
>  
> -	gem = mtk_fb_get_gem_obj(fb);
> +	gem = fb->obj[0];
>  	mtk_gem = to_mtk_gem_obj(gem);
>  	addr = mtk_gem->dma_addr;
>  	pitch = fb->pitches[0];


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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 10/24] drm/mtk: mtk_drm_fb -> drm_framebuffer
  2018-03-30 14:11   ` [PATCH 10/24] drm/mtk: mtk_drm_fb -> drm_framebuffer Daniel Stone
                       ` (2 preceding siblings ...)
  2018-05-17 14:56     ` Thierry Reding
@ 2018-05-18  8:37     ` CK Hu
  3 siblings, 0 replies; 73+ messages in thread
From: CK Hu @ 2018-05-18  8:37 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel

On Fri, 2018-03-30 at 22:11 +0800, Daniel Stone wrote:
> Now that mtk_drm_fb is an empty wrapper around drm_framebuffer, we can
> just delete it.
> 

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Cc: CK Hu <ck.hu@mediatek.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_fb.c | 40 ++++++++++++-----------------------
>  1 file changed, 14 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> index f130e37123b5..be5f6f1daf55 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> @@ -23,49 +23,37 @@
>  #include "mtk_drm_fb.h"
>  #include "mtk_drm_gem.h"
>  
> -/*
> - * mtk specific framebuffer structure.
> - *
> - * @fb: drm framebuffer object.
> - * @gem_obj: array of gem objects.
> - */
> -struct mtk_drm_fb {
> -	struct drm_framebuffer	base;
> -};
> -
> -#define to_mtk_fb(x) container_of(x, struct mtk_drm_fb, base)
> -
>  static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = {
>  	.create_handle = drm_gem_fb_create_handle,
>  	.destroy = drm_gem_fb_destroy,
>  };
>  
> -static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev,
> +static struct drm_framebuffer *mtk_drm_framebuffer_init(struct drm_device *dev,
>  					const struct drm_mode_fb_cmd2 *mode,
>  					struct drm_gem_object *obj)
>  {
> -	struct mtk_drm_fb *mtk_fb;
> +	struct drm_framebuffer *fb;
>  	int ret;
>  
>  	if (drm_format_num_planes(mode->pixel_format) != 1)
>  		return ERR_PTR(-EINVAL);
>  
> -	mtk_fb = kzalloc(sizeof(*mtk_fb), GFP_KERNEL);
> -	if (!mtk_fb)
> +	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
> +	if (!fb)
>  		return ERR_PTR(-ENOMEM);
>  
> -	drm_helper_mode_fill_fb_struct(dev, &mtk_fb->base, mode);
> +	drm_helper_mode_fill_fb_struct(dev, fb, mode);
>  
> -	mtk_fb->base.obj[0] = obj;
> +	fb->obj[0] = obj;
>  
> -	ret = drm_framebuffer_init(dev, &mtk_fb->base, &mtk_drm_fb_funcs);
> +	ret = drm_framebuffer_init(dev, fb, &mtk_drm_fb_funcs);
>  	if (ret) {
>  		DRM_ERROR("failed to initialize framebuffer\n");
> -		kfree(mtk_fb);
> +		kfree(fb);
>  		return ERR_PTR(ret);
>  	}
>  
> -	return mtk_fb;
> +	return fb;
>  }
>  
>  /*
> @@ -100,7 +88,7 @@ struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
>  					       struct drm_file *file,
>  					       const struct drm_mode_fb_cmd2 *cmd)
>  {
> -	struct mtk_drm_fb *mtk_fb;
> +	struct drm_framebuffer *fb;
>  	struct drm_gem_object *gem;
>  	unsigned int width = cmd->width;
>  	unsigned int height = cmd->height;
> @@ -123,13 +111,13 @@ struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
>  		goto unreference;
>  	}
>  
> -	mtk_fb = mtk_drm_framebuffer_init(dev, cmd, gem);
> -	if (IS_ERR(mtk_fb)) {
> -		ret = PTR_ERR(mtk_fb);
> +	fb = mtk_drm_framebuffer_init(dev, cmd, gem);
> +	if (IS_ERR(fb)) {
> +		ret = PTR_ERR(fb);
>  		goto unreference;
>  	}
>  
> -	return &mtk_fb->base;
> +	return fb;
>  
>  unreference:
>  	drm_gem_object_put_unlocked(gem);


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

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 19/24] drm/armada: Move GEM BO to drm_framebuffer
  2018-05-17 15:41         ` Daniel Stone
@ 2018-06-26 14:49           ` Russell King - ARM Linux
  2018-06-27 10:40             ` Daniel Stone
  0 siblings, 1 reply; 73+ messages in thread
From: Russell King - ARM Linux @ 2018-06-26 14:49 UTC (permalink / raw)
  To: Daniel Stone; +Cc: dri-devel

On Thu, May 17, 2018 at 04:41:35PM +0100, Daniel Stone wrote:
> On 17 May 2018 at 16:26, Russell King - ARM Linux <linux@armlinux.org.uk> wrote:
> > On Thu, May 17, 2018 at 02:15:40PM +0100, Daniel Stone wrote:
> >> On 30 March 2018 at 15:11, Daniel Stone <daniels@collabora.com> wrote:
> >> > 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.
> >>
> >> Ping - have you had a chance to look at this?
> >
> > I haven't, I've not moved any of my trees off 4.16 yet as I've been
> > away on vacation, and also busy dealing with Spectre for 32-bit ARM.
> >
> > From a quick look, it seems fine, and as I guess the autobuilders
> > haven't complained, it probably builds okay.  So it can probably
> > be merged without much risk - if there are any problems I'll sort it
> > out later.
> 
> Thanks Russell. I did do a build test locally as well which had no
> complaints. I'll merge this through drm-misc.

Hi Daniel,

I've not seen this go in during the last merge window, so I assume
either it missed the window or it's been forgotten.  Mind if I pick
it up instead - I finally have armada on the way to atomic modeset
conversion.

Thanks.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 19/24] drm/armada: Move GEM BO to drm_framebuffer
  2018-06-26 14:49           ` Russell King - ARM Linux
@ 2018-06-27 10:40             ` Daniel Stone
  0 siblings, 0 replies; 73+ messages in thread
From: Daniel Stone @ 2018-06-27 10:40 UTC (permalink / raw)
  To: Russell King - ARM Linux; +Cc: dri-devel

Hi Russell,
On Tue, 26 Jun 2018 at 15:49, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Thu, May 17, 2018 at 04:41:35PM +0100, Daniel Stone wrote:
> > Thanks Russell. I did do a build test locally as well which had no
> > complaints. I'll merge this through drm-misc.
>
> I've not seen this go in during the last merge window, so I assume
> either it missed the window or it's been forgotten.  Mind if I pick
> it up instead - I finally have armada on the way to atomic modeset
> conversion.

Thanks for chasing this up! AFAICT it has been merged though though:
it went into drm-misc-next last month, which Dave merged into drm-next
with f4366e44efeb895c.

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

^ permalink raw reply	[flat|nested] 73+ messages in thread

end of thread, other threads:[~2018-06-27 10:41 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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-05-17 14:25     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 03/24] drm/virtio: Place GEM BOs in drm_framebuffer Daniel Stone
2018-05-17 14:29     ` Thierry Reding
2018-05-17 14:29     ` 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-05-17 13:54   ` Thierry Reding
2018-03-30 14:47 ` [PATCH 00/24] drm_framebuffer boilerplate removal Alex Deucher
2018-03-30 14:47 ` Alex Deucher
2018-03-30 15:00   ` Daniel Stone
     [not found]     ` <CAPj87rOfg18u1xBioeu1D0MoD4My2rZy1Nw3yfA4DhdX2R7g7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-03-30 15:03       ` Alex Deucher

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.