From 0114391e0a3c7b8832a893e54c44c13b059af048 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Thu, 11 Oct 2012 15:44:34 +0200 Subject: [PATCH] L4Linux: fix IRQ save functions (fix #406) --- ports-foc/patches/l4lx_genode.patch | 4 ++-- ports-foc/src/lib/l4lx/include/linux.h | 8 ++++---- ports-foc/src/lib/l4lx/l4lx_irq.cc | 4 ++-- ports-foc/src/lib/l4lx/l4lx_task.cc | 5 +---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ports-foc/patches/l4lx_genode.patch b/ports-foc/patches/l4lx_genode.patch index 988163f05..8764c3cb6 100644 --- a/ports-foc/patches/l4lx_genode.patch +++ b/ports-foc/patches/l4lx_genode.patch @@ -514,11 +514,11 @@ Index: arch/l4/kernel/main.c +static spinlock_t migrate_lock; + -+void l4x_irq_save(unsigned long flags) { local_irq_save(flags); } ++void l4x_irq_save(unsigned long *flags) { local_irq_save(*flags); } +void l4x_irq_restore(unsigned long flags) { local_irq_restore(flags); } +unsigned long l4x_hz(void) { return HZ; } +int l4x_nr_irqs(void) { return NR_IRQS; } -+void l4x_migrate_lock(unsigned long flags) { spin_lock_irqsave(&migrate_lock, flags); } ++void l4x_migrate_lock(unsigned long *flags) { spin_lock_irqsave(&migrate_lock, *flags); } +void l4x_migrate_unlock(unsigned long flags) { spin_unlock_irqrestore(&migrate_lock, flags);} + +unsigned l4x_target_cpu(const struct cpumask *dest) diff --git a/ports-foc/src/lib/l4lx/include/linux.h b/ports-foc/src/lib/l4lx/include/linux.h index 1b59adadf..9fe7f09ec 100644 --- a/ports-foc/src/lib/l4lx/include/linux.h +++ b/ports-foc/src/lib/l4lx/include/linux.h @@ -22,9 +22,9 @@ extern "C" { #endif -FASTCALL void l4x_irq_save(unsigned long flags); +FASTCALL void l4x_irq_save(unsigned long *flags); FASTCALL void l4x_irq_restore(unsigned long flags); -FASTCALL void l4x_migrate_lock(unsigned long flags); +FASTCALL void l4x_migrate_lock(unsigned long *flags); FASTCALL void l4x_migrate_unlock(unsigned long flags); FASTCALL unsigned long l4x_hz(); FASTCALL int l4x_nr_irqs(void); @@ -35,7 +35,7 @@ FASTCALL void l4x_cpumask_copy(struct irq_data*, const struct cpumask*); #define IRQ_SAFE(x) do { \ unsigned long flags = 0; \ - l4x_irq_save(flags); \ + l4x_irq_save(&flags); \ x; \ l4x_irq_restore(flags); \ } while(0) @@ -56,7 +56,7 @@ namespace Linux { public: - Irq_guard() : _flags(0) { l4x_irq_save(_flags); } + Irq_guard() : _flags(0) { l4x_irq_save(&_flags); } ~Irq_guard() { l4x_irq_restore(_flags); } }; } diff --git a/ports-foc/src/lib/l4lx/l4lx_irq.cc b/ports-foc/src/lib/l4lx/l4lx_irq.cc index b5265b8ad..f82b939ae 100644 --- a/ports-foc/src/lib/l4lx/l4lx_irq.cc +++ b/ports-foc/src/lib/l4lx/l4lx_irq.cc @@ -107,7 +107,7 @@ void l4lx_irq_dev_enable(struct irq_data *data) if (DEBUG) PDBG("irq=%d cap=%lx", data->irq, p->irq_cap); - l4x_irq_save(flags); + l4x_irq_save(&flags); l4_msgtag_t ret = l4_irq_attach(p->irq_cap, data->irq << 2, l4x_cpu_thread_get_cap(p->cpu)); if (l4_error(ret)) @@ -165,7 +165,7 @@ int l4lx_irq_dev_set_affinity(struct irq_data *data, return 0; unsigned long flags; - l4x_migrate_lock(flags); + l4x_migrate_lock(&flags); { Linux::Irq_guard guard; diff --git a/ports-foc/src/lib/l4lx/l4lx_task.cc b/ports-foc/src/lib/l4lx/l4lx_task.cc index 01973e881..07cd48ccb 100644 --- a/ports-foc/src/lib/l4lx/l4lx_task.cc +++ b/ports-foc/src/lib/l4lx/l4lx_task.cc @@ -159,14 +159,11 @@ int l4lx_task_delete_task(l4_cap_idx_t task, unsigned option) { using namespace L4lx; - unsigned long flags = 0; - l4x_irq_save(flags); + Linux::Irq_guard guard; Task *entry = Env::env()->tasks()->find_by_ref(task); Env::env()->tasks()->remove(entry); destroy(Genode::env()->heap(), entry); - - l4x_irq_restore(flags); return 1; }