Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1021079yba; Thu, 4 Apr 2019 02:36:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZUMJLqHEUsE8db2Nug3NldmkBlqFmjXzUviXdwSfCfz7pR/EXFDWAxeHQ+BkVEbWbRcjY X-Received: by 2002:a63:e14e:: with SMTP id h14mr4795681pgk.184.1554370572953; Thu, 04 Apr 2019 02:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370572; cv=none; d=google.com; s=arc-20160816; b=s48ZFetgZgr0u8uE/COhpZ6AJ7am2+kVuDWEi1XUSccNgRM/UFu00M/okqPhz9nW3j MBIAvVkzgYeEWSWCt19TlIB5z840ZAtav5Snbv3DAL/GijkQVp8tLlK6ffNW3hWQJ6Q2 LHsutHXEbpCrPc9s5hyQux+vPWhN8MAB3RzgGUO/CmpC5cL10lInlsrDGxagqNuHdTIW GdK7MD+CDPK65T3+qTSTFDoXed5Qit5ywLGTSVZrkQ/MsUuBs3yyVxPgTF6TUkAYQrys 5PLq48plYEBTZ+zqdkkiPir+57K2Io8x5l91e6BLcZ/7PfkS0BLhuqCnWm+w9NhBX211 niqg== 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=Vhqt9pmEIHKHPOYpYrEqcUNS8iOaKsKOfuIr3hcL5tk=; b=a0zs841AXxDRSSaivdrwMt3o9w9Eskas4tPBNZta9elnQ8W3wJb4SK7aEbgRMswaEf N89Sz/Ise0lkAXXyAPadwkH6yIIDQKIsS+mm67ywy3QLGhmqTUCzG804REHKCRVFXa+A uKniovvm1qbYNc6q9QPg36BhWvkxtu+D8Xw/mjfqWwvLIGJkmVbFaVLnqybhuzNk3rCS zIBEn4f7YVFaoccysxv8lmHUBwrxpbIh+XIYTQFtOV4Ueyz+KT30WlVn855fBnXQ4JFM hafZTy7wYhfjx4O2ncYb0WbYBz4qbcx2n9/QFCou5ZD8nHhhuJnLTma8L9X77CO1ILtQ MfyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rP7vV3+X; 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 p87si10340716pfa.77.2019.04.04.02.35.58; Thu, 04 Apr 2019 02:36:12 -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; dkim=pass header.i=@kernel.org header.s=default header.b=rP7vV3+X; 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 S1732422AbfDDJG5 (ORCPT + 99 others); Thu, 4 Apr 2019 05:06:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:45638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732099AbfDDJG4 (ORCPT ); Thu, 4 Apr 2019 05:06:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 0A8032183E; Thu, 4 Apr 2019 09:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368815; bh=9SOBwbDgsJmLRo156uxkqLvfyj28siZx6cxArqKiC3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rP7vV3+XlHDkpfOF8hEbL7Kj5gMmaSRYLEZwmoTOugoSzh/J0gLt8Rs6Nx3cLBoaQ krPPzzAbVNUo+LMbPd6esiLUejOOr+qiuhCQlns4XwFCPBqnA+INyzZTOOLUfUDdbf PvXqCoq3Y+JsazH0cKLKSoYtvop60osSPJoruGOw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joey Zheng , Sinan Kaya , Shunyong Yang , Vinod Koul , Sasha Levin Subject: [PATCH 4.19 164/187] dmaengine: qcom_hidma: assign channel cookie correctly Date: Thu, 4 Apr 2019 10:48:21 +0200 Message-Id: <20190404084610.823595544@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@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.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 546c0547555efca8ba8c120716c325435e29df1b ] When dma_cookie_complete() is called in hidma_process_completed(), dma_cookie_status() will return DMA_COMPLETE in hidma_tx_status(). Then, hidma_txn_is_success() will be called to use channel cookie mchan->last_success to do additional DMA status check. Current code assigns mchan->last_success after dma_cookie_complete(). This causes a race condition of dma_cookie_status() returns DMA_COMPLETE before mchan->last_success is assigned correctly. The race will cause hidma_tx_status() return DMA_ERROR but the transaction is actually a success. Moreover, in async_tx case, it will cause a timeout panic in async_tx_quiesce(). Kernel panic - not syncing: async_tx_quiesce: DMA error waiting for transaction ... Call trace: [] dump_backtrace+0x0/0x1f4 [] show_stack+0x24/0x2c [] dump_stack+0x84/0xa8 [] panic+0x12c/0x29c [] async_tx_quiesce+0xa4/0xc8 [async_tx] [] async_trigger_callback+0x70/0x1c0 [async_tx] [] raid_run_ops+0x86c/0x1540 [raid456] [] handle_stripe+0x5e8/0x1c7c [raid456] [] handle_active_stripes.isra.45+0x2d4/0x550 [raid456] [] raid5d+0x38c/0x5d0 [raid456] [] md_thread+0x108/0x168 [] kthread+0x10c/0x138 [] ret_from_fork+0x10/0x18 Cc: Joey Zheng Reviewed-by: Sinan Kaya Signed-off-by: Shunyong Yang Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/qcom/hidma.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c index 43d4b00b8138..ea219bca116d 100644 --- a/drivers/dma/qcom/hidma.c +++ b/drivers/dma/qcom/hidma.c @@ -138,24 +138,25 @@ static void hidma_process_completed(struct hidma_chan *mchan) desc = &mdesc->desc; last_cookie = desc->cookie; + llstat = hidma_ll_status(mdma->lldev, mdesc->tre_ch); + spin_lock_irqsave(&mchan->lock, irqflags); + if (llstat == DMA_COMPLETE) { + mchan->last_success = last_cookie; + result.result = DMA_TRANS_NOERROR; + } else { + result.result = DMA_TRANS_ABORTED; + } + dma_cookie_complete(desc); spin_unlock_irqrestore(&mchan->lock, irqflags); - llstat = hidma_ll_status(mdma->lldev, mdesc->tre_ch); dmaengine_desc_get_callback(desc, &cb); dma_run_dependencies(desc); spin_lock_irqsave(&mchan->lock, irqflags); list_move(&mdesc->node, &mchan->free); - - if (llstat == DMA_COMPLETE) { - mchan->last_success = last_cookie; - result.result = DMA_TRANS_NOERROR; - } else - result.result = DMA_TRANS_ABORTED; - spin_unlock_irqrestore(&mchan->lock, irqflags); dmaengine_desc_callback_invoke(&cb, &result); -- 2.19.1