All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leo Liu <leo.liu-5C7GfCeVMHo@public.gmane.org>
To: "Deucher,
	Alexander" <Alexander.Deucher-5C7GfCeVMHo@public.gmane.org>,
	"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH 3/3] drm/amdgpu: add saved_bo to save vce 4.0 context when suspend
Date: Wed, 31 May 2017 16:06:22 -0400	[thread overview]
Message-ID: <db96eb28-fa40-1029-c2a4-12eeb200ac63@amd.com> (raw)
In-Reply-To: <BN6PR12MB1652D083E4A3123CFE3B3628F7F10-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 4216 bytes --]



On 05/31/2017 03:54 PM, Deucher, Alexander wrote:
> > -----Original Message-----
> > From: amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] On Behalf
> > Of Leo Liu
> > Sent: Wednesday, May 31, 2017 3:28 PM
> > To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> > Cc: Liu, Leo
> > Subject: [PATCH 3/3] drm/amdgpu: add saved_bo to save vce 4.0 context
> > when suspend
> >
> > We are using PSP to resume firmware after suspend, and it is
> > resumed at where it got suspended, so we'd better save the
> > the context.
> >
> > Signed-off-by: Leo Liu <leo.liu-5C7GfCeVMHo@public.gmane.org>
>
> Patches 1, 2 are:
> Reviewed-by: Alex Deucher <alexander.deucher-5C7GfCeVMHo@public.gmane.org>
> A few comments below on patch 3.
>
>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h |  1 +
> >  drivers/gpu/drm/amd/amdgpu/vce_v4_0.c   | 39
> > ++++++++++++++++++++++++++++-----
> >  2 files changed, 35 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
> > index c93f74a..5ce54cd 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
> > @@ -34,6 +34,7 @@ struct amdgpu_vce {
> >        struct amdgpu_bo        *vcpu_bo;
> >        uint64_t                gpu_addr;
> >        void                    *cpu_addr;
> > +     void                    *saved_bo;
> >        unsigned                fw_version;
> >        unsigned                fb_version;
> >        atomic_t handles[AMDGPU_MAX_VCE_HANDLES];
> > diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> > b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> > index 0b7fcc1..2230a99 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> > @@ -522,8 +522,22 @@ static int vce_v4_0_hw_fini(void *handle)
> >
> >  static int vce_v4_0_suspend(void *handle)
> >  {
> > -     int r;
> >        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> > +     int r;
> > +
> > +     if (adev->vce.vcpu_bo == NULL)
> > +             return 0;
> > +
> > +     if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
> > +             unsigned size = amdgpu_bo_size(adev->vce.vcpu_bo);
> > +             void *ptr = adev->vce.cpu_addr;
> > +
> > +             adev->vce.saved_bo = kmalloc(size, GFP_KERNEL);
>
> Might want to avoid malloc/free in the suspend/resume paths.  Just 
> malloc/free the memory at sw_init/fini time.

Just waste a bit memory if it never goes to suspend, but sure, I will 
fix it in v2.

Thanks,
Leo

>
> > +             if (!adev->vce.saved_bo)
> > +                     return -ENOMEM;
> > +
> > +             memcpy_fromio(adev->vce.saved_bo, ptr, size);
> > +     }
> >
> >        r = vce_v4_0_hw_fini(adev);
> >        if (r)
> > @@ -534,12 +548,27 @@ static int vce_v4_0_suspend(void *handle)
> >
> >  static int vce_v4_0_resume(void *handle)
> >  {
> > -     int r;
> >        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> > +     int r;
> >
> > -     r = amdgpu_vce_resume(adev);
> > -     if (r)
> > -             return r;
> > +     if (adev->vce.vcpu_bo == NULL)
> > +             return -EINVAL;
> > +
> > +     if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
> > +             unsigned size = amdgpu_bo_size(adev->vce.vcpu_bo);
> > +             void *ptr = adev->vce.cpu_addr;
> > +
> > +             if (adev->vce.saved_bo != NULL) {
> > +                     memcpy_toio(ptr, adev->vce.saved_bo, size);
> > +                     kfree(adev->vce.saved_bo);
> > +                     adev->vce.saved_bo = NULL;
> > +             } else
>
> Kernel coding style; should be } else { ... } to match the chunk above.
>
> > +                     memset_io(ptr, 0, size);
> > +     } else {
> > +             r = amdgpu_vce_resume(adev);
> > +             if (r)
> > +                     return r;
> > +     }
> >
> >        return vce_v4_0_hw_init(adev);
> >  }
> > --
> > 2.7.4
> >
> > _______________________________________________
> > amd-gfx mailing list
> > amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[-- Attachment #1.2: Type: text/html, Size: 8783 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

  parent reply	other threads:[~2017-05-31 20:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-31 19:28 [PATCH 1/3] drm/amdgpu: add vcpu_bo cpu address Leo Liu
     [not found] ` <20170531192826.17571-1-leo.liu-5C7GfCeVMHo@public.gmane.org>
2017-05-31 19:28   ` [PATCH 2/3] drm/amdgpu: use existing function amdgpu_bo_create_kernel Leo Liu
     [not found]     ` <20170531192826.17571-2-leo.liu-5C7GfCeVMHo@public.gmane.org>
2017-06-01 10:55       ` Christian König
     [not found]         ` <852ceaa1-a899-40ab-a6a2-fb33001885b0-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-06-01 13:11           ` Leo Liu
2017-05-31 19:28   ` [PATCH 3/3] drm/amdgpu: add saved_bo to save vce 4.0 context when suspend Leo Liu
     [not found]     ` <20170531192826.17571-3-leo.liu-5C7GfCeVMHo@public.gmane.org>
2017-05-31 19:54       ` Deucher, Alexander
     [not found]         ` <BN6PR12MB1652D083E4A3123CFE3B3628F7F10-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-05-31 20:06           ` Leo Liu [this message]
2017-05-31 21:00   ` Leo Liu
     [not found]     ` <20170531210040.20919-1-leo.liu-5C7GfCeVMHo@public.gmane.org>
2017-05-31 21:18       ` Deucher, Alexander

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=db96eb28-fa40-1029-c2a4-12eeb200ac63@amd.com \
    --to=leo.liu-5c7gfcevmho@public.gmane.org \
    --cc=Alexander.Deucher-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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 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.