pinctrl: cherryview: fix issues caused by dynamic gpio irqs mapping
Subsystems (3)
PATCH 1/1 pinctrl: cherryview: fix issues caused by dynamic gpio irqs mapping
New GPIO IRQs are allocated and mapped dynamically by default when GPIO IRQ infrastructure is used by cherryview-pinctrl driver. This causes issues on some Intel platforms [1][2] with broken BIOS which hardcodes Linux IRQ numbers in their ACPI tables.
On such platforms cherryview-pinctrl driver should allocate and map all GPIO IRQs at probe time.
Side effect - "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n" can be seen at boot log.
NOTE. It still may fail if boot sequence will changed and some interrupt controller will be probed before cherryview-pinctrl which will shift Linux IRQ numbering (expected with CONFIG_SPARCE_IRQ enabled).
[1] https://bugzilla.kernel.org/show_bug.cgi?id=194945
[2] https://lkml.org/lkml/2017/9/28/153
--- drivers/pinctrl/intel/pinctrl-cherryview.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/pinctrl/intel/pinctrl-cherryview.c +13 -1
@@ -1577,6 +1577,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)struct gpio_chip *chip = &pctrl->chip;bool need_valid_mask = !dmi_check_system (chv_no_valid_mask);int ret, i, offset; +int irq_base; *chip = chv_gpio_chip;
@@ -1622,7 +1623,18 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)/* Clear all interrupts */ chv_writel (0xffff , pctrl->regs +CHV_INTSTAT ); - ret =gpiochip_irqchip_add (chip, &chv_gpio_irqchip,0 , +if (!need_valid_mask) { + irq_base =devm_irq_alloc_descs (pctrl->dev,-1 ,0 , + chip->ngpio,NUMA_NO_NODE ); +if (irq_base <0 ) { +dev_err (pctrl->dev,"Failed to allocate IRQ numbers\n" ); +return irq_base; + } + }else { + irq_base =0 ; + } + + ret =gpiochip_irqchip_add (chip, &chv_gpio_irqchip, irq_base, handle_bad_irq,IRQ_TYPE_NONE );if (ret) {dev_err (pctrl->dev,"failed to add IRQ chip\n" );
Signature · 1 line
2.10.1
Quoted 10 lines · Grygorii Strashko
New GPIO IRQs are allocated and mapped dynamically by default when GPIO IRQ infrastructure is used by cherryview-pinctrl driver. This causes issues on some Intel platforms [1][2] with broken BIOS which hardcodes Linux IRQ numbers in their ACPI tables.
On such platforms cherryview-pinctrl driver should allocate and map all GPIO IRQs at probe time.
Side effect - "Cannot allocateirq_descs@ IRQ%d, assuming pre-allocated\n" can be seen at boot log.
Quoted 6 lines
NOTE. It still may fail if boot sequence will changed and some interrupt controller will be probed before cherryview-pinctrl which will shift Linux IRQ numbering (expected with
CONFIG_SPARCE_IRQenabled).[1] https://bugzilla.kernel.org/show_bug.cgi?id=194945
[2] https://lkml.org/lkml/2017/9/28/153
Btw, you might want to use one of
Buglink:
Bugzilla:
Link:
tags.
Quoted 7 lines
Cc Andy Shevchenko <[email protected]>Cc Chris Gorman <[email protected]>Cc Mika Westerberg <[email protected]>Cc Heikki Krogerus <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reported-by Chris Gorman <[email protected]>Reported-by Mika Westerberg <[email protected]>
I'm not sure about this approach. It might be some other broken BIOS discovered with some other driver (like pinctrl-baytrail.c as an hypothetical example).
Alternative is to deselect SPARSE_IRQ (though it makes it non-usable in entire x86 world).
Quoted 38 lines
drivers/pinctrl/intel/pinctrl-cherryview.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/pinctrl/intel/pinctrl-cherryview.c +13
-2@@ -1577,6 +1577,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)struct gpio_chip *chip = &pctrl->chip;bool need_valid_mask = !dmi_check_system (chv_no_valid_mask);int ret, i, offset; +int irq_base; *chip = chv_gpio_chip;@@ -1622,7 +1623,18 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)/* Clear all interrupts */ chv_writel (0xffff , pctrl->regs +CHV_INTSTAT ); - ret =gpiochip_irqchip_add (chip, &chv_gpio_irqchip,0 , +if (!need_valid_mask) { + irq_base =devm_irq_alloc_descs (pctrl->dev,-1 ,0 , + chip->ngpio,NUMA_NO_NODE ); +if (irq_base <0 ) { +dev_err (pctrl->dev,"Failed to allocate IRQ numbers\n" ); +return irq_base; + } + }else { + irq_base =0 ; + } + + ret =gpiochip_irqchip_add (chip, &chv_gpio_irqchip, irq_base, handle_bad_irq,IRQ_TYPE_NONE );if (ret) {dev_err (pctrl->dev,"failed to add IRQ chip\n" ); --2.10.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 35 lines · Andy Shevchenko
Quoted 10 lines · Grygorii Strashko
New GPIO IRQs are allocated and mapped dynamically by default when GPIO IRQ infrastructure is used by cherryview-pinctrl driver. This causes issues on some Intel platforms [1][2] with broken BIOS which hardcodes Linux IRQ numbers in their ACPI tables.
On such platforms cherryview-pinctrl driver should allocate and map all GPIO IRQs at probe time.
Side effect - "Cannot allocateirq_descs@ IRQ%d, assuming pre-allocated\n" can be seen at boot log.Quoted 6 lines
NOTE. It still may fail if boot sequence will changed and some interrupt controller will be probed before cherryview-pinctrl which will shift Linux IRQ numbering (expected with
CONFIG_SPARCE_IRQenabled).[1] https://bugzilla.kernel.org/show_bug.cgi?id=194945
[2] https://lkml.org/lkml/2017/9/28/153Btw, you might want to use one of
Buglink:
Bugzilla:
Link:tags.
Quoted 7 lines
Cc Andy Shevchenko <[email protected]>Cc Chris Gorman <[email protected]>Cc Mika Westerberg <[email protected]>Cc Heikki Krogerus <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reported-by Chris Gorman <[email protected]>Reported-by Mika Westerberg <[email protected]>
Quoted 3 lines
I'm not sure about this approach. It might be some other broken BIOS discovered with some other driver (like
pinctrl-baytrail.cas an hypothetical example).
It can be made more safe by fixing gpio chip base irq numbers, but this info should be passed to drivers somehow. Of course, above note will be still valid
- as W/A, required IRQ ranges can be reserved very early during boot in platform code.
Quoted 3 lines
Alternative is to deselect
SPARSE_IRQ(though it makes it non-usable in entire x86 world).
:) nuke mix.
Quoted 42 lines
Quoted 39 lines
drivers/pinctrl/intel/pinctrl-cherryview.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/pinctrl/intel/pinctrl-cherryview.c +13
-2@@ -1577,6 +1577,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)struct gpio_chip *chip = &pctrl->chip;bool need_valid_mask = !dmi_check_system (chv_no_valid_mask);int ret, i, offset; +int irq_base; *chip = chv_gpio_chip;@@ -1622,7 +1623,18 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)/* Clear all interrupts */ chv_writel (0xffff , pctrl->regs +CHV_INTSTAT ); - ret =gpiochip_irqchip_add (chip, &chv_gpio_irqchip,0 , +if (!need_valid_mask) { + irq_base =devm_irq_alloc_descs (pctrl->dev,-1 ,0 , + chip->ngpio,NUMA_NO_NODE ); +if (irq_base <0 ) { +dev_err (pctrl->dev,"Failed to allocate IRQ numbers\n" ); +return irq_base; + } + }else { + irq_base =0 ; + } + + ret =gpiochip_irqchip_add (chip, &chv_gpio_irqchip, irq_base, handle_bad_irq,IRQ_TYPE_NONE );if (ret) {dev_err (pctrl->dev,"failed to add IRQ chip\n" ); --2.10.1
Signature · 2 lines
regards, -grygorii
Mika Westerberg
maintainerQuoted 3 lines · Andy Shevchenko
I'm not sure about this approach. It might be some other broken BIOS discovered with some other driver (like
pinctrl-baytrail.cas an hypothetical example).
Let's deal that separately if it ever happens.
Quoted 2 lines
Alternative is to deselect
SPARSE_IRQ(though it makes it non-usable in entire x86 world).
No way.
Mika Westerberg
maintainerQuoted 16 lines · Grygorii Strashko
New GPIO IRQs are allocated and mapped dynamically by default when GPIO IRQ infrastructure is used by cherryview-pinctrl driver. This causes issues on some Intel platforms [1][2] with broken BIOS which hardcodes Linux IRQ numbers in their ACPI tables.
On such platforms cherryview-pinctrl driver should allocate and map all GPIO IRQs at probe time.
Side effect - "Cannot allocateirq_descs@ IRQ%d, assuming pre-allocated\n" can be seen at boot log.NOTE. It still may fail if boot sequence will changed and some interrupt controller will be probed before cherryview-pinctrl which will shift Linux IRQ numbering (expected with
CONFIG_SPARCE_IRQenabled).[1] https://bugzilla.kernel.org/show_bug.cgi?id=194945
[2] https://lkml.org/lkml/2017/9/28/153
Quoted 7 lines
Cc Andy Shevchenko <[email protected]>Cc Chris Gorman <[email protected]>Cc Mika Westerberg <[email protected]>Cc Heikki Krogerus <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reported-by Chris Gorman <[email protected]>Reported-by Mika Westerberg <[email protected]>
Looks reasonable to me. Thanks for taking care of this!
Chris, can you try if this fixes the issue and provide your Tested-by?
Tested on 4.14.0-rc3 and this works for me.
Tested by: Chris Gorman <[email protected]>
Quoted 62 lines · Grygorii Strashko
New GPIO IRQs are allocated and mapped dynamically by default when GPIO IRQ infrastructure is used by cherryview-pinctrl driver. This causes issues on some Intel platforms [1][2] with broken BIOS which hardcodes Linux IRQ numbers in their ACPI tables.
On such platforms cherryview-pinctrl driver should allocate and map all GPIO IRQs at probe time.
Side effect - "Cannot allocateirq_descs@ IRQ%d, assuming pre-allocated\n" can be seen at boot log.NOTE. It still may fail if boot sequence will changed and some interrupt controller will be probed before cherryview-pinctrl which will shift Linux IRQ numbering (expected with
CONFIG_SPARCE_IRQenabled).[1] https://bugzilla.kernel.org/show_bug.cgi?id=194945
[2] https://lkml.org/lkml/2017/9/28/153Cc Andy Shevchenko <[email protected]>Cc Chris Gorman <[email protected]>Cc Mika Westerberg <[email protected]>Cc Heikki Krogerus <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reported-by Chris Gorman <[email protected]>Reported-by Mika Westerberg <[email protected]>--- drivers/pinctrl/intel/pinctrl-cherryview.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/pinctrl/intel/pinctrl-cherryview.c +13
-2@@ -1577,6 +1577,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)struct gpio_chip *chip = &pctrl->chip;bool need_valid_mask = !dmi_check_system (chv_no_valid_mask);int ret, i, offset; +int irq_base; *chip = chv_gpio_chip;@@ -1622,7 +1623,18 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)/* Clear all interrupts */ chv_writel (0xffff , pctrl->regs +CHV_INTSTAT ); - ret =gpiochip_irqchip_add (chip, &chv_gpio_irqchip,0 , +if (!need_valid_mask) { + irq_base =devm_irq_alloc_descs (pctrl->dev,-1 ,0 , + chip->ngpio,NUMA_NO_NODE ); +if (irq_base <0 ) { +dev_err (pctrl->dev,"Failed to allocate IRQ numbers\n" ); +return irq_base; + } + }else { + irq_base =0 ; + } + + ret =gpiochip_irqchip_add (chip, &chv_gpio_irqchip, irq_base, handle_bad_irq,IRQ_TYPE_NONE );if (ret) {dev_err (pctrl->dev,"failed to add IRQ chip\n" ); --2.10.1
Quoted 25 lines · Mika Westerberg
Quoted 16 lines · Grygorii Strashko
New GPIO IRQs are allocated and mapped dynamically by default when GPIO IRQ infrastructure is used by cherryview-pinctrl driver. This causes issues on some Intel platforms [1][2] with broken BIOS which hardcodes Linux IRQ numbers in their ACPI tables.
On such platforms cherryview-pinctrl driver should allocate and map all GPIO IRQs at probe time.
Side effect - "Cannot allocateirq_descs@ IRQ%d, assuming pre-allocated\n" can be seen at boot log.NOTE. It still may fail if boot sequence will changed and some interrupt controller will be probed before cherryview-pinctrl which will shift Linux IRQ numbering (expected with
CONFIG_SPARCE_IRQenabled).[1] https://bugzilla.kernel.org/show_bug.cgi?id=194945
[2] https://lkml.org/lkml/2017/9/28/153Quoted 7 lines
Cc Andy Shevchenko <[email protected]>Cc Chris Gorman <[email protected]>Cc Mika Westerberg <[email protected]>Cc Heikki Krogerus <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reported-by Chris Gorman <[email protected]>Reported-by Mika Westerberg <[email protected]>
Quoted 3 lines
Looks reasonable to me. Thanks for taking care of this!
Chris, can you try if this fixes the issue and provide your Tested-by?
Linus,
Chris gave his tested-by in another thread:
https://patchwork.kernel.org/patch/9985087/
Chris, please let me know if that was not your intention.
I'm fine with the patch as well,
I guess this requires stable tag because if I understand comments in that bug right, it affects the whole v4.13.
Chris Gorman
Tested-byHello all,
Apologies if you are receiving this acknowledgement a second time. I have tested this patch on an Intel_Strago chromebook (Acer cb3-532) and it works to enable the keyboard. I tested it on 4.14.0-rc3. Let me know if you want me to test the patch on the stable branch.
Quoted 44 lines · Mika Westerberg
Quoted 25 lines · Mika Westerberg
Quoted 16 lines · Grygorii Strashko
New GPIO IRQs are allocated and mapped dynamically by default when GPIO IRQ infrastructure is used by cherryview-pinctrl driver. This causes issues on some Intel platforms [1][2] with broken BIOS which hardcodes Linux IRQ numbers in their ACPI tables.
On such platforms cherryview-pinctrl driver should allocate and map all GPIO IRQs at probe time.
Side effect - "Cannot allocateirq_descs@ IRQ%d, assuming pre-allocated\n" can be seen at boot log.NOTE. It still may fail if boot sequence will changed and some interrupt controller will be probed before cherryview-pinctrl which will shift Linux IRQ numbering (expected with
CONFIG_SPARCE_IRQenabled).[1] https://bugzilla.kernel.org/show_bug.cgi?id=194945
[2] https://lkml.org/lkml/2017/9/28/153Quoted 7 lines
Cc Andy Shevchenko <[email protected]>Cc Chris Gorman <[email protected]>Cc Mika Westerberg <[email protected]>Cc Heikki Krogerus <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reported-by Chris Gorman <[email protected]>Reported-by Mika Westerberg <[email protected]>Quoted 3 lines
Looks reasonable to me. Thanks for taking care of this!
Chris, can you try if this fixes the issue and provide your Tested-by?
Linus,
Chris gave his tested-by in another thread:
https://patchwork.kernel.org/patch/9985087/
Chris, please let me know if that was not your intention.
I'm fine with the patch as well,
Acked-by Mika Westerberg <[email protected]>I guess this requires stable tag because if I understand comments in that bug right, it affects the whole v4.13.
Quoted 16 lines · Grygorii Strashko
New GPIO IRQs are allocated and mapped dynamically by default when GPIO IRQ infrastructure is used by cherryview-pinctrl driver. This causes issues on some Intel platforms [1][2] with broken BIOS which hardcodes Linux IRQ numbers in their ACPI tables.
On such platforms cherryview-pinctrl driver should allocate and map all GPIO IRQs at probe time.
Side effect - "Cannot allocateirq_descs@ IRQ%d, assuming pre-allocated\n" can be seen at boot log.NOTE. It still may fail if boot sequence will changed and some interrupt controller will be probed before cherryview-pinctrl which will shift Linux IRQ numbering (expected with
CONFIG_SPARCE_IRQenabled).[1] https://bugzilla.kernel.org/show_bug.cgi?id=194945
[2] https://lkml.org/lkml/2017/9/28/153
Quoted 7 lines
Cc Andy Shevchenko <[email protected]>Cc Chris Gorman <[email protected]>Cc Mika Westerberg <[email protected]>Cc Heikki Krogerus <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reported-by Chris Gorman <[email protected]>Reported-by Mika Westerberg <[email protected]>
OK patch applied for fixes.
But I'mm still very sceptical about this.
Look at the following (just from grep irq_base drivers/gpio/):
drivers/gpio/gpio-ml-ioh.c:
static int ioh_gpio_to_irq(struct gpio_chip *gpio, unsigned offset)
{
struct ioh_gpio *chip = gpiochip_get_data(gpio);
return chip->irq_base + offset;
}(...)
ch = irq - chip->irq_base;
if (irq <= chip->irq_base + 7) {
im_reg = &chip->reg->regs[chip->ch].im_0;
im_pos = ch;(...)
drivers/gpio/gpio-sta2x11.c:
static int gsta_gpio_to_irq(struct gpio_chip *gpio, unsigned offset)
{
struct gsta_gpio *chip = gpiochip_get_data(gpio);
return chip->irq_base + offset;
}(etc)
The thing is that the lines you deleted from gpiolib were the only thing ever assigning chip->irq_base. This patch, if performed properly should have removed the .irq_base field from struct gpio_chip altogether without regressions.
As it is not, anything using .irq_base is regressing.
Either you need to convince me you can quickfix all of these users, or we need to simply revert this change.
Yours,
Linus Walleij
Quoted 31 lines · Linus Walleij
Quoted 16 lines · Grygorii Strashko
New GPIO IRQs are allocated and mapped dynamically by default when GPIO IRQ infrastructure is used by cherryview-pinctrl driver. This causes issues on some Intel platforms [1][2] with broken BIOS which hardcodes Linux IRQ numbers in their ACPI tables.
On such platforms cherryview-pinctrl driver should allocate and map all GPIO IRQs at probe time.
Side effect - "Cannot allocateirq_descs@ IRQ%d, assuming pre-allocated\n" can be seen at boot log.NOTE. It still may fail if boot sequence will changed and some interrupt controller will be probed before cherryview-pinctrl which will shift Linux IRQ numbering (expected with
CONFIG_SPARCE_IRQenabled).[1] https://bugzilla.kernel.org/show_bug.cgi?id=194945
[2] https://lkml.org/lkml/2017/9/28/153Quoted 7 lines
Cc Andy Shevchenko <[email protected]>Cc Chris Gorman <[email protected]>Cc Mika Westerberg <[email protected]>Cc Heikki Krogerus <[email protected]>Signed-off-by Grygorii Strashko <[email protected]>Reported-by Chris Gorman <[email protected]>Reported-by Mika Westerberg <[email protected]>OK patch applied for fixes.
But I'mm still very sceptical about this.
Quoted 7 lines
Look at the following (just from grep
irq_basedrivers/gpio/):
drivers/gpio/gpio-ml-ioh.c:static int
ioh_gpio_to_irq(struct gpio_chip *gpio, unsigned offset){ struct ioh_gpio *chip = gpiochip_get_data(gpio);
It is ioh_gpio - not gpio_chip ;)
Quoted 9 lines
return chip->irq_base + offset; }(...)
ch = irq - chip->irq_base; if (irq <= chip->irq_base + 7) { im_reg = &chip->reg->regs[chip->ch].im_0; im_pos = ch;(...)
not an issue gpio-ml-ioh.c:ioh_gpio_probe()
irq_base = devm_irq_alloc_descs(&pdev->dev, -1, IOH_IRQ_BASE,
num_ports[j], NUMA_NO_NODE); ... chip->irq_base = irq_base;
Quoted 7 lines
drivers/gpio/gpio-sta2x11.c:static int
gsta_gpio_to_irq(struct gpio_chip *gpio, unsigned offset){ struct gsta_gpio *chip = gpiochip_get_data(gpio); return chip->irq_base + offset;
same. It is gsta_gpio - not gpio_chip ;)
Quoted 13 lines
}
(etc)
The thing is that the lines you deleted from gpiolib were the only thing ever assigning
chip->irq_base. This patch, if performed properly should have removed the .irq_base field from structgpio_chipaltogether without regressions.As it is not, anything using .irq_base is regressing.
Either you need to convince me you can quickfix all of these users, or we need to simply revert this change.
Signature · 2 lines
regards, -grygorii