From patchwork Sun Nov 15 09:32:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 4116 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mxe881.netcup.net (Postfix) with ESMTPS id A1ED11C44E3 for ; Sun, 15 Nov 2026 10:33:47 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 104.64.211.4) smtp.mailfrom=linux-sunxi+bounces-27662-noreply=patchwork.local@lists.linux.dev smtp.helo=sin.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 104.64.211.4 as permitted sender) client-ip=104.64.211.4; envelope-from=linux-sunxi+bounces-27662-noreply=patchwork.local@lists.linux.dev; helo=sin.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 0C82B2C7E2 for ; Sun, 15 Nov 2026 09:33:26 +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=1794735200; b=xnxNwnzUJ6mkC29iaNvMr14jL2b0cVGf5buFAM80ua31gvz65vVZrDFECjuuAZeA8Lej yyRikACvOC3oF/X/AIa5k/oWbgMdaE9S4kt4HlTKTOB1nytNQRsaADr67V5T4V030qhYX Ullt+J5n7USu3/BS/sXzZd439pOMK0J7I3t6FXmA2TJ+Lqx7I0bZeL4lq0Bg9Zm1Cc69R njg37B+wTKAe+8dQHWzYqaWqwOp6F6PTAuqfPb5TyJPq3Xu1K2Dc1Ps++iS2W5Dqrk6Cm KR3xCfjxI6baO1tGbL8y2krs8TlDbIjPM6n8PoqAJKpJgqEhJLP5a2izE67BLmxrwYw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735200; 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=bPluMEVsq1fcd/2/kENoSJW0juxe38/N67JwApwlVx8=; b=Iz9iA9RRW9c/JVaJmHJmGFujNhuZFSMgltdP1fTZLXu9tgO7qb+vRxU+CKYX65Ek/+g5 9LCGEavBomniEjVUZUtivVplqJBOdrHTpdzqVn4LGwRtdFBrqE5V6IsooahKmuw9OFczV ERCH6UTHQG0Lo92M9WzP9wRIBKZjENVSgYpyixliN1D4RLwGSts5uOUpCoEUvPBQSSA16 QJq7eAAdZUsjMPQbsV2G0al9XQ2MqJBAVomIZXzNgn9dYFGEER6I6oRwQ6gJixIX0QPYc MTey5kSZa6Y7h+g//4OV4qKlRY4815Sdymi5pYUvLleqT/TqFwTY4xqpntKpVEOpRgQ== 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=20260707 header.b=NBesxtUM; 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 DC7D9606A32E; Sun, 15 Nov 2026 09:33:20 +0000 (UTC) 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=NBesxtUM X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735200; b=QIyQZhtVYl3F5zXCr1JYpTcmzz1+x13JVHTgMdPmMQrqRu6ixetBRmLAYeZt5+EBNJn5 yyFPa7BHm6qjDLZVEztNAwyGZQpDtiRRiqyQfPkgumvzcIv3MYnTvz4iuGtAjbr17hYGA apmBgnMztFc5vNt9RHrJxjpeNchCYZ8vo3bq+8m0hBEqs/6xs6FwFZziO66wqt+MSoNEA 4TsOdvv766iveqcFVW8rUSDiF8yVPZKzb4D+1GzImKWgjbPALLWeGS1raLfnjMU60EEG0 ErMO1vabmEWAiYYQ+i9feEXa6L1iHua/qDLpi+gxN4QYcP4Yl4ILQYEnIOzooaF0JMQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735200; 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=bPluMEVsq1fcd/2/kENoSJW0juxe38/N67JwApwlVx8=; b=sr0ku7ZgrB80MLbZvFqqBzkaDSYGmxHMtQx0jB0M9s68bX5/shF0IptXoz4LJqHPf7km i+fWNKHcH5M8EvY033Fie0wg3jx66uV0SIDhG0N5rIYxSa2s7K/gZCdfnZgoaeyhXrD4i 41dO1UP4i3WuVlqgi50om94gXDV9U9U1ors3oKZ2IaR9olB/B3vs3C0Ri3H2vfwE2+l8U ukJDTwLbv9Er0Xf8nRiR+ksp2nTrD+0UnEO2HqtzxMmzI77VJ41xGstAvTSVAkxzn8Ut3 tJb6rnsyE3KQkb9AO5zMAUml1LTz3VtyNwmW8JxVJUXa7lqzgAoUCdloq9A2GO6icUA== 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=NBesxtUM; arc=none smtp.remote-ip=209.85.161.49 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (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 78568606A8A5 for ; Sun, 15 Nov 2026 09:33:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 78568606A8A5 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-f49.google.com with SMTP id 006d021491bc7-6ddef424972so3070226eaf.3 for ; Sun, 15 Nov 2026 01:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794735199; x=1795339999; 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=bPluMEVsq1fcd/2/kENoSJW0juxe38/N67JwApwlVx8=; b=NBesxtUMqpmhjldUwKr+Cw2iHbmeUc9uqIRQry0+mt07O6B4UqhBy+uIohBgBVzBjp 9CEHWjrtGbR7ZaAMz4/Yema56BxbDcjO9yBWrffFyw/Ik34VGZrTGEmJYuM8qgNs257f 1CGQKKuuEKRQsqs1jHBohu/N21SOXU0iujJ9k5E5ijyLeHO7SR7JxWw1LE0c7qVHWsv6 RNmqXJD1Hm+3gOEx7GZj9NPcBFZgpm/Z/3boW4XQVMEB2AjP3/rJfTw737Bqtqv2eWPQ NK1zr8YJLZO4fSKYvN7kplAcXZlUvk43FgKI1PrK9swsxETGl1xzlP4ztBZHfUt5vg5j kkVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794735199; x=1795339999; 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=bPluMEVsq1fcd/2/kENoSJW0juxe38/N67JwApwlVx8=; b=LIpaOOmueFIY6cam/oY8lb84hVOzXPMNsSA2Bq5gj0k1Z0ssOxSiGLebVW/WVAZjxP Aol34ZJJQisPlB8a1H8BGlts/wCgKaLIvqn5ysdI/EuqH484x1v0AztXEg0nnLvsLVhQ z0hvaqfENpVt/+Fk7VngRMaRDbuztF3y5eDKesQW3OTiuuVJCHWRPvn8mWBgEVLtWZs7 VQWyJpO0ZA6JxcjcjYNYK094ZqwDaUFi3os/nTmCERJg13+ln3P19k/v0IrNRvoYUHZo lJ7f/WUhzj1CBoSWIufmIGrlpTD974SDGiQwfj4Njpa0c5XZgPLwOdbbjjPjcuUeAw5e yzMw== X-Forwarded-Encrypted: i=1; AL+hErEi4oCJgR5dv9fqdkMO1XZfieg5jOwvWRUdtOm+1sFXkaqptJSQ92zxnAF1uAfwTN5/sTOIFkT+UTkuWg==@lists.linux.dev X-Gm-Message-State: APuU4Z9qwiKest4XZVzCyU9AFSUsUqOx4xC9j1TVVyBQojT6JOpi1ZtB lC9FV2bfESHbIswVa6w4SvB5iM/KA8ByUP+AxeZQ1dONeYvg/mOwL4hf X-Gm-Gg: AYBFou28+25WbQzIo2ciszUcBVgXXKscjpred4GBdCqHRELPKdDmPdGdWEpXOXuw5KU TJiMPkdKh0VPiiZEu6avPd8hiraNTe+gb5t7K1hLge46nXre0d/pw1UIAwKmojJGG4T5ZfgwTV8 95P7ngijmNsdCJOvlr8+r44lmznQdhQv0x2fNaV+HW5sVYgyFJ7nh+jyOihF3uOUqmDJy/9ETpS vIjpNGe/WEFMI0fmZ/5r5sekG/GK0I2aKv0F1BgoFiOYCeQ8sAzA8JGBbzSoqjVZ98kKCuXW2Cw nHb8NGAWtgGz5TrN8q/9FITmc8UWorshUy8rZpVqMalpfFpRPboAWywCUS63lM5kM/f+l3ir51M dN3bnNxQYNpretq6yPeoQLj13zGvj4uUwojoh0r0a7F2Vj4CoPsy12mPA5docjLhKem8dTdQOoi AOPxIWrAicdV6x11Auv9wxqTh3mV26gF51CxLgNbcBffXFY9iGEWVYUfC4rXv+pKFrnsuKg+jaB r0vt9UFjlTj223kVmgwK7oe1iWXtbKTIv947x5xt8KwtAeU0Khiq3lpLtW6va6pbhBOnuVvNYdL GS//4ex1LLUyvrpTNnq2kOjVYT3nuFQhMUTGNL6tcSGRjFKefjrZvdCoz5n1lO0dJUhJISNQltd GApbm5gmVCwSkFFJaNQcvNeQrlPTI5cNQ0/P6FfR1nMSW9wz6u+YK1Kl93yUr7qeUySlWnpPBqD LiNu3snryLViyoVzu0xxDQAqr1ibTnp7KXGLb/k7E9tntehfcEsC0= X-Received: by 2002:a05:6820:1627:b0:71a:ee76:d7c3 with SMTP id 006d021491bc7-71aee76dd86mr223150eaf.7.1794735199376; Sun, 15 Nov 2026 01:33:19 -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-71ab43347b9sm5933617eaf.12.2026.11.15.01.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 01:33:18 -0800 (PST) From: James Hilliard Date: Sun, 15 Nov 2026 02:32:53 -0700 Subject: [PATCH v4 5/9] dmaengine: sun6i: detach completed descriptors before invoking callbacks 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: <20261115-submit-sun6i-dma-lifetime-next-v1-v4-5-043cd476a45f@gmail.com> References: <20261115-submit-sun6i-dma-lifetime-next-v1-v4-0-043cd476a45f@gmail.com> In-Reply-To: <20261115-submit-sun6i-dma-lifetime-next-v1-v4-0-043cd476a45f@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 , Frank Li 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)[104.64.211.4: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_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[nxp.com:email,sin.lore.kernel.org:helo,sin.lore.kernel.org:rdns]; RCVD_COUNT_FIVE(0.00)[6]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; TAGGED_RCPT(0.00)[]; FORGED_SENDER_MAILLIST(0.00)[]; RCPT_COUNT_TWELVE(0.00)[18]; 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_FROM(0.00)[bounces-27662-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:104.64.192.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,209.85.161.49:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[104.64.211.4:from]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; R_SPF_ALLOW(0.00)[+ip4:104.64.211.4]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; 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: A1ED11C44E3 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX Finite completion publishes a descriptor to virt-dma but leaves pchan->desc pointing to it until the allocator runs. The virtual-channel tasklet may free that descriptor first. A residue query for another incomplete cookie can still pass the retired descriptor to sun6i_get_chan_size(). Clear the active descriptor pointer before publishing completion. An assigned physical channel without a descriptor is ready for the allocator to start its next transfer or release it. Use that state in place of the completed-descriptor pointer, so residue queries and termination only consult descriptors still owned by the physical channel. Fixes: 555859308723 ("dmaengine: sun6i: Add driver for the Allwinner A31 DMA controller") Reviewed-by: Frank Li Signed-off-by: James Hilliard --- drivers/dma/sun6i-dma.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index 5d39a2c0c2e1..c30e244e50ea 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 { @@ -492,16 +491,12 @@ 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); @@ -538,7 +533,7 @@ static void sun6i_dma_tasklet(struct tasklet_struct *t) pchan = vchan->phy; - if (pchan && pchan->done) { + if (pchan && !pchan->desc) { if (sun6i_dma_start_desc(vchan)) { /* * No current txd associated with this channel @@ -584,6 +579,7 @@ 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; @@ -603,13 +599,15 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id) i * channels_per_reg + j < sdev->num_pchans; 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 { - vchan_cookie_complete(&pchan->desc->vd); - pchan->done = pchan->desc; + /* Completion transfers ownership to virt-dma. */ + pchan->desc = NULL; + vchan_cookie_complete(&desc->vd); } spin_unlock(&vchan->vc.lock); } @@ -985,7 +983,7 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan) pchan = vchan->phy; list_del_init(&vchan->node); - if (pchan && pchan->desc && pchan->desc != pchan->done) { + if (pchan && pchan->desc) { struct virt_dma_desc *vd = &pchan->desc->vd; vchan_terminate_vdesc(vd); @@ -1001,7 +999,6 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan) vchan->phy = NULL; pchan->vchan = NULL; pchan->desc = NULL; - pchan->done = NULL; } spin_unlock(&vchan->vc.lock);