From nobody Mon Nov 23 10:29:57 2026 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=1794735195; b=jO39mYQEAT/cCIrgow/D5N293+PI8x5pf5fAhTI02zADGTU2av3Z+V+w321Qcnr8rKEJ nGN04WfKV76aTprIWVIk4MAiQspRs4JCR3hXNi1dLTZcqKFPllPMOy0dwE+tSWj6nfkas lHapljZR1cQ5+dNPqnYWwMNbkWx0TZcldZAlUoM2SSbZJoY58cVHHPHlUtKZ0fpoJZd9R zoK3iKJFpmaTfwDmKgF+FntIUK5006Smjflh6quwqyjdZdgdnS3wmEFGcLNv2GCPkIuvI iRUTCWypxln19TQOz3ntDqHvm2FKhucMDBnMXug0d8JWgGXhypVN21SY9INo5bfl3Dw== 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=R6pc9OIxCl15f2JiwONY6meFE3ByP8QXBPQn4inNK+f2IqwQfvgOh1M3ItTgOf1RA1rs XgZ0QnzRX42Hx/AhUx9VTyvQcfJcMZwqHcrceamuTr28sqPwqkZUwA9KTjU0aWrCcbEG0 oQLMg1KdDTg3dHPyXjZdBEWynnwI0M108GCwokfSYSIwowK1cr0Ko+rWR0s4vEUAh7ZZU b2OGvQZJvARVQ5ecW1Ng1P8UQa/CF3SA/Lk5WPlxBH+GVTuYWJFagvNpV/mvbc1zt21Ex SPBI8l/Wuq0SWBJM8QGn90acDDLUnRtNFU0FQu5Y8Ps3AOsyBWNDM/2Bzoo9EecysOw== 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="fs/rvhwe"; 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 B0966606A333 for ; Sun, 15 Nov 2026 09:33:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B0966606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=fs/rvhwe Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-6b19e291cc6so3368687eaf.2 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=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=R2O9ixsjiKLUJuRb29OcTSyZsQI1rKD89T0Os+kzNHA=; b=fs/rvhwefb3mMzLgtgmDlbzn+euuyqPVkCufyk0vazIKUe0xa7dm7d0OBBKCkgEdxD 6kBuunuY6gtr/uoLEhtVHv3YQUOutY2hGXGAnR0A2WER43Zx55GOK5iCBeA/oUe+qHjA SL62uIko58yfVm5nfUXYhKkeeXv/PK/tbgbqPQQQxVTcoab2WTDU1mDzwMXjqk/atNTT estj09AaSWkb7Kz7KxATe0p2h/+pP89t6mzSPfG0H924LT1IEAD05pOKk2c02LynK+m8 Cu8JFSZYqg2O2pO88MMlkbbUALW1jG/q6Y7EBBIR8Gv9UVhQFj0P2cWFOoACw4U8c6KR SmQw== 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=YcIHiYySdngtFng0oxpwotxcS2nsz5iDfJxpAaOZgV1Bx5v1n/BMItggRp66c7Ieuk xcP7yXdEP+2b/tyuKLMTsWcWZgnq4sVfEcOsUdZZkGTer5gpDw7WMbgOhmIf931nmhJv p1SEN2azdvyGqubsjo9p7owA5nsIwZ/IR926Lul2RIzaTA7upZdi5g7lTe7MyqkJzza5 SfdJHc8FQW1qTP96VpWouKIOsJ5AN7UzE04mVQ0y/oRR+C/cPptnAn7xdyq7wKg+/kEA nXixjmp/CuOMPwerfZKW0Ui/BgkoHDzR0BGMP0B9jpgp8+34AfGgALOi5Ml3avvgg3Nk nQag== X-Forwarded-Encrypted: i=1; AL+hErEU38i32o532H788K4tbiCgxofgpxoq7YZgGuTUtFRmnFG4L7mu1Zk0GDFBtywBXUvlD3jj6t1P6dPacQw=@vger.kernel.org X-Gm-Message-State: APuU4Z+OQtZzfO3r9cFEm5g9/OEFnNCsYE8J4A58LWXT2YXblJak3nxr Ys3fsb0RVUaYMBESCQGxE1ZONng3nuFh9eQlX4qlSbzlvQfsFXZDReDc X-Gm-Gg: AYBFou0ujHQuw2z5wx8jGfQHe7eXjKlVYI9iCupC+ogUa2Cg3rJGbCRmB8QTmYnvXQU 8ujPL1kXKpzr2GEuYX3VaoOnnHy2wIH3MqtjfqVMSPCoETuV/yisKIbWDyEO0sch4jEh/uPjrt+ UuxNV8vGXo1ybTzgScr7QRpjHKe1NfViVdSeGAey6s9mb5Ij5k0KiHcOdhJ1nJIp1N5zB9hafvg u6RQsmaPU0DEAtf5RkE4Z5KrPUhMtjXry3x1gwMbFVURAwmNOq71Cogqngh68ZJB+vY1p3/OY5i 3CRljOS873EEGpKsuUW0rdYIUbnQPPBP1izMh6PTkCWi3mTruACOaKnIIv8xK/n+3pQPlTyqAsv Paa/1Ka1szpyQuhOhlWM8NK0o0owHnnTqlj9Z1mMVz/feUlFlwy2j2WXZJ7BDokAvxkOYHIV/F8 dEzCYUZfpzB/xXQRWQFUFpXemLSWq/ktIRG9vT8V5pXUShrd6/vEmlMOf3Sc4sKGcgSdtIPgXya q/uctubFfezBbXSJnV8icWOLX1N6yZ6UFchAZ0U93VHk38wr7GDGb4VukUdk+qh7AWlRnMaNmbe nyXbaskPT4DOKbaJGVMkjfoEKKagEhWWLgi1deg6NCb2OYpS/v+ZmSwnoFdbL1i0XwQjnfgbyFM qreRHrmuIVL2lOUYV75uU+Jg3oDzh5VZSyIzWj+8qvvg8QHlfjzta5tRo5bG/YCNfNX5FZ4cWNC dQlQIHt0o2O2ZVw9bu4Xe03p03jGB0QxVlAPyu8KH1Dkwpxst93WI= 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-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 DM= A 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 *d= ev_id) sun6i_write_irq_stat(sdev, i, status); =20 for (j =3D 0; (j < sdev->cfg->num_channels_per_reg) && status; j++) { - pchan =3D sdev->pchans + j; + pchan =3D sdev->pchans + i * sdev->cfg->num_channels_per_reg + j; vchan =3D pchan->vchan; if (vchan && (status & vchan->irq_type)) { if (vchan->cyclic) { --=20 2.53.0 From nobody Mon Nov 23 10:29:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735196; b=hvKLusYIR+jzKgAb0L+hBBIhWFXfyPYVOX67dKfyfYkImQIIpibgg5xFvEMq+X0cDoF2 sT+pNKxw8y2SlQBkQHs2xRx/E/Nz60ftU8vKo1A/PLGrxHmtg4BkKZX9HkHnBLh7v428I +DGViH/HZaQMf5iz4MYKkcIBv0j3iBKMK5Jly4maSGgP7qxsWp23N7soSEUuwq55a19LV 06kU9JI3TJazaQuUV6hkoWzEFgbQL6OxC0uCjny8QFxqtrqT79HQO9LHqaLMtzmZErazH BvtTFvyc8+QC2q8m7lnrNNLOnTRdRTsAq0vCyMYYQiOcvWiGAUIora1beBHGY3y4NDA== 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=xTD183LzI1n4zmJI9NUYsz83Jh8R4V62AKy0USHCXCT1zYgGiClmDDT91X9PgdRGB+Mz /2wBi1CITpgYgizPWlIBgoUoTj2FpCbPnh291a9HwR+4Y23YnipF/HO9XdNUz+EPWYRi6 OqpFQlFbEbIjFwYwtL2FMI78sZGgXfa3I3Dzrky8us9d/qISxqOM+PEkRy59XvVhv1Y0f uGqZg9V0gJ6aTwBfWPsvoppUXYkeo8dI97FbOhJTH/Aky1remRriVJlHhOjlR5jCMnBd4 +uqx4EZ6xp/OpGx6BZrc17juDX3CdF8cXtzivfvn48af7MgATDOK/NLLnFLesnraINw== 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=dLQfn8SE; arc=none smtp.remote-ip=209.85.210.51 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.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 2D8A5606A33D for ; Sun, 15 Nov 2026 09:33:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2D8A5606A33D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=dLQfn8SE Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-862b090e41eso348513a34.0 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=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=w8G8ifHYAKfhALD5ae+dZe67OgXfj22iPEwtf7Dbt0k=; b=dLQfn8SENWQdwhM+3gZFbvRn/ZEgQYuRLM3YfMEKnqn0VRTM4jtSpbKJxmMGbMD1jh Rq8fOsIb5OxLScPlINGeWLcelmVraq8Ny0mON1YOEhVXfmlU+SlXYbH5w1hkFYe/j8Oa rjt1Amg9sXXqe8YuabcTmXgJBKnvHzWgIHqyZ54HohEkD15vDvbkgQyVNzZjmbFh3LNe vB3Mt0QL0SWGcD7I9o1mzuvjNPtsVFTM1a4EsaPvDwntJAopJlTKHsBLjPcmjH1hdFgJ MPf3fFcNpUuYhAw1d4axKklQn7q8rWsBAS4Ilbjf639v18qY7EVz678eFrLHmjZWm2lz w3vA== 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=NimODumD6WJHK/HsZtIiNACICaWhm/ecf5uUx01FUAWxKH8UzXt5seT0aUNC7QIJRO Rw7ub0ZUzjd2XENf+2K33Xw6Ig4dscO3cVYcUscoxpAdk5E1o3gBmplCxDzwNRruGCOO DLcV0HVyyFECLzuXhUFhhZHwy6EabymBbg8nSzrrx2LKfyKqkM7kjW2r1ttz9nauMCPN S7HcWg5M6Fg3jMsBgo2Z+5ufFnCR1ZSchvpIUYIhuHy6Pao6xbo8ivF7odlIr9rkd4m1 0Llh7ylS5tt08CtbBg24UJBo76FqoSAiJdU2K2IUkpM6fuuZo1FBz/pNdq06clU/sRhR hbhg== X-Forwarded-Encrypted: i=1; AL+hErHnZciHUk7Ry+9IAsSnz+2Kme8QjcMBYHedhMhH1fA1VoJYAacOM8R6bMPG8xr6PLWRxxvYeSSQPNLHBm8=@vger.kernel.org X-Gm-Message-State: APuU4Z8U/OyyDrNrdlBxSEmHHqhwdwicV3dWjzlO3RtbKnAkvg6rh4vH HeAX7Sxiu2eq9AHYbMkDz/m92jdMp7q1lGQH6Kjpvii9/Pll0vvX6a1P X-Gm-Gg: AYBFou108eOPG+25e3oTCbi6/MtEI0iWR1SIub/1P6jwVJaSBkM9z1Hddt5ETbEKbNo 0fSlxnUN/HctYBS6xX4eW0a4aMm+sA/QjqpEHbXJm/gUK51wRK1BzjI3r0SPGUycjNoBcFWO0RD LPIRqO+UYQaH/9z55V5pAFcwCTfNqHBGl4z7bh1ShNnSqvuXZabW3IktAxRizdm1YrMS12e6L0/ m+4rjupAp/l9szeaWLWpQTWIi8ANTvvl1LWCt+8Jhj11I7352uItK2NHXsu9CkBPAEoGAnMPmA2 P3WfOiMVp9qQMwSjLFCTkZxi6P+T011Knix3+GEtidm29HZVk+olbL6kF7SUjfGnG3KbOodX6jn z9rJckfy0dE28OxfXnK/JXFWLtFsWU0TMUskknEH2Bx9iQHtPbPZvamRcULlgCPHtQp8lC6FLeN VvJzgwnbN3QicCiZx0X/EKsxLv5gllwu4ObDcgHuoNlvRZxj8AALdFZxb7gqtb9zn+zmuetAjtP +NR0JEc/I2CMXe6j4PJjwfGOg4GsyXQk7ZSF1LJYTFUcyUwGr9XbXo0wpXJcAD2eNdhTQvGcy5g agVTtLZmN0hWP5dqNYphtWeUOZUvS6723dCTPgAGGszSB8wHWY56cNFsc2gjlrVc7IOGTjoaOjF z4X5YmPAxNI3u7f6y0BdXaZfJL93RktGe6czGrQe2lJrhJCxCBEsNGxfo3glVzkghMtqr22lggv uIhJgvhp8UxWsA7OnEEcybjKqD7OYx75651XMqQR478HFX3k4DDGc= 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-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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.o= rg 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 =3D dev_id; + u32 channels_per_reg =3D sdev->cfg->num_channels_per_reg; struct sun6i_vchan *vchan; struct sun6i_pchan *pchan; int i, j, ret =3D IRQ_NONE; u32 status; =20 - for (i =3D 0; i < sdev->num_pchans / sdev->cfg->num_channels_per_reg; i++= ) { + for (i =3D 0; i < DIV_ROUND_UP(sdev->num_pchans, channels_per_reg); i++) { status =3D sun6i_read_irq_stat(sdev, i); if (!status) continue; @@ -604,8 +605,9 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *d= ev_id) =20 sun6i_write_irq_stat(sdev, i, status); =20 - for (j =3D 0; (j < sdev->cfg->num_channels_per_reg) && status; j++) { - pchan =3D sdev->pchans + i * sdev->cfg->num_channels_per_reg + j; + for (j =3D 0; status && j < channels_per_reg && + i * channels_per_reg + j < sdev->num_pchans; j++) { + pchan =3D sdev->pchans + i * channels_per_reg + j; vchan =3D pchan->vchan; if (vchan && (status & vchan->irq_type)) { if (vchan->cyclic) { --=20 2.53.0 From nobody Mon Nov 23 10:29:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735197; b=JZRTi2+czRZnLUl6J6UI/DNTzn1ZDNGNgOqErdqoVOk1uhAHUOsrW0PdzpDbifSO7rFv MW0GYaDTVfXJylylJ/u7Q/EuIkGzG2Z8K23Lrsb338MPyJHHactrQ7PMPM3iUWo22K/Nu SEaW9F8npGWFCvrVrwmBYmXKaHGQ/YK2eWpILo2RsNY7ruU9j9JhVdZ/l10jbY7OCL1+/ 6016Dg6WF8aATovlc2Kh2140XU25NKia5PG5aVmKbP2Utzf4aZAZfYRr+jROkdmBlxoG2 AIUWVYrE1SsdqDTab18ayKWGAtgCJ2Uf4RIGhyZa5ri8xMYE0a2iihn7h1hkwA1nQsA== 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=c1dG+yeYj6ta2Xz0ii3GCaI6M/hQMOqZgpRx0FTL4lqWyyApROYkG12zClsKRTHs9hkN FNDd2vbKVkerBT1c1vP/HNMQyMKhr/OvpPaztpUyQHEDBW2hzpkhK2Xk/Q0k5va+omRLa H4PqLTSh99RhGBrmQ4YzVcLtlmqltdKtwS3sUbXcic+6uqH422evqR2zO9j0WYfKSFefS 9CGsTwmIMINI3Nm6E0QTsg0C5+ONcmbJQkTHrr5Hxaljx/nsWtp/Jg9GlEaCJZmWNbOsI zx4IWqwU/jS6cTvqRV0pRny4QHNy34qPusrRsE9YDU8rKFhdQ4RvV89Lq1x5mPQMgmQ== 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=qqJJk866; arc=none smtp.remote-ip=209.85.161.46 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 82661606A336 for ; Sun, 15 Nov 2026 09:33:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 82661606A336 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qqJJk866 Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-716d052dc23so891864eaf.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=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ULmfgjA8hHN0IGqRl2n23MUGsl2Syf0XQisPuEg7n6M=; b=qqJJk8662Fzd874Ad0qZxtNVkMdspNn74DC+U8MD2yXKBI930cQ/vNUl2LZC/MsMIh tuCmlOm+AVXfFxs462pE+8i4JCsNlejeC/wTVqarM7xKMrr9kiXAKvdfQLyiTOza/d19 bmmcOGEgv1SPFLGbjpZBer4djzPH9HofROdPuCPuedzkmtn1SJQEEeOMHzmShtf2VkbL vqrEOnqbwnlHuNl89StZ5/2rdzvr+Cv4d8RHnr+cWtiLfOgsoRt6S0ghwH/Ho/a0uEBs +fBSzLfklwJHMDPo+yca2K19KOH4J2nJi/CBsZ0HNXt/OnAe4ZskoecEmSysW5/Qr1aj /8Kw== 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=PiNNXHabPajJQ0RdAYa+1rTvdc/4gjwGJwthE5vRJtS0FLG5vWhP2dqQW+uyG7an2a RZ5XsU1fdjS+3VRox4/obq9PZ7gg63QqfTgeThMlHRMvputSlhwFIFkbJdGRjM6CkeKT WSaj/OI3uNStKwhzIqzRUccU30TxyV5Rl7j6yMUrg+b/GPx4RHRBp9HKqwElWBW3NVKV /4oN3dqXk9N527USnlOCspQ/bXFGnsIjnLzcsAZ8CoNY6Oi79fv7qXiTJv18KlCJN91W r6KEDGmqYW4+P/86GHR+nx4u9NmRFEoZkId4l6WI6QXwIRk69Ll0F7OTRzHBQ+G/yi5R /DIA== X-Forwarded-Encrypted: i=1; AL+hErEXIGLwO5nrqhXy24s49tSN6/QvNxJskJsuMDVGLtSyD+PERwPulhKld9mPdPFSQFm8atKWFyI8TBX2I9s=@vger.kernel.org X-Gm-Message-State: APuU4Z/eMeLAVEZ8Y6HLWgDVCI0817/FsuXDgfhvvOAh9d4NlHdjHaVg pEbuO5AI5fMnIB5aBXIsFXT8RAe01I6bpY8JqyfJjQWlki8tCVeMarXH X-Gm-Gg: AYBFou1Ahln4bPvB2NK3gghE1NKBXFt5wKtd21OmqCMocZVS1T2X4DGBtQ45oS6SeeN g0XlSRUCALA7Hkk4xmgUJZAyrfcdVrO0HAOcpd2uhC792/zhW+WsfYTmpg+1G2EnULoGr3EdwGn /EcxkSAOlXHK+l6PQRjwSduBVWTwKtDFy+pKSuWI3EMWnEZqEmdePlgt80XrEvIQC2ZyYoXr+Pb KJIiBQhbynMiorwn9ywz0KTE9jHxdHKz0RIoICTpILlWX8eMh6Kc68NZLH3qwAs03vgIt8/nIO0 jLESoEXtIR9Wi4Hch54Nx4bpx1nef39KzFfBZ6aE8dZE9HU3sOgZgacWkVCEVHtEd/8nPnMXRg1 vLwwKBaLRFK/VBKxfRYrZjdF0LuzMtrirTZEgLexFrYlxs+nB6JxS7xz8dAizWzKWFfqpuMXqFd CoX09escu2eTTNEoxqH+jDBF+jB8vqYsplad1+4LkGoEGqr4ukg93bQe0ZM8ngN6OfrJorOe4XI 13i48soQGv/lxLzW/79+OtI8m8b/U30szZtJGCSPdSJNZe+YP9Wm2O8i4e8mqEdoK6rQWlasDje GbsJPOACX/c9yhoQP8oTlUBM+tXJmYuSA2TrMAjTadIzaQ6YeXFlWc/AqCF9VZyKCBCV+OINdyP mXCaFMsEndna94Kz2YIVzZMMRTuh5TtjLfPxmWVmhnLS64DiJXLbMIGtUcldzeBLLMS8vRADQUt 9tDlnX4BEj5cvRJluQEFcp11EReWU5rQ6FpbHAILTT5VUOZTbaQV8= 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-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 =3D to_sun6i_dma_dev(chan->device); struct sun6i_vchan *vchan =3D to_sun6i_vchan(chan); - struct sun6i_pchan *pchan =3D vchan->phy; + struct sun6i_pchan *pchan; unsigned long flags; =20 dev_dbg(dmaengine_chan_dev(chan), "vchan %p: resume\n", &vchan->vc); =20 - spin_lock_irqsave(&vchan->vc.lock, flags); + spin_lock_irqsave(&sdev->lock, flags); + spin_lock(&vchan->vc.lock); + pchan =3D vchan->phy; =20 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); } =20 - spin_unlock_irqrestore(&vchan->vc.lock, flags); + spin_unlock(&vchan->vc.lock); + spin_unlock_irqrestore(&sdev->lock, flags); =20 return 0; } @@ -1058,25 +1059,23 @@ static void sun6i_dma_issue_pending(struct dma_chan= *chan) struct sun6i_vchan *vchan =3D to_sun6i_vchan(chan); unsigned long flags; =20 - spin_lock_irqsave(&vchan->vc.lock, flags); + spin_lock_irqsave(&sdev->lock, flags); + spin_lock(&vchan->vc.lock); =20 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); } =20 - spin_unlock_irqrestore(&vchan->vc.lock, flags); + spin_unlock(&vchan->vc.lock); + spin_unlock_irqrestore(&sdev->lock, flags); } =20 static void sun6i_dma_free_chan_resources(struct dma_chan *chan) --=20 2.53.0 From nobody Mon Nov 23 10:29:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735199; b=FKPdiNddNXQbnpb2NVwCripERnkycFYz0od2d5Y64jA9VcaOaoSrMhJYjMy1KKbVNv81 6iaIxJFOBV+gdRkjNo/dE9spN8CpkbWZsDMVD3MDXK1zh1m5NMWdezDRLIFb3sHGTtg3L Xa2Jut2tPL2YSRL4VCn56xLwGWQ0p6LwM2giUc1VPoSv1fKGizKkrcTpqfFtBqn6Klhs7 YpFkennPx4EZgJ00nSlzky/fnWo57JMlmIt4+FwHfMk13qK9R6VNus0eiMJ3VGx6zQqQG PPsobULSlWRTHGsiQ+la7wGOEiKZYdBqffMFky62gQ+Rc4XXbvjJSt48XJn4gvmBe/w== 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=zwYl+LDCo2/v24pT2cE7gbFS+sSNohpb3/Wa00mWTbyuNJuTkleRQzfbBDCV1ocyEcmC ANNuel2bbDmAdwgo1WiVn20sbmQKiMyKQeG7IcEqrHdasZzTfrkm82WUIIIz3XlKg8DTT Jg9sT14ahFjFHc+gafqKJXCzTtdxjwA1MfYhct1qXKlouu5ANsb+kYcgMYLzj20DYgfh4 BIArlra1Utl6y6BH/dD69rK5VKtnpzREQuolq9FkU+oZ7QnULOPShJX8zHYBH8YjBFpgF 2OhQmT2ntxdXnqMw8S1Ab/IoNfV6xy8F2VapBqwC/z/h0mR8mLNAb8v2Z6rUEHmLx+Q== 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=C75E2lCj; arc=none smtp.remote-ip=209.85.210.48 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (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 30D1F606A31F for ; Sun, 15 Nov 2026 09:33:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 30D1F606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=C75E2lCj Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-86156cf8a7eso2971864a34.1 for ; Sun, 15 Nov 2026 01:33:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794735198; x=1795339998; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PHAQXgA7Ag6ugvQaLzYJVeEvbSBqXCAOAmP+o62IFzg=; b=C75E2lCj6W6LCJZpJdOZXTm83xopMdBxBvjb4L19/A15MgKA3qiNnMfjtxofVQNsja +SBKQ+1wI7zyqxbx2t2R4xLigvHY/5a5coYqmmVzsz0JVO0ZprfkOFJc/S8dF1ROwhXk Tg0d04JibDkMETJTUiv0iPcj4qMYwy5JhBJW3gTgJWphVEMIfnZGlGYbKKinjEWDr1UU lvGE6NHgd+Bi153TzwuFUs96+8eKvm/yf4Obw0U5oYl5tSb0e3r1NeelvP1kXMSxLRdk B5mza6mnjApt0ewOl1YIDwziaD0BfbsdzQHvUrpRne4rTrnlPssVoEevaAZguJnNHwpT 7icA== 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=qTGH8agSVLTHKrqFKhl7Un+lL/E7HZCMOLvoYsi2XSFS5goeh6OkXioNDfK/WLFRdN yY+lNaD2q5ksRbwmx9CPTwsKs2R/ykqFATGGq4SshjVqYgyU+U4rF1GvhOJBfEeI+Uae g8y38dXOW6S4sMwZQAKY3cdqpYl9alBxTUgTGaTGYHlKQ+dhhTJoY+//xuDLm3SDZmPo oHaadyaVVI0gjgvVtw+1nEwEoDunFvtLdypKvFckSXtXyK3sYRLS9o7s7/BhE+h7fhaZ VVhd8GGjGGDj+Ko4+37FULHPhlWWgraiCNCcfcpQFDZexBTQ2iypcXlKuVobGcbRMRmU ROYw== X-Forwarded-Encrypted: i=1; AL+hErHIpNpZvpvSJU2ckGcVmO8gmZH9irT189O6DbMoCsAfsW0dPNzz609l77x0udtlAqcXNFa/ebzgOj8YX3o=@vger.kernel.org X-Gm-Message-State: APuU4Z/KvsckuO/aX6fOhOJAgpASdDhfQ2knvIE0pi7UDNryKKkXKef0 H8t7Ph6sQedBNZ5YRZ2zRRmYqYEI88O38ZFn7bLiyNuIHMb3yHNMDtTn X-Gm-Gg: AYBFou0T494/Uki/PlW9yVp29Mu3+KKb1J7MDGtujBYVa977xHMb7ZacDScUtMxtoag CNiHw/svXROtGmpJGLpUOaMiIE4LwqejUKBrbtRlAS432AmHzpOVlqSTqtQ7CWGS3a8MXPpceHL TpipYUDxYZvGxViyvcXyaEdxa5Qxidd08dx01pfnWDcgZKT9Vbh8f0hAeSEuJ+Kf2v1XLlL0KaE DePDf60I0JiMaHNq7ndaeYIFkTvQ4mNP8YjvthiLVVmp9iLH+ikNSXiahrRDiLZWBLgquuGljIz yGy07dqeNiCnbME3Ybdg9VQ2lgBI+Ytr9gIcmyEwtdiiTqBbYqM0bQi/6JhddoHGDyPO3f77HD5 dR1wgHCBq2KPLd2YR+6L3iieXd/nK2ZqLHz0WX4PkEOf7rkU0BsNnrd8mOirIWxTfrUCcJ1pZ0z gKO2h7XkdWOAzwQ/7RDInB8L474evxXUrzMqoV65N32p4D0h97Ruksq8scio8mC/dTCoeOE5iE0 QJ7cN3otPTFapa4mimOUs5Hsb75kzm+3/IKbvIO+GV6Jc+qgLOFj3wWNUTHbpYqS0V3MSsZJRK0 79T2vLKIzdGPEyMksY53U44Y2/XTjvpVeEGE51QBkqinuFnLcE88WP7FRAxGgxwYmvX2h89i97p i571OxXqHrGTrdFoychyhtA6uHPxmcqTbrs7gWQb9ZqG07JRDnxYk/JwxeqSDl0usj0WBaGZHzF bbpizLe5ccqxbzhF529a1NI01qp5RzSGNloQexdAQqJe+YtYTbooc= 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-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 DM= A controller") Reported-by: Sashiko Closes: https://lore.kernel.org/r/20260706065650.34B131F00A3A@smtp.kernel.o= rg 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 =3D from_tasklet(sdev, t, task); struct sun6i_vchan *vchan; struct sun6i_pchan *pchan; - unsigned int pchan_alloc =3D 0; unsigned int pchan_idx; =20 + 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); =20 pchan =3D vchan->phy; =20 @@ -547,10 +551,9 @@ static void sun6i_dma_tasklet(struct tasklet_struct *t) pchan->vchan =3D NULL; } } - spin_unlock_irq(&vchan->vc.lock); + spin_unlock(&vchan->vc.lock); } =20 - spin_lock_irq(&sdev->lock); for (pchan_idx =3D 0; pchan_idx < sdev->num_pchans; pchan_idx++) { pchan =3D &sdev->pchans[pchan_idx]; =20 @@ -559,31 +562,20 @@ static void sun6i_dma_tasklet(struct tasklet_struct *= t) =20 vchan =3D list_first_entry(&sdev->pending, struct sun6i_vchan, node); + spin_lock(&vchan->vc.lock); =20 /* Remove from pending channels */ list_del_init(&vchan->node); - pchan_alloc |=3D BIT(pchan_idx); =20 /* Mark this channel allocated */ pchan->vchan =3D vchan; vchan->phy =3D 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 =3D 0; pchan_idx < sdev->num_pchans; pchan_idx++) { - if (!(pchan_alloc & BIT(pchan_idx))) - continue; - - pchan =3D sdev->pchans + pchan_idx; - vchan =3D pchan->vchan; - if (vchan) { - spin_lock_irq(&vchan->vc.lock); - sun6i_dma_start_desc(vchan); - spin_unlock_irq(&vchan->vc.lock); - } - } } =20 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 =3D sdev->cfg->num_channels_per_reg; struct sun6i_vchan *vchan; struct sun6i_pchan *pchan; + unsigned long flags; int i, j, ret =3D IRQ_NONE; u32 status; =20 + spin_lock_irqsave(&sdev->lock, flags); for (i =3D 0; i < DIV_ROUND_UP(sdev->num_pchans, channels_per_reg); i++) { status =3D sun6i_read_irq_stat(sdev, i); if (!status) @@ -610,14 +604,14 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void = *dev_id) pchan =3D sdev->pchans + i * channels_per_reg + j; vchan =3D 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 =3D pchan->desc; - spin_unlock(&vchan->vc.lock); } + spin_unlock(&vchan->vc.lock); } =20 status =3D status >> DMA_IRQ_CHAN_WIDTH; @@ -627,6 +621,7 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *d= ev_id) tasklet_schedule(&sdev->task); ret =3D IRQ_HANDLED; } + spin_unlock_irqrestore(&sdev->lock, flags); =20 return ret; } @@ -933,19 +928,20 @@ static int sun6i_dma_pause(struct dma_chan *chan) { struct sun6i_dma_dev *sdev =3D to_sun6i_dma_dev(chan->device); struct sun6i_vchan *vchan =3D to_sun6i_vchan(chan); - struct sun6i_pchan *pchan =3D vchan->phy; + struct sun6i_pchan *pchan; unsigned long flags; =20 dev_dbg(dmaengine_chan_dev(chan), "vchan %p: pause\n", &vchan->vc); =20 + spin_lock_irqsave(&sdev->lock, flags); + pchan =3D 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); =20 return 0; } @@ -980,15 +976,14 @@ static int sun6i_dma_terminate_all(struct dma_chan *c= han) { struct sun6i_dma_dev *sdev =3D to_sun6i_dma_dev(chan->device); struct sun6i_vchan *vchan =3D to_sun6i_vchan(chan); - struct sun6i_pchan *pchan =3D vchan->phy; + struct sun6i_pchan *pchan; unsigned long flags; LIST_HEAD(head); =20 spin_lock_irqsave(&sdev->lock, flags); + spin_lock(&vchan->vc.lock); + pchan =3D vchan->phy; list_del_init(&vchan->node); - spin_unlock_irqrestore(&sdev->lock, flags); - - spin_lock_irqsave(&vchan->vc.lock, flags); =20 if (pchan && pchan->desc && pchan->desc !=3D pchan->done) { struct virt_dma_desc *vd =3D &pchan->desc->vd; @@ -1009,7 +1004,8 @@ static int sun6i_dma_terminate_all(struct dma_chan *c= han) pchan->done =3D NULL; } =20 - spin_unlock_irqrestore(&vchan->vc.lock, flags); + spin_unlock(&vchan->vc.lock); + spin_unlock_irqrestore(&sdev->lock, flags); =20 vchan_dma_desc_free_list(&vchan->vc, &head); =20 @@ -1020,19 +1016,21 @@ static enum dma_status sun6i_dma_tx_status(struct d= ma_chan *chan, dma_cookie_t cookie, struct dma_tx_state *state) { + struct sun6i_dma_dev *sdev =3D to_sun6i_dma_dev(chan->device); struct sun6i_vchan *vchan =3D to_sun6i_vchan(chan); - struct sun6i_pchan *pchan =3D 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 =3D 0; =20 + spin_lock_irqsave(&sdev->lock, flags); + spin_lock(&vchan->vc.lock); ret =3D dma_cookie_status(chan, cookie, state); if (ret =3D=3D DMA_COMPLETE || !state) - return ret; - - spin_lock_irqsave(&vchan->vc.lock, flags); + goto out; + pchan =3D vchan->phy; =20 vd =3D vchan_find_desc(&vchan->vc, cookie); =20 @@ -1046,9 +1044,10 @@ static enum dma_status sun6i_dma_tx_status(struct dm= a_chan *chan, bytes =3D sun6i_get_chan_size(pchan); } =20 - spin_unlock_irqrestore(&vchan->vc.lock, flags); - dma_set_residue(state, bytes); +out: + spin_unlock(&vchan->vc.lock); + spin_unlock_irqrestore(&sdev->lock, flags); =20 return ret; } --=20 2.53.0 From nobody Mon Nov 23 10:29:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735200; b=jk0rn79rrWdZ99bP+ucFS7i/1AB+uaWGmFd30EdEk/eHKiRamC4riVVRVBvTA/kRkKca n1Z2FaIJyYkvJMWlpXKa7QlY6we3Nrs/vc/ZQypsv68cDgEVdm7gzmrt1d2zapMA+AErl ryBIHD6lzuEy9noijzIOdkGauaoqhuzSAFNvk9UN/vUFhcBXkmMtUmim3PwC50sMN8YeT cC8JbyWGPTCxzLE+/rNW460Mz3pG0EBMdkrew6quMrRkPpnhMLnrr0eQoqkgIqt/Jb2ni 5ZUFI8whU58B8eENg6ltXKF7WI5oVElNupCirDOKJ/E5kab/IokZ02fJG+/lu0CCVeg== 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=HK81sKRlv23YOhSizjFozZWYKhYhB49FAhW/bvAXTPLn+MJQIYYfV9da/L079DYJjtqw PrT4kmUVELccog+Xj/OaN2pDv7Wf/cztDHfhR71ElnAU6RDNW7qLZebOj3jpCF8QIjw+0 uajZASwTus3ETfyV2LEDgayVk3qls95OyqTOvnOD/d7eIbi1938OXO1LjTXVU+TSLM5+F ZqH2JN68lechPpaJyt2bzkMV0FThcNhLNRtH5a/YHlB1MRxIX+D2BYyUqNVOhA3YZItfG mFntRFfnyRGUyk4P3OOJJw/wckFGBYVXtmpOGkKni3uPOX/jkq3O+F5AGVKYoyWw2Gw== 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=SCsOlmBq; arc=none smtp.remote-ip=209.85.161.47 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 5815C606A8A1 for ; Sun, 15 Nov 2026 09:33:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5815C606A8A1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=SCsOlmBq Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-6aa9606ddadso2375631eaf.0 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=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bPluMEVsq1fcd/2/kENoSJW0juxe38/N67JwApwlVx8=; b=SCsOlmBqgEDJ6BmeoTUMFusmIni3X/V3Yt2R2U0E+/irtRlSJl1YACWDg77DdUKsGL IyruwbNdhGjrvQDDHY4F/XDdKtvmN1BifV4F4V41h773/9tUkghJRu5XeLdr2UKzSCw5 mOs8kcatb2MTwBMoulEBiEVdl787QFkkCeW84Kr+JbW3Kw7DdeowYVhHElQQu3z+tVH4 m5WgTuewHGZs9Ysr+zQ3Xec1nOnFOKc9G7HRqlb9bWdoA0MXTttfRuhFkqFJ4CGN5oDd MMj5SjR0WbZYhM4lNrRJdNivCOiswaYpbSXNhuzf38Rnq0bd3zulE0JnxAEm/8/zWoZr ykpg== 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=We/1uKmJ7crolUyp/tbJGr9fOQjaPdIQukOYOXC3aQHCQu2gF16nXzLoQpBuAm4K4x J/51GpysTBq0OGvHyYJyyPCrrhu0MyYTwG09O0luxoqL/lek4892s1Ss72SJ2EWCx6+1 QppxgJc+e9POMAcAFk276mna4dyJENKuz7HfmVX0pCTPuoC88IkJzygfFj2EygTnYd6t rRazZd5ma26VYHqs4BNyQZN5qa5ymyeSDgobA6gpY5dIvdw9zKAHbTyW7NIF5+xUx9tz dvoL1L4zxNi5hFF+pBJsRqw9rJFeiWmP0eB0xGDUEMmcZ1s5Wcp2WSXW47T/INu6voje XB9Q== X-Forwarded-Encrypted: i=1; AL+hErHVq3JiB1wVQ3J3O7b3KvOrLPxlBfFmuki5Q8yeAaCRGoSdG+HJNhSt40aGnSIU5en9w166J705kUoOR8A=@vger.kernel.org X-Gm-Message-State: APuU4Z/bnADUn2W8GyEJ42k3x5861PRBewa7LdVOBC+fTpatgvkAA4z3 Ifh0jEsHJtWY2SLgeskhfVxZIMvjIzk1JsDJiKU40ejSoWsCBGnSspLD X-Gm-Gg: AYBFou2wdecSK4reG25Pxfz6xgUC5x7SxHH8ed24NkVrqIRqLcMLpRDsHuu/iLGLX0F KyyucXwoQ7OFCOg3pCid//TvjYUr3jzKOalZKU/eUZ5GHcjjFqilwecMExRVZCWCRuliA14W61E a2h3P5M9TprolISmQY+gcRLoQlZ0aDtsSE3PGQa2lKvX+81EKBJYoeB3Gv+I/rcLkZvkQJZ6HlD VmSf8xs1X7JPw4XJ8/rMfwIAdpxDtxsK4vM6S+EBItVJ5D/fJpvTaPiDmKlAKP/TTIpXXHel0jT MoGYzZ7uMrzB2eRdgWOwg8Eei7G/w7gmnQrTwDb/e0ashwsLM5g4zCDyrgepw1MgOxozYkqsuQc akNpGOrPoyNePIOYwOC3z7ukGk9BTLBojfP3gKqeEDIr93PUdPRP2Fif5PAc/xMyW8J3n+bpKSk F8VWqsKvBymP4XW3Smg8/xG6weNcJtRh1QgLKkFhdRca0tbtgF0oeC01Ukneqsrm+aS9eicCmvu TSEPm8nkCNTb7iknuqkq4IlrBL094PbAGOSGcNkwnrmSpODCBuoycpdX4ofqD+KPreIW/uy6EhT laH7OKOd9UhxNnWjIJHADA25EtdpupCtJTQEu2Z7DH1u4a26WIs4T0GF/9u3A4BGNacmfgUwniZ VZfyk60xBAvGr4yiUdtzY7Mj71+XBGuo6WbqAeQmRTswlvCkXoaFfwOxAD4yKqB8ia5ZOzyTjRN XnzjmnxF0AopvCBkRoNej6YL5BkqDRIZzWkuT6Q5J8Ftv/+T2O+KY= 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-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 DM= A 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; }; =20 struct sun6i_vchan { @@ -492,16 +491,12 @@ static int sun6i_dma_start_desc(struct sun6i_vchan *v= chan) if (!pchan) return -EAGAIN; =20 - if (!desc) { - pchan->desc =3D NULL; - pchan->done =3D NULL; + if (!desc) return -EAGAIN; - } =20 list_del(&desc->node); =20 pchan->desc =3D to_sun6i_desc(&desc->tx); - pchan->done =3D NULL; =20 sun6i_dma_dump_lli(vchan, pchan->desc->v_lli, pchan->desc->p_lli); =20 @@ -538,7 +533,7 @@ static void sun6i_dma_tasklet(struct tasklet_struct *t) =20 pchan =3D vchan->phy; =20 - 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 *d= ev_id) u32 channels_per_reg =3D 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 =3D 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 =3D sdev->pchans + i * channels_per_reg + j; vchan =3D pchan->vchan; - if (vchan && (status & vchan->irq_type)) { + desc =3D 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 =3D pchan->desc; + /* Completion transfers ownership to virt-dma. */ + pchan->desc =3D NULL; + vchan_cookie_complete(&desc->vd); } spin_unlock(&vchan->vc.lock); } @@ -985,7 +983,7 @@ static int sun6i_dma_terminate_all(struct dma_chan *cha= n) pchan =3D vchan->phy; list_del_init(&vchan->node); =20 - if (pchan && pchan->desc && pchan->desc !=3D pchan->done) { + if (pchan && pchan->desc) { struct virt_dma_desc *vd =3D &pchan->desc->vd; =20 vchan_terminate_vdesc(vd); @@ -1001,7 +999,6 @@ static int sun6i_dma_terminate_all(struct dma_chan *ch= an) vchan->phy =3D NULL; pchan->vchan =3D NULL; pchan->desc =3D NULL; - pchan->done =3D NULL; } =20 spin_unlock(&vchan->vc.lock); --=20 2.53.0 From nobody Mon Nov 23 10:29:57 2026 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=1794735202; b=SLUHPRwyf+nezz49qB9TyUsfiMUTMr04gQTpDm3M4X7hlAGKec5GniJ8H8PYqP771UgJ QtiALQ1a1ZS7T9r2g30w5n6GMLkal7vm8eWQmYQ+DD17w1+eyRb+wP2mfT5O4sihRDJYE +GH2x5stvAplw1mBnn+KHunRNp5Nay6sWnhwL55i515U2wV3S0ngIWpRk0NqMGJEdQIRs r0lMNUWr9M53cVLpoBr4pZK1eHwaaAGbZ1SOYvX2LwSq6dBLM9G++ZbSTB5jqpjS+TPuL 8cNIsVJM09XkH8bec+xyAvlYMcoS7Q8vWdwnQAf5zhGfkUdt7XRAdH8cSy9QPyRDWNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794735202; 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=LC8Xera3+D7jF+RCIg+Bl/AFmsO6NKpeM4MF0x439bfbdCSAIejRvpG0n530Klt35PFM JcoowOSHtrDgH3kellycSD8/cf4w6h6hMV3ADeRQJiFyIx9u/xn7saKHx1+MZOEGGw+iI V/H+tUKKYPiu18UNs62Umd+TzcVtnrp9LzfOt+jeJNVy7wf7F44NXognZL0MhKJ8iqMsU QciD5KP+xh8j+aHKTyAlbC6LRSmrDYprW+6vcyfkCjNMUBJXJFqDbs6CDWmPbXSJ+BtWt FRNJwV0zligb5aiiWlxA61SE6K1Ux10sEHH9ucuQHVvjdjRciD+E/6TySQ/NY2iu05A== 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=pSk1uQwr; 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 94C7C606A8A3 for ; Sun, 15 Nov 2026 09:33:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 94C7C606A8A3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=pSk1uQwr Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-6d290b10a35so879557eaf.2 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=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NlQp3R8KuFLhV9wrXx8XG9nak7uXzaBTY2y9ltCW+Ec=; b=pSk1uQwrQ9+IhZo3tVwwW4sDd0IXKsvXfiY9bYZPx1icGRAr2hZVNhxDr/iSSRozAq sHvbcYqEHglKucpIZsRdVhpcO77N2p6LNvN+MN8s5rf/ebFxAScYN+qtbKfGtDmAZTpC mJIYB9RQgATzVINQlzLXyDrO6u6vohBh5Ooylwy3KXGXLnugXIrEqdR5DDaryY4KBhvl XsCXpxMVPZpDJRe9uTm7aD5aprL4YgKeRKfdSByLHoEzQ8Nh+s366tkUBLsJWFnNguH5 6Lmnq7Fjn7ieWnENvtT2DLXJYrnn6E8tJnSEXH7c+b+lvnFcqM71K0lJJ0FeNTv8xhAH 9zgw== 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=LDA2SfsPbz8Gz1MMg2QKHPkL1HkjGgyMs0Z8yIgeWgDDMpWdhP5CMpNjFZX32o+QcC s1v7d2RLNL0OVTK6pjrAeXCYT/UtsKSXBnA/0vl2zNJj/YaZez23l9MhFMJMB1dzxQoo C5ohG4BDKqZVf5WF4Cupk2QPaL6klfKKEcPyUNeUtF2aAHj+VUksC0gf5PkuLw3fK5se iSkSK3J6Bqo9cZCxyI8tRXkeX6S2UixklDX0bra2qiOo4TLyTNzXsdOGm+tovc4+wby7 BddRUwaKV4zE5S4LPxkWbriokdOTG+3rYCmpw+1kJfahGuCUAp7VtgAGn11tvxIAdIct MzBA== X-Forwarded-Encrypted: i=1; AL+hErFREfh9srL+Hk3PPJss6FOa/sQQwo6EMv+az3jQ38KQsWCgPSBNOzzSs1yE76/0gLtxlbGibUEZEPt3Wx4=@vger.kernel.org X-Gm-Message-State: APuU4Z+dkK84Xc1yEgMw0TKaM2/z26jLyMaZb6gS1BeH6jT8xYQR+DDm HU2u6op82fx+8oPNVMTkrwU9C/I0ni95LXYLYKqfOWnx1lCNXAkOfIiy9fLuKw== X-Gm-Gg: AYBFou1mdGTA7+C+hGPaumCH/mjEfSLzI5eq/3OZEVsibV66MQNKh3VZ6Rwgeuexc7P GNUbTHKeyFbE6aRparttKuWshEoO9vH2LgMOxeQzM1EbZ1hCuJsGf2Sb6rKGgrv1UXv+EJMk9TM fITe/cQI0vYAc7ervgmLIAYJHgOlfWTEYXFiW0dT4VWGc8RhAzcb2c0dyuWHQRu22fimIIzsqyF NGOGrUGJQcXyhoIdYY8pHquxHI3fASh25bM07VVBmu782yHGn95yvO8jVkwaVzeWMO6hW3/9kH1 TaYadTzmb0M/qU3GxyFReDWnA80VjwziH9t0QtrJ/QNAVpjpdByequcGX36GVeemgQtJaAfkY2C ipCjLTvU4+b7OX7tQFwAPgvuXBBkbGGJ7ygd16kJfSI2nJBJjSydf/HGCzWBFQhUztBn6c0zpGB 8Ls15wOXo9oB1mXiNy4x7VeWciRiThw+AgNqEJXOkW3cs2TMudTCHqCEqiXcX8WfYUqvqqH74Jq JeKQKrEM3HxTlmd+0XdMmy8aHyKEc7zrcYjJy3pyrmq1snlb/A7jdL/49C7q56bMnA5G1fPTc0/ InCwFhr8c1bY2yxckRoiR1oN3CAKbLkQjUECBHHh+7Xonq9zLk4RN0eVOOx/kJDb1Jmo/3uCJT9 uB7M96umXzITp12iOimNcJOC/G56zcr2gnIt/sUwkoz/lD/AOKJpqb1PS9bzV/5dOT1aCn4EEoK C6vgU/05aaC+JvfGHoB98P06KgmDE85l+KEv+66raoaYDfaCm6HTg= 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-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 DM= A 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 *vc= han) irq_reg =3D pchan->idx / sdev->cfg->num_channels_per_reg; irq_offset =3D pchan->idx % sdev->cfg->num_channels_per_reg; =20 + /* 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 =3D vchan->cyclic ? DMA_IRQ_PKG : DMA_IRQ_QUEUE; =20 irq_val =3D sun6i_read_irq_en(sdev, irq_reg); @@ -975,6 +980,7 @@ static int sun6i_dma_terminate_all(struct dma_chan *cha= n) struct sun6i_dma_dev *sdev =3D to_sun6i_dma_dev(chan->device); struct sun6i_vchan *vchan =3D to_sun6i_vchan(chan); struct sun6i_pchan *pchan; + u32 irq_reg, irq_shift, irq_mask; unsigned long flags; LIST_HEAD(head); =20 @@ -996,6 +1002,14 @@ static int sun6i_dma_terminate_all(struct dma_chan *c= han) writel(DMA_CHAN_ENABLE_STOP, pchan->base + DMA_CHAN_ENABLE); writel(DMA_CHAN_PAUSE_RESUME, pchan->base + DMA_CHAN_PAUSE); =20 + irq_reg =3D pchan->idx / sdev->cfg->num_channels_per_reg; + irq_shift =3D (pchan->idx % sdev->cfg->num_channels_per_reg) * + DMA_IRQ_CHAN_WIDTH; + irq_mask =3D (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 =3D NULL; pchan->vchan =3D NULL; pchan->desc =3D NULL; @@ -1005,6 +1019,8 @@ static int sun6i_dma_terminate_all(struct dma_chan *c= han) spin_unlock_irqrestore(&sdev->lock, flags); =20 vchan_dma_desc_free_list(&vchan->vc, &head); + if (!atomic_read(&sdev->tasklet_shutdown)) + tasklet_schedule(&sdev->task); =20 return 0; } --=20 2.53.0 From nobody Mon Nov 23 10:29:57 2026 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=1794735203; b=bic59NcK0w8W+cj/8umQ5pQepM6Uqw3xRYaspzuJVu9l4qjuW30pZuEPCrJF3AjViCtJ tfdehYWdouw6d8G4q+ujbQpodbFdWKAqL5IsIbJdlX9CLr8OD+wV5nVycRKCteStQpX/2 hhjs1izKx+ZNm/gVD/hLT1+7vox7nb7QxyV3rI20Oeuqve/TyCBN2hvCU+AvXhZcKqcKc Pdr8MweSjdUZSgqF9R3hn1g2NDz+WzPlsa1ipzTCx00b0o2lcqlGjMuX5wF+9UuJesL93 iVikLsz3SUUMyYJBTFG9opRb0AsYP3l1gKnOKHPpm6h7UofZYOvVol77x3pSlElwCdg== 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=qDZSEBpWjmB7kgzGqddPUaxCdgsIUBsWp9qhEbinXvXO9bNIYwxxYEyXRXXoyi3eLgpr 4qkMHhuesne6FOPQIpLCjUI2nNVReu8v8ddmrvw3l0MYeR0cZ0loGOKs+lT9+JoaAcEDB AIZ3Z4NtihQ4T1mGLm2bJzF16spXPB1SxGWGNWiEfgQnXmvlrkkBMrIbYUawIFjon+ZiD ATsGht1RJzLT+gZubBdvKLi3aFs4j+GSQb+N8Wr7DoaWLpiK+fewVbjGiuNeEixSWG6G9 kA9suSa0li6SvUMy8xftFBkcRMAbqzInSYRDmRkoqaRIajrZThJyYOKwHr3hExi33HQ== 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=G1np7wLe; 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 347E5606A889 for ; Sun, 15 Nov 2026 09:33:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 347E5606A889 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=G1np7wLe Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-70b875f6f1fso2980261eaf.2 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=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=nj+huGoNy2lIUQaGcQ7MZRaU7F68XeRQvFxjv76wcSM=; b=G1np7wLe9YENBfqgbqsA3M95uDrY92Ce+uYyA4rjypwjjgqs/2/eEx9wbHH1gKTIe0 As2VwO0SgzYcp9ynYl51iAvtA7n/WYtD/tPqrX0+koGDUZc40Wdpqo7R5gJsOxHOzHq4 G85IgQcG2dT3Loqwnb2K3i3+csoZo1Xz2uD0PHXEMZwUWkZ5ZLD+v0GQ05K+krI/BA76 cZpgBZZeHd1xsW9+PfhQlve5dZDzCxsAbiqoMW+NzAh7qc0drN2DW5Z5kj/jTjAG0W+F Jb56tn6WV5kePXZWBUMtNe6pfkZkyjXkdA6bNMaffYJkgKrCSEIafLAEl/R8s9DZPTOi QTYw== 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=NshMD+T5WEPG3ekvupXctOAdZLy2kfxykDh7yBhXo+aBNsTw0fbh8a7lVhkkW73wpV kdaW+VpDgVWRi0Wo0tcKtRAsh30hjXrEuXorsaC/2OoXXyBOSUxgg4kwd5v2iZQYwc0T 8sVvTYj+ODM20Q4pLi8FdC8uuiW9d23XIxZqtQT4Sw5LaB34aesvwzBVQeNdSX8bnvmf r3uj4w4w1dMabcLSIl6gs3qE3B5htJXKvQGycnamLhaLTq64Y2kTguF1tZYYMPraNEbB erJC7o4IYP3x/A8Eb7qpUTCUkhkq9S0iJODen8LrETHXtTVIElgdxnOIXVFK2/6yi1pQ QqCw== X-Forwarded-Encrypted: i=1; AL+hErHhfEc+G54lIvT6Dqb2oYAXnl9eaxtPndiU467kYI8mZk7JjVZSNNn4KQLcSYIy/3ppO21jlwY6qFFyrro=@vger.kernel.org X-Gm-Message-State: APuU4Z+U07R9wX6Ak88j/45J1QTLHY6gXB7ZwTnaiCOCKiT3BYiv4x2O dnNPfznzXPMvLk+wSHu+CPwsy1VFSkS4yaBN8xYxu65F6zI1xKFjFHYd X-Gm-Gg: AYBFou3rJEaET/wEKfGjPlL57VLn5+Av1NwP1us8QJlMxp+DWy8x7nmLd5PHPMeiYJz DVjsW8/MAnsRKWmCFYHBy93Z0nPgRf3QwTo0tghudO6sPSyvh+N+/9OduWOFMqt10qQ71+Z43rq r+tPuJRyNr4WbJ6bV8b0h1QpGCKUReQnbVexdWU+t+ksvtI1ayAQTwmDfkVVyvKBDfF9SP6GKUc xeEgbW3oaJoW9D6HL19W67KoVxKjYNVmbZxiPt9tFe6uc0wSe2lYSA4SKMwQ9A9olUe/KSr8meM 85KzQenejPxVUmyJMiImpjy+1MPxXnLwHwnAHTQRxP3yB4wmDc3t/N6txnhf6mdMZlmec3uHkU8 dOeEdOP6KUQrOCJsNa5PPLPRGq27CmMqgPFdnoMTIXQCB/rxaqGIsGOxNnZT3f3bTOQe9DaGxoH bmrE+i6nk68tHLwIjcLeptkLr3uvK3K+lb8M+lSkCcfvWja0IqrQjI6FA3UwZg290qzaDRFWDEd 3HkVm04KJQbD6L67Sm0XhYWkdjDWR/VvMINept8wmClCYXQI07PwS6k2afPHcAg2Le4nleCVwDO rDAg5D/SN9n24+WXykS8LftcZsi4oLA2p98+xmkS8AjXvmRoQGf9NLLgJNyQHN/mYdRjSM3ysBs PpyEqqtlNNk5vjkfFR0i0tnj3rP/PdHdeMWadJv7zdOHj6CxTE3umpScgp6ZXvbF9iwWewyeXsq bqjmLavYDlY3flSZnPF/Xw2c6ymdFZH/M5T6BUg4pMzwT/S5s5wSg= 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-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 DM= A controller") Signed-off-by: James Hilliard --- 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; }; =20 struct sun6i_dma_dev { @@ -539,13 +540,17 @@ static void sun6i_dma_tasklet(struct tasklet_struct *= t) pchan =3D vchan->phy; =20 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); =20 + /* 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 =3D NULL; pchan->vchan =3D 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); =20 spin_lock_irqsave(&sdev->lock, flags); + vchan->paused =3D true; pchan =3D 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 =3D vchan->phy; =20 + vchan->paused =3D 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); =20 spin_unlock(&vchan->vc.lock); spin_unlock_irqrestore(&sdev->lock, flags); @@ -996,6 +1006,7 @@ static int sun6i_dma_terminate_all(struct dma_chan *ch= an) } =20 vchan->cyclic =3D false; + vchan->paused =3D false; vchan_get_all_descriptors(&vchan->vc, &head); =20 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 =3D dma_cookie_status(chan, cookie, state); + if (ret =3D=3D DMA_IN_PROGRESS && vchan->paused) + ret =3D DMA_PAUSED; if (ret =3D=3D DMA_COMPLETE || !state) goto out; pchan =3D vchan->phy; @@ -1075,7 +1088,7 @@ static void sun6i_dma_issue_pending(struct dma_chan *= chan) spin_lock(&vchan->vc.lock); =20 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", --=20 2.53.0 From nobody Mon Nov 23 10:29:57 2026 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=1794735204; b=1DGJG3uCG4rwrjI0wLfyhDj4E9/7Hl9ENfWGIqDMJdfMZdelLHJysdLiHSUr99hQyA2F cktPK6/PkBVTkI7RPmNkKGAXRuGwa2LQb8QKTlpQjydmegq6cO34uus+3DbFbYB7We8YV GwDALqextyAevShuL1aKyl3BUFh2TI9QEQIv8WVHEJj1R/iSm7mivbj9L6OgjvbA9lAhJ 1KaBzHLOH+H994jzjWp7+UFhwr1zLDHEZFSc9NX2HPJG/m/A52NFsTQs9cVtcASJGD6dI Sjd6EQXIfXqtICN/f3+kL8GYGBeOSW2GJwAU+eiOBWyffx/ZUJiEQBTiUZy6Khx1C9g== 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=w5zHWPQ8ch4LGd82vKDlGgZP2f4Ji2W98xyZy0CS95DTJrIa8RKSz7oDPRh3ER05qJcU KYYgSC97FZkRTTjfeHuQULss5Q+GI5ugGEW0Jk0H+CfK+7XDIWFZxxy1q9W1HiJ7R9Gbr 7umCs7QQnrpv0S90XcsDcNSsjbBvbRZqL155dcMj74kTJas9cwg9uPo+Sh/JR/AEDoGV+ ASq8Hm7lvBUXXYdUOpy/OjwNWG596RL0oh+XGe1k0PiVTzEkYCuwjJA4iMTvHttQ/HcNH c3pDaty/3P19/8RsfPJeu2UnpI1tWEZVVYV/F1GTACLyPUv3TDXtYJCJdc1R1JYUvdg== 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=IpyWNPZd; 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 968AA606A8B3 for ; Sun, 15 Nov 2026 09:33:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 968AA606A8B3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=IpyWNPZd Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-71acdd32a53so428021eaf.3 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=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=lLq7Tf1B3BpSLBANTG+leF3RFU5GTaZTVgWe2BOgm6s=; b=IpyWNPZdqceAlFctVKztCOgO9NxIIZRdBOkA02Ciwd1vmjP2LCTInxAT6oE+bLK+e0 njTA6+b58A+09rZGrffxmzxqSPADp939jLPkQpLwCATgiZExRrsJXk7qxSmV3dMoJByo n9swLTzD76yJW1uaP4jAOfqSjy5kLy2edvBsSFG52H4J1x0baNbPKpXJrcouwacMYFTe FUwhVYcSUdgnFBtDfwpJO6sY2GGL8wn0A1skz1lS6PiXMW/KA8K3J9Ux1923y9SG7yQ5 /OOfNLkLrIxArqjkmT9wLNZzmuNvGQkSF+7XtMYklArZbsmDHfxDe461+X3FF6y0lWqa /2kw== 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=o83Jg/40EoB8LLgbi/nQP+tDSf00OY7/c4hR++ZygWXfnlqBwWz9Io97mhzcogxIUd 1bRunwBQjQA1zddS3bOGpVG1XNbXqGiyMahAvxL9DPqjtcGYVi/vSsnJwg2ord46ZZLg Tp3/7Nxdl2LvANUeMqh7XLcIFd9gtrSKiEicMQzRe1NUtGRR8Wix/Dm49QCGajCJhhlK Z53Bag2VYlov6yp5H/pdgzzXqLoGQXi0UVKp+ertVWSUX1kdhD3yCZfGtzZtoxKtmGrm tKy1OUsbl/omhtq+CmocEXDLKduZIPzYYQDeLCMFxLWpG3phIsoXItEzEACz34AhKSN3 yLUA== X-Forwarded-Encrypted: i=1; AL+hErEHpl2SVTlnsW+L01UTnhz1HRai/ebApYlP2oI70e6e6mqefAWoUdNYkgZ+wmT9wkRM6OM0W2d0+ir4K3Y=@vger.kernel.org X-Gm-Message-State: APuU4Z/sABijp3qpJoIQ31Wl+I1McvDdDG7cDWHcCd8/L9iu5GVhwcg7 m35mqh0PISXOM5Xf7bGTqhtIsJiq3D6dEc0hNbFns2fhLnGXh9uL882l X-Gm-Gg: AYBFou3LfEPymAOVxK3gZRpORCDCOjpzsZSzipeprjC1IHxr52luKUV+6nes/RJkWOC vPPG2rv97pEMxYcfGbQ/HI0kTulGJzyej56WPaK3X8b5TQHr0Y76yMypjVhb9UG/0XvauM9kZdl 8WsH36bdFS9fG2DJVtauti/wrDHkcEIJz1EX0hlmyGdGogomwASEgQv9CM5Wlm4jVbhT5CpYsX6 nZwOXQxQtj1Ugp+DFFrNAHg6p/tUrNXQpwEzodZUWRm0EcId6SHWekvbVj61n+oIPRLgLuc5VaV QfVsyGpxL9yv3yT291tKGHelx0vgouifDwDHQi5yAmJNihCCtFG+iEc+svm2rxfp7wDNeAzeGUi UoANTVW1EIk0FyiiuwIHH3tF1N0EhZVgzHFDD7gb0Dee0X+lLBeIofobcJEEYiQTZddgiRjEcGx xMyprDrjsRXLYF8vuLLtT8L6LWBCCdBXIYDm8cXKwvt2cmZUI3KpsVEgcpW8DPOGA4ayZny8AFe SfPQ3uArCRehouCtXSCz1Yn+77P2NNX/myhZeRH6uAtFC9v5Y2lQxGyYfAGrBQn4n2aAHqkh4bv i5wag0bI+itWHUu1wpyzSJhvDZGtJgaFGrsWUdB398Ty+fNAgJCwPgMHMHKCvVh/zLamWAgZ8zR 6ljzaHAi1ZtnW8iGuqDFDFsnQgt9r4huH3rP5Y+ryvHjEqAdBkHGnu7TL9Rsa9XuDkLQSvyEFFj QXDELOaa2IwC8my2OPUBJd4Qlr9Bfs6A83jXmugdKufuv6/t242gE= 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-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 DM= A 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 =3D &pchan->desc->vd; =20 - 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); } =20 vchan->cyclic =3D false; vchan->paused =3D 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); =20 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) =20 static void sun6i_dma_free_chan_resources(struct dma_chan *chan) { - struct sun6i_dma_dev *sdev =3D to_sun6i_dma_dev(chan->device); struct sun6i_vchan *vchan =3D to_sun6i_vchan(chan); - unsigned long flags; - - spin_lock_irqsave(&sdev->lock, flags); - list_del_init(&vchan->node); - spin_unlock_irqrestore(&sdev->lock, flags); =20 + sun6i_dma_terminate_all(chan); + vchan_dma_synchronize(chan); vchan_free_chan_resources(&vchan->vc); } =20 @@ -1485,6 +1489,7 @@ static int sun6i_dma_probe(struct platform_device *pd= ev) sdc->slave.device_pause =3D sun6i_dma_pause; sdc->slave.device_resume =3D sun6i_dma_resume; sdc->slave.device_terminate_all =3D sun6i_dma_terminate_all; + sdc->slave.device_synchronize =3D vchan_dma_synchronize; sdc->slave.src_addr_widths =3D sdc->cfg->src_addr_widths; sdc->slave.dst_addr_widths =3D sdc->cfg->dst_addr_widths; sdc->slave.directions =3D BIT(DMA_DEV_TO_MEM) | --=20 2.53.0 From nobody Mon Nov 23 10:29:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794735206; b=yC+RiZ9Rvm4PcAfCSrYVKaE7MWttVtzqLFntqgEdInWpRxbSdTTv3f1LcycrKh3f1tKr dXqHmYrDxnQ8itI+4Il9XQP5NOl5nh8Km5R3Ax8j0axAafDhYd9Fq9kzoKuIm/xgYcsHF gCX5SNY1+1ePdwSZRQwZlbKN/OwlKJR4QlgTLKXzSScEHSph0MOfXgxT6LFAk0P/Leciy aRiNU4X7mBs05l3HwCleFX4aifL6H0qcwdcMdGMStahZEPw7aGgwP8c2xLisYgXMisnC8 0+8qUiByTSGeXJRazJ0ll8H23hBKkhp9xsFVHBUg4ufbl/f7lYjhDSv8TiP4RJpZrtw== 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=sxXl9ti49GndgZ6/KJufVPRmjU/92jmUs3JKGNFv1HmmD1RPpowz1W0sYIKtH8CjqN9D vqUIfk7skKjVO9Qeaovc/DiUEYifKpudf4DUbyJdJ8Py9ctX3BC5q6as75hKVicY2DHIc Z3bwrJANxmnCi7NFYZ4vRFq45NA78NqtjUyEH8RKxNXc1qHUesiLarS3EsQi/GjB5voJW H0xclJCS/+Y4ktUxFnIRb7ui1jlltOKwHbecWfEN2wFioyN2TkGWA8Yi+21F+VXH4MjjR 5C5PxQgHQ4806z6/CWI4X4wZnmaZnEu1LGMnCwTHeqsjjMyqWCFO+SF2O+aVp+qXHPQ== 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=PEj59C2r; arc=none smtp.remote-ip=209.85.161.47 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 0D1EF60A2603 for ; Sun, 15 Nov 2026 09:33:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0D1EF60A2603 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=PEj59C2r Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-71acdd32a53so428024eaf.3 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=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PuczV2jozFUeyJsXtX8bgTt59XDEa5cGyADBIgej+KE=; b=PEj59C2rYSl+quIcKTy9dV9+5SuhTpvAT2KDDAuzgsQBLvmnNlEET4u5uAC76Sf1Zy 3/4PovDy8uKhKxBxSv/cVQ9f0/SN5gyLl4odEOi0edPTRaX4ELapu9bk6C5dHaBvrWmK 1GVI2tHz0bvRCmFCFu1EhCeB0qJqsoCXnYOURXflf5yMk/7A4WNZrmSVgghBKzN6QTOe sknbs2Rk157BMvySDqe1jemIz1GfnoPBt7Un3s7sIcrH/b8aMVoUiL6gkKRHNnTXAb3z HjnpREoNDWwbPivwwr0bSzHqnpV30LT+sEcZCCUVnnZD6nsaPu0TMDI9rR8n3t6oFshk bgZA== 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=tDw9N+bLKSHLfj8QCHgUZ2zAruB9+MoD+wd8wZutwSEBx6RgmdtgBA5X5+cw6seCeK 8hkTRNLzsLHiQegb4UXGHkkBPRR2vBShz+hgwfBvyOK7u17YAV3qWzIwfp11fZieu0V4 /GNaAymfTfv+Z/sO98Pzv5GsF21d3ZQ97roqrWl82SchLwUX0FkYpVUKtgTl0Mh/bHAk tnoRzwoM2ugEkg90WZJ2D7dRtQE1ykC4feS6o/z7OceV3tsoSElxl231hI2ykjRRCIqg +FGJWpF3EZcLbMh6Cn6T520SLkVHeuIJAvGln0sJSdjSUAyFaQq3pe1VQKv/lqDg2C/R qthA== X-Forwarded-Encrypted: i=1; AL+hErHlq0vxCjdygKscjnz9qMI/AaABkxI56gQOJkmnsZQPL5DPluLnon6rQyjqu2i5mWceECPQJ1ikU9S/vXQ=@vger.kernel.org X-Gm-Message-State: APuU4Z9ZwHJXm+TQ9o0s3ifO/S9S6yDpuvUxT/ADWfNRwGtug6rYv8Xa uS3HnlQisX4uiX4alDuZXaJ3wiq/Hdixv5DTS4GErTQHlw2KoWvTv5Om X-Gm-Gg: AYBFou1nrPGC6B4G0iw3ygdyHhhUR7O1qkcaKf+vfEDlSV1cqaIu9HAMJ5EKu52eKLv FGPpPHIUXQRma2EBwM90aeqTtLx2u34IliAestuqrBGyPL1el7zUwzFP792BdbadGD0BsCKt6Vf bNnK4UL1npxDo9hv/R0yMNPdVywMgrCUsoABVT1GqxC3fagGiT4adZuKzV3DSfsVqj0oFu37y+N qKI/hEg8T8RmFAdfFxpW4KAaIeKVJb0gP8D8vlIv5deqsuqyawLr6h8ZRKHWp3KOPtKRS5/N71J GLlhLP2G2BP+Vh2xDsZ6GZJq2Mb3i0oH5ZiFPH5PFZ9ImbgfWbKSjPbRDqrH7qV3c1+h/G6E0Up 1e60sTpyrsF7jhtEG5oermP8nXDyVp+D0BzrEsG2o1XqAQBXOMiQnwt9o3gB8OTqs00CnJjmrpd Idzf3IaSPkJpS5TkR88Zx46Lo6jXwhmzPkAxWXglT5FX+Eplj4L18C1zaYY64wgegY1BUZA2omr a8CFJhqQX+4Zxxy7qLk5JdPt79yMvlJQsJznXu02jcDuEjzdozFzjOhPfQtvbg7VUceSRiiYryU Np6ZFccAW6PEtcpfUDwZTDTfXkXuGJpPFDCx848ni9wfBcti6mX3fGnDCCHRl8mW99P7jPpTNR5 qpwYmW/NV38/BNwvgxliuxOUGfhbQojWtFjOnR/oJam2oe6MsBvxfH9qSmZPytz9ULwPfRcXCAo 5SzrmoHrejZdmB4Y32AXeFyQhllnFsUWzm6qAEvaWuzY4N0FRIuUI= 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-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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; }; =20 struct sun6i_pchan { @@ -207,7 +208,6 @@ struct sun6i_vchan { struct sun6i_pchan *phy; u8 port; u8 irq_type; - bool cyclic; bool paused; }; =20 @@ -509,7 +509,7 @@ static int sun6i_dma_start_desc(struct sun6i_vchan *vch= an) (DMA_IRQ_HALF | DMA_IRQ_PKG | DMA_IRQ_QUEUE) << (irq_offset * DMA_IRQ_CHAN_WIDTH)); =20 - vchan->irq_type =3D vchan->cyclic ? DMA_IRQ_PKG : DMA_IRQ_QUEUE; + vchan->irq_type =3D pchan->desc->cyclic ? DMA_IRQ_PKG : DMA_IRQ_QUEUE; =20 irq_val =3D sun6i_read_irq_en(sdev, irq_reg); irq_val &=3D ~((DMA_IRQ_HALF | DMA_IRQ_PKG | DMA_IRQ_QUEUE) << @@ -612,7 +612,7 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *d= ev_id) desc =3D 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_d= ma_cyclic( =20 prev->p_lli_next =3D txd->p_lli; /* cyclic list */ =20 - vchan->cyclic =3D true; + txd->cyclic =3D true; =20 return vchan_tx_prep(&vchan->vc, &txd->vd, flags); =20 @@ -1003,13 +1003,12 @@ static int sun6i_dma_terminate_all(struct dma_chan = *chan) struct virt_dma_desc *vd =3D &pchan->desc->vd; =20 /* 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); } =20 - vchan->cyclic =3D false; vchan->paused =3D false; /* Leave terminated cyclic descriptors for the sleepable synchronize. */ list_splice_tail_init(&vchan->vc.desc_allocated, &head); --=20 2.53.0