Commit 3995461c authored by Philippe Gerum's avatar Philippe Gerum
Browse files

evl/irq: fix SMP kernel boot on uniprocessor machine



We may be running a SMP kernel on a uniprocessor machine whose
interrupt controller supports no IPI. We should attempt to hook IPIs
only if the hardware can support multiple CPUs, otherwise it is
unneeded and poised to fail.
Signed-off-by: default avatarPhilippe Gerum <rpm@xenomai.org>
parent 54848cde
...@@ -719,6 +719,7 @@ static inline void leave_inband(struct evl_thread *root) ...@@ -719,6 +719,7 @@ static inline void leave_inband(struct evl_thread *root)
#endif #endif
} }
#ifdef CONFIG_SMP
/* oob stalled. */ /* oob stalled. */
static irqreturn_t oob_reschedule_interrupt(int irq, void *dev_id) static irqreturn_t oob_reschedule_interrupt(int irq, void *dev_id)
{ {
...@@ -728,6 +729,9 @@ static irqreturn_t oob_reschedule_interrupt(int irq, void *dev_id) ...@@ -728,6 +729,9 @@ static irqreturn_t oob_reschedule_interrupt(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
#else
#define oob_reschedule_interrupt NULL
#endif
static inline void set_next_running(struct evl_rq *rq, static inline void set_next_running(struct evl_rq *rq,
struct evl_thread *next) struct evl_thread *next)
...@@ -1347,7 +1351,8 @@ int __init evl_init_sched(void) ...@@ -1347,7 +1351,8 @@ int __init evl_init_sched(void)
init_rq(rq, cpu); init_rq(rq, cpu);
} }
if (IS_ENABLED(CONFIG_SMP)) { /* See comment about hooking TIMER_OOB_IPI. */
if (IS_ENABLED(CONFIG_SMP) && num_possible_cpus() > 1) {
ret = __request_percpu_irq(RESCHEDULE_OOB_IPI, ret = __request_percpu_irq(RESCHEDULE_OOB_IPI,
oob_reschedule_interrupt, oob_reschedule_interrupt,
IRQF_OOB, IRQF_OOB,
...@@ -1373,7 +1378,7 @@ void __init evl_cleanup_sched(void) ...@@ -1373,7 +1378,7 @@ void __init evl_cleanup_sched(void)
struct evl_rq *rq; struct evl_rq *rq;
int cpu; int cpu;
if (IS_ENABLED(CONFIG_SMP)) if (IS_ENABLED(CONFIG_SMP) && num_possible_cpus() > 1)
free_percpu_irq(RESCHEDULE_OOB_IPI, &evl_machine_cpudata); free_percpu_irq(RESCHEDULE_OOB_IPI, &evl_machine_cpudata);
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
......
...@@ -81,14 +81,14 @@ static int proxy_set_oneshot_stopped(struct clock_event_device *proxy_dev) ...@@ -81,14 +81,14 @@ static int proxy_set_oneshot_stopped(struct clock_event_device *proxy_dev)
} }
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static irqreturn_t clock_ipi_handler(int irq, void *dev_id) static irqreturn_t clock_ipi_handler(int irq, void *dev_id)
{ {
evl_core_tick(NULL); evl_core_tick(NULL);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
#else
#define clock_ipi_handler NULL
#endif #endif
static void setup_proxy(struct clock_proxy_device *dev) static void setup_proxy(struct clock_proxy_device *dev)
...@@ -108,14 +108,20 @@ int evl_enable_tick(void) ...@@ -108,14 +108,20 @@ int evl_enable_tick(void)
{ {
int ret; int ret;
#ifdef CONFIG_SMP /*
ret = __request_percpu_irq(TIMER_OOB_IPI, * We may be running a SMP kernel on a uniprocessor machine
clock_ipi_handler, * whose interrupt controller provides no IPI: attempt to hook
IRQF_OOB, "EVL timer IPI", * the timer IPI only if the hardware can support multiple
&evl_machine_cpudata); * CPUs.
if (ret) */
return ret; if (IS_ENABLED(CONFIG_SMP) && num_possible_cpus() > 1) {
#endif ret = __request_percpu_irq(TIMER_OOB_IPI,
clock_ipi_handler,
IRQF_OOB, "EVL timer IPI",
&evl_machine_cpudata);
if (ret)
return ret;
}
/* /*
* CAUTION: * CAUTION:
...@@ -129,11 +135,8 @@ int evl_enable_tick(void) ...@@ -129,11 +135,8 @@ int evl_enable_tick(void)
* device supports oneshot mode, or fails. * device supports oneshot mode, or fails.
*/ */
ret = tick_install_proxy(setup_proxy, &evl_oob_cpus); ret = tick_install_proxy(setup_proxy, &evl_oob_cpus);
if (ret) { if (ret && IS_ENABLED(CONFIG_SMP) && num_possible_cpus() > 1) {
#ifdef CONFIG_SMP free_percpu_irq(TIMER_OOB_IPI, &evl_machine_cpudata);
free_percpu_irq(TIMER_OOB_IPI,
&evl_machine_cpudata);
#endif
return ret; return ret;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment