Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2647727imj; Mon, 11 Feb 2019 06:26:15 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib53GXvwSn80gVDz2rqFodGd9w0PM6DUtc68GUNWXzjtzA2gQCOWLhipA2MnR10i+f3gzzX X-Received: by 2002:a62:1e45:: with SMTP id e66mr36723339pfe.152.1549895175364; Mon, 11 Feb 2019 06:26:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895175; cv=none; d=google.com; s=arc-20160816; b=eSvKspKb36LAhqX7icgFNhbbOPIxPl/D/VjpmTRlshtDRvfcdroO5xMp40QVhn3kwb nlrq9xlFl6XsiPwULIbnmSfX/lYYHyttqJpW6y3VSUQEdvgOhrpF3w0DycRMk6UbD6oM WQiGCWCwrPIke3ZSD3+hWroCHTWURk23gqU62l0ME/8pr6iyBNL7JYdPPxn3dLr+IgLt atKYzsG+sY14cxc46/MxVIPFIcWmH/W2V5oCL/3osyjZ/1+Xq0rs/oJb3gMLK24mY8Dq mJ4KFAN1ecZW6nHYoDeRu4Q5XvEmSDcWp+ZgHJMdfNy2I0RNaAZahT8Eayr1dImJ8f9m +MxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8PmBsqm03IxECAY+9kyx9GnkweoWZb1s6MoPUsSORdE=; b=XCMY9C6fJt1HqQo4thtPzyQiVoDza374P1ntOC5jvQLEL3mnJ3VyB6tg5Px8Ed2pU1 RINbIkZ83QniAREv6vW1oES+t1NFQ8tSyOFJtVSmiDG15sHtftBeJxnlT/ns4dwHzALC KBN1oDZQNcOrnnjoh0a0QZMdEqZ5LNg47LRSuzMTpaDFTEFpd1rN6d+uLflUuJC6BBeH xHp98Y8HljaLS5z0cYKzcrp0KtcxdGAdkuj2zOa09NqYCmJ1WhGwUM2DDxbrt9/77Oeq 3qTyOagyk9Yeiod+cBlOCMXixHBLiASpgyL5KWZPaI3fl/FO9ZQz1baieMSSAd4p+1ii v6dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pgDgxIv3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12si9571531pgh.368.2019.02.11.06.25.58; Mon, 11 Feb 2019 06:26:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pgDgxIv3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728522AbfBKOV1 (ORCPT + 99 others); Mon, 11 Feb 2019 09:21:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:54218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726941AbfBKOVW (ORCPT ); Mon, 11 Feb 2019 09:21:22 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D76F220838; Mon, 11 Feb 2019 14:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549894881; bh=n0DcqnhkeKyFYSnHdcn8wDqrKv3LLrJ8QtrUGyV73ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pgDgxIv3rcxLgVQm5Ar4oQYJ1Wh7RQSeDfPd6fTRa6Hn9AN6zwBZFNKu/zo6YuGJS 69Q7gsFh2GrXgYmUVEWoMB+Ws/jkw+i2/wBTr+1S/G29Ta4xB30QL/qQoQ8chIicLw EHclEDAKGIciqb45Wi1uKwly4kzurECUqF0cMyRs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steve Longerbeam , Philipp Zabel , Sasha Levin Subject: [PATCH 4.20 012/352] gpu: ipu-v3: image-convert: Prevent race between run and unprepare Date: Mon, 11 Feb 2019 15:13:59 +0100 Message-Id: <20190211141847.195066018@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 819bec35c8c9706185498c9222bd244e0781ad35 ] 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 Tested-by: Philipp Zabel Signed-off-by: Philipp Zabel Signed-off-by: Sasha Levin --- drivers/gpu/ipu-v3/ipu-image-convert.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c b/drivers/gpu/ipu-v3/ipu-image-convert.c index f4081962784c..91653adc41cc 100644 --- a/drivers/gpu/ipu-v3/ipu-image-convert.c +++ b/drivers/gpu/ipu-v3/ipu-image-convert.c @@ -1524,7 +1524,7 @@ unlock: EXPORT_SYMBOL_GPL(ipu_image_convert_queue); /* 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_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); - ctx->aborting = need_abort; + ctx->aborting = true; 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__); force_abort(ctx); } +} +void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx) +{ + __ipu_image_convert_abort(ctx); ctx->aborting = false; } 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; /* 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__, chan->ic_task, ctx); -- 2.19.1