public inbox for dri-devel@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 07/20] drm/rcar-du: Use drm_fbdev_generic_setup()
Date: Sun, 09 Sep 2018 17:13:15 +0300	[thread overview]
Message-ID: <1561867.9121V6CoeS@avalon> (raw)
In-Reply-To: <20180908134648.2582-8-noralf@tronnes.org>

Hi Noralf,

Thank you for the patch.

On Saturday, 8 September 2018 16:46:35 EEST Noralf Trønnes wrote:
> 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.
> 
> Use the drm_mode_config_helper_suspend/resume helpers instead of open
> coding it.

As Sam already pointed out, shouldn't this change be split to a separate patch 
?

Apart from that this patch looks good to me.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

I assume you will push the entire series through drm-misc. If you'd like me to 
take this patch in my tree instead please let me know.

> drm_fbdev_generic_setup() handles mode_config.num_connector being zero.
> In that case it retries fbdev setup on the next .output_poll_changed.
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> ---
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c | 34 ++++++--------------------------
>  drivers/gpu/drm/rcar-du/rcar_du_drv.h |  3 ---
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c | 21 ---------------------
>  3 files changed, 6 insertions(+), 52 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index 02aee6cb0e53..bcb01d7b4a89
> 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> @@ -25,7 +25,9 @@
>  #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 <drm/drm_modeset_helper.h>
> 
>  #include "rcar_du_drv.h"
>  #include "rcar_du_kms.h"
> @@ -316,19 +318,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,
> @@ -357,30 +351,15 @@ static struct drm_driver rcar_du_driver = {
>  static int rcar_du_pm_suspend(struct device *dev)
>  {
>  	struct rcar_du_device *rcdu = dev_get_drvdata(dev);
> -	struct drm_atomic_state *state;
> 
> -	drm_kms_helper_poll_disable(rcdu->ddev);
> -	drm_fbdev_cma_set_suspend_unlocked(rcdu->fbdev, true);
> -
> -	state = drm_atomic_helper_suspend(rcdu->ddev);
> -	if (IS_ERR(state)) {
> -		drm_fbdev_cma_set_suspend_unlocked(rcdu->fbdev, false);
> -		drm_kms_helper_poll_enable(rcdu->ddev);
> -		return PTR_ERR(state);
> -	}
> -
> -	rcdu->suspend_state = state;
> -
> -	return 0;
> +	return drm_mode_config_helper_suspend(rcdu->ddev);
>  }
> 
>  static int rcar_du_pm_resume(struct device *dev)
>  {
>  	struct rcar_du_device *rcdu = dev_get_drvdata(dev);
> 
> -	drm_atomic_helper_resume(rcdu->ddev, rcdu->suspend_state);
> -	drm_fbdev_cma_set_suspend_unlocked(rcdu->fbdev, false);
> -	drm_kms_helper_poll_enable(rcdu->ddev);
> +	drm_mode_config_helper_resume(rcdu->ddev);
> 
>  	return 0;
>  }
> @@ -401,9 +380,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);
> 
> @@ -463,6 +439,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:
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
> b/drivers/gpu/drm/rcar-du/rcar_du_drv.h index b3a25e8e07d0..58d5c730d2d2
> 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
> @@ -24,7 +24,6 @@
>  struct clk;
>  struct device;
>  struct drm_device;
> -struct drm_fbdev_cma;
>  struct rcar_du_device;
> 
>  #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK	(1 << 0)	/* Per-CRTC IRQ and clock
> */ @@ -77,8 +76,6 @@ struct rcar_du_device {
>  	void __iomem *mmio;
> 
>  	struct drm_device *ddev;
> -	struct drm_fbdev_cma *fbdev;
> -	struct drm_atomic_state *suspend_state;
> 
>  	struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
>  	unsigned int num_crtcs;
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index f0bc7cc0e913..19dfe4bf5446
> 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> @@ -216,13 +216,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
>   */
> @@ -269,7 +262,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,
>  };
> @@ -504,7 +496,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 num_encoders;
>  	unsigned int num_groups;
>  	unsigned int swindex;
> @@ -621,17 +612,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;
>  }


-- 
Regards,

Laurent Pinchart



_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-09-09 14:13 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-08 13:46 [PATCH 00/20] drm/cma-helper drivers: Use drm_fbdev_generic_setup() Noralf Trønnes
2018-09-08 13:46 ` [PATCH 01/20] drm/fb-helper: Improve error reporting in setup Noralf Trønnes
2018-09-25  9:46   ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 02/20] drm/arc: Use drm_fbdev_generic_setup() Noralf Trønnes
2018-09-10 12:31   ` Alexey Brodkin
2018-09-10 13:00     ` Noralf Trønnes
2018-09-28  7:34   ` Alexey Brodkin
2018-09-28 10:42     ` Noralf Trønnes
2018-10-01  7:56       ` Alexey Brodkin
2018-10-01 12:05         ` Noralf Trønnes
2018-10-01 12:06           ` Alexey Brodkin
2018-09-08 13:46 ` [PATCH 03/20] drm/fsl-dcu: " Noralf Trønnes
2018-09-27 21:08   ` Stefan Agner
2018-09-27 21:23     ` Noralf Trønnes
2018-09-28 14:11       ` Stefan Agner
2018-09-28 14:57         ` Noralf Trønnes
2018-09-28 15:00           ` Stefan Agner
2018-09-08 13:46 ` [PATCH 04/20] drm/hisilicon/kirin: " Noralf Trønnes
2018-09-08 13:46 ` [PATCH 05/20] drm/meson: " Noralf Trønnes
2018-09-12  9:48   ` Neil Armstrong
2018-09-12  9:56     ` Maxime Ripard
2018-09-12 10:57       ` Noralf Trønnes
2018-09-12 11:06         ` Noralf Trønnes
2018-09-13 13:21           ` Daniel Vetter
2018-09-13 14:26             ` Neil Armstrong
2018-09-13 14:55               ` Daniel Vetter
2018-09-14  8:23                 ` Neil Armstrong
2018-09-14  8:51                   ` Daniel Vetter
2018-09-14 16:33                   ` Noralf Trønnes
2018-09-17  7:53                     ` Neil Armstrong
2018-10-01 12:27                       ` Neil Armstrong
2018-10-03 19:24   ` Neil Armstrong
2018-10-25 15:09     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 06/20] drm/mxsfb: " Noralf Trønnes
2018-09-08 13:46 ` [PATCH 07/20] drm/rcar-du: " Noralf Trønnes
2018-09-09 14:00   ` Sam Ravnborg
2018-09-09 14:13   ` Laurent Pinchart [this message]
2018-09-10 13:02     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 08/20] drm/arm/hdlcd: " Noralf Trønnes
2018-09-11 12:17   ` Liviu Dudau
2018-09-11 12:41     ` Noralf Trønnes
2018-09-25  9:47     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 09/20] drm/arm/mali: " Noralf Trønnes
2018-09-11 12:18   ` Liviu Dudau
2018-09-25  9:47     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 10/20] drm/atmel-hlcdc: " Noralf Trønnes
2018-09-08 13:46 ` [PATCH 11/20] drm/imx: " Noralf Trønnes
2018-09-14 11:42   ` Philipp Zabel
2018-09-25  9:48     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 12/20] drm/pl111: " Noralf Trønnes
2018-09-13  0:07   ` Eric Anholt
2018-09-25  9:48     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 13/20] drm/sti: " Noralf Trønnes
2018-09-10  9:39   ` Benjamin Gaignard
2018-09-25  9:48     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 14/20] drm/stm: " Noralf Trønnes
2018-09-27 11:45   ` Yannick FERTRE
2018-10-25 15:10     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 15/20] drm/sun4i: " Noralf Trønnes
2018-09-10  7:28   ` Maxime Ripard
2018-09-10 12:57     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 16/20] drm/tilcdc: " Noralf Trønnes
2018-09-08 13:46 ` [PATCH 17/20] drm/tve200: " Noralf Trønnes
2018-09-18 22:10   ` Linus Walleij
2018-09-25  9:49     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 18/20] drm/vc4: " Noralf Trønnes
2018-09-13  0:06   ` Eric Anholt
2018-09-25  9:49     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 19/20] drm/zte: " Noralf Trønnes
2018-09-10  1:23   ` Shawn Guo
2018-09-25  9:49     ` Noralf Trønnes
2018-09-08 13:46 ` [PATCH 20/20] drm/cma-helper: Remove unused fbdev code Noralf Trønnes
2018-09-09 14:09 ` [PATCH 00/20] drm/cma-helper drivers: Use drm_fbdev_generic_setup() Sam Ravnborg
     [not found] ` <606da8a9-a402-5d2e-1f22-d287982f6abc@tronnes.org>
2018-09-11 11:40   ` Noralf Trønnes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1561867.9121V6CoeS@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=noralf@tronnes.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox