diff mbox

[1/4] gpu: ipu-v3: ipu-dmfc: Protect function ipu_dmfc_init_channel() with mutex

Message ID 1457943011-20542-1-git-send-email-gnuiyl@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ying Liu March 14, 2016, 8:10 a.m. UTC
To avoid race condition issue, we should protect the function
ipu_dmfc_init_channel() with the mutex dmfc->priv->mutex, since it
configures the register DMFC_GENERAL1 at runtime which contains
several control bits for various display channels.  This matches
better with fine grained locking logic in upper layer.

Signed-off-by: Liu Ying <gnuiyl@gmail.com>
---
 drivers/gpu/ipu-v3/ipu-dmfc.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Philipp Zabel March 31, 2016, 5:27 p.m. UTC | #1
Hi Liu,

Am Montag, den 14.03.2016, 16:10 +0800 schrieb Liu Ying:
> To avoid race condition issue, we should protect the function
> ipu_dmfc_init_channel() with the mutex dmfc->priv->mutex, since it
> configures the register DMFC_GENERAL1 at runtime which contains
> several control bits for various display channels.  This matches
> better with fine grained locking logic in upper layer.

Applied all four patches, thank you.

regards
Philipp
diff mbox

Patch

diff --git a/drivers/gpu/ipu-v3/ipu-dmfc.c b/drivers/gpu/ipu-v3/ipu-dmfc.c
index 042c395..129ccfa 100644
--- a/drivers/gpu/ipu-v3/ipu-dmfc.c
+++ b/drivers/gpu/ipu-v3/ipu-dmfc.c
@@ -355,6 +355,8 @@  int ipu_dmfc_init_channel(struct dmfc_channel *dmfc, int width)
 	struct ipu_dmfc_priv *priv = dmfc->priv;
 	u32 dmfc_gen1;
 
+	mutex_lock(&priv->mutex);
+
 	dmfc_gen1 = readl(priv->base + DMFC_GENERAL1);
 
 	if ((dmfc->slots * 64 * 4) / width > dmfc->data->max_fifo_lines)
@@ -364,6 +366,8 @@  int ipu_dmfc_init_channel(struct dmfc_channel *dmfc, int width)
 
 	writel(dmfc_gen1, priv->base + DMFC_GENERAL1);
 
+	mutex_unlock(&priv->mutex);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(ipu_dmfc_init_channel);