mbox series

[v2,00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O

Message ID 20230515094033.2133-1-tzimmermann@suse.de
Headers show
Series drm/fbdev: Remove DRM's helpers for fbdev I/O | expand

Message

Thomas Zimmermann May 15, 2023, 9:40 a.m. UTC
DRM provides a number of wrappers around fbdev cfb_() sys_(), fb_io_()
and fb_sys_() helpers. The DRM functions don't provide any additional
functionality for most DRM drivers. So remove them and call the fbdev
I/O helpers directly.

The DRM fbdev I/O wrappers were originally added because <linux/fb.h>
does not protect its content with CONFIG_FB. DRM fbdev emulation did
not build if the config option had been disabled. This has been
fixed. For fbdev-generic and i915, the wrappers added support for damage
handling. But this is better handled within the two callers, as each
is special in its damage handling.

Patch 1 adds several internal Kconfig otpions that DRM drivers (and
possibly other fbdev code) will use to select the correct set of I/O
helpers.

Patches 2 to 9 replace the DRM wrappers in a number of fbdev emulations.
Patch 10 exports two helpers for damage handling. Patches 11 and 12
update fbdev-generic and i915 with the help of the exported functions.
The patches also remove DRM's fbdev I/O helpers, which are now unused.

DRM's fbdev helpers had to select fbdev I/O helpers for I/O and for
system memory. Each fbdev emulation now selects the correct helpers
for itself. Depending on the selected DRM drivers, kernel builds will
now only contain the necessary fbdev I/O helpers and might be slightly
smaller in size.

v2:
	* simplify Kconfig handling (Sam)

Thomas Zimmermann (12):
  fbdev: Add Kconfig options to select different fb_ops helpers
  drm/armada: Use regular fbdev I/O helpers
  drm/exynos: Use regular fbdev I/O helpers
  drm/gma500: Use regular fbdev I/O helpers
  drm/radeon: Use regular fbdev I/O helpers
  drm/fbdev-dma: Use regular fbdev I/O helpers
  drm/msm: Use regular fbdev I/O helpers
  drm/omapdrm: Use regular fbdev I/O helpers
  drm/tegra: Use regular fbdev I/O helpers
  drm/fb-helper: Export helpers for marking damage areas
  drm/fbdev-generic: Implement dedicated fbdev I/O helpers
  drm/i915: Implement dedicated fbdev I/O helpers

 drivers/gpu/drm/Kconfig                    |  10 +-
 drivers/gpu/drm/armada/Kconfig             |   1 +
 drivers/gpu/drm/armada/armada_fbdev.c      |   9 +-
 drivers/gpu/drm/drm_fb_helper.c            | 233 ++-------------------
 drivers/gpu/drm/drm_fbdev_dma.c            |  12 +-
 drivers/gpu/drm/drm_fbdev_generic.c        |  47 ++++-
 drivers/gpu/drm/exynos/Kconfig             |   1 +
 drivers/gpu/drm/exynos/Makefile            |   2 +-
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c  |  10 +-
 drivers/gpu/drm/gma500/Kconfig             |   1 +
 drivers/gpu/drm/gma500/fbdev.c             |   9 +-
 drivers/gpu/drm/i915/Kconfig               |   1 +
 drivers/gpu/drm/i915/display/intel_fbdev.c |  51 ++++-
 drivers/gpu/drm/msm/Kconfig                |   1 +
 drivers/gpu/drm/msm/msm_fbdev.c            |  12 +-
 drivers/gpu/drm/omapdrm/Kconfig            |   1 +
 drivers/gpu/drm/omapdrm/omap_fbdev.c       |  12 +-
 drivers/gpu/drm/radeon/Kconfig             |   1 +
 drivers/gpu/drm/radeon/radeon_fbdev.c      |   9 +-
 drivers/gpu/drm/tegra/Kconfig              |   1 +
 drivers/gpu/drm/tegra/fbdev.c              |  11 +-
 drivers/video/fbdev/Kconfig                |  21 ++
 include/drm/drm_fb_helper.h                |  84 +-------
 23 files changed, 184 insertions(+), 356 deletions(-)


base-commit: 451e49cfbaa90720149e63f4fa9c7824013c783d

Comments

Sam Ravnborg May 15, 2023, 5:55 p.m. UTC | #1
Hi Thomas,

On Mon, May 15, 2023 at 11:40:23AM +0200, Thomas Zimmermann wrote:
> Use the regular fbdev helpers for framebuffer I/O instead of DRM's
> helpers. Armada does not use damage handling, so DRM's fbdev helpers
> are mere wrappers around the fbdev code.
> 
> By using fbdev helpers directly within each DRM fbdev emulation,
> we can eventually remove DRM's wrapper functions entirely.
> 
> v2:
> 	* use FB_IO_HELPERS option
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Russell King <linux@armlinux.org.uk>
> ---
>  drivers/gpu/drm/armada/Kconfig        | 1 +
>  drivers/gpu/drm/armada/armada_fbdev.c | 9 ++++-----
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/armada/Kconfig b/drivers/gpu/drm/armada/Kconfig
> index f5c66d89ba99..5afade25e217 100644
> --- a/drivers/gpu/drm/armada/Kconfig
> +++ b/drivers/gpu/drm/armada/Kconfig
> @@ -3,6 +3,7 @@ config DRM_ARMADA
>  	tristate "DRM support for Marvell Armada SoCs"
>  	depends on DRM && HAVE_CLK && ARM && MMU
>  	select DRM_KMS_HELPER
> +	select FB_IO_HELPERS if DRM_FBDEV_EMULATION
>  	help
>  	  Support the "LCD" controllers found on the Marvell Armada 510
>  	  devices.  There are two controllers on the device, each controller
> diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
> index 0a5fd1aa86eb..6c3bbaf53569 100644
> --- a/drivers/gpu/drm/armada/armada_fbdev.c
> +++ b/drivers/gpu/drm/armada/armada_fbdev.c
> @@ -5,6 +5,7 @@
>   */
>  
>  #include <linux/errno.h>
> +#include <linux/fb.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  
> @@ -34,11 +35,9 @@ static void armada_fbdev_fb_destroy(struct fb_info *info)
>  static const struct fb_ops armada_fb_ops = {
>  	.owner		= THIS_MODULE,
>  	DRM_FB_HELPER_DEFAULT_OPS,
> -	.fb_read	= drm_fb_helper_cfb_read,
> -	.fb_write	= drm_fb_helper_cfb_write,
I had expected to see
.fb_read = fb_io_read,

But maybe this only used when using damage handling?

Likewise for drm_fb_helper_cfb_write.

??

> -	.fb_fillrect	= drm_fb_helper_cfb_fillrect,
> -	.fb_copyarea	= drm_fb_helper_cfb_copyarea,
> -	.fb_imageblit	= drm_fb_helper_cfb_imageblit,
> +	.fb_fillrect	= cfb_fillrect,
> +	.fb_copyarea	= cfb_copyarea,
> +	.fb_imageblit	= cfb_imageblit,

This part is as expected.

	Sam

>  	.fb_destroy	= armada_fbdev_fb_destroy,
>  };
>  
> -- 
> 2.40.1
Thomas Zimmermann May 16, 2023, 1:03 p.m. UTC | #2
Hi

Am 15.05.23 um 19:55 schrieb Sam Ravnborg:
> Hi Thomas,
> 
> On Mon, May 15, 2023 at 11:40:23AM +0200, Thomas Zimmermann wrote:
>> Use the regular fbdev helpers for framebuffer I/O instead of DRM's
>> helpers. Armada does not use damage handling, so DRM's fbdev helpers
>> are mere wrappers around the fbdev code.
>>
>> By using fbdev helpers directly within each DRM fbdev emulation,
>> we can eventually remove DRM's wrapper functions entirely.
>>
>> v2:
>> 	* use FB_IO_HELPERS option
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Cc: Russell King <linux@armlinux.org.uk>
>> ---
>>   drivers/gpu/drm/armada/Kconfig        | 1 +
>>   drivers/gpu/drm/armada/armada_fbdev.c | 9 ++++-----
>>   2 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/armada/Kconfig b/drivers/gpu/drm/armada/Kconfig
>> index f5c66d89ba99..5afade25e217 100644
>> --- a/drivers/gpu/drm/armada/Kconfig
>> +++ b/drivers/gpu/drm/armada/Kconfig
>> @@ -3,6 +3,7 @@ config DRM_ARMADA
>>   	tristate "DRM support for Marvell Armada SoCs"
>>   	depends on DRM && HAVE_CLK && ARM && MMU
>>   	select DRM_KMS_HELPER
>> +	select FB_IO_HELPERS if DRM_FBDEV_EMULATION
>>   	help
>>   	  Support the "LCD" controllers found on the Marvell Armada 510
>>   	  devices.  There are two controllers on the device, each controller
>> diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
>> index 0a5fd1aa86eb..6c3bbaf53569 100644
>> --- a/drivers/gpu/drm/armada/armada_fbdev.c
>> +++ b/drivers/gpu/drm/armada/armada_fbdev.c
>> @@ -5,6 +5,7 @@
>>    */
>>   
>>   #include <linux/errno.h>
>> +#include <linux/fb.h>
>>   #include <linux/kernel.h>
>>   #include <linux/module.h>
>>   
>> @@ -34,11 +35,9 @@ static void armada_fbdev_fb_destroy(struct fb_info *info)
>>   static const struct fb_ops armada_fb_ops = {
>>   	.owner		= THIS_MODULE,
>>   	DRM_FB_HELPER_DEFAULT_OPS,
>> -	.fb_read	= drm_fb_helper_cfb_read,
>> -	.fb_write	= drm_fb_helper_cfb_write,
> I had expected to see
> .fb_read = fb_io_read,
> 
> But maybe this only used when using damage handling?

fb_io_read() and fb_io_write() are the default implementations. They are 
called when no callback has been set.  All the other fbdev drivers leave 
them out, so I kept this pattern for the DRM side as well.

Best regards
Thomas

> 
> Likewise for drm_fb_helper_cfb_write.
> 
> ??
> 
>> -	.fb_fillrect	= drm_fb_helper_cfb_fillrect,
>> -	.fb_copyarea	= drm_fb_helper_cfb_copyarea,
>> -	.fb_imageblit	= drm_fb_helper_cfb_imageblit,
>> +	.fb_fillrect	= cfb_fillrect,
>> +	.fb_copyarea	= cfb_copyarea,
>> +	.fb_imageblit	= cfb_imageblit,
> 
> This part is as expected.
> 
> 	Sam
> 
>>   	.fb_destroy	= armada_fbdev_fb_destroy,
>>   };
>>   
>> -- 
>> 2.40.1
Thomas Zimmermann May 16, 2023, 1:13 p.m. UTC | #3
Hi

Am 15.05.23 um 20:04 schrieb Russell King (Oracle):
> On Mon, May 15, 2023 at 07:55:44PM +0200, Sam Ravnborg wrote:
>> Hi Thomas,
>>
>> On Mon, May 15, 2023 at 11:40:23AM +0200, Thomas Zimmermann wrote:
>>> Use the regular fbdev helpers for framebuffer I/O instead of DRM's
>>> helpers. Armada does not use damage handling, so DRM's fbdev helpers
>>> are mere wrappers around the fbdev code.
>>>
>>> By using fbdev helpers directly within each DRM fbdev emulation,
>>> we can eventually remove DRM's wrapper functions entirely.
>>>
>>> v2:
>>> 	* use FB_IO_HELPERS option
>>>
>>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>>> Cc: Russell King <linux@armlinux.org.uk>
>>> ---
>>>   drivers/gpu/drm/armada/Kconfig        | 1 +
>>>   drivers/gpu/drm/armada/armada_fbdev.c | 9 ++++-----
>>>   2 files changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/armada/Kconfig b/drivers/gpu/drm/armada/Kconfig
>>> index f5c66d89ba99..5afade25e217 100644
>>> --- a/drivers/gpu/drm/armada/Kconfig
>>> +++ b/drivers/gpu/drm/armada/Kconfig
>>> @@ -3,6 +3,7 @@ config DRM_ARMADA
>>>   	tristate "DRM support for Marvell Armada SoCs"
>>>   	depends on DRM && HAVE_CLK && ARM && MMU
>>>   	select DRM_KMS_HELPER
>>> +	select FB_IO_HELPERS if DRM_FBDEV_EMULATION
>>>   	help
>>>   	  Support the "LCD" controllers found on the Marvell Armada 510
>>>   	  devices.  There are two controllers on the device, each controller
>>> diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
>>> index 0a5fd1aa86eb..6c3bbaf53569 100644
>>> --- a/drivers/gpu/drm/armada/armada_fbdev.c
>>> +++ b/drivers/gpu/drm/armada/armada_fbdev.c
>>> @@ -5,6 +5,7 @@
>>>    */
>>>   
>>>   #include <linux/errno.h>
>>> +#include <linux/fb.h>
>>>   #include <linux/kernel.h>
>>>   #include <linux/module.h>
>>>   
>>> @@ -34,11 +35,9 @@ static void armada_fbdev_fb_destroy(struct fb_info *info)
>>>   static const struct fb_ops armada_fb_ops = {
>>>   	.owner		= THIS_MODULE,
>>>   	DRM_FB_HELPER_DEFAULT_OPS,
>>> -	.fb_read	= drm_fb_helper_cfb_read,
>>> -	.fb_write	= drm_fb_helper_cfb_write,
>> I had expected to see
>> .fb_read = fb_io_read,
>>
>> But maybe this only used when using damage handling?
>>
>> Likewise for drm_fb_helper_cfb_write.
>>
>> ??
>>
>>> -	.fb_fillrect	= drm_fb_helper_cfb_fillrect,
>>> -	.fb_copyarea	= drm_fb_helper_cfb_copyarea,
>>> -	.fb_imageblit	= drm_fb_helper_cfb_imageblit,
>>> +	.fb_fillrect	= cfb_fillrect,
>>> +	.fb_copyarea	= cfb_copyarea,
>>> +	.fb_imageblit	= cfb_imageblit,
>>
>> This part is as expected.
> 
> Well, to me it looks like this has gone through an entire circular set
> of revisions:
> 
> commit e8b70e4dd7b5dad7c2379de6e0851587bf86bfd6
> Author: Archit Taneja <architt@codeaurora.org>
> Date:   Wed Jul 22 14:58:04 2015 +0530
> 
>      drm/armada: Use new drm_fb_helper functions
> 
> -       .fb_fillrect    = cfb_fillrect,
> -       .fb_copyarea    = cfb_copyarea,
> -       .fb_imageblit   = cfb_imageblit,
> +       .fb_fillrect    = drm_fb_helper_cfb_fillrect,
> +       .fb_copyarea    = drm_fb_helper_cfb_copyarea,
> +       .fb_imageblit   = drm_fb_helper_cfb_imageblit,
> 
> commit 983780918c759fdbbf0bf033e701bbff75d2af23
> Author: Thomas Zimmermann <tzimmermann@suse.de>
> Date:   Thu Nov 3 16:14:40 2022 +0100
> 
>      drm/fb-helper: Perform all fbdev I/O with the same implementation
> 
> +       .fb_read        = drm_fb_helper_cfb_read,
> +       .fb_write       = drm_fb_helper_cfb_write,
> 
> and now effectively those two changes are being reverted, so we'd
> now be back to the pre-July 2015 state of affairs. As I believe
> the fbdev layer has been stable, this change merely reverts the
> driver back to what it once was.

Not quite. One long-standing problem has been that fbdev does not 
protect its public interfaces with CONFIG_FB. If fbdev had been 
disabled, DRM drivers could no longer be linked/loaded. DRM wrappers 
solved this. The issue has recently been fixed for all of DRM. DRM does 
not build it's fbdev emulation if CONFIG_FB has been disabled.

Another thing was that the original DRM wrappers might have been 
different from fbdev's I/O helpers in subtle ways. But now they are 
simple wrappers around their fbdev counterparts; plus the option of 
additional damage handling.  But such damage handling is better 
implemented by the driver itself. The two cases that require it, i915 
and fbdev-generic, are different enough that each should probably have 
it's own code.

Best regards
Thomas

>