diff mbox series

[v2,1/1] drm/amd/pm: Implement get GFXOFF status for vangogh

Message ID 20220711193458.158462-1-andrealmeid@igalia.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/1] drm/amd/pm: Implement get GFXOFF status for vangogh | expand

Commit Message

André Almeida July 11, 2022, 7:34 p.m. UTC
Implement function to get current GFXOFF status for vangogh.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
Changes from v1:
- Squash commits in a single one

 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 38 +++++++++++++++++++
 1 file changed, 38 insertions(+)

Comments

Evan Quan July 12, 2022, 3:56 a.m. UTC | #1
[AMD Official Use Only - General]

Acked-by: Evan Quan <evan.quan@amd.com>

> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of
> André Almeida
> Sent: Tuesday, July 12, 2022 3:35 AM
> To: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; Pan, Xinhui <Xinhui.Pan@amd.com>; David
> Airlie <airlied@linux.ie>; Daniel Vetter <daniel@ffwll.ch>; Zhang, Hawking
> <Hawking.Zhang@amd.com>; Zhou1, Tao <Tao.Zhou1@amd.com>; Kuehling,
> Felix <Felix.Kuehling@amd.com>; Xiao, Jack <Jack.Xiao@amd.com>; amd-
> gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; linux-
> kernel@vger.kernel.org
> Cc: André Almeida <andrealmeid@igalia.com>; kernel-dev@igalia.com
> Subject: [PATCH v2 1/1] drm/amd/pm: Implement get GFXOFF status for
> vangogh
> 
> Implement function to get current GFXOFF status for vangogh.
> 
> Signed-off-by: André Almeida <andrealmeid@igalia.com>
> ---
> Changes from v1:
> - Squash commits in a single one
> 
>  .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 38
> +++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
> b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
> index e2d8ac90cf36..89504ff8e9ed 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
> @@ -46,6 +46,18 @@
>  #undef pr_info
>  #undef pr_debug
> 
> +// Registers related to GFXOFF
> +// addressBlock: smuio_smuio_SmuSmuioDec
> +// base address: 0x5a000
> +#define mmSMUIO_GFX_MISC_CNTL			0x00c5
> +#define mmSMUIO_GFX_MISC_CNTL_BASE_IDX		0
> +
> +//SMUIO_GFX_MISC_CNTL
> +#define SMUIO_GFX_MISC_CNTL__SMU_GFX_cold_vs_gfxoff__SHIFT
> 	0x0
> +#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS__SHIFT
> 	0x1
> +#define SMUIO_GFX_MISC_CNTL__SMU_GFX_cold_vs_gfxoff_MASK
> 	0x00000001L
> +#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS_MASK
> 	0x00000006L
> +
>  #define FEATURE_MASK(feature) (1ULL << feature)
>  #define SMC_DPM_FEATURE ( \
>  	FEATURE_MASK(FEATURE_CCLK_DPM_BIT) | \
> @@ -2045,6 +2057,31 @@ static int vangogh_mode2_reset(struct
> smu_context *smu)
>  	return vangogh_mode_reset(smu, SMU_RESET_MODE_2);
>  }
> 
> +/**
> + * vangogh_get_gfxoff_status - Get gfxoff status
> + *
> + * @smu: amdgpu_device pointer
> + *
> + * Get current gfxoff status
> + *
> + * Return:
> + * * 0	- GFXOFF (default if enabled).
> + * * 1	- Transition out of GFX State.
> + * * 2	- Not in GFXOFF.
> + * * 3	- Transition into GFXOFF.
> + */
> +static u32 vangogh_get_gfxoff_status(struct smu_context *smu)
> +{
> +	struct amdgpu_device *adev = smu->adev;
> +	u32 reg, gfxoff_status;
> +
> +	reg = RREG32_SOC15(SMUIO, 0, mmSMUIO_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 vangogh_get_power_limit(struct smu_context *smu,
>  				   uint32_t *current_power_limit,
>  				   uint32_t *default_power_limit,
> @@ -2199,6 +2236,7 @@ static const struct pptable_funcs
> vangogh_ppt_funcs = {
>  	.post_init = vangogh_post_smu_init,
>  	.mode2_reset = vangogh_mode2_reset,
>  	.gfx_off_control = smu_v11_0_gfx_off_control,
> +	.get_gfx_off_status = vangogh_get_gfxoff_status,
>  	.get_ppt_limit = vangogh_get_ppt_limit,
>  	.get_power_limit = vangogh_get_power_limit,
>  	.set_power_limit = vangogh_set_power_limit,
> --
> 2.37.0
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
index e2d8ac90cf36..89504ff8e9ed 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
@@ -46,6 +46,18 @@ 
 #undef pr_info
 #undef pr_debug
 
+// Registers related to GFXOFF
+// addressBlock: smuio_smuio_SmuSmuioDec
+// base address: 0x5a000
+#define mmSMUIO_GFX_MISC_CNTL			0x00c5
+#define mmSMUIO_GFX_MISC_CNTL_BASE_IDX		0
+
+//SMUIO_GFX_MISC_CNTL
+#define SMUIO_GFX_MISC_CNTL__SMU_GFX_cold_vs_gfxoff__SHIFT	0x0
+#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS__SHIFT		0x1
+#define SMUIO_GFX_MISC_CNTL__SMU_GFX_cold_vs_gfxoff_MASK	0x00000001L
+#define SMUIO_GFX_MISC_CNTL__PWR_GFXOFF_STATUS_MASK		0x00000006L
+
 #define FEATURE_MASK(feature) (1ULL << feature)
 #define SMC_DPM_FEATURE ( \
 	FEATURE_MASK(FEATURE_CCLK_DPM_BIT) | \
@@ -2045,6 +2057,31 @@  static int vangogh_mode2_reset(struct smu_context *smu)
 	return vangogh_mode_reset(smu, SMU_RESET_MODE_2);
 }
 
+/**
+ * vangogh_get_gfxoff_status - Get gfxoff status
+ *
+ * @smu: amdgpu_device pointer
+ *
+ * Get current gfxoff status
+ *
+ * Return:
+ * * 0	- GFXOFF (default if enabled).
+ * * 1	- Transition out of GFX State.
+ * * 2	- Not in GFXOFF.
+ * * 3	- Transition into GFXOFF.
+ */
+static u32 vangogh_get_gfxoff_status(struct smu_context *smu)
+{
+	struct amdgpu_device *adev = smu->adev;
+	u32 reg, gfxoff_status;
+
+	reg = RREG32_SOC15(SMUIO, 0, mmSMUIO_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 vangogh_get_power_limit(struct smu_context *smu,
 				   uint32_t *current_power_limit,
 				   uint32_t *default_power_limit,
@@ -2199,6 +2236,7 @@  static const struct pptable_funcs vangogh_ppt_funcs = {
 	.post_init = vangogh_post_smu_init,
 	.mode2_reset = vangogh_mode2_reset,
 	.gfx_off_control = smu_v11_0_gfx_off_control,
+	.get_gfx_off_status = vangogh_get_gfxoff_status,
 	.get_ppt_limit = vangogh_get_ppt_limit,
 	.get_power_limit = vangogh_get_power_limit,
 	.set_power_limit = vangogh_set_power_limit,