From patchwork Fri Oct 23 23:38:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3715 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 DE2C91C010E for ; Sat, 24 Oct 2026 01:40:14 +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-26839-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-26839-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 B75E63CEFB for ; Fri, 23 Oct 2026 23:38:41 +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=1792798721; b=rAwa08BO79kzHIzPph3ohhyM0IMigt2A8khygbK0H1XtD+jbXXzlURFuTflBpxHeC/3G Ij2pxYBO6Ugrp2T7KtWiHG/7e8oITxBzAT8KsscLnY0C+bbsVgMUqClCr+FhXLJBGnfOH zJpduNniA0TkBSayxlq6ZLuQK3oqAa1G0p3tNcmzS73/QElPo9JOS5MXTfL+7FjEnYnDn YtvLMKp7A1RYdI32LmSldTR6sjt9207mu4nHlAaCXLXEbFCqV6NBqfOQ00IyWSBIejtAZ cqRqieV5s8zUKSkDVlRcZdmlc57x/qkIQ8ksEaFgZWiPTtXq1VNyVSPffVzQzaBIKRw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792798721; 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=vk26c3BTQSmOJJ6zClJ284dH3SqVTC5An1nrNJrjOFw=; b=NZ3A8yYvXe0C692JFBXKB2z1JDg9uzvgC9BYc5C/dmWdwiDal5BCdW1oKn5GnuQ3JXo/ wAuKp4gUgbhsAPHFH08GaP3sWC3ch0NjMUho71CQ2FxLx1xXJUgry4z4A0yCx4mE15EHs dGa5Uga27f4iRQQop1z71H6gaBKyZ0r2wMDoxgvKziESb5c1BMhT+hVfxYKaQPkmeEVaz T5PfKgGg5l4qjP/OHXTuOfZMLJCx/y4rn8F9VrfCvmpvSjpaZiN4QIm0fT8kzVXPwXGSA RwknBijAuJnvydWmClYb9N6RIOycsvhpLGm5pilS3GJjXTJr0zPr5Ds1yKMJVhqpYzQ== 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=YUOpcbFM; 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 7357060A260B; Fri, 23 Oct 2026 23:38:41 +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=YUOpcbFM X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792798721; b=NJClIsJPXAu143F8SZN/y+blBgiWgv+KEfkuGniAP1ZcnDRxaoZX1QqR0XhkEbHEPET8 ARPLDNBycapekOLDgIzAUsN069IovEk0ymbE7XKPVGL0mAWBFg5/YlTQjFg+UbD67mnsc cvFn5y851DwdfSKwIugKQsLsCBJgwLnNGdO9MOgjetIP3hl2r3ThM35Hhh4aELWVYxxT5 OzxpWcN0ZA3bd0LuqDJ0c58TTg4RjfsxpjTRvbJ8iQ3Duh6YZl8bEqSKW8GEqoyHTqE0/ R0p3pwWwCVVIZ8SGkjBaeh/MGDRopmli1omfirbDR/x3GNWpECgGxc70gHwBYIsPI6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792798721; 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=vk26c3BTQSmOJJ6zClJ284dH3SqVTC5An1nrNJrjOFw=; b=MBWSXfQbyVhu7TvyAaJxx328kCrRp0JfMepZPYPjuuFto07w1Ie/ebSdzr4IBfmxGBtP xcD0ZUsuCWcgy6s2uBJMpdK0VaP5TBLt+01UC88cM9wCxvUVQDaU7iO5EJrd24lkMGntP f9bq9VFvcaydhJQrGzLuT03Zo1AaNYttZPQYwGhW2jUHyEh6RfLhdZosvVLul94U+Kf9Z GBycV9/Xsry0JDK0KfBtdrVkFEY9jT1o9K8+snLJshNRVjh6Wz1zFoOON9QYLaDT1t1wF /8SeTN4AUPhzCmuvhvUEP1NRQyTBnjvx5vC7DBNfNQps8qLTxiSrBdB8a2tzW3Rumww== 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=YUOpcbFM; arc=none smtp.remote-ip=209.85.167.177 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (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 65E9560A2609 for ; Fri, 23 Oct 2026 23:38:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 65E9560A2609 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-f177.google.com with SMTP id 5614622812f47-55651e7de9bso776612b6e.0 for ; Fri, 23 Oct 2026 16:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792798719; x=1793403519; 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=vk26c3BTQSmOJJ6zClJ284dH3SqVTC5An1nrNJrjOFw=; b=YUOpcbFM+aErvs4u36vrzZFSCMd9mrIuB4ptO3MN3SrXRMggI1fVrY0XobPuLTXd6r jT8v5byoP19WDHlXhl5Oi0QBAfQEIoPFP6PICFU+Dt8qZBo6HfH/Ed3E5JbC59B2enpL 55KnzR+hWZydtYSvpwvhKISnLISulV4/FTwvfNQON+srtYr1uPWPULR4rcDWwnX4OwLF PlLuG8YLjb4srfdevVrcl89xYTdWgwDWoAYEHFVZJh96nrHKxL1rmjSEfNYLH2Uq2N1u YaBuWUjztOypUsem0oUlvGqlnLwhZsTrJjoQzjMdo7n6eHackBPv8R68vzQf7UPKFtc4 i8DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792798719; x=1793403519; 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=vk26c3BTQSmOJJ6zClJ284dH3SqVTC5An1nrNJrjOFw=; b=qOxEjk2YHh6rBKNWzlXIrc07/Qoqmr9sBoyTQi1NgFgXd3961OGkb/RkIEVaJ2l1gK ir/HIjSfDIPTeE4GwWd6B7GxAzT7cepk5z5TxklKp1EzXfrTkY0i4/dmBS8HBOu74tXV zIkRRw4DnwpWz8cTL5MMkUc02tW4psuq/Q3jBfmgjFO4n+IV8UWb3RjZJ+904K/5In0u zYw7na4lktDrC6chlQrrjgBgzsJidMwb9OCnQ5ybRXlQcHJw3Z4vax5bFDz2oN7eBYlN 7/dgBNbVja4dkqEm5rO9ToWy0t4cjcuJf4EM4G5mnrA17u7akljewxgtLPXgrZlHYzQY 6ytQ== X-Forwarded-Encrypted: i=1; AKwUvBwI04coBD7r/p+2NbuAcSAxrkf9uH0za9mdeHe6rUCmqmLvwiD18m2CkSMLQenSj/+9zwO/ewrAASQj+Q==@lists.linux.dev X-Gm-Message-State: AFq9FYKbr3Lr6blWWTByLA20ujPfSr9LbtAym8IxN7fAZqmDzgMgZlNx Wym8Q7slx+fH1WTFKq83baLyC2HDFEquSB8kKakXkIS9RAVdOZPF7WC2 X-Gm-Gg: AYBFou2DL7MkKDgSWRpVWttiBBzx04UTuO7Cx2Ba+mtAjDwZwSKTGAdmRX0Pxjtyai3 hOYBxT3IY/gT6eHGv/L42jWx5+W0GXSnVBNBsB0RQfsSKQykS3FpYqaqbfiBX2FSbKRTEZOQmiw x4SlAWLEqLz7kp7XuqnqBk82P7v/rqijke/sFHWcM+EOR/BOh/Oo2Cmx7SRUVw6bIQ/EQ6SBjqd eWKBBkzdvoB8Ps/3BpMBfXuXWjguxRsyQKn5kGZ7YgrI1PGR9bVwWNw5qSs1lsG60QLll3b80CU WGs7C9FER62+jjQM/XSlH7LP2bnKjWiFUaX33r8mgRwM7NAiZHy74+YTVTS3PDO5iQX6C4uKwmS 3Wmq2AA5Jk8BMUrL6ueId/RI57P20Cxi1OgGkw4P7t3NMS7D0boaDXrVXserti55lb2RidNglS/ /wEaSO8fFQO/jILezu+6ieITg6o7GcM4UAkmBN9y56yT2R7Pe6WOSY5XTOkCTYT+Qyeg9Me91ra on3Y3LKiXfxZ4lT2Hat7yn1D2luVLnDe66lK9qP5EhTIX2edEKJjZPqbMWungaoKy6KjxKe0JCZ MuH5vB05ukwcWGjTtTfnvIQ5L7YDgWKLLTFXXV+dmuDUvu+tUalL4xbnKOrG8t3hflPH3z4idEa 3x5nf0clEVk6wVNt38ZikMQicj22KCQqhZh4MvvbTvfR64YuUYPFFk8DMef7PF2r+b89YuIZJAk 2nnHUVAyTg4VeTwEFxYKRHZ4OT X-Received: by 2002:a05:6808:538b:b0:4d7:2721:cfb0 with SMTP id 5614622812f47-55c002e295emr491276b6e.31.1792798719329; Fri, 23 Oct 2026 16:38:39 -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 586e51a60fabf-4a843225d69sm284345fac.15.2026.10.23.16.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2026 16:38:38 -0700 (PDT) From: James Hilliard Date: Fri, 23 Oct 2026 17:38:24 -0600 Subject: [PATCH v3 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: <20261023-submit-sun6i-dma-lifetime-next-v1-v3-5-ef1acb0be768@gmail.com> References: <20261023-submit-sun6i-dma-lifetime-next-v1-v3-0-ef1acb0be768@gmail.com> In-Reply-To: <20261023-submit-sun6i-dma-lifetime-next-v1-v3-0-ef1acb0be768@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]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; FORGED_SENDER_MAILLIST(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWELVE(0.00)[17]; FORGED_RECIPIENTS_MAILLIST(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)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; RCVD_COUNT_FIVE(0.00)[6]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10:c]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received,209.85.167.177:received]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; MIME_TRACE(0.00)[0:+]; TAGGED_FROM(0.00)[bounces-26839-noreply=patchwork.local]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: DE2C91C010E 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?= 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") 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 d3a63c866645..900bb629ba3b 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 { @@ -490,16 +489,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); @@ -536,7 +531,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 @@ -582,6 +577,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; @@ -601,13 +597,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); } @@ -983,7 +981,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); @@ -999,7 +997,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);