RE: [PATCH 4/4] drm/amd/powerplay: add profiling mode in dpm level

2017-01-08 Thread Zhu, Rex
Thanks Andy,

The attached patch can fix this bug.
Please review.

Best Regards
Rex

-Original Message-
From: Andy Furniss [mailto:adf.li...@gmail.com] 
Sent: Monday, January 09, 2017 4:18 AM
To: Alex Deucher; Zhu, Rex
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: add profiling mode in dpm level

Alex Deucher wrote:
> On Fri, Dec 23, 2016 at 3:45 AM, Rex Zhu  wrote:
>> Change-Id: I4a46440882cd94fe5e77e3f351aaccc218a2ece5
>
> Patches 1-3:
> Reviewed-by: Alex Deucher 
>
> patch 4:
> Please add a better patch description and explain what profiling mode 
> is good for, etc.

This on drm-next-4.10-wip regresses setting profile a bit on R9285.

It works eg. if in auto then doing

echo high > /sys/class/drm/card0/device/power_dpm_force_performance_level

is OK and echo auto  > ... is also OK.

The issue if I am in auto and echo auto >  then I don't get my prompt back.

echo high from elsewhere will make it return - but it doesn't set high.



0001-drm-amdgpu-fix-bug-return-invaild-value-to-sysfs.patch
Description: 0001-drm-amdgpu-fix-bug-return-invaild-value-to-sysfs.patch
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 4/4] drm/amdgpu: extend profiling mode.

2017-01-08 Thread Rex Zhu
in profiling mode, powerplay will fix power state
as stable as possible.and disable gfx cg and LBPW feature.

profile_standard: as a prerequisite, ensure power and thermal
sustainable, set clocks ratio as close to the highest clock
ratio as possible.
profile_min_sclk: fix mclk as profile_normal, set lowest sclk
profile_min_mclk: fix sclk as profile_normal, set lowest mclk
profile_peak: set highest sclk and mclk, power and thermal not
sustainable
profile_exit: exit profile mode. enable gfx cg/lbpw feature.

Change-Id: I217b8cfb98b6a628a11091776debe039bad997a2
Signed-off-by: Rex Zhu 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c   |  38 ---
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c  |   5 +-
 drivers/gpu/drm/amd/include/amd_shared.h |   6 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c   |   3 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 127 ++-
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h|   1 +
 6 files changed, 154 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 8438642..a6a4d36 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -120,12 +120,15 @@ static ssize_t 
amdgpu_get_dpm_forced_performance_level(struct device *dev,
 
level = amdgpu_dpm_get_performance_level(adev);
return snprintf(buf, PAGE_SIZE, "%s\n",
-   (level & (AMD_DPM_FORCED_LEVEL_AUTO) ? "auto" :
-   (level & AMD_DPM_FORCED_LEVEL_LOW) ? "low" :
-   (level & AMD_DPM_FORCED_LEVEL_HIGH) ? "high" :
-   (level & AMD_DPM_FORCED_LEVEL_MANUAL) ? "manual" :
-   (level & AMD_DPM_FORCED_LEVEL_PROFILING) ? "profiling" :
-   "unknown"));
+   (level == AMD_DPM_FORCED_LEVEL_AUTO) ? "auto" :
+   (level == AMD_DPM_FORCED_LEVEL_LOW) ? "low" :
+   (level == AMD_DPM_FORCED_LEVEL_HIGH) ? "high" :
+   (level == AMD_DPM_FORCED_LEVEL_MANUAL) ? "manual" :
+   (level == AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD) ? 
"profile_standard" :
+   (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK) ? 
"profile_min_sclk" :
+   (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK) ? 
"profile_min_mclk" :
+   (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) ? 
"profile_peak" :
+   "unknown");
 }
 
 static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
@@ -154,9 +157,17 @@ static ssize_t 
amdgpu_set_dpm_forced_performance_level(struct device *dev,
level = AMD_DPM_FORCED_LEVEL_AUTO;
} else if (strncmp("manual", buf, strlen("manual")) == 0) {
level = AMD_DPM_FORCED_LEVEL_MANUAL;
-   } else if (strncmp("profile", buf, strlen("profile")) == 0) {
-   level = AMD_DPM_FORCED_LEVEL_PROFILING;
-   } else {
+   } else if (strncmp("profile_exit", buf, strlen("profile_exit")) == 0) {
+   level = AMD_DPM_FORCED_LEVEL_PROFILE_EXIT;
+   } else if (strncmp("profile_standard", buf, strlen("profile_standard")) 
== 0) {
+   level = AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD;
+   } else if (strncmp("profile_min_sclk", buf, strlen("profile_min_sclk")) 
== 0) {
+   level = AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK;
+   } else if (strncmp("profile_min_mclk", buf, strlen("profile_min_mclk")) 
== 0) {
+   level = AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK;
+   } else if (strncmp("profile_peak", buf, strlen("profile_peak")) == 0) {
+   level = AMD_DPM_FORCED_LEVEL_PROFILE_PEAK;
+   }  else {
count = -EINVAL;
goto fail;
}
@@ -164,14 +175,6 @@ static ssize_t 
amdgpu_set_dpm_forced_performance_level(struct device *dev,
if (current_level == level)
return 0;
 
-   if (level == AMD_DPM_FORCED_LEVEL_PROFILING)
-   amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
-   AMD_CG_STATE_UNGATE);
-   else if (level != AMD_DPM_FORCED_LEVEL_PROFILING &&
-   current_level == AMD_DPM_FORCED_LEVEL_PROFILING)
-   amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
-   AMD_CG_STATE_GATE);
-
if (adev->pp_enabled)
amdgpu_dpm_force_performance_level(adev, level);
else {
@@ -188,6 +191,7 @@ static ssize_t 
amdgpu_set_dpm_forced_performance_level(struct device *dev,
adev->pm.dpm.forced_level = level;
mutex_unlock(&adev->pm.mutex);
}
+
 fail:
return count;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c 
b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
index 9a544ad..ece94ee 100644
--- a/drivers/gpu/dr

[PATCH 2/4] drm/amd/powerplay: add new smu message.

2017-01-08 Thread Rex Zhu
Change-Id: I17f02555fbc79a9e5a2e9d3160fddbc6c502eaf4
Signed-off-by: Rex Zhu 
---
 drivers/gpu/drm/amd/powerplay/inc/smu7_ppsmc.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu7_ppsmc.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu7_ppsmc.h
index bce0009..fbc504c 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu7_ppsmc.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu7_ppsmc.h
@@ -394,6 +394,9 @@ typedef uint16_t PPSMC_Result;
 
 #define PPSMC_MSG_SetVBITimeout   ((uint16_t) 0x306)
 
+#define PPSMC_MSG_EnableDpmDidt   ((uint16_t) 0x309)
+#define PPSMC_MSG_DisableDpmDidt  ((uint16_t) 0x30A)
+
 #define PPSMC_MSG_SecureSRBMWrite ((uint16_t) 0x600)
 #define PPSMC_MSG_SecureSRBMRead  ((uint16_t) 0x601)
 #define PPSMC_MSG_SetAddress  ((uint16_t) 0x800)
-- 
1.9.1

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


[PATCH 1/4] drm/amd/powerplay: Configuring DIDT blocks only SQ enabled on Polaris11.

2017-01-08 Thread Rex Zhu
following firmware's request.

Change-Id: I0098144cae57727999101152e973338ddffec28e
Signed-off-by: Rex Zhu 
---
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index 2f6225e..2ea9c0e 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
@@ -767,17 +767,10 @@ int phm_get_voltage_evv_on_sclk(struct pp_hwmgr *hwmgr, 
uint8_t voltage_type,
 
 int polaris_set_asic_special_caps(struct pp_hwmgr *hwmgr)
 {
-   /* power tune caps Assume disabled */
+
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
PHM_PlatformCaps_SQRamping);
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
-   PHM_PlatformCaps_DBRamping);
-   phm_cap_set(hwmgr->platform_descriptor.platformCaps,
-   PHM_PlatformCaps_TDRamping);
-   phm_cap_set(hwmgr->platform_descriptor.platformCaps,
-   PHM_PlatformCaps_TCPRamping);
-
-   phm_cap_set(hwmgr->platform_descriptor.platformCaps,
PHM_PlatformCaps_RegulatorHot);
 
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
@@ -786,9 +779,19 @@ int polaris_set_asic_special_caps(struct pp_hwmgr *hwmgr)
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
PHM_PlatformCaps_TablelessHardwareInterface);
 
-   if ((hwmgr->chip_id == CHIP_POLARIS11) || (hwmgr->chip_id == 
CHIP_POLARIS12))
+
+   if (hwmgr->chip_id != CHIP_POLARIS10)
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
PHM_PlatformCaps_SPLLShutdownSupport);
+
+   if (hwmgr->chip_id != CHIP_POLARIS11) {
+   phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+   
PHM_PlatformCaps_DBRamping);
+   phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+   
PHM_PlatformCaps_TDRamping);
+   phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+   
PHM_PlatformCaps_TCPRamping);
+   }
return 0;
 }
 
-- 
1.9.1

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


[PATCH 3/4] drm/amd/powerplay: refine DIDT feature in Powerplay.

2017-01-08 Thread Rex Zhu
Updating SQ DIDT settings and block mask
so SQ uses PCC on Polaris11.

Change-Id: I80c48de1eab812ff4e201505331c95ddb33b2ad5
Signed-off-by: Rex Zhu 
---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c   |   4 +
 .../gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c   | 224 -
 2 files changed, 179 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index be6d374..acd038cc 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -1294,6 +1294,10 @@ int smu7_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE((tmp_result == 0),
"Failed to disable SMC CAC!", result = tmp_result);
 
+   tmp_result = smu7_disable_didt_config(hwmgr);
+   PP_ASSERT_WITH_CODE((tmp_result == 0),
+   "Failed to disable DIDT!", result = tmp_result);
+
PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
CG_SPLL_SPREAD_SPECTRUM, SSEN, 0);
PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c
index 77d469f..3341c0f 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c
@@ -31,6 +31,8 @@
 
 static uint32_t DIDTBlock_Info = SQ_IR_MASK | TCP_IR_MASK | TD_PCC_MASK;
 
+static uint32_t Polaris11_DIDTBlock_Info = SQ_PCC_MASK | TCP_IR_MASK | 
TD_PCC_MASK;
+
 static const struct gpu_pt_config_reg GCCACConfig_Polaris10[] = {
 /* 
-
  *  Offset Mask
Shift   Value   
Type
@@ -261,9 +263,9 @@ static const struct gpu_pt_config_reg 
DIDTConfig_Polaris11[] = {
{   ixDIDT_SQ_CTRL_OCP,DIDT_SQ_CTRL_OCP__UNUSED_0_MASK, 
   DIDT_SQ_CTRL_OCP__UNUSED_0__SHIFT,  0x,  
   GPU_CONFIGREG_DIDT_IND },
{   ixDIDT_SQ_CTRL_OCP,
DIDT_SQ_CTRL_OCP__OCP_MAX_POWER_MASK,   
DIDT_SQ_CTRL_OCP__OCP_MAX_POWER__SHIFT, 0x, 
GPU_CONFIGREG_DIDT_IND },
 
-   {   ixDIDT_SQ_CTRL2,   
DIDT_SQ_CTRL2__MAX_POWER_DELTA_MASK,
DIDT_SQ_CTRL2__MAX_POWER_DELTA__SHIFT,  0x3853, 
GPU_CONFIGREG_DIDT_IND },
+   {   ixDIDT_SQ_CTRL2,   
DIDT_SQ_CTRL2__MAX_POWER_DELTA_MASK,
DIDT_SQ_CTRL2__MAX_POWER_DELTA__SHIFT,  0x3fff, 
GPU_CONFIGREG_DIDT_IND },
{   ixDIDT_SQ_CTRL2,   DIDT_SQ_CTRL2__UNUSED_0_MASK,
   DIDT_SQ_CTRL2__UNUSED_0__SHIFT, 0x,  
   GPU_CONFIGREG_DIDT_IND },
-   {   ixDIDT_SQ_CTRL2,   
DIDT_SQ_CTRL2__SHORT_TERM_INTERVAL_SIZE_MASK,   
DIDT_SQ_CTRL2__SHORT_TERM_INTERVAL_SIZE__SHIFT, 0x005a, 
GPU_CONFIGREG_DIDT_IND },
+   {   ixDIDT_SQ_CTRL2,   
DIDT_SQ_CTRL2__SHORT_TERM_INTERVAL_SIZE_MASK,   
DIDT_SQ_CTRL2__SHORT_TERM_INTERVAL_SIZE__SHIFT, 0x000f, 
GPU_CONFIGREG_DIDT_IND },
{   ixDIDT_SQ_CTRL2,   DIDT_SQ_CTRL2__UNUSED_1_MASK,
   DIDT_SQ_CTRL2__UNUSED_1__SHIFT, 0x,  
   GPU_CONFIGREG_DIDT_IND },
{   ixDIDT_SQ_CTRL2,   
DIDT_SQ_CTRL2__LONG_TERM_INTERVAL_RATIO_MASK,   
DIDT_SQ_CTRL2__LONG_TERM_INTERVAL_RATIO__SHIFT, 0x, 
GPU_CONFIGREG_DIDT_IND },
{   ixDIDT_SQ_CTRL2,   DIDT_SQ_CTRL2__UNUSED_2_MASK,
   DIDT_SQ_CTRL2__UNUSED_2__SHIFT, 0x,  
   GPU_CONFIGREG_DIDT_IND },
@@ -271,12 +273,12 @@ static const struct gpu_pt_config_reg 
DIDTConfig_Polaris11[] = {
{   ixDIDT_SQ_STALL_CTRL,  
DIDT_SQ_STALL_CTRL__DIDT_STALL_CTRL_ENABLE_MASK,
DIDT_SQ_STALL_CTRL__DIDT_STALL_CTRL_ENABLE__SHIFT,  0x0001, 
GPU_CONFIGREG_DIDT_IND },
{   ixDIDT_SQ_STALL_CTRL,  
DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_HI_MASK,   
DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_HI__SHIFT, 0x0001, 
GPU_CONFIGREG_DIDT_IND },
{   ixDIDT_SQ_STALL_CTRL,  
DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_LO_MASK,   
DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_LO__SHIFT, 0x0001, 
GPU_CONFIGREG_DIDT_IND },
-   {   ixDIDT_SQ_STALL_CTRL,  
DIDT_SQ_STALL_CTRL__DIDT_HI_POWER_THRESHOLD_MASK,   
DIDT_SQ_STALL_CTRL__DIDT_HI_POWER_THRESHOLD__SHIFT, 0x0ebb, 
GPU_CONFIGREG_DIDT_IND },
+   {   ixDIDT_SQ_STALL_CTRL,  
DIDT_SQ_STALL_CTRL__DIDT_HI_POWER_THRESHOLD_MASK,   

[PART1 PATCH v4 2/8] drm/amdgpu: add parse clock gating state

2017-01-08 Thread Huang Rui
Suggested-by: Felix Kuehling 
Signed-off-by: Huang Rui 
Reviewed-by: Alex Deucher 
Cc: William Lewis 
---

Changes from V3 -> V4:
- fix some typo

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 33 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h |  6 ++
 2 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 1203e9a..dba462f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -34,6 +34,28 @@
 
 static int amdgpu_debugfs_pm_init(struct amdgpu_device *adev);
 
+static const struct cg_flag_name clocks[] = {
+   {AMD_CG_SUPPORT_GFX_MGCG, "Graphics Medium Grain Clock Gating"},
+   {AMD_CG_SUPPORT_GFX_MGLS, "Graphics Medium Grain memory Light Sleep"},
+   {AMD_CG_SUPPORT_GFX_CGCG, "Graphics Coarse Grain Clock Gating"},
+   {AMD_CG_SUPPORT_GFX_CGLS, "Graphics Coarse Grain memory Light Sleep"},
+   {AMD_CG_SUPPORT_GFX_CGTS, "Graphics Coarse Grain Tree Shader Light 
Sleep"},
+   {AMD_CG_SUPPORT_GFX_CGTS_LS, "Graphics Coarse Grain Tree Shader Light 
Sleep"},
+   {AMD_CG_SUPPORT_GFX_CP_LS, "Graphics Command Processor Light Sleep"},
+   {AMD_CG_SUPPORT_GFX_RLC_LS, "Graphics Run List Controller Light Sleep"},
+   {AMD_CG_SUPPORT_MC_LS, "Memory Controller Light Sleep"},
+   {AMD_CG_SUPPORT_MC_MGCG, "Memory Controller Medium Grain Clock Gating"},
+   {AMD_CG_SUPPORT_SDMA_LS, "System Direct Memory Access Light Sleep"},
+   {AMD_CG_SUPPORT_SDMA_MGCG, "System Direct Memory Access Medium Grain 
Clock Gating"},
+   {AMD_CG_SUPPORT_BIF_LS, "Bus Interface Light Sleep"},
+   {AMD_CG_SUPPORT_UVD_MGCG, "Universal Video Decoder Medium Grain Clock 
Gating"},
+   {AMD_CG_SUPPORT_VCE_MGCG, "Video Compression Engine Medium Grain Clock 
Gating"},
+   {AMD_CG_SUPPORT_HDP_LS, "Host Data Path Light Sleep"},
+   {AMD_CG_SUPPORT_HDP_MGCG, "Host Data Path Medium Grain Clock Gating"},
+   {AMD_CG_SUPPORT_ROM_MGCG, "Rom Medium Grain Clock Gating"},
+   {0, NULL},
+};
+
 void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)
 {
if (adev->pp_enabled)
@@ -1536,6 +1558,15 @@ static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, 
struct amdgpu_device *a
return 0;
 }
 
+static void amdgpu_parse_cg_state(struct seq_file *m, u32 flags)
+{
+   int i;
+
+   for (i = 0; clocks[i].flag; i++)
+   seq_printf(m, "\t%s: %s\n", clocks[i].name,
+  (flags & clocks[i].flag) ? "On" : "Off");
+}
+
 static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data)
 {
struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -1546,6 +1577,8 @@ static int amdgpu_debugfs_pm_info(struct seq_file *m, 
void *data)
 
amdgpu_get_clockgating_state(adev, &flags);
seq_printf(m, "Clock Gating Flags Mask: 0x%x\n", flags);
+   amdgpu_parse_cg_state(m, flags);
+   seq_printf(m, "\n");
 
if (!adev->pm.dpm_enabled) {
seq_printf(m, "dpm not enabled\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h
index 5fd7734..c19c4d1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h
@@ -24,6 +24,12 @@
 #ifndef __AMDGPU_PM_H__
 #define __AMDGPU_PM_H__
 
+struct cg_flag_name
+{
+   u32 flag;
+   const char *name;
+};
+
 int amdgpu_pm_sysfs_init(struct amdgpu_device *adev);
 void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev);
 void amdgpu_pm_print_power_states(struct amdgpu_device *adev);
-- 
2.7.4

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


[PART1 PATCH v4 8/8] drm/amdgpu: add get clockgating_state method for vce v3

2017-01-08 Thread Huang Rui
Signed-off-by: Huang Rui 
---

Changes from V3 -> V4:
- use pm mutex to protect VCE clock gating status

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 44 +++
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 31054c7..3c52b81 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1212,6 +1212,7 @@ struct amdgpu_vce {
struct amd_sched_entity entity;
uint32_tsrbm_soft_reset;
unsignednum_rings;
+   boolis_powergated;
 };
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c 
b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
index 35ff1c3..dde46ea 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
@@ -770,15 +770,50 @@ static int vce_v3_0_set_powergating_state(void *handle,
 * the smc and the hw blocks
 */
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   int ret = 0;
 
if (!(adev->pg_flags & AMD_PG_SUPPORT_VCE))
return 0;
 
-   if (state == AMD_PG_STATE_GATE)
+   mutex_lock(&adev->pm.mutex);
+
+   if (state == AMD_PG_STATE_GATE) {
+   adev->vce.is_powergated = true;
/* XXX do we need a vce_v3_0_stop()? */
-   return 0;
-   else
-   return vce_v3_0_start(adev);
+   } else {
+   ret = vce_v3_0_start(adev);
+   if (ret)
+   goto out;
+   adev->vce.is_powergated = false;
+   }
+
+out:
+   mutex_unlock(&adev->pm.mutex);
+
+   return ret;
+}
+
+static void vce_v3_0_get_clockgating_state(void *handle, u32 *flags)
+{
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   int data;
+
+   mutex_lock(&adev->pm.mutex);
+
+   if (adev->vce.is_powergated) {
+   DRM_INFO("Cannot get clockgating state when VCE is 
powergated.\n");
+   goto out;
+   }
+
+   WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, 0);
+
+   /* AMD_CG_SUPPORT_VCE_MGCG */
+   data = RREG32(mmVCE_CLOCK_GATING_A);
+   if (data & (0x04 << 4))
+   *flags |= AMD_CG_SUPPORT_VCE_MGCG;
+
+out:
+   mutex_unlock(&adev->pm.mutex);
 }
 
 static void vce_v3_0_ring_emit_ib(struct amdgpu_ring *ring,
@@ -832,6 +867,7 @@ static const struct amd_ip_funcs vce_v3_0_ip_funcs = {
.post_soft_reset = vce_v3_0_post_soft_reset,
.set_clockgating_state = vce_v3_0_set_clockgating_state,
.set_powergating_state = vce_v3_0_set_powergating_state,
+   .get_clockgating_state = vce_v3_0_get_clockgating_state,
 };
 
 static const struct amdgpu_ring_funcs vce_v3_0_ring_phys_funcs = {
-- 
2.7.4

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


amd-gfx@lists.freedesktop.org

2017-01-08 Thread Huang Rui
Signed-off-by: Huang Rui 
---

Changes from V3 -> V4:
- use pm mutex to protect UVD clock gating status

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | 37 +--
 drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 37 +--
 3 files changed, 71 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 530549b..31054c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1183,6 +1183,7 @@ struct amdgpu_uvd {
booluse_ctx_buf;
struct amd_sched_entity entity;
uint32_tsrbm_soft_reset;
+   boolis_powergated;
 };
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c 
b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
index 03a35d9..e647d3e 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
@@ -781,16 +781,48 @@ static int uvd_v5_0_set_powergating_state(void *handle,
 * the smc and the hw blocks
 */
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   int ret = 0;
 
if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
return 0;
 
+   mutex_lock(&adev->pm.mutex);
+
if (state == AMD_PG_STATE_GATE) {
+   adev->uvd.is_powergated = true;
uvd_v5_0_stop(adev);
-   return 0;
} else {
-   return uvd_v5_0_start(adev);
+   ret = uvd_v5_0_start(adev);
+   if (ret)
+   goto out;
+   adev->uvd.is_powergated = false;
+   }
+
+out:
+   mutex_unlock(&adev->pm.mutex);
+
+   return ret;
+}
+
+static void uvd_v5_0_get_clockgating_state(void *handle, u32 *flags)
+{
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   int data;
+
+   mutex_lock(&adev->pm.mutex);
+
+   if (adev->uvd.is_powergated) {
+   DRM_INFO("Cannot get clockgating state when UVD is 
powergated.\n");
+   goto out;
}
+
+   /* AMD_CG_SUPPORT_UVD_MGCG */
+   data = RREG32(mmUVD_CGC_CTRL);
+   if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK)
+   *flags |= AMD_CG_SUPPORT_UVD_MGCG;
+
+out:
+   mutex_unlock(&adev->pm.mutex);
 }
 
 static const struct amd_ip_funcs uvd_v5_0_ip_funcs = {
@@ -808,6 +840,7 @@ static const struct amd_ip_funcs uvd_v5_0_ip_funcs = {
.soft_reset = uvd_v5_0_soft_reset,
.set_clockgating_state = uvd_v5_0_set_clockgating_state,
.set_powergating_state = uvd_v5_0_set_powergating_state,
+   .get_clockgating_state = uvd_v5_0_get_clockgating_state,
 };
 
 static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = {
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index 8779d4b..2585ae9 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
@@ -987,18 +987,50 @@ static int uvd_v6_0_set_powergating_state(void *handle,
 * the smc and the hw blocks
 */
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   int ret = 0;
 
if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
return 0;
 
WREG32(mmUVD_POWER_STATUS, UVD_POWER_STATUS__UVD_PG_EN_MASK);
 
+   mutex_lock(&adev->pm.mutex);
+
if (state == AMD_PG_STATE_GATE) {
+   adev->uvd.is_powergated = true;
uvd_v6_0_stop(adev);
-   return 0;
} else {
-   return uvd_v6_0_start(adev);
+   ret = uvd_v6_0_start(adev);
+   if (ret)
+   goto out;
+   adev->uvd.is_powergated = false;
+   }
+
+out:
+   mutex_unlock(&adev->pm.mutex);
+
+   return ret;
+}
+
+static void uvd_v6_0_get_clockgating_state(void *handle, u32 *flags)
+{
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   int data;
+
+   mutex_lock(&adev->pm.mutex);
+
+   if (adev->uvd.is_powergated) {
+   DRM_INFO("Cannot get clockgating state when UVD is 
powergated.\n");
+   goto out;
}
+
+   /* AMD_CG_SUPPORT_UVD_MGCG */
+   data = RREG32(mmUVD_CGC_CTRL);
+   if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK)
+   *flags |= AMD_CG_SUPPORT_UVD_MGCG;
+
+out:
+   mutex_unlock(&adev->pm.mutex);
 }
 
 static const struct amd_ip_funcs uvd_v6_0_ip_funcs = {
@@ -1019,6 +1051,7 @@ static const struct amd_ip_funcs uvd_v6_0_ip_funcs = {
.post_soft_reset = uvd_v6_0_post_soft_reset,
.set_clockgating_state = uvd_v6_0_set_clockgating_state,
.set_powergating_state = uvd_v6_0_set_powergating_state,
+   .get_clockgating_state = uvd_v6_0_get_clockgating_state,
 };
 
 static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = {
-- 
2.7.4

_

答复: [V2 1/2] drm/amdgpu/vi: move virtualization detection forward

2017-01-08 Thread Liu, Monk
Reviewed-by: Monk Liu 



发件人: amd-gfx  代表 Xiangliang Yu 

发送时间: 2017年1月9日 13:05:53
收件人: amd-gfx@lists.freedesktop.org
抄送: Yu, Xiangliang
主题: [V2 1/2] drm/amdgpu/vi: move virtualization detection forward

Move the detection forward into vi_set_ip_blocks function, then
add ip blocks virtualization need if device is VF.

V2: add ip blocks according to asic type.

Signed-off-by: Xiangliang Yu 
---
 drivers/gpu/drm/amd/amdgpu/vi.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
index b2ce7da..7350a8f 100644
--- a/drivers/gpu/drm/amd/amdgpu/vi.c
+++ b/drivers/gpu/drm/amd/amdgpu/vi.c
@@ -857,7 +857,6 @@ static const struct amdgpu_asic_funcs vi_asic_funcs =
 {
 .read_disabled_bios = &vi_read_disabled_bios,
 .read_bios_from_rom = &vi_read_bios_from_rom,
-   .detect_hw_virtualization = vi_detect_hw_virtualization,
 .read_register = &vi_read_register,
 .reset = &vi_asic_reset,
 .set_vga_state = &vi_vga_set_state,
@@ -1049,10 +1048,6 @@ static int vi_common_early_init(void *handle)
 return -EINVAL;
 }

-   /* in early init stage, vbios code won't work */
-   if (adev->asic_funcs->detect_hw_virtualization)
-   amdgpu_asic_detect_hw_virtualization(adev);
-
 if (amdgpu_smc_load_fw && smc_enabled)
 adev->firmware.smu_load = true;

@@ -1403,6 +1398,9 @@ static const struct amdgpu_ip_block_version 
vi_common_ip_block =

 int vi_set_ip_blocks(struct amdgpu_device *adev)
 {
+   /* in early init stage, vbios code won't work */
+   vi_detect_hw_virtualization(adev);
+
 switch (adev->asic_type) {
 case CHIP_TOPAZ:
 /* topaz has no DCE, UVD, VCE */
@@ -1420,7 +1418,7 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
 amdgpu_ip_block_add(adev, &gmc_v8_5_ip_block);
 amdgpu_ip_block_add(adev, &tonga_ih_ip_block);
 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
-   if (adev->enable_virtual_display)
+   if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
 #if defined(CONFIG_DRM_AMD_DC)
 else if (amdgpu_device_has_dc_support(adev))
@@ -1430,15 +1428,17 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
 amdgpu_ip_block_add(adev, &dce_v10_1_ip_block);
 amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block);
 amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block);
-   amdgpu_ip_block_add(adev, &uvd_v6_0_ip_block);
-   amdgpu_ip_block_add(adev, &vce_v3_0_ip_block);
+   if (!amdgpu_sriov_vf(adev)) {
+   amdgpu_ip_block_add(adev, &uvd_v6_0_ip_block);
+   amdgpu_ip_block_add(adev, &vce_v3_0_ip_block);
+   }
 break;
 case CHIP_TONGA:
 amdgpu_ip_block_add(adev, &vi_common_ip_block);
 amdgpu_ip_block_add(adev, &gmc_v8_0_ip_block);
 amdgpu_ip_block_add(adev, &tonga_ih_ip_block);
 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
-   if (adev->enable_virtual_display)
+   if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
 #if defined(CONFIG_DRM_AMD_DC)
 else if (amdgpu_device_has_dc_support(adev))
@@ -1448,8 +1448,10 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
 amdgpu_ip_block_add(adev, &dce_v10_0_ip_block);
 amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block);
 amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block);
-   amdgpu_ip_block_add(adev, &uvd_v5_0_ip_block);
-   amdgpu_ip_block_add(adev, &vce_v3_0_ip_block);
+   if (!amdgpu_sriov_vf(adev)) {
+   amdgpu_ip_block_add(adev, &uvd_v5_0_ip_block);
+   amdgpu_ip_block_add(adev, &vce_v3_0_ip_block);
+   }
 break;
 case CHIP_POLARIS11:
 case CHIP_POLARIS10:
--
2.7.4

___
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


答复: [V2 2/2] drm/amdgpu: remove detect_hw_virtualization interface

2017-01-08 Thread Liu, Monk
RB as well


发件人: amd-gfx  代表 Xiangliang Yu 

发送时间: 2017年1月9日 13:06:07
收件人: amd-gfx@lists.freedesktop.org
抄送: Yu, Xiangliang
主题: [V2 2/2] drm/amdgpu: remove detect_hw_virtualization interface

Call detection function driectly, so remove the interface.

V2: ci and si also need to call the detec function.

Signed-off-by: Xiangliang Yu 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 --
 drivers/gpu/drm/amd/amdgpu/cik.c| 3 ++-
 drivers/gpu/drm/amd/amdgpu/si.c | 3 ++-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index b7d520fc..13c30ab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1192,7 +1192,6 @@ struct amdgpu_asic_funcs {
 bool (*read_disabled_bios)(struct amdgpu_device *adev);
 bool (*read_bios_from_rom)(struct amdgpu_device *adev,
u8 *bios, u32 length_bytes);
-   void (*detect_hw_virtualization) (struct amdgpu_device *adev);
 int (*read_register)(struct amdgpu_device *adev, u32 se_num,
  u32 sh_num, u32 reg_offset, u32 *value);
 void (*set_vga_state)(struct amdgpu_device *adev, bool state);
@@ -1626,7 +1625,6 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
 #define amdgpu_asic_get_gpu_clock_counter(adev) 
(adev)->asic_funcs->get_gpu_clock_counter((adev))
 #define amdgpu_asic_read_disabled_bios(adev) 
(adev)->asic_funcs->read_disabled_bios((adev))
 #define amdgpu_asic_read_bios_from_rom(adev, b, l) 
(adev)->asic_funcs->read_bios_from_rom((adev), (b), (l))
-#define amdgpu_asic_detect_hw_virtualization(adev) 
(adev)->asic_funcs->detect_hw_virtualization((adev))
 #define amdgpu_asic_read_register(adev, se, sh, offset, 
v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v)))
 #define amdgpu_gart_flush_gpu_tlb(adev, vmid) 
(adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid))
 #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) 
(adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags))
diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c
index 3793a04..da255e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik.c
@@ -1635,7 +1635,6 @@ static const struct amdgpu_asic_funcs cik_asic_funcs =
 {
 .read_disabled_bios = &cik_read_disabled_bios,
 .read_bios_from_rom = &cik_read_bios_from_rom,
-   .detect_hw_virtualization = cik_detect_hw_virtualization,
 .read_register = &cik_read_register,
 .reset = &cik_asic_reset,
 .set_vga_state = &cik_vga_set_state,
@@ -1891,6 +1890,8 @@ static const struct amdgpu_ip_block_version 
cik_common_ip_block =

 int cik_set_ip_blocks(struct amdgpu_device *adev)
 {
+   cik_detect_hw_virtualization(adev);
+
 switch (adev->asic_type) {
 case CHIP_BONAIRE:
 amdgpu_ip_block_add(adev, &cik_common_ip_block);
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c
index 6a85daa..413a516 100644
--- a/drivers/gpu/drm/amd/amdgpu/si.c
+++ b/drivers/gpu/drm/amd/amdgpu/si.c
@@ -1144,7 +1144,6 @@ static void si_detect_hw_virtualization(struct 
amdgpu_device *adev)
 static const struct amdgpu_asic_funcs si_asic_funcs =
 {
 .read_disabled_bios = &si_read_disabled_bios,
-   .detect_hw_virtualization = si_detect_hw_virtualization,
 .read_register = &si_read_register,
 .reset = &si_asic_reset,
 .set_vga_state = &si_vga_set_state,
@@ -1861,6 +1860,8 @@ static const struct amdgpu_ip_block_version 
si_common_ip_block =

 int si_set_ip_blocks(struct amdgpu_device *adev)
 {
+   si_detect_hw_virtualization(adev);
+
 switch (adev->asic_type) {
 case CHIP_VERDE:
 case CHIP_TAHITI:
--
2.7.4

___
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


[V2 2/2] drm/amdgpu: remove detect_hw_virtualization interface

2017-01-08 Thread Xiangliang Yu
Call detection function driectly, so remove the interface.

V2: ci and si also need to call the detec function.

Signed-off-by: Xiangliang Yu 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 --
 drivers/gpu/drm/amd/amdgpu/cik.c| 3 ++-
 drivers/gpu/drm/amd/amdgpu/si.c | 3 ++-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index b7d520fc..13c30ab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1192,7 +1192,6 @@ struct amdgpu_asic_funcs {
bool (*read_disabled_bios)(struct amdgpu_device *adev);
bool (*read_bios_from_rom)(struct amdgpu_device *adev,
   u8 *bios, u32 length_bytes);
-   void (*detect_hw_virtualization) (struct amdgpu_device *adev);
int (*read_register)(struct amdgpu_device *adev, u32 se_num,
 u32 sh_num, u32 reg_offset, u32 *value);
void (*set_vga_state)(struct amdgpu_device *adev, bool state);
@@ -1626,7 +1625,6 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
 #define amdgpu_asic_get_gpu_clock_counter(adev) 
(adev)->asic_funcs->get_gpu_clock_counter((adev))
 #define amdgpu_asic_read_disabled_bios(adev) 
(adev)->asic_funcs->read_disabled_bios((adev))
 #define amdgpu_asic_read_bios_from_rom(adev, b, l) 
(adev)->asic_funcs->read_bios_from_rom((adev), (b), (l))
-#define amdgpu_asic_detect_hw_virtualization(adev) 
(adev)->asic_funcs->detect_hw_virtualization((adev))
 #define amdgpu_asic_read_register(adev, se, sh, offset, 
v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v)))
 #define amdgpu_gart_flush_gpu_tlb(adev, vmid) 
(adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid))
 #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) 
(adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags))
diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c
index 3793a04..da255e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik.c
@@ -1635,7 +1635,6 @@ static const struct amdgpu_asic_funcs cik_asic_funcs =
 {
.read_disabled_bios = &cik_read_disabled_bios,
.read_bios_from_rom = &cik_read_bios_from_rom,
-   .detect_hw_virtualization = cik_detect_hw_virtualization,
.read_register = &cik_read_register,
.reset = &cik_asic_reset,
.set_vga_state = &cik_vga_set_state,
@@ -1891,6 +1890,8 @@ static const struct amdgpu_ip_block_version 
cik_common_ip_block =
 
 int cik_set_ip_blocks(struct amdgpu_device *adev)
 {
+   cik_detect_hw_virtualization(adev);
+
switch (adev->asic_type) {
case CHIP_BONAIRE:
amdgpu_ip_block_add(adev, &cik_common_ip_block);
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c
index 6a85daa..413a516 100644
--- a/drivers/gpu/drm/amd/amdgpu/si.c
+++ b/drivers/gpu/drm/amd/amdgpu/si.c
@@ -1144,7 +1144,6 @@ static void si_detect_hw_virtualization(struct 
amdgpu_device *adev)
 static const struct amdgpu_asic_funcs si_asic_funcs =
 {
.read_disabled_bios = &si_read_disabled_bios,
-   .detect_hw_virtualization = si_detect_hw_virtualization,
.read_register = &si_read_register,
.reset = &si_asic_reset,
.set_vga_state = &si_vga_set_state,
@@ -1861,6 +1860,8 @@ static const struct amdgpu_ip_block_version 
si_common_ip_block =
 
 int si_set_ip_blocks(struct amdgpu_device *adev)
 {
+   si_detect_hw_virtualization(adev);
+
switch (adev->asic_type) {
case CHIP_VERDE:
case CHIP_TAHITI:
-- 
2.7.4

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


[V2 1/2] drm/amdgpu/vi: move virtualization detection forward

2017-01-08 Thread Xiangliang Yu
Move the detection forward into vi_set_ip_blocks function, then
add ip blocks virtualization need if device is VF.

V2: add ip blocks according to asic type.

Signed-off-by: Xiangliang Yu 
---
 drivers/gpu/drm/amd/amdgpu/vi.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
index b2ce7da..7350a8f 100644
--- a/drivers/gpu/drm/amd/amdgpu/vi.c
+++ b/drivers/gpu/drm/amd/amdgpu/vi.c
@@ -857,7 +857,6 @@ static const struct amdgpu_asic_funcs vi_asic_funcs =
 {
.read_disabled_bios = &vi_read_disabled_bios,
.read_bios_from_rom = &vi_read_bios_from_rom,
-   .detect_hw_virtualization = vi_detect_hw_virtualization,
.read_register = &vi_read_register,
.reset = &vi_asic_reset,
.set_vga_state = &vi_vga_set_state,
@@ -1049,10 +1048,6 @@ static int vi_common_early_init(void *handle)
return -EINVAL;
}
 
-   /* in early init stage, vbios code won't work */
-   if (adev->asic_funcs->detect_hw_virtualization)
-   amdgpu_asic_detect_hw_virtualization(adev);
-
if (amdgpu_smc_load_fw && smc_enabled)
adev->firmware.smu_load = true;
 
@@ -1403,6 +1398,9 @@ static const struct amdgpu_ip_block_version 
vi_common_ip_block =
 
 int vi_set_ip_blocks(struct amdgpu_device *adev)
 {
+   /* in early init stage, vbios code won't work */
+   vi_detect_hw_virtualization(adev);
+
switch (adev->asic_type) {
case CHIP_TOPAZ:
/* topaz has no DCE, UVD, VCE */
@@ -1420,7 +1418,7 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
amdgpu_ip_block_add(adev, &gmc_v8_5_ip_block);
amdgpu_ip_block_add(adev, &tonga_ih_ip_block);
amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
-   if (adev->enable_virtual_display)
+   if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
 #if defined(CONFIG_DRM_AMD_DC)
else if (amdgpu_device_has_dc_support(adev))
@@ -1430,15 +1428,17 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
amdgpu_ip_block_add(adev, &dce_v10_1_ip_block);
amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block);
amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block);
-   amdgpu_ip_block_add(adev, &uvd_v6_0_ip_block);
-   amdgpu_ip_block_add(adev, &vce_v3_0_ip_block);
+   if (!amdgpu_sriov_vf(adev)) {
+   amdgpu_ip_block_add(adev, &uvd_v6_0_ip_block);
+   amdgpu_ip_block_add(adev, &vce_v3_0_ip_block);
+   }
break;
case CHIP_TONGA:
amdgpu_ip_block_add(adev, &vi_common_ip_block);
amdgpu_ip_block_add(adev, &gmc_v8_0_ip_block);
amdgpu_ip_block_add(adev, &tonga_ih_ip_block);
amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
-   if (adev->enable_virtual_display)
+   if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
 #if defined(CONFIG_DRM_AMD_DC)
else if (amdgpu_device_has_dc_support(adev))
@@ -1448,8 +1448,10 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
amdgpu_ip_block_add(adev, &dce_v10_0_ip_block);
amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block);
amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block);
-   amdgpu_ip_block_add(adev, &uvd_v5_0_ip_block);
-   amdgpu_ip_block_add(adev, &vce_v3_0_ip_block);
+   if (!amdgpu_sriov_vf(adev)) {
+   amdgpu_ip_block_add(adev, &uvd_v5_0_ip_block);
+   amdgpu_ip_block_add(adev, &vce_v3_0_ip_block);
+   }
break;
case CHIP_POLARIS11:
case CHIP_POLARIS10:
-- 
2.7.4

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


RE: [PATCH 2/2] drm/amdgpu: remove detect_hw_virtualization interface

2017-01-08 Thread Yu, Xiangliang

>From: Liu, Monk 
>Sent: Monday, January 09, 2017 11:32 AM
>To: Yu, Xiangliang ; amd-gfx@lists.freedesktop.org
>Subject: 答复: [PATCH 2/2] drm/amdgpu: remove detect_hw_virtualization interface

>after you removed this interface, don't forget to call thos 
>"xx_detect_hw_virtualization" in head of xx_set_ip_blocks() routine

>e.g. CI also need its "adev->virt.caps" with flag of "AMDGPU_PASSTHROUGH_MODE"

Sure.

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


RE: [PATCH 1/2] drm/amdgpu/vi: move virtualization detection forward

2017-01-08 Thread Yu, Xiangliang

>please change as below accordingly:
> 1, call "vi_detect_hw_virtualization" in vi_set_ip_blocks directly 

That is what my patch does

>2, drop below changes:
>+   if (amdgpu_sriov_vf(adev)) {
>+   amdgpu_ip_block_add(adev, &vi_common_ip_block);
>+   amdgpu_ip_block_add(adev, &gmc_v8_5_ip_block);
>+   amdgpu_ip_block_add(adev, &tonga_ih_ip_block);
>+   amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
>+   amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
>+   amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block);
>+   amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block);
>+   }

>since some ip  version is different between VI (e.g. FIJI use gmc_v8_5 and 
>tonga use v8_0, so your change at last increase more lines, we'll finally 
>support TONGA/FIJI/Ellesmere for SRIOV)

Make sense. I'll send out v2 to change it.

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


答复: [PATCH 2/2] drm/amdgpu: remove detect_hw_virtualization interface

2017-01-08 Thread Liu, Monk
after you removed this interface, don't forget to call thos 
"xx_detect_hw_virtualization" in head of xx_set_ip_blocks() routine


e.g. CI also need its "adev->virt.caps" with flag of "AMDGPU_PASSTHROUGH_MODE"


BR Monk


发件人: amd-gfx  代表 Xiangliang Yu 

发送时间: 2017年1月8日 11:12:49
收件人: amd-gfx@lists.freedesktop.org
抄送: Yu, Xiangliang
主题: [PATCH 2/2] drm/amdgpu: remove detect_hw_virtualization interface

Don't use the interface anymore, remove it.

Signed-off-by: Xiangliang Yu 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 --
 drivers/gpu/drm/amd/amdgpu/cik.c| 7 ---
 drivers/gpu/drm/amd/amdgpu/si.c | 7 ---
 3 files changed, 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index b7d520fc..13c30ab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1192,7 +1192,6 @@ struct amdgpu_asic_funcs {
 bool (*read_disabled_bios)(struct amdgpu_device *adev);
 bool (*read_bios_from_rom)(struct amdgpu_device *adev,
u8 *bios, u32 length_bytes);
-   void (*detect_hw_virtualization) (struct amdgpu_device *adev);
 int (*read_register)(struct amdgpu_device *adev, u32 se_num,
  u32 sh_num, u32 reg_offset, u32 *value);
 void (*set_vga_state)(struct amdgpu_device *adev, bool state);
@@ -1626,7 +1625,6 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
 #define amdgpu_asic_get_gpu_clock_counter(adev) 
(adev)->asic_funcs->get_gpu_clock_counter((adev))
 #define amdgpu_asic_read_disabled_bios(adev) 
(adev)->asic_funcs->read_disabled_bios((adev))
 #define amdgpu_asic_read_bios_from_rom(adev, b, l) 
(adev)->asic_funcs->read_bios_from_rom((adev), (b), (l))
-#define amdgpu_asic_detect_hw_virtualization(adev) 
(adev)->asic_funcs->detect_hw_virtualization((adev))
 #define amdgpu_asic_read_register(adev, se, sh, offset, 
v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v)))
 #define amdgpu_gart_flush_gpu_tlb(adev, vmid) 
(adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid))
 #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) 
(adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags))
diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c
index 3793a04..d615d64 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik.c
@@ -1625,17 +1625,10 @@ static uint32_t cik_get_rev_id(struct amdgpu_device 
*adev)
 >> CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT;
 }

-static void cik_detect_hw_virtualization(struct amdgpu_device *adev)
-{
-   if (is_virtual_machine()) /* passthrough mode */
-   adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE;
-}
-
 static const struct amdgpu_asic_funcs cik_asic_funcs =
 {
 .read_disabled_bios = &cik_read_disabled_bios,
 .read_bios_from_rom = &cik_read_bios_from_rom,
-   .detect_hw_virtualization = cik_detect_hw_virtualization,
 .read_register = &cik_read_register,
 .reset = &cik_asic_reset,
 .set_vga_state = &cik_vga_set_state,
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c
index 6a85daa..bde82fa 100644
--- a/drivers/gpu/drm/amd/amdgpu/si.c
+++ b/drivers/gpu/drm/amd/amdgpu/si.c
@@ -1135,16 +1135,9 @@ static int si_set_uvd_clocks(struct amdgpu_device *adev, 
u32 vclk, u32 dclk)
 return 0;
 }

-static void si_detect_hw_virtualization(struct amdgpu_device *adev)
-{
-   if (is_virtual_machine()) /* passthrough mode */
-   adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE;
-}
-
 static const struct amdgpu_asic_funcs si_asic_funcs =
 {
 .read_disabled_bios = &si_read_disabled_bios,
-   .detect_hw_virtualization = si_detect_hw_virtualization,
 .read_register = &si_read_register,
 .reset = &si_asic_reset,
 .set_vga_state = &si_vga_set_state,
--
2.7.4

___
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


答复: [PATCH 1/2] drm/amdgpu/vi: move virtualization detection forward

2017-01-08 Thread Liu, Monk
Hi Xiangliang


please change as below accordingly:

1, call "vi_detect_hw_virtualization" in vi_set_ip_blocks directly

2, drop below changes:

+   if (amdgpu_sriov_vf(adev)) {
+   amdgpu_ip_block_add(adev, &vi_common_ip_block);
+   amdgpu_ip_block_add(adev, &gmc_v8_5_ip_block);
+   amdgpu_ip_block_add(adev, &tonga_ih_ip_block);
+   amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
+   amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
+   amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block);
+   amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block);
+   }


since some ip  version is different between VI (e.g. FIJI use gmc_v8_5 and 
tonga use v8_0, so your change at last increase more lines, we'll finally 
support TONGA/FIJI/Ellesmere for SRIOV)


BR Monk


发件人: amd-gfx  代表 Xiangliang Yu 

发送时间: 2017年1月8日 11:12:35
收件人: amd-gfx@lists.freedesktop.org
抄送: Yu, Xiangliang
主题: [PATCH 1/2] drm/amdgpu/vi: move virtualization detection forward

Move the detection forward into vi_set_ip_blocks function, then
add ip blocks virtualization need if device is VF.

Signed-off-by: Xiangliang Yu 
---
 drivers/gpu/drm/amd/amdgpu/vi.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
index b2ce7da..580b392 100644
--- a/drivers/gpu/drm/amd/amdgpu/vi.c
+++ b/drivers/gpu/drm/amd/amdgpu/vi.c
@@ -857,7 +857,6 @@ static const struct amdgpu_asic_funcs vi_asic_funcs =
 {
 .read_disabled_bios = &vi_read_disabled_bios,
 .read_bios_from_rom = &vi_read_bios_from_rom,
-   .detect_hw_virtualization = vi_detect_hw_virtualization,
 .read_register = &vi_read_register,
 .reset = &vi_asic_reset,
 .set_vga_state = &vi_vga_set_state,
@@ -1049,10 +1048,6 @@ static int vi_common_early_init(void *handle)
 return -EINVAL;
 }

-   /* in early init stage, vbios code won't work */
-   if (adev->asic_funcs->detect_hw_virtualization)
-   amdgpu_asic_detect_hw_virtualization(adev);
-
 if (amdgpu_smc_load_fw && smc_enabled)
 adev->firmware.smu_load = true;

@@ -1403,6 +1398,18 @@ static const struct amdgpu_ip_block_version 
vi_common_ip_block =

 int vi_set_ip_blocks(struct amdgpu_device *adev)
 {
+   /* in early init stage, vbios code won't work */
+   vi_detect_hw_virtualization(adev);
+   if (amdgpu_sriov_vf(adev)) {
+   amdgpu_ip_block_add(adev, &vi_common_ip_block);
+   amdgpu_ip_block_add(adev, &gmc_v8_5_ip_block);
+   amdgpu_ip_block_add(adev, &tonga_ih_ip_block);
+   amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
+   amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
+   amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block);
+   amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block);
+   }
+
 switch (adev->asic_type) {
 case CHIP_TOPAZ:
 /* topaz has no DCE, UVD, VCE */
--
2.7.4

___
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


Re: [PATCH 4/4] drm/amd/powerplay: add profiling mode in dpm level

2017-01-08 Thread Andy Furniss

Alex Deucher wrote:

On Fri, Dec 23, 2016 at 3:45 AM, Rex Zhu  wrote:

Change-Id: I4a46440882cd94fe5e77e3f351aaccc218a2ece5


Patches 1-3:
Reviewed-by: Alex Deucher 

patch 4:
Please add a better patch description and explain what profiling mode
is good for, etc.


This on drm-next-4.10-wip regresses setting profile a bit on R9285.

It works eg. if in auto then doing

echo high > /sys/class/drm/card0/device/power_dpm_force_performance_level

is OK and echo auto  > ... is also OK.

The issue if I am in auto and echo auto >  then I don't get my
prompt back.

echo high from elsewhere will make it return - but it doesn't set high.

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