aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorHuang Rui <ray.huang@amd.com>2017-03-21 22:16:05 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-04-28 16:37:57 -0400
commit2b0c3aee2172451e9f982b25f3fdf59a1b687dc3 (patch)
tree7eff824ff1de66f8b4a95bf9d0827082ca6228de /drivers/gpu/drm/amd
parent53a5cf57d819f12b2de365aa3137c9175a032608 (diff)
drm/amdgpu: use private memory to store psp firmware data
Rework in order to properly support suspend. Signed-off-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c28
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/psp_v3_1.c48
3 files changed, 16 insertions, 61 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index f70ab550934c..ed9c04b7a286 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -209,9 +209,9 @@ static void psp_prep_asd_cmd_buf(struct psp_gfx_cmd_resp *cmd,
209static int psp_asd_load(struct psp_context *psp) 209static int psp_asd_load(struct psp_context *psp)
210{ 210{
211 int ret; 211 int ret;
212 struct amdgpu_bo *asd_bo, *asd_shared_bo; 212 struct amdgpu_bo *asd_shared_bo;
213 uint64_t asd_mc_addr, asd_shared_mc_addr; 213 uint64_t asd_shared_mc_addr;
214 void *asd_buf, *asd_shared_buf; 214 void *asd_shared_buf;
215 struct psp_gfx_cmd_resp *cmd; 215 struct psp_gfx_cmd_resp *cmd;
216 216
217 cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL); 217 cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
@@ -224,38 +224,26 @@ static int psp_asd_load(struct psp_context *psp)
224 */ 224 */
225 ret = amdgpu_bo_create_kernel(psp->adev, PSP_ASD_SHARED_MEM_SIZE, PAGE_SIZE, 225 ret = amdgpu_bo_create_kernel(psp->adev, PSP_ASD_SHARED_MEM_SIZE, PAGE_SIZE,
226 AMDGPU_GEM_DOMAIN_VRAM, 226 AMDGPU_GEM_DOMAIN_VRAM,
227 &asd_shared_bo, &asd_shared_mc_addr, &asd_buf); 227 &asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf);
228 if (ret) 228 if (ret)
229 goto failed; 229 goto failed;
230 230
231 /* 231 memset(psp->fw_pri_buf, 0, PSP_1_MEG);
232 * Allocate 256k memory aligned to 4k from Frame Buffer (local 232 memcpy(psp->fw_pri_buf, psp->asd_start_addr, psp->asd_ucode_size);
233 * physical) for ASD firmware
234 */
235 ret = amdgpu_bo_create_kernel(psp->adev, PSP_ASD_BIN_SIZE, PAGE_SIZE,
236 AMDGPU_GEM_DOMAIN_VRAM,
237 &asd_bo, &asd_mc_addr, &asd_buf);
238 if (ret)
239 goto failed_mem;
240 233
241 memcpy(asd_buf, psp->asd_start_addr, psp->asd_ucode_size); 234 psp_prep_asd_cmd_buf(cmd, psp->fw_pri_mc_addr, asd_shared_mc_addr,
242
243 psp_prep_asd_cmd_buf(cmd, asd_mc_addr, asd_shared_mc_addr,
244 psp->asd_ucode_size, PSP_ASD_SHARED_MEM_SIZE); 235 psp->asd_ucode_size, PSP_ASD_SHARED_MEM_SIZE);
245 236
246 ret = psp_cmd_submit_buf(psp, NULL, cmd, 237 ret = psp_cmd_submit_buf(psp, NULL, cmd,
247 psp->fence_buf_mc_addr, 2); 238 psp->fence_buf_mc_addr, 2);
248 if (ret) 239 if (ret)
249 goto failed_mem1; 240 goto failed_mem;
250 241
251 amdgpu_bo_free_kernel(&asd_bo, &asd_mc_addr, &asd_buf);
252 amdgpu_bo_free_kernel(&asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf); 242 amdgpu_bo_free_kernel(&asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf);
253 kfree(cmd); 243 kfree(cmd);
254 244
255 return 0; 245 return 0;
256 246
257failed_mem1:
258 amdgpu_bo_free_kernel(&asd_bo, &asd_mc_addr, &asd_buf);
259failed_mem: 247failed_mem:
260 amdgpu_bo_free_kernel(&asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf); 248 amdgpu_bo_free_kernel(&asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf);
261failed: 249failed:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index b309b6a62c65..125a5dc0c0e1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -30,7 +30,6 @@
30 30
31#define PSP_FENCE_BUFFER_SIZE 0x1000 31#define PSP_FENCE_BUFFER_SIZE 0x1000
32#define PSP_CMD_BUFFER_SIZE 0x1000 32#define PSP_CMD_BUFFER_SIZE 0x1000
33#define PSP_ASD_BIN_SIZE 0x40000
34#define PSP_ASD_SHARED_MEM_SIZE 0x4000 33#define PSP_ASD_SHARED_MEM_SIZE 0x4000
35#define PSP_1_MEG 0x100000 34#define PSP_1_MEG 0x100000
36 35
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
index c3588d1c7cb0..aae6b6540161 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
@@ -166,11 +166,8 @@ int psp_v3_1_bootloader_load_sysdrv(struct psp_context *psp)
166{ 166{
167 int ret; 167 int ret;
168 uint32_t psp_gfxdrv_command_reg = 0; 168 uint32_t psp_gfxdrv_command_reg = 0;
169 struct amdgpu_bo *psp_sysdrv;
170 void *psp_sysdrv_virt = NULL;
171 uint64_t psp_sysdrv_mem;
172 struct amdgpu_device *adev = psp->adev; 169 struct amdgpu_device *adev = psp->adev;
173 uint32_t size, sol_reg; 170 uint32_t sol_reg;
174 171
175 /* Check sOS sign of life register to confirm sys driver and sOS 172 /* Check sOS sign of life register to confirm sys driver and sOS
176 * are already been loaded. 173 * are already been loaded.
@@ -185,27 +182,14 @@ int psp_v3_1_bootloader_load_sysdrv(struct psp_context *psp)
185 if (ret) 182 if (ret)
186 return ret; 183 return ret;
187 184
188 /* 185 memset(psp->fw_pri_buf, 0, PSP_1_MEG);
189 * Create a 1 meg GART memory to store the psp sys driver
190 * binary with a 1 meg aligned address
191 */
192 size = (psp->sys_bin_size + (PSP_BOOTLOADER_1_MEG_ALIGNMENT - 1)) &
193 (~(PSP_BOOTLOADER_1_MEG_ALIGNMENT - 1));
194
195 ret = amdgpu_bo_create_kernel(adev, size, PSP_BOOTLOADER_1_MEG_ALIGNMENT,
196 AMDGPU_GEM_DOMAIN_GTT,
197 &psp_sysdrv,
198 &psp_sysdrv_mem,
199 &psp_sysdrv_virt);
200 if (ret)
201 return ret;
202 186
203 /* Copy PSP System Driver binary to memory */ 187 /* Copy PSP System Driver binary to memory */
204 memcpy(psp_sysdrv_virt, psp->sys_start_addr, psp->sys_bin_size); 188 memcpy(psp->fw_pri_buf, psp->sys_start_addr, psp->sys_bin_size);
205 189
206 /* Provide the sys driver to bootrom */ 190 /* Provide the sys driver to bootrom */
207 WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_36), 191 WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_36),
208 (uint32_t)(psp_sysdrv_mem >> 20)); 192 (uint32_t)(psp->fw_pri_mc_addr >> 20));
209 psp_gfxdrv_command_reg = 1 << 16; 193 psp_gfxdrv_command_reg = 1 << 16;
210 WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_35), 194 WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_35),
211 psp_gfxdrv_command_reg); 195 psp_gfxdrv_command_reg);
@@ -216,8 +200,6 @@ int psp_v3_1_bootloader_load_sysdrv(struct psp_context *psp)
216 ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_35), 200 ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_35),
217 0x80000000, 0x80000000, false); 201 0x80000000, 0x80000000, false);
218 202
219 amdgpu_bo_free_kernel(&psp_sysdrv, &psp_sysdrv_mem, &psp_sysdrv_virt);
220
221 return ret; 203 return ret;
222} 204}
223 205
@@ -225,11 +207,8 @@ int psp_v3_1_bootloader_load_sos(struct psp_context *psp)
225{ 207{
226 int ret; 208 int ret;
227 unsigned int psp_gfxdrv_command_reg = 0; 209 unsigned int psp_gfxdrv_command_reg = 0;
228 struct amdgpu_bo *psp_sos;
229 void *psp_sos_virt = NULL;
230 uint64_t psp_sos_mem;
231 struct amdgpu_device *adev = psp->adev; 210 struct amdgpu_device *adev = psp->adev;
232 uint32_t size, sol_reg; 211 uint32_t sol_reg;
233 212
234 /* Check sOS sign of life register to confirm sys driver and sOS 213 /* Check sOS sign of life register to confirm sys driver and sOS
235 * are already been loaded. 214 * are already been loaded.
@@ -244,23 +223,14 @@ int psp_v3_1_bootloader_load_sos(struct psp_context *psp)
244 if (ret) 223 if (ret)
245 return ret; 224 return ret;
246 225
247 size = (psp->sos_bin_size + (PSP_BOOTLOADER_1_MEG_ALIGNMENT - 1)) & 226 memset(psp->fw_pri_buf, 0, PSP_1_MEG);
248 (~((uint64_t)PSP_BOOTLOADER_1_MEG_ALIGNMENT - 1));
249
250 ret = amdgpu_bo_create_kernel(adev, size, PSP_BOOTLOADER_1_MEG_ALIGNMENT,
251 AMDGPU_GEM_DOMAIN_GTT,
252 &psp_sos,
253 &psp_sos_mem,
254 &psp_sos_virt);
255 if (ret)
256 return ret;
257 227
258 /* Copy Secure OS binary to PSP memory */ 228 /* Copy Secure OS binary to PSP memory */
259 memcpy(psp_sos_virt, psp->sos_start_addr, psp->sos_bin_size); 229 memcpy(psp->fw_pri_buf, psp->sos_start_addr, psp->sos_bin_size);
260 230
261 /* Provide the PSP secure OS to bootrom */ 231 /* Provide the PSP secure OS to bootrom */
262 WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_36), 232 WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_36),
263 (uint32_t)(psp_sos_mem >> 20)); 233 (uint32_t)(psp->fw_pri_mc_addr >> 20));
264 psp_gfxdrv_command_reg = 2 << 16; 234 psp_gfxdrv_command_reg = 2 << 16;
265 WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_35), 235 WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_35),
266 psp_gfxdrv_command_reg); 236 psp_gfxdrv_command_reg);
@@ -273,8 +243,6 @@ int psp_v3_1_bootloader_load_sos(struct psp_context *psp)
273 0, true); 243 0, true);
274#endif 244#endif
275 245
276 amdgpu_bo_free_kernel(&psp_sos, &psp_sos_mem, &psp_sos_virt);
277
278 return ret; 246 return ret;
279} 247}
280 248