From: Jinzhou Su <[email protected]>

PSP may be disabled during driver initialization. So psp->cmd
is not allocated, so any psp_*() call would deref NULL. Also skip
if sysfs_init failed and ualink.info was never allocated.

Signed-off-by: Jinzhou Su <[email protected]>
Acked-by: Felix Kuehling <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
index 428296e5cec6a..76aec9eaa59fe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
@@ -33,6 +33,14 @@ int amdgpu_ualink_init(struct amdgpu_device *adev)
 {
        int r;
 
+       /* UALink relies on PSP services. If the PSP IP block is not present
+        * just skip UALink initialization.
+        */
+       if (!amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_PSP)) {
+               adev->ualink.psp_if_ver = 0xffffffff;
+               return 0;
+       }
+
        r = psp_ual_get_interface_version(&adev->psp, &adev->ualink.psp_if_ver);
        if (r) {
                adev->ualink.psp_if_ver = 0xffffffff;
@@ -920,6 +928,9 @@ int amdgpu_ualink_sysfs_init(struct amdgpu_device *adev)
        struct amdgpu_ualink_info *info = NULL;
        int r;
 
+       if (!amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_PSP))
+               return 0;
+
        info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
-- 
2.55.0

Reply via email to