All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] tqmx86: TQMxE40M support
@ 2021-03-31 11:35 Matthias Schiffer
  2021-03-31 11:35 ` [PATCH 1/3] gpio: tqmx86: really make IRQ optional Matthias Schiffer
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Matthias Schiffer @ 2021-03-31 11:35 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Lee Jones, linux-gpio, linux-kernel, Matthias Schiffer

This fixes a bug in the IRQ setup of the tqmx86 MFD / GPIO drivers and
adds support for our upcoming Elkhart Lake module TQMxE40M (as well as
future SoMs).

As patch 2 depends on patch 1, it would make sense to push the whole
series through the same tree.

Matthias Schiffer (3):
  gpio: tqmx86: really make IRQ optional
  mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set
  mfd: tqmx86: add support for TQMxE40M

 drivers/gpio/gpio-tqmx86.c |  6 +++---
 drivers/mfd/tqmx86.c       | 13 ++++++-------
 2 files changed, 9 insertions(+), 10 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/3] gpio: tqmx86: really make IRQ optional
  2021-03-31 11:35 [PATCH 0/3] tqmx86: TQMxE40M support Matthias Schiffer
@ 2021-03-31 11:35 ` Matthias Schiffer
  2021-03-31 12:29   ` Andy Shevchenko
  2021-03-31 12:30   ` Andy Shevchenko
  2021-03-31 11:35 ` [PATCH 2/3] mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set Matthias Schiffer
  2021-03-31 11:35 ` [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M Matthias Schiffer
  2 siblings, 2 replies; 20+ messages in thread
From: Matthias Schiffer @ 2021-03-31 11:35 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Lee Jones, linux-gpio, linux-kernel, Matthias Schiffer

The tqmx86 MFD driver was passing IRQ 0 for "no IRQ" in the past. This
causes warnings with newer kernels.

Prepare the gpio-tqmx86 driver for the fixed MFD driver by handling a
missing IRQ properly.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
 drivers/gpio/gpio-tqmx86.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
index 5022e0ad0fae..0f5d17f343f1 100644
--- a/drivers/gpio/gpio-tqmx86.c
+++ b/drivers/gpio/gpio-tqmx86.c
@@ -238,8 +238,8 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
 	struct resource *res;
 	int ret, irq;
 
-	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
+	irq = platform_get_irq_optional(pdev, 0);
+	if (irq < 0 && irq != -ENXIO)
 		return irq;
 
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
@@ -278,7 +278,7 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(&pdev->dev);
 
-	if (irq) {
+	if (irq > 0) {
 		struct irq_chip *irq_chip = &gpio->irq_chip;
 		u8 irq_status;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/3] mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set
  2021-03-31 11:35 [PATCH 0/3] tqmx86: TQMxE40M support Matthias Schiffer
  2021-03-31 11:35 ` [PATCH 1/3] gpio: tqmx86: really make IRQ optional Matthias Schiffer
@ 2021-03-31 11:35 ` Matthias Schiffer
  2021-03-31 12:35   ` Andy Shevchenko
  2021-03-31 11:35 ` [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M Matthias Schiffer
  2 siblings, 1 reply; 20+ messages in thread
From: Matthias Schiffer @ 2021-03-31 11:35 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Lee Jones, linux-gpio, linux-kernel, Matthias Schiffer

The driver was registering IRQ 0 when no IRQ was set. This leads to
warnings with newer kernels.

Clear the resource flags, so no resource is registered at all in this
case.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
 drivers/mfd/tqmx86.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
index ddddf08b6a4c..732013f40e4e 100644
--- a/drivers/mfd/tqmx86.c
+++ b/drivers/mfd/tqmx86.c
@@ -209,6 +209,8 @@ static int tqmx86_probe(struct platform_device *pdev)
 
 		/* Assumes the IRQ resource is first. */
 		tqmx_gpio_resources[0].start = gpio_irq;
+	} else {
+		tqmx_gpio_resources[0].flags = 0;
 	}
 
 	ocores_platfom_data.clock_khz = tqmx86_board_id_to_clk_rate(board_id);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M
  2021-03-31 11:35 [PATCH 0/3] tqmx86: TQMxE40M support Matthias Schiffer
  2021-03-31 11:35 ` [PATCH 1/3] gpio: tqmx86: really make IRQ optional Matthias Schiffer
  2021-03-31 11:35 ` [PATCH 2/3] mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set Matthias Schiffer
@ 2021-03-31 11:35 ` Matthias Schiffer
  2021-03-31 12:37   ` Andy Shevchenko
  2 siblings, 1 reply; 20+ messages in thread
From: Matthias Schiffer @ 2021-03-31 11:35 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Lee Jones, linux-gpio, linux-kernel, Matthias Schiffer

All future TQMx86 SoMs will use a 24MHz LPC clock, so we can use that as
a default instead of listing each new module individually.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
 drivers/mfd/tqmx86.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
index 732013f40e4e..1d5cebc4e72b 100644
--- a/drivers/mfd/tqmx86.c
+++ b/drivers/mfd/tqmx86.c
@@ -36,6 +36,7 @@
 #define TQMX86_REG_BOARD_ID_70EB	8
 #define TQMX86_REG_BOARD_ID_80UC	9
 #define TQMX86_REG_BOARD_ID_90UC	10
+#define TQMX86_REG_BOARD_ID_E40M	12
 #define TQMX86_REG_BOARD_REV	0x21
 #define TQMX86_REG_IO_EXT_INT	0x26
 #define TQMX86_REG_IO_EXT_INT_NONE		0
@@ -130,6 +131,8 @@ static const char *tqmx86_board_id_to_name(u8 board_id)
 		return "TQMx80UC";
 	case TQMX86_REG_BOARD_ID_90UC:
 		return "TQMx90UC";
+	case TQMX86_REG_BOARD_ID_E40M:
+		return "TQMxE40M";
 	default:
 		return "Unknown";
 	}
@@ -138,12 +141,6 @@ static const char *tqmx86_board_id_to_name(u8 board_id)
 static int tqmx86_board_id_to_clk_rate(u8 board_id)
 {
 	switch (board_id) {
-	case TQMX86_REG_BOARD_ID_50UC:
-	case TQMX86_REG_BOARD_ID_60EB:
-	case TQMX86_REG_BOARD_ID_70EB:
-	case TQMX86_REG_BOARD_ID_80UC:
-	case TQMX86_REG_BOARD_ID_90UC:
-		return 24000;
 	case TQMX86_REG_BOARD_ID_E39M:
 	case TQMX86_REG_BOARD_ID_E39C:
 	case TQMX86_REG_BOARD_ID_E39x:
@@ -152,7 +149,7 @@ static int tqmx86_board_id_to_clk_rate(u8 board_id)
 	case TQMX86_REG_BOARD_ID_E38C:
 		return 33000;
 	default:
-		return 0;
+		return 24000;
 	}
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
  2021-03-31 11:35 ` [PATCH 1/3] gpio: tqmx86: really make IRQ optional Matthias Schiffer
@ 2021-03-31 12:29   ` Andy Shevchenko
  2021-03-31 12:36     ` (EXT) " Matthias Schiffer
  2021-03-31 12:30   ` Andy Shevchenko
  1 sibling, 1 reply; 20+ messages in thread
From: Andy Shevchenko @ 2021-03-31 12:29 UTC (permalink / raw)
  To: Matthias Schiffer
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, Mar 31, 2021 at 2:37 PM Matthias Schiffer
<matthias.schiffer@ew.tq-group.com> wrote:
>
> The tqmx86 MFD driver was passing IRQ 0 for "no IRQ" in the past. This
> causes warnings with newer kernels.
>
> Prepare the gpio-tqmx86 driver for the fixed MFD driver by handling a
> missing IRQ properly.

...

> -       irq = platform_get_irq(pdev, 0);
> -       if (irq < 0)
> +       irq = platform_get_irq_optional(pdev, 0);

> +       if (irq < 0 && irq != -ENXIO)
>                 return irq;

This is a dead code now. I suggest you to do the opposite, i.e.
if (irq < 0)
  irq = 0;

In such a case below change is not required.

...

> -       if (irq) {
> +       if (irq > 0) {
>                 struct irq_chip *irq_chip = &gpio->irq_chip;
>                 u8 irq_status;


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
  2021-03-31 11:35 ` [PATCH 1/3] gpio: tqmx86: really make IRQ optional Matthias Schiffer
  2021-03-31 12:29   ` Andy Shevchenko
@ 2021-03-31 12:30   ` Andy Shevchenko
  1 sibling, 0 replies; 20+ messages in thread
From: Andy Shevchenko @ 2021-03-31 12:30 UTC (permalink / raw)
  To: Matthias Schiffer
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, Mar 31, 2021 at 2:37 PM Matthias Schiffer
<matthias.schiffer@ew.tq-group.com> wrote:
>
> The tqmx86 MFD driver was passing IRQ 0 for "no IRQ" in the past. This
> causes warnings with newer kernels.
>
> Prepare the gpio-tqmx86 driver for the fixed MFD driver by handling a
> missing IRQ properly.

Also you missed a Fixes tag.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/3] mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set
  2021-03-31 11:35 ` [PATCH 2/3] mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set Matthias Schiffer
@ 2021-03-31 12:35   ` Andy Shevchenko
  2021-03-31 13:24     ` Matthias Schiffer
  0 siblings, 1 reply; 20+ messages in thread
From: Andy Shevchenko @ 2021-03-31 12:35 UTC (permalink / raw)
  To: Matthias Schiffer
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, Mar 31, 2021 at 2:39 PM Matthias Schiffer
<matthias.schiffer@ew.tq-group.com> wrote:
>
> The driver was registering IRQ 0 when no IRQ was set. This leads to
> warnings with newer kernels.
>
> Clear the resource flags, so no resource is registered at all in this
> case.

...

>                 /* Assumes the IRQ resource is first. */
>                 tqmx_gpio_resources[0].start = gpio_irq;
> +       } else {
> +               tqmx_gpio_resources[0].flags = 0;

Please set IORESOURCE_DISABLED flag in the initial structure instead.

>         }


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: (EXT) Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
  2021-03-31 12:29   ` Andy Shevchenko
@ 2021-03-31 12:36     ` Matthias Schiffer
  2021-03-31 12:39       ` Andy Shevchenko
  0 siblings, 1 reply; 20+ messages in thread
From: Matthias Schiffer @ 2021-03-31 12:36 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, 2021-03-31 at 15:29 +0300, Andy Shevchenko wrote:
> On Wed, Mar 31, 2021 at 2:37 PM Matthias Schiffer
> <matthias.schiffer@ew.tq-group.com> wrote:
> > 
> > The tqmx86 MFD driver was passing IRQ 0 for "no IRQ" in the past. This
> > causes warnings with newer kernels.
> > 
> > Prepare the gpio-tqmx86 driver for the fixed MFD driver by handling a
> > missing IRQ properly.
> 
> ...
> 
> > -       irq = platform_get_irq(pdev, 0);
> > -       if (irq < 0)
> > +       irq = platform_get_irq_optional(pdev, 0);
> > +       if (irq < 0 && irq != -ENXIO)
> >                 return irq;
> 
> This is a dead code now. I suggest you to do the opposite, i.e.
> if (irq < 0)
>   irq = 0;

I don't understand which part of the code is dead now. I assume the
`return irq` case is still useful for unexpected errors, or things like
EPROBE_DEFER? I'm not sure if EPROBE_DEFER is relevant for this driver,
but just ignoring the error code completely doesn't seem right to me.



> 
> In such a case below change is not required.
> 
> ...
> 
> > -       if (irq) {
> > +       if (irq > 0) {
> >                 struct irq_chip *irq_chip = &gpio->irq_chip;
> >                 u8 irq_status;
> 
> 


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M
  2021-03-31 11:35 ` [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M Matthias Schiffer
@ 2021-03-31 12:37   ` Andy Shevchenko
  2021-03-31 13:33     ` Matthias Schiffer
  0 siblings, 1 reply; 20+ messages in thread
From: Andy Shevchenko @ 2021-03-31 12:37 UTC (permalink / raw)
  To: Matthias Schiffer
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, Mar 31, 2021 at 2:38 PM Matthias Schiffer
<matthias.schiffer@ew.tq-group.com> wrote:
>
> All future TQMx86 SoMs will use a 24MHz LPC clock, so we can use that as
> a default instead of listing each new module individually.

...

>         case TQMX86_REG_BOARD_ID_90UC:
>                 return "TQMx90UC";
> +       case TQMX86_REG_BOARD_ID_E40M:
> +               return "TQMxE40M";
>         default:
>                 return "Unknown";
>         }
> @@ -138,12 +141,6 @@ static const char *tqmx86_board_id_to_name(u8 board_id)
>  static int tqmx86_board_id_to_clk_rate(u8 board_id)
>  {
>         switch (board_id) {
> -       case TQMX86_REG_BOARD_ID_50UC:
> -       case TQMX86_REG_BOARD_ID_60EB:
> -       case TQMX86_REG_BOARD_ID_70EB:
> -       case TQMX86_REG_BOARD_ID_80UC:
> -       case TQMX86_REG_BOARD_ID_90UC:
> -               return 24000;
>         case TQMX86_REG_BOARD_ID_E39M:
>         case TQMX86_REG_BOARD_ID_E39C:
>         case TQMX86_REG_BOARD_ID_E39x:
> @@ -152,7 +149,7 @@ static int tqmx86_board_id_to_clk_rate(u8 board_id)
>         case TQMX86_REG_BOARD_ID_E38C:
>                 return 33000;
>         default:
> -               return 0;
> +               return 24000;

AFAICS it will return 24 MHz for "Unknown" board. Is it okay to be so brave?

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: (EXT) Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
  2021-03-31 12:36     ` (EXT) " Matthias Schiffer
@ 2021-03-31 12:39       ` Andy Shevchenko
  2021-03-31 13:36         ` Matthias Schiffer
  0 siblings, 1 reply; 20+ messages in thread
From: Andy Shevchenko @ 2021-03-31 12:39 UTC (permalink / raw)
  To: Matthias Schiffer
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, Mar 31, 2021 at 3:37 PM Matthias Schiffer
<matthias.schiffer@ew.tq-group.com> wrote:
> On Wed, 2021-03-31 at 15:29 +0300, Andy Shevchenko wrote:
> > On Wed, Mar 31, 2021 at 2:37 PM Matthias Schiffer
> > <matthias.schiffer@ew.tq-group.com> wrote:

...

> > > -       irq = platform_get_irq(pdev, 0);
> > > -       if (irq < 0)
> > > +       irq = platform_get_irq_optional(pdev, 0);
> > > +       if (irq < 0 && irq != -ENXIO)
> > >                 return irq;
> >
> > This is a dead code now. I suggest you to do the opposite, i.e.
> > if (irq < 0)
> >   irq = 0;
>
> I don't understand which part of the code is dead now. I assume the
> `return irq` case is still useful for unexpected errors, or things like
> EPROBE_DEFER? I'm not sure if EPROBE_DEFER is relevant for this driver,
> but just ignoring the error code completely doesn't seem right to me.

platform_get_irq() AFAIK won't ever return such a code.
So, basically your conditional is always false.

I would like to see the code path which makes my comment wrong.


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/3] mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set
  2021-03-31 12:35   ` Andy Shevchenko
@ 2021-03-31 13:24     ` Matthias Schiffer
  2021-03-31 14:10       ` Andy Shevchenko
  0 siblings, 1 reply; 20+ messages in thread
From: Matthias Schiffer @ 2021-03-31 13:24 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, 2021-03-31 at 15:35 +0300, Andy Shevchenko wrote:
> On Wed, Mar 31, 2021 at 2:39 PM Matthias Schiffer
> <matthias.schiffer@ew.tq-group.com> wrote:
> > 
> > The driver was registering IRQ 0 when no IRQ was set. This leads to
> > warnings with newer kernels.
> > 
> > Clear the resource flags, so no resource is registered at all in this
> > case.
> 
> ...
> 
> >                 /* Assumes the IRQ resource is first. */
> >                 tqmx_gpio_resources[0].start = gpio_irq;
> > +       } else {
> > +               tqmx_gpio_resources[0].flags = 0;
> 
> Please set IORESOURCE_DISABLED flag in the initial structure instead.

Is there any documentation for the correct usage of this flag? I think
I tried IORESOURCE_DISABLED originally, but it didn't have any effect
(platform_get_irq() ignored the flag and returned the resource
anyways). I might misremember though, I originally wrote the series
some time ago.


> 
> >         }
> 
> 


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M
  2021-03-31 12:37   ` Andy Shevchenko
@ 2021-03-31 13:33     ` Matthias Schiffer
  2021-03-31 14:11       ` Andy Shevchenko
  0 siblings, 1 reply; 20+ messages in thread
From: Matthias Schiffer @ 2021-03-31 13:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, 2021-03-31 at 15:37 +0300, Andy Shevchenko wrote:
> On Wed, Mar 31, 2021 at 2:38 PM Matthias Schiffer
> <matthias.schiffer@ew.tq-group.com> wrote:
> > 
> > All future TQMx86 SoMs will use a 24MHz LPC clock, so we can use that as
> > a default instead of listing each new module individually.
> 
> ...
> 
> >         case TQMX86_REG_BOARD_ID_90UC:
> >                 return "TQMx90UC";
> > +       case TQMX86_REG_BOARD_ID_E40M:
> > +               return "TQMxE40M";
> >         default:
> >                 return "Unknown";
> >         }
> > @@ -138,12 +141,6 @@ static const char *tqmx86_board_id_to_name(u8 board_id)
> >  static int tqmx86_board_id_to_clk_rate(u8 board_id)
> >  {
> >         switch (board_id) {
> > -       case TQMX86_REG_BOARD_ID_50UC:
> > -       case TQMX86_REG_BOARD_ID_60EB:
> > -       case TQMX86_REG_BOARD_ID_70EB:
> > -       case TQMX86_REG_BOARD_ID_80UC:
> > -       case TQMX86_REG_BOARD_ID_90UC:
> > -               return 24000;
> >         case TQMX86_REG_BOARD_ID_E39M:
> >         case TQMX86_REG_BOARD_ID_E39C:
> >         case TQMX86_REG_BOARD_ID_E39x:
> > @@ -152,7 +149,7 @@ static int tqmx86_board_id_to_clk_rate(u8 board_id)
> >         case TQMX86_REG_BOARD_ID_E38C:
> >                 return 33000;
> >         default:
> > -               return 0;
> > +               return 24000;
> 
> AFAICS it will return 24 MHz for "Unknown" board. Is it okay to be so brave?

As noted in the commit message, our hardware developers intend to use
24 MHz for all future x86 SoMs.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
  2021-03-31 12:39       ` Andy Shevchenko
@ 2021-03-31 13:36         ` Matthias Schiffer
  2021-03-31 14:03           ` Andy Shevchenko
  0 siblings, 1 reply; 20+ messages in thread
From: Matthias Schiffer @ 2021-03-31 13:36 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, 2021-03-31 at 15:39 +0300, Andy Shevchenko wrote:
> On Wed, Mar 31, 2021 at 3:37 PM Matthias Schiffer
> <matthias.schiffer@ew.tq-group.com> wrote:
> > On Wed, 2021-03-31 at 15:29 +0300, Andy Shevchenko wrote:
> > > On Wed, Mar 31, 2021 at 2:37 PM Matthias Schiffer
> > > <matthias.schiffer@ew.tq-group.com> wrote:
> 
> ...
> 
> > > > -       irq = platform_get_irq(pdev, 0);
> > > > -       if (irq < 0)
> > > > +       irq = platform_get_irq_optional(pdev, 0);
> > > > +       if (irq < 0 && irq != -ENXIO)
> > > >                 return irq;
> > > 
> > > This is a dead code now. I suggest you to do the opposite, i.e.
> > > if (irq < 0)
> > >   irq = 0;
> > 
> > I don't understand which part of the code is dead now. I assume the
> > `return irq` case is still useful for unexpected errors, or things like
> > EPROBE_DEFER? I'm not sure if EPROBE_DEFER is relevant for this driver,
> > but just ignoring the error code completely doesn't seem right to me.
> 
> platform_get_irq() AFAIK won't ever return such a code.
> So, basically your conditional is always false.
> 
> I would like to see the code path which makes my comment wrong.
> 

EPROBE_DEFER appears a few times in platform_get_irq_optional()
(drivers/base/platform.c), but it's possible that this is only relevant
for OF-based platforms and not x86.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
  2021-03-31 13:36         ` Matthias Schiffer
@ 2021-03-31 14:03           ` Andy Shevchenko
  2021-06-24 13:44             ` Matthias Schiffer
  0 siblings, 1 reply; 20+ messages in thread
From: Andy Shevchenko @ 2021-03-31 14:03 UTC (permalink / raw)
  To: Matthias Schiffer
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, Mar 31, 2021 at 4:36 PM Matthias Schiffer
<matthias.schiffer@ew.tq-group.com> wrote:
>
> On Wed, 2021-03-31 at 15:39 +0300, Andy Shevchenko wrote:
> > On Wed, Mar 31, 2021 at 3:37 PM Matthias Schiffer
> > <matthias.schiffer@ew.tq-group.com> wrote:
> > > On Wed, 2021-03-31 at 15:29 +0300, Andy Shevchenko wrote:

...

> > > I don't understand which part of the code is dead now. I assume the
> > > `return irq` case is still useful for unexpected errors, or things like
> > > EPROBE_DEFER? I'm not sure if EPROBE_DEFER is relevant for this driver,
> > > but just ignoring the error code completely doesn't seem right to me.
> >
> > platform_get_irq() AFAIK won't ever return such a code.
> > So, basically your conditional is always false.
> >
> > I would like to see the code path which makes my comment wrong.
> >
>
> EPROBE_DEFER appears a few times in platform_get_irq_optional()
> (drivers/base/platform.c), but it's possible that this is only relevant
> for OF-based platforms and not x86.

Ah, okay, that's something I haven't paid attention to.

So the root cause of the your case is platform_get_irq_optional|()
return code. I'm wondering why it can't return 0 instead of absent
IRQ? Perhaps you need to fix it instead of lurking into each caller.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/3] mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set
  2021-03-31 13:24     ` Matthias Schiffer
@ 2021-03-31 14:10       ` Andy Shevchenko
  0 siblings, 0 replies; 20+ messages in thread
From: Andy Shevchenko @ 2021-03-31 14:10 UTC (permalink / raw)
  To: Matthias Schiffer
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, Mar 31, 2021 at 4:24 PM Matthias Schiffer
<matthias.schiffer@ew.tq-group.com> wrote:
> On Wed, 2021-03-31 at 15:35 +0300, Andy Shevchenko wrote:
> > On Wed, Mar 31, 2021 at 2:39 PM Matthias Schiffer
> > <matthias.schiffer@ew.tq-group.com> wrote:

...

> > > +               tqmx_gpio_resources[0].flags = 0;
> >
> > Please set IORESOURCE_DISABLED flag in the initial structure instead.
>
> Is there any documentation for the correct usage of this flag? I think
> I tried IORESOURCE_DISABLED originally, but it didn't have any effect
> (platform_get_irq() ignored the flag and returned the resource
> anyways). I might misremember though, I originally wrote the series
> some time ago.

It seems this flag is used solely for ACPI / PNP resources...
Hmm... I dunno how platorm_get_irq*() should respect this flag. You
see, that in the ACPI branch it has been checked there.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M
  2021-03-31 13:33     ` Matthias Schiffer
@ 2021-03-31 14:11       ` Andy Shevchenko
  2021-04-01  8:04         ` Lee Jones
  0 siblings, 1 reply; 20+ messages in thread
From: Andy Shevchenko @ 2021-03-31 14:11 UTC (permalink / raw)
  To: Matthias Schiffer
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, Mar 31, 2021 at 4:33 PM Matthias Schiffer
<matthias.schiffer@ew.tq-group.com> wrote:
> On Wed, 2021-03-31 at 15:37 +0300, Andy Shevchenko wrote:
> > On Wed, Mar 31, 2021 at 2:38 PM Matthias Schiffer
> > <matthias.schiffer@ew.tq-group.com> wrote:

...

> > > +               return 24000;
> >
> > AFAICS it will return 24 MHz for "Unknown" board. Is it okay to be so brave?
>
> As noted in the commit message, our hardware developers intend to use
> 24 MHz for all future x86 SoMs.

What may go wrong in the future?.. (rhetorical question, obviously)

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M
  2021-03-31 14:11       ` Andy Shevchenko
@ 2021-04-01  8:04         ` Lee Jones
  2021-04-01  8:06           ` Matthias Schiffer
  0 siblings, 1 reply; 20+ messages in thread
From: Lee Jones @ 2021-04-01  8:04 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Matthias Schiffer, Linus Walleij, Bartosz Golaszewski,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, 31 Mar 2021, Andy Shevchenko wrote:

> On Wed, Mar 31, 2021 at 4:33 PM Matthias Schiffer
> <matthias.schiffer@ew.tq-group.com> wrote:
> > On Wed, 2021-03-31 at 15:37 +0300, Andy Shevchenko wrote:
> > > On Wed, Mar 31, 2021 at 2:38 PM Matthias Schiffer
> > > <matthias.schiffer@ew.tq-group.com> wrote:
> 
> ...
> 
> > > > +               return 24000;
> > >
> > > AFAICS it will return 24 MHz for "Unknown" board. Is it okay to be so brave?
> >
> > As noted in the commit message, our hardware developers intend to use
> > 24 MHz for all future x86 SoMs.
> 
> What may go wrong in the future?.. (rhetorical question, obviously)

My preference would be to be explicit.

Rather than support boards implicitly i.e. by accident.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M
  2021-04-01  8:04         ` Lee Jones
@ 2021-04-01  8:06           ` Matthias Schiffer
  0 siblings, 0 replies; 20+ messages in thread
From: Matthias Schiffer @ 2021-04-01  8:06 UTC (permalink / raw)
  To: Lee Jones, Andy Shevchenko
  Cc: Linus Walleij, Bartosz Golaszewski, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

On Thu, 2021-04-01 at 09:04 +0100, Lee Jones wrote:
> On Wed, 31 Mar 2021, Andy Shevchenko wrote:
> 
> > On Wed, Mar 31, 2021 at 4:33 PM Matthias Schiffer
> > <matthias.schiffer@ew.tq-group.com> wrote:
> > > On Wed, 2021-03-31 at 15:37 +0300, Andy Shevchenko wrote:
> > > > On Wed, Mar 31, 2021 at 2:38 PM Matthias Schiffer
> > > > <matthias.schiffer@ew.tq-group.com> wrote:
> > 
> > ...
> > 
> > > > > +               return 24000;
> > > > 
> > > > AFAICS it will return 24 MHz for "Unknown" board. Is it okay to be so brave?
> > > 
> > > As noted in the commit message, our hardware developers intend to use
> > > 24 MHz for all future x86 SoMs.
> > 
> > What may go wrong in the future?.. (rhetorical question, obviously)
> 
> My preference would be to be explicit.
> 
> Rather than support boards implicitly i.e. by accident.
> 

How about logging a warning for unknown boards, but still returning
24 MHz?


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
  2021-03-31 14:03           ` Andy Shevchenko
@ 2021-06-24 13:44             ` Matthias Schiffer
  2021-06-27  9:23               ` Andy Shevchenko
  0 siblings, 1 reply; 20+ messages in thread
From: Matthias Schiffer @ 2021-06-24 13:44 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Wed, 2021-03-31 at 17:03 +0300, Andy Shevchenko wrote:
> On Wed, Mar 31, 2021 at 4:36 PM Matthias Schiffer
> <matthias.schiffer@ew.tq-group.com> wrote:
> > 
> > On Wed, 2021-03-31 at 15:39 +0300, Andy Shevchenko wrote:
> > > On Wed, Mar 31, 2021 at 3:37 PM Matthias Schiffer
> > > <matthias.schiffer@ew.tq-group.com> wrote:
> > > > On Wed, 2021-03-31 at 15:29 +0300, Andy Shevchenko wrote:
> 
> ...
> 
> > > > I don't understand which part of the code is dead now. I assume the
> > > > `return irq` case is still useful for unexpected errors, or things like
> > > > EPROBE_DEFER? I'm not sure if EPROBE_DEFER is relevant for this driver,
> > > > but just ignoring the error code completely doesn't seem right to me.
> > > 
> > > platform_get_irq() AFAIK won't ever return such a code.
> > > So, basically your conditional is always false.
> > > 
> > > I would like to see the code path which makes my comment wrong.
> > > 
> > 
> > EPROBE_DEFER appears a few times in platform_get_irq_optional()
> > (drivers/base/platform.c), but it's possible that this is only relevant
> > for OF-based platforms and not x86.
> 
> Ah, okay, that's something I haven't paid attention to.
> 
> So the root cause of the your case is platform_get_irq_optional|()
> return code. I'm wondering why it can't return 0 instead of absent
> IRQ? Perhaps you need to fix it instead of lurking into each caller.
> 


Hi Andy,

what's the plan here? "driver core: platform: Make
platform_get_irq_optional() optional" had to be reverted because it
broke existing users of platform_get_irq_optional(). I'm not convinced
that a slightly more convenient API is worth going through the trouble
of fixing them all - I know we don't care much about out-of-tree
modules, but subtly changing the behaviour of such a function doesn't
seem like a good idea to me even if we review all in-tree users.

Should I just rebase my patches with the existing ENXIO handing (and
fix up the other issues that were noted), or do you intend to give the
platform_get_irq_optional() revamp another try?

Kind regards,
Matthias


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
  2021-06-24 13:44             ` Matthias Schiffer
@ 2021-06-27  9:23               ` Andy Shevchenko
  0 siblings, 0 replies; 20+ messages in thread
From: Andy Shevchenko @ 2021-06-27  9:23 UTC (permalink / raw)
  To: Matthias Schiffer
  Cc: Linus Walleij, Bartosz Golaszewski, Lee Jones,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List

On Thu, Jun 24, 2021 at 4:44 PM Matthias Schiffer
<matthias.schiffer@ew.tq-group.com> wrote:
> On Wed, 2021-03-31 at 17:03 +0300, Andy Shevchenko wrote:
> > On Wed, Mar 31, 2021 at 4:36 PM Matthias Schiffer
> > <matthias.schiffer@ew.tq-group.com> wrote:
> > > On Wed, 2021-03-31 at 15:39 +0300, Andy Shevchenko wrote:
> > > > On Wed, Mar 31, 2021 at 3:37 PM Matthias Schiffer
> > > > <matthias.schiffer@ew.tq-group.com> wrote:
> > > > > On Wed, 2021-03-31 at 15:29 +0300, Andy Shevchenko wrote:

...

> > > > > I don't understand which part of the code is dead now. I assume the
> > > > > `return irq` case is still useful for unexpected errors, or things like
> > > > > EPROBE_DEFER? I'm not sure if EPROBE_DEFER is relevant for this driver,
> > > > > but just ignoring the error code completely doesn't seem right to me.
> > > >
> > > > platform_get_irq() AFAIK won't ever return such a code.
> > > > So, basically your conditional is always false.
> > > >
> > > > I would like to see the code path which makes my comment wrong.
> > >
> > > EPROBE_DEFER appears a few times in platform_get_irq_optional()
> > > (drivers/base/platform.c), but it's possible that this is only relevant
> > > for OF-based platforms and not x86.
> >
> > Ah, okay, that's something I haven't paid attention to.
> >
> > So the root cause of the your case is platform_get_irq_optional|()
> > return code. I'm wondering why it can't return 0 instead of absent
> > IRQ? Perhaps you need to fix it instead of lurking into each caller.
>
> what's the plan here? "driver core: platform: Make
> platform_get_irq_optional() optional" had to be reverted because it
> broke existing users of platform_get_irq_optional(). I'm not convinced
> that a slightly more convenient API is worth going through the trouble
> of fixing them all - I know we don't care much about out-of-tree
> modules, but subtly changing the behaviour of such a function doesn't
> seem like a good idea to me even if we review all in-tree users.

Why? The problem with this function is either naming or semantics.
It should be fixed and that will require revisiting all current users anyway.

> Should I just rebase my patches with the existing ENXIO handing (and
> fix up the other issues that were noted), or do you intend to give the
> platform_get_irq_optional() revamp another try?

I do intend to give another try, but if you want to be independent of
that, just make sure that in any new / revisited user of
platform_get_irq_optional() the 0 is taken into consideration as an
optional case.


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2021-06-27  9:24 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 11:35 [PATCH 0/3] tqmx86: TQMxE40M support Matthias Schiffer
2021-03-31 11:35 ` [PATCH 1/3] gpio: tqmx86: really make IRQ optional Matthias Schiffer
2021-03-31 12:29   ` Andy Shevchenko
2021-03-31 12:36     ` (EXT) " Matthias Schiffer
2021-03-31 12:39       ` Andy Shevchenko
2021-03-31 13:36         ` Matthias Schiffer
2021-03-31 14:03           ` Andy Shevchenko
2021-06-24 13:44             ` Matthias Schiffer
2021-06-27  9:23               ` Andy Shevchenko
2021-03-31 12:30   ` Andy Shevchenko
2021-03-31 11:35 ` [PATCH 2/3] mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set Matthias Schiffer
2021-03-31 12:35   ` Andy Shevchenko
2021-03-31 13:24     ` Matthias Schiffer
2021-03-31 14:10       ` Andy Shevchenko
2021-03-31 11:35 ` [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M Matthias Schiffer
2021-03-31 12:37   ` Andy Shevchenko
2021-03-31 13:33     ` Matthias Schiffer
2021-03-31 14:11       ` Andy Shevchenko
2021-04-01  8:04         ` Lee Jones
2021-04-01  8:06           ` Matthias Schiffer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.