From patchwork Fri Oct 23 18:42:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3703 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 522311C010E for ; Fri, 23 Oct 2026 20:43:12 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-26823-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-26823-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id D6BC634DA4 for ; Fri, 23 Oct 2026 18:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792780965; b=xt/kM8a7+Ct8Qzk16kG4+ZF5Oc9TTax9Xz4xmpAKppZFfQTo3tqEfscMNurEo9BBhAcn wI6sAVeW7b9Yw6a2x+s/dZ6/ZulvDyzlybglQiiGn/nsQtTRmd0tYDjhzli/O3RAUaUMB q0Tpf3pr/FKpH0elhgK6vkgVmz6W10BQaV+UDH43feMY8xK3JTj54uIrrZglw53mnCQZN IhaB3eUZZ0TsUvKbhosAlku8trolla7El9hafntluKwn9BZc3hgCN2rQSsVJ1e4yKqGA9 HZwPdJiO3hBuaoqlMuguJbLSm/8RMub1F6mq9sx2wyNxsRgozJW9doWR0e9JuSvYXkg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780965; h=X-Original-To:Received: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:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=Yi+Mby52IcSMxw6Bb+wKdKUkb+i4YW8eVg++kxowvr0=; b=k1vOq5m7EnNuwxyQT1TjbGC0pUml6IeISLuyXjllDSivc5ITFFspShYzPprTw1SXV8Pt rwwhBp+4AdplhNbuonxo3iArXGjp3EEOJH1EQVVY64Woh4pn8v9I0gwsTwEXhXG61i7dZ OjtPXsNeqOjam3RqRT6PUDBa8I4lNYSqUMocrlMfcd1rTI4ciFYQ9d2mgrFIC0kS/3PLv +UMd8xfNMN0RWRYkXrMgmdow1cQiG5WZmThbVTC+difFM6rOD7QAaZiAR+eKJPNlj4ZV9 5xBoCmH1QbKfv50HXoHmAb8oJUJcWrJe2FmH8DyXK4x7J2m1V5gPcYVYrJXlk9X/Cmw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=lxuKGAZj; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73172606A336; Fri, 23 Oct 2026 18:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=lxuKGAZj X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792780965; b=z9x+exk5smkrbLF13HHKKrlzGV6/W5JGE3UAoFRykk+TSEtMGj/GN5rs+rSxcdG0H8zo kWc/DnsPgqvXPyUwXeNXtEQhHe3dDkZdDIH0uv7sxxBvaU7EzydPrA65AATmLT5o34kbp /fAXahpiRFDGULcsToOfJ/ircPpsDWcn0seofQTHXfP7lEOT1Ut7s8kUrtWDCUYNqxV0S parqlbKShOwGPN2aA16yxHFw59A7+00Ia7FiWAx2MLCbgKj/DOY4yiJpUPJQTEhrtgOox YvxkpDCbDkL6x2QebqJJfcdXwAYOlhOveEQOpSG92+Iu8P7TJN9o/Ud37RqrpSFHITw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780965; 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=Yi+Mby52IcSMxw6Bb+wKdKUkb+i4YW8eVg++kxowvr0=; b=UaNgtQCXMCpf4tqGIcDN6815Vd1avMdokOvvvi8y07BQBapAg7319gvgAmxVMuu2Zmc4 bkbhLBATELBRRglVvcntq7pKr6gmt9fdmzOs1UFopEqDd1ruSjoyYBg3W4f+XUUuwfAeI aq6ysna45ev63CLvoWTKpDLlLDzdINWq47kiCn30MsCmZptI0E+TIDgFH1sA7W+M1tLs2 PO3vG8EpEzZfNMnDPHzOR2HCv4a+RvqxItpVdCXsIPl2w1oFVBUp1IFdw1dx+zde5CIlM ssVwhzbQVCOWngEYqyggW6WTCGnUZGeQ8tkTtC4/STAGkr3exipTbcGoLnhBeCUNAWg== 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=20251104 header.b=lxuKGAZj; arc=none smtp.remote-ip=209.85.210.44 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 B5DC6606A325 for ; Fri, 23 Oct 2026 18:42:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B5DC6606A325 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 Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-847ac7ccd85so736859a34.3 for ; Fri, 23 Oct 2026 11:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792780964; x=1793385764; darn=lists.linux.dev; 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=Yi+Mby52IcSMxw6Bb+wKdKUkb+i4YW8eVg++kxowvr0=; b=lxuKGAZjzNzYQNOTUDNSscESM1RYZ6xzs6V6opZcchEptyyNBUWX3/wXMUP4EWUybb UYadYjUzok5TQnfVnQfvDQ02W0kLXU64Hsvmt1VSyTiY8Le8uBw1986JmNaEO5WYT1Uq VwNu85rtnPNUjj/eoMgZqg6nse0kTcOtD1gI5az7zktrRctesGYkeUueHoIR9Ql5FTDb JMYunq5v5R92y7oawKisCMIHo2lhctU5iUu8xpSHh6axjTZX1DchEtAaECXcNcAyFnOY Bj1wmKCOsjP5dbOV7JytSwL9CvshE/wHjFDOM1v17hpmDeZ5w64I1nxYiFADAlIImw4d IUUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792780964; x=1793385764; 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=Yi+Mby52IcSMxw6Bb+wKdKUkb+i4YW8eVg++kxowvr0=; b=qoXgfTzb9PEx2+izy00AyzJvUoXsqF0DxuG3VXFOTLY/GdHyC2e4ZLRzkm3FRKF98U bIY7zp0nKWbR/k9CpshwnV0yfIm7PMypzIWxmJzRFhmz1NzO2zDb+YDgiehXsSHTV3Aj iXzdfZZbxAbMtrW6lzWC5LlRzyn4pfEPdTgHL532j3l8WtuuFf6+avOPAncnmbJnpDeZ cC9nJveEPHDrP8DCqF93hiyPV/p+oLGI6r+SycohxXXKEsRb3O5YThD2S8+VQzllY4aW 9P7yoMM2sUyXMAxOH7wRXDpEVfX2X5P7FkXbt/s/P4Qy2wcxL3tIalZyQq+ygmKe9Jrx W1gA== X-Forwarded-Encrypted: i=1; AKwUvBydpiEVVCLX/+CSImLWycsRHNMAhq2Rp+z23FbUQ+TUSlrTdAER3qWMrBPa/6REEo7o6TB41aSXY2D1GQ==@lists.linux.dev X-Gm-Message-State: AFq9FYJeekEpI2y9OC37GH+jNf/9vpBFYFP0/1f0IZhwqhB+0sgjZqf0 2pSydhHGGSf8sNHumeMTRIwxTZnsh7wdvEkHDaHKZrH/STlsork2MLmA X-Gm-Gg: AYBFou3docYRaOTUPWLjLEjfq46eMMr2qvDtl548UtaU7hsDHKQvEmEFOKVkaiwDGuf uVIV73OPZ8B49uObxf0VYBmd8AKhQMnnXSXsgEXpZSpL5ZUCDPVlIuES5BPtSzO035Wa3Rpm8vZ ob5Iqy+UkHuvoyISnvMJ6WM+TA5i2brGiAljd1U2emzTOT9TakZx9WoPpj1vonTtQGHah4SNNa7 Q1q4rPHViIGV0tVMmG+A0Dfc0QC3tjSSs0PILKj9lmHrQ2ebtAvEB2hp+8rPnufIP+l0cmSaEHR ynme2haZC0heuKYUGqaHMcZxvvfvzdipNo7W/3jMY94NFwGXX9LIx5XaUBX+WsQyAFSHNhSkMqs kEDW7LSwG8m6y1KMsyqQR6nCi5DjUtqdXNPFYVy+bFHwYIwrOr8lMpInE869/MCbe9TtEwsjWmn EdG1tWje8F6ymKdWMSzVp8cIRnAZGx9tkvaj9ki5O/R3EkERWpwdSgsDSCdXhJ6HhwdugNhdD0p 7NY+8UeTG7c5urTKswfEtkWIAM1BifMRZFVA9c+W+polvydTTC6iQciMWRlCuby7WW7bRo5LY7I MEHXk5eaI6cyrYutn5dcwzQokCGYGjNWpIL5qmYHFAuHcuMAWGjGKfAe4+pUM3FlQWKwJ349SvA uYitkIMD29C/U8bS55NU0XKs48p1HwSDY4v0ItuZIcoNWh292f7Ec1+8atQXsolqw0N/rHwkS7f h36Q== X-Received: by 2002:a05:6808:30a3:b0:4cb:818f:d56e with SMTP id 5614622812f47-55c0020ff8amr68675b6e.22.1792780963715; Fri, 23 Oct 2026 11:42:43 -0700 (PDT) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 5614622812f47-55bfe199544sm336682b6e.13.2026.10.23.11.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2026 11:42:43 -0700 (PDT) From: James Hilliard Date: Fri, 23 Oct 2026 12:42:35 -0600 Subject: [PATCH v2 1/6] dmaengine: sun6i: fix physical channel index in interrupt handler X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-1-c9e07cc44bf8@gmail.com> References: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> In-Reply-To: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> To: Vinod Koul , Frank Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Arnd Bergmann , Maxime Ripard , Jens Kuske , Jean-Francois Moine Cc: Hongling Zeng , Chengfeng Ye , Nguyen Minh Tien , dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard , stable@vger.kernel.org, Frank Li X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.19 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[nxp.com:email,sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns,kylinos.cn:email]; FROM_HAS_DN(0.00)[]; FORGED_SENDER_MAILLIST(0.00)[]; RCPT_COUNT_TWELVE(0.00)[19]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FREEMAIL_CC(0.00)[kylinos.cn,connect.ust.hk,embeddedlinux.blog,vger.kernel.org,lists.infradead.org,lists.linux.dev,gmail.com,nxp.com]; TAGGED_RCPT(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; TAGGED_FROM(0.00)[bounces-26823-noreply=patchwork.local]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10:c]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received,174.29.1.49:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; FREEMAIL_FROM(0.00)[gmail.com]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 522311C010E X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: Hongling Zeng The interrupt handler iterates over register banks in the outer loop, but the physical channel lookup uses only the inner loop index. It therefore handles every bank as if it belonged to the first channels. For controllers with eight channels per bank, interrupts from channels 8 and above are routed to channels 0-7. On A733, each bank covers one channel, so every interrupt is routed to channel 0. This can falsely complete descriptors for unrelated channels and corrupt their data. Use the absolute channel index, calculated from the bank number and the controller's configured number of channels per bank. Fixes: 555859308723 ("dmaengine: sun6i: Add driver for the Allwinner A31 DMA controller") Cc: stable@vger.kernel.org Signed-off-by: Hongling Zeng Reviewed-by: Frank Li [james: use the configured bank size and describe the A733 case] Signed-off-by: James Hilliard --- drivers/dma/sun6i-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index 8752969366ff..9d94a37fcf10 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -603,7 +603,7 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id) sun6i_write_irq_stat(sdev, i, status); for (j = 0; (j < sdev->cfg->num_channels_per_reg) && status; j++) { - pchan = sdev->pchans + j; + pchan = sdev->pchans + i * sdev->cfg->num_channels_per_reg + j; vchan = pchan->vchan; if (vchan && (status & vchan->irq_type)) { if (vchan->cyclic) { From patchwork Fri Oct 23 18:42:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3706 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 806E61C010E for ; Fri, 23 Oct 2026 20:44:54 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-26826-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-26826-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id C38AC307AE for ; Fri, 23 Oct 2026 18:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792780972; b=Rpl1C4pJe26rcMgytHE98KslyjJ4HDg/mv+WAr3VuqqPkACCiMu0JzyjThWUCl0wmBQs cV0HOxroYWmyiJ5+MP9Qswtp4ApaBT3PCvWw1opZ3cwaVD5oVHns8Zp/3x0FzUrh051Sv S456aEdjA/3BPYf413F0vhWQJ+9PY2hptTyrlnx33j9/DuzqP3mfLRDtgwCDVJyorWqP3 adwvcmDjpiJfAzB1C+356Dl4XWKY+f84XYRn/eAQI/JvIeeAyafXd/lTGAzpPQMK6+DJL LNB+I2S7OJ+mMCeJOAzM/vRgXdVn+g0QEjqQ7TtqcweAoFM31eQxBqHJSRccN2yPxZQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780972; h=X-Original-To:Received: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:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=M4PRNLWENu8KTspo6tzX21p33JWmvMwO8+MOa0PXQoA=; b=sLIxOrR2+4KCHtB5dSS1Qp+ghiRLE7vavt8DhpzFse7KPel0TKlRMkQsbQ5yc9Vgf/nU 2jXauyQYrQz3B0jQJoO6oHbH6vZbtIZE3f/V7A7yvti7V8OGakdyffuesizZzI6VG5eQq j9pF36cR3I4p6AxSTJTI4MdQFMuKXDu2qZfL4ta1C0lkVta//TwWIMOi7ba7zYixm+i52 5bBayrL82c81ENT6cN+vJsXawP3M/oEA5ufscL7Y7v5Bk723GfJSoDV3QDKJYmGsyPmbK kFw41ewR3K6f9r5LjoRZwmM08XTj72FPnECkJCO8Hedx6sf71rF0fV9n35HhSXDhzng== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=cEnpIv0q; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2793260A2604; Fri, 23 Oct 2026 18:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=cEnpIv0q X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792780972; b=T1/qux8KW7P6aUlmLXBOvcQZTmys7YFT6L0shjZje4MRWMcm2IR4nOnvBOfZwA3NsDpA VEyUax+D9m41N6yoWY+UYIbz9HIGaM5PaiONmimQntbcxrevscBmQr2TA/z5LgnpGBL8e n7jj8LVZplmyDwvW7Fe5ZxtToINHVVR1cKz2SijIeJDX7AY/sfc1rdecrmA/I6sueu+er sJ6GX/T/pzX0aE3IfvXEU0rFtOB9JzfXa9bJto3mjVyScWuSaSGLpUgF3Av4NFPR1nrP9 +I8gJPaZHVkd4M+lBsjmXbcB4lQw+AnG3D7zHoWUFVlXegSBHTNwb/t3d7dnGsaAeUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780972; 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=M4PRNLWENu8KTspo6tzX21p33JWmvMwO8+MOa0PXQoA=; b=JHbBfJv2dw+ZjfE94wikfSLMYzTyb70ckUe+BJThPYfCtxP2aq5XSNAcqTCHbd/5qBph 7YITHAv/l6LiN+CUE0NoF5Jn0YDIx0NTT+YxZihzmA7BJEJmXXK2SA148a71cmMolMS4Y e2Oanc3PIv2JdLront9MG4oA+PqReN+KPy/D4tmvp9eVV+hXEgGFuDy1Zm0uZJGAUa3Dp 3yx+GSmW8DhfkkS+H/lcskObMTeeu7sYd4p16nBfJfyodLCtLKhllvayRvHKs1tC48rxp LJoIOldCjgpyWrOZPELaAuUcdeQjSmt6sOUSfh3L19fWp2p3G0HAMvJGsDGLvmtN5/w== 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=20251104 header.b=cEnpIv0q; arc=none smtp.remote-ip=209.85.167.169 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (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 50B19606A335 for ; Fri, 23 Oct 2026 18:42:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 50B19606A335 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 Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-4f488ba6e90so302004b6e.3 for ; Fri, 23 Oct 2026 11:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792780965; x=1793385765; darn=lists.linux.dev; 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=M4PRNLWENu8KTspo6tzX21p33JWmvMwO8+MOa0PXQoA=; b=cEnpIv0qwqz0t0fBhWvl0DYyJqnpHLAAvDyC3Es3sI/X4ERPieDgNgFxzMvH8HpJty opWXRTAhZeb1ThL41T1gqK1GSGWO0E0PDg6gxpV4Kze3xSERjmbtBNdOEac9a0qBNEr5 ejHnFP29sQ+ISlnoFrNO8eVs7jHQ8YIerYyWn2/9XwB05HmcgcOrI676Zixh8ESeCbah Y9Y60rUXUYEhlsVnteTXyrHp0SmVSxM+wfzx++3uxc93P/YMz9i059y4+hbSXjOm2TXz BmuR9vKzWR3rz9bWmDjNL/Be1jZYq9asucrBh69mgakoT1CJVcLmpznJPCjeV1b2UfNQ TYEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792780965; x=1793385765; 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=M4PRNLWENu8KTspo6tzX21p33JWmvMwO8+MOa0PXQoA=; b=vyjZSdnxjX0IcuGb5HasmQq1ByjE09FwH72jxm7O01q/zQ/tqfFy1C3rEQmVgj1m9P itztg3MWU5zyqGDFKz0awj1AJuF/cZtwlYebyyXgDHpuLTlwNjEFA3cSRTwB9eT6vCoz csn3Q51lDaZiCJGcDbReYtX5QQt0iCXy5h8RnGXaTjBMJy7QFTu+SsYQ7DkG/UNcKIde bvw+FVvZrN+9rHLYxlKILgtdJJjwigmTDTLM7LxERFYQLgA+fur7F1RR6e7DyIA7NAsM 39iZO45SRz4j34kt75+ZQp3KtxigXNna1j+cZ0gnMLtMCUnOZTHRIJEiGwLEcGzb9oFN kpbA== X-Forwarded-Encrypted: i=1; AKwUvBy8T4gqOpXJyCYr+oCb4WgKPH/2AAbdUBJ7TOWSE2e+jpOCdtiZRUNHeIaYNFAg9Ql/eIhlwLpa2Kdp9A==@lists.linux.dev X-Gm-Message-State: AFq9FYJ/Ocm6I9CbsAuf6i4lcbIeXTB51W/mB6k2aN441fZCTHm09bVR Vl1FM4OjnvyhJhLvx5zbbK5LHxGSsSw31NN2pnhzilPUlx6JZGeUQnRL X-Gm-Gg: AYBFou3fQpf/gX/Y3KsIoss1DhstdQj0gADTpH375VDKpr00/lsMKQ+eW0oE/1/glnK C+ui/mNalxySi2FKd6diCG99v2m9dLul5zQKxRSElc8M/YggG0eNp0sYS2UKVIBJ6FUPrs/+qzv EaKd7Ey2tEyIgKwPFbA2VfPw0YUsSzWOruoyJpWeqG91EkzSXvhTWgIVhcME9/a35Jo6jY27CeK 5Xx3T4us7fa8pCWDbwp0eDYMAOthQVx/hjBoPNxfVB1Zo9/EANNq/oM/G/cgMVXc+9UP3m3Xcf3 djMF+N2ArHi2t5p8K1zZr7dFL3z4e/lLQ+13ukDibJiI+vOCd82sEYsbUArAN5F1zp8YOL3BBsI F3qAND6eRTqIZhi4l7PdlCXjykIdltR1oY4mTOkiW7Ab2Ddl2PNqylR1e+EbNOF/GzIh/sATH5k fvsAMz+T78ymYM+mLTFBW3McLQhLwLzKU+4c6TZij0sj25A0yQHmbiLk4UO4WIRMRbxjJEUeZRN 7k+RXAqG1NCeKCDF80e7f7itnNGGLxHTllKcipjE/GJGDghmt1SoGSgsz78TlwNyYLu4iJ/ZGZ4 ONUotdE//4yLgGpSp/Nwa9enObtOjvT8tEHficQ0EO+mROMzllYhBfvEfkgn4BJUvq6+MlyfsM4 C+g5XuxjP+naN+6Sv9cqV9PKWvHql81NIsfEXixjg/PQIPXgaQUo99EFw2HRJ90U8R2ZCvuN7tO 4BiQ== X-Received: by 2002:a05:6808:1819:b0:539:596f:6623 with SMTP id 5614622812f47-55c0035e613mr53516b6e.64.1792780965312; Fri, 23 Oct 2026 11:42:45 -0700 (PDT) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 5614622812f47-55bfe199544sm336682b6e.13.2026.10.23.11.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2026 11:42:44 -0700 (PDT) From: James Hilliard Date: Fri, 23 Oct 2026 12:42:36 -0600 Subject: [PATCH v2 2/6] dmaengine: sun6i: handle the last partial interrupt bank X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-2-c9e07cc44bf8@gmail.com> References: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> In-Reply-To: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> To: Vinod Koul , Frank Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Arnd Bergmann , Maxime Ripard , Jens Kuske , Jean-Francois Moine Cc: Hongling Zeng , Chengfeng Ye , Nguyen Minh Tien , dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard , Sashiko X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.19 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; FORGED_SENDER_MAILLIST(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; RCPT_COUNT_TWELVE(0.00)[18]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[kylinos.cn,connect.ust.hk,embeddedlinux.blog,vger.kernel.org,lists.infradead.org,lists.linux.dev,gmail.com,kernel.org]; TAGGED_RCPT(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[174.29.1.49:received,100.77.114.92:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from]; TAGGED_FROM(0.00)[bounces-26826-noreply=patchwork.local]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 806E61C010E X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= The number of physical channels need not be a multiple of the number covered by an interrupt-status register. H3 has twelve channels and eight channels per bank. Rounding down the number of banks leaves its channels 8 through 11 without completion handling. Round up the number of banks to visit, and stop processing the last bank at num_pchans so unused status bits cannot index past the physical-channel array. Use the controller's configured bank size for both limits and the physical-channel index. Fixes: f008db8c00c1 ("dmaengine: sun6i: Add support for Allwinner H3 (sun8i) variant") Reported-by: Sashiko Closes: https://lore.kernel.org/r/20260706065650.34B131F00A3A@smtp.kernel.org Signed-off-by: James Hilliard --- drivers/dma/sun6i-dma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index 9d94a37fcf10..0a9645171180 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -587,12 +587,13 @@ static void sun6i_dma_tasklet(struct tasklet_struct *t) static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id) { struct sun6i_dma_dev *sdev = dev_id; + u32 channels_per_reg = sdev->cfg->num_channels_per_reg; struct sun6i_vchan *vchan; struct sun6i_pchan *pchan; int i, j, ret = IRQ_NONE; u32 status; - for (i = 0; i < sdev->num_pchans / sdev->cfg->num_channels_per_reg; i++) { + for (i = 0; i < DIV_ROUND_UP(sdev->num_pchans, channels_per_reg); i++) { status = sun6i_read_irq_stat(sdev, i); if (!status) continue; @@ -602,8 +603,9 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id) sun6i_write_irq_stat(sdev, i, status); - for (j = 0; (j < sdev->cfg->num_channels_per_reg) && status; j++) { - pchan = sdev->pchans + i * sdev->cfg->num_channels_per_reg + j; + for (j = 0; j < channels_per_reg && + i * channels_per_reg + j < sdev->num_pchans && status; j++) { + pchan = sdev->pchans + i * channels_per_reg + j; vchan = pchan->vchan; if (vchan && (status & vchan->irq_type)) { if (vchan->cyclic) { From patchwork Fri Oct 23 18:42:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3707 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id E71171C010E for ; Fri, 23 Oct 2026 20:45:12 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-26827-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-26827-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 83B5E3B6CD for ; Fri, 23 Oct 2026 18:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792780973; b=NawPyNbgjf+CRk9HVCxb8VmBP0T/wfz6ZknBcsNlt1OO1N3OZUo3xSJ6dParoLkczvWT tYp83akVKMKksVgZ4p4KFpxG5W0cMdfphOvMtfLjcVOMT/d907NZggbeXeGKcmxkLoj4R dcUN6q37TqP0v4FkrGuHAZszpyOyD/5L5ZByRyAdeFuCU/Q4CiAgZrL6zSo6bFdPQGMvv UOLMfaFZzQTZsClQG3OYVBSwr99/76pJ8ZgxL1r4fwIINO+kpi/Yg3nydk0146bfl5GSk gqc+MF9rwpwFvQLrzYLTmX7afCyWrybSnNlfLuNWlpz3mGErsoG/EmrdedmNcb6og4A== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780973; h=X-Original-To:Received: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:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=ajRh/8q3xGrAtR9/oKjXRIyuCbzBYMEpU+B4J/2GtKQ=; b=WILsRuQewhnvDOqRoE8xOQ6CvtSmnXhbCRPvF6uW47dOF1BLQFET5ugE9qr1Uy8Grjx0 uAGdjkn3yUNMRQzStFkrkfaXS/j7q4fTvm/gtDFhJz/2y1Jyx2Lhb3I6cKdFGyfrPtxlP rSIU87z3qJpYaEudMe73udcaqVqWWiQTzk7IZ8UwdDBAvLB9epze4FVwkjj7jL+utMtQG RQolx6KLDKR/XFlvrBGVh1/oBUFNZpk1TwNzEtsOhjLKX2AKsLJCmrsYCNnAmelz/Il1q lOydamOJgpYbtPJVrcpLcLiI49TlnEVi6J0395ubKK+p3S4wIMNEpG1gqbNA8oYpIVQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=p4QVmmeW; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E4B9606A338; Fri, 23 Oct 2026 18:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=p4QVmmeW X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792780973; b=sJv6CQtYv7Z5Z1lm1cwLAAkoix+jSaiuKqLlzgwsniowL+5oIntyKt3akmYTMD9vKp1j WtQCg7nU5eyDSXXoAJRn7WXk0cO67N7htOoLQZ3Dl76wlgtrBpDi3RZuywjrDtnhfhgq+ 3PnNzESEZwoNZc1HM4cYp4vgsIz9rGmgHCIOW1lCCiyzHmZX8ttx++FCkiwq8K9+QoqaU WhSI4YG6lxfd4KFSuKA9XA4rIuDwTJkeQJIZPxMq6ymZuH6x23dvKwVSsP8RQ51W27NNu rRnGPKZBQ5xLp2uGxuwit8N+/vWVr8Gbz6k8QpnHwyOFJj4cRhNhqbBjpkpHuxrgQQw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780973; 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=ajRh/8q3xGrAtR9/oKjXRIyuCbzBYMEpU+B4J/2GtKQ=; b=X1q3QP1exXszmwe2apOOpD9AZeZWGS4iOnmsc83hrZjwhHYFqEktry4iB4S1AE73G8fj inBaTj2rCGtoNknEEEdlJZVvFviAMlXknFl6g+NrLIsM8tUZ3yq8CbwHkTFkGg/NUzeLx 7lLVj5ugalzqCZksv8RVdVAH57ysW0hWaIu76laSCYhf4L+2sx2ONpLg5Z4B7YxKBJS25 rhUgtNIOuJT0yv7BevwoccAEtzUDDlplWcy/occH3CMDnb8pyXxaZQpNdcPqlqjF/WE80 k8XoEVrPwDViJTZoSof6cTKni73XYcEHo8SeOGFhGA0ZzgvHt3rHWHu7jLFJcDYSCwA== 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=20251104 header.b=p4QVmmeW; arc=none smtp.remote-ip=209.85.210.53 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.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 27C9460A260B for ; Fri, 23 Oct 2026 18:42:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 27C9460A260B 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 Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-81ae6aefdceso1016740a34.0 for ; Fri, 23 Oct 2026 11:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792780967; x=1793385767; darn=lists.linux.dev; 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=ajRh/8q3xGrAtR9/oKjXRIyuCbzBYMEpU+B4J/2GtKQ=; b=p4QVmmeWA3HoRS3ZHf9XOiidHzkOymyfCTYP0+v9B2SP5kVu7wDSl+mqsRm/PfIKcR SkwdicULO0WpU2ptwo+CysWP0SSwzlCvgToSrYOXCGHmdhwSbzrTocDZIzhh9PLG6Jq+ gDdvTbVNaTF4bK/oy/WVOoh9W52cDhG+24EqExxp0T6AL3mgLuQ+dUHPhlVNKpDwP8US tlrzKMxcOBjT6+eeWSOpeScqJzfXQy7ScZWpS5OojxgqplFwN1X6dK4yb6ysrBJ1a/Xr x1UAed4oopv1fBJxQ4HEtYRuHcSS5iFfz2XLCk/Nxijd+/Y7WMcflNG6Q7HXbAHAPu8Z Tlmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792780967; x=1793385767; 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=ajRh/8q3xGrAtR9/oKjXRIyuCbzBYMEpU+B4J/2GtKQ=; b=kv5kZnzBXoYTyUAjQME4yI1041zVB9hGPfGNDmf8OOcI/iuU/vFBb08snBlhVyaTdy jN/c6WJCXwSjr7guFHGF5HCxKJkHkC1wvCuTFGX/G76K1nC3RVQs2dD+ds+JNFjy6PWJ XC3u69I3pzkcVDgN0yH+lnsjGaOcED9BeCaK3v18vdlEsONpyjrPbfOmKg5DEtAIQIxa 38aeBRE4uyNQh+x0oBsKAxbcz3rXQQUYCgKeXhi8ZnHkZh5ujNJmGPlc/e/P058+6PF0 fu+zMsEbLmqXbA4IqOXMKPvzAIcNmkJq5HAgL3wrQ8c72HKQQCEkEvF8yDeBJ94LHpsG ftCg== X-Forwarded-Encrypted: i=1; AKwUvBx7JmRtlAouIUcTlViYqsAZH+lzEGrkHTdw4xn0ATyeXi44pk18DUSXOIcsw1rx/SEAvSe0nFAnaKQskw==@lists.linux.dev X-Gm-Message-State: AFq9FYI61wGNt0wf/FvjI7GDCH1688cNqcOQYFYDuR2sFC8AZ88E2jE+ 8mON9RHP9p2YMxqQB2uiO//f8APKUDOM5+wg+53+QEXOD1D2VDI8BYnQ X-Gm-Gg: AYBFou1cxZguxBKk+tNJ8wmnFhoBr7boelnztfg//SqWgV2Ec/oVoiTympiKw5y8qQ2 +Hdchyi0v15NcEifjv/xQPWvIAmHG64WYs3OkslZPD8WTIC2Kq8DtR+fmridridG5ei0sRwFgt7 fxjDd4mS1uPt06LHRGWUHfJ+G9bAfSrZcBzJq+xV3ZYBIEyrE+kAOsQVG/bufjX6FBjnDK+MA1Y 9+U9X6DD2WetPfKQehJrUKRU3SSW7o/t94qgHiVO5fGGoyLPfAtBBGy8DvVMwT59uVCugdRylxo MD8ScaHWBvU7zUnnqYC9F+Cc6S1vAulro6lMtGpi4So+oI4kEnVJz/vib3xQZ24gP5bBmC26wwf ruWTBGouEnrM4GQiyQhWS9P9Fywqts2apRu6BZ+n88jfckUlTfpmSuJnXjgBNg/iAuc0v9GigGk 738CQNulYY0BA1iIl/boK6DA5643ffpDCdAzxJ1NTkfVb27nSE5TnY74iUyxPnjmr/G1mo17O7J tolQHQc+cO5IChVHqUrVbk6K3CJGtgW8SeRecXlSIVLv1xh3nO53eD0oPAH+ZURFzKm0umZVBdQ TX+PVxc6BJZO8cHX4mcHe1eh2vPxg/O4u6aqd7opeiAZwu6AFbhMkvAZ+99dntIRF6FP2GD3iwz xvRGRtKcVgFVraHJxRENu2oT2yfbNRbgAYUqd21ILk7NPYHBvI4mfQU+ss/DFZTg5hpVpqUi9kO 2OpvRn7RIrNKFFSdfLLrvjRY11 X-Received: by 2002:a05:6808:198d:b0:4f3:68d6:f0dd with SMTP id 5614622812f47-55c002f88b2mr60849b6e.38.1792780966700; Fri, 23 Oct 2026 11:42:46 -0700 (PDT) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 5614622812f47-55bfe199544sm336682b6e.13.2026.10.23.11.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2026 11:42:46 -0700 (PDT) From: James Hilliard Date: Fri, 23 Oct 2026 12:42:37 -0600 Subject: [PATCH v2 3/6] dmaengine: sun6i: serialize channel reassignment with interrupt handling X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-3-c9e07cc44bf8@gmail.com> References: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> In-Reply-To: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> To: Vinod Koul , Frank Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Arnd Bergmann , Maxime Ripard , Jens Kuske , Jean-Francois Moine Cc: Hongling Zeng , Chengfeng Ye , Nguyen Minh Tien , dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard , Sashiko X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.19 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; FORGED_SENDER_MAILLIST(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; RCPT_COUNT_TWELVE(0.00)[18]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[kylinos.cn,connect.ust.hk,embeddedlinux.blog,vger.kernel.org,lists.infradead.org,lists.linux.dev,gmail.com,kernel.org]; TAGGED_RCPT(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received,174.29.1.49:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from]; TAGGED_FROM(0.00)[bounces-26827-noreply=patchwork.local]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: E71171C010E X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= The allocator changes vchan->phy and pchan->vchan under sdev->lock, but termination reads the physical channel before taking either lock. The IRQ handler also takes an owner snapshot without protecting it. Termination can therefore miss a new assignment or detach an owner while an interrupt is about to complete its descriptor. An IRQ status snapshot can survive reassignment and be applied to the next transfer. Use sdev->lock for physical-channel ownership, pending channels and the shared interrupt registers, nesting vc.lock inside it for descriptor lists and cookie updates. Allocate and start each pending channel in one critical section. Read and acknowledge IRQ status under the same outer lock, and protect cyclic notifications as well as ordinary completions. Clear the active descriptor pointer before publishing finite completion to virt-dma, whose tasklet may free it independently of the allocator. An assigned channel without an active descriptor is ready for the allocator to start its next transfer or release it. This replaces the completed-descriptor pointer and keeps residue queries and termination from consulting a descriptor already handed to virt-dma. Mask and clear a stopped channel's IRQs before releasing its ownership, and clear pending status before starting a new descriptor. Schedule the allocator after termination so other pending channels can use the released physical channel without depending on another device interrupt. This also keeps process-context acquisitions IRQ-safe. Client callbacks remain outside these locks in the virtual-channel completion tasklet. Fixes: 555859308723 ("dmaengine: sun6i: Add driver for the Allwinner A31 DMA controller") Reported-by: Sashiko Closes: https://lore.kernel.org/r/20260706065650.34B131F00A3A@smtp.kernel.org Signed-off-by: James Hilliard --- drivers/dma/sun6i-dma.c | 124 ++++++++++++++++++++++++++---------------------- 1 file changed, 66 insertions(+), 58 deletions(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index 0a9645171180..a21acb9ecc27 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -198,7 +198,6 @@ struct sun6i_pchan { void __iomem *base; struct sun6i_vchan *vchan; struct sun6i_desc *desc; - struct sun6i_desc *done; }; struct sun6i_vchan { @@ -217,6 +216,7 @@ struct sun6i_dma_dev { struct clk *clk; struct clk *clk_mbus; int irq; + /* Channel assignment and register access; nests outside vc.lock. */ spinlock_t lock; struct reset_control *rstc; struct tasklet_struct task; @@ -486,22 +486,23 @@ static int sun6i_dma_start_desc(struct sun6i_vchan *vchan) if (!pchan) return -EAGAIN; - if (!desc) { - pchan->desc = NULL; - pchan->done = NULL; + if (!desc) return -EAGAIN; - } list_del(&desc->node); pchan->desc = to_sun6i_desc(&desc->tx); - pchan->done = NULL; sun6i_dma_dump_lli(vchan, pchan->desc->v_lli, pchan->desc->p_lli); irq_reg = pchan->idx / sdev->cfg->num_channels_per_reg; irq_offset = pchan->idx % sdev->cfg->num_channels_per_reg; + /* Do not deliver a previous transfer's interrupt to this descriptor. */ + sun6i_write_irq_stat(sdev, irq_reg, + (DMA_IRQ_HALF | DMA_IRQ_PKG | DMA_IRQ_QUEUE) << + (irq_offset * DMA_IRQ_CHAN_WIDTH)); + vchan->irq_type = vchan->cyclic ? DMA_IRQ_PKG : DMA_IRQ_QUEUE; irq_val = sun6i_read_irq_en(sdev, irq_reg); @@ -524,15 +525,15 @@ static void sun6i_dma_tasklet(struct tasklet_struct *t) struct sun6i_dma_dev *sdev = from_tasklet(sdev, t, task); struct sun6i_vchan *vchan; struct sun6i_pchan *pchan; - unsigned int pchan_alloc = 0; unsigned int pchan_idx; + spin_lock_irq(&sdev->lock); list_for_each_entry(vchan, &sdev->slave.channels, vc.chan.device_node) { - spin_lock_irq(&vchan->vc.lock); + spin_lock(&vchan->vc.lock); pchan = vchan->phy; - if (pchan && pchan->done) { + if (pchan && !pchan->desc) { if (sun6i_dma_start_desc(vchan)) { /* * No current txd associated with this channel @@ -545,10 +546,9 @@ static void sun6i_dma_tasklet(struct tasklet_struct *t) pchan->vchan = NULL; } } - spin_unlock_irq(&vchan->vc.lock); + spin_unlock(&vchan->vc.lock); } - spin_lock_irq(&sdev->lock); for (pchan_idx = 0; pchan_idx < sdev->num_pchans; pchan_idx++) { pchan = &sdev->pchans[pchan_idx]; @@ -557,31 +557,20 @@ static void sun6i_dma_tasklet(struct tasklet_struct *t) vchan = list_first_entry(&sdev->pending, struct sun6i_vchan, node); + spin_lock(&vchan->vc.lock); /* Remove from pending channels */ list_del_init(&vchan->node); - pchan_alloc |= BIT(pchan_idx); /* Mark this channel allocated */ pchan->vchan = vchan; vchan->phy = pchan; dev_dbg(sdev->slave.dev, "pchan %u: alloc vchan %p\n", pchan->idx, &vchan->vc); + sun6i_dma_start_desc(vchan); + spin_unlock(&vchan->vc.lock); } spin_unlock_irq(&sdev->lock); - - for (pchan_idx = 0; pchan_idx < sdev->num_pchans; pchan_idx++) { - if (!(pchan_alloc & BIT(pchan_idx))) - continue; - - pchan = sdev->pchans + pchan_idx; - vchan = pchan->vchan; - if (vchan) { - spin_lock_irq(&vchan->vc.lock); - sun6i_dma_start_desc(vchan); - spin_unlock_irq(&vchan->vc.lock); - } - } } static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id) @@ -590,9 +579,12 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id) u32 channels_per_reg = sdev->cfg->num_channels_per_reg; struct sun6i_vchan *vchan; struct sun6i_pchan *pchan; + struct sun6i_desc *desc; + unsigned long flags; int i, j, ret = IRQ_NONE; u32 status; + spin_lock_irqsave(&sdev->lock, flags); for (i = 0; i < DIV_ROUND_UP(sdev->num_pchans, channels_per_reg); i++) { status = sun6i_read_irq_stat(sdev, i); if (!status) @@ -607,15 +599,17 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id) i * channels_per_reg + j < sdev->num_pchans && status; j++) { pchan = sdev->pchans + i * channels_per_reg + j; vchan = pchan->vchan; - if (vchan && (status & vchan->irq_type)) { + desc = pchan->desc; + if (vchan && desc && (status & vchan->irq_type)) { + spin_lock(&vchan->vc.lock); if (vchan->cyclic) { - vchan_cyclic_callback(&pchan->desc->vd); + vchan_cyclic_callback(&desc->vd); } else { - spin_lock(&vchan->vc.lock); - vchan_cookie_complete(&pchan->desc->vd); - pchan->done = pchan->desc; - spin_unlock(&vchan->vc.lock); + /* Completion transfers ownership to virt-dma. */ + pchan->desc = NULL; + vchan_cookie_complete(&desc->vd); } + spin_unlock(&vchan->vc.lock); } status = status >> DMA_IRQ_CHAN_WIDTH; @@ -625,6 +619,7 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id) tasklet_schedule(&sdev->task); ret = IRQ_HANDLED; } + spin_unlock_irqrestore(&sdev->lock, flags); return ret; } @@ -931,19 +926,20 @@ static int sun6i_dma_pause(struct dma_chan *chan) { struct sun6i_dma_dev *sdev = to_sun6i_dma_dev(chan->device); struct sun6i_vchan *vchan = to_sun6i_vchan(chan); - struct sun6i_pchan *pchan = vchan->phy; + struct sun6i_pchan *pchan; unsigned long flags; dev_dbg(dmaengine_chan_dev(chan), "vchan %p: pause\n", &vchan->vc); + spin_lock_irqsave(&sdev->lock, flags); + pchan = vchan->phy; if (pchan) { writel(DMA_CHAN_PAUSE_PAUSE, pchan->base + DMA_CHAN_PAUSE); } else { - spin_lock_irqsave(&sdev->lock, flags); list_del_init(&vchan->node); - spin_unlock_irqrestore(&sdev->lock, flags); } + spin_unlock_irqrestore(&sdev->lock, flags); return 0; } @@ -952,23 +948,24 @@ static int sun6i_dma_resume(struct dma_chan *chan) { struct sun6i_dma_dev *sdev = to_sun6i_dma_dev(chan->device); struct sun6i_vchan *vchan = to_sun6i_vchan(chan); - struct sun6i_pchan *pchan = vchan->phy; + struct sun6i_pchan *pchan; unsigned long flags; dev_dbg(dmaengine_chan_dev(chan), "vchan %p: resume\n", &vchan->vc); - spin_lock_irqsave(&vchan->vc.lock, flags); + spin_lock_irqsave(&sdev->lock, flags); + spin_lock(&vchan->vc.lock); + pchan = vchan->phy; if (pchan) { writel(DMA_CHAN_PAUSE_RESUME, pchan->base + DMA_CHAN_PAUSE); } else if (!list_empty(&vchan->vc.desc_issued)) { - spin_lock(&sdev->lock); list_add_tail(&vchan->node, &sdev->pending); - spin_unlock(&sdev->lock); } - spin_unlock_irqrestore(&vchan->vc.lock, flags); + spin_unlock(&vchan->vc.lock); + spin_unlock_irqrestore(&sdev->lock, flags); return 0; } @@ -977,17 +974,17 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan) { struct sun6i_dma_dev *sdev = to_sun6i_dma_dev(chan->device); struct sun6i_vchan *vchan = to_sun6i_vchan(chan); - struct sun6i_pchan *pchan = vchan->phy; + struct sun6i_pchan *pchan; + u32 irq_reg, irq_shift, irq_mask; unsigned long flags; LIST_HEAD(head); spin_lock_irqsave(&sdev->lock, flags); + spin_lock(&vchan->vc.lock); + pchan = vchan->phy; list_del_init(&vchan->node); - spin_unlock_irqrestore(&sdev->lock, flags); - spin_lock_irqsave(&vchan->vc.lock, flags); - - if (pchan && pchan->desc && pchan->desc != pchan->done) { + if (pchan && pchan->desc) { struct virt_dma_desc *vd = &pchan->desc->vd; vchan_terminate_vdesc(vd); @@ -1000,15 +997,25 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan) writel(DMA_CHAN_ENABLE_STOP, pchan->base + DMA_CHAN_ENABLE); writel(DMA_CHAN_PAUSE_RESUME, pchan->base + DMA_CHAN_PAUSE); + irq_reg = pchan->idx / sdev->cfg->num_channels_per_reg; + irq_shift = (pchan->idx % sdev->cfg->num_channels_per_reg) * + DMA_IRQ_CHAN_WIDTH; + irq_mask = (DMA_IRQ_HALF | DMA_IRQ_PKG | DMA_IRQ_QUEUE) << irq_shift; + sun6i_write_irq_en(sdev, irq_reg, + sun6i_read_irq_en(sdev, irq_reg) & ~irq_mask); + sun6i_write_irq_stat(sdev, irq_reg, irq_mask); + vchan->phy = NULL; pchan->vchan = NULL; pchan->desc = NULL; - pchan->done = NULL; } - spin_unlock_irqrestore(&vchan->vc.lock, flags); + spin_unlock(&vchan->vc.lock); + spin_unlock_irqrestore(&sdev->lock, flags); vchan_dma_desc_free_list(&vchan->vc, &head); + if (!atomic_read(&sdev->tasklet_shutdown)) + tasklet_schedule(&sdev->task); return 0; } @@ -1017,8 +1024,9 @@ static enum dma_status sun6i_dma_tx_status(struct dma_chan *chan, dma_cookie_t cookie, struct dma_tx_state *state) { + struct sun6i_dma_dev *sdev = to_sun6i_dma_dev(chan->device); struct sun6i_vchan *vchan = to_sun6i_vchan(chan); - struct sun6i_pchan *pchan = vchan->phy; + struct sun6i_pchan *pchan; struct sun6i_dma_lli *lli; struct virt_dma_desc *vd; struct sun6i_desc *txd; @@ -1026,11 +1034,12 @@ static enum dma_status sun6i_dma_tx_status(struct dma_chan *chan, unsigned long flags; size_t bytes = 0; + spin_lock_irqsave(&sdev->lock, flags); + spin_lock(&vchan->vc.lock); ret = dma_cookie_status(chan, cookie, state); if (ret == DMA_COMPLETE || !state) - return ret; - - spin_lock_irqsave(&vchan->vc.lock, flags); + goto out; + pchan = vchan->phy; vd = vchan_find_desc(&vchan->vc, cookie); txd = to_sun6i_desc(&vd->tx); @@ -1044,9 +1053,10 @@ static enum dma_status sun6i_dma_tx_status(struct dma_chan *chan, bytes = sun6i_get_chan_size(pchan); } - spin_unlock_irqrestore(&vchan->vc.lock, flags); - dma_set_residue(state, bytes); +out: + spin_unlock(&vchan->vc.lock); + spin_unlock_irqrestore(&sdev->lock, flags); return ret; } @@ -1057,25 +1067,23 @@ static void sun6i_dma_issue_pending(struct dma_chan *chan) struct sun6i_vchan *vchan = to_sun6i_vchan(chan); unsigned long flags; - spin_lock_irqsave(&vchan->vc.lock, flags); + spin_lock_irqsave(&sdev->lock, flags); + spin_lock(&vchan->vc.lock); if (vchan_issue_pending(&vchan->vc)) { - spin_lock(&sdev->lock); - if (!vchan->phy && list_empty(&vchan->node)) { list_add_tail(&vchan->node, &sdev->pending); tasklet_schedule(&sdev->task); dev_dbg(dmaengine_chan_dev(chan), "vchan %p: issued\n", &vchan->vc); } - - spin_unlock(&sdev->lock); } else { dev_dbg(dmaengine_chan_dev(chan), "vchan %p: nothing to issue\n", &vchan->vc); } - spin_unlock_irqrestore(&vchan->vc.lock, flags); + spin_unlock(&vchan->vc.lock); + spin_unlock_irqrestore(&sdev->lock, flags); } static void sun6i_dma_free_chan_resources(struct dma_chan *chan) From patchwork Fri Oct 23 18:42:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3704 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id BE0BC1C0B33 for ; Fri, 23 Oct 2026 20:44:04 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-26824-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-26824-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 20F32388C2 for ; Fri, 23 Oct 2026 18:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792780970; b=43ZAVnGmwa4azTbT6WOFvmHe7jx/VFvg6xrib8b/8kPrR1yWy/ed/wesJeLj3SvvbwN5 mlxWLysTona7qXdwpnJKleAoCF57G4oV+c5yVQVaWK3zw8UXVVlW06dlKne/UY3U6mixc YvO3fipxzRCWnluJtPBrsbumRwit69L4aLjbSdvobiepiCFC+mFqrrrGoVq0X1eb+WGJx fR6MzJ/+WpHK0RCvefX68/l6EENZx1sE8iRs41wGpYwuaUpb+Fxsk2wggFDMBcRngRHhk XYlNCtbNRetGI7WfHlp1j2LGwlDZDih9zIKE6Sx6txbh2Ltd9RsrMQLLbmqwKJFjZFQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780970; h=X-Original-To:Received: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:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=EdzVfCnxM9RWe3gkl8fuF1B/Ob/41o49mzScjy2RIHw=; b=bpXVjz/4piBv0ZtoPC2a2EC5ShXSM6NyBxYRQDnIWLxgTbRPwp3/fS4HWRcyGNYZeKKt onYp78aU5K0HQIvDmqwt6zSgX4vh7hpKxFQz158+WjlyWRLKlBQXvYNAetcejxSVYdX/X edPiFJfGv0i1Y7eHaY7VoegUt/hoNOFaCYjuPrwXGGX5nVmgh3kSfcjKJPuhPZPImoEpd aJ1LDnvpsAUn/zwzMUEqNHT2Bcmj6Oidey+rF5phPkUpPq39TLfuwxVlth2EX4XyuxeAr 0WO4k8eC4W7Rh6MUBjVBvFfYw/j7Vg60X3wNaXNrGsk3eo+jHB2Kq3Vl/jm1sGex+zQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=Xt9eJVl1; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EBBB6606A326; Fri, 23 Oct 2026 18:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=Xt9eJVl1 X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792780969; b=XNqnGLRSpqrNxmbgGMCmNU1hyOxD2xAAuPr/6LziRMCA+qx0iP3d9P738yUfWL/wuWHy pgUNK/mCb3VzaULQI00vcRdVs1AtFKmVeGt14OlpfxXe1+LDxmp8obvNmeFApA6sQf/Pc wWwatpJq9Fm2ANjCelsZBT7VhLyL9jvZ5+x63dxwHvB3Xov9MsEKYjS3AC6KoUDmUr7KB 07MXOuhxuC35FW4jvF5idI98EGNbeiNAUif8HhBuKZM08f8ZdQX4jdIwEd3+tj/RmpNDa P07A9DWYjxmbV+bWJGSmpnzgf6e1ykmvwaRZyKgEjTk+BvNLseUDISSVsNoZILOGtiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780969; 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=EdzVfCnxM9RWe3gkl8fuF1B/Ob/41o49mzScjy2RIHw=; b=sb1O/qgqeAM2vbBKu4QEADnpR/4ixtFQ/0FwvWZqocvef2aqetMIRjNFFvmQrERuwpOD InoD28ZbA5jLgr1ZzGTjKPvDGY60lQTFSplOYAvo05wgig5zt4yxGSoDkJwtwTg8P5G2h mtSsqN2A7V2cPjcEVKPVqg5Yq5AVUDPpjTZL+A5WwaD3MHp+MUYSG6czHxSfhHdcspe7W Pr6LZApDO0bxGbdTg2UQQPPZA20BI1fndWuyCqLnZAYMnSFjq/w1xofYvN3Raz6ittoJL deumbFAJUY6rX/t/4Qx8LjBAPpncOR1GKvbcot+KZvYWHi+8J8uWQdjre1oEXoZ2otQ== 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=20251104 header.b=Xt9eJVl1; arc=none smtp.remote-ip=209.85.161.42 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (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 7A38E606A31A for ; Fri, 23 Oct 2026 18:42:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7A38E606A31A 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 Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-6d290b10a35so527459eaf.2 for ; Fri, 23 Oct 2026 11:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792780968; x=1793385768; darn=lists.linux.dev; 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=EdzVfCnxM9RWe3gkl8fuF1B/Ob/41o49mzScjy2RIHw=; b=Xt9eJVl1PuzzN7TxerPXNg3wl6z/mOmGmuIsfmBfwG3G+TIrvS/GAyePxNQQqVfMqV xIruSe9Z96YnmRBBQNPpZXfkOaZ0BOAZfYXfQmnyla7+iXleIdALchEJFHtyNWtC8/tq wBQygulqwCcHmjz/lZGl7i91uEUL27iQr/bNBT3/LZog87oTuCHH/gYDjJWBTVet0F+o 8sns07K1oibpOUdQwJwzHVRKEWclsLi3AUfBglikLgI0/ceXAgPViUN4f/DpRDfHaJtb ccSZ8cHdfGh3+nt4Fyj14CRYXyqZ0UyomNt++06C8ji39EmFVJ8LBiGnl8w+Ks3DKytg 3SWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792780968; x=1793385768; 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=EdzVfCnxM9RWe3gkl8fuF1B/Ob/41o49mzScjy2RIHw=; b=sCrsDIGi57wefUBv/3olfNnAcWOcjKutOn/L/cwWt1eznGrDmPruiXPDl45X5nqwuJ z44YdGed3IE9U4COMJenPRaSB/PQqTZx8WCi0l1NvxskIveqx2RSSwc2AuBnuDF9IBbD R6P+wSGxt+vaK4jK8vrXiRsoxMrnMxYbwpHBWSiS/psOhQWJa5zJFJ6OrIU5YOI/LPLq BE9MoT2p84jwhDcut1gQTH4+A4f0uNY0iJwHfA+Qt/+ISZeHWLz2kgANpiHW/pCd6UM5 Bv5XO8xcPJaBkUH0/bEhnccxrLuKIOCIvXk9dFcLDqNjZRb8HfpsOjsuLdWgHipovjZt +omA== X-Forwarded-Encrypted: i=1; AKwUvBwBez8yQU5z2X88UL4ghCnYdy90dyHOsw8jcbHpjc22INzQ2mdfjxOGgmGhIgaW+bRRpx29uZGVusnlmw==@lists.linux.dev X-Gm-Message-State: AFq9FYKZP6uxgCIPPQBI4YmASsiCSFXOzhZnmqsT4DCpEuSqnYM2nrLW wApBXhQPvqgcnLwwgzYMFNkX6S+kU3qoi5iHZHX5obd/1ZaFg/3Jgptt X-Gm-Gg: AYBFou07ImWaVGk1M7Ji2856Upl8eRfKar4YmXCRBTdIyMLx7xeReQmQS9CRc4yE/DR uknwS4XHeWmIsEtO5+vLsXSFOsmqY8J2RbjHjI/m4d+Q5s5AvCB2IiM+E359QPkqIicNAHoK4gI 7u0XrbGstoBMUhNwa2wJ+N04cnBii69/xAux7IiBVkZ4EMYw4cvndjOhHf07rWaeU+r/Hfn9flU Wl78QEY0XfBM5MBVFYWSfWxPO1o+Keh2vro7OaWD8x7siatHlt97xcMxuIby/7DGV7hBRArZ25A ScO7U3htGm9rr+ysIP5LgWt+J+s/FreSlCGyH73Favnz4NjG/HNly252czCY4adW9eTTAriuxUe Yto8LGpmcJTkAXubjp2rnMlkmAHCAuJK8JvxDsTMa43o70lhTTtxv5/OzyP/GIIIX6DzdYABp2s wtJ5BNuWGMz8PkWW/tddzCeEdIitoRLY4J5T636CxCZLD94HYkEcb5r9zWkDJFDm/MStiIK/XTF TU4s4dOjQ71CrEoo8Aub9ZQhBYpNWpMdlG7nmY9ShaFeglne1TVaMog4eBo73R6TXGRavETM43P E/OztCYikr1hqFDcaywKsC4jTSH7X5GRB4G7G3LVK+a4t1zfKgoSdta2/rqI1reKv14OkInNIz+ mvtXUxwdfUqrFJGHRnjNCiCo6G6KJ5GNTOkrBBpvPVOskD6Gcpw9cV4nDU+6/4+BF+dpfnjrXpp D22A== X-Received: by 2002:a05:6808:4486:b0:524:884f:d89d with SMTP id 5614622812f47-55c0029724dmr56674b6e.21.1792780968326; Fri, 23 Oct 2026 11:42:48 -0700 (PDT) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 5614622812f47-55bfe199544sm336682b6e.13.2026.10.23.11.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2026 11:42:47 -0700 (PDT) From: James Hilliard Date: Fri, 23 Oct 2026 12:42:38 -0600 Subject: [PATCH v2 4/6] dmaengine: sun6i: track paused virtual channels X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-4-c9e07cc44bf8@gmail.com> References: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> In-Reply-To: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> To: Vinod Koul , Frank Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Arnd Bergmann , Maxime Ripard , Jens Kuske , Jean-Francois Moine Cc: Hongling Zeng , Chengfeng Ye , Nguyen Minh Tien , dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [4.31 / 15.00]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; RCPT_COUNT_TWELVE(0.00)[17]; TAGGED_RCPT(0.00)[]; FREEMAIL_CC(0.00)[kylinos.cn,connect.ust.hk,embeddedlinux.blog,vger.kernel.org,lists.infradead.org,lists.linux.dev,gmail.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; FORGED_SENDER_MAILLIST(0.00)[]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[209.85.161.42:received,100.77.114.92:received,174.29.1.49:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from]; TAGGED_FROM(0.00)[bounces-26824-noreply=patchwork.local]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: BE0BC1C0B33 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= sun6i_dma_tx_status() only returns the cookie state, so a paused but incomplete transfer is reported as DMA_IN_PROGRESS. The 8250 RX flush path pauses the channel and calls its completion helper before terminating it. That helper ignores an in-progress transfer to avoid consuming a new RX operation. With sun6i it consequently drops the partial buffer and leaves rx_running set, preventing another receive from being submitted. Track pause state under the channel-assignment lock and report DMA_PAUSED for incomplete cookies, including status queries without a residue output. Flush the hardware pause request before returning. Completed cookies remain DMA_COMPLETE. Keep paused channels out of the pending queue and do not start a queued descriptor when a paused channel's previous descriptor completes. Release the completed physical channel so other virtual channels can use it, and clear its hardware pause request before reassignment. The paused virtual channel retains its queued descriptors until resume. Resume requeues an unassigned channel only once and schedules the allocator, so an idle controller does not require an unrelated completion to resume it. Clear the pause state when terminating the channel. Fixes: 555859308723 ("dmaengine: sun6i: Add driver for the Allwinner A31 DMA controller") Signed-off-by: James Hilliard --- drivers/dma/sun6i-dma.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index a21acb9ecc27..157746c9423d 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -208,6 +208,7 @@ struct sun6i_vchan { u8 port; u8 irq_type; bool cyclic; + bool paused; }; struct sun6i_dma_dev { @@ -534,13 +535,17 @@ static void sun6i_dma_tasklet(struct tasklet_struct *t) pchan = vchan->phy; if (pchan && !pchan->desc) { - if (sun6i_dma_start_desc(vchan)) { + if (vchan->paused || sun6i_dma_start_desc(vchan)) { /* * No current txd associated with this channel */ dev_dbg(sdev->slave.dev, "pchan %u: free\n", pchan->idx); + /* The next owner must not inherit the pause request. */ + writel(DMA_CHAN_PAUSE_RESUME, + pchan->base + DMA_CHAN_PAUSE); + /* Mark this channel free */ vchan->phy = NULL; pchan->vchan = NULL; @@ -932,10 +937,12 @@ static int sun6i_dma_pause(struct dma_chan *chan) dev_dbg(dmaengine_chan_dev(chan), "vchan %p: pause\n", &vchan->vc); spin_lock_irqsave(&sdev->lock, flags); + vchan->paused = true; pchan = vchan->phy; if (pchan) { writel(DMA_CHAN_PAUSE_PAUSE, pchan->base + DMA_CHAN_PAUSE); + readl(pchan->base + DMA_CHAN_PAUSE); } else { list_del_init(&vchan->node); } @@ -957,12 +964,14 @@ static int sun6i_dma_resume(struct dma_chan *chan) spin_lock(&vchan->vc.lock); pchan = vchan->phy; + vchan->paused = false; if (pchan) { writel(DMA_CHAN_PAUSE_RESUME, pchan->base + DMA_CHAN_PAUSE); - } else if (!list_empty(&vchan->vc.desc_issued)) { + } else if (!list_empty(&vchan->vc.desc_issued) && list_empty(&vchan->node)) { list_add_tail(&vchan->node, &sdev->pending); } + tasklet_schedule(&sdev->task); spin_unlock(&vchan->vc.lock); spin_unlock_irqrestore(&sdev->lock, flags); @@ -991,6 +1000,7 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan) } vchan->cyclic = false; + vchan->paused = false; vchan_get_all_descriptors(&vchan->vc, &head); if (pchan) { @@ -1037,6 +1047,8 @@ static enum dma_status sun6i_dma_tx_status(struct dma_chan *chan, spin_lock_irqsave(&sdev->lock, flags); spin_lock(&vchan->vc.lock); ret = dma_cookie_status(chan, cookie, state); + if (ret == DMA_IN_PROGRESS && vchan->paused) + ret = DMA_PAUSED; if (ret == DMA_COMPLETE || !state) goto out; pchan = vchan->phy; @@ -1071,7 +1083,7 @@ static void sun6i_dma_issue_pending(struct dma_chan *chan) spin_lock(&vchan->vc.lock); if (vchan_issue_pending(&vchan->vc)) { - if (!vchan->phy && list_empty(&vchan->node)) { + if (!vchan->paused && !vchan->phy && list_empty(&vchan->node)) { list_add_tail(&vchan->node, &sdev->pending); tasklet_schedule(&sdev->task); dev_dbg(dmaengine_chan_dev(chan), "vchan %p: issued\n", From patchwork Fri Oct 23 18:42:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3705 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 3D4431C010E for ; Fri, 23 Oct 2026 20:44:39 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-26825-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-26825-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 76DF939C13 for ; Fri, 23 Oct 2026 18:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792780971; b=e/AFRQqRaaKxLUdmVZAuX1EJeTGGmU2glvq/qhsFbwbfRG2BDliJ5dumkV/ueC9lzNav fl9haL9J27lLZJciBD54iytILSH/MBb31IN4zY/UFSlJav00D3gOUFOX45kF1mowHzrKX p/mDZCfT6AHU/C+RA3f6OTlFE/7bfbQYtHHbaK5GQ/06dqO0zSfUn+u7LR/WFjsZ8+wtf Q6RtBBM3QJ1cJ3+UFglS89lzNZ3kcjUFdBGLL6XZkoWxvy6nWTHQbnvIPi/EBtwP4R6x6 MVegDImjE90KLxfiS3rVARpTdY6qG2ENp54l8q4tTbJQkNPIwaNhzN/qiWa26gBgMcA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780971; h=X-Original-To:Received: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:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=B1IqYW+doNQQMcUHP4l8j+5MQVcguml9gPI+cwHAG8g=; b=E4O07It6s9kp7h7g2wAppjr7JpOLF7xpJGlbWoXJeBUhcXKq4OzORjSJrhQolGTQTdZN Ji1sIm/y1vg3P0NdPB4Xln6UePBHF4e17mg2qeq7rZ+EEyVtyTGfeEGApWwJDyN9h91PD ciincv52+HEkKJU/uwQBGKLZ7g0A0bNzLxEagFS2etLcSm/EchAKrvIcEZp0mxjdMklDm 2MIau2x2T3cIyhAAfzjWScw80Ev2kk8PmpAHVuhwWvXcWTVofUVZLqRf3lXE4lFYmuMUe mzrnA8PnBHXPYWOzpQGMfDK6+mfyIENEg+f+bWd+kuyG8VPyqL1XaJDTk0IWwZIwzsg== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=pizzbvuS; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79D04606A32D; Fri, 23 Oct 2026 18:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=pizzbvuS X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792780971; b=fIeRwWAfc8Ca8oDGH1zhXQn8VXIltepTM2LQV9iyjMXblH7Mu1a9u9xrtvFCCL1Zzcff p8GxXM9WhXb9I9uZRW0P9jK1+JkdqLKd/cjZvoR655WN5skdbzBxWoCAQwITi6tp52PiD A65ZAApZsfqzHGReTyxhcXyII10w8Wmi9tsp9VCoOmueLcb7ctq1egzfDXgkhVR6aZf+a TpJtGvu30hsfO2LspSl0UNFydiDSJuPrGIA0mnFR2e5qkG0PCj//GqtpXsstwkWGrCNH9 P1aU/75aM8QfBb1/fsXVc587xRzDXChCrRLW5aE1A3WI0YtM+rlYNQpy/SDXkUQy5HQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780971; 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=B1IqYW+doNQQMcUHP4l8j+5MQVcguml9gPI+cwHAG8g=; b=dqRdGTw0G8GBNa+Nc9rmcWPVRlMMuFHI6522d/maXgdlrTFsjI0rUIkpLxyNZ8KR42mR ykUciWi+L9S2oiOv2Nqs+xpNwy3BZnzvzUnBYpuuHJnzzvKWSXGE7gHr4Mo5+BRdQbUVf 9Rc+/aS9j8C5gkMKwRvY92iDvqhVr5IouoJwVLs88Mp1EVUkKm10RfITuoCWQoDZkiMvw XqOJCmgjzEwFUYdwS9+cEnxcaYeU6Y1CRgTZ4wogYpRc3jv+m0IverfnDqD9NP8/yVceF tCTJrVIj5j4dwTQakOz1Gs+y7Kn/xJ4B4BpNGg13esSkvf07TX1mQ8KWROqaf7L0+5Q== 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=20251104 header.b=pizzbvuS; arc=none smtp.remote-ip=209.85.167.181 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 12E89606A337 for ; Fri, 23 Oct 2026 18:42:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 12E89606A337 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 Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-4d198f1a591so634856b6e.2 for ; Fri, 23 Oct 2026 11:42:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792780970; x=1793385770; darn=lists.linux.dev; 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=B1IqYW+doNQQMcUHP4l8j+5MQVcguml9gPI+cwHAG8g=; b=pizzbvuSpBODje3Uf7MNf1IYzvBe7mQOQKnsRzkDlV1auyHXV/H5TuIyRKC1BVrMEK 1FfItGf1fBy8cLeJS6E65H5DzJ8HGRHUXy0RZ7ch4BHdNvA0Prj9PQhSt09atnndyvBv HYGOpp2LBBfoAr8XWZ74MUbCawJLRJDzts1oIVXV4E8x+cEJfd5iPZ6tk9S7RmfW6BPX PZ+jwCoJWmyYY7U4vTCxI82MkBrLs1gepgSLl0zpQU33lQJZZSdR0mmufzC8z4gsxyZT OgsSaWiTTNHpN6OSd+pMpMrzt+JrwWn5QYuHu5wrz+h+1aH6u2hPeF7AHoNYW6YImnC8 GO8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792780970; x=1793385770; 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=B1IqYW+doNQQMcUHP4l8j+5MQVcguml9gPI+cwHAG8g=; b=Bm0e6iSj/oVbVwIr0rVcivSrGo0DTbJUVDPxxiKqOpk645me/mW5waNnZ8Guc3jzdy WjeLQwC088QzwE2dZIkIPVk+C8xiKG9qeSm0CN4I3HoyV7XM3AgscfZJGxw4t1CBseLA +q4QJnkho6kjVQw7X7sdoMsQL8fIztftNhGV3yHZRKuB7LzpZXJGAzx+SEF/d6OOfcqy 8hQNK9Y2OL2nE9wxJdc5XG5p8Y+LPIZnB9fxMNf+DL2gjvlZnWX7QIC3oDranoYXcgbt SPNGWf14XVdiOGvYSmOrjCXwde5asg/qlYiM+QanCV868X17opNWcwVcABx06MQGx3dZ 0eWw== X-Forwarded-Encrypted: i=1; AKwUvByazAZu1PHMntFi6hoGmb1aXbuNh+CVgdZixcuIOmBRPW/LyfDYiTQh7s10756Czed3FlIZQbNUNMKKGQ==@lists.linux.dev X-Gm-Message-State: AFq9FYKSOc8POzetxyGd3gDT2hiuU1XBt45EsuHiHn8lWVXBkkIYR2kV KKYffnK/5fEjraa4vnP/JfosGtXU4mYJRUT6/yvicV5uhJb4Uja0wWU0 X-Gm-Gg: AYBFou3CkNw4AZKFleYo+ajC3W1rUM2UttRhEnTN4DB0YffAHfvZUyFz9x549LiDWM4 iOfon9rMmKRRzbbJfiZ3ojc9pDEx6igXwhzRuwX+E56YAARDQBaZxMYI8/d6bmxL7z92ol62AIt CAAyV53B8xiqqPRIv5tiZOpX8bT8PkLy44p42pGF9w/1TGVYlCMof/Mgq96nNN+TfgfPUFvrTey KqXsXcFWoFDUhVzm2wGxYFNyFFbO17ZTofMFXlOjWD0rhlavpQkjrdD/3FVuqGD41aMPQZygB2U /IDmOIAoA08OHzt1HUet/bttZrRbBVXv6ka3b7sMN3LFiK4IkwTHDvha1vIuTvJW+L2Q6Aw2Jl1 0+SHl7tSbvmHYWYLEK7B76ItgEHQ/1y7mGeStBLSESXR2qdS0rL1hTvhNcOUUwFSJJQCZSbB0iF 6j8Gv6Li/8j8QXJJYGs/vSSommB7BjOUqpaxviPCCFKobb8FN9J2uHyThBXE8N9Ehiqx7iO8330 2RRaRa9/rrn/5DXJgeYFZDnrXEj/lRYfQc4q/DMYw+Zw4wc3sEvwG3QUp0CeY660y1SSWllCzHs 05psa+soE2ag0GfkchALUvYbZb/OSqosxLh29I10z+S8TVJzwOMCcn8PMlXZFRDhnbKGsnsDotx adI2iViAOgdZQaFNb1+Qy/KvH0/WyeHp3gHAqdMXTpTUm2f3T8WPKW7+6SYZ9jr2xMBfA6+72gD kN9k8= X-Received: by 2002:a05:6808:4f6b:b0:4f5:eaac:5173 with SMTP id 5614622812f47-55c002c7d48mr52342b6e.57.1792780969992; Fri, 23 Oct 2026 11:42:49 -0700 (PDT) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 5614622812f47-55bfe199544sm336682b6e.13.2026.10.23.11.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2026 11:42:49 -0700 (PDT) From: James Hilliard Date: Fri, 23 Oct 2026 12:42:39 -0600 Subject: [PATCH v2 5/6] dmaengine: sun6i: synchronize callbacks before releasing channel resources X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-5-c9e07cc44bf8@gmail.com> References: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> In-Reply-To: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> To: Vinod Koul , Frank Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Arnd Bergmann , Maxime Ripard , Jens Kuske , Jean-Francois Moine Cc: Hongling Zeng , Chengfeng Ye , Nguyen Minh Tien , dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.19 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; FORGED_SENDER_MAILLIST(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; RCPT_COUNT_TWELVE(0.00)[17]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[kylinos.cn,connect.ust.hk,embeddedlinux.blog,vger.kernel.org,lists.infradead.org,lists.linux.dev,gmail.com]; TAGGED_RCPT(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[174.29.1.49:received,209.85.167.181:received,100.77.114.92:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from]; TAGGED_FROM(0.00)[bounces-26825-noreply=patchwork.local]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 3D4431C010E X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= The driver has no device_synchronize callback. dmaengine_terminate_sync() therefore returns after stopping the channel without waiting for the virtual-channel tasklet. That tasklet may already have removed completed descriptors from the shared list and be executing their callbacks. For example, serial8250_release_dma() frees the RX buffer and unmaps the TX buffer immediately after terminate_sync(), while those callbacks can still access them. Use vchan_dma_synchronize() for device_synchronize. Channel termination excludes the interrupt handler and allocator before detaching the channel, so they cannot schedule another completion for that transfer. Also stop the channel and synchronize when freeing its resources. Keep terminated cyclic descriptors on desc_terminated until synchronization finishes. vchan_complete() may retain that descriptor outside vc.lock. Ordinary active descriptors have not published a callback and can still be freed by terminate_all(). This avoids accumulating descriptors on each 8250 partial-RX flush, which uses the atomic termination API. Fixes: 555859308723 ("dmaengine: sun6i: Add driver for the Allwinner A31 DMA controller") Signed-off-by: James Hilliard --- drivers/dma/sun6i-dma.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index 157746c9423d..c244ef572492 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -996,12 +996,20 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan) if (pchan && pchan->desc) { struct virt_dma_desc *vd = &pchan->desc->vd; - vchan_terminate_vdesc(vd); + /* A cyclic callback may still hold this descriptor outside vc.lock. */ + if (vchan->cyclic) + vchan_terminate_vdesc(vd); + else + list_add_tail(&vd->node, &head); } vchan->cyclic = false; vchan->paused = false; - vchan_get_all_descriptors(&vchan->vc, &head); + /* Leave terminated cyclic descriptors for the sleepable synchronize. */ + list_splice_tail_init(&vchan->vc.desc_allocated, &head); + list_splice_tail_init(&vchan->vc.desc_submitted, &head); + list_splice_tail_init(&vchan->vc.desc_issued, &head); + list_splice_tail_init(&vchan->vc.desc_completed, &head); if (pchan) { writel(DMA_CHAN_ENABLE_STOP, pchan->base + DMA_CHAN_ENABLE); @@ -1100,14 +1108,10 @@ static void sun6i_dma_issue_pending(struct dma_chan *chan) static void sun6i_dma_free_chan_resources(struct dma_chan *chan) { - struct sun6i_dma_dev *sdev = to_sun6i_dma_dev(chan->device); struct sun6i_vchan *vchan = to_sun6i_vchan(chan); - unsigned long flags; - - spin_lock_irqsave(&sdev->lock, flags); - list_del_init(&vchan->node); - spin_unlock_irqrestore(&sdev->lock, flags); + sun6i_dma_terminate_all(chan); + vchan_dma_synchronize(chan); vchan_free_chan_resources(&vchan->vc); } @@ -1480,6 +1484,7 @@ static int sun6i_dma_probe(struct platform_device *pdev) sdc->slave.device_pause = sun6i_dma_pause; sdc->slave.device_resume = sun6i_dma_resume; sdc->slave.device_terminate_all = sun6i_dma_terminate_all; + sdc->slave.device_synchronize = vchan_dma_synchronize; sdc->slave.src_addr_widths = sdc->cfg->src_addr_widths; sdc->slave.dst_addr_widths = sdc->cfg->dst_addr_widths; sdc->slave.directions = BIT(DMA_DEV_TO_MEM) | From patchwork Fri Oct 23 18:42:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3708 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 5B8E71C010E for ; Fri, 23 Oct 2026 20:46:40 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-26828-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-26828-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id CE1A43E49A for ; Fri, 23 Oct 2026 18:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792780984; b=iZqn6eZhhX54q8/8BQyDFD+yupKEPzkbCCxGVRT803zUswP3Nsbd0vrTcDa42sNDonrA v1LSuKloIRKMzv4F+DQqrNmORv3jEO8vZ0fyKMKGoJy4t3xhqBsfLeq953AH3yqW4chN5 PqkIbjEPBRXVqGnzMnL9vcYmuR3q8F4rChB5AINirzlzHZJqK7UZhUKPAiVp+1KdDtFUs 1Ej/oSXDunF0WwCCtjAkJo52cf1OnC3EeHraaFaPHLMNkbgY5HUfxZ38XWpTcZ/xFtSRZ qYF/Vr3VXus33PfJIwAKTvKxUBlKhu6qDjicPTU/xPfkrsmjV3YYpRwnyU+fTZz5G5g== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780984; h=X-Original-To:Received: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:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=PqNMKX2JAKOcdDMHgbj/E/YCDonhqS9mo8xwaEZBKXY=; b=A53ldtnP/HTdi9kDa+slcM8MMjFYWaSgkx8ZkKl8AXAFBFsBbj2dVGRNnBJJC8OoUWju lQgHWFz9sJOyv5MVrKuCpvegN2G0jWXqh8t01M2D9XJC0jFNtRvMCvuaCHipRBzNTddJ5 hKGMysufe72UdFAzTwMaz+ReODVHRcF6rA9UWsDk2KexDozMOZw83kBfLJoq5nwTRpnUg cPBMVNzO39elQ1Zw8kaez1320q7HL/APHNrR3R8UR0mIY7xHfKEPrxTk7yPksEWHHJICY 6mPF6DBwiJZib7KsQ5W0n1vmz2A2n5iCSEgHO1WAef6YvV7htiDAESCiBIu+FHMD73w== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b="IE7JoqV/"; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6AA9606A32A; Fri, 23 Oct 2026 18:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=IE7JoqV/ X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792780984; b=F9PPTvOLBANmIWRgNzsmUxP3mDCZ8xVy0KAIHfNt/QTOhgz5t+eMqx22xwzXqkoigvtF NNSo5p/rDsFwl3P3gN6qHnp1oiu98kvAn/8k4ITwHgYdEBsHcIMyH14DgUXjFKc5kfy+a ZQDkYo95dYw+n7bRhOD5gfgnBcp24tAknA4hViJWvh+qgTmY4tId8qsUYBdrlxmfm52EN u0miwtZK+8SxC3W5kMq6RGWnJeqiK1cwYp7f1lxEWkDjRFLHRrswGbQaXbposX/+jkUEB rvCk2Fi/deq/EOuQ0ns7X4eXZppUlyGZnHrovHcQ8Y8A7mAyDA8PvD416T3f9XwuVTQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792780984; 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=PqNMKX2JAKOcdDMHgbj/E/YCDonhqS9mo8xwaEZBKXY=; b=Z3glM6gtSnvPYjqLGnSw8qod6IUh2M8sCr3dArxLsxtl+Megv5optNfaKL0ohTo2Ve2v /SL8ip3YLYCdmheArDNLUprTSUXppVclZvFvr6lHScVGVMzRh2M28fBsR1RmE3p01c+Dp GwMZ22g0CHW9bZ27eOczbg/eA4io5TgNfRs9PzC++ratHJSMal0aaRKdrAHDy7QOXy2QD 9tLN+LMV4qnybamK6LEzecN1iGSUZ01aswcwE6NJCBBgjljHUH3SaABgoE0qnzx2azvUc c62IikYGeZa/AgAM3KiY3dCxJoZvOzTRDL1vlZnE5TL7zfTa1ac0RFESsiHwT4PSYqg== 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=20251104 header.b="IE7JoqV/"; arc=none smtp.remote-ip=209.85.167.182 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 7AC1E60A2607 for ; Fri, 23 Oct 2026 18:42:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7AC1E60A2607 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 Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-4c382ece86fso608900b6e.1 for ; Fri, 23 Oct 2026 11:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792780971; x=1793385771; darn=lists.linux.dev; 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=PqNMKX2JAKOcdDMHgbj/E/YCDonhqS9mo8xwaEZBKXY=; b=IE7JoqV/7kZ/srCOuAFdFuykRBCW4ADu7ONIpWaJT0gUctgZ6GarvBH7fanaWIqCv7 FtsGtYLpMhgOYMmy7qJgKyXjgLlEwOb66IoN4n4XWr9ZPgWvG3Uai8wo+24iXPDpmkDj fzZ+oVpLu11WIHIx0u+DkwhKgn7GSa1/0/vRiFIjlhzY0xa3wOt2KEFpC/WoLyK/5qvB 5kT4sHIbQcLE5Y9bEikmnRRmtFwWrSObQ3AjYuG3perEq2w8VEBN3YXUiCeROzMVMVQf pHIZJmJ2Wd6w7mWCTME09IvhkWxxFNN2uuaxP902wY9FfsDUq5sRH1avuoYz3kCrk0c3 ahYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792780971; x=1793385771; 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=PqNMKX2JAKOcdDMHgbj/E/YCDonhqS9mo8xwaEZBKXY=; b=U2Xtl/x4330b7gnrPsNJMdLROTWjDiRHjfVNrSxe4vaHwxBBznSvY2W0rwRtr/kvu1 ZipV9uCSZD4Rk1y7GaT+Y9eoF0Y5V73pHCMWahTdm0Zs08Se7ZHVDEmCvhIN+W6ivJlF sSpmV2z+PGdvd926fPyiuycUfvxkxeinlgjB1XW416ShbSYIVvA0u4XDbf46HJCsyTUS M9vjjCOehTtWwtIwsSAZZu3ezSXQztXxAOkbs85t2GyAVZI8Qtb9Oz8SV4TuBbImCEo7 daoDS6jeHWwxets4AW1rayciaLrZaIsAqDIMxyZii06nPSKcybzE6AihUtAvEVU2b2bd 9rQA== X-Forwarded-Encrypted: i=1; AKwUvBzMAs7MDfkpASI/7LYhEy030mM1kSIznBohjjjRm1Gebkz2lImgIar0mLBVJKWA/Y/E3wlH00iLP2c4Qg==@lists.linux.dev X-Gm-Message-State: AFq9FYL4/UsSxcoTk4Ml5ygLMFeKrg5Q+o/b+NSEKBoihwshdD34L2Qc LMadsObx0ICXhphJirJytp77I6/3nQBDPel8bHVdWupycI+Ljq4cMLz5 X-Gm-Gg: AYBFou1KcYz1HdDlUB+AiBhyFL3Bm7edaZ/2bu2M1+PoVJEa6gVCJjMGOF2OW5u7ptI avNS2wd9QVn6pt2Y04E7JH5qEhEje2c0AS+t/i+bWfbxWmNY0b9bW2NX98qZgf9NkkPa6B14g9O Brlao6rBUaQ9al2Rx9BF9rJf8xNfmwJ+WYH66UZ7Z+VNuO6ClrQ4r4beBeVFXH3wvJ0KJvFs14E Y/GqYx5YTK3f8js8Dejr3btfokJbxW07bxe4I7DOSouY3wukekEgqBKuplwcIOXeHtnETJ/tSO/ bd6spvQSsSTWM/5JyK76zoWn29unn7qCxkdFTTO6VeZBhLWlqvMZfdg7xzxkR0lDiKdrjpP3ctP wNFJYZpVO6PLWMcg9ZzmWpfh0dVrJwjjy5BErkqkMCGXSalY/QbnTdZME44eOcyg7ocpej9IGls nOMIT2RaV58ilV02hE7CzrlknvSO2MVM2QTnLqbXIPLpkVuM3HYDNgIZcQIV0OHndFZ3ZZZkw7g KoH/06IoN0r8ceJqmSZpcyvuiva4ch9jozrhQQtB7/4+wEBD+6U6pmfSfpDDPEUkHws69ie9LWu L0Pv/5TOVuNx7O0nbHZjOQ0PPZEsZ8QXynSicTLrsdSyJd6wgIPOfvbtTzNwQVCApA+pfCZvgVH dJ8/aLlxIrYGFXXTDhxJRBmUShzUhPKOIz3qbcjjTgHzAYXiljZVREMjKymLExYSGGRr/n7NK+t 1dhtM1yjKrqjfvvQWeZgeeozI= X-Received: by 2002:a05:6808:1911:b0:50a:6fcf:d287 with SMTP id 5614622812f47-55c00232f05mr72486b6e.37.1792780971361; Fri, 23 Oct 2026 11:42:51 -0700 (PDT) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 5614622812f47-55bfe199544sm336682b6e.13.2026.10.23.11.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2026 11:42:50 -0700 (PDT) From: James Hilliard Date: Fri, 23 Oct 2026 12:42:40 -0600 Subject: [PATCH v2 6/6] dmaengine: sun6i: keep cyclic state with the prepared descriptor X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-6-c9e07cc44bf8@gmail.com> References: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> In-Reply-To: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-0-c9e07cc44bf8@gmail.com> To: Vinod Koul , Frank Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Arnd Bergmann , Maxime Ripard , Jens Kuske , Jean-Francois Moine Cc: Hongling Zeng , Chengfeng Ye , Nguyen Minh Tien , dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.19 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; FORGED_SENDER_MAILLIST(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; RCPT_COUNT_TWELVE(0.00)[17]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[kylinos.cn,connect.ust.hk,embeddedlinux.blog,vger.kernel.org,lists.infradead.org,lists.linux.dev,gmail.com]; TAGGED_RCPT(0.00)[]; TAGGED_FROM(0.00)[bounces-26828-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[209.85.167.182:received,100.77.114.92:received,174.29.1.49:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 5B8E71C010E X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Preparing a cyclic transfer sets vchan->cyclic before the descriptor is submitted. A finite transfer on that channel can then select package interrupts and take the cyclic callback path instead of completing its cookie. Merely preparing an unrelated future transfer must not change the active transfer or the meaning of queued descriptors. Store the flag in sun6i_desc and consult the active descriptor when selecting interrupts, completing a transfer and terminating it. Finite descriptors retain their zero-initialized flag. This also makes callback retirement depend on the descriptor whose lifetime is being ended. The shared state was identified during the H616 cyclic UART RX review. Fixes: a90e173f3faf ("dmaengine: sun6i: Add cyclic capability") Signed-off-by: James Hilliard --- drivers/dma/sun6i-dma.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index c244ef572492..c9a72cfe3f44 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -191,6 +191,7 @@ struct sun6i_desc { struct virt_dma_desc vd; dma_addr_t p_lli; struct sun6i_dma_lli *v_lli; + bool cyclic; }; struct sun6i_pchan { @@ -207,7 +208,6 @@ struct sun6i_vchan { struct sun6i_pchan *phy; u8 port; u8 irq_type; - bool cyclic; bool paused; }; @@ -504,7 +504,7 @@ static int sun6i_dma_start_desc(struct sun6i_vchan *vchan) (DMA_IRQ_HALF | DMA_IRQ_PKG | DMA_IRQ_QUEUE) << (irq_offset * DMA_IRQ_CHAN_WIDTH)); - vchan->irq_type = vchan->cyclic ? DMA_IRQ_PKG : DMA_IRQ_QUEUE; + vchan->irq_type = pchan->desc->cyclic ? DMA_IRQ_PKG : DMA_IRQ_QUEUE; irq_val = sun6i_read_irq_en(sdev, irq_reg); irq_val &= ~((DMA_IRQ_HALF | DMA_IRQ_PKG | DMA_IRQ_QUEUE) << @@ -607,7 +607,7 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id) desc = pchan->desc; if (vchan && desc && (status & vchan->irq_type)) { spin_lock(&vchan->vc.lock); - if (vchan->cyclic) { + if (desc->cyclic) { vchan_cyclic_callback(&desc->vd); } else { /* Completion transfers ownership to virt-dma. */ @@ -908,7 +908,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_cyclic( prev->p_lli_next = txd->p_lli; /* cyclic list */ - vchan->cyclic = true; + txd->cyclic = true; return vchan_tx_prep(&vchan->vc, &txd->vd, flags); @@ -997,13 +997,12 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan) struct virt_dma_desc *vd = &pchan->desc->vd; /* A cyclic callback may still hold this descriptor outside vc.lock. */ - if (vchan->cyclic) + if (pchan->desc->cyclic) vchan_terminate_vdesc(vd); else list_add_tail(&vd->node, &head); } - vchan->cyclic = false; vchan->paused = false; /* Leave terminated cyclic descriptors for the sleepable synchronize. */ list_splice_tail_init(&vchan->vc.desc_allocated, &head);