Skip to contentSkip to conversation

drm/admdgpu: Add get_gfx_off_status interface

PATCH In review [email protected] 4 participants 4 messages Jul 21, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/admdgpu: Add get_gfx_off_status interface

From: Shikai Guo <[email protected]>

add get_gfx_off_status interface to yellow_carp_ppt_funcs structure.

---
 .../drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c  | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +30 -0
index 70cbc46341a3..cac48121d72b 100644
@@ -31,6 +31,7 @@
 #include "smu_v13_0_1_ppsmc.h"
 #include "smu_v13_0_1_pmfw.h"
 #include "smu_cmn.h"
+#include "asic_reg/smuio/smuio_13_0_2_offset.h"
 
 /*
  * DO NOT use these for err/warn/info/debug messages.
@@ -42,6 +43,9 @@
 #undef pr_info
 #undef pr_debug
 
+#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS_MASK		0x00000006L
+#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS__SHIFT			0x1
+
 #define FEATURE_MASK(feature) (1ULL << feature)
 #define SMC_DPM_FEATURE ( \
 	FEATURE_MASK(FEATURE_CCLK_DPM_BIT) | \
@@ -587,6 +591,31 @@ static ssize_t yellow_carp_get_gpu_metrics(struct smu_context *smu,
 	return sizeof(struct gpu_metrics_v2_1);
 }
 
+/**
+ * yellow_carp_get_gfxoff_status - get gfxoff status
+ *
+ * @smu: amdgpu_device pointer
+ *
+ * This function will be used to get gfxoff status
+ *
+ * Returns 0=GFXOFF(default).
+ * Returns 1=Transition out of GFX State.
+ * Returns 2=Not in GFXOFF.
+ * Returns 3=Transition into GFXOFF.
+ */
+static uint32_t yellow_carp_get_gfxoff_status(struct smu_context *smu)
+{
+	uint32_t reg;
+	uint32_t gfxOff_Status = 0;
+	struct amdgpu_device *adev = smu->adev;
+
+	reg = RREG32_SOC15(SMUIO, 0, regSMUIO_GFX_MISC_CNTL);
+	gfxOff_Status = (reg & SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS_MASK)
+		>> SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS__SHIFT;
+
+	return gfxOff_Status;
+}
+
 static int yellow_carp_set_default_dpm_tables(struct smu_context *smu)
 {
 	struct smu_table_context *smu_table = &smu->smu_table;
@@ -1186,6 +1215,7 @@ static const struct pptable_funcs yellow_carp_ppt_funcs = {
 	.get_pp_feature_mask = smu_cmn_get_pp_feature_mask,
 	.set_driver_table_location = smu_v13_0_set_driver_table_location,
 	.gfx_off_control = smu_v13_0_gfx_off_control,
+	.get_gfx_off_status = yellow_carp_get_gfxoff_status,
 	.post_init = yellow_carp_post_smu_init,
 	.mode2_reset = yellow_carp_mode2_reset,
 	.get_dpm_ultimate_freq = yellow_carp_get_dpm_ultimate_freq,
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

Quoted 90 lines

-----Original Message-----
From: Guo, Shikai <[email protected]>
Sent: Thursday, July 21, 2022 2:20 PM
To: [email protected]
Cc: Quan, Evan <[email protected]>; Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>; Guo, Shikai <[email protected]>; Guo, Shikai <[email protected]>
Subject: [PATCH] drm/admdgpu: Add get_gfx_off_status interface

From: Shikai Guo <[email protected]>

add get_gfx_off_status interface to yellow_carp_ppt_funcs structure.

---
 .../drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c  | 30
+++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +4 -0
index 70cbc46341a3..cac48121d72b 100644
@@ -31,6 +31,7 @@
 #include "smu_v13_0_1_ppsmc.h"
 #include "smu_v13_0_1_pmfw.h"
 #include "smu_cmn.h"
+#include "asic_reg/smuio/smuio_13_0_2_offset.h"
 
 /*
  * DO NOT use these for err/warn/info/debug messages.
@@ -42,6 +43,9 @@
 #undef pr_info
 #undef pr_debug
 
+#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS_MASK
 	0x00000006L
+#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS__SHIFT
 		0x1
+
 #define FEATURE_MASK(feature) (1ULL << feature)

#define SMC_DPM_FEATURE ( \

drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +25 -0
 	FEATURE_MASK(FEATURE_CCLK_DPM_BIT) | \
@@ -587,6 +591,31 @@ static ssize_t yellow_carp_get_gpu_metrics(struct
 smu_context *smu,
 	return sizeof(struct gpu_metrics_v2_1);
 }
 
+/**
+ * yellow_carp_get_gfxoff_status - get gfxoff status
+ *
+ * @smu: amdgpu_device pointer
+ *
+ * This function will be used to get gfxoff status
+ *
+ * Returns 0=GFXOFF(default).
+ * Returns 1=Transition out of GFX State.
+ * Returns 2=Not in GFXOFF.
+ * Returns 3=Transition into GFXOFF.
+ */
+static uint32_t yellow_carp_get_gfxoff_status(struct smu_context *smu)
+{
+	uint32_t reg;
+	uint32_t gfxOff_Status = 0;
+	struct amdgpu_device *adev = smu->adev;
+
+	reg = RREG32_SOC15(SMUIO, 0, regSMUIO_GFX_MISC_CNTL);
+	gfxOff_Status = (reg &
 SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS_MASK)
+		>>
 SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS__SHIFT;
+
+	return gfxOff_Status;
+}
+

static int yellow_carp_set_default_dpm_tables(struct smu_context *smu) {

drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +1 -0
 	struct smu_table_context *smu_table = &smu->smu_table;
@@ -1186,6 +1215,7 @@ static const struct pptable_funcs
 yellow_carp_ppt_funcs = {
 	.get_pp_feature_mask = smu_cmn_get_pp_feature_mask,
 	.set_driver_table_location = smu_v13_0_set_driver_table_location,
 	.gfx_off_control = smu_v13_0_gfx_off_control,
+	.get_gfx_off_status = yellow_carp_get_gfxoff_status,
 	.post_init = yellow_carp_post_smu_init,
 	.mode2_reset = yellow_carp_mode2_reset,

.get_dpm_ultimate_freq = yellow_carp_get_dpm_ultimate_freq,
--
2.25.1

#2 lore raw
In reply to [email protected]

*@smu: amdgpu_device pointer

I guess a typo here, smu is not amdgpu device pointer.

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of [email protected]
Sent: Thursday, July 21, 2022 2:20 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>; Quan, Evan <[email protected]>; Guo, Shikai <[email protected]>
Subject: [PATCH] drm/admdgpu: Add get_gfx_off_status interface

From: Shikai Guo <[email protected]>

add get_gfx_off_status interface to yellow_carp_ppt_funcs structure.

---
 .../drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c  | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +4 -0
index 70cbc46341a3..cac48121d72b 100644
@@ -31,6 +31,7 @@
 #include "smu_v13_0_1_ppsmc.h"
 #include "smu_v13_0_1_pmfw.h"
 #include "smu_cmn.h"
+#include "asic_reg/smuio/smuio_13_0_2_offset.h"
 
 /*
  * DO NOT use these for err/warn/info/debug messages.
@@ -42,6 +43,9 @@
 #undef pr_info
 #undef pr_debug
 
+#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS_MASK		0x00000006L
+#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS__SHIFT			0x1
+
 #define FEATURE_MASK(feature) (1ULL << feature)  #define SMC_DPM_FEATURE ( \
 	FEATURE_MASK(FEATURE_CCLK_DPM_BIT) | \ @@ -587,6 +591,31 @@ static ssize_t yellow_carp_get_gpu_metrics(struct smu_context *smu,
 	return sizeof(struct gpu_metrics_v2_1);  }

+/**
+ * yellow_carp_get_gfxoff_status - get gfxoff status
+ *
+ * @smu: amdgpu_device pointer
+ *
+ * This function will be used to get gfxoff status
+ *
+ * Returns 0=GFXOFF(default).
+ * Returns 1=Transition out of GFX State.
+ * Returns 2=Not in GFXOFF.
+ * Returns 3=Transition into GFXOFF.
+ */
+static uint32_t yellow_carp_get_gfxoff_status(struct smu_context *smu)
+{
+ uint32_t reg;
+ uint32_t gfxOff_Status = 0;
+ struct amdgpu_device *adev = smu->adev;
+
+ reg = RREG32_SOC15(SMUIO, 0, regSMUIO_GFX_MISC_CNTL);
+ gfxOff_Status = (reg & SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS_MASK)
+ >> SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS__SHIFT;
+
+ return gfxOff_Status;
+}
+
static int yellow_carp_set_default_dpm_tables(struct smu_context *smu) {
struct smu_table_context *smu_table = &smu->smu_table; @@ -1186,6 +1215,7 @@ static const struct pptable_funcs yellow_carp_ppt_funcs = { .get_pp_feature_mask = smu_cmn_get_pp_feature_mask,
.set_driver_table_location = smu_v13_0_set_driver_table_location,
.gfx_off_control = smu_v13_0_gfx_off_control,
+ .get_gfx_off_status = yellow_carp_get_gfxoff_status,
.post_init = yellow_carp_post_smu_init,
.mode2_reset = yellow_carp_mode2_reset,
.get_dpm_ultimate_freq = yellow_carp_get_dpm_ultimate_freq,
--
2.25.1

#3 lore raw
In reply to [email protected]

[Public]

It looks like the amdgpu_device pointer declaration is useless, please clean it up. Meanwhile need correct the patch subject prefix to drm/amd/pm: instead of drm/admdgpu.

With the above fixed the patch is Reviewed-by: Prike Liang <[email protected]>

Quoted 86 lines

-----Original Message-----
From: Guo, Shikai <[email protected]>
Sent: Thursday, July 21, 2022 2:20 PM
To: [email protected]
Cc: Quan, Evan <[email protected]>; Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>; Guo, Shikai <[email protected]>; Guo, Shikai <[email protected]>
Subject: [PATCH] drm/admdgpu: Add get_gfx_off_status interface

From: Shikai Guo <[email protected]>

add get_gfx_off_status interface to yellow_carp_ppt_funcs structure.

---
 .../drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c  | 30
+++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +4 -0
index 70cbc46341a3..cac48121d72b 100644
@@ -31,6 +31,7 @@
 #include "smu_v13_0_1_ppsmc.h"
 #include "smu_v13_0_1_pmfw.h"
 #include "smu_cmn.h"
+#include "asic_reg/smuio/smuio_13_0_2_offset.h"
 
 /*
  * DO NOT use these for err/warn/info/debug messages.
@@ -42,6 +43,9 @@
 #undef pr_info
 #undef pr_debug
 
+#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS_MASK
      0x00000006L
+#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS__SHIFT
              0x1
+
 #define FEATURE_MASK(feature) (1ULL << feature)  #define
SMC_DPM_FEATURE ( \
      FEATURE_MASK(FEATURE_CCLK_DPM_BIT) | \ @@ -587,6 +591,31
@@ static ssize_t yellow_carp_get_gpu_metrics(struct smu_context *smu,
      return sizeof(struct gpu_metrics_v2_1);  }
drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +20 -0
+/**
+ * yellow_carp_get_gfxoff_status - get gfxoff status
+ *
+ * @smu: amdgpu_device pointer
+ *
+ * This function will be used to get gfxoff status
+ *
+ * Returns 0=GFXOFF(default).
+ * Returns 1=Transition out of GFX State.
+ * Returns 2=Not in GFXOFF.
+ * Returns 3=Transition into GFXOFF.
+ */
+static uint32_t yellow_carp_get_gfxoff_status(struct smu_context *smu)
+{
+     uint32_t reg;
+     uint32_t gfxOff_Status = 0;
+     struct amdgpu_device *adev = smu->adev;
+
+     reg = RREG32_SOC15(SMUIO, 0, regSMUIO_GFX_MISC_CNTL);
+     gfxOff_Status = (reg &

SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS_MASK)

drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +5 -0
+             >> SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS__SHIFT;
+
+     return gfxOff_Status;
+}
+
 static int yellow_carp_set_default_dpm_tables(struct smu_context *smu)  {
      struct smu_table_context *smu_table = &smu->smu_table; @@ -

1186,6 +1215,7 @@ static const struct pptable_funcs yellow_carp_ppt_funcs = {
.get_pp_feature_mask = smu_cmn_get_pp_feature_mask, .set_driver_table_location = smu_v13_0_set_driver_table_location, .gfx_off_control = smu_v13_0_gfx_off_control,
+ .get_gfx_off_status = yellow_carp_get_gfxoff_status,
.post_init = yellow_carp_post_smu_init,
.mode2_reset = yellow_carp_mode2_reset, .get_dpm_ultimate_freq = yellow_carp_get_dpm_ultimate_freq,
--
2.25.1