All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/19] Enable BACO for power savings
@ 2019-10-11  1:45 Alex Deucher
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

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
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 01/19] drm/amdgpu: add asic callback for BACO support
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 02/19] drm/amdgpu: add supports_baco callback for soc15 asics Alex Deucher
                     ` (18 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

Used to check whether the device supports BACO.  This will
be used to enable runtime pm on devices which support BACO.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 438775d54a6a..78338db7e48e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -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 */
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 02/19] drm/amdgpu: add supports_baco callback for soc15 asics.
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2019-10-11  1:45   ` [PATCH 01/19] drm/amdgpu: add asic callback for BACO support Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
       [not found]     ` <20191011014536.10869-3-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2019-10-11  1:45   ` [PATCH 03/19] drm/amdgpu: add supports_baco callback for SI asics Alex Deucher
                     ` (17 subsequent siblings)
  19 siblings, 1 reply; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

Check the BACO capabilities from the powerplay table.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index b3291a19a771..c49f7a78a2d5 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -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)
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 03/19] drm/amdgpu: add supports_baco callback for SI asics.
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2019-10-11  1:45   ` [PATCH 01/19] drm/amdgpu: add asic callback for BACO support Alex Deucher
  2019-10-11  1:45   ` [PATCH 02/19] drm/amdgpu: add supports_baco callback for soc15 asics Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 04/19] drm/amdgpu: add supports_baco callback for CIK asics Alex Deucher
                     ` (16 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

Not supported.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/si.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c
index 493af42152f2..401e43255a64 100644
--- a/drivers/gpu/drm/amd/amdgpu/si.c
+++ b/drivers/gpu/drm/amd/amdgpu/si.c
@@ -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)
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 04/19] drm/amdgpu: add supports_baco callback for CIK asics.
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (2 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 03/19] drm/amdgpu: add supports_baco callback for SI asics Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 05/19] drm/amdgpu: add supports_baco callback for VI asics Alex Deucher
                     ` (15 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

Check the BACO capabilities from the powerplay table.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/cik.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c
index fc8b34480f66..423ff97ac7dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik.c
@@ -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)
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 05/19] drm/amdgpu: add supports_baco callback for VI asics.
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (3 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 04/19] drm/amdgpu: add supports_baco callback for CIK asics Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 06/19] drm/amdgpu: add supports_baco callback for NV asics Alex Deucher
                     ` (14 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

Check the BACO capabilities from the powerplay table.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/vi.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
index 78e5cdc0c058..871c0b8c6b0b 100644
--- a/drivers/gpu/drm/amd/amdgpu/vi.c
+++ b/drivers/gpu/drm/amd/amdgpu/vi.c
@@ -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)	 \
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 06/19] drm/amdgpu: add supports_baco callback for NV asics.
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (4 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 05/19] drm/amdgpu: add supports_baco callback for VI asics Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 07/19] drm/amdgpu: add a amdgpu_device_supports_baco helper Alex Deucher
                     ` (13 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

Check the BACO capabilities from the powerplay table.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/nv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index 46206a1a1f4d..68c18f5f4b41 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -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)
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 07/19] drm/amdgpu: add a amdgpu_device_supports_baco helper
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (5 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 06/19] drm/amdgpu: add supports_baco callback for NV asics Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 08/19] drm/amdgpu: rename amdgpu_device_is_px to amdgpu_device_supports_boco Alex Deucher
                     ` (12 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

To check if a device supports BACO or not.  This will be
used in determining when to enable runtime pm.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 78338db7e48e..5f1ae09f4644 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -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);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 91bdb246e405..d0c17e38b430 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -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.
  */
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 08/19] drm/amdgpu: rename amdgpu_device_is_px to amdgpu_device_supports_boco
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (6 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 07/19] drm/amdgpu: add a amdgpu_device_supports_baco helper Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
       [not found]     ` <20191011014536.10869-9-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2019-10-11  1:45   ` [PATCH 09/19] drm/amdgpu: add additional boco checks to runtime suspend/resume Alex Deucher
                     ` (11 subsequent siblings)
  19 siblings, 1 reply; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: 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

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 5f1ae09f4644..df45a6c6cc0b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -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);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d0c17e38b430..d668b94451c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -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,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 64141386e603..bd22f0ce4d47 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -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;
 	}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 6746967f5e80..d305069efcff 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -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);
 	}
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 09/19] drm/amdgpu: add additional boco checks to runtime suspend/resume
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (7 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 08/19] drm/amdgpu: rename amdgpu_device_is_px to amdgpu_device_supports_boco Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
       [not found]     ` <20191011014536.10869-10-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2019-10-11  1:45   ` [PATCH 10/19] drm/amdgpu: split swSMU baco_reset into enter and exit Alex Deucher
                     ` (10 subsequent siblings)
  19 siblings, 1 reply; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

We will take slightly different paths for boco and baco.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 46 ++++++++++++++-----------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index bd22f0ce4d47..199b240811da 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -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;
 }
 
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 10/19] drm/amdgpu: split swSMU baco_reset into enter and exit
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (8 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 09/19] drm/amdgpu: add additional boco checks to runtime suspend/resume Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 11/19] drm/amdgpu: add helpers for baco entry " Alex Deucher
                     ` (9 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

So we can use it for power savings rather than just reset.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index 68c18f5f4b41..f716f8f14715 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -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);
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index c49f7a78a2d5..0bae9f77242b 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -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;
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
index ccf711c327c8..78d227b048fc 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
@@ -546,7 +546,8 @@ struct smu_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);
@@ -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) \
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index c9e90d59a6b8..4e88fc9047b0 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -1705,7 +1705,7 @@ static int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state
 	return 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,
 };
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 11/19] drm/amdgpu: add helpers for baco entry and exit
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (9 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 10/19] drm/amdgpu: split swSMU baco_reset into enter and exit Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 12/19] drm/amdgpu: add baco support to runtime suspend/resume Alex Deucher
                     ` (8 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

Will be used for runtime pm.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 61 ++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index df45a6c6cc0b..2b488ae9a324 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -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)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d668b94451c9..0f4e65d3bfaf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4207,3 +4207,64 @@ static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev)
 	}
 }
 
+int amdgpu_device_baco_enter(struct drm_device *dev)
+{
+	struct amdgpu_device *adev = dev->dev_private;
+
+	if (!amdgpu_device_supports_baco(adev->ddev))
+		return -ENOTSUPP;
+
+	if (is_support_sw_smu(adev)) {
+		struct smu_context *smu = &adev->smu;
+		int ret;
+
+		ret = smu_baco_enter(smu);
+		if (ret)
+			return ret;
+
+		return 0;
+	} else {
+		void *pp_handle = adev->powerplay.pp_handle;
+		const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+
+		if (!pp_funcs ||!pp_funcs->get_asic_baco_state ||!pp_funcs->set_asic_baco_state)
+			return -ENOENT;
+
+		/* enter BACO state */
+		if (pp_funcs->set_asic_baco_state(pp_handle, 1))
+			return -EIO;
+
+		return 0;
+	}
+}
+
+int amdgpu_device_baco_exit(struct drm_device *dev)
+{
+	struct amdgpu_device *adev = dev->dev_private;
+
+	if (!amdgpu_device_supports_baco(adev->ddev))
+		return -ENOTSUPP;
+
+	if (is_support_sw_smu(adev)) {
+		struct smu_context *smu = &adev->smu;
+		int ret;
+
+		ret = smu_baco_exit(smu);
+		if (ret)
+			return ret;
+
+		return 0;
+	} else {
+		void *pp_handle = adev->powerplay.pp_handle;
+		const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+
+		if (!pp_funcs ||!pp_funcs->get_asic_baco_state ||!pp_funcs->set_asic_baco_state)
+			return -ENOENT;
+
+		/* exit BACO state */
+		if (pp_funcs->set_asic_baco_state(pp_handle, 0))
+			return -EIO;
+
+		return 0;
+	}
+}
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 12/19] drm/amdgpu: add baco support to runtime suspend/resume
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (10 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 11/19] drm/amdgpu: add helpers for baco entry " Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 13/19] drm/amdgpu: start to disentangle boco from runtime pm Alex Deucher
                     ` (7 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

This adds the necessary support to the runtime suspend
and resume functions to handle boards that support
baco.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 199b240811da..db82ce4d5dd9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -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);
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 13/19] drm/amdgpu: start to disentangle boco from runtime pm
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (11 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 12/19] drm/amdgpu: add baco support to runtime suspend/resume Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 14/19] drm/amdgpu: disentangle runtime pm and vga_switcheroo Alex Deucher
                     ` (6 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

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.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 2b488ae9a324..f321dc2751e4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -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)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index db82ce4d5dd9..03cc94bd4132 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -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;
 	}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index d305069efcff..f9b1ebe875fe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -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);
 	}
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 14/19] drm/amdgpu: disentangle runtime pm and vga_switcheroo
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (12 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 13/19] drm/amdgpu: start to disentangle boco from runtime pm Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 15/19] drm/amdgpu: enable runtime pm on BACO capable boards if runpm=1 Alex Deucher
                     ` (5 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

Originally we only supported runtime pm on PX/HG laptops
so vga_switcheroo and runtime pm are sort of entangled.

Attempt to logically separate them.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 0f4e65d3bfaf..c0cb681457be 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -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)
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 15/19] drm/amdgpu: enable runtime pm on BACO capable boards if runpm=1
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (13 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 14/19] drm/amdgpu: disentangle runtime pm and vga_switcheroo Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 16/19] drm/amdgpu/runpm: enable runpm on baco capable VI+ asics Alex Deucher
                     ` (4 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

Everything is in place now.  Not enabled by default yet.  You
still have to specify runpm=1.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index f9b1ebe875fe..63ae8fd76e53 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -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
 	 */
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 16/19] drm/amdgpu/runpm: enable runpm on baco capable VI+ asics
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (14 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 15/19] drm/amdgpu: enable runtime pm on BACO capable boards if runpm=1 Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-11  1:45   ` [PATCH 17/19] ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD Alex Deucher
                     ` (3 subsequent siblings)
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

Seems to work reliably on VI+.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 63ae8fd76e53..25cf4df4f781 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -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
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 17/19] ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (15 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 16/19] drm/amdgpu/runpm: enable runpm on baco capable VI+ asics Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
       [not found]     ` <20191011014536.10869-18-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2019-10-11  1:45   ` [PATCH 18/19] ALSA: hda/hdmi - enable runtime pm for newer AMD display audio Alex Deucher
                     ` (2 subsequent siblings)
  19 siblings, 1 reply; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

Only 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.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 sound/pci/hda/hda_intel.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 1e14d7270adf..9b90312d7314 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -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),
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 18/19] ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (16 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 17/19] ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
       [not found]     ` <20191011014536.10869-19-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2019-10-11  1:45   ` [PATCH 19/19] ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by default Alex Deucher
  2019-10-14  3:32   ` [PATCH 00/19] Enable BACO for power savings Quan, Evan
  19 siblings, 1 reply; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: 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 <alexander.deucher@amd.com>
---
 sound/pci/hda/hda_intel.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 9b90312d7314..925a95927f20 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -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 */
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 19/19] ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by default
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (17 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 18/19] ALSA: hda/hdmi - enable runtime pm for newer AMD display audio Alex Deucher
@ 2019-10-11  1:45   ` Alex Deucher
  2019-10-14  3:32   ` [PATCH 00/19] Enable BACO for power savings Quan, Evan
  19 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-11  1:45 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, tiwai-l3A5Bk7waGM,
	lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Alex Deucher

So that we can power down the GPU and audio to save power.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 sound/pci/hda/patch_hdmi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index bea7b0961080..26613733f109 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -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;
 }
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/19] drm/amdgpu: add supports_baco callback for soc15 asics.
       [not found]     ` <20191011014536.10869-3-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2019-10-12 11:45       ` Lukas Wunner
       [not found]         ` <20191012114527.akspejxsm3hvrzil-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
  0 siblings, 1 reply; 28+ messages in thread
From: Lukas Wunner @ 2019-10-12 11:45 UTC (permalink / raw)
  To: Alex Deucher
  Cc: tiwai-l3A5Bk7waGM, Alex Deucher,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Thu, Oct 10, 2019 at 08:45:19PM -0500, Alex Deucher wrote:
> Check the BACO capabilities from the powerplay table.
> 
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
[...]
> @@ -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
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 08/19] drm/amdgpu: rename amdgpu_device_is_px to amdgpu_device_supports_boco
       [not found]     ` <20191011014536.10869-9-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2019-10-12 11:51       ` Lukas Wunner
  0 siblings, 0 replies; 28+ messages in thread
From: Lukas Wunner @ 2019-10-12 11:51 UTC (permalink / raw)
  To: Alex Deucher
  Cc: tiwai-l3A5Bk7waGM, Alex Deucher,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Thu, Oct 10, 2019 at 08:45:25PM -0500, Alex Deucher wrote:
> 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.


> - * 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
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 09/19] drm/amdgpu: add additional boco checks to runtime suspend/resume
       [not found]     ` <20191011014536.10869-10-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2019-10-12 11:55       ` Lukas Wunner
  0 siblings, 0 replies; 28+ messages in thread
From: Lukas Wunner @ 2019-10-12 11:55 UTC (permalink / raw)
  To: Alex Deucher
  Cc: tiwai-l3A5Bk7waGM, Alex Deucher,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Thu, Oct 10, 2019 at 08:45:26PM -0500, Alex Deucher wrote:
> +	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
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/19] drm/amdgpu: add supports_baco callback for soc15 asics.
       [not found]         ` <20191012114527.akspejxsm3hvrzil-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
@ 2019-10-13 16:50           ` Alex Deucher
  0 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-13 16:50 UTC (permalink / raw)
  To: Lukas Wunner; +Cc: Takashi Iwai, Alex Deucher, amd-gfx list

On Sat, Oct 12, 2019 at 7:45 AM Lukas Wunner <lukas@wunner.de> wrote:
>
> On Thu, Oct 10, 2019 at 08:45:19PM -0500, Alex Deucher wrote:
> > Check the BACO capabilities from the powerplay table.
> >
> > Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> [...]
> > @@ -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.

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
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: [PATCH 00/19] Enable BACO for power savings
       [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (18 preceding siblings ...)
  2019-10-11  1:45   ` [PATCH 19/19] ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by default Alex Deucher
@ 2019-10-14  3:32   ` Quan, Evan
  19 siblings, 0 replies; 28+ messages in thread
From: Quan, Evan @ 2019-10-14  3:32 UTC (permalink / raw)
  To: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	tiwai-l3A5Bk7waGM, lukas-JFq808J9C/izQB+pC5nmwQ
  Cc: Deucher, Alexander

Patch 1 - 16 are Reviewed-by: Evan Quan <evan.quan@amd.com>
Patch 17 - 19 are acked-by: Evan Quan <evan.quan@amd.com>

-----Original Message-----
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex Deucher
Sent: Friday, October 11, 2019 9:45 AM
To: amd-gfx@lists.freedesktop.org; tiwai@suse.de; lukas@wunner.de
Cc: Deucher, Alexander <Alexander.Deucher@amd.com>
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
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 18/19] ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
       [not found]     ` <20191011014536.10869-19-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2019-10-17  7:51       ` Takashi Iwai
       [not found]         ` <s5hpnivizcc.wl-tiwai-l3A5Bk7waGM@public.gmane.org>
  0 siblings, 1 reply; 28+ messages in thread
From: Takashi Iwai @ 2019-10-17  7:51 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Alex Deucher, lukas-JFq808J9C/izQB+pC5nmwQ,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Fri, 11 Oct 2019 03:45:35 +0200,
Alex Deucher wrote:
> 
> 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 <alexander.deucher@amd.com>

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

> ---
>  sound/pci/hda/hda_intel.c | 35 ++++++++++++++++++++++++++++++-----
>  1 file changed, 30 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> index 9b90312d7314..925a95927f20 100644
> --- a/sound/pci/hda/hda_intel.c
> +++ b/sound/pci/hda/hda_intel.c
> @@ -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 */
> -- 
> 2.20.1
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 17/19] ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD
       [not found]     ` <20191011014536.10869-18-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2019-10-17  7:55       ` Takashi Iwai
  0 siblings, 0 replies; 28+ messages in thread
From: Takashi Iwai @ 2019-10-17  7:55 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Alex Deucher, lukas-JFq808J9C/izQB+pC5nmwQ,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Fri, 11 Oct 2019 03:45:34 +0200,
Alex Deucher wrote:
> 
> Only 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.
> 
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  sound/pci/hda/hda_intel.c | 39 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> index 1e14d7270adf..9b90312d7314 100644
> --- a/sound/pci/hda/hda_intel.c
> +++ b/sound/pci/hda/hda_intel.c
> @@ -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;

Won't this lead to the unbalanced refcount for the device returned
from atpx_present()?


thanks,

Takashi

> +				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),
> -- 
> 2.20.1
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 18/19] ALSA: hda/hdmi - enable runtime pm for newer AMD display audio
       [not found]         ` <s5hpnivizcc.wl-tiwai-l3A5Bk7waGM@public.gmane.org>
@ 2019-10-17 12:43           ` Alex Deucher
  0 siblings, 0 replies; 28+ messages in thread
From: Alex Deucher @ 2019-10-17 12:43 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Alex Deucher, Lukas Wunner, amd-gfx list

On Thu, Oct 17, 2019 at 3:51 AM Takashi Iwai <tiwai@suse.de> wrote:
>
> On Fri, 11 Oct 2019 03:45:35 +0200,
> Alex Deucher wrote:
> >
> > 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 <alexander.deucher@amd.com>
>
> 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.

>
> 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

>
> thanks,
>
> Takashi
>
> > ---
> >  sound/pci/hda/hda_intel.c | 35 ++++++++++++++++++++++++++++++-----
> >  1 file changed, 30 insertions(+), 5 deletions(-)
> >
> > diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> > index 9b90312d7314..925a95927f20 100644
> > --- a/sound/pci/hda/hda_intel.c
> > +++ b/sound/pci/hda/hda_intel.c
> > @@ -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 */
> > --
> > 2.20.1
> >
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2019-10-17 12:43 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-11  1:45 [PATCH 00/19] Enable BACO for power savings Alex Deucher
     [not found] ` <20191011014536.10869-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2019-10-11  1:45   ` [PATCH 01/19] drm/amdgpu: add asic callback for BACO support Alex Deucher
2019-10-11  1:45   ` [PATCH 02/19] drm/amdgpu: add supports_baco callback for soc15 asics Alex Deucher
     [not found]     ` <20191011014536.10869-3-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2019-10-12 11:45       ` Lukas Wunner
     [not found]         ` <20191012114527.akspejxsm3hvrzil-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2019-10-13 16:50           ` Alex Deucher
2019-10-11  1:45   ` [PATCH 03/19] drm/amdgpu: add supports_baco callback for SI asics Alex Deucher
2019-10-11  1:45   ` [PATCH 04/19] drm/amdgpu: add supports_baco callback for CIK asics Alex Deucher
2019-10-11  1:45   ` [PATCH 05/19] drm/amdgpu: add supports_baco callback for VI asics Alex Deucher
2019-10-11  1:45   ` [PATCH 06/19] drm/amdgpu: add supports_baco callback for NV asics Alex Deucher
2019-10-11  1:45   ` [PATCH 07/19] drm/amdgpu: add a amdgpu_device_supports_baco helper Alex Deucher
2019-10-11  1:45   ` [PATCH 08/19] drm/amdgpu: rename amdgpu_device_is_px to amdgpu_device_supports_boco Alex Deucher
     [not found]     ` <20191011014536.10869-9-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2019-10-12 11:51       ` Lukas Wunner
2019-10-11  1:45   ` [PATCH 09/19] drm/amdgpu: add additional boco checks to runtime suspend/resume Alex Deucher
     [not found]     ` <20191011014536.10869-10-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2019-10-12 11:55       ` Lukas Wunner
2019-10-11  1:45   ` [PATCH 10/19] drm/amdgpu: split swSMU baco_reset into enter and exit Alex Deucher
2019-10-11  1:45   ` [PATCH 11/19] drm/amdgpu: add helpers for baco entry " Alex Deucher
2019-10-11  1:45   ` [PATCH 12/19] drm/amdgpu: add baco support to runtime suspend/resume Alex Deucher
2019-10-11  1:45   ` [PATCH 13/19] drm/amdgpu: start to disentangle boco from runtime pm Alex Deucher
2019-10-11  1:45   ` [PATCH 14/19] drm/amdgpu: disentangle runtime pm and vga_switcheroo Alex Deucher
2019-10-11  1:45   ` [PATCH 15/19] drm/amdgpu: enable runtime pm on BACO capable boards if runpm=1 Alex Deucher
2019-10-11  1:45   ` [PATCH 16/19] drm/amdgpu/runpm: enable runpm on baco capable VI+ asics Alex Deucher
2019-10-11  1:45   ` [PATCH 17/19] ALSA: hda/hdmi - fix vgaswitcheroo detection for AMD Alex Deucher
     [not found]     ` <20191011014536.10869-18-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2019-10-17  7:55       ` Takashi Iwai
2019-10-11  1:45   ` [PATCH 18/19] ALSA: hda/hdmi - enable runtime pm for newer AMD display audio Alex Deucher
     [not found]     ` <20191011014536.10869-19-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2019-10-17  7:51       ` Takashi Iwai
     [not found]         ` <s5hpnivizcc.wl-tiwai-l3A5Bk7waGM@public.gmane.org>
2019-10-17 12:43           ` Alex Deucher
2019-10-11  1:45   ` [PATCH 19/19] ALSA: hda/hdmi - enable automatic runtime pm for AMD HDMI codecs by default Alex Deucher
2019-10-14  3:32   ` [PATCH 00/19] Enable BACO for power savings Quan, Evan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.