From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796456014; b=GXByOqcUo9ihMiUhdqN/UEVtisInW3Za6GI7WDDTFNfpoEOzaKKO1w6B0EVy0HzRwpMp RfK0IHRZmfmKBYKNEiIZvQXe/2Q3IbpvrSVRaN/HwAgI3cIxVJgDn67d0gldLNdCuqB/v 8odKzc0W0qWX9xkgnEs1P89P9Wp/pzhs2HxzxRdZPPrhWjtQLaT0bESTEAJQdyeVHg08w ru0RXXyG7zAfSY5hojiQIE8kj+MDMBTBiOp3i9r3ZAzKPCaW8ldF42guVzt+d8q9wmzJx 1Lm095w5GqnmTyvksKb4ErXXMUGkVKjliguSASIAjm3lhvrPzhQCGToidoWld+SL6yw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796456014; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=CMV/+DdlJ/VYR2T/PZRCl83LYFSheQdyxfgazHpbg5E=; b=jJ/B2ZfnJgIUQtFwE2FnuEfKpz0IWsfdydTPV0T1mGKDtwPVCU+MvxMDsERpYiWM7gvO Vvhsetw5uPwB3qhgEwkqyXrmTwD2928RaolVrAzd9DvnewCND0yDuApWcYVv8Lw/l4aBq qeFPTIlbE/oi4q9ISaL5vLdFUePA5x7k75gjc543PagqQQwYsFbb8ClR/AvRdVo4y7HGU EW9XjBwp6xWHFPYcq2yQYzk/7DKfiaf+CFfhPPLtU7wkBiVGAujKzxX44CsvEYZ1BXYCg xU1MXYwZ7tt0NI1GH2ac+PtXC2DfHQlFvOpIYxZZFqfCxKmVAe2skMnV4UBeoSNQjaw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OWtNwsMo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 386B7606A322 for ; Sat, 5 Dec 2026 07:33:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OWtNwsMo Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC0541F00936; Sat, 5 Dec 2026 07:33:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796456013; bh=CMV/+DdlJ/VYR2T/PZRCl83LYFSheQdyxfgazHpbg5E=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=OWtNwsMokvTwOQQN/eDqeGqyySEv/eHomtNrJE0zyg/VUa26cCW5zJEMHE0Wr2+hs 32kwmwzZ58+7KFl31wLcazGJDrbolHoOyu0ZEYWtLoynSz0kXevewP0b7+s2srj+Xu 3IV7Exz2lSChHt0AKmDDLchXOjPNltfmaC/rwkLU0piAPALR/YbwTpEtimzCuGLWis qKLACbuxc5Ej7u3GLy09W/JJ34zg178P7R1eypxbqKAwCjv0cthTN5gqW0oTAe+fXF zVb/eUKWZQ49SowFo9se5x9r03nQioWNvxEl7++X2Vj0ibYSHPIcTpbrU0SXArWpUj dhCFHaXXPRwAg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 5/5] reset: core: translate GPIO specifier via gpio_device_find_by_fwnode_args() Reply-To: sashiko-reviews@lists.linux.dev To: "Pufan Jin" Cc: linux-gpio@vger.kernel.org In-Reply-To: <20261205064355.137581-6-cyan2254650260@gmail.com> References: <20261205064355.137581-1-cyan2254650260@gmail.com> <20261205064355.137581-6-cyan2254650260@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 07:33:33 +0000 X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] reset: __reset_add_reset_gpio_device() breaks multi-bank OF deferral - [Low] reset: reset_gpio_fwnode_xlate() narrows raw args[0] to signed int -- commit d70530f0cba9c1ef9268f09aea4abc3962e72330 Author: Pufan Jin reset: core: translate GPIO specifier via gpio_device_find_by_fwnode_args() This commit replaces manual parsing of reset-gpios arguments in __reset_add_reset_gpio_device() with gpio_device_find_by_fwnode_args(), removing the #gpio-cells =3D=3D 2 and flag checks from the reset core. > diff --git a/drivers/reset/core.c b/drivers/reset/core.c > index 0bff49d9b5586..7281eb8b527d8 100644 > --- a/drivers/reset/core.c > +++ b/drivers/reset/core.c [ ... ] > @@ -1126,27 +1117,10 @@ static int __reset_add_reset_gpio_device(struct f= wnode_handle *fwnode, [ ... ] > struct gpio_device *gdev __free(gpio_device_put) =3D > - gpio_device_find_by_fwnode(args->fwnode); > - if (!gdev) > - return -EPROBE_DEFER; > + gpio_device_find_by_fwnode_args(args, &offset, &lflags); > + if (IS_ERR(gdev)) > + return PTR_ERR(gdev); [Severity: Medium] Can returning PTR_ERR(gdev) here turn a probe deferral into a permanent -EINVAL failure on multi-bank OF GPIO controllers? Controllers that share one device_node across multiple gpio_chip instances, such as spacemit_gpio_probe() in drivers/gpio/gpio-spacemit-k1.c, register each bank sequentially via devm_gpiochip_add_data(). CPU0 (GPIO controller probe) CPU1 (consumer probe) spacemit_gpio_probe() spacemit_gpio_add_bank(..., 0) devm_gpiochip_add_data() __reset_add_reset_gpio_device() gpio_device_find_by_fwnode_args() of_gpio_device_find_by_fwnode_args() of_gpiochip_match_and_xlate() bank 0 of_xlate() -> -EINVAL ctx->err =3D -EINVAL return -EINVAL <-- probe fails spacemit_gpio_add_bank(..., 1) In of_gpio_device_find_by_fwnode_args(), ctx.err starts as -EPROBE_DEFER, but of_gpiochip_match_and_xlate() overwrites ctx->err with ret whenever a registered bank matching the device_node rejects the specifier. When a consumer targeting bank 1 probes before bank 1 finishes registering, it receives -EINVAL instead of -EPROBE_DEFER and fails permanently. By contrast, of_get_named_gpiod_flags() always returns -EPROBE_DEFER when of_find_gpio_device_by_xlate() finds no matching bank. Preserving -EPROBE_DEFER in of_gpio_device_find_by_fwnode_args() when no registered bank matches would avoid this probe-ordering regression. [ ... ] > @@ -1161,7 +1135,6 @@ static int __reset_add_reset_gpio_device(struct fwn= ode_handle *fwnode, > } > } > =20 > - lflags =3D GPIO_PERSISTENT | (flags & GPIO_ACTIVE_LOW); > parent =3D gpio_device_to_device(gdev); > properties[prop++] =3D PROPERTY_ENTRY_STRING("compatible", "reset-gpio"= ); > properties[prop++] =3D PROPERTY_ENTRY_GPIO("reset-gpios", parent->fwnod= e, offset, lflags); [Severity: Low] Can decoupling the translated offset from raw args[0] cause reset_gpio_fwnode_xlate() to return an invalid ERR_PTR()? Previously, __reset_add_reset_gpio_device() required args->nargs =3D=3D 2 a= nd passed raw args->args[0] as the GPIO offset, so reset_gpio_probe() bounded args[0] against gdev->ngpio. Now 3-cell controllers with custom of_xlate() callbacks are accepted and only the translated offset is validated, while reset_gpio_fwnode_xlate() still narrows raw u64 args[0] to a signed int: drivers/reset/reset-gpio.c:reset_gpio_fwnode_xlate() { return reset_spec->nargs ? reset_spec->args[0] : 0; } In sunxi_pinctrl_gpio_of_xlate(), PINS_PER_BANK * gpiospec->args[0] wraps modulo 2^32 for a malformed specifier with bit 31 set (such as args[0] =3D 0x80000000), translating to pin 0 so reset_gpio_probe() succeed= s. reset_gpio_fwnode_xlate() then returns -2147483648, and __fwnode_reset_control_get() converts any rstc_id < 0 directly into ERR_PTR(rstc_id), producing a non-IS_ERR() invalid pointer that causes callers to oops. Since each reset-gpio device has nr_resets =3D 1 and ignores the id in its ops, returning 0 unconditionally from reset_gpio_fwnode_xlate() avoids the truncation. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205064355.1375= 81-1-cyan2254650260@gmail.com?part=3D5