Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp522154rdb; Thu, 5 Oct 2023 12:47:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzO3HvKYv0Awiz0W31EtIo27J/kyWucHn3WPyLW5Zxtc4FGOYaQ2zqdIeARQpkaHV7FAQk X-Received: by 2002:a05:6808:210c:b0:3ac:aae1:6d64 with SMTP id r12-20020a056808210c00b003acaae16d64mr7394744oiw.2.1696535258172; Thu, 05 Oct 2023 12:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696535258; cv=none; d=google.com; s=arc-20160816; b=N3gsc1ThVymEeheD/hRC6jsnpo8U1v92ty0PqbEJu/HDXZPz/fBBOoQl44xZFFHKfY lI/umDeH2x0SF+koy7XlTVZI7ZX8Vr5hv1QVYFn4BXj5yUvRX1I1WnaKkZA7SOceh2EK hfAF4XdVCsFi1UNUM8j/4Noi0dyxR2TXaRtuQJzrByhum3Sh1mW4zHHJnOvdIsOxN3Kc XW6e/bHgJy1j9sV5fqYSxzGFfyBuhe+3F06X1RBk3AEuTKQADVhFEL/AwfMRNvt/6KSW IRX5GbQ1G05CHtebLD+GFbyb3ARlHT7seP2K7IMkQ+4e7O5y4SrrIikQ37p9TSXEXuya kF4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=fLJjywY8LzZjMJ4Ua1HVIFQQKdDKE5FDxSdi//HT1kY=; fh=C2pAXAY1VXCVk3tkuA/GEi48o7WSsVXf2eMhjwC2+wQ=; b=ST5FOfgNJDQoRg865Tsnt1Xhx+SPEEEf1y1BNq0uF4ZD+E1GLWkzhwjkCIdimBJuQX mKfjKPef4LZ4+rCVl7ctkK1N6ddg5Dbh6RR76yMv6EWAI/O9j+CdJuc92HsKKwPddAQp uKYmY8fr8l6xjB4WVxcYcd7lX4HQYIcFVsGoQ8f2TiCdfVuai4hi7VCgiInSNa6DGmUk Qi0B6al1FE8HFiD4TfKQn0DURjfIIpT9isZUm+fd2sgiFj8AcyLcuQPMt7vS7L8qB7Ob QeM8Y1keRw7YYn0YUkEqbSa8brE9XxU15wMIs+o2QZl/nnrfyo/2wc4XTgREmHLgY/EF 1emg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=ksipxG7G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id by31-20020a056a02059f00b005859af516b9si2342362pgb.647.2023.10.05.12.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 12:47:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=ksipxG7G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D53F0875EA2F; Thu, 5 Oct 2023 12:47:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231636AbjJETrV (ORCPT + 99 others); Thu, 5 Oct 2023 15:47:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231494AbjJETrU (ORCPT ); Thu, 5 Oct 2023 15:47:20 -0400 Received: from mail-ua1-x92b.google.com (mail-ua1-x92b.google.com [IPv6:2607:f8b0:4864:20::92b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF684E4 for ; Thu, 5 Oct 2023 12:47:17 -0700 (PDT) Received: by mail-ua1-x92b.google.com with SMTP id a1e0cc1a2514c-7afc13d58c6so578161241.1 for ; Thu, 05 Oct 2023 12:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696535237; x=1697140037; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fLJjywY8LzZjMJ4Ua1HVIFQQKdDKE5FDxSdi//HT1kY=; b=ksipxG7GnTOnJHPTocs8DMa8TTDqe/zqjzlUHoZDTh7o/xP6ti8SfoVP/KqS449Oi+ eesDdbM6FsviLCj5O99A5fsw1Y7vXgjWerHoRpBgSSe/5cMkINWDoNfwxTTrX1YFuYs3 DBqfPfBbcJrSxvEo94EgRtHOQoY83qsbr5F206p1T2R5QfspgYWvQG0Oci8y+DxZNzej aJmN4hvekDQ33cONcYGoK/g2wJrjlGfjHgz2uFxMYhQZG7DLEyyIp6ZuCCewW1I1G2rh 7ZXl39+SlYPgLqq5k0C27L73YNerFgs/cs+GTuX+r7VAXLHQOvHjz/jtIp6ZInH321Mb kIRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696535237; x=1697140037; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fLJjywY8LzZjMJ4Ua1HVIFQQKdDKE5FDxSdi//HT1kY=; b=hCRqt17B5Dh03LbQ9bd9c9kU5F/u44Xt7A+PB1KsgBJrmLB+NJDtxhriElPiBlVv5z Py/mlXb8oWnkipnzbi14tczSW0Vkjd1TmwMoWXPpVcCEJVtfp7GsY0CIL4wqGLOf8h8z pfIjYjUi96tYZImzVxwTJVtDbCGSh2/j+C5gwvCT7sJg7mxT2DDbue4sAejPlFqmyVno m1SI21pUunBth0wpst1QHuJ4uMmmEtgCRr8N7Gw+LgvXetjo4RAotscoC39VdONY8Z2b OBFKzuFHgF+h2bIVi7PF4EhQrasCI0iHivlfRRlVrQNUudo/blQ+sTzwNVI2auc6UHfI IDmg== X-Gm-Message-State: AOJu0Yx02MRtPT+23iXnepnS0s+ReRy1WSRbO+I3xMfObofPZ7XTNmi4 04fsEqswJAk7LzM5XofSAhu0nlH2EBnH2kiu7Xpeng== X-Received: by 2002:a67:f65a:0:b0:44d:3f96:6c61 with SMTP id u26-20020a67f65a000000b0044d3f966c61mr6494546vso.30.1696535235393; Thu, 05 Oct 2023 12:47:15 -0700 (PDT) MIME-Version: 1.0 References: <20230905185309.131295-1-brgl@bgdev.pl> <20230905185309.131295-15-brgl@bgdev.pl> <36b17290-c643-8d8e-e82b-49afa6b34fbb@nvidia.com> <3624e973-d09a-d211-c6d0-d0ffb8c20c4b@nvidia.com> <90b5f887-8af4-a80d-ea4d-cf2199752de4@nvidia.com> <0e7cae42-0b81-c038-8beb-49102feea8a6@nvidia.com> <647d3b52-1daf-175d-d5c2-45653dd2604c@nvidia.com> In-Reply-To: From: Bartosz Golaszewski Date: Thu, 5 Oct 2023 21:47:04 +0200 Message-ID: Subject: Re: [RFT PATCH 14/21] hte: tegra194: don't access struct gpio_chip To: Dipen Patel , Andy Shevchenko , Linus Walleij Cc: Aaro Koskinen , Janusz Krzysztofik , Tony Lindgren , Russell King , Mika Westerberg , Thierry Reding , Jonathan Hunter , Hans de Goede , Mark Gross , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, timestamp@lists.linux.dev, linux-tegra@vger.kernel.org, platform-driver-x86@vger.kernel.org, Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 12:47:35 -0700 (PDT) On Thu, Oct 5, 2023 at 9:43=E2=80=AFPM Dipen Patel wrot= e: > > On 10/5/23 12:05 PM, Bartosz Golaszewski wrote: > > On Thu, Oct 5, 2023 at 8:12=E2=80=AFPM Dipen Patel = wrote: > >> > >> On 10/5/23 6:48 AM, Bartosz Golaszewski wrote: > >>> On Thu, Oct 5, 2023 at 1:52=E2=80=AFAM Dipen Patel wrote: > >>>> > >>>> On 10/4/23 3:54 PM, Dipen Patel wrote: > >>>>> On 10/4/23 1:33 PM, Dipen Patel wrote: > >>>>>> On 10/4/23 1:30 PM, Dipen Patel wrote: > >>>>>>> On 10/4/23 5:00 AM, Bartosz Golaszewski wrote: > >>>>>>>> On Thu, Sep 7, 2023 at 9:28=E2=80=AFAM Linus Walleij wrote: > >>>>>>>>> > >>>>>>>>> On Tue, Sep 5, 2023 at 8:53=E2=80=AFPM Bartosz Golaszewski wrote: > >>>>>>>>> > >>>>>>>>>> From: Bartosz Golaszewski > >>>>>>>>>> > >>>>>>>>>> Using struct gpio_chip is not safe as it will disappear if the > >>>>>>>>>> underlying driver is unbound for any reason. Switch to using r= eference > >>>>>>>>>> counted struct gpio_device and its dedicated accessors. > >>>>>>>>>> > >>>>>>>>>> Signed-off-by: Bartosz Golaszewski > >>>>>>>>> > >>>>>>>>> As Andy points out add , with that fixed: > >>>>>>>>> Reviewed-by: Linus Walleij > >>>>>>>>> > >>>>>>>>> I think this can be merged into the gpio tree after leaving som= e > >>>>>>>>> slack for the HTE maintainer to look at it, things look so much > >>>>>>>>> better after this. > >>>>>>>>> > >>>>>>>>> Yours, > >>>>>>>>> Linus Walleij > >>>>>>>> > >>>>>>>> Dipen, > >>>>>>>> > >>>>>>>> if you could give this patch a test and possibly ack it for me t= o take > >>>>>>>> it through the GPIO tree (or go the immutable tag from HTE route= ) then > >>>>>>>> it would be great. This is the last user of gpiochip_find() tree= wide, > >>>>>>>> so with it we could remove it entirely for v6.7. > >>>>>>> > >>>>>>> Progress so far for the RFT... > >>>>>>> > >>>>>>> I tried applying the patch series on 6.6-rc1 and it did not apply= cleanly, > >>>>>>> some patches I needed to manually apply and correct. With all thi= s, it failed > >>>>>>> compilation at some spi/spi-bcm2835 driver. I disabled that and w= as able to > >>>>>>> compile. I thought I should let you know this part. > >>>>>>> > >>>>>>> Now, I tried to test the hte and it seems to fail finding the gpi= o device, > >>>>>>> roughly around this place [1]. I thought it would be your patch s= eries so > >>>>>>> tried to just use 6.6rc1 without your patches and it still failed= at the > >>>>>>> same place. I have to trace back now from which kernel version it= broke. > >>>>>> > >>>>>> [1]. > >>>>>> https://git.kernel.org/pub/scm/linux/kernel/git/pateldipen1984/lin= ux.git/tree/drivers/hte/hte-tegra194.c?h=3Dfor-next#n781 > >>>>>> > >>>>>> of course with your patches it would fail for the gdev instead of = the chip. > >>>>> > >>>>> Small update: > >>>>> > >>>>> I put some debugging prints in the gpio match function in the hte-t= egra194.c as > >>>>> below: > >>>>> > >>>>> static int tegra_gpiochip_match(struct gpio_chip *chip, void *data) > >>>>> { > >>>>> + struct device_node *node =3D data; > >>>>> + struct fwnode_handle *fw =3D of_node_to_fwnode(data); > >>>>> + if (!fw || !chip->fwnode) > >>>>> + pr_err("dipen patel: fw is null\n"); > >>>>> > >>>>> - pr_err("%s:%d\n", __func__, __LINE__); > >>>>> + pr_err("dipen patel, %s:%d: %s, %s, %s, match?:%d, fwnode n= ame:%s\n", > >>>>> __func__, __LINE__, chip->label, node->name, node->full_name, (chip= ->fwnode =3D=3D > >>>>> fw), fw->dev->init_name); > >>>>> return chip->fwnode =3D=3D of_node_to_fwnode(data); > >>>>> } > >>>>> > >>>>> The output of the printfs looks like below: > >>>>> [ 3.955194] dipen patel: fw is null -----> this message started = appearing > >>>>> when I added !chip->fwnode test in the if condition line. > >>>>> > >>>>> [ 3.958864] dipen patel, tegra_gpiochip_match:689: tegra234-gpio= , gpio, > >>>>> gpio@c2f0000, match?:0, fwnode name:(null) > >>>>> > >>>>> I conclude that chip->fwnode is empty. Any idea in which conditions= that node > >>>>> would be empty? > >>>> > >>>> sorry for spamming, one last message before I sign off for the day..= .. > >>>> > >>>> Seems, adding below in the tegra gpio driver resolved the issue I am= facing, I > >>>> was able to verify your patch series. > >>>> > >>>> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra1= 86.c > >>>> index d87dd06db40d..a56c159d7136 100644 > >>>> --- a/drivers/gpio/gpio-tegra186.c > >>>> +++ b/drivers/gpio/gpio-tegra186.c > >>>> @@ -989,6 +989,8 @@ static int tegra186_gpio_probe(struct platform_d= evice *pdev) > >>>> offset +=3D port->pins; > >>>> } > >>>> > >>>> + gpio->gpio.fwnode =3D of_node_to_fwnode(pdev->dev.of_node); > >>>> + > >>>> return devm_gpiochip_add_data(&pdev->dev, &gpio->gpio, gpio)= ; > >>>> } > >>>> > >>>> Now, few follow up questions: > >>>> 1) is this the correct way of setting the chip fwnode in the gpio dr= iver? > >>> > >>> You shouldn't need this. This driver already does: > >>> > >>> gpio->gpio.parent =3D &pdev->dev; > >>> > >>> so fwnode should be assigned in gpiochip_add_data_with_key(). Can you > >>> check why this doesn't happen? > >> > >> I do not see anywhere chip->fwnode being set in the gpiochip_add_* fun= ction. > >> The only reference I see is here [1]. Does it mean I need to change my= match > >> function from: > >> > >> chip->fwnode =3D=3D of_node_to_fwnode(data) > >> > >> to: > >> dev_fwnode(chip->parent) =3D=3D of_node_to_fwnode(data)? > > > > No! chip->fwnode is only used to let GPIOLIB know which fwnode to > > assign to the GPIO device (struct gpio_device). > What do you suggest I should use for the match as I do not see chip->fwno= de > being set? > Andy, Linus, Do you think it makes sense to make gpiochip_add_data_with_key() assign the chip's fwnode if it's not set by the caller (and instead taken from the parent device) for this particular use-case? I think it's fine but wanted to run it by you. Bart > > > > Bart > > > >> > >> [1]: > >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tre= e/drivers/gpio/gpiolib.c?h=3Dv6.6-rc1#n767 > >> > >>> > >>> Bart > >>> > >>>> 2) Or should I use something else in hte matching function instead o= f fwnode so > >>>> to avoid adding above line in the gpio driver? > >>>> > >>>>> > >>>>>>> > >>>>>>>> > >>>>>>>> Bart > >>>>>>> > >>>>>> > >>>>> > >>>> > >> >