From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794727184; b=qPFarTKN9DliaZHu+vghREp9UaBegdYpU/AwL7R6mHDxk0367AZ/CGW5oPacRhBICcuB lMA9gjDENLm52ugqP+UcLSeP6WY7Kaoa+c25gQyzjjLbjCJa190L82Adzhk0QqsUbzlAI U952LlINO40rgj4S+3Ci6CpHAalohF54SeffNnFYTkSvqAenKPEWLD0eHlty3uYmUM8Zr m2JT4//wBpu99bnYy+CaNCEaxhcE4dU8GCK+ywmS4PkKFYWMAhpR7wy3a4g/oEvmFaGZl U1OQPQfRen2740D+MIEkLfLBZwjN1R1CYXESzFNY5Z6jOG58GRhEkCm17cZbn6RZ0SQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794727184; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=OS2UBcR5n5u6jJuSGCUmpdlBoEKk3jjjMEO5gyi3TM8=; b=icLWO3IbQ1q4KSw7Iis36VNMmzOhbc52Bpjo35TTLkjEzJSXY5QF7qEmIdiuYWO8+gNK YHlB0oZytdH/Kk/RRZ2LHxpw6WbKNgPOaMpbtEOFws7HgZf2tBvOu7JHAyhPpRqwLXQCH Py+v6mZn24sJiR7bvgBNm2ViHE3Vt1Uavggf7GvfYK51RIdpJu0iIbDRouP0zoL3vXLf1 EW14xD2sJ6EZmFn2T1Ms0Nv+jo6elpBhdSIYZv/eTti5R1zHXYsMTPS9zUaeTxTVIF0no 3nE9W2xBpecMzterSNqVdOAbVZ2ygrSsrHXgBe5VxvJjulfsPuSDp+BuzSB9wv15DLQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Xrz58Soe; arc=none smtp.remote-ip=209.85.161.53 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4FAF606A88E for ; Sun, 15 Nov 2026 07:19:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A4FAF606A88E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Xrz58Soe Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-71acdd32a53so412014eaf.3 for ; Sat, 14 Nov 2026 23:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794727183; x=1795331983; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OS2UBcR5n5u6jJuSGCUmpdlBoEKk3jjjMEO5gyi3TM8=; b=Xrz58Soe6mVRrL1DqwdKRygaPBSGaJEq7xhHj0c++hmICPBmBOcPadHiJWj1z+iT0M dQGFrvd/VdkQRYlAyPbIY4o7oBeUdhO/zV/m2YqENIxD1b5vW5CYkfWySGU5CV6RU+xD xRYeR/oKqtiMa2ScTfRYwFB1IWvgxUk5ZDeoHeJa/uhd2AbKPS43nsDnvGHbYgWb/J1a uOikHHJlCJQgIECMrY5P3J8VulRZpnMAAusb6nqJW451uY73CRYWSEVaQzK0m0EqZ12U M5QEYPeYfeVW94CG1ougP0Ml4QedH+3iugWeKl4BYQNqIJIFyfxPfWW4uWjGURMdwCQD KPAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794727183; x=1795331983; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=OS2UBcR5n5u6jJuSGCUmpdlBoEKk3jjjMEO5gyi3TM8=; b=MxLCFyGMo5zg7vf2cHomSLDkureLGKNngmfwOdmr59Jb47qp7vFNHfz0WeGpRSnz2F j6l3lV09JU8OEMokl+rRF9o0PejoCLCMJFmP8fBN+631iInaK/ukGSYNMWXMnoReAOaG LbFKoIfRUt+tKI10LxISCgG8AjUX+swzmvWIsPuEZ41BKwOZ9+zPzLsN9txsnTYM84KT 34+ZeyxNPrnLmAi/GpFlf4fplbbkTODzt5X8Vy5H8ieTHyJ9FunnA/Y2DN3sivrS5r+G 1UmVGylLw2hsosu1StZ7H/GoiBFEZqyY1s/+Gj9KRztaB7AY96PbWl9bw1XIRlJLhHpA uspw== X-Forwarded-Encrypted: i=1; AL+hErHtLJk538iPcy6+cAFHlDSOFantDFyEr2fUBKTlm5gC6EwGhwUHKhLxcgcYaJp4VWXPw56QBsXMk8WpkqU=@vger.kernel.org X-Gm-Message-State: APuU4Z+Iz19vVMuj6vOYWMczXMZb5hqPzuErIqIer33n61cNilZSdkez foz8NbarzQXIbUuMq3z25a1yP+IFcLzqpxgRG+v65f/ItTlJPsqBxw4t X-Gm-Gg: AYBFou0psQunaXD3eexzST7N6gKxfWyraC+tpbjAIj/omzGfbkteXTYmh2uC/7A9Z49 T/RjYd6ZbsmVeqzGwoizX+44oMrBop7GcDyZy8i7SfdQZDjlnYSIqH8th9lCdcdX/rxohhzHGiE 5nAaBRKvfweSoqRYcupMKZZOPDK0qUCcCsgTxv0BFFFbn23OwTiJgI1pBOzRJU5wsC6z0eJ41Hc hK2ZEyZnLrEWNSFF4YE4cPsOmUS52RVePFr612KSh0+9NA23MYTmcMlAsHEe8O3vB72rMqME6Xx oGdlgoXowjUGwaLMemMj7lrNGIM4xm/QdXSzt/7lUEcT2mTTwQDPIGsWsfijnhoJ7YeHtQZPzIB MFnaNQ36ub3dc6nqfUCGR7n2oKWlw1n/yRdMhV7ffftra/nVJXmOUNK+o+rjzogngPdaBGTGZbi 70HPcuPw27W/FSHonYDmLlXpNB1Sp4nnbvK9UutV4Z2VbVEB5SnkoNxSUilNmqjKjEpxUn5fcvD ltCxIDClOLQdXT8LO/lietVKz601wID462qirKeRNckliEtKvP5K+mckTEJLhXYx6AXOlnb8yx0 zpxLjWs1APZtR5YC++kk++kM8rAN9MvmbnefQUH3k3W4dAMvSfk58xxhOXtKluroCNn2QQa7zkl zxnmcx2i8ds57xVzE3qx/QVf10vFe7CxDr4xvoCw0I1FWRX/gstf8ECFnKYdpsvHJcdZ4WG199y ZavesvPbb14eH9Jnu2JFiGelm6rcqyk9olTyI1+p4opK7D/MJJUnRO X-Received: by 2002:a05:6820:2485:b0:70a:549:292e with SMTP id 006d021491bc7-71ab4f908f5mr3485508eaf.28.1794727182620; Sat, 14 Nov 2026 23:19:42 -0800 (PST) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-71ae860ebd7sm1145321eaf.8.2026.11.14.23.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Nov 2026 23:19:42 -0800 (PST) From: James Hilliard Date: Sun, 15 Nov 2026 00:19:35 -0700 Subject: [PATCH v7 02/10] dmaengine: dw: serialize error recovery with channel termination X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261115-submit-dw-dma-synchronize-v1-v7-2-8d58f3d49e4d@gmail.com> References: <20261115-submit-dw-dma-synchronize-v1-v7-0-8d58f3d49e4d@gmail.com> In-Reply-To: <20261115-submit-dw-dma-synchronize-v1-v7-0-8d58f3d49e4d@gmail.com> To: Viresh Kumar , Andy Shevchenko , Vinod Koul , Frank Li , Dan Williams Cc: Serge Semin , Greg Kroah-Hartman , Jiri Slaby , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , dmaengine@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Sashiko , Lars-Peter Clausen , James Hilliard , stable@vger.kernel.org, Frank Li X-Mailer: b4 0.15.2 The tasklet samples RAW.ERROR before taking the channel lock. A concurrent termination can empty the active list before dwc_handle_error() uses that cached error to select a descriptor. The list head is then interpreted as a descriptor. Even with an active descriptor, moving queue.next unconditionally can put an empty queue's head on the active list and pass it to dwc_dostart(). Recheck the error status under the channel lock and stop the channel before selecting its failed descriptor. Only one transaction is issued at a time, so take that descriptor directly instead of scanning for completions first. The scan can otherwise complete it and start queued work before the error handler has identified the failed transaction. Detach the failed descriptor under the same lock and use the queued-start helper, which leaves an empty queue alone. Clear the software-LLP flag before restarting so a failed multiblock transfer does not prevent the next transaction from starting. Keep the completion callback outside the lock, with the detached descriptor owned by the tasklet. Fixes: 3bfb1d20b547 ("dmaengine: Driver for the Synopsys DesignWare DMA controller") Fixes: f336e42f73d9 ("dw_dmac: Move single descriptor from dwc->queue to dwc->active_list in dwc_complete_all") Cc: stable@vger.kernel.org Reviewed-by: Frank Li Signed-off-by: James Hilliard --- drivers/dma/dw/core.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c index 2a9db9e39f5f..f7ca9da5af90 100644 --- a/drivers/dma/dw/core.c +++ b/drivers/dma/dw/core.c @@ -403,10 +403,17 @@ static void dwc_handle_error(struct dw_dma *dw, struct dw_dma_chan *dwc) struct dw_desc *child; unsigned long flags; - dwc_scan_descriptors(dw, dwc); - spin_lock_irqsave(&dwc->lock, flags); + /* Termination may have cleared the error since the tasklet sampled it. */ + if (!(dma_readl(dw, RAW.ERROR) & dwc->mask)) + goto unlock; + + dwc_chan_disable(dw, dwc); + clear_bit(DW_DMA_IS_SOFT_LLP, &dwc->flags); + if (list_empty(&dwc->active_list)) + goto unlock; + /* * The descriptor currently at the head of the active list is * borked. Since we don't have any way to report errors, we'll @@ -414,12 +421,7 @@ static void dwc_handle_error(struct dw_dma *dw, struct dw_dma_chan *dwc) */ bad_desc = dwc_first_active(dwc); list_del_init(&bad_desc->desc_node); - list_move(dwc->queue.next, dwc->active_list.prev); - - /* Clear the error flag and try to restart the controller */ - dma_writel(dw, CLEAR.ERROR, dwc->mask); - if (!list_empty(&dwc->active_list)) - dwc_dostart(dwc, dwc_first_active(dwc)); + dwc_dostart_first_queued(dwc); /* * WARN may seem harsh, but since this only happens @@ -438,6 +440,10 @@ static void dwc_handle_error(struct dw_dma *dw, struct dw_dma_chan *dwc) /* Pretend the descriptor completed successfully */ dwc_descriptor_complete(dwc, bad_desc, true); + return; + +unlock: + spin_unlock_irqrestore(&dwc->lock, flags); } static void dw_dma_tasklet(struct tasklet_struct *t) -- 2.53.0