@@ -283,7 +283,7 @@ static int dmfc_find_slots(struct ipu_dmfc_priv *priv, int slots)
return -EBUSY;
}
-void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc)
+static void dmfc_free_bandwidth(struct dmfc_channel *dmfc)
{
struct ipu_dmfc_priv *priv = dmfc->priv;
int i;
@@ -291,10 +291,8 @@ void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc)
dev_dbg(priv->dev, "dmfc: freeing %d slots starting from segment %d\n",
dmfc->slots, dmfc->segment);
- mutex_lock(&priv->mutex);
-
if (!dmfc->slots)
- goto out;
+ return;
dmfc->slotmask = 0;
dmfc->slots = 0;
@@ -320,7 +318,14 @@ void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc)
priv->channels[i].segment,
priv->channels[i].burstsize);
}
-out:
+}
+
+void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc)
+{
+ struct ipu_dmfc_priv *priv = dmfc->priv;
+
+ mutex_lock(&priv->mutex);
+ dmfc_free_bandwidth(dmfc);
mutex_unlock(&priv->mutex);
}
EXPORT_SYMBOL_GPL(ipu_dmfc_free_bandwidth);
@@ -337,10 +342,10 @@ int ipu_dmfc_alloc_bandwidth(struct dmfc_channel *dmfc,
"dmfc: trying to allocate %ldMpixel/s for IPU channel %d\n",
bandwidth_pixel_per_second / 1000000, dmfc->data->ipu_channel);
- ipu_dmfc_free_bandwidth(dmfc);
-
mutex_lock(&priv->mutex);
+ dmfc_free_bandwidth(dmfc);
+
if (slots > 8) {
ret = -EBUSY;
goto out;
The dmfc mutex was being acquired in ipu_dmfc_free_bandwidth(), freed, then immediately re-acquired in ipu_dmfc_alloc_bandwidth(). Acquire the lock once at the beginning of ipu_dmfc_alloc_bandwidth(). Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> --- drivers/gpu/ipu-v3/ipu-dmfc.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)