From: =?UTF-8?Q?Christian_K=c3=b6nig?= Subject: Re: [PATCH] drm/amdgpu:No action needs when VCN PG state is unchanged Date: Tue, 11 Sep 2018 17:17:54 +0200 Message-ID: <68b30f71-86eb-89a0-0f8d-fcfb18e89cc2@gmail.com> References: <1536598142-19689-1-git-send-email-James.Zhu@amd.com> Reply-To: christian.koenig-5C7GfCeVMHo@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1864429797==" Return-path: In-Reply-To: Content-Language: en-US List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Sender: "amd-gfx" To: James Zhu , Alex Deucher , James Zhu Cc: James Zhu , amd-gfx list This is a multi-part message in MIME format. --===============1864429797== Content-Type: multipart/alternative; boundary="------------525741412282FCED4FA8D558" Content-Language: en-US This is a multi-part message in MIME format. --------------525741412282FCED4FA8D558 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Am 11.09.2018 um 17:06 schrieb James Zhu: > > > > On 2018-09-11 10:44 AM, Alex Deucher wrote: >> On Mon, Sep 10, 2018 at 4:34 PM James Zhu wrote: >>> Signed-off-by: James Zhu >>> >>> When VCN PG state is unchanged, it is unnecessary to reset >>> power gate state again. >> Don't you need to initialize and store the PG state somewhere? You >> are just using a local variable here. >> >> Alex >> > Hi Alex, > > I used */static/* for this local state variable(*cur_state*) with > initialization state AMD_PG_STATE_GATE. That won't work correctly. A "static" variable is global, but the power state is per device. Regards, Christian. > this variable's scope is only inside this function, but it's > initialization is done > once at compile time and it's lifetime will last until the driver exit. > > Since it is only used inside this function, I didn't put it into > struct amdgpu_vcn. > > Best Regards! > James Zhu >>> --- >>> drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 13 +++++++++++-- >>> 1 file changed, 11 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c >>> index 2664bb2..86d98d2 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c >>> @@ -1633,12 +1633,21 @@ static int vcn_v1_0_set_powergating_state(void *handle, >>> * revisit this when there is a cleaner line between >>> * the smc and the hw blocks >>> */ >>> + int ret; >>> + static enum amd_powergating_state cur_state = AMD_PG_STATE_GATE; >>> struct amdgpu_device *adev = (struct amdgpu_device *)handle; >>> >>> + if (state == cur_state) >>> + return 0; >>> + >>> if (state == AMD_PG_STATE_GATE) >>> - return vcn_v1_0_stop(adev); >>> + ret = vcn_v1_0_stop(adev); >>> else >>> - return vcn_v1_0_start(adev); >>> + ret = vcn_v1_0_start(adev); >>> + >>> + if (!ret) >>> + cur_state = state; >>> + return ret; >>> } >>> >>> static const struct amd_ip_funcs vcn_v1_0_ip_funcs = { >>> -- >>> 2.7.4 >>> >>> _______________________________________________ >>> amd-gfx mailing list >>> amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org >>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx > > > > _______________________________________________ > amd-gfx mailing list > amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx --------------525741412282FCED4FA8D558 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit
Am 11.09.2018 um 17:06 schrieb James Zhu:



On 2018-09-11 10:44 AM, Alex Deucher wrote:
On Mon, Sep 10, 2018 at 4:34 PM James Zhu <jzhums-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Signed-off-by: James Zhu <James.Zhu-5C7GfCeVMHo@public.gmane.org>

When VCN PG state is unchanged, it is unnecessary to reset
power gate state again.
Don't you need to initialize and store the PG state somewhere?  You
are just using a local variable here.

Alex

Hi Alex,

I used static for this local state variable(cur_state) with initialization state AMD_PG_STATE_GATE.

That won't work correctly. A "static" variable is global, but the power state is per device.

Regards,
Christian.

this variable's scope is only inside this function, but it's initialization is done
once at compile time and it's lifetime will last until the driver exit.

Since it is only used inside this function, I didn't put it into struct amdgpu_vcn.

Best Regards!
James Zhu
---
 drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
index 2664bb2..86d98d2 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
@@ -1633,12 +1633,21 @@ static int vcn_v1_0_set_powergating_state(void *handle,
         * revisit this when there is a cleaner line between
         * the smc and the hw blocks
         */
+       int ret;
+       static enum amd_powergating_state cur_state = AMD_PG_STATE_GATE;
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;

+       if (state == cur_state)
+               return 0;
+
        if (state == AMD_PG_STATE_GATE)
-               return vcn_v1_0_stop(adev);
+               ret = vcn_v1_0_stop(adev);
        else
-               return vcn_v1_0_start(adev);
+               ret = vcn_v1_0_start(adev);
+
+       if (!ret)
+               cur_state = state;
+       return ret;
 }

 static const struct amd_ip_funcs vcn_v1_0_ip_funcs = {
--
2.7.4

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



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

--------------525741412282FCED4FA8D558-- --===============1864429797== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KYW1kLWdmeCBt YWlsaW5nIGxpc3QKYW1kLWdmeEBsaXN0cy5mcmVlZGVza3RvcC5vcmcKaHR0cHM6Ly9saXN0cy5m cmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9hbWQtZ2Z4Cg== --===============1864429797==--