linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/24] drm_framebuffer boilerplate removal
@ 2018-03-30 14:11 Daniel Stone
       [not found] ` <20180330141138.28987-1-daniels@collabora.com>
  2018-03-30 14:47 ` [PATCH 00/24] drm_framebuffer boilerplate removal Alex Deucher
  0 siblings, 2 replies; 5+ 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] 5+ messages in thread

* [PATCH 21/24] drm/msm: Move GEM BOs to drm_framebuffer
       [not found] ` <20180330141138.28987-1-daniels@collabora.com>
@ 2018-03-30 14:11   ` Daniel Stone
  2018-05-17 13:12     ` Daniel Stone
  2018-05-17 15:05     ` Thierry Reding
  0 siblings, 2 replies; 5+ 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] 5+ 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
       [not found] ` <20180330141138.28987-1-daniels@collabora.com>
@ 2018-03-30 14:47 ` Alex Deucher
  1 sibling, 0 replies; 5+ 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] 5+ 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 to drm_framebuffer Daniel Stone
@ 2018-05-17 13:12     ` Daniel Stone
  2018-05-17 15:05     ` Thierry Reding
  1 sibling, 0 replies; 5+ 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] 5+ 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 to drm_framebuffer Daniel Stone
  2018-05-17 13:12     ` Daniel Stone
@ 2018-05-17 15:05     ` Thierry Reding
  1 sibling, 0 replies; 5+ 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] 5+ messages in thread

end of thread, other threads:[~2018-05-17 15:05 UTC | newest]

Thread overview: 5+ 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
     [not found] ` <20180330141138.28987-1-daniels@collabora.com>
2018-03-30 14:11   ` [PATCH 21/24] drm/msm: Move GEM BOs to drm_framebuffer Daniel Stone
2018-05-17 13:12     ` Daniel Stone
2018-05-17 15:05     ` Thierry Reding
2018-03-30 14:47 ` [PATCH 00/24] drm_framebuffer boilerplate removal Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).