drm/amdgpu: set APU flag based on IP discovery table
Subsystems (2)
Alex Deucher
maintainerPATCH 1/5 drm/amdgpu: set APU flag based on IP discovery table
Use the IP versions to set the APU flag when necessary.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +13 -0
@@ -1253,6 +1253,19 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)return -EINVAL ; } +switch (adev->ip_versions[GC_HWIP ][0 ]) { +case IP_VERSION (9 ,1 ,0 ): +case IP_VERSION (9 ,2 ,2 ): +case IP_VERSION (9 ,3 ,0 ): +case IP_VERSION (10 ,1 ,3 ): +case IP_VERSION (10 ,3 ,1 ): +case IP_VERSION (10 ,3 ,3 ): + adev->flags |=AMD_IS_APU ; +break ; +default : +break ; + } +if (adev->ip_versions[XGMI_HWIP ][0 ] ==IP_VERSION (4 ,8 ,0 )) adev->gmc.xgmi.supported = true;
Signature · 1 line
2.34.1
Alex Deucher
maintainerPATCH 2/5 drm/amdgpu: move PX checking into amdgpu_device_ip_early_init
We need to set the APU flag from IP discovery before we evaluate this code.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 13 ------------- 2 files changed, 15 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +15 -0
@@ -31,6 +31,7 @@#include <linux/console.h> #include <linux/slab.h> #include <linux/iommu.h> +#include <linux/pci.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_probe_helper.h>
@@ -2073,6 +2074,8 @@ static int amdgpu_device_parse_gpu_info_fw(struct amdgpu_device *adev)*/ static int amdgpu_device_ip_early_init (struct amdgpu_device *adev) { +struct drm_device *dev =adev_to_drm (adev); +struct pci_dev *parent;int i, r;amdgpu_device_enable_virtual_display (adev);
@@ -2137,6 +2140,18 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)break ; } +if (amdgpu_has_atpx () && + (amdgpu_is_atpx_hybrid () || +amdgpu_has_atpx_dgpu_power_cntl ()) && + ((adev->flags &AMD_IS_APU ) ==0 ) && + !pci_is_thunderbolt_attached (to_pci_dev (dev->dev))) + adev->flags |=AMD_IS_PX ; + +if (!(adev->flags &AMD_IS_APU )) { + parent =pci_upstream_bridge (adev->pdev); + adev->has_pr3 = parent ?pci_pr3_present (parent) : false; + } +amdgpu_amdkfd_device_probe (adev); adev->pm.pp_feature = amdgpu_pp_feature_mask;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -13
@@ -152,23 +152,10 @@ static void amdgpu_get_audio_func(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); -if (amdgpu_has_atpx () && - (amdgpu_is_atpx_hybrid () || -amdgpu_has_atpx_dgpu_power_cntl ()) && - ((flags &AMD_IS_APU ) ==0 ) && - !pci_is_thunderbolt_attached (to_pci_dev (dev->dev))) - flags |=AMD_IS_PX ; - -if (!(flags &AMD_IS_APU )) { - 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 · 1 line
2.34.1
Alex Deucher
maintainerPATCH 3/5 drm/amdgpu: move runtime pm init after drm and fbdev init
In reply to Alex DeucherSeems more logical to enable runtime pm at the end of the init sequence so we don't end up entering runtime suspend before init is finished.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 65 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 69 +------------------------ 2 files changed, 66 insertions(+), 68 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +65 -0
@@ -1968,6 +1968,22 @@ static bool amdgpu_is_fw_framebuffer(resource_size_t base,return found; } +static void amdgpu_get_audio_func (struct amdgpu_device *adev) +{ +struct pci_dev *p =NULL ; + + p =pci_get_domain_bus_and_slot (pci_domain_nr (adev->pdev->bus), + adev->pdev->bus->number,1 ); +if (p) { +pm_runtime_get_sync (&p->dev); + +pm_runtime_mark_last_busy (&p->dev); +pm_runtime_put_autosuspend (&p->dev); + +pci_dev_put (p); + } +} +static int amdgpu_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) {
@@ -2100,6 +2116,48 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,if (ret)DRM_ERROR ("Creating debugfs files failed (%d).\n" , ret); +if (adev->runpm) { +/* only need to skip on ATPX */ +if (amdgpu_device_supports_px (ddev)) +dev_pm_set_driver_flags (ddev->dev,DPM_FLAG_NO_DIRECT_COMPLETE ); +/* we want direct complete for BOCO */ +if (amdgpu_device_supports_boco (ddev)) +dev_pm_set_driver_flags (ddev->dev,DPM_FLAG_SMART_PREPARE | +DPM_FLAG_SMART_SUSPEND | +DPM_FLAG_MAY_SKIP_RESUME ); +pm_runtime_use_autosuspend (ddev->dev); +pm_runtime_set_autosuspend_delay (ddev->dev,5000 ); + +pm_runtime_allow (ddev->dev); + +pm_runtime_mark_last_busy (ddev->dev); +pm_runtime_put_autosuspend (ddev->dev); + +/* +* For runpm implemented via BACO, PMFW will handle the +* timing for BACO in and out: +* - put ASIC into BACO state only when both video and +* audio functions are in D3 state. +* - pull ASIC out of BACO state when either video or +* audio function is in D0 state. +* Also, at startup, PMFW assumes both functions are in +* D0 state. +* +* So if snd driver was loaded prior to amdgpu driver +* and audio function was put into D3 state, there will +* be no PMFW-aware D-state transition(D0->D3) on runpm +* suspend. Thus the BACO will be not correctly kicked in. +* +* Via amdgpu_get_audio_func(), the audio dev is put +* into D0 state. Then there will be a PMFW-aware D-state +* transition(D0->D3) on runpm suspend. +*/ +if (amdgpu_device_supports_baco (ddev) && + !(adev->flags &AMD_IS_APU ) && + (adev->asic_type >=CHIP_NAVI10 )) +amdgpu_get_audio_func (adev); + } +return 0 ; err_pci:
@@ -2111,8 +2169,15 @@ static void amdgpu_pci_remove(struct pci_dev *pdev) {struct drm_device *dev =pci_get_drvdata (pdev); +struct amdgpu_device *adev =drm_to_adev (dev);drm_dev_unplug (dev); + +if (adev->runpm) { +pm_runtime_get_sync (dev->dev); +pm_runtime_forbid (dev->dev); + } +amdgpu_driver_unload_kms (dev);/*
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -68
92 lines not on this page · raw message
Signature · 1 line
2.34.1
Alex Deucher
maintainerPATCH 4/5 drm/amdgpu: handle BACO synchronization with secondary funcs
In reply to Alex DeucherExtend secondary function handling for runtime pm beyond audio to USB and UCSI.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 30 +++++++++++++++---------- 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +18 -12
@@ -1968,19 +1968,25 @@ static bool amdgpu_is_fw_framebuffer(resource_size_t base,return found; } -static void amdgpu_get_audio_func (struct amdgpu_device *adev) +static void amdgpu_get_secondary_funcs (struct amdgpu_device *adev) {struct pci_dev *p =NULL ; +int i; - p =pci_get_domain_bus_and_slot (pci_domain_nr (adev->pdev->bus), - adev->pdev->bus->number,1 ); -if (p) { -pm_runtime_get_sync (&p->dev); - -pm_runtime_mark_last_busy (&p->dev); -pm_runtime_put_autosuspend (&p->dev); - -pci_dev_put (p); +/* 0 - GPU +* 1 - audio +* 2 - USB +* 3 - UCSI +*/ +for (i =1 ; i <4 ; i++) { + p =pci_get_domain_bus_and_slot (pci_domain_nr (adev->pdev->bus), + adev->pdev->bus->number, i); +if (p) { +pm_runtime_get_sync (&p->dev); +pm_runtime_mark_last_busy (&p->dev); +pm_runtime_put_autosuspend (&p->dev); +pci_dev_put (p); + } } }
@@ -2148,14 +2154,14 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,* be no PMFW-aware D-state transition(D0->D3) on runpm * suspend. Thus the BACO will be not correctly kicked in. * -* Via amdgpu_get_audio_func(), the audio dev is put +* Via amdgpu_get_secondary_funcs(), the audio dev is put * into D0 state. Then there will be a PMFW-aware D-state * transition(D0->D3) on runpm suspend. */ if (amdgpu_device_supports_baco (ddev) && !(adev->flags &AMD_IS_APU ) && (adev->asic_type >=CHIP_NAVI10 )) -amdgpu_get_audio_func (adev); +amdgpu_get_secondary_funcs (adev); }return 0 ;
Signature · 1 line
2.34.1
RE: [PATCH 4/5] drm/amdgpu: handle BACO synchronization with secondary funcs
[AMD Official Use Only]
Quoted 54 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, January 22, 2022 4:22 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 4/5] drm/amdgpu: handle BACO synchronization with secondary funcsExtend secondary function handling for runtime pm beyond audio to USB and UCSI.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 30 +++++++++++++++------ ---- 1 file changed, 18 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +10
-10@@ -1968,19 +1968,25 @@ static bool amdgpu_is_fw_framebuffer(resource_size_t base, return found; } -static void amdgpu_get_audio_func (struct amdgpu_device *adev) +static void amdgpu_get_secondary_funcs (struct amdgpu_device *adev) {struct pci_dev *p =NULL ; +int i; - p =pci_get_domain_bus_and_slot (pci_domain_nr (adev->pdev- >bus), - adev->pdev->bus->number,1 ); -if (p) { -pm_runtime_get_sync (&p->dev); - -pm_runtime_mark_last_busy (&p->dev); -pm_runtime_put_autosuspend (&p->dev); - -pci_dev_put (p); +/* 0 - GPU +* 1 - audio +* 2 - USB +* 3 - UCSI +*/ + for (i = 1; i < 4; i++) { + p = pci_get_domain_bus_and_slot(pci_domain_nr(adev- >pdev->bus), + adev->pdev->bus->number,i);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static bool amdgpu_is_fw_framebuffer(resource_size_t base, · line 1991
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6
-0+if (p) { +pm_runtime_get_sync (&p->dev); +pm_runtime_mark_last_busy (&p->dev); +pm_runtime_put_autosuspend (&p->dev); +pci_dev_put (p); + } } }
[Quan, Evan] Although PMFW does not care the status of those functions except audio. Logically this seems more reasonable and should be harmless. Patch 3 & 4 are reviewed-by: Evan Quan <[email protected]>
Patch 1, 2, 5 are acked-by: Evan Quan <[email protected]>
Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-2@@ -2148,14 +2154,14 @@ static int amdgpu_pci_probe(struct pci_dev*pdev, * be no PMFW-aware D-state transition(D0->D3) on runpm * suspend. Thus the BACO will be not correctly kicked in. * -* Via amdgpu_get_audio_func(), the audio dev is put +* Via amdgpu_get_secondary_funcs(), the audio dev is put * into D0 state. Then there will be a PMFW-aware D-state * transition(D0->D3) on runpm suspend. */ if (amdgpu_device_supports_baco (ddev) && !(adev->flags &AMD_IS_APU ) && (adev->asic_type >=CHIP_NAVI10 )) -amdgpu_get_audio_func (adev); +amdgpu_get_secondary_funcs (adev); }return 0;
--
2.34.1
Alex Deucher
maintainerPATCH 5/5 drm/amdgpu: convert amdgpu_display_supported_domains() to IP versions
In reply to Alex DeucherCheck IP versions rather than asic types.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 29 ++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +17 -12
@@ -510,19 +510,24 @@ uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,case CHIP_STONEY : domain |=AMDGPU_GEM_DOMAIN_GTT ;break ; -case CHIP_RAVEN : -/* enable S/G on PCO and RV2 */ -if ((adev->apu_flags &AMD_APU_IS_RAVEN2 ) || - (adev->apu_flags &AMD_APU_IS_PICASSO )) - domain |=AMDGPU_GEM_DOMAIN_GTT ; -break ; -case CHIP_RENOIR : -case CHIP_VANGOGH : -case CHIP_YELLOW_CARP : - domain |=AMDGPU_GEM_DOMAIN_GTT ; -break ; -default : +switch (adev->ip_versions[DCE_HWIP ][0 ]) { +case IP_VERSION (1 ,0 ,0 ): +case IP_VERSION (1 ,0 ,1 ): +/* enable S/G on PCO and RV2 */ +if ((adev->apu_flags &AMD_APU_IS_RAVEN2 ) || + (adev->apu_flags &AMD_APU_IS_PICASSO )) + domain |=AMDGPU_GEM_DOMAIN_GTT ; +break ; +case IP_VERSION (2 ,1 ,0 ): +case IP_VERSION (3 ,0 ,1 ): +case IP_VERSION (3 ,1 ,2 ): +case IP_VERSION (3 ,1 ,3 ): + domain |=AMDGPU_GEM_DOMAIN_GTT ; +break ; +default : +break ; + }break ; } }
Signature · 1 line
2.34.1
[AMD Official Use Only]
--
Best Regards
Aaron Liu
Quoted 43 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, January 22, 2022 4:22 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 1/5] drm/amdgpu: set APU flag based on IP discovery tableUse the IP versions to set the APU flag when necessary.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +13
-1@@ -1253,6 +1253,19 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)return -EINVAL ; } +switch (adev->ip_versions[GC_HWIP ][0 ]) { +case IP_VERSION (9 ,1 ,0 ): +case IP_VERSION (9 ,2 ,2 ): +case IP_VERSION (9 ,3 ,0 ): +case IP_VERSION (10 ,1 ,3 ): +case IP_VERSION (10 ,3 ,1 ): +case IP_VERSION (10 ,3 ,3 ): + adev->flags |=AMD_IS_APU ; +break ; +default : +break ; + } +if (adev->ip_versions[XGMI_HWIP ][0 ] ==IP_VERSION (4 ,8 ,0 )) adev->gmc.xgmi.supported = true; --2.34.1