Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp502686rdb; Thu, 5 Oct 2023 12:06:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2XUJhCmN6cmYF8bg4BH5lL/5P6lpfKvnSXskOQixw3x+Rk7ljCakN+IZ1YNpYqZELbw4j X-Received: by 2002:a05:6e02:e47:b0:350:e9c6:e765 with SMTP id l7-20020a056e020e4700b00350e9c6e765mr4905249ilk.11.1696532791336; Thu, 05 Oct 2023 12:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696532791; cv=none; d=google.com; s=arc-20160816; b=IVFg9IHRn+qQe40HntTwYdY1LI7JG/U6QhMK7hFUmMeFYZ9OWHKOO7ycJCSGKjZlc1 OjgplKJAgFUh9LTE3MKKeYn3dEt+4MExurk7wKsjKDcPZ9lgOKUjfL6K1VJRC6gACj3H 1dXHKjMtqdwVjeDFm5UM9IAEU/acYsY8I1cCqHND+hl7Su+2gQoAFE4xc8sNUhlj8jTw LqraY+x8aZQ5QEzHd0ydeIm+xJbhqFujQ4Nb7h/m+Jr3ma5jAOLizXEQiYmJT3Hsm7+y wDgU7OzKbeJZWjIqR7zH7CkFeDszf+e9Pt4yO0ROZ2It3Jad8Jd2Mz2QJgB38320fOhT q+hw== 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=B2BbXZ6zku6CreVtFbsfProDFvSQWLPs41LvEjW0tpg=; fh=U05zTU+BzIQZrsx+NkQTNGLX0zEOzzBDMkCwLxuVHJg=; b=nuEv1jCpH4627W7W3gu+9vKRRdgpMqsrXum9rOTjR3+uy241Gfv7mt8YsVIakAxcNE x3WGhV355FsmLEo3+Ju0Wd2mbt4t1tjV+6/5xlzhdxzvxP1Jr6Azy7RZ0PGjAZn8k/dk imk3AVL/0ElAId/94AgG/P4UmavjYmc7US8iXDsE4zfcKfdoWPhpEEBDpYf0p/2Y10DX OqTh7I3EhZUVPk7+oWs3LXC2iA1nE4moe/ZQBplzstJdbpSANDfnGGiGXJj/Q7sO3xDz f4wQxalSZB7Y/Ru1wJVk7iCnHwSQIBIEsyHyKLCavpmebIFkAa1nfOo1bJxfWiCi22bf 8EjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=0Zv4tMCF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id k191-20020a6384c8000000b00578c8ce14edsi2085609pgd.252.2023.10.05.12.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 12:06:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=0Zv4tMCF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 2BF1F81A6C30; Thu, 5 Oct 2023 12:06:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbjJETFv (ORCPT + 99 others); Thu, 5 Oct 2023 15:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbjJETFt (ORCPT ); Thu, 5 Oct 2023 15:05:49 -0400 Received: from mail-vk1-xa34.google.com (mail-vk1-xa34.google.com [IPv6:2607:f8b0:4864:20::a34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D763E4 for ; Thu, 5 Oct 2023 12:05:46 -0700 (PDT) Received: by mail-vk1-xa34.google.com with SMTP id 71dfb90a1353d-49369d29be3so538624e0c.3 for ; Thu, 05 Oct 2023 12:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696532745; x=1697137545; 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=B2BbXZ6zku6CreVtFbsfProDFvSQWLPs41LvEjW0tpg=; b=0Zv4tMCF+t8NirqOQmQGZm51hO32yLzsbCro2T4GH6g+a5cwATniRhdDlbHxABknqj w7rLjUBBnKQ2cqdBN1NtnMTyuedkt/Gwm9DsopMVsC0n/YB1ZF2bracnuO5ZsTQHOxT/ kOw93Ix+4vbQQ1TViz5MXgNL/lJ7O7/YpaflWKOtymKhKt3mJibnBqll1RYtEa30xRLl xhAluyOGvYMucC4m9FwGqbPlkhAaOyA/3t57AxBOZmz/2yIIPUzJa79k9pVUH4XeC+nk BE+P6gZgSPtqPoejyJHmw9T7qTVN8xB3crs+gxzLL3/AexcjYvDY8MyTF5Ylvch7ii71 CvGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696532745; x=1697137545; 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=B2BbXZ6zku6CreVtFbsfProDFvSQWLPs41LvEjW0tpg=; b=CoSs/lvKilEum4DH6U0nhDZ7mWbZT+4p4i7OuMcsx+dX53USTUpBF9JQkes2CtMmiY Fr/DFHcRiwDR0SR4XCkAkfb4vfBHKHHONC1cKh6J9DHI3WMJCBrpbZXLuqFVJTmpVb3t 9veGktSsp1SV8y1m3FvArOW9Tu6/Iu/YJ+24/x2lpaZPmulqLaVK1IRKNePtbQYElqGn hCzxKJ8px7nHuq4E3V13cMow+Fv3zT7FyFRfY/fM1UmbbRUtWlST+XdSotxczUbak0bI VZl3hgi3M/xGs5TcMbYXn8SDfnwj4Le6fE1Hq6aJB/HX7JNgjetKIi9STSt3l07vTEr3 O6/g== X-Gm-Message-State: AOJu0Yx2WmJtGFOURP71gBPYVZl/xfSL/7hRzXBRvz2fAZA9+3obluG6 t0O+yjzBC+7YPgI6a0zMQ3bOF2pfUViPMsW5Fb0Brg== X-Received: by 2002:a1f:66c3:0:b0:49a:a773:fe80 with SMTP id a186-20020a1f66c3000000b0049aa773fe80mr6001000vkc.2.1696532745272; Thu, 05 Oct 2023 12:05:45 -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: <647d3b52-1daf-175d-d5c2-45653dd2604c@nvidia.com> From: Bartosz Golaszewski Date: Thu, 5 Oct 2023 21:05:34 +0200 Message-ID: Subject: Re: [RFT PATCH 14/21] hte: tegra194: don't access struct gpio_chip To: Dipen Patel Cc: Linus Walleij , Aaro Koskinen , Janusz Krzysztofik , Tony Lindgren , Russell King , Mika Westerberg , Andy Shevchenko , 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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 05 Oct 2023 12:06:05 -0700 (PDT) On Thu, Oct 5, 2023 at 8:12=E2=80=AFPM Dipen Patel wrot= e: > > 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 ref= erence > >>>>>>>> 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 some > >>>>>>> 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 to = 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() treewi= de, > >>>>>> 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 c= leanly, > >>>>> some patches I needed to manually apply and correct. With all this,= it failed > >>>>> compilation at some spi/spi-bcm2835 driver. I disabled that and was= 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 gpio = device, > >>>>> roughly around this place [1]. I thought it would be your patch ser= ies so > >>>>> tried to just use 6.6rc1 without your patches and it still failed a= t the > >>>>> same place. I have to trace back now from which kernel version it b= roke. > >>>> > >>>> [1]. > >>>> https://git.kernel.org/pub/scm/linux/kernel/git/pateldipen1984/linux= .git/tree/drivers/hte/hte-tegra194.c?h=3Dfor-next#n781 > >>>> > >>>> of course with your patches it would fail for the gdev instead of th= e chip. > >>> > >>> Small update: > >>> > >>> I put some debugging prints in the gpio match function in the hte-teg= ra194.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 nam= e:%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 ap= pearing > >>> 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 t= hat 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 f= acing, I > >> was able to verify your patch series. > >> > >> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186= .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_dev= ice *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 driv= er? > > > > 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_* functi= on. > The only reference I see is here [1]. Does it mean I need to change my ma= tch > 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). Bart > > [1]: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/d= rivers/gpio/gpiolib.c?h=3Dv6.6-rc1#n767 > > > > > Bart > > > >> 2) Or should I use something else in hte matching function instead of = fwnode so > >> to avoid adding above line in the gpio driver? > >> > >>> > >>>>> > >>>>>> > >>>>>> Bart > >>>>> > >>>> > >>> > >> >