drm/amdgpu: added api for stopping psp ring (v2)
authorEvan Quan <evan.quan@amd.com>
Fri, 8 Sep 2017 05:04:52 +0000 (13:04 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 12 Sep 2017 18:30:11 +0000 (14:30 -0400)
- v2: reuse the ring stop api in ring destory

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
drivers/gpu/drm/amd/amdgpu/psp_v10_0.c
drivers/gpu/drm/amd/amdgpu/psp_v10_0.h
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
drivers/gpu/drm/amd/amdgpu/psp_v3_1.h

index 8c2204c..abd2081 100644 (file)
@@ -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;
                psp->cmd_submit = psp_v10_0_cmd_submit;
                psp->compare_sram_data = psp_v10_0_compare_sram_data;
index 538fa9d..e79795b 100644 (file)
@@ -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,
index b77feef..6ec5c9f 100644 (file)
@@ -207,7 +207,7 @@ int psp_v10_0_ring_create(struct psp_context *psp, enum psp_ring_type ring_type)
        return ret;
 }
 
-int psp_v10_0_ring_destroy(struct psp_context *psp, enum psp_ring_type ring_type)
+int psp_v10_0_ring_stop(struct psp_context *psp, enum psp_ring_type ring_type)
 {
        int ret = 0;
        struct psp_ring *ring;
@@ -227,6 +227,19 @@ int psp_v10_0_ring_destroy(struct psp_context *psp, enum psp_ring_type ring_type
        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;
+       struct psp_ring *ring = &psp->km_ring;
+       struct amdgpu_device *adev = psp->adev;
+
+       ret = psp_v10_0_ring_stop(psp, ring_type);
+       if (ret)
+               DRM_ERROR("Fail to stop psp ring\n");
+
        amdgpu_bo_free_kernel(&adev->firmware.rbuf,
                              &ring->ring_mem_mc_addr,
                              (void **)&ring->ring_mem);
index e76cde2..3af3ad1 100644 (file)
@@ -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,
index 2a535a4..bcbe30d 100644 (file)
@@ -319,7 +319,7 @@ 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 psp_v3_1_ring_stop(struct psp_context *psp, enum psp_ring_type ring_type)
 {
        int ret = 0;
        struct psp_ring *ring;
@@ -339,6 +339,19 @@ int psp_v3_1_ring_destroy(struct psp_context *psp, enum psp_ring_type ring_type)
        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;
+       struct psp_ring *ring = &psp->km_ring;
+       struct amdgpu_device *adev = psp->adev;
+
+       ret = psp_v3_1_ring_stop(psp, ring_type);
+       if (ret)
+               DRM_ERROR("Fail to stop psp ring\n");
+
        amdgpu_bo_free_kernel(&adev->firmware.rbuf,
                              &ring->ring_mem_mc_addr,
                              (void **)&ring->ring_mem);
index 9dcd0b2..5af2231 100644 (file)
@@ -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,