From: Philippe Gerum <rpm@xenomai.org>
To: Dmitry Adamushko <dmitry.adamushko@domain.hid>
Cc: xenomai@xenomai.org
Subject: [Xenomai-core] Re: [PATCH, RFC] nucleus:shared irq and possible ipipe problem
Date: Sun, 08 Jan 2006 12:29:22 +0100 [thread overview]
Message-ID: <43C0F792.3000300@domain.hid> (raw)
In-Reply-To: <b647ffbd0601071105p746bf2ebx@domain.hid>
Dmitry Adamushko wrote:
>
>
> On 31/12/05, *Philippe Gerum* <rpm@xenomai.org <mailto:rpm@xenomai.org>>
> wrote:
>
> > ...
>
> > 2) xnintr_irq_handler() gets a cookie which is == xnshared_irq_t*
> (see
> > xnintr_attach) that may already be invalid at that time or, and
> that's a
> > problem, become invalid during the execution of xnintr_irq_handler().
> > To prevent that, we could add a flag like IRQ_INPROGRESS but
> >
> > either we have to set/remove it on the adeos layer before the
> control is
> > passed to the xnintr_irq_handler() (to be sure that cookie is not
> > xnfree()'d. xnintr_detach() will do busy waiting)
> >
>
> Synchronizing the pending IRQs in ipipe_virtualize_irq() should be done
> by polling the proper irq_pending count (and _not_ the hi/lo bits which
> get cleared before the handler is run).
>
>
> But irq_pending counter (pending_hits in the recent adeos patch) gets
> cleared before running the isr handler too.
>
I was referring to __ipipe_lock_irq() which clears the pending bits but
keeps the irq count intact to emulate a PIC masking for a given interrupt.
> In ipipe_sync_stage() :
> ...
> if (--cpudata->irq_pending_hits[irq] == 0) {
> __clear_bit(rank,
> &cpudata->irq_pending_lo[level]);
> ipipe_mark_irq_delivery(ipd,irq,cpuid);
> }
> (*)
>
> // run the corresponding isr handler
>
> This code drops the irq_pending_hits to 0 before running the handler.
>
> Doesn't it make the following code wrong ?
>
> for (_cpuid = 0; _cpuid < nr_cpus; _cpuid++)
> while (ipd->cpudata[_cpuid].irq_pending_hits[irq] > 0)
> cpu_relax();
>
>
> as the handler still can be running / or even about to be run when
> ipd->cpudata[_cpuid].irq_pending_hits[irq] is already 0.
>
> We can remove the (*) code at the end of ipipe_sync_stage() so that
> irq_pending_hits[irq] may become 0 only after the corresponding isr
> handler has completed.
>
I don't like the idea of having the interrupt bookkeeping stuff
incompletely updated while calling a handler that might sleep and/or
migrate to another CPU.
Another option would be to check for SYNC flag; the syncer sets it
before entering the dispatch loop.
> At the same time, the irq_pending counter can't be increased anymore
> since we clear the IPIPE_HANDLE_FLAG before doing the busy waiting in
> ipipe_unregister_domain() or ipipe_virtualize_irq().
>
>
> --
>
> Philippe.
>
>
> --
> Best regards,
> Dmitry Adamushko
>
--
Philippe.
next prev parent reply other threads:[~2006-01-08 11:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-31 12:37 [Xenomai-core] [PATCH, RFC] nucleus:shared irq and possible ipipe problem Dmitry Adamushko
2005-12-31 14:59 ` [Xenomai-core] " Philippe Gerum
[not found] ` <b647ffbd0601021042h140c0f7dk@domain.hid>
2006-01-02 18:43 ` Dmitry Adamushko
2006-01-05 19:00 ` Philippe Gerum
[not found] ` <b647ffbd0601061202g4414bb86k@domain.hid>
2006-01-06 20:06 ` Dmitry Adamushko
2006-01-07 19:05 ` Dmitry Adamushko
2006-01-08 11:29 ` Philippe Gerum [this message]
2006-01-09 20:14 ` Dmitry Adamushko
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=43C0F792.3000300@domain.hid \
--to=rpm@xenomai.org \
--cc=dmitry.adamushko@domain.hid \
--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.