Skip to content

Commit

Permalink
MIPS: cevt-r4k: Don't call get_c0_compare_int if timer irq is installed
Browse files Browse the repository at this point in the history
[ Upstream commit 50f2b98 ]

This avoids warning:

[    0.118053] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:283

Caused by get_c0_compare_int on secondary CPU.

We also skipped saving IRQ number to struct clock_event_device *cd as
it's never used by clockevent core, as per comments it's only meant
for "non CPU local devices".

Reported-by: Serge Semin <[email protected]>
Closes: https://lore.kernel.org/linux-mips/6szkkqxpsw26zajwysdrwplpjvhl5abpnmxgu2xuj3dkzjnvsf@4daqrz4mf44k/
Signed-off-by: Jiaxun Yang <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Serge Semin <[email protected]>
Tested-by: Serge Semin <[email protected]>
Signed-off-by: Thomas Bogendoerfer <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
FlyGoat authored and gregkh committed Sep 12, 2024
1 parent d942e85 commit 32ee052
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions arch/mips/kernel/cevt-r4k.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,6 @@ int r4k_clockevent_init(void)
if (!c0_compare_int_usable())
return -ENXIO;

/*
* With vectored interrupts things are getting platform specific.
* get_c0_compare_int is a hook to allow a platform to return the
* interrupt number of its liking.
*/
irq = get_c0_compare_int();

cd = &per_cpu(mips_clockevent_device, cpu);

cd->name = "MIPS";
Expand All @@ -320,7 +313,6 @@ int r4k_clockevent_init(void)
min_delta = calculate_min_delta();

cd->rating = 300;
cd->irq = irq;
cd->cpumask = cpumask_of(cpu);
cd->set_next_event = mips_next_event;
cd->event_handler = mips_event_handler;
Expand All @@ -332,6 +324,13 @@ int r4k_clockevent_init(void)

cp0_timer_irq_installed = 1;

/*
* With vectored interrupts things are getting platform specific.
* get_c0_compare_int is a hook to allow a platform to return the
* interrupt number of its liking.
*/
irq = get_c0_compare_int();

if (request_irq(irq, c0_compare_interrupt, flags, "timer",
c0_compare_interrupt))
pr_err("Failed to request irq %d (timer)\n", irq);
Expand Down

0 comments on commit 32ee052

Please sign in to comment.