From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97684606A329 for ; Fri, 6 Nov 2026 18:18:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Y61+Lj7p; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=sntech.de header.i=@sntech.de header.a=rsa-sha256 header.s=gloria202408 header.b=jRTSBGkB DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=OU9ALgx7a2MbIsRDDkSUEvr1QS2yZIA+9f2SmS49vwo=; b=Y61+Lj7p9G2Hx2baHqugO1w57L wD2bZgEQmVaeyuIS2H7TYhNK8ZATry9uZ1Zd4KFwaguzPGMjnbyWp8wC2xTd8m4awUio8u/lR6Dlt ZmbH7QHTr9Ed2xCtZALewNmsxhK0BpDTgRms1m4Kq2kpnMs7r6n/nlYHeEZdvuxPsul015aWcgoUB IbzNqrx/4/+8hBAy4XUVob0tLSCZ189dVcV17qoSAanbCMtSx3qUuQYDZJ4F4bSZ4WiHgXIpQ2KYE LoW970yOyeHB/RNX9Tco3ToSmN6V9aV3qBr9U/E1TMam3TfpCye5OniNNajOjNC1dmsDGQOJhj/bf s/yGpFKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xPOWH-0000000DNfF-39zm; Fri, 06 Nov 2026 18:18:33 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xPOWE-0000000DNcz-3Bqe; Fri, 06 Nov 2026 18:18:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sntech.de; s=gloria202408; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:Cc:To:From:Reply-To:Content-Type:In-Reply-To:References; bh=UQa4GKXrA9X+wr7u/zsOdyF9bjrxFeMq7idC2deAia8=; b=jRTSBGkBNHrkqdFy+yA8aopz4F e1Rnt9GPp24aSyLnAYmdzF56oK0syYCaEO5zC9Tp0E8iAaAKgO2rurmQzx+ffo8CsFetrNhNNZB2b /D4zRarhpxgjcQf0TidPSrN0Wjsbim7c14wwvqCzNX8ZQqQy3uj6OG4+Xs9yobGjLvHX6OzB7xus0 3aa/eAWlJr2cU85x+di3oNWrmAOsf2I61I+nVs5j4GZ/CeFg/ugmxUffg8/UR54gA0h96bTMVKFS2 oYfir7sEh40zfJyLEL67FtuOILzkVYiOVTmV13nbHr4XUkwwwdUcwL5gyvGVbtt3J6i9XccbDuYkj pImTOMSg==; From: Heiko Stuebner To: broonie@kernel.org Cc: Heiko Stuebner , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, quentin.schulz@cherry.de, Lee Jones , Sebastian Reichel Subject: [PATCH 0/2] spi: Implement a atomic transfer as a last resort Date: Fri, 6 Nov 2026 19:18:21 +0100 Message-ID: <20261106181824.1361235-1-heiko@sntech.de> X-Mailer: git-send-email 2.47.3 X-Archived-By: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261106_101830_888219_02758880 X-CRM114-Status: GOOD ( 15.58 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" X-Spam-Status: No, score=-11.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 SPI devices at times are used as PMICs including a power-controller functionality that should turn off a system. This happens in an atomic context very late during the shutdown, where no interrupts are available anymore and conflicts with the asynchronous nature of the SPI subsystem. ====== History ====== For the RK806 spi-connected PMIC this has already caused interesting artifacts. A first change, tried to "fix" the issue by using the SYS_OFF_MODE_POWER_OFF_PREPARE step of poweroff. While this hides the issue, on some devices this now turns the pmic off too early before other important steps are done. To mitigate that issue for "some" devices, a change [0] tried to use different poweroff phases for i2c and spi devices, where Lee rightfully said, that with this no proper solution would be done - and Lee was right, as that issue now is open since 2024. The newest change is a simple revert back the old way [1] because of those issues caused on other devices, but that now breaks the SPI side again and also did not take into account that long history. ====== Now ======= The I2C framework has an atomic transfer callback for exactly this late stage transfers since commit 63b96983a5dd ("i2c: core: introduce callbacks for atomic transfers") and during the discussion it was suggested implementing something like this for SPI too. As this did not seem to have happened yet, I thought I'd try my luck. Similar to I2C this is meant only for that latest stage so I stole the gating from there too. I assume I did not take some SPI specifics into account, but I guess having some code to discuss is a starting point at least :-) [0] https://lore.kernel.org/lkml/20240730180903.81688-1-sebastian.reichel@collabora.com/ [1] https://lore.kernel.org/all/20260908-veyron-shutdown-v1-1-066ecb80f5f2@gmail.com/ Cc: Heiko Stuebner Cc: linux-spi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-rockchip@lists.infradead.org Cc: quentin.schulz@cherry.de Cc: Lee Jones Cc: Sebastian Reichel Heiko Stuebner (2): spi: Add infrastructure for atomic sync transfers spi: rockchip: add an atomic transfer function drivers/spi/spi-rockchip.c | 88 ++++++++++++++++++++++++++++++++++++++ drivers/spi/spi.c | 66 ++++++++++++++++++++++++++-- include/linux/spi/spi.h | 11 +++++ 3 files changed, 161 insertions(+), 4 deletions(-) -- 2.47.3 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip