Fix the regression for the thunderx gpio
Subsystems (7)
cover Fix the regression for the thunderx gpio
Hi Linus,
Since the commit a7fc89f9d5fc ("gpio: thunderx: Switch to GPIOLIB_IRQCHIP"), the thunderx gpio doesn't work anymore. I noticed that you have submitted a patch [1] to fix the " irq_domain_push_irq: -22" error, but the kernel would panic after applying that fix because the hwirq passed to the msi irqdomain is still not correct. It seems that we need more codes to make the thunderx gpio work with the GPIOLIB_IRQCHIP. So I would prefer to revert the commit a7fc89f9d5fc first to make the thunderx gpio to work on the 5.4.x and 5.5 at least. We can then do more test for GPIOLIB_IRQCHIP switching (which the patch 2 ~ 4 do) before merging them.
[1] https://patchwork.ozlabs.org/patch/1210180/
Kevin Hao (4):
Revert "gpio: thunderx: Switch to GPIOLIB_IRQCHIP"
gpiolib: Add support for the irqdomain which doesn't use irq_fwspec as
arg
gpiolib: Add the support for the msi parent domain
gpio: thunderx: Switch to GPIOLIB_IRQCHIP
drivers/gpio/gpio-tegra186.c | 13 ++++++-- drivers/gpio/gpio-thunderx.c | 36 +++++++++++++++++++--- drivers/gpio/gpiolib.c | 51 ++++++++++++++++++++++---------- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 2 +- drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 2 +- include/linux/gpio/driver.h | 21 +++++-------- 6 files changed, 87 insertions(+), 38 deletions(-)
Signature · 1 line
2.14.4
PATCH 1/4 Revert "gpio: thunderx: Switch to GPIOLIB_IRQCHIP"
This reverts commit a7fc89f9d5fcc10a5474cfe555f5a9e5df8b0f1f because there are some bugs in this commit, and we don't have a simple way to fix these bugs. So revert this commit to make the thunderx gpio work on the stable kernel at least. We will switch to GPIOLIB_IRQCHIP for thunderx gpio by following patches.
--- drivers/gpio/Kconfig | 1 - drivers/gpio/gpio-thunderx.c | 163 ++++++++++++++++++++++++++++--------------- 2 files changed, 107 insertions(+), 57 deletions(-)
drivers/gpio/Kconfig +0 -1
@@ -571,7 +571,6 @@ config GPIO_THUNDERX tristate "Cavium ThunderX/OCTEON-TX GPIO" depends on ARCH_THUNDER || (64BIT && COMPILE_TEST) depends on PCI_MSI - select GPIOLIB_IRQCHIP select IRQ_DOMAIN_HIERARCHY select IRQ_FASTEOI_HIERARCHY_HANDLERS help
drivers/gpio/gpio-thunderx.c +107 -56
262 lines not on this page · raw message
Signature · 1 line
2.14.4
PATCH 2/4 gpiolib: Add support for the irqdomain which doesn't use irq_fwspec as arg
In reply to Kevin HaoSome gpio's parent irqdomain may not use the struct irq_fwspec as argument, such as msi irqdomain. So rename the callback populate_parent_fwspec() to populate_parent_alloc_arg() and make it allocate and populate the specific struct which is needed by the parent irqdomain.
--- drivers/gpio/gpio-tegra186.c | 13 ++++++--- drivers/gpio/gpiolib.c | 45 ++++++++++++++++++++------------ drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 2 +- drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 2 +- include/linux/gpio/driver.h | 21 ++++++--------- 5 files changed, 49 insertions(+), 34 deletions(-)
drivers/gpio/gpio-tegra186.c +10 -3
@@ -448,17 +448,24 @@ static int tegra186_gpio_irq_domain_translate(struct irq_domain *domain,return 0 ; } -static void tegra186_gpio_populate_parent_fwspec (struct gpio_chip *chip, -struct irq_fwspec *fwspec, +static void *tegra186_gpio_populate_parent_fwspec (struct gpio_chip *chip,unsigned int parent_hwirq,unsigned int parent_type) {struct tegra_gpio *gpio =gpiochip_get_data (chip); +struct irq_fwspec *fwspec; + fwspec =kmalloc (sizeof (*fwspec),GFP_KERNEL ); +if (!fwspec) +return NULL ; + + fwspec->fwnode = chip->irq.parent_domain->fwnode; fwspec->param_count =3 ; fwspec->param[0 ] = gpio->soc->instance; fwspec->param[1 ] = parent_hwirq; fwspec->param[2 ] = parent_type; + +return fwspec; } static int tegra186_gpio_child_to_parent_hwirq(struct gpio_chip *chip,
@@ -621,7 +628,7 @@ static int tegra186_gpio_probe(struct platform_device *pdev) irq->chip = &gpio->intc; irq->fwnode =of_node_to_fwnode (pdev->dev.of_node); irq->child_to_parent_hwirq = tegra186_gpio_child_to_parent_hwirq; - irq->populate_parent_fwspec = tegra186_gpio_populate_parent_fwspec; + irq->populate_parent_alloc_arg = tegra186_gpio_populate_parent_fwspec; irq->child_offset_to_irq = tegra186_gpio_child_offset_to_irq; irq->child_irq_domain_ops.translate = tegra186_gpio_irq_domain_translate; irq->handler = handle_simple_irq;
drivers/gpio/gpiolib.c +29 -16
94 lines not on this page · raw message
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +1 -1
@@ -1060,7 +1060,7 @@ static int pmic_gpio_probe(struct platform_device *pdev) girq->fwnode =of_node_to_fwnode (state->dev->of_node); girq->parent_domain = parent_domain; girq->child_to_parent_hwirq = pmic_gpio_child_to_parent_hwirq; - girq->populate_parent_fwspec = gpiochip_populate_parent_fwspec_fourcell; + girq->populate_parent_alloc_arg = gpiochip_populate_parent_fwspec_fourcell; girq->child_offset_to_irq = pmic_gpio_child_offset_to_irq; girq->child_irq_domain_ops.translate = pmic_gpio_domain_translate;
drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +1 -1
@@ -794,7 +794,7 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev) girq->fwnode =of_node_to_fwnode (pctrl->dev->of_node); girq->parent_domain = parent_domain; girq->child_to_parent_hwirq = pm8xxx_child_to_parent_hwirq; - girq->populate_parent_fwspec = gpiochip_populate_parent_fwspec_fourcell; + girq->populate_parent_alloc_arg = gpiochip_populate_parent_fwspec_fourcell; girq->child_offset_to_irq = pm8xxx_child_offset_to_irq; girq->child_irq_domain_ops.translate = pm8xxx_domain_translate;
include/linux/gpio/driver.h +8 -13
@@ -94,16 +94,15 @@ struct gpio_irq_chip { unsigned int *parent_type);/** -* @populate_parent_fwspec: +* @populate_parent_alloc_arg : * -* This optional callback populates the &struct irq_fwspec for the -* parent's IRQ domain. If this is not specified, then +* This optional callback allocates and populates the specific struct +* for the parent's IRQ domain. If this is not specified, then * &gpiochip_populate_parent_fwspec_twocell will be used. A four-cell * variant named &gpiochip_populate_parent_fwspec_fourcell is also * available. */ -void (*populate_parent_fwspec)(struct gpio_chip *chip, -struct irq_fwspec *fwspec, +void *(*populate_parent_alloc_arg)(struct gpio_chip *chip,unsigned int parent_hwirq,unsigned int parent_type);
@@ -537,26 +536,22 @@ struct bgpio_pdata {#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY -void gpiochip_populate_parent_fwspec_twocell (struct gpio_chip *chip, -struct irq_fwspec *fwspec, +void *gpiochip_populate_parent_fwspec_twocell (struct gpio_chip *chip,unsigned int parent_hwirq,unsigned int parent_type); -void gpiochip_populate_parent_fwspec_fourcell (struct gpio_chip *chip, -struct irq_fwspec *fwspec, +void *gpiochip_populate_parent_fwspec_fourcell (struct gpio_chip *chip,unsigned int parent_hwirq,unsigned int parent_type);#else -static inline void gpiochip_populate_parent_fwspec_twocell (struct gpio_chip *chip, -struct irq_fwspec *fwspec, +static inline void *gpiochip_populate_parent_fwspec_twocell (struct gpio_chip *chip,unsigned int parent_hwirq,unsigned int parent_type) { } -static inline void gpiochip_populate_parent_fwspec_fourcell (struct gpio_chip *chip, -struct irq_fwspec *fwspec, +static inline void *gpiochip_populate_parent_fwspec_fourcell (struct gpio_chip *chip,unsigned int parent_hwirq,unsigned int parent_type) {
Signature · 1 line
2.14.4
kbuild test robot
build botRe: [PATCH 2/4] gpiolib: Add support for the irqdomain which doesn't use irq_fwspec as arg
Thank you for the patch! Perhaps something to improve:
Hi Kevin,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on gpio/for-next]
[also build test WARNING on pinctrl/devel v5.5-rc6 next-20200110] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Kevin-Hao/Fix-the-regression-for-the-thunderx-gpio/20200114-164910 base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next config: m68k-m5475evb_defconfig (attached as .config) compiler: m68k-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag
All warnings (new ones prefixed by >>):
In file included from include/asm-generic/gpio.h:13:0,
from arch/m68k/include/asm/mcfgpio.h:12,
from arch/m68k/include/asm/gpio.h:14,
from include/linux/gpio.h:59,
from arch/m68k/coldfire/device.c:15:
include/linux/gpio/driver.h: In function 'gpiochip_populate_parent_fwspec_twocell':
>> include/linux/gpio/driver.h:552:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
include/linux/gpio/driver.h: In function 'gpiochip_populate_parent_fwspec_fourcell':
include/linux/gpio/driver.h:558:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^vim +552 include/linux/gpio/driver.h
fdd61a013a24f2 Linus Walleij 2019-08-08 547
cee429771459e7 Kevin Hao 2020-01-14 548 static inline void *gpiochip_populate_parent_fwspec_twocell(struct gpio_chip *chip,
fdd61a013a24f2 Linus Walleij 2019-08-08 549 unsigned int parent_hwirq,
fdd61a013a24f2 Linus Walleij 2019-08-08 550 unsigned int parent_type)
fdd61a013a24f2 Linus Walleij 2019-08-08 551 {fdd61a013a24f2 Linus Walleij 2019-08-08 @552 }fdd61a013a24f2 Linus Walleij 2019-08-08 553
:::::: The code at line 552 was first introduced by commit
:::::: fdd61a013a24f2699aec1a446f0168682b6f9ec4 gpio: Add support for hierarchical IRQ domains
:::::: TO: Linus Walleij <[email protected]> :::::: CC: Linus Walleij <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
PATCH 3/4 gpiolib: Add the support for the msi parent domain
In reply to Kevin HaoIf the gpio's parent irqdomain is a msi irqdomain, we should ignore the EEXIST error returned by the msi irqdomain because all the msi interrupts have already been allocated.
--- drivers/gpio/gpiolib.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpio/gpiolib.c +6 -0
@@ -2037,6 +2037,12 @@ static int gpiochip_hierarchy_irq_domain_alloc(struct irq_domain *d,chip_info (gc,"alloc_irqs_parent for %d parent hwirq %d\n" , irq, parent_hwirq); ret =irq_domain_alloc_irqs_parent (d, irq,1 , parent_arg); +/* +* If the parent irqdomain is msi, the interrupts have already +* been allocated, so the EEXIST is good. +*/ +if (irq_domain_is_msi (d->parent) && (ret == -EEXIST )) + ret =0 ;if (ret) chip_err(gc, "failed to allocate parent hwirq %d for hwirq %lu\n",
Signature · 1 line
2.14.4
PATCH 4/4 gpio: thunderx: Switch to GPIOLIB_IRQCHIP
In reply to Kevin HaoThe main parts of this patch are from commit a7fc89f9d5fc ("gpio:
thunderx: Switch to GPIOLIB_IRQCHIP") and patch [1]. And also adjust thunderx_gpio_child_to_parent_hwirq() and add thunderx_gpio_populate_parent_alloc_info() to make sure that the correct hwirq are passed to the parent msi irqdomain.
[1] https://patchwork.ozlabs.org/patch/1210180/
--- drivers/gpio/Kconfig | 1 + drivers/gpio/gpio-thunderx.c | 177 +++++++++++++++++++------------------------ 2 files changed, 78 insertions(+), 100 deletions(-)
drivers/gpio/Kconfig +1 -0
@@ -571,6 +571,7 @@ config GPIO_THUNDERX tristate "Cavium ThunderX/OCTEON-TX GPIO" depends on ARCH_THUNDER || (64BIT && COMPILE_TEST) depends on PCI_MSI + select GPIOLIB_IRQCHIP select IRQ_DOMAIN_HIERARCHY select IRQ_FASTEOI_HIERARCHY_HANDLERS help
drivers/gpio/gpio-thunderx.c +77 -100
287 lines not on this page · raw message
Signature · 1 line
2.14.4
Quoted 10 lines · Kevin Hao
Since the commit
a7fc89f9d5fc("gpio: thunderx: Switch toGPIOLIB_IRQCHIP"), the thunderx gpio doesn't work anymore. I noticed that you have submitted a patch [1] to fix the "irq_domain_push_irq: -22" error, but the kernel would panic after applying that fix because the hwirq passed to the msi irqdomain is still not correct. It seems that we need more codes to make the thunderx gpio work with theGPIOLIB_IRQCHIP. So I would prefer to revert the commita7fc89f9d5fcfirst to make the thunderx gpio to work on the 5.4.x and 5.5 at least. We can then do more test forGPIOLIB_IRQCHIPswitching (which the patch 2 ~ 4 do) before merging them.
Thanks a LOT Kevin, and I'm sorry for open coding and breaking this driver so much :/
I have applied all four patches for fixes.
Yours,
Linus Walleij
Quoted 14 lines · Linus Walleij
Quoted 10 lines · Kevin Hao
Since the commit
a7fc89f9d5fc("gpio: thunderx: Switch toGPIOLIB_IRQCHIP"), the thunderx gpio doesn't work anymore. I noticed that you have submitted a patch [1] to fix the "irq_domain_push_irq: -22" error, but the kernel would panic after applying that fix because the hwirq passed to the msi irqdomain is still not correct. It seems that we need more codes to make the thunderx gpio work with theGPIOLIB_IRQCHIP. So I would prefer to revert the commita7fc89f9d5fcfirst to make the thunderx gpio to work on the 5.4.x and 5.5 at least. We can then do more test forGPIOLIB_IRQCHIPswitching (which the patch 2 ~ 4 do) before merging them.
Quoted 5 lines
Thanks a LOT Kevin, and I'm sorry for open coding and breaking this driver so much :/
I have applied all four patches for fixes.
I'm running into an issue with thunderx-gpio when using a gpio as an interrupt with an mfd driver I'm working on[1]. The breakage appeared with 0d04d0c146786da42c6e68c7d2f09c956c5b5bd3 'gpio: thunderx: Use the default parent apis for {request,release}_resources'[2] and occurs when irq_chip_request_resources_parent() fails with -ENOSYS. Any ideas what happened here... It seems perhaps parent_data got lost?
1. https://patchwork.kernel.org/patch/11401555/
2. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/gpio/gpio-thunderx.c?id=0d04d0c146786da42c6e68c7d2f09c956c5b5bd3
Best regards,
Tim
Quoted 21 lines · Tim Harvey
Quoted 14 lines · Linus Walleij
Quoted 10 lines · Kevin Hao
Since the commit
a7fc89f9d5fc("gpio: thunderx: Switch toGPIOLIB_IRQCHIP"), the thunderx gpio doesn't work anymore. I noticed that you have submitted a patch [1] to fix the "irq_domain_push_irq: -22" error, but the kernel would panic after applying that fix because the hwirq passed to the msi irqdomain is still not correct. It seems that we need more codes to make the thunderx gpio work with theGPIOLIB_IRQCHIP. So I would prefer to revert the commita7fc89f9d5fcfirst to make the thunderx gpio to work on the 5.4.x and 5.5 at least. We can then do more test forGPIOLIB_IRQCHIPswitching (which the patch 2 ~ 4 do) before merging them.Quoted 5 lines
Thanks a LOT Kevin, and I'm sorry for open coding and breaking this driver so much :/
I have applied all four patches for fixes.
Quoted 6 lines
I'm running into an issue with thunderx-gpio when using a gpio as an interrupt with an mfd driver I'm working on[1]. The breakage appeared with
0d04d0c146786da42c6e68c7d2f09c956c5b5bd3'gpio: thunderx: Use the default parent apis for {request,release}_resources'[2] and occurs whenirq_chip_request_resources_parent()fails with-ENOSYS. Any ideas what happened here... It seems perhapsparent_datagot lost?
No, the parent_data doesn't get lost. The reason that -ENOSYS is returned is because the its_msi_irq_chip (the parent irq chip of thunderx-gpio) doesn't implement the .irq_request_resources callback. As you can see in the irq_chip_request_resources_parent() code:
int irq_chip_request_resources_parent(struct irq_data *data)
{
data = data->parent_data;
if (data->chip->irq_request_resources)
return data->chip->irq_request_resources(data);
return -ENOSYS;
}So the commit 0d04d0c14678 does change the logic of the original code and make the thunderx_gpio_irq_request_resources() return -ENOSYS in a normal case. But it doesn't matter now since the thunderx_gpio_irq_request_resources() has been dropped by the patches in this patch series. So your code should work with the latest code. Could you rebase your code and git it a try?
Thanks,
Kevin