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

Commit 6957735b authored by Ajay Singh Parmar's avatar Ajay Singh Parmar
Browse files

drm/msm/dp: fix race condition during simulation



The simulation script can end abruptly during simulation
testing. This may result in buffers being released by the
script while the test may still be using them.
Use mutex lock to avoid multiple threads to allocate/deallocate
and access the buffers at the same time to avoid system instability.

CRs-Fixed: 2308439
Change-Id: Ia1c407d91afa98b4085d58cb45c8659206a0f990
Signed-off-by: default avatarAjay Singh Parmar <aparmar@codeaurora.org>
parent ade22fca
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -479,6 +479,8 @@ static ssize_t dp_aux_transfer_debug(struct drm_dp_aux *drm_aux,
	struct dp_aux_private *aux = container_of(drm_aux,
		struct dp_aux_private, drm_aux);

	mutex_lock(&aux->mutex);

	ret = dp_aux_transfer_ready(aux, msg, false);
	if (ret)
		goto end;
@@ -536,12 +538,14 @@ static ssize_t dp_aux_transfer_debug(struct drm_dp_aux *drm_aux,
			DP_AUX_NATIVE_REPLY_DEFER : DP_AUX_I2C_REPLY_DEFER;
	}

	return msg->size;
	ret = msg->size;
	goto end;

address_error:
	memset(msg->buffer, 0, msg->size);
	ret = msg->size;
end:
	mutex_unlock(&aux->mutex);
	return ret;
}

@@ -720,6 +724,8 @@ static void dp_aux_set_sim_mode(struct dp_aux *dp_aux, bool en,

	aux = container_of(dp_aux, struct dp_aux_private, dp_aux);

	mutex_lock(&aux->mutex);

	aux->edid = edid;
	aux->dpcd = dpcd;

@@ -727,6 +733,8 @@ static void dp_aux_set_sim_mode(struct dp_aux *dp_aux, bool en,
		aux->drm_aux.transfer = dp_aux_transfer_debug;
	else
		aux->drm_aux.transfer = dp_aux_transfer;

	mutex_unlock(&aux->mutex);
}

static int dp_aux_configure_aux_switch(struct dp_aux *dp_aux,
+7 −5
Original line number Diff line number Diff line
@@ -1029,7 +1029,14 @@ static ssize_t dp_debug_write_sim(struct file *file,

		if (dp_debug_get_dpcd_buf(debug))
			goto error;

		debug->dp_debug.sim_mode = true;
		debug->aux->set_sim_mode(debug->aux, true,
			debug->edid, debug->dpcd);
	} else {
		debug->aux->set_sim_mode(debug->aux, false, NULL, NULL);
		debug->dp_debug.sim_mode = false;

		if (debug->edid) {
			devm_kfree(debug->dev, debug->edid);
			debug->edid = NULL;
@@ -1040,11 +1047,6 @@ static ssize_t dp_debug_write_sim(struct file *file,
			debug->dpcd = NULL;
		}
	}

	debug->dp_debug.sim_mode = !!sim;

	debug->aux->set_sim_mode(debug->aux, debug->dp_debug.sim_mode,
			debug->edid, debug->dpcd);
end:
	return len;
error: