Message ID | 20211009022023.3796472-10-f.fainelli@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Modular Broadcom irqchip drivers | expand |
On Sat, 09 Oct 2021 03:20:18 +0100, Florian Fainelli <f.fainelli@gmail.com> wrote: > > Provide the platform device mapping to the interrupt controller node to > the of_irq_init_cb_t callback such that drivers can make use of it. > > Reviewed-by: Rob Herring <robh@kernel.org> > Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> > --- > drivers/irqchip/irqchip.c | 2 +- > drivers/irqchip/qcom-pdc.c | 3 ++- > drivers/of/irq.c | 2 +- > include/linux/of_irq.h | 5 ++++- > 4 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c > index 3570f0a588c4..289784eefd00 100644 > --- a/drivers/irqchip/irqchip.c > +++ b/drivers/irqchip/irqchip.c > @@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev) > if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) > return -EPROBE_DEFER; > > - return irq_init_cb(np, par_np); > + return irq_init_cb(np, par_np, pdev); > } > EXPORT_SYMBOL_GPL(platform_irqchip_probe); > diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c > index 173e6520e06e..819a93360b96 100644 > --- a/drivers/irqchip/qcom-pdc.c > +++ b/drivers/irqchip/qcom-pdc.c > @@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np) > return 0; > } > > -static int qcom_pdc_init(struct device_node *node, struct device_node *parent) > +static int qcom_pdc_init(struct device_node *node, struct device_node *parent, > + struct platform_device *pdev) > { > struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain; > int ret; > diff --git a/drivers/of/irq.c b/drivers/of/irq.c > index 352e14b007e7..18f3f5c00c87 100644 > --- a/drivers/of/irq.c > +++ b/drivers/of/irq.c > @@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches) > desc->dev, > desc->dev, desc->interrupt_parent); > ret = desc->irq_init_cb(desc->dev, > - desc->interrupt_parent); > + desc->interrupt_parent, NULL); > if (ret) { > of_node_clear_flag(desc->dev, OF_POPULATED); > kfree(desc); > diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h > index aaf219bd0354..89acc8b089f0 100644 > --- a/include/linux/of_irq.h > +++ b/include/linux/of_irq.h > @@ -9,7 +9,10 @@ > #include <linux/ioport.h> > #include <linux/of.h> > > -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *); > +struct platform_device; > + > +typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *, > + struct platform_device *); Having added some type-checking to the IRQCHIP_MATCH() #definery, I end-up with warnings such as: In file included from ./include/linux/kernel.h:16, from drivers/irqchip/irq-bcm7038-l1.c:12: ./include/linux/minmax.h:20:28: warning: comparison of distinct pointer types lacks a cast 20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) | ^~ ./include/linux/irqchip.h:41:2: note: in expansion of macro ‘__typecheck’ 41 | __typecheck(typecheck_irq_init_cb, fn) ? fn : fn | ^~~~~~~~~~~ ./include/linux/irqchip.h:44:12: note: in expansion of macro ‘typecheck_irq_init_cb’ 44 | .data = typecheck_irq_init_cb(fn), }, | ^~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-bcm7038-l1.c:459:1: note: in expansion of macro ‘IRQCHIP_MATCH’ 459 | IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init) | ^~~~~~~~~~~~~ Clearly, you didn't update the drivers you just converted to IRQCHIP_MATCH(), and only fixed the QC driver. FWIW, I'm planning to take something like the hack below into the tree to detect this sort of stuff early. M. diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h index ccf32758ea85..146a9d80a6a2 100644 --- a/include/linux/irqchip.h +++ b/include/linux/irqchip.h @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev); #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \ static const struct of_device_id drv_name##_irqchip_match_table[] = { -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn }, +/* Undefined on purpose */ +int typecheck_irq_init_cb(struct device_node *, struct device_node *, + struct platform_device *); + +#define typecheck_irq_init_cb(fn) \ + __typecheck(typecheck_irq_init_cb, fn) ? fn : fn + +#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, \ + .data = typecheck_irq_init_cb(fn), }, #define IRQCHIP_PLATFORM_DRIVER_END(drv_name) \ {}, \
On 10/19/21 2:43 PM, Marc Zyngier wrote: > On Sat, 09 Oct 2021 03:20:18 +0100, > Florian Fainelli <f.fainelli@gmail.com> wrote: >> >> Provide the platform device mapping to the interrupt controller node to >> the of_irq_init_cb_t callback such that drivers can make use of it. >> >> Reviewed-by: Rob Herring <robh@kernel.org> >> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> >> --- >> drivers/irqchip/irqchip.c | 2 +- >> drivers/irqchip/qcom-pdc.c | 3 ++- >> drivers/of/irq.c | 2 +- >> include/linux/of_irq.h | 5 ++++- >> 4 files changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c >> index 3570f0a588c4..289784eefd00 100644 >> --- a/drivers/irqchip/irqchip.c >> +++ b/drivers/irqchip/irqchip.c >> @@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev) >> if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) >> return -EPROBE_DEFER; >> >> - return irq_init_cb(np, par_np); >> + return irq_init_cb(np, par_np, pdev); >> } >> EXPORT_SYMBOL_GPL(platform_irqchip_probe); >> diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c >> index 173e6520e06e..819a93360b96 100644 >> --- a/drivers/irqchip/qcom-pdc.c >> +++ b/drivers/irqchip/qcom-pdc.c >> @@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np) >> return 0; >> } >> >> -static int qcom_pdc_init(struct device_node *node, struct device_node *parent) >> +static int qcom_pdc_init(struct device_node *node, struct device_node *parent, >> + struct platform_device *pdev) >> { >> struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain; >> int ret; >> diff --git a/drivers/of/irq.c b/drivers/of/irq.c >> index 352e14b007e7..18f3f5c00c87 100644 >> --- a/drivers/of/irq.c >> +++ b/drivers/of/irq.c >> @@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches) >> desc->dev, >> desc->dev, desc->interrupt_parent); >> ret = desc->irq_init_cb(desc->dev, >> - desc->interrupt_parent); >> + desc->interrupt_parent, NULL); >> if (ret) { >> of_node_clear_flag(desc->dev, OF_POPULATED); >> kfree(desc); >> diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h >> index aaf219bd0354..89acc8b089f0 100644 >> --- a/include/linux/of_irq.h >> +++ b/include/linux/of_irq.h >> @@ -9,7 +9,10 @@ >> #include <linux/ioport.h> >> #include <linux/of.h> >> >> -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *); >> +struct platform_device; >> + >> +typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *, >> + struct platform_device *); > > Having added some type-checking to the IRQCHIP_MATCH() #definery, I > end-up with warnings such as: > > In file included from ./include/linux/kernel.h:16, > from drivers/irqchip/irq-bcm7038-l1.c:12: > ./include/linux/minmax.h:20:28: warning: comparison of distinct pointer types lacks a cast > 20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) > | ^~ > ./include/linux/irqchip.h:41:2: note: in expansion of macro ‘__typecheck’ > 41 | __typecheck(typecheck_irq_init_cb, fn) ? fn : fn > | ^~~~~~~~~~~ > ./include/linux/irqchip.h:44:12: note: in expansion of macro ‘typecheck_irq_init_cb’ > 44 | .data = typecheck_irq_init_cb(fn), }, > | ^~~~~~~~~~~~~~~~~~~~~ > drivers/irqchip/irq-bcm7038-l1.c:459:1: note: in expansion of macro ‘IRQCHIP_MATCH’ > 459 | IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init) > | ^~~~~~~~~~~~~ > > Clearly, you didn't update the drivers you just converted to > IRQCHIP_MATCH(), and only fixed the QC driver. Yes, I will re-order the patches a little bit and update the drivers as they are converted. > > FWIW, I'm planning to take something like the hack below into the tree > to detect this sort of stuff early. Sounds good, thanks!
On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote: > > On Sat, 09 Oct 2021 03:20:18 +0100, > Florian Fainelli <f.fainelli@gmail.com> wrote: > > > > Provide the platform device mapping to the interrupt controller node to > > the of_irq_init_cb_t callback such that drivers can make use of it. > > > > Reviewed-by: Rob Herring <robh@kernel.org> > > Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> > > --- > > drivers/irqchip/irqchip.c | 2 +- > > drivers/irqchip/qcom-pdc.c | 3 ++- > > drivers/of/irq.c | 2 +- > > include/linux/of_irq.h | 5 ++++- > > 4 files changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c > > index 3570f0a588c4..289784eefd00 100644 > > --- a/drivers/irqchip/irqchip.c > > +++ b/drivers/irqchip/irqchip.c > > @@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev) > > if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) > > return -EPROBE_DEFER; > > > > - return irq_init_cb(np, par_np); > > + return irq_init_cb(np, par_np, pdev); > > } > > EXPORT_SYMBOL_GPL(platform_irqchip_probe); > > diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c > > index 173e6520e06e..819a93360b96 100644 > > --- a/drivers/irqchip/qcom-pdc.c > > +++ b/drivers/irqchip/qcom-pdc.c > > @@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np) > > return 0; > > } > > > > -static int qcom_pdc_init(struct device_node *node, struct device_node *parent) > > +static int qcom_pdc_init(struct device_node *node, struct device_node *parent, > > + struct platform_device *pdev) > > { > > struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain; > > int ret; > > diff --git a/drivers/of/irq.c b/drivers/of/irq.c > > index 352e14b007e7..18f3f5c00c87 100644 > > --- a/drivers/of/irq.c > > +++ b/drivers/of/irq.c > > @@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches) > > desc->dev, > > desc->dev, desc->interrupt_parent); > > ret = desc->irq_init_cb(desc->dev, > > - desc->interrupt_parent); > > + desc->interrupt_parent, NULL); > > if (ret) { > > of_node_clear_flag(desc->dev, OF_POPULATED); > > kfree(desc); > > diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h > > index aaf219bd0354..89acc8b089f0 100644 > > --- a/include/linux/of_irq.h > > +++ b/include/linux/of_irq.h > > @@ -9,7 +9,10 @@ > > #include <linux/ioport.h> > > #include <linux/of.h> > > > > -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *); > > +struct platform_device; > > + > > +typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *, > > + struct platform_device *); > > Having added some type-checking to the IRQCHIP_MATCH() #definery, I > end-up with warnings such as: > > In file included from ./include/linux/kernel.h:16, > from drivers/irqchip/irq-bcm7038-l1.c:12: > ./include/linux/minmax.h:20:28: warning: comparison of distinct pointer types lacks a cast > 20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) > | ^~ > ./include/linux/irqchip.h:41:2: note: in expansion of macro ‘__typecheck’ > 41 | __typecheck(typecheck_irq_init_cb, fn) ? fn : fn > | ^~~~~~~~~~~ > ./include/linux/irqchip.h:44:12: note: in expansion of macro ‘typecheck_irq_init_cb’ > 44 | .data = typecheck_irq_init_cb(fn), }, > | ^~~~~~~~~~~~~~~~~~~~~ > drivers/irqchip/irq-bcm7038-l1.c:459:1: note: in expansion of macro ‘IRQCHIP_MATCH’ > 459 | IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init) > | ^~~~~~~~~~~~~ > > Clearly, you didn't update the drivers you just converted to > IRQCHIP_MATCH(), and only fixed the QC driver. > > FWIW, I'm planning to take something like the hack below into the tree > to detect this sort of stuff early. > > M. > > diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h > index ccf32758ea85..146a9d80a6a2 100644 > --- a/include/linux/irqchip.h > +++ b/include/linux/irqchip.h > @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev); > #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \ > static const struct of_device_id drv_name##_irqchip_match_table[] = { > > -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn }, > +/* Undefined on purpose */ > +int typecheck_irq_init_cb(struct device_node *, struct device_node *, > + struct platform_device *); > + > +#define typecheck_irq_init_cb(fn) \ > + __typecheck(typecheck_irq_init_cb, fn) ? fn : fn That's nice! Shouldn't it also be used for IRQCHIP_DECLARE? > +#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, \ > + .data = typecheck_irq_init_cb(fn), }, I was going to say I wasn't really a fan of IRQCHIP_MATCH given it had nothing irqchip specific about it, but you fixed that now... > > #define IRQCHIP_PLATFORM_DRIVER_END(drv_name) \ > {}, \ > > -- > Without deviation from the norm, progress is not possible.
On Tue, 19 Oct 2021 23:23:52 +0100, Rob Herring <robh@kernel.org> wrote: > > On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote: > > > > diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h > > index ccf32758ea85..146a9d80a6a2 100644 > > --- a/include/linux/irqchip.h > > +++ b/include/linux/irqchip.h > > @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev); > > #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \ > > static const struct of_device_id drv_name##_irqchip_match_table[] = { > > > > -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn }, > > +/* Undefined on purpose */ > > +int typecheck_irq_init_cb(struct device_node *, struct device_node *, > > + struct platform_device *); > > + > > +#define typecheck_irq_init_cb(fn) \ > > + __typecheck(typecheck_irq_init_cb, fn) ? fn : fn > > That's nice! Shouldn't it also be used for IRQCHIP_DECLARE? Absolutely. And enabling this shows that changing of_irq_init_cb_t breaks *all users* of IRQCHIP_DECLARE(). Not an acceptable outcome when we're at -rc5. Why can't the relevant drivers use of_find_device_by_node() instead? That would allow us to keep the status-quo on of_irq_init_cb_t. Thanks, M.
On 10/20/2021 1:24 AM, Marc Zyngier wrote: > On Tue, 19 Oct 2021 23:23:52 +0100, > Rob Herring <robh@kernel.org> wrote: >> >> On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote: >>> >>> diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h >>> index ccf32758ea85..146a9d80a6a2 100644 >>> --- a/include/linux/irqchip.h >>> +++ b/include/linux/irqchip.h >>> @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev); >>> #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \ >>> static const struct of_device_id drv_name##_irqchip_match_table[] = { >>> >>> -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn }, >>> +/* Undefined on purpose */ >>> +int typecheck_irq_init_cb(struct device_node *, struct device_node *, >>> + struct platform_device *); >>> + >>> +#define typecheck_irq_init_cb(fn) \ >>> + __typecheck(typecheck_irq_init_cb, fn) ? fn : fn >> >> That's nice! Shouldn't it also be used for IRQCHIP_DECLARE? > > Absolutely. And enabling this shows that changing of_irq_init_cb_t > breaks *all users* of IRQCHIP_DECLARE(). Not an acceptable outcome > when we're at -rc5. > > Why can't the relevant drivers use of_find_device_by_node() instead? > That would allow us to keep the status-quo on of_irq_init_cb_t. Rob had suggested several solutions, including using of_find_device_by_node(), however updating of_irq_init_cb_t was indicated to be the better way. I had intentionally not updated IRQCHIP_DECLARE() because it would ignore the 3rd argument we passed to it (platform_device *) so I thought. If I am spinning a v6 using of_find_device_by_node() would that be acceptable to you?
On Wed, 20 Oct 2021 16:14:07 +0100, Florian Fainelli <f.fainelli@gmail.com> wrote: > > > > On 10/20/2021 1:24 AM, Marc Zyngier wrote: > > On Tue, 19 Oct 2021 23:23:52 +0100, > > Rob Herring <robh@kernel.org> wrote: > >> > >> On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote: > >>> > >>> diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h > >>> index ccf32758ea85..146a9d80a6a2 100644 > >>> --- a/include/linux/irqchip.h > >>> +++ b/include/linux/irqchip.h > >>> @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev); > >>> #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \ > >>> static const struct of_device_id drv_name##_irqchip_match_table[] = { > >>> > >>> -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn }, > >>> +/* Undefined on purpose */ > >>> +int typecheck_irq_init_cb(struct device_node *, struct device_node *, > >>> + struct platform_device *); > >>> + > >>> +#define typecheck_irq_init_cb(fn) \ > >>> + __typecheck(typecheck_irq_init_cb, fn) ? fn : fn > >> > >> That's nice! Shouldn't it also be used for IRQCHIP_DECLARE? > > > > Absolutely. And enabling this shows that changing of_irq_init_cb_t > > breaks *all users* of IRQCHIP_DECLARE(). Not an acceptable outcome > > when we're at -rc5. > > > Why can't the relevant drivers use of_find_device_by_node() instead? > > That would allow us to keep the status-quo on of_irq_init_cb_t. > > Rob had suggested several solutions, including using > of_find_device_by_node(), however updating of_irq_init_cb_t was > indicated to be the better way. I had intentionally not updated > IRQCHIP_DECLARE() because it would ignore the 3rd argument we passed > to it (platform_device *) so I thought. In general, conflicting prototype always lead to the compiler legitimately screwing something up, and you are left with a pile of steaming crap to debug. So *no* to that sort of trick. > If I am spinning a v6 using of_find_device_by_node() would that be > acceptable to you? That'd be much better. Thanks, M.
diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c index 3570f0a588c4..289784eefd00 100644 --- a/drivers/irqchip/irqchip.c +++ b/drivers/irqchip/irqchip.c @@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev) if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) return -EPROBE_DEFER; - return irq_init_cb(np, par_np); + return irq_init_cb(np, par_np, pdev); } EXPORT_SYMBOL_GPL(platform_irqchip_probe); diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c index 173e6520e06e..819a93360b96 100644 --- a/drivers/irqchip/qcom-pdc.c +++ b/drivers/irqchip/qcom-pdc.c @@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np) return 0; } -static int qcom_pdc_init(struct device_node *node, struct device_node *parent) +static int qcom_pdc_init(struct device_node *node, struct device_node *parent, + struct platform_device *pdev) { struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain; int ret; diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 352e14b007e7..18f3f5c00c87 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches) desc->dev, desc->dev, desc->interrupt_parent); ret = desc->irq_init_cb(desc->dev, - desc->interrupt_parent); + desc->interrupt_parent, NULL); if (ret) { of_node_clear_flag(desc->dev, OF_POPULATED); kfree(desc); diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index aaf219bd0354..89acc8b089f0 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -9,7 +9,10 @@ #include <linux/ioport.h> #include <linux/of.h> -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *); +struct platform_device; + +typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *, + struct platform_device *); /* * Workarounds only applied to 32bit powermac machines