From nobody Sat Apr 4 06:09:50 2026 Received: from s106b.cyber-folks.pl (s106b.cyber-folks.pl [195.78.66.88]) (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 C334B28469F; Fri, 20 Mar 2026 17:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.78.66.88 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774029204; cv=none; b=BdkFUmy1/62cn5MgI8E+FOLIuBlLWLyMkRCLRGti/wDXd5zP19QkA6y6hdH84oWQ2nGKqDhlC6wgQJ9m/yTUAZqVwsDQNc97kdUUOmOqUBQ1iBxoJrSWgYvi825IEWrbjOdMdyzCOwVfj5BxwGnjT3pgdauKM3PmwuzTTcAKQFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774029204; c=relaxed/simple; bh=rZ8GolW8aT1v8bfrIeIl9S12jlFKdW++KGKQxWnb5Xc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UrWgnyh/do23g27Rvy8wCP58p4+ipjUzyRTUon4xM6L63BYS+pQgOxQV3rO0eUQyfk+ykn8eFZggMXWnDJ+mxdomYU2mL5S3YEcckEZ1cm4eYK4cBsa6m+8KGuDt/H6BQamWnGDdcsp4UqRjz+nOJkjGBcesku1vPz0k4EV2dxg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mmpsystems.pl; spf=pass smtp.mailfrom=mmpsystems.pl; dkim=pass (2048-bit key) header.d=mmpsystems.pl header.i=@mmpsystems.pl header.b=T2ahv+do; arc=none smtp.client-ip=195.78.66.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mmpsystems.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mmpsystems.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mmpsystems.pl header.i=@mmpsystems.pl header.b="T2ahv+do" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mmpsystems.pl; s=x; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=+5pKY2eSspVqqY3nsOZ1gQ+ssdoRyfh9wUR9eYtNMao=; b=T2ahv+dodZUILVWl1mJkUKcm1c UXhL3IZqk0LmYTbQIaEI2eiUFyh2/laid1Qm+Vn+QxBjZ7Q1tDNIMEnFuaplwvoJX/BhaLiyvPe0I NxkP+rtsVABKTtIO11+4x+LMJBxWAwI7NDztdI98ckYavoAtVk4x0QpgjEapvk/pz5a9CUt+v5cRf U3x1AaYrN9ReZfU66Dyau5WKyQQOounL2WoEgikNZGyWvwc1DIileJiGcGse3IGW6dzru0Waqj/YH MN/qbj64eNsleqZzbTYhAsPZiwmrdCz78s2ovMqxG4qJgQWTYS7/om6DBUDOR8Pl5Xg4VgbNatWS1 g/woX1eQ==; Received: from user-5-173-16-20.play-internet.pl ([5.173.16.20] helo=localhost) by s106.cyber-folks.pl with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w3e2B-00000005OnI-1SW7; Fri, 20 Mar 2026 18:53:19 +0100 From: Michal Piekos Date: Fri, 20 Mar 2026 18:52:31 +0100 Subject: [PATCH v6 2/2] pinctrl: sunxi: fix gpiochip_lock_as_irq() failure when pinmux is unknown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260320-rc2-boot-hang-v6-2-74dca70dd60e@mmpsystems.pl> References: <20260320-rc2-boot-hang-v6-0-74dca70dd60e@mmpsystems.pl> In-Reply-To: <20260320-rc2-boot-hang-v6-0-74dca70dd60e@mmpsystems.pl> To: Linus Walleij , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Andre Przywara , Michal Piekos X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774029161; l=2683; i=michal.piekos@mmpsystems.pl; s=20260301; h=from:subject:message-id; bh=rZ8GolW8aT1v8bfrIeIl9S12jlFKdW++KGKQxWnb5Xc=; b=JM0Yz0qx+b3ioJx5PketJuePCKqOuSTNIiAD7JoTPWldPKr9KzlNDN2kUXm7Iz89xnHKSBI64 y57MhvTpr2jCB4nvNougc8nI8yNcUgqX2nWYtzvQ2AmyRVJ9cuJh96B X-Developer-Key: i=michal.piekos@mmpsystems.pl; a=ed25519; pk=Aixyx03If7ZDamiKKN0lsa+0mtA+WjIuIf2ZQVYNBqg= X-Authenticated-Id: michal.piekos@mmpsystems.pl Fixes kernel hang during boot due to inability to set up IRQ on AXP313a. The issue is caused by gpiochip_lock_as_irq() which is failing when gpio is in uninitialized state. Solution is to set pinmux to GPIO INPUT in sunxi_pinctrl_irq_request_resources() if it wasn't initialized earlier. Tested on Orange Pi Zero 3. Fixes: 01e10d0272b9 ("pinctrl: sunxi: Implement gpiochip::get_direction()") Reviewed-by: Andre Przywara Reviewed-by: Chen-Yu Tsai Signed-off-by: Michal Piekos --- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 20 ++++++++++++++++++-- drivers/pinctrl/sunxi/pinctrl-sunxi.h | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/= pinctrl-sunxi.c index 685b79fc0bf8..d3042e0c9712 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -1092,6 +1092,9 @@ static int sunxi_pinctrl_irq_request_resources(struct= irq_data *d) { struct sunxi_pinctrl *pctl =3D irq_data_get_irq_chip_data(d); struct sunxi_desc_function *func; + unsigned int offset; + u32 reg, shift, mask; + u8 disabled_mux, muxval; int ret; =20 func =3D sunxi_pinctrl_desc_find_function_by_pin(pctl, @@ -1099,8 +1102,21 @@ static int sunxi_pinctrl_irq_request_resources(struc= t irq_data *d) if (!func) return -EINVAL; =20 - ret =3D gpiochip_lock_as_irq(pctl->chip, - pctl->irq_array[d->hwirq] - pctl->desc->pin_base); + offset =3D pctl->irq_array[d->hwirq] - pctl->desc->pin_base; + sunxi_mux_reg(pctl, offset, ®, &shift, &mask); + muxval =3D (readl(pctl->membase + reg) & mask) >> shift; + + /* Change muxing to GPIO INPUT mode if at reset value */ + if (pctl->flags & SUNXI_PINCTRL_NEW_REG_LAYOUT) + disabled_mux =3D SUN4I_FUNC_DISABLED_NEW; + else + disabled_mux =3D SUN4I_FUNC_DISABLED_OLD; + + if (muxval =3D=3D disabled_mux) + sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq], + SUN4I_FUNC_INPUT); + + ret =3D gpiochip_lock_as_irq(pctl->chip, offset); if (ret) { dev_err(pctl->dev, "unable to lock HW IRQ %lu for IRQ\n", irqd_to_hwirq(d)); diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/= pinctrl-sunxi.h index 22bffac1c3f0..0daf7600e2fb 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h @@ -86,6 +86,8 @@ =20 #define SUN4I_FUNC_INPUT 0 #define SUN4I_FUNC_IRQ 6 +#define SUN4I_FUNC_DISABLED_OLD 7 +#define SUN4I_FUNC_DISABLED_NEW 15 =20 #define SUNXI_PINCTRL_VARIANT_MASK GENMASK(7, 0) #define SUNXI_PINCTRL_NEW_REG_LAYOUT BIT(8) --=20 2.43.0