amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: "Sun, Roy" <Roy.Sun@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH] drm/amd/amdgpu: Expose some power info through AMDGPU_INFO
Date: Tue, 13 Apr 2021 15:20:26 +0200	[thread overview]
Message-ID: <a27997fc-e635-299a-417b-eb70c2bde408@gmail.com> (raw)
In-Reply-To: <CY4PR12MB16062ED181829A47D1B4EC1DFF4F9@CY4PR12MB1606.namprd12.prod.outlook.com>



Am 13.04.21 um 15:09 schrieb Sun, Roy:
> [AMD Official Use Only - Internal Distribution Only]
>
> ping
>
> -----Original Message-----
> From: Roy Sun <Roy.Sun@amd.com>
> Sent: Monday, April 12, 2021 8:15 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Sun, Roy <Roy.Sun@amd.com>
> Subject: [PATCH] drm/amd/amdgpu: Expose some power info through AMDGPU_INFO
>
> Add interface to get the mm clock, temperature and memory load
>
> Signed-off-by: Roy Sun <Roy.Sun@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 50 +++++++++++++++++++++++++
>   include/uapi/drm/amdgpu_drm.h           | 12 ++++++
>   2 files changed, 62 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index b2e774aeab45..e5b16e0819ce 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -971,6 +971,56 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
>   			}
>   			ui32 /= 100;
>   			break;
> +		case AMDGPU_INFO_SENSOR_UVD_VCLK:
> +			/* get mm vclk in Mhz */

Maybe drop the comment, it looks redundant.

> +			if (amdgpu_dpm_read_sensor(adev,
> +						   AMDGPU_PP_SENSOR_UVD_VCLK,

In general I would not repeat that code over and over again, but rather 
translate the parameter and then call amdgpu_dpm_read_sensor() once.

But this is just my top level view on code I don't know well.

Regards,
Christian.

> +						   (void *)&ui32, &ui32_size)) {
> +				return -EINVAL;
> +			}
> +			ui32 /= 100;
> +			break;
> +		case AMDGPU_INFO_SENSOR_UVD_DCLK:
> +			/* get mm dclk in Mhz */
> +			if (amdgpu_dpm_read_sensor(adev,
> +						   AMDGPU_PP_SENSOR_UVD_DCLK,
> +						   (void *)&ui32, &ui32_size)) {
> +				return -EINVAL;
> +			}
> +			ui32 /= 100;
> +			break;
> +		case AMDGPU_INFO_SENSOR_HOTSPOT_TEMP:
> +			/* get junction temperature */
> +			if (amdgpu_dpm_read_sensor(adev,
> +						   AMDGPU_PP_SENSOR_HOTSPOT_TEMP,
> +						   (void *)&ui32, &ui32_size)) {
> +				return -EINVAL;
> +			}
> +			break;
> +		case AMDGPU_INFO_SENSOR_EDGE_TEMP:
> +			/* get current edge temperature */
> +			if (amdgpu_dpm_read_sensor(adev,
> +						   AMDGPU_PP_SENSOR_EDGE_TEMP,
> +						   (void *)&ui32, &ui32_size)) {
> +				return -EINVAL;
> +			}
> +			break;
> +		case AMDGPU_INFO_SENSOR_MEM_TEMP:
> +			/* get current memory temperature */
> +			if (amdgpu_dpm_read_sensor(adev,
> +						   AMDGPU_PP_SENSOR_MEM_TEMP,
> +						   (void *)&ui32, &ui32_size)) {
> +				return -EINVAL;
> +			}
> +			break;
> +		case AMDGPU_INFO_SENSOR_MEM_LOAD:
> +			/* get memory load */
> +			if (amdgpu_dpm_read_sensor(adev,
> +						   AMDGPU_PP_SENSOR_MEM_LOAD,
> +						   (void *)&ui32, &ui32_size)) {
> +				return -EINVAL;
> +			}
> +			break;
>   		default:
>   			DRM_DEBUG_KMS("Invalid request %d\n",
>   				      info->sensor_info.type);
> diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h index 8b832f7458f2..484c72e17c72 100644
> --- a/include/uapi/drm/amdgpu_drm.h
> +++ b/include/uapi/drm/amdgpu_drm.h
> @@ -780,6 +780,18 @@ struct drm_amdgpu_cs_chunk_data {
>   	#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK		0x8
>   	/* Subquery id: Query GPU stable pstate memory clock */
>   	#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK		0x9
> +	/* Subquery id: Query GPU mm vclk */
> +	#define AMDGPU_INFO_SENSOR_UVD_VCLK		0xa
> +	/* Subquery id: Query GPU mm dclk */
> +	#define AMDGPU_INFO_SENSOR_UVD_DCLK		0xb
> +	/* Subquery id: Query junction temperature */
> +	#define AMDGPU_INFO_SENSOR_HOTSPOT_TEMP		0xc
> +	/* Subquery id: Query edge temperature */
> +	#define AMDGPU_INFO_SENSOR_EDGE_TEMP		0xd
> +	/* Subquery id: Query memory temperature */
> +	#define AMDGPU_INFO_SENSOR_MEM_TEMP		0xe
> +	/* Subquery id: Query Memory load */
> +	#define AMDGPU_INFO_SENSOR_MEM_LOAD		0xf
>   /* Number of VRAM page faults on CPU access. */
>   #define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS	0x1E
>   #define AMDGPU_INFO_VRAM_LOST_COUNTER		0x1F
> --
> 2.31.1
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

  reply	other threads:[~2021-04-13 13:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 12:15 [PATCH] drm/amd/amdgpu: Expose some power info through AMDGPU_INFO Roy Sun
2021-04-13 13:09 ` Sun, Roy
2021-04-13 13:20   ` Christian König [this message]
2021-04-13 14:58 ` Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a27997fc-e635-299a-417b-eb70c2bde408@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=Roy.Sun@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).