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

Commit 552b9ed7 authored by Vara Reddy's avatar Vara Reddy Committed by Steve Cohen
Browse files

drm/msm/dsi-staging: make cmd enable/disable functions atomic



Multiple threads can call into cmd engine enable and disable api's
to transfer commands. Making these calls atomic with ctrl mutex.

Change-Id: I8157bdf487562b45398076f5a9ed5b65bda85401
Signed-off-by: default avatarVara Reddy <varar@codeaurora.org>
parent bcf3b035
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -2756,8 +2756,6 @@ int dsi_ctrl_set_cmd_engine_state(struct dsi_ctrl *dsi_ctrl,
		return -EINVAL;
	}

	mutex_lock(&dsi_ctrl->ctrl_lock);

	rc = dsi_ctrl_check_state(dsi_ctrl, DSI_CTRL_OP_CMD_ENGINE, state);
	if (rc) {
		pr_err("[DSI_%d] Controller state check failed, rc=%d\n",
@@ -2774,7 +2772,6 @@ int dsi_ctrl_set_cmd_engine_state(struct dsi_ctrl *dsi_ctrl,
		 state);
	dsi_ctrl_update_state(dsi_ctrl, DSI_CTRL_OP_CMD_ENGINE, state);
error:
	mutex_unlock(&dsi_ctrl->ctrl_lock);
	return rc;
}

+15 −9
Original line number Diff line number Diff line
@@ -131,18 +131,19 @@ static int dsi_display_cmd_engine_enable(struct dsi_display *display)
	int i;
	struct dsi_display_ctrl *m_ctrl, *ctrl;

	m_ctrl = &display->ctrl[display->cmd_master_idx];
	mutex_lock(&m_ctrl->ctrl->ctrl_lock);

	if (display->cmd_engine_refcount > 0) {
		display->cmd_engine_refcount++;
		return 0;
		goto done;
	}

	m_ctrl = &display->ctrl[display->cmd_master_idx];

	rc = dsi_ctrl_set_cmd_engine_state(m_ctrl->ctrl, DSI_CTRL_ENGINE_ON);
	if (rc) {
		pr_err("[%s] failed to enable cmd engine, rc=%d\n",
		       display->name, rc);
		goto error;
		goto done;
	}

	for (i = 0; i < display->ctrl_count; i++) {
@@ -160,10 +161,11 @@ static int dsi_display_cmd_engine_enable(struct dsi_display *display)
	}

	display->cmd_engine_refcount++;
	return rc;
	goto done;
error_disable_master:
	(void)dsi_ctrl_set_cmd_engine_state(m_ctrl->ctrl, DSI_CTRL_ENGINE_OFF);
error:
done:
	mutex_unlock(&m_ctrl->ctrl->ctrl_lock);
	return rc;
}

@@ -173,15 +175,17 @@ static int dsi_display_cmd_engine_disable(struct dsi_display *display)
	int i;
	struct dsi_display_ctrl *m_ctrl, *ctrl;

	m_ctrl = &display->ctrl[display->cmd_master_idx];
	mutex_lock(&m_ctrl->ctrl->ctrl_lock);

	if (display->cmd_engine_refcount == 0) {
		pr_err("[%s] Invalid refcount\n", display->name);
		return 0;
		goto done;
	} else if (display->cmd_engine_refcount > 1) {
		display->cmd_engine_refcount--;
		return 0;
		goto done;
	}

	m_ctrl = &display->ctrl[display->cmd_master_idx];
	for (i = 0; i < display->ctrl_count; i++) {
		ctrl = &display->ctrl[i];
		if (!ctrl->ctrl || (ctrl == m_ctrl))
@@ -203,6 +207,8 @@ static int dsi_display_cmd_engine_disable(struct dsi_display *display)

error:
	display->cmd_engine_refcount = 0;
done:
	mutex_unlock(&m_ctrl->ctrl->ctrl_lock);
	return rc;
}

+0 −1
Original line number Diff line number Diff line
@@ -493,7 +493,6 @@ static int dsi_panel_tx_cmd_set(struct dsi_panel *panel,
	}

	for (i = 0; i < count; i++) {
		/* TODO:  handle last command */
		if (state == DSI_CMD_SET_STATE_LP)
			cmds->msg.flags |= MIPI_DSI_MSG_USE_LPM;