xenomai.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Ulrich Schwab <uli.schwab@domain.hid>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] Error propagating ISR to Linux domain
Date: Wed, 30 Jul 2008 10:31:33 +0200	[thread overview]
Message-ID: <489026E5.1010801@domain.hid> (raw)
In-Reply-To: <f5e14e470807291515j19e7d34v3b9a1579bc10377f@domain.hid>

Ulrich Schwab wrote:
> On Tue, Jul 29, 2008 at 4:20 PM, Gilles Chanteperdrix
> <gilles.chanteperdrix@xenomai.org> wrote:
>> Gilles Chanteperdrix wrote:
>>> Ulrich Schwab wrote:
>>>> why not checking for irq origin like this:
>>>> int my_isr_handler (xnintr_t *irq)
>>>> {
>>>>  if ( ! test_my_card_for_irq_origin )
>>>>     return XN_ISR_NONE | XN_ISR_PROPAGATE;
>>>>   ... /* handling */
>>>>  return XN_ISR_HANDLED;
>>>> }
>>>>
>>>> this way XN_ISR_PROPAGATE is never returned in the not-shared case.
>>> I think this idea needs an answer; the answer is no: it will not work.
>>> Because the IRQ will remain masked until Linux handles it, which
>>> basically means that the RT irq will wait for non-RT activity, you loose
>>> real-time response.
>> It will not work, but not for the reason I mention: Adeos WILL re-enable
>> the IRQ at interrupt controller level after the end of this handler,
>> however, since the interrupt was not cleared on the peripheral side, the
>> peripheral will reassert the interrupt when the interrupt is unmasked at
>> interrupt controller level, so the CPU will enter an infinite loop
>> invoking the ISR.
>>
>> --
>>                                                 Gilles.
>>
> Are You sure?
> IIRC the infinte loop You describe occurs when XN_ISR_PROPAGATE is
> removed from the code above.

Actually, no, I was not sure, so, I had a look at the code, all IRQs
handlers do:

        if (s & XN_ISR_PROPAGATE)
                xnarch_chain_irq(irq);
        else if (!(s & XN_ISR_NOENABLE))
                xnarch_end_irq(irq);

It means that when XN_ISR_PROPAGATE is set the IRQ does not get unmasked
at interrupt controller level, and your solution does not cause the
system to enter the infinite loop, however you loose the RT response, as
was (correctly) said in my first answer.

It also means that my solution has the same issue. So, we should add a
call to xnarch_end_irq in the non-rt driver RT stub. So, the solution
becomes:

int driver2_nrt_irq_pending;

int driver2_rt_isr_handler(xnintr_t *irq)
{
   if (!test_driver2_hard_irq_pending())
 	return XN_ISR_NONE;

   clear_driver2_hard_irq();
   driver2_nrt_irq_pending = 1;

   xnarch_end_irq(irq->irq);

   return XN_ISR_HANDLED | XN_ISR_PROPAGATE;
}

int driver1_rt_isr_handler(xnintr_t *irq)
{
   if (!test_driver1_irq_pending())
	return XN_ISR_NONE;

   /* driver1 handling */

   return XN_ISR_HANDLED;
}

int driver2_nrt_isr_handler(int irq, void *dev_id)
{
#ifndef CONFIG_IPIPE
	/* The old code checking and clearing hardware irqs. */
        if (!test_drive2_hard_irq_pending())
		return IRQ_NONE;

	clear_drive2_hard_irq();
#else /* IPIPE */
	/* Replaced by this code. */
	if (!driver2_nrt_irq_pending)
		return IRQ_NONE;

	driver2_nrt_irq_pending = 0;
#endif /* IPIPE */

	/* driver2 irq handling. */

	return IRQ_HANDLED;
}

-- 
                                                 Gilles.


  parent reply	other threads:[~2008-07-30  8:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-16 16:03 [Xenomai-core] Error propagating ISR to Linux domain Benjamin ZORES
2008-07-16 17:02 ` Jan Kiszka
2008-07-20 16:25 ` Ulrich Schwab
2008-07-28 14:37   ` Gilles Chanteperdrix
2008-07-29 14:20     ` Gilles Chanteperdrix
2008-07-29 22:15       ` Ulrich Schwab
2008-07-29 22:24         ` Gilles Chanteperdrix
2008-07-30  8:31         ` Gilles Chanteperdrix [this message]
2008-07-30  9:22           ` Ulrich Schwab
2008-07-30  9:26             ` Gilles Chanteperdrix

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=489026E5.1010801@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=uli.schwab@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).