disp: msm: sde: avoid sde debugfs register access based on HW ownership

Add VM ownership checks before accessing the HW through the debugfs
path in sde crtc/encoder/connector modules to avoid illegal access.

Change-Id: I4ff8f29353835d263beb2091bdeec40125addbf8
Signed-off-by: Veera Sundaram Sankaran <veeras@codeaurora.org>
This commit is contained in:
Veera Sundaram Sankaran
2020-12-08 15:34:17 -08:00
committed by Dhaval Patel
parent a40c87b676
commit d26e510b77
3 changed files with 40 additions and 1 deletions

View File

@@ -41,6 +41,7 @@
#include "sde_core_perf.h"
#include "sde_trace.h"
#include "msm_drv.h"
#include "sde_vm.h"
#define SDE_PSTATES_MAX (SDE_STAGE_MAX * 4)
#define SDE_MULTIRECT_PLANE_MAX (SDE_STAGE_MAX * 2)
@@ -6272,6 +6273,7 @@ static ssize_t _sde_crtc_misr_read(struct file *file,
struct sde_crtc *sde_crtc;
struct sde_kms *sde_kms;
struct sde_crtc_mixer *m;
struct sde_vm_ops *vm_ops;
int i = 0, rc;
ssize_t len = 0;
char buf[MISR_BUFF_SIZE + 1] = {'\0'};
@@ -6292,8 +6294,17 @@ static ssize_t _sde_crtc_misr_read(struct file *file,
if (rc < 0)
return rc;
vm_ops = sde_vm_get_ops(sde_kms);
sde_vm_lock(sde_kms);
if (vm_ops && vm_ops->vm_owns_hw && !vm_ops->vm_owns_hw(sde_kms)) {
SDE_DEBUG("op not supported due to HW unavailability\n");
rc = -EOPNOTSUPP;
goto end;
}
if (sde_kms_is_secure_session_inprogress(sde_kms)) {
SDE_DEBUG("crtc:%d misr read not allowed\n", DRMID(crtc));
rc = -EOPNOTSUPP;
goto end;
}
@@ -6343,6 +6354,7 @@ buff_check:
*ppos += len; /* increase offset */
end:
sde_vm_unlock(sde_kms);
pm_runtime_put_sync(crtc->dev->dev);
return len;
}