Skip to contentSkip to conversation

drm: Improve fbdev emulation for DMA-able framebuffers

PATCH Superseded Thomas Zimmermann 4 participants 30 messages Jul 4, 2023 – Jul 6, 2023

Subsystems (8)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

cover drm: Improve fbdev emulation for DMA-able framebuffers

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.

Patch 10 removes some fbdev macros for system memory that are now unused.

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

Thomas Zimmermann (10):
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 flags
drm/exynos: Use fbdev DMA helpers
drm/exynos: Set fbdev flags
drm/omapdrm: Set VM flags in GEM-object mmap function drm/omapdrm: Use GEM mmap for fbdev emulation drm/omapdrm: Set fbdev flags
fbdev: Remove FB_DEFAULT_SYS_OPS

 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 |  6 ++++--
 drivers/gpu/drm/omapdrm/Kconfig           |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c        | 12 +-----------
 drivers/gpu/drm/omapdrm/omap_fbdev.c      | 17 ++++++++++++++--
 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             |  7 +++++--
 drivers/video/fbdev/Kconfig               |  8 ++++++++
 include/linux/fb.h                        | 17 ++++++++++------
 14 files changed, 57 insertions(+), 56 deletions(-)
Signature · 1 line
2.41.0
author maintainer
#1 lore raw

PATCH 1/10 fbdev: Add fb_ops init macros for framebuffers in DMA-able memory

Add initializer macros for struct fb_ops for framebuffers in DMA-able memory areas. Also add a corresponding Kconfig token. As of now, this is equivalent to system framebuffers and mostly useful for labeling drivers correctly.

A later patch may add a generic DMA-specific mmap operation. Linux offers a number of dma_mmap_*() helpers for different use cases.

---
 drivers/video/fbdev/Kconfig |  8 ++++++++
 include/linux/fb.h          | 13 +++++++++++++
 2 files changed, 21 insertions(+)
drivers/video/fbdev/Kconfig +8 -0
index cecf15418632..f14229757311 100644
@@ -168,6 +168,14 @@ config FB_DEFERRED_IO
 	bool
 	depends on FB
 
+config FB_DMA_HELPERS
+	bool
+	depends on FB
+	select FB_SYS_COPYAREA
+	select FB_SYS_FILLRECT
+	select FB_SYS_FOPS
+	select FB_SYS_IMAGEBLIT
+
 config FB_IO_HELPERS
 	bool
 	depends on FB
include/linux/fb.h +13 -0
index 1d5c13f34b09..1191a78c5289 100644
@@ -594,6 +594,19 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
 	__FB_DEFAULT_SYS_OPS_DRAW, \
 	__FB_DEFAULT_SYS_OPS_MMAP
 
+/*
+ * Helpers for framebuffers in DMA-able memory
+ */
+
+#define __FB_DEFAULT_DMA_OPS_RDWR \
+	.fb_read	= fb_sys_read, \
+	.fb_write	= fb_sys_write
+
+#define __FB_DEFAULT_DMA_OPS_DRAW \
+	.fb_fillrect	= sys_fillrect, \
+	.fb_copyarea	= sys_copyarea, \
+	.fb_imageblit	= sys_imageblit
+
 /* drivers/video/fbmem.c */
 extern int register_framebuffer(struct fb_info *fb_info);
 extern void unregister_framebuffer(struct fb_info *fb_info);
Signature · 1 line
2.41.0
Reviewed-by on v1 1/10
#2 lore raw

Re: [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory

Thomas Zimmermann <[email protected]> writes:

Hello Thomas,

Quoted 39 lines

Add initializer macros for struct fb_ops for framebuffers in DMA-able memory areas. Also add a corresponding Kconfig token. As of now, this is equivalent to system framebuffers and mostly useful for labeling drivers correctly.

A later patch may add a generic DMA-specific mmap operation. Linux offers a number of dma_mmap_*() helpers for different use cases.

---
 drivers/video/fbdev/Kconfig |  8 ++++++++
 include/linux/fb.h          | 13 +++++++++++++
 2 files changed, 21 insertions(+)
drivers/video/fbdev/Kconfig +8 -0
index cecf15418632..f14229757311 100644
@@ -168,6 +168,14 @@ config FB_DEFERRED_IO
 	bool
 	depends on FB
 
+config FB_DMA_HELPERS
+	bool
+	depends on FB
+	select FB_SYS_COPYAREA
+	select FB_SYS_FILLRECT
+	select FB_SYS_FOPS
+	select FB_SYS_IMAGEBLIT
+
 config FB_IO_HELPERS
 	bool
 	depends on FB
include/linux/fb.h +0 -0
index 1d5c13f34b09..1191a78c5289 100644

include/linux/fb.h extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf, · line 600

Quoted 7 lines
include/linux/fb.h +4 -0
@@ -594,6 +594,19 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
 	__FB_DEFAULT_SYS_OPS_DRAW, \
 	__FB_DEFAULT_SYS_OPS_MMAP
 
+/*
+ * Helpers for framebuffers in DMA-able memory
+ */
+

The comment for I/O memory helpers says:

/*
* Initializes struct fb_ops for framebuffers in I/O memory. */

I think that would be good to have consistency between these two, so something like:

/*
* Initializes struct fb_ops for framebuffers in DMA-able memory. */

include/linux/fb.h extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf, · line 609

Quoted 9 lines
include/linux/fb.h +9 -0
+#define __FB_DEFAULT_DMA_OPS_RDWR \
+	.fb_read	= fb_sys_read, \
+	.fb_write	= fb_sys_write
+
+#define __FB_DEFAULT_DMA_OPS_DRAW \
+	.fb_fillrect	= sys_fillrect, \
+	.fb_copyarea	= sys_copyarea, \
+	.fb_imageblit	= sys_imageblit
+
Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#3 lore raw

Re: [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory

Hi Javier

Am 05.07.23 um 10:23 schrieb Javier Martinez Canillas:

Quoted 53 lines

Thomas Zimmermann <[email protected]> writes:

Hello Thomas,

Quoted 39 lines

Add initializer macros for struct fb_ops for framebuffers in DMA-able memory areas. Also add a corresponding Kconfig token. As of now, this is equivalent to system framebuffers and mostly useful for labeling drivers correctly.

A later patch may add a generic DMA-specific mmap operation. Linux offers a number of dma_mmap_*() helpers for different use cases.

---
  drivers/video/fbdev/Kconfig |  8 ++++++++
  include/linux/fb.h          | 13 +++++++++++++
  2 files changed, 21 insertions(+)
drivers/video/fbdev/Kconfig +8 -0
index cecf15418632..f14229757311 100644
@@ -168,6 +168,14 @@ config FB_DEFERRED_IO
  	bool
  	depends on FB
 
+config FB_DMA_HELPERS
+	bool
+	depends on FB
+	select FB_SYS_COPYAREA
+	select FB_SYS_FILLRECT
+	select FB_SYS_FOPS
+	select FB_SYS_IMAGEBLIT
+
  config FB_IO_HELPERS
  	bool
  	depends on FB
include/linux/fb.h +0 -0
index 1d5c13f34b09..1191a78c5289 100644

include/linux/fb.h extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf, · line 600

Quoted 7 lines
include/linux/fb.h +4 -0
@@ -594,6 +594,19 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
  	__FB_DEFAULT_SYS_OPS_DRAW, \
  	__FB_DEFAULT_SYS_OPS_MMAP
 
+/*
+ * Helpers for framebuffers in DMA-able memory
+ */
+

The comment for I/O memory helpers says:

Quoted 5 lines

/*
* Initializes struct fb_ops for framebuffers in I/O memory. */

I think that would be good to have consistency between these two,

Sure, I had the same thought. I think I'll rather change the existing comments a bit.

Best regards
Thomas

Quoted 18 lines

so something like:

/*
* Initializes struct fb_ops for framebuffers in DMA-able memory. */

include/linux/fb.h extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf, · line 609

Quoted 9 lines
include/linux/fb.h +9 -0
+#define __FB_DEFAULT_DMA_OPS_RDWR \
+	.fb_read	= fb_sys_read, \
+	.fb_write	= fb_sys_write
+
+#define __FB_DEFAULT_DMA_OPS_DRAW \
+	.fb_fillrect	= sys_fillrect, \
+	.fb_copyarea	= sys_copyarea, \
+	.fb_imageblit	= sys_imageblit
+
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#4 lore raw

Re: [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory

Thomas Zimmermann <[email protected]> writes:

[...]

Quoted 12 lines
Quoted 8 lines

The comment for I/O memory helpers says:

/*
* Initializes struct fb_ops for framebuffers in I/O memory. */

I think that would be good to have consistency between these two,

Sure, I had the same thought. I think I'll rather change the existing comments a bit.

Yes, that works for me too. Thanks!

Quoted 4 lines

Best regards
Thomas

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#5 lore raw

PATCH 2/10 drm/fbdev-dma: Use fbdev DMA helpers

In reply to Thomas Zimmermann

Use fbdev's DMA helpers for fbdev-dma. They are equivalent to the previously used system-memory helpers, so no functional changes here.

---
 drivers/gpu/drm/Kconfig         | 2 +-
 drivers/gpu/drm/drm_fbdev_dma.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/Kconfig +1 -1
index afb3b2f5f425..da3aa0625c36 100644
@@ -216,7 +216,7 @@ config DRM_TTM_HELPER
 config DRM_GEM_DMA_HELPER
 	tristate
 	depends on DRM
-	select FB_SYS_HELPERS if DRM_FBDEV_EMULATION
+	select FB_DMA_HELPERS if DRM_FBDEV_EMULATION
 	help
 	  Choose this if you need the GEM DMA helper functions
 
drivers/gpu/drm/drm_fbdev_dma.c +2 -2
index 8217f1ddc007..040c229a1737 100644
@@ -62,9 +62,9 @@ static const struct fb_ops drm_fbdev_dma_fb_ops = {
 	.owner = THIS_MODULE,
 	.fb_open = drm_fbdev_dma_fb_open,
 	.fb_release = drm_fbdev_dma_fb_release,
-	__FB_DEFAULT_SYS_OPS_RDWR,
+	__FB_DEFAULT_DMA_OPS_RDWR,
 	DRM_FB_HELPER_DEFAULT_OPS,
-	__FB_DEFAULT_SYS_OPS_DRAW,
+	__FB_DEFAULT_DMA_OPS_DRAW,
 	.fb_mmap = drm_fbdev_dma_fb_mmap,
 	.fb_destroy = drm_fbdev_dma_fb_destroy,
 };
Signature · 1 line
2.41.0
Reviewed-by on v1 2/10
#6 lore raw

Re: [PATCH 02/10] drm/fbdev-dma: Use fbdev DMA helpers

Quoted 5 lines · Thomas Zimmermann

Use fbdev's DMA helpers for fbdev-dma. They are equivalent to the previously used system-memory helpers, so no functional changes here.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#7 lore raw

PATCH 3/10 drm/tegra: Use fbdev DMA helpers

In reply to Thomas Zimmermann

Use fbdev's DMA helpers for fbdev emulation. They are equivalent to the previously used system-memory helpers, so no functional changes here.

Cc Thierry Reding <[email protected]>
Cc Mikko Perttunen <[email protected]>
---
 drivers/gpu/drm/tegra/Kconfig | 2 +-
 drivers/gpu/drm/tegra/fbdev.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/tegra/Kconfig +1 -1
index 498313778175..39452c8480c1 100644
@@ -12,7 +12,7 @@ config DRM_TEGRA
 	select DRM_KMS_HELPER
 	select DRM_MIPI_DSI
 	select DRM_PANEL
-	select FB_SYS_HELPERS if DRM_FBDEV_EMULATION
+	select FB_DMA_HELPERS if DRM_FBDEV_EMULATION
 	select TEGRA_HOST1X
 	select INTERCONNECT
 	select IOMMU_IOVA
drivers/gpu/drm/tegra/fbdev.c +2 -2
index e74d9be981c7..82577b7c88da 100644
@@ -59,9 +59,9 @@ static void tegra_fbdev_fb_destroy(struct fb_info *info)
 
 static const struct fb_ops tegra_fb_ops = {
 	.owner = THIS_MODULE,
-	__FB_DEFAULT_SYS_OPS_RDWR,
+	__FB_DEFAULT_DMA_OPS_RDWR,
 	DRM_FB_HELPER_DEFAULT_OPS,
-	__FB_DEFAULT_SYS_OPS_DRAW,
+	__FB_DEFAULT_DMA_OPS_DRAW,
 	.fb_mmap = tegra_fb_mmap,
 	.fb_destroy = tegra_fbdev_fb_destroy,
 };
Signature · 1 line
2.41.0
Reviewed-by on v1 3/10
#8 lore raw

Re: [PATCH 03/10] drm/tegra: Use fbdev DMA helpers

Quoted 7 lines · Thomas Zimmermann

Use fbdev's DMA helpers for fbdev emulation. They are equivalent to the previously used system-memory helpers, so no functional changes here.

Cc Thierry Reding <[email protected]>
Cc Mikko Perttunen <[email protected]>

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#9 lore raw

PATCH 4/10 drm/tegra: Set fbdev flags

In reply to Thomas Zimmermann

Set fbdev default flags FBNFO_DEFAULT and 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.

Cc Thierry Reding <[email protected]>
Cc Mikko Perttunen <[email protected]>
---
 drivers/gpu/drm/tegra/fbdev.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/tegra/fbdev.c +3 -0
index 82577b7c88da..8074430c52f1 100644
@@ -103,6 +103,8 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
 		return PTR_ERR(info);
 	}
 
+	info->flags = FBINFO_DEFAULT;
+
 	fb = tegra_fb_alloc(drm, &cmd, &bo, 1);
 	if (IS_ERR(fb)) {
 		err = PTR_ERR(fb);
@@ -132,6 +134,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
 		}
 	}
 
+	info->flags |= FBINFO_VIRTFB;
 	info->screen_base = (void __iomem *)bo->vaddr + offset;
 	info->screen_size = size;
 	info->fix.smem_start = (unsigned long)(bo->iova + offset);
Signature · 1 line
2.41.0
Reviewed-by on v1 4/10
#10 lore raw

Re: [PATCH 04/10] drm/tegra: Set fbdev flags

Quoted 25 lines · Thomas Zimmermann

Set fbdev default flags FBNFO_DEFAULT and 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.

Cc Thierry Reding <[email protected]>
Cc Mikko Perttunen <[email protected]>
---
 drivers/gpu/drm/tegra/fbdev.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/tegra/fbdev.c +2 -0
index 82577b7c88da..8074430c52f1 100644
@@ -103,6 +103,8 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
 		return PTR_ERR(info);
 	}
 
+	info->flags = FBINFO_DEFAULT;
+
 	fb = tegra_fb_alloc(drm, &cmd, &bo, 1);
 	if (IS_ERR(fb)) {
 		err = PTR_ERR(fb);

drivers/gpu/drm/tegra/fbdev.c static int tegra_fbdev_probe(struct drm_fb_helper *helper, · line 137

Quoted 4 lines
drivers/gpu/drm/tegra/fbdev.c +1 -0
@@ -132,6 +134,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
 		}
 	}
 
+	info->flags |= FBINFO_VIRTFB;

I see that all fbdev drivers just do: info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB

Guess you are doing in two assignments to be consistent with drm_fbdev_dma.c ? I was just curious about the rationale for setting the flags in two steps.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#11 lore raw

Re: [PATCH 04/10] drm/tegra: Set fbdev flags

Hi Javier

Am 05.07.23 um 10:34 schrieb Javier Martinez Canillas:

Quoted 30 lines
Quoted 28 lines · Thomas Zimmermann

Set fbdev default flags FBNFO_DEFAULT and 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.

Cc Thierry Reding <[email protected]>
Cc Mikko Perttunen <[email protected]>
---
  drivers/gpu/drm/tegra/fbdev.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/tegra/fbdev.c +2 -0
index 82577b7c88da..8074430c52f1 100644
@@ -103,6 +103,8 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
  		return PTR_ERR(info);
  	}
 
+	info->flags = FBINFO_DEFAULT;
+
  	fb = tegra_fb_alloc(drm, &cmd, &bo, 1);
  	if (IS_ERR(fb)) {
  		err = PTR_ERR(fb);
@@ -132,6 +134,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
  		}
  	}
 
Quoted 6 lines

drivers/gpu/drm/tegra/fbdev.c static int tegra_fbdev_probe(struct drm_fb_helper *helper, · line 137

Quoted 1 line
drivers/gpu/drm/tegra/fbdev.c +1 -0
+	info->flags |= FBINFO_VIRTFB;

I see that all fbdev drivers just do: info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB

Guess you are doing in two assignments to be consistent with drm_fbdev_dma.c ? I was just curious about the rationale for setting the flags in two steps.

The _DEFAULT flag is really just a zero. And the other flags describe different aspects of the framebuffer. I think it makes sense to set the flags together with the respective state. For example, _VIRTFB is set next to ->screen_buffer, because they belong together.

_VIRTFB is currently only used in defio code at

https://elixir.bootlin.com/linux/latest/source/drivers/video/fbdev/core/fb_defio.c#L232

I think the fbdev I/O helpers should also test this flag after all drivers have been annotated correctly. For example, fb_io_read() would WARN_ONCE if the _VIRTFB flag has been set; and fb_sys_read() would warn if it hasn't been set. For the read helpers, it also makes sense to WARN_ONCE if the _READS_FAST flag has not been set.

Best regards
Thomas

Quoted 3 lines
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#12 lore raw

Re: [PATCH 04/10] drm/tegra: Set fbdev flags

Thomas Zimmermann <[email protected]> writes:

[...]

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/tegra/fbdev.c static int tegra_fbdev_probe(struct drm_fb_helper *helper, · line 137

Quoted 1 line
drivers/gpu/drm/tegra/fbdev.c +1 -0
+	info->flags |= FBINFO_VIRTFB;

I see that all fbdev drivers just do: info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB

Quoted 8 lines
Quoted 2 lines

Guess you are doing in two assignments to be consistent with drm_fbdev_dma.c ? I was just curious about the rationale for setting the flags in two steps.

The _DEFAULT flag is really just a zero. And the other flags describe different aspects of the framebuffer. I think it makes sense to set the flags together with the respective state. For example, _VIRTFB is set next to ->screen_buffer, because they belong together.

Yes, that makes sense.

Quoted 10 lines

_VIRTFB is currently only used in defio code at

https://elixir.bootlin.com/linux/latest/source/drivers/video/fbdev/core/fb_defio.c#L232

I think the fbdev I/O helpers should also test this flag after all drivers have been annotated correctly. For example, fb_io_read() would WARN_ONCE if the _VIRTFB flag has been set; and fb_sys_read() would warn if it hasn't been set. For the read helpers, it also makes sense to WARN_ONCE if the _READS_FAST flag has not been set.

Agreed. Maybe you could add those warn (or at least info or debug?) even if not all drivers have been annotated correctly. That way people can be aware that is missing and fix if there are remaining drivers.

Quoted 3 lines

Best regards
Thomas

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#13 lore raw

Re: [PATCH 04/10] drm/tegra: Set fbdev flags

Hi

Am 05.07.23 um 11:34 schrieb Javier Martinez Canillas:

Quoted 30 lines

Thomas Zimmermann <[email protected]> writes:

[...]

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/tegra/fbdev.c static int tegra_fbdev_probe(struct drm_fb_helper *helper, · line 137

Quoted 1 line
drivers/gpu/drm/tegra/fbdev.c +1 -0
+	info->flags |= FBINFO_VIRTFB;

I see that all fbdev drivers just do: info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB

Quoted 8 lines
Quoted 2 lines

Guess you are doing in two assignments to be consistent with drm_fbdev_dma.c ? I was just curious about the rationale for setting the flags in two steps.

The _DEFAULT flag is really just a zero. And the other flags describe different aspects of the framebuffer. I think it makes sense to set the flags together with the respective state. For example, _VIRTFB is set next to ->screen_buffer, because they belong together.

Yes, that makes sense.

Quoted 10 lines

_VIRTFB is currently only used in defio code at

https://elixir.bootlin.com/linux/latest/source/drivers/video/fbdev/core/fb_defio.c#L232

I think the fbdev I/O helpers should also test this flag after all drivers have been annotated correctly. For example, fb_io_read() would WARN_ONCE if the _VIRTFB flag has been set; and fb_sys_read() would warn if it hasn't been set. For the read helpers, it also makes sense to WARN_ONCE if the _READS_FAST flag has not been set.

Quoted 3 lines

Agreed. Maybe you could add those warn (or at least info or debug?) even if not all drivers have been annotated correctly. That way people can be aware that is missing and fix if there are remaining drivers.

Yes, we could do that. I want to go through drivers first and fix the low-hanging fruits. Some of the old fbdev drivers use either DMA or I/O memory. They would only be fix-worthy if someone complains.

Best regards
Thomas

Quoted 5 lines
Quoted 4 lines

Best regards
Thomas

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
author maintainer
#14 lore raw

PATCH 5/10 drm/exynos: Use fbdev DMA helpers

In reply to Thomas Zimmermann

Use fbdev's DMA helpers for fbdev emulation. They drivers previously used the I/O-memory helpers, while allocating DMA-able system memory. This could (in theory) result in bus errors from accessing the memory range.

This bug has been present since the exynos driver was first added.

Fixes 1c248b7d2960 ("DRM: add DRM Driver for Samsung SoC EXYNOS4210.")
Cc Inki Dae <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Alim Akhtar <[email protected]>
---
 drivers/gpu/drm/exynos/Kconfig            | 2 +-
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/exynos/Kconfig +1 -1
index 7ca7e1dab52c..661b42ad4873 100644
@@ -7,7 +7,7 @@ config DRM_EXYNOS
 	select DRM_DISPLAY_HELPER if DRM_EXYNOS_DP
 	select DRM_KMS_HELPER
 	select VIDEOMODE_HELPERS
-	select FB_IO_HELPERS if DRM_FBDEV_EMULATION
+	select FB_DMA_HELPERS if DRM_FBDEV_EMULATION
 	select SND_SOC_HDMI_CODEC if SND_SOC
 	help
 	  Choose this option if you have a Samsung SoC Exynos chipset.
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +2 -2
index fdf65587f1fe..7ca3424b59ce 100644
@@ -49,9 +49,9 @@ static void exynos_drm_fb_destroy(struct fb_info *info)
 
 static const struct fb_ops exynos_drm_fb_ops = {
 	.owner		= THIS_MODULE,
-	__FB_DEFAULT_IO_OPS_RDWR,
+	__FB_DEFAULT_DMA_OPS_RDWR,
 	DRM_FB_HELPER_DEFAULT_OPS,
-	__FB_DEFAULT_IO_OPS_DRAW,
+	__FB_DEFAULT_DMA_OPS_DRAW,
 	.fb_mmap        = exynos_drm_fb_mmap,
 	.fb_destroy	= exynos_drm_fb_destroy,
 };
Signature · 1 line
2.41.0
maintainer Acked-by on v1 5/10
#15 lore raw

RE: [PATCH 05/10] drm/exynos: Use fbdev DMA helpers

Hi,

Quoted 13 lines

-----Original Message-----
From: Thomas Zimmermann <[email protected]>
Sent: Wednesday, July 5, 2023 12:50 AM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Thomas Zimmermann <[email protected]>; Inki Dae <[email protected]>; Seung-Woo Kim <[email protected]>; Kyungmin Park <[email protected]>; Krzysztof Kozlowski <[email protected]>; Alim Akhtar <[email protected]>
Subject: [PATCH 05/10] drm/exynos: Use fbdev DMA helpers

Quoted 6 lines

Use fbdev's DMA helpers for fbdev emulation. They drivers previously used the I/O-memory helpers, while allocating DMA-able system memory. This could (in theory) result in bus errors from accessing the memory range.

This bug has been present since the exynos driver was first added.

Thanks,
Inki Dae

Quoted 46 lines
Fixes 1c248b7d2960 ("DRM: add DRM Driver for Samsung SoC EXYNOS4210.")
Cc Inki Dae <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Alim Akhtar <[email protected]>
---
 drivers/gpu/drm/exynos/Kconfig            | 2 +-
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/exynos/Kconfig +1 -1
index 7ca7e1dab52c..661b42ad4873 100644
@@ -7,7 +7,7 @@ config DRM_EXYNOS
 	select DRM_DISPLAY_HELPER if DRM_EXYNOS_DP
 	select DRM_KMS_HELPER
 	select VIDEOMODE_HELPERS
-	select FB_IO_HELPERS if DRM_FBDEV_EMULATION
+	select FB_DMA_HELPERS if DRM_FBDEV_EMULATION
 	select SND_SOC_HDMI_CODEC if SND_SOC
 	help
 	  Choose this option if you have a Samsung SoC Exynos chipset.
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +2 -3
index fdf65587f1fe..7ca3424b59ce 100644
@@ -49,9 +49,9 @@ static void exynos_drm_fb_destroy(struct fb_info *info)
 
 static const struct fb_ops exynos_drm_fb_ops = {
 	.owner		= THIS_MODULE,
-	__FB_DEFAULT_IO_OPS_RDWR,
+	__FB_DEFAULT_DMA_OPS_RDWR,
 	DRM_FB_HELPER_DEFAULT_OPS,
-	__FB_DEFAULT_IO_OPS_DRAW,
+	__FB_DEFAULT_DMA_OPS_DRAW,
 	.fb_mmap        = exynos_drm_fb_mmap,
 	.fb_destroy	= exynos_drm_fb_destroy,
 };
--

2.41.0

Reviewed-by on v1 5/10
#16 lore raw

Re: [PATCH 05/10] drm/exynos: Use fbdev DMA helpers

In reply to Thomas Zimmermann
Quoted 1 line · Thomas Zimmermann

Use fbdev's DMA helpers for fbdev emulation. They drivers previously

s/They/The

Quoted 8 lines

used the I/O-memory helpers, while allocating DMA-able system memory. This could (in theory) result in bus errors from accessing the memory range.

This bug has been present since the exynos driver was first added.

Fixes 1c248b7d2960 ("DRM: add DRM Driver for Samsung SoC EXYNOS4210.")

Wonder the value of this "Fixes:" tag since this patch depends on the DMA helpers introduced in 1/10? I would just drop it, since it might confuse the different kernel stable scripts that attempt to backport by looking at this tag.

As you said, it has been present from the beginning of this driver.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#17 lore raw

PATCH 6/10 drm/exynos: Set fbdev flags

In reply to Thomas Zimmermann

Set fbdev default flags FBNFO_DEFAULT and 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.

Cc Inki Dae <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Alim Akhtar <[email protected]>
---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +2 -0
index 7ca3424b59ce..28dc398d6e10 100644
@@ -72,6 +72,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
 		return PTR_ERR(fbi);
 	}
 
+	fbi->flags = FBINFO_FLAG_DEFAULT;
 	fbi->fbops = &exynos_drm_fb_ops;
 
 	drm_fb_helper_fill_info(fbi, helper, sizes);
@@ -79,6 +80,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
 	offset = fbi->var.xoffset * fb->format->cpp[0];
 	offset += fbi->var.yoffset * fb->pitches[0];
 
+	fbi->flags |= FBINFO_VIRTFB;
 	fbi->screen_buffer = exynos_gem->kvaddr + offset;
 	fbi->screen_size = size;
 	fbi->fix.smem_len = size;
Signature · 1 line
2.41.0
Reviewed-by on v1 6/10
#18 lore raw

Re: [PATCH 06/10] drm/exynos: Set fbdev flags

Quoted 1 line · Thomas Zimmermann

Set fbdev default flags FBNFO_DEFAULT and mark the framebuffer with

FBINFO_DEFAULT, or did you meand FBINFO_FLAG_DEFAULT (the flag your patch is actually using) ?

I just noticed that are the same... and in patch 04/10 you used the former for the tegra driver, but here you are using the latter. Is on purpose or just a mistake ?

Quoted 18 lines

FBINFO_VIRTFB. The framebuffer range is in DMA-able memory and should be accessed with the CPU's regular memory ops.

Cc Inki Dae <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Alim Akhtar <[email protected]>
---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0 -0
index 7ca3424b59ce..28dc398d6e10 100644

drivers/gpu/drm/exynos/exynos_drm_fbdev.c static int exynos_drm_fbdev_update(struct drm_fb_helper *helper, · line 75

Quoted 4 lines
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1 -0
@@ -72,6 +72,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
 		return PTR_ERR(fbi);
 	}
 
+	fbi->flags = FBINFO_FLAG_DEFAULT;

The #define FBINFO_FLAG_DEFAULT FBINFO_DEFAULT seems to be there since the
original v2.6.12-rc2 git import in commit 1da177e4c3f4, so is hard to know why was introduced. FBINFO_DEFAULT is more used, I will just stick to that:

$ git grep FBINFO_DEFAULT | wc -l
92
$ git grep FBINFO_FLAG_DEFAULT | wc -l
38
Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#19 lore raw

Re: [PATCH 06/10] drm/exynos: Set fbdev flags

Hi

Am 05.07.23 um 10:49 schrieb Javier Martinez Canillas:

Quoted 32 lines
Quoted 1 line · Thomas Zimmermann

Set fbdev default flags FBNFO_DEFAULT and mark the framebuffer with

FBINFO_DEFAULT, or did you meand FBINFO_FLAG_DEFAULT (the flag your patch is actually using) ?

I just noticed that are the same... and in patch 04/10 you used the former for the tegra driver, but here you are using the latter. Is on purpose or just a mistake ?

Quoted 21 lines

FBINFO_VIRTFB. The framebuffer range is in DMA-able memory and should be accessed with the CPU's regular memory ops.

Cc Inki Dae <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Alim Akhtar <[email protected]>
---
  drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0 -0
index 7ca3424b59ce..28dc398d6e10 100644
@@ -72,6 +72,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
  		return PTR_ERR(fbi);
  	}
 
Quoted 5 lines

drivers/gpu/drm/exynos/exynos_drm_fbdev.c static int exynos_drm_fbdev_update(struct drm_fb_helper *helper, · line 75

Quoted 1 line
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1 -0
+	fbi->flags = FBINFO_FLAG_DEFAULT;

The #define FBINFO_FLAG_DEFAULT FBINFO_DEFAULT seems to be there since the
original v2.6.12-rc2 git import in commit 1da177e4c3f4, so is hard to know why was introduced. FBINFO_DEFAULT is more used, I will just stick to that:

Thanks for commenting on this issue. I didn't notice that.

I think I'll just remove these _DEFAULT assignments from the patchset.

And I think we should nuke them entirely everywhere. The _DEFAULT values are just 0 after commit 376b3ff54c9a1. So there's no value in assigning them at all.

Best regards
Thomas

Quoted 9 lines
$ git grep FBINFO_DEFAULT | wc -l
92
$ git grep FBINFO_FLAG_DEFAULT | wc -l
38
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#20 lore raw

Re: [PATCH 06/10] drm/exynos: Set fbdev flags

Quoted 3 lines · Thomas Zimmermann

Hi

Am 05.07.23 um 10:49 schrieb Javier Martinez Canillas:

[...]

Quoted 5 lines
Quoted 4 lines

The #define FBINFO_FLAG_DEFAULT FBINFO_DEFAULT seems to be there since the
original v2.6.12-rc2 git import in commit 1da177e4c3f4, so is hard to know why was introduced. FBINFO_DEFAULT is more used, I will just stick to that:

Quoted 8 lines

Thanks for commenting on this issue. I didn't notice that.

I think I'll just remove these _DEFAULT assignments from the patchset.

And I think we should nuke them entirely everywhere. The _DEFAULT values are just 0 after commit 376b3ff54c9a1. So there's no value in assigning them at all.

Agreed.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#21 lore raw

PATCH 7/10 drm/omapdrm: Set VM flags in GEM-object mmap function

In reply to Thomas Zimmermann

Use the mmap callback in struct drm_gem_object_funcs to set the VM flags. Replace a number of mmap helpers in omapdrm with their GEM helper counterparts. Generate DRM's file-operations instance with GEM's DEFINE_DRM_GEM_FOPS.

---
 drivers/gpu/drm/omapdrm/omap_drv.c        | 12 +-----------
 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 +------
 4 files changed, 8 insertions(+), 38 deletions(-)
drivers/gpu/drm/omapdrm/omap_drv.c +1 -11
index e2697fe80e62..afeeb7737552 100644
@@ -636,17 +636,7 @@ static int dev_open(struct drm_device *dev, struct drm_file *file)
 	return 0;
 }
 
-static const struct file_operations omapdriver_fops = {
-	.owner = THIS_MODULE,
-	.open = drm_open,
-	.unlocked_ioctl = drm_ioctl,
-	.compat_ioctl = drm_compat_ioctl,
-	.release = drm_release,
-	.mmap = omap_gem_mmap,
-	.poll = drm_poll,
-	.read = drm_read,
-	.llseek = noop_llseek,
-};
+DEFINE_DRM_GEM_FOPS(omapdriver_fops);
 
 static const struct drm_driver omap_drm_driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM  |
drivers/gpu/drm/omapdrm/omap_gem.c +6 -18
index 6b58a5bb7b44..c9c64ad17ce6 100644
@@ -524,26 +524,11 @@ static vm_fault_t omap_gem_fault(struct vm_fault *vmf)
 	return ret;
 }
 
-/** We override mainly to fix up some of the vm mapping flags.. */
-int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-	int ret;
-
-	ret = drm_gem_mmap(filp, vma);
-	if (ret) {
-		DBG("mmap failed: %d", ret);
-		return ret;
-	}
-
-	return omap_gem_mmap_obj(vma->vm_private_data, vma);
-}
-
-int omap_gem_mmap_obj(struct drm_gem_object *obj,
-		struct vm_area_struct *vma)
+static int omap_gem_object_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 {
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
 
-	vm_flags_mod(vma, VM_MIXEDMAP, VM_PFNMAP);
+	vm_flags_set(vma, VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_IO | VM_MIXEDMAP);
 
 	if (omap_obj->flags & OMAP_BO_WC) {
 		vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
@@ -563,12 +548,14 @@ int omap_gem_mmap_obj(struct drm_gem_object *obj,
 		 * address_space (so unmap_mapping_range does what we want,
 		 * in particular in the case of mmap'd dmabufs)
 		 */
-		vma->vm_pgoff = 0;
+		vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);
 		vma_set_file(vma, obj->filp);
 
 		vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
 	}
 
+	vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
+
 	return 0;
 }
 
@@ -1282,6 +1269,7 @@ static const struct vm_operations_struct omap_gem_vm_ops = {
 static const struct drm_gem_object_funcs omap_gem_object_funcs = {
 	.free = omap_gem_free_object,
 	.export = omap_gem_prime_export,
+	.mmap = omap_gem_object_mmap,
 	.vm_ops = &omap_gem_vm_ops,
 };
 
drivers/gpu/drm/omapdrm/omap_gem.h +0 -3
index 4d4488939f6b..fec3fa0e4c33 100644
@@ -57,9 +57,6 @@ int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
 		struct drm_mode_create_dumb *args);
 
 /* mmap() Interface */
-int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
-int omap_gem_mmap_obj(struct drm_gem_object *obj,
-		struct vm_area_struct *vma);
 u64 omap_gem_mmap_offset(struct drm_gem_object *obj);
 size_t omap_gem_mmap_size(struct drm_gem_object *obj);
 
drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +1 -6
index 8e194dbc9506..36f9ee4baad3 100644
@@ -64,13 +64,8 @@ static int omap_gem_dmabuf_mmap(struct dma_buf *buffer,
 		struct vm_area_struct *vma)
 {
 	struct drm_gem_object *obj = buffer->priv;
-	int ret = 0;
 
-	ret = drm_gem_mmap_obj(obj, omap_gem_mmap_size(obj), vma);
-	if (ret < 0)
-		return ret;
-
-	return omap_gem_mmap_obj(obj, vma);
+	return drm_gem_mmap_obj(obj, omap_gem_mmap_size(obj), vma);
 }
 
 static const struct dma_buf_ops omap_dmabuf_ops = {
Signature · 1 line
2.41.0
Reviewed-by on v1 7/10
#22 lore raw

Re: [PATCH 07/10] drm/omapdrm: Set VM flags in GEM-object mmap function

Quoted 24 lines · Thomas Zimmermann

Use the mmap callback in struct drm_gem_object_funcs to set the VM flags. Replace a number of mmap helpers in omapdrm with their GEM helper counterparts. Generate DRM's file-operations instance with GEM's DEFINE_DRM_GEM_FOPS.

---

drivers/gpu/drm/omapdrm/omap_gem.c +3 -2
+static int omap_gem_object_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 {
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
 
-	vm_flags_mod(vma, VM_MIXEDMAP, VM_PFNMAP);
+	vm_flags_set(vma, VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_IO | VM_MIXEDMAP);
 
 	if (omap_obj->flags & OMAP_BO_WC) {
 		vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
@@ -563,12 +548,14 @@ int omap_gem_mmap_obj(struct drm_gem_object *obj,
 		 * address_space (so unmap_mapping_range does what we want,
 		 * in particular in the case of mmap'd dmabufs)
 		 */
-		vma->vm_pgoff = 0;
+		vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);

drivers/gpu/drm/omapdrm/omap_gem.c int omap_gem_mmap_obj(struct drm_gem_object *obj, · line 561

Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_gem.c +2 -0
 		vma_set_file(vma, obj->filp);
 
 		vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
 	}
 
+	vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
+
 	return 0;
 }
 

I think this rework deserves a more elaborated commit message.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#23 lore raw

PATCH 8/10 drm/omapdrm: Use GEM mmap for fbdev emulation

In reply to Thomas Zimmermann

The fbdev emulation currently uses fbdev's default mmap code, which has been written for I/O memory. Provide an mmap that uses GEM's mmap infrastructure.

Utilize fine-grained fbdev macros to initialize struct fb_ops. The macros set the read/write and the draw callbacks for DMA memory. Set the fb_mmap callback to omapdrm's new mmap helper. Also select the correct Kconfig token for fbdev's DMA helpers. Note that the DMA helpers are the same as for system memory.

---
 drivers/gpu/drm/omapdrm/Kconfig      |  2 +-
 drivers/gpu/drm/omapdrm/omap_fbdev.c | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/omapdrm/Kconfig +1 -1
index b4ac76c9f31b..d3c4877e465c 100644
@@ -4,7 +4,7 @@ config DRM_OMAP
 	depends on DRM && OF
 	depends on ARCH_OMAP2PLUS
 	select DRM_KMS_HELPER
-	select FB_SYS_HELPERS if DRM_FBDEV_EMULATION
+	select FB_DMA_HELPERS if DRM_FBDEV_EMULATION
 	select VIDEOMODE_HELPERS
 	select HDMI
 	default n
drivers/gpu/drm/omapdrm/omap_fbdev.c +13 -2
index b7ccce0704a3..b1a2d00ef52d 100644
@@ -76,6 +76,15 @@ static int omap_fbdev_pan_display(struct fb_var_screeninfo *var,
 	return drm_fb_helper_pan_display(var, fbi);
 }
 
+static int omap_fbdev_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
+{
+	struct drm_fb_helper *helper = info->par;
+	struct drm_framebuffer *fb = helper->fb;
+	struct drm_gem_object *bo = drm_gem_fb_get_obj(fb, 0);
+
+	return drm_gem_mmap_obj(bo, omap_gem_mmap_size(bo), vma);
+}
+
 static void omap_fbdev_fb_destroy(struct fb_info *info)
 {
 	struct drm_fb_helper *helper = info->par;
@@ -97,14 +106,16 @@ static void omap_fbdev_fb_destroy(struct fb_info *info)
 
 static const struct fb_ops omap_fb_ops = {
 	.owner = THIS_MODULE,
-	FB_DEFAULT_SYS_OPS,
+	__FB_DEFAULT_DMA_OPS_RDWR,
 	.fb_check_var	= drm_fb_helper_check_var,
 	.fb_set_par	= drm_fb_helper_set_par,
 	.fb_setcmap	= drm_fb_helper_setcmap,
 	.fb_blank	= drm_fb_helper_blank,
 	.fb_pan_display = omap_fbdev_pan_display,
+	__FB_DEFAULT_DMA_OPS_DRAW,
 	.fb_ioctl	= drm_fb_helper_ioctl,
-	.fb_destroy = omap_fbdev_fb_destroy,
+	.fb_mmap	= omap_fbdev_fb_mmap,
+	.fb_destroy	= omap_fbdev_fb_destroy,
 };
 
 static int omap_fbdev_create(struct drm_fb_helper *helper,
Signature · 1 line
2.41.0
Reviewed-by on v1 8/10
#24 lore raw

Re: [PATCH 08/10] drm/omapdrm: Use GEM mmap for fbdev emulation

Quoted 10 lines · Thomas Zimmermann

The fbdev emulation currently uses fbdev's default mmap code, which has been written for I/O memory. Provide an mmap that uses GEM's mmap infrastructure.

Utilize fine-grained fbdev macros to initialize struct fb_ops. The macros set the read/write and the draw callbacks for DMA memory. Set the fb_mmap callback to omapdrm's new mmap helper. Also select the correct Kconfig token for fbdev's DMA helpers. Note that the DMA helpers are the same as for system memory.

Quoted 3 lines

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#25 lore raw

PATCH 9/10 drm/omapdrm: Set fbdev flags

In reply to Thomas Zimmermann

Set fbdev default flags FBNFO_DEFAULT and 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.

---
 drivers/gpu/drm/omapdrm/omap_fbdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/omapdrm/omap_fbdev.c +2 -0
index b1a2d00ef52d..2dd86e6f5268 100644
@@ -203,10 +203,12 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
 
 	helper->fb = fb;
 
+	fbi->flags = FBINFO_DEFAULT;
 	fbi->fbops = &omap_fb_ops;
 
 	drm_fb_helper_fill_info(fbi, helper, sizes);
 
+	fbi->flags |= FBINFO_VIRTFB;
 	fbi->screen_buffer = omap_gem_vaddr(bo);
 	fbi->screen_size = bo->size;
 	fbi->fix.smem_start = dma_addr;
Signature · 1 line
2.41.0
Reviewed-by on v1 9/10
#26 lore raw

Re: [PATCH 09/10] drm/omapdrm: Set fbdev flags

Quoted 1 line · Thomas Zimmermann

Set fbdev default flags FBNFO_DEFAULT and mark the framebuffer with

FBINFO_DEFAULT. I noticed that the same typo is in patch 04/10 as well.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#27 lore raw

PATCH 10/10 fbdev: Remove FB_DEFAULT_SYS_OPS

In reply to Thomas Zimmermann

Remove the initializer macro FB_DEFAULT_SYS_OPS and its helper macro __FB_DEFAULT_SYS_OPS_MMAP. There are no users.

Cc Helge Deller <[email protected]> (maintainer:FRAMEBUFFER LAYER)
---
 include/linux/fb.h | 8 --------
 1 file changed, 8 deletions(-)
include/linux/fb.h +0 -8
index 1191a78c5289..d370f84fbca9 100644
@@ -586,14 +586,6 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
 	.fb_copyarea	= sys_copyarea, \
 	.fb_imageblit	= sys_imageblit
 
-#define __FB_DEFAULT_SYS_OPS_MMAP \
-	.fb_mmap	= NULL /* default implementation */
-
-#define FB_DEFAULT_SYS_OPS \
-	__FB_DEFAULT_SYS_OPS_RDWR, \
-	__FB_DEFAULT_SYS_OPS_DRAW, \
-	__FB_DEFAULT_SYS_OPS_MMAP
-
 /*
  * Helpers for framebuffers in DMA-able memory
  */
Signature · 1 line
2.41.0
Reviewed-by on v1 10/10
#28 lore raw

Re: [PATCH 10/10] fbdev: Remove FB_DEFAULT_SYS_OPS

Quoted 6 lines · Thomas Zimmermann

Remove the initializer macro FB_DEFAULT_SYS_OPS and its helper macro __FB_DEFAULT_SYS_OPS_MMAP. There are no users.

Cc Helge Deller <[email protected]> (maintainer:FRAMEBUFFER LAYER)

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat