linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/rockchip: remove early framebuffers before registering the fbdev
@ 2021-05-15 22:14 Javier Martinez Canillas
  2021-05-16  5:30 ` Thomas Zimmermann
  0 siblings, 1 reply; 2+ messages in thread
From: Javier Martinez Canillas @ 2021-05-15 22:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Daniel Vetter, David Airlie,
	Heiko Stübner, Peter Robinson, Sandy Huang, dri-devel,
	linux-arm-kernel, linux-rockchip

There are drivers that register framebuffer devices very early in the boot
process and make use of the existing framebuffer as setup by the firmware.

If one of those drivers has registered a fbdev, then the fbdev registered
by a DRM driver won't be bound to the framebuffer console. To avoid that,
remove any early framebuffer before registering a DRM framebuffer device.

By doing that, the fb mapped to the console is switched correctly from the
early fbdev to the one registered by the rockchip DRM driver:

    [   40.752420] fb0: switching to rockchip-drm-fb from EFI VGA

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

 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
index 2fdc455c4ad..e3e5b63fdcc 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
@@ -4,6 +4,7 @@
  * Author:Mark Yao <mark.yao@rock-chips.com>
  */
 
+#include <drm/drm_aperture.h>
 #include <drm/drm.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_fourcc.h>
@@ -124,6 +125,15 @@ int rockchip_drm_fbdev_init(struct drm_device *dev)
 
 	drm_fb_helper_prepare(dev, helper, &rockchip_drm_fb_helper_funcs);
 
+	/* Remove early framebuffers (e.g: simplefb or efifb) */
+	ret = drm_aperture_remove_framebuffers(false, "rockchip-drm-fb");
+	if (ret) {
+		DRM_DEV_ERROR(dev->dev,
+			      "Failed to remove early framebuffers - %d.\n",
+			      ret);
+		return ret;
+	}
+
 	ret = drm_fb_helper_init(dev, helper);
 	if (ret < 0) {
 		DRM_DEV_ERROR(dev->dev,
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] drm/rockchip: remove early framebuffers before registering the fbdev
  2021-05-15 22:14 [PATCH] drm/rockchip: remove early framebuffers before registering the fbdev Javier Martinez Canillas
@ 2021-05-16  5:30 ` Thomas Zimmermann
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Zimmermann @ 2021-05-16  5:30 UTC (permalink / raw)
  To: Javier Martinez Canillas, linux-kernel
  Cc: David Airlie, Sandy Huang, dri-devel, linux-rockchip,
	Peter Robinson, linux-arm-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 2511 bytes --]

Hi

Am 16.05.21 um 00:14 schrieb Javier Martinez Canillas:
> There are drivers that register framebuffer devices very early in the boot
> process and make use of the existing framebuffer as setup by the firmware.
> 
> If one of those drivers has registered a fbdev, then the fbdev registered
> by a DRM driver won't be bound to the framebuffer console. To avoid that,
> remove any early framebuffer before registering a DRM framebuffer device.
> 
> By doing that, the fb mapped to the console is switched correctly from the
> early fbdev to the one registered by the rockchip DRM driver:
> 
>      [   40.752420] fb0: switching to rockchip-drm-fb from EFI VGA
> 
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
> ---
> 
>   drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
> index 2fdc455c4ad..e3e5b63fdcc 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
> @@ -4,6 +4,7 @@
>    * Author:Mark Yao <mark.yao@rock-chips.com>
>    */
>   
> +#include <drm/drm_aperture.h>
>   #include <drm/drm.h>
>   #include <drm/drm_fb_helper.h>
>   #include <drm/drm_fourcc.h>
> @@ -124,6 +125,15 @@ int rockchip_drm_fbdev_init(struct drm_device *dev)
>   
>   	drm_fb_helper_prepare(dev, helper, &rockchip_drm_fb_helper_funcs);
>   
> +	/* Remove early framebuffers (e.g: simplefb or efifb) */
> +	ret = drm_aperture_remove_framebuffers(false, "rockchip-drm-fb");
> +	if (ret) {
> +		DRM_DEV_ERROR(dev->dev,
> +			      "Failed to remove early framebuffers - %d.\n",
> +			      ret);
> +		return ret;
> +	}
> +

Such code used to be part of the fbdev helpers, but it's not really 
related to fbdev functonality. Rather it controls ownership of the I/O 
ranges.

This code block should be done at the very beginning; before the driver 
tries to reserve the device's I/O ranges. Probably at [1]

Best regards
Thomas

[1] 
https://elixir.bootlin.com/linux/v5.13-rc1/source/drivers/gpu/drm/rockchip/rockchip_drm_drv.c#L116


>   	ret = drm_fb_helper_init(dev, helper);
>   	if (ret < 0) {
>   		DRM_DEV_ERROR(dev->dev,
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-05-16  5:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-15 22:14 [PATCH] drm/rockchip: remove early framebuffers before registering the fbdev Javier Martinez Canillas
2021-05-16  5:30 ` 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).