Skip to contentSkip to conversation

drm/mediatek: Remove all conflicting aperture devices during probe

PATCH Applied Luca Leonardo Scorcia 3 participants 3 messages Feb 12 – Mar 22

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

PATCH v2 1/1 drm/mediatek: Remove all conflicting aperture devices during probe

If a device has a framebuffer available it might be already used as display by simple-framebuffer or simpledrm when mediatek-drm is probed. This is actually helpful when porting to a new device as framebuffers are simple to setup in device trees and fbcon can be used to monitor the kernel boot process.

When drm-mediatek loads a new fb device is initialized, however fbcon remains attached to the initial framebuffer which is no longer connected to the actual display - the early fb is never removed.

We can gracefully transition from framebuffer handling to drm-managed display by calling aperture_remove_all_conflicting_devices before registering mediatek-drm. This takes care of unloading other fb devices/drivers and disconnects fbcon which then automatically reconnects to mediatekdrmfb as soon as it's available.

The function is invoked just before drm_dev_register() to kick out the existing framebuffer as late as possible to reduce the time the screen is unresponsive.

---
v2: Moved the call to aperture_remove_all_conflicting_devices to
right before drm_dev_register()

 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +5 -0
index a94c51a83261..02effd9fc698 100644
@@ -4,6 +4,7 @@
  * Author: YT SHEN <[email protected]>
  */
 
+#include <linux/aperture.h>
 #include <linux/component.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -670,6 +671,10 @@ static int mtk_drm_bind(struct device *dev)
 	if (ret < 0)
 		goto err_free;
 
+	ret = aperture_remove_all_conflicting_devices(DRIVER_NAME);
+	if (ret < 0)
+		dev_err(dev, "Error %d while removing conflicting aperture devices", ret);
+
 	ret = drm_dev_register(drm, 0);
 	if (ret < 0)
 		goto err_deinit;
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 19 lines · Luca Leonardo Scorcia

External email : Please do not click links or open attachments until you have verified the sender or the content.

If a device has a framebuffer available it might be already used as display by simple-framebuffer or simpledrm when mediatek-drm is probed. This is actually helpful when porting to a new device as framebuffers are simple to setup in device trees and fbcon can be used to monitor the kernel boot process.

When drm-mediatek loads a new fb device is initialized, however fbcon remains attached to the initial framebuffer which is no longer connected to the actual display - the early fb is never removed.

We can gracefully transition from framebuffer handling to drm-managed display by calling aperture_remove_all_conflicting_devices before registering mediatek-drm. This takes care of unloading other fb devices/drivers and disconnects fbcon which then automatically reconnects to mediatekdrmfb as soon as it's available.

Quoted 3 lines

The function is invoked just before drm_dev_register() to kick out the existing framebuffer as late as possible to reduce the time the screen is unresponsive.

Quoted 36 lines

---
v2: Moved the call to aperture_remove_all_conflicting_devices to
right before drm_dev_register()

 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +5 -1
index a94c51a83261..02effd9fc698 100644
@@ -4,6 +4,7 @@
  * Author: YT SHEN <[email protected]>
  */
 
+#include <linux/aperture.h>
 #include <linux/component.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -670,6 +671,10 @@ static int mtk_drm_bind(struct device *dev)
        if (ret < 0)
                goto err_free;
 
+       ret = aperture_remove_all_conflicting_devices(DRIVER_NAME);
+       if (ret < 0)
+               dev_err(dev, "Error %d while removing conflicting aperture devices", ret);
+
        ret = drm_dev_register(drm, 0);
        if (ret < 0)
                goto err_deinit;
--

2.43.0

maintainer Applied
#2 lore raw
In reply to Luca Leonardo Scorcia

Hi, Luca:

Luca Leonardo Scorcia <[email protected]> 於 2026年2月12日週四 下午7:26寫道:

Quoted 17 lines

If a device has a framebuffer available it might be already used as display by simple-framebuffer or simpledrm when mediatek-drm is probed. This is actually helpful when porting to a new device as framebuffers are simple to setup in device trees and fbcon can be used to monitor the kernel boot process.

When drm-mediatek loads a new fb device is initialized, however fbcon remains attached to the initial framebuffer which is no longer connected to the actual display - the early fb is never removed.

We can gracefully transition from framebuffer handling to drm-managed display by calling aperture_remove_all_conflicting_devices before registering mediatek-drm. This takes care of unloading other fb devices/drivers and disconnects fbcon which then automatically reconnects to mediatekdrmfb as soon as it's available.

Quoted 3 lines

The function is invoked just before drm_dev_register() to kick out the existing framebuffer as late as possible to reduce the time the screen is unresponsive.

Applied to mediatek-drm-next [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

Quoted 35 lines

---
v2: Moved the call to aperture_remove_all_conflicting_devices to
right before drm_dev_register()

 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +5 -1
index a94c51a83261..02effd9fc698 100644
@@ -4,6 +4,7 @@
  * Author: YT SHEN <[email protected]>
  */
 
+#include <linux/aperture.h>
 #include <linux/component.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -670,6 +671,10 @@ static int mtk_drm_bind(struct device *dev)
        if (ret < 0)
                goto err_free;
 
+       ret = aperture_remove_all_conflicting_devices(DRIVER_NAME);
+       if (ret < 0)
+               dev_err(dev, "Error %d while removing conflicting aperture devices", ret);
+
        ret = drm_dev_register(drm, 0);
        if (ret < 0)
                goto err_deinit;
--

2.43.0