linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers
@ 2023-07-04 15:49 Thomas Zimmermann
  2023-07-04 15:49 ` [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory Thomas Zimmermann
                   ` (10 more replies)
  0 siblings, 11 replies; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-04 15:49 UTC (permalink / raw)
  To: javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann

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(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory
  2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
@ 2023-07-04 15:49 ` Thomas Zimmermann
  2023-07-05  8:23   ` Javier Martinez Canillas
  2023-07-04 15:49 ` [PATCH 02/10] drm/fbdev-dma: Use fbdev DMA helpers Thomas Zimmermann
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-04 15:49 UTC (permalink / raw)
  To: javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Helge Deller

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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Helge Deller <deller@gmx.de>
---
 drivers/video/fbdev/Kconfig |  8 ++++++++
 include/linux/fb.h          | 13 +++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index cecf15418632..f14229757311 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 1d5c13f34b09..1191a78c5289 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -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);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 02/10] drm/fbdev-dma: Use fbdev DMA helpers
  2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
  2023-07-04 15:49 ` [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory Thomas Zimmermann
@ 2023-07-04 15:49 ` Thomas Zimmermann
  2023-07-05  8:24   ` Javier Martinez Canillas
  2023-07-04 15:50 ` [PATCH 03/10] drm/tegra: " Thomas Zimmermann
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-04 15:49 UTC (permalink / raw)
  To: javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/Kconfig         | 2 +-
 drivers/gpu/drm/drm_fbdev_dma.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index afb3b2f5f425..da3aa0625c36 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -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
 
diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c
index 8217f1ddc007..040c229a1737 100644
--- a/drivers/gpu/drm/drm_fbdev_dma.c
+++ b/drivers/gpu/drm/drm_fbdev_dma.c
@@ -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,
 };
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 03/10] drm/tegra: Use fbdev DMA helpers
  2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
  2023-07-04 15:49 ` [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory Thomas Zimmermann
  2023-07-04 15:49 ` [PATCH 02/10] drm/fbdev-dma: Use fbdev DMA helpers Thomas Zimmermann
@ 2023-07-04 15:50 ` Thomas Zimmermann
  2023-07-05  8:24   ` Javier Martinez Canillas
  2023-07-04 15:50 ` [PATCH 04/10] drm/tegra: Set fbdev flags Thomas Zimmermann
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-04 15:50 UTC (permalink / raw)
  To: javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Thierry Reding, Mikko Perttunen

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

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Mikko Perttunen <mperttunen@nvidia.com>
---
 drivers/gpu/drm/tegra/Kconfig | 2 +-
 drivers/gpu/drm/tegra/fbdev.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig
index 498313778175..39452c8480c1 100644
--- a/drivers/gpu/drm/tegra/Kconfig
+++ b/drivers/gpu/drm/tegra/Kconfig
@@ -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
diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c
index e74d9be981c7..82577b7c88da 100644
--- a/drivers/gpu/drm/tegra/fbdev.c
+++ b/drivers/gpu/drm/tegra/fbdev.c
@@ -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,
 };
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 04/10] drm/tegra: Set fbdev flags
  2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
                   ` (2 preceding siblings ...)
  2023-07-04 15:50 ` [PATCH 03/10] drm/tegra: " Thomas Zimmermann
@ 2023-07-04 15:50 ` Thomas Zimmermann
  2023-07-05  8:34   ` Javier Martinez Canillas
  2023-07-04 15:50 ` [PATCH 05/10] drm/exynos: Use fbdev DMA helpers Thomas Zimmermann
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-04 15:50 UTC (permalink / raw)
  To: javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Thierry Reding, Mikko Perttunen

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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Mikko Perttunen <mperttunen@nvidia.com>
---
 drivers/gpu/drm/tegra/fbdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c
index 82577b7c88da..8074430c52f1 100644
--- a/drivers/gpu/drm/tegra/fbdev.c
+++ b/drivers/gpu/drm/tegra/fbdev.c
@@ -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);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 05/10] drm/exynos: Use fbdev DMA helpers
  2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
                   ` (3 preceding siblings ...)
  2023-07-04 15:50 ` [PATCH 04/10] drm/tegra: Set fbdev flags Thomas Zimmermann
@ 2023-07-04 15:50 ` Thomas Zimmermann
  2023-07-05  2:10   ` 대인기/Tizen Platform Lab(SR)/삼성전자
  2023-07-05  8:38   ` Javier Martinez Canillas
  2023-07-04 15:50 ` [PATCH 06/10] drm/exynos: Set fbdev flags Thomas Zimmermann
                   ` (5 subsequent siblings)
  10 siblings, 2 replies; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-04 15:50 UTC (permalink / raw)
  To: javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Inki Dae, Seung-Woo Kim,
	Kyungmin Park, Krzysztof Kozlowski, Alim Akhtar

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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 1c248b7d2960 ("DRM: add DRM Driver for Samsung SoC EXYNOS4210.")
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
---
 drivers/gpu/drm/exynos/Kconfig            | 2 +-
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 7ca7e1dab52c..661b42ad4873 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -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.
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index fdf65587f1fe..7ca3424b59ce 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -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


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 06/10] drm/exynos: Set fbdev flags
  2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
                   ` (4 preceding siblings ...)
  2023-07-04 15:50 ` [PATCH 05/10] drm/exynos: Use fbdev DMA helpers Thomas Zimmermann
@ 2023-07-04 15:50 ` Thomas Zimmermann
  2023-07-05  8:49   ` Javier Martinez Canillas
  2023-07-04 15:50 ` [PATCH 07/10] drm/omapdrm: Set VM flags in GEM-object mmap function Thomas Zimmermann
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-04 15:50 UTC (permalink / raw)
  To: javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Inki Dae, Seung-Woo Kim,
	Kyungmin Park, Krzysztof Kozlowski, Alim Akhtar

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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index 7ca3424b59ce..28dc398d6e10 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 07/10] drm/omapdrm: Set VM flags in GEM-object mmap function
  2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
                   ` (5 preceding siblings ...)
  2023-07-04 15:50 ` [PATCH 06/10] drm/exynos: Set fbdev flags Thomas Zimmermann
@ 2023-07-04 15:50 ` Thomas Zimmermann
  2023-07-05  9:03   ` Javier Martinez Canillas
  2023-07-04 15:50 ` [PATCH 08/10] drm/omapdrm: Use GEM mmap for fbdev emulation Thomas Zimmermann
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-04 15:50 UTC (permalink / raw)
  To: javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Tomi Valkeinen

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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 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(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index e2697fe80e62..afeeb7737552 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -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  |
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 6b58a5bb7b44..c9c64ad17ce6 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -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,
 };
 
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.h b/drivers/gpu/drm/omapdrm/omap_gem.h
index 4d4488939f6b..fec3fa0e4c33 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.h
+++ b/drivers/gpu/drm/omapdrm/omap_gem.h
@@ -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);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
index 8e194dbc9506..36f9ee4baad3 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
@@ -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 = {
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 08/10] drm/omapdrm: Use GEM mmap for fbdev emulation
  2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
                   ` (6 preceding siblings ...)
  2023-07-04 15:50 ` [PATCH 07/10] drm/omapdrm: Set VM flags in GEM-object mmap function Thomas Zimmermann
@ 2023-07-04 15:50 ` Thomas Zimmermann
  2023-07-05  9:05   ` Javier Martinez Canillas
  2023-07-04 15:50 ` [PATCH 09/10] drm/omapdrm: Set fbdev flags Thomas Zimmermann
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-04 15:50 UTC (permalink / raw)
  To: javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Tomi Valkeinen

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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/Kconfig      |  2 +-
 drivers/gpu/drm/omapdrm/omap_fbdev.c | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
index b4ac76c9f31b..d3c4877e465c 100644
--- a/drivers/gpu/drm/omapdrm/Kconfig
+++ b/drivers/gpu/drm/omapdrm/Kconfig
@@ -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
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index b7ccce0704a3..b1a2d00ef52d 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -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,
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 09/10] drm/omapdrm: Set fbdev flags
  2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
                   ` (7 preceding siblings ...)
  2023-07-04 15:50 ` [PATCH 08/10] drm/omapdrm: Use GEM mmap for fbdev emulation Thomas Zimmermann
@ 2023-07-04 15:50 ` Thomas Zimmermann
  2023-07-05  9:07   ` Javier Martinez Canillas
  2023-07-04 15:50 ` [PATCH 10/10] fbdev: Remove FB_DEFAULT_SYS_OPS Thomas Zimmermann
  2023-07-05  8:30 ` [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Maxime Ripard
  10 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-04 15:50 UTC (permalink / raw)
  To: javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Tomi Valkeinen

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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_fbdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index b1a2d00ef52d..2dd86e6f5268 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 10/10] fbdev: Remove FB_DEFAULT_SYS_OPS
  2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
                   ` (8 preceding siblings ...)
  2023-07-04 15:50 ` [PATCH 09/10] drm/omapdrm: Set fbdev flags Thomas Zimmermann
@ 2023-07-04 15:50 ` Thomas Zimmermann
  2023-07-05  9:07   ` Javier Martinez Canillas
  2023-07-05  8:30 ` [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Maxime Ripard
  10 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-04 15:50 UTC (permalink / raw)
  To: javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Helge Deller

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

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Helge Deller <deller@gmx.de> (maintainer:FRAMEBUFFER LAYER)
---
 include/linux/fb.h | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/include/linux/fb.h b/include/linux/fb.h
index 1191a78c5289..d370f84fbca9 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -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
  */
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* RE: [PATCH 05/10] drm/exynos: Use fbdev DMA helpers
  2023-07-04 15:50 ` [PATCH 05/10] drm/exynos: Use fbdev DMA helpers Thomas Zimmermann
@ 2023-07-05  2:10   ` 대인기/Tizen Platform Lab(SR)/삼성전자
  2023-07-05  8:38   ` Javier Martinez Canillas
  1 sibling, 0 replies; 30+ messages in thread
From: 대인기/Tizen Platform Lab(SR)/삼성전자 @ 2023-07-05  2:10 UTC (permalink / raw)
  To: 'Thomas Zimmermann', javierm, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, 'Seung-Woo Kim', 'Kyungmin Park',
	'Krzysztof Kozlowski', 'Alim Akhtar'

Hi,

> -----Original Message-----
> From: Thomas Zimmermann <tzimmermann@suse.de>
> Sent: Wednesday, July 5, 2023 12:50 AM
> To: javierm@redhat.com; maarten.lankhorst@linux.intel.com;
> mripard@kernel.org
> Cc: dri-devel@lists.freedesktop.org; linux-arm-kernel@lists.infradead.org;
> linux-samsung-soc@vger.kernel.org; linux-tegra@vger.kernel.org; linux-
> fbdev@vger.kernel.org; Thomas Zimmermann <tzimmermann@suse.de>; Inki Dae
> <inki.dae@samsung.com>; Seung-Woo Kim <sw0312.kim@samsung.com>; Kyungmin
> Park <kyungmin.park@samsung.com>; Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org>; Alim Akhtar <alim.akhtar@samsung.com>
> Subject: [PATCH 05/10] drm/exynos: Use fbdev DMA helpers
> 
> 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.

Acked-by : Inki Dae <inki.dae@samsung.com>

Thanks,
Inki Dae

> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Fixes: 1c248b7d2960 ("DRM: add DRM Driver for Samsung SoC EXYNOS4210.")
> Cc: Inki Dae <inki.dae@samsung.com>
> Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> ---
>  drivers/gpu/drm/exynos/Kconfig            | 2 +-
>  drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/Kconfig
> b/drivers/gpu/drm/exynos/Kconfig
> index 7ca7e1dab52c..661b42ad4873 100644
> --- a/drivers/gpu/drm/exynos/Kconfig
> +++ b/drivers/gpu/drm/exynos/Kconfig
> @@ -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.
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> index fdf65587f1fe..7ca3424b59ce 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> @@ -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



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory
  2023-07-04 15:49 ` [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory Thomas Zimmermann
@ 2023-07-05  8:23   ` Javier Martinez Canillas
  2023-07-05  9:08     ` Thomas Zimmermann
  0 siblings, 1 reply; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  8:23 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Helge Deller

Thomas Zimmermann <tzimmermann@suse.de> writes:

Hello Thomas,

> 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Helge Deller <deller@gmx.de>
> ---
>  drivers/video/fbdev/Kconfig |  8 ++++++++
>  include/linux/fb.h          | 13 +++++++++++++
>  2 files changed, 21 insertions(+)
>
> diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
> index cecf15418632..f14229757311 100644
> --- a/drivers/video/fbdev/Kconfig
> +++ b/drivers/video/fbdev/Kconfig
> @@ -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
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index 1d5c13f34b09..1191a78c5289 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -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.
 */

> +#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
> +

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 02/10] drm/fbdev-dma: Use fbdev DMA helpers
  2023-07-04 15:49 ` [PATCH 02/10] drm/fbdev-dma: Use fbdev DMA helpers Thomas Zimmermann
@ 2023-07-05  8:24   ` Javier Martinez Canillas
  0 siblings, 0 replies; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  8:24 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Use fbdev's DMA helpers for fbdev-dma. They are equivalent to the
> previously used system-memory helpers, so no functional changes here.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 03/10] drm/tegra: Use fbdev DMA helpers
  2023-07-04 15:50 ` [PATCH 03/10] drm/tegra: " Thomas Zimmermann
@ 2023-07-05  8:24   ` Javier Martinez Canillas
  0 siblings, 0 replies; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  8:24 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Thierry Reding, Mikko Perttunen

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Use fbdev's DMA helpers for fbdev emulation. They are equivalent to the
> previously used system-memory helpers, so no functional changes here.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Mikko Perttunen <mperttunen@nvidia.com>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers
  2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
                   ` (9 preceding siblings ...)
  2023-07-04 15:50 ` [PATCH 10/10] fbdev: Remove FB_DEFAULT_SYS_OPS Thomas Zimmermann
@ 2023-07-05  8:30 ` Maxime Ripard
  10 siblings, 0 replies; 30+ messages in thread
From: Maxime Ripard @ 2023-07-05  8:30 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: dri-devel, javierm, linux-arm-kernel, linux-fbdev,
	linux-samsung-soc, linux-tegra, maarten.lankhorst, mripard

On Tue, 4 Jul 2023 17:49:57 +0200, Thomas Zimmermann wrote:
> 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.
> 
> 
> [ ... ]

Acked-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 04/10] drm/tegra: Set fbdev flags
  2023-07-04 15:50 ` [PATCH 04/10] drm/tegra: Set fbdev flags Thomas Zimmermann
@ 2023-07-05  8:34   ` Javier Martinez Canillas
  2023-07-05  9:19     ` Thomas Zimmermann
  0 siblings, 1 reply; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  8:34 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Thierry Reding, Mikko Perttunen

Thomas Zimmermann <tzimmermann@suse.de> writes:

> 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Mikko Perttunen <mperttunen@nvidia.com>
> ---
>  drivers/gpu/drm/tegra/fbdev.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c
> index 82577b7c88da..8074430c52f1 100644
> --- a/drivers/gpu/drm/tegra/fbdev.c
> +++ b/drivers/gpu/drm/tegra/fbdev.c
> @@ -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;

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.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 05/10] drm/exynos: Use fbdev DMA helpers
  2023-07-04 15:50 ` [PATCH 05/10] drm/exynos: Use fbdev DMA helpers Thomas Zimmermann
  2023-07-05  2:10   ` 대인기/Tizen Platform Lab(SR)/삼성전자
@ 2023-07-05  8:38   ` Javier Martinez Canillas
  1 sibling, 0 replies; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  8:38 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Inki Dae, Seung-Woo Kim,
	Kyungmin Park, Krzysztof Kozlowski, Alim Akhtar

Thomas Zimmermann <tzimmermann@suse.de> writes:

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

s/They/The

> 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> 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.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 06/10] drm/exynos: Set fbdev flags
  2023-07-04 15:50 ` [PATCH 06/10] drm/exynos: Set fbdev flags Thomas Zimmermann
@ 2023-07-05  8:49   ` Javier Martinez Canillas
  2023-07-05  9:31     ` Thomas Zimmermann
  0 siblings, 1 reply; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  8:49 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Inki Dae, Seung-Woo Kim,
	Kyungmin Park, Krzysztof Kozlowski, Alim Akhtar

Thomas Zimmermann <tzimmermann@suse.de> writes:

> 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 ?

> FBINFO_VIRTFB. The framebuffer range is in DMA-able memory and should
> be accessed with the CPU's regular memory ops.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Inki Dae <inki.dae@samsung.com>
> Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> index 7ca3424b59ce..28dc398d6e10 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> @@ -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

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 07/10] drm/omapdrm: Set VM flags in GEM-object mmap function
  2023-07-04 15:50 ` [PATCH 07/10] drm/omapdrm: Set VM flags in GEM-object mmap function Thomas Zimmermann
@ 2023-07-05  9:03   ` Javier Martinez Canillas
  0 siblings, 0 replies; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  9:03 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Tomi Valkeinen

Thomas Zimmermann <tzimmermann@suse.de> writes:

> 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---

> +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;
>  }
>

I think this rework deserves a more elaborated commit message.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 08/10] drm/omapdrm: Use GEM mmap for fbdev emulation
  2023-07-04 15:50 ` [PATCH 08/10] drm/omapdrm: Use GEM mmap for fbdev emulation Thomas Zimmermann
@ 2023-07-05  9:05   ` Javier Martinez Canillas
  0 siblings, 0 replies; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  9:05 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Tomi Valkeinen

Thomas Zimmermann <tzimmermann@suse.de> writes:

> 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 09/10] drm/omapdrm: Set fbdev flags
  2023-07-04 15:50 ` [PATCH 09/10] drm/omapdrm: Set fbdev flags Thomas Zimmermann
@ 2023-07-05  9:07   ` Javier Martinez Canillas
  0 siblings, 0 replies; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  9:07 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Tomi Valkeinen

Thomas Zimmermann <tzimmermann@suse.de> writes:

> 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.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 10/10] fbdev: Remove FB_DEFAULT_SYS_OPS
  2023-07-04 15:50 ` [PATCH 10/10] fbdev: Remove FB_DEFAULT_SYS_OPS Thomas Zimmermann
@ 2023-07-05  9:07   ` Javier Martinez Canillas
  0 siblings, 0 replies; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  9:07 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thomas Zimmermann, Helge Deller

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Remove the initializer macro FB_DEFAULT_SYS_OPS and its helper macro
> __FB_DEFAULT_SYS_OPS_MMAP. There are no users.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Helge Deller <deller@gmx.de> (maintainer:FRAMEBUFFER LAYER)
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory
  2023-07-05  8:23   ` Javier Martinez Canillas
@ 2023-07-05  9:08     ` Thomas Zimmermann
  2023-07-05  9:13       ` Javier Martinez Canillas
  0 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-05  9:08 UTC (permalink / raw)
  To: Javier Martinez Canillas, maarten.lankhorst, mripard
  Cc: linux-fbdev, linux-samsung-soc, Helge Deller, dri-devel,
	linux-tegra, linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 2713 bytes --]

Hi Javier

Am 05.07.23 um 10:23 schrieb Javier Martinez Canillas:
> Thomas Zimmermann <tzimmermann@suse.de> writes:
> 
> Hello Thomas,
> 
>> 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.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Cc: Helge Deller <deller@gmx.de>
>> ---
>>   drivers/video/fbdev/Kconfig |  8 ++++++++
>>   include/linux/fb.h          | 13 +++++++++++++
>>   2 files changed, 21 insertions(+)
>>
>> diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
>> index cecf15418632..f14229757311 100644
>> --- a/drivers/video/fbdev/Kconfig
>> +++ b/drivers/video/fbdev/Kconfig
>> @@ -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
>> diff --git a/include/linux/fb.h b/include/linux/fb.h
>> index 1d5c13f34b09..1191a78c5289 100644
>> --- a/include/linux/fb.h
>> +++ b/include/linux/fb.h
>> @@ -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,

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

Best regards
Thomas


> so something like:
> 
> /*
>   * Initializes struct fb_ops 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
>> +
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> 

-- 
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)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory
  2023-07-05  9:08     ` Thomas Zimmermann
@ 2023-07-05  9:13       ` Javier Martinez Canillas
  0 siblings, 0 replies; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  9:13 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: linux-fbdev, linux-samsung-soc, Helge Deller, dri-devel,
	linux-tegra, linux-arm-kernel

Thomas Zimmermann <tzimmermann@suse.de> writes:

[...]

>> 
>> 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!

> Best regards
> Thomas
>
>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 04/10] drm/tegra: Set fbdev flags
  2023-07-05  8:34   ` Javier Martinez Canillas
@ 2023-07-05  9:19     ` Thomas Zimmermann
  2023-07-05  9:34       ` Javier Martinez Canillas
  0 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-05  9:19 UTC (permalink / raw)
  To: Javier Martinez Canillas, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thierry Reding, Mikko Perttunen


[-- Attachment #1.1: Type: text/plain, Size: 2537 bytes --]

Hi Javier

Am 05.07.23 um 10:34 schrieb Javier Martinez Canillas:
> Thomas Zimmermann <tzimmermann@suse.de> writes:
> 
>> 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.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Cc: Thierry Reding <thierry.reding@gmail.com>
>> Cc: Mikko Perttunen <mperttunen@nvidia.com>
>> ---
>>   drivers/gpu/drm/tegra/fbdev.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c
>> index 82577b7c88da..8074430c52f1 100644
>> --- a/drivers/gpu/drm/tegra/fbdev.c
>> +++ b/drivers/gpu/drm/tegra/fbdev.c
>> @@ -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;
> 
> 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

> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> 

-- 
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)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 06/10] drm/exynos: Set fbdev flags
  2023-07-05  8:49   ` Javier Martinez Canillas
@ 2023-07-05  9:31     ` Thomas Zimmermann
  2023-07-05  9:53       ` Javier Martinez Canillas
  0 siblings, 1 reply; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-05  9:31 UTC (permalink / raw)
  To: Javier Martinez Canillas, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Alim Akhtar


[-- Attachment #1.1: Type: text/plain, Size: 2398 bytes --]

Hi

Am 05.07.23 um 10:49 schrieb Javier Martinez Canillas:
> Thomas Zimmermann <tzimmermann@suse.de> writes:
> 
>> 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 ?
> 
>> FBINFO_VIRTFB. The framebuffer range is in DMA-able memory and should
>> be accessed with the CPU's regular memory ops.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Cc: Inki Dae <inki.dae@samsung.com>
>> Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
>> Cc: Kyungmin Park <kyungmin.park@samsung.com>
>> Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>> Cc: Alim Akhtar <alim.akhtar@samsung.com>
>> ---
>>   drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
>> index 7ca3424b59ce..28dc398d6e10 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
>> @@ -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:

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

> 
> $ git grep FBINFO_DEFAULT | wc -l
> 92
> 
> $ git grep FBINFO_FLAG_DEFAULT | wc -l
> 38
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> 

-- 
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)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 04/10] drm/tegra: Set fbdev flags
  2023-07-05  9:19     ` Thomas Zimmermann
@ 2023-07-05  9:34       ` Javier Martinez Canillas
  2023-07-06 12:44         ` Thomas Zimmermann
  0 siblings, 1 reply; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  9:34 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thierry Reding, Mikko Perttunen

Thomas Zimmermann <tzimmermann@suse.de> writes:

[...]
   
>>> +	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.
>

Yes, that makes sense.

> _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.

> Best regards
> Thomas
>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 06/10] drm/exynos: Set fbdev flags
  2023-07-05  9:31     ` Thomas Zimmermann
@ 2023-07-05  9:53       ` Javier Martinez Canillas
  0 siblings, 0 replies; 30+ messages in thread
From: Javier Martinez Canillas @ 2023-07-05  9:53 UTC (permalink / raw)
  To: Thomas Zimmermann, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Alim Akhtar

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Hi
>
> Am 05.07.23 um 10:49 schrieb Javier Martinez Canillas:

[...]

>> 
>> 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.
>

Agreed.

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 04/10] drm/tegra: Set fbdev flags
  2023-07-05  9:34       ` Javier Martinez Canillas
@ 2023-07-06 12:44         ` Thomas Zimmermann
  0 siblings, 0 replies; 30+ messages in thread
From: Thomas Zimmermann @ 2023-07-06 12:44 UTC (permalink / raw)
  To: Javier Martinez Canillas, maarten.lankhorst, mripard
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	linux-fbdev, Thierry Reding, Mikko Perttunen


[-- Attachment #1.1: Type: text/plain, Size: 1995 bytes --]

Hi

Am 05.07.23 um 11:34 schrieb Javier Martinez Canillas:
> Thomas Zimmermann <tzimmermann@suse.de> writes:
> 
> [...]
>     
>>>> +	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.
>>
> 
> Yes, that makes sense.
> 
>> _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.

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

> 
>> Best regards
>> Thomas
>>
> 

-- 
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)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2023-07-06 12:45 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04 15:49 [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Thomas Zimmermann
2023-07-04 15:49 ` [PATCH 01/10] fbdev: Add fb_ops init macros for framebuffers in DMA-able memory Thomas Zimmermann
2023-07-05  8:23   ` Javier Martinez Canillas
2023-07-05  9:08     ` Thomas Zimmermann
2023-07-05  9:13       ` Javier Martinez Canillas
2023-07-04 15:49 ` [PATCH 02/10] drm/fbdev-dma: Use fbdev DMA helpers Thomas Zimmermann
2023-07-05  8:24   ` Javier Martinez Canillas
2023-07-04 15:50 ` [PATCH 03/10] drm/tegra: " Thomas Zimmermann
2023-07-05  8:24   ` Javier Martinez Canillas
2023-07-04 15:50 ` [PATCH 04/10] drm/tegra: Set fbdev flags Thomas Zimmermann
2023-07-05  8:34   ` Javier Martinez Canillas
2023-07-05  9:19     ` Thomas Zimmermann
2023-07-05  9:34       ` Javier Martinez Canillas
2023-07-06 12:44         ` Thomas Zimmermann
2023-07-04 15:50 ` [PATCH 05/10] drm/exynos: Use fbdev DMA helpers Thomas Zimmermann
2023-07-05  2:10   ` 대인기/Tizen Platform Lab(SR)/삼성전자
2023-07-05  8:38   ` Javier Martinez Canillas
2023-07-04 15:50 ` [PATCH 06/10] drm/exynos: Set fbdev flags Thomas Zimmermann
2023-07-05  8:49   ` Javier Martinez Canillas
2023-07-05  9:31     ` Thomas Zimmermann
2023-07-05  9:53       ` Javier Martinez Canillas
2023-07-04 15:50 ` [PATCH 07/10] drm/omapdrm: Set VM flags in GEM-object mmap function Thomas Zimmermann
2023-07-05  9:03   ` Javier Martinez Canillas
2023-07-04 15:50 ` [PATCH 08/10] drm/omapdrm: Use GEM mmap for fbdev emulation Thomas Zimmermann
2023-07-05  9:05   ` Javier Martinez Canillas
2023-07-04 15:50 ` [PATCH 09/10] drm/omapdrm: Set fbdev flags Thomas Zimmermann
2023-07-05  9:07   ` Javier Martinez Canillas
2023-07-04 15:50 ` [PATCH 10/10] fbdev: Remove FB_DEFAULT_SYS_OPS Thomas Zimmermann
2023-07-05  9:07   ` Javier Martinez Canillas
2023-07-05  8:30 ` [PATCH 00/10] drm: Improve fbdev emulation for DMA-able framebuffers Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).