diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_device.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 680df0504f86..372574abc1c4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -1525,6 +1525,51 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) | |||
1525 | return 0; | 1525 | return 0; |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | static int amdgpu_device_ip_hw_init_phase1(struct amdgpu_device *adev) | ||
1529 | { | ||
1530 | int i, r; | ||
1531 | |||
1532 | for (i = 0; i < adev->num_ip_blocks; i++) { | ||
1533 | if (!adev->ip_blocks[i].status.sw) | ||
1534 | continue; | ||
1535 | if (adev->ip_blocks[i].status.hw) | ||
1536 | continue; | ||
1537 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_COMMON || | ||
1538 | adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_IH) { | ||
1539 | r = adev->ip_blocks[i].version->funcs->hw_init(adev); | ||
1540 | if (r) { | ||
1541 | DRM_ERROR("hw_init of IP block <%s> failed %d\n", | ||
1542 | adev->ip_blocks[i].version->funcs->name, r); | ||
1543 | return r; | ||
1544 | } | ||
1545 | adev->ip_blocks[i].status.hw = true; | ||
1546 | } | ||
1547 | } | ||
1548 | |||
1549 | return 0; | ||
1550 | } | ||
1551 | |||
1552 | static int amdgpu_device_ip_hw_init_phase2(struct amdgpu_device *adev) | ||
1553 | { | ||
1554 | int i, r; | ||
1555 | |||
1556 | for (i = 0; i < adev->num_ip_blocks; i++) { | ||
1557 | if (!adev->ip_blocks[i].status.sw) | ||
1558 | continue; | ||
1559 | if (adev->ip_blocks[i].status.hw) | ||
1560 | continue; | ||
1561 | r = adev->ip_blocks[i].version->funcs->hw_init(adev); | ||
1562 | if (r) { | ||
1563 | DRM_ERROR("hw_init of IP block <%s> failed %d\n", | ||
1564 | adev->ip_blocks[i].version->funcs->name, r); | ||
1565 | return r; | ||
1566 | } | ||
1567 | adev->ip_blocks[i].status.hw = true; | ||
1568 | } | ||
1569 | |||
1570 | return 0; | ||
1571 | } | ||
1572 | |||
1528 | /** | 1573 | /** |
1529 | * amdgpu_device_ip_init - run init for hardware IPs | 1574 | * amdgpu_device_ip_init - run init for hardware IPs |
1530 | * | 1575 | * |
@@ -1584,19 +1629,14 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) | |||
1584 | r = amdgpu_ucode_create_bo(adev); /* create ucode bo when sw_init complete*/ | 1629 | r = amdgpu_ucode_create_bo(adev); /* create ucode bo when sw_init complete*/ |
1585 | if (r) | 1630 | if (r) |
1586 | return r; | 1631 | return r; |
1587 | for (i = 0; i < adev->num_ip_blocks; i++) { | 1632 | |
1588 | if (!adev->ip_blocks[i].status.sw) | 1633 | r = amdgpu_device_ip_hw_init_phase1(adev); |
1589 | continue; | 1634 | if (r) |
1590 | if (adev->ip_blocks[i].status.hw) | 1635 | return r; |
1591 | continue; | 1636 | |
1592 | r = adev->ip_blocks[i].version->funcs->hw_init((void *)adev); | 1637 | r = amdgpu_device_ip_hw_init_phase2(adev); |
1593 | if (r) { | 1638 | if (r) |
1594 | DRM_ERROR("hw_init of IP block <%s> failed %d\n", | 1639 | return r; |
1595 | adev->ip_blocks[i].version->funcs->name, r); | ||
1596 | return r; | ||
1597 | } | ||
1598 | adev->ip_blocks[i].status.hw = true; | ||
1599 | } | ||
1600 | 1640 | ||
1601 | amdgpu_xgmi_add_device(adev); | 1641 | amdgpu_xgmi_add_device(adev); |
1602 | amdgpu_amdkfd_device_init(adev); | 1642 | amdgpu_amdkfd_device_init(adev); |