drm/amdgpu: split BOCO and ATPX handling
Subsystems (2)
PATCH 1/7 drm/amdgpu: split BOCO and ATPX handling
In preparation for systems that support d3cold on dGPUs independent of PX/HG. No functional change intended.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ++++++++++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 18 +++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 +-- 4 files changed, 42 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -1230,6 +1230,7 @@ void amdgpu_device_program_register_sequence(struct amdgpu_device *adev,const u32 *registers, const u32 array_size); +bool amdgpu_device_supports_atpx (struct drm_device *dev);bool amdgpu_device_supports_boco (struct drm_device *dev);bool amdgpu_device_supports_baco (struct drm_device *dev); bool amdgpu_device_is_peer_accessible(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +25 -8
@@ -211,6 +211,23 @@ static ssize_t amdgpu_device_get_serial_number(struct device *dev, static DEVICE_ATTR(serial_number, S_IRUGO, amdgpu_device_get_serial_number, NULL); +/** +* amdgpu_device_supports_atpx - Is the device a dGPU with HG/PX power control +* +* @dev: drm_device pointer +* +* Returns true if the device is a dGPU with HG/PX power control, +* otherwise return false. +*/ +bool amdgpu_device_supports_atpx (struct drm_device *dev) +{ +struct amdgpu_device *adev =drm_to_adev (dev); + +if (adev->flags &AMD_IS_PX ) +return true; +return false; +} +/** * amdgpu_device_supports_boco - Is the device a dGPU with HG/PX power control *
@@ -1398,7 +1415,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev,struct drm_device *dev =pci_get_drvdata (pdev);int r; -if (amdgpu_device_supports_boco (dev) && state ==VGA_SWITCHEROO_OFF ) +if (amdgpu_device_supports_atpx (dev) && state ==VGA_SWITCHEROO_OFF )return ;if (state ==VGA_SWITCHEROO_ON ) {
@@ -3177,7 +3194,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,struct drm_device *ddev =adev_to_drm (adev);struct pci_dev *pdev = adev->pdev;int r, i; -bool boco = false; +bool atpx = false;u32 max_MBps; adev->shutdown = false;
@@ -3349,15 +3366,15 @@ int amdgpu_device_init(struct amdgpu_device *adev,if ((adev->pdev->class >>8 ) ==PCI_CLASS_DISPLAY_VGA )vga_client_register (adev->pdev, adev,NULL , amdgpu_device_vga_set_decode); -if (amdgpu_device_supports_boco (ddev)) - boco = true; +if (amdgpu_device_supports_atpx (ddev)) + atpx = true;if (amdgpu_has_atpx () && (amdgpu_is_atpx_hybrid () ||amdgpu_has_atpx_dgpu_power_cntl ()) && !pci_is_thunderbolt_attached (adev->pdev))vga_switcheroo_register_client (adev->pdev, - &amdgpu_switcheroo_ops, boco); -if (boco) + &amdgpu_switcheroo_ops, atpx); +if (atpx)vga_switcheroo_init_domain_pm_ops (adev->dev, &adev->vga_pm_domain);if (amdgpu_emu_mode ==1 ) {
@@ -3540,7 +3557,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, failed:amdgpu_vf_error_trans_all (adev); -if (boco) +if (atpx)vga_switcheroo_fini_domain_pm_ops (adev->dev); failed_unmap:
@@ -3604,7 +3621,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev) amdgpu_has_atpx_dgpu_power_cntl()) && !pci_is_thunderbolt_attached(adev->pdev))vga_switcheroo_unregister_client (adev->pdev); -if (amdgpu_device_supports_boco (adev_to_drm (adev))) +if (amdgpu_device_supports_atpx (adev_to_drm (adev)))vga_switcheroo_fini_domain_pm_ops (adev->dev);if ((adev->pdev->class >>8 ) ==PCI_CLASS_DISPLAY_VGA )vga_client_register (adev->pdev,NULL ,NULL ,NULL );
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +14 -4
@@ -1340,7 +1340,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) } adev->in_runpm = true; -if (amdgpu_device_supports_boco (drm_dev)) +if (amdgpu_device_supports_atpx (drm_dev)) drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;drm_kms_helper_poll_disable (drm_dev);
@@ -1348,7 +1348,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)if (ret)return ret; -if (amdgpu_device_supports_boco (drm_dev)) { +if (amdgpu_device_supports_atpx (drm_dev)) {/* Only need to handle PCI state in the driver for ATPX * PCI core handles it for _PR3. */
@@ -1361,6 +1361,11 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)pci_set_power_state (pdev, PCI_D3cold); } drm_dev->switch_power_state =DRM_SWITCH_POWER_DYNAMIC_OFF ; + }else if (amdgpu_device_supports_boco (drm_dev)) { +/* Only need to handle PCI state in the driver for ATPX +* PCI core handles it for _PR3. +*/ +pci_ignore_hotplug (pdev); }else if (amdgpu_device_supports_baco (drm_dev)) {amdgpu_device_baco_enter (drm_dev); }
@@ -1378,7 +1383,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)if (!adev->runpm)return -EINVAL ; -if (amdgpu_device_supports_boco (drm_dev)) { +if (amdgpu_device_supports_atpx (drm_dev)) { drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;/* Only need to handle PCI state in the driver for ATPX
@@ -1394,12 +1399,17 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)return ret;pci_set_master (pdev); } + }else if (amdgpu_device_supports_boco (drm_dev)) { +/* Only need to handle PCI state in the driver for ATPX +* PCI core handles it for _PR3. +*/ +pci_set_master (pdev); }else if (amdgpu_device_supports_baco (drm_dev)) {amdgpu_device_baco_exit (drm_dev); } ret =amdgpu_device_resume (drm_dev, false);drm_kms_helper_poll_enable (drm_dev); -if (amdgpu_device_supports_boco (drm_dev)) +if (amdgpu_device_supports_atpx (drm_dev)) drm_dev->switch_power_state =DRM_SWITCH_POWER_ON ; adev->in_runpm = false;return 0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -2
@@ -156,7 +156,7 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags) goto out; } -if (amdgpu_device_supports_boco (dev) && +if (amdgpu_device_supports_atpx (dev) && (amdgpu_runtime_pm !=0 )) {/* enable runpm by default for boco */ adev->runpm = true; } else if (amdgpu_device_supports_baco(dev) &&
@@ -192,7 +192,7 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)if (adev->runpm) {/* only need to skip on ATPX */ -if (amdgpu_device_supports_boco (dev) && +if (amdgpu_device_supports_atpx (dev) && !amdgpu_is_atpx_hybrid ())dev_pm_set_driver_flags (dev->dev,DPM_FLAG_NO_DIRECT_COMPLETE );pm_runtime_use_autosuspend (dev->dev);
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/7 drm/amdgpu: add check for ACPI power resources
Check if the device has ACPI power resources so we can enable runtime pm if so.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++ 2 files changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -1024,6 +1024,7 @@ struct amdgpu_device {/* enable runtime pm on the device */ bool runpm;bool in_runpm; +bool has_pr3;bool pm_sysfs_en;bool ucode_sysfs_en;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -0
@@ -133,6 +133,7 @@ void amdgpu_register_gpu_instance(struct amdgpu_device *adev)int amdgpu_driver_load_kms (struct amdgpu_device *adev,unsigned long flags) {struct drm_device *dev; +struct pci_dev *parent;int r, acpi_status; dev =adev_to_drm (adev);
@@ -144,6 +145,9 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags) !pci_is_thunderbolt_attached(dev->pdev)) flags |=AMD_IS_PX ; + parent =pci_upstream_bridge (adev->pdev); + adev->has_pr3 = parent ?pci_pr3_present (parent) : false; +/* amdgpu_device_init should report only fatal error * like memory allocation failure or iomapping failure, * or memory manager initialization failure, it must
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/7 drm/amdgpu: update amdgpu_device_supports_boco()
In reply to Alex DeucherChange it to check if the device has ACPI power resources.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -2
@@ -229,7 +229,7 @@ bool amdgpu_device_supports_atpx(struct drm_device *dev) }/** -* amdgpu_device_supports_boco - Is the device a dGPU with HG/PX power control +* amdgpu_device_supports_boco - Is the device a dGPU with ACPI power resources * * @dev: drm_device pointer *
@@ -240,7 +240,7 @@ bool amdgpu_device_supports_boco(struct drm_device *dev) {struct amdgpu_device *adev =drm_to_adev (dev); -if (adev->flags &AMD_IS_PX ) +if (adev->has_pr3)return true;return false; }
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/7 drm/amdgpu: support runtime pm for GPUs that support BOCO
In reply to Alex DeucherEnable runtime pm on non HG/PX BOCO capable boards.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -1
@@ -161,7 +161,10 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags) }if (amdgpu_device_supports_atpx (dev) && - (amdgpu_runtime_pm !=0 )) {/* enable runpm by default for boco */ + (amdgpu_runtime_pm !=0 )) {/* enable runpm by default for atpx */ + adev->runpm = true; + }else if (amdgpu_device_supports_boco (dev) && + (amdgpu_runtime_pm !=0 )) {/* enable runpm by default for boco */ adev->runpm = true; }else if (amdgpu_device_supports_baco (dev) && (amdgpu_runtime_pm !=0 )) {
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/7 drm/amdgpu: no need to call pci_ignore_hotplug for _PR3
In reply to Alex DeucherThe platform knows it's doing d3cold.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -8
@@ -1352,20 +1352,13 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)/* Only need to handle PCI state in the driver for ATPX * PCI core handles it for _PR3. */ -if (amdgpu_is_atpx_hybrid ()) { -pci_ignore_hotplug (pdev); - }else { +if (!amdgpu_is_atpx_hybrid ()) {amdgpu_device_cache_pci_state (pdev);pci_disable_device (pdev);pci_ignore_hotplug (pdev);pci_set_power_state (pdev, PCI_D3cold); } drm_dev->switch_power_state =DRM_SWITCH_POWER_DYNAMIC_OFF ; - }else if (amdgpu_device_supports_boco (drm_dev)) { -/* Only need to handle PCI state in the driver for ATPX -* PCI core handles it for _PR3. -*/ -pci_ignore_hotplug (pdev); }else if (amdgpu_device_supports_baco (drm_dev)) {amdgpu_device_baco_enter (drm_dev); }
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/7 drm/amdgpu: simplify logic in atpx resume handling
In reply to Alex DeucherSimplify the logic in the runtime resume handling for atpx
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -4
@@ -1382,16 +1382,14 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)/* Only need to handle PCI state in the driver for ATPX * PCI core handles it for _PR3. */ -if (amdgpu_is_atpx_hybrid ()) { -pci_set_master (pdev); - }else { +if (!amdgpu_is_atpx_hybrid ()) {pci_set_power_state (pdev,PCI_D0 );amdgpu_device_load_pci_state (pdev); ret =pci_enable_device (pdev);if (ret)return ret; -pci_set_master (pdev); } +pci_set_master (pdev); }else if (amdgpu_device_supports_boco (drm_dev)) {/* Only need to handle PCI state in the driver for ATPX * PCI core handles it for _PR3.
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/7 drm/amdgpu: print what method we are using for runtime pm
In reply to Alex DeucherSo we know when it's enabled and what method we are using.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -0
@@ -163,9 +163,11 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)if (amdgpu_device_supports_atpx (dev) && (amdgpu_runtime_pm !=0 )) {/* enable runpm by default for atpx */ adev->runpm = true; +dev_info (adev->dev,"Using ATPX for runtime pm\n" ); }else if (amdgpu_device_supports_boco (dev) && (amdgpu_runtime_pm !=0 )) {/* enable runpm by default for boco */ adev->runpm = true; +dev_info (adev->dev,"Using BOCO for runtime pm\n" ); }else if (amdgpu_device_supports_baco (dev) && (amdgpu_runtime_pm !=0 )) {switch (adev->asic_type) {
@@ -187,6 +189,8 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags) adev->runpm = true;break ; } +if (adev->runpm) +dev_info (adev->dev,"Using BACO for runtime pm\n" ); }/* Call ACPI methods: require modeset init
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 7/7] drm/amdgpu: print what method we are using for runtime pm
[AMD Official Use Only - Internal Distribution Only]
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, December 11, 2020 5:45 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 7/7] drm/amdgpu: print what method we are using for runtime pm
So we know when it's enabled and what method we are using.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -0
@@ -163,9 +163,11 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)if (amdgpu_device_supports_atpx (dev) && (amdgpu_runtime_pm !=0 )) {/* enable runpm by default for atpx */ adev->runpm = true; +dev_info (adev->dev,"Using ATPX for runtime pm\n" ); }else if (amdgpu_device_supports_boco (dev) && (amdgpu_runtime_pm !=0 )) {/* enable runpm by default for boco */ adev->runpm = true; +dev_info (adev->dev,"Using BOCO for runtime pm\n" ); }else if (amdgpu_device_supports_baco (dev) && (amdgpu_runtime_pm !=0 )) {switch (adev->asic_type) {
@@ -187,6 +189,8 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags) adev->runpm = true;break ; } +if (adev->runpm) +dev_info (adev->dev,"Using BACO for runtime pm\n" ); }/* Call ACPI methods: require modeset init
--
2.25.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Cevan.quan%40amd.com%7Cefb94cd5b4444ecee0d208d89d54f281%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637432335462088875%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=qXcWeg5ccsPXl6lZrL9YYaQF2GyvrzjyWuvDGBbX%2BMs%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 7/7] drm/amdgpu: print what method we are using for runtime pm
In reply to Alex Deucher[AMD Official Use Only - Internal Distribution Only]
Series is acked-by: Evan Quan <[email protected]>
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, December 11, 2020 5:45 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 7/7] drm/amdgpu: print what method we are using for runtime pm
So we know when it's enabled and what method we are using.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -0
@@ -163,9 +163,11 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)if (amdgpu_device_supports_atpx (dev) && (amdgpu_runtime_pm !=0 )) {/* enable runpm by default for atpx */ adev->runpm = true; +dev_info (adev->dev,"Using ATPX for runtime pm\n" ); }else if (amdgpu_device_supports_boco (dev) && (amdgpu_runtime_pm !=0 )) {/* enable runpm by default for boco */ adev->runpm = true; +dev_info (adev->dev,"Using BOCO for runtime pm\n" ); }else if (amdgpu_device_supports_baco (dev) && (amdgpu_runtime_pm !=0 )) {switch (adev->asic_type) {
@@ -187,6 +189,8 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags) adev->runpm = true;break ; } +if (adev->runpm) +dev_info (adev->dev,"Using BACO for runtime pm\n" ); }/* Call ACPI methods: require modeset init
--
2.25.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Cevan.quan%40amd.com%7Cefb94cd5b4444ecee0d208d89d54f281%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637432335462088875%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=qXcWeg5ccsPXl6lZrL9YYaQF2GyvrzjyWuvDGBbX%2BMs%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx