aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHawking Zhang <Hawking.Zhang@amd.com>2018-09-28 09:28:10 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-11-06 14:02:43 -0500
commit3e2e2ab55499f77cbd57ee91e250c085d252a979 (patch)
tree0cc22414c154be7517325409264609f286150563
parentca6e1e59a24bf4aed4d017163f8184eb4e384a9b (diff)
drm/amdgpu/psp: initialize xgmi session (v2)
Setup and tear down xgmi as part of psp. v2: - make psp_xgmi_terminate static - squash in: drm/amdgpu: only issue xgmi cmd when it is enabled drm/amdgpu/psp: terminate xgmi ta in suspend and hw_fini phase Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c69
2 files changed, 71 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 0bf13d69efbc..590588a82471 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1683,7 +1683,8 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
1683 if (r) 1683 if (r)
1684 return r; 1684 return r;
1685 1685
1686 amdgpu_xgmi_add_device(adev); 1686 if (adev->gmc.xgmi.num_physical_nodes > 1)
1687 amdgpu_xgmi_add_device(adev);
1687 amdgpu_amdkfd_device_init(adev); 1688 amdgpu_amdkfd_device_init(adev);
1688 1689
1689 if (amdgpu_sriov_vf(adev)) 1690 if (amdgpu_sriov_vf(adev))
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 07f9fcb59c0a..e05dc66b1090 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -405,6 +405,53 @@ int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id)
405 return ret; 405 return ret;
406} 406}
407 407
408static int psp_xgmi_terminate(struct psp_context *psp)
409{
410 int ret;
411
412 if (!psp->xgmi_context.initialized)
413 return 0;
414
415 ret = psp_xgmi_unload(psp);
416 if (ret)
417 return ret;
418
419 psp->xgmi_context.initialized = 0;
420
421 /* free xgmi shared memory */
422 amdgpu_bo_free_kernel(&psp->xgmi_context.xgmi_shared_bo,
423 &psp->xgmi_context.xgmi_shared_mc_addr,
424 &psp->xgmi_context.xgmi_shared_buf);
425
426 return 0;
427}
428
429static int psp_xgmi_initialize(struct psp_context *psp)
430{
431 struct ta_xgmi_shared_memory *xgmi_cmd;
432 int ret;
433
434 if (!psp->xgmi_context.initialized) {
435 ret = psp_xgmi_init_shared_buf(psp);
436 if (ret)
437 return ret;
438 }
439
440 /* Load XGMI TA */
441 ret = psp_xgmi_load(psp);
442 if (ret)
443 return ret;
444
445 /* Initialize XGMI session */
446 xgmi_cmd = (struct ta_xgmi_shared_memory *)(psp->xgmi_context.xgmi_shared_buf);
447 memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
448 xgmi_cmd->cmd_id = TA_COMMAND_XGMI__INITIALIZE;
449
450 ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
451
452 return ret;
453}
454
408static int psp_hw_start(struct psp_context *psp) 455static int psp_hw_start(struct psp_context *psp)
409{ 456{
410 struct amdgpu_device *adev = psp->adev; 457 struct amdgpu_device *adev = psp->adev;
@@ -432,6 +479,15 @@ static int psp_hw_start(struct psp_context *psp)
432 if (ret) 479 if (ret)
433 return ret; 480 return ret;
434 481
482 if (adev->gmc.xgmi.num_physical_nodes > 1) {
483 ret = psp_xgmi_initialize(psp);
484 /* Warning the XGMI seesion initialize failure
485 * Instead of stop driver initialization
486 */
487 if (ret)
488 dev_err(psp->adev->dev,
489 "XGMI: Failed to initialize XGMI session\n");
490 }
435 return 0; 491 return 0;
436} 492}
437 493
@@ -592,6 +648,10 @@ static int psp_hw_fini(void *handle)
592 if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) 648 if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
593 return 0; 649 return 0;
594 650
651 if (adev->gmc.xgmi.num_physical_nodes > 1 &&
652 psp->xgmi_context.initialized == 1)
653 psp_xgmi_terminate(psp);
654
595 psp_ring_destroy(psp, PSP_RING_TYPE__KM); 655 psp_ring_destroy(psp, PSP_RING_TYPE__KM);
596 656
597 amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf); 657 amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
@@ -619,6 +679,15 @@ static int psp_suspend(void *handle)
619 if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) 679 if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
620 return 0; 680 return 0;
621 681
682 if (adev->gmc.xgmi.num_physical_nodes > 1 &&
683 psp->xgmi_context.initialized == 1) {
684 ret = psp_xgmi_terminate(psp);
685 if (ret) {
686 DRM_ERROR("Failed to terminate xgmi ta\n");
687 return ret;
688 }
689 }
690
622 ret = psp_ring_stop(psp, PSP_RING_TYPE__KM); 691 ret = psp_ring_stop(psp, PSP_RING_TYPE__KM);
623 if (ret) { 692 if (ret) {
624 DRM_ERROR("PSP ring stop failed\n"); 693 DRM_ERROR("PSP ring stop failed\n");