All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/10] drm/amdgpu: move common pm sysfs code to amdgpu_device.c
@ 2017-09-25 13:48 Rex Zhu
       [not found] ` <1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Rex Zhu @ 2017-09-25 13:48 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

Change-Id: I4ad2c914081dd71b10a89f650fea87f9cbc9c859
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 6 ++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c        | 6 ++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | 7 +------
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c           | 1 -
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c           | 7 -------
 drivers/gpu/drm/amd/amdgpu/si_dpm.c           | 6 ------
 6 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index a86d856..599b310 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -57,6 +57,7 @@
 #include "amdgpu_vf_error.h"
 
 #include "amdgpu_amdkfd.h"
+#include "amdgpu_pm.h"
 
 MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin");
 MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin");
@@ -2260,6 +2261,10 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 
 	amdgpu_fbdev_init(adev);
 
+	r = amdgpu_pm_sysfs_init(adev);
+	if (r)
+		DRM_ERROR("registering pm debugfs failed (%d).\n", r);;
+
 	r = amdgpu_gem_debugfs_init(adev);
 	if (r)
 		DRM_ERROR("registering gem debugfs failed (%d).\n", r);
@@ -2357,6 +2362,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
 	iounmap(adev->rmmio);
 	adev->rmmio = NULL;
 	amdgpu_doorbell_fini(adev);
+	amdgpu_pm_sysfs_fini(adev);
 	amdgpu_debugfs_regs_cleanup(adev);
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 9cbd3cd..723fc16 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -1316,6 +1316,9 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
 	if (adev->pm.sysfs_initialized)
 		return 0;
 
+	if (adev->pm.dpm_enabled == 0)
+		return 0;
+
 	if (adev->powerplay.pp_funcs->get_temperature == NULL)
 		return 0;
 
@@ -1416,6 +1419,9 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
 
 void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
 {
+	if (adev->pm.dpm_enabled == 0)
+		return;
+
 	if (adev->pm.int_hwmon_dev)
 		hwmon_device_unregister(adev->pm.int_hwmon_dev);
 	device_remove_file(adev->dev, &dev_attr_power_dpm_state);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
index 2d2f0960..1ad6323 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
@@ -137,10 +137,8 @@ static int amdgpu_pp_late_init(void *handle)
 		ret = adev->powerplay.ip_funcs->late_init(
 					adev->powerplay.pp_handle);
 
-	if (adev->pp_enabled && adev->pm.dpm_enabled) {
-		amdgpu_pm_sysfs_init(adev);
+	if (adev->pp_enabled && adev->pm.dpm_enabled)
 		amdgpu_dpm_dispatch_task(adev, AMD_PP_TASK_COMPLETE_INIT, NULL, NULL);
-	}
 
 	return ret;
 }
@@ -199,9 +197,6 @@ static int amdgpu_pp_hw_fini(void *handle)
 	int ret = 0;
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
-	if (adev->pp_enabled && adev->pm.dpm_enabled)
-		amdgpu_pm_sysfs_fini(adev);
-
 	if (adev->powerplay.ip_funcs->hw_fini)
 		ret = adev->powerplay.ip_funcs->hw_fini(
 					adev->powerplay.pp_handle);
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
index 68ce1bd..68b505c 100644
--- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
@@ -6365,7 +6365,6 @@ static int ci_dpm_sw_fini(void *handle)
 	flush_work(&adev->pm.dpm.thermal.work);
 
 	mutex_lock(&adev->pm.mutex);
-	amdgpu_pm_sysfs_fini(adev);
 	ci_dpm_fini(adev);
 	mutex_unlock(&adev->pm.mutex);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
index b57399a..f33d1ff 100644
--- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
@@ -2969,16 +2969,10 @@ static int kv_dpm_late_init(void *handle)
 {
 	/* powerdown unused blocks for now */
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	int ret;
 
 	if (!amdgpu_dpm)
 		return 0;
 
-	/* init the sysfs and debugfs files late */
-	ret = amdgpu_pm_sysfs_init(adev);
-	if (ret)
-		return ret;
-
 	kv_dpm_powergate_acp(adev, true);
 	kv_dpm_powergate_samu(adev, true);
 
@@ -3040,7 +3034,6 @@ static int kv_dpm_sw_fini(void *handle)
 	flush_work(&adev->pm.dpm.thermal.work);
 
 	mutex_lock(&adev->pm.mutex);
-	amdgpu_pm_sysfs_fini(adev);
 	kv_dpm_fini(adev);
 	mutex_unlock(&adev->pm.mutex);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
index 9b8db60..51fd0c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
@@ -7604,11 +7604,6 @@ static int si_dpm_late_init(void *handle)
 	if (!amdgpu_dpm)
 		return 0;
 
-	/* init the sysfs and debugfs files late */
-	ret = amdgpu_pm_sysfs_init(adev);
-	if (ret)
-		return ret;
-
 	ret = si_set_temperature_range(adev);
 	if (ret)
 		return ret;
@@ -7764,7 +7759,6 @@ static int si_dpm_sw_fini(void *handle)
 	flush_work(&adev->pm.dpm.thermal.work);
 
 	mutex_lock(&adev->pm.mutex);
-	amdgpu_pm_sysfs_fini(adev);
 	si_dpm_fini(adev);
 	mutex_unlock(&adev->pm.mutex);
 
-- 
1.9.1

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

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

* [PATCH 02/10] drm/amdgpu: move amdgpu_ucode_init_bo to amdgpu_device.c
       [not found] ` <1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
@ 2017-09-25 13:48   ` Rex Zhu
  2017-09-25 13:48   ` [PATCH 03/10] drm/amd/powerplay: fix memory leak in powerplay Rex Zhu
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Rex Zhu @ 2017-09-25 13:48 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

Change-Id: I8f1016d9d77437b80fce97dadaae52f49c2c901e
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 8 ++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | 5 -----
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c       | 9 ---------
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 599b310..7b199c8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1605,6 +1605,7 @@ static int amdgpu_init(struct amdgpu_device *adev)
 			return r;
 		}
 		adev->ip_blocks[i].status.sw = true;
+
 		/* need to do gmc hw init early so we can allocate gpu mem */
 		if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) {
 			r = amdgpu_vram_scratch_init(adev);
@@ -1635,6 +1636,11 @@ static int amdgpu_init(struct amdgpu_device *adev)
 		}
 	}
 
+	mutex_lock(&adev->firmware.mutex);
+	if (amdgpu_ucode_init_bo(adev))
+		adev->firmware.load_type = AMDGPU_FW_LOAD_DIRECT;
+	mutex_unlock(&adev->firmware.mutex);
+
 	for (i = 0; i < adev->num_ip_blocks; i++) {
 		if (!adev->ip_blocks[i].status.sw)
 			continue;
@@ -1770,6 +1776,8 @@ static int amdgpu_fini(struct amdgpu_device *adev)
 
 		adev->ip_blocks[i].status.hw = false;
 	}
+	if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)
+		amdgpu_ucode_fini_bo(adev);
 
 	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
 		if (!adev->ip_blocks[i].status.sw)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
index 1ad6323..c05e5a8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
@@ -174,8 +174,6 @@ static int amdgpu_pp_hw_init(void *handle)
 	int ret = 0;
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
-	if (adev->pp_enabled && adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
-		amdgpu_ucode_init_bo(adev);
 
 	if (adev->powerplay.ip_funcs->hw_init)
 		ret = adev->powerplay.ip_funcs->hw_init(
@@ -201,9 +199,6 @@ static int amdgpu_pp_hw_fini(void *handle)
 		ret = adev->powerplay.ip_funcs->hw_fini(
 					adev->powerplay.pp_handle);
 
-	if (adev->pp_enabled && adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
-		amdgpu_ucode_fini_bo(adev);
-
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 447d446..f1035a6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -411,13 +411,6 @@ static int psp_hw_init(void *handle)
 		return 0;
 
 	mutex_lock(&adev->firmware.mutex);
-	/*
-	 * This sequence is just used on hw_init only once, no need on
-	 * resume.
-	 */
-	ret = amdgpu_ucode_init_bo(adev);
-	if (ret)
-		goto failed;
 
 	ret = psp_load_fw(adev);
 	if (ret) {
@@ -442,8 +435,6 @@ static int psp_hw_fini(void *handle)
 	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
 		return 0;
 
-	amdgpu_ucode_fini_bo(adev);
-
 	psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
 	amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
-- 
1.9.1

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

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

* [PATCH 03/10] drm/amd/powerplay: fix memory leak in powerplay
       [not found] ` <1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
  2017-09-25 13:48   ` [PATCH 02/10] drm/amdgpu: move amdgpu_ucode_init_bo " Rex Zhu
@ 2017-09-25 13:48   ` Rex Zhu
  2017-09-25 13:48   ` [PATCH 04/10] drm/amdgpu: delete dead code about fw load check Rex Zhu
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Rex Zhu @ 2017-09-25 13:48 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

cgs device not free.

Change-Id: I89435944a1205cb1a8da93469db3a3633a54125e
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c     | 9 ++++++---
 drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h | 1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
index c05e5a8..2ed81cd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
@@ -45,7 +45,7 @@ static int amdgpu_create_pp_handle(struct amdgpu_device *adev)
 	pp_init.chip_id = adev->asic_type;
 	pp_init.pm_en = (amdgpu_dpm != 0 && !amdgpu_sriov_vf(adev)) ? true : false;
 	pp_init.feature_mask = amdgpu_pp_feature_mask;
-	pp_init.device = amdgpu_cgs_create_device(adev);
+	pp_init.device = amd_pp->cgs_device;
 	ret = amd_powerplay_create(&pp_init, &(amd_pp->pp_handle));
 	if (ret)
 		return -EINVAL;
@@ -74,6 +74,7 @@ static int amdgpu_pp_early_init(void *handle)
 	case CHIP_VEGA10:
 	case CHIP_RAVEN:
 		adev->pp_enabled = true;
+		amd_pp->cgs_device = amdgpu_cgs_create_device(adev);
 		if (amdgpu_create_pp_handle(adev))
 			return -EINVAL;
 		amd_pp->ip_funcs = &pp_ip_funcs;
@@ -97,7 +98,7 @@ static int amdgpu_pp_early_init(void *handle)
 			amd_pp->ip_funcs = &ci_dpm_ip_funcs;
 			amd_pp->pp_funcs = &ci_dpm_funcs;
 		} else {
-			adev->pp_enabled = true;
+			amd_pp->cgs_device = amdgpu_cgs_create_device(adev);
 			if (amdgpu_create_pp_handle(adev))
 				return -EINVAL;
 			amd_pp->ip_funcs = &pp_ip_funcs;
@@ -211,8 +212,10 @@ static void amdgpu_pp_late_fini(void *handle)
 			  adev->powerplay.pp_handle);
 
 
-	if (adev->pp_enabled)
+	if (adev->pp_enabled) {
 		amd_powerplay_destroy(adev->powerplay.pp_handle);
+		amdgpu_cgs_destroy_device(adev->powerplay.cgs_device);
+	}
 }
 
 static int amdgpu_pp_suspend(void *handle)
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
index 435da26..437d785 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
@@ -268,6 +268,7 @@ struct pp_display_clock_request {
 								state << PP_STATE_SHIFT)
 
 struct amd_powerplay {
+	struct cgs_device *cgs_device;
 	void *pp_handle;
 	const struct amd_ip_funcs *ip_funcs;
 	const struct amd_pm_funcs *pp_funcs;
-- 
1.9.1

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

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

* [PATCH 04/10] drm/amdgpu: delete dead code about fw load check
       [not found] ` <1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
  2017-09-25 13:48   ` [PATCH 02/10] drm/amdgpu: move amdgpu_ucode_init_bo " Rex Zhu
  2017-09-25 13:48   ` [PATCH 03/10] drm/amd/powerplay: fix memory leak in powerplay Rex Zhu
@ 2017-09-25 13:48   ` Rex Zhu
  2017-09-25 13:48   ` [PATCH 05/10] drm/amdgpu: delete pp_enable in adev Rex Zhu
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Rex Zhu @ 2017-09-25 13:48 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

Change-Id: I1df6ff230a4fc95afdb319f37f24dd1cae82eaaa
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  | 60 ++++++++--------------------------
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 20 +++---------
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 21 +++---------
 3 files changed, 23 insertions(+), 78 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index dfc10b1..e04de7a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -4132,18 +4132,12 @@ static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev)
 	gfx_v8_0_rlc_reset(adev);
 	gfx_v8_0_init_pg(adev);
 
-	if (!adev->pp_enabled) {
-		if (adev->firmware.load_type != AMDGPU_FW_LOAD_SMU) {
-			/* legacy rlc firmware loading */
-			r = gfx_v8_0_rlc_load_microcode(adev);
-			if (r)
-				return r;
-		} else {
-			r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
-							AMDGPU_UCODE_ID_RLC_G);
-			if (r)
-				return -EINVAL;
-		}
+
+	if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {
+		/* legacy rlc firmware loading */
+		r = gfx_v8_0_rlc_load_microcode(adev);
+		if (r)
+			return r;
 	}
 
 	gfx_v8_0_rlc_start(adev);
@@ -4959,43 +4953,15 @@ static int gfx_v8_0_cp_resume(struct amdgpu_device *adev)
 	if (!(adev->flags & AMD_IS_APU))
 		gfx_v8_0_enable_gui_idle_interrupt(adev, false);
 
-	if (!adev->pp_enabled) {
-		if (adev->firmware.load_type != AMDGPU_FW_LOAD_SMU) {
+	if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {
 			/* legacy firmware loading */
-			r = gfx_v8_0_cp_gfx_load_microcode(adev);
-			if (r)
-				return r;
+		r = gfx_v8_0_cp_gfx_load_microcode(adev);
+		if (r)
+			return r;
 
-			r = gfx_v8_0_cp_compute_load_microcode(adev);
-			if (r)
-				return r;
-		} else {
-			r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
-							AMDGPU_UCODE_ID_CP_CE);
-			if (r)
-				return -EINVAL;
-
-			r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
-							AMDGPU_UCODE_ID_CP_PFP);
-			if (r)
-				return -EINVAL;
-
-			r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
-							AMDGPU_UCODE_ID_CP_ME);
-			if (r)
-				return -EINVAL;
-
-			if (adev->asic_type == CHIP_TOPAZ) {
-				r = gfx_v8_0_cp_compute_load_microcode(adev);
-				if (r)
-					return r;
-			} else {
-				r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
-										 AMDGPU_UCODE_ID_CP_MEC1);
-				if (r)
-					return -EINVAL;
-			}
-		}
+		r = gfx_v8_0_cp_compute_load_microcode(adev);
+		if (r)
+			return r;
 	}
 
 	r = gfx_v8_0_cp_gfx_resume(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
index acdee3a..67f375b 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
@@ -561,21 +561,11 @@ static int sdma_v2_4_start(struct amdgpu_device *adev)
 {
 	int r;
 
-	if (!adev->pp_enabled) {
-		if (adev->firmware.load_type != AMDGPU_FW_LOAD_SMU) {
-			r = sdma_v2_4_load_microcode(adev);
-			if (r)
-				return r;
-		} else {
-			r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
-							AMDGPU_UCODE_ID_SDMA0);
-			if (r)
-				return -EINVAL;
-			r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
-							AMDGPU_UCODE_ID_SDMA1);
-			if (r)
-				return -EINVAL;
-		}
+
+	if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {
+		r = sdma_v2_4_load_microcode(adev);
+		if (r)
+			return r;
 	}
 
 	/* halt the engine before programing */
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
index 72f31cc..6d06f8e 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
@@ -819,23 +819,12 @@ static int sdma_v3_0_load_microcode(struct amdgpu_device *adev)
  */
 static int sdma_v3_0_start(struct amdgpu_device *adev)
 {
-	int r, i;
+	int r;
 
-	if (!adev->pp_enabled) {
-		if (adev->firmware.load_type != AMDGPU_FW_LOAD_SMU) {
-			r = sdma_v3_0_load_microcode(adev);
-			if (r)
-				return r;
-		} else {
-			for (i = 0; i < adev->sdma.num_instances; i++) {
-				r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
-										 (i == 0) ?
-										 AMDGPU_UCODE_ID_SDMA0 :
-										 AMDGPU_UCODE_ID_SDMA1);
-				if (r)
-					return -EINVAL;
-			}
-		}
+	if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {
+		r = sdma_v3_0_load_microcode(adev);
+		if (r)
+			return r;
 	}
 
 	/* disable sdma engine before programing it */
-- 
1.9.1

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

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

* [PATCH 05/10] drm/amdgpu: delete pp_enable in adev
       [not found] ` <1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
                     ` (2 preceding siblings ...)
  2017-09-25 13:48   ` [PATCH 04/10] drm/amdgpu: delete dead code about fw load check Rex Zhu
@ 2017-09-25 13:48   ` Rex Zhu
  2017-09-25 13:49   ` [PATCH 06/10] drm/amdgpu: add cgs interface to register pp handle Rex Zhu
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Rex Zhu @ 2017-09-25 13:48 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

amdgpu not care powerplay or dpm is enabled.
just check ip functions and pp functions

Change-Id: I972700055e2ee4655ac1b24fe7ff2dacdaf49979
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c        | 77 ++++++++++++---------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c |  7 +--
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 18 ++++++-
 4 files changed, 53 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index a5b0b67..518ba7c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1529,7 +1529,6 @@ struct amdgpu_device {
 
 	/* powerplay */
 	struct amd_powerplay		powerplay;
-	bool				pp_enabled;
 	bool				pp_force_state_enabled;
 
 	/* dpm */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 723fc16..f3b23f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -64,10 +64,6 @@
 
 void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)
 {
-	if (adev->pp_enabled)
-		/* TODO */
-		return;
-
 	if (adev->pm.dpm_enabled) {
 		mutex_lock(&adev->pm.mutex);
 		if (power_supply_is_system_supplied() > 0)
@@ -118,7 +114,7 @@ static ssize_t amdgpu_set_dpm_state(struct device *dev,
 		goto fail;
 	}
 
-	if (adev->pp_enabled) {
+	if (adev->powerplay.pp_funcs->dispatch_tasks) {
 		amdgpu_dpm_dispatch_task(adev, AMD_PP_TASK_ENABLE_USER_STATE, &state, NULL);
 	} else {
 		mutex_lock(&adev->pm.mutex);
@@ -303,7 +299,8 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev,
 
 	if (strlen(buf) == 1)
 		adev->pp_force_state_enabled = false;
-	else if (adev->pp_enabled) {
+	else if (adev->powerplay.pp_funcs->dispatch_tasks &&
+			adev->powerplay.pp_funcs->get_pp_num_states) {
 		struct pp_states_info data;
 
 		ret = kstrtoul(buf, 0, &idx);
@@ -531,7 +528,7 @@ static ssize_t amdgpu_set_pp_sclk_od(struct device *dev,
 	if (adev->powerplay.pp_funcs->set_sclk_od)
 		amdgpu_dpm_set_sclk_od(adev, (uint32_t)value);
 
-	if (adev->pp_enabled) {
+	if (adev->powerplay.pp_funcs->dispatch_tasks) {
 		amdgpu_dpm_dispatch_task(adev, AMD_PP_TASK_READJUST_POWER_STATE, NULL, NULL);
 	} else {
 		adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps;
@@ -575,7 +572,7 @@ static ssize_t amdgpu_set_pp_mclk_od(struct device *dev,
 	if (adev->powerplay.pp_funcs->set_mclk_od)
 		amdgpu_dpm_set_mclk_od(adev, (uint32_t)value);
 
-	if (adev->pp_enabled) {
+	if (adev->powerplay.pp_funcs->dispatch_tasks) {
 		amdgpu_dpm_dispatch_task(adev, AMD_PP_TASK_READJUST_POWER_STATE, NULL, NULL);
 	} else {
 		adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps;
@@ -959,9 +956,6 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
 	     attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
 		return 0;
 
-	if (adev->pp_enabled)
-		return effective_mode;
-
 	/* Skip fan attributes if fan is not present */
 	if (adev->pm.no_fan &&
 	    (attr == &sensor_dev_attr_pwm1.dev_attr.attr ||
@@ -1343,27 +1337,26 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
 		return ret;
 	}
 
-	if (adev->pp_enabled) {
-		ret = device_create_file(adev->dev, &dev_attr_pp_num_states);
-		if (ret) {
-			DRM_ERROR("failed to create device file pp_num_states\n");
-			return ret;
-		}
-		ret = device_create_file(adev->dev, &dev_attr_pp_cur_state);
-		if (ret) {
-			DRM_ERROR("failed to create device file pp_cur_state\n");
-			return ret;
-		}
-		ret = device_create_file(adev->dev, &dev_attr_pp_force_state);
-		if (ret) {
-			DRM_ERROR("failed to create device file pp_force_state\n");
-			return ret;
-		}
-		ret = device_create_file(adev->dev, &dev_attr_pp_table);
-		if (ret) {
-			DRM_ERROR("failed to create device file pp_table\n");
-			return ret;
-		}
+
+	ret = device_create_file(adev->dev, &dev_attr_pp_num_states);
+	if (ret) {
+		DRM_ERROR("failed to create device file pp_num_states\n");
+		return ret;
+	}
+	ret = device_create_file(adev->dev, &dev_attr_pp_cur_state);
+	if (ret) {
+		DRM_ERROR("failed to create device file pp_cur_state\n");
+		return ret;
+	}
+	ret = device_create_file(adev->dev, &dev_attr_pp_force_state);
+	if (ret) {
+		DRM_ERROR("failed to create device file pp_force_state\n");
+		return ret;
+	}
+	ret = device_create_file(adev->dev, &dev_attr_pp_table);
+	if (ret) {
+		DRM_ERROR("failed to create device file pp_table\n");
+		return ret;
 	}
 
 	ret = device_create_file(adev->dev, &dev_attr_pp_dpm_sclk);
@@ -1426,12 +1419,12 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
 		hwmon_device_unregister(adev->pm.int_hwmon_dev);
 	device_remove_file(adev->dev, &dev_attr_power_dpm_state);
 	device_remove_file(adev->dev, &dev_attr_power_dpm_force_performance_level);
-	if (adev->pp_enabled) {
-		device_remove_file(adev->dev, &dev_attr_pp_num_states);
-		device_remove_file(adev->dev, &dev_attr_pp_cur_state);
-		device_remove_file(adev->dev, &dev_attr_pp_force_state);
-		device_remove_file(adev->dev, &dev_attr_pp_table);
-	}
+
+	device_remove_file(adev->dev, &dev_attr_pp_num_states);
+	device_remove_file(adev->dev, &dev_attr_pp_cur_state);
+	device_remove_file(adev->dev, &dev_attr_pp_force_state);
+	device_remove_file(adev->dev, &dev_attr_pp_table);
+
 	device_remove_file(adev->dev, &dev_attr_pp_dpm_sclk);
 	device_remove_file(adev->dev, &dev_attr_pp_dpm_mclk);
 	device_remove_file(adev->dev, &dev_attr_pp_dpm_pcie);
@@ -1462,7 +1455,7 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
 			amdgpu_fence_wait_empty(ring);
 	}
 
-	if (adev->pp_enabled) {
+	if (adev->powerplay.pp_funcs->dispatch_tasks) {
 		amdgpu_dpm_dispatch_task(adev, AMD_PP_TASK_DISPLAY_CONFIG_CHANGE, NULL, NULL);
 	} else {
 		mutex_lock(&adev->pm.mutex);
@@ -1597,15 +1590,15 @@ static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data)
 	if  ((adev->flags & AMD_IS_PX) &&
 	     (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) {
 		seq_printf(m, "PX asic powered off\n");
-	} else if (adev->pp_enabled) {
-		return amdgpu_debugfs_pm_info_pp(m, adev);
-	} else {
+	} else if (adev->powerplay.pp_funcs->debugfs_print_current_performance_level) {
 		mutex_lock(&adev->pm.mutex);
 		if (adev->powerplay.pp_funcs->debugfs_print_current_performance_level)
 			adev->powerplay.pp_funcs->debugfs_print_current_performance_level(adev, m);
 		else
 			seq_printf(m, "Debugfs support not implemented for this asic\n");
 		mutex_unlock(&adev->pm.mutex);
+	} else {
+		return amdgpu_debugfs_pm_info_pp(m, adev);
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
index 2ed81cd..eb88665 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
@@ -59,7 +59,6 @@ static int amdgpu_pp_early_init(void *handle)
 	int ret = 0;
 
 	amd_pp = &(adev->powerplay);
-	adev->pp_enabled = false;
 	amd_pp->pp_handle = (void *)adev;
 
 	switch (adev->asic_type) {
@@ -73,7 +72,6 @@ static int amdgpu_pp_early_init(void *handle)
 	case CHIP_STONEY:
 	case CHIP_VEGA10:
 	case CHIP_RAVEN:
-		adev->pp_enabled = true;
 		amd_pp->cgs_device = amdgpu_cgs_create_device(adev);
 		if (amdgpu_create_pp_handle(adev))
 			return -EINVAL;
@@ -138,9 +136,6 @@ static int amdgpu_pp_late_init(void *handle)
 		ret = adev->powerplay.ip_funcs->late_init(
 					adev->powerplay.pp_handle);
 
-	if (adev->pp_enabled && adev->pm.dpm_enabled)
-		amdgpu_dpm_dispatch_task(adev, AMD_PP_TASK_COMPLETE_INIT, NULL, NULL);
-
 	return ret;
 }
 
@@ -212,7 +207,7 @@ static void amdgpu_pp_late_fini(void *handle)
 			  adev->powerplay.pp_handle);
 
 
-	if (adev->pp_enabled) {
+	if (adev->powerplay.cgs_device) {
 		amd_powerplay_destroy(adev->powerplay.pp_handle);
 		amdgpu_cgs_destroy_device(adev->powerplay.cgs_device);
 	}
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index 9f3f3b8..5c7415e 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -30,6 +30,9 @@
 #include "pp_instance.h"
 #include "power_state.h"
 
+static int pp_dpm_dispatch_tasks(void *handle, enum amd_pp_task task_id,
+		void *input, void *output);
+
 static inline int pp_check(struct pp_instance *handle)
 {
 	if (handle == NULL || handle->pp_valid != PP_VALID)
@@ -146,6 +149,19 @@ static int pp_hw_fini(void *handle)
 	return 0;
 }
 
+static int pp_late_init(void *handle)
+{
+	struct pp_instance *pp_handle = (struct pp_instance *)handle;
+	int ret = 0;
+
+	ret = pp_check(pp_handle);
+	if (ret == 0)
+		pp_dpm_dispatch_tasks(pp_handle,
+					AMD_PP_TASK_COMPLETE_INIT, NULL, NULL);
+
+	return 0;
+}
+
 static bool pp_is_idle(void *handle)
 {
 	return false;
@@ -254,7 +270,7 @@ static int pp_resume(void *handle)
 const struct amd_ip_funcs pp_ip_funcs = {
 	.name = "powerplay",
 	.early_init = pp_early_init,
-	.late_init = NULL,
+	.late_init = pp_late_init,
 	.sw_init = pp_sw_init,
 	.sw_fini = pp_sw_fini,
 	.hw_init = pp_hw_init,
-- 
1.9.1

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

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

* [PATCH 06/10] drm/amdgpu: add cgs interface to register pp handle
       [not found] ` <1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
                     ` (3 preceding siblings ...)
  2017-09-25 13:48   ` [PATCH 05/10] drm/amdgpu: delete pp_enable in adev Rex Zhu
@ 2017-09-25 13:49   ` Rex Zhu
  2017-09-25 13:49   ` [PATCH 07/10] drm/amdgpu: create powerplay by cgs interface Rex Zhu
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Rex Zhu @ 2017-09-25 13:49 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c  | 23 +++++++++++++++++++++++
 drivers/gpu/drm/amd/include/cgs_common.h |  8 ++++++++
 2 files changed, 31 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
index 1933253..fc9a50a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
@@ -42,6 +42,28 @@ struct amdgpu_cgs_device {
 	struct amdgpu_device *adev =					\
 		((struct amdgpu_cgs_device *)cgs_device)->adev
 
+static void* amdgpu_cgs_register_pp_handle(struct cgs_device *cgs_device,
+                       int (*call_back_func)(struct amd_pp_init *, void **))
+{
+	CGS_FUNC_ADEV;
+	struct amd_pp_init pp_init;
+	struct amd_powerplay *amd_pp;
+
+	if (call_back_func == NULL)
+		return NULL;
+
+       amd_pp = &(adev->powerplay);
+       pp_init.chip_family = adev->family;
+       pp_init.chip_id = adev->asic_type;
+       pp_init.pm_en = (amdgpu_dpm != 0 && !amdgpu_sriov_vf(adev)) ? true : false;
+       pp_init.feature_mask = amdgpu_pp_feature_mask;
+       pp_init.device = amdgpu_cgs_create_device(adev);
+       if (call_back_func(&pp_init, &(amd_pp->pp_handle)))
+               return NULL;
+
+       return adev->powerplay.pp_handle;
+}
+
 static int amdgpu_cgs_alloc_gpu_mem(struct cgs_device *cgs_device,
 				    enum cgs_gpu_mem_type type,
 				    uint64_t size, uint64_t align,
@@ -1188,6 +1210,7 @@ static int amdgpu_cgs_call_acpi_method(struct cgs_device *cgs_device,
 	.is_virtualization_enabled = amdgpu_cgs_is_virtualization_enabled,
 	.enter_safe_mode = amdgpu_cgs_enter_safe_mode,
 	.lock_grbm_idx = amdgpu_cgs_lock_grbm_idx,
+	.register_pp_handle = amdgpu_cgs_register_pp_handle,
 };
 
 static const struct cgs_os_ops amdgpu_cgs_os_ops = {
diff --git a/drivers/gpu/drm/amd/include/cgs_common.h b/drivers/gpu/drm/amd/include/cgs_common.h
index 030b146..675988d 100644
--- a/drivers/gpu/drm/amd/include/cgs_common.h
+++ b/drivers/gpu/drm/amd/include/cgs_common.h
@@ -423,6 +423,10 @@ typedef int (*cgs_query_system_info)(struct cgs_device *cgs_device,
 
 typedef void (*cgs_lock_grbm_idx)(struct cgs_device *cgs_device, bool lock);
 
+struct amd_pp_init;
+typedef void* (*cgs_register_pp_handle)(struct cgs_device *cgs_device,
+			int (*call_back_func)(struct amd_pp_init *, void **));
+
 struct cgs_ops {
 	/* memory management calls (similar to KFD interface) */
 	cgs_alloc_gpu_mem_t alloc_gpu_mem;
@@ -459,6 +463,7 @@ struct cgs_ops {
 	cgs_is_virtualization_enabled_t is_virtualization_enabled;
 	cgs_enter_safe_mode enter_safe_mode;
 	cgs_lock_grbm_idx lock_grbm_idx;
+	cgs_register_pp_handle register_pp_handle;
 };
 
 struct cgs_os_ops; /* To be define in OS-specific CGS header */
@@ -537,4 +542,7 @@ struct cgs_device
 
 #define cgs_lock_grbm_idx(cgs_device, lock) \
 		CGS_CALL(lock_grbm_idx, cgs_device, lock)
+#define cgs_register_pp_handle(cgs_device, call_back_func) \
+		CGS_CALL(register_pp_handle, cgs_device, call_back_func)
+
 #endif /* _CGS_COMMON_H */
-- 
1.9.1

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

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

* [PATCH 07/10] drm/amdgpu: create powerplay by cgs interface
       [not found] ` <1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
                     ` (4 preceding siblings ...)
  2017-09-25 13:49   ` [PATCH 06/10] drm/amdgpu: add cgs interface to register pp handle Rex Zhu
@ 2017-09-25 13:49   ` Rex Zhu
       [not found]     ` <1506347344-26516-7-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
  2017-09-25 13:49   ` [PATCH 08/10] drm/amd/powerplay: change dmesg log level in powerplay Rex Zhu
                     ` (2 subsequent siblings)
  8 siblings, 1 reply; 13+ messages in thread
From: Rex Zhu @ 2017-09-25 13:49 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>

Change-Id: I3b2fa446fd7e233042794fe3d2fb5cbce903fe2d
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c     | 30 +--------
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c     | 81 +++++++++++++----------
 drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h |  5 --
 3 files changed, 48 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
index eb88665..1649b1e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
@@ -34,24 +34,6 @@
 #include "cik_dpm.h"
 #include "vi_dpm.h"
 
-static int amdgpu_create_pp_handle(struct amdgpu_device *adev)
-{
-	struct amd_pp_init pp_init;
-	struct amd_powerplay *amd_pp;
-	int ret;
-
-	amd_pp = &(adev->powerplay);
-	pp_init.chip_family = adev->family;
-	pp_init.chip_id = adev->asic_type;
-	pp_init.pm_en = (amdgpu_dpm != 0 && !amdgpu_sriov_vf(adev)) ? true : false;
-	pp_init.feature_mask = amdgpu_pp_feature_mask;
-	pp_init.device = amd_pp->cgs_device;
-	ret = amd_powerplay_create(&pp_init, &(amd_pp->pp_handle));
-	if (ret)
-		return -EINVAL;
-	return 0;
-}
-
 static int amdgpu_pp_early_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -73,8 +55,6 @@ static int amdgpu_pp_early_init(void *handle)
 	case CHIP_VEGA10:
 	case CHIP_RAVEN:
 		amd_pp->cgs_device = amdgpu_cgs_create_device(adev);
-		if (amdgpu_create_pp_handle(adev))
-			return -EINVAL;
 		amd_pp->ip_funcs = &pp_ip_funcs;
 		amd_pp->pp_funcs = &pp_dpm_funcs;
 		break;
@@ -97,8 +77,6 @@ static int amdgpu_pp_early_init(void *handle)
 			amd_pp->pp_funcs = &ci_dpm_funcs;
 		} else {
 			amd_pp->cgs_device = amdgpu_cgs_create_device(adev);
-			if (amdgpu_create_pp_handle(adev))
-				return -EINVAL;
 			amd_pp->ip_funcs = &pp_ip_funcs;
 			amd_pp->pp_funcs = &pp_dpm_funcs;
 		}
@@ -117,7 +95,8 @@ static int amdgpu_pp_early_init(void *handle)
 
 	if (adev->powerplay.ip_funcs->early_init)
 		ret = adev->powerplay.ip_funcs->early_init(
-					adev->powerplay.pp_handle);
+					amd_pp->cgs_device ? amd_pp->cgs_device :
+					amd_pp->pp_handle);
 
 	if (ret == PP_DPM_DISABLED) {
 		adev->pm.dpm_enabled = false;
@@ -206,11 +185,8 @@ static void amdgpu_pp_late_fini(void *handle)
 		adev->powerplay.ip_funcs->late_fini(
 			  adev->powerplay.pp_handle);
 
-
-	if (adev->powerplay.cgs_device) {
-		amd_powerplay_destroy(adev->powerplay.pp_handle);
+	if (adev->powerplay.cgs_device)
 		amdgpu_cgs_destroy_device(adev->powerplay.cgs_device);
-	}
 }
 
 static int amdgpu_pp_suspend(void *handle)
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index 5c7415e..7c1a974 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -50,10 +50,47 @@ static inline int pp_check(struct pp_instance *handle)
 	return 0;
 }
 
+static int amd_powerplay_create(struct amd_pp_init *pp_init,
+				void **handle)
+{
+	struct pp_instance *instance;
+
+	if (pp_init == NULL || handle == NULL)
+		return -EINVAL;
+
+	instance = kzalloc(sizeof(struct pp_instance), GFP_KERNEL);
+	if (instance == NULL)
+		return -ENOMEM;
+
+	instance->pp_valid = PP_VALID;
+	instance->chip_family = pp_init->chip_family;
+	instance->chip_id = pp_init->chip_id;
+	instance->pm_en = pp_init->pm_en;
+	instance->feature_mask = pp_init->feature_mask;
+	instance->device = pp_init->device;
+	mutex_init(&instance->pp_lock);
+	*handle = instance;
+	return 0;
+}
+
+static int amd_powerplay_destroy(void *handle)
+{
+	struct pp_instance *instance = (struct pp_instance *)handle;
+
+	kfree(instance->hwmgr);
+	instance->hwmgr = NULL;
+
+	kfree(instance);
+	instance = NULL;
+	return 0;
+}
+
 static int pp_early_init(void *handle)
 {
 	int ret;
-	struct pp_instance *pp_handle = (struct pp_instance *)handle;
+	struct pp_instance *pp_handle;
+
+	pp_handle = cgs_register_pp_handle(handle, amd_powerplay_create);
 
 	ret = hwmgr_early_init(pp_handle);
 	if (ret)
@@ -162,6 +199,12 @@ static int pp_late_init(void *handle)
 	return 0;
 }
 
+static void pp_late_fini(void *handle)
+{
+	amd_powerplay_destroy(handle);
+}
+
+
 static bool pp_is_idle(void *handle)
 {
 	return false;
@@ -275,6 +318,7 @@ static int pp_resume(void *handle)
 	.sw_fini = pp_sw_fini,
 	.hw_init = pp_hw_init,
 	.hw_fini = pp_hw_fini,
+	.late_fini = pp_late_fini,
 	.suspend = pp_suspend,
 	.resume = pp_resume,
 	.is_idle = pp_is_idle,
@@ -1138,41 +1182,6 @@ static int pp_dpm_switch_power_profile(void *handle,
 	.switch_power_profile = pp_dpm_switch_power_profile,
 };
 
-int amd_powerplay_create(struct amd_pp_init *pp_init,
-				void **handle)
-{
-	struct pp_instance *instance;
-
-	if (pp_init == NULL || handle == NULL)
-		return -EINVAL;
-
-	instance = kzalloc(sizeof(struct pp_instance), GFP_KERNEL);
-	if (instance == NULL)
-		return -ENOMEM;
-
-	instance->pp_valid = PP_VALID;
-	instance->chip_family = pp_init->chip_family;
-	instance->chip_id = pp_init->chip_id;
-	instance->pm_en = pp_init->pm_en;
-	instance->feature_mask = pp_init->feature_mask;
-	instance->device = pp_init->device;
-	mutex_init(&instance->pp_lock);
-	*handle = instance;
-	return 0;
-}
-
-int amd_powerplay_destroy(void *handle)
-{
-	struct pp_instance *instance = (struct pp_instance *)handle;
-
-	kfree(instance->hwmgr);
-	instance->hwmgr = NULL;
-
-	kfree(instance);
-	instance = NULL;
-	return 0;
-}
-
 int amd_powerplay_reset(void *handle)
 {
 	struct pp_instance *instance = (struct pp_instance *)handle;
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
index 437d785..916b6c4 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
@@ -274,11 +274,6 @@ struct amd_powerplay {
 	const struct amd_pm_funcs *pp_funcs;
 };
 
-int amd_powerplay_create(struct amd_pp_init *pp_init,
-				void **handle);
-
-int amd_powerplay_destroy(void *handle);
-
 int amd_powerplay_reset(void *handle);
 
 int amd_powerplay_display_configuration_change(void *handle,
-- 
1.9.1

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

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

* [PATCH 08/10] drm/amd/powerplay: change dmesg log level in powerplay
       [not found] ` <1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
                     ` (5 preceding siblings ...)
  2017-09-25 13:49   ` [PATCH 07/10] drm/amdgpu: create powerplay by cgs interface Rex Zhu
@ 2017-09-25 13:49   ` Rex Zhu
  2017-09-25 13:49   ` [PATCH 09/10] drm/amdgpu: add comments in struct amd_pm_funcs define Rex Zhu
  2017-09-25 13:49   ` [PATCH 10/10] drm/amd/powerplay: export new interfaces in amd_pm_funcs Rex Zhu
  8 siblings, 0 replies; 13+ messages in thread
From: Rex Zhu @ 2017-09-25 13:49 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

Use pr_debug to prevent spamming unimportant dmesg.

Change-Id: I18b4df61d9d36f081df8ad3ed047eb195da70e7c
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
index 73bb99d..189f3b5 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
@@ -704,7 +704,7 @@ static int cz_update_sclk_limit(struct pp_hwmgr *hwmgr)
 
 	clock = hwmgr->display_config.min_core_set_clock;
 	if (clock == 0)
-		pr_info("min_core_set_clock not set\n");
+		pr_debug("min_core_set_clock not set\n");
 
 	if (cz_hwmgr->sclk_dpm.hard_min_clk != clock) {
 		cz_hwmgr->sclk_dpm.hard_min_clk = clock;
-- 
1.9.1

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

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

* [PATCH 09/10] drm/amdgpu: add comments in struct amd_pm_funcs define
       [not found] ` <1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
                     ` (6 preceding siblings ...)
  2017-09-25 13:49   ` [PATCH 08/10] drm/amd/powerplay: change dmesg log level in powerplay Rex Zhu
@ 2017-09-25 13:49   ` Rex Zhu
  2017-09-25 13:49   ` [PATCH 10/10] drm/amd/powerplay: export new interfaces in amd_pm_funcs Rex Zhu
  8 siblings, 0 replies; 13+ messages in thread
From: Rex Zhu @ 2017-09-25 13:49 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

Change-Id: Ie54071d41fc8d67cb35a89cd500514dc067a9192
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/gpu/drm/amd/include/amd_shared.h | 51 ++++++++++++++++++--------------
 1 file changed, 29 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
index 48c4439..292f602 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -237,38 +237,44 @@ struct amd_ip_funcs {
 struct pp_states_info;
 
 struct amd_pm_funcs {
-	int (*get_temperature)(void *handle);
+/* export for dpm on ci and si */
 	int (*pre_set_power_state)(void *handle);
 	int (*set_power_state)(void *handle);
 	void (*post_set_power_state)(void *handle);
 	void (*display_configuration_changed)(void *handle);
-	u32 (*get_sclk)(void *handle, bool low);
-	u32 (*get_mclk)(void *handle, bool low);
 	void (*print_power_state)(void *handle, void *ps);
-	void (*debugfs_print_current_performance_level)(void *handle, struct seq_file *m);
-	int (*force_performance_level)(void *handle, enum amd_dpm_forced_level level);
 	bool (*vblank_too_short)(void *handle);
-	void (*powergate_uvd)(void *handle, bool gate);
-	void (*powergate_vce)(void *handle, bool gate);
 	void (*enable_bapm)(void *handle, bool enable);
+	int (*check_state_equal)(void *handle,
+				void  *cps,
+				void  *rps,
+				bool  *equal);
+/* export for sysfs */
+	int (*get_temperature)(void *handle);
 	void (*set_fan_control_mode)(void *handle, u32 mode);
 	u32 (*get_fan_control_mode)(void *handle);
 	int (*set_fan_speed_percent)(void *handle, u32 speed);
 	int (*get_fan_speed_percent)(void *handle, u32 *speed);
 	int (*force_clock_level)(void *handle, enum pp_clock_type type, uint32_t mask);
 	int (*print_clock_levels)(void *handle, enum pp_clock_type type, char *buf);
+	int (*force_performance_level)(void *handle, enum amd_dpm_forced_level level);
+
 	int (*get_sclk_od)(void *handle);
 	int (*set_sclk_od)(void *handle, uint32_t value);
 	int (*get_mclk_od)(void *handle);
 	int (*set_mclk_od)(void *handle, uint32_t value);
-	int (*check_state_equal)(void *handle,
-				void  *cps,
-				void  *rps,
-				bool  *equal);
-	int (*read_sensor)(void *handle, int idx, void *value,
-			   int *size);
 
-	struct amd_vce_state* (*get_vce_clock_state)(void *handle, u32 idx);
+	int (*read_sensor)(void *handle, int idx, void *value, int *size);
+
+	enum amd_dpm_forced_level (*get_performance_level)(void *handle);
+	enum amd_pm_state_type (*get_current_power_state)(void *handle);
+
+	int (*get_fan_speed_rpm)(void *handle, uint32_t *rpm);
+	int (*get_pp_num_states)(void *handle, struct pp_states_info *data);
+	int (*get_pp_table)(void *handle, char **table);
+	int (*set_pp_table)(void *handle, const char *buf, size_t size);
+	void (*debugfs_print_current_performance_level)(void *handle, struct seq_file *m);
+
 	int (*reset_power_profile_state)(void *handle,
 			struct amd_pp_profile *request);
 	int (*get_power_profile_state)(void *handle,
@@ -277,16 +283,17 @@ struct amd_pm_funcs {
 			struct amd_pp_profile *request);
 	int (*switch_power_profile)(void *handle,
 			enum amd_pp_profile_type type);
-	int (*load_firmware)(void *handle);
-	int (*wait_for_fw_loading_complete)(void *handle);
-	enum amd_dpm_forced_level (*get_performance_level)(void *handle);
-	enum amd_pm_state_type (*get_current_power_state)(void *handle);
+/* export for amdgpu */
+	void (*powergate_uvd)(void *handle, bool gate);
+	void (*powergate_vce)(void *handle, bool gate);
+	struct amd_vce_state* (*get_vce_clock_state)(void *handle, u32 idx);
 	int (*dispatch_tasks)(void *handle, enum amd_pp_task task_id,
 				   void *input, void *output);
-	int (*get_fan_speed_rpm)(void *handle, uint32_t *rpm);
-	int (*get_pp_num_states)(void *handle, struct pp_states_info *data);
-	int (*get_pp_table)(void *handle, char **table);
-	int (*set_pp_table)(void *handle, const char *buf, size_t size);
+	int (*load_firmware)(void *handle);
+	int (*wait_for_fw_loading_complete)(void *handle);
+/* export for DISPLAY */
+	u32 (*get_sclk)(void *handle, bool low);
+	u32 (*get_mclk)(void *handle, bool low);
 };
 
 
-- 
1.9.1

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

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

* [PATCH 10/10] drm/amd/powerplay: export new interfaces in amd_pm_funcs
       [not found] ` <1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
                     ` (7 preceding siblings ...)
  2017-09-25 13:49   ` [PATCH 09/10] drm/amdgpu: add comments in struct amd_pm_funcs define Rex Zhu
@ 2017-09-25 13:49   ` Rex Zhu
       [not found]     ` <1506347344-26516-10-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
  8 siblings, 1 reply; 13+ messages in thread
From: Rex Zhu @ 2017-09-25 13:49 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

Change-Id: If13500f76da6e42f50d40fc794fc5e1e5dc143bf
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/gpu/drm/amd/include/amd_shared.h | 38 +++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
index 292f602..89ad5bf 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -232,9 +232,18 @@ struct amd_ip_funcs {
 	void (*get_clockgating_state)(void *handle, u32 *flags);
 };
 
-enum amd_pp_task;
 
+enum amd_pp_task;
+enum amd_pp_clock_type;
 struct pp_states_info;
+struct amd_pp_simple_clock_info;
+struct amd_pp_display_configuration;
+struct amd_pp_clock_info;
+struct pp_display_clock_request;
+struct pp_wm_sets_with_clock_ranges_soc15;
+struct pp_clock_levels_with_voltage;
+struct pp_clock_levels_with_latency;
+struct amd_pp_clocks;
 
 struct amd_pm_funcs {
 /* export for dpm on ci and si */
@@ -258,17 +267,13 @@ struct amd_pm_funcs {
 	int (*force_clock_level)(void *handle, enum pp_clock_type type, uint32_t mask);
 	int (*print_clock_levels)(void *handle, enum pp_clock_type type, char *buf);
 	int (*force_performance_level)(void *handle, enum amd_dpm_forced_level level);
-
 	int (*get_sclk_od)(void *handle);
 	int (*set_sclk_od)(void *handle, uint32_t value);
 	int (*get_mclk_od)(void *handle);
 	int (*set_mclk_od)(void *handle, uint32_t value);
-
 	int (*read_sensor)(void *handle, int idx, void *value, int *size);
-
 	enum amd_dpm_forced_level (*get_performance_level)(void *handle);
 	enum amd_pm_state_type (*get_current_power_state)(void *handle);
-
 	int (*get_fan_speed_rpm)(void *handle, uint32_t *rpm);
 	int (*get_pp_num_states)(void *handle, struct pp_states_info *data);
 	int (*get_pp_table)(void *handle, char **table);
@@ -283,6 +288,7 @@ struct amd_pm_funcs {
 			struct amd_pp_profile *request);
 	int (*switch_power_profile)(void *handle,
 			enum amd_pp_profile_type type);
+
 /* export for amdgpu */
 	void (*powergate_uvd)(void *handle, bool gate);
 	void (*powergate_vce)(void *handle, bool gate);
@@ -291,9 +297,31 @@ struct amd_pm_funcs {
 				   void *input, void *output);
 	int (*load_firmware)(void *handle);
 	int (*wait_for_fw_loading_complete)(void *handle);
+	int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id);
 /* export for DISPLAY */
 	u32 (*get_sclk)(void *handle, bool low);
 	u32 (*get_mclk)(void *handle, bool low);
+	int (*display_configuration_change)(void *handle,
+		const struct amd_pp_display_configuration *input);
+	int (*get_display_power_level)(void *handle,
+		struct amd_pp_simple_clock_info *output);
+	int (*get_current_clocks)(void *handle,
+		struct amd_pp_clock_info *clocks);
+	int (*get_clock_by_type)(void *handle,
+		enum amd_pp_clock_type type,
+		struct amd_pp_clocks *clocks);
+	int (*get_clock_by_type_with_latency)(void *handle,
+		enum amd_pp_clock_type type,
+		struct pp_clock_levels_with_latency *clocks);
+	int (*get_clock_by_type_with_voltage)(void *handle,
+		enum amd_pp_clock_type type,
+		struct pp_clock_levels_with_voltage *clocks);
+	int (*set_watermarks_for_clocks_ranges)(void *handle,
+		struct pp_wm_sets_with_clock_ranges_soc15 *wm_with_clock_ranges);
+	int (*display_clock_voltage_request)(void *handle,
+		struct pp_display_clock_request *clock);
+	int (*get_display_mode_validation_clocks)(void *handle,
+		struct amd_pp_simple_clock_info *clocks);
 };
 
 
-- 
1.9.1

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

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

* Re: [PATCH 07/10] drm/amdgpu: create powerplay by cgs interface
       [not found]     ` <1506347344-26516-7-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
@ 2017-09-25 16:13       ` Tom St Denis
       [not found]         ` <a47193f7-925d-81ae-fbc4-2647c4ee3ea8-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Tom St Denis @ 2017-09-25 16:13 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

This doesn't apply on top of drm-next I don't know why since "git 
status" doesn't report any conflicting files...

Tom

On 25/09/17 09:49 AM, Rex Zhu wrote:
> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
> 
> Change-Id: I3b2fa446fd7e233042794fe3d2fb5cbce903fe2d
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c     | 30 +--------
>   drivers/gpu/drm/amd/powerplay/amd_powerplay.c     | 81 +++++++++++++----------
>   drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h |  5 --
>   3 files changed, 48 insertions(+), 68 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
> index eb88665..1649b1e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
> @@ -34,24 +34,6 @@
>   #include "cik_dpm.h"
>   #include "vi_dpm.h"
>   
> -static int amdgpu_create_pp_handle(struct amdgpu_device *adev)
> -{
> -	struct amd_pp_init pp_init;
> -	struct amd_powerplay *amd_pp;
> -	int ret;
> -
> -	amd_pp = &(adev->powerplay);
> -	pp_init.chip_family = adev->family;
> -	pp_init.chip_id = adev->asic_type;
> -	pp_init.pm_en = (amdgpu_dpm != 0 && !amdgpu_sriov_vf(adev)) ? true : false;
> -	pp_init.feature_mask = amdgpu_pp_feature_mask;
> -	pp_init.device = amd_pp->cgs_device;
> -	ret = amd_powerplay_create(&pp_init, &(amd_pp->pp_handle));
> -	if (ret)
> -		return -EINVAL;
> -	return 0;
> -}
> -
>   static int amdgpu_pp_early_init(void *handle)
>   {
>   	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> @@ -73,8 +55,6 @@ static int amdgpu_pp_early_init(void *handle)
>   	case CHIP_VEGA10:
>   	case CHIP_RAVEN:
>   		amd_pp->cgs_device = amdgpu_cgs_create_device(adev);
> -		if (amdgpu_create_pp_handle(adev))
> -			return -EINVAL;
>   		amd_pp->ip_funcs = &pp_ip_funcs;
>   		amd_pp->pp_funcs = &pp_dpm_funcs;
>   		break;
> @@ -97,8 +77,6 @@ static int amdgpu_pp_early_init(void *handle)
>   			amd_pp->pp_funcs = &ci_dpm_funcs;
>   		} else {
>   			amd_pp->cgs_device = amdgpu_cgs_create_device(adev);
> -			if (amdgpu_create_pp_handle(adev))
> -				return -EINVAL;
>   			amd_pp->ip_funcs = &pp_ip_funcs;
>   			amd_pp->pp_funcs = &pp_dpm_funcs;
>   		}
> @@ -117,7 +95,8 @@ static int amdgpu_pp_early_init(void *handle)
>   
>   	if (adev->powerplay.ip_funcs->early_init)
>   		ret = adev->powerplay.ip_funcs->early_init(
> -					adev->powerplay.pp_handle);
> +					amd_pp->cgs_device ? amd_pp->cgs_device :
> +					amd_pp->pp_handle);
>   
>   	if (ret == PP_DPM_DISABLED) {
>   		adev->pm.dpm_enabled = false;
> @@ -206,11 +185,8 @@ static void amdgpu_pp_late_fini(void *handle)
>   		adev->powerplay.ip_funcs->late_fini(
>   			  adev->powerplay.pp_handle);
>   
> -
> -	if (adev->powerplay.cgs_device) {
> -		amd_powerplay_destroy(adev->powerplay.pp_handle);
> +	if (adev->powerplay.cgs_device)
>   		amdgpu_cgs_destroy_device(adev->powerplay.cgs_device);
> -	}
>   }
>   
>   static int amdgpu_pp_suspend(void *handle)
> diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> index 5c7415e..7c1a974 100644
> --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> @@ -50,10 +50,47 @@ static inline int pp_check(struct pp_instance *handle)
>   	return 0;
>   }
>   
> +static int amd_powerplay_create(struct amd_pp_init *pp_init,
> +				void **handle)
> +{
> +	struct pp_instance *instance;
> +
> +	if (pp_init == NULL || handle == NULL)
> +		return -EINVAL;
> +
> +	instance = kzalloc(sizeof(struct pp_instance), GFP_KERNEL);
> +	if (instance == NULL)
> +		return -ENOMEM;
> +
> +	instance->pp_valid = PP_VALID;
> +	instance->chip_family = pp_init->chip_family;
> +	instance->chip_id = pp_init->chip_id;
> +	instance->pm_en = pp_init->pm_en;
> +	instance->feature_mask = pp_init->feature_mask;
> +	instance->device = pp_init->device;
> +	mutex_init(&instance->pp_lock);
> +	*handle = instance;
> +	return 0;
> +}
> +
> +static int amd_powerplay_destroy(void *handle)
> +{
> +	struct pp_instance *instance = (struct pp_instance *)handle;
> +
> +	kfree(instance->hwmgr);
> +	instance->hwmgr = NULL;
> +
> +	kfree(instance);
> +	instance = NULL;
> +	return 0;
> +}
> +
>   static int pp_early_init(void *handle)
>   {
>   	int ret;
> -	struct pp_instance *pp_handle = (struct pp_instance *)handle;
> +	struct pp_instance *pp_handle;
> +
> +	pp_handle = cgs_register_pp_handle(handle, amd_powerplay_create);
>   
>   	ret = hwmgr_early_init(pp_handle);
>   	if (ret)
> @@ -162,6 +199,12 @@ static int pp_late_init(void *handle)
>   	return 0;
>   }
>   
> +static void pp_late_fini(void *handle)
> +{
> +	amd_powerplay_destroy(handle);
> +}
> +
> +
>   static bool pp_is_idle(void *handle)
>   {
>   	return false;
> @@ -275,6 +318,7 @@ static int pp_resume(void *handle)
>   	.sw_fini = pp_sw_fini,
>   	.hw_init = pp_hw_init,
>   	.hw_fini = pp_hw_fini,
> +	.late_fini = pp_late_fini,
>   	.suspend = pp_suspend,
>   	.resume = pp_resume,
>   	.is_idle = pp_is_idle,
> @@ -1138,41 +1182,6 @@ static int pp_dpm_switch_power_profile(void *handle,
>   	.switch_power_profile = pp_dpm_switch_power_profile,
>   };
>   
> -int amd_powerplay_create(struct amd_pp_init *pp_init,
> -				void **handle)
> -{
> -	struct pp_instance *instance;
> -
> -	if (pp_init == NULL || handle == NULL)
> -		return -EINVAL;
> -
> -	instance = kzalloc(sizeof(struct pp_instance), GFP_KERNEL);
> -	if (instance == NULL)
> -		return -ENOMEM;
> -
> -	instance->pp_valid = PP_VALID;
> -	instance->chip_family = pp_init->chip_family;
> -	instance->chip_id = pp_init->chip_id;
> -	instance->pm_en = pp_init->pm_en;
> -	instance->feature_mask = pp_init->feature_mask;
> -	instance->device = pp_init->device;
> -	mutex_init(&instance->pp_lock);
> -	*handle = instance;
> -	return 0;
> -}
> -
> -int amd_powerplay_destroy(void *handle)
> -{
> -	struct pp_instance *instance = (struct pp_instance *)handle;
> -
> -	kfree(instance->hwmgr);
> -	instance->hwmgr = NULL;
> -
> -	kfree(instance);
> -	instance = NULL;
> -	return 0;
> -}
> -
>   int amd_powerplay_reset(void *handle)
>   {
>   	struct pp_instance *instance = (struct pp_instance *)handle;
> diff --git a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
> index 437d785..916b6c4 100644
> --- a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
> +++ b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
> @@ -274,11 +274,6 @@ struct amd_powerplay {
>   	const struct amd_pm_funcs *pp_funcs;
>   };
>   
> -int amd_powerplay_create(struct amd_pp_init *pp_init,
> -				void **handle);
> -
> -int amd_powerplay_destroy(void *handle);
> -
>   int amd_powerplay_reset(void *handle);
>   
>   int amd_powerplay_display_configuration_change(void *handle,
> 

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

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

* Re: [PATCH 07/10] drm/amdgpu: create powerplay by cgs interface
       [not found]         ` <a47193f7-925d-81ae-fbc4-2647c4ee3ea8-5C7GfCeVMHo@public.gmane.org>
@ 2017-09-25 16:22           ` Tom St Denis
  0 siblings, 0 replies; 13+ messages in thread
From: Tom St Denis @ 2017-09-25 16:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Nevermind it applies fine after the series you pushed a bit ago today.

Cheers,
Tom

On 25/09/17 12:13 PM, Tom St Denis wrote:
> This doesn't apply on top of drm-next I don't know why since "git 
> status" doesn't report any conflicting files...
> 
> Tom
> 
> On 25/09/17 09:49 AM, Rex Zhu wrote:
>> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
>>
>> Change-Id: I3b2fa446fd7e233042794fe3d2fb5cbce903fe2d
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c     | 30 +--------
>>   drivers/gpu/drm/amd/powerplay/amd_powerplay.c     | 81 
>> +++++++++++++----------
>>   drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h |  5 --
>>   3 files changed, 48 insertions(+), 68 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
>> index eb88665..1649b1e 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
>> @@ -34,24 +34,6 @@
>>   #include "cik_dpm.h"
>>   #include "vi_dpm.h"
>> -static int amdgpu_create_pp_handle(struct amdgpu_device *adev)
>> -{
>> -    struct amd_pp_init pp_init;
>> -    struct amd_powerplay *amd_pp;
>> -    int ret;
>> -
>> -    amd_pp = &(adev->powerplay);
>> -    pp_init.chip_family = adev->family;
>> -    pp_init.chip_id = adev->asic_type;
>> -    pp_init.pm_en = (amdgpu_dpm != 0 && !amdgpu_sriov_vf(adev)) ? 
>> true : false;
>> -    pp_init.feature_mask = amdgpu_pp_feature_mask;
>> -    pp_init.device = amd_pp->cgs_device;
>> -    ret = amd_powerplay_create(&pp_init, &(amd_pp->pp_handle));
>> -    if (ret)
>> -        return -EINVAL;
>> -    return 0;
>> -}
>> -
>>   static int amdgpu_pp_early_init(void *handle)
>>   {
>>       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>> @@ -73,8 +55,6 @@ static int amdgpu_pp_early_init(void *handle)
>>       case CHIP_VEGA10:
>>       case CHIP_RAVEN:
>>           amd_pp->cgs_device = amdgpu_cgs_create_device(adev);
>> -        if (amdgpu_create_pp_handle(adev))
>> -            return -EINVAL;
>>           amd_pp->ip_funcs = &pp_ip_funcs;
>>           amd_pp->pp_funcs = &pp_dpm_funcs;
>>           break;
>> @@ -97,8 +77,6 @@ static int amdgpu_pp_early_init(void *handle)
>>               amd_pp->pp_funcs = &ci_dpm_funcs;
>>           } else {
>>               amd_pp->cgs_device = amdgpu_cgs_create_device(adev);
>> -            if (amdgpu_create_pp_handle(adev))
>> -                return -EINVAL;
>>               amd_pp->ip_funcs = &pp_ip_funcs;
>>               amd_pp->pp_funcs = &pp_dpm_funcs;
>>           }
>> @@ -117,7 +95,8 @@ static int amdgpu_pp_early_init(void *handle)
>>       if (adev->powerplay.ip_funcs->early_init)
>>           ret = adev->powerplay.ip_funcs->early_init(
>> -                    adev->powerplay.pp_handle);
>> +                    amd_pp->cgs_device ? amd_pp->cgs_device :
>> +                    amd_pp->pp_handle);
>>       if (ret == PP_DPM_DISABLED) {
>>           adev->pm.dpm_enabled = false;
>> @@ -206,11 +185,8 @@ static void amdgpu_pp_late_fini(void *handle)
>>           adev->powerplay.ip_funcs->late_fini(
>>                 adev->powerplay.pp_handle);
>> -
>> -    if (adev->powerplay.cgs_device) {
>> -        amd_powerplay_destroy(adev->powerplay.pp_handle);
>> +    if (adev->powerplay.cgs_device)
>>           amdgpu_cgs_destroy_device(adev->powerplay.cgs_device);
>> -    }
>>   }
>>   static int amdgpu_pp_suspend(void *handle)
>> diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c 
>> b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
>> index 5c7415e..7c1a974 100644
>> --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
>> +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
>> @@ -50,10 +50,47 @@ static inline int pp_check(struct pp_instance 
>> *handle)
>>       return 0;
>>   }
>> +static int amd_powerplay_create(struct amd_pp_init *pp_init,
>> +                void **handle)
>> +{
>> +    struct pp_instance *instance;
>> +
>> +    if (pp_init == NULL || handle == NULL)
>> +        return -EINVAL;
>> +
>> +    instance = kzalloc(sizeof(struct pp_instance), GFP_KERNEL);
>> +    if (instance == NULL)
>> +        return -ENOMEM;
>> +
>> +    instance->pp_valid = PP_VALID;
>> +    instance->chip_family = pp_init->chip_family;
>> +    instance->chip_id = pp_init->chip_id;
>> +    instance->pm_en = pp_init->pm_en;
>> +    instance->feature_mask = pp_init->feature_mask;
>> +    instance->device = pp_init->device;
>> +    mutex_init(&instance->pp_lock);
>> +    *handle = instance;
>> +    return 0;
>> +}
>> +
>> +static int amd_powerplay_destroy(void *handle)
>> +{
>> +    struct pp_instance *instance = (struct pp_instance *)handle;
>> +
>> +    kfree(instance->hwmgr);
>> +    instance->hwmgr = NULL;
>> +
>> +    kfree(instance);
>> +    instance = NULL;
>> +    return 0;
>> +}
>> +
>>   static int pp_early_init(void *handle)
>>   {
>>       int ret;
>> -    struct pp_instance *pp_handle = (struct pp_instance *)handle;
>> +    struct pp_instance *pp_handle;
>> +
>> +    pp_handle = cgs_register_pp_handle(handle, amd_powerplay_create);
>>       ret = hwmgr_early_init(pp_handle);
>>       if (ret)
>> @@ -162,6 +199,12 @@ static int pp_late_init(void *handle)
>>       return 0;
>>   }
>> +static void pp_late_fini(void *handle)
>> +{
>> +    amd_powerplay_destroy(handle);
>> +}
>> +
>> +
>>   static bool pp_is_idle(void *handle)
>>   {
>>       return false;
>> @@ -275,6 +318,7 @@ static int pp_resume(void *handle)
>>       .sw_fini = pp_sw_fini,
>>       .hw_init = pp_hw_init,
>>       .hw_fini = pp_hw_fini,
>> +    .late_fini = pp_late_fini,
>>       .suspend = pp_suspend,
>>       .resume = pp_resume,
>>       .is_idle = pp_is_idle,
>> @@ -1138,41 +1182,6 @@ static int pp_dpm_switch_power_profile(void 
>> *handle,
>>       .switch_power_profile = pp_dpm_switch_power_profile,
>>   };
>> -int amd_powerplay_create(struct amd_pp_init *pp_init,
>> -                void **handle)
>> -{
>> -    struct pp_instance *instance;
>> -
>> -    if (pp_init == NULL || handle == NULL)
>> -        return -EINVAL;
>> -
>> -    instance = kzalloc(sizeof(struct pp_instance), GFP_KERNEL);
>> -    if (instance == NULL)
>> -        return -ENOMEM;
>> -
>> -    instance->pp_valid = PP_VALID;
>> -    instance->chip_family = pp_init->chip_family;
>> -    instance->chip_id = pp_init->chip_id;
>> -    instance->pm_en = pp_init->pm_en;
>> -    instance->feature_mask = pp_init->feature_mask;
>> -    instance->device = pp_init->device;
>> -    mutex_init(&instance->pp_lock);
>> -    *handle = instance;
>> -    return 0;
>> -}
>> -
>> -int amd_powerplay_destroy(void *handle)
>> -{
>> -    struct pp_instance *instance = (struct pp_instance *)handle;
>> -
>> -    kfree(instance->hwmgr);
>> -    instance->hwmgr = NULL;
>> -
>> -    kfree(instance);
>> -    instance = NULL;
>> -    return 0;
>> -}
>> -
>>   int amd_powerplay_reset(void *handle)
>>   {
>>       struct pp_instance *instance = (struct pp_instance *)handle;
>> diff --git a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h 
>> b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
>> index 437d785..916b6c4 100644
>> --- a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
>> +++ b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h
>> @@ -274,11 +274,6 @@ struct amd_powerplay {
>>       const struct amd_pm_funcs *pp_funcs;
>>   };
>> -int amd_powerplay_create(struct amd_pp_init *pp_init,
>> -                void **handle);
>> -
>> -int amd_powerplay_destroy(void *handle);
>> -
>>   int amd_powerplay_reset(void *handle);
>>   int amd_powerplay_display_configuration_change(void *handle,
>>
> 
> _______________________________________________
> 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] 13+ messages in thread

* Re: [PATCH 10/10] drm/amd/powerplay: export new interfaces in amd_pm_funcs
       [not found]     ` <1506347344-26516-10-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
@ 2017-09-26 16:24       ` Alex Deucher
  0 siblings, 0 replies; 13+ messages in thread
From: Alex Deucher @ 2017-09-26 16:24 UTC (permalink / raw)
  To: Rex Zhu; +Cc: amd-gfx list

On Mon, Sep 25, 2017 at 9:49 AM, Rex Zhu <Rex.Zhu@amd.com> wrote:
> Change-Id: If13500f76da6e42f50d40fc794fc5e1e5dc143bf
> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>

Series is:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/include/amd_shared.h | 38 +++++++++++++++++++++++++++-----
>  1 file changed, 33 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
> index 292f602..89ad5bf 100644
> --- a/drivers/gpu/drm/amd/include/amd_shared.h
> +++ b/drivers/gpu/drm/amd/include/amd_shared.h
> @@ -232,9 +232,18 @@ struct amd_ip_funcs {
>         void (*get_clockgating_state)(void *handle, u32 *flags);
>  };
>
> -enum amd_pp_task;
>
> +enum amd_pp_task;
> +enum amd_pp_clock_type;
>  struct pp_states_info;
> +struct amd_pp_simple_clock_info;
> +struct amd_pp_display_configuration;
> +struct amd_pp_clock_info;
> +struct pp_display_clock_request;
> +struct pp_wm_sets_with_clock_ranges_soc15;
> +struct pp_clock_levels_with_voltage;
> +struct pp_clock_levels_with_latency;
> +struct amd_pp_clocks;
>
>  struct amd_pm_funcs {
>  /* export for dpm on ci and si */
> @@ -258,17 +267,13 @@ struct amd_pm_funcs {
>         int (*force_clock_level)(void *handle, enum pp_clock_type type, uint32_t mask);
>         int (*print_clock_levels)(void *handle, enum pp_clock_type type, char *buf);
>         int (*force_performance_level)(void *handle, enum amd_dpm_forced_level level);
> -
>         int (*get_sclk_od)(void *handle);
>         int (*set_sclk_od)(void *handle, uint32_t value);
>         int (*get_mclk_od)(void *handle);
>         int (*set_mclk_od)(void *handle, uint32_t value);
> -
>         int (*read_sensor)(void *handle, int idx, void *value, int *size);
> -
>         enum amd_dpm_forced_level (*get_performance_level)(void *handle);
>         enum amd_pm_state_type (*get_current_power_state)(void *handle);
> -
>         int (*get_fan_speed_rpm)(void *handle, uint32_t *rpm);
>         int (*get_pp_num_states)(void *handle, struct pp_states_info *data);
>         int (*get_pp_table)(void *handle, char **table);
> @@ -283,6 +288,7 @@ struct amd_pm_funcs {
>                         struct amd_pp_profile *request);
>         int (*switch_power_profile)(void *handle,
>                         enum amd_pp_profile_type type);
> +
>  /* export for amdgpu */
>         void (*powergate_uvd)(void *handle, bool gate);
>         void (*powergate_vce)(void *handle, bool gate);
> @@ -291,9 +297,31 @@ struct amd_pm_funcs {
>                                    void *input, void *output);
>         int (*load_firmware)(void *handle);
>         int (*wait_for_fw_loading_complete)(void *handle);
> +       int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id);
>  /* export for DISPLAY */
>         u32 (*get_sclk)(void *handle, bool low);
>         u32 (*get_mclk)(void *handle, bool low);
> +       int (*display_configuration_change)(void *handle,
> +               const struct amd_pp_display_configuration *input);
> +       int (*get_display_power_level)(void *handle,
> +               struct amd_pp_simple_clock_info *output);
> +       int (*get_current_clocks)(void *handle,
> +               struct amd_pp_clock_info *clocks);
> +       int (*get_clock_by_type)(void *handle,
> +               enum amd_pp_clock_type type,
> +               struct amd_pp_clocks *clocks);
> +       int (*get_clock_by_type_with_latency)(void *handle,
> +               enum amd_pp_clock_type type,
> +               struct pp_clock_levels_with_latency *clocks);
> +       int (*get_clock_by_type_with_voltage)(void *handle,
> +               enum amd_pp_clock_type type,
> +               struct pp_clock_levels_with_voltage *clocks);
> +       int (*set_watermarks_for_clocks_ranges)(void *handle,
> +               struct pp_wm_sets_with_clock_ranges_soc15 *wm_with_clock_ranges);
> +       int (*display_clock_voltage_request)(void *handle,
> +               struct pp_display_clock_request *clock);
> +       int (*get_display_mode_validation_clocks)(void *handle,
> +               struct amd_pp_simple_clock_info *clocks);
>  };
>
>
> --
> 1.9.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] 13+ messages in thread

end of thread, other threads:[~2017-09-26 16:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25 13:48 [PATCH 01/10] drm/amdgpu: move common pm sysfs code to amdgpu_device.c Rex Zhu
     [not found] ` <1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
2017-09-25 13:48   ` [PATCH 02/10] drm/amdgpu: move amdgpu_ucode_init_bo " Rex Zhu
2017-09-25 13:48   ` [PATCH 03/10] drm/amd/powerplay: fix memory leak in powerplay Rex Zhu
2017-09-25 13:48   ` [PATCH 04/10] drm/amdgpu: delete dead code about fw load check Rex Zhu
2017-09-25 13:48   ` [PATCH 05/10] drm/amdgpu: delete pp_enable in adev Rex Zhu
2017-09-25 13:49   ` [PATCH 06/10] drm/amdgpu: add cgs interface to register pp handle Rex Zhu
2017-09-25 13:49   ` [PATCH 07/10] drm/amdgpu: create powerplay by cgs interface Rex Zhu
     [not found]     ` <1506347344-26516-7-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
2017-09-25 16:13       ` Tom St Denis
     [not found]         ` <a47193f7-925d-81ae-fbc4-2647c4ee3ea8-5C7GfCeVMHo@public.gmane.org>
2017-09-25 16:22           ` Tom St Denis
2017-09-25 13:49   ` [PATCH 08/10] drm/amd/powerplay: change dmesg log level in powerplay Rex Zhu
2017-09-25 13:49   ` [PATCH 09/10] drm/amdgpu: add comments in struct amd_pm_funcs define Rex Zhu
2017-09-25 13:49   ` [PATCH 10/10] drm/amd/powerplay: export new interfaces in amd_pm_funcs Rex Zhu
     [not found]     ` <1506347344-26516-10-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
2017-09-26 16:24       ` Alex Deucher

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.