From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BDE2379988 for ; Thu, 11 Jun 2026 08:26:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781166387; cv=none; b=DqIcdsrTaN6dQJQzLYys9Lvv6AARgIsRSQjZT6yFTGI5JRKgpJwdDfXZF1KfoqupU86TQRm5OMAUyS48H1pCwmrbOrJ5U5Dnjrx3DxlzduSn1wA8OmoErSDoI5TFNx+2Yg4YgK8iPutDdOlP1gAU+bqa4pJ4aASXUKqccYTK5iU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781166387; c=relaxed/simple; bh=yrHk8vQXuFVs66bjErYiRp21ChFTNAqXmEMeBmKpI4Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:From:In-Reply-To: Content-Type:References; b=OQE4RMHhd/a39cdQ3Oca6Kr/ZjTKtCJLzlIuLahZmVlCZnD4TlwGxOdUTO7iR2m7YqvaDO0LqakLaP69pZa4stFDRZJxDoAvEFEynFW9TKDsjQYIfXuh1Vtb8yrbJQcpdMqkSQX7kwhnQlQY2qtdS+rtL9d2HDyLJGNayz1Lq/U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=WP5fVf7b; arc=none smtp.client-ip=210.118.77.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="WP5fVf7b" Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20260611082616euoutp02b3238d9b80024567896eebd94d2a0ed1~3_WHQ-yFe2227622276euoutp02Y for ; Thu, 11 Jun 2026 08:26:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20260611082616euoutp02b3238d9b80024567896eebd94d2a0ed1~3_WHQ-yFe2227622276euoutp02Y 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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> Content-Transfer-Encoding: 7bit X-CMS-MailID: 20260611082615eucas1p2e0d075707c644743cc2b745ed838d646 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20260610153425eucas1p29d20a835114a28b15cb12ea00534e074 X-EPHeader: CA X-CMS-RootMailID: 20260610153425eucas1p29d20a835114a28b15cb12ea00534e074 References: <20260610153329.937833-1-v@baodeep.com> 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