Skip to contentSkip to conversation

drm/cma-helper drivers: Use drm_fbdev_generic_setup()

PATCH Applied Noralf Trønnes 2 participants 12 messages Nov 28, 2018 – Jan 14, 2019

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v3 cover drm/cma-helper drivers: Use drm_fbdev_generic_setup()

This patchset moves the drivers using the CMA helper fully over to the generic fbdev emulation.

Changes this time is to remove a stray include from the rcar patch and some more include cleanup in the cma-helper which required a change to drm_framebuffer.h.

I'm still hoping to get driver maintainer ack's for the hisilicon and mxsfb patches.

For context, here's part 1 of the generic fbdev emulation:
drm: Add generic fbdev emulation
https://patchwork.freedesktop.org/series/45848/

Noralf.

Cc Xinliang Liu <[email protected]>
Cc Rongrong Zou <[email protected]>
Cc Xinwei Kong <[email protected]>
Cc Chen Feng <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Laurent Pinchart <[email protected]>

Noralf Trønnes (5):
drm/hisilicon/kirin: Use drm_fbdev_generic_setup() drm/mxsfb: Use drm_fbdev_generic_setup() drm/rcar-du: Use drm_fbdev_generic_setup() drm/framebuffer: Include linux/sched.h in header file drm/cma-helper: Remove unused fbdev code

 drivers/gpu/drm/Kconfig                         |   4 -
 drivers/gpu/drm/drm_fb_cma_helper.c             | 137 +-----------------------
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  38 +------
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h |   4 -
 drivers/gpu/drm/mxsfb/mxsfb_drv.c               |  26 +----
 drivers/gpu/drm/mxsfb/mxsfb_drv.h               |   1 -
 drivers/gpu/drm/rcar-du/rcar_du_drv.c           |  14 +--
 drivers/gpu/drm/rcar-du/rcar_du_drv.h           |   2 -
 drivers/gpu/drm/rcar-du/rcar_du_kms.c           |  21 ----
 include/drm/drm_fb_cma_helper.h                 |  22 ----
 include/drm/drm_framebuffer.h                   |   1 +
 11 files changed, 11 insertions(+), 259 deletions(-)
Signature · 6 lines
2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v3 1/5 drm/hisilicon/kirin: Use drm_fbdev_generic_setup()

The CMA helper is already using the drm_fb_helper_generic_probe part of the generic fbdev emulation. This patch makes full use of the generic fbdev emulation by using its drm_client callbacks. This means that drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are now handled by the emulation code. Additionally fbdev unregister happens automatically on drm_dev_unregister().

The drm_fbdev_generic_setup() call is put after drm_dev_register() in the driver. This is done to highlight the fact that fbdev emulation is an internal client that makes use of the driver, it is not part of the driver as such. If fbdev setup fails, an error is printed, but the driver succeeds probing.

struct kirin_drm_private can be removed now that driver doesn't have to store the fbdev pointer.

---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 38 ++-----------------------
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h |  4 ---
 2 files changed, 3 insertions(+), 39 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +3 -35
index e6a62d5a00a3..15e32e5d9101 100644
@@ -22,6 +22,7 @@
 #include <drm/drmP.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc_helper.h>
@@ -33,32 +34,15 @@ static struct kirin_dc_ops *dc_ops;
 
 static int kirin_drm_kms_cleanup(struct drm_device *dev)
 {
-	struct kirin_drm_private *priv = dev->dev_private;
-
-	if (priv->fbdev) {
-		drm_fbdev_cma_fini(priv->fbdev);
-		priv->fbdev = NULL;
-	}
-
 	drm_kms_helper_poll_fini(dev);
 	dc_ops->cleanup(to_platform_device(dev->dev));
 	drm_mode_config_cleanup(dev);
-	devm_kfree(dev->dev, priv);
-	dev->dev_private = NULL;
 
 	return 0;
 }
 
-static void kirin_fbdev_output_poll_changed(struct drm_device *dev)
-{
-	struct kirin_drm_private *priv = dev->dev_private;
-
-	drm_fbdev_cma_hotplug_event(priv->fbdev);
-}
-
 static const struct drm_mode_config_funcs kirin_drm_mode_config_funcs = {
 	.fb_create = drm_gem_fb_create,
-	.output_poll_changed = kirin_fbdev_output_poll_changed,
 	.atomic_check = drm_atomic_helper_check,
 	.atomic_commit = drm_atomic_helper_commit,
 };
@@ -76,14 +60,8 @@ static void kirin_drm_mode_config_init(struct drm_device *dev)
 
 static int kirin_drm_kms_init(struct drm_device *dev)
 {
-	struct kirin_drm_private *priv;
 	int ret;
 
-	priv = devm_kzalloc(dev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	dev->dev_private = priv;
 	dev_set_drvdata(dev->dev, dev);
 
 	/* dev->mode_config initialization */
@@ -117,26 +95,14 @@ static int kirin_drm_kms_init(struct drm_device *dev)
 	/* init kms poll for handling hpd */
 	drm_kms_helper_poll_init(dev);
 
-	priv->fbdev = drm_fbdev_cma_init(dev, 32,
-					 dev->mode_config.num_connector);
-
-	if (IS_ERR(priv->fbdev)) {
-		DRM_ERROR("failed to initialize fbdev.\n");
-		ret = PTR_ERR(priv->fbdev);
-		goto err_cleanup_poll;
-	}
 	return 0;
 
-err_cleanup_poll:
-	drm_kms_helper_poll_fini(dev);
 err_unbind_all:
 	component_unbind_all(dev->dev, dev);
 err_dc_cleanup:
 	dc_ops->cleanup(to_platform_device(dev->dev));
 err_mode_config_cleanup:
 	drm_mode_config_cleanup(dev);
-	devm_kfree(dev->dev, priv);
-	dev->dev_private = NULL;
 
 	return ret;
 }
@@ -199,6 +165,8 @@ static int kirin_drm_bind(struct device *dev)
 	if (ret)
 		goto err_kms_cleanup;
 
+	drm_fbdev_generic_setup(drm_dev, 32);
+
 	return 0;
 
 err_kms_cleanup:
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +0 -4
index 56cb62df065c..ad027d1cc826 100644
@@ -19,10 +19,6 @@ struct kirin_dc_ops {
 	void (*cleanup)(struct platform_device *pdev);
 };
 
-struct kirin_drm_private {
-	struct drm_fbdev_cma *fbdev;
-};
-
 extern const struct kirin_dc_ops ade_dc_ops;
 
 #endif /* __KIRIN_DRM_DRV_H__ */
Signature · 6 lines
2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author Applied
#2 lore raw

Re: [PATCH v3 1/5] drm/hisilicon/kirin: Use drm_fbdev_generic_setup()

Den 28.11.2018 22.27, skrev Noralf Trønnes:

Quoted 16 lines

The CMA helper is already using the drm_fb_helper_generic_probe part of the generic fbdev emulation. This patch makes full use of the generic fbdev emulation by using its drm_client callbacks. This means that drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are now handled by the emulation code. Additionally fbdev unregister happens automatically on drm_dev_unregister().

The drm_fbdev_generic_setup() call is put after drm_dev_register() in the driver. This is done to highlight the fact that fbdev emulation is an internal client that makes use of the driver, it is not part of the driver as such. If fbdev setup fails, an error is printed, but the driver succeeds probing.

struct kirin_drm_private can be removed now that driver doesn't have to store the fbdev pointer.

Quoted 7 lines

---

Applied to drm-misc-next.

Noralf.

Quoted 106 lines
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 38 ++-----------------------
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h |  4 ---
 2 files changed, 3 insertions(+), 39 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +3 -35
index e6a62d5a00a3..15e32e5d9101 100644
@@ -22,6 +22,7 @@
 #include <drm/drmP.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc_helper.h>
@@ -33,32 +34,15 @@ static struct kirin_dc_ops *dc_ops;
 
 static int kirin_drm_kms_cleanup(struct drm_device *dev)
 {
-	struct kirin_drm_private *priv = dev->dev_private;
-
-	if (priv->fbdev) {
-		drm_fbdev_cma_fini(priv->fbdev);
-		priv->fbdev = NULL;
-	}
-
 	drm_kms_helper_poll_fini(dev);
 	dc_ops->cleanup(to_platform_device(dev->dev));
 	drm_mode_config_cleanup(dev);
-	devm_kfree(dev->dev, priv);
-	dev->dev_private = NULL;
 
 	return 0;
 }
 
-static void kirin_fbdev_output_poll_changed(struct drm_device *dev)
-{
-	struct kirin_drm_private *priv = dev->dev_private;
-
-	drm_fbdev_cma_hotplug_event(priv->fbdev);
-}
-
 static const struct drm_mode_config_funcs kirin_drm_mode_config_funcs = {
 	.fb_create = drm_gem_fb_create,
-	.output_poll_changed = kirin_fbdev_output_poll_changed,
 	.atomic_check = drm_atomic_helper_check,
 	.atomic_commit = drm_atomic_helper_commit,
 };
@@ -76,14 +60,8 @@ static void kirin_drm_mode_config_init(struct drm_device *dev)
 
 static int kirin_drm_kms_init(struct drm_device *dev)
 {
-	struct kirin_drm_private *priv;
 	int ret;
 
-	priv = devm_kzalloc(dev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	dev->dev_private = priv;
 	dev_set_drvdata(dev->dev, dev);
 
 	/* dev->mode_config initialization */
@@ -117,26 +95,14 @@ static int kirin_drm_kms_init(struct drm_device *dev)
 	/* init kms poll for handling hpd */
 	drm_kms_helper_poll_init(dev);
 
-	priv->fbdev = drm_fbdev_cma_init(dev, 32,
-					 dev->mode_config.num_connector);
-
-	if (IS_ERR(priv->fbdev)) {
-		DRM_ERROR("failed to initialize fbdev.\n");
-		ret = PTR_ERR(priv->fbdev);
-		goto err_cleanup_poll;
-	}
 	return 0;
 
-err_cleanup_poll:
-	drm_kms_helper_poll_fini(dev);
 err_unbind_all:
 	component_unbind_all(dev->dev, dev);
 err_dc_cleanup:
 	dc_ops->cleanup(to_platform_device(dev->dev));
 err_mode_config_cleanup:
 	drm_mode_config_cleanup(dev);
-	devm_kfree(dev->dev, priv);
-	dev->dev_private = NULL;
 
 	return ret;
 }
@@ -199,6 +165,8 @@ static int kirin_drm_bind(struct device *dev)
 	if (ret)
 		goto err_kms_cleanup;
 
+	drm_fbdev_generic_setup(drm_dev, 32);
+
 	return 0;
 
 err_kms_cleanup:
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +0 -0
index 56cb62df065c..ad027d1cc826 100644

drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h struct kirin_dc_ops { · line 24

Quoted 10 lines
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +0 -4
@@ -19,10 +19,6 @@ struct kirin_dc_ops {
 	void (*cleanup)(struct platform_device *pdev);
 };
 
-struct kirin_drm_private {
-	struct drm_fbdev_cma *fbdev;
-};
-
 extern const struct kirin_dc_ops ade_dc_ops;
 
 #endif /* __KIRIN_DRM_DRV_H__ */

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

PATCH v3 2/5 drm/mxsfb: Use drm_fbdev_generic_setup()

In reply to Noralf Trønnes

The CMA helper is already using the drm_fb_helper_generic_probe part of the generic fbdev emulation. This patch makes full use of the generic fbdev emulation by using its drm_client callbacks. This means that drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are now handled by the emulation code. Additionally fbdev unregister happens automatically on drm_dev_unregister().

The drm_fbdev_generic_setup() call is put after drm_dev_register() in the driver. This is done to highlight the fact that fbdev emulation is an internal client that makes use of the driver, it is not part of the driver as such. If fbdev setup fails, an error is printed, but the driver succeeds probing.

---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 26 ++------------------------
 drivers/gpu/drm/mxsfb/mxsfb_drv.h |  1 -
 2 files changed, 2 insertions(+), 25 deletions(-)
drivers/gpu/drm/mxsfb/mxsfb_drv.c +2 -24
index 88ba003979e6..13e778825098 100644
@@ -263,23 +263,12 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)
 
 	drm_kms_helper_poll_init(drm);
 
-	mxsfb->fbdev = drm_fbdev_cma_init(drm, 32,
-					  drm->mode_config.num_connector);
-	if (IS_ERR(mxsfb->fbdev)) {
-		ret = PTR_ERR(mxsfb->fbdev);
-		mxsfb->fbdev = NULL;
-		dev_err(drm->dev, "Failed to init FB CMA area\n");
-		goto err_cma;
-	}
-
 	platform_set_drvdata(pdev, drm);
 
 	drm_helper_hpd_irq_event(drm);
 
 	return 0;
 
-err_cma:
-	drm_irq_uninstall(drm);
 err_irq:
 	drm_panel_detach(mxsfb->panel);
 err_vblank:
@@ -290,11 +279,6 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)
 
 static void mxsfb_unload(struct drm_device *drm)
 {
-	struct mxsfb_drm_private *mxsfb = drm->dev_private;
-
-	if (mxsfb->fbdev)
-		drm_fbdev_cma_fini(mxsfb->fbdev);
-
 	drm_kms_helper_poll_fini(drm);
 	drm_mode_config_cleanup(drm);
 
@@ -307,13 +291,6 @@ static void mxsfb_unload(struct drm_device *drm)
 	pm_runtime_disable(drm->dev);
 }
 
-static void mxsfb_lastclose(struct drm_device *drm)
-{
-	struct mxsfb_drm_private *mxsfb = drm->dev_private;
-
-	drm_fbdev_cma_restore_mode(mxsfb->fbdev);
-}
-
 static void mxsfb_irq_preinstall(struct drm_device *drm)
 {
 	struct mxsfb_drm_private *mxsfb = drm->dev_private;
@@ -347,7 +324,6 @@ static struct drm_driver mxsfb_driver = {
 	.driver_features	= DRIVER_GEM | DRIVER_MODESET |
 				  DRIVER_PRIME | DRIVER_ATOMIC |
 				  DRIVER_HAVE_IRQ,
-	.lastclose		= mxsfb_lastclose,
 	.irq_handler		= mxsfb_irq_handler,
 	.irq_preinstall		= mxsfb_irq_preinstall,
 	.irq_uninstall		= mxsfb_irq_preinstall,
@@ -412,6 +388,8 @@ static int mxsfb_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_unload;
 
+	drm_fbdev_generic_setup(drm, 32);
+
 	return 0;
 
 err_unload:
drivers/gpu/drm/mxsfb/mxsfb_drv.h +0 -1
index 5d0883fc805b..bedd6801edca 100644
@@ -37,7 +37,6 @@ struct mxsfb_drm_private {
 	struct drm_simple_display_pipe	pipe;
 	struct drm_connector		connector;
 	struct drm_panel		*panel;
-	struct drm_fbdev_cma		*fbdev;
 };
 
 int mxsfb_setup_crtc(struct drm_device *dev);
Signature · 6 lines
2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author Applied
#4 lore raw

Re: [PATCH v3 2/5] drm/mxsfb: Use drm_fbdev_generic_setup()

Den 28.11.2018 22.27, skrev Noralf Trønnes:

Quoted 13 lines

The CMA helper is already using the drm_fb_helper_generic_probe part of the generic fbdev emulation. This patch makes full use of the generic fbdev emulation by using its drm_client callbacks. This means that drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are now handled by the emulation code. Additionally fbdev unregister happens automatically on drm_dev_unregister().

The drm_fbdev_generic_setup() call is put after drm_dev_register() in the driver. This is done to highlight the fact that fbdev emulation is an internal client that makes use of the driver, it is not part of the driver as such. If fbdev setup fails, an error is printed, but the driver succeeds probing.

Quoted 4 lines

---

Applied to drm-misc-next.

Noralf.

Quoted 81 lines
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 26 ++------------------------
 drivers/gpu/drm/mxsfb/mxsfb_drv.h |  1 -
 2 files changed, 2 insertions(+), 25 deletions(-)
drivers/gpu/drm/mxsfb/mxsfb_drv.c +2 -24
index 88ba003979e6..13e778825098 100644
@@ -263,23 +263,12 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)
 
 	drm_kms_helper_poll_init(drm);
 
-	mxsfb->fbdev = drm_fbdev_cma_init(drm, 32,
-					  drm->mode_config.num_connector);
-	if (IS_ERR(mxsfb->fbdev)) {
-		ret = PTR_ERR(mxsfb->fbdev);
-		mxsfb->fbdev = NULL;
-		dev_err(drm->dev, "Failed to init FB CMA area\n");
-		goto err_cma;
-	}
-
 	platform_set_drvdata(pdev, drm);
 
 	drm_helper_hpd_irq_event(drm);
 
 	return 0;
 
-err_cma:
-	drm_irq_uninstall(drm);
 err_irq:
 	drm_panel_detach(mxsfb->panel);
 err_vblank:
@@ -290,11 +279,6 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)
 
 static void mxsfb_unload(struct drm_device *drm)
 {
-	struct mxsfb_drm_private *mxsfb = drm->dev_private;
-
-	if (mxsfb->fbdev)
-		drm_fbdev_cma_fini(mxsfb->fbdev);
-
 	drm_kms_helper_poll_fini(drm);
 	drm_mode_config_cleanup(drm);
 
@@ -307,13 +291,6 @@ static void mxsfb_unload(struct drm_device *drm)
 	pm_runtime_disable(drm->dev);
 }
 
-static void mxsfb_lastclose(struct drm_device *drm)
-{
-	struct mxsfb_drm_private *mxsfb = drm->dev_private;
-
-	drm_fbdev_cma_restore_mode(mxsfb->fbdev);
-}
-
 static void mxsfb_irq_preinstall(struct drm_device *drm)
 {
 	struct mxsfb_drm_private *mxsfb = drm->dev_private;
@@ -347,7 +324,6 @@ static struct drm_driver mxsfb_driver = {
 	.driver_features	= DRIVER_GEM | DRIVER_MODESET |
 				  DRIVER_PRIME | DRIVER_ATOMIC |
 				  DRIVER_HAVE_IRQ,
-	.lastclose		= mxsfb_lastclose,
 	.irq_handler		= mxsfb_irq_handler,
 	.irq_preinstall		= mxsfb_irq_preinstall,
 	.irq_uninstall		= mxsfb_irq_preinstall,
@@ -412,6 +388,8 @@ static int mxsfb_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_unload;
 
+	drm_fbdev_generic_setup(drm, 32);
+
 	return 0;
 
 err_unload:
drivers/gpu/drm/mxsfb/mxsfb_drv.h +0 -0
index 5d0883fc805b..bedd6801edca 100644

drivers/gpu/drm/mxsfb/mxsfb_drv.h struct mxsfb_drm_private { · line 42

Quoted 7 lines
drivers/gpu/drm/mxsfb/mxsfb_drv.h +0 -1
@@ -37,7 +37,6 @@ struct mxsfb_drm_private {
 	struct drm_simple_display_pipe	pipe;
 	struct drm_connector		connector;
 	struct drm_panel		*panel;
-	struct drm_fbdev_cma		*fbdev;
 };
 
 int mxsfb_setup_crtc(struct drm_device *dev);

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

PATCH v3 3/5 drm/rcar-du: Use drm_fbdev_generic_setup()

In reply to Noralf Trønnes

The CMA helper is already using the drm_fb_helper_generic_probe part of the generic fbdev emulation. This patch makes full use of the generic fbdev emulation by using its drm_client callbacks. This means that drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are now handled by the emulation code. Additionally fbdev unregister happens automatically on drm_dev_unregister().

The drm_fbdev_generic_setup() call is put after drm_dev_register() in the driver. This is done to highlight the fact that fbdev emulation is an internal client that makes use of the driver, it is not part of the driver as such. If fbdev setup fails, an error is printed, but the driver succeeds probing.

drm_fbdev_generic_setup() handles mode_config.num_connector being zero. In that case it retries fbdev setup on the next .output_poll_changed.

---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 14 +++-----------
 drivers/gpu/drm/rcar-du/rcar_du_drv.h |  2 --
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 21 ---------------------
 3 files changed, 3 insertions(+), 34 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_drv.c +3 -11
index c6770043dcdc..c24aabe3e3e9 100644
@@ -21,6 +21,7 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 
 #include "rcar_du_drv.h"
@@ -363,19 +364,11 @@ MODULE_DEVICE_TABLE(of, rcar_du_of_table);
  * DRM operations
  */
 
-static void rcar_du_lastclose(struct drm_device *dev)
-{
-	struct rcar_du_device *rcdu = dev->dev_private;
-
-	drm_fbdev_cma_restore_mode(rcdu->fbdev);
-}
-
 DEFINE_DRM_GEM_CMA_FOPS(rcar_du_fops);
 
 static struct drm_driver rcar_du_driver = {
 	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME
 				| DRIVER_ATOMIC,
-	.lastclose		= rcar_du_lastclose,
 	.gem_free_object_unlocked = drm_gem_cma_free_object,
 	.gem_vm_ops		= &drm_gem_cma_vm_ops,
 	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd,
@@ -431,9 +424,6 @@ static int rcar_du_remove(struct platform_device *pdev)
 
 	drm_dev_unregister(ddev);
 
-	if (rcdu->fbdev)
-		drm_fbdev_cma_fini(rcdu->fbdev);
-
 	drm_kms_helper_poll_fini(ddev);
 	drm_mode_config_cleanup(ddev);
 
@@ -493,6 +483,8 @@ static int rcar_du_probe(struct platform_device *pdev)
 
 	DRM_INFO("Device %s probed\n", dev_name(&pdev->dev));
 
+	drm_fbdev_generic_setup(ddev, 32);
+
 	return 0;
 
 error:
drivers/gpu/drm/rcar-du/rcar_du_drv.h +0 -2
index 9f5563296c5a..a68da79b424e 100644
@@ -20,7 +20,6 @@
 struct clk;
 struct device;
 struct drm_device;
-struct drm_fbdev_cma;
 struct rcar_du_device;
 
 #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK	BIT(0)	/* Per-CRTC IRQ and clock */
@@ -78,7 +77,6 @@ struct rcar_du_device {
 	void __iomem *mmio;
 
 	struct drm_device *ddev;
-	struct drm_fbdev_cma *fbdev;
 
 	struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
 	unsigned int num_crtcs;
drivers/gpu/drm/rcar-du/rcar_du_kms.c +0 -21
index 4ebd61ecbee1..6562871aa706 100644
@@ -255,13 +255,6 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
 	return drm_gem_fb_create(dev, file_priv, mode_cmd);
 }
 
-static void rcar_du_output_poll_changed(struct drm_device *dev)
-{
-	struct rcar_du_device *rcdu = dev->dev_private;
-
-	drm_fbdev_cma_hotplug_event(rcdu->fbdev);
-}
-
 /* -----------------------------------------------------------------------------
  * Atomic Check and Update
  */
@@ -308,7 +301,6 @@ static const struct drm_mode_config_helper_funcs rcar_du_mode_config_helper = {
 
 static const struct drm_mode_config_funcs rcar_du_mode_config_funcs = {
 	.fb_create = rcar_du_fb_create,
-	.output_poll_changed = rcar_du_output_poll_changed,
 	.atomic_check = rcar_du_atomic_check,
 	.atomic_commit = drm_atomic_helper_commit,
 };
@@ -543,7 +535,6 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
 
 	struct drm_device *dev = rcdu->ddev;
 	struct drm_encoder *encoder;
-	struct drm_fbdev_cma *fbdev;
 	unsigned int dpad0_sources;
 	unsigned int num_encoders;
 	unsigned int num_groups;
@@ -682,17 +673,5 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
 
 	drm_kms_helper_poll_init(dev);
 
-	if (dev->mode_config.num_connector) {
-		fbdev = drm_fbdev_cma_init(dev, 32,
-					   dev->mode_config.num_connector);
-		if (IS_ERR(fbdev))
-			return PTR_ERR(fbdev);
-
-		rcdu->fbdev = fbdev;
-	} else {
-		dev_info(rcdu->dev,
-			 "no connector found, disabling fbdev emulation\n");
-	}
-
 	return 0;
 }
Signature · 6 lines
2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author Applied
#6 lore raw

Re: [PATCH v3 3/5] drm/rcar-du: Use drm_fbdev_generic_setup()

Den 28.11.2018 22.27, skrev Noralf Trønnes:

Quoted 13 lines

The CMA helper is already using the drm_fb_helper_generic_probe part of the generic fbdev emulation. This patch makes full use of the generic fbdev emulation by using its drm_client callbacks. This means that drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are now handled by the emulation code. Additionally fbdev unregister happens automatically on drm_dev_unregister().

The drm_fbdev_generic_setup() call is put after drm_dev_register() in the driver. This is done to highlight the fact that fbdev emulation is an internal client that makes use of the driver, it is not part of the driver as such. If fbdev setup fails, an error is printed, but the driver succeeds probing.

Quoted 8 lines

drm_fbdev_generic_setup() handles mode_config.num_connector being zero. In that case it retries fbdev setup on the next .output_poll_changed.

---

Applied to drm-misc-next.

Noralf.

Quoted 118 lines
  drivers/gpu/drm/rcar-du/rcar_du_drv.c | 14 +++-----------
  drivers/gpu/drm/rcar-du/rcar_du_drv.h |  2 --
  drivers/gpu/drm/rcar-du/rcar_du_kms.c | 21 ---------------------
  3 files changed, 3 insertions(+), 34 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_drv.c +3 -11
index c6770043dcdc..c24aabe3e3e9 100644
@@ -21,6 +21,7 @@
  #include <drm/drm_atomic_helper.h>
  #include <drm/drm_crtc_helper.h>
  #include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_fb_helper.h>
  #include <drm/drm_gem_cma_helper.h>
 
  #include "rcar_du_drv.h"
@@ -363,19 +364,11 @@ MODULE_DEVICE_TABLE(of, rcar_du_of_table);
   * DRM operations
   */
 
-static void rcar_du_lastclose(struct drm_device *dev)
-{
-	struct rcar_du_device *rcdu = dev->dev_private;
-
-	drm_fbdev_cma_restore_mode(rcdu->fbdev);
-}
-
  DEFINE_DRM_GEM_CMA_FOPS(rcar_du_fops);
 
  static struct drm_driver rcar_du_driver = {
  	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME
  				| DRIVER_ATOMIC,
-	.lastclose		= rcar_du_lastclose,
  	.gem_free_object_unlocked = drm_gem_cma_free_object,
  	.gem_vm_ops		= &drm_gem_cma_vm_ops,
  	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd,
@@ -431,9 +424,6 @@ static int rcar_du_remove(struct platform_device *pdev)
 
  	drm_dev_unregister(ddev);
 
-	if (rcdu->fbdev)
-		drm_fbdev_cma_fini(rcdu->fbdev);
-
  	drm_kms_helper_poll_fini(ddev);
  	drm_mode_config_cleanup(ddev);
 
@@ -493,6 +483,8 @@ static int rcar_du_probe(struct platform_device *pdev)
 
  	DRM_INFO("Device %s probed\n", dev_name(&pdev->dev));
 
+	drm_fbdev_generic_setup(ddev, 32);
+
  	return 0;
 
  error:
drivers/gpu/drm/rcar-du/rcar_du_drv.h +0 -2
index 9f5563296c5a..a68da79b424e 100644
@@ -20,7 +20,6 @@
  struct clk;
  struct device;
  struct drm_device;
-struct drm_fbdev_cma;
  struct rcar_du_device;
 
  #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK	BIT(0)	/* Per-CRTC IRQ and clock */
@@ -78,7 +77,6 @@ struct rcar_du_device {
  	void __iomem *mmio;
 
  	struct drm_device *ddev;
-	struct drm_fbdev_cma *fbdev;
 
  	struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
  	unsigned int num_crtcs;
drivers/gpu/drm/rcar-du/rcar_du_kms.c +0 -13
index 4ebd61ecbee1..6562871aa706 100644
@@ -255,13 +255,6 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
  	return drm_gem_fb_create(dev, file_priv, mode_cmd);
  }
 
-static void rcar_du_output_poll_changed(struct drm_device *dev)
-{
-	struct rcar_du_device *rcdu = dev->dev_private;
-
-	drm_fbdev_cma_hotplug_event(rcdu->fbdev);
-}
-
  /* -----------------------------------------------------------------------------
   * Atomic Check and Update
   */
@@ -308,7 +301,6 @@ static const struct drm_mode_config_helper_funcs rcar_du_mode_config_helper = {
 
  static const struct drm_mode_config_funcs rcar_du_mode_config_funcs = {
  	.fb_create = rcar_du_fb_create,
-	.output_poll_changed = rcar_du_output_poll_changed,
  	.atomic_check = rcar_du_atomic_check,
  	.atomic_commit = drm_atomic_helper_commit,
  };
@@ -543,7 +535,6 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
 
  	struct drm_device *dev = rcdu->ddev;
  	struct drm_encoder *encoder;
-	struct drm_fbdev_cma *fbdev;
  	unsigned int dpad0_sources;
  	unsigned int num_encoders;
  	unsigned int num_groups;
@@ -682,17 +673,5 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
 
  	drm_kms_helper_poll_init(dev);
 
-	if (dev->mode_config.num_connector) {
-		fbdev = drm_fbdev_cma_init(dev, 32,
-					   dev->mode_config.num_connector);
-		if (IS_ERR(fbdev))

drivers/gpu/drm/rcar-du/rcar_du_kms.c int rcar_du_modeset_init(struct rcar_du_device *rcdu) · line 677

Quoted 10 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +0 -8
-			return PTR_ERR(fbdev);
-
-		rcdu->fbdev = fbdev;
-	} else {
-		dev_info(rcdu->dev,
-			 "no connector found, disabling fbdev emulation\n");
-	}
-
  	return 0;
  }

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

PATCH v3 4/5 drm/framebuffer: Include linux/sched.h in header file

In reply to Noralf Trønnes

A cleanup of the includes in drm_fb_cma_helper resulted in:

CC [M] drivers/gpu/drm/drm_fb_cma_helper.o
In file included from drivers/gpu/drm/drm_fb_cma_helper.c:21:0:
include/drm/drm_framebuffer.h:128:12: error: ‘TASK_COMM_LEN’ undeclared here (not in a function)
char comm[TASK_COMM_LEN];

Fix it by including linux/sched.h.

---
 include/drm/drm_framebuffer.h | 1 +
 1 file changed, 1 insertion(+)
include/drm/drm_framebuffer.h +1 -0
index c94acedfb08e..d4ce58568fa6 100644
@@ -25,6 +25,7 @@
 
 #include <linux/list.h>
 #include <linux/ctype.h>
+#include <linux/sched.h>
 #include <drm/drm_mode_object.h>
 
 struct drm_framebuffer;
Signature · 6 lines
2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw

Re: [PATCH v3 4/5] drm/framebuffer: Include linux/sched.h in header file

Quoted 6 lines · Noralf Trønnes

A cleanup of the includes in drm_fb_cma_helper resulted in:

CC [M] drivers/gpu/drm/drm_fb_cma_helper.o
In file included from drivers/gpu/drm/drm_fb_cma_helper.c:21:0:
include/drm/drm_framebuffer.h:128:12: error: ‘TASK_COMM_LEN’ undeclared here (not in a function)
char comm[TASK_COMM_LEN];

Huh, I'm not seeing this. And we have 3 defconfigs for compile-testing, they still seem to work. Which patch broke this? Should be quick to bisect since fully automateable ... And would be good to have the Fixes: tag for this.

Anyway, Acked-by: Daniel Vetter <[email protected]>

Quoted 27 lines

Fix it by including linux/sched.h.

---
 include/drm/drm_framebuffer.h | 1 +
 1 file changed, 1 insertion(+)
include/drm/drm_framebuffer.h +1 -0
index c94acedfb08e..d4ce58568fa6 100644
@@ -25,6 +25,7 @@
 
 #include <linux/list.h>
 #include <linux/ctype.h>
+#include <linux/sched.h>
 #include <drm/drm_mode_object.h>
 
 struct drm_framebuffer;
Signature · 6 lines
2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

Re: [PATCH v3 4/5] drm/framebuffer: Include linux/sched.h in header file

Den 29.11.2018 10.35, skrev Daniel Vetter:

Quoted 7 lines · Noralf Trønnes
Quoted 6 lines

A cleanup of the includes in drm_fb_cma_helper resulted in:

CC [M] drivers/gpu/drm/drm_fb_cma_helper.o
In file included from drivers/gpu/drm/drm_fb_cma_helper.c:21:0:
include/drm/drm_framebuffer.h:128:12: error: ‘TASK_COMM_LEN’ undeclared here (not in a function)
char comm[TASK_COMM_LEN];

Quoted 6 lines

Huh, I'm not seeing this. And we have 3 defconfigs for compile-testing, they still seem to work. Which patch broke this? Should be quick to bisect since fully automateable ... And would be good to have the Fixes: tag for this.

Anyway, Acked-by: Daniel Vetter <[email protected]>

My wording isn't optimal I see. It's the cleanup in the next patch that uncovered this.

Maybe this is better:

drm_framebuffer.h references TASK_COMM_LEN but doesn't include the header that defines this macro. Include linux/sched.h so the user doesn't have to make sure it's present.

Noralf.

Quoted 18 lines
Quoted 18 lines

Fix it by including linux/sched.h.

---
  include/drm/drm_framebuffer.h | 1 +
  1 file changed, 1 insertion(+)
include/drm/drm_framebuffer.h +1 -0
index c94acedfb08e..d4ce58568fa6 100644
@@ -25,6 +25,7 @@
 
  #include <linux/list.h>
  #include <linux/ctype.h>
+#include <linux/sched.h>
  #include <drm/drm_mode_object.h>
 
Quoted 8 lines
Quoted 8 lines
include/drm/drm_framebuffer.h +0 -0
  struct drm_framebuffer;
Signature · 6 lines
2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw

Re: [PATCH v3 4/5] drm/framebuffer: Include linux/sched.h in header file

Quoted 18 lines · Noralf Trønnes

Den 29.11.2018 10.35, skrev Daniel Vetter:

Quoted 7 lines · Noralf Trønnes
Quoted 6 lines

A cleanup of the includes in drm_fb_cma_helper resulted in:

CC [M] drivers/gpu/drm/drm_fb_cma_helper.o
In file included from drivers/gpu/drm/drm_fb_cma_helper.c:21:0:
include/drm/drm_framebuffer.h:128:12: error: ‘TASK_COMM_LEN’ undeclared here (not in a function)
char comm[TASK_COMM_LEN];

Quoted 6 lines

Huh, I'm not seeing this. And we have 3 defconfigs for compile-testing, they still seem to work. Which patch broke this? Should be quick to bisect since fully automateable ... And would be good to have the Fixes: tag for this.

Anyway, Acked-by: Daniel Vetter <[email protected]>

Quoted 8 lines

My wording isn't optimal I see. It's the cleanup in the next patch that uncovered this.

Maybe this is better:

drm_framebuffer.h references TASK_COMM_LEN but doesn't include the header that defines this macro. Include linux/sched.h so the user doesn't have to make sure it's present.

Yeah just include this, and we're good to go I think. -Daniel

Quoted 30 lines

Noralf.

Quoted 26 lines
Quoted 26 lines

Fix it by including linux/sched.h.

---
  include/drm/drm_framebuffer.h | 1 +
  1 file changed, 1 insertion(+)
include/drm/drm_framebuffer.h +1 -1
index c94acedfb08e..d4ce58568fa6 100644
@@ -25,6 +25,7 @@
 
  #include <linux/list.h>
  #include <linux/ctype.h>
+#include <linux/sched.h>
  #include <drm/drm_mode_object.h>
 
  struct drm_framebuffer;
--

2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

PATCH v3 5/5 drm/cma-helper: Remove unused fbdev code

In reply to Noralf Trønnes

CMA helper drivers have been converted to drm_fbdev_generic_setup() so the fbdev code can be removed.

v2: Clean up the includes some more (Laurent)

---
 drivers/gpu/drm/Kconfig             |   4 --
 drivers/gpu/drm/drm_fb_cma_helper.c | 137 +-----------------------------------
 include/drm/drm_fb_cma_helper.h     |  22 ------
 3 files changed, 2 insertions(+), 161 deletions(-)
drivers/gpu/drm/Kconfig +0 -4
index 4385f00e1d05..bd943a71756c 100644
@@ -170,10 +170,6 @@ config DRM_KMS_CMA_HELPER
 	bool
 	depends on DRM
 	select DRM_GEM_CMA_HELPER
-	select DRM_KMS_FB_HELPER
-	select FB_SYS_FILLRECT
-	select FB_SYS_COPYAREA
-	select FB_SYS_IMAGEBLIT
 	help
 	  Choose this if you need the KMS CMA helper functions
 
drivers/gpu/drm/drm_fb_cma_helper.c +2 -135

159 lines not on this page · raw message

include/drm/drm_fb_cma_helper.h +0 -22
index 8dbbe1eece1b..4becb09975a4 100644
@@ -2,31 +2,9 @@
 #ifndef __DRM_FB_CMA_HELPER_H__
 #define __DRM_FB_CMA_HELPER_H__
 
-struct drm_fbdev_cma;
-struct drm_gem_cma_object;
-
-struct drm_fb_helper_surface_size;
-struct drm_framebuffer_funcs;
-struct drm_fb_helper_funcs;
 struct drm_framebuffer;
-struct drm_fb_helper;
-struct drm_device;
-struct drm_file;
-struct drm_mode_fb_cmd2;
-struct drm_plane;
 struct drm_plane_state;
 
-int drm_fb_cma_fbdev_init(struct drm_device *dev, unsigned int preferred_bpp,
-			  unsigned int max_conn_count);
-void drm_fb_cma_fbdev_fini(struct drm_device *dev);
-
-struct drm_fbdev_cma *drm_fbdev_cma_init(struct drm_device *dev,
-	unsigned int preferred_bpp, unsigned int max_conn_count);
-void drm_fbdev_cma_fini(struct drm_fbdev_cma *fbdev_cma);
-
-void drm_fbdev_cma_restore_mode(struct drm_fbdev_cma *fbdev_cma);
-void drm_fbdev_cma_hotplug_event(struct drm_fbdev_cma *fbdev_cma);
-
 struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb,
 	unsigned int plane);
 
Signature · 6 lines
2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel