mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
gpu: ipu-v3: image-convert: Prevent race between run and unprepare
Prevent possible race by parallel threads between ipu_image_convert_run() and ipu_image_convert_unprepare(). This involves setting ctx->aborting to true unconditionally so that no new job runs can be queued during unprepare, and holding the ctx->aborting flag until the context is freed. Note that the "normal" ipu_image_convert_abort() case (e.g. not during context unprepare) should clear the ctx->aborting flag after aborting any active run and clearing the context's pending queue. This is because it should be possible to continue to use the conversion context and queue more runs after an abort. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Tested-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
parent
d0cbc93a01
commit
819bec35c8
@ -1524,7 +1524,7 @@ unlock:
|
|||||||
EXPORT_SYMBOL_GPL(ipu_image_convert_queue);
|
EXPORT_SYMBOL_GPL(ipu_image_convert_queue);
|
||||||
|
|
||||||
/* Abort any active or pending conversions for this context */
|
/* Abort any active or pending conversions for this context */
|
||||||
void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx)
|
static void __ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct ipu_image_convert_chan *chan = ctx->chan;
|
struct ipu_image_convert_chan *chan = ctx->chan;
|
||||||
struct ipu_image_convert_priv *priv = chan->priv;
|
struct ipu_image_convert_priv *priv = chan->priv;
|
||||||
@ -1551,7 +1551,7 @@ void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx)
|
|||||||
|
|
||||||
need_abort = (run_count || active_run);
|
need_abort = (run_count || active_run);
|
||||||
|
|
||||||
ctx->aborting = need_abort;
|
ctx->aborting = true;
|
||||||
|
|
||||||
spin_unlock_irqrestore(&chan->irqlock, flags);
|
spin_unlock_irqrestore(&chan->irqlock, flags);
|
||||||
|
|
||||||
@ -1572,7 +1572,11 @@ void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx)
|
|||||||
dev_warn(priv->ipu->dev, "%s: timeout\n", __func__);
|
dev_warn(priv->ipu->dev, "%s: timeout\n", __func__);
|
||||||
force_abort(ctx);
|
force_abort(ctx);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx)
|
||||||
|
{
|
||||||
|
__ipu_image_convert_abort(ctx);
|
||||||
ctx->aborting = false;
|
ctx->aborting = false;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(ipu_image_convert_abort);
|
EXPORT_SYMBOL_GPL(ipu_image_convert_abort);
|
||||||
@ -1586,7 +1590,7 @@ void ipu_image_convert_unprepare(struct ipu_image_convert_ctx *ctx)
|
|||||||
bool put_res;
|
bool put_res;
|
||||||
|
|
||||||
/* make sure no runs are hanging around */
|
/* make sure no runs are hanging around */
|
||||||
ipu_image_convert_abort(ctx);
|
__ipu_image_convert_abort(ctx);
|
||||||
|
|
||||||
dev_dbg(priv->ipu->dev, "%s: task %u: removing ctx %p\n", __func__,
|
dev_dbg(priv->ipu->dev, "%s: task %u: removing ctx %p\n", __func__,
|
||||||
chan->ic_task, ctx);
|
chan->ic_task, ctx);
|
||||||
|
Loading…
Reference in New Issue
Block a user