From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.227.203 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796230409; b=vVy0GSB7JcgFBt4KZ9W2mJPMlBT3nkMxqUb35l1fQ12psYKXEYj5THR85xx6PjkpEp7M c/s+8AqSuJRAyDa8BrrGimuUGdunD/Q4uPbYsaCYeLcj72hpV2OyB5R1YtPC0QOZ46L9S XN9ttNBGAawGI4nh2HX1xO9enzix7jnuX2KIdfLYeWpwew2bb8h4JKsNOaaszWtKDh2x+ DCvZNdhItBgGdHAPiYWs8GebiD/XJxGhQEhXW3Dzo8kjhvCZ7Y1kdM0PCgW0QJfKfN2lb TDH5PUrozvrtQCiDGvWY0BqorL8EGKbJXgSkkKmS11haU5ry2yaKclt3vtha9jDgD8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796230409; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=M2K1t7Y94hGGs27RGbVn0gEbyKzdFO959I5bbw1unRc=; b=ahx8nBT00WEoS6F5D5ZksTFQ3X8WWrIrKMNz68eBbBV+HfPnGhsS7erTfjpnwPCL3aYn Gmss/A7Hv5xtmVcUHV9WCN7MqVYvkHOfuVqUq4VsWcqnEStvbgwelgaT8NlKifGqMOUoJ 1Izev4DWsXbZNxUDOq0qJY1bM4RFrTJpjMUF1pXoo63vdgOl52jXNlxE3e2SCDTGgmZcO 4IU0D7tQeRPY2SYbFE2HU7jwCpxc7GD1k/nW9T3tLYrDYNYCwtwOYp9e2XoNwuEcd/o9A q7MrXWDaOe8/yryDkAqNZrTeQNek7vOBRrTu8iYmplhuxOWC0wt7p8TjNptzIHnRVbw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=pUcoZXpZ; arc=none smtp.remote-ip=74.125.227.203 Received: from mail-pi2-f11.google.com (mail-pi2-f11.google.com [74.125.227.203]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 572BB606A323 for ; Wed, 2 Dec 2026 16:53:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 572BB606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=pUcoZXpZ Received: by mail-pi2-f11.google.com with SMTP id 41be03b00d2f7-cde795fea95so3699630a12.1 for ; Wed, 02 Dec 2026 08:53:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796230408; x=1796835208; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=M2K1t7Y94hGGs27RGbVn0gEbyKzdFO959I5bbw1unRc=; b=pUcoZXpZX5rBeVcPSFFhvaH40ICsqQPQWVT5ImhFk1HFjXn357GywTZoqnUjjmEpKE qm/QlEelL+29olG3Ljc/ZfGp/COzayQTxBWR2s6vnNzWQsROrtmNbx9vNcc8JKu4k1RH 87SXql0mAWluGo6mchsRxtAnR2g3ZbaOhbfXeg48rqowoQDZJ6Y5nuqKl1X1f6Vu8tep GgDnOz1K1QbQxCKw5VAMpS5dRhqG9oh5G5xF/0cFnOYqVzYa8YULqdwRbHrT70cwzbkn neEZOZbUcpSgI+VmiLv0pGZrmhkQity8sYM/IZ+N5I1C8k8mKY4ziuVI3HTNgph8Ea1a kK8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796230408; x=1796835208; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=M2K1t7Y94hGGs27RGbVn0gEbyKzdFO959I5bbw1unRc=; b=DGbG7x6Oi1Q61zDNTnxLEP6IkVr+7eocXB+nrol3n7FzFRroAkwdy57c8egTg2dqq0 +JKoKNBwFSe5OkBqumWgn+lAQce1Yb29j1fbpZLzUGzto6FD661ikfybQQ9ky1EAyoyR 9dWtS7sy1l7eU642+zNDX6J36KhH1vps72ZIty0LJrPTQ6qwRSNuPaqxk85x9m1U7VWo 5QlTvcNURg2DY3PkbajopymnCc2qHQk6wHYLkmf/mhXRmmoLMxW+UHSCXwMqF7FfHjv7 fprLiB6VBZQE7yPKvF+UK921tgX+LjqCaWADcPCeJQEq49BCYc8LPkKcDDdsNnNbbU0Z mWOg== X-Forwarded-Encrypted: i=1; AL+hErHlZnohr4SM4ku5pQVS6cc/4E7d/PCk8Z8wUAKaCkVojdZrxHyIia/0gpKAZGSxAOXCzUPAYR0=@vger.kernel.org X-Gm-Message-State: APuU4Z+ynchPV40aw5APJYimH/7hNve4DnVUh5UVZjDBfZ611GgKafNH hbjm++ioriIwazfF8+Vs+9f7yO1Dgqa2NgXrc56onS02igcF/6A2DRJL X-Gm-Gg: AZFdTZef5KKcNiJgq0W9pzA6yVNIQISLyHJEMgy3IDTs22l8hpxZfpM8VUl2pegiU1v kmNM/r91XJAOZJ5C7++KpkSKG4YFXL88aRu2S0zPTztwfiuOPgen4Ut2fZGm3zxfwttuqsLXb3a ppqhgrgO440kCdWrfA26RwZWbuiiIplZSxqXxobHY5PisdrLVCWpFB9v+N4uo0QeQx0xz6wglgL T8fa1Dc0NLvNDwTyEOh7ywJ5c3rlMCJ9PqOUYUZvhvYNeSXiJJmXF41poYG8NpAXMGuL1TXthhV OAoI0ZEAZAnuEA07qF6e+iYISM4S91WUxhjB0s6Hc+cUJjVk5FPZSQ3wdL7cT9UOOUfPdKA79x6 DEQcPm+2aZLk7WS2OUAji8t2ecA6UhCfI71KqLlWk3bVwnsGXe1tqDHbJSuStf4D73J7KlijZ9V zww4Xb9+yTSPEHpR+P006shd7iiAGDFau7JhJ9DoUf9OKXV6QXKyp7ojzl1WJ2XnA4qJqItQvIV 2MSxF5dOrr7+3Ba+QEF7Rup2P97bn/4bsfnhi9TwE81Fxbz1nuYROalR97jx2AxpVm7KI6x9E9v FJ9MaKY7g9yrwoYp+xAYK9I3qKgzkiH3tyg= X-Received: by 2002:a05:6a21:6812:b0:3e2:8c31:21cf with SMTP id adf61e73a8af0-4014de5bd25mr40309320637.76.1796230408312; Wed, 02 Dec 2026 08:53:28 -0800 (PST) Received: from [198.18.0.1] ([64.118.149.232]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cdea2aed207sm16005436a12.11.2026.12.02.08.53.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2026 08:53:27 -0800 (PST) Message-ID: Date: Thu, 3 Dec 2026 00:53:22 +0800 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] reset: core: translate GPIO specifier via of_xlate for reset GPIO devices To: Bartosz Golaszewski Cc: Philipp Zabel , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Linus Walleij References: <20261128165814.740455-1-cyan2254650260@gmail.com> <63bac83829bb0662340d044a19e4d79cb457a9f6.camel@pengutronix.de> Content-Language: en-US From: Pufan Jin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/3/26 12:28 AM, Bartosz Golaszewski wrote: > On Wed, Dec 02, 2026 at 04:08:37PM +0800, Pufan Jin wrote: >> Hi Philipp, Bartosz, >> >> Thanks for the review and feedback. >> >> Agreed -- calling the deprecated gpio_device_get_chip() and invoking >> chip->of_xlate() directly in drivers/reset/core.c is not the >> right approach. >> > Sigh... why do I feel like this is an LLM-generated response... > >> Before I prepare a v2 series, I would like to check what GPIOLIB >> interface design you would prefer for this use case. >> >> Looking at what __reset_add_reset_gpio_device() needs from a parsed >> struct fwnode_reference_args *args: >> 1. The target struct gpio_device * (to set the reset-gpio auxiliary >>    device's parent via gpio_device_to_device() and obtain parent->fwnode >>    for PROPERTY_ENTRY_GPIO()). >> 2. The chip-relative hardware GPIO offset (unsigned int *offset). >> 3. The translated Linux lookup flags (unsigned long *lflags, using >>    enum gpio_lookup_flags for PROPERTY_ENTRY_GPIO()). >> >> Would an interface along these lines in gpiolib make sense? >> >>   struct gpio_device * >>   gpio_device_find_by_fwnode_args(const struct fwnode_reference_args *args, >>                                   unsigned int *offset, >>                                   unsigned long *lflags); >> >> Inside gpiolib (with kernel-doc in drivers/gpio/gpiolib.c and prototype >> in include/linux/gpio/driver.h): >> - For OF nodes (is_of_node(args->fwnode)): >>   Convert args to struct of_phandle_args, look up the matching >>   gpio_device via of_find_gpio_device_by_xlate() (which handles >>   custom of_xlate() and arbitrary #gpio-cells cleanly), invoke >>   gc->of_xlate() safely under guard(srcu)(&gdev->srcu) and >>   srcu_dereference(gdev->chip, &gdev->srcu), and convert the resulting >>   of_gpio_flags to Linux lookup flags via of_convert_gpio_flags(). >>   This eliminates both the #gpio-cells == 2 restriction (TODO) and the >>   manual flag matching (FIXME) in drivers/reset/core.c. >> - For software nodes (is_software_node(args->fwnode)): >>   Look up via gpio_device_find_by_fwnode(args->fwnode) and extract >>   args->args[0] / args->args[1] (with nargs == 2 validation). >> - Return ERR_PTR(-EPROBE_DEFER) if no matching gpio_device is >>   registered yet, or the corresponding negative errno on invalid args. >> >> Two related details I noticed while checking the surrounding code: >> 1. In drivers/reset/reset-gpio.c, reset_gpio_probe() hardcodes >>    priv->rc.fwnode_reset_n_cells = 2, which would trigger >>    WARN_ON(args.nargs != rcdev->fwnode_reset_n_cells) in >>    __fwnode_reset_control_get() once #gpio-cells != 2 is supported. >>    Since drivers/reset/core.c already passes &rgpio_dev->ref_args via >>    adev->dev.platform_data, reset_gpio_probe() can read nargs from >>    platform_data. >> 2. In drivers/gpio/gpiolib-shared.c, gpio_shared_dev_is_reset_gpio() >>    compares ref_args.args[0] from the DT consumer (pre-xlate) >>    against aux_args.args[0] from the reset-gpio swnode (post-xlate if >>    translated here), and assumes 2 args. If a shared reset-gpios uses a >>    custom of_xlate() like tegra186-gpio, that comparison would mismatch >>    (though that can be tracked/handled separately if appropriate). >> >> Bartosz, Philipp: does this API shape (name, signature, and header >> placement) look reasonable to you, or would you prefer a different >> naming or design? > If you're using an LLM, you may as well have it generate the code an > post it, it will make the discussion easier if we're working with an > actual implementation. > > Bart Hi Bartosz, Sorry, English isn't my first language, so I used an AI tool to translate and polish my wording to avoid misunderstandings, though the TX2 debugging and ideas were my own. Makes sense to discuss actual code instead. I'll put together the gpiolib helper and reset changes, test them on my Jetson TX2 board, and post an RFC v2 here. Regards, Pufan Jin