[PATCH 2/4] drm/amdgpu: added api for stopping psp ring

Huang Rui ray.huang at amd.com
Mon Sep 11 08:51:49 UTC 2017


On Mon, Sep 11, 2017 at 09:22:03AM +0800, Evan Quan wrote:
> Change-Id: I53bcacd531d8df801a49acd0409c3f27b49fb1be
> Signed-off-by: Evan Quan <evan.quan at amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c |  2 ++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  2 ++
>  drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  | 23 +++++++++++++++++++++++
>  drivers/gpu/drm/amd/amdgpu/psp_v10_0.h  |  2 ++
>  drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 23 +++++++++++++++++++++++
>  drivers/gpu/drm/amd/amdgpu/psp_v3_1.h   |  2 ++
>  6 files changed, 54 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 4c429f4..1ea879d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -57,6 +57,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_stop = psp_v3_1_ring_stop;
>  		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;
> @@ -69,6 +70,7 @@ static int psp_sw_init(void *handle)
>  		psp->prep_cmd_buf = psp_v10_0_prep_cmd_buf;
>  		psp->ring_init = psp_v10_0_ring_init;
>  		psp->ring_create = psp_v10_0_ring_create;
> +		psp->ring_stop = psp_v10_0_ring_stop;
>  		psp->ring_destroy = psp_v10_0_ring_destroy;

As introduced ring_stop interface, we can re-use ring_top in ring_destroy
handler. Because ring_destroy is actually equal to ring_stop and ring
buffer free.

Thanks
Rui

>  		psp->cmd_submit = psp_v10_0_cmd_submit;
>  		psp->compare_sram_data = psp_v10_0_compare_sram_data;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> index 538fa9d..e79795b 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_stop)(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,
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c
> index 702d68d..5826a83 100644
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c
> @@ -208,6 +208,29 @@ int psp_v10_0_ring_create(struct psp_context *psp, enum psp_ring_type ring_type)
>  	return ret;
>  }
>  
> +int psp_v10_0_ring_stop(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(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, 0x80000000, false);
> +
> +	return ret;
> +}
> +
>  int psp_v10_0_ring_destroy(struct psp_context *psp, enum psp_ring_type ring_type)
>  {
>  	int ret = 0;
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h
> index e76cde2..3af3ad1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h
> @@ -34,6 +34,8 @@ extern int psp_v10_0_ring_init(struct psp_context *psp,
>  			      enum psp_ring_type ring_type);
>  extern int psp_v10_0_ring_create(struct psp_context *psp,
>  				 enum psp_ring_type ring_type);
> +extern int psp_v10_0_ring_stop(struct psp_context *psp,
> +				  enum psp_ring_type ring_type);
>  extern int psp_v10_0_ring_destroy(struct psp_context *psp,
>  				  enum psp_ring_type ring_type);
>  extern int psp_v10_0_cmd_submit(struct psp_context *psp,
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
> index 23106e3..80c4f97 100644
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
> @@ -319,6 +319,29 @@ int psp_v3_1_ring_create(struct psp_context *psp, enum psp_ring_type ring_type)
>  	return ret;
>  }
>  
> +int psp_v3_1_ring_stop(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(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, 0x80000000, false);
> +
> +	return ret;
> +}
> +
>  int psp_v3_1_ring_destroy(struct psp_context *psp, enum psp_ring_type ring_type)
>  {
>  	int ret = 0;
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.h b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.h
> index 9dcd0b2..5af2231 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_stop(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,
> -- 
> 2.7.4
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list