Enable BACO for power savings
Subsystems (3)
cover Enable BACO for power savings
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
Alex Deucher (19):
drm/amdgpu: add asic callback for BACO support
drm/amdgpu: add supports_baco callback for soc15 asics. 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 drm/amdgpu: add additional boco checks to runtime suspend/resume 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 - 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 | 64 ++++++----- 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 | 37 +++++- drivers/gpu/drm/amd/amdgpu/vi.c | 22 ++++ .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 9 +- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 12 +- sound/pci/hda/hda_intel.c | 74 +++++++++++- sound/pci/hda/patch_hdmi.c | 1 + 13 files changed, 343 insertions(+), 56 deletions(-)
Signature · 6 lines
2.20.1 _______________________________________________ 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): 20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org
PATCH 1/19 drm/amdgpu: add asic callback for BACO support
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
@@ -583,6 +583,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); };/*
@@ -1099,6 +1101,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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/19 drm/amdgpu: add supports_baco callback for soc15 asics.
In reply to a message not in the archiveCheck the BACO capabilities from the powerplay table.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/soc15.c +25 -1
@@ -589,6 +589,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) {
@@ -989,6 +1011,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 =
@@ -997,6 +1020,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,
@@ -1009,7 +1033,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, - .reset_method = &soc15_asic_reset_method + .supports_baco = &soc15_supports_baco, };static int soc15_common_early_init (void *handle)
Signature · 6 lines
2.20.1 _______________________________________________ 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): 20191011014536.10869-3-alexander.deucher-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 02/19] drm/amdgpu: add supports_baco callback for soc15 asics.
Quoted 3 lines · Alex Deucher
Check the BACO capabilities from the powerplay table.
Signed-off-by Alex Deucher <[email protected]>
[...]
drivers/gpu/drm/amd/amdgpu/soc15.c static const struct amdgpu_asic_funcs vega20_asic_funcs = · line 1012
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/soc15.c +1
-1@@ -997,6 +1020,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,@@ -1009,7 +1033,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, - .reset_method = &soc15_asic_reset_method
Seemingly unrelated change without explanation.
_______________________________________________
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): 20191012114527.akspejxsm3hvrzil-JFq808J9C/[email protected]
Re: [PATCH 02/19] drm/amdgpu: add supports_baco callback for soc15 asics.
Quoted 6 lines · Lukas Wunner
Quoted 3 lines · Alex Deucher
Check the BACO capabilities from the powerplay table.
Signed-off-by Alex Deucher <[email protected]>[...]
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/soc15.c static const struct amdgpu_asic_funcs vega20_asic_funcs = · line 1012
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/soc15.c +1
-1@@ -997,6 +1020,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,@@ -1009,7 +1033,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, - .reset_method = &soc15_asic_reset_methodSeemingly unrelated change without explanation.
Just moves the setting of that callback to better align with the struct definition and other other structs defined in this fine. I can drop it.
Alex
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/19 drm/amdgpu: add supports_baco callback for SI asics.
In reply to a message not in the archiveNot supported.
--- drivers/gpu/drm/amd/amdgpu/si.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/si.c +6 -0
@@ -1186,6 +1186,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) {
@@ -1414,6 +1419,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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/19 drm/amdgpu: add supports_baco callback for CIK asics.
In reply to a message not in the archiveCheck 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
@@ -1291,6 +1291,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) {
@@ -1880,6 +1897,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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/19 drm/amdgpu: add supports_baco callback for VI asics.
In reply to a message not in the archiveCheck 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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/19 drm/amdgpu: add supports_baco callback for NV asics.
In reply to a message not in the archiveCheck 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
@@ -293,6 +293,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) {
@@ -585,6 +595,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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/19 drm/amdgpu: add a amdgpu_device_supports_baco helper
In reply to a message not in the archiveTo 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
@@ -1120,6 +1120,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
@@ -153,6 +153,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); +} +/* * MMIO register access helper functions. */
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/19 drm/amdgpu: rename amdgpu_device_is_px to amdgpu_device_supports_boco
In reply to a message not in the archiveTo better match what we are checking for and to align with amdgpu_device_supports_baco.
BACO - Bus Active, Chip Off
BOCO - Bus Off, Chip Off
--- 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
@@ -1119,7 +1119,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
@@ -137,14 +137,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 is 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;
@@ -1058,7 +1058,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 ) {
@@ -2832,7 +2832,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
@@ -1106,7 +1106,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);
@@ -1154,7 +1154,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 ; }
@@ -1181,7 +1181,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 ;
@@ -1206,7 +1206,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); }
@@ -215,7 +215,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 );
@@ -229,7 +229,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.20.1 _______________________________________________ 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): 20191011014536.10869-9-alexander.deucher-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 08/19] drm/amdgpu: rename amdgpu_device_is_px to amdgpu_device_supports_boco
Quoted 5 lines · Alex Deucher
To better match what we are checking for and to align with
amdgpu_device_supports_baco.BACO - Bus Active, Chip Off
BOCO - Bus Off, Chip Off
It would be useful to spell out BACO in the preceding patches as well.
Quoted 2 lines
- *
amdgpu_device_is_px- Is the device is a dGPU with HG/PX power control
+ *amdgpu_device_supports_boco- Is the device is a dGPU with HG/PX power control
Duplicate verb.
My personal style to document boolean return values is "whether ...", i.e. "whether device is a dGPU with HG/PX power control". But that's just me.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/19 drm/amdgpu: add additional boco checks to runtime suspend/resume
In reply to a message not in the archiveWe will take slightly different paths for boco and baco.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 46 ++++++++++++++----------- 1 file changed, 26 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +26 -20
@@ -1159,18 +1159,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 ; }
@@ -1184,20 +1187,23 @@ 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_device_supports_boco (drm_dev)) { +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.20.1 _______________________________________________ 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): 20191011014536.10869-10-alexander.deucher-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 09/19] drm/amdgpu: add additional boco checks to runtime suspend/resume
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_runtime_resume(struct device *dev) · line 1202
Quoted 13 lines · Alex Deucher
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +12
-0+if (amdgpu_device_supports_boco (drm_dev)) + drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; +if (amdgpu_device_supports_boco (drm_dev)) { +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); + }
Two consecutive if-clauses with same condition, can be folded into one.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/19 drm/amdgpu: split swSMU baco_reset into enter and exit
In reply to a message not in the archiveSo 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 | 11 ++++++++++- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 9 ++++++--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 12 ++++++++++-- 4 files changed, 32 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/nv.c +6 -1
@@ -331,7 +331,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 +10 -1
@@ -500,10 +500,19 @@ static int soc15_asic_baco_reset(struct amdgpu_device *adev) {if (is_support_sw_smu (adev)) {struct smu_context *smu = &adev->smu; +int ret; + + ret =smu_baco_enter (smu); +if (ret) +return ret; + + ret =smu_baco_exit (smu); +if (ret) +return ret;dev_info (adev->dev,"GPU BACO reset\n" ); -return smu_baco_reset (smu); +return 0 ; }else {void *pp_handle = adev->powerplay.pp_handle;const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +6 -3
@@ -546,7 +546,8 @@ struct smu_funcsbool (*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);
@@ -768,8 +769,10 @@ struct smu_funcs ((smu)->funcs->baco_is_support? (smu)->funcs->baco_is_support((smu)) : false)#define smu_baco_get_state (smu, state) \ ((smu)->funcs->baco_get_state? (smu)->funcs->baco_get_state((smu), (state)) : 0) -#define smu_baco_reset (smu) \ - ((smu)->funcs->baco_reset? (smu)->funcs->baco_reset((smu)) : 0) +#define smu_baco_enter (smu) \ + ((smu)->funcs->baco_enter? (smu)->funcs->baco_enter((smu)) : 0) +#define smu_baco_exit (smu) \ + ((smu)->funcs->baco_exit? (smu)->funcs->baco_exit((smu)) : 0)#define smu_mode2_reset (smu) \ ((smu)->funcs->mode2_reset? (smu)->funcs->mode2_reset((smu)) : 0)#define smu_asic_set_performance_level (smu, level) \
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +10 -2
@@ -1705,7 +1705,7 @@ static int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_statereturn ret; } -static int smu_v11_0_baco_reset (struct smu_context *smu) +static int smu_v11_0_baco_enter (struct smu_context *smu) {int ret =0 ;
@@ -1719,6 +1719,13 @@ static int smu_v11_0_baco_reset(struct smu_context *smu)msleep (10 ); +return ret; +} + +static 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;
@@ -1841,7 +1848,8 @@ static const struct smu_funcs smu_v11_0_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, };
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 11/19 drm/amdgpu: add helpers for baco entry and exit
In reply to a message not in the archiveWill be used for runtime pm.
--- 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
@@ -1123,6 +1123,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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 12/19 drm/amdgpu: add baco support to runtime suspend/resume
In reply to a message not in the archiveThis 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
@@ -1106,7 +1106,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);
@@ -1173,6 +1174,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 ;
@@ -1199,6 +1202,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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 13/19 drm/amdgpu: start to disentangle boco from runtime pm
In reply to a message not in the archiveWe 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
@@ -968,6 +968,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
@@ -1153,9 +1153,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 ; }
@@ -1185,9 +1186,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))
@@ -1215,9 +1217,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); }
@@ -185,14 +185,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
@@ -215,7 +218,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 );
@@ -229,7 +232,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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 14/19 drm/amdgpu: disentangle runtime pm and vga_switcheroo
In reply to a message not in the archiveOriginally 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
@@ -2662,7 +2662,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;
@@ -2833,11 +2833,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 ) {
@@ -3014,7 +3017,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;
@@ -3061,9 +3064,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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 15/19 drm/amdgpu: enable runtime pm on BACO capable boards if runpm=1
In reply to a message not in the archiveEverything 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
@@ -192,10 +192,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
@@ -208,6 +204,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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 16/19 drm/amdgpu/runpm: enable runpm on baco capable VI+ asics
In reply to a message not in the archiveSeems 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
@@ -205,10 +205,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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 17/19 ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD
In reply to a message not in the archiveOnly 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.
--- sound/pci/hda/hda_intel.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
sound/pci/hda/hda_intel.c +39 -0
@@ -35,6 +35,9 @@#include <linux/clocksource.h> #include <linux/time.h> #include <linux/completion.h> +#ifdef SUPPORT_VGA_SWITCHEROO +#include <linux/acpi.h> +#endif #ifdef CONFIG_X86 /* for snoop control */
@@ -1345,6 +1348,26 @@ static int azx_dev_free(struct snd_device *device) }#ifdef SUPPORT_VGA_SWITCHEROO +/* ATPX is in the integrated GPU's namespace */ +static struct pci_dev *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) +continue ; + + status =acpi_get_handle (dhandle,"ATPX" , &atpx_handle); +if (ACPI_FAILURE (status)) +continue ; +return pdev; + } +return NULL ; +} +/* * Check of disabled HDMI controller by vga_switcheroo */
@@ -1356,6 +1379,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.20.1 _______________________________________________ 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): 20191011014536.10869-18-alexander.deucher-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 17/19] ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD
Quoted 58 lines · Alex Deucher
Only enable the
vga_switcheroologic 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.Signed-off-by Alex Deucher <[email protected]>--- sound/pci/hda/hda_intel.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)sound/pci/hda/hda_intel.c +25
-0@@ -35,6 +35,9 @@#include <linux/clocksource.h> #include <linux/time.h> #include <linux/completion.h> +#ifdef SUPPORT_VGA_SWITCHEROO +#include <linux/acpi.h> +#endif #ifdef CONFIG_X86 /* for snoop control */ @@ -1345,6 +1348,26 @@ static int azx_dev_free(struct snd_device *device) }#ifdef SUPPORT_VGA_SWITCHEROO +/* ATPX is in the integrated GPU's namespace */ +static struct pci_dev *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) +continue ; + + status =acpi_get_handle (dhandle,"ATPX" , &atpx_handle); +if (ACPI_FAILURE (status)) +continue ; +return pdev; + } +return NULL ; +} +/* * Check of disabled HDMI controller by vga_switcheroo */ @@ -1356,6 +1379,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),
sound/pci/hda/hda_intel.c static struct pci_dev *get_bound_vga(struct pci_dev *pci) · line 1393
Quoted 10 lines
sound/pci/hda/hda_intel.c +10
-0+ 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;
Won't this lead to the unbalanced refcount for the device returned from atpx_present()?
thanks,
Takashi
Quoted 10 lines
sound/pci/hda/hda_intel.c +4
-0+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 · 1 line
2.20.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 18/19 ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
In reply to a message not in the archiveWe are able to power down the GPU and audio via the GPU driver so flag these asics as supporting runtime pm.
--- sound/pci/hda/hda_intel.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-)
sound/pci/hda/hda_intel.c +30 -5
@@ -2562,13 +2562,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 | + AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xab00), + .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 | + AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xab10), + .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 | + AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xab20), + .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 | + AZX_DCAPS_PM_RUNTIME }, /* VIA VT8251/VT8237A */ { PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },/* VIA GFX VT7122/VX900 */
Signature · 6 lines
2.20.1 _______________________________________________ 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): 20191011014536.10869-19-alexander.deucher-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 18/19] ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
Quoted 5 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.
Signed-off-by Alex Deucher <[email protected]>
Sorry for the late reply, as I've been off for the last few weeks.
The change itself looks good to me, but maybe it'd be nicer to mention that you're adding new IDs, not only flipping the flag of the existing entries.
Also, you can define a new flag, e.g.
#define AZX_DCAPS_PRESET_ATI_HDMI_PM \
(AZX_DCAPS_PRESET_ATI_HDMI_NS | AZX_DCAPS_PM_RUNTIME)
and use them instead of open-coding at each place.
This is just a matter of taste, so I don't mind either way, though.
thanks,
Takashi
Quoted 55 lines
--- sound/pci/hda/hda_intel.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-)sound/pci/hda/hda_intel.c +30
-5@@ -2562,13 +2562,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 | + AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xab00), + .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 | + AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xab10), + .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 | + AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xab20), + .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 | + AZX_DCAPS_PM_RUNTIME }, /* VIA VT8251/VT8237A */ { PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },/* VIA GFX VT7122/VX900 */ Signature · 1 line
2.20.1
_______________________________________________
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): [email protected]
Re: [PATCH 18/19] ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
Quoted 7 lines · Takashi Iwai
Quoted 4 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.
Quoted 7 lines
Quoted 1 line
Signed-off-by Alex Deucher <[email protected]>Sorry for the late reply, as I've been off for the last few weeks.
The change itself looks good to me, but maybe it'd be nicer to mention that you're adding new IDs, not only flipping the flag of the existing entries.
I'll split it into two patches.
Quoted 9 lines
Also, you can define a new flag, e.g.
#define
AZX_DCAPS_PRESET_ATI_HDMI_PM\
(AZX_DCAPS_PRESET_ATI_HDMI_NS|AZX_DCAPS_PM_RUNTIME)and use them instead of open-coding at each place.
This is just a matter of taste, so I don't mind either way, though.
Thanks!
Alex
Quoted 52 lines
thanks,
Takashi
Quoted 47 lines
--- sound/pci/hda/hda_intel.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-)sound/pci/hda/hda_intel.c +28
-5@@ -2562,13 +2562,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 | + AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xab00), + .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 | + AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xab10), + .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 | + AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xab20), + .driver_data =AZX_DRIVER_ATIHDMI_NS |AZX_DCAPS_PRESET_ATI_HDMI_NS | + AZX_DCAPS_PM_RUNTIME }, + { PCI_DEVICE(0x1002, 0xab38),
Quoted 8 lines
Quoted 8 lines
sound/pci/hda/hda_intel.c +2
-1+ .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 */ --2.20.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 19/19 ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by default
In reply to a message not in the archiveSo 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.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Patch 1 - 16 are Reviewed-by: Evan Quan <[email protected]> Patch 17 - 19 are acked-by: Evan Quan <[email protected]>
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, October 11, 2019 9:45 AM
To: [email protected]; [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 00/19] Enable BACO for power savings
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
Alex Deucher (19):
drm/amdgpu: add asic callback for BACO support
drm/amdgpu: add supports_baco callback for soc15 asics. 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 drm/amdgpu: add additional boco checks to runtime suspend/resume 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 - 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 | 64 ++++++----- 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 | 37 +++++- drivers/gpu/drm/amd/amdgpu/vi.c | 22 ++++ .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 9 +- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 12 +- sound/pci/hda/hda_intel.c | 74 +++++++++++- sound/pci/hda/patch_hdmi.c | 1 + 13 files changed, 343 insertions(+), 56 deletions(-)
--
2.20.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx