Skip to contentSkip to conversation

drm/amdgpu: move common pm sysfs code to amdgpu_device.c

PATCH In review Rex Zhu 3 participants 13 messages Sep 25, 2017 – Sep 26, 2017 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Rex Zhu

author
#0 lore raw

PATCH 1/10 drm/amdgpu: move common pm sysfs code to amdgpu_device.c

Change-Id I4ad2c914081dd71b10a89f650fea87f9cbc9c859
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
index a86d856..599b310 100644
@@ -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);
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6 -0
index 9cbd3cd..723fc16 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +1 -6
index 2d2f0960..1ad6323 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/ci_dpm.c +0 -1
index 68ce1bd..68b505c 100644
@@ -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);
 
drivers/gpu/drm/amd/amdgpu/kv_dpm.c +0 -7
index b57399a..f33d1ff 100644
@@ -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);
 
drivers/gpu/drm/amd/amdgpu/si_dpm.c +0 -6
index 9b8db60..51fd0c9 100644
@@ -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);
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1506347344-26516-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 2/10 drm/amdgpu: move amdgpu_ucode_init_bo to amdgpu_device.c

Change-Id I8f1016d9d77437b80fce97dadaae52f49c2c901e
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8 -0
index 599b310..7b199c8 100644
@@ -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)
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +0 -5
index 1ad6323..c05e5a8 100644
@@ -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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -9
index 447d446..f1035a6 100644
@@ -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);
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#3 lore raw

PATCH 3/10 drm/amd/powerplay: fix memory leak in powerplay

In reply to a message not in the archive

cgs device not free.

Change-Id I89435944a1205cb1a8da93469db3a3633a54125e
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +6 -3
index c05e5a8..2ed81cd 100644
@@ -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)
drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +1 -0
index 435da26..437d785 100644
@@ -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;
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#4 lore raw

PATCH 4/10 drm/amdgpu: delete dead code about fw load check

In reply to a message not in the archive
Change-Id I1df6ff230a4fc95afdb319f37f24dd1cae82eaaa
---
 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(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +13 -47
index dfc10b1..e04de7a 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +5 -15
index acdee3a..67f375b 100644
@@ -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 */
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +5 -16
index 72f31cc..6d06f8e 100644
@@ -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 */
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#5 lore raw

PATCH 5/10 drm/amdgpu: delete pp_enable in adev

In reply to a message not in the archive

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

Change-Id I972700055e2ee4655ac1b24fe7ff2dacdaf49979
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
index a5b0b67..518ba7c 100644
@@ -1529,7 +1529,6 @@ struct amdgpu_device {
 
 	/* powerplay */
 	struct amd_powerplay		powerplay;
-	bool				pp_enabled;
 	bool				pp_force_state_enabled;
 
 	/* dpm */
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +35 -42

143 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +1 -6
index 2ed81cd..eb88665 100644
@@ -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);
 	}
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +17 -1
index 9f3f3b8..5c7415e 100644
@@ -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,
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#6 lore raw

PATCH 6/10 drm/amdgpu: add cgs interface to register pp handle

In reply to a message not in the archive
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c  | 23 +++++++++++++++++++++++
 drivers/gpu/drm/amd/include/cgs_common.h |  8 ++++++++
 2 files changed, 31 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +23 -0
index 1933253..fc9a50a 100644
@@ -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 = {
drivers/gpu/drm/amd/include/cgs_common.h +8 -0
index 030b146..675988d 100644
@@ -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 */
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#7 lore raw

PATCH 7/10 drm/amdgpu: create powerplay by cgs interface

In reply to a message not in the archive

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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +3 -27
index eb88665..1649b1e 100644
@@ -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)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +45 -36

108 lines not on this page · raw message

drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +0 -5
index 437d785..916b6c4 100644
@@ -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,
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1506347344-26516-7-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org

#9 lore raw

Re: [PATCH 07/10] drm/amdgpu: create powerplay by cgs interface

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

Tom

Quoted 202 lines · Rex Zhu

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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +3 -27
index eb88665..1649b1e 100644
@@ -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)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +45 -36
index 5c7415e..7c1a974 100644
@@ -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;
drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +0 -0
index 437d785..916b6c4 100644
@@ -274,11 +274,6 @@ struct amd_powerplay {
  	const struct amd_pm_funcs *pp_funcs;

drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h struct amd_powerplay { · line 279

Quoted 10 lines
drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +0 -5
  };
 
-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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): a47193f7-925d-81ae-fbc4-2647c4ee3ea8-5C7GfCeVMHo@public.gmane.org

#11 lore raw

Re: [PATCH 07/10] drm/amdgpu: create powerplay by cgs interface

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

Cheers,
Tom

Quoted 207 lines · Tom St Denis

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

Tom

Quoted 202 lines · Rex Zhu

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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +0 -18
index eb88665..1649b1e 100644
@@ -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;

drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +0 -2
@@ -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;

drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +0 -0
@@ -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)

drivers/gpu/drm/amd/powerplay/amd_powerplay.c +45 -36
index 5c7415e..7c1a974 100644
@@ -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;
drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +0 -5
index 437d785..916b6c4 100644
@@ -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);
-
Quoted 8 lines

drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h struct amd_powerplay {

Quoted 3 lines
drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +0 -0
   int amd_powerplay_reset(void *handle);
   int amd_powerplay_display_configuration_change(void *handle,
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#12 lore raw

PATCH 8/10 drm/amd/powerplay: change dmesg log level in powerplay

In reply to a message not in the archive

Use pr_debug to prevent spamming unimportant dmesg.

Change-Id I18b4df61d9d36f081df8ad3ed047eb195da70e7c
---
 drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +1 -1
index 73bb99d..189f3b5 100644
@@ -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;
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#13 lore raw

PATCH 9/10 drm/amdgpu: add comments in struct amd_pm_funcs define

In reply to a message not in the archive
Change-Id Ie54071d41fc8d67cb35a89cd500514dc067a9192
---
 drivers/gpu/drm/amd/include/amd_shared.h | 51 ++++++++++++++++++--------------
 1 file changed, 29 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/include/amd_shared.h +29 -22
index 48c4439..292f602 100644
@@ -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);
 };
 
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#14 lore raw

PATCH 10/10 drm/amd/powerplay: export new interfaces in amd_pm_funcs

In reply to a message not in the archive
Change-Id If13500f76da6e42f50d40fc794fc5e1e5dc143bf
---
 drivers/gpu/drm/amd/include/amd_shared.h | 38 +++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/include/amd_shared.h +33 -5
index 292f602..89ad5bf 100644
@@ -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);
 };
 
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1506347344-26516-10-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#16 lore raw

Re: [PATCH 10/10] drm/amd/powerplay: export new interfaces in amd_pm_funcs

Quoted 2 lines · Rex Zhu
Change-Id If13500f76da6e42f50d40fc794fc5e1e5dc143bf

Series is:

Quoted 89 lines
---
 drivers/gpu/drm/amd/include/amd_shared.h | 38 +++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/include/amd_shared.h +33 -6
index 292f602..89ad5bf 100644
@@ -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

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx