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

Commit f02f23f1 authored by Alan Kwong's avatar Alan Kwong Committed by Gerrit - the friendly Code Review server
Browse files

drm/msm/sde: add mode config mutex lock for connector search



Connection enumeration is used by writeback device to find the
writeback connector. Using connector for_each macros requires
lock of mode config mutex.  Add mutex protection for writeback
connector enumeration.

Change-Id: Ib299f1576cb17d30543daa00df95924b51bc862f
Signed-off-by: default avatarAlan Kwong <akwong@codeaurora.org>
parent 4edc9e77
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -781,15 +781,25 @@ static void sde_encoder_phys_wb_enable(struct sde_encoder_phys *phys_enc)
{
	struct sde_encoder_phys_wb *wb_enc = to_sde_encoder_phys_wb(phys_enc);
	struct sde_hw_wb *hw_wb = wb_enc->hw_wb;
	struct drm_device *dev;
	struct drm_connector *connector;

	SDE_DEBUG("[wb:%d]\n", hw_wb->idx - WB_0);

	if (!wb_enc->base.parent || !wb_enc->base.parent->dev) {
		SDE_ERROR("invalid drm device\n");
		return;
	}
	dev = wb_enc->base.parent->dev;

	/* find associated writeback connector */
	mutex_lock(&dev->mode_config.mutex);
	drm_for_each_connector(connector, phys_enc->parent->dev) {
		if (connector->encoder == phys_enc->parent)
			break;
	}
	mutex_unlock(&dev->mode_config.mutex);

	if (!connector || connector->encoder != phys_enc->parent) {
		SDE_ERROR("failed to find writeback connector\n");
		return;