Enable BACO for power savings (v2)
Subsystems (3)
cover Enable BACO for power savings (v2)
This patch set enables BACO (Bus Active Chip Off) for power savings on VI+ asics. Similar to PowerXpress and Hybrid Graphics (PX/HG) laptops, we can disable GPUs at runtime when they are not in use is they support BACO. The runtime pm code in amdgpu was originally developed for PX/HG laptops, so it was pretty entangled with the vga_switcheroo and ACPI code. Since the GPU contains an audio codec for HDMI/DP, there is some interaction with the hda driver. I am by no means an expert on alsa, so any advice on those patches is much appreciated. I had to enable runtime pm on the hda device to allow the GPU to enter runtime pm because they are linked.
These patches depend on the clean patches and CI/VI BACO patches I sent out earlier today.
The full tree can be found here:
https://cgit.freedesktop.org/~agd5f/linux/log/?h=baco
TODO:
- Turn off runtime pm when KFD is active
- Make sure audio still works
- Make sure PX/HG still works
v2:
- Split whitespace changes from baco callback addition
- Fix pci ref counting in px/hg handling in hda driver
- Handle CONFIG_ACPI properly
- Split adding new hda pci ids from adding runpm flag
Alex Deucher (21):
drm/amdgpu: add asic callback for BACO support drm/amdgpu/soc15: move struct definition around to align with other
soc15 asics
drm/amdgpu: add supports_baco callback for soc15 asics. (v2) drm/amdgpu: add supports_baco callback for SI asics. drm/amdgpu: add supports_baco callback for CIK asics. drm/amdgpu: add supports_baco callback for VI asics. drm/amdgpu: add supports_baco callback for NV asics. drm/amdgpu: add a amdgpu_device_supports_baco helper drm/amdgpu: rename amdgpu_device_is_px to amdgpu_device_supports_boco
(v2)
drm/amdgpu: add additional boco checks to runtime suspend/resume (v2) drm/amdgpu: split swSMU baco_reset into enter and exit drm/amdgpu: add helpers for baco entry and exit drm/amdgpu: add baco support to runtime suspend/resume drm/amdgpu: start to disentangle boco from runtime pm drm/amdgpu: disentangle runtime pm and vga_switcheroo drm/amdgpu: enable runtime pm on BACO capable boards if runpm=1 drm/amdgpu/runpm: enable runpm on baco capable VI+ asics
ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD
ALSA: hda/hdmi - Add new pci ids for AMD GPU display audio
ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by
default
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 12 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 106 ++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 63 ++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 20 +++- drivers/gpu/drm/amd/amdgpu/cik.c | 18 +++ drivers/gpu/drm/amd/amdgpu/nv.c | 18 ++- drivers/gpu/drm/amd/amdgpu/si.c | 6 + drivers/gpu/drm/amd/amdgpu/soc15.c | 36 +++++- drivers/gpu/drm/amd/amdgpu/vi.c | 22 ++++ drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 20 +++- drivers/gpu/drm/amd/powerplay/arcturus_ppt.c | 3 +- .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 6 +- drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h | 3 +- drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 3 +- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 9 +- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 3 +- sound/pci/hda/hda_intel.c | 84 +++++++++++++- sound/pci/hda/patch_hdmi.c | 1 + 18 files changed, 371 insertions(+), 62 deletions(-)
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 1/21 drm/amdgpu: add asic callback for BACO support
BACO - Bus Active, Chip Off
Used to check whether the device supports BACO. This will be used to enable runtime pm on devices which support BACO.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -0
@@ -591,6 +591,8 @@ struct amdgpu_asic_funcs {bool (*need_reset_on_init)(struct amdgpu_device *adev);/* PCIe replay counter */ uint64_t (*get_pcie_replay_count)(struct amdgpu_device *adev); +/* device supports BACO */ +bool (*supports_baco)(struct amdgpu_device *adev); };/*
@@ -1118,6 +1120,8 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_asic_get_pcie_usage (adev, cnt0, cnt1) ((adev)->asic_funcs->get_pcie_usage((adev), (cnt0), (cnt1)))#define amdgpu_asic_need_reset_on_init (adev) (adev)->asic_funcs->need_reset_on_init((adev))#define amdgpu_asic_get_pcie_replay_count (adev) ((adev)->asic_funcs->get_pcie_replay_count((adev))) +#define amdgpu_asic_supports_baco (adev) (adev)->asic_funcs->supports_baco((adev)) +#define amdgpu_inc_vram_lost (adev) atomic_inc(&((adev)->vram_lost_counter));/* Common functions */
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/21 drm/amdgpu/soc15: move struct definition around to align with other soc15 asics
In reply to Alex DeucherMove reset_method next to reset callback to match the struct layout and the other definition in this file.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/soc15.c +1 -1
@@ -1007,6 +1007,7 @@ static const struct amdgpu_asic_funcs vega20_asic_funcs = .read_bios_from_rom = &soc15_read_bios_from_rom, .read_register = &soc15_read_register, .reset = &soc15_asic_reset, + .reset_method = &soc15_asic_reset_method, .set_vga_state = &soc15_vga_set_state, .get_xclk = &soc15_get_xclk, .set_uvd_clocks = &soc15_set_uvd_clocks,
@@ -1019,7 +1020,6 @@ static const struct amdgpu_asic_funcs vega20_asic_funcs = .get_pcie_usage = &vega20_get_pcie_usage, .need_reset_on_init = &soc15_need_reset_on_init, .get_pcie_replay_count = &soc15_get_pcie_replay_count, - .reset_method = &soc15_asic_reset_method };static int soc15_common_early_init (void *handle)
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/21 drm/amdgpu: add supports_baco callback for soc15 asics. (v2)
In reply to Alex DeucherBACO - Bus Active, Chip Off
Check the BACO capabilities from the powerplay table.
v2: drop unrelated struct cleanup
---
v2: drop unrelated struct cleanup
drivers/gpu/drm/amd/amdgpu/soc15.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc15.c +24 -0
@@ -599,6 +599,28 @@ static int soc15_asic_reset(struct amdgpu_device *adev) } } +static bool soc15_supports_baco (struct amdgpu_device *adev) +{ +bool baco_support; + +switch (adev->asic_type) { +case CHIP_VEGA10 : +case CHIP_VEGA12 : +soc15_asic_get_baco_capability (adev, &baco_support); +break ; +case CHIP_VEGA20 : +if (adev->psp.sos_fw_version >=0x80067 ) +soc15_asic_get_baco_capability (adev, &baco_support); +else + baco_support = false; +break ; +default : +return false; + } + +return baco_support; +} +/*static int soc15_set_uvd_clock(struct amdgpu_device *adev, u32 clock, u32 cntl_reg, u32 status_reg) {
@@ -999,6 +1021,7 @@ static const struct amdgpu_asic_funcs soc15_asic_funcs = .get_pcie_usage = &soc15_get_pcie_usage, .need_reset_on_init = &soc15_need_reset_on_init, .get_pcie_replay_count = &soc15_get_pcie_replay_count, + .supports_baco = &soc15_supports_baco, }; static const struct amdgpu_asic_funcs vega20_asic_funcs =
@@ -1020,6 +1043,7 @@ static const struct amdgpu_asic_funcs vega20_asic_funcs = .get_pcie_usage = &vega20_get_pcie_usage, .need_reset_on_init = &soc15_need_reset_on_init, .get_pcie_replay_count = &soc15_get_pcie_replay_count, + .supports_baco = &soc15_supports_baco, };static int soc15_common_early_init (void *handle)
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/21 drm/amdgpu: add supports_baco callback for SI asics.
In reply to Alex DeucherBACO - Bus Active, Chip Off
Not supported.
--- drivers/gpu/drm/amd/amdgpu/si.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/si.c +6 -0
@@ -1197,6 +1197,11 @@ static int si_asic_reset(struct amdgpu_device *adev)return 0 ; } +static bool si_asic_supports_baco (struct amdgpu_device *adev) +{ +return false; +} +static enum amd_reset_method si_asic_reset_method (struct amdgpu_device *adev) {
@@ -1425,6 +1430,7 @@ static const struct amdgpu_asic_funcs si_asic_funcs = .get_pcie_usage = &si_get_pcie_usage, .need_reset_on_init = &si_need_reset_on_init, .get_pcie_replay_count = &si_get_pcie_replay_count, + .supports_baco = &si_asic_supports_baco, };static uint32_t si_get_rev_id (struct amdgpu_device *adev)
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/21 drm/amdgpu: add supports_baco callback for CIK asics.
In reply to Alex DeucherBACO - Bus Active, Chip Off
Check the BACO capabilities from the powerplay table.
--- drivers/gpu/drm/amd/amdgpu/cik.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/gpu/drm/amd/amdgpu/cik.c +18 -0
@@ -1310,6 +1310,23 @@ static int cik_asic_pci_config_reset(struct amdgpu_device *adev)return r; } +static bool cik_asic_supports_baco (struct amdgpu_device *adev) +{ +bool baco_support; + +switch (adev->asic_type) { +case CHIP_BONAIRE : +case CHIP_HAWAII : +smu7_asic_get_baco_capability (adev, &baco_support); +break ; +default : + baco_support = false; +break ; + } + +return baco_support; +} +static enum amd_reset_method cik_asic_reset_method (struct amdgpu_device *adev) {
@@ -1899,6 +1916,7 @@ static const struct amdgpu_asic_funcs cik_asic_funcs = .get_pcie_usage = &cik_get_pcie_usage, .need_reset_on_init = &cik_need_reset_on_init, .get_pcie_replay_count = &cik_get_pcie_replay_count, + .supports_baco = &cik_asic_supports_baco, };static int cik_common_early_init (void *handle)
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/21 drm/amdgpu: add supports_baco callback for VI asics.
In reply to Alex DeucherBACO - Bus Active, Chip Off
Check the BACO capabilities from the powerplay table.
--- drivers/gpu/drm/amd/amdgpu/vi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/gpu/drm/amd/amdgpu/vi.c +22 -0
@@ -745,6 +745,27 @@ static int vi_asic_pci_config_reset(struct amdgpu_device *adev)return r; } +static bool vi_asic_supports_baco (struct amdgpu_device *adev) +{ +bool baco_support; + +switch (adev->asic_type) { +case CHIP_FIJI : +case CHIP_TONGA : +case CHIP_POLARIS10 : +case CHIP_POLARIS11 : +case CHIP_POLARIS12 : +case CHIP_TOPAZ : +smu7_asic_get_baco_capability (adev, &baco_support); +break ; +default : + baco_support = false; +break ; + } + +return baco_support; +} +static enum amd_reset_method vi_asic_reset_method (struct amdgpu_device *adev) {
@@ -1116,6 +1137,7 @@ static const struct amdgpu_asic_funcs vi_asic_funcs = .get_pcie_usage = &vi_get_pcie_usage, .need_reset_on_init = &vi_need_reset_on_init, .get_pcie_replay_count = &vi_get_pcie_replay_count, + .supports_baco = &vi_asic_supports_baco, };#define CZ_REV_BRISTOL (rev) \
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/21 drm/amdgpu: add supports_baco callback for NV asics.
In reply to Alex DeucherBACO - Bus Active, Chip Off
Check the BACO capabilities from the powerplay table.
--- drivers/gpu/drm/amd/amdgpu/nv.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/amd/amdgpu/nv.c +11 -0
@@ -294,6 +294,16 @@ static int nv_asic_mode1_reset(struct amdgpu_device *adev)return ret; } +static bool nv_asic_supports_baco (struct amdgpu_device *adev) +{ +struct smu_context *smu = &adev->smu; + +if (smu_baco_is_support (smu)) +return true; +else +return false; +} +static enum amd_reset_method nv_asic_reset_method (struct amdgpu_device *adev) {
@@ -586,6 +596,7 @@ static const struct amdgpu_asic_funcs nv_asic_funcs = .need_full_reset = &nv_need_full_reset, .get_pcie_usage = &nv_get_pcie_usage, .need_reset_on_init = &nv_need_reset_on_init, + .supports_baco = &nv_asic_supports_baco, };static int nv_common_early_init (void *handle)
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/21 drm/amdgpu: add a amdgpu_device_supports_baco helper
In reply to Alex DeucherBACO - Bus Active, Chip Off
To check if a device supports BACO or not. This will be used in determining when to enable runtime pm.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -1139,6 +1139,7 @@ void amdgpu_device_program_register_sequence(struct amdgpu_device *adev, const u32 array_size);bool amdgpu_device_is_px (struct drm_device *dev); +bool amdgpu_device_supports_baco (struct drm_device *dev);bool amdgpu_device_is_peer_accessible (struct amdgpu_device *adev,struct amdgpu_device *peer_adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +15 -0
@@ -154,6 +154,21 @@ bool amdgpu_device_is_px(struct drm_device *dev)return false; } +/** +* amdgpu_device_supports_baco - Does the device support BACO +* +* @dev: drm_device pointer +* +* Returns true if the device supporte BACO, +* otherwise return false. +*/ +bool amdgpu_device_supports_baco (struct drm_device *dev) +{ +struct amdgpu_device *adev = dev->dev_private; + +return amdgpu_asic_supports_baco (adev); +} +/** * VRAM access helper functions. *
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/21 drm/amdgpu: rename amdgpu_device_is_px to amdgpu_device_supports_boco (v2)
In reply to Alex DeucherBACO - Bus Active, Chip Off
BOCO - Bus Off, Chip Off
To better match what we are checking for and to align with amdgpu_device_supports_baco.
BOCO is used on PowerXpress/Hybrid Graphics systems and BACO is used on desktop dGPU boards.
v2: fix typo in documentation
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
@@ -1138,7 +1138,7 @@ void amdgpu_device_program_register_sequence(struct amdgpu_device *adev,const u32 *registers, const u32 array_size); -bool amdgpu_device_is_px (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,struct amdgpu_device *peer_adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -4
@@ -138,14 +138,14 @@ static DEVICE_ATTR(pcie_replay_count, S_IRUGO,static void amdgpu_device_get_pcie_info (struct amdgpu_device *adev);/** -* amdgpu_device_is_px - Is the device is a dGPU with HG/PX power control +* amdgpu_device_supports_boco - 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_is_px (struct drm_device *dev) +bool amdgpu_device_supports_boco (struct drm_device *dev) {struct amdgpu_device *adev = dev->dev_private;
@@ -1091,7 +1091,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero {struct drm_device *dev =pci_get_drvdata (pdev); -if (amdgpu_device_is_px (dev) && state ==VGA_SWITCHEROO_OFF ) +if (amdgpu_device_supports_boco (dev) && state ==VGA_SWITCHEROO_OFF )return ;if (state ==VGA_SWITCHEROO_ON ) {
@@ -2881,7 +2881,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,* ignore it */ vga_client_register (adev->pdev, adev,NULL , amdgpu_device_vga_set_decode); -if (amdgpu_device_is_px (ddev)) +if (amdgpu_device_supports_boco (ddev)) runtime = true;if (!pci_is_thunderbolt_attached (adev->pdev)) vga_switcheroo_register_client(adev->pdev,
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -4
@@ -1164,7 +1164,7 @@ static int amdgpu_pmops_resume(struct device *dev)struct drm_device *drm_dev =dev_get_drvdata (dev);/* GPU comes up enabled by the bios on resume */ -if (amdgpu_device_is_px (drm_dev)) { +if (amdgpu_device_supports_boco (drm_dev)) {pm_runtime_disable (dev);pm_runtime_set_active (dev);pm_runtime_enable (dev);
@@ -1212,7 +1212,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)struct drm_device *drm_dev =pci_get_drvdata (pdev);int ret; -if (!amdgpu_device_is_px (drm_dev)) { +if (!amdgpu_device_supports_boco (drm_dev)) {pm_runtime_forbid (dev);return -EBUSY ; }
@@ -1239,7 +1239,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)struct drm_device *drm_dev =pci_get_drvdata (pdev);int ret; -if (!amdgpu_device_is_px (drm_dev)) +if (!amdgpu_device_supports_boco (drm_dev))return -EINVAL ; drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;
@@ -1264,7 +1264,7 @@ static int amdgpu_pmops_runtime_idle(struct device *dev)struct drm_device *drm_dev =dev_get_drvdata (dev);struct drm_crtc *crtc; -if (!amdgpu_device_is_px (drm_dev)) { +if (!amdgpu_device_supports_boco (drm_dev)) {pm_runtime_forbid (dev);return -EBUSY ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -3
@@ -91,7 +91,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)if (amdgpu_sriov_vf (adev))amdgpu_virt_request_full_gpu (adev, false); -if (amdgpu_device_is_px (dev)) { +if (amdgpu_device_supports_boco (dev)) {pm_runtime_get_sync (dev->dev);pm_runtime_forbid (dev->dev); }
@@ -180,7 +180,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) "Error during ACPI methods call\n"); } -if (amdgpu_device_is_px (dev)) { +if (amdgpu_device_supports_boco (dev)) {dev_pm_set_driver_flags (dev->dev,DPM_FLAG_NEVER_SKIP );pm_runtime_use_autosuspend (dev->dev);pm_runtime_set_autosuspend_delay (dev->dev,5000 );
@@ -194,7 +194,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) out:if (r) {/* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */ -if (adev->rmmio &&amdgpu_device_is_px (dev)) +if (adev->rmmio &&amdgpu_device_supports_boco (dev))pm_runtime_put_noidle (dev->dev);amdgpu_driver_unload_kms (dev); }
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/21 drm/amdgpu: add additional boco checks to runtime suspend/resume (v2)
In reply to Alex DeucherBACO - Bus Active, Chip Off
BOCO - Bus Off, Chip Off
We will take slightly different paths for boco and baco.
v2: fold together two consecutive if clauses
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 47 ++++++++++++++----------- 1 file changed, 26 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +26 -21
@@ -1217,18 +1217,21 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)return -EBUSY ; } - drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; +if (amdgpu_device_supports_boco (drm_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); -pci_save_state (pdev); -pci_disable_device (pdev); -pci_ignore_hotplug (pdev); -if (amdgpu_is_atpx_hybrid ()) -pci_set_power_state (pdev, PCI_D3cold); -else if (!amdgpu_has_atpx_dgpu_power_cntl ()) -pci_set_power_state (pdev, PCI_D3hot); - drm_dev->switch_power_state =DRM_SWITCH_POWER_DYNAMIC_OFF ; +if (amdgpu_device_supports_boco (drm_dev)) { +pci_save_state (pdev); +pci_disable_device (pdev); +pci_ignore_hotplug (pdev); +if (amdgpu_is_atpx_hybrid ()) +pci_set_power_state (pdev, PCI_D3cold); +else if (!amdgpu_has_atpx_dgpu_power_cntl ()) +pci_set_power_state (pdev, PCI_D3hot); + drm_dev->switch_power_state =DRM_SWITCH_POWER_DYNAMIC_OFF ; + }return 0 ; }
@@ -1242,20 +1245,22 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)if (!amdgpu_device_supports_boco (drm_dev))return -EINVAL ; - drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; - -if (amdgpu_is_atpx_hybrid () || - !amdgpu_has_atpx_dgpu_power_cntl ()) -pci_set_power_state (pdev,PCI_D0 ); -pci_restore_state (pdev); - ret =pci_enable_device (pdev); -if (ret) -return ret; -pci_set_master (pdev); - +if (amdgpu_device_supports_boco (drm_dev)) { + drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; + +if (amdgpu_is_atpx_hybrid () || + !amdgpu_has_atpx_dgpu_power_cntl ()) +pci_set_power_state (pdev,PCI_D0 ); +pci_restore_state (pdev); + ret =pci_enable_device (pdev); +if (ret) +return ret; +pci_set_master (pdev); + } ret =amdgpu_device_resume (drm_dev, false, false);drm_kms_helper_poll_enable (drm_dev); - drm_dev->switch_power_state =DRM_SWITCH_POWER_ON ; +if (amdgpu_device_supports_boco (drm_dev)) + drm_dev->switch_power_state =DRM_SWITCH_POWER_ON ;return 0 ; }
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 11/21 drm/amdgpu: split swSMU baco_reset into enter and exit
In reply to Alex DeucherBACO - Bus Active, Chip Off
So we can use it for power savings rather than just reset.
--- drivers/gpu/drm/amd/amdgpu/nv.c | 7 ++++++- drivers/gpu/drm/amd/amdgpu/soc15.c | 10 ++++++++-- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 20 ++++++++++++++++--- drivers/gpu/drm/amd/powerplay/arcturus_ppt.c | 3 ++- .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 6 ++++-- drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h | 3 ++- drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 3 ++- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 9 ++++++++- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 3 ++- 9 files changed, 51 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/nv.c +6 -1
@@ -332,7 +332,12 @@ static int nv_asic_reset(struct amdgpu_device *adev)if (nv_asic_reset_method (adev) ==AMD_RESET_METHOD_BACO ) {if (!adev->in_suspend)amdgpu_inc_vram_lost (adev); - ret =smu_baco_reset (smu); + ret =smu_baco_enter (smu); +if (ret) +return ret; + ret =smu_baco_exit (smu); +if (ret) +return ret; }else {if (!adev->in_suspend)amdgpu_inc_vram_lost (adev);
drivers/gpu/drm/amd/amdgpu/soc15.c +8 -2
@@ -509,9 +509,15 @@ static int soc15_asic_baco_reset(struct amdgpu_device *adev)if (is_support_sw_smu (adev)) {struct smu_context *smu = &adev->smu; +int ret; -if (smu_baco_reset (smu)) -return -EIO ; + ret =smu_baco_enter (smu); +if (ret) +return ret; + + ret =smu_baco_exit (smu); +if (ret) +return ret; }else {void *pp_handle = adev->powerplay.pp_handle;const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +17 -3
@@ -2413,14 +2413,28 @@ int smu_baco_get_state(struct smu_context *smu, enum smu_baco_state *state)return 0 ; } -int smu_baco_reset (struct smu_context *smu) +int smu_baco_enter (struct smu_context *smu) {int ret =0 ;mutex_lock (&smu->mutex); -if (smu->ppt_funcs->baco_reset) - ret = smu->ppt_funcs->baco_reset (smu); +if (smu->ppt_funcs->baco_enter) + ret = smu->ppt_funcs->baco_enter (smu); + +mutex_unlock (&smu->mutex); + +return ret; +} + +int smu_baco_exit (struct smu_context *smu) +{ +int ret =0 ; + +mutex_lock (&smu->mutex); + +if (smu->ppt_funcs->baco_exit) + ret = smu->ppt_funcs->baco_exit (smu);mutex_unlock (&smu->mutex);
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c +2 -1
@@ -2156,7 +2156,8 @@ static const struct pptable_funcs arcturus_ppt_funcs = { .baco_is_support= smu_v11_0_baco_is_support, .baco_get_state = smu_v11_0_baco_get_state, .baco_set_state = smu_v11_0_baco_set_state, - .baco_reset = smu_v11_0_baco_reset, + .baco_enter = smu_v11_0_baco_enter, + .baco_exit = smu_v11_0_baco_exit, .get_dpm_ultimate_freq = smu_v11_0_get_dpm_ultimate_freq, .set_soft_freq_limited_range = smu_v11_0_set_soft_freq_limited_range, .override_pcie_parameters = smu_v11_0_override_pcie_parameters,
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -2
@@ -543,7 +543,8 @@ struct pptable_funcs {bool (*baco_is_support)(struct smu_context *smu);enum smu_baco_state (*baco_get_state)(struct smu_context *smu);int (*baco_set_state)(struct smu_context *smu,enum smu_baco_state state); -int (*baco_reset)(struct smu_context *smu); +int (*baco_enter)(struct smu_context *smu); +int (*baco_exit)(struct smu_context *smu);int (*mode2_reset)(struct smu_context *smu);int (*get_dpm_ultimate_freq)(struct smu_context *smu,enum smu_clk_type clk_type,uint32_t *min,uint32_t *max);int (*set_soft_freq_limited_range)(struct smu_context *smu,enum smu_clk_type clk_type,uint32_t min,uint32_t max);
@@ -624,7 +625,8 @@ bool smu_baco_is_support(struct smu_context *smu);int smu_baco_get_state (struct smu_context *smu,enum smu_baco_state *state); -int smu_baco_reset (struct smu_context *smu); +int smu_baco_enter (struct smu_context *smu); +int smu_baco_exit (struct smu_context *smu);int smu_mode2_reset (struct smu_context *smu);
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h +2 -1
@@ -240,7 +240,8 @@ enum smu_baco_state smu_v11_0_baco_get_state(struct smu_context *smu);int smu_v11_0_baco_set_state (struct smu_context *smu,enum smu_baco_state state); -int smu_v11_0_baco_reset (struct smu_context *smu); +int smu_v11_0_baco_enter (struct smu_context *smu); +int smu_v11_0_baco_exit (struct smu_context *smu);int smu_v11_0_get_dpm_ultimate_freq (struct smu_context *smu,enum smu_clk_type clk_type,uint32_t *min,uint32_t *max);
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +2 -1
@@ -1738,7 +1738,8 @@ static const struct pptable_funcs navi10_ppt_funcs = { .baco_is_support= smu_v11_0_baco_is_support, .baco_get_state = smu_v11_0_baco_get_state, .baco_set_state = smu_v11_0_baco_set_state, - .baco_reset = smu_v11_0_baco_reset, + .baco_enter = smu_v11_0_baco_enter, + .baco_exit = smu_v11_0_baco_exit, .get_dpm_ultimate_freq = smu_v11_0_get_dpm_ultimate_freq, .set_soft_freq_limited_range = smu_v11_0_set_soft_freq_limited_range, .override_pcie_parameters = smu_v11_0_override_pcie_parameters,
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +8 -1
@@ -1655,7 +1655,7 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state)return ret; } -int smu_v11_0_baco_reset (struct smu_context *smu) +int smu_v11_0_baco_enter (struct smu_context *smu) {int ret =0 ;
@@ -1669,6 +1669,13 @@ int smu_v11_0_baco_reset(struct smu_context *smu)msleep (10 ); +return ret; +} + +int smu_v11_0_baco_exit (struct smu_context *smu) +{ +int ret =0 ; + ret =smu_v11_0_baco_set_state (smu,SMU_BACO_STATE_EXIT );if (ret)return ret;
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +2 -1
@@ -3258,7 +3258,8 @@ static const struct pptable_funcs vega20_ppt_funcs = { .baco_is_support= smu_v11_0_baco_is_support, .baco_get_state = smu_v11_0_baco_get_state, .baco_set_state = smu_v11_0_baco_set_state, - .baco_reset = smu_v11_0_baco_reset, + .baco_enter = smu_v11_0_baco_enter, + .baco_exit = smu_v11_0_baco_exit, .get_dpm_ultimate_freq = smu_v11_0_get_dpm_ultimate_freq, .set_soft_freq_limited_range = smu_v11_0_set_soft_freq_limited_range, .override_pcie_parameters = smu_v11_0_override_pcie_parameters,
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 12/21 drm/amdgpu: add helpers for baco entry and exit
In reply to Alex DeucherBACO - Bus Active, Chip Off
Will be used for runtime pm. Entry will enter the BACO state (chip off). Exit will exit the BACO state (chip on).
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 61 ++++++++++++++++++++++ 2 files changed, 63 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1142,6 +1142,8 @@ 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,struct amdgpu_device *peer_adev); +int amdgpu_device_baco_enter (struct drm_device *dev); +int amdgpu_device_baco_exit (struct drm_device *dev);/* atpx handler */ #if defined(CONFIG_VGA_SWITCHEROO )
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +61 -0
64 lines not on this page · raw message
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 13/21 drm/amdgpu: add baco support to runtime suspend/resume
In reply to Alex DeucherBACO - Bus Active, Chip Off
This adds the necessary support to the runtime suspend and resume functions to handle boards that support baco.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -1
@@ -1164,7 +1164,8 @@ static int amdgpu_pmops_resume(struct device *dev)struct drm_device *drm_dev =dev_get_drvdata (dev);/* GPU comes up enabled by the bios on resume */ -if (amdgpu_device_supports_boco (drm_dev)) { +if (amdgpu_device_supports_boco (drm_dev) || +amdgpu_device_supports_baco (drm_dev)) {pm_runtime_disable (dev);pm_runtime_set_active (dev);pm_runtime_enable (dev);
@@ -1231,6 +1232,8 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)else if (!amdgpu_has_atpx_dgpu_power_cntl ())pci_set_power_state (pdev, PCI_D3hot); drm_dev->switch_power_state =DRM_SWITCH_POWER_DYNAMIC_OFF ; + }else if (amdgpu_device_supports_baco (drm_dev)) { +amdgpu_device_baco_enter (drm_dev); }return 0 ;
@@ -1256,6 +1259,8 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)if (ret)return ret;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, false);drm_kms_helper_poll_enable (drm_dev);
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 14/21 drm/amdgpu: start to disentangle boco from runtime pm
In reply to Alex DeucherBACO - Bus Active, Chip Off
BOCO - Bus Off, Chip Off
We originally only supported runtime pm on PX/HG laptops so most of the runtime pm code looks for this. Add a new flag to check for runtime pm enablement and use this rather than checking for PX/HG.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 ++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 13 ++++++++----- 3 files changed, 17 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
@@ -985,6 +985,9 @@ struct amdgpu_device {uint64_t unique_id;uint64_t df_perfmon_config_assign_mask[AMDGPU_MAX_DF_PERFMONS ]; + +/* enable runtime pm on the device */ +bool runpm; };static inline struct amdgpu_device *amdgpu_ttm_adev (struct ttm_bo_device *bdev)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -3
@@ -1211,9 +1211,10 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct amdgpu_device *adev = drm_dev->dev_private;int ret; -if (!amdgpu_device_supports_boco (drm_dev)) { +if (!adev->runpm) {pm_runtime_forbid (dev);return -EBUSY ; }
@@ -1243,9 +1244,10 @@ static int amdgpu_pmops_runtime_resume(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct amdgpu_device *adev = drm_dev->dev_private;int ret; -if (!amdgpu_device_supports_boco (drm_dev)) +if (!adev->runpm)return -EINVAL ;if (amdgpu_device_supports_boco (drm_dev)) {
@@ -1272,9 +1274,10 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)static int amdgpu_pmops_runtime_idle (struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); +struct amdgpu_device *adev = drm_dev->dev_private;struct drm_crtc *crtc; -if (!amdgpu_device_supports_boco (drm_dev)) { +if (!adev->runpm) {pm_runtime_forbid (dev);return -EBUSY ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +8 -5
@@ -91,7 +91,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)if (amdgpu_sriov_vf (adev))amdgpu_virt_request_full_gpu (adev, false); -if (amdgpu_device_supports_boco (dev)) { +if (adev->runpm) {pm_runtime_get_sync (dev->dev);pm_runtime_forbid (dev->dev); }
@@ -150,14 +150,17 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) } dev->dev_private = (void *)adev; -if ((amdgpu_runtime_pm !=0 ) && -amdgpu_has_atpx () && +if (amdgpu_has_atpx () && (amdgpu_is_atpx_hybrid () ||amdgpu_has_atpx_dgpu_power_cntl ()) && ((flags &AMD_IS_APU ) ==0 ) && !pci_is_thunderbolt_attached (dev->pdev)) flags |=AMD_IS_PX ; +if ((amdgpu_runtime_pm !=0 ) && + (flags &AMD_IS_PX )) + adev->runpm = true; +/* amdgpu_device_init should report only fatal error * like memory allocation failure or iomapping failure, * or memory manager initialization failure, it must
@@ -180,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) "Error during ACPI methods call\n"); } -if (amdgpu_device_supports_boco (dev)) { +if (adev->runpm) {dev_pm_set_driver_flags (dev->dev,DPM_FLAG_NEVER_SKIP );pm_runtime_use_autosuspend (dev->dev);pm_runtime_set_autosuspend_delay (dev->dev,5000 );
@@ -194,7 +197,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) out:if (r) {/* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */ -if (adev->rmmio &&amdgpu_device_supports_boco (dev)) +if (adev->rmmio && adev->runpm)pm_runtime_put_noidle (dev->dev);amdgpu_driver_unload_kms (dev); }
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 15/21 drm/amdgpu: disentangle runtime pm and vga_switcheroo
In reply to Alex DeucherOriginally we only supported runtime pm on PX/HG laptops so vga_switcheroo and runtime pm are sort of entangled.
Attempt to logically separate them.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +14 -8
@@ -2711,7 +2711,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, uint32_t flags) {int r, i; -bool runtime = false; +bool boco = false;u32 max_MBps; adev->shutdown = false;
@@ -2882,11 +2882,14 @@ int amdgpu_device_init(struct amdgpu_device *adev,vga_client_register (adev->pdev, adev,NULL , amdgpu_device_vga_set_decode);if (amdgpu_device_supports_boco (ddev)) - runtime = true; -if (!pci_is_thunderbolt_attached (adev->pdev)) + boco = 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, runtime); -if (runtime) + &amdgpu_switcheroo_ops, boco); +if (boco)vga_switcheroo_init_domain_pm_ops (adev->dev, &adev->vga_pm_domain);if (amdgpu_emu_mode ==1 ) {
@@ -3063,7 +3066,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, failed:amdgpu_vf_error_trans_all (adev); -if (runtime) +if (boco)vga_switcheroo_fini_domain_pm_ops (adev->dev);return r;
@@ -3110,9 +3113,12 @@ void amdgpu_device_fini(struct amdgpu_device *adev)kfree (adev->bios); adev->bios =NULL ; -if (!pci_is_thunderbolt_attached (adev->pdev)) +if (amdgpu_has_atpx () && + (amdgpu_is_atpx_hybrid () || +amdgpu_has_atpx_dgpu_power_cntl ()) && + !pci_is_thunderbolt_attached (adev->pdev))vga_switcheroo_unregister_client (adev->pdev); -if (adev->flags &AMD_IS_PX ) +if (amdgpu_device_supports_boco (adev->ddev))vga_switcheroo_fini_domain_pm_ops (adev->dev);vga_client_register (adev->pdev,NULL ,NULL ,NULL );if (adev->rio_mem)
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 16/21 drm/amdgpu: enable runtime pm on BACO capable boards if runpm=1
In reply to Alex DeucherBACO - Bus Active, Chip Off
Everything is in place now. Not enabled by default yet. You still have to specify runpm=1.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -4
@@ -157,10 +157,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) !pci_is_thunderbolt_attached(dev->pdev)) flags |=AMD_IS_PX ; -if ((amdgpu_runtime_pm !=0 ) && - (flags &AMD_IS_PX )) - adev->runpm = true; -/* amdgpu_device_init should report only fatal error * like memory allocation failure or iomapping failure, * or memory manager initialization failure, it must
@@ -173,6 +169,13 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) goto out; } +if (amdgpu_device_supports_boco (dev) && + (amdgpu_runtime_pm !=0 ))/* enable runpm by default */ + adev->runpm = true; +else if (amdgpu_device_supports_baco (dev) && + (amdgpu_runtime_pm >0 ))/* enable runpm if runpm=1 */ + adev->runpm = true; +/* Call ACPI methods: require modeset init * but failure is not fatal */
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 17/21 drm/amdgpu/runpm: enable runpm on baco capable VI+ asics
In reply to Alex DeucherBACO - Bus Active, Chip Off
Seems to work reliably on VI+.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +6 -2
@@ -170,10 +170,14 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) }if (amdgpu_device_supports_boco (dev) && - (amdgpu_runtime_pm !=0 ))/* enable runpm by default */ + (amdgpu_runtime_pm !=0 ))/* enable runpm by default for boco */ adev->runpm = true;else if (amdgpu_device_supports_baco (dev) && - (amdgpu_runtime_pm >0 ))/* enable runpm if runpm=1 */ + (amdgpu_runtime_pm !=0 ) && + (adev->asic_type >=CHIP_TOPAZ ))/* enable runpm by default on VI+ */ + adev->runpm = true; +else if (amdgpu_device_supports_baco (dev) && + (amdgpu_runtime_pm >0 ))/* enable runpm if runpm=1 on CI */ adev->runpm = true;/* Call ACPI methods: require modeset init
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 18/21 ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD
In reply to Alex DeucherOnly enable the vga_switcheroo logic on systems with the ATPX ACPI method. This logic is not needed for asics that are not part of a PX (PowerXpress)/HG (Hybrid Graphics) platform.
---
v2:
- check CONFIG_ACPI
- fix pci ref logic
sound/pci/hda/hda_intel.c | 49 +++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
sound/pci/hda/hda_intel.c +49 -0
@@ -35,6 +35,11 @@#include <linux/clocksource.h> #include <linux/time.h> #include <linux/completion.h> +#ifdef SUPPORT_VGA_SWITCHEROO +#ifdef CONFIG_ACPI +#include <linux/acpi.h> +#endif +#endif #ifdef CONFIG_X86 /* for snoop control */
@@ -1345,6 +1350,34 @@ static int azx_dev_free(struct snd_device *device) }#ifdef SUPPORT_VGA_SWITCHEROO +#ifdef CONFIG_ACPI +/* ATPX is in the integrated GPU's namespace */ +static bool atpx_present (void ) +{ +struct pci_dev *pdev =NULL ; +acpi_handle dhandle, atpx_handle; +acpi_status status; + +while ((pdev =pci_get_class (PCI_BASE_CLASS_DISPLAY <<16 , pdev)) !=NULL ) { + dhandle =ACPI_HANDLE (&pdev->dev); +if (dhandle) { + status =acpi_get_handle (dhandle,"ATPX" , &atpx_handle); +if (!ACPI_FAILURE (status)) { +pci_dev_put (pdev); +return true; + } + } +pci_dev_put (pdev); + } +return false; +} +#else +static bool atpx_present (void ) +{ +return false; +} +#endif +/* * Check of disabled HDMI controller by vga_switcheroo */
@@ -1356,6 +1389,22 @@ static struct pci_dev *get_bound_vga(struct pci_dev *pci)switch (pci->vendor) {case PCI_VENDOR_ID_ATI :case PCI_VENDOR_ID_AMD : +if (pci->devfn ==1 ) { + p =pci_get_domain_bus_and_slot (pci_domain_nr (pci->bus), + pci->bus->number,0 ); +if (p) { +/* ATPX is in the integrated GPU's ACPI namespace +* rather than the dGPU's namespace. However, +* the dGPU is the one who is involved in +* vgaswitcheroo. +*/ +if (((p->class >>16 ) ==PCI_BASE_CLASS_DISPLAY ) && +atpx_present ()) +return p; +pci_dev_put (p); + } + } +break ;case PCI_VENDOR_ID_NVIDIA :if (pci->devfn ==1 ) { p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [alsa-devel] [PATCH 18/21] ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD
sound/pci/hda/hda_intel.c line 42
Quoted 10 lines · Alex Deucher
sound/pci/hda/hda_intel.c +5
-0@@ -35,6 +35,11 @@#include <linux/clocksource.h> #include <linux/time.h> #include <linux/completion.h> +#ifdef SUPPORT_VGA_SWITCHEROO +#ifdef CONFIG_ACPI +#include <linux/acpi.h> +#endif +#endif
I don't think we need ifdefs here.
Other than that,
thanks,
Takashi
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 19/21 ALSA: hda/hdmi - Add new pci ids for AMD GPU display audio
In reply to Alex DeucherThese are needed so we can enable runtime pm in a subsequent patch.
--- sound/pci/hda/hda_intel.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
sound/pci/hda/hda_intel.c +14 -0
@@ -2579,6 +2579,20 @@ static const struct pci_device_id azx_ids[] = { .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, { PCI_DEVICE(0x1002, 0xaaf0), .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + { PCI_DEVICE(0x1002, 0xaaf8), + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + { PCI_DEVICE(0x1002, 0xab00), + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + { PCI_DEVICE(0x1002, 0xab08), + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + { PCI_DEVICE(0x1002, 0xab10), + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + { PCI_DEVICE(0x1002, 0xab18), + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + { PCI_DEVICE(0x1002, 0xab20), + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + { PCI_DEVICE(0x1002, 0xab38), + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, /* VIA VT8251/VT8237A */ { PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },/* VIA GFX VT7122/VX900 */
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [alsa-devel] [PATCH 19/21] ALSA: hda/hdmi - Add new pci ids for AMD GPU display audio
Quoted 5 lines · Alex Deucher
These are needed so we can enable runtime pm in a subsequent patch.
Signed-off-by Alex Deucher <[email protected]>
thanks,
Takashi
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 20/21 ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
In reply to Alex DeucherWe are able to power down the GPU and audio via the GPU driver so flag these asics as supporting runtime pm.
---
v2:
- split out adding the new pci ids
sound/pci/hda/hda_intel.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-)
sound/pci/hda/hda_intel.c +23 -12
@@ -2572,27 +2572,38 @@ static const struct pci_device_id azx_ids[] = { { PCI_DEVICE(0x1002, 0xaac8), .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, { PCI_DEVICE(0x1002, 0xaad8), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, - { PCI_DEVICE(0x1002, 0xaae8), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, { PCI_DEVICE(0x1002, 0xaae0), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xaae8), + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, { PCI_DEVICE(0x1002, 0xaaf0), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, { PCI_DEVICE(0x1002, 0xaaf8), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, { PCI_DEVICE(0x1002, 0xab00), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, { PCI_DEVICE(0x1002, 0xab08), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, { PCI_DEVICE(0x1002, 0xab10), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, { PCI_DEVICE(0x1002, 0xab18), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, { PCI_DEVICE(0x1002, 0xab20), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, { PCI_DEVICE(0x1002, 0xab38), - .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, /* VIA VT8251/VT8237A */ { PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },/* VIA GFX VT7122/VX900 */
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [alsa-devel] [PATCH 20/21] ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
Quoted 10 lines · Alex Deucher
We are able to power down the GPU and audio via the GPU driver so flag these asics as supporting runtime pm.
Acked-by Evan Quan <[email protected]>Signed-off-by Alex Deucher <[email protected]>---
v2:
- split out adding the new pci ids
thanks,
Takashi
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 21/21 ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by default
In reply to Alex DeucherSo that we can power down the GPU and audio to save power.
--- sound/pci/hda/patch_hdmi.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_hdmi.c +1 -0
@@ -3779,6 +3779,7 @@ static int atihdmi_init(struct hda_codec *codec)ATI_VERB_SET_MULTICHANNEL_MODE , ATI_MULTICHANNEL_MODE_SINGLE); } + codec->auto_runtime_pm =1 ;return 0 ; }
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [alsa-devel] [PATCH 21/21] ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by default
Quoted 5 lines · Alex Deucher
So that we can power down the GPU and audio to save power.
Acked-by Evan Quan <[email protected]>Signed-off-by Alex Deucher <[email protected]>
thanks,
Takashi
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx