From patchwork Sun Nov 15 09:32:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 4110 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 AE04E1C58A3 for ; Sun, 15 Nov 2026 10:33:18 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27658-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-27658-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 988C82AB52 for ; Sun, 15 Nov 2026 09:33:15 +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=1794735195; b=rJs7A/gyOKDukqcOVI9iVOk3+mMeRsES33V4QLR3e7vvZ1htXwanlQran45YYUrdknfF 5yzN4OuDrbA7DdDaZoUZw8n8cCz+8ihQUTJuxkhrH1TzBofmUnmPpC6uy9F/agDHnIWn2 0ZpYvjQ6l89S/Rsc3XSjWmGtq8sBpqsUwBR+m0oJ8lUzqvhsU+BH5ZNNdfXMaWWZ0oKbr DXZvRnlhgBm/TKwxNNn540oJyRCEOUX9wK/UvqKpVmPlgn10xYtPhnAj4twcLWeUMIX6p FSP3XKQAnpkWt8uLw2LUUpyp/WOzGE0W8hiP7lUYxq0u3xfUqEJ0ysIlWpH89jIgDrA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735195; 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=R2O9ixsjiKLUJuRb29OcTSyZsQI1rKD89T0Os+kzNHA=; b=j+DXsDy736yVrcTApC4thvBD0I87wWUK8HVF0xCHVc9PRyLUuLAHQibz+Rt6v6Bj6pa/ KVqNh7vilih/Qqq8s4zhklxsfO4n5H+X9kfYFI2MUCJilSTn2+e0KD+tiEwpyzr+M8a1l Sx9vacE6OvYxuWC3MdLTpFuBHu8EqmT0vmkCiFqyRYkbKN7T6YJjslnnl9bcpC2kW7dav uOCsNHrExGmrf4XIjQN/WCJVUznyUBFd/eEp3AwspFy3KjJLVDy60T3zF5DYrVqUTTJYy OnExW5uyWWTgOOKeyWH2JRbNP6FxCcyxtNnisb9q3mRH5AqfeeZ33jyeWQOLLYhoIgg== 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=iR1q1aZ6; 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 2D7A2606A331; Sun, 15 Nov 2026 09:33:15 +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=iR1q1aZ6 X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735195; b=m0Xox/rT4RfD2S3UHEFC/zcMhnTiGpt8CA85QYGqR2WWlugqgVnZ0KEtZprrtuho1DF2 rMa4g1eRINNiB4EaEXwFw5M0qtJ7Nh99cSp6f+QWhp8O3sAUwD32YC0aAwlfsCbvC5uB0 QA5wNix+rlePFJxmR/KtnTgCCOx/CH4hOcpqrVl/ZRjIq5R6SHiMmWEWO1ZxHjw2dUwPL FUGzuk2Ef26tC6S8ZvoazyuXN3gtgLBmAWABskZae+Ghz16tGbsOGGP+AHppkiZsMu14A BA0fbGTUtH9pklPfWK2cRcg2qOB1aaSHHt8DYwXUvKjCEdOu+86Appi/qgp5I03fhbQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735195; 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=R2O9ixsjiKLUJuRb29OcTSyZsQI1rKD89T0Os+kzNHA=; b=WECto6tclkgaseOh/4Sq2JxJ1KKWX7LXJdGd3KYGAiFS5PB6KBoVXv9QjRnt+zigKOJI hnAFWTPuKep+l8C3tUqVyoM2bp9ODP69Fq6lTgK4ghP6bBdJ2cnxap3vjZ08k2McCThmA BM0Tyb0rx3pKUsSrDhW83wq+dI6gLkg8CzQAB5Nc1mtpobYiZn7DpYiIUJON1nNU3mYOX PVW97RBdsR6z0J0fho8X4cSglqSNmYrspftJHJNAUY8CZQPvA2YmyxNPgkpDH5xqMRqIC pajRubBAEAPAn5q2yFJ2IcHChkwJhg508hxWvl9xBXly47kkGpAfkGcnJqEp+GT0lnA== 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=iR1q1aZ6; arc=none smtp.remote-ip=209.85.161.52 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (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 BCBF0606A337 for ; Sun, 15 Nov 2026 09:33:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BCBF0606A337 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-f52.google.com with SMTP id 006d021491bc7-7190d9bdb2cso2300014eaf.0 for ; Sun, 15 Nov 2026 01:33:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794735194; x=1795339994; 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=R2O9ixsjiKLUJuRb29OcTSyZsQI1rKD89T0Os+kzNHA=; b=iR1q1aZ6oJ7Zi3OzIGRoQ6ug6X2EWhKtmkuMWW5ySE2BkYPSijfbwnlcnk1XWHwE81 p/GXrJ/tIIDEqvu0XzAq/FupF5zAQ/AlckK+E1YI+85uVXiGVFYTc6Yl9P7mD83HP19J fjOFA2+jk69rqhmTPGK/2NS0fBjvOPTwK3czESwNsV2+FIeLq5oKFOVlEiAQgpnwlsVT TP+e6v2nbx4T9pQ4a40sfC4PlYQnHPVpnYPSXEtCj/AKMN0716jyGvkAe+VGbbt2hjmT 32j3z/aUH0yHfNeyfY1rHuBld95VEU7GlIjXYvWDo1HxRZhXJ0cX/vPNxzrLs7G1ZXdi leQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794735194; x=1795339994; 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=R2O9ixsjiKLUJuRb29OcTSyZsQI1rKD89T0Os+kzNHA=; b=ewJeq2qqlEfTEP0GKb7NClCrHeteyfQeP161wenwOxaW2wixo9jvgTpgjAsKmTgUVZ AiEBCcV/t3UBlrvpJ8uxqNwRwu/MjQRHJMUUdBMyn7L3lkk/qEdXJx4sq21zWQe13t56 YxqeUgUVVxucf+nMsLyek6oNElAtqqBZYTQILymPDJt2RabiSlRyTW3i03H/N570RYMX PmfCMJ3TrkF4d+4OZDhdDIHiwDdbZd9ot8PTKcQYCSnPOWQ+sFkXovPMAEyvXFj16Cen hM2SWa/oww5/tQug+XBY1aWhu41OxCb8oCAIoKcDkdPmfmuR8pkbblUZ12KLk27fE0y7 h1vw== X-Forwarded-Encrypted: i=1; AL+hErEYh7N9aNWvNnrUcYsvfP9zL+n5kMGWcykkIM1qN97QhIGyvLkNmGpr1rzeW2qGHUJjFH0bzWp9AnpYlQ==@lists.linux.dev X-Gm-Message-State: APuU4Z8sHJyM7b3ULQ9efnQgO2cFRad9K7ea00a1UKBNlPGQ3tpLTMH2 /a1BUP3pFxCRDWgok7M1OyFRE/JteFn603BHF1A0Q/5a8orb0H1Ls2Lf X-Gm-Gg: AYBFou29qwSOUf9cW/+JgBAyKakhqPDAI+jZK8eAnT1RAJ5CRo2ZkG98glmfP34/8lO 0ibgItj2N2SY3KGAVoPWUXtPxAxi+xASTpGxul99YLcCZMV+KSuWWFgYYL5ANc7Qgx2woHrOgkt ZDYf/x9tdULB5G+iQQUKAwuWFFwVh5oGsPYIP9waxGaOWDpAgoSqd2NO8IyvSV479ikC0uS4Ziy M3Vz4Vo8CnoqeBhZ7V4GWo/yK7UxLrjbDYp7ibjcXGt4l1KKtS5pmJUag6oi4qq8xENN8chJQd1 8F41lg7/OJEv0Fg8MM2WLk7AhwI2kIoqf+iNzDQLESRTrFqn9Qu0qvwh0oNeCPQhUB4adLkTtV+ MtUqNwIU1Q4ZaF2FmDfkry+WhfmIMjqy8AjD74dEShbGBUmwWLfQ98b4R/lgvucDCLV5r1QUmzr vgkaTxtdCvJEcUJgfNRql+n3VswNbe2/W6/GsD5Ka6+ltmaVE/5Yf5/KBcL1UFlJQXrIUpbQrw+ g1tcN0EOYhw0qEY28kBqs+mtUll32RRhXLV2dVKI+qBKTIseUEz0AJ6JhZ2tDhEDqihMeXR4VBI hKtiZOXwsj16PbxcipLMtw3XeD/CUmll1K00XXY42gx9nxcnBrkSeNJwri4OPRzC52kXQL0Afxh VVFcDPnL4X+ZLCJoahsPvi0YpMaEXSjtA9NdYKDJIHtVVVnMU+s3W0YbDULUmcvQQF1/cH428ry DVn8f6gJQppLGy464cD65qczaGxOo1tJQbd202qplwb19fkmte5Gw= X-Received: by 2002:a05:6820:c3d8:b0:717:da:ba3f with SMTP id 006d021491bc7-71ab4fa7032mr3576066eaf.18.1794735193626; Sun, 15 Nov 2026 01:33:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 01:33:13 -0800 (PST) From: James Hilliard Date: Sun, 15 Nov 2026 02:32:49 -0700 Subject: [PATCH v4 1/9] 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: <20261115-submit-sun6i-dma-lifetime-next-v1-v4-1-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 , stable@vger.kernel.org, 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)[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)[]; TAGGED_RCPT(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_TWELVE(0.00)[19]; FREEMAIL_CC(0.00)[kylinos.cn,connect.ust.hk,embeddedlinux.blog,vger.kernel.org,lists.infradead.org,lists.linux.dev,gmail.com,nxp.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns,nxp.com:email,kylinos.cn:email]; FORGED_SENDER_MAILLIST(0.00)[]; FROM_HAS_DN(0.00)[]; TAGGED_FROM(0.00)[bounces-27658-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received]; RCVD_COUNT_FIVE(0.00)[6]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from] X-Rspamd-Queue-Id: AE04E1C58A3 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: 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 a57f530c6f70..885cb237b2b9 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -605,7 +605,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 Sun Nov 15 09:32:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 4111 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 046421C44E3 for ; Sun, 15 Nov 2026 10:33:25 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27659-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-27659-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 78C952E4CB for ; Sun, 15 Nov 2026 09:33:17 +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=1794735196; b=FkVhdm/FmekXAnV4H88VLY4o58lkfe/e02WV5R8z8ViyEiFpePwfCh1fni9yym2SDGQV b0NYrlOMaCM2XyertK4pBX9Z+P+HG8heCOffWPSqPUj973j9KcXXh5x3uAlWsfWfYl1FA JXVzhE2bj3NLMhI/nhE4cvPLYbKYy1nEag/QvazNpSHP+qIf6h73kGya6/MSZp78XT+3d 5bKlk6+S4sOVplDqte7G5ycuJ4UMy5WgJwU+cnD6qyEABngze/JCjd5ggSqhyCuJSxWFI dWa2QB2+DaawAfYWUFu3EC/Fb+Xp67sH2I1LSUT8gM4knJY+su1ACDw/O5FU1CMxlpQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735196; 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=w8G8ifHYAKfhALD5ae+dZe67OgXfj22iPEwtf7Dbt0k=; b=g5cI560L6biyNSvOyVXXDVigr+YTLongkBm+2F37za6S63aZ+GBbMJ83JxOxR4WtYZg/ 4a8yK53FH2GNMXCDwmD6KnKVSxcXCvIHe85AhFep06z/sX/TC3YxK0w82CBvD8sFnCxGe apefNdABiTNdSOjFQLMPCTtACVymeobnk91ub2bDZ6M81NJOqQLPXEUqKMwLT3GV47vkD 8Qss7zRPKXRM/OlErJfXnSXi4iQN5adXV2glkMxlmA9yll5P/CtmIzrKKWb0CLMOlZMmQ l+uUb7Weiku0617MaPXZTHWlS9SFPc8M9cCIYw9kc6wF7JXMN6NRrPH1E6GIFMqCOCg== 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=S131ZIaZ; 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 91E3B606A886; Sun, 15 Nov 2026 09:33:16 +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=S131ZIaZ 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=1794735196; b=pUC1Ou2/6HFvUqxrtbQohcrgkJ3M6xVSbeZEkBFLPBpY1R5L0trwQQdRRFd1Evn0rJWr FW0e7dX8tSnxdvkTRBM2JPpEc6xtf5Gmtuyb7eE12WRH6BS8dzc69Y28wpxb2RFFWxIVa 3HCY7z9D6jfhnrXvGqsqLNUDH6gmA7V79YFEB5Gc87ZnShAuZJZqIfTXPuHyTSig1HgsL YgrqiMaEH1T/7EF+Wz7paVy1JcnkcouRFdJlkKwQ3zy00OJxmwKgv70G5DD+Mkik5Eh+Y yRVZFKFRVN3LzD8WSH3KnPf9YW1FCQwSaGVhCsqIR0gSe4pTfu/jCKjfHMnY3cGRMww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735196; 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=w8G8ifHYAKfhALD5ae+dZe67OgXfj22iPEwtf7Dbt0k=; b=RMhAKmXI5ohz0TsqltheIQUis35qIEE+aD+nJIlD5xQdjOfci01l8whos1abIAYkMO35 yBCDMN1/2pP/bE06oyzAA95coem7OXZe+LKOpe18h5b3qJCVc05uSK8bTdKj7UDMYzpMH H8GMtVObwaXEl77pt/L4pDbZt0sIH5b4nYzlf5qLPDzNtX6+i6+l/5+jie0OOTHjEKEtH qQK/xm3yKxrGSCk+rikPmTDnL5tXaEWMLN+7f2mMe2dbG29CoYpWxlpNgH7ru6A8weRLo Y3OtUdBW6O7+oul8vzMDg5Bvcmhv2kAkZS2t1E/QaEdBeGsJkvMLcq6T0PbgIKnUtFw== 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=S131ZIaZ; 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 26DAE606A337 for ; Sun, 15 Nov 2026 09:33:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26DAE606A337 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-70b875f6f1fso2980225eaf.2 for ; Sun, 15 Nov 2026 01:33:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794735195; x=1795339995; 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=w8G8ifHYAKfhALD5ae+dZe67OgXfj22iPEwtf7Dbt0k=; b=S131ZIaZ6mMQnADaKxWtZOqwPvRDBs7+NptMmrpTVyLOnbWVTXRJXvoEnPxCmHPTwz yYxYRsW103LEX/30F54l6T8dKj3nzyyPF+7uWa2I3XT8PU57qQIbgXP480M040mEshSj uVAcQAPumClQIUH4xXXCnW6tkDVQ+0Er0fW1PqkB+ZchOUF6+KJncMXf3nnppdtIjiBx 7rE5UsfjtpRIgayukAw7zfhpnxIg6Q4vgW2vRUlL53Y4I6Vv0sl05mg9hYtxaSrZAMNJ 7WXvbr8axeC0XF5350U5rhwrxFeiaopFD7ZK3WEQqackzzp8/68qb0LrkeDF/0Az3Xd7 Zpfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794735195; x=1795339995; 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=w8G8ifHYAKfhALD5ae+dZe67OgXfj22iPEwtf7Dbt0k=; b=sguCx3Ud3uzAMgNgiBbpULIcA8o/vASulBnFHW4qaFzPNBTisOVWj43B0Ftj5BxdVk ixbKoTeUetDF1OdZyENJe4dDMs4T4od3qtK/ItJp+eOQfWcanJKVdzYfikniHsnDD0An KKDRFMq7mj8CkJcZu/ft6OYe1SR/fYf5eSktYAzsFc6X56PTQa0EIkC/VuDU54MFBMCK 4YhwqdFcfTwfqYmJ091FBL98HOQFNBwb0blK3wzaO47UisPw/5/qQOEX7hz7Thl3V8a7 Mbbhn8vQ3Ue5zhdmUpALyfa4/cPX5jck0r0rOZ1NmruGtXmHamwMpSGocUBez21lpMoM Epsw== X-Forwarded-Encrypted: i=1; AL+hErHRtCJNzLWIIbmEaxF3UJR/fAekHcuCLVM/DlEYEimAQVTCvAq/y8rJy15FeYomcGo/4Wu2OLpUSwgWcw==@lists.linux.dev X-Gm-Message-State: APuU4Z96fDTthXThgIocdccEX/3QHm2yaRr4ajZ6RSROgeJ8cBwh+lhu jTSHVdKkD6qKXYPURIv+NM57gl4be8eRva0tHjaAecv0PSgddFjlsVUy X-Gm-Gg: AYBFou2xkN0CWIvRnkeibapYa+lQa5BuTt9c9VYZTRe8op654wLd/KiQcxL7bn3w8Q3 WGGbD9LXjOL5Mpchpk05K30mGI3fQorf/QU8YEMmw6NKHH2a+e9nv/cMSSrzo9ysaUMRD6ena4N FmoK7C3SL5ghdPNaLwvyP0a5o8FQvy7ptkJ/vr0dUiHQ71BVaEcG3TLEU1wVIcA3zFQKelM75BB +I3WLQ6mee6DRUPE9SSBv474mpUC+FgSISguzuX1ZVnVL45qfjUkxuxlnY4vbdqG4HmRLiP8hxW FUGsGjkEAT93eWllGbz3psx/bT/NSJsA60OHvT5kI4Mb0MDJqNDFeXhoeC64lx0IBfghtql3FVK 3RcrHMx93N3HaRS67YwIj6AxrnFkPfplU2uR9Om8nwNtxIYDD6Nkv2BuwxUrVmQrhPH8jcHqF5Z teSCXlhtZlYVt7rGjoI182ybk9dvoMJGyOzNZE1lQ2Fa+oDagSyQYC6pfxg3P2khfx1IP0QX9dJ AeRFyAzH4g7x/s6H/uDyX/6bkbNkaqzNbDnw4WkvvqP2Bi+6cuEUvHhcinyY0BF9/ojAztBDqDH 9Eh0QG3OQqTt8mrXGxBYHNWdTBRL/vks9tbpYZKHuOn49HyN+XjSvMF/VrXoM2HBQ4eUjdV8fzT N+42ba3S5e1y7FMSkOmcdCjamesZZCelo1bteY9Kzj05b2Gs0Ny2wbBHwYNfc2/M6ZzgFDnnXlM 0HP6ZUW+vsQUVCPWXBRlVcONpuwHS234CS3GJuNtCq1OkZrQ1S78o= X-Received: by 2002:a05:6820:4a8e:b0:71a:ecfc:4434 with SMTP id 006d021491bc7-71aecfc5888mr297943eaf.61.1794735195084; Sun, 15 Nov 2026 01:33:15 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 01:33:14 -0800 (PST) From: James Hilliard Date: Sun, 15 Nov 2026 02:32:50 -0700 Subject: [PATCH v4 2/9] 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: <20261115-submit-sun6i-dma-lifetime-next-v1-v4-2-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 , Sashiko , 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)[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)[]; TAGGED_RCPT(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_TWELVE(0.00)[19]; FREEMAIL_CC(0.00)[kylinos.cn,connect.ust.hk,embeddedlinux.blog,vger.kernel.org,lists.infradead.org,lists.linux.dev,gmail.com,kernel.org,nxp.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns,nxp.com:email]; FORGED_SENDER_MAILLIST(0.00)[]; FROM_HAS_DN(0.00)[]; TAGGED_FROM(0.00)[bounces-27659-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received]; RCVD_COUNT_FIVE(0.00)[6]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from] X-Rspamd-Queue-Id: 046421C44E3 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: 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 Reviewed-by: Frank Li --- 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 885cb237b2b9..9533f3bdb949 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -589,12 +589,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; @@ -604,8 +605,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; status && j < channels_per_reg && + 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)) { if (vchan->cyclic) { From patchwork Sun Nov 15 09:32:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 4112 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 64ECB1C41A4 for ; Sun, 15 Nov 2026 10:33:30 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27660-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-27660-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 C59A236D05 for ; Sun, 15 Nov 2026 09:33:19 +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=1794735198; b=ZqUkhoBVYKIdDoXpfOeNexOpORUU0p3xeuO4sdSKxZpzLUP3YkzZ/WzTQr5zsgXyS7Ud edxbAkoJnhYCJWt+iH7jTtTncNvJ+gLpVpiE+vb1x9s81YlIV+p8ghAt8JjZjdlbC9+LF qXjP6Q2ksf0KbrkDvkJ1Tv/O5aDIgYgNddGun6is0tZBwj/F8jZ8j2O+UaSRmZXihn14w xoT7U+Wpk9pEOwIH/Gopi360Jb3c0PfgzEWg5fYxPAzkkw7Ll8Jor9mvI5AEDbZ7NcW2K T1GI9dt8j6vFXLCJvZmKK4Hfy9Iet/BuLG0Hap/DwOhKjyb+K7/BbndO73ClVJbibEw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735198; 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=ULmfgjA8hHN0IGqRl2n23MUGsl2Syf0XQisPuEg7n6M=; b=xzKIljr0yTJqxDRqk/qV+OSYNDyyJmDlAOvcYKd4M5QJa9itcvAgDsjZznLYul+IHRpJ faNJtiSFFe04scnJ+UOdGKh4Mn76Aze9X526jvkJQgRE9b5OrAxDt8Az+IEmOobO7l+Sk ewiwOr/NRITiMm8BjMcAjd43PNNMJGICCEEVSySuOqRJNpzw4jQU9oNNABrLhVXzHgy65 CFXce2vd3HNkdebnmbRzZprx69i/SDy2VIqz+g1vBioAs93tLK9I3BO9LV4Jgh2sGXMUL g72PBWu0+EQZiQMguRmW3d8B5zkpKhYHT4G3O8QfowNnUToYccJ/jln62yHJHtnDVBg== 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=regd0l0n; 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 EF4EB606A894; Sun, 15 Nov 2026 09:33:17 +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=regd0l0n X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735197; b=bb7AkrE+pXvLBw5zo7R88Kl4lHDUq324+SOkP3EHVdaYyl8F21A2ywNiQu/5YzE9BsFU gX8NLZk66xuH0p6gEpOb0lob78AsexFperrNFnvE2SU/1s/BHY0mlMtd62FD/LuHIwt/T z61Bhfcv1/FIBOoKkclOLZx3wDPBWdYxicoaJ7jiPH+TvU2Dm7FzsJpD2/QHzUupzWOMj vIqSyB8XsVO4wXFw2Vtmvg6b93GFhilNCxPNUnwRGOQ1O6GN927I+BVGJ6Pc2tniElgrO u24uzLyHxElPj9SmuCD6740uf5qOusjDzri93KowWFKsTG8gBKiRBYwYDBB410aGicw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735197; 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=ULmfgjA8hHN0IGqRl2n23MUGsl2Syf0XQisPuEg7n6M=; b=W++nOlnbw02NACcTY9oqwKdpZKvFh8YeJIzOZYAE9Q5WB3vxeydxLC9iHjmSThCp11Nq uI3SykBl/9GkN0VDvi5mQHkKicMjPBRSC2Q3SoQiGzsRwoL2FLyO/P/5n9xyrLcChgO8f nNVdLNbiUlpLfF1SMmpD9/aVrBCUDkjPrxwP9yJ9d2v14b7Lncp3HG2S5yueDHsIV3xWk O4kgfx9+bcJsysG66wbKEkoZXjGCSVUcFzI+c/A6jIauX6q8nWEwhwOuOZM6uWbb273kV k0lO1BO1H2Nudlc5OK4vx+Kwm3X//k9P8yhbzkM7JhMS3oANqKO176Ng9PjqOdB9IKw== 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=regd0l0n; arc=none smtp.remote-ip=209.85.161.45 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) (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 84DD7606A33F for ; Sun, 15 Nov 2026 09:33:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 84DD7606A33F 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-f45.google.com with SMTP id 006d021491bc7-716d052dc23so891862eaf.1 for ; Sun, 15 Nov 2026 01:33:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794735196; x=1795339996; 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=ULmfgjA8hHN0IGqRl2n23MUGsl2Syf0XQisPuEg7n6M=; b=regd0l0nLo1+HQ4IjCgI/5FocQp6y84LrqG8b5sdhM+5dSq/zj67PwCnFZMZlNwbSn avEEhk8rhwqsoX6t4ni0UT+8r/cwRAoIbeNs56MCZ8VyPFjn6Dcikb1hsDY+YcHzssHN sNZMJVeyw8Lyo1K6uGHQsImht2ri+LbUkFcfE6ZpjJY6S9RNpXqYCU04901ggALLRLtN +vGFmBgWSadB77e8xIpUUO9+aNeCnV95Q1rDv28CdVLHluxJqig9jzLW3+2g9llpkPAQ T3/QPzFwAMLYTVgKqy/DMRreZxmtCU/OiqwJn7lO/DxJTfsApmIre4rVfn/8RQ79I8lG oE8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794735196; x=1795339996; 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=ULmfgjA8hHN0IGqRl2n23MUGsl2Syf0XQisPuEg7n6M=; b=VGw2XsrG3zHMN3FISrYgHOhYqDyD8kOjiHlxWYzHpnO//s4W4cLSdbRbCAPMt31/ow 0uKcigmXi8uoCeVXmW30hkC4vTOtApyGd0H2EdOIb/OhYZ3ugLHrOxnaCh6TEljVU0hY NiMXGfLheOH5LuFqRJKFtO+lC6Zzi+es2fuUShG14X2GvGqx4TzhIXzqoGQEcgCCNTN8 YL6UYsMpOsAZmY6v46lAdseRocodUSGWqsDtDJ+Rp9MX9T5EINcSeZczeTrH9RdSz16O Pxz5SQP8m5dBgSLPGQAB3t2PEMD2OjrKa8B8sh+VUUGS5VqPonU99A+GWRIbnpPzbnTq BxEw== X-Forwarded-Encrypted: i=1; AL+hErFlrKuezmQjV+6ZR3EnUE4/V1WA2FDA/HUPbeBQGPgEZYW5U9nY1TpgDN2v/NAugefy4oJaoOL3WZ7JEw==@lists.linux.dev X-Gm-Message-State: APuU4Z9MtlBdIxa1edOEjJyQs5Xte0wZ6f5jT4ayV0Z7Zs15EWTkyBdG eXshZw2jRaYsvvbPR5hNdVAheioKSzRvQT1MzohWhkgH7aZPtPXOZsyu X-Gm-Gg: AYBFou1p3oO0gBd63ouCdQDQSJBss9+61eY/iYfxbhTa/fzqfXC5n/TNn+z1gofEoXa Zc/aVi4UjsVzuDwbOHDc1k613dzOM6+L7tBM/JGCRGqT5MvtXvN7AfwjlIjI4vFvJjnheuc7EMn Gfg3/Wwip9WULtexDeyiSN0fwMvpidRa89H77WQn5Qma/d4p2pPswsirPpzvwHyVaH8tWTriOHZ Sz8XGahLamWQDwpYjWULOpmfLUmDxgGuQqqcmxMET7pf6pBgsXryjPg+WJ4j+SEsfBId6J/NFQF s4XxVD7guNnqnUAZIm92XCvtvapoAeOxsBBS8i6qEII07wJO424ZPQY/9EOd83f4ZnuAsVECXo+ K62TP4p8C+lU1YCTVcQdUBYpNXa6hnYkTB1h1sBymqpW7Tr90W0ZkSCFIJAtt65MPHPHEYSk1ts cO2u3Ua+2dGpcJXOMX2kspfFAZIECA4EWNItvsrzLpzTtuQ0IenRiEaIUHBKQ6jY8+g01Q0kqK5 HJWE8el8rd/h89YECb+NfWQRoYO7m0BrXgvdkCxhKeXwxq8jGB2bVwoSiu/1vMjrwWLxhL3dwAC 8dz6rPpEYj7ZxpOkxRxDlE6g/A8aOZTOAy81pkcXTUoCLLXZ8MCyPj8yawYymrRTNo22PgeT6mv OV0RDVpx9ThQPkN5PFlCaDE84tFBjuKOGEmlktCB5yz5682wQWCnSekW7MW0rWTIbaWzczNhqXf bQi6bo4ivnSQtpuJpxCv1y/cnil1whAyQ/wC6s23RlSq7FAfCCjgY= X-Received: by 2002:a05:6820:5201:b0:71a:ed36:e3e2 with SMTP id 006d021491bc7-71aed36e554mr241349eaf.27.1794735196516; Sun, 15 Nov 2026 01:33:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 01:33:16 -0800 (PST) From: James Hilliard Date: Sun, 15 Nov 2026 02:32:51 -0700 Subject: [PATCH v4 3/9] dmaengine: sun6i: take the device lock before the virtual channel lock 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-3-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)[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)[]; TAGGED_RCPT(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_VIA_SMTP_AUTH(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]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns,nxp.com:email]; FORGED_SENDER_MAILLIST(0.00)[]; FROM_HAS_DN(0.00)[]; TAGGED_FROM(0.00)[bounces-27660-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received,209.85.161.45:received]; RCVD_COUNT_FIVE(0.00)[6]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from] X-Rspamd-Queue-Id: 64ECB1C41A4 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX The pending queue is protected by sdev->lock, while virt-dma uses vc.lock for descriptor lists and cookies. issue_pending() and resume() currently take the device lock inside the virtual-channel lock when queueing work. Take sdev->lock first in both paths, and inspect the physical-channel assignment after acquiring the locks. This establishes the nesting order needed to keep allocation and descriptor startup in one critical section. virt-dma preparation, submission and callback processing continue to use vc.lock independently. Signed-off-by: James Hilliard Reviewed-by: Frank Li --- drivers/dma/sun6i-dma.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index 9533f3bdb949..0b8e5deb2252 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -954,23 +954,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; } @@ -1058,25 +1059,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 Sun Nov 15 09:32:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 4115 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 2E7751C41A4 for ; Sun, 15 Nov 2026 10:33:46 +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-27661-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-27661-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 296F62C847 for ; Sun, 15 Nov 2026 09:33:23 +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=1794735199; b=X2qeStTAKHnMJU9XizCNm/bQeBLWz9ufedVPnQTgSL4IV3cg9dvbHY5EPLgS0VUzVDJC vppEVx2QaS4c+o4enWHwwSE2hbolfPaBMs9XvbzNuuWeYPks4wwxUWzlxj3nJlYTK3qcW uppcbq4PxC3SWCQkGtOYNJUJTeiaeQnMiAPO8va7/qM1fABYmmATHvmBKqSlV0rbkzsfJ EPcZGxZR2C0wyZ3iAdUIlmAgQ3pYTEBrwopyt8Buces7z7e8z9qpKr3s6TrcIqb0qNyrm 4JbFK7QXTTQEz3kSH5hTfQSj7CbP2fP/VIbndEeok+RlC1ZqgLfCRUVPmN5TN4QetLg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735199; 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=PHAQXgA7Ag6ugvQaLzYJVeEvbSBqXCAOAmP+o62IFzg=; b=SmkKl+dBsLSAci6LG3p4tD/BzKxpyn6O/Vp3zzOM8dUhujxrjSfq11ohl31In9hExA2S 8qx66l97GkzSUbkPs9Zak23oRKkLhZjExnT7FXZNtpBAD5o6suxJ86Dl/onSK0dYBY6AI JYccbc1mv5RvRCcdmRqwGY0YYZnXZDIY7FSvj+EXSH4jA1zD7s/hHwY64bVA8SUeHI6bb r32Zxtsy9GR9Q9ehZaUn6D8Ep2DwGSDYjjGRSHQkkbQSDNx3vzz4FzPyenSz62Li85xnc wWGYLkRvDKNwKipbab1EVfRDWev/VWRvo/GGKAL+YZrWbM22Y117IhfuVRDweJdYZOA== 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=Oi9xuYYj; 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 8AFD8606A89A; Sun, 15 Nov 2026 09:33:19 +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=Oi9xuYYj X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735199; b=A2Rpzo+z9P6hLG6HgFdrZHTt5FZSgJe6l+taJopln7CCXkxqM5G7k5kUPpQ0wLztqgmY zvVkohmtpOPZfY2yROdzll3UfoK/XltotQqS6bbeBqq6yEqoIvnCMD5Ph+ebPv0aKMSLP l1/S7eqAK8nrc4Bv741ApBH0RBi/bOFPJh29KIRtEn8mbP8JQpZvZBd5Vdl4wguoXYEJ+ XnmUMJdmjxdzsr30ODQ2vm62sghgGwqgMAeKiyeUoMaJ/vO0lW/WNOL1Q5qIOeyxui2U+ TLJ16DvTpCKvSwT8PU30FT+3qdZspduyRNt3LZdyD6Gy5KEf273J43lkFSM78wHJLhw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735199; 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=PHAQXgA7Ag6ugvQaLzYJVeEvbSBqXCAOAmP+o62IFzg=; b=RbBENew1XD0KP0CQqfZmu2gZCUPHrXIN0OwdVcwpdVVRSgfQoJtgQFmattwWYwazazBs aINosYc5GvXsnLJhm9G/RZ+odiZmJjzwOAkveBDIpiuyaP6GGRaqp3vf6HcXllJM+BOtY ExsnI6uVaEnOGX/Pp+4oCiCueFy+z5xuQgsUJC0IP2DWuoT6b1xePSLWCGK1Wikdj3+PF QHkMUMVTMSftNb8NbgugOG4aE7UquUp3XiOw0CQCnRSByxoALLSKibc/XUt5xVJ/or3lE 8jxHpyYv9txwSFzHf6s6qDVt27wWQXatWFD6zG08MOtLmTH2sFxdj9rsSPTsIwGauRw== 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=Oi9xuYYj; arc=none smtp.remote-ip=209.85.161.50 Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (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 2391B606A899 for ; Sun, 15 Nov 2026 09:33:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2391B606A899 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-f50.google.com with SMTP id 006d021491bc7-71ad1db7e31so549773eaf.1 for ; Sun, 15 Nov 2026 01:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794735198; x=1795339998; 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=PHAQXgA7Ag6ugvQaLzYJVeEvbSBqXCAOAmP+o62IFzg=; b=Oi9xuYYjEsf8MeEchTj9ts6ec30HBryuRbLNxvwKUnTTOehoo7UkdNBKKXn+ERpUqr MoUOVmq7KWApFBqoD63EDAoanuj7vG2/M+H+EIuJyVX5hyd1BMDE0ri0MHrcmG1VZyYc GHBRsQgldCy+eod41NOGnFse9ndmSONt5ANJ+0M/EyOSyrz4ibJu5s54EA7zsMLoK4u+ einLH3aH8KsqbUhTo/ebHJyj3IyGDHp+yLK/BKRVX2xL1QvNGrN4arirURleHRcZv1/F JM+eaJaHrqpcoEnL1JK/vtLu9GTkUiBUldoRt49aCwENcTJQPDt5vZaeQI+znvzdgkxu 7V3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794735198; x=1795339998; 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=PHAQXgA7Ag6ugvQaLzYJVeEvbSBqXCAOAmP+o62IFzg=; b=ph4MBVL9J7lyCFfnpw4GpZkXMcIY6Cw8VMDN5EGON2hM7oDQAn5BasZHHUSX2PM7Ka tmz/B0y24FZNyqiESv0odwcaAq5n7UmcR+hLBV9jpFKA18eC521X53gKTsU9d0e6MhFa NbeqsPX3IsS2RTvpP3K17vUmdJMGT3dAE+G6E7/u6UL8ssS9NVdHuoAYJE8oe77ZYlBj 5NHv3lIDAiuMgT/2lcN/0mcYHtSC5o85Oc7OLWstenPPzqYihmQ2ppH8nVqWVXTKobIc 0BgVHyZh0aGvEjxAjb8HAgoECAuwQiB/K9FHLqcdN0tyE65gMrc75IpjsQSg/phfC9jx CRoA== X-Forwarded-Encrypted: i=1; AL+hErGGucKmQ77iLaCieOFEhjY4DCRtEIQivxX8SmMNhpMrhLkrNJepHbf5u5yoZZZIY3Teo608sDi/Mx+z4A==@lists.linux.dev X-Gm-Message-State: APuU4Z+WpnlV8o29SIkXZm1vYJGAoRjUF914JLU0DMB0NXJTyldXIjjD FkwBYxYoy54xftx9upYm4ZISRhg7MZdvMwCa0tHROvtx/qVXhJRrpSB1 X-Gm-Gg: AYBFou1Yr4N6TP+8+D+2nwcVo+r7c0OD2klwFt7X7zoufUu/nwNSPox9yI/KuOHWzJX KeV/6BypYZaHqSXJg3IuaoPOhrDVO0goSIyAKNKG5mAiuvfPI9Rd7et1Zm4qqJHDkcwkPN/WI1W 6iNEhIgyydEBmUSu/amkPDo5045TGRJNKeq4ctF/ICnr4XKHNPDRhWPO6YhfbCvxCZOaEWX0hJt wgKtxAQ4vSk7t78uWTwYoOEFPAEdIzPs5o+95crCDtUiLjmmB4RP/d+4W5nTO0Eglf1u8bjeC9X i/yDCfAX5UWHN+b7krP7b9eThcdy5Hs8UAZ/ZtJlP8z8iz1wBuFJhD8cip6Y6xy+523EzEW0QYn OHPdeBgniTnOXCR2z1uqd76CiXjrWQ453+J/9wX0p/0b/WCJLoVfKUbQsWxxrrTwP0nqaEDZdhb LZYYg0W+4i9dQmgh72EbIPQd6db+vHLx4kbfj9yQ+MVv6qGcN08/FKK04is+I/RdTS8CpeZ/ynR uVsdntrl0lr7uUEy0pI5aPjIAPlA/c7AnbdSZhGWp0+D8c7prf24huLUv3AW99z5EihRVk/hcWr P8QRpp8XU6QuHxlSMamR2uM4CAgIwoSbbkR0l5lGvvu2FS4PYlF8ii/z4wDbdZLBKcpsmJwl9cp r1dUaJLzu/0T6zg1/tNl7BQUCQy3tZDyn6OJRvWsFxZaSd4BesKGuJbZJOJFCupo/k7ONlcWQ1h LRmK1Za1h0V8ISh4TFm7XoEYWErVoSgKJ9D38klNGWtb1M5y6Mj6g= X-Received: by 2002:a05:6820:1caa:b0:71a:e9eb:6b93 with SMTP id 006d021491bc7-71ae9eb6f20mr396173eaf.1.1794735197991; Sun, 15 Nov 2026 01:33:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 01:33:17 -0800 (PST) From: James Hilliard Date: Sun, 15 Nov 2026 02:32:52 -0700 Subject: [PATCH v4 4/9] dmaengine: sun6i: serialize physical channel ownership 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-4-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 , Sashiko , 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]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; TAGGED_RCPT(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_TWELVE(0.00)[19]; FREEMAIL_CC(0.00)[kylinos.cn,connect.ust.hk,embeddedlinux.blog,vger.kernel.org,lists.infradead.org,lists.linux.dev,gmail.com,kernel.org,nxp.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[sin.lore.kernel.org:helo,sin.lore.kernel.org:rdns,nxp.com:email]; FORGED_SENDER_MAILLIST(0.00)[]; FROM_HAS_DN(0.00)[]; TAGGED_FROM(0.00)[bounces-27661-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:104.64.192.0/19, country:SG]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:104.64.211.4]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received,209.85.161.50:received]; RCVD_COUNT_FIVE(0.00)[6]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[104.64.211.4:from] X-Rspamd-Queue-Id: 2E7751C41A4 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: 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 unprotected owner snapshot. Termination can miss a new assignment or detach an owner while an interrupt is about to complete its descriptor. A sampled IRQ can also be applied after reassignment. Protect physical-channel ownership with sdev->lock across allocation, interrupt handling, pause, termination and residue queries. Read and acknowledge IRQ status under that lock, and allocate and start each pending channel in the same critical section. This also serializes updates to the shared interrupt-enable registers. Nest vc.lock inside the device lock when accessing descriptor lists or updating cookies, including cyclic notifications. virt-dma takes vc.lock independently when preparing, submitting and completing descriptors, so the device lock does not replace it. Client callbacks run outside both locks in the virtual-channel 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 Reviewed-by: Frank Li Signed-off-by: James Hilliard --- drivers/dma/sun6i-dma.c | 67 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index 0b8e5deb2252..5d39a2c0c2e1 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -217,6 +217,10 @@ struct sun6i_dma_dev { struct clk *clk; struct clk *clk_mbus; int irq; + /* + * Physical channels, pending list and registers; nests outside vc.lock. + * virt-dma also takes vc.lock independently for its lists and cookies. + */ spinlock_t lock; struct reset_control *rstc; struct tasklet_struct task; @@ -526,11 +530,11 @@ 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; @@ -547,10 +551,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]; @@ -559,31 +562,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) @@ -592,9 +584,11 @@ 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; + 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) @@ -610,14 +604,14 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id) pchan = sdev->pchans + i * channels_per_reg + j; vchan = pchan->vchan; if (vchan && (status & vchan->irq_type)) { + spin_lock(&vchan->vc.lock); if (vchan->cyclic) { vchan_cyclic_callback(&pchan->desc->vd); } else { - spin_lock(&vchan->vc.lock); vchan_cookie_complete(&pchan->desc->vd); pchan->done = pchan->desc; - spin_unlock(&vchan->vc.lock); } + spin_unlock(&vchan->vc.lock); } status = status >> DMA_IRQ_CHAN_WIDTH; @@ -627,6 +621,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; } @@ -933,19 +928,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; } @@ -980,15 +976,14 @@ 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; 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) { struct virt_dma_desc *vd = &pchan->desc->vd; @@ -1009,7 +1004,8 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan) 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); @@ -1020,19 +1016,21 @@ 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; enum dma_status ret; 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); @@ -1046,9 +1044,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; } 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); From patchwork Sun Nov 15 09:32:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 4117 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 793381C58A7 for ; Sun, 15 Nov 2026 10:33:38 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27663-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-27663-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 C028E306D0 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=1794735202; b=UgbKZnTgtR+bKh4LIQiVqnrnCsk7nUGfwxl2j+Pjt7mCCwwtMLDbgD5eUekgk7L/7lCR i/Z+1i3nPLtUqiJbTw/t282jeX5lWtINUJO+lwUfZQReewneZXpZ42ssDQ5u5B2OOL5iF YvKuZQMy115D/9HISTX0oPmhrClS6YNKRN/kL/6kTiR4BjKaQRmlrcmSFTMdfO+VMaM9h /RTw/KVheu+q/wcEI4XLysy/yh51X6Q8F3E8ujgLxn0lqKFaUsfoy27e/Wh5YevI8kQKi 8oihpsv0h411Xtd8eY0evKLcZt6uDLsaR7ncoeXnx3fhTw1N5BYPaE66BXrKOyx4SLw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735202; 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=NlQp3R8KuFLhV9wrXx8XG9nak7uXzaBTY2y9ltCW+Ec=; b=Nqt2HWVumdfBY7wlCv6ckPxtQ1rCLdeLnBnNj1xbM3BMUnAb1JFgolz8LesC4LeefH+x XYgnp/sW9UrGnRQ4yJ4Gxe4H4vNycqUCvoHp2DFpTTyNtFEEEUlUBrCgqZsw2lj2VnVNQ WUNT05NdOJtTnBr1y+orQp09viq7S1qpJxPQDuatTVfOgMtt8yY1ME2H51mazDrfn7EA+ VapTrNbIRJpzyDoNwWiKWvLs2LAHgXe+iHBf9pt373uUzAJ9eNtLHQyj7X9z4JXhV6OS1 cI/I40OvLamy4Err4rQkHKoaRYaURL20MRO6O/ks5QlPNRseaSYd4d77r9S8jrrFOvQ== 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=clNl6+d9; 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 0CA71606A330; Sun, 15 Nov 2026 09:33:22 +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=clNl6+d9 X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735201; b=usjZ3tGuz9X7SyJpEqyirR9T/2nJrKjiPeESE5AuIDxTDrewy9IKnacfpdN85Bzj71kX FVvqAsndK/JVPqI0NnrhdMaPn60kGgA/QIXcJwkHxGfZ2XcHfO4FUn/7JyLVwk4JFQjNv eM5fLH42p3K2TJ8Fk7DISXvAFlQA4BGj5v6oBnxt4VaCKBpuhLknW8LCzTz4vcTMHk0/i wB/NGZU2JNJN/G7D4jYFzUYpZeEIycOWqKSTru2CHqGR6TCbrObAZFmHffUG1XXX+DFI9 QfZigTpW+nvONMrXhag1LUgmcxomt9KUX4j8LVCx38viwnQOXvyZVJv7GqyWPCSmoyg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735201; 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=NlQp3R8KuFLhV9wrXx8XG9nak7uXzaBTY2y9ltCW+Ec=; b=naLL4wTB+T/h4AwxJCue3BrZLkCwFt0bitZicN3VjaLNn6xdhpc4Poxaleja1efmr3K4 1OhiFjVh+Bya+b5PvSLh2ingw2pPAUovuH7C1H7bo3xAzCxQIYGE3i5XhTav4iHaZlCHO FQ90sEXoVNQlXQ9cvyJSHM8twktMMa35Npn3Z12FI7O27QRxLQVM86g0AWGgUC7seoLSd j/ypADaWwXhKgK9YGZZcWVxj5BNTDliQDoW2Mw8ZfZbFN7vtjpx6FlWzqU4yNw4XmVYR3 hRYHskeQ+yQNCv3kx7GzQXm+HOEOTDi7VMce2Im9dE1uEZhIdKz9+V0+8bxvTLwR3dw== 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=clNl6+d9; arc=none smtp.remote-ip=209.85.161.44 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.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 94D30606A8A6 for ; Sun, 15 Nov 2026 09:33:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 94D30606A8A6 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-f44.google.com with SMTP id 006d021491bc7-6de2f213b7aso905267eaf.0 for ; Sun, 15 Nov 2026 01:33:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794735200; x=1795340000; 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=NlQp3R8KuFLhV9wrXx8XG9nak7uXzaBTY2y9ltCW+Ec=; b=clNl6+d9X8exKCMnGNwaG/cjldOjhn8ZH2SvvZmbk6SuLq23QmChrNz6CeBtIHSB5G QOTf55A0fXGIsTgTdvji7dTV4tB2WXJ4wQMwS/3re5A+9g/tp7M4IlOW202tMWyNtdMZ Q2eZgSZoi//5ISqWAyBq7SXMAO++BEMdRDcleGUTo+quyvAIOjB3XZozK3pPKXYWh4Q/ SyjaK2/r9OaX3rV7m08E/FQepLczbZ8Mj6WBjzVLCTlxV3QYZ6xpo1MObV+iGPFeRETA 6NvvmR4hHxKaDRj7uILkXY9NDgIg6gCkzFURfZA95Zv0/0Nw4NwcuSq0t7AfnatlEc38 5XTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794735200; x=1795340000; 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=NlQp3R8KuFLhV9wrXx8XG9nak7uXzaBTY2y9ltCW+Ec=; b=okFOWuHUW5acJDiOF2W6kKnDyCnAXYuhUnarECeotZupJqlALACIwpz0wQ8X9Ut6Rs pi/o/svMaSNPeFc15RJ2l03h6J3ixeC7FeQFGm4gbGv9jeEeypvy33eKN3DqBINCgDkr gBc5111duKHOqnEjGCU/LI5dD6pS2jDjES9/oxcSUp2lgJtW9TWFAe6k66+B7snTaGEP mEF5zAxula2QUV89roUHOtMyhzumFCnHP1bXtmK4RVtbOOEy1NiseYOClosHHnH9Dr07 v4BK6EfOp4zrfhhdQ/McZcHHMTxI/qJA4zxN7d5ZyogQ0XDbQhyO5AxUfOE5H81pdLyJ ElPg== X-Forwarded-Encrypted: i=1; AL+hErH5qRwpsce9DPbzoFXGP0dN0DmYFdmjTge9nleSeDqvF5vWyMW5rpFCPKcpGXQe0cJkjhPwrQhqMxAaCQ==@lists.linux.dev X-Gm-Message-State: APuU4Z80PgVSC0r0R01LpUbcQuTjW0ngKXQ3Dv5+H94y5m+plFxUnKlW f6tmndg/3v5pvuXnRtpuGtOMOwFPkF5fzGTvEuKNg2qq3X3AZ4x7Ahv4 X-Gm-Gg: AYBFou3kgFb4VjPSC4g9VcXvDlyWbBRW6Us+gU62egUrFoCBnX7YhcnutAvWqRxV3XL Mxuj6vASkGShgdlSQR6OanWZdYLh7XKVp0TVLcfaGENIxUzsA/itqiyfBm3hiqZwDewhFdflhsu n5tOUBEVGGLZ0FbYytJxW14G3fQJJNJDu7lQ/Snw30Twd/A02B5+2fTDv2vh497B218LiZResoy KxjjsSVEkpjTx6TuwXyDDBXqksto93+bBT8NYMZTFYdA+JeweGuhZEHlfd6pfHgSAT77Kx86nRT VPH90LOrSq5hMKHLTEuSx1PJiGaJdVJDMkPE/QE1OgEIJNMWfEc2j9Ud/KKxBnDZmxktAabs5gK idEmIMjREz/0UYx4uMiwnKcsmQWnLbCS5G3a1SIwTUVXTFfWskozWEZhorIGGUQNanwcQUODdmD 7tFZMXMV2DDcsYhhrKFQFAAFM6MhEGI+5QKCe1CCf/U5PoW4qU5ooAb+mMpNFBnSDQZrJ+cEdQJ SqrEZywtdAcYmnn9wmxKZP/txRiTvTSJVVABDdWQYKu7gME76CN/lWFvuETou/+1cSj9n71zM0r Eb19vftDbnuN2pqoz/he/olpqTvW+19RjNQs8MHKrj85vjZ8W9JWicisXNEoMHWcECzUt/DhSPn YEWNm7dLXTZCdPayOAr22rSS4Jj2ELBGdSR+4MeEq9FMvHtwDBwMPbeCwocNLkWgTeYDr06A2Pq TC82m2/H/ny45n4qe6fMjNv+Su91wGP1vSinfOuUuBken5Sn7dX5g= X-Received: by 2002:a05:6820:a711:10b0:70e:1dd8:6713 with SMTP id 006d021491bc7-71ab51550camr2956017eaf.71.1794735200601; Sun, 15 Nov 2026 01:33:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 01:33:20 -0800 (PST) From: James Hilliard Date: Sun, 15 Nov 2026 02:32:54 -0700 Subject: [PATCH v4 6/9] dmaengine: sun6i: retire interrupt state before reusing physical 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: <20261115-submit-sun6i-dma-lifetime-next-v1-v4-6-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)[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)[]; TAGGED_RCPT(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_VIA_SMTP_AUTH(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]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns,nxp.com:email]; FORGED_SENDER_MAILLIST(0.00)[]; FROM_HAS_DN(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]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[209.85.161.44:received,100.77.114.92:received]; RCVD_COUNT_FIVE(0.00)[6]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; MIME_TRACE(0.00)[0:+]; TAGGED_FROM(0.00)[bounces-27663-noreply=patchwork.local]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from] X-Rspamd-Queue-Id: 793381C58A7 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX Termination stops a physical channel and drops its owner without masking or clearing its interrupt state. A completion latched by the old transfer can therefore be delivered to a descriptor installed after reassignment. Mask and acknowledge the stopped channel's interrupts before releasing its ownership, and clear pending status before starting a new descriptor. Keep these register updates under the same device lock used to sample and acknowledge interrupts in the handler. Schedule the allocator after termination so pending virtual channels can use the released physical channel even when no further interrupt occurs. 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index c30e244e50ea..ab4474f0a8aa 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -503,6 +503,11 @@ static int sun6i_dma_start_desc(struct sun6i_vchan *vchan) 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); @@ -975,6 +980,7 @@ 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; + u32 irq_reg, irq_shift, irq_mask; unsigned long flags; LIST_HEAD(head); @@ -996,6 +1002,14 @@ 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; @@ -1005,6 +1019,8 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan) 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; } From patchwork Sun Nov 15 09:32:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 4113 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id 7F2EC1C44E3 for ; Sun, 15 Nov 2026 10:33:33 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-27664-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-27664-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id AD0392DB18 for ; Sun, 15 Nov 2026 09:33:29 +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=1794735203; b=nqWy9t1Iv2GPvo15XjUn+Bd0nMeKwSZvt4cfGoV4CvJlmAq8NiQ3VAu7pF80hUugAw1f 34cyVmW8TRcty4+DcIn6lpb2uci4EW7A4ek4jwWweWvXwJtD22RQplUVFq0r/7lJjwiiC I1KH2UTSUr8yfssR9bR49GhQoB/m+Ko7xQvIMX6/xabPHXkFZCzzmYEN+xO7/gxcrNCZg Ap+9dOt33afA2CHMcInUbzAf+aL26IbZSX9/C2F/+tJ+HUxIivx4VCgWlVSD6KcyRaoP8 qfy5ohRitSoA2OQW5u67zIkgEGj5VQrO9U5sOnabDw+oBg4lJSmq37d6H2EEhlQAbhQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735203; 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=nj+huGoNy2lIUQaGcQ7MZRaU7F68XeRQvFxjv76wcSM=; b=zbDe5DF08yecWNAwmJf7FFaGp+T8yeR6p0xoMZzwgSTHturedzZ+mfwzuVwWPBSBOAqy 2nve9c50E90OuZ8ZOewVbw9Wy9VADp5PikNOPk7aYjbR6S87LD4ia/wVfZKEn2ab/QNSQ owLbSnNiAiLwq361I+Q1aw18yY3RQb5/tOQiXuS/2Qhzf1JDR1NNaR7As5DjDw1uTlmAb rd2ADm17GD4slzWmFJj4Js1gPLos/zqEQ7IThGFlzbbrHbnWVWX7yXTtZlfDbbR85xG3R 8tYCrN/26lbyGnhaVJ448zr8TNbbD/W6NJleX5DToUBbJ0w6FN6o7+sY8fG1dS1WXCg== 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=nuI9u00S; 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 8717B606A882; Sun, 15 Nov 2026 09:33:23 +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=nuI9u00S X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735203; b=V0HAYHaHCdLKBkkYbDlONmv9XV4XQqfe/TuKMOnyd8nafn018jZJp6xeXJDvSW4T5K0L 9E5KvneQCFaJfocMaMYkJt/SGcjl7MiqjGPTM9C6ewrDXoUxScleT5BM79pnbTY8NeUTi OLNtwxPGe3gZxrz4fIsI+eDio8wQvLSR0n6aU3B0WDFt2QUqgqCsMt/IHtdEnbZlI1fwv cI6eV9CcaPSMCh9ksTezn6Mlvcj8Jgj0As4nLh+u9hP/LrvYv84w7BcHD5qN8CJKMnYXM uoKEvvirylLo5Og30ZCyMMyYBvWzhxn6kbAYELvwG93mrhr6IF1ZljjmUQBG4BQmA7Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735203; 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=nj+huGoNy2lIUQaGcQ7MZRaU7F68XeRQvFxjv76wcSM=; b=vestnORVtLu2l6UfdXVBLNBkvZkvd8G/dQX1v3bNdgKPMmnNm/Hs75+0jO/oZ7LDvvlS VFFp4zwLgue7AfQLnbKo5EL7iuxMfmlSfto3lYfFvHoNYCTrzHNz5d2Sqk9FYgqBFzzO1 HBfAZbWUX9h3F5Oh3u+MDJdD8ClRRdIRW0NafFzU7VFsq/ogN3jRKKze872251k1eK8I/ lPDrgmuR9XlKEtXZg/Aqs+XhErRKyrCFB0i2/Sz4hH0LfpO//47i8G6CXN6Z2O5zhH2J0 79oKd01+4CLXmSsokn44BL6/5hHCVspuA1AnLIlnBPG3e73d5WHZMYHXc5ai1m3ggbA== 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=nuI9u00S; arc=none smtp.remote-ip=209.85.161.51 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) (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 1E01B606A8A4 for ; Sun, 15 Nov 2026 09:33:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1E01B606A8A4 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-f51.google.com with SMTP id 006d021491bc7-6b8e2d8df4fso2344741eaf.1 for ; Sun, 15 Nov 2026 01:33:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794735202; x=1795340002; 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=nj+huGoNy2lIUQaGcQ7MZRaU7F68XeRQvFxjv76wcSM=; b=nuI9u00SouzTOuvYNnNeaOCJ5U9Yje7CayHlcGOOPU/DeZDCta7rtM+i4jPK8jYZ/E WMJjkj9wmdtf86OMt776uBa4Q5O/R4b9ufeLRoJ/mrrqwmkX2SCov79msFN+Vvgtso2s xm/uquZ9kPFRd2zehAcYtJLHnWrZDilv+4TSVSrOH+onpFyCYZHZbxHmssi9+j/Rve7c Ccho5GmWspXzQUApaLBOxGlb3OkNKTZx/Rzpw8HGmPg+2PFq010KWunkakzNmXy1hVVi kAuYwJiMf/KHt+bBLDgfIffBCvMkRnnQHnLPzdH7bgncozwGqZgiyMEARJSvj3Rn2MFw vLJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794735202; x=1795340002; 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=nj+huGoNy2lIUQaGcQ7MZRaU7F68XeRQvFxjv76wcSM=; b=TlxYyZr1FsMp0cT4lLBsp0yxxcHi61W+9b+iEz01Ojexy7G4ft8KOmxWI33lGXP1cy NNpGLio9rhEPNN6A8f5SCQlAUhvrVFXEZF8rm4mmaDrCPEdLhDIax6AnK9B5Qyvrcbod J/KRG7js52NTX9t8h5QIEO9biGMOjeParNf+2PDU87lGCU0J7Xyo8vFuAM9pCET4zE73 lb+cUCWz85i3FbZLrE+hDaHR+GwcnoxZEpwHAyTDIht+axwohSQgy5LFVuJR84AgA9BW mFrmpIfysxXkDb4Z0dx6oj9YMekNlJgY7/11z1zAgiTa7HvWeICTB0rFtmYc914vovo8 KbwA== X-Forwarded-Encrypted: i=1; AL+hErHti15yLhbAJNLHexCXQeb2DQYQh32mG6j/GKcYFDTpPSj2N0iL6OjJldVfjDCIDKZJk4NxXkIo1lgrfw==@lists.linux.dev X-Gm-Message-State: APuU4Z9Ym7hR1eK8sUM2dVsDxbYqHfeD6oToMIOHDhRHjStXoed+wjlO NUVgX5vC2cyPHoQSvhEbW5rZv6PrwsD6YtdDSG+H6iwcw3Xkw/RCFb1Z X-Gm-Gg: AYBFou23leI8WdWKzoZqkNXa5e/w+SrUuhZebjaV7y83swoMhy7eOrfrW779U1o10/K YWCGZE17n5ZcXMY7CBz2+fH5EKmWlOJqGDM4Dp17nJLf+ZOp3dUwBtBozE3s9T87hZz6kcnmoTM xDQM7niItk+oQ/Y/IFola21X1AaXubWIF9UsaufLG+BS3O3NqEBoJBdFupxpXlPF+7TgaqbQUrF Ez75Wn+3A2FlPHxhp8jltqHdmV8F74gQ7/dsphAEJ37JsC/BQg2Q3Q2tUsXeZVsXyEOInUv8oqc zKPOcStPsJnSio6rFJH0mxdCaic86ZtsI+PR9UMGdFpd5bxHLYhuNVtSkiVWPjlMZPT+F0QHjtN vrSMC6x2H2sM/mqK35SDO2XKmF3Sw2dPjw10/8KSQgCuQPhq3A60xhef3gJobeZ310s+KqF6GRd q1/Lqe15/rZbeYk9DYTMyUotJ0vORrQVFBYRNQBXecFUGDgiX3UBvRXp/qHaJd2prY1c9Vp5Y+1 bbbwEBuPh+gVGKKLRpERADALpWJ8KUReHBoirCqjYq0gPp0WAYkd3J/geOZaCMEsafNU2WWXA8I un/mQSEagGD4HKQiv6aZkGKSyKSMaBfUqTXKeHAE/MxBEheC63hxgxqm4cKLDMCVssqIHkVbghE tAL+c2E2X2kdgeWn5EJfO+helyWApleGY2aw8gW3Wd21hQ4xfo5OzfxmrTGy8UEuritx4qR0i25 g58ULFTxO8HDZZbQuecOr/dndJ/B4FMQ/Hc5nSWKrevamVe4UKH6I= X-Received: by 2002:a05:6820:1396:b0:71a:e696:71bb with SMTP id 006d021491bc7-71ae69675ecmr1052335eaf.35.1794735202064; Sun, 15 Nov 2026 01:33:22 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 01:33:21 -0800 (PST) From: James Hilliard Date: Sun, 15 Nov 2026 02:32:55 -0700 Subject: [PATCH v4 7/9] 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: <20261115-submit-sun6i-dma-lifetime-next-v1-v4-7-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 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.105.105.114: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)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; RCPT_COUNT_TWELVE(0.00)[17]; FROM_HAS_DN(0.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; TAGGED_RCPT(0.00)[]; FORGED_SENDER_MAILLIST(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[tor.lore.kernel.org:helo,tor.lore.kernel.org:rdns]; FREEMAIL_CC(0.00)[kylinos.cn,connect.ust.hk,embeddedlinux.blog,vger.kernel.org,lists.infradead.org,lists.linux.dev,gmail.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:172.105.105.114]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received,209.85.161.51:received]; TAGGED_FROM(0.00)[bounces-27664-noreply=patchwork.local]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.105.105.114:from] X-Rspamd-Queue-Id: 7F2EC1C44E3 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: 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. Read back the pause register before returning so a posted MMIO write has reached the controller when the client inspects the transfer. The readback flushes the request; it is not a separate hardware suspension acknowledgment. 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 Reviewed-by: Frank Li --- drivers/dma/sun6i-dma.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index ab4474f0a8aa..14f1f463005e 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 { @@ -539,13 +540,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; @@ -937,10 +942,13 @@ 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); + /* Flush the request before clients inspect the transfer. */ + readl(pchan->base + DMA_CHAN_PAUSE); } else { list_del_init(&vchan->node); } @@ -962,12 +970,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); @@ -996,6 +1006,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) { @@ -1041,6 +1052,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; @@ -1075,7 +1088,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 Sun Nov 15 09:32:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 4114 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id 591D41C41A4 for ; Sun, 15 Nov 2026 10:33:38 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-27665-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-27665-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 3F2663531A for ; Sun, 15 Nov 2026 09:33:33 +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=1794735205; b=MMeQ6i5KGeBYWWIBZH+68sNheLlCAcr2QVfTXUAH3nwErYVZIqUVYs8Uzl2vbELz7tJ6 xRmugtKuudM742ZN/izvNemUboIUKcQ0eTRD88W846VnH4toAMBC3czoJsP4w0E3PDF64 N1BRrjZUVnwrxQKgicLy+uP02epc+QC8utTlsCm+8L1byiaeiSVl3tpfnLCwKb2pxNllI 2mvXpXoSFYrPhYRk/PnsXYKEFseWCrM1dNMfYRdeolmnlm3eTiKVg3BMrdk9ky0s+Oya4 JkEbM5ZkUPvFUZwdZJRscoJvD3oeYgnx+aH414XblAQ7yPx1xLsnqTUR4ZDwA+6nCgw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735205; 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=lLq7Tf1B3BpSLBANTG+leF3RFU5GTaZTVgWe2BOgm6s=; b=4to3ePqbURm06koOQTBvEvRCFsB6oU4OlxPYBALTzEFSIrPSPxr4MMLxjEJbXrhstqdl I0s0UN47413hVo2vbyxQGztMPT7rueM7b+KLCFS9LbqNrxgsVIH/bC+gyrbRtspYI0RMs F143909n4mHr/ZGmuaspBUC+2HOB3BmitAcP22ZjD1cl5CCN1iJxRGi729TsqxqPR+Mcn wsZoY9AP6ZV7ARX+puUnKfRqdkgLeE/HyYhnmZnnJ6rIlsefGR8Y/hjNwYERYa/M/cNEt f70Ld5bV93nC7U3eovlh4gcygc4HZzmun0fNE+TLIpRcUm9rOfPRg9rOpzVcNU2CnLw== 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=RNTvfa8e; 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 E3C80606A8B9; Sun, 15 Nov 2026 09:33:24 +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=RNTvfa8e X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735204; b=rfK5bfk+cFo3z6D+2MM/xuQ1HFcMhE/fuxrODIjh6pSss8Z2MTuwJdpTCb2BxHjz+pPS HhmANtNGrO7B2GV8/sN/kahQtkjCBp4D83AUNam0LwaVRYYwmOLlXePaxtxbGTTi1/dVf 55S1QDq9p2/UchHkpH+WrugMhjv48hzsJdlUdU+VvVDdDIVtKqZsMpYYVkrLkrExupPYp u2Q5nVP/LclBulQ4YnGiRyAJRk4XF0GYw2LuhIPcA9QEeoia5pYo40DVTXs+q3AunVUvA zXY3fubRvaEEj0PRE9n2tWRM1rmRt8ERI+TiF72/T0GzngHbA3dusTHtN1hW3bG+cRw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735204; 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=lLq7Tf1B3BpSLBANTG+leF3RFU5GTaZTVgWe2BOgm6s=; b=BiDqgBqqFMPTw0c4vudVeIFcRgSRhAfWbq0uhb06TNpBVTjDyCOMWLB5ciWLQ6IraVcr P+3doxfdwxcVCokpayvhtvdlMSK9ohiZ2NSLD827XcNd++v+iTLTpHZJcIv3kU2lQuubv FbWo2KCMaTPm27Pe+SsEVRrFNbPvezxqMDy4bNl5ATY3J47anmXU9Q4Smt0DVvEvwh/es O2xQSImVdnVIpm7G832s3uZAM0q0FhfmO4BOHNOYrExViyc08iqlJ8Qcngo0jKcmaaxed WGj+DXjkI6Z+puRhZaqC2kpgPD1GE3kqDtvPcrO7CUKV52K3febjfooi3Tp0tFhlNtA== 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=RNTvfa8e; arc=none smtp.remote-ip=209.85.161.52 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (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 79B56606A89A for ; Sun, 15 Nov 2026 09:33:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 79B56606A89A 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-f52.google.com with SMTP id 006d021491bc7-6de2f213b7aso905276eaf.0 for ; Sun, 15 Nov 2026 01:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794735203; x=1795340003; 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=lLq7Tf1B3BpSLBANTG+leF3RFU5GTaZTVgWe2BOgm6s=; b=RNTvfa8eb81loVcYokQNeIhBEJRkzsMxzHoRab5d7GD3lWedt4xQootJorGqTjO1Xg iAkwX3PMJXjOBNRDZf3oyXPMuIJvaPUixACLEoYDNpwx+PobrZyl2/yQcPyby8DaTjB0 0zWanwK+I9Pt81BYQ+scz41rK1l7kuGGMWL8CSr64qCpEfhOlRUA76bluAQSKtT4qm6y GVeFVUgF9rsIQ5h44zk94RUM9PTMv41qeJ5OnR4yMIGgZ9w2p3Ut/hMPWOTRJnPJi3/P kkJvMKM5hMNvpPppPo6tfLMUtEjnuMA7KOXyrY+BQLE8mJ89qk++EfYK1ew2Xlj8c1+C V0ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794735203; x=1795340003; 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=lLq7Tf1B3BpSLBANTG+leF3RFU5GTaZTVgWe2BOgm6s=; b=2ADEwrGgpL8nd5cHMBjTCspM3Skz29xiHBcVRlJgkMdBnkWd7ILY4d/+CebIfV7sCZ KhVzoP05AD2Lyot+/2vIzI6WifrkB/8VKMegLLNLETIjYNoQL0xUv9wKplBTLubn04Ca w4s0RCYpvTWhDIrgfFAUy/BIDG52fXtdF0MclEC954VhySivkrwMCa2Fn+Lvz5p2lH2y AX3+oSNTvRcM+uuhzr2ALUdFcz4zMt2t5CErsQsorujx6hREbEqlD+dI3QbAmACrkoaP ZZ7ZLfyjotSM0tuzqd+B/Lc74pviSoCjjw42g37cYh3fBe9Wi7StL2AMY7c/2aEewYyJ n5oQ== X-Forwarded-Encrypted: i=1; AL+hErH3/VPmHyt1rzp8ogRpQ52rHBbVXd7potWnCFQuJFmVVuhkoSoSA3+b2j8u1dd8+j+Qulz1kpyLXMZjpA==@lists.linux.dev X-Gm-Message-State: APuU4Z8H2NKao+IBIa+GT63GRiVOCNddnkzjXl6NSAzWScoGI39JQWZV jZtyuvTrDuTWSE6IDd7UEngqnoaGPeg1HwEOWx1xYBLpv4112jK5X1al X-Gm-Gg: AYBFou1mQDZMZq72yYUrfMTIoEnzdcZpVXBacYy4MpjqjAWyRcmRevrtiWM6SWZ2dZR mtO+5cQnGZ8MIDadk4n7nbb6J8RFl6Kp6xtMW8TmcBWWw9vjE3h1wXVGYcXZHjfdPT4OptSYYxx GEqkeSs/2i/7KL6a6mHgigrvLo/rKsgekGZqnRZ53OhXj144YNyfwmpQNCqeU87eYoE0A/t3lOh wVFqAxSCQs90hFIziVphDXe1R4kccImwB9lHr4pyWvVIDr+SNrFK938ZAa+x9ajEdiugqVRcOph N5X8ZWyI5Cxgpa1FIsgL2CxISYDk1Xn8MHN3knw9AgNCN3NtrJhgJDZF4Avx9R8F052FR2KRh+k oOP2voba/iyouVA0G01B3oiV0LZqysvzMHlnVDbDHmgGJqShDRkZ7HvZXkvL7Wde8o2wtH/Cbdy XES+jgWyvIEf3Oy8a8PmjMgLyy86FHJiDKmK3c0Bft0h4/19uNjxDgY20VgOLR5P3TMSd83fOmB Ql3PX8CdU/K+YyK9/hEdJPqfOVx+YU0rgQhUDlyx15XIGVPX+yc75z3FwZDMIHcR6JTWA58DEOg xCPvV3ncQPUPdFDAaoQ9+66iPs/mFG3Xe6cVIUwX9IrubZWU+VAhE3/4rHGP9XMs+9kzTYRDdtP qsuWOr1/AysZVHzgdW/mjoMgLTUMhJywkuqzYfbA2m9rCN7i0XGeyB6fFEkiuLdIxO5Dz6qfRUl YrdHuIT+guCdObokXNfILucKVb3zT3uruBouuvIeQdBAJENpGsxdQ= X-Received: by 2002:a05:6820:3416:10b0:6cd:3ffc:64d7 with SMTP id 006d021491bc7-71ab51acb62mr2760644eaf.82.1794735203521; Sun, 15 Nov 2026 01:33:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 01:33:23 -0800 (PST) From: James Hilliard Date: Sun, 15 Nov 2026 02:32:56 -0700 Subject: [PATCH v4 8/9] 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: <20261115-submit-sun6i-dma-lifetime-next-v1-v4-8-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-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: 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") Reviewed-by: Frank Li 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 14f1f463005e..8f8443e14719 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -1002,12 +1002,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); @@ -1105,14 +1113,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); } @@ -1485,6 +1489,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 Sun Nov 15 09:32:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 4118 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 C4F7A1C44E3 for ; Sun, 15 Nov 2026 10:34:04 +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-27666-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-27666-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 46FBD2D049 for ; Sun, 15 Nov 2026 09:33:38 +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=1794735206; b=PNg9irbHi2Z+30VjwARJAAca6CUyeSQF75OXz/BZO+UajWqTNGHszrp54b2E9YwJNPCP xUWKAtfyaqcrOSO21DnNQq0SQPunsZTtgAhNgoAQOuVeHXdXPhioJ/G5sd35PH9DBSuou Pls0Y83kVP4dIxkSGb6g1Avq0gFEveSqZS4xJ3miqaiKxWhaRRzZ+R3vT8Y7MFbhMN0c4 07jVEeJhjpWp8iW/TkdnloC6dcQ2a4cMj8dybwnsYZlSwq03hIkLSSW1fQZ4PiU4L1wqe lVXGxUaYbDV2d7FZJAtB6JViepkQPyERmXqDEz7eA9cuhBQURTRiNkmTMW/NiGk4z7A== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735206; 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=PuczV2jozFUeyJsXtX8bgTt59XDEa5cGyADBIgej+KE=; b=pj3ms45NgCCVJ6xLdT2ECz7GsFRLffbdbLbeEC30ud3prBSsSFhtD1oNhsqLWesNH015 UaWiYgkmyphTtjTlO1wRgALpSs4X+L/ZOHl1dIWY1rkiq+Igsctb5AbuC4XFcZlIsLq+H ARlFuHlbPLrzZhG23uvXtWEgZmcbHW8WNvKnoePs2Q3rPQw++aUPWS5B+dL02y7NIANyd IVhhiQGbD1C9JV3Lo7FKsXVVsJx3Z4eqI/lV4RS9lzXS3bdm7xQ19MImizH272aUDM4rc 5j7+a9CP7ZYzaDi9AZ2SxrBzrUu5+mYuNtx0ddvFpBoDxuNd1gVXExBJ2qqqX/Aq0kw== 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=uuCRFqpD; 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 84D4460A260E; Sun, 15 Nov 2026 09:33:26 +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=uuCRFqpD 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=1794735206; b=z7/ji9HkDILgQrWTbZOMQh7lT3Vdvz5dq4BuWbk+zj6P+c5/ePP/s2+uCCH7sp4FRg6q kLNR4I2EwCQFDoLLVstJufg1Q1vd2aSbynTOIJX3y/FKJ9PvaPZg3r51T+mcVO3rraUEP 86oQ6KIquinN3PtI1FzRyPXL7ckMcQjpn/LnXd8WRfqxxGnNs9AOffiA+1moqhaDe+tV9 Akbmw+C+TbcecDy8exbgFOFZExK6TbxJO7thmzjcBwG7rDxjcZ5yJzgDfbXh5fWcOvq28 72T0gSiSaW1Y61dmL2kt8NHcWKQQPlBqqHS5l9dBUN4OmF/ZHIAvN4tHpD5K9z2rsrQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735206; 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=PuczV2jozFUeyJsXtX8bgTt59XDEa5cGyADBIgej+KE=; b=tjTWINo2SSc/NMujW/bZ65sODQQmr2BqdsnJya4F7XIUizEk+sKeJXZG6B7ZKjbw+9y2 n6m39sTTpFZgdB5w1VELzpgRUwcN3D8CDrkQfmBEWsdZbEcLbZNHD6Mth+grkmTOh66j/ UwjwS2t2ML4vRgVTitP2f2wxrDnsFfVpq4bFROCHCq9JbzbDLKzhxF1yuIYH5BdY0MnSI 0QkUsaTHygxT2qOQvylj2NI5xfiNw/aKls4o6k/wtt7tesEVxzPRl3xbko/nN1AvQAYMo EckjlsWK4lpwNXtcsQjWPrverQIBm4bZtTFHEbNAwAUrnBrnb5bENTGLhfi6aJjVgBA== 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=uuCRFqpD; 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 1D8D960A2604 for ; Sun, 15 Nov 2026 09:33:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1D8D960A2604 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-6de2f213b7aso905282eaf.0 for ; Sun, 15 Nov 2026 01:33:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794735205; x=1795340005; 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=PuczV2jozFUeyJsXtX8bgTt59XDEa5cGyADBIgej+KE=; b=uuCRFqpDFytKH9kuusroZ9ICgfFLMl7ZVWACwxURJxv7LfDBvSA2xidhX/oG4tULRM L+W6gCYv6lB7IkiLCsVD161EV+fgNUXk6CIv3Foq/wHK/2n6kfeZ0CMaH2VJOJTuD7vK WMiliwql0m9Eg/aAhznU077/7gcNdyuYa82A3kAI8ckIlLKGdbNSg94I3qp9+wMfm1Sx Efx84pYyqUOGgrl1I+acVRWrVe1j1jKF1/lHS2+hGV4ihqhVQ3I9ybL26ZfW9l2Rbvio 17P7Fjw10JrlBG1KwIv1cmkg35ZqV7lSXbYh/5Gr3cYLzx5l0BrB6zmLvp/T369iSeoL 6Wow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794735205; x=1795340005; 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=PuczV2jozFUeyJsXtX8bgTt59XDEa5cGyADBIgej+KE=; b=ZDoiHcH5+Am7OSez0yXplS6nQeeEQ/9s3oXc1IeQA4FVBFVfFQcNd176DNp7IGnCxI zFugUJAhlTebwUpOw4C3/yFHgU33rZLC/fY6uvlqD5gd44YpFA2yymA32S5SUeDzGc3T 84BYzek1OlDekRnRJ0zixY7wipqWSAHgXHIE34Q9t35TTOU3nUEccixHnW9RdZ9XZx2E Y1Ft++RUGwHf6ZyLUJ0bIfjK4QK900Wck3b3wzZ1wzRfd4e9QWDAY39uFpeTRs7/oZh3 hNf8ROvD1aoTZpujwQz+ISgvBlQsOcAM743DNXdu1qAi9VSPAeuVkHv/ZG1qQyUmiaWo F4QA== X-Forwarded-Encrypted: i=1; AL+hErF39+VdV3I1wzJGBeJn5jcvZ/GbVF1JIYBOdKhnI7pF6Dwtwnp7Dq/6oc+vxKGTj1E9y1dn6Ub+XuoQZA==@lists.linux.dev X-Gm-Message-State: APuU4Z8P8q6L57bmo9zjosuc2Gsy5oDAyo6h/lvGOGfrd1vyjc6MM6IC e5ta4CyRX+UjDF9YcZk+PzLcwvckTQIm1RQgofISmULxe+En8iLrqPNI X-Gm-Gg: AYBFou1uG6rbL7eY9CRrMq58yBBfl9uA6jtNQI92QfXa0OuKTLxydNU1GGPOczVA5mY sa8cAxRUWSV+swc+vvPyWsmWx782bIh2OKfVsoUv4Znu/BwBkCKfn8RURW5lvfqWn4t89I3tsVU BM/Q3tMxrIlT/7CoELE/+e+M1ZPzbOJk97aaButaSj9wYS+36rD1mIWJVXCblEPMbSXSVm+j4/t DQPXS2Jk4ICYVJ1GEZaeeQC0773ncyO5PX6Dm08CQ6lQ3OhdBTPQ+IgdC/zCILKpvg2a1DaTi14 WQnZJoW856dzWPv/LRUSzIVC3IuanbFamnw4G+Kp+qgrhVFFYqbuT6WcQXNPPSDpRBap8tQUna5 7by9pyN32w5/b7taCr8uGPKDAPDI78wmLARDy+z8iFvWLf4WKCxmJiEnvg5NV9OGsH9uEmfI9EW GiXqA4ywK3QjwMPBujsJYXGl4ZUWWnEI81+tnzfEIvvz8dD5ePfR3XE0RmeZaYcjww88qcCTmfr r8PuYki355VM9w2IzpsjYx54iBBAy1SG15Ka7Ui7w6accXiSuFtuxFRZxD8lryZvOO8TYBD3B3R WPbcSONO5ZWUjoMIabCKcm/pFgoXJzw43emIGHr34urvpB7LesSqfOUXsm+Wd4zDmWWDZplzx+1 fz2sosdWYRTrY9CFqADApQ+Pu3p//n7oe3pWNtkHH3JTHsJ5u5h319kfUkVwTK3i8b8vup32xrr IzkMdbG+IBbV8BCLxLyMrVb71hMToBOThACkWhh6RbhHxsvVvAnW8= X-Received: by 2002:a05:6820:5604:20b0:716:c2df:d9a2 with SMTP id 006d021491bc7-71ab505077cmr2942230eaf.44.1794735204957; Sun, 15 Nov 2026 01:33:24 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 01:33:24 -0800 (PST) From: James Hilliard Date: Sun, 15 Nov 2026 02:32:57 -0700 Subject: [PATCH v4 9/9] 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: <20261115-submit-sun6i-dma-lifetime-next-v1-v4-9-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]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; TAGGED_RCPT(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_VIA_SMTP_AUTH(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]; DBL_BLOCKED_OPENRESOLVER(0.00)[sin.lore.kernel.org:helo,sin.lore.kernel.org:rdns,nxp.com:email]; FORGED_SENDER_MAILLIST(0.00)[]; FROM_HAS_DN(0.00)[]; TAGGED_FROM(0.00)[bounces-27666-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:104.64.192.0/19, country:SG]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:104.64.211.4]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received]; RCVD_COUNT_FIVE(0.00)[6]; FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arndb.de,free.fr]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[104.64.211.4:from] X-Rspamd-Queue-Id: C4F7A1C44E3 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: 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") Reviewed-by: Frank Li 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 8f8443e14719..7316631545c3 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; }; @@ -509,7 +509,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) << @@ -612,7 +612,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. */ @@ -913,7 +913,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); @@ -1003,13 +1003,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);