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 61D41606A322 for ; Wed, 2 Dec 2026 20:09:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=2yIwgTzw; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XQ2r19Ge DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=FPqKzTGrizueEzjivBIbcOs0FzepCFWpQaEkoAfZm5A=; b=2yIwgTzwSC5yptANANcXRDMeoz LII5GECW4KjMCSabadnAYNL8KY1HXt4Nii2L1nm16PHD01rsdE5ozxxHiTPbnZ+2xnUd0Xt6QSUaW A5otqA3LXGwBaSdScg/zIOblRMGUSfje5BOmJt0F1gplaTQCT8a3w9ig7soeG02WBz0JX2CQl2H5C NmWyaqXAezTuFhby5KTgtz6oZh7HgJMnQ63tXt+AFirNAD6tCkV80yltoewQW40E7ygcwZEOTqMd+ a97ixqVYnl/gl1Bvy5Lhcbvm7tYTY2mxFZNNpaAlLrnZ6aPaF9wQANqwzc6rgW1LPnHKrXPuFeW0K zB5JxiMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYqdJ-0000000Cgqv-3YHD; Wed, 02 Dec 2026 20:08:53 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYqdI-0000000Cgqp-36Qs for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2026 20:08:52 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 3D08740B9B; Wed, 2 Dec 2026 20:08:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 160D61F00893; Wed, 2 Dec 2026 20:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796242131; bh=FPqKzTGrizueEzjivBIbcOs0FzepCFWpQaEkoAfZm5A=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=XQ2r19Ge9erPrNlZyyocplfRBefrMfd+rtBM3WEN+KABmHaI0lrHMpIB0UcYp5kMP tzCXbGOsBkN7dLMmdAv8p0RYrtYqJxaim+M8ZtSfcsnU1ZGSSSIFGT+M+wP3HCfDgZ sqyd5+t9NZfBFpiqtErl5kQuQpop6eGJgTVOU5prJc+0GY41gpr3lXPUFtCh4gCLXh vAbnC044/OABCU9RDO0OBdNYnChp0HnJs+CXSCOHhRHXI9TGlR41hJt746/FqmNOka vZttJGQqhI1CMpE6CMVTTpcj8cAtiMZMhiYKW3aIl83qCQHt83LN+Xzv8N4+n2JomG cBlD7yQzBK22g== Date: Wed, 2 Dec 2026 20:08:44 +0000 From: Lee Jones To: Frank Li Cc: Dong Aisheng , Fabio Estevam , Frank Li , Jacky Bai , Pengutronix Kernel Team , NXP S32 Linux Team , Linus Walleij , Sascha Hauer , Mehmet Fide , Bartosz Golaszewski , Haibo Chen , Takashi Sakamoto , Danilo Krummrich , Bjorn Helgaas , Uwe =?iso-8859-1?Q?Kleine-K=F6nig_=28The_Capable_Hub=29?= , Shawn Guo , linux-gpio@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 06/12] pinctrl: imx: Serialise MMIO register updates with a spinlock Message-ID: <20261202200844.GE98551@kernel.org> References: X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-5.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 > On Wed, Dec 02, 2026 at 09:30:00AM +0000, Lee Jones wrote: > > The pinctrl core does not serialise .set_mux() and .pin_config_set() > > callbacks against one another or against concurrent .set_mux() calls. > > On i.MX platforms that share mux and configuration registers via > > SHARE_MUX_CONF_REG or share general-purpose select-input registers, > > concurrent read-modify-write sequences in imx_pmx_set_one_pin_mmio(), > > imx_pinconf_set_mmio(), and the GPIO direction callbacks can race and > > overwrite each other's updates. > > > > Add a raw_spinlock_t to struct imx_pinctrl and hold it across MMIO > > why choose raw_spinlock_t instead of spinlock_t? Thanks for the interest and the question, Frank. A regular 'spinlock_t' becomes a sleeping rt_mutex under PREEMPT_RT. Whilst standard pinctrl state transitions like pinctrl_select_state() occur in process context, the '.gpio_set_direction' callback is also wired into the pinctrl ops and shares this lock. Moreover, pinctrl state switches can be invoked from low-level PM and idle paths where sleeping is not allowed and 'raw_spinlock_t' is the standard choice across pinctrl drivers for short MMIO register read-modify-write. If someone can confirm that none of the i.MX call paths can ever be reached from atomic or non-sleepable contexts (even under PREEMPT_RT), we could downgrade this to 'spinlock_t', otherwise 'raw_spinlock_t' is the safer option for a few-instruction MMIO critical section. -- Lee Jones