linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@arm.com>
To: Saravana Kannan <saravanak@google.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Cristian Marussi <cristian.marussi@arm.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Thomas Gleixner <tglx@linutronix.de>,
	Marc Zyngier <maz@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	NXP Linux Team <linux-imx@nxp.com>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>, Len Brown <lenb@kernel.org>,
	Daniel Scally <djrscally@gmail.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Tony Lindgren <tony@atomide.com>,
	Linux Kernel Functional Testing <lkft@linaro.org>,
	Naresh Kamboju <naresh.kamboju@linaro.org>,
	Abel Vesa <abel.vesa@linaro.org>,
	Alexander Stein <alexander.stein@ew.tq-group.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	John Stultz <jstultz@google.com>,
	Doug Anderson <dianders@chromium.org>,
	Guenter Roeck <linux@roeck-us.net>,
	Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	Maxim Kiselev <bigunclemax@gmail.com>,
	Maxim Kochetkov <fido_max@inbox.ru>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Luca Weiss <luca.weiss@fairphone.com>,
	Colin Foster <colin.foster@in-advantage.com>,
	Martin Kepplinger <martin.kepplinger@puri.sm>,
	Jean-Philippe Brucker <jpb@kernel.org>,
	kernel-team@android.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-acpi@vger.kernel.org
Subject: Re: [PATCH v2 04/11] gpiolib: Clear the gpio_device's fwnode initialized flag before adding
Date: Tue, 31 Jan 2023 10:13:37 +0000	[thread overview]
Message-ID: <20230131101337.376mnrvhltbsychd@bogus> (raw)
In-Reply-To: <CAGETcx9aPp+JU-hO+fGyGps6jaoKoFzZd2zzy5YZBKoU8G=OhA@mail.gmail.com>

On Mon, Jan 30, 2023 at 08:01:17PM -0800, Saravana Kannan wrote:
> On Mon, Jan 30, 2023 at 7:14 AM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Mon, Jan 30, 2023 at 02:31:53PM +0000, Sudeep Holla wrote:
> > > On Thu, Jan 26, 2023 at 04:11:31PM -0800, Saravana Kannan wrote:
> > > > Registering an irqdomain sets the flag for the fwnode. But having the
> > > > flag set when a device is added is interpreted by fw_devlink to mean the
> > > > device has already been initialized and will never probe. This prevents
> > > > fw_devlink from creating device links with the gpio_device as a
> > > > supplier. So, clear the flag before adding the device.
> >
> > ...
> >
> > > > +   /*
> > > > +    * If fwnode doesn't belong to another device, it's safe to clear its
> > > > +    * initialized flag.
> > > > +    */
> > > > +   if (!gdev->dev.fwnode->dev)
> > > > +           fwnode_dev_initialized(gdev->dev.fwnode, false);
> > >
> > > This is the one causing the kernel crash during the boot on FVP which
> > > Naresh has reported. Just reverted this and was able to boot, confirming
> > > the issue with this patch.
> >
> > I'm wondering if
> >
> >         if (!dev_fwnode(&gdev->dev)->dev)
> >                 fwnode_dev_initialized(&dev_fwnode(gdev->dev), false);
> >
> > works.
> 
> No, that won't help. The problem was that with arm32, we have gpio
> devices created without any of_node or fwnode. So I can't assume
> fwnode will always be present.
>

Correct, and this one is not even arm32. But it is just reusing a driver
that needs to be supported even on arm32.

Not sure on how to proceed. As a simple way to check, I added a NULL check
for fwnode building on top of Andy's suggestion[1]. That works.

Also the driver in question on arm64 FVP model is drivers/mfd/vexpress-sysreg.c
mfd_add_device() in drivers/mfd/mfd-core.c allows addition of devices without
of_node/fwnode. I am sure returning error like[2] will break many platforms
but I just wanted to confirm the root cause and [2] fixes the boot without
NULL check for fwnode in gpiochip_setup_dev().

Hope this helps.

--
Regards,
Sudeep

[1]

-->8
diff --git i/drivers/gpio/gpiolib.c w/drivers/gpio/gpiolib.c
index b23140c6485f..e162f13aa2c9 100644
--- i/drivers/gpio/gpiolib.c
+++ w/drivers/gpio/gpiolib.c
@@ -577,13 +577,15 @@ static void gpiodevice_release(struct device *dev)
 static int gpiochip_setup_dev(struct gpio_device *gdev)
 {
        int ret;
+       struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev);

        /*
         * If fwnode doesn't belong to another device, it's safe to clear its
         * initialized flag.
         */
-       if (!gdev->dev.fwnode->dev)
-               fwnode_dev_initialized(gdev->dev.fwnode, false);
+       if (fwnode && !fwnode->dev)
+               fwnode_dev_initialized(fwnode, false);
+
        ret = gcdev_register(gdev, gpio_devt);
        if (ret)
                return ret;

[2]

-->8

diff --git i/drivers/mfd/mfd-core.c w/drivers/mfd/mfd-core.c
index 16d1861e9682..3b2c4b0e9a2a 100644
--- i/drivers/mfd/mfd-core.c
+++ w/drivers/mfd/mfd-core.c
@@ -231,9 +231,11 @@ static int mfd_add_device(struct device *parent, int id,
                        }
                }

-               if (!pdev->dev.of_node)
+               if (!pdev->dev.of_node) {
                        pr_warn("%s: Failed to locate of_node [id: %d]\n",
                                cell->name, platform_id);
+                       goto fail_alias;
+               }
        }

        mfd_acpi_add_device(cell, pdev);


  reply	other threads:[~2023-01-31 10:13 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27  0:11 [PATCH v2 00/11] fw_devlink improvements Saravana Kannan
2023-01-27  0:11 ` [PATCH v2 01/11] driver core: fw_devlink: Don't purge child fwnode's consumer links Saravana Kannan
2023-01-27  9:21   ` Andy Shevchenko
2023-01-28  7:33     ` Saravana Kannan
2023-01-30 12:04       ` Andy Shevchenko
2023-01-27  0:11 ` [PATCH v2 02/11] driver core: fw_devlink: Improve check for fwnode with no device/driver Saravana Kannan
2023-01-27  0:11 ` [PATCH v2 03/11] soc: renesas: Move away from using OF_POPULATED for fw_devlink Saravana Kannan
2023-01-27  8:11   ` Geert Uytterhoeven
2023-01-28  7:18     ` Saravana Kannan
2023-01-30  8:42       ` Geert Uytterhoeven
2023-01-30 20:00         ` Saravana Kannan
2023-01-31  8:14           ` Geert Uytterhoeven
2023-02-04 22:30             ` Saravana Kannan
2023-01-27  9:25   ` Andy Shevchenko
2023-01-27  9:30     ` Geert Uytterhoeven
2023-01-27  9:44       ` Andy Shevchenko
2023-01-27  0:11 ` [PATCH v2 04/11] gpiolib: Clear the gpio_device's fwnode initialized flag before adding Saravana Kannan
2023-01-27  9:27   ` Andy Shevchenko
2023-01-28  7:33     ` Saravana Kannan
2023-01-30 12:05       ` Andy Shevchenko
2023-01-30 14:31   ` Sudeep Holla
2023-01-30 15:14     ` Andy Shevchenko
2023-01-31  4:01       ` Saravana Kannan
2023-01-31 10:13         ` Sudeep Holla [this message]
2023-02-04 22:32           ` Saravana Kannan
2023-01-27  0:11 ` [PATCH v2 05/11] driver core: fw_devlink: Add DL_FLAG_CYCLE support to device links Saravana Kannan
2023-01-27  9:29   ` Andy Shevchenko
2023-01-27  9:30     ` Andy Shevchenko
2023-01-27  9:55     ` Geert Uytterhoeven
2023-01-28  7:34     ` Saravana Kannan
2023-01-30 12:08       ` Andy Shevchenko
2023-01-27  0:11 ` [PATCH v2 06/11] driver core: fw_devlink: Allow marking a fwnode link as being part of a cycle Saravana Kannan
2023-01-27  9:33   ` Andy Shevchenko
2023-01-28  7:34     ` Saravana Kannan
2023-01-30 12:09       ` Andy Shevchenko
2023-01-27  0:11 ` [PATCH v2 07/11] driver core: fw_devlink: Consolidate device link flag computation Saravana Kannan
2023-01-27  0:11 ` [PATCH v2 08/11] driver core: fw_devlink: Make cycle detection more robust Saravana Kannan
2023-01-27  9:43   ` Andy Shevchenko
2023-01-27  9:52     ` Geert Uytterhoeven
2023-01-27 10:10       ` Andy Shevchenko
2023-01-27 10:29         ` Geert Uytterhoeven
2023-01-28  7:34     ` Saravana Kannan
2023-01-30 12:15       ` Andy Shevchenko
2023-01-30 14:36         ` Geert Uytterhoeven
2023-01-30 15:16           ` Andy Shevchenko
2023-01-27  0:11 ` [PATCH v2 09/11] of: property: Simplify of_link_to_phandle() Saravana Kannan
2023-01-30 14:39   ` Sakari Ailus
2023-01-31  3:51     ` Saravana Kannan
2023-01-27  0:11 ` [PATCH v2 10/11] irqchip/irq-imx-gpcv2: Mark fwnode device as not initialized Saravana Kannan
2023-01-27  9:51   ` Andy Shevchenko
2023-01-28  7:34     ` Saravana Kannan
2023-01-27  0:11 ` [PATCH v2 11/11] firmware: arm_scmi: Set fwnode for the scmi_device Saravana Kannan
2023-01-27  9:52   ` Andy Shevchenko
2023-01-27 10:48   ` Sudeep Holla
2023-01-27 20:30 ` [PATCH v2 00/11] fw_devlink improvements Colin Foster
2023-01-27 21:35   ` Saravana Kannan
2023-01-30  8:55 ` Naresh Kamboju
2023-01-30 10:49   ` Marc Zyngier
2023-01-30 23:03   ` Saravana Kannan
2023-01-31 10:18     ` Sudeep Holla
2023-02-02 17:36       ` Maxim Kiselev
2023-02-03  6:07         ` Saravana Kannan
2023-02-03  9:39           ` Maxim Kiselev
2023-02-06  1:32             ` Saravana Kannan
2023-02-06  2:17               ` Saravana Kannan
2023-02-06  9:39               ` Miquel Raynal
2023-02-06 20:08                 ` Saravana Kannan
2023-02-24 14:46                   ` Miquel Raynal
2023-02-06 15:18               ` Rob Herring
2023-02-06 19:59                 ` Saravana Kannan
2023-01-30 10:48 ` Miquel Raynal
2023-01-30 12:08   ` Maxim Kiselev
2023-01-31  1:20     ` Saravana Kannan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230131101337.376mnrvhltbsychd@bogus \
    --to=sudeep.holla@arm.com \
    --cc=abel.vesa@linaro.org \
    --cc=alexander.stein@ew.tq-group.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bigunclemax@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=colin.foster@in-advantage.com \
    --cc=cristian.marussi@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=djrscally@gmail.com \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=festevam@gmail.com \
    --cc=fido_max@inbox.ru \
    --cc=frowand.list@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jpb@kernel.org \
    --cc=jstultz@google.com \
    --cc=kernel-team@android.com \
    --cc=kernel@pengutronix.de \
    --cc=lenb@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lkft@linaro.org \
    --cc=luca.weiss@fairphone.com \
    --cc=magnus.damm@gmail.com \
    --cc=martin.kepplinger@puri.sm \
    --cc=maz@kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=naresh.kamboju@linaro.org \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sakari.ailus@linux.intel.com \
    --cc=saravanak@google.com \
    --cc=shawnguo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).