Re: [PATCH 0/6] Kill setup_irq()
Hi Brian, On Fri, Mar 27, 2020 at 09:48:38PM -0500, Brian Cain wrote: > > Note 2: hexagon final image creation fails even w/o my patch > What's the nature of the failure in "Note 2"? drivers/base/firmware_loader/main.o: In function `fw_is_builtin_firmware': /devel/src/kernel6/drivers/base/firmware_loader/main.c:132:(.text+0xc8): relocation truncated to fit: R_HEX_16_X against symbol `__start_builtin_fw' defined in .modinfo section in .tmp_vmlinux1 Makefile:1077: recipe for target 'vmlinux' failed make: *** [vmlinux] Error 1 [ i had deleted the toolchain earlier, since you asked, download again & checked ] Regards afzal
[PATCH 0/6] Kill setup_irq()
Hi Thomas, As compared to the situation mentioned earlier[1], now powerpc patch is also in -next, and the pending ARM patches has been picked up by ARM SoC maintainers today and is expected to show up in next -next. All other subsytem patches has been picked by relevant maintainers & are already in -next except alpha, c6x, hexagon, unicore32 & sh. As it is the case, i am sending you patches for the above 5 architecture's plus the core removal patch. Status of 5 arch's: --- alpha: received ack from Matt Turner, build test success c6x:did receive ack from Mark Salter in v1, the final version (v3) was with minor changes, hence removed his ack & cc'ed him, build test success hexagon:build test success unicore32: couldn't get toolchain from kernel.org, 0day test robot or Segher's buildall sh: To compile the relevant changes sh64 compiler is required, couldn't get it from above mentioned 3 sources. Note 1: sh toolchain is available, but that will not make the relevant changes compile as it has dependency of 64bit arch toolchain, did try a Kconfig hack to make it compile w/ 32bit sh toolchain, but it failed due to other reasons (unknown operands), so gave up on that. Note 2: hexagon final image creation fails even w/o my patch, but it has been ensured that w/ my changes relevant object files are getting built w/o warnings. Regards afzal [1] https://lkml.kernel.org/r/20200321172626.GA6323@afzalpc afzal mohammed (6): alpha: Replace setup_irq() by request_irq() c6x: replace setup_irq() by request_irq() hexagon: replace setup_irq() by request_irq() sh: replace setup_irq() by request_irq() unicore32: replace setup_irq() by request_irq() genirq: Remove setup_irq() and remove_irq() arch/alpha/kernel/irq_alpha.c | 29 arch/alpha/kernel/irq_i8259.c | 8 ++ arch/alpha/kernel/irq_impl.h | 7 + arch/alpha/kernel/irq_pyxis.c | 3 ++- arch/alpha/kernel/sys_alcor.c | 3 ++- arch/alpha/kernel/sys_cabriolet.c | 3 ++- arch/alpha/kernel/sys_eb64p.c | 3 ++- arch/alpha/kernel/sys_marvel.c| 2 +- arch/alpha/kernel/sys_miata.c | 6 +++-- arch/alpha/kernel/sys_ruffian.c | 3 ++- arch/alpha/kernel/sys_rx164.c | 3 ++- arch/alpha/kernel/sys_sx164.c | 3 ++- arch/alpha/kernel/sys_wildfire.c | 7 ++--- arch/alpha/kernel/time.c | 6 ++--- arch/c6x/platforms/timer64.c | 11 +++- arch/hexagon/kernel/smp.c | 22 arch/hexagon/kernel/time.c| 11 +++- arch/sh/boards/mach-cayman/irq.c | 18 + arch/sh/drivers/dma/dma-pvr2.c| 9 +++ arch/unicore32/kernel/time.c | 11 +++- include/linux/irq.h | 2 -- kernel/irq/manage.c | 44 --- 22 files changed, 60 insertions(+), 154 deletions(-) -- 2.25.1
Re: [PATCH v4] powerpc: Replace setup_irq() by request_irq()
Hi Michael Ellerman, On Thu, Mar 12, 2020 at 12:12:55PM +0530, afzal mohammed wrote: > request_irq() is preferred over setup_irq(). Invocations of setup_irq() > occur after memory allocators are ready. > > Per tglx[1], setup_irq() existed in olden days when allocators were not > ready by the time early interrupts were initialized. > > Hence replace setup_irq() by request_irq(). > > [1] https://lkml.kernel.org/r/alpine.DEB.2.20.1710191609480.1971@nanos > > Signed-off-by: afzal mohammed This patch is seen in next-test branch for last 4-5 days, i don't know exactly how powerpc workflow happens, so a question - this would be appear in linux-next soon right ? (for last 4-5 days i had been daily checking -next, but not appearing there). Sorry for the query for this trivial patch, i am asking because Thomas had mentioned [1] to get setup_irq() cleanup thr' respective maintainers (earlier it was part of tree-wide series), check -next after -rc6 & resubmit ignored ones to him, this patch is neither in -next, neither ignored, so i am at a loss what to do :( And i would prefer to let each patch go thr' respective maintainers so that only least patches has to be sent to Thomas. Bigger problem is that core removal patch of setup_irq() can be sent to him only after making sure that it's tree-wide usage has been removed. Regards afzal [1] https://lkml.kernel.org/r/87y2somido@nanos.tec.linutronix.de
Re: [PATCH 00/18] genirq: Remove setup_irq()
Hi Thomas, On Thu, Feb 27, 2020 at 04:37:13PM +0530, afzal mohammed wrote: > On Thu, Feb 27, 2020 at 11:31:15AM +0100, Thomas Gleixner wrote: > > Vs. merging this series, I suggest the following approach: > > > >- Resubmit the individual changes as single patches or small series > > to the relevant maintainers and subsystem mailing lists. They have > > no dependency on a core change and can be applied where they belong > > to. > > > >- After 5.6-rc6, verify which parts have made their way into > > linux-next and resubmit the ignored ones as a series to me along > > with the removal of the core parts. > > > > That way we can avoid conflicting changes between subsystems and the tip > > irq/core branch as much as possible. > > Okay, i will do accordingly. i am on it, is delayed due to the reason as mentioned at, https://lkml.kernel.org/r/20200321172626.GA6323@afzalpc [ not repeating contents here since other mail was sent just now, cc'ing you ] Regards afzal
[PATCH v4] powerpc: Replace setup_irq() by request_irq()
request_irq() is preferred over setup_irq(). Invocations of setup_irq() occur after memory allocators are ready. Per tglx[1], setup_irq() existed in olden days when allocators were not ready by the time early interrupts were initialized. Hence replace setup_irq() by request_irq(). [1] https://lkml.kernel.org/r/alpine.DEB.2.20.1710191609480.1971@nanos Signed-off-by: afzal mohammed --- v4: * pass non-NULL dev_id while requesting shared irq in mpc85xx_cds.c, as request_irq() can fail due to sanity check, which is not done in setup_irq() v3: * Split out from tree wide series, as Thomas suggested to get it thr' respective maintainers * Modify pr_err displayed in case of error * Re-arrange code & choose pr_err args as required to improve readability * Remove irrelevant parts from commit message & improve v2: * Replace pr_err("request_irq() on %s failed" by pr_err("%s: request_irq() failed" * Commit message massage arch/powerpc/platforms/85xx/mpc85xx_cds.c | 11 - arch/powerpc/platforms/8xx/cpm1.c | 9 ++- arch/powerpc/platforms/8xx/m8xx_setup.c | 9 ++- arch/powerpc/platforms/chrp/setup.c | 14 --- arch/powerpc/platforms/powermac/pic.c | 29 +-- arch/powerpc/platforms/powermac/smp.c | 12 -- 6 files changed, 29 insertions(+), 55 deletions(-) diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c index 6b1436abe9b1..915ab6710b93 100644 --- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c +++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c @@ -218,12 +218,6 @@ static irqreturn_t mpc85xx_8259_cascade_action(int irq, void *dev_id) { return IRQ_HANDLED; } - -static struct irqaction mpc85xxcds_8259_irqaction = { - .handler = mpc85xx_8259_cascade_action, - .flags = IRQF_SHARED | IRQF_NO_THREAD, - .name = "8259 cascade", -}; #endif /* PPC_I8259 */ #endif /* CONFIG_PCI */ @@ -271,7 +265,10 @@ static int mpc85xx_cds_8259_attach(void) * disabled when the last user of the shared IRQ line frees their * interrupt. */ - if ((ret = setup_irq(cascade_irq, _8259_irqaction))) { + ret = request_irq(cascade_irq, mpc85xx_8259_cascade_action, + IRQF_SHARED | IRQF_NO_THREAD, "8259 cascade", + cascade_node); + if (ret) { printk(KERN_ERR "Failed to setup cascade interrupt\n"); return ret; } diff --git a/arch/powerpc/platforms/8xx/cpm1.c b/arch/powerpc/platforms/8xx/cpm1.c index a43ee7d1ff85..4db4ca2e1222 100644 --- a/arch/powerpc/platforms/8xx/cpm1.c +++ b/arch/powerpc/platforms/8xx/cpm1.c @@ -120,12 +120,6 @@ static irqreturn_t cpm_error_interrupt(int irq, void *dev) return IRQ_HANDLED; } -static struct irqaction cpm_error_irqaction = { - .handler = cpm_error_interrupt, - .flags = IRQF_NO_THREAD, - .name = "error", -}; - static const struct irq_domain_ops cpm_pic_host_ops = { .map = cpm_pic_host_map, }; @@ -187,7 +181,8 @@ unsigned int __init cpm_pic_init(void) if (!eirq) goto end; - if (setup_irq(eirq, _error_irqaction)) + if (request_irq(eirq, cpm_error_interrupt, IRQF_NO_THREAD, "error", + NULL)) printk(KERN_ERR "Could not allocate CPM error IRQ!"); setbits32(_reg->cpic_cicr, CICR_IEN); diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c index f1c805c8adbc..df4d57d07f9a 100644 --- a/arch/powerpc/platforms/8xx/m8xx_setup.c +++ b/arch/powerpc/platforms/8xx/m8xx_setup.c @@ -39,12 +39,6 @@ static irqreturn_t timebase_interrupt(int irq, void *dev) return IRQ_HANDLED; } -static struct irqaction tbint_irqaction = { - .handler = timebase_interrupt, - .flags = IRQF_NO_THREAD, - .name = "tbint", -}; - /* per-board overridable init_internal_rtc() function. */ void __init __attribute__ ((weak)) init_internal_rtc(void) @@ -157,7 +151,8 @@ void __init mpc8xx_calibrate_decr(void) (TBSCR_TBF | TBSCR_TBE)); immr_unmap(sys_tmr2); - if (setup_irq(virq, _irqaction)) + if (request_irq(virq, timebase_interrupt, IRQF_NO_THREAD, "tbint", + NULL)) panic("Could not allocate timer IRQ!"); } diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c index fcf6f2342ef4..8328cd5817b0 100644 --- a/arch/powerpc/platforms/chrp/setup.c +++ b/arch/powerpc/platforms/chrp/setup.c @@ -451,13 +451,6 @@ static void __init chrp_find_openpic(void) of_node_put(np); } -#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_XMON) -static struct irqa
[PATCH v3] powerpc: Replace setup_irq() by request_irq()
request_irq() is preferred over setup_irq(). Invocations of setup_irq() occur after memory allocators are ready. Per tglx[1], setup_irq() existed in olden days when allocators were not ready by the time early interrupts were initialized. Hence replace setup_irq() by request_irq(). [1] https://lkml.kernel.org/r/alpine.DEB.2.20.1710191609480.1971@nanos Signed-off-by: afzal mohammed --- Hi powerpc maintainers, if okay w/ this change, please consider taking it thr' your tree, else please let me know. Regards afzal Link to v2 & v1, [v2] https://lkml.kernel.org/r/cover.1582471508.git.afzal.mohd...@gmail.com [v1] https://lkml.kernel.org/r/cover.1581478323.git.afzal.mohd...@gmail.com v3: * Split out from tree wide series, as Thomas suggested to get it thr' respective maintainers * Modify pr_err displayed in case of error * Re-arrange code & choose pr_err args as required to improve readability * Remove irrelevant parts from commit message & improve v2: * Replace pr_err("request_irq() on %s failed" by pr_err("%s: request_irq() failed" * Commit message massage arch/powerpc/platforms/85xx/mpc85xx_cds.c | 10 +++- arch/powerpc/platforms/8xx/cpm1.c | 9 ++- arch/powerpc/platforms/8xx/m8xx_setup.c | 9 ++- arch/powerpc/platforms/chrp/setup.c | 14 --- arch/powerpc/platforms/powermac/pic.c | 29 +-- arch/powerpc/platforms/powermac/smp.c | 12 -- 6 files changed, 28 insertions(+), 55 deletions(-) diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c index 6b1436abe9b1..1c5598877d70 100644 --- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c +++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c @@ -218,12 +218,6 @@ static irqreturn_t mpc85xx_8259_cascade_action(int irq, void *dev_id) { return IRQ_HANDLED; } - -static struct irqaction mpc85xxcds_8259_irqaction = { - .handler = mpc85xx_8259_cascade_action, - .flags = IRQF_SHARED | IRQF_NO_THREAD, - .name = "8259 cascade", -}; #endif /* PPC_I8259 */ #endif /* CONFIG_PCI */ @@ -271,7 +265,9 @@ static int mpc85xx_cds_8259_attach(void) * disabled when the last user of the shared IRQ line frees their * interrupt. */ - if ((ret = setup_irq(cascade_irq, _8259_irqaction))) { + ret = request_irq(cascade_irq, mpc85xx_8259_cascade_action, + IRQF_SHARED | IRQF_NO_THREAD, "8259 cascade", NULL); + if (ret) { printk(KERN_ERR "Failed to setup cascade interrupt\n"); return ret; } diff --git a/arch/powerpc/platforms/8xx/cpm1.c b/arch/powerpc/platforms/8xx/cpm1.c index a43ee7d1ff85..4db4ca2e1222 100644 --- a/arch/powerpc/platforms/8xx/cpm1.c +++ b/arch/powerpc/platforms/8xx/cpm1.c @@ -120,12 +120,6 @@ static irqreturn_t cpm_error_interrupt(int irq, void *dev) return IRQ_HANDLED; } -static struct irqaction cpm_error_irqaction = { - .handler = cpm_error_interrupt, - .flags = IRQF_NO_THREAD, - .name = "error", -}; - static const struct irq_domain_ops cpm_pic_host_ops = { .map = cpm_pic_host_map, }; @@ -187,7 +181,8 @@ unsigned int __init cpm_pic_init(void) if (!eirq) goto end; - if (setup_irq(eirq, _error_irqaction)) + if (request_irq(eirq, cpm_error_interrupt, IRQF_NO_THREAD, "error", + NULL)) printk(KERN_ERR "Could not allocate CPM error IRQ!"); setbits32(_reg->cpic_cicr, CICR_IEN); diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c index f1c805c8adbc..df4d57d07f9a 100644 --- a/arch/powerpc/platforms/8xx/m8xx_setup.c +++ b/arch/powerpc/platforms/8xx/m8xx_setup.c @@ -39,12 +39,6 @@ static irqreturn_t timebase_interrupt(int irq, void *dev) return IRQ_HANDLED; } -static struct irqaction tbint_irqaction = { - .handler = timebase_interrupt, - .flags = IRQF_NO_THREAD, - .name = "tbint", -}; - /* per-board overridable init_internal_rtc() function. */ void __init __attribute__ ((weak)) init_internal_rtc(void) @@ -157,7 +151,8 @@ void __init mpc8xx_calibrate_decr(void) (TBSCR_TBF | TBSCR_TBE)); immr_unmap(sys_tmr2); - if (setup_irq(virq, _irqaction)) + if (request_irq(virq, timebase_interrupt, IRQF_NO_THREAD, "tbint", + NULL)) panic("Could not allocate timer IRQ!"); } diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c index fcf6f2342ef4..8328cd5817b0 100644 --- a/arch/powerpc/platforms/chrp/setup.c +++ b/arch/powerpc/platforms/chrp/setup.c @@ -451,13 +451,6 @@ static void __init chrp_find_openpic(void) of_node_put(np); } -#if defined(CO
Re: [PATCH 00/18] genirq: Remove setup_irq()
Hi Thomas, On Thu, Feb 27, 2020 at 11:31:15AM +0100, Thomas Gleixner wrote: > Vs. merging this series, I suggest the following approach: > >- Resubmit the individual changes as single patches or small series > to the relevant maintainers and subsystem mailing lists. They have > no dependency on a core change and can be applied where they belong > to. > >- After 5.6-rc6, verify which parts have made their way into > linux-next and resubmit the ignored ones as a series to me along > with the removal of the core parts. > > That way we can avoid conflicting changes between subsystems and the tip > irq/core branch as much as possible. Okay, i will do accordingly. [ your mail crossed my v3 (only one patch) posting ] Regards afzal
[PATCH v2 10/18] powerpc: Replace setup_irq() by request_irq()
request_irq() is preferred over setup_irq(). The early boot setup_irq() invocations happen either via 'init_IRQ()' or 'time_init()', while memory allocators are ready by 'mm_init()'. Per tglx[1], setup_irq() existed in olden days when allocators were not ready by the time early interrupts were initialized. Hence replace setup_irq() by request_irq(). Seldom remove_irq() usage has been observed coupled with setup_irq(), wherever that has been found, it too has been replaced by free_irq(). [1] https://lkml.kernel.org/r/alpine.DEB.2.20.1710191609480.1971@nanos Signed-off-by: afzal mohammed Tested-by: Christophe Leroy # for 8xx parts --- v2: * Replace pr_err("request_irq() on %s failed" by pr_err("%s: request_irq() failed" * Commit message massage arch/powerpc/platforms/85xx/mpc85xx_cds.c | 10 +++- arch/powerpc/platforms/8xx/cpm1.c | 9 ++- arch/powerpc/platforms/8xx/m8xx_setup.c | 9 ++- arch/powerpc/platforms/chrp/setup.c | 14 -- arch/powerpc/platforms/powermac/pic.c | 31 ++- arch/powerpc/platforms/powermac/smp.c | 9 ++- 6 files changed, 27 insertions(+), 55 deletions(-) diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c index 6b1436abe9b1..1c5598877d70 100644 --- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c +++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c @@ -218,12 +218,6 @@ static irqreturn_t mpc85xx_8259_cascade_action(int irq, void *dev_id) { return IRQ_HANDLED; } - -static struct irqaction mpc85xxcds_8259_irqaction = { - .handler = mpc85xx_8259_cascade_action, - .flags = IRQF_SHARED | IRQF_NO_THREAD, - .name = "8259 cascade", -}; #endif /* PPC_I8259 */ #endif /* CONFIG_PCI */ @@ -271,7 +265,9 @@ static int mpc85xx_cds_8259_attach(void) * disabled when the last user of the shared IRQ line frees their * interrupt. */ - if ((ret = setup_irq(cascade_irq, _8259_irqaction))) { + ret = request_irq(cascade_irq, mpc85xx_8259_cascade_action, + IRQF_SHARED | IRQF_NO_THREAD, "8259 cascade", NULL); + if (ret) { printk(KERN_ERR "Failed to setup cascade interrupt\n"); return ret; } diff --git a/arch/powerpc/platforms/8xx/cpm1.c b/arch/powerpc/platforms/8xx/cpm1.c index a43ee7d1ff85..4db4ca2e1222 100644 --- a/arch/powerpc/platforms/8xx/cpm1.c +++ b/arch/powerpc/platforms/8xx/cpm1.c @@ -120,12 +120,6 @@ static irqreturn_t cpm_error_interrupt(int irq, void *dev) return IRQ_HANDLED; } -static struct irqaction cpm_error_irqaction = { - .handler = cpm_error_interrupt, - .flags = IRQF_NO_THREAD, - .name = "error", -}; - static const struct irq_domain_ops cpm_pic_host_ops = { .map = cpm_pic_host_map, }; @@ -187,7 +181,8 @@ unsigned int __init cpm_pic_init(void) if (!eirq) goto end; - if (setup_irq(eirq, _error_irqaction)) + if (request_irq(eirq, cpm_error_interrupt, IRQF_NO_THREAD, "error", + NULL)) printk(KERN_ERR "Could not allocate CPM error IRQ!"); setbits32(_reg->cpic_cicr, CICR_IEN); diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c index f1c805c8adbc..df4d57d07f9a 100644 --- a/arch/powerpc/platforms/8xx/m8xx_setup.c +++ b/arch/powerpc/platforms/8xx/m8xx_setup.c @@ -39,12 +39,6 @@ static irqreturn_t timebase_interrupt(int irq, void *dev) return IRQ_HANDLED; } -static struct irqaction tbint_irqaction = { - .handler = timebase_interrupt, - .flags = IRQF_NO_THREAD, - .name = "tbint", -}; - /* per-board overridable init_internal_rtc() function. */ void __init __attribute__ ((weak)) init_internal_rtc(void) @@ -157,7 +151,8 @@ void __init mpc8xx_calibrate_decr(void) (TBSCR_TBF | TBSCR_TBE)); immr_unmap(sys_tmr2); - if (setup_irq(virq, _irqaction)) + if (request_irq(virq, timebase_interrupt, IRQF_NO_THREAD, "tbint", + NULL)) panic("Could not allocate timer IRQ!"); } diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c index fcf6f2342ef4..3f4e324f1d67 100644 --- a/arch/powerpc/platforms/chrp/setup.c +++ b/arch/powerpc/platforms/chrp/setup.c @@ -451,13 +451,6 @@ static void __init chrp_find_openpic(void) of_node_put(np); } -#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_XMON) -static struct irqaction xmon_irqaction = { - .handler = xmon_irq, - .name = "XMON break", -}; -#endif - static void __init chrp_find_8259(void) { struct device_node *np, *pic = NULL; @@ -541,8 +534,11 @@ static void __init chrp_init_
[PATCH v2 00/18] genirq: Remove setup_irq()
While trying to understand internals of irq handling, came across a thread [1] in which tglx was referring to avoid usage of setup_irq(). The early boot setup_irq() invocations happen either via 'init_IRQ()' or 'time_init()', while memory allocators are ready by 'mm_init()'. Hence instances of setup_irq() are replaced by request_irq() & setup_irq() [along with remove_irq()] definition deleted in the last patch. Seldom remove_irq() usage has been observed coupled with setup_irq(), wherever that has been found, it too has been replaced by free_irq(). Build & boot tested on ARM & x86_64 platforms (ensured that on the machines used for testing, modifications made in this series is being exercised at runtime) Much of the changes were created using Coccinelle with an intention to learn it. But not everything could be automated. Searching with 'git grep -n '\Wsetup_irq('' & avoiding the irrelevant ones, 153 invocation's of setup_irq() were found. 112 could be replaced w/ cocci, of which in a few files some desired hunks were missing or not as expected, these were fixed up manually. Also the remaining 41 had to be done manually. Although cocci could replace 112, because of line continue not happening at paranthesis for request_irq(), around 80 had to be manually aligned in the request_irq() statement. So though many changes could be automated, there are a considerable amount of manual changes, please review carefully especially mips & alpha. Usage of setup_percpu_irq() is untouched w/ this series. There are 2 checkpatch warning about usage of BUG(), they were already present w/ setup_irq(), status quo maintained. [1] https://lkml.kernel.org/r/alpine.DEB.2.20.1710191609480.1971@nanos Since changes from v1 are trivial as below, tags received has been applied to the relevant patches, if any objections, please shout. v2: * Replace pr_err("request_irq() on %s failed" by pr_err("%s: request_irq() failed" * m68k: remove now irrelevant comment separation comment lines * Commit message massage afzal mohammed (18): alpha: replace setup_irq() by request_irq() ARM: replace setup_irq() by request_irq() c6x: replace setup_irq() by request_irq() hexagon: replace setup_irq() by request_irq() ia64: replace setup_irq() by request_irq() m68k: Replace setup_irq() by request_irq() microblaze: Replace setup_irq() by request_irq() MIPS: Replace setup_irq() by request_irq() parisc: Replace setup_irq() by request_irq() powerpc: Replace setup_irq() by request_irq() s390: replace setup_irq() by request_irq() sh: replace setup_irq() by request_irq() unicore32: replace setup_irq() by request_irq() x86: Replace setup_irq() by request_irq() xtensa: replace setup_irq() by request_irq() clocksource: Replace setup_irq() by request_irq() irqchip: Replace setup_irq() by request_irq() genirq: Remove setup_irq() and remove_irq() arch/alpha/kernel/irq_alpha.c | 29 ++--- arch/alpha/kernel/irq_i8259.c | 8 +-- arch/alpha/kernel/irq_impl.h | 7 +-- arch/alpha/kernel/irq_pyxis.c | 3 +- arch/alpha/kernel/sys_alcor.c | 3 +- arch/alpha/kernel/sys_cabriolet.c | 3 +- arch/alpha/kernel/sys_eb64p.c | 3 +- arch/alpha/kernel/sys_marvel.c| 2 +- arch/alpha/kernel/sys_miata.c | 6 +- arch/alpha/kernel/sys_ruffian.c | 3 +- arch/alpha/kernel/sys_rx164.c | 3 +- arch/alpha/kernel/sys_sx164.c | 3 +- arch/alpha/kernel/sys_wildfire.c | 7 +-- arch/alpha/kernel/time.c | 6 +- arch/arm/mach-cns3xxx/core.c | 10 +--- arch/arm/mach-ebsa110/core.c | 10 +--- arch/arm/mach-ep93xx/timer-ep93xx.c | 12 ++-- arch/arm/mach-footbridge/dc21285-timer.c | 11 +--- arch/arm/mach-footbridge/isa-irq.c| 8 +-- arch/arm/mach-footbridge/isa-timer.c | 11 +--- arch/arm/mach-iop32x/time.c | 12 ++-- arch/arm/mach-mmp/time.c | 11 +--- arch/arm/mach-omap1/pm.c | 22 --- arch/arm/mach-omap1/time.c| 10 +--- arch/arm/mach-omap1/timer32k.c| 10 +--- arch/arm/mach-omap2/timer.c | 11 +--- arch/arm/mach-rpc/time.c | 8 +-- arch/arm/mach-spear/time.c| 9 +-- arch/arm/plat-orion/time.c| 10 +--- arch/c6x/platforms/timer64.c | 11 +--- arch/hexagon/kernel/smp.c | 17 +++--- arch/hexagon/kernel/time.c| 11 +--- arch/ia64/kernel/irq_ia64.c | 42 + arch/ia64/kernel/mca.c| 51 +--- arch/m68k/68000/timers.c | 11 +--- arch/m68k/coldfire/pit.c
[PATCH 10/18] powerpc: Replace setup_irq() by request_irq()
request_irq() is preferred over setup_irq(). Existing callers of setup_irq() reached mostly via 'init_IRQ()' & 'time_init()', while memory allocators are ready by 'mm_init()'. Per tglx[1], setup_irq() existed in olden days when allocators were not ready by the time early interrupts were initialized. Hence replace setup_irq() by request_irq(). Seldom remove_irq() usage has been observed coupled with setup_irq(), wherever that has been found, it too has been replaced by free_irq(). [1] https://lkml.kernel.org/r/alpine.DEB.2.20.1710191609480.1971@nanos Signed-off-by: afzal mohammed --- Since cc'ing cover letter to all maintainers/reviewers would be too many, refer for cover letter, https://lkml.kernel.org/r/cover.1581478323.git.afzal.mohd...@gmail.com arch/powerpc/platforms/85xx/mpc85xx_cds.c | 10 +++- arch/powerpc/platforms/8xx/cpm1.c | 9 ++- arch/powerpc/platforms/8xx/m8xx_setup.c | 9 ++- arch/powerpc/platforms/chrp/setup.c | 14 -- arch/powerpc/platforms/powermac/pic.c | 31 ++- arch/powerpc/platforms/powermac/smp.c | 9 ++- 6 files changed, 27 insertions(+), 55 deletions(-) diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c index 6b1436abe9b1..1c5598877d70 100644 --- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c +++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c @@ -218,12 +218,6 @@ static irqreturn_t mpc85xx_8259_cascade_action(int irq, void *dev_id) { return IRQ_HANDLED; } - -static struct irqaction mpc85xxcds_8259_irqaction = { - .handler = mpc85xx_8259_cascade_action, - .flags = IRQF_SHARED | IRQF_NO_THREAD, - .name = "8259 cascade", -}; #endif /* PPC_I8259 */ #endif /* CONFIG_PCI */ @@ -271,7 +265,9 @@ static int mpc85xx_cds_8259_attach(void) * disabled when the last user of the shared IRQ line frees their * interrupt. */ - if ((ret = setup_irq(cascade_irq, _8259_irqaction))) { + ret = request_irq(cascade_irq, mpc85xx_8259_cascade_action, + IRQF_SHARED | IRQF_NO_THREAD, "8259 cascade", NULL); + if (ret) { printk(KERN_ERR "Failed to setup cascade interrupt\n"); return ret; } diff --git a/arch/powerpc/platforms/8xx/cpm1.c b/arch/powerpc/platforms/8xx/cpm1.c index a43ee7d1ff85..4db4ca2e1222 100644 --- a/arch/powerpc/platforms/8xx/cpm1.c +++ b/arch/powerpc/platforms/8xx/cpm1.c @@ -120,12 +120,6 @@ static irqreturn_t cpm_error_interrupt(int irq, void *dev) return IRQ_HANDLED; } -static struct irqaction cpm_error_irqaction = { - .handler = cpm_error_interrupt, - .flags = IRQF_NO_THREAD, - .name = "error", -}; - static const struct irq_domain_ops cpm_pic_host_ops = { .map = cpm_pic_host_map, }; @@ -187,7 +181,8 @@ unsigned int __init cpm_pic_init(void) if (!eirq) goto end; - if (setup_irq(eirq, _error_irqaction)) + if (request_irq(eirq, cpm_error_interrupt, IRQF_NO_THREAD, "error", + NULL)) printk(KERN_ERR "Could not allocate CPM error IRQ!"); setbits32(_reg->cpic_cicr, CICR_IEN); diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c index f1c805c8adbc..df4d57d07f9a 100644 --- a/arch/powerpc/platforms/8xx/m8xx_setup.c +++ b/arch/powerpc/platforms/8xx/m8xx_setup.c @@ -39,12 +39,6 @@ static irqreturn_t timebase_interrupt(int irq, void *dev) return IRQ_HANDLED; } -static struct irqaction tbint_irqaction = { - .handler = timebase_interrupt, - .flags = IRQF_NO_THREAD, - .name = "tbint", -}; - /* per-board overridable init_internal_rtc() function. */ void __init __attribute__ ((weak)) init_internal_rtc(void) @@ -157,7 +151,8 @@ void __init mpc8xx_calibrate_decr(void) (TBSCR_TBF | TBSCR_TBE)); immr_unmap(sys_tmr2); - if (setup_irq(virq, _irqaction)) + if (request_irq(virq, timebase_interrupt, IRQF_NO_THREAD, "tbint", + NULL)) panic("Could not allocate timer IRQ!"); } diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c index fcf6f2342ef4..95ac1f510b1e 100644 --- a/arch/powerpc/platforms/chrp/setup.c +++ b/arch/powerpc/platforms/chrp/setup.c @@ -451,13 +451,6 @@ static void __init chrp_find_openpic(void) of_node_put(np); } -#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_XMON) -static struct irqaction xmon_irqaction = { - .handler = xmon_irq, - .name = "XMON break", -}; -#endif - static void __init chrp_find_8259(void) { struct device_node *np, *pic = NULL; @@ -541,8 +534,11 @@ static void __init chrp_init_IRQ(void)
[PATCH 00/18] genirq: Remove setup_irq()
While trying to understand internals of irq handling, came across a thread [1] in which tglx was referring to avoid usage of setup_irq(). Existing callers of setup_irq() reached mostly via 'init_IRQ()' & 'time_init()', while memory allocators are ready by 'mm_init()'. Hence instances of setup_irq() is replaced by request_irq() & setup_irq() (along with remove_irq()) definition deleted in the last patch. Seldom remove_irq() usage has been observed coupled with setup_irq(), wherever that has been found, it too has been replaced by free_irq(). Build & boot tested on ARM & x86_64 platforms (ensured that on the machines used for testing there was an existing setup_irq() invocation occuring at runtime) Much of the changes were created using Coccinelle with an intention to learn it. spatch command was directly run w/ semantic patch below. But not everything could be automated. Searching with 'git grep -n '\Wsetup_irq('' & avoiding the irrelevant ones, 153 invocation's of setup_irq() were found. 112 could be replaced w/ cocci, of which in a few files some desired hunks were missing or not as expected, these were fixed up manually. Also the remaining 41 had to be done manually. Although cocci could replace 112, because of line continue not happening at paranthesis for request_irq(), around 80 had to be manually aligned in the request_irq() statement. Problem was with my below cocci snippet, - setup_irq(E1,); + if (request_irq(E1,f_handler,f_flags,f_name,f_dev_id)) + pr_err("request_irq() on %s failed\n", f_name); Instead of the above, if below is used, line continue happens exactly at paranthesis, but it lacks addition of printing on request_irq() failure where existing setup_irq() failure was not doing it. - setup_irq(E1,) + request_irq(E1,f_handler,f_flags,f_name,f_dev_id) Above had an additional advantage of replacing instances of if (setup_irq()) & BUG(setup_irq()), but luckily those instances were very few. So though many changes could be automated, there are a considerable amount of manual changes, please review carefully especially mips & alpha. Usage of setup_percpu_irq() is untouched w/ this series. There are 2 checkpatch warning about usage of BUG() [which was already there w/ setup_irq()], they are left as is as it seems appropriate for tick timer interrupt. [1] https://lkml.kernel.org/r/alpine.DEB.2.20.1710191609480.1971@nanos --->8--- @r1@ identifier ret; @@ ( setup_irq(...); | ret = setup_irq(...); ) @r2 depends on r1@ identifier act; @@ static struct irqaction act = { }; @r11 depends on r2@ identifier r2.act; identifier f_handler; @@ ( - act.handler = f_handler; | static struct irqaction act = { .handler = f_handler, }; ) @r12 depends on r2@ identifier r2.act; expression f_name; @@ ( - act.name = f_name; | static struct irqaction act = { .name = f_name, }; ) @r15 depends on r2@ identifier r2.act; expression f_dev_id; @@ ( - act.dev_id = f_dev_id; | static struct irqaction act = { .dev_id = f_dev_id, }; ) @r16 depends on r2@ identifier r2.act; expression f_flags; @@ ( - act.flags = f_flags; | static struct irqaction act = { .flags = f_flags, }; ) @r21 depends on r2@ identifier r2.act; @@ - static struct irqaction act = { - ... - }; @r22 depends on r2 && r11 && r12 && r15 && r16@ identifier r2.act; identifier r11.f_handler; expression r12.f_name; expression r15.f_dev_id; expression r16.f_flags; expression E1; identifier ret; @@ ( - setup_irq(E1,); + if (request_irq(E1,f_handler,f_flags,f_name,f_dev_id)) + pr_err("request_irq() on %s failed\n", f_name); | - ret = setup_irq(E1,); + ret = request_irq(E1,f_handler,f_flags,f_name,f_dev_id); ) @r23 depends on r2 && r11 && r12 && !r15 && r16@ identifier r2.act; identifier r11.f_handler; expression r12.f_name; expression r16.f_flags; expression E1; identifier ret; @@ ( - setup_irq(E1,); + if (request_irq(E1,f_handler,f_flags,f_name,NULL)) + pr_err("request_irq() on %s failed\n", f_name); | - ret = setup_irq(E1,); + ret = request_irq(E1,f_handler,f_flags,f_name,NULL); ) @r24 depends on r2 && r11 && r12 && r15 && !r16@ identifier r2.act; identifier r11.f_handler; expression r12.f_name; expression r15.f_dev_id; expression E1; identifier ret; @@ ( - setup_irq(E1,); + if (request_irq(E1,f_handler,0,f_name,f_dev_id)) + pr_err("request_irq() on %s failed\n", f_name); | - ret = setup_irq(E1,); + ret = request_irq(E1,f_handler,0,f_name,f_dev_id); ) @r25 depends on r2 && r11 && r12 && !r15 && !r16@ identifier r2.act; identifier r11.f_handler; expression r12.f_name; expression E1; identifier ret; @@ ( - setup_irq(E1,); + if (request_irq(E1,f_handler,0,f_name,NULL)) + pr_err("request_irq() on %s failed\n", f_name); | - ret = setup_irq(E1,); + ret = request_irq(E1,f_handler,0,f_name,NULL); ) -