All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Quan, Evan" <Evan.Quan@amd.com>
To: Paul Menzel <pmenzel@molgen.mpg.de>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"Lazar, Lijo" <Lijo.Lazar@amd.com>, Borislav Petkov <bp@suse.de>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Subject: RE: [PATCH] drm/amd/pm: avoid duplicate powergate/ungate setting
Date: Tue, 9 Nov 2021 03:24:47 +0000	[thread overview]
Message-ID: <DM6PR12MB261990A29A6F83192D1D277FE4929@DM6PR12MB2619.namprd12.prod.outlook.com> (raw)
In-Reply-To: <427ace3e-ba04-bd5c-4eef-d83147ef288e@molgen.mpg.de>

[AMD Official Use Only]



> -----Original Message-----
> From: Paul Menzel <pmenzel@molgen.mpg.de>
> Sent: Monday, November 8, 2021 4:51 PM
> To: Quan, Evan <Evan.Quan@amd.com>
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Lazar, Lijo
> <Lijo.Lazar@amd.com>; Borislav Petkov <bp@suse.de>; amd-
> gfx@lists.freedesktop.org
> Subject: Re: [PATCH] drm/amd/pm: avoid duplicate powergate/ungate
> setting
> 
> Dear Evan,
> 
> 
> Am 08.11.21 um 05:47 schrieb Evan Quan:
> > Just bail out if the target IP block is already in the desired
> > powergate/ungate state. This can avoid some duplicate settings which
> > sometime may cause unexpected issues.
> 
> sometime*s*
> 
> Please elaborate the kind of issues.
> 
> On what systems did you test this? Also, there is a new debug log message.
[Quan, Evan] Locally I verified this on my Polaris12 card and Boris helped to verify on his Carrizo platform. Both show positive results.
The log message was left intentionally. But I downgraded the log level from INFO to DEBUG to avoid confusing.
> 
> > Change-Id: I66346c69f121df0f5ee20182451313ae4fda2d04
> > Signed-off-by: Evan Quan <evan.quan@amd.com>
> > Tested-by: Borislav Petkov <bp@suse.de>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu.h              |  7 +++++++
> >   drivers/gpu/drm/amd/include/amd_shared.h         |  3 ++-
> >   drivers/gpu/drm/amd/pm/amdgpu_dpm.c              | 13 ++++++++++++-
> >   drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c |  3 +++
> >   drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c        |  3 +++
> >   drivers/gpu/drm/amd/pm/powerplay/si_dpm.c        |  3 +++
> >   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c        |  3 +++
> >   7 files changed, 33 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > index b85b67a88a3d..19fa21ad8a44 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > @@ -767,9 +767,16 @@ enum amd_hw_ip_block_type {
> >   #define HW_ID_MAX		300
> >   #define IP_VERSION(mj, mn, rv) (((mj) << 16) | ((mn) << 8) | (rv))
> >
> > +enum amd_ip_powergate_state {
> > +	POWERGATE_STATE_INITIAL,
> > +	POWERGATE_STATE_GATE,
> > +	POWERGATE_STATE_UNGATE,
> > +};
> > +
> >   struct amd_powerplay {
> >   	void *pp_handle;
> >   	const struct amd_pm_funcs *pp_funcs;
> > +	atomic_t pg_state[AMD_IP_BLOCK_TYPE_NUM];
> >   };
> >
> >   /* polaris10 kickers */
> > diff --git a/drivers/gpu/drm/amd/include/amd_shared.h
> > b/drivers/gpu/drm/amd/include/amd_shared.h
> > index f1a46d16f7ea..4b9e68a79f06 100644
> > --- a/drivers/gpu/drm/amd/include/amd_shared.h
> > +++ b/drivers/gpu/drm/amd/include/amd_shared.h
> > @@ -98,7 +98,8 @@ enum amd_ip_block_type {
> >   	AMD_IP_BLOCK_TYPE_ACP,
> >   	AMD_IP_BLOCK_TYPE_VCN,
> >   	AMD_IP_BLOCK_TYPE_MES,
> > -	AMD_IP_BLOCK_TYPE_JPEG
> > +	AMD_IP_BLOCK_TYPE_JPEG,
> > +	AMD_IP_BLOCK_TYPE_NUM,
> >   };
> >
> >   enum amd_clockgating_state {
> > diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > index 03581d5b1836..a6b337b6f4a9 100644
> > --- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > +++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > @@ -927,6 +927,14 @@ int
> amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev,
> uint32_t block
> >   {
> >   	int ret = 0;
> >   	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
> > +	enum amd_ip_powergate_state pg_state =
> > +		gate ? POWERGATE_STATE_GATE :
> POWERGATE_STATE_UNGATE;
> > +
> > +	if (atomic_read(&adev->powerplay.pg_state[block_type]) ==
> pg_state) {
> > +		dev_dbg(adev->dev, "IP block%d already in the target %s
> state!",
> > +				block_type, gate ? "gate" : "ungate");
> > +		return 0;
> > +	}
> >
> >   	switch (block_type) {
> >   	case AMD_IP_BLOCK_TYPE_UVD:
> > @@ -976,9 +984,12 @@ int
> amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev,
> uint32_t block
> >   		}
> >   		break;
> >   	default:
> > -		break;
> > +		return -EINVAL;
> >   	}
> >
> > +	if (!ret)
> > +		atomic_set(&adev->powerplay.pg_state[block_type],
> pg_state);
> > +
> >   	return ret;
> >   }
> >
> > diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
> > b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
> > index bba7479f6265..8d8a7cf615eb 100644
> > --- a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
> > +++ b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
> > @@ -38,6 +38,7 @@ static const struct amd_pm_funcs pp_dpm_funcs;
> >   static int amd_powerplay_create(struct amdgpu_device *adev)
> >   {
> >   	struct pp_hwmgr *hwmgr;
> > +	int i;
> 
> I’d use `unsigned int` or `size_t` to make it clear, that they cannot get
> negative.
[Quan, Evan] Sure, I can do that.

BR
Evan
> 
> >
> >   	if (adev == NULL)
> >   		return -EINVAL;
> > @@ -57,6 +58,8 @@ static int amd_powerplay_create(struct
> amdgpu_device *adev)
> >   	hwmgr->display_config = &adev->pm.pm_display_cfg;
> >   	adev->powerplay.pp_handle = hwmgr;
> >   	adev->powerplay.pp_funcs = &pp_dpm_funcs;
> > +	for (i = 0; i < AMD_IP_BLOCK_TYPE_NUM; i++)
> > +		atomic_set(&adev->powerplay.pg_state[i],
> POWERGATE_STATE_INITIAL);
> >   	return 0;
> >   }
> >
> > diff --git a/drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c
> > b/drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c
> > index bcae42cef374..f84f56552fd0 100644
> > --- a/drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c
> > +++ b/drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c
> > @@ -2965,9 +2965,12 @@ static int kv_dpm_get_temp(void *handle)
> >   static int kv_dpm_early_init(void *handle)
> >   {
> >   	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> > +	int i;
> >
> >   	adev->powerplay.pp_funcs = &kv_dpm_funcs;
> >   	adev->powerplay.pp_handle = adev;
> > +	for (i = 0; i < AMD_IP_BLOCK_TYPE_NUM; i++)
> > +		atomic_set(&adev->powerplay.pg_state[i],
> POWERGATE_STATE_INITIAL);
> >   	kv_dpm_set_irq_funcs(adev);
> >
> >   	return 0;
> > diff --git a/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c
> > b/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c
> > index 81f82aa05ec2..f1eb22c9bb59 100644
> > --- a/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c
> > +++ b/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c
> > @@ -7916,9 +7916,12 @@ static int si_dpm_early_init(void *handle)
> >   {
> >
> >   	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> > +	int i;
> >
> >   	adev->powerplay.pp_funcs = &si_dpm_funcs;
> >   	adev->powerplay.pp_handle = adev;
> > +	for (i = 0; i < AMD_IP_BLOCK_TYPE_NUM; i++)
> > +		atomic_set(&adev->powerplay.pg_state[i],
> POWERGATE_STATE_INITIAL);
> >   	si_dpm_set_irq_funcs(adev);
> >   	return 0;
> >   }
> > diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > index 01168b8955bf..fdc25bae8237 100644
> > --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > @@ -627,6 +627,7 @@ static int smu_early_init(void *handle)
> >   {
> >   	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> >   	struct smu_context *smu = &adev->smu;
> > +	int i;
> >
> >   	smu->adev = adev;
> >   	smu->pm_enabled = !!amdgpu_dpm;
> > @@ -639,6 +640,8 @@ static int smu_early_init(void *handle)
> >
> >   	adev->powerplay.pp_handle = smu;
> >   	adev->powerplay.pp_funcs = &swsmu_pm_funcs;
> > +	for (i = 0; i < AMD_IP_BLOCK_TYPE_NUM; i++)
> > +		atomic_set(&adev->powerplay.pg_state[i],
> POWERGATE_STATE_INITIAL);
> >
> >   	return smu_set_funcs(adev);
> >   }
> >

  parent reply	other threads:[~2021-11-09  3:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08  4:47 [PATCH] drm/amd/pm: avoid duplicate powergate/ungate setting Evan Quan
2021-11-08  8:51 ` Paul Menzel
2021-11-08 11:15   ` Borislav Petkov
2021-11-08 14:14     ` Christian König
2021-11-08 14:41       ` Lazar, Lijo
2021-11-09  3:56         ` Quan, Evan
2021-11-09  7:16         ` Christian König
2021-11-09  7:28           ` Lazar, Lijo
2021-11-09  7:44             ` Christian König
2021-11-09  8:51             ` Quan, Evan
2021-11-09  3:25     ` Quan, Evan
2021-11-09  3:24   ` Quan, Evan [this message]
2021-11-08 11:15 ` Lazar, Lijo
2021-11-09  3:40   ` Quan, Evan
2021-11-09  4:15     ` Lazar, Lijo
2021-11-09  8:45       ` Quan, Evan
2021-11-10  9:39         ` Lazar, Lijo
2021-11-11  7:57 Evan Quan
2021-11-12  8:45 ` Lazar, Lijo
2021-11-15  2:45   ` Quan, Evan

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=DM6PR12MB261990A29A6F83192D1D277FE4929@DM6PR12MB2619.namprd12.prod.outlook.com \
    --to=evan.quan@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Lijo.Lazar@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=bp@suse.de \
    --cc=pmenzel@molgen.mpg.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.