From patchwork Tue Dec 26 05:15:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yi.shao" X-Patchwork-Id: 13504760 Received: from va-2-39.ptr.blmpb.com (va-2-39.ptr.blmpb.com [209.127.231.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A8104AF95 for ; Tue, 26 Dec 2023 05:17:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=semidrive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=semidrive.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=semidrive-com.20200927.dkim.feishu.cn header.i=@semidrive-com.20200927.dkim.feishu.cn header.b="TXTGPZDj" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=s1; d=semidrive-com.20200927.dkim.feishu.cn; t=1703567722; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=vHeWsMfM12kuVaIVTOroSE1f22ig5Ahs9GSqrLGp8P8=; b=TXTGPZDjiEa6rva1LVYiPD8bqUM1aKr+mDf5bK1UqrE84gMYXY9GrjVbIr5JfJVtaCduO9 809Tvsg8ZenA3yKQWcx6/0jlMhWmegSjn0G4IGz3ybfe8V2Of9AhSDrBIksiCCo8MSEC2E Lmn/WyAtfw2oVGG0u10Ckgb7UXEfqfI9wWw7pAtrw8kmyaLUv1W0rnTil3dw4rI+Ee4Yuf pEbSfBDcTq/ZJmu2HRtbazdIjBHYHX8Lpf71AVJ8gB2Za+2JPbPKB7bqS0vzjq52eSZO8O Va80dgttR1k5IMMoGvPog6Af0/G/8pk45Md6wxhYFgHQXnaH1BOJ9w0xhld23Q== Cc: , , From: "yi.shao" X-Mailer: git-send-email 2.7.4 Subject: [PATCH] dmaengine: virt-dma:fix vchan_dma_desc_free_list list_del corruption. Date: Tue, 26 Dec 2023 13:15:17 +0800 Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Message-Id: <1703567717-71861-1-git-send-email-yi.shao@semidrive.com> Received: from nj-bsvm040.semidrive.cc ([58.213.129.90]) by smtp.feishu.cn with ESMTPS; Tue, 26 Dec 2023 13:15:20 +0800 To: X-Lms-Return-Path: X-Original-From: "yi.shao" To resolve the race problem when terminating a cyclic transfer, dmaengine calls vchan_terminate_vdesc() from the DMA terminate_all function. When configuring the CONFIG_DEBUG_LIST macro, it detects a list corruption error in the vchan_dma_desc_free_list function, displaying the following message: "[54.964702] list_del corruption. prev->next should be ffffa0001395a0b8, but it was ffffa000180a7950". This error occurs because the virt_dma_desc remains in the vc->desc_issued list.To resolve this issue, the vchan_terminate_vdesc function should remove the descriptor from vc->desc_issued and then add it to vc->desc_terminated. Signed-off-by: yi.shao --- drivers/dma/virt-dma.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/dma/virt-dma.h b/drivers/dma/virt-dma.h index e9f5250..eee97d2 100644 --- a/drivers/dma/virt-dma.h +++ b/drivers/dma/virt-dma.h @@ -146,6 +146,7 @@ static inline void vchan_terminate_vdesc(struct virt_dma_desc *vd) { struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan); + list_del(&vd->node); list_add_tail(&vd->node, &vc->desc_terminated); if (vc->cyclic == vd)