Skip to contentSkip to conversation

drm/tegra: Remove existing framebuffer only if we support display

PATCH Applied Thierry Reding 4 participants 7 messages Feb 23, 2024 – Feb 26, 2024

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

PATCH v2 1/1 drm/tegra: Remove existing framebuffer only if we support display

From: Thierry Reding <[email protected]>

Tegra DRM doesn't support display on Tegra234 and later, so make sure not to remove any existing framebuffers in that case.

v2: - add comments explaining how this situation can come about
- clear DRIVER_MODESET and DRIVER_ATOMIC feature bits

---
 drivers/gpu/drm/tegra/drm.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/gpu/drm/tegra/drm.c +20 -3
index b1e1a78e30c6..2e1cfe6f6d74 100644
@@ -1220,9 +1220,26 @@ static int host1x_drm_probe(struct host1x_device *dev)
 
 	drm_mode_config_reset(drm);
 
-	err = drm_aperture_remove_framebuffers(&tegra_drm_driver);
-	if (err < 0)
-		goto hub;
+	/*
+	 * Only take over from a potential firmware framebuffer if any CRTCs
+	 * have been registered. This must not be a fatal error because there
+	 * are other accelerators that are exposed via this driver.
+	 *
+	 * Another case where this happens is on Tegra234 where the display
+	 * hardware is no longer part of the host1x complex, so this driver
+	 * will not expose any modesetting features.
+	 */
+	if (drm->mode_config.num_crtc > 0) {
+		err = drm_aperture_remove_framebuffers(&tegra_drm_driver);
+		if (err < 0)
+			goto hub;
+	} else {
+		/*
+		 * Indicate to userspace that this doesn't expose any display
+		 * capabilities.
+		 */
+		drm->driver_features &= ~(DRIVER_MODESET | DRIVER_ATOMIC);
+	}
 
 	err = drm_dev_register(drm, 0);
 	if (err < 0)
Signature · 1 line
2.43.2
Reviewed-by on v2 1/1
#1 lore raw

Thierry Reding <[email protected]> writes:

Hello Thierry,

Quoted 10 lines

From: Thierry Reding <[email protected]>

Tegra DRM doesn't support display on Tegra234 and later, so make sure not to remove any existing framebuffers in that case.

v2: - add comments explaining how this situation can come about
- clear DRIVER_MODESET and DRIVER_ATOMIC feature bits

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
Reviewed-by on v2 1/1
#2 lore raw
In reply to Thierry Reding

Hi

Am 23.02.24 um 16:03 schrieb Thierry Reding:

Quoted 9 lines

From: Thierry Reding <[email protected]>

Tegra DRM doesn't support display on Tegra234 and later, so make sure not to remove any existing framebuffers in that case.

v2: - add comments explaining how this situation can come about
- clear DRIVER_MODESET and DRIVER_ATOMIC feature bits

Makes sense as far as the aperture helpers are concerned.

Best regards
Thomas

Quoted 38 lines
---
  drivers/gpu/drm/tegra/drm.c | 23 ++++++++++++++++++++---
  1 file changed, 20 insertions(+), 3 deletions(-)
drivers/gpu/drm/tegra/drm.c +20 -3
index b1e1a78e30c6..2e1cfe6f6d74 100644
@@ -1220,9 +1220,26 @@ static int host1x_drm_probe(struct host1x_device *dev)
 
  	drm_mode_config_reset(drm);
 
-	err = drm_aperture_remove_framebuffers(&tegra_drm_driver);
-	if (err < 0)
-		goto hub;
+	/*
+	 * Only take over from a potential firmware framebuffer if any CRTCs
+	 * have been registered. This must not be a fatal error because there
+	 * are other accelerators that are exposed via this driver.
+	 *
+	 * Another case where this happens is on Tegra234 where the display
+	 * hardware is no longer part of the host1x complex, so this driver
+	 * will not expose any modesetting features.
+	 */
+	if (drm->mode_config.num_crtc > 0) {
+		err = drm_aperture_remove_framebuffers(&tegra_drm_driver);
+		if (err < 0)
+			goto hub;
+	} else {
+		/*
+		 * Indicate to userspace that this doesn't expose any display
+		 * capabilities.
+		 */
+		drm->driver_features &= ~(DRIVER_MODESET | DRIVER_ATOMIC);
+	}
 
  	err = drm_dev_register(drm, 0);
  	if (err < 0)
Signature · 7 lines
--
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)
#3 lore raw
Quoted 8 lines · Thomas Zimmermann

Hi

Am 23.02.24 um 16:03 schrieb Thierry Reding:

Quoted 5 lines

From: Thierry Reding <[email protected]>

Tegra DRM doesn't support display on Tegra234 and later, so make sure not to remove any existing framebuffers in that case.

Quoted 9 lines
Quoted 4 lines

v2: - add comments explaining how this situation can come about
- clear DRIVER_MODESET and DRIVER_ATOMIC feature bits

Makes sense as far as the aperture helpers are concerned.

I believe this is drm-misc-fixes material. Since the tegra DRM will remove simple{fb,drm} for Tegra234, even when the driver does not support display on that platform, leaving the system with no display output at all.

Are you going to push this patch or is going to be done by Thierry?

Quoted 3 lines

Best regards
Thomas

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#4 lore raw
Quoted 6 lines · Javier Martinez Canillas
Quoted 3 lines · Thomas Zimmermann

Hi

Am 23.02.24 um 16:03 schrieb Thierry Reding:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

From: Thierry Reding <[email protected]>

Tegra DRM doesn't support display on Tegra234 and later, so make sure not to remove any existing framebuffers in that case.

v2: - add comments explaining how this situation can come about
- clear DRIVER_MODESET and DRIVER_ATOMIC feature bits

Fixes 6848c291a54f ("drm/aperture: Convert drivers to aperture interfaces")

Maybe this is more of a philosophical question, but either the introduction of this hardware generation is where this regression was introduced or this possibly this commit.

Either way, I'd like to get this into the drm-misc-fixes branch.

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Makes sense as far as the aperture helpers are concerned.

Quoted 8 lines
Quoted 2 lines

I believe this is drm-misc-fixes material. Since the tegra DRM will remove simple{fb,drm} for Tegra234, even when the driver does not support display on that platform, leaving the system with no display output at all.

Are you going to push this patch or is going to be done by Thierry?

I'm on it.

Quoted 12 lines
Quoted 4 lines

Best regards
Thomas

--
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat

#5 lore raw
Quoted 17 lines · Robert Foss
Quoted 6 lines · Javier Martinez Canillas
Quoted 3 lines · Thomas Zimmermann

Hi

Am 23.02.24 um 16:03 schrieb Thierry Reding:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

From: Thierry Reding <[email protected]>

Tegra DRM doesn't support display on Tegra234 and later, so make sure not to remove any existing framebuffers in that case.

v2: - add comments explaining how this situation can come about
- clear DRIVER_MODESET and DRIVER_ATOMIC feature bits

Quoted 7 lines
Fixes 6848c291a54f ("drm/aperture: Convert drivers to aperture interfaces")

Maybe this is more of a philosophical question, but either the introduction of this hardware generation is where this regression was introduced or this possibly this commit.

Either way, I'd like to get this into the drm-misc-fixes branch.

That commit looks about right. Technically Tegra234 support was introduced in Linux 5.10 but the first platform where you we would've seen this wasn't added until 5.17. The above commit is from 5.14, which puts it about right in between there, so I think that's fine.

Backporting to anything before 5.14 would need to be manual and isn't worth it.

Thierry

Applied
#6 lore raw
In reply to Thierry Reding
Quoted 9 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Tegra DRM doesn't support display on Tegra234 and later, so make sure not to remove any existing framebuffers in that case.

v2: - add comments explaining how this situation can come about
- clear DRIVER_MODESET and DRIVER_ATOMIC feature bits

[...]

Applied, thanks!

[1/1] drm/tegra: Remove existing framebuffer only if we support display

      https://cgit.freedesktop.org/drm/drm-misc/commit/?id=86bf8cfda6d2

Rob