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_hw_top.h"
#include "sde_hw_qdss.h"
#include "sde_encoder_dce.h"
#include "sde_vm.h"
#define SDE_DEBUG_ENC(e, fmt, ...) SDE_DEBUG("enc%d " fmt,\
(e) ? (e)->base.base.id : -1, ##__VA_ARGS__)
@@ -4608,6 +4609,7 @@ static ssize_t _sde_encoder_misr_read(struct file *file,
struct sde_encoder_virt *sde_enc;
struct sde_kms *sde_kms = NULL;
struct drm_encoder *drm_enc;
struct sde_vm_ops *vm_ops;
int i = 0, len = 0;
char buf[MISR_BUFF_SIZE + 1] = {'\0'};
int rc;
@@ -4633,6 +4635,14 @@ static ssize_t _sde_encoder_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 unavailablity\n");
rc = -EOPNOTSUPP;
goto end;
}
if (!sde_enc->misr_enable) {
len += scnprintf(buf + len, MISR_BUFF_SIZE - len,
"disabled\n");
@@ -4680,6 +4690,7 @@ buff_check:
*ppos += len; /* increase offset */
end:
sde_vm_unlock(sde_kms);
pm_runtime_put_sync(drm_enc->dev->dev);
return len;
}