Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2725544imj; Mon, 11 Feb 2019 07:33:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IaBb+n9yDtLT/dRJwgO6Vyz6rEFbqUHFl0haVSHGrdLP2b1LMBiGfT29FS0JC9HXlqrpJ+e X-Received: by 2002:aa7:86d1:: with SMTP id h17mr30830329pfo.181.1549899222586; Mon, 11 Feb 2019 07:33:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549899222; cv=none; d=google.com; s=arc-20160816; b=lLa1XQz2MHWFeZpll0HW6sW9WH0xEDiBmu++AMTn4V8gZjkOIWlIShYY0ITui1Mz9r Wtjsi/3T53izrM6QieCXRBlAHlkq3bJKhkymRdA0Sl0KR6ZKKCQKXhROjdJx5wYvfBTd qSvWzlbJ3B9jkeyGeWdDscajSvJw7oc3N7KdqFs/JCKQ/jUN8bdWHSf/VeumiPErNAw9 rO3rgPsibNJjVTvilPPtG1Sd4IuTjVGw5vlNADJhjhp+eVRf3vnPEpyMBFEKKLz0LeKH oYprZaoPv+12sgTKFYZ0ww7akz38Fnav/uNRH1queuVvFJ7eXskF8NAgE7gsMGcIy3SN EkMg== 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=evFCIrZ78EPGzynPa7P0X6QtplQu/W/NF7HQSciiFWM=; b=ThvclBfsOMq8B1sCrZ440leArQXwE4RQ8lxjiQMuHvAMqyXedzRmMYQGY1wxkgjzO0 +TdwIJfxfbCLfkJuUKDzdgjRhdH8QeGGWQm/GL9Lo6p3dA3WAAA/MsbxwwaYPC3Wp4wJ o/n+hXL5YHp9iAe8vNGJHvG1watqB2Q9ZVa/8MDFA4RXmAIv1I/GqS/jnRTqCD+3RmxC kNbC07eqNVTOCaiIBEp6ZdB7d383FfdSzHseEIPPNg+UjOwy7t8f+TXPvpDehna8v7t0 cT9oIPgDiszLqLpohDinoKy7GhNYsLICSJAw25sBwg8THlne48/pOrnP2RRKDHgNg+Z+ LikQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kXhd+2ff; 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 s87si10779630pfi.185.2019.02.11.07.33.26; Mon, 11 Feb 2019 07:33:42 -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=kXhd+2ff; 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 S2389215AbfBKPc2 (ORCPT + 99 others); Mon, 11 Feb 2019 10:32:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:41604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388365AbfBKOyr (ORCPT ); Mon, 11 Feb 2019 09:54:47 -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 10A682229E; Mon, 11 Feb 2019 14:54:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896886; bh=GRA4+zXjpsl7dlV8a4Z0jckTJYc+58L2WiqayCpIpRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kXhd+2ffmZRKAWzRZl0q6yCTYHLSdtdw37gCWdH1GZSaSJlGEdCgGN4KTVEaEt15Q stRy2paf7ESLpv5iUi0igChq5M9PLQpCWHMBiY2eSXSQ9AOUSgda95W7Dr9AJxdBMH wRUWP7NZxgteqxWh7gtXSsGIg5qUUMtUn3reykJ4= 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.14 006/205] gpu: ipu-v3: image-convert: Prevent race between run and unprepare Date: Mon, 11 Feb 2019 15:16:44 +0100 Message-Id: <20190211141827.576791817@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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 524a717ab28e..a5e33d58e02f 100644 --- a/drivers/gpu/ipu-v3/ipu-image-convert.c +++ b/drivers/gpu/ipu-v3/ipu-image-convert.c @@ -1518,7 +1518,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; @@ -1545,7 +1545,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); @@ -1566,7 +1566,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); @@ -1580,7 +1584,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