From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F253DCD98D4 for ; Thu, 11 Jun 2026 08:26:35 +0000 (UTC) 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:References:In-Reply-To:From:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QIizbLnehMjIucuhkDuxpdlSXhCZmMvAFjgYOe0c5kI=; b=UFCqeLwiRG9YbO A9Zj2h1IaNM8vatmTf6fszCEwKqWbbGTDSkDZzeAc9/pp17XPmRulb39PvpsEn4iGuzZjnU4BDYCz 1lN1si0fB0eJ8BFC9AODv08WGyqa2CeYvK7KLeraeuaqpC05fWB4NS1lHTgGA/ERQuQhGH1ft6CPo eBIL6FyaQbcUXJXencxI0Odq2Ywuh1jl+Tks4mbCcG7BKgykPDiKwmJZY99Kk0BFm7fO+GSrcqiUH 6WqdS9oARvjRD9ydYDzUWLeqMwQ9ZFMcgZXYkwSsjOpn0tiIJW7vcwF1aAKjjtPIu59/6JzlNYZNv /XPP4BVg8cNqOamuWe9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wXak9-000000090TI-2Iqn; Thu, 11 Jun 2026 08:26:29 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wXak4-000000090QQ-08Au for linux-amlogic@lists.infradead.org; Thu, 11 Jun 2026 08:26:27 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20260611082616euoutp01e71d950baf69afcb650d0755f6408b23~3_WHLwvcV2456124561euoutp01j for ; Thu, 11 Jun 2026 08:26:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20260611082616euoutp01e71d950baf69afcb650d0755f6408b23~3_WHLwvcV2456124561euoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1781166376; bh=DhwGhRTjppBgNw8HHFKEmC3YfseR6UOeLF4WLAZNcaw=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=WP5fVf7bqkbo4VdgHWn8qqtBKF+RHRqV6LI00ZwUCFzhaBP9Eq70e7Py9u09YikTW Fm6zSKjRTYXbF6SnqgLbnVCAvgIU09OXFAIR8ifTes5554DpJgawudUQOPqaZxhgZJ BjdWLYKrK2SjvkVRm9a5LiwWmJee0pVSsXSXo/Mo= Received: from eusmtip1.samsung.com (unknown [203.254.199.221]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20260611082615eucas1p2e0d075707c644743cc2b745ed838d646~3_WGwPZ402819828198eucas1p2c; Thu, 11 Jun 2026 08:26:15 +0000 (GMT) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20260611082614eusmtip15addb285747362b715188d44fa381fda~3_WGD3M962800828008eusmtip1H; Thu, 11 Jun 2026 08:26:14 +0000 (GMT) Message-ID: <184d315b-a0a1-4792-8a40-1b4967025916@samsung.com> Date: Thu, 11 Jun 2026 10:26:14 +0200 MIME-Version: 1.0 User-Agent: Betterbird (Windows) Subject: Re: [PATCH 0/2] gpio: fix sleeping-in-atomic in shared-proxy; restore meson non-sleeping To: Viacheslav Bocharov , Linus Walleij , Bartosz Golaszewski Cc: Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Robin Murphy , Diederik de Haas , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Heiko Stuebner Content-Language: en-US From: Marek Szyprowski In-Reply-To: <20260610153329.937833-1-v@baodeep.com> X-CMS-MailID: 20260611082615eucas1p2e0d075707c644743cc2b745ed838d646 X-Msg-Generator: CA X-RootMTR: 20260610153425eucas1p29d20a835114a28b15cb12ea00534e074 X-EPHeader: CA X-CMS-RootMailID: 20260610153425eucas1p29d20a835114a28b15cb12ea00534e074 References: <20260610153329.937833-1-v@baodeep.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260611_012625_471632_08D273FB X-CRM114-Status: GOOD ( 16.43 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Hi Viachesla, On 10.06.2026 17:32, Viacheslav Bocharov wrote: > gpio-shared-proxy chooses its descriptor lock (mutex vs spinlock) from > the underlying chip's can_sleep, but under that lock it calls config and > direction ops that reach sleeping pinctrl paths. On a controller with > non-sleeping MMIO value ops the lock is a spinlock, so a sleeping call > runs from atomic context: > > BUG: sleeping function called from invalid context > ... pinctrl_gpio_set_config <- gpiochip_generic_config > <- gpio_shared_proxy_set_config (voting spinlock held) > <- ... <- mmc_pwrseq_simple_probe > > This was reported on Khadas VIM3 and worked around for Amlogic by > commit 28f240683871 ("pinctrl: meson: mark the GPIO controller as > sleeping"), which marked the whole meson controller sleeping. That > workaround broke atomic value-path consumers: w1-gpio (1-Wire bitbang) > no longer detects devices, because its IRQ-disabled read slot calls the > non-cansleep gpiod_*_value() and now hits WARN_ON(can_sleep) per bit. > > Patch 1 fixes the proxy locking generically (always a sleeping mutex). > Patch 2 then restores meson can_sleep=false, fixing 1-Wire. > > Patch 1 has a trade-off: a proxied GPIO becomes sleeping, so consumers > gating on gpiod_cansleep() change behaviour. No current device needs > atomic (non-cansleep) value access on a shared GPIO -- every report > (Khadas VIM3, ODROID-M1, my test on JetHub D1+) is a shared reset line > (eMMC/SDIO pwrseq or PCIe reset) driven through the cansleep accessors, > which is what the proxy exists to vote on. An alternative that keeps > atomic value access (split locking) is possible but adds a second lock > and new race windows. I went with the simpler, verified approach and > would appreciate guidance on whether the atomic value path must be > preserved. > > The two are a unit: patch 2 must not be applied without patch 1, > otherwise the original VIM3 splat returns on boards that share a meson > GPIO -- please keep the order. I have not Cc'd stable; I will request > stable backports separately once both patches have landed. > > Viacheslav Bocharov (2): > gpio: shared-proxy: always serialize with a sleeping mutex > pinctrl: meson: restore non-sleeping GPIO access Tested-by: Marek Szyprowski This probably also affects the similar changes in Rockchip GPIO driver done by the following commits: 20cf2aed89ac ("gpio: rockchip: mark the GPIO controller as sleeping") 7ca497be0016 ("gpio: rockchip: Stop calling pinctrl for set_direction") I've checked this patchset with these two reverted and no warning was reported. Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic