Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91d1ed8e authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "disp: msm: dsi: avoid debugfs HW access based on HW ownership"

parents eb21ca87 8f957517
Loading
Loading
Loading
Loading
+49 −3
Original line number Original line Diff line number Diff line
@@ -1383,6 +1383,14 @@ static ssize_t debugfs_misr_setup(struct file *file,
	display->misr_frame_count = frame_count;
	display->misr_frame_count = frame_count;


	mutex_lock(&display->display_lock);
	mutex_lock(&display->display_lock);

	if (!display->hw_ownership) {
		DSI_DEBUG("[%s] op not supported due to HW unavailability\n",
				display->name);
		rc = -EOPNOTSUPP;
		goto unlock;
	}

	rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
	rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
			DSI_CORE_CLK, DSI_CLK_ON);
			DSI_CORE_CLK, DSI_CLK_ON);
	if (rc) {
	if (rc) {
@@ -1434,6 +1442,14 @@ static ssize_t debugfs_misr_read(struct file *file,
		return -ENOMEM;
		return -ENOMEM;


	mutex_lock(&display->display_lock);
	mutex_lock(&display->display_lock);

	if (!display->hw_ownership) {
		DSI_DEBUG("[%s] op not supported due to HW unavailability\n",
				display->name);
		rc = -EOPNOTSUPP;
		goto error;
	}

	rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
	rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
			DSI_CORE_CLK, DSI_CLK_ON);
			DSI_CORE_CLK, DSI_CLK_ON);
	if (rc) {
	if (rc) {
@@ -1531,6 +1547,15 @@ static ssize_t debugfs_esd_trigger_check(struct file *file,


	display->esd_trigger = esd_trigger;
	display->esd_trigger = esd_trigger;


	mutex_lock(&display->display_lock);

	if (!display->hw_ownership) {
		DSI_DEBUG("[%s] op not supported due to HW unavailability\n",
				display->name);
		rc = -EOPNOTSUPP;
		goto unlock;
	}

	if (display->esd_trigger) {
	if (display->esd_trigger) {
		DSI_INFO("ESD attack triggered by user\n");
		DSI_INFO("ESD attack triggered by user\n");
		rc = dsi_panel_trigger_esd_attack(display->panel,
		rc = dsi_panel_trigger_esd_attack(display->panel,
@@ -1542,6 +1567,8 @@ static ssize_t debugfs_esd_trigger_check(struct file *file,
	}
	}


	rc = len;
	rc = len;
unlock:
	mutex_unlock(&display->display_lock);
error:
error:
	kfree(buf);
	kfree(buf);
	return rc;
	return rc;
@@ -4159,10 +4186,13 @@ static int dsi_display_res_init(struct dsi_display *display)
	 * In trusted vm, the connectors will not be enabled
	 * In trusted vm, the connectors will not be enabled
	 * until the HW resources are assigned and accepted.
	 * until the HW resources are assigned and accepted.
	 */
	 */
	if (display->trusted_vm_env)
	if (display->trusted_vm_env) {
		display->is_active = false;
		display->is_active = false;
	else
		display->hw_ownership = false;
	} else {
		display->is_active = true;
		display->is_active = true;
		display->hw_ownership = true;
	}


	return 0;
	return 0;
error_ctrl_put:
error_ctrl_put:
@@ -5405,19 +5435,33 @@ static int dsi_display_get_io_resources(struct msm_io_res *io_res, void *data)


static int dsi_display_pre_release(void *data)
static int dsi_display_pre_release(void *data)
{
{
	struct dsi_display *display;

	if (!data)
	if (!data)
		return -EINVAL;
		return -EINVAL;


	dsi_display_ctrl_irq_update((struct dsi_display *)data, false);
	display = (struct dsi_display *)data;
	mutex_lock(&display->display_lock);
	display->hw_ownership = false;
	mutex_unlock(&display->display_lock);

	dsi_display_ctrl_irq_update(display, false);


	return 0;
	return 0;
}
}


static int dsi_display_pre_acquire(void *data)
static int dsi_display_pre_acquire(void *data)
{
{
	struct dsi_display *display;

	if (!data)
	if (!data)
		return -EINVAL;
		return -EINVAL;


	display = (struct dsi_display *)data;
	mutex_lock(&display->display_lock);
	display->hw_ownership = true;
	mutex_unlock(&display->display_lock);

	dsi_display_ctrl_irq_update((struct dsi_display *)data, true);
	dsi_display_ctrl_irq_update((struct dsi_display *)data, true);


	return 0;
	return 0;
@@ -7651,6 +7695,7 @@ int dsi_display_prepare(struct dsi_display *display)
	SDE_EVT32(SDE_EVTLOG_FUNC_ENTRY);
	SDE_EVT32(SDE_EVTLOG_FUNC_ENTRY);
	mutex_lock(&display->display_lock);
	mutex_lock(&display->display_lock);


	display->hw_ownership = true;
	mode = display->panel->cur_mode;
	mode = display->panel->cur_mode;


	dsi_display_set_ctrl_esd_check_flag(display, false);
	dsi_display_set_ctrl_esd_check_flag(display, false);
@@ -8508,6 +8553,7 @@ int dsi_display_unprepare(struct dsi_display *display)
			DSI_ERR("[%s] panel post-unprepare failed, rc=%d\n",
			DSI_ERR("[%s] panel post-unprepare failed, rc=%d\n",
			       display->name, rc);
			       display->name, rc);
	}
	}
	display->hw_ownership = false;


	mutex_unlock(&display->display_lock);
	mutex_unlock(&display->display_lock);


+2 −0
Original line number Original line Diff line number Diff line
@@ -192,6 +192,7 @@ struct dsi_display_ext_bridge {
 * @is_active:        status of the display
 * @is_active:        status of the display
 * @trusted_vm_env:   Set to true, it the executing VM is Trusted VM.
 * @trusted_vm_env:   Set to true, it the executing VM is Trusted VM.
 *                    Set to false, otherwise.
 *                    Set to false, otherwise.
 * @hw_ownership:     Indicates if VM owns the hardware resources.
 * @tx_cmd_buf_ndx:   Index to the DSI debugfs TX CMD buffer.
 * @tx_cmd_buf_ndx:   Index to the DSI debugfs TX CMD buffer.
 * @cmd_set:	      Debugfs TX cmd set.
 * @cmd_set:	      Debugfs TX cmd set.
 * @enabled:	      Boolean to indicate display enabled.
 * @enabled:	      Boolean to indicate display enabled.
@@ -290,6 +291,7 @@ struct dsi_display {
	bool is_active;
	bool is_active;


	bool trusted_vm_env;
	bool trusted_vm_env;
	bool hw_ownership;


	int tx_cmd_buf_ndx;
	int tx_cmd_buf_ndx;
	struct dsi_panel_cmd_set cmd_set;
	struct dsi_panel_cmd_set cmd_set;
+17 −1
Original line number Original line Diff line number Diff line
@@ -1901,6 +1901,8 @@ static ssize_t _sde_debugfs_conn_cmd_tx_write(struct file *file,
{
{
	struct drm_connector *connector = file->private_data;
	struct drm_connector *connector = file->private_data;
	struct sde_connector *c_conn = NULL;
	struct sde_connector *c_conn = NULL;
	struct sde_vm_ops *vm_ops;
	struct sde_kms *sde_kms;
	char *input, *token, *input_copy, *input_dup = NULL;
	char *input, *token, *input_copy, *input_dup = NULL;
	const char *delim = " ";
	const char *delim = " ";
	char buffer[MAX_CMD_PAYLOAD_SIZE] = {0};
	char buffer[MAX_CMD_PAYLOAD_SIZE] = {0};
@@ -1911,9 +1913,14 @@ static ssize_t _sde_debugfs_conn_cmd_tx_write(struct file *file,
		SDE_ERROR("invalid argument(s), conn %d\n", connector != NULL);
		SDE_ERROR("invalid argument(s), conn %d\n", connector != NULL);
		return -EINVAL;
		return -EINVAL;
	}
	}

	c_conn = to_sde_connector(connector);
	c_conn = to_sde_connector(connector);


	sde_kms = _sde_connector_get_kms(&c_conn->base);
	if (!sde_kms) {
		SDE_ERROR("invalid kms\n");
		return -EINVAL;
	}

	if (!c_conn->ops.cmd_transfer) {
	if (!c_conn->ops.cmd_transfer) {
		SDE_ERROR("no cmd transfer support for connector name %s\n",
		SDE_ERROR("no cmd transfer support for connector name %s\n",
				c_conn->name);
				c_conn->name);
@@ -1924,6 +1931,14 @@ static ssize_t _sde_debugfs_conn_cmd_tx_write(struct file *file,
	if (!input)
	if (!input)
		return -ENOMEM;
		return -ENOMEM;


	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 (copy_from_user(input, p, count)) {
	if (copy_from_user(input, p, count)) {
		SDE_ERROR("copy from user failed\n");
		SDE_ERROR("copy from user failed\n");
		rc = -EFAULT;
		rc = -EFAULT;
@@ -1973,6 +1988,7 @@ static ssize_t _sde_debugfs_conn_cmd_tx_write(struct file *file,
end1:
end1:
	kfree(input_dup);
	kfree(input_dup);
end:
end:
	sde_vm_unlock(sde_kms);
	kfree(input);
	kfree(input);
	return rc;
	return rc;
}
}
+12 −0
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@
#include "sde_power_handle.h"
#include "sde_power_handle.h"
#include "sde_core_perf.h"
#include "sde_core_perf.h"
#include "sde_trace.h"
#include "sde_trace.h"
#include "sde_vm.h"


#define SDE_PSTATES_MAX (SDE_STAGE_MAX * 4)
#define SDE_PSTATES_MAX (SDE_STAGE_MAX * 4)
#define SDE_MULTIRECT_PLANE_MAX (SDE_STAGE_MAX * 2)
#define SDE_MULTIRECT_PLANE_MAX (SDE_STAGE_MAX * 2)
@@ -6003,6 +6004,7 @@ static ssize_t _sde_crtc_misr_read(struct file *file,
	struct sde_crtc *sde_crtc;
	struct sde_crtc *sde_crtc;
	struct sde_kms *sde_kms;
	struct sde_kms *sde_kms;
	struct sde_crtc_mixer *m;
	struct sde_crtc_mixer *m;
	struct sde_vm_ops *vm_ops;
	int i = 0, rc;
	int i = 0, rc;
	ssize_t len = 0;
	ssize_t len = 0;
	char buf[MISR_BUFF_SIZE + 1] = {'\0'};
	char buf[MISR_BUFF_SIZE + 1] = {'\0'};
@@ -6023,8 +6025,17 @@ static ssize_t _sde_crtc_misr_read(struct file *file,
	if (rc < 0)
	if (rc < 0)
		return rc;
		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)) {
	if (sde_kms_is_secure_session_inprogress(sde_kms)) {
		SDE_DEBUG("crtc:%d misr read not allowed\n", DRMID(crtc));
		SDE_DEBUG("crtc:%d misr read not allowed\n", DRMID(crtc));
		rc = -EOPNOTSUPP;
		goto end;
		goto end;
	}
	}


@@ -6074,6 +6085,7 @@ static ssize_t _sde_crtc_misr_read(struct file *file,
	*ppos += len;   /* increase offset */
	*ppos += len;   /* increase offset */


end:
end:
	sde_vm_unlock(sde_kms);
	pm_runtime_put_sync(crtc->dev->dev);
	pm_runtime_put_sync(crtc->dev->dev);
	return len;
	return len;
}
}
+11 −0
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@
#include "sde_hw_top.h"
#include "sde_hw_top.h"
#include "sde_hw_qdss.h"
#include "sde_hw_qdss.h"
#include "sde_encoder_dce.h"
#include "sde_encoder_dce.h"
#include "sde_vm.h"


#define SDE_DEBUG_ENC(e, fmt, ...) SDE_DEBUG("enc%d " fmt,\
#define SDE_DEBUG_ENC(e, fmt, ...) SDE_DEBUG("enc%d " fmt,\
		(e) ? (e)->base.base.id : -1, ##__VA_ARGS__)
		(e) ? (e)->base.base.id : -1, ##__VA_ARGS__)
@@ -4496,6 +4497,7 @@ static ssize_t _sde_encoder_misr_read(struct file *file,
	struct sde_encoder_virt *sde_enc;
	struct sde_encoder_virt *sde_enc;
	struct sde_kms *sde_kms = NULL;
	struct sde_kms *sde_kms = NULL;
	struct drm_encoder *drm_enc;
	struct drm_encoder *drm_enc;
	struct sde_vm_ops *vm_ops;
	int i = 0, len = 0;
	int i = 0, len = 0;
	char buf[MISR_BUFF_SIZE + 1] = {'\0'};
	char buf[MISR_BUFF_SIZE + 1] = {'\0'};
	int rc;
	int rc;
@@ -4521,6 +4523,14 @@ static ssize_t _sde_encoder_misr_read(struct file *file,
	if (rc < 0)
	if (rc < 0)
		return rc;
		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) {
	if (!sde_enc->misr_enable) {
		len += scnprintf(buf + len, MISR_BUFF_SIZE - len,
		len += scnprintf(buf + len, MISR_BUFF_SIZE - len,
				"disabled\n");
				"disabled\n");
@@ -4568,6 +4578,7 @@ static ssize_t _sde_encoder_misr_read(struct file *file,
	*ppos += len;   /* increase offset */
	*ppos += len;   /* increase offset */


end:
end:
	sde_vm_unlock(sde_kms);
	pm_runtime_put_sync(drm_enc->dev->dev);
	pm_runtime_put_sync(drm_enc->dev->dev);
	return len;
	return len;
}
}
Loading