From: Linus Walleij <linus.walleij@linaro.org>
To: "Théo Lebrun" <theo.lebrun@bootlin.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mips@vger.kernel.org,
Gregory CLEMENT <gregory.clement@bootlin.com>,
Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Tawfik Bayouk <tawfik.bayouk@mobileye.com>
Subject: Re: [PATCH 18/23] gpio: nomadik: support mobileye,eyeq5-gpio
Date: Wed, 21 Feb 2024 20:36:39 +0100 [thread overview]
Message-ID: <CACRpkdZQ9LEqKvugDCMEXPPLMCUJ-f9rYQOpmsSEJhtW0zjNsg@mail.gmail.com> (raw)
In-Reply-To: <CZAW47LJHQVD.1Z9GFT8UENYXT@bootlin.com>
On Wed, Feb 21, 2024 at 5:16 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:
> > Trying to figure it out...
>
> Can I help in the debugging process?
Nah, I found it :)
> Reading the code once again I'd guess
> of_device_get_match_data(&gpio_pdev->dev) could be the root cause. We
> are accessing match data for the GPIO device while probing the pinctrl
> device. Maybe something isn't initialised properly yet? The rest looks
> rather harmless, I've checked all conditional expressions.
Yep spot on. The nmk_gpio_populate_chip() is sometimes called from
the pinctrl driver before the gpio probe() has been called, so the match
data is NULL and we crash.
This looks like it does for historical reasons and there could be better
ways to fix it now that Saravana Kannan has fixed up the probe ordering
code.
The following is one way to fix it for now using device_is_compatible()
(illustrating some other changes I did as well):
diff --git a/drivers/gpio/gpio-nomadik.c b/drivers/gpio/gpio-nomadik.c
index 21bb6d6363fc..11071a982ebb 100644
--- a/drivers/gpio/gpio-nomadik.c
+++ b/drivers/gpio/gpio-nomadik.c
@@ -27,6 +27,7 @@
#include <linux/of_platform.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/reset.h>
#include <linux/seq_file.h>
#include <linux/types.h>
@@ -37,15 +38,13 @@
static DEFINE_SPINLOCK(nmk_gpio_slpm_lock);
#endif
-#define NMK_GPIO_FLAG_QUIRK_MBLY BIT(0)
-
void __nmk_gpio_set_slpm(struct nmk_gpio_chip *nmk_chip, unsigned int offset,
enum nmk_gpio_slpm mode)
{
u32 slpm;
/* We should NOT have been called. */
- if (WARN_ON(nmk_chip->quirk_mbly))
+ if (WARN_ON(nmk_chip->is_mobileye_soc))
return;
slpm = readl(nmk_chip->addr + NMK_GPIO_SLPC);
@@ -105,7 +104,7 @@ static void __nmk_gpio_irq_modify(struct
nmk_gpio_chip *nmk_chip,
fimscval = &nmk_chip->fimsc;
} else {
/* We should NOT have been called. */
- if (WARN_ON(nmk_chip->quirk_mbly))
+ if (WARN_ON(nmk_chip->is_mobileye_soc))
return;
rimscreg = NMK_GPIO_RWIMSC;
fimscreg = NMK_GPIO_FWIMSC;
@@ -134,7 +133,7 @@ static void __nmk_gpio_set_wake(struct
nmk_gpio_chip *nmk_chip,
int offset, bool on)
{
/* We should NOT have been called. */
- if (WARN_ON(nmk_chip->quirk_mbly))
+ if (WARN_ON(nmk_chip->is_mobileye_soc))
return;
/*
@@ -161,7 +160,7 @@ static void nmk_gpio_irq_maskunmask(struct
nmk_gpio_chip *nmk_chip,
__nmk_gpio_irq_modify(nmk_chip, d->hwirq, NORMAL, enable);
- if (!nmk_chip->quirk_mbly && !(nmk_chip->real_wake & BIT(d->hwirq)))
+ if (!nmk_chip->is_mobileye_soc && !(nmk_chip->real_wake & BIT(d->hwirq)))
__nmk_gpio_set_wake(nmk_chip, d->hwirq, enable);
spin_unlock(&nmk_chip->lock);
@@ -194,7 +193,7 @@ static int nmk_gpio_irq_set_wake(struct irq_data
*d, unsigned int on)
unsigned long flags;
/* Handler is registered in all cases. */
- if (nmk_chip->quirk_mbly)
+ if (nmk_chip->is_mobileye_soc)
return -ENXIO;
clk_enable(nmk_chip->clk);
@@ -235,7 +234,7 @@ static int nmk_gpio_irq_set_type(struct irq_data
*d, unsigned int type)
if (enabled)
__nmk_gpio_irq_modify(nmk_chip, d->hwirq, NORMAL, false);
- if (!nmk_chip->quirk_mbly && (enabled || wake))
+ if (!nmk_chip->is_mobileye_soc && (enabled || wake))
__nmk_gpio_irq_modify(nmk_chip, d->hwirq, WAKE, false);
nmk_chip->edge_rising &= ~BIT(d->hwirq);
@@ -249,7 +248,7 @@ static int nmk_gpio_irq_set_type(struct irq_data
*d, unsigned int type)
if (enabled)
__nmk_gpio_irq_modify(nmk_chip, d->hwirq, NORMAL, true);
- if (!nmk_chip->quirk_mbly && (enabled || wake))
+ if (!nmk_chip->is_mobileye_soc && (enabled || wake))
__nmk_gpio_irq_modify(nmk_chip, d->hwirq, WAKE, true);
spin_unlock_irqrestore(&nmk_chip->lock, flags);
@@ -383,7 +382,7 @@ static int nmk_gpio_get_mode(struct nmk_gpio_chip
*nmk_chip, int offset)
u32 afunc, bfunc;
/* We don't support modes. */
- if (nmk_chip->quirk_mbly)
+ if (nmk_chip->is_mobileye_soc)
return NMK_GPIO_ALT_GPIO;
clk_enable(nmk_chip->clk);
@@ -517,7 +516,6 @@ struct nmk_gpio_chip
*nmk_gpio_populate_chip(struct device_node *np,
struct resource *res;
struct clk *clk;
void __iomem *base;
- uintptr_t flags;
u32 id, ngpio;
gpio_pdev = of_find_device_by_node(np);
@@ -551,8 +549,7 @@ struct nmk_gpio_chip
*nmk_gpio_populate_chip(struct device_node *np,
dev_dbg(&pdev->dev, "populate: using default ngpio (%d)\n", ngpio);
}
- flags = (uintptr_t)of_device_get_match_data(&gpio_pdev->dev);
- nmk_chip->quirk_mbly = !!(flags & NMK_GPIO_FLAG_QUIRK_MBLY);
+ nmk_chip->is_mobileye_soc = device_is_compatible(&gpio_pdev->dev,
"mobileye,eyeq5-gpio");
nmk_chip->bank = id;
chip = &nmk_chip->chip;
chip->base = -1;
@@ -667,7 +664,7 @@ static int nmk_gpio_probe(struct platform_device *pdev)
return ret;
}
- if (!nmk_chip->quirk_mbly) {
+ if (!nmk_chip->is_mobileye_soc) {
clk_enable(nmk_chip->clk);
nmk_chip->lowemi = readl_relaxed(nmk_chip->addr + NMK_GPIO_LOWEMI);
clk_disable(nmk_chip->clk);
@@ -690,7 +687,6 @@ static const struct of_device_id nmk_gpio_match[] = {
},
{
.compatible = "mobileye,eyeq5-gpio",
- .data = (void*)NMK_GPIO_FLAG_QUIRK_MBLY,
},
{}
};
diff --git a/include/linux/gpio/gpio-nomadik.h
b/include/linux/gpio/gpio-nomadik.h
index 8d0134dd3771..ede16cdaa920 100644
--- a/include/linux/gpio/gpio-nomadik.h
+++ b/include/linux/gpio/gpio-nomadik.h
@@ -51,6 +51,7 @@ enum nmk_gpio_slpm {
struct nmk_gpio_chip {
struct gpio_chip chip;
+ bool is_mobileye_soc;
void __iomem *addr;
struct clk *clk;
unsigned int bank;
Yours,
Linus Walleij
next prev parent reply other threads:[~2024-02-21 19:36 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-14 16:23 [PATCH 00/23] Rework Nomadik GPIO to add Mobileye EyeQ5 support Théo Lebrun
2024-02-14 16:23 ` [PATCH 01/23] dt-bindings: gpio: nomadik: convert into yaml format Théo Lebrun
2024-02-15 9:11 ` Krzysztof Kozlowski
2024-02-15 9:47 ` Théo Lebrun
2024-02-19 14:50 ` Linus Walleij
2024-02-14 16:23 ` [PATCH 02/23] dt-bindings: gpio: nomadik: add optional ngpios property Théo Lebrun
2024-02-15 9:12 ` Krzysztof Kozlowski
2024-02-19 14:50 ` Linus Walleij
2024-02-19 14:55 ` Théo Lebrun
2024-02-14 16:23 ` [PATCH 03/23] dt-bindings: gpio: nomadik: add mobileye,eyeq5-gpio compatible Théo Lebrun
2024-02-15 9:13 ` Krzysztof Kozlowski
2024-02-15 9:52 ` Théo Lebrun
2024-02-14 16:23 ` [PATCH 04/23] dt-bindings: gpio: nomadik: add optional reset property Théo Lebrun
2024-02-15 9:13 ` Krzysztof Kozlowski
2024-02-19 14:55 ` Linus Walleij
2024-02-14 16:23 ` [PATCH 05/23] gpio: nomadik: extract GPIO platform driver from drivers/pinctrl/nomadik/ Théo Lebrun
2024-02-15 10:03 ` Philipp Zabel
2024-02-16 10:43 ` Théo Lebrun
2024-02-19 15:33 ` Bartosz Golaszewski
2024-02-21 11:41 ` Philipp Zabel
2024-02-19 16:08 ` Bartosz Golaszewski
2024-02-21 16:02 ` Théo Lebrun
2024-02-21 14:37 ` Linus Walleij
2024-02-21 16:20 ` Théo Lebrun
2024-02-21 19:31 ` Linus Walleij
2024-02-14 16:23 ` [PATCH 06/23] pinctrl: nomadik: fix build warning (-Wformat) Théo Lebrun
2024-02-14 16:24 ` [PATCH 07/23] pinctrl: nomadik: fix build warning (-Wpointer-to-int-cast) Théo Lebrun
2024-02-14 16:24 ` [PATCH 08/23] pinctrl: nomadik: minimise indentation in probe Théo Lebrun
2024-02-14 16:24 ` [PATCH 09/23] pinctrl: nomadik: follow type-system kernel coding conventions Théo Lebrun
2024-02-14 16:24 ` [PATCH 10/23] pinctrl: nomadik: follow whitespace " Théo Lebrun
2024-02-14 16:24 ` [PATCH 11/23] pinctrl: nomadik: follow conditional " Théo Lebrun
2024-02-14 16:24 ` [PATCH 12/23] gpio: nomadik: request dynamic ID allocation Théo Lebrun
2024-02-14 16:24 ` [PATCH 13/23] gpio: nomadik: fix offset bug in nmk_pmx_set() Théo Lebrun
2024-02-19 15:54 ` Bartosz Golaszewski
2024-02-21 15:57 ` Théo Lebrun
2024-02-19 21:56 ` Linus Walleij
2024-02-21 16:05 ` Théo Lebrun
2024-02-14 16:24 ` [PATCH 14/23] gpio: nomadik: make clock optional Théo Lebrun
2024-02-14 16:24 ` [PATCH 15/23] gpio: nomadik: change driver name from gpio to gpio-nomadik Théo Lebrun
2024-02-14 16:24 ` [PATCH 16/23] gpio: nomadik: support shared GPIO IRQs Théo Lebrun
2024-02-19 15:48 ` Bartosz Golaszewski
2024-02-19 15:54 ` Théo Lebrun
2024-02-19 16:17 ` Bartosz Golaszewski
2024-02-20 8:07 ` Linus Walleij
2024-02-14 16:24 ` [PATCH 17/23] gpio: nomadik: handle variadic GPIO count Théo Lebrun
2024-02-19 16:17 ` Bartosz Golaszewski
2024-02-20 8:08 ` Linus Walleij
2024-02-14 16:24 ` [PATCH 18/23] gpio: nomadik: support mobileye,eyeq5-gpio Théo Lebrun
2024-02-21 13:45 ` Linus Walleij
2024-02-21 16:22 ` Théo Lebrun
2024-02-21 14:31 ` Linus Walleij
2024-02-21 16:16 ` Théo Lebrun
2024-02-21 19:36 ` Linus Walleij [this message]
2024-02-22 9:37 ` Théo Lebrun
2024-02-14 16:24 ` [PATCH 19/23] gpio: nomadik: grab optional reset control and deassert it at probe Théo Lebrun
2024-02-15 10:19 ` Philipp Zabel
2024-02-16 10:46 ` Théo Lebrun
2024-02-14 16:24 ` [PATCH 20/23] MIPS: eyeq5_defconfig: enable GPIO by default Théo Lebrun
2024-02-14 16:24 ` [PATCH 21/23] MIPS: mobileye: eyeq5: add two GPIO bank nodes Théo Lebrun
2024-02-14 16:24 ` [PATCH 22/23] MIPS: mobileye: eyeq5: add resets to GPIO banks Théo Lebrun
2024-02-14 16:24 ` [PATCH 23/23] MIPS: mobileye: eyeq5: map GPIOs to pins using gpio-ranges Théo Lebrun
2024-02-19 15:44 ` [PATCH 00/23] Rework Nomadik GPIO to add Mobileye EyeQ5 support Bartosz Golaszewski
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=CACRpkdZQ9LEqKvugDCMEXPPLMCUJ-f9rYQOpmsSEJhtW0zjNsg@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregory.clement@bootlin.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=tawfik.bayouk@mobileye.com \
--cc=theo.lebrun@bootlin.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tsbogend@alpha.franken.de \
--cc=vladimir.kondratiev@mobileye.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).