From: Alan Liu <[email protected]>

[Why]
- Need error message when failing to allocating secure_display_ctx.
- Need to check if secure display context in psp is initialized or not
before using it.

[How]
- Add error message when memory allocation fail.
- Add check before accessing psp secure display context.

Acked-by: Aurabindo Pillai <[email protected]>
Signed-off-by: Alan Liu <[email protected]>
Reviewed-by: Wayne Lin <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c     | 3 +++
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 24443547bd02..6b7a0f521f1f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1644,6 +1644,9 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 #endif
 #if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
        adev->dm.secure_display_ctxs = 
amdgpu_dm_crtc_secure_display_create_contexts(adev);
+       if (!adev->dm.secure_display_ctxs) {
+               DRM_ERROR("amdgpu: failed to initialize 
secure_display_ctxs.\n");
+       }
 #endif
        if (dc_is_dmub_outbox_supported(adev->dm.dc)) {
                init_completion(&adev->dm.dmub_aux_transfer_done);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
index 8bf33fa4abd9..ad73e5855580 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c
@@ -117,6 +117,12 @@ static void amdgpu_dm_crtc_notify_ta_to_read(struct 
work_struct *work)
        }
 
        psp = &drm_to_adev(crtc->dev)->psp;
+
+       if (!psp->securedisplay_context.context.initialized) {
+               DRM_DEBUG_DRIVER("Secure Display fails to notify PSP TA\n");
+               return;
+       }
+
        stream = to_amdgpu_crtc(crtc)->dm_irq_params.stream;
        phy_inst = stream->link->link_enc_hw_inst;
 
-- 
2.39.0

Reply via email to