All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huang Rui <ray.huang-5C7GfCeVMHo@public.gmane.org>
To: "Yu, Xiangliang" <Xiangliang.Yu-5C7GfCeVMHo@public.gmane.org>
Cc: "Liu, Monk" <Monk.Liu-5C7GfCeVMHo@public.gmane.org>,
	"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>,
	"Huang, Trigger" <Trigger.Huang-5C7GfCeVMHo@public.gmane.org>
Subject: Re: [PATCH] drm/amdgpu: Destroy psp ring in hw_fini
Date: Tue, 18 Apr 2017 11:21:17 +0800	[thread overview]
Message-ID: <20170418032116.GA7811@hr-amur2> (raw)
In-Reply-To: <BY2PR1201MB0935245FEA9C66C8B3227A1EEB190-O28G1zQ8oGkaqtME6NEo1mrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>

On Tue, Apr 18, 2017 at 10:39:33AM +0800, Yu, Xiangliang wrote:
> Better to add SRIOV case in your commit message, I think bare metal doesn't
> care re-initialization.

Needn't add SRIOV case, because this is the common behavior for psp.

Thanks,
Rui

> Reviewed-by: Xiangliang Yu <Xiangliang.Yu@amd.com> with fixing.
> 
> 
> Thanks!
> Xiangliang Yu
> 
> 
> > -----Original Message-----
> > From: Trigger Huang [mailto:trigger.huang@amd.com]
> > Sent: Tuesday, April 18, 2017 10:26 AM
> > To: amd-gfx@lists.freedesktop.org
> > Cc: Liu, Monk <Monk.Liu@amd.com>; Yu, Xiangliang
> > <Xiangliang.Yu@amd.com>; Huang, Ray <Ray.Huang@amd.com>; Huang,
> > Trigger <Trigger.Huang@amd.com>
> > Subject: [PATCH] drm/amdgpu: Destroy psp ring in hw_fini
> >
> > Fix issue that PSP initialization will fail if reload amdgpu module.
> > That's because the PSP ring must be destroyed to be ready for the next time
> > PSP initialization.
> >
> > Signed-off-by: Trigger Huang <trigger.huang@amd.com>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c |  3 +++
> > drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  3 +++
> >  drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 27
> > +++++++++++++++++++++++++++
> >  drivers/gpu/drm/amd/amdgpu/psp_v3_1.h   |  2 ++
> >  4 files changed, 35 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> > index 19180aa..51b8a15 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> > @@ -56,6 +56,7 @@ static int psp_sw_init(void *handle)
> >                psp->prep_cmd_buf = psp_v3_1_prep_cmd_buf;
> >                psp->ring_init = psp_v3_1_ring_init;
> >                psp->ring_create = psp_v3_1_ring_create;
> > +             psp->ring_destroy = psp_v3_1_ring_destroy;
> >                psp->cmd_submit = psp_v3_1_cmd_submit;
> >                psp->compare_sram_data = psp_v3_1_compare_sram_data;
> >                psp->smu_reload_quirk = psp_v3_1_smu_reload_quirk; @@
> > -425,6 +426,8 @@ static int psp_hw_fini(void *handle)
> >                amdgpu_bo_free_kernel(&psp->fence_buf_bo,
> >                                      &psp->fence_buf_mc_addr, &psp-
> > >fence_buf);
> >
> > +     psp_ring_destroy(psp, PSP_RING_TYPE__KM);
> > +
> >        return 0;
> >  }
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> > index 28faba5..0301e4e 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> > @@ -66,6 +66,8 @@ struct psp_context
> >                            struct psp_gfx_cmd_resp *cmd);
> >        int (*ring_init)(struct psp_context *psp, enum psp_ring_type
> > ring_type);
> >        int (*ring_create)(struct psp_context *psp, enum psp_ring_type
> > ring_type);
> > +     int (*ring_destroy)(struct psp_context *psp,
> > +                         enum psp_ring_type ring_type);
> >        int (*cmd_submit)(struct psp_context *psp, struct
> > amdgpu_firmware_info *ucode,
> >                          uint64_t cmd_buf_mc_addr, uint64_t
> > fence_mc_addr, int index);
> >        bool (*compare_sram_data)(struct psp_context *psp, @@ -116,6
> > +118,7 @@ struct amdgpu_psp_funcs {  #define psp_prep_cmd_buf(ucode,
> > type) (psp)->prep_cmd_buf((ucode), (type))  #define psp_ring_init(psp,
> > type) (psp)->ring_init((psp), (type))  #define psp_ring_create(psp, type)
> > (psp)->ring_create((psp), (type))
> > +#define psp_ring_destroy(psp, type) ((psp)->ring_destroy((psp),
> > +(type)))
> >  #define psp_cmd_submit(psp, ucode, cmd_mc, fence_mc, index) \
> >                (psp)->cmd_submit((psp), (ucode), (cmd_mc), (fence_mc),
> > (index))  #define psp_compare_sram_data(psp, ucode, type) \ diff --git
> > a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
> > b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
> > index d351583..e834b55 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
> > @@ -321,6 +321,33 @@ int psp_v3_1_ring_create(struct psp_context *psp,
> > enum psp_ring_type ring_type)
> >        return ret;
> >  }
> >
> > +int psp_v3_1_ring_destroy(struct psp_context *psp, enum psp_ring_type
> > +ring_type) {
> > +     int ret = 0;
> > +     struct psp_ring *ring;
> > +     unsigned int psp_ring_reg = 0;
> > +     struct amdgpu_device *adev = psp->adev;
> > +
> > +     ring = &psp->km_ring;
> > +
> > +     /* Write the ring destroy command to C2PMSG_64 */
> > +     psp_ring_reg = 3 << 16;
> > +     WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64),
> > psp_ring_reg);
> > +
> > +     /* there might be handshake issue with hardware which needs delay
> > */
> > +     mdelay(20);
> > +
> > +     /* Wait for response flag (bit 31) in C2PMSG_64 */
> > +     ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0,
> > mmMP0_SMN_C2PMSG_64),
> > +                        0x80000000, 0x8000FFFF, false);
> > +
> > +     if (ring->ring_mem)
> > +             amdgpu_bo_free_kernel(&adev->firmware.rbuf,
> > +                                   &ring->ring_mem_mc_addr,
> > +                                   (void **)&ring->ring_mem);
> > +     return ret;
> > +}
> > +
> >  int psp_v3_1_cmd_submit(struct psp_context *psp,
> >                        struct amdgpu_firmware_info *ucode,
> >                        uint64_t cmd_buf_mc_addr, uint64_t fence_mc_addr,
> > diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.h
> > b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.h
> > index 5230d278..9dcd0b2 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.h
> > @@ -41,6 +41,8 @@ extern int psp_v3_1_ring_init(struct psp_context *psp,
> >                              enum psp_ring_type ring_type);  extern int
> > psp_v3_1_ring_create(struct psp_context *psp,
> >                                enum psp_ring_type ring_type);
> > +extern int psp_v3_1_ring_destroy(struct psp_context *psp,
> > +                             enum psp_ring_type ring_type);
> >  extern int psp_v3_1_cmd_submit(struct psp_context *psp,
> >                               struct amdgpu_firmware_info *ucode,
> >                               uint64_t cmd_buf_mc_addr, uint64_t
> > fence_mc_addr,
> > --
> > 2.7.4
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-04-18  3:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-18  2:25 [PATCH] drm/amdgpu: Destroy psp ring in hw_fini Trigger Huang
     [not found] ` <1492482337-24930-1-git-send-email-trigger.huang-5C7GfCeVMHo@public.gmane.org>
2017-04-18  2:39   ` Yu, Xiangliang
     [not found]     ` <BY2PR1201MB0935245FEA9C66C8B3227A1EEB190-O28G1zQ8oGkaqtME6NEo1mrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-04-18  3:21       ` Huang Rui [this message]
2017-04-18  3:17   ` Huang Rui

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=20170418032116.GA7811@hr-amur2 \
    --to=ray.huang-5c7gfcevmho@public.gmane.org \
    --cc=Monk.Liu-5C7GfCeVMHo@public.gmane.org \
    --cc=Trigger.Huang-5C7GfCeVMHo@public.gmane.org \
    --cc=Xiangliang.Yu-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.