drm/amdgpu: move pci handling out of pm ops
Subsystems (2)
PATCH 1/1 drm/amdgpu: move pci handling out of pm ops
The documentation says the that PCI core handles this for you unless you choose to implement it. Just rely on the PCI core to handle the pci specific bits.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 +++++------ 3 files changed, 24 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -2
@@ -1191,8 +1191,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);void amdgpu_driver_postclose_kms (struct drm_device *dev,struct drm_file *file_priv);int amdgpu_device_ip_suspend (struct amdgpu_device *adev); -int amdgpu_device_suspend (struct drm_device *dev,bool suspend,bool fbcon); -int amdgpu_device_resume (struct drm_device *dev,bool resume,bool fbcon); +int amdgpu_device_suspend (struct drm_device *dev,bool fbcon); +int amdgpu_device_resume (struct drm_device *dev,bool fbcon);u32 amdgpu_get_vblank_counter_kms (struct drm_device *dev,unsigned int pipe);int amdgpu_enable_vblank_kms (struct drm_device *dev,unsigned int pipe);void amdgpu_disable_vblank_kms (struct drm_device *dev,unsigned int pipe);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +14 -19
@@ -1090,6 +1090,7 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev)static void amdgpu_switcheroo_set_state (struct pci_dev *pdev,enum vga_switcheroo_state state) {struct drm_device *dev =pci_get_drvdata (pdev); +int r;if (amdgpu_device_supports_boco (dev) && state ==VGA_SWITCHEROO_OFF )return ;
@@ -1099,7 +1100,12 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero/* don't suspend or resume card normally */ dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_resume (dev, true, true); +pci_set_power_state (dev->pdev,PCI_D0 ); +pci_restore_state (dev->pdev); + r =pci_enable_device (dev->pdev); +if (r) +DRM_WARN ("pci_enable_device failed (%d)\n" , r); +amdgpu_device_resume (dev, true); dev->switch_power_state =DRM_SWITCH_POWER_ON ;drm_kms_helper_poll_enable (dev);
@@ -1107,7 +1113,11 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheropr_info ("amdgpu: switched off\n" );drm_kms_helper_poll_disable (dev); dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_suspend (dev, true, true); +amdgpu_device_suspend (dev, true); +pci_save_state (dev->pdev); +/* Shut down the device */ +pci_disable_device (dev->pdev); +pci_set_power_state (dev->pdev, PCI_D3cold); dev->switch_power_state =DRM_SWITCH_POWER_OFF ; } }
@@ -3198,7 +3208,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)* Returns 0 for success or an error on failure. * Called at driver suspend. */ -int amdgpu_device_suspend (struct drm_device *dev,bool suspend,bool fbcon) +int amdgpu_device_suspend (struct drm_device *dev,bool fbcon) {struct amdgpu_device *adev;struct drm_crtc *crtc;
@@ -3281,13 +3291,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)*/ amdgpu_bo_evict_vram (adev); -if (suspend) { -pci_save_state (dev->pdev); -/* Shut down the device */ -pci_disable_device (dev->pdev); -pci_set_power_state (dev->pdev, PCI_D3hot); - } -return 0 ; }
@@ -3302,7 +3305,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)* Returns 0 for success or an error on failure. * Called at driver resume. */ -int amdgpu_device_resume (struct drm_device *dev,bool resume,bool fbcon) +int amdgpu_device_resume (struct drm_device *dev,bool fbcon) {struct drm_connector *connector;struct drm_connector_list_iter iter;
@@ -3313,14 +3316,6 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)if (dev->switch_power_state ==DRM_SWITCH_POWER_OFF )return 0 ; -if (resume) { -pci_set_power_state (dev->pdev,PCI_D0 ); -pci_restore_state (dev->pdev); - r =pci_enable_device (dev->pdev); -if (r) -return r; - } -/* post card */ if (amdgpu_device_need_post (adev)) { r =amdgpu_atom_asic_init (adev->mode_info.atom_context);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +8 -8
@@ -1158,7 +1158,7 @@ static int amdgpu_pmops_suspend(struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); -return amdgpu_device_suspend (drm_dev, true, true); +return amdgpu_device_suspend (drm_dev, true); }static int amdgpu_pmops_resume (struct device *dev)
@@ -1173,7 +1173,7 @@ static int amdgpu_pmops_resume(struct device *dev)pm_runtime_enable (dev); } -return amdgpu_device_resume (drm_dev, true, true); +return amdgpu_device_resume (drm_dev, true); }static int amdgpu_pmops_freeze (struct device *dev)
@@ -1182,7 +1182,7 @@ static int amdgpu_pmops_freeze(struct device *dev)struct amdgpu_device *adev = drm_dev->dev_private;int r; - r =amdgpu_device_suspend (drm_dev, false, true); + r =amdgpu_device_suspend (drm_dev, true);if (r)return r;return amdgpu_asic_reset (adev);
@@ -1192,21 +1192,21 @@ static int amdgpu_pmops_thaw(struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); -return amdgpu_device_resume (drm_dev, false, true); +return amdgpu_device_resume (drm_dev, true); }static int amdgpu_pmops_poweroff (struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); -return amdgpu_device_suspend (drm_dev, true, true); +return amdgpu_device_suspend (drm_dev, true); }static int amdgpu_pmops_restore (struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); -return amdgpu_device_resume (drm_dev, false, true); +return amdgpu_device_resume (drm_dev, true); }static int amdgpu_pmops_runtime_suspend (struct device *dev)
@@ -1225,7 +1225,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;drm_kms_helper_poll_disable (drm_dev); - ret =amdgpu_device_suspend (drm_dev, false, false); + ret =amdgpu_device_suspend (drm_dev, false);if (amdgpu_device_supports_boco (drm_dev)) {/* Only need to handle PCI state in the driver for ATPX * PCI core handles it for _PR3.
@@ -1275,7 +1275,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev) }else if (amdgpu_device_supports_baco (drm_dev)) {amdgpu_device_baco_exit (drm_dev); } - ret =amdgpu_device_resume (drm_dev, false, false); + ret =amdgpu_device_resume (drm_dev, false);drm_kms_helper_poll_enable (drm_dev);if (amdgpu_device_supports_boco (drm_dev)) drm_dev->switch_power_state =DRM_SWITCH_POWER_ON ;
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20191121165529.3941-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org
Quoted 54 lines · Alex Deucher
The documentation says the that PCI core handles this for you unless you choose to implement it. Just rely on the PCI core to handle the pci specific bits.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 +++++------ 3 files changed, 24 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-2@@ -1191,8 +1191,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);void amdgpu_driver_postclose_kms (struct drm_device *dev,struct drm_file *file_priv);int amdgpu_device_ip_suspend (struct amdgpu_device *adev); -int amdgpu_device_suspend (struct drm_device *dev,bool suspend,bool fbcon); -int amdgpu_device_resume (struct drm_device *dev,bool resume,bool fbcon); +int amdgpu_device_suspend (struct drm_device *dev,bool fbcon); +int amdgpu_device_resume (struct drm_device *dev,bool fbcon);u32 amdgpu_get_vblank_counter_kms (struct drm_device *dev,unsigned int pipe);int amdgpu_enable_vblank_kms (struct drm_device *dev,unsigned int pipe);void amdgpu_disable_vblank_kms (struct drm_device *dev,unsigned int pipe);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-1@@ -1090,6 +1090,7 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev)static void amdgpu_switcheroo_set_state (struct pci_dev *pdev,enum vga_switcheroo_state state) {struct drm_device *dev =pci_get_drvdata (pdev); +int r;if (amdgpu_device_supports_boco (dev) && state ==VGA_SWITCHEROO_OFF )return ;@@ -1099,7 +1100,12 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero/* don't suspend or resume card normally */ dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_resume (dev, true, true); +pci_set_power_state (dev->pdev,PCI_D0 ); +pci_restore_state (dev->pdev); + r =pci_enable_device (dev->pdev); +if (r) +DRM_WARN ("pci_enable_device failed (%d)\n" , r); +amdgpu_device_resume (dev, true); dev->switch_power_state =DRM_SWITCH_POWER_ON ;drm_kms_helper_poll_enable (dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero · line 1120
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-1@@ -1107,7 +1113,11 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheropr_info ("amdgpu: switched off\n" );drm_kms_helper_poll_disable (dev); dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_suspend (dev, true, true); +amdgpu_device_suspend (dev, true); +pci_save_state (dev->pdev); +/* Shut down the device */ +pci_disable_device (dev->pdev); +pci_set_power_state (dev->pdev, PCI_D3cold);
I think this will break D3 cold on ATPX systems (i.e. before PCIE d3 cold support).
I'm not 100% sure but I'd really like to test it, as I don't think the core will put the device into D3cold for us here.
Dave.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CAPM=9twAwCJaXHS=cWNCihsyfydAKqQ1igjLt1g_vbFBL0bdMg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 70 lines · Dave Airlie
Quoted 54 lines · Alex Deucher
The documentation says the that PCI core handles this for you unless you choose to implement it. Just rely on the PCI core to handle the pci specific bits.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 +++++------ 3 files changed, 24 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-2@@ -1191,8 +1191,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);void amdgpu_driver_postclose_kms (struct drm_device *dev,struct drm_file *file_priv);int amdgpu_device_ip_suspend (struct amdgpu_device *adev); -int amdgpu_device_suspend (struct drm_device *dev,bool suspend,bool fbcon); -int amdgpu_device_resume (struct drm_device *dev,bool resume,bool fbcon); +int amdgpu_device_suspend (struct drm_device *dev,bool fbcon); +int amdgpu_device_resume (struct drm_device *dev,bool fbcon);u32 amdgpu_get_vblank_counter_kms (struct drm_device *dev,unsigned int pipe);int amdgpu_enable_vblank_kms (struct drm_device *dev,unsigned int pipe);void amdgpu_disable_vblank_kms (struct drm_device *dev,unsigned int pipe);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-1@@ -1090,6 +1090,7 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev)static void amdgpu_switcheroo_set_state (struct pci_dev *pdev,enum vga_switcheroo_state state) {struct drm_device *dev =pci_get_drvdata (pdev); +int r;if (amdgpu_device_supports_boco (dev) && state ==VGA_SWITCHEROO_OFF )return ;@@ -1099,7 +1100,12 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero/* don't suspend or resume card normally */ dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_resume (dev, true, true); +pci_set_power_state (dev->pdev,PCI_D0 ); +pci_restore_state (dev->pdev); + r =pci_enable_device (dev->pdev); +if (r) +DRM_WARN ("pci_enable_device failed (%d)\n" , r); +amdgpu_device_resume (dev, true); dev->switch_power_state =DRM_SWITCH_POWER_ON ;drm_kms_helper_poll_enable (dev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero · line 1120
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-1@@ -1107,7 +1113,11 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheropr_info ("amdgpu: switched off\n" );drm_kms_helper_poll_disable (dev); dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_suspend (dev, true, true); +amdgpu_device_suspend (dev, true); +pci_save_state (dev->pdev); +/* Shut down the device */ +pci_disable_device (dev->pdev); +pci_set_power_state (dev->pdev, PCI_D3cold);I think this will break D3 cold on ATPX systems (i.e. before PCIE d3 cold support).
Quoted 2 lines
I'm not 100% sure but I'd really like to test it, as I don't think the core will put the device into D3cold for us here.
Should be the same as before, I just moved the pci funcs up from the callee into the caller, or are you talking about the switch from d3hot to d3cold? I can make the hot/cold change a separate commit however. That said, it doesn't really matter what d3 state we choose here. The APTX call cuts the power rail anyway (effectively d3cold).
Alex
Quoted 2 lines
Dave.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_N5GFf2kHANxBHn_Pn3=XZ=XcfgociQaDxp7zd0Hewjkw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 72 lines · Alex Deucher
Quoted 70 lines · Dave Airlie
Quoted 54 lines · Alex Deucher
The documentation says the that PCI core handles this for you unless you choose to implement it. Just rely on the PCI core to handle the pci specific bits.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 +++++------ 3 files changed, 24 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-2@@ -1191,8 +1191,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);void amdgpu_driver_postclose_kms (struct drm_device *dev,struct drm_file *file_priv);int amdgpu_device_ip_suspend (struct amdgpu_device *adev); -int amdgpu_device_suspend (struct drm_device *dev,bool suspend,bool fbcon); -int amdgpu_device_resume (struct drm_device *dev,bool resume,bool fbcon); +int amdgpu_device_suspend (struct drm_device *dev,bool fbcon); +int amdgpu_device_resume (struct drm_device *dev,bool fbcon);u32 amdgpu_get_vblank_counter_kms (struct drm_device *dev,unsigned int pipe);int amdgpu_enable_vblank_kms (struct drm_device *dev,unsigned int pipe);void amdgpu_disable_vblank_kms (struct drm_device *dev,unsigned int pipe);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-1@@ -1090,6 +1090,7 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev)static void amdgpu_switcheroo_set_state (struct pci_dev *pdev,enum vga_switcheroo_state state) {struct drm_device *dev =pci_get_drvdata (pdev); +int r;if (amdgpu_device_supports_boco (dev) && state ==VGA_SWITCHEROO_OFF )return ;@@ -1099,7 +1100,12 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero/* don't suspend or resume card normally */ dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_resume (dev, true, true); +pci_set_power_state (dev->pdev,PCI_D0 ); +pci_restore_state (dev->pdev); + r =pci_enable_device (dev->pdev); +if (r) +DRM_WARN ("pci_enable_device failed (%d)\n" , r); +amdgpu_device_resume (dev, true); dev->switch_power_state =DRM_SWITCH_POWER_ON ;drm_kms_helper_poll_enable (dev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero · line 1120
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-1@@ -1107,7 +1113,11 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheropr_info ("amdgpu: switched off\n" );drm_kms_helper_poll_disable (dev); dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_suspend (dev, true, true); +amdgpu_device_suspend (dev, true); +pci_save_state (dev->pdev); +/* Shut down the device */ +pci_disable_device (dev->pdev); +pci_set_power_state (dev->pdev, PCI_D3cold);I think this will break D3 cold on ATPX systems (i.e. before PCIE d3 cold support).
Quoted 8 lines
Quoted 2 lines
I'm not 100% sure but I'd really like to test it, as I don't think the core will put the device into D3cold for us here.
Should be the same as before, I just moved the pci funcs up from the callee into the caller, or are you talking about the switch from d3hot to d3cold? I can make the hot/cold change a separate commit however. That said, it doesn't really matter what d3 state we choose here. The APTX call cuts the power rail anyway (effectively d3cold).
It matters to the OS, as it has to bring the device out of cold for certain operations that work in hot (like conifg space access).
But sorry I misread the patch I thought you were dropping the calls in favour of the pci core doing them.
Dave.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CAPM=9txC5CZdQ8WY5RqOJNr7n+jqZ-ge1YeZxvME-Qdn_rREow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 77 lines · Dave Airlie
Quoted 75 lines · Alex Deucher
Quoted 72 lines · Dave Airlie
Quoted 54 lines · Alex Deucher
The documentation says the that PCI core handles this for you unless you choose to implement it. Just rely on the PCI core to handle the pci specific bits.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 +++++------ 3 files changed, 24 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-2@@ -1191,8 +1191,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);void amdgpu_driver_postclose_kms (struct drm_device *dev,struct drm_file *file_priv);int amdgpu_device_ip_suspend (struct amdgpu_device *adev); -int amdgpu_device_suspend (struct drm_device *dev,bool suspend,bool fbcon); -int amdgpu_device_resume (struct drm_device *dev,bool resume,bool fbcon); +int amdgpu_device_suspend (struct drm_device *dev,bool fbcon); +int amdgpu_device_resume (struct drm_device *dev,bool fbcon);u32 amdgpu_get_vblank_counter_kms (struct drm_device *dev,unsigned int pipe);int amdgpu_enable_vblank_kms (struct drm_device *dev,unsigned int pipe);void amdgpu_disable_vblank_kms (struct drm_device *dev,unsigned int pipe);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-1@@ -1090,6 +1090,7 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev)static void amdgpu_switcheroo_set_state (struct pci_dev *pdev,enum vga_switcheroo_state state) {struct drm_device *dev =pci_get_drvdata (pdev); +int r;if (amdgpu_device_supports_boco (dev) && state ==VGA_SWITCHEROO_OFF )return ;@@ -1099,7 +1100,12 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero/* don't suspend or resume card normally */ dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_resume (dev, true, true); +pci_set_power_state (dev->pdev,PCI_D0 ); +pci_restore_state (dev->pdev); + r =pci_enable_device (dev->pdev); +if (r) +DRM_WARN ("pci_enable_device failed (%d)\n" , r); +amdgpu_device_resume (dev, true); dev->switch_power_state =DRM_SWITCH_POWER_ON ;drm_kms_helper_poll_enable (dev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero · line 1120
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-1@@ -1107,7 +1113,11 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheropr_info ("amdgpu: switched off\n" );drm_kms_helper_poll_disable (dev); dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_suspend (dev, true, true); +amdgpu_device_suspend (dev, true); +pci_save_state (dev->pdev); +/* Shut down the device */ +pci_disable_device (dev->pdev); +pci_set_power_state (dev->pdev, PCI_D3cold);I think this will break D3 cold on ATPX systems (i.e. before PCIE d3 cold support).
I'm not 100% sure but I'd really like to test it, as I don't think the core will put the device into D3cold for us here.
Quoted 8 lines
Quoted 5 lines
Should be the same as before, I just moved the pci funcs up from the callee into the caller, or are you talking about the switch from d3hot to d3cold? I can make the hot/cold change a separate commit however. That said, it doesn't really matter what d3 state we choose here. The APTX call cuts the power rail anyway (effectively d3cold).
It matters to the OS, as it has to bring the device out of cold for certain operations that work in hot (like conifg space access).
Well, in that case, d3cold better matches what actually happens. Nothing can access the device until it's powered back up via ATPX.
Quoted 3 lines
But sorry I misread the patch I thought you were dropping the calls in favour of the pci core doing them.
No problem.
Alex
Quoted 2 lines
Dave.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Ping? I've tested this on all the cards I have access to.
Alex
Quoted 188 lines · Alex Deucher
The documentation says the that PCI core handles this for you unless you choose to implement it. Just rely on the PCI core to handle the pci specific bits.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 +++++------ 3 files changed, 24 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-2@@ -1191,8 +1191,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);void amdgpu_driver_postclose_kms (struct drm_device *dev,struct drm_file *file_priv);int amdgpu_device_ip_suspend (struct amdgpu_device *adev); -int amdgpu_device_suspend (struct drm_device *dev,bool suspend,bool fbcon); -int amdgpu_device_resume (struct drm_device *dev,bool resume,bool fbcon); +int amdgpu_device_suspend (struct drm_device *dev,bool fbcon); +int amdgpu_device_resume (struct drm_device *dev,bool fbcon);u32 amdgpu_get_vblank_counter_kms (struct drm_device *dev,unsigned int pipe);int amdgpu_enable_vblank_kms (struct drm_device *dev,unsigned int pipe);void amdgpu_disable_vblank_kms (struct drm_device *dev,unsigned int pipe);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +14
-19@@ -1090,6 +1090,7 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev)static void amdgpu_switcheroo_set_state (struct pci_dev *pdev,enum vga_switcheroo_state state) {struct drm_device *dev =pci_get_drvdata (pdev); +int r;if (amdgpu_device_supports_boco (dev) && state ==VGA_SWITCHEROO_OFF )return ;@@ -1099,7 +1100,12 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero/* don't suspend or resume card normally */ dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_resume (dev, true, true); +pci_set_power_state (dev->pdev,PCI_D0 ); +pci_restore_state (dev->pdev); + r =pci_enable_device (dev->pdev); +if (r) +DRM_WARN ("pci_enable_device failed (%d)\n" , r); +amdgpu_device_resume (dev, true); dev->switch_power_state =DRM_SWITCH_POWER_ON ;drm_kms_helper_poll_enable (dev);@@ -1107,7 +1113,11 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheropr_info ("amdgpu: switched off\n" );drm_kms_helper_poll_disable (dev); dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_suspend (dev, true, true); +amdgpu_device_suspend (dev, true); +pci_save_state (dev->pdev); +/* Shut down the device */ +pci_disable_device (dev->pdev); +pci_set_power_state (dev->pdev, PCI_D3cold); dev->switch_power_state =DRM_SWITCH_POWER_OFF ; } }@@ -3198,7 +3208,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)* Returns 0 for success or an error on failure. * Called at driver suspend. */ -int amdgpu_device_suspend (struct drm_device *dev,bool suspend,bool fbcon) +int amdgpu_device_suspend (struct drm_device *dev,bool fbcon) {struct amdgpu_device *adev;struct drm_crtc *crtc;@@ -3281,13 +3291,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)*/ amdgpu_bo_evict_vram (adev); -if (suspend) { -pci_save_state (dev->pdev); -/* Shut down the device */ -pci_disable_device (dev->pdev); -pci_set_power_state (dev->pdev, PCI_D3hot); - } -return 0 ; }@@ -3302,7 +3305,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)* Returns 0 for success or an error on failure. * Called at driver resume. */ -int amdgpu_device_resume (struct drm_device *dev,bool resume,bool fbcon) +int amdgpu_device_resume (struct drm_device *dev,bool fbcon) {struct drm_connector *connector;struct drm_connector_list_iter iter;@@ -3313,14 +3316,6 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)if (dev->switch_power_state ==DRM_SWITCH_POWER_OFF )return 0 ; -if (resume) { -pci_set_power_state (dev->pdev,PCI_D0 ); -pci_restore_state (dev->pdev); - r =pci_enable_device (dev->pdev); -if (r) -return r; - } -/* post card */ if (amdgpu_device_need_post (adev)) { r =amdgpu_atom_asic_init (adev->mode_info.atom_context);drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +8
-9@@ -1158,7 +1158,7 @@ static int amdgpu_pmops_suspend(struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); -return amdgpu_device_suspend (drm_dev, true, true); +return amdgpu_device_suspend (drm_dev, true); }static int amdgpu_pmops_resume (struct device *dev)@@ -1173,7 +1173,7 @@ static int amdgpu_pmops_resume(struct device *dev)pm_runtime_enable (dev); } -return amdgpu_device_resume (drm_dev, true, true); +return amdgpu_device_resume (drm_dev, true); }static int amdgpu_pmops_freeze (struct device *dev)@@ -1182,7 +1182,7 @@ static int amdgpu_pmops_freeze(struct device *dev)struct amdgpu_device *adev = drm_dev->dev_private;int r; - r =amdgpu_device_suspend (drm_dev, false, true); + r =amdgpu_device_suspend (drm_dev, true);if (r)return r;return amdgpu_asic_reset (adev);@@ -1192,21 +1192,21 @@ static int amdgpu_pmops_thaw(struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); -return amdgpu_device_resume (drm_dev, false, true); +return amdgpu_device_resume (drm_dev, true); }static int amdgpu_pmops_poweroff (struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); -return amdgpu_device_suspend (drm_dev, true, true); +return amdgpu_device_suspend (drm_dev, true); }static int amdgpu_pmops_restore (struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); -return amdgpu_device_resume (drm_dev, false, true); +return amdgpu_device_resume (drm_dev, true); }static int amdgpu_pmops_runtime_suspend (struct device *dev)@@ -1225,7 +1225,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;drm_kms_helper_poll_disable (drm_dev); - ret =amdgpu_device_suspend (drm_dev, false, false); + ret =amdgpu_device_suspend (drm_dev, false);if (amdgpu_device_supports_boco (drm_dev)) {/* Only need to handle PCI state in the driver for ATPX * PCI core handles it for _PR3. @@ -1275,7 +1275,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev) }else if (amdgpu_device_supports_baco (drm_dev)) {amdgpu_device_baco_exit (drm_dev); } - ret =amdgpu_device_resume (drm_dev, false, false); + ret =amdgpu_device_resume (drm_dev, false);drm_kms_helper_poll_enable (drm_dev);if (amdgpu_device_supports_boco (drm_dev)) drm_dev->switch_power_state =DRM_SWITCH_POWER_ON ; --
Quoted 2 lines
2.23.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_OA56jv3wjRH43obaFM4M=nsZ4fESbQ6fDzOZ2RiQ21Sg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Liu, Zhan
Reviewed-by Zhan LiuQuoted 10 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: 2019/November/26, Tuesday 9:51 AM
To: amd-gfx list <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: move pci handling out of pm ops
Quoted 12 lines
Ping? I've tested this on all the cards I have access to.
Alex
Quoted 6 lines · Alex Deucher
The documentation says the that PCI core handles this for you unless you choose to implement it. Just rely on the PCI core to handle the pci specific bits.
Signed-off-by Alex Deucher <[email protected]>
Quoted 203 lines
Quoted 3 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++-------------
drivers/gpu/drm/amd/amdgpu/amdgpu.h int amdgpu_driver_open_kms(struct drm_device · line 1191
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 +++++------ 3 files changed, 24 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0@@ -1191,8 +1191,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv); voidamdgpu_driver_postclose_kms(struct
drm_device*dev,drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0struct drm_file *file_priv); int
amdgpu_device_ip_suspend(struct amdgpu_device *adev); -intamdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon); -intamdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-0+int amdgpu_device_suspend (struct drm_device *dev,bool fbcon);int +amdgpu_device_resume (struct drm_device *dev,bool fbcon); u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsignedint pipe); int
amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe); voidamdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe); diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
indexb1408c5e4640..d832bd22ba9d100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -1090,6 +1090,7 @@ static intamdgpu_device_check_arguments(struct
Quoted 6 lines
amdgpu_device*adev) static void amdgpu_switcheroo_set_state(structpci_dev *pdev, enum vga_switcheroo_state state) { struct drm_device *dev = pci_get_drvdata(pdev);+ int r;
if (amdgpu_device_supports_boco(dev) && state ==
VGA_SWITCHEROO_OFF)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_switcheroo_set_state(struct
Quoted 2 lines
return;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -1099,7 +1100,12 @@ static void amdgpu_switcheroo_set_state(struct
pci_dev*pdev, enumvga_switcheroQuoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-1/* don't suspend or resume card normally */ dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -amdgpu_device_resume (dev, true, true); +pci_set_power_state (dev->pdev,PCI_D0 ); +pci_restore_state (dev->pdev); + r =pci_enable_device (dev->pdev); +if (r) +DRM_WARN ("pci_enable_device failed (%d)\n" , r); +amdgpu_device_resume (dev, true); dev->switch_power_state =DRM_SWITCH_POWER_ON ; drm_kms_helper_poll_enable(dev); @@ -1107,7 +1113,11Quoted 1 line
@@ static void amdgpu_switcheroo_set_state(struct
pci_dev*pdev,enum
vga_switcherodrivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device
Quoted 13 lines
pr_info("amdgpu: switched off\n"); drm_kms_helper_poll_disable(dev); dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-1-amdgpu_device_suspend (dev, true, true); +amdgpu_device_suspend (dev, true); +pci_save_state (dev->pdev); +/* Shut down the device */ +pci_disable_device (dev->pdev); +pci_set_power_state (dev->pdev, PCI_D3cold); dev->switch_power_state =DRM_SWITCH_POWER_OFF ; } }@@ -3198,7 +3208,7 @@ void amdgpu_device_fini(struct amdgpu_device*adev)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1* Returns 0 for success or an error on failure. * Called at driver suspend. */ -int amdgpu_device_suspend (struct drm_device *dev,bool suspend,bool fbcon) +int amdgpu_device_suspend (struct drm_device *dev,bool fbcon) {struct amdgpu_device *adev;struct drm_crtc *crtc;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -3281,13 +3291,6 @@ int amdgpu_device_suspend(struct drm_device*dev, bool suspend, bool fbcon)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-7*/ amdgpu_bo_evict_vram (adev); -if (suspend) { -pci_save_state (dev->pdev); -/* Shut down the device */ -pci_disable_device (dev->pdev); -pci_set_power_state (dev->pdev, PCI_D3hot); - } -return 0 ; }@@ -3302,7 +3305,7 @@ int amdgpu_device_suspend(struct drm_device*dev, bool suspend, bool fbcon)
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1* Returns 0 for success or an error on failure. * Called at driver resume. */ -int amdgpu_device_resume (struct drm_device *dev,bool resume,bool fbcon) +int amdgpu_device_resume (struct drm_device *dev,bool fbcon) {struct drm_connector *connector;struct drm_connector_list_iter iter; @@ -3313,14 +3316,6 @@int amdgpu_device_resume(struct
drm_device*dev, bool resume, boolfbcon)
Quoted 21 lines
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) return 0;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-8-if (resume) { -pci_set_power_state (dev->pdev,PCI_D0 ); -pci_restore_state (dev->pdev); - r =pci_enable_device (dev->pdev); -if (r) -return r; - } -/* post card */ if (amdgpu_device_need_post (adev)) { r =
amdgpu_atom_asic_init(adev->mode_info.atom_context);drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_suspend(struct device · line 1164
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-1@@ -1158,7 +1158,7 @@ static int amdgpu_pmops_suspend(struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); -return amdgpu_device_suspend (drm_dev, true, true); +return amdgpu_device_suspend (drm_dev, true); } static int amdgpu_pmops_resume(struct device *dev) @@ -1173,7+1173,7
Quoted 31 lines
@@ static int
amdgpu_pmops_resume(struct device *dev)pm_runtime_enable(dev); }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-1-return amdgpu_device_resume (drm_dev, true, true); +return amdgpu_device_resume (drm_dev, true); } static int amdgpu_pmops_freeze(struct device *dev) @@ -1182,7 +1182,7@@ static int
amdgpu_pmops_freeze(struct device *dev)struct amdgpu_device *adev = drm_dev->dev_private; int r;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-1- r =amdgpu_device_suspend (drm_dev, false, true); + r =amdgpu_device_suspend (drm_dev, true);if (r)return r; return amdgpu_asic_reset(adev); @@ -1192,21 +1192,21 @@ staticint amdgpu_pmops_thaw(struct device *dev) { struct drm_device *drm_dev = dev_get_drvdata(dev);drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-2-return amdgpu_device_resume (drm_dev, false, true); +return amdgpu_device_resume (drm_dev, true); }static int amdgpu_pmops_poweroff (struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); -return amdgpu_device_suspend (drm_dev, true, true); +return amdgpu_device_suspend (drm_dev, true); }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_thaw(struct device *dev)
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-2static int amdgpu_pmops_restore (struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); -return amdgpu_device_resume (drm_dev, false, true); +return amdgpu_device_resume (drm_dev, true); } static int amdgpu_pmops_runtime_suspend(struct device *dev) @@ -1225,7 +1225,7 @@ static int amdgpu_pmops_runtime_suspend(structdevice *dev)
Quoted 1 line
drm_dev->switch_power_state =
DRM_SWITCH_POWER_CHANGING;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int
Quoted 8 lines
drm_kms_helper_poll_disable(drm_dev);drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-1- ret =amdgpu_device_suspend (drm_dev, false, false); + ret =amdgpu_device_suspend (drm_dev, false);if (amdgpu_device_supports_boco (drm_dev)) {/* Only need to handle PCI state in the driver for ATPX * PCI core handles it for _PR3. @@ -1275,7 +1275,7 @@ static int
amdgpu_pmops_runtime_resume(struct device *dev)Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-2}else if (amdgpu_device_supports_baco (drm_dev)) {amdgpu_device_baco_exit (drm_dev); } - ret =amdgpu_device_resume (drm_dev, false, false); + ret =amdgpu_device_resume (drm_dev, false);drm_kms_helper_poll_enable (drm_dev);if (amdgpu_device_supports_boco (drm_dev)) drm_dev->switch_power_state =DRM_SWITCH_POWER_ON ; --2.23.0
Quoted 3 lines
_______________________________________________
amd-gfx mailing list
[email protected]
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx