From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5383B2D112E; Mon, 5 May 2025 22:51:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746485472; cv=none; b=RA8//7DEok16/9Pcro6y+zeLgcoudYOYUDVF35fTy9KrHbunlckcyrcMBNSIAzBE1wEygJzoRji9D31Wu0Vtyll+AM/okfowXZyrSMjJR/nXxnBHKU0Nd2FyJEPBYf1ojX9RGWNg9e/E6aVu+GzvJfifZqsnYo/U1+NtaCrQTwo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746485472; c=relaxed/simple; bh=AWuDwQHhVZqwsKiuJexopmeKVA3Ii4AwL48PA1xN6vs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q/Xl4+0QJkP5TgRX972uy3vHIf8IZFsR5AyOH4bnrlOjlMZuUyj1jMkCihxRsz6Df0pEJfQfDPASHQcvMsfBRiItBRVduEsgPjZ86YM4I33aX7T+WYHtKkJUt0MHSwI2HxYDGkAzeRehrvxJweRt+8LowIRC55fv8Cra4eiXg6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YyXgX/6S; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YyXgX/6S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70274C4CEED; Mon, 5 May 2025 22:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746485472; bh=AWuDwQHhVZqwsKiuJexopmeKVA3Ii4AwL48PA1xN6vs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YyXgX/6SsTmgrNGfOhAOSLvrLCsNvR9XOM03lovb9QQTWT9IyBQp6J6RECsv4MA5Y gLjX6cg995y7L9cjPSddkGsayHTbTo9V/S0poBi+pIPLDDhjwtTrxEjJG3GMcHmfG5 V9W+diRErck2zUEFJtHGUyV4lDel5QGlc0Pq6pBybRk1Vh3MEhV4jom25/yWP+2Je0 7WzUlwj7zDVXCA3ChsWXgks6vULmV8YJSNrl5BbrbRI4dJojUUq1bA+UcRPWYeJaSP WE5uu3Y84QMeE2nuvkcEu65tx/tzRTVEWAFb/r5Yu8j84HUvsrc5bH8eNypczENhIp iTb2SXL8R6jnA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Valentin Caron , Linus Walleij , Sasha Levin , linux-gpio@vger.kernel.org Subject: [PATCH AUTOSEL 6.12 331/486] pinctrl: devicetree: do not goto err when probing hogs in pinctrl_dt_to_map Date: Mon, 5 May 2025 18:36:47 -0400 Message-Id: <20250505223922.2682012-331-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250505223922.2682012-1-sashal@kernel.org> References: <20250505223922.2682012-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.12.26 Content-Transfer-Encoding: 8bit From: Valentin Caron [ Upstream commit c98868e816209e568c9d72023ba0bc1e4d96e611 ] Cross case in pinctrl framework make impossible to an hogged pin and another, not hogged, used within the same device-tree node. For example with this simplified device-tree : &pinctrl { pinctrl_pin_1: pinctrl-pin-1 { pins = "dummy-pinctrl-pin"; }; }; &rtc { pinctrl-names = "default" pinctrl-0 = <&pinctrl_pin_1 &rtc_pin_1> rtc_pin_1: rtc-pin-1 { pins = "dummy-rtc-pin"; }; }; "pinctrl_pin_1" configuration is never set. This produces this path in the code: really_probe() pinctrl_bind_pins() | devm_pinctrl_get() | pinctrl_get() | create_pinctrl() | pinctrl_dt_to_map() | // Hog pin create an abort for all pins of the node | ret = dt_to_map_one_config() | | /* Do not defer probing of hogs (circular loop) */ | | if (np_pctldev == p->dev->of_node) | | return -ENODEV; | if (ret) | goto err | call_driver_probe() stm32_rtc_probe() pinctrl_enable() pinctrl_claim_hogs() create_pinctrl() for_each_maps(maps_node, i, map) // Not hog pin is skipped if (pctldev && strcmp(dev_name(pctldev->dev), map->ctrl_dev_name)) continue; At the first call of create_pinctrl() the hogged pin produces an abort to avoid a defer of hogged pins. All other pin configurations are trashed. At the second call, create_pinctrl is now called with pctldev parameter to get hogs, but in this context only hogs are set. And other pins are skipped. To handle this, do not produce an abort in the first call of create_pinctrl(). Classic pin configuration will be set in pinctrl_bind_pins() context. And the hogged pin configuration will be set in pinctrl_claim_hogs() context. Signed-off-by: Valentin Caron Link: https://lore.kernel.org/20250116170009.2075544-1-valentin.caron@foss.st.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/devicetree.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c index 6a94ecd6a8dea..0b7f74beb6a6a 100644 --- a/drivers/pinctrl/devicetree.c +++ b/drivers/pinctrl/devicetree.c @@ -143,10 +143,14 @@ static int dt_to_map_one_config(struct pinctrl *p, pctldev = get_pinctrl_dev_from_of_node(np_pctldev); if (pctldev) break; - /* Do not defer probing of hogs (circular loop) */ + /* + * Do not defer probing of hogs (circular loop) + * + * Return 1 to let the caller catch the case. + */ if (np_pctldev == p->dev->of_node) { of_node_put(np_pctldev); - return -ENODEV; + return 1; } } of_node_put(np_pctldev); @@ -265,6 +269,8 @@ int pinctrl_dt_to_map(struct pinctrl *p, struct pinctrl_dev *pctldev) ret = dt_to_map_one_config(p, pctldev, statename, np_config); of_node_put(np_config); + if (ret == 1) + continue; if (ret < 0) goto err; } -- 2.39.5