From: "S, Shirish" Subject: Re: [PATCH] drm/amdpu/vce_v3: skip suspend and resume if powergated Date: Fri, 10 Aug 2018 12:45:01 +0530 Message-ID: References: <1533881700-10371-1-git-send-email-shirish.s@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0990311926==" 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: "Zhu, Rex" , "S, Shirish" , "Deucher, Alexander" , "Liu, Leo" Cc: "amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org" This is a multi-part message in MIME format. --===============0990311926== Content-Type: multipart/alternative; boundary="------------5311365E7BC8463906096B8A" Content-Language: en-US This is a multi-part message in MIME format. --------------5311365E7BC8463906096B8A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 8/10/2018 12:02 PM, Zhu, Rex wrote: > > I am Ok with the check when call vce_v3_0_hw_fini. > > > But we may still need to call amdpug_vce_suspend/resume. > Done in V2. Have moved the check such that both are executed. Regards, Shirish S > > > and not sure whether need to do ring test when resume back. > > > Best Regards > > Rex > > ------------------------------------------------------------------------ > *From:* S, Shirish > *Sent:* Friday, August 10, 2018 2:15 PM > *To:* Deucher, Alexander; Zhu, Rex; Liu, Leo > *Cc:* amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; S, Shirish > *Subject:* [PATCH] drm/amdpu/vce_v3: skip suspend and resume if > powergated > This patch adds a mechanism by which the VCE 3.0 block > shall check if it was enabled or in use before suspending, > if it was powergated while entering suspend then there > is no need to repeat it in vce_3_0_suspend(). > Similarly, if the block was powergated while entering suspend > itself then there is no need to resume it. > > By this we not only make the suspend and resume sequence > more efficient, but also optimize the overall amdgpu suspend > and resume time by reducing the ring intialize and tests > for unused IP blocks. > > Signed-off-by: Shirish S > --- >  drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  2 ++ >  drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 21 +++++++++++++++++++++ >  2 files changed, 23 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > index 07924d4..aa85063 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -1035,6 +1035,8 @@ struct amdgpu_device { > >          /* vce */ >          struct amdgpu_vce               vce; > +       bool                            is_vce_pg; > +       bool is_vce_disabled; > >          /* vcn */ >          struct amdgpu_vcn               vcn; > diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c > b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c > index cc6ce6c..822cfd6 100644 > --- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c > @@ -326,6 +326,7 @@ static int vce_v3_0_start(struct amdgpu_device *adev) >          WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT); >          mutex_unlock(&adev->grbm_idx_mutex); > > +       adev->is_vce_pg = false; >          return 0; >  } > > @@ -355,6 +356,7 @@ static int vce_v3_0_stop(struct amdgpu_device *adev) >          WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT); >          mutex_unlock(&adev->grbm_idx_mutex); > > +       adev->is_vce_pg = true; >          return 0; >  } > > @@ -506,6 +508,17 @@ static int vce_v3_0_suspend(void *handle) >          int r; >          struct amdgpu_device *adev = (struct amdgpu_device *)handle; > > +       /* Proceed with suspend sequence only if VCE is started > +        * Mark the block as being disabled if its stopped. > +        */ > +       if (adev->is_vce_pg) { > +               DRM_DEBUG("VCE is already powergated, not suspending\n"); > +               adev->is_vce_disabled = true; > +               return 0; > +       } > + > +       adev->is_vce_disabled = false; > + >          r = vce_v3_0_hw_fini(adev); >          if (r) >                  return r; > @@ -518,6 +531,14 @@ static int vce_v3_0_resume(void *handle) >          int r; >          struct amdgpu_device *adev = (struct amdgpu_device *)handle; > > +       /* Proceed with resume sequence if VCE was enabled > +        * while suspending. > +        */ > +       if (adev->is_vce_disabled) { > +               DRM_DEBUG("VCE is powergated, not resuming the block\n"); > +               return 0; > +       } > + >          r = amdgpu_vce_resume(adev); >          if (r) >                  return r; > -- > 2.7.4 > -- Regards, Shirish S --------------5311365E7BC8463906096B8A Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit



On 8/10/2018 12:02 PM, Zhu, Rex wrote:

I am Ok with the check when call vce_v3_0_hw_fini.


But we may still need to call amdpug_vce_suspend/resume.

Done in V2. Have moved the check such that both are executed.
Regards,
Shirish S


and not sure whether need to do ring test when resume back.


Best Regards

Rex


From: S, Shirish
Sent: Friday, August 10, 2018 2:15 PM
To: Deucher, Alexander; Zhu, Rex; Liu, Leo
Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; S, Shirish
Subject: [PATCH] drm/amdpu/vce_v3: skip suspend and resume if powergated
 
This patch adds a mechanism by which the VCE 3.0 block
shall check if it was enabled or in use before suspending,
if it was powergated while entering suspend then there
is no need to repeat it in vce_3_0_suspend().
Similarly, if the block was powergated while entering suspend
itself then there is no need to resume it.

By this we not only make the suspend and resume sequence
more efficient, but also optimize the overall amdgpu suspend
and resume time by reducing the ring intialize and tests
for unused IP blocks.

Signed-off-by: Shirish S <shirish.s-5C7GfCeVMHo@public.gmane.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  2 ++
 drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 07924d4..aa85063 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1035,6 +1035,8 @@ struct amdgpu_device {
 
         /* vce */
         struct amdgpu_vce               vce;
+       bool                            is_vce_pg;
+       bool                            is_vce_disabled;
 
         /* vcn */
         struct amdgpu_vcn               vcn;
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
index cc6ce6c..822cfd6 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
@@ -326,6 +326,7 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
         WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
         mutex_unlock(&adev->grbm_idx_mutex);
 
+       adev->is_vce_pg = false;
         return 0;
 }
 
@@ -355,6 +356,7 @@ static int vce_v3_0_stop(struct amdgpu_device *adev)
         WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
         mutex_unlock(&adev->grbm_idx_mutex);
 
+       adev->is_vce_pg = true;
         return 0;
 }
 
@@ -506,6 +508,17 @@ static int vce_v3_0_suspend(void *handle)
         int r;
         struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+       /* Proceed with suspend sequence only if VCE is started
+        * Mark the block as being disabled if its stopped.
+        */
+       if (adev->is_vce_pg) {
+               DRM_DEBUG("VCE is already powergated, not suspending\n");
+               adev->is_vce_disabled = true;
+               return 0;
+       }
+
+       adev->is_vce_disabled = false;
+
         r = vce_v3_0_hw_fini(adev);
         if (r)
                 return r;
@@ -518,6 +531,14 @@ static int vce_v3_0_resume(void *handle)
         int r;
         struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+       /* Proceed with resume sequence if VCE was enabled
+        * while suspending.
+        */
+       if (adev->is_vce_disabled) {
+               DRM_DEBUG("VCE is powergated, not resuming the block\n");
+               return 0;
+       }
+
         r = amdgpu_vce_resume(adev);
         if (r)
                 return r;
--
2.7.4


-- 
Regards,
Shirish S
--------------5311365E7BC8463906096B8A-- --===============0990311926== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KYW1kLWdmeCBt YWlsaW5nIGxpc3QKYW1kLWdmeEBsaXN0cy5mcmVlZGVza3RvcC5vcmcKaHR0cHM6Ly9saXN0cy5m cmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9hbWQtZ2Z4Cg== --===============0990311926==--