mbox series

[v2,00/11] drm: Improve fbdev emulation for DMA-able framebuffers

Message ID 20230706124905.15134-1-tzimmermann@suse.de
Headers show
Series drm: Improve fbdev emulation for DMA-able framebuffers | expand

Message

Thomas Zimmermann July 6, 2023, 12:46 p.m. UTC
Add fbdev helpers for framebuffers in DMA-able memory and update
fbdev emulation in the respective DRM drivers. DMA memory used to
handled as system memory. Improve this and prepare for possible
future changes.

Patch 1 adds initializer macros for struct fb_ops and a Kconfig
token for framebuffers in DMA memory.

Patches 2 to 4 update fbdev-dma and tegra. No functional changes
are expected as both used system memory before.

Patches 5 and 6 update exynos to use DMA helpers. Exynos incorrectly
used fbdev's I/O-memory helpers. Fix this.

Patches 7 to 9 update omapdrm to use DMA helpers. Patch 7 first
reworks the driver's mmap to current best practices. This also makes
it suitable for use with fbdev, which patches 8 and 9 implement.

Patchies 10 removes some fbdev macros for system memory that are now
unused; patch 11 fixes some comments.

The patchset would ideally go through drm-misc-next. Future patches
can build upon it and update fbdev drivers in similar ways.

v2:
	* fix omap mmap flags
	* drop FBINFO_DEFAULT from patches
	* minor cleanups

Thomas Zimmermann (11):
  fbdev: Add fb_ops init macros for framebuffers in DMA-able memory
  drm/fbdev-dma: Use fbdev DMA helpers
  drm/tegra: Use fbdev DMA helpers
  drm/tegra: Set fbdev FBINFO_VIRTFB flag
  drm/exynos: Use fbdev DMA helpers
  drm/exynos: Set fbdev FBINFO_VIRTFB flag
  drm/omapdrm: Set VM flags in GEM-object mmap function
  drm/omapdrm: Use GEM mmap for fbdev emulation
  drm/omapdrm: Set fbdev FBINFO_VIRTFB flag
  fbdev: Remove FB_DEFAULT_SYS_OPS
  fbdev: Harmonize some comments in <linux/fb.h>

 drivers/gpu/drm/Kconfig                   |  2 +-
 drivers/gpu/drm/drm_fbdev_dma.c           |  4 ++--
 drivers/gpu/drm/exynos/Kconfig            |  2 +-
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c |  5 ++--
 drivers/gpu/drm/omapdrm/Kconfig           |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c        | 12 +---------
 drivers/gpu/drm/omapdrm/omap_fbdev.c      | 16 +++++++++++--
 drivers/gpu/drm/omapdrm/omap_gem.c        | 24 +++++--------------
 drivers/gpu/drm/omapdrm/omap_gem.h        |  3 ---
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  7 +-----
 drivers/gpu/drm/tegra/Kconfig             |  2 +-
 drivers/gpu/drm/tegra/fbdev.c             |  5 ++--
 drivers/video/fbdev/Kconfig               |  8 +++++++
 include/linux/fb.h                        | 29 ++++++++++-------------
 14 files changed, 55 insertions(+), 66 deletions(-)

Comments

Thierry Reding July 6, 2023, 2:31 p.m. UTC | #1
On Thu, Jul 06, 2023 at 02:46:42PM +0200, Thomas Zimmermann wrote:
> Mark the framebuffer with FBINFO_VIRTFB. The framebuffer range is
> in DMA-able memory and should be accessed with the CPU's regular
> memory ops.
> 
> v2:
> 	* drop FBINFO_DEFAULT
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> Acked-by: Maxime Ripard <mripard@kernel.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Mikko Perttunen <mperttunen@nvidia.com>
> ---
>  drivers/gpu/drm/tegra/fbdev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c
> index 82577b7c88da..d8460c5dc91e 100644
> --- a/drivers/gpu/drm/tegra/fbdev.c
> +++ b/drivers/gpu/drm/tegra/fbdev.c
> @@ -132,6 +132,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
>  		}
>  	}
>  
> +	info->flags |= FBINFO_VIRTFB;
>  	info->screen_base = (void __iomem *)bo->vaddr + offset;

As part of this, do we also need to set info->screen_buffer instead of
info->screen_base? The drm_fbdev_dma_helper functions do that.

Thierry

>  	info->screen_size = size;
>  	info->fix.smem_start = (unsigned long)(bo->iova + offset);
> -- 
> 2.41.0
>
Thomas Zimmermann July 6, 2023, 2:47 p.m. UTC | #2
Hi

Am 06.07.23 um 16:31 schrieb Thierry Reding:
> On Thu, Jul 06, 2023 at 02:46:42PM +0200, Thomas Zimmermann wrote:
>> Mark the framebuffer with FBINFO_VIRTFB. The framebuffer range is
>> in DMA-able memory and should be accessed with the CPU's regular
>> memory ops.
>>
>> v2:
>> 	* drop FBINFO_DEFAULT
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
>> Acked-by: Maxime Ripard <mripard@kernel.org>
>> Cc: Thierry Reding <thierry.reding@gmail.com>
>> Cc: Mikko Perttunen <mperttunen@nvidia.com>
>> ---
>>   drivers/gpu/drm/tegra/fbdev.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c
>> index 82577b7c88da..d8460c5dc91e 100644
>> --- a/drivers/gpu/drm/tegra/fbdev.c
>> +++ b/drivers/gpu/drm/tegra/fbdev.c
>> @@ -132,6 +132,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
>>   		}
>>   	}
>>   
>> +	info->flags |= FBINFO_VIRTFB;
>>   	info->screen_base = (void __iomem *)bo->vaddr + offset;
> 
> As part of this, do we also need to set info->screen_buffer instead of
> info->screen_base? The drm_fbdev_dma_helper functions do that.

Indeed, good point. I'll update this in the next iteration.

Best regards
Thomas

> 
> Thierry
> 
>>   	info->screen_size = size;
>>   	info->fix.smem_start = (unsigned long)(bo->iova + offset);
>> -- 
>> 2.41.0
>>