diff mbox series

[02/20] drm/arc: Use drm_fbdev_generic_setup()

Message ID 20180908134648.2582-3-noralf@tronnes.org (mailing list archive)
State New, archived
Headers show
Series drm/cma-helper drivers: Use drm_fbdev_generic_setup() | expand

Commit Message

Noralf Trønnes Sept. 8, 2018, 1:46 p.m. UTC
The CMA helper is already using the drm_fb_helper_generic_probe part of
the generic fbdev emulation. This patch makes full use of the generic
fbdev emulation by using its drm_client callbacks. This means that
drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are
now handled by the emulation code. Additionally fbdev unregister happens
automatically on drm_dev_unregister().

The drm_fbdev_generic_setup() call is put after drm_dev_register() in the
driver. This is done to highlight the fact that fbdev emulation is an
internal client that makes use of the driver, it is not part of the
driver as such. If fbdev setup fails, an error is printed, but the driver
succeeds probing.

Cc: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
---
 drivers/gpu/drm/arc/arcpgu.h     |  4 ----
 drivers/gpu/drm/arc/arcpgu_drv.c | 33 +++------------------------------
 2 files changed, 3 insertions(+), 34 deletions(-)

Comments

Alexey Brodkin Sept. 10, 2018, 12:31 p.m. UTC | #1
Hi Noralf,

On Sat, 2018-09-08 at 15:46 +0200, Noralf Trønnes wrote:
> The CMA helper is already using the drm_fb_helper_generic_probe part of
> the generic fbdev emulation. This patch makes full use of the generic
> fbdev emulation by using its drm_client callbacks. This means that
> drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are
> now handled by the emulation code. Additionally fbdev unregister happens
> automatically on drm_dev_unregister().
> 
> The drm_fbdev_generic_setup() call is put after drm_dev_register() in the
> driver. This is done to highlight the fact that fbdev emulation is an
> internal client that makes use of the driver, it is not part of the
> driver as such. If fbdev setup fails, an error is printed, but the driver
> succeeds probing.
> 
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> ---

Thanks for making these improvements!
I'm wondering what is a base for these changes so that I may try it on
my board?

Preferably I'd like to get a link to the tag in your git tree with all
the prerequisites in place.

-Alexey
Noralf Trønnes Sept. 10, 2018, 1 p.m. UTC | #2
Den 10.09.2018 14.31, skrev Alexey Brodkin:
> Hi Noralf,
>
> On Sat, 2018-09-08 at 15:46 +0200, Noralf Trønnes wrote:
>> The CMA helper is already using the drm_fb_helper_generic_probe part of
>> the generic fbdev emulation. This patch makes full use of the generic
>> fbdev emulation by using its drm_client callbacks. This means that
>> drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are
>> now handled by the emulation code. Additionally fbdev unregister happens
>> automatically on drm_dev_unregister().
>>
>> The drm_fbdev_generic_setup() call is put after drm_dev_register() in the
>> driver. This is done to highlight the fact that fbdev emulation is an
>> internal client that makes use of the driver, it is not part of the
>> driver as such. If fbdev setup fails, an error is printed, but the driver
>> succeeds probing.
>>
>> Cc: Alexey Brodkin <abrodkin@synopsys.com>
>> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
>> ---
> Thanks for making these improvements!

Glad you like it.
Funny how a simple idea can turn into 6 months of work.

> I'm wondering what is a base for these changes so that I may try it on
> my board?
>
> Preferably I'd like to get a link to the tag in your git tree with all
> the prerequisites in place.

It's only this one patch to apply for you.
I replied to the cover letter with some more context.

Noralf.
Alexey Brodkin Sept. 28, 2018, 7:34 a.m. UTC | #3
Hi Noralf,

On Sat, 2018-09-08 at 15:46 +0200, Noralf Trønnes wrote:
> The CMA helper is already using the drm_fb_helper_generic_probe part of
> the generic fbdev emulation. This patch makes full use of the generic
> fbdev emulation by using its drm_client callbacks. This means that
> drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are
> now handled by the emulation code. Additionally fbdev unregister happens
> automatically on drm_dev_unregister().
> 
> The drm_fbdev_generic_setup() call is put after drm_dev_register() in the
> driver. This is done to highlight the fact that fbdev emulation is an
> internal client that makes use of the driver, it is not part of the
> driver as such. If fbdev setup fails, an error is printed, but the driver
> succeeds probing.
> 
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

Thanks for doing that!
Quite some code removed from the driver and still FBDEV emulation works :)

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Noralf Trønnes Sept. 28, 2018, 10:42 a.m. UTC | #4
Den 28.09.2018 09.34, skrev Alexey Brodkin:
> Hi Noralf,
>
> On Sat, 2018-09-08 at 15:46 +0200, Noralf Trønnes wrote:
>> The CMA helper is already using the drm_fb_helper_generic_probe part of
>> the generic fbdev emulation. This patch makes full use of the generic
>> fbdev emulation by using its drm_client callbacks. This means that
>> drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are
>> now handled by the emulation code. Additionally fbdev unregister happens
>> automatically on drm_dev_unregister().
>>
>> The drm_fbdev_generic_setup() call is put after drm_dev_register() in the
>> driver. This is done to highlight the fact that fbdev emulation is an
>> internal client that makes use of the driver, it is not part of the
>> driver as such. If fbdev setup fails, an error is printed, but the driver
>> succeeds probing.
>>
>> Cc: Alexey Brodkin <abrodkin@synopsys.com>
>> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> Thanks for doing that!
> Quite some code removed from the driver and still FBDEV emulation works :)

Yeah we're down to one line of code in the driver to get fbdev emulation
which is quite nice a think :D

Noralf.

> Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
>
Alexey Brodkin Oct. 1, 2018, 7:56 a.m. UTC | #5
Hi Noralf,

On Fri, 2018-09-28 at 12:42 +0200, Noralf Trønnes wrote:
> Den 28.09.2018 09.34, skrev Alexey Brodkin:
> > Hi Noralf,
> > 
> > On Sat, 2018-09-08 at 15:46 +0200, Noralf Trønnes wrote:
> > > The CMA helper is already using the drm_fb_helper_generic_probe part of
> > > the generic fbdev emulation. This patch makes full use of the generic
> > > fbdev emulation by using its drm_client callbacks. This means that
> > > drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are
> > > now handled by the emulation code. Additionally fbdev unregister happens
> > > automatically on drm_dev_unregister().
> > > 
> > > The drm_fbdev_generic_setup() call is put after drm_dev_register() in the
> > > driver. This is done to highlight the fact that fbdev emulation is an
> > > internal client that makes use of the driver, it is not part of the
> > > driver as such. If fbdev setup fails, an error is printed, but the driver
> > > succeeds probing.
> > > 
> > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> > 
> > Thanks for doing that!
> > Quite some code removed from the driver and still FBDEV emulation works :)
> 
> Yeah we're down to one line of code in the driver to get fbdev emulation
> which is quite nice a think :D

Exactly!

And just to not lose this nice improvement - do I need to pull this through
my tree or entire series will be merged in main DRM tree?

-Alexey
Noralf Trønnes Oct. 1, 2018, 12:05 p.m. UTC | #6
Den 01.10.2018 09.56, skrev Alexey Brodkin:
> Hi Noralf,
>
> On Fri, 2018-09-28 at 12:42 +0200, Noralf Trønnes wrote:
>> Den 28.09.2018 09.34, skrev Alexey Brodkin:
>>> Hi Noralf,
>>>
>>> On Sat, 2018-09-08 at 15:46 +0200, Noralf Trønnes wrote:
>>>> The CMA helper is already using the drm_fb_helper_generic_probe part of
>>>> the generic fbdev emulation. This patch makes full use of the generic
>>>> fbdev emulation by using its drm_client callbacks. This means that
>>>> drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are
>>>> now handled by the emulation code. Additionally fbdev unregister happens
>>>> automatically on drm_dev_unregister().
>>>>
>>>> The drm_fbdev_generic_setup() call is put after drm_dev_register() in the
>>>> driver. This is done to highlight the fact that fbdev emulation is an
>>>> internal client that makes use of the driver, it is not part of the
>>>> driver as such. If fbdev setup fails, an error is printed, but the driver
>>>> succeeds probing.
>>>>
>>>> Cc: Alexey Brodkin <abrodkin@synopsys.com>
>>>> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
>>> Thanks for doing that!
>>> Quite some code removed from the driver and still FBDEV emulation works :)
>> Yeah we're down to one line of code in the driver to get fbdev emulation
>> which is quite nice a think :D
> Exactly!
>
> And just to not lose this nice improvement - do I need to pull this through
> my tree or entire series will be merged in main DRM tree?

I apply the patches to drm-misc-next when I get acks.
Unless the maintainer wants to take it himself.
So, yes I'll apply this one :-)

Noralf.
Alexey Brodkin Oct. 1, 2018, 12:06 p.m. UTC | #7
Hi Noralf,

On Mon, 2018-10-01 at 14:05 +0200, Noralf Trønnes wrote:
> 
> Den 01.10.2018 09.56, skrev Alexey Brodkin:
> > Hi Noralf,
> > 
> > On Fri, 2018-09-28 at 12:42 +0200, Noralf Trønnes wrote:
> > > Den 28.09.2018 09.34, skrev Alexey Brodkin:
> > > > Hi Noralf,
> > > > 
> > > > On Sat, 2018-09-08 at 15:46 +0200, Noralf Trønnes wrote:
> > > > > The CMA helper is already using the drm_fb_helper_generic_probe part of
> > > > > the generic fbdev emulation. This patch makes full use of the generic
> > > > > fbdev emulation by using its drm_client callbacks. This means that
> > > > > drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are
> > > > > now handled by the emulation code. Additionally fbdev unregister happens
> > > > > automatically on drm_dev_unregister().
> > > > > 
> > > > > The drm_fbdev_generic_setup() call is put after drm_dev_register() in the
> > > > > driver. This is done to highlight the fact that fbdev emulation is an
> > > > > internal client that makes use of the driver, it is not part of the
> > > > > driver as such. If fbdev setup fails, an error is printed, but the driver
> > > > > succeeds probing.
> > > > > 
> > > > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > > > Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> > > > 
> > > > Thanks for doing that!
> > > > Quite some code removed from the driver and still FBDEV emulation works :)
> > > 
> > > Yeah we're down to one line of code in the driver to get fbdev emulation
> > > which is quite nice a think :D
> > 
> > Exactly!
> > 
> > And just to not lose this nice improvement - do I need to pull this through
> > my tree or entire series will be merged in main DRM tree?
> 
> I apply the patches to drm-misc-next when I get acks.
> Unless the maintainer wants to take it himself.
> So, yes I'll apply this one :-)

Cool! thanks for doing that!

-Alexey
diff mbox series

Patch

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index e8fcf3ab1d9a..90ef76b19f8a 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -20,7 +20,6 @@ 
 struct arcpgu_drm_private {
 	void __iomem		*regs;
 	struct clk		*clk;
-	struct drm_fbdev_cma	*fbdev;
 	struct drm_framebuffer	*fb;
 	struct drm_crtc		crtc;
 	struct drm_plane	*plane;
@@ -43,8 +42,5 @@  static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
 int arc_pgu_setup_crtc(struct drm_device *dev);
 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
-struct drm_fbdev_cma *arcpgu_fbdev_cma_init(struct drm_device *dev,
-	unsigned int preferred_bpp, unsigned int num_crtc,
-	unsigned int max_conn_count);
 
 #endif
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index f067de4e1e82..d3bc5a5cb4c2 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -17,6 +17,7 @@ 
 #include <linux/clk.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_atomic_helper.h>
@@ -25,16 +26,8 @@ 
 #include "arcpgu.h"
 #include "arcpgu_regs.h"
 
-static void arcpgu_fb_output_poll_changed(struct drm_device *dev)
-{
-	struct arcpgu_drm_private *arcpgu = dev->dev_private;
-
-	drm_fbdev_cma_hotplug_event(arcpgu->fbdev);
-}
-
 static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = {
 	.fb_create  = drm_gem_fb_create,
-	.output_poll_changed = arcpgu_fb_output_poll_changed,
 	.atomic_check = drm_atomic_helper_check,
 	.atomic_commit = drm_atomic_helper_commit,
 };
@@ -51,13 +44,6 @@  static void arcpgu_setup_mode_config(struct drm_device *drm)
 
 DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops);
 
-static void arcpgu_lastclose(struct drm_device *drm)
-{
-	struct arcpgu_drm_private *arcpgu = drm->dev_private;
-
-	drm_fbdev_cma_restore_mode(arcpgu->fbdev);
-}
-
 static int arcpgu_load(struct drm_device *drm)
 {
 	struct platform_device *pdev = to_platform_device(drm->dev);
@@ -113,26 +99,12 @@  static int arcpgu_load(struct drm_device *drm)
 	drm_mode_config_reset(drm);
 	drm_kms_helper_poll_init(drm);
 
-	arcpgu->fbdev = drm_fbdev_cma_init(drm, 16,
-					   drm->mode_config.num_connector);
-	if (IS_ERR(arcpgu->fbdev)) {
-		ret = PTR_ERR(arcpgu->fbdev);
-		arcpgu->fbdev = NULL;
-		return -ENODEV;
-	}
-
 	platform_set_drvdata(pdev, drm);
 	return 0;
 }
 
 static int arcpgu_unload(struct drm_device *drm)
 {
-	struct arcpgu_drm_private *arcpgu = drm->dev_private;
-
-	if (arcpgu->fbdev) {
-		drm_fbdev_cma_fini(arcpgu->fbdev);
-		arcpgu->fbdev = NULL;
-	}
 	drm_kms_helper_poll_fini(drm);
 	drm_mode_config_cleanup(drm);
 
@@ -167,7 +139,6 @@  static int arcpgu_debugfs_init(struct drm_minor *minor)
 static struct drm_driver arcpgu_drm_driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
 			   DRIVER_ATOMIC,
-	.lastclose = arcpgu_lastclose,
 	.name = "arcpgu",
 	.desc = "ARC PGU Controller",
 	.date = "20160219",
@@ -210,6 +181,8 @@  static int arcpgu_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_unload;
 
+	drm_fbdev_generic_setup(drm, 16);
+
 	return 0;
 
 err_unload: