Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2481314imm; Mon, 24 Sep 2018 05:14:19 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaiEAgNz+bjoDwVnllKdr0D3UaqMhiHiJKk9vGg38HBLcO5bLOSy5wZd0Kxc/1oTgDEXM5o X-Received: by 2002:a62:642:: with SMTP id 63-v6mr10224257pfg.42.1537791259715; Mon, 24 Sep 2018 05:14:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537791259; cv=none; d=google.com; s=arc-20160816; b=wB4oEsfEZn5gdmlJI0bZ0eHB4RCYCuIZz9B0v9bq2m0F0P11mmvks+5PoiwrGVCna6 G+Rg7N8Qpdz0cXDEwevnpNTtYEThc5H43u47Im+q7vXNe82mPFfxwOetzi6d6LfB9tEs ttXMjRYZ6A8sAfeX45MbzpQHq9sFoNdHJXNnDh4uZSPr54R+qHirmJU/gp3qzjV8W5NK 5OeAgPAj+dDW1oX8SCrAiuTkGWd2Lc8ESIQBv3rq/7dg5nhnXFsHRyokcfcj3XUjpqCj nfdYMCfAFeu2NiVyfkWlPE6TML67AxR5fUNHb4PWBvxM6jRadYR2y11m94saY+oDAuga IUkw== 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; bh=DqrVIA8rVGrCRFrVwopNq3FwGXTNp2HLENU2RQp3Wzo=; b=xAy6JpN71fjS3TQ43mEnB7xFN/mwdG/zl40x+u9mTxoreBn2bdXb0n/tzulJTXVoFn edTDN06bMo7r9DifGl/Vx0bZzlM1Hb/Y+NYveibnm4J20PNOpepiw7CU9icWGm/Amt7p isG6aPq6XWNT9z2QWGd83rjAgfszRw1hXjqMjgqrAuaYZANQ0L0IPAXm+h6Xp86i1/YJ px4AeW3cuflQZaN9VnAETRSoDb940E7ZQM696irSzl+9xqKhIVTsXVlGF0wUC0p48fn4 sDaOLvHRWZKWLd+F733EzudJBXW1Ek2PdIYQnjt1Qu2MQm/diNk2t4t9R0vOFNTWaGrA 1YRQ== ARC-Authentication-Results: i=1; mx.google.com; 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 e124-v6si15298697pfg.216.2018.09.24.05.14.04; Mon, 24 Sep 2018 05:14:19 -0700 (PDT) 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; 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 S1731571AbeIXSPD (ORCPT + 99 others); Mon, 24 Sep 2018 14:15:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55142 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729879AbeIXSPC (ORCPT ); Mon, 24 Sep 2018 14:15:02 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BCB1E1094; Mon, 24 Sep 2018 12:13:11 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Keeping , Vinod Koul , Sasha Levin Subject: [PATCH 4.14 026/173] dmaengine: pl330: fix irq race with terminate_all Date: Mon, 24 Sep 2018 13:51:00 +0200 Message-Id: <20180924113117.696429612@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113114.334025954@linuxfoundation.org> References: <20180924113114.334025954@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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. ------------------ From: John Keeping [ Upstream commit e49756544a21f5625b379b3871d27d8500764670 ] In pl330_update() when checking if a channel has been aborted, the channel's lock is not taken, only the overall pl330_dmac lock. But in pl330_terminate_all() the aborted flag (req_running==-1) is set under the channel lock and not the pl330_dmac lock. With threaded interrupts, this leads to a potential race: pl330_terminate_all pl330_update ------------------- ------------ lock channel entry lock pl330 _stop channel unlock pl330 lock pl330 check req_running != -1 req_running = -1 _start channel Signed-off-by: John Keeping Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/dma/pl330.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2142,13 +2142,14 @@ static int pl330_terminate_all(struct dm pm_runtime_get_sync(pl330->ddma.dev); spin_lock_irqsave(&pch->lock, flags); + spin_lock(&pl330->lock); _stop(pch->thread); - spin_unlock(&pl330->lock); - pch->thread->req[0].desc = NULL; pch->thread->req[1].desc = NULL; pch->thread->req_running = -1; + spin_unlock(&pl330->lock); + power_down = pch->active; pch->active = false;