linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O
@ 2023-05-22 12:21 Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 01/12] fbdev: Add Kconfig options to select different fb_ops helpers Thomas Zimmermann
                   ` (11 more replies)
  0 siblings, 12 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann

DRM provides a number of wrappers around fbdev cfb_() sys_(), fb_io_()
and fb_sys_() helpers. The DRM functions don't provide any additional
functionality for most DRM drivers. So remove them and call the fbdev
I/O helpers directly.

The DRM fbdev I/O wrappers were originally added because <linux/fb.h>
does not protect its content with CONFIG_FB. DRM fbdev emulation did
not build if the config option had been disabled. This has been
fixed. For fbdev-generic and i915, the wrappers added support for damage
handling. But this is better handled within the two callers, as each
is special in its damage handling.

Patch 1 adds several internal Kconfig otpions that DRM drivers (and
possibly other fbdev code) will use to select the correct set of I/O
helpers.

Patches 2 to 9 replace the DRM wrappers in a number of fbdev emulations.
Patch 10 exports two helpers for damage handling. Patches 11 and 12
update fbdev-generic and i915 with the help of the exported functions.
The patches also remove DRM's fbdev I/O helpers, which are now unused.

DRM's fbdev helpers had to select fbdev I/O helpers for I/O and for
system memory. Each fbdev emulation now selects the correct helpers
for itself. Depending on the selected DRM drivers, kernel builds will
now only contain the necessary fbdev I/O helpers and might be slightly
smaller in size.

v3:
	* fix Kconfig options (Jingfeng)
	* minimize changes to exynos (Sam)
v2:
	* simplify Kconfig handling (Sam)

Thomas Zimmermann (12):
  fbdev: Add Kconfig options to select different fb_ops helpers
  drm/armada: Use regular fbdev I/O helpers
  drm/exynos: Use regular fbdev I/O helpers
  drm/gma500: Use regular fbdev I/O helpers
  drm/radeon: Use regular fbdev I/O helpers
  drm/fbdev-dma: Use regular fbdev I/O helpers
  drm/msm: Use regular fbdev I/O helpers
  drm/omapdrm: Use regular fbdev I/O helpers
  drm/tegra: Use regular fbdev I/O helpers
  drm/fb-helper: Export helpers for marking damage areas
  drm/fbdev-generic: Implement dedicated fbdev I/O helpers
  drm/i915: Implement dedicated fbdev I/O helpers

 drivers/gpu/drm/Kconfig                    |  10 +-
 drivers/gpu/drm/armada/Kconfig             |   1 +
 drivers/gpu/drm/armada/armada_fbdev.c      |   9 +-
 drivers/gpu/drm/drm_fb_helper.c            | 233 ++-------------------
 drivers/gpu/drm/drm_fbdev_dma.c            |  12 +-
 drivers/gpu/drm/drm_fbdev_generic.c        |  47 ++++-
 drivers/gpu/drm/exynos/Kconfig             |   1 +
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c  |  10 +-
 drivers/gpu/drm/gma500/Kconfig             |   1 +
 drivers/gpu/drm/gma500/fbdev.c             |   9 +-
 drivers/gpu/drm/i915/Kconfig               |   1 +
 drivers/gpu/drm/i915/display/intel_fbdev.c |  51 ++++-
 drivers/gpu/drm/msm/Kconfig                |   1 +
 drivers/gpu/drm/msm/msm_fbdev.c            |  12 +-
 drivers/gpu/drm/omapdrm/Kconfig            |   1 +
 drivers/gpu/drm/omapdrm/omap_fbdev.c       |  12 +-
 drivers/gpu/drm/radeon/Kconfig             |   1 +
 drivers/gpu/drm/radeon/radeon_fbdev.c      |   9 +-
 drivers/gpu/drm/tegra/Kconfig              |   1 +
 drivers/gpu/drm/tegra/fbdev.c              |  11 +-
 drivers/video/fbdev/Kconfig                |  21 ++
 include/drm/drm_fb_helper.h                |  84 +-------
 22 files changed, 183 insertions(+), 355 deletions(-)


base-commit: f533234d40e8f5b8599bd5bc97fa8e30384aec03
prerequisite-patch-id: 0aa359f6144c4015c140c8a6750be19099c676fb
prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24
prerequisite-patch-id: cbc453ee02fae02af22fbfdce56ab732c7a88c36
-- 
2.40.1


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

* [PATCH v3 01/12] fbdev: Add Kconfig options to select different fb_ops helpers
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 02/12] drm/armada: Use regular fbdev I/O helpers Thomas Zimmermann
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann

Many fbdev drivers use the same set of fb_ops helpers. Add Kconfig
options to select them at once. This will help with making DRM's
fbdev emulation code more modular, but can also be used to simplify
fbdev's driver configs.

v3:
	* fix select statement (Jingfeng)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/Kconfig | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 485e8c35d5c6..6e4b6ad9d8e6 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -158,6 +158,27 @@ config FB_DEFERRED_IO
 	bool
 	depends on FB
 
+config FB_IO_HELPERS
+	bool
+	depends on FB
+	select FB_CFB_COPYAREA
+	select FB_CFB_FILLRECT
+	select FB_CFB_IMAGEBLIT
+
+config FB_SYS_HELPERS
+	bool
+	depends on FB
+	select FB_SYS_COPYAREA
+	select FB_SYS_FILLRECT
+	select FB_SYS_FOPS
+	select FB_SYS_IMAGEBLIT
+
+config FB_SYS_HELPERS_DEFERRED
+	bool
+	depends on FB
+	select FB_DEFERRED_IO
+	select FB_SYS_HELPERS
+
 config FB_HECUBA
 	tristate
 	depends on FB
-- 
2.40.1


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

* [PATCH v3 02/12] drm/armada: Use regular fbdev I/O helpers
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 01/12] fbdev: Add Kconfig options to select different fb_ops helpers Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 03/12] drm/exynos: " Thomas Zimmermann
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann, Russell King

Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Armada does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v2:
	* use FB_IO_HELPERS option

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Russell King <linux@armlinux.org.uk>
---
 drivers/gpu/drm/armada/Kconfig        | 1 +
 drivers/gpu/drm/armada/armada_fbdev.c | 9 ++++-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/armada/Kconfig b/drivers/gpu/drm/armada/Kconfig
index f5c66d89ba99..5afade25e217 100644
--- a/drivers/gpu/drm/armada/Kconfig
+++ b/drivers/gpu/drm/armada/Kconfig
@@ -3,6 +3,7 @@ config DRM_ARMADA
 	tristate "DRM support for Marvell Armada SoCs"
 	depends on DRM && HAVE_CLK && ARM && MMU
 	select DRM_KMS_HELPER
+	select FB_IO_HELPERS if DRM_FBDEV_EMULATION
 	help
 	  Support the "LCD" controllers found on the Marvell Armada 510
 	  devices.  There are two controllers on the device, each controller
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
index 0a5fd1aa86eb..6c3bbaf53569 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -5,6 +5,7 @@
  */
 
 #include <linux/errno.h>
+#include <linux/fb.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 
@@ -34,11 +35,9 @@ static void armada_fbdev_fb_destroy(struct fb_info *info)
 static const struct fb_ops armada_fb_ops = {
 	.owner		= THIS_MODULE,
 	DRM_FB_HELPER_DEFAULT_OPS,
-	.fb_read	= drm_fb_helper_cfb_read,
-	.fb_write	= drm_fb_helper_cfb_write,
-	.fb_fillrect	= drm_fb_helper_cfb_fillrect,
-	.fb_copyarea	= drm_fb_helper_cfb_copyarea,
-	.fb_imageblit	= drm_fb_helper_cfb_imageblit,
+	.fb_fillrect	= cfb_fillrect,
+	.fb_copyarea	= cfb_copyarea,
+	.fb_imageblit	= cfb_imageblit,
 	.fb_destroy	= armada_fbdev_fb_destroy,
 };
 
-- 
2.40.1


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

* [PATCH v3 03/12] drm/exynos: Use regular fbdev I/O helpers
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 01/12] fbdev: Add Kconfig options to select different fb_ops helpers Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 02/12] drm/armada: Use regular fbdev I/O helpers Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 04/12] drm/gma500: " Thomas Zimmermann
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Alim Akhtar

Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Exynos does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v3:
	* don't reorder Makefile rules (Sam)
v2:
	* use FB_IO_HELPERS option

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/Kconfig            |  1 +
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 0cb92d651ff1..7ca7e1dab52c 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -7,6 +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 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 ea4b3d248aac..b3333dd1d087 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -8,6 +8,8 @@
  *	Seung-Woo Kim <sw0312.kim@samsung.com>
  */
 
+#include <linux/fb.h>
+
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_fb_helper.h>
@@ -49,11 +51,9 @@ static const struct fb_ops exynos_drm_fb_ops = {
 	.owner		= THIS_MODULE,
 	DRM_FB_HELPER_DEFAULT_OPS,
 	.fb_mmap        = exynos_drm_fb_mmap,
-	.fb_read	= drm_fb_helper_cfb_read,
-	.fb_write	= drm_fb_helper_cfb_write,
-	.fb_fillrect	= drm_fb_helper_cfb_fillrect,
-	.fb_copyarea	= drm_fb_helper_cfb_copyarea,
-	.fb_imageblit	= drm_fb_helper_cfb_imageblit,
+	.fb_fillrect	= cfb_fillrect,
+	.fb_copyarea	= cfb_copyarea,
+	.fb_imageblit	= cfb_imageblit,
 	.fb_destroy	= exynos_drm_fb_destroy,
 };
 
-- 
2.40.1


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

* [PATCH v3 04/12] drm/gma500: Use regular fbdev I/O helpers
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
                   ` (2 preceding siblings ...)
  2023-05-22 12:21 ` [PATCH v3 03/12] drm/exynos: " Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 05/12] drm/radeon: " Thomas Zimmermann
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann, Patrik Jakobsson

Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Gma500 does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v2:
	* use FB_IO_HELPERS option

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
---
 drivers/gpu/drm/gma500/Kconfig | 1 +
 drivers/gpu/drm/gma500/fbdev.c | 9 ++++-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/gma500/Kconfig b/drivers/gpu/drm/gma500/Kconfig
index 2efc0eb41c64..cd3d92725ed4 100644
--- a/drivers/gpu/drm/gma500/Kconfig
+++ b/drivers/gpu/drm/gma500/Kconfig
@@ -3,6 +3,7 @@ config DRM_GMA500
 	tristate "Intel GMA500/600/3600/3650 KMS Framebuffer"
 	depends on DRM && PCI && X86 && MMU
 	select DRM_KMS_HELPER
+	select FB_IO_HELPERS if DRM_FBDEV_EMULATION
 	select I2C
 	select I2C_ALGOBIT
 	# GMA500 depends on ACPI_VIDEO when ACPI is enabled, just like i915
diff --git a/drivers/gpu/drm/gma500/fbdev.c b/drivers/gpu/drm/gma500/fbdev.c
index 62287407e717..60005c3d01d0 100644
--- a/drivers/gpu/drm/gma500/fbdev.c
+++ b/drivers/gpu/drm/gma500/fbdev.c
@@ -5,6 +5,7 @@
  *
  **************************************************************************/
 
+#include <linux/fb.h>
 #include <linux/pfn_t.h>
 
 #include <drm/drm_crtc_helper.h>
@@ -136,11 +137,9 @@ static const struct fb_ops psb_fbdev_fb_ops = {
 	.owner = THIS_MODULE,
 	DRM_FB_HELPER_DEFAULT_OPS,
 	.fb_setcolreg = psb_fbdev_fb_setcolreg,
-	.fb_read = drm_fb_helper_cfb_read,
-	.fb_write = drm_fb_helper_cfb_write,
-	.fb_fillrect = drm_fb_helper_cfb_fillrect,
-	.fb_copyarea = drm_fb_helper_cfb_copyarea,
-	.fb_imageblit = drm_fb_helper_cfb_imageblit,
+	.fb_fillrect = cfb_fillrect,
+	.fb_copyarea = cfb_copyarea,
+	.fb_imageblit = cfb_imageblit,
 	.fb_mmap = psb_fbdev_fb_mmap,
 	.fb_destroy = psb_fbdev_fb_destroy,
 };
-- 
2.40.1


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

* [PATCH v3 05/12] drm/radeon: Use regular fbdev I/O helpers
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
                   ` (3 preceding siblings ...)
  2023-05-22 12:21 ` [PATCH v3 04/12] drm/gma500: " Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 06/12] drm/fbdev-dma: " Thomas Zimmermann
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann, Alex Deucher, Christian König, Pan,
	Xinhui

Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Radeon does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v2:
	* use FB_IO_HELPERS option

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
---
 drivers/gpu/drm/radeon/Kconfig        | 1 +
 drivers/gpu/drm/radeon/radeon_fbdev.c | 9 ++++-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/radeon/Kconfig b/drivers/gpu/drm/radeon/Kconfig
index e19d77d58810..fe498c8af1bb 100644
--- a/drivers/gpu/drm/radeon/Kconfig
+++ b/drivers/gpu/drm/radeon/Kconfig
@@ -11,6 +11,7 @@ config DRM_RADEON
 	select DRM_SUBALLOC_HELPER
         select DRM_TTM
 	select DRM_TTM_HELPER
+	select FB_IO_HELPERS if DRM_FBDEV_EMULATION
 	select SND_HDA_COMPONENT if SND_HDA_CORE
 	select POWER_SUPPLY
 	select HWMON
diff --git a/drivers/gpu/drm/radeon/radeon_fbdev.c b/drivers/gpu/drm/radeon/radeon_fbdev.c
index fe76e29910ef..dcabe527f9c0 100644
--- a/drivers/gpu/drm/radeon/radeon_fbdev.c
+++ b/drivers/gpu/drm/radeon/radeon_fbdev.c
@@ -24,6 +24,7 @@
  *     David Airlie
  */
 
+#include <linux/fb.h>
 #include <linux/pci.h>
 #include <linux/pm_runtime.h>
 #include <linux/vga_switcheroo.h>
@@ -193,11 +194,9 @@ static const struct fb_ops radeon_fbdev_fb_ops = {
 	DRM_FB_HELPER_DEFAULT_OPS,
 	.fb_open = radeon_fbdev_fb_open,
 	.fb_release = radeon_fbdev_fb_release,
-	.fb_read = drm_fb_helper_cfb_read,
-	.fb_write = drm_fb_helper_cfb_write,
-	.fb_fillrect = drm_fb_helper_cfb_fillrect,
-	.fb_copyarea = drm_fb_helper_cfb_copyarea,
-	.fb_imageblit = drm_fb_helper_cfb_imageblit,
+	.fb_fillrect = cfb_fillrect,
+	.fb_copyarea = cfb_copyarea,
+	.fb_imageblit = cfb_imageblit,
 	.fb_destroy = radeon_fbdev_fb_destroy,
 };
 
-- 
2.40.1


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

* [PATCH v3 06/12] drm/fbdev-dma: Use regular fbdev I/O helpers
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
                   ` (4 preceding siblings ...)
  2023-05-22 12:21 ` [PATCH v3 05/12] drm/radeon: " Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 07/12] drm/msm: " Thomas Zimmermann
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann

Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Fbdev-dma does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v2:
	* use FB_SYS_HELPERS option

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

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index ba3fb04bb691..77fb10ddd8a2 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -223,6 +223,7 @@ config DRM_TTM_HELPER
 config DRM_GEM_DMA_HELPER
 	tristate
 	depends on DRM
+	select FB_SYS_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 728deffcc0d9..09a36dc38c43 100644
--- a/drivers/gpu/drm/drm_fbdev_dma.c
+++ b/drivers/gpu/drm/drm_fbdev_dma.c
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: MIT
 
+#include <linux/fb.h>
+
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_fb_helper.h>
@@ -64,12 +66,12 @@ 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_read = drm_fb_helper_sys_read,
-	.fb_write = drm_fb_helper_sys_write,
+	.fb_read = fb_sys_read,
+	.fb_write = fb_sys_write,
 	DRM_FB_HELPER_DEFAULT_OPS,
-	.fb_fillrect = drm_fb_helper_sys_fillrect,
-	.fb_copyarea = drm_fb_helper_sys_copyarea,
-	.fb_imageblit = drm_fb_helper_sys_imageblit,
+	.fb_fillrect = sys_fillrect,
+	.fb_copyarea = sys_copyarea,
+	.fb_imageblit = sys_imageblit,
 	.fb_destroy = drm_fbdev_dma_fb_destroy,
 	.fb_mmap = drm_fbdev_dma_fb_mmap,
 };
-- 
2.40.1


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

* [PATCH v3 07/12] drm/msm: Use regular fbdev I/O helpers
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
                   ` (5 preceding siblings ...)
  2023-05-22 12:21 ` [PATCH v3 06/12] drm/fbdev-dma: " Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 08/12] drm/omapdrm: " Thomas Zimmermann
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann, Dmitry Baryshkov, Rob Clark, Abhinav Kumar,
	Sean Paul

Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Msm does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v2:
	* use FB_SYS_HELPERS option

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Sean Paul <sean@poorly.run>
---
 drivers/gpu/drm/msm/Kconfig     |  1 +
 drivers/gpu/drm/msm/msm_fbdev.c | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig
index 85f5ab1d552c..a78662bd6273 100644
--- a/drivers/gpu/drm/msm/Kconfig
+++ b/drivers/gpu/drm/msm/Kconfig
@@ -21,6 +21,7 @@ config DRM_MSM
 	select DRM_BRIDGE
 	select DRM_PANEL_BRIDGE
 	select DRM_SCHED
+	select FB_SYS_HELPERS if DRM_FBDEV_EMULATION
 	select SHMEM
 	select TMPFS
 	select QCOM_SCM
diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index 2ebc86381e1c..fc0353a4160e 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -4,6 +4,8 @@
  * Author: Rob Clark <robdclark@gmail.com>
  */
 
+#include <linux/fb.h>
+
 #include <drm/drm_drv.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
@@ -57,11 +59,11 @@ static const struct fb_ops msm_fb_ops = {
 	/* Note: to properly handle manual update displays, we wrap the
 	 * basic fbdev ops which write to the framebuffer
 	 */
-	.fb_read = drm_fb_helper_sys_read,
-	.fb_write = drm_fb_helper_sys_write,
-	.fb_fillrect = drm_fb_helper_sys_fillrect,
-	.fb_copyarea = drm_fb_helper_sys_copyarea,
-	.fb_imageblit = drm_fb_helper_sys_imageblit,
+	.fb_read = fb_sys_read,
+	.fb_write = fb_sys_write,
+	.fb_fillrect = sys_fillrect,
+	.fb_copyarea = sys_copyarea,
+	.fb_imageblit = sys_imageblit,
 	.fb_mmap = msm_fbdev_mmap,
 	.fb_destroy = msm_fbdev_fb_destroy,
 };
-- 
2.40.1


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

* [PATCH v3 08/12] drm/omapdrm: Use regular fbdev I/O helpers
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
                   ` (6 preceding siblings ...)
  2023-05-22 12:21 ` [PATCH v3 07/12] drm/msm: " Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 09/12] drm/tegra: " Thomas Zimmermann
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann, Tomi Valkeinen

Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Omapdrm does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v2:
	* use FB_SYS_HELPERS option

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Tomi Valkeinen <tomba@kernel.org>
---
 drivers/gpu/drm/omapdrm/Kconfig      |  1 +
 drivers/gpu/drm/omapdrm/omap_fbdev.c | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
index 76ded1568bd0..b4ac76c9f31b 100644
--- a/drivers/gpu/drm/omapdrm/Kconfig
+++ b/drivers/gpu/drm/omapdrm/Kconfig
@@ -4,6 +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 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 b950e93b3846..55a65b81ccdc 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -4,6 +4,8 @@
  * Author: Rob Clark <rob@ti.com>
  */
 
+#include <linux/fb.h>
+
 #include <drm/drm_drv.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
@@ -103,11 +105,11 @@ static const struct fb_ops omap_fb_ops = {
 	.fb_pan_display = omap_fbdev_pan_display,
 	.fb_ioctl	= drm_fb_helper_ioctl,
 
-	.fb_read = drm_fb_helper_sys_read,
-	.fb_write = drm_fb_helper_sys_write,
-	.fb_fillrect = drm_fb_helper_sys_fillrect,
-	.fb_copyarea = drm_fb_helper_sys_copyarea,
-	.fb_imageblit = drm_fb_helper_sys_imageblit,
+	.fb_read = fb_sys_read,
+	.fb_write = fb_sys_write,
+	.fb_fillrect = sys_fillrect,
+	.fb_copyarea = sys_copyarea,
+	.fb_imageblit = sys_imageblit,
 
 	.fb_destroy = omap_fbdev_fb_destroy,
 };
-- 
2.40.1


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

* [PATCH v3 09/12] drm/tegra: Use regular fbdev I/O helpers
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
                   ` (7 preceding siblings ...)
  2023-05-22 12:21 ` [PATCH v3 08/12] drm/omapdrm: " Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 10/12] drm/fb-helper: Export helpers for marking damage areas Thomas Zimmermann
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann, Thierry Reding, Mikko Perttunen,
	Jonathan Hunter

Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Tegra does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

v2:
	* use FB_SYS_HELPERS option

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

diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig
index 56453ca277c2..498313778175 100644
--- a/drivers/gpu/drm/tegra/Kconfig
+++ b/drivers/gpu/drm/tegra/Kconfig
@@ -12,6 +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 TEGRA_HOST1X
 	select INTERCONNECT
 	select IOMMU_IOVA
diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c
index dca9eccae466..144d851e566f 100644
--- a/drivers/gpu/drm/tegra/fbdev.c
+++ b/drivers/gpu/drm/tegra/fbdev.c
@@ -8,6 +8,7 @@
  */
 
 #include <linux/console.h>
+#include <linux/fb.h>
 #include <linux/vmalloc.h>
 
 #include <drm/drm_drv.h>
@@ -59,11 +60,11 @@ static void tegra_fbdev_fb_destroy(struct fb_info *info)
 static const struct fb_ops tegra_fb_ops = {
 	.owner = THIS_MODULE,
 	DRM_FB_HELPER_DEFAULT_OPS,
-	.fb_read = drm_fb_helper_sys_read,
-	.fb_write = drm_fb_helper_sys_write,
-	.fb_fillrect = drm_fb_helper_sys_fillrect,
-	.fb_copyarea = drm_fb_helper_sys_copyarea,
-	.fb_imageblit = drm_fb_helper_sys_imageblit,
+	.fb_read = fb_sys_read,
+	.fb_write = fb_sys_write,
+	.fb_fillrect = sys_fillrect,
+	.fb_copyarea = sys_copyarea,
+	.fb_imageblit = sys_imageblit,
 	.fb_mmap = tegra_fb_mmap,
 	.fb_destroy = tegra_fbdev_fb_destroy,
 };
-- 
2.40.1


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

* [PATCH v3 10/12] drm/fb-helper: Export helpers for marking damage areas
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
                   ` (8 preceding siblings ...)
  2023-05-22 12:21 ` [PATCH v3 09/12] drm/tegra: " Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 11/12] drm/fbdev-generic: Implement dedicated fbdev I/O helpers Thomas Zimmermann
  2023-05-22 12:21 ` [PATCH v3 12/12] drm/i915: " Thomas Zimmermann
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann

Export drm_fb_helper_damage() and drm_fb_helper_damage_range(), which
handle damage areas for fbdev emulation. This is a temporary export
that allows to move the DRM I/O helpers for fbdev into drivers. Only
fbdev-generic and i915 need them. Both will be updated to implement
damage handling by themselves and the exported functions will be removed.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/drm_fb_helper.c | 19 +++++++++++++++++--
 include/drm/drm_fb_helper.h     |  4 ++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index f0e9549b6bd7..8724e08c518b 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -625,13 +625,15 @@ static void drm_fb_helper_add_damage_clip(struct drm_fb_helper *helper, u32 x, u
 	spin_unlock_irqrestore(&helper->damage_lock, flags);
 }
 
-static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y,
-				 u32 width, u32 height)
+/* Don't use in new code. */
+void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y,
+			  u32 width, u32 height)
 {
 	drm_fb_helper_add_damage_clip(helper, x, y, width, height);
 
 	schedule_work(&helper->damage_work);
 }
+EXPORT_SYMBOL(drm_fb_helper_damage);
 
 /*
  * Convert memory region into area of scanlines and pixels per
@@ -670,6 +672,19 @@ static void drm_fb_helper_memory_range_to_clip(struct fb_info *info, off_t off,
 	drm_rect_init(clip, x1, y1, x2 - x1, y2 - y1);
 }
 
+/* Don't use in new code. */
+void drm_fb_helper_damage_range(struct drm_fb_helper *fb_helper, off_t off, size_t len)
+{
+	struct fb_info *info = fb_helper->info;
+	struct drm_rect damage_area;
+
+	drm_fb_helper_memory_range_to_clip(info, off, len, &damage_area);
+	drm_fb_helper_damage(fb_helper, damage_area.x1, damage_area.y1,
+			     drm_rect_width(&damage_area),
+			     drm_rect_height(&damage_area));
+}
+EXPORT_SYMBOL(drm_fb_helper_damage_range);
+
 /**
  * drm_fb_helper_deferred_io() - fbdev deferred_io callback function
  * @info: fb_info struct pointer
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 72032c354a30..80c402f4e379 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -253,6 +253,10 @@ void drm_fb_helper_fill_info(struct fb_info *info,
 			     struct drm_fb_helper *fb_helper,
 			     struct drm_fb_helper_surface_size *sizes);
 
+void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y,
+			  u32 width, u32 height);
+void drm_fb_helper_damage_range(struct drm_fb_helper *helper, off_t off, size_t len);
+
 void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagereflist);
 
 ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
-- 
2.40.1


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

* [PATCH v3 11/12] drm/fbdev-generic: Implement dedicated fbdev I/O helpers
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
                   ` (9 preceding siblings ...)
  2023-05-22 12:21 ` [PATCH v3 10/12] drm/fb-helper: Export helpers for marking damage areas Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  2023-05-22 13:20   ` [Freedreno] " Dmitry Baryshkov
  2023-05-22 12:21 ` [PATCH v3 12/12] drm/i915: " Thomas Zimmermann
  11 siblings, 1 reply; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann

Implement dedicated fbdev helpers for framebuffer I/O instead
of using DRM's helpers. Fbdev-generic was the only caller of the
DRM helpers, so remove them from the helper module.

v2:
	* use FB_SYS_HELPERS_DEFERRED option

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/Kconfig             |   6 +-
 drivers/gpu/drm/drm_fb_helper.c     | 107 ----------------------------
 drivers/gpu/drm/drm_fbdev_generic.c |  47 ++++++++++--
 include/drm/drm_fb_helper.h         |  41 -----------
 4 files changed, 43 insertions(+), 158 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 77fb10ddd8a2..92a782827b7b 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -95,6 +95,7 @@ config DRM_KUNIT_TEST
 config DRM_KMS_HELPER
 	tristate
 	depends on DRM
+	select FB_SYS_HELPERS_DEFERRED if DRM_FBDEV_EMULATION
 	help
 	  CRTC helpers for KMS drivers.
 
@@ -135,11 +136,6 @@ config DRM_FBDEV_EMULATION
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
-	select FB_DEFERRED_IO
-	select FB_SYS_FOPS
-	select FB_SYS_FILLRECT
-	select FB_SYS_COPYAREA
-	select FB_SYS_IMAGEBLIT
 	select FRAMEBUFFER_CONSOLE if !EXPERT
 	select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
 	default y
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 8724e08c518b..ba0a808f14ee 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -729,113 +729,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli
 }
 EXPORT_SYMBOL(drm_fb_helper_deferred_io);
 
-/**
- * drm_fb_helper_sys_read - Implements struct &fb_ops.fb_read for system memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to read from framebuffer memory
- * @count: number of bytes to read from framebuffer memory
- * @ppos: read offset within framebuffer memory
- *
- * Returns:
- * The number of bytes read on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
-			       size_t count, loff_t *ppos)
-{
-	return fb_sys_read(info, buf, count, ppos);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_read);
-
-/**
- * drm_fb_helper_sys_write - Implements struct &fb_ops.fb_write for system memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to write to framebuffer memory
- * @count: number of bytes to write to framebuffer memory
- * @ppos: write offset within framebuffer memory
- *
- * Returns:
- * The number of bytes written on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
-				size_t count, loff_t *ppos)
-{
-	struct drm_fb_helper *helper = info->par;
-	loff_t pos = *ppos;
-	ssize_t ret;
-	struct drm_rect damage_area;
-
-	ret = fb_sys_write(info, buf, count, ppos);
-	if (ret <= 0)
-		return ret;
-
-	if (helper->funcs->fb_dirty) {
-		drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area);
-		drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
-				     drm_rect_width(&damage_area),
-				     drm_rect_height(&damage_area));
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_write);
-
-/**
- * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect
- * @info: fbdev registered by the helper
- * @rect: info about rectangle to fill
- *
- * A wrapper around sys_fillrect implemented by fbdev core
- */
-void drm_fb_helper_sys_fillrect(struct fb_info *info,
-				const struct fb_fillrect *rect)
-{
-	struct drm_fb_helper *helper = info->par;
-
-	sys_fillrect(info, rect);
-
-	if (helper->funcs->fb_dirty)
-		drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_fillrect);
-
-/**
- * drm_fb_helper_sys_copyarea - wrapper around sys_copyarea
- * @info: fbdev registered by the helper
- * @area: info about area to copy
- *
- * A wrapper around sys_copyarea implemented by fbdev core
- */
-void drm_fb_helper_sys_copyarea(struct fb_info *info,
-				const struct fb_copyarea *area)
-{
-	struct drm_fb_helper *helper = info->par;
-
-	sys_copyarea(info, area);
-
-	if (helper->funcs->fb_dirty)
-		drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_copyarea);
-
-/**
- * drm_fb_helper_sys_imageblit - wrapper around sys_imageblit
- * @info: fbdev registered by the helper
- * @image: info about image to blit
- *
- * A wrapper around sys_imageblit implemented by fbdev core
- */
-void drm_fb_helper_sys_imageblit(struct fb_info *info,
-				 const struct fb_image *image)
-{
-	struct drm_fb_helper *helper = info->par;
-
-	sys_imageblit(info, image);
-
-	if (helper->funcs->fb_dirty)
-		drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_imageblit);
-
 /**
  * drm_fb_helper_cfb_read - Implements struct &fb_ops.fb_read for I/O memory
  * @info: fb_info struct pointer
diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c
index 8e5148bf40bb..f53fc49e34a4 100644
--- a/drivers/gpu/drm/drm_fbdev_generic.c
+++ b/drivers/gpu/drm/drm_fbdev_generic.c
@@ -34,6 +34,43 @@ static int drm_fbdev_generic_fb_release(struct fb_info *info, int user)
 	return 0;
 }
 
+static ssize_t drm_fbdev_generic_fb_write(struct fb_info *info, const char __user *buf,
+					  size_t count, loff_t *ppos)
+{
+	struct drm_fb_helper *helper = info->par;
+	loff_t pos = *ppos;
+	ssize_t ret;
+
+	ret = fb_sys_write(info, buf, count, ppos);
+	if (ret > 0)
+		drm_fb_helper_damage_range(helper, pos, ret);
+	return ret;
+}
+
+static void drm_fbdev_generic_fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
+{
+	struct drm_fb_helper *helper = info->par;
+
+	sys_fillrect(info, rect);
+	drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height);
+}
+
+static void drm_fbdev_generic_fb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
+{
+	struct drm_fb_helper *helper = info->par;
+
+	sys_copyarea(info, area);
+	drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height);
+}
+
+static void drm_fbdev_generic_fb_imageblit(struct fb_info *info, const struct fb_image *image)
+{
+	struct drm_fb_helper *helper = info->par;
+
+	sys_imageblit(info, image);
+	drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->height);
+}
+
 static void drm_fbdev_generic_fb_destroy(struct fb_info *info)
 {
 	struct drm_fb_helper *fb_helper = info->par;
@@ -56,12 +93,12 @@ static const struct fb_ops drm_fbdev_generic_fb_ops = {
 	.owner		= THIS_MODULE,
 	.fb_open	= drm_fbdev_generic_fb_open,
 	.fb_release	= drm_fbdev_generic_fb_release,
-	.fb_read	= drm_fb_helper_sys_read,
-	.fb_write	= drm_fb_helper_sys_write,
+	.fb_read	= fb_sys_read,
+	.fb_write	= drm_fbdev_generic_fb_write,
 	DRM_FB_HELPER_DEFAULT_OPS,
-	.fb_fillrect	= drm_fb_helper_sys_fillrect,
-	.fb_copyarea	= drm_fb_helper_sys_copyarea,
-	.fb_imageblit	= drm_fb_helper_sys_imageblit,
+	.fb_fillrect	= drm_fbdev_generic_fb_fillrect,
+	.fb_copyarea	= drm_fbdev_generic_fb_copyarea,
+	.fb_imageblit	= drm_fbdev_generic_fb_imageblit,
 	.fb_mmap	= fb_deferred_io_mmap,
 	.fb_destroy	= drm_fbdev_generic_fb_destroy,
 };
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 80c402f4e379..e3240d749a43 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -259,18 +259,6 @@ void drm_fb_helper_damage_range(struct drm_fb_helper *helper, off_t off, size_t
 
 void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagereflist);
 
-ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
-			       size_t count, loff_t *ppos);
-ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
-				size_t count, loff_t *ppos);
-
-void drm_fb_helper_sys_fillrect(struct fb_info *info,
-				const struct fb_fillrect *rect);
-void drm_fb_helper_sys_copyarea(struct fb_info *info,
-				const struct fb_copyarea *area);
-void drm_fb_helper_sys_imageblit(struct fb_info *info,
-				 const struct fb_image *image);
-
 ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
 			       size_t count, loff_t *ppos);
 ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf,
@@ -398,35 +386,6 @@ static inline int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper)
 	return -ENODEV;
 }
 
-static inline ssize_t drm_fb_helper_sys_read(struct fb_info *info,
-					     char __user *buf, size_t count,
-					     loff_t *ppos)
-{
-	return -ENODEV;
-}
-
-static inline ssize_t drm_fb_helper_sys_write(struct fb_info *info,
-					      const char __user *buf,
-					      size_t count, loff_t *ppos)
-{
-	return -ENODEV;
-}
-
-static inline void drm_fb_helper_sys_fillrect(struct fb_info *info,
-					      const struct fb_fillrect *rect)
-{
-}
-
-static inline void drm_fb_helper_sys_copyarea(struct fb_info *info,
-					      const struct fb_copyarea *area)
-{
-}
-
-static inline void drm_fb_helper_sys_imageblit(struct fb_info *info,
-					       const struct fb_image *image)
-{
-}
-
 static inline ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
 					     size_t count, loff_t *ppos)
 {
-- 
2.40.1


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

* [PATCH v3 12/12] drm/i915: Implement dedicated fbdev I/O helpers
  2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
                   ` (10 preceding siblings ...)
  2023-05-22 12:21 ` [PATCH v3 11/12] drm/fbdev-generic: Implement dedicated fbdev I/O helpers Thomas Zimmermann
@ 2023-05-22 12:21 ` Thomas Zimmermann
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 12:21 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, javierm, sam
  Cc: dri-devel, linux-arm-kernel, linux-samsung-soc, intel-gfx,
	linux-arm-msm, freedreno, amd-gfx, linux-tegra,
	Thomas Zimmermann, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
	Tvrtko Ursulin, Ville Syrjälä

Implement dedicated fbdev helpers for framebuffer I/O instead
of using DRM's helpers. i915 was the only caller of the DRM
helpers, so remove them from the helper module.

v2:
	* use FB_IO_HELPERS options

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/Kconfig                    |   3 -
 drivers/gpu/drm/drm_fb_helper.c            | 107 ---------------------
 drivers/gpu/drm/i915/Kconfig               |   1 +
 drivers/gpu/drm/i915/display/intel_fbdev.c |  51 ++++++++--
 include/drm/drm_fb_helper.h                |  39 --------
 5 files changed, 46 insertions(+), 155 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 92a782827b7b..bb2e48cc6cd6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -133,9 +133,6 @@ config DRM_FBDEV_EMULATION
 	bool "Enable legacy fbdev support for your modesetting driver"
 	depends on DRM_KMS_HELPER
 	depends on FB=y || FB=DRM_KMS_HELPER
-	select FB_CFB_FILLRECT
-	select FB_CFB_COPYAREA
-	select FB_CFB_IMAGEBLIT
 	select FRAMEBUFFER_CONSOLE if !EXPERT
 	select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
 	default y
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index ba0a808f14ee..5927896ad8f6 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -729,113 +729,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli
 }
 EXPORT_SYMBOL(drm_fb_helper_deferred_io);
 
-/**
- * drm_fb_helper_cfb_read - Implements struct &fb_ops.fb_read for I/O memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to read from framebuffer memory
- * @count: number of bytes to read from framebuffer memory
- * @ppos: read offset within framebuffer memory
- *
- * Returns:
- * The number of bytes read on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
-			       size_t count, loff_t *ppos)
-{
-	return fb_io_read(info, buf, count, ppos);
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_read);
-
-/**
- * drm_fb_helper_cfb_write - Implements struct &fb_ops.fb_write for I/O memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to write to framebuffer memory
- * @count: number of bytes to write to framebuffer memory
- * @ppos: write offset within framebuffer memory
- *
- * Returns:
- * The number of bytes written on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf,
-				size_t count, loff_t *ppos)
-{
-	struct drm_fb_helper *helper = info->par;
-	loff_t pos = *ppos;
-	ssize_t ret;
-	struct drm_rect damage_area;
-
-	ret = fb_io_write(info, buf, count, ppos);
-	if (ret <= 0)
-		return ret;
-
-	if (helper->funcs->fb_dirty) {
-		drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area);
-		drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
-				     drm_rect_width(&damage_area),
-				     drm_rect_height(&damage_area));
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_write);
-
-/**
- * drm_fb_helper_cfb_fillrect - wrapper around cfb_fillrect
- * @info: fbdev registered by the helper
- * @rect: info about rectangle to fill
- *
- * A wrapper around cfb_fillrect implemented by fbdev core
- */
-void drm_fb_helper_cfb_fillrect(struct fb_info *info,
-				const struct fb_fillrect *rect)
-{
-	struct drm_fb_helper *helper = info->par;
-
-	cfb_fillrect(info, rect);
-
-	if (helper->funcs->fb_dirty)
-		drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect);
-
-/**
- * drm_fb_helper_cfb_copyarea - wrapper around cfb_copyarea
- * @info: fbdev registered by the helper
- * @area: info about area to copy
- *
- * A wrapper around cfb_copyarea implemented by fbdev core
- */
-void drm_fb_helper_cfb_copyarea(struct fb_info *info,
-				const struct fb_copyarea *area)
-{
-	struct drm_fb_helper *helper = info->par;
-
-	cfb_copyarea(info, area);
-
-	if (helper->funcs->fb_dirty)
-		drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_copyarea);
-
-/**
- * drm_fb_helper_cfb_imageblit - wrapper around cfb_imageblit
- * @info: fbdev registered by the helper
- * @image: info about image to blit
- *
- * A wrapper around cfb_imageblit implemented by fbdev core
- */
-void drm_fb_helper_cfb_imageblit(struct fb_info *info,
-				 const struct fb_image *image)
-{
-	struct drm_fb_helper *helper = info->par;
-
-	cfb_imageblit(info, image);
-
-	if (helper->funcs->fb_dirty)
-		drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_imageblit);
-
 /**
  * drm_fb_helper_set_suspend - wrapper around fb_set_suspend
  * @fb_helper: driver-allocated fbdev helper, can be NULL
diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
index e4f4d2e3fdfe..01b5a8272a27 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -17,6 +17,7 @@ config DRM_I915
 	select DRM_KMS_HELPER
 	select DRM_PANEL
 	select DRM_MIPI_DSI
+	select FB_IO_HELPERS if DRM_FBDEV_EMULATION
 	select RELAY
 	select I2C
 	select I2C_ALGOBIT
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c b/drivers/gpu/drm/i915/display/intel_fbdev.c
index aab1ae74a8f7..64aeacef703d 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -28,6 +28,7 @@
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
+#include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
@@ -84,6 +85,20 @@ static void intel_fbdev_invalidate(struct intel_fbdev *ifbdev)
 	intel_frontbuffer_invalidate(to_frontbuffer(ifbdev), ORIGIN_CPU);
 }
 
+static ssize_t intel_fbdev_fb_write(struct fb_info *info, const char __user *buf,
+				    size_t count, loff_t *ppos)
+{
+	struct drm_fb_helper *helper = info->par;
+	loff_t pos = *ppos;
+	ssize_t ret;
+
+	ret = fb_io_write(info, buf, count, ppos);
+	if (ret > 0)
+		drm_fb_helper_damage_range(helper, pos, ret);
+
+	return ret;
+}
+
 static int intel_fbdev_set_par(struct fb_info *info)
 {
 	struct intel_fbdev *ifbdev = to_intel_fbdev(info->par);
@@ -121,6 +136,30 @@ static int intel_fbdev_pan_display(struct fb_var_screeninfo *var,
 	return ret;
 }
 
+static void intel_fbdev_fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
+{
+	struct drm_fb_helper *helper = info->par;
+
+	cfb_fillrect(info, rect);
+	drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height);
+}
+
+static void intel_fbdev_fb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
+{
+	struct drm_fb_helper *helper = info->par;
+
+	cfb_copyarea(info, area);
+	drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height);
+}
+
+static void intel_fbdev_fb_imageblit(struct fb_info *info, const struct fb_image *image)
+{
+	struct drm_fb_helper *helper = info->par;
+
+	cfb_imageblit(info, image);
+	drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->height);
+}
+
 static int intel_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma)
 {
 	struct intel_fbdev *fbdev = to_intel_fbdev(info->par);
@@ -134,13 +173,13 @@ static const struct fb_ops intelfb_ops = {
 	.owner = THIS_MODULE,
 	DRM_FB_HELPER_DEFAULT_OPS,
 	.fb_set_par = intel_fbdev_set_par,
-	.fb_read = drm_fb_helper_cfb_read,
-	.fb_write = drm_fb_helper_cfb_write,
-	.fb_fillrect = drm_fb_helper_cfb_fillrect,
-	.fb_copyarea = drm_fb_helper_cfb_copyarea,
-	.fb_imageblit = drm_fb_helper_cfb_imageblit,
-	.fb_pan_display = intel_fbdev_pan_display,
+	.fb_read = fb_io_read,
+	.fb_write = intel_fbdev_fb_write,
 	.fb_blank = intel_fbdev_blank,
+	.fb_pan_display = intel_fbdev_pan_display,
+	.fb_fillrect = intel_fbdev_fb_fillrect,
+	.fb_copyarea = intel_fbdev_fb_copyarea,
+	.fb_imageblit = intel_fbdev_fb_imageblit,
 	.fb_mmap = intel_fbdev_mmap,
 };
 
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index e3240d749a43..15f03d8fb5cd 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -259,18 +259,6 @@ void drm_fb_helper_damage_range(struct drm_fb_helper *helper, off_t off, size_t
 
 void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagereflist);
 
-ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
-			       size_t count, loff_t *ppos);
-ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf,
-				size_t count, loff_t *ppos);
-
-void drm_fb_helper_cfb_fillrect(struct fb_info *info,
-				const struct fb_fillrect *rect);
-void drm_fb_helper_cfb_copyarea(struct fb_info *info,
-				const struct fb_copyarea *area);
-void drm_fb_helper_cfb_imageblit(struct fb_info *info,
-				 const struct fb_image *image);
-
 void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, bool suspend);
 void drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper,
 					bool suspend);
@@ -386,33 +374,6 @@ static inline int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper)
 	return -ENODEV;
 }
 
-static inline ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
-					     size_t count, loff_t *ppos)
-{
-	return -ENODEV;
-}
-
-static inline ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf,
-					      size_t count, loff_t *ppos)
-{
-	return -ENODEV;
-}
-
-static inline void drm_fb_helper_cfb_fillrect(struct fb_info *info,
-					      const struct fb_fillrect *rect)
-{
-}
-
-static inline void drm_fb_helper_cfb_copyarea(struct fb_info *info,
-					      const struct fb_copyarea *area)
-{
-}
-
-static inline void drm_fb_helper_cfb_imageblit(struct fb_info *info,
-					       const struct fb_image *image)
-{
-}
-
 static inline void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper,
 					     bool suspend)
 {
-- 
2.40.1


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

* Re: [Freedreno] [PATCH v3 11/12] drm/fbdev-generic: Implement dedicated fbdev I/O helpers
  2023-05-22 12:21 ` [PATCH v3 11/12] drm/fbdev-generic: Implement dedicated fbdev I/O helpers Thomas Zimmermann
@ 2023-05-22 13:20   ` Dmitry Baryshkov
  2023-05-22 18:46     ` Thomas Zimmermann
  0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Baryshkov @ 2023-05-22 13:20 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: daniel, airlied, maarten.lankhorst, mripard, javierm, sam,
	linux-samsung-soc, linux-arm-msm, intel-gfx, dri-devel, amd-gfx,
	linux-tegra, freedreno, linux-arm-kernel

On Mon, 22 May 2023 at 15:22, Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Implement dedicated fbdev helpers for framebuffer I/O instead
> of using DRM's helpers. Fbdev-generic was the only caller of the
> DRM helpers, so remove them from the helper module.
>
> v2:
>         * use FB_SYS_HELPERS_DEFERRED option
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>  drivers/gpu/drm/Kconfig             |   6 +-
>  drivers/gpu/drm/drm_fb_helper.c     | 107 ----------------------------
>  drivers/gpu/drm/drm_fbdev_generic.c |  47 ++++++++++--
>  include/drm/drm_fb_helper.h         |  41 -----------
>  4 files changed, 43 insertions(+), 158 deletions(-)

Looking at this patch makes me wonder if we should have implemented
fb_dirty for the MSM driver. We have drm_framebuffer_funcs::dirty()
implemented (by wrapping the drm_atomic_helper_dirtyfb()).

>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 77fb10ddd8a2..92a782827b7b 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -95,6 +95,7 @@ config DRM_KUNIT_TEST
>  config DRM_KMS_HELPER
>         tristate
>         depends on DRM
> +       select FB_SYS_HELPERS_DEFERRED if DRM_FBDEV_EMULATION
>         help
>           CRTC helpers for KMS drivers.
>
> @@ -135,11 +136,6 @@ config DRM_FBDEV_EMULATION
>         select FB_CFB_FILLRECT
>         select FB_CFB_COPYAREA
>         select FB_CFB_IMAGEBLIT
> -       select FB_DEFERRED_IO
> -       select FB_SYS_FOPS
> -       select FB_SYS_FILLRECT
> -       select FB_SYS_COPYAREA
> -       select FB_SYS_IMAGEBLIT
>         select FRAMEBUFFER_CONSOLE if !EXPERT
>         select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
>         default y
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 8724e08c518b..ba0a808f14ee 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -729,113 +729,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli
>  }
>  EXPORT_SYMBOL(drm_fb_helper_deferred_io);
>
> -/**
> - * drm_fb_helper_sys_read - Implements struct &fb_ops.fb_read for system memory
> - * @info: fb_info struct pointer
> - * @buf: userspace buffer to read from framebuffer memory
> - * @count: number of bytes to read from framebuffer memory
> - * @ppos: read offset within framebuffer memory
> - *
> - * Returns:
> - * The number of bytes read on success, or an error code otherwise.
> - */
> -ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
> -                              size_t count, loff_t *ppos)
> -{
> -       return fb_sys_read(info, buf, count, ppos);
> -}
> -EXPORT_SYMBOL(drm_fb_helper_sys_read);
> -
> -/**
> - * drm_fb_helper_sys_write - Implements struct &fb_ops.fb_write for system memory
> - * @info: fb_info struct pointer
> - * @buf: userspace buffer to write to framebuffer memory
> - * @count: number of bytes to write to framebuffer memory
> - * @ppos: write offset within framebuffer memory
> - *
> - * Returns:
> - * The number of bytes written on success, or an error code otherwise.
> - */
> -ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
> -                               size_t count, loff_t *ppos)
> -{
> -       struct drm_fb_helper *helper = info->par;
> -       loff_t pos = *ppos;
> -       ssize_t ret;
> -       struct drm_rect damage_area;
> -
> -       ret = fb_sys_write(info, buf, count, ppos);
> -       if (ret <= 0)
> -               return ret;
> -
> -       if (helper->funcs->fb_dirty) {
> -               drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area);
> -               drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
> -                                    drm_rect_width(&damage_area),
> -                                    drm_rect_height(&damage_area));
> -       }
> -
> -       return ret;
> -}
> -EXPORT_SYMBOL(drm_fb_helper_sys_write);
> -
> -/**
> - * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect
> - * @info: fbdev registered by the helper
> - * @rect: info about rectangle to fill
> - *
> - * A wrapper around sys_fillrect implemented by fbdev core
> - */
> -void drm_fb_helper_sys_fillrect(struct fb_info *info,
> -                               const struct fb_fillrect *rect)
> -{
> -       struct drm_fb_helper *helper = info->par;
> -
> -       sys_fillrect(info, rect);
> -
> -       if (helper->funcs->fb_dirty)
> -               drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height);
> -}
> -EXPORT_SYMBOL(drm_fb_helper_sys_fillrect);
> -
> -/**
> - * drm_fb_helper_sys_copyarea - wrapper around sys_copyarea
> - * @info: fbdev registered by the helper
> - * @area: info about area to copy
> - *
> - * A wrapper around sys_copyarea implemented by fbdev core
> - */
> -void drm_fb_helper_sys_copyarea(struct fb_info *info,
> -                               const struct fb_copyarea *area)
> -{
> -       struct drm_fb_helper *helper = info->par;
> -
> -       sys_copyarea(info, area);
> -
> -       if (helper->funcs->fb_dirty)
> -               drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height);
> -}
> -EXPORT_SYMBOL(drm_fb_helper_sys_copyarea);
> -
> -/**
> - * drm_fb_helper_sys_imageblit - wrapper around sys_imageblit
> - * @info: fbdev registered by the helper
> - * @image: info about image to blit
> - *
> - * A wrapper around sys_imageblit implemented by fbdev core
> - */
> -void drm_fb_helper_sys_imageblit(struct fb_info *info,
> -                                const struct fb_image *image)
> -{
> -       struct drm_fb_helper *helper = info->par;
> -
> -       sys_imageblit(info, image);
> -
> -       if (helper->funcs->fb_dirty)
> -               drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->height);
> -}
> -EXPORT_SYMBOL(drm_fb_helper_sys_imageblit);
> -
>  /**
>   * drm_fb_helper_cfb_read - Implements struct &fb_ops.fb_read for I/O memory
>   * @info: fb_info struct pointer
> diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c
> index 8e5148bf40bb..f53fc49e34a4 100644
> --- a/drivers/gpu/drm/drm_fbdev_generic.c
> +++ b/drivers/gpu/drm/drm_fbdev_generic.c
> @@ -34,6 +34,43 @@ static int drm_fbdev_generic_fb_release(struct fb_info *info, int user)
>         return 0;
>  }
>
> +static ssize_t drm_fbdev_generic_fb_write(struct fb_info *info, const char __user *buf,
> +                                         size_t count, loff_t *ppos)
> +{
> +       struct drm_fb_helper *helper = info->par;
> +       loff_t pos = *ppos;
> +       ssize_t ret;
> +
> +       ret = fb_sys_write(info, buf, count, ppos);
> +       if (ret > 0)
> +               drm_fb_helper_damage_range(helper, pos, ret);
> +       return ret;
> +}
> +
> +static void drm_fbdev_generic_fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
> +{
> +       struct drm_fb_helper *helper = info->par;
> +
> +       sys_fillrect(info, rect);
> +       drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height);
> +}
> +
> +static void drm_fbdev_generic_fb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
> +{
> +       struct drm_fb_helper *helper = info->par;
> +
> +       sys_copyarea(info, area);
> +       drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height);
> +}
> +
> +static void drm_fbdev_generic_fb_imageblit(struct fb_info *info, const struct fb_image *image)
> +{
> +       struct drm_fb_helper *helper = info->par;
> +
> +       sys_imageblit(info, image);
> +       drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->height);
> +}
> +
>  static void drm_fbdev_generic_fb_destroy(struct fb_info *info)
>  {
>         struct drm_fb_helper *fb_helper = info->par;
> @@ -56,12 +93,12 @@ static const struct fb_ops drm_fbdev_generic_fb_ops = {
>         .owner          = THIS_MODULE,
>         .fb_open        = drm_fbdev_generic_fb_open,
>         .fb_release     = drm_fbdev_generic_fb_release,
> -       .fb_read        = drm_fb_helper_sys_read,
> -       .fb_write       = drm_fb_helper_sys_write,
> +       .fb_read        = fb_sys_read,
> +       .fb_write       = drm_fbdev_generic_fb_write,
>         DRM_FB_HELPER_DEFAULT_OPS,
> -       .fb_fillrect    = drm_fb_helper_sys_fillrect,
> -       .fb_copyarea    = drm_fb_helper_sys_copyarea,
> -       .fb_imageblit   = drm_fb_helper_sys_imageblit,
> +       .fb_fillrect    = drm_fbdev_generic_fb_fillrect,
> +       .fb_copyarea    = drm_fbdev_generic_fb_copyarea,
> +       .fb_imageblit   = drm_fbdev_generic_fb_imageblit,
>         .fb_mmap        = fb_deferred_io_mmap,
>         .fb_destroy     = drm_fbdev_generic_fb_destroy,
>  };
> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
> index 80c402f4e379..e3240d749a43 100644
> --- a/include/drm/drm_fb_helper.h
> +++ b/include/drm/drm_fb_helper.h
> @@ -259,18 +259,6 @@ void drm_fb_helper_damage_range(struct drm_fb_helper *helper, off_t off, size_t
>
>  void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagereflist);
>
> -ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
> -                              size_t count, loff_t *ppos);
> -ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
> -                               size_t count, loff_t *ppos);
> -
> -void drm_fb_helper_sys_fillrect(struct fb_info *info,
> -                               const struct fb_fillrect *rect);
> -void drm_fb_helper_sys_copyarea(struct fb_info *info,
> -                               const struct fb_copyarea *area);
> -void drm_fb_helper_sys_imageblit(struct fb_info *info,
> -                                const struct fb_image *image);
> -
>  ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
>                                size_t count, loff_t *ppos);
>  ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf,
> @@ -398,35 +386,6 @@ static inline int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper)
>         return -ENODEV;
>  }
>
> -static inline ssize_t drm_fb_helper_sys_read(struct fb_info *info,
> -                                            char __user *buf, size_t count,
> -                                            loff_t *ppos)
> -{
> -       return -ENODEV;
> -}
> -
> -static inline ssize_t drm_fb_helper_sys_write(struct fb_info *info,
> -                                             const char __user *buf,
> -                                             size_t count, loff_t *ppos)
> -{
> -       return -ENODEV;
> -}
> -
> -static inline void drm_fb_helper_sys_fillrect(struct fb_info *info,
> -                                             const struct fb_fillrect *rect)
> -{
> -}
> -
> -static inline void drm_fb_helper_sys_copyarea(struct fb_info *info,
> -                                             const struct fb_copyarea *area)
> -{
> -}
> -
> -static inline void drm_fb_helper_sys_imageblit(struct fb_info *info,
> -                                              const struct fb_image *image)
> -{
> -}
> -
>  static inline ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
>                                              size_t count, loff_t *ppos)
>  {
> --
> 2.40.1
>


-- 
With best wishes
Dmitry

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

* Re: [Freedreno] [PATCH v3 11/12] drm/fbdev-generic: Implement dedicated fbdev I/O helpers
  2023-05-22 13:20   ` [Freedreno] " Dmitry Baryshkov
@ 2023-05-22 18:46     ` Thomas Zimmermann
  2023-05-23 19:19       ` Thomas Zimmermann
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-22 18:46 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: daniel, airlied, maarten.lankhorst, mripard, javierm, sam,
	linux-samsung-soc, linux-arm-msm, intel-gfx, dri-devel, amd-gfx,
	linux-tegra, freedreno, linux-arm-kernel


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

Hi

Am 22.05.23 um 15:20 schrieb Dmitry Baryshkov:
> On Mon, 22 May 2023 at 15:22, Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>
>> Implement dedicated fbdev helpers for framebuffer I/O instead
>> of using DRM's helpers. Fbdev-generic was the only caller of the
>> DRM helpers, so remove them from the helper module.
>>
>> v2:
>>          * use FB_SYS_HELPERS_DEFERRED option
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> ---
>>   drivers/gpu/drm/Kconfig             |   6 +-
>>   drivers/gpu/drm/drm_fb_helper.c     | 107 ----------------------------
>>   drivers/gpu/drm/drm_fbdev_generic.c |  47 ++++++++++--
>>   include/drm/drm_fb_helper.h         |  41 -----------
>>   4 files changed, 43 insertions(+), 158 deletions(-)
> 
> Looking at this patch makes me wonder if we should have implemented
> fb_dirty for the MSM driver. We have drm_framebuffer_funcs::dirty()
> implemented (by wrapping the drm_atomic_helper_dirtyfb()).

I think so. You'd need something similar to the generic fbdev emulation. 
But it's for a separate patchset. Apparently no one has complained so far.

Best regards
Thomas

> 
>>
>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>> index 77fb10ddd8a2..92a782827b7b 100644
>> --- a/drivers/gpu/drm/Kconfig
>> +++ b/drivers/gpu/drm/Kconfig
>> @@ -95,6 +95,7 @@ config DRM_KUNIT_TEST
>>   config DRM_KMS_HELPER
>>          tristate
>>          depends on DRM
>> +       select FB_SYS_HELPERS_DEFERRED if DRM_FBDEV_EMULATION
>>          help
>>            CRTC helpers for KMS drivers.
>>
>> @@ -135,11 +136,6 @@ config DRM_FBDEV_EMULATION
>>          select FB_CFB_FILLRECT
>>          select FB_CFB_COPYAREA
>>          select FB_CFB_IMAGEBLIT
>> -       select FB_DEFERRED_IO
>> -       select FB_SYS_FOPS
>> -       select FB_SYS_FILLRECT
>> -       select FB_SYS_COPYAREA
>> -       select FB_SYS_IMAGEBLIT
>>          select FRAMEBUFFER_CONSOLE if !EXPERT
>>          select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
>>          default y
>> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
>> index 8724e08c518b..ba0a808f14ee 100644
>> --- a/drivers/gpu/drm/drm_fb_helper.c
>> +++ b/drivers/gpu/drm/drm_fb_helper.c
>> @@ -729,113 +729,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli
>>   }
>>   EXPORT_SYMBOL(drm_fb_helper_deferred_io);
>>
>> -/**
>> - * drm_fb_helper_sys_read - Implements struct &fb_ops.fb_read for system memory
>> - * @info: fb_info struct pointer
>> - * @buf: userspace buffer to read from framebuffer memory
>> - * @count: number of bytes to read from framebuffer memory
>> - * @ppos: read offset within framebuffer memory
>> - *
>> - * Returns:
>> - * The number of bytes read on success, or an error code otherwise.
>> - */
>> -ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
>> -                              size_t count, loff_t *ppos)
>> -{
>> -       return fb_sys_read(info, buf, count, ppos);
>> -}
>> -EXPORT_SYMBOL(drm_fb_helper_sys_read);
>> -
>> -/**
>> - * drm_fb_helper_sys_write - Implements struct &fb_ops.fb_write for system memory
>> - * @info: fb_info struct pointer
>> - * @buf: userspace buffer to write to framebuffer memory
>> - * @count: number of bytes to write to framebuffer memory
>> - * @ppos: write offset within framebuffer memory
>> - *
>> - * Returns:
>> - * The number of bytes written on success, or an error code otherwise.
>> - */
>> -ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
>> -                               size_t count, loff_t *ppos)
>> -{
>> -       struct drm_fb_helper *helper = info->par;
>> -       loff_t pos = *ppos;
>> -       ssize_t ret;
>> -       struct drm_rect damage_area;
>> -
>> -       ret = fb_sys_write(info, buf, count, ppos);
>> -       if (ret <= 0)
>> -               return ret;
>> -
>> -       if (helper->funcs->fb_dirty) {
>> -               drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area);
>> -               drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
>> -                                    drm_rect_width(&damage_area),
>> -                                    drm_rect_height(&damage_area));
>> -       }
>> -
>> -       return ret;
>> -}
>> -EXPORT_SYMBOL(drm_fb_helper_sys_write);
>> -
>> -/**
>> - * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect
>> - * @info: fbdev registered by the helper
>> - * @rect: info about rectangle to fill
>> - *
>> - * A wrapper around sys_fillrect implemented by fbdev core
>> - */
>> -void drm_fb_helper_sys_fillrect(struct fb_info *info,
>> -                               const struct fb_fillrect *rect)
>> -{
>> -       struct drm_fb_helper *helper = info->par;
>> -
>> -       sys_fillrect(info, rect);
>> -
>> -       if (helper->funcs->fb_dirty)
>> -               drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height);
>> -}
>> -EXPORT_SYMBOL(drm_fb_helper_sys_fillrect);
>> -
>> -/**
>> - * drm_fb_helper_sys_copyarea - wrapper around sys_copyarea
>> - * @info: fbdev registered by the helper
>> - * @area: info about area to copy
>> - *
>> - * A wrapper around sys_copyarea implemented by fbdev core
>> - */
>> -void drm_fb_helper_sys_copyarea(struct fb_info *info,
>> -                               const struct fb_copyarea *area)
>> -{
>> -       struct drm_fb_helper *helper = info->par;
>> -
>> -       sys_copyarea(info, area);
>> -
>> -       if (helper->funcs->fb_dirty)
>> -               drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height);
>> -}
>> -EXPORT_SYMBOL(drm_fb_helper_sys_copyarea);
>> -
>> -/**
>> - * drm_fb_helper_sys_imageblit - wrapper around sys_imageblit
>> - * @info: fbdev registered by the helper
>> - * @image: info about image to blit
>> - *
>> - * A wrapper around sys_imageblit implemented by fbdev core
>> - */
>> -void drm_fb_helper_sys_imageblit(struct fb_info *info,
>> -                                const struct fb_image *image)
>> -{
>> -       struct drm_fb_helper *helper = info->par;
>> -
>> -       sys_imageblit(info, image);
>> -
>> -       if (helper->funcs->fb_dirty)
>> -               drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->height);
>> -}
>> -EXPORT_SYMBOL(drm_fb_helper_sys_imageblit);
>> -
>>   /**
>>    * drm_fb_helper_cfb_read - Implements struct &fb_ops.fb_read for I/O memory
>>    * @info: fb_info struct pointer
>> diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c
>> index 8e5148bf40bb..f53fc49e34a4 100644
>> --- a/drivers/gpu/drm/drm_fbdev_generic.c
>> +++ b/drivers/gpu/drm/drm_fbdev_generic.c
>> @@ -34,6 +34,43 @@ static int drm_fbdev_generic_fb_release(struct fb_info *info, int user)
>>          return 0;
>>   }
>>
>> +static ssize_t drm_fbdev_generic_fb_write(struct fb_info *info, const char __user *buf,
>> +                                         size_t count, loff_t *ppos)
>> +{
>> +       struct drm_fb_helper *helper = info->par;
>> +       loff_t pos = *ppos;
>> +       ssize_t ret;
>> +
>> +       ret = fb_sys_write(info, buf, count, ppos);
>> +       if (ret > 0)
>> +               drm_fb_helper_damage_range(helper, pos, ret);
>> +       return ret;
>> +}
>> +
>> +static void drm_fbdev_generic_fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
>> +{
>> +       struct drm_fb_helper *helper = info->par;
>> +
>> +       sys_fillrect(info, rect);
>> +       drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height);
>> +}
>> +
>> +static void drm_fbdev_generic_fb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
>> +{
>> +       struct drm_fb_helper *helper = info->par;
>> +
>> +       sys_copyarea(info, area);
>> +       drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height);
>> +}
>> +
>> +static void drm_fbdev_generic_fb_imageblit(struct fb_info *info, const struct fb_image *image)
>> +{
>> +       struct drm_fb_helper *helper = info->par;
>> +
>> +       sys_imageblit(info, image);
>> +       drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->height);
>> +}
>> +
>>   static void drm_fbdev_generic_fb_destroy(struct fb_info *info)
>>   {
>>          struct drm_fb_helper *fb_helper = info->par;
>> @@ -56,12 +93,12 @@ static const struct fb_ops drm_fbdev_generic_fb_ops = {
>>          .owner          = THIS_MODULE,
>>          .fb_open        = drm_fbdev_generic_fb_open,
>>          .fb_release     = drm_fbdev_generic_fb_release,
>> -       .fb_read        = drm_fb_helper_sys_read,
>> -       .fb_write       = drm_fb_helper_sys_write,
>> +       .fb_read        = fb_sys_read,
>> +       .fb_write       = drm_fbdev_generic_fb_write,
>>          DRM_FB_HELPER_DEFAULT_OPS,
>> -       .fb_fillrect    = drm_fb_helper_sys_fillrect,
>> -       .fb_copyarea    = drm_fb_helper_sys_copyarea,
>> -       .fb_imageblit   = drm_fb_helper_sys_imageblit,
>> +       .fb_fillrect    = drm_fbdev_generic_fb_fillrect,
>> +       .fb_copyarea    = drm_fbdev_generic_fb_copyarea,
>> +       .fb_imageblit   = drm_fbdev_generic_fb_imageblit,
>>          .fb_mmap        = fb_deferred_io_mmap,
>>          .fb_destroy     = drm_fbdev_generic_fb_destroy,
>>   };
>> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
>> index 80c402f4e379..e3240d749a43 100644
>> --- a/include/drm/drm_fb_helper.h
>> +++ b/include/drm/drm_fb_helper.h
>> @@ -259,18 +259,6 @@ void drm_fb_helper_damage_range(struct drm_fb_helper *helper, off_t off, size_t
>>
>>   void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagereflist);
>>
>> -ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
>> -                              size_t count, loff_t *ppos);
>> -ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
>> -                               size_t count, loff_t *ppos);
>> -
>> -void drm_fb_helper_sys_fillrect(struct fb_info *info,
>> -                               const struct fb_fillrect *rect);
>> -void drm_fb_helper_sys_copyarea(struct fb_info *info,
>> -                               const struct fb_copyarea *area);
>> -void drm_fb_helper_sys_imageblit(struct fb_info *info,
>> -                                const struct fb_image *image);
>> -
>>   ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
>>                                 size_t count, loff_t *ppos);
>>   ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf,
>> @@ -398,35 +386,6 @@ static inline int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper)
>>          return -ENODEV;
>>   }
>>
>> -static inline ssize_t drm_fb_helper_sys_read(struct fb_info *info,
>> -                                            char __user *buf, size_t count,
>> -                                            loff_t *ppos)
>> -{
>> -       return -ENODEV;
>> -}
>> -
>> -static inline ssize_t drm_fb_helper_sys_write(struct fb_info *info,
>> -                                             const char __user *buf,
>> -                                             size_t count, loff_t *ppos)
>> -{
>> -       return -ENODEV;
>> -}
>> -
>> -static inline void drm_fb_helper_sys_fillrect(struct fb_info *info,
>> -                                             const struct fb_fillrect *rect)
>> -{
>> -}
>> -
>> -static inline void drm_fb_helper_sys_copyarea(struct fb_info *info,
>> -                                             const struct fb_copyarea *area)
>> -{
>> -}
>> -
>> -static inline void drm_fb_helper_sys_imageblit(struct fb_info *info,
>> -                                              const struct fb_image *image)
>> -{
>> -}
>> -
>>   static inline ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
>>                                               size_t count, loff_t *ppos)
>>   {
>> --
>> 2.40.1
>>
> 
> 

-- 
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] 16+ messages in thread

* Re: [Freedreno] [PATCH v3 11/12] drm/fbdev-generic: Implement dedicated fbdev I/O helpers
  2023-05-22 18:46     ` Thomas Zimmermann
@ 2023-05-23 19:19       ` Thomas Zimmermann
  0 siblings, 0 replies; 16+ messages in thread
From: Thomas Zimmermann @ 2023-05-23 19:19 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: freedreno, linux-samsung-soc, amd-gfx, intel-gfx, javierm,
	dri-devel, linux-arm-msm, linux-tegra, sam, linux-arm-kernel


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



Am 22.05.23 um 20:46 schrieb Thomas Zimmermann:
[...]
>>
>> Looking at this patch makes me wonder if we should have implemented
>> fb_dirty for the MSM driver. We have drm_framebuffer_funcs::dirty()
>> implemented (by wrapping the drm_atomic_helper_dirtyfb()).
> 
> I think so. You'd need something similar to the generic fbdev emulation. 
> But it's for a separate patchset. Apparently no one has complained so far.

I have another revision of these patches in the works and will add 
initial support for damage handling.

> 
> Best regards
> Thomas
> 
>>
>>>
>>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>>> index 77fb10ddd8a2..92a782827b7b 100644
>>> --- a/drivers/gpu/drm/Kconfig
>>> +++ b/drivers/gpu/drm/Kconfig
>>> @@ -95,6 +95,7 @@ config DRM_KUNIT_TEST
>>>   config DRM_KMS_HELPER
>>>          tristate
>>>          depends on DRM
>>> +       select FB_SYS_HELPERS_DEFERRED if DRM_FBDEV_EMULATION
>>>          help
>>>            CRTC helpers for KMS drivers.
>>>
>>> @@ -135,11 +136,6 @@ config DRM_FBDEV_EMULATION
>>>          select FB_CFB_FILLRECT
>>>          select FB_CFB_COPYAREA
>>>          select FB_CFB_IMAGEBLIT
>>> -       select FB_DEFERRED_IO
>>> -       select FB_SYS_FOPS
>>> -       select FB_SYS_FILLRECT
>>> -       select FB_SYS_COPYAREA
>>> -       select FB_SYS_IMAGEBLIT
>>>          select FRAMEBUFFER_CONSOLE if !EXPERT
>>>          select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if 
>>> FRAMEBUFFER_CONSOLE
>>>          default y
>>> diff --git a/drivers/gpu/drm/drm_fb_helper.c 
>>> b/drivers/gpu/drm/drm_fb_helper.c
>>> index 8724e08c518b..ba0a808f14ee 100644
>>> --- a/drivers/gpu/drm/drm_fb_helper.c
>>> +++ b/drivers/gpu/drm/drm_fb_helper.c
>>> @@ -729,113 +729,6 @@ void drm_fb_helper_deferred_io(struct fb_info 
>>> *info, struct list_head *pagerefli
>>>   }
>>>   EXPORT_SYMBOL(drm_fb_helper_deferred_io);
>>>
>>> -/**
>>> - * drm_fb_helper_sys_read - Implements struct &fb_ops.fb_read for 
>>> system memory
>>> - * @info: fb_info struct pointer
>>> - * @buf: userspace buffer to read from framebuffer memory
>>> - * @count: number of bytes to read from framebuffer memory
>>> - * @ppos: read offset within framebuffer memory
>>> - *
>>> - * Returns:
>>> - * The number of bytes read on success, or an error code otherwise.
>>> - */
>>> -ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
>>> -                              size_t count, loff_t *ppos)
>>> -{
>>> -       return fb_sys_read(info, buf, count, ppos);
>>> -}
>>> -EXPORT_SYMBOL(drm_fb_helper_sys_read);
>>> -
>>> -/**
>>> - * drm_fb_helper_sys_write - Implements struct &fb_ops.fb_write for 
>>> system memory
>>> - * @info: fb_info struct pointer
>>> - * @buf: userspace buffer to write to framebuffer memory
>>> - * @count: number of bytes to write to framebuffer memory
>>> - * @ppos: write offset within framebuffer memory
>>> - *
>>> - * Returns:
>>> - * The number of bytes written on success, or an error code otherwise.
>>> - */
>>> -ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char 
>>> __user *buf,
>>> -                               size_t count, loff_t *ppos)
>>> -{
>>> -       struct drm_fb_helper *helper = info->par;
>>> -       loff_t pos = *ppos;
>>> -       ssize_t ret;
>>> -       struct drm_rect damage_area;
>>> -
>>> -       ret = fb_sys_write(info, buf, count, ppos);
>>> -       if (ret <= 0)
>>> -               return ret;
>>> -
>>> -       if (helper->funcs->fb_dirty) {
>>> -               drm_fb_helper_memory_range_to_clip(info, pos, ret, 
>>> &damage_area);
>>> -               drm_fb_helper_damage(helper, damage_area.x1, 
>>> damage_area.y1,
>>> -                                    drm_rect_width(&damage_area),
>>> -                                    drm_rect_height(&damage_area));
>>> -       }
>>> -
>>> -       return ret;
>>> -}
>>> -EXPORT_SYMBOL(drm_fb_helper_sys_write);
>>> -
>>> -/**
>>> - * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect
>>> - * @info: fbdev registered by the helper
>>> - * @rect: info about rectangle to fill
>>> - *
>>> - * A wrapper around sys_fillrect implemented by fbdev core
>>> - */
>>> -void drm_fb_helper_sys_fillrect(struct fb_info *info,
>>> -                               const struct fb_fillrect *rect)
>>> -{
>>> -       struct drm_fb_helper *helper = info->par;
>>> -
>>> -       sys_fillrect(info, rect);
>>> -
>>> -       if (helper->funcs->fb_dirty)
>>> -               drm_fb_helper_damage(helper, rect->dx, rect->dy, 
>>> rect->width, rect->height);
>>> -}
>>> -EXPORT_SYMBOL(drm_fb_helper_sys_fillrect);
>>> -
>>> -/**
>>> - * drm_fb_helper_sys_copyarea - wrapper around sys_copyarea
>>> - * @info: fbdev registered by the helper
>>> - * @area: info about area to copy
>>> - *
>>> - * A wrapper around sys_copyarea implemented by fbdev core
>>> - */
>>> -void drm_fb_helper_sys_copyarea(struct fb_info *info,
>>> -                               const struct fb_copyarea *area)
>>> -{
>>> -       struct drm_fb_helper *helper = info->par;
>>> -
>>> -       sys_copyarea(info, area);
>>> -
>>> -       if (helper->funcs->fb_dirty)
>>> -               drm_fb_helper_damage(helper, area->dx, area->dy, 
>>> area->width, area->height);
>>> -}
>>> -EXPORT_SYMBOL(drm_fb_helper_sys_copyarea);
>>> -
>>> -/**
>>> - * drm_fb_helper_sys_imageblit - wrapper around sys_imageblit
>>> - * @info: fbdev registered by the helper
>>> - * @image: info about image to blit
>>> - *
>>> - * A wrapper around sys_imageblit implemented by fbdev core
>>> - */
>>> -void drm_fb_helper_sys_imageblit(struct fb_info *info,
>>> -                                const struct fb_image *image)
>>> -{
>>> -       struct drm_fb_helper *helper = info->par;
>>> -
>>> -       sys_imageblit(info, image);
>>> -
>>> -       if (helper->funcs->fb_dirty)
>>> -               drm_fb_helper_damage(helper, image->dx, image->dy, 
>>> image->width, image->height);
>>> -}
>>> -EXPORT_SYMBOL(drm_fb_helper_sys_imageblit);
>>> -
>>>   /**
>>>    * drm_fb_helper_cfb_read - Implements struct &fb_ops.fb_read for 
>>> I/O memory
>>>    * @info: fb_info struct pointer
>>> diff --git a/drivers/gpu/drm/drm_fbdev_generic.c 
>>> b/drivers/gpu/drm/drm_fbdev_generic.c
>>> index 8e5148bf40bb..f53fc49e34a4 100644
>>> --- a/drivers/gpu/drm/drm_fbdev_generic.c
>>> +++ b/drivers/gpu/drm/drm_fbdev_generic.c
>>> @@ -34,6 +34,43 @@ static int drm_fbdev_generic_fb_release(struct 
>>> fb_info *info, int user)
>>>          return 0;
>>>   }
>>>
>>> +static ssize_t drm_fbdev_generic_fb_write(struct fb_info *info, 
>>> const char __user *buf,
>>> +                                         size_t count, loff_t *ppos)
>>> +{
>>> +       struct drm_fb_helper *helper = info->par;
>>> +       loff_t pos = *ppos;
>>> +       ssize_t ret;
>>> +
>>> +       ret = fb_sys_write(info, buf, count, ppos);
>>> +       if (ret > 0)
>>> +               drm_fb_helper_damage_range(helper, pos, ret);
>>> +       return ret;
>>> +}
>>> +
>>> +static void drm_fbdev_generic_fb_fillrect(struct fb_info *info, 
>>> const struct fb_fillrect *rect)
>>> +{
>>> +       struct drm_fb_helper *helper = info->par;
>>> +
>>> +       sys_fillrect(info, rect);
>>> +       drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, 
>>> rect->height);
>>> +}
>>> +
>>> +static void drm_fbdev_generic_fb_copyarea(struct fb_info *info, 
>>> const struct fb_copyarea *area)
>>> +{
>>> +       struct drm_fb_helper *helper = info->par;
>>> +
>>> +       sys_copyarea(info, area);
>>> +       drm_fb_helper_damage(helper, area->dx, area->dy, area->width, 
>>> area->height);
>>> +}
>>> +
>>> +static void drm_fbdev_generic_fb_imageblit(struct fb_info *info, 
>>> const struct fb_image *image)
>>> +{
>>> +       struct drm_fb_helper *helper = info->par;
>>> +
>>> +       sys_imageblit(info, image);
>>> +       drm_fb_helper_damage(helper, image->dx, image->dy, 
>>> image->width, image->height);
>>> +}
>>> +
>>>   static void drm_fbdev_generic_fb_destroy(struct fb_info *info)
>>>   {
>>>          struct drm_fb_helper *fb_helper = info->par;
>>> @@ -56,12 +93,12 @@ static const struct fb_ops 
>>> drm_fbdev_generic_fb_ops = {
>>>          .owner          = THIS_MODULE,
>>>          .fb_open        = drm_fbdev_generic_fb_open,
>>>          .fb_release     = drm_fbdev_generic_fb_release,
>>> -       .fb_read        = drm_fb_helper_sys_read,
>>> -       .fb_write       = drm_fb_helper_sys_write,
>>> +       .fb_read        = fb_sys_read,
>>> +       .fb_write       = drm_fbdev_generic_fb_write,
>>>          DRM_FB_HELPER_DEFAULT_OPS,
>>> -       .fb_fillrect    = drm_fb_helper_sys_fillrect,
>>> -       .fb_copyarea    = drm_fb_helper_sys_copyarea,
>>> -       .fb_imageblit   = drm_fb_helper_sys_imageblit,
>>> +       .fb_fillrect    = drm_fbdev_generic_fb_fillrect,
>>> +       .fb_copyarea    = drm_fbdev_generic_fb_copyarea,
>>> +       .fb_imageblit   = drm_fbdev_generic_fb_imageblit,
>>>          .fb_mmap        = fb_deferred_io_mmap,
>>>          .fb_destroy     = drm_fbdev_generic_fb_destroy,
>>>   };
>>> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
>>> index 80c402f4e379..e3240d749a43 100644
>>> --- a/include/drm/drm_fb_helper.h
>>> +++ b/include/drm/drm_fb_helper.h
>>> @@ -259,18 +259,6 @@ void drm_fb_helper_damage_range(struct 
>>> drm_fb_helper *helper, off_t off, size_t
>>>
>>>   void drm_fb_helper_deferred_io(struct fb_info *info, struct 
>>> list_head *pagereflist);
>>>
>>> -ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
>>> -                              size_t count, loff_t *ppos);
>>> -ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char 
>>> __user *buf,
>>> -                               size_t count, loff_t *ppos);
>>> -
>>> -void drm_fb_helper_sys_fillrect(struct fb_info *info,
>>> -                               const struct fb_fillrect *rect);
>>> -void drm_fb_helper_sys_copyarea(struct fb_info *info,
>>> -                               const struct fb_copyarea *area);
>>> -void drm_fb_helper_sys_imageblit(struct fb_info *info,
>>> -                                const struct fb_image *image);
>>> -
>>>   ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
>>>                                 size_t count, loff_t *ppos);
>>>   ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char 
>>> __user *buf,
>>> @@ -398,35 +386,6 @@ static inline int 
>>> drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper)
>>>          return -ENODEV;
>>>   }
>>>
>>> -static inline ssize_t drm_fb_helper_sys_read(struct fb_info *info,
>>> -                                            char __user *buf, size_t 
>>> count,
>>> -                                            loff_t *ppos)
>>> -{
>>> -       return -ENODEV;
>>> -}
>>> -
>>> -static inline ssize_t drm_fb_helper_sys_write(struct fb_info *info,
>>> -                                             const char __user *buf,
>>> -                                             size_t count, loff_t 
>>> *ppos)
>>> -{
>>> -       return -ENODEV;
>>> -}
>>> -
>>> -static inline void drm_fb_helper_sys_fillrect(struct fb_info *info,
>>> -                                             const struct 
>>> fb_fillrect *rect)
>>> -{
>>> -}
>>> -
>>> -static inline void drm_fb_helper_sys_copyarea(struct fb_info *info,
>>> -                                             const struct 
>>> fb_copyarea *area)
>>> -{
>>> -}
>>> -
>>> -static inline void drm_fb_helper_sys_imageblit(struct fb_info *info,
>>> -                                              const struct fb_image 
>>> *image)
>>> -{
>>> -}
>>> -
>>>   static inline ssize_t drm_fb_helper_cfb_read(struct fb_info *info, 
>>> char __user *buf,
>>>                                               size_t count, loff_t 
>>> *ppos)
>>>   {
>>> -- 
>>> 2.40.1
>>>
>>
>>
> 

-- 
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] 16+ messages in thread

end of thread, other threads:[~2023-05-23 19:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22 12:21 [PATCH v3 00/12] drm/fbdev: Remove DRM's helpers for fbdev I/O Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 01/12] fbdev: Add Kconfig options to select different fb_ops helpers Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 02/12] drm/armada: Use regular fbdev I/O helpers Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 03/12] drm/exynos: " Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 04/12] drm/gma500: " Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 05/12] drm/radeon: " Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 06/12] drm/fbdev-dma: " Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 07/12] drm/msm: " Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 08/12] drm/omapdrm: " Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 09/12] drm/tegra: " Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 10/12] drm/fb-helper: Export helpers for marking damage areas Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 11/12] drm/fbdev-generic: Implement dedicated fbdev I/O helpers Thomas Zimmermann
2023-05-22 13:20   ` [Freedreno] " Dmitry Baryshkov
2023-05-22 18:46     ` Thomas Zimmermann
2023-05-23 19:19       ` Thomas Zimmermann
2023-05-22 12:21 ` [PATCH v3 12/12] drm/i915: " Thomas Zimmermann

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