Skip to contentSkip to conversation

drm/amdgpu: don't call drm_fb_helper_lastclose in lastclose()

PATCH In review Alex Deucher 4 participants 6 messages Oct 20, 2022 – Oct 27, 2022

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: don't call drm_fb_helper_lastclose in lastclose()

It's used to restore the fbdev console, but as amdgpu uses generic fbdev emulation, the console is being restored by the DRM client helpers already. See the call to drm_client_dev_restore() in drm_lastclose().

Fixes 087451f372bf76 ("drm/amdgpu: use generic fb helpers instead of setting up AMD own's.")
Cc Thomas Zimmermann <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
index fe23e09eec98..474b9f40f792 100644
@@ -1106,7 +1106,6 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
  */
 void amdgpu_driver_lastclose_kms(struct drm_device *dev)
 {
-	drm_fb_helper_lastclose(dev);
 	vga_switcheroo_process_delayed_switch();
 }
 
Signature · 1 line
2.37.3
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

Quoted 39 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 20, 2022 10:36 PM
To: [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Thomas Zimmermann <[email protected]>
Subject: [PATCH] drm/amdgpu: don't call drm_fb_helper_lastclose in lastclose()

It's used to restore the fbdev console, but as amdgpu uses generic fbdev emulation, the console is being restored by the DRM client helpers already. See the call to drm_client_dev_restore() in drm_lastclose().

Fixes 087451f372bf76 ("drm/amdgpu: use generic fb helpers instead of

setting up AMD own's.")

Cc Thomas Zimmermann <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -2
index fe23e09eec98..474b9f40f792 100644
@@ -1106,7 +1106,6 @@ int amdgpu_info_ioctl(struct drm_device *dev,
 void *data, struct drm_file *filp)
  */
 void amdgpu_driver_lastclose_kms(struct drm_device *dev)
 {
-	drm_fb_helper_lastclose(dev);
 	vga_switcheroo_process_delayed_switch();
 }
 
--

2.37.3

#2 lore raw

Hi

Am 24.10.22 um 08:20 schrieb Quan, Evan:

Quoted 27 lines

[AMD Official Use Only - General]

Quoted 23 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 20, 2022 10:36 PM
To: [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Thomas Zimmermann <[email protected]>
Subject: [PATCH] drm/amdgpu: don't call drm_fb_helper_lastclose in lastclose()

It's used to restore the fbdev console, but as amdgpu uses generic fbdev emulation, the console is being restored by the DRM client helpers already. See the call to drm_client_dev_restore() in drm_lastclose().

Fixes 087451f372bf76 ("drm/amdgpu: use generic fb helpers instead of

setting up AMD own's.")

Cc Thomas Zimmermann <[email protected]>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 -
  1 file changed, 1 deletion(-)
Quoted 13 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_info_ioctl(struct drm_device *dev, · line 1111

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
index fe23e09eec98..474b9f40f792 100644
@@ -1106,7 +1106,6 @@ int amdgpu_info_ioctl(struct drm_device *dev,
 void *data, struct drm_file *filp)
   */
  void amdgpu_driver_lastclose_kms(struct drm_device *dev)
  {
-	drm_fb_helper_lastclose(dev);
  	vga_switcheroo_process_delayed_switch();
  }

Without the call to drm_fb_helper_lastclose(), the console emulation will be restored by drm_client_dev_restore() from drm_lastclose(). [1] It means that it's now changing order with the call to vga_switcheroo_process_delay_switch(). Can this become a problem?

I looked at the other callers of that function. Most restore the console before doing the switcheroo. Nouveau doesn't seem to care about the console at all.

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/v6.0.3/source/drivers/gpu/drm/drm_file.c#L467

Quoted 3 lines
Quoted 3 lines

--
2.37.3

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
#3 lore raw
Quoted 50 lines · Thomas Zimmermann

Hi

Am 24.10.22 um 08:20 schrieb Quan, Evan:

Quoted 27 lines

[AMD Official Use Only - General]

Quoted 23 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 20, 2022 10:36 PM
To: [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Thomas Zimmermann <[email protected]>
Subject: [PATCH] drm/amdgpu: don't call drm_fb_helper_lastclose in lastclose()

It's used to restore the fbdev console, but as amdgpu uses generic fbdev emulation, the console is being restored by the DRM client helpers already. See the call to drm_client_dev_restore() in drm_lastclose().

Fixes 087451f372bf76 ("drm/amdgpu: use generic fb helpers instead of

setting up AMD own's.")

Cc Thomas Zimmermann <[email protected]>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 -
  1 file changed, 1 deletion(-)
Quoted 13 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_info_ioctl(struct drm_device *dev, · line 1111

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
index fe23e09eec98..474b9f40f792 100644
@@ -1106,7 +1106,6 @@ int amdgpu_info_ioctl(struct drm_device *dev,
 void *data, struct drm_file *filp)
   */
  void amdgpu_driver_lastclose_kms(struct drm_device *dev)
  {
-    drm_fb_helper_lastclose(dev);
     vga_switcheroo_process_delayed_switch();
  }

Without the call to drm_fb_helper_lastclose(), the console emulation will be restored by drm_client_dev_restore() from drm_lastclose(). [1] It means that it's now changing order with the call to vga_switcheroo_process_delay_switch(). Can this become a problem?

Quoted 3 lines

I looked at the other callers of that function. Most restore the console before doing the switcheroo. Nouveau doesn't seem to care about the console at all.

I don't know off hand. I suppose if the switch powered down the GPU and then we tried to restore it's console state that would be a problem, but it looks like vga_switchto_stage2() just powers down the GPU without going through suspend so I'm not sure if this actually worked correctly? What are the potential problems with calling drm_fb_helper_lastclose twice?

Alex

Quoted 18 lines

Best regards
Thomas

[1]
https://elixir.bootlin.com/linux/v6.0.3/source/drivers/gpu/drm/drm_file.c#L467

Quoted 3 lines
Quoted 3 lines

--
2.37.3

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

#4 lore raw

Hi

Am 24.10.22 um 18:48 schrieb Alex Deucher:

Quoted 55 lines · Thomas Zimmermann
Quoted 50 lines

Hi

Am 24.10.22 um 08:20 schrieb Quan, Evan:

Quoted 27 lines

[AMD Official Use Only - General]

Quoted 23 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 20, 2022 10:36 PM
To: [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Thomas Zimmermann <[email protected]>
Subject: [PATCH] drm/amdgpu: don't call drm_fb_helper_lastclose in lastclose()

It's used to restore the fbdev console, but as amdgpu uses generic fbdev emulation, the console is being restored by the DRM client helpers already. See the call to drm_client_dev_restore() in drm_lastclose().

Fixes 087451f372bf76 ("drm/amdgpu: use generic fb helpers instead of

setting up AMD own's.")

Cc Thomas Zimmermann <[email protected]>
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 -
   1 file changed, 1 deletion(-)
Quoted 13 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_info_ioctl(struct drm_device *dev, · line 1111

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
index fe23e09eec98..474b9f40f792 100644
@@ -1106,7 +1106,6 @@ int amdgpu_info_ioctl(struct drm_device *dev,
 void *data, struct drm_file *filp)
    */
   void amdgpu_driver_lastclose_kms(struct drm_device *dev)
   {
-    drm_fb_helper_lastclose(dev);
      vga_switcheroo_process_delayed_switch();
   }

Without the call to drm_fb_helper_lastclose(), the console emulation will be restored by drm_client_dev_restore() from drm_lastclose(). [1] It means that it's now changing order with the call to vga_switcheroo_process_delay_switch(). Can this become a problem?

Quoted 3 lines

I looked at the other callers of that function. Most restore the console before doing the switcheroo. Nouveau doesn't seem to care about the console at all.

Quoted 6 lines

I don't know off hand. I suppose if the switch powered down the GPU and then we tried to restore it's console state that would be a problem, but it looks like vga_switchto_stage2() just powers down the GPU without going through suspend so I'm not sure if this actually worked correctly? What are the potential problems with calling drm_fb_helper_lastclose twice?

It should do fbdev console modesetting twice; so no problem.

AFAIU calling vga switcheroo does nothing for devices without support. So let's call vga_switcheroo_process_delayed_switch() at the very end of drm_lastclose() and remove the amdgpu callback entirely. [1] This should not be a problem and if, we can refactor the whole function.

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/drm_file.c#L468

Quoted 21 lines

Alex

Quoted 18 lines

Best regards
Thomas

[1]
https://elixir.bootlin.com/linux/v6.0.3/source/drivers/gpu/drm/drm_file.c#L467

Quoted 3 lines
Quoted 3 lines

--
2.37.3

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

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
#5 lore raw
Quoted 66 lines · Thomas Zimmermann

Hi

Am 24.10.22 um 18:48 schrieb Alex Deucher:

Quoted 55 lines · Thomas Zimmermann
Quoted 50 lines

Hi

Am 24.10.22 um 08:20 schrieb Quan, Evan:

Quoted 27 lines

[AMD Official Use Only - General]

Quoted 23 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 20, 2022 10:36 PM
To: [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Thomas Zimmermann <[email protected]>
Subject: [PATCH] drm/amdgpu: don't call drm_fb_helper_lastclose in lastclose()

It's used to restore the fbdev console, but as amdgpu uses generic fbdev emulation, the console is being restored by the DRM client helpers already. See the call to drm_client_dev_restore() in drm_lastclose().

Fixes 087451f372bf76 ("drm/amdgpu: use generic fb helpers instead of

setting up AMD own's.")

Cc Thomas Zimmermann <[email protected]>
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 -
   1 file changed, 1 deletion(-)
Quoted 13 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_info_ioctl(struct drm_device *dev, · line 1111

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
index fe23e09eec98..474b9f40f792 100644
@@ -1106,7 +1106,6 @@ int amdgpu_info_ioctl(struct drm_device *dev,
 void *data, struct drm_file *filp)
    */
   void amdgpu_driver_lastclose_kms(struct drm_device *dev)
   {
-    drm_fb_helper_lastclose(dev);
      vga_switcheroo_process_delayed_switch();
   }

Without the call to drm_fb_helper_lastclose(), the console emulation will be restored by drm_client_dev_restore() from drm_lastclose(). [1] It means that it's now changing order with the call to vga_switcheroo_process_delay_switch(). Can this become a problem?

Quoted 3 lines

I looked at the other callers of that function. Most restore the console before doing the switcheroo. Nouveau doesn't seem to care about the console at all.

Quoted 6 lines

I don't know off hand. I suppose if the switch powered down the GPU and then we tried to restore it's console state that would be a problem, but it looks like vga_switchto_stage2() just powers down the GPU without going through suspend so I'm not sure if this actually worked correctly? What are the potential problems with calling drm_fb_helper_lastclose twice?

Quoted 6 lines

It should do fbdev console modesetting twice; so no problem.

AFAIU calling vga switcheroo does nothing for devices without support. So let's call vga_switcheroo_process_delayed_switch() at the very end of drm_lastclose() and remove the amdgpu callback entirely. [1] This should not be a problem and if, we can refactor the whole function.

Sounds like a plan. Thanks!

Alex

Quoted 36 lines

Best regards
Thomas

[1]
https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/drm_file.c#L468

Quoted 21 lines

Alex

Quoted 18 lines

Best regards
Thomas

[1]
https://elixir.bootlin.com/linux/v6.0.3/source/drivers/gpu/drm/drm_file.c#L467

Quoted 3 lines
Quoted 3 lines

--
2.37.3

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

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