From: Jan Kiszka <jan.kiszka@siemens.com>
To: Xenomai <xenomai@xenomai.org>
Subject: [Xenomai] [PATCH v2] nucleus: Convert intrlock to a sleeping Linux lock
Date: Thu, 18 Oct 2012 19:40:49 +0200 [thread overview]
Message-ID: <50803F21.5020205@siemens.com> (raw)
In-Reply-To: <507E9424.8060800@siemens.com>
All users of this lock are supposed to run over Linux context already.
Moreover, latest I-pipe patches complain that ipipe_virtualize_irq is
called with the Xenomai domain stalled which invalidates that useful
internal bug check. So convert this lock to a sleeping Linux variant to
avoid the alarm.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
Changes in v2:
- Improved commit message, no code changes
ksrc/nucleus/intr.c | 22 +++++++++-------------
1 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/ksrc/nucleus/intr.c b/ksrc/nucleus/intr.c
index c75fcac..4747de1 100644
--- a/ksrc/nucleus/intr.c
+++ b/ksrc/nucleus/intr.c
@@ -39,7 +39,7 @@
#define XNINTR_MAX_UNHANDLED 1000
-DEFINE_PRIVATE_XNLOCK(intrlock);
+static DEFINE_BINARY_SEMAPHORE(intrlock);
#ifdef CONFIG_XENO_OPT_STATS
xnintr_t nkclock; /* Only for statistics */
@@ -709,7 +709,6 @@ EXPORT_SYMBOL_GPL(xnintr_destroy);
int xnintr_attach(xnintr_t *intr, void *cookie)
{
int ret;
- spl_t s;
trace_mark(xn_nucleus, irq_attach, "irq %u name %s",
intr->irq, intr->name);
@@ -721,7 +720,7 @@ int xnintr_attach(xnintr_t *intr, void *cookie)
xnarch_set_irq_affinity(intr->irq, nkaffinity);
#endif /* CONFIG_SMP */
- xnlock_get_irqsave(&intrlock, s);
+ down(&intrlock);
if (__testbits(intr->flags, XN_ISR_ATTACHED)) {
ret = -EBUSY;
@@ -735,7 +734,7 @@ int xnintr_attach(xnintr_t *intr, void *cookie)
__setbits(intr->flags, XN_ISR_ATTACHED);
xnintr_stat_counter_inc();
out:
- xnlock_put_irqrestore(&intrlock, s);
+ up(&intrlock);
return ret;
}
@@ -775,11 +774,10 @@ EXPORT_SYMBOL_GPL(xnintr_attach);
int xnintr_detach(xnintr_t *intr)
{
int ret;
- spl_t s;
trace_mark(xn_nucleus, irq_detach, "irq %u", intr->irq);
- xnlock_get_irqsave(&intrlock, s);
+ down(&intrlock);
if (!__testbits(intr->flags, XN_ISR_ATTACHED)) {
ret = -EINVAL;
@@ -794,7 +792,7 @@ int xnintr_detach(xnintr_t *intr)
xnintr_stat_counter_dec();
out:
- xnlock_put_irqrestore(&intrlock, s);
+ up(&intrlock);
return ret;
}
@@ -920,13 +918,12 @@ int xnintr_query_next(int irq, xnintr_iterator_t *iterator, char *name_buf)
xnticks_t last_switch;
int cpu_no = iterator->cpu + 1;
int err = 0;
- spl_t s;
if (cpu_no == xnarch_num_online_cpus())
cpu_no = 0;
iterator->cpu = cpu_no;
- xnlock_get_irqsave(&intrlock, s);
+ down(&intrlock);
if (iterator->list_rev != xnintr_list_rev) {
err = -EAGAIN;
@@ -969,7 +966,7 @@ int xnintr_query_next(int irq, xnintr_iterator_t *iterator, char *name_buf)
iterator->prev = intr;
unlock_and_exit:
- xnlock_put_irqrestore(&intrlock, s);
+ up(&intrlock);
return err;
}
@@ -983,7 +980,6 @@ static inline int format_irq_proc(unsigned int irq,
struct xnvfile_regular_iterator *it)
{
struct xnintr *intr;
- spl_t s;
if (irq == XNARCH_TIMER_IRQ) {
xnvfile_puts(it, " [timer]");
@@ -1005,7 +1001,7 @@ static inline int format_irq_proc(unsigned int irq,
return 0;
}
- xnlock_get_irqsave(&intrlock, s);
+ down(&intrlock);
intr = xnintr_shirq_first(irq);
if (intr) {
@@ -1018,7 +1014,7 @@ static inline int format_irq_proc(unsigned int irq,
} while (intr);
}
- xnlock_put_irqrestore(&intrlock, s);
+ up(&intrlock);
return 0;
}
--
1.7.3.4
--
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2012-10-18 17:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-17 11:19 [Xenomai] [PATCH] nucleus: Convert intrlock to a sleeping Linux lock Jan Kiszka
2012-10-18 4:37 ` Gilles Chanteperdrix
2012-10-18 6:11 ` Jan Kiszka
2012-10-18 6:21 ` Gilles Chanteperdrix
2012-10-18 6:30 ` Jan Kiszka
2012-10-18 17:40 ` Jan Kiszka [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-01-02 18:07 [Xenomai] [PATCH v2] " Jan Kiszka
2013-01-02 20:25 ` Jeff Webb
2013-01-03 10:46 ` Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50803F21.5020205@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.