drm/dma-helper: Add dedicated fbdev emulation
Subsystems (29)
Thomas Zimmermann
maintainercover drm/dma-helper: Add dedicated fbdev emulation
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
Signature · 1 line
2.39.2
Thomas Zimmermann
maintainerPATCH 1/22 drm/fbdev-dma: Implement fbdev emulation for GEM DMA helpers
Implement fbdev emulation that is optimized for drivers that use DMA helpers. The buffers may no tbe moveable, may not require damage handling and have to be located in system memory. This allows fbdev emulation to operate directly on the buffer and mmap it to userspace.
Besides those constraints, the emulation works like in the generic code. As an internal DRM client provides, it receives hotplug, restore and unregister events. The DRM client is independent from the fbdev probing, which runs on the first successful hotplug event.
The emulation is part of the DMA helper module and not build unless DMA helpers and fbdev emulation has been configured.
Tested with vc4.
--- drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_fbdev_dma.c | 275 ++++++++++++++++++++++++++++++++ include/drm/drm_fbdev_dma.h | 15 ++ 3 files changed, 291 insertions(+) create mode 100644 drivers/gpu/drm/drm_fbdev_dma.c create mode 100644 include/drm/drm_fbdev_dma.h
drivers/gpu/drm/Makefile +1 -0
@@ -82,6 +82,7 @@ obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o obj-$(CONFIG_DRM_BUDDY) += drm_buddy.o drm_dma_helper-y := drm_gem_dma_helper.o +drm_dma_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fbdev_dma.o drm_dma_helper-$(CONFIG_DRM_KMS_HELPER) += drm_fb_dma_helper.o obj-$(CONFIG_DRM_GEM_DMA_HELPER) += drm_dma_helper.o
drivers/gpu/drm/drm_fbdev_dma.c new file +275 -0
275 lines not on this page · raw message
include/drm/drm_fbdev_dma.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: MIT */ + +#ifndef DRM_FBDEV_DMA_H +#define DRM_FBDEV_DMA_H + +struct drm_device ; + +#ifdef CONFIG_DRM_FBDEV_EMULATION +void drm_fbdev_dma_setup (struct drm_device *dev,unsigned int preferred_bpp); +#else +static inline void drm_fbdev_dma_setup (struct drm_device *dev,unsigned int preferred_bpp) +{ } +#endif + +#endif
Signature · 1 line
2.39.2
Re: [PATCH 01/22] drm/fbdev-dma: Implement fbdev emulation for GEM DMA helpers
Quoted 2 lines · Thomas Zimmermann
Implement fbdev emulation that is optimized for drivers that use DMA helpers. The buffers may no tbe moveable, may not require damage
"may not be"
Is may the correct verb here though? I guess you meant "shall not".
Quoted 15 lines
handling and have to be located in system memory. This allows fbdev emulation to operate directly on the buffer and mmap it to userspace.
Besides those constraints, the emulation works like in the generic code. As an internal DRM client provides, it receives hotplug, restore and unregister events. The DRM client is independent from the fbdev probing, which runs on the first successful hotplug event.
The emulation is part of the DMA helper module and not build unless DMA helpers and fbdev emulation has been configured.
Tested with vc4.
Signed-off-by Thomas Zimmermann <[email protected]>---
[...]
Quoted 11 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +11
-0+static int drm_fbdev_dma_fb_open (struct fb_info *info,int user) +{ +struct drm_fb_helper *fb_helper = info->par; + +/* No need to take a ref for fbcon because it unbinds on unregister */ +if (user && !try_module_get (fb_helper->dev->driver->fops->owner)) +return -ENODEV ; + +return 0 ; +} +
drivers/gpu/drm/drm_fbdev_dma.c line 35
Quoted 10 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +10
-0+static int drm_fbdev_dma_fb_release (struct fb_info *info,int user) +{ +struct drm_fb_helper *fb_helper = info->par; + +if (user) +module_put (fb_helper->dev->driver->fops->owner); + +return 0 ; +} +
These two functions are the same than what's used by the generic fbdev emulation. Maybe they could be moved to drivers/gpu/drm/drm_fb_helper.c and be reused ?
Quoted 19 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +19
-0+static int drm_fbdev_dma_helper_fb_probe (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) +{ +struct drm_client_dev *client = &fb_helper->client; +struct drm_device *dev = fb_helper->dev; +struct drm_client_buffer *buffer; +struct drm_gem_dma_object *dma_obj; +struct drm_framebuffer *fb; +struct fb_info *info; +u32 format; +struct iosys_map map; +int ret; + +drm_dbg_kms (dev,"surface width(%d), height(%d) and bpp(%d)\n" , + sizes->surface_width, sizes->surface_height, + sizes->surface_bpp); + + format =drm_mode_legacy_fb_format (sizes->surface_bpp, sizes->surface_depth); + buffer = drm_client_framebuffer_create(client, sizes->surface_width,
drivers/gpu/drm/drm_fbdev_dma.c line 109
Quoted 10 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +10
-0+ sizes->surface_height, format); +if (IS_ERR (buffer)) +return PTR_ERR (buffer); + dma_obj =to_drm_gem_dma_obj (buffer->gem); + + fb = buffer->fb; +if (drm_WARN_ON (dev, fb->funcs->dirty)) { + ret = -ENODEV ;/* damage handling not supported; use generic emulation */ + goto err_drm_client_buffer_delete; + }
Should we have a similar check for drm_fbdev_use_shadow_fb(fb_helper) and warn on ?
drivers/gpu/drm/drm_fbdev_dma.c line 115
Quoted 6 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +6
-0+ + ret =drm_client_buffer_vmap (buffer, &map); +if (ret) { + goto err_drm_client_buffer_delete; + }else if (drm_WARN_ON (dev, map.is_iomem)) { + ret = -ENODEV ;/* I/O memory not supported; use generic emulation */
I also wonder if here and above instead of the warn on, there should just be a normal check and print more verbose warning messages.
[...]
drivers/gpu/drm/drm_fbdev_dma.c line 179
Quoted 12 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +12
-0+static void drm_fbdev_dma_client_unregister (struct drm_client_dev *client) +{ +struct drm_fb_helper *fb_helper =drm_fb_helper_from_client (client); + +if (fb_helper->info) { +drm_fb_helper_unregister_info (fb_helper); + }else { +drm_client_release (&fb_helper->client); +drm_fb_helper_unprepare (fb_helper); +kfree (fb_helper); + } +}
This is again the same than drm_fbdev_client_unregister() so I think that can be made a helper and shared bewteen the two implementations.
drivers/gpu/drm/drm_fbdev_dma.c line 186
Quoted 7 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +7
-0+ +static int drm_fbdev_dma_client_restore (struct drm_client_dev *client) +{ +drm_fb_helper_lastclose (client->dev); + +return 0 ; +}
Same for this one.
Quoted 19 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +19
-0+ +static int drm_fbdev_dma_client_hotplug (struct drm_client_dev *client) +{ +struct drm_fb_helper *fb_helper =drm_fb_helper_from_client (client); +struct drm_device *dev = client->dev; +int ret; + +if (dev->fb_helper) +return drm_fb_helper_hotplug_event (dev->fb_helper); + + ret =drm_fb_helper_init (dev, fb_helper); +if (ret) + goto err_drm_err; + +if (!drm_drv_uses_atomic_modeset (dev)) +drm_helper_disable_unused_functions (dev); + + ret =drm_fb_helper_initial_config (fb_helper); +if (ret)
drivers/gpu/drm/drm_fbdev_dma.c line 215
Quoted 10 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +10
-0+ goto err_drm_fb_helper_fini; + +return 0 ; + +err_drm_fb_helper_fini: +drm_fb_helper_fini (fb_helper); +err_drm_err: +drm_err (dev,"fbdev-dma: Failed to setup generic emulation (ret=%d)\n" , ret); +return ret; +}
And this one.
Quoted 42 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +42
-0+/** +* drm_fbdev_dma_setup() - Setup fbdev emulation for GEM DMA helpers +* @dev: DRM device +* @preferred_bpp: Preferred bits per pixel for the device. +* @dev->mode_config.preferred_depth is used if this is zero. +* +* This function sets up fbdev emulation for GEM DMA drivers that support +* dumb buffers with a virtual address and that can be mmap'ed. +* drm_fbdev_dma_setup() shall be called after the DRM driver registered +* the new DRM device with drm_dev_register(). +* +* Restore, hotplug events and teardown are all taken care of. Drivers that do +* suspend/resume need to call drm_fb_helper_set_suspend_unlocked() themselves. +* Simple drivers might use drm_mode_config_helper_suspend(). +* +* This function is safe to call even when there are no connectors present. +* Setup will be retried on the next hotplug event. +* +* The fbdev is destroyed by drm_dev_unregister(). +*/ +void drm_fbdev_dma_setup (struct drm_device *dev,unsigned int preferred_bpp) +{ +struct drm_fb_helper *fb_helper; +int ret; + +drm_WARN (dev, !dev->registered,"Device has not been registered.\n" ); +drm_WARN (dev, dev->fb_helper,"fb_helper is already set!\n" ); + + fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); +if (!fb_helper) +return ; +drm_fb_helper_prepare (dev, fb_helper, preferred_bpp, &drm_fbdev_dma_helper_funcs); + + ret =drm_client_init (dev, &fb_helper->client,"fbdev" , &drm_fbdev_dma_client_funcs); +if (ret) { +drm_err (dev,"Failed to register client: %d\n" , ret); + goto err_drm_client_init; + } + + ret =drm_fbdev_dma_client_hotplug (&fb_helper->client); +if (ret) +drm_dbg_kms (dev,"client hotplug ret=%d\n" , ret);
drivers/gpu/drm/drm_fbdev_dma.c line 275
Quoted 10 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +10
-0+ +drm_client_register (&fb_helper->client); + +return ; + +err_drm_client_init: +drm_fb_helper_unprepare (fb_helper); +kfree (fb_helper); +} +EXPORT_SYMBOL (drm_fbdev_dma_setup);
And this one could also be shared AFAICT if drm_fbdev_client_hotplug() is used instead.
Quoted 12 lines
include/drm/drm_fbdev_dma.h new file +5
-0@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: MIT */ + +#ifndef DRM_FBDEV_DMA_H +#define DRM_FBDEV_DMA_H +
include/drm/drm_fbdev_dma.h line 15
Quoted 10 lines
include/drm/drm_fbdev_dma.h new file +10
-0+struct drm_device ; + +#ifdef CONFIG_DRM_FBDEV_EMULATION +void drm_fbdev_dma_setup (struct drm_device *dev,unsigned int preferred_bpp); +#else +static inline void drm_fbdev_dma_setup (struct drm_device *dev,unsigned int preferred_bpp) +{ } +#endif + +#endif
And you should be able to drop this header too if split the common helpers from drm_fbdev_generic.c or maybe I'm missing something ?
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Re: [PATCH 01/22] drm/fbdev-dma: Implement fbdev emulation for GEM DMA helpers
Javier Martinez Canillas <[email protected]> writes:
[...]
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +16
-0+drm_fb_helper_prepare (dev, fb_helper, preferred_bpp, &drm_fbdev_dma_helper_funcs); + + ret =drm_client_init (dev, &fb_helper->client,"fbdev" , &drm_fbdev_dma_client_funcs); +if (ret) { +drm_err (dev,"Failed to register client: %d\n" , ret); + goto err_drm_client_init; + } + + ret =drm_fbdev_dma_client_hotplug (&fb_helper->client); +if (ret) +drm_dbg_kms (dev,"client hotplug ret=%d\n" , ret); + +drm_client_register (&fb_helper->client); + +return ; +
Quoted 9 lines
drivers/gpu/drm/drm_fbdev_dma.c line 275
Quoted 5 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +5
-0+err_drm_client_init: +drm_fb_helper_unprepare (fb_helper); +kfree (fb_helper); +} +EXPORT_SYMBOL (drm_fbdev_dma_setup);And this one could also be shared AFAICT if
drm_fbdev_client_hotplug()is used instead.
Scratch this one, you need the custom setup function to pass the drm_fbdev_dma_helper_funcs to drm_client_init(). But I think the other comments this apply.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerRe: [PATCH 01/22] drm/fbdev-dma: Implement fbdev emulation for GEM DMA helpers
In reply to Javier Martinez CanillasHi Javier,
thanks for your review.
Am 09.03.23 um 12:04 schrieb Javier Martinez Canillas:
Quoted 8 lines
Quoted 2 lines · Thomas Zimmermann
Implement fbdev emulation that is optimized for drivers that use DMA helpers. The buffers may no tbe moveable, may not require damage
"may not be"
Is may the correct verb here though? I guess you meant "shall not".
I cannnot say for sure, but I always thought 'may not' is a nicer term for 'must not'. But RFC2119 disagrees wrt to the use of 'may'. I'll change the wording to 'must not'.
Quoted 36 lines
Quoted 16 lines
handling and have to be located in system memory. This allows fbdev emulation to operate directly on the buffer and mmap it to userspace.
Besides those constraints, the emulation works like in the generic code. As an internal DRM client provides, it receives hotplug, restore and unregister events. The DRM client is independent from the fbdev probing, which runs on the first successful hotplug event.
The emulation is part of the DMA helper module and not build unless DMA helpers and fbdev emulation has been configured.
Tested with vc4.
Signed-off-by Thomas Zimmermann <[email protected]>---
[...]
Quoted 17 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +17
-0+static int drm_fbdev_dma_fb_open (struct fb_info *info,int user) +{ +struct drm_fb_helper *fb_helper = info->par; + +/* No need to take a ref for fbcon because it unbinds on unregister */ +if (user && !try_module_get (fb_helper->dev->driver->fops->owner)) +return -ENODEV ; + +return 0 ; +} + +static int drm_fbdev_dma_fb_release (struct fb_info *info,int user) +{ +struct drm_fb_helper *fb_helper = info->par; + +if (user) +module_put (fb_helper->dev->driver->fops->owner);
Quoted 8 lines
drivers/gpu/drm/drm_fbdev_dma.c line 25
Quoted 4 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +4
-0+ +return 0 ; +} +These two functions are the same than what's used by the generic fbdev emulation. Maybe they could be moved to
drivers/gpu/drm/drm_fb_helper.cand be reused ?
I deliberately did not share code between the existing generic fbdev emulation and the new one. A number of drivers come with their own fbdev code and need conversion to struct drm_client. I want to see if there really is a pattern can can be shared in a helper.
I've done 'premature helperization' before and had to undo it later on. The existing fbdev code is an example of that. I'm trying to not do this mistake again.
Quoted 25 lines
Quoted 25 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +24
-0+static int drm_fbdev_dma_helper_fb_probe (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_surface_size *sizes) +{ +struct drm_client_dev *client = &fb_helper->client; +struct drm_device *dev = fb_helper->dev; +struct drm_client_buffer *buffer; +struct drm_gem_dma_object *dma_obj; +struct drm_framebuffer *fb; +struct fb_info *info; +u32 format; +struct iosys_map map; +int ret; + +drm_dbg_kms (dev,"surface width(%d), height(%d) and bpp(%d)\n" , + sizes->surface_width, sizes->surface_height, + sizes->surface_bpp); + + format =drm_mode_legacy_fb_format (sizes->surface_bpp, sizes->surface_depth); + buffer =drm_client_framebuffer_create (client, sizes->surface_width, + sizes->surface_height, format); +if (IS_ERR (buffer)) +return PTR_ERR (buffer); + dma_obj =to_drm_gem_dma_obj (buffer->gem); +
Quoted 8 lines
drivers/gpu/drm/drm_fbdev_dma.c line 109
Quoted 5 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +5
-0+ fb = buffer->fb; +if (drm_WARN_ON (dev, fb->funcs->dirty)) { + ret = -ENODEV ;/* damage handling not supported; use generic emulation */ + goto err_drm_client_buffer_delete; + }Should we have a similar check for
drm_fbdev_use_shadow_fb(fb_helper)and warn on ?
That function (and several others) will go away soon. After the fbdev code for DMA helpers has been merged, generic fbdev will go shadow-fb-only.
Quoted 10 lines
drivers/gpu/drm/drm_fbdev_dma.c line 115
Quoted 7 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +6
-0+ + ret =drm_client_buffer_vmap (buffer, &map); +if (ret) { + goto err_drm_client_buffer_delete; + }else if (drm_WARN_ON (dev, map.is_iomem)) { + ret = -ENODEV ;/* I/O memory not supported; use generic emulation */ I also wonder if here and above instead of the warn on, there should just be a normal check and print more verbose warning messages.
No, because it's a driver bug that should be fixed ASAP. The driver should call generic fbdev instead. A regular warning would be appropriate for a runtime error over which the driver has no control, such as a OOM.
Quoted 18 lines
[...]
drivers/gpu/drm/drm_fbdev_dma.c line 179
Quoted 12 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +12
-0+static void drm_fbdev_dma_client_unregister (struct drm_client_dev *client) +{ +struct drm_fb_helper *fb_helper =drm_fb_helper_from_client (client); + +if (fb_helper->info) { +drm_fb_helper_unregister_info (fb_helper); + }else { +drm_client_release (&fb_helper->client); +drm_fb_helper_unprepare (fb_helper); +kfree (fb_helper); + } +}This is again the same than
drm_fbdev_client_unregister()so I think that can be made a helper and shared bewteen the two implementations.
I've have the same discussion with Patrik when I sent such an updte for gma500. These functions are the same, but I think this will change.
Here in _unregister(), the kfree() expects struct drm_fb_helper. But other drivers will certainly have their own structures and then require their own unregister helpers.
Quoted 10 lines
drivers/gpu/drm/drm_fbdev_dma.c line 186
Quoted 8 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +7
-0+ +static int drm_fbdev_dma_client_restore (struct drm_client_dev *client) +{ +drm_fb_helper_lastclose (client->dev); + +return 0 ; +}Same for this one.
Maybe more sharable, but there will be a version that supports vgaswitcheroo on several drivers.
Quoted 24 lines
Quoted 24 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +23
-0+ +static int drm_fbdev_dma_client_hotplug (struct drm_client_dev *client) +{ +struct drm_fb_helper *fb_helper =drm_fb_helper_from_client (client); +struct drm_device *dev = client->dev; +int ret; + +if (dev->fb_helper) +return drm_fb_helper_hotplug_event (dev->fb_helper); + + ret =drm_fb_helper_init (dev, fb_helper); +if (ret) + goto err_drm_err; + +if (!drm_drv_uses_atomic_modeset (dev)) +drm_helper_disable_unused_functions (dev); + + ret =drm_fb_helper_initial_config (fb_helper); +if (ret) + goto err_drm_fb_helper_fini; + +return 0 ; +
Quoted 8 lines
drivers/gpu/drm/drm_fbdev_dma.c line 215
Quoted 6 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +6
-0+err_drm_fb_helper_fini: +drm_fb_helper_fini (fb_helper); +err_drm_err: +drm_err (dev,"fbdev-dma: Failed to setup generic emulation (ret=%d)\n" , ret); +return ret; +}And this one.
I think, we should try to remove drm_fb_helper_funcs and therefore merge probe into hotplug. Each fbdev emulation will then require its own _hotplug() function. So this code won't be shareable in the future.
As I outlined before, I intentionally didn't share this code because I expect that it will be 'un-shared' in the near future.
Quoted 74 lines
Quoted 43 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +42
-0+/** +* drm_fbdev_dma_setup() - Setup fbdev emulation for GEM DMA helpers +* @dev: DRM device +* @preferred_bpp: Preferred bits per pixel for the device. +* @dev->mode_config.preferred_depth is used if this is zero. +* +* This function sets up fbdev emulation for GEM DMA drivers that support +* dumb buffers with a virtual address and that can be mmap'ed. +* drm_fbdev_dma_setup() shall be called after the DRM driver registered +* the new DRM device with drm_dev_register(). +* +* Restore, hotplug events and teardown are all taken care of. Drivers that do +* suspend/resume need to call drm_fb_helper_set_suspend_unlocked() themselves. +* Simple drivers might use drm_mode_config_helper_suspend(). +* +* This function is safe to call even when there are no connectors present. +* Setup will be retried on the next hotplug event. +* +* The fbdev is destroyed by drm_dev_unregister(). +*/ +void drm_fbdev_dma_setup (struct drm_device *dev,unsigned int preferred_bpp) +{ +struct drm_fb_helper *fb_helper; +int ret; + +drm_WARN (dev, !dev->registered,"Device has not been registered.\n" ); +drm_WARN (dev, dev->fb_helper,"fb_helper is already set!\n" ); + + fb_helper =kzalloc (sizeof (*fb_helper),GFP_KERNEL ); +if (!fb_helper) +return ; +drm_fb_helper_prepare (dev, fb_helper, preferred_bpp, &drm_fbdev_dma_helper_funcs); + + ret =drm_client_init (dev, &fb_helper->client,"fbdev" , &drm_fbdev_dma_client_funcs); +if (ret) { +drm_err (dev,"Failed to register client: %d\n" , ret); + goto err_drm_client_init; + } + + ret =drm_fbdev_dma_client_hotplug (&fb_helper->client); +if (ret) +drm_dbg_kms (dev,"client hotplug ret=%d\n" , ret);drivers/gpu/drm/drm_fbdev_dma.c line 275
Quoted 10 lines
drivers/gpu/drm/drm_fbdev_dma.c new file +10
-0+ +drm_client_register (&fb_helper->client); + +return ; + +err_drm_client_init: +drm_fb_helper_unprepare (fb_helper); +kfree (fb_helper); +} +EXPORT_SYMBOL (drm_fbdev_dma_setup);And this one could also be shared AFAICT if
drm_fbdev_client_hotplug()is used instead.Quoted 17 lines
include/drm/drm_fbdev_dma.h new file +11
-0@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: MIT */ + +#ifndef DRM_FBDEV_DMA_H +#define DRM_FBDEV_DMA_H + +struct drm_device ; + +#ifdef CONFIG_DRM_FBDEV_EMULATION +void drm_fbdev_dma_setup (struct drm_device *dev,unsigned int preferred_bpp); +#else +static inline void drm_fbdev_dma_setup (struct drm_device *dev,unsigned int preferred_bpp)
Quoted 8 lines
include/drm/drm_fbdev_dma.h line 15
Quoted 5 lines
include/drm/drm_fbdev_dma.h new file +4
-0+{ } +#endif + +#endif And you should be able to drop this header too if split the common helpers from
drm_fbdev_generic.cor maybe I'm missing something ?
This is the header that drivers include to run DMA fbdev emulation. We cannot remove it.
Best regards
Thomas
Quoted 1 line
Signature · 13 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 N?rnberg, Germany (HRB 36809, AG N?rnberg) Gesch?ftsf?hrer: Ivo Totev -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 840 bytes Desc: OpenPGP digital signature URL: <http://lists.ozlabs.org/pipermail/linux-aspeed/attachments/20230310/30eeef11/attachment-0001.sig>
Thomas Zimmermann
maintainerPATCH 2/22 arm/hdlcd: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/arm/hdlcd_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/arm/hdlcd_drv.c +2 -2
@@ -26,7 +26,7 @@#include <drm/drm_crtc.h> #include <drm/drm_debugfs.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h>
@@ -301,7 +301,7 @@ static int hdlcd_drm_bind(struct device *dev)if (ret) goto err_register; -drm_fbdev_generic_setup (drm,32 ); +drm_fbdev_dma_setup (drm,32 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 02/22] arm/hdlcd: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 3/22 arm/malidp: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/arm/malidp_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/arm/malidp_drv.c +2 -2
@@ -19,7 +19,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_fourcc.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
@@ -852,7 +852,7 @@ static int malidp_bind(struct device *dev)if (ret) goto register_fail; -drm_fbdev_generic_setup (drm,32 ); +drm_fbdev_dma_setup (drm,32 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 03/22] arm/malidp: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 4/22 drm/aspeed: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +2 -2
@@ -15,7 +15,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_device.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_module.h>
@@ -341,7 +341,7 @@ static int aspeed_gfx_probe(struct platform_device *pdev)if (ret) goto err_unload; -drm_fbdev_generic_setup (&priv->drm,32 ); +drm_fbdev_dma_setup (&priv->drm,32 );return 0 ; err_unload:
Signature · 1 line
2.39.2
Re: [PATCH 04/22] drm/aspeed: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 5/22 drm/atmel-hlcdc: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +2 -2
@@ -19,7 +19,7 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_module.h>
@@ -760,7 +760,7 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev)if (ret) goto err_unload; -drm_fbdev_generic_setup (ddev,24 ); +drm_fbdev_dma_setup (ddev,24 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 05/22] drm/atmel-hlcdc: Use GEM DMA fbdev emulation
Quoted 4 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>
Quoted 28 lines
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +2
-2@@ -19,7 +19,7 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_module.h> @@ -760,7 +760,7 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev)if (ret) goto err_unload; -drm_fbdev_generic_setup (ddev,24 ); +drm_fbdev_dma_setup (ddev,24 );return 0 ;Signature · 1 line
2.39.2
Re: [PATCH 05/22] drm/atmel-hlcdc: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannQuoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 6/22 drm/fsl-dcu: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +2 -2
@@ -20,7 +20,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_modeset_helper.h> #include <drm/drm_module.h>
@@ -333,7 +333,7 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)if (ret <0 ) goto put; -drm_fbdev_generic_setup (drm, legacyfb_depth); +drm_fbdev_dma_setup (drm, legacyfb_depth);return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 06/22] drm/fsl-dcu: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 7/22 drm/imx/dcss: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/imx/dcss/dcss-kms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/imx/dcss/dcss-kms.c +2 -2
@@ -7,7 +7,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_bridge_connector.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_of.h>
@@ -145,7 +145,7 @@ struct dcss_kms_dev *dcss_kms_attach(struct dcss_dev *dcss)if (ret) goto cleanup_crtc; -drm_fbdev_generic_setup (drm,32 ); +drm_fbdev_dma_setup (drm,32 );return kms;
Signature · 1 line
2.39.2
Re: [PATCH 07/22] drm/imx/dcss: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 8/22 drm/imx: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/imx/ipuv3/imx-drm-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/imx/ipuv3/imx-drm-core.c +2 -2
@@ -16,7 +16,7 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_managed.h>
@@ -249,7 +249,7 @@ static int imx_drm_bind(struct device *dev)if (ret) goto err_poll_fini; -drm_fbdev_generic_setup (drm, legacyfb_depth); +drm_fbdev_dma_setup (drm, legacyfb_depth);return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 08/22] drm/imx: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Re: [PATCH 08/22] drm/imx: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannQuoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 9/22 drm/kmb: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/kmb/kmb_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/kmb/kmb_drv.c +2 -2
@@ -15,7 +15,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_module.h>
@@ -562,7 +562,7 @@ static int kmb_probe(struct platform_device *pdev)if (ret) goto err_register; -drm_fbdev_generic_setup (&kmb->drm,0 ); +drm_fbdev_dma_setup (&kmb->drm,0 );return 0 ;
Signature · 1 line
2.39.2
RE: [PATCH 09/22] drm/kmb: Use GEM DMA fbdev emulation
Quoted 56 lines
-----Original Message-----
From: Thomas Zimmermann <[email protected]>
Sent: Wednesday, March 1, 2023 7:31 AM
To: javierm at redhat.com; maarten.lankhorst at linux.intel.com; mripard at kernel.org; airlied at gmail.com; daniel at ffwll.ch; andrew at aj.id.au; laurentiu.palcu at oss.nxp.com; l.stach at pengutronix.de;
shawnguo at kernel.org; s.hauer at pengutronix.de; kernel at pengutronix.de; festevam at gmail.com; linux-imx at nxp.com; p.zabel at pengutronix.de; Chrisanthus, Anitha <[email protected]>;
edmund.j.dea at intel.com; khilman at baylibre.com; jbrunet at baylibre.com; martin.blumenstingl at googlemail.com; alain.volmat at foss.st.com; yannick.fertre at foss.st.com; raphael.gallais-pou at foss.st.com; philippe.cornu at foss.st.com; mcoquelin.stm32 at gmail.com; alexandre.torgue at foss.st.com; jernej.skrabec at gmail.com;
samuel at sholland.org; jyri.sarha at iki.fi; tomba at kernel.org; linus.walleij at linaro.org; hyun.kwon at xilinx.com;
laurent.pinchart at ideasonboard.com
Cc: dri-devel at lists.freedesktop.org; linux-aspeed at lists.ozlabs.org; linux-arm- kernel at lists.infradead.org; linux-amlogic at lists.infradead.org; linux- stm32 at st-md-mailman.stormreply.com; linux-sunxi at lists.linux.dev; Thomas Zimmermann <[email protected]>
Subject: [PATCH 09/22] drm/kmb: Use GEM DMA fbdev emulationUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/kmb/kmb_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/kmb/kmb_drv.c +2
-3@@ -15,7 +15,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_module.h> @@ -562,7 +562,7 @@ static int kmb_probe(struct platform_device *pdev)if (ret) goto err_register; -drm_fbdev_generic_setup (&kmb->drm,0 ); +drm_fbdev_dma_setup (&kmb->drm,0 );return 0 ; --2.39.2
Re: [PATCH 09/22] drm/kmb: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannQuoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 10/22 drm/logicvc: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/logicvc/logicvc_drm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/logicvc/logicvc_drm.c +2 -2
@@ -17,7 +17,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_print.h>
@@ -449,7 +449,7 @@ static int logicvc_drm_probe(struct platform_device *pdev) preferred_bpp =32 ;break ; } -drm_fbdev_generic_setup (drm_dev, preferred_bpp); +drm_fbdev_dma_setup (drm_dev, preferred_bpp);return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 10/22] drm/logicvc: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 11/22 drm/meson: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/meson/meson_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/meson/meson_drv.c +2 -2
@@ -18,7 +18,7 @@#include <drm/drm_aperture.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper_vtables.h>
@@ -353,7 +353,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)if (ret) goto uninstall_irq; -drm_fbdev_generic_setup (drm,32 ); +drm_fbdev_dma_setup (drm,32 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 11/22] drm/meson: Use GEM DMA fbdev emulation
Quoted 5 lines · On Wed, Mar 1, 2023 at 4:31?PM Thomas Zimmermann <[email protected]> wrote:
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>
Re: [PATCH 11/22] drm/meson: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannQuoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 12/22 drm/mxsfb/lcdif: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/mxsfb/lcdif_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/mxsfb/lcdif_drv.c +2 -2
@@ -16,7 +16,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_bridge.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_mode_config.h>
@@ -220,7 +220,7 @@ static int lcdif_probe(struct platform_device *pdev)if (ret) goto err_unload; -drm_fbdev_generic_setup (drm,32 ); +drm_fbdev_dma_setup (drm,32 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 12/22] drm/mxsfb/lcdif: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 13/22 drm/mxsfb: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/mxsfb/mxsfb_drv.c +2 -2
@@ -20,7 +20,7 @@#include <drm/drm_bridge.h> #include <drm/drm_connector.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_fourcc.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
@@ -365,7 +365,7 @@ static int mxsfb_probe(struct platform_device *pdev)if (ret) goto err_unload; -drm_fbdev_generic_setup (drm,32 ); +drm_fbdev_dma_setup (drm,32 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 13/22] drm/mxsfb: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 14/22 drm/sti: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/sti/sti_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/sti/sti_drv.c +2 -2
@@ -14,7 +14,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_debugfs.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_of.h>
@@ -199,7 +199,7 @@ static int sti_bind(struct device *dev)drm_mode_config_reset (ddev); -drm_fbdev_generic_setup (ddev,32 ); +drm_fbdev_dma_setup (ddev,32 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 14/22] drm/sti: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 15/22 drm/stm: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/stm/drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/stm/drv.c +2 -2
@@ -18,7 +18,7 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_module.h>
@@ -203,7 +203,7 @@ static int stm_drm_platform_probe(struct platform_device *pdev)if (ret) goto err_put; -drm_fbdev_generic_setup (ddev,16 ); +drm_fbdev_dma_setup (ddev,16 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 15/22] drm/stm: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 16/22 drm/sun4i: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/sun4i/sun4i_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/sun4i/sun4i_drv.c +2 -2
@@ -17,7 +17,7 @@#include <drm/drm_aperture.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_module.h> #include <drm/drm_of.h>
@@ -111,7 +111,7 @@ static int sun4i_drv_bind(struct device *dev)if (ret) goto finish_poll; -drm_fbdev_generic_setup (drm,32 ); +drm_fbdev_dma_setup (drm,32 );dev_set_drvdata (dev, drm);
Signature · 1 line
2.39.2
Re: [PATCH 16/22] drm/sun4i: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 17/22 drm/tidss: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/tidss/tidss_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tidss/tidss_drv.c +2 -2
@@ -13,7 +13,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_managed.h> #include <drm/drm_module.h>
@@ -179,7 +179,7 @@ static int tidss_probe(struct platform_device *pdev) goto err_irq_uninstall; } -drm_fbdev_generic_setup (ddev,32 ); +drm_fbdev_dma_setup (ddev,32 );dev_dbg (dev,"%s done\n" , __func__);
Signature · 1 line
2.39.2
Re: [PATCH 17/22] drm/tidss: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 18/22 drm/tilcdc: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tilcdc/tilcdc_drv.c +2 -2
@@ -16,7 +16,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_debugfs.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_fourcc.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
@@ -384,7 +384,7 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev) goto init_failed; priv->is_registered = true; -drm_fbdev_generic_setup (ddev, bpp); +drm_fbdev_dma_setup (ddev, bpp);return 0 ; init_failed:
Signature · 1 line
2.39.2
Re: [PATCH 18/22] drm/tilcdc: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 19/22 drm/arcpgu: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/tiny/arcpgu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tiny/arcpgu.c +2 -2
@@ -12,7 +12,7 @@#include <drm/drm_drv.h> #include <drm/drm_edid.h> #include <drm/drm_fb_dma_helper.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_dma_helper.h>
@@ -394,7 +394,7 @@ static int arcpgu_probe(struct platform_device *pdev)if (ret) goto err_unload; -drm_fbdev_generic_setup (&arcpgu->drm,16 ); +drm_fbdev_dma_setup (&arcpgu->drm,16 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 19/22] drm/arcpgu: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 20/22 drm/tve200: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/tve200/tve200_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tve200/tve200_drv.c +2 -2
@@ -40,7 +40,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_bridge.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_module.h>
@@ -227,7 +227,7 @@ static int tve200_probe(struct platform_device *pdev)* Passing in 16 here will make the RGB565 mode the default * Passing in 32 will use XRGB8888 mode */ -drm_fbdev_generic_setup (drm,16 ); +drm_fbdev_dma_setup (drm,16 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 20/22] drm/tve200: Use GEM DMA fbdev emulation
Quoted 4 lines · On Wed, Mar 1, 2023 at 4:31?PM Thomas Zimmermann <[email protected]> wrote:
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>
That sounds neat:
Yours,
Linus Walleij
Re: [PATCH 20/22] drm/tve200: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannQuoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 21/22 drm/vc4: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/vc4/vc4_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_drv.c +2 -2
@@ -33,7 +33,7 @@#include <drm/drm_aperture.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_vblank.h> #include <soc/bcm2835/raspberrypi-firmware.h>
@@ -387,7 +387,7 @@ static int vc4_drm_bind(struct device *dev)if (ret <0 ) goto unbind_all; -drm_fbdev_generic_setup (drm,16 ); +drm_fbdev_dma_setup (drm,16 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 21/22] drm/vc4: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 22/22 drm/xlnx: Use GEM DMA fbdev emulation
In reply to Thomas ZimmermannUse the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
--- drivers/gpu/drm/xlnx/zynqmp_kms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xlnx/zynqmp_kms.c +2 -2
@@ -19,7 +19,7 @@#include <drm/drm_device.h> #include <drm/drm_drv.h> #include <drm/drm_encoder.h> -#include <drm/drm_fbdev_generic.h> +#include <drm/drm_fbdev_dma.h> #include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_dma_helper.h>
@@ -515,7 +515,7 @@ int zynqmp_dpsub_drm_init(struct zynqmp_dpsub *dpsub) goto err_poll_fini;/* Initialize fbdev generic emulation. */ -drm_fbdev_generic_setup (drm,24 ); +drm_fbdev_dma_setup (drm,24 );return 0 ;
Signature · 1 line
2.39.2
Re: [PATCH 22/22] drm/xlnx: Use GEM DMA fbdev emulation
Quoted 5 lines · Thomas Zimmermann
Use the fbdev emulation that is optimized for DMA helpers. Avoids possible shadow buffering and makes the code simpler.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Quoted 11 lines · On Wed, Mar 1, 2023 at 4:31?PM Thomas Zimmermann <[email protected]> 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
maintainerHi
Am 06.03.23 um 23:19 schrieb Linus Walleij:
Quoted 8 lines · On Wed, Mar 1, 2023 at 4:31?PM Thomas Zimmermann <[email protected]> wrote:
Quoted 7 lines
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.
Quoted 7 lines
Quoted 5 lines
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. :)
Quoted 4 lines
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.'
Quoted 6 lines
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
Quoted 5 lines
They aren't much different in how they work from the TVE200.
Yours,
Linus Walleij
Signature · 13 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 N?rnberg, Germany (HRB 36809, AG N?rnberg) Gesch?ftsf?hrer: Ivo Totev -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 840 bytes Desc: OpenPGP digital signature URL: <http://lists.ozlabs.org/pipermail/linux-aspeed/attachments/20230307/f4147fe7/attachment.sig>
Quoted 10 lines · On Tue, Mar 7, 2023 at 9:55?AM Thomas Zimmermann <[email protected]> wrote:
Am 06.03.23 um 23:19 schrieb Linus Walleij:
Quoted 3 lines
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#L97for 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