mbox series

[00/22] drm/dma-helper: Add dedicated fbdev emulation

Message ID 20230301153101.4282-1-tzimmermann@suse.de (mailing list archive)
Headers show
Series drm/dma-helper: Add dedicated fbdev emulation | expand

Message

Thomas Zimmermann March 1, 2023, 3:30 p.m. UTC
Add fbdev emulation that is optimized for DMA helpers, as used by most
drivers. It operates directly on GEM DMA buffers in system memory.
Memory pages are mmap'ed directly to userspace. No implicit shadow
buffers need to be allocated; as can happen with the generic fbdev
emulation. Convert drivers that fulfil the requirements.

Tested with fbcon and IGT on vc4.

Future direction: providing a dedicated fbdev emulation for GEM DMA
helpers will allow us to remove this case from the generic fbdev code.
The latter can then be simplified.

Thomas Zimmermann (22):
  drm/fbdev-dma: Implement fbdev emulation for GEM DMA helpers
  arm/hdlcd: Use GEM DMA fbdev emulation
  arm/malidp: Use GEM DMA fbdev emulation
  drm/aspeed: Use GEM DMA fbdev emulation
  drm/atmel-hlcdc: Use GEM DMA fbdev emulation
  drm/fsl-dcu: Use GEM DMA fbdev emulation
  drm/imx/dcss: Use GEM DMA fbdev emulation
  drm/imx: Use GEM DMA fbdev emulation
  drm/kmb: Use GEM DMA fbdev emulation
  drm/logicvc: Use GEM DMA fbdev emulation
  drm/meson: Use GEM DMA fbdev emulation
  drm/mxsfb/lcdif: Use GEM DMA fbdev emulation
  drm/mxsfb: Use GEM DMA fbdev emulation
  drm/sti: Use GEM DMA fbdev emulation
  drm/stm: Use GEM DMA fbdev emulation
  drm/sun4i: Use GEM DMA fbdev emulation
  drm/tidss: Use GEM DMA fbdev emulation
  drm/tilcdc: Use GEM DMA fbdev emulation
  drm/arcpgu: Use GEM DMA fbdev emulation
  drm/tve200: Use GEM DMA fbdev emulation
  drm/vc4: Use GEM DMA fbdev emulation
  drm/xlnx: Use GEM DMA fbdev emulation

 drivers/gpu/drm/Makefile                     |   1 +
 drivers/gpu/drm/arm/hdlcd_drv.c              |   4 +-
 drivers/gpu/drm/arm/malidp_drv.c             |   4 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c      |   4 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |   4 +-
 drivers/gpu/drm/drm_fbdev_dma.c              | 275 +++++++++++++++++++
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |   4 +-
 drivers/gpu/drm/imx/dcss/dcss-kms.c          |   4 +-
 drivers/gpu/drm/imx/ipuv3/imx-drm-core.c     |   4 +-
 drivers/gpu/drm/kmb/kmb_drv.c                |   4 +-
 drivers/gpu/drm/logicvc/logicvc_drm.c        |   4 +-
 drivers/gpu/drm/meson/meson_drv.c            |   4 +-
 drivers/gpu/drm/mxsfb/lcdif_drv.c            |   4 +-
 drivers/gpu/drm/mxsfb/mxsfb_drv.c            |   4 +-
 drivers/gpu/drm/sti/sti_drv.c                |   4 +-
 drivers/gpu/drm/stm/drv.c                    |   4 +-
 drivers/gpu/drm/sun4i/sun4i_drv.c            |   4 +-
 drivers/gpu/drm/tidss/tidss_drv.c            |   4 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c          |   4 +-
 drivers/gpu/drm/tiny/arcpgu.c                |   4 +-
 drivers/gpu/drm/tve200/tve200_drv.c          |   4 +-
 drivers/gpu/drm/vc4/vc4_drv.c                |   4 +-
 drivers/gpu/drm/xlnx/zynqmp_kms.c            |   4 +-
 include/drm/drm_fbdev_dma.h                  |  15 +
 24 files changed, 333 insertions(+), 42 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_fbdev_dma.c
 create mode 100644 include/drm/drm_fbdev_dma.h


base-commit: 734cd918122f6ec06e4c9366fb3283b29b1c7ea5
prerequisite-patch-id: 0aa359f6144c4015c140c8a6750be19099c676fb
prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24
prerequisite-patch-id: 3f204510fcbf9530d6540bd8e6128cce598988b6

Comments

Linus Walleij March 6, 2023, 10:19 p.m. UTC | #1
On Wed, Mar 1, 2023 at 4:31 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:

> Add fbdev emulation that is optimized for DMA helpers, as used by most
> drivers. It operates directly on GEM DMA buffers in system memory.
> Memory pages are mmap'ed directly to userspace. No implicit shadow
> buffers need to be allocated; as can happen with the generic fbdev
> emulation. Convert drivers that fulfil the requirements.
>
> Tested with fbcon and IGT on vc4.
>
> Future direction: providing a dedicated fbdev emulation for GEM DMA
> helpers will allow us to remove this case from the generic fbdev code.
> The latter can then be simplified.

1) I love your work.

2) Why isn't this DRM driver changed?
drivers/gpu/drm/mcde/mcde_drv.c
AFAICT it also uses GEM buffers in system memory.

3) This one:
drivers/gpu/drm/pl111/pl111_drv.c
is also very similar, but can sometimes use a dedicated
RAM memory for allocations using CMA, does that make
it not a candidate?

They aren't much different in how they work from the TVE200.

Yours,
Linus Walleij
Thomas Zimmermann March 7, 2023, 8:55 a.m. UTC | #2
Hi

Am 06.03.23 um 23:19 schrieb Linus Walleij:
> On Wed, Mar 1, 2023 at 4:31 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
> 
>> Add fbdev emulation that is optimized for DMA helpers, as used by most
>> drivers. It operates directly on GEM DMA buffers in system memory.
>> Memory pages are mmap'ed directly to userspace. No implicit shadow
>> buffers need to be allocated; as can happen with the generic fbdev
>> emulation. Convert drivers that fulfil the requirements.
>>
>> Tested with fbcon and IGT on vc4.
>>
>> Future direction: providing a dedicated fbdev emulation for GEM DMA
>> helpers will allow us to remove this case from the generic fbdev code.
>> The latter can then be simplified.
> 
> 1) I love your work.

Thank you. :)

> 
> 2) Why isn't this DRM driver changed?
> drivers/gpu/drm/mcde/mcde_drv.c
> AFAICT it also uses GEM buffers in system memory.

This driver requires damage handling

 
https://elixir.bootlin.com/linux/v6.2/source/drivers/gpu/drm/mcde/mcde_drv.c#L97

for which we have to call the framebuffer's dirty callback

 
https://elixir.bootlin.com/linux/v6.2/source/drivers/gpu/drm/drm_gem_framebuffer_helper.c#L285

after each write.

Doing this with fbdev emulation requires tracking of mmap'ed pages via 
fbdev's deferred-I/O mechanisms. That makes the fbdev-emulation code 
more complex. AFAICT, the existing generic fbdev emulation already 
implements this case 'good enough.'

> 
> 3) This one:
> drivers/gpu/drm/pl111/pl111_drv.c
> is also very similar, but can sometimes use a dedicated
> RAM memory for allocations using CMA, does that make
> it not a candidate?

Thanks, I think I simply missed pl111.

Best regards
Thomas

> 
> They aren't much different in how they work from the TVE200.
> 
> Yours,
> Linus Walleij
Linus Walleij March 9, 2023, 8:17 a.m. UTC | #3
On Tue, Mar 7, 2023 at 9:55 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
> Am 06.03.23 um 23:19 schrieb Linus Walleij:

> > 2) Why isn't this DRM driver changed?
> > drivers/gpu/drm/mcde/mcde_drv.c
> > AFAICT it also uses GEM buffers in system memory.
>
> This driver requires damage handling
> https://elixir.bootlin.com/linux/v6.2/source/drivers/gpu/drm/mcde/mcde_drv.c#L97
>
> for which we have to call the framebuffer's dirty callback

Oh that one is on me ... I no longer remember exactly why I used
drm_gem_fb_create_with_dirty() but I think it was because I had the
ambition that the driver would only send out updates to DSI command
displays whenever something changed, so as to minimize traffic.

It turns out this ambition with command mode isn't working in
practice because all the MCDE does is to create a continuous stream
of DSI commands and while it is possible to send single frame
updates with it, it's not working in practice. So we are just setting
up continuous updates. We turn of the VBLANK IRQs a bit, but I
guess the DRM framework does that for us when nothing goes on.

I tested to replace this with drm_gem_fb_create and it works just
fine. I'll send out a patch so you can make this change also to the
MCDE driver.

Yours,
Linus Walleij