Skip to contentSkip to conversation

No hardware interrupts with xenomai on ppc405

Xenomai-core Applied Matthias Fuchs 4 participants 23 messages Sep 10, 2006 – Sep 15, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

I was trying to use some external hardware interupts on a PPC405 board as part of a hacking session with Jan to bring up the rtcan driver on this board.

Here are some versions:

	Linux Kernel: 2.6.14
	Adeos: 1.3-07
	Xenomai: from svn (2.3pre, last friday night)

The first interrupt interrupt was always fine. When the 2nd interupt occured, it was never handled and did not cause any action. We used the ipipe-tracer and did not see anything related to the 2nd and any further interrupt.

I think that the hardware interrupt is somehow masked and therefore never result in any action. So the handling of the first interrupt might be incorrect.

This seems to be ppc or even ppc4xx related because I assume that x86 platforms do not have this issue. Is this an Adeos issue.

I will do the same test on a 2.4 kernel next week - if nobody tells me that this will be a waste of time.

Matthias

#1 lore raw

Hi Matthias,

Quoted 21 lines · Matthias Fuchs

Hi,

I was trying to use some external hardware interupts on a PPC405 board as part of a hacking session with Jan to bring up the rtcan driver on this board.

Here are some versions:

	Linux Kernel: 2.6.14
	Adeos: 1.3-07
	Xenomai: from svn (2.3pre, last friday night)

The first interrupt interrupt was always fine. When the 2nd interupt occured, it was never handled and did not cause any action. We used the ipipe-tracer and did not see anything related to the 2nd and any further interrupt.

I think that the hardware interrupt is somehow masked and therefore never result in any action. So the handling of the first interrupt might be incorrect.

Quoted 5 lines

This seems to be ppc or even ppc4xx related because I assume that x86 platforms do not have this issue. Is this an Adeos issue.

I will do the same test on a 2.4 kernel next week - if nobody tells me that this will be a waste of time.

Could you please add printk statements to the ack, enable and end functions to arch/ppc/syslib/ppc4xx_pic.c if the irq number matches. Please print also SR, ER and status.

Wolfgang.

#2 lore raw
Quoted 5 lines · Wolfgang Grandegger

Hi Matthias,

Quoted 2 lines · Matthias Fuchs

Hi,

Quoted 8 lines
Quoted 4 lines

I was trying to use some external hardware interupts on a PPC405 board as part of a hacking session with Jan to bring up the rtcan driver on this board.

Could you please add printk statements to the ack, enable and end functions to arch/ppc/syslib/ppc4xx_pic.c if the irq number matches. Please print also SR, ER and status.

1) insmodding the driver:
bash-3.00# modprobe xeno_rtcan_isa mem=0xf0000000 irq=25
rtcan: registered rtcan0
_enable: ER=003f0040, SR=c0000000

2) receiving
bash-3.00# /sbin/rtcanconfig rtcan0 -b 500000 up
bash-3.00# ./bin/rtcanrecv rtcan0
_ack: ER=003f0000, SR=c0000040
_end: ER=003f0000, SR=c0000000
#0: (1) <0x000> [8] 00 00 00 00 01 00 00 00

That's it. When sending a 2nd message to the board, nothing happens. We have a LED on the SJA1000 interrupt signal. After sending the 2nd message this LED stays on, so the interrupt is never handled.

It seems that the interrupt is not reenabled (bit 25) in the "end" function.

Matthias

#3 lore raw
Quoted 17 lines · Matthias Fuchs
Quoted 10 lines · Wolfgang Grandegger

Hi Matthias,

Quoted 6 lines · Matthias Fuchs

Hi,

I was trying to use some external hardware interupts on a PPC405 board as part of a hacking session with Jan to bring up the rtcan driver on this board.

Could you please add printk statements to the ack, enable and end functions to arch/ppc/syslib/ppc4xx_pic.c if the irq number matches. Please print also SR, ER and status.

1) insmodding the driver:
bash-3.00# modprobe xeno_rtcan_isa mem=0xf0000000 irq=25
rtcan: registered rtcan0
_enable: ER=003f0040, SR=c0000000

Quoted 6 lines

2) receiving
bash-3.00# /sbin/rtcanconfig rtcan0 -b 500000 up
bash-3.00# ./bin/rtcanrecv rtcan0
_ack: ER=003f0000, SR=c0000040
_end: ER=003f0000, SR=c0000000
#0: (1) <0x000> [8] 00 00 00 00 01 00 00 00

OK. I will lookup the meaning later today.

Quoted 3 lines

That's it. When sending a 2nd message to the board, nothing happens. We have a LED on the SJA1000 interrupt signal. After sending the 2nd message this LED stays on, so the interrupt is never handled.

It seems that the interrupt is not reenabled (bit 25) in the "end" function.

Could you please add a printout of status. It's important that the following if statement is entered in the end function:

	if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
                ppc_cached_irq_mask[n] |= mask;
                mtdcr(DCRN_UIC_ER(UIC##n), ppc_cached_irq_mask[n]);
        }

And could you also try replacing all lines

        if (status & IRQ_LEVEL) { 

with

        if (status & IRQ_LEVEL || irq == <your-irq>) { 

Thanks.

Wolfgang.

#4 lore raw
In reply to Matthias Fuchs
Quoted 27 lines · Matthias Fuchs
Quoted 5 lines · Wolfgang Grandegger

Hi Matthias,

Quoted 2 lines · Matthias Fuchs

Hi,

Quoted 8 lines
Quoted 4 lines

I was trying to use some external hardware interupts on a PPC405 board as part of a hacking session with Jan to bring up the rtcan driver on this board.

Could you please add printk statements to the ack, enable and end functions to arch/ppc/syslib/ppc4xx_pic.c if the irq number matches. Please print also SR, ER and status.

1) insmodding the driver:
bash-3.00# modprobe xeno_rtcan_isa mem=0xf0000000 irq=25
rtcan: registered rtcan0
_enable: ER=003f0040, SR=c0000000

2) receiving
bash-3.00# /sbin/rtcanconfig rtcan0 -b 500000 up
bash-3.00# ./bin/rtcanrecv rtcan0
_ack: ER=003f0000, SR=c0000040
_end: ER=003f0000, SR=c0000000
#0: (1) <0x000> [8] 00 00 00 00 01 00 00 00

Quoted 6 lines

That's it. When sending a 2nd message to the board, nothing happens. We have a LED on the SJA1000 interrupt signal. After sending the 2nd message this LED stays on, so the interrupt is never handled.

It seems that the interrupt is not reenabled (bit 25) in the "end" function.

It's likely an Adeos issue. Could you try this patch? TIA,

ppc/syslib/ppc4xx_pic.c renamed from ppc/syslib/ppc4xx_pic.c~ +2 -1
@@ -72,7 +72,8 @@
 		mtdcr(DCRN_UIC_SR(UIC##n), mask);			\
 		ACK_UIC##n##_PARENT					\
 	}								\
-	if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
+	if (!ipipe_root_domain_p ||					\
+	    !(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
 		ppc_cached_irq_mask[n] |= mask;				\
 		mtdcr(DCRN_UIC_ER(UIC##n), ppc_cached_irq_mask[n]);	\
 	}								\
Quoted 6 lines

Matthias

_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core

Signature · 1 line
Philippe.
#5 lore raw

Hello Philippe,

that helps. I will do some further testing.

Matthias

Quoted 14 lines · Philippe Gerum

It's likely an Adeos issue. Could you try this patch? TIA,

ppc/syslib/ppc4xx_pic.c renamed from ppc/syslib/ppc4xx_pic.c~ +2 -1
@@ -72,7 +72,8 @@
 		mtdcr(DCRN_UIC_SR(UIC##n), mask);			\
 		ACK_UIC##n##_PARENT					\
 	}								\
-	if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
+	if (!ipipe_root_domain_p ||					\
+	    !(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
 		ppc_cached_irq_mask[n] |= mask;				\
 		mtdcr(DCRN_UIC_ER(UIC##n), ppc_cached_irq_mask[n]);	\
 	}								\
#6 lore raw
Quoted 10 lines · Matthias Fuchs

Hello Philippe,

that helps. I will do some further testing.

Matthias

Quoted 2 lines · Philippe Gerum

It's likely an Adeos issue. Could you try this patch? TIA,

Quoted 13 lines

ppc/syslib/ppc4xx_pic.c line 79

Quoted 12 lines
ppc/syslib/ppc4xx_pic.c renamed from ppc/syslib/ppc4xx_pic.c~ +2 -1
@@ -72,7 +72,8 @@
 		mtdcr(DCRN_UIC_SR(UIC##n), mask);			\
 		ACK_UIC##n##_PARENT					\
 	}								\
-	if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
+	if (!ipipe_root_domain_p ||					\
+	    !(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
 		ppc_cached_irq_mask[n] |= mask;				\
 		mtdcr(DCRN_UIC_ER(UIC##n), ppc_cached_irq_mask[n]);	\
 	}								\

Philippe, could you please explain the problem in more detail? And what are the consequences for other PowerPC ARCs and PICs, also for Linux 2.4?

Thanks.

Wolfgang.

#7 lore raw
Quoted 25 lines · Wolfgang Grandegger
Quoted 10 lines · Matthias Fuchs

Hello Philippe,

that helps. I will do some further testing.

Matthias

Quoted 2 lines · Philippe Gerum

It's likely an Adeos issue. Could you try this patch? TIA,

Quoted 13 lines

ppc/syslib/ppc4xx_pic.c line 79

Quoted 12 lines
ppc/syslib/ppc4xx_pic.c renamed from ppc/syslib/ppc4xx_pic.c~ +2 -1
@@ -72,7 +72,8 @@
 		mtdcr(DCRN_UIC_SR(UIC##n), mask);			\
 		ACK_UIC##n##_PARENT					\
 	}								\
-	if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
+	if (!ipipe_root_domain_p ||					\
+	    !(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
 		ppc_cached_irq_mask[n] |= mask;				\
 		mtdcr(DCRN_UIC_ER(UIC##n), ppc_cached_irq_mask[n]);	\
 	}								\
Quoted 2 lines

Philippe, could you please explain the problem in more detail? And what are the consequences for other PowerPC ARCs and PICs, also for Linux 2.4?

The issue lies in the fact that PICs *_end() routines may be called over the Xenomai domain, and actually are, most of the time, since xnintr_irq_handler() -which invokes xnarch_end_irq()- is always called from the the Xenomai stage in the Adeos pipeline.

In such a case, we must not check for the Linux-defined IRQ bits (e.g. IRQ_INPROGRESS), and always send the eoi, since those bits are not relevant to the Xenomai context. The patch above ensures this.

And yes, the 2.4 patch has the very same problem, which should be fixed the same way for all supported ppc platforms in the various PIC management code. Oops.

Quoted 5 lines

Thanks.

Wolfgang.

Signature · 1 line
Philippe.
#8 lore raw
Quoted 32 lines · Philippe Gerum
Quoted 11 lines · Wolfgang Grandegger
Quoted 10 lines · Matthias Fuchs

Hello Philippe,

that helps. I will do some further testing.

Matthias

Quoted 2 lines · Philippe Gerum

It's likely an Adeos issue. Could you try this patch? TIA,

Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
ppc/syslib/ppc4xx_pic.c renamed from ppc/syslib/ppc4xx_pic.c~ +0 -0
@@ -72,7 +72,8 @@
 		mtdcr(DCRN_UIC_SR(UIC##n), mask);			\
Quoted 8 lines

ppc/syslib/ppc4xx_pic.c line 79

Quoted 8 lines
ppc/syslib/ppc4xx_pic.c renamed from ppc/syslib/ppc4xx_pic.c~ +2 -1
 		ACK_UIC##n##_PARENT					\
 	}								\
-	if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
+	if (!ipipe_root_domain_p ||					\
+	    !(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
 		ppc_cached_irq_mask[n] |= mask;				\
 		mtdcr(DCRN_UIC_ER(UIC##n), ppc_cached_irq_mask[n]);	\
 	}								\

Philippe, could you please explain the problem in more detail? And what are the consequences for other PowerPC ARCs and PICs, also for Linux 2.4?

The issue lies in the fact that PICs *_end() routines may be called over the Xenomai domain, and actually are, most of the time, since xnintr_irq_handler() -which invokes xnarch_end_irq()- is always called from the the Xenomai stage in the Adeos pipeline.

Quoted 7 lines

In such a case, we must not check for the Linux-defined IRQ bits (e.g. IRQ_INPROGRESS), and always send the eoi, since those bits are not relevant to the Xenomai context. The patch above ensures this.

And yes, the 2.4 patch has the very same problem, which should be fixed the same way for all supported ppc platforms in the various PIC management code. Oops.

And why didn't this render PPC-over-2.4 useless, i.e. what is special about this 405-scenario?

Jan

#9 lore raw
Quoted 37 lines · Jan Kiszka
Quoted 36 lines · Philippe Gerum
Quoted 11 lines · Wolfgang Grandegger
Quoted 10 lines · Matthias Fuchs

Hello Philippe,

that helps. I will do some further testing.

Matthias

Quoted 2 lines · Philippe Gerum

It's likely an Adeos issue. Could you try this patch? TIA,

Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
ppc/syslib/ppc4xx_pic.c renamed from ppc/syslib/ppc4xx_pic.c~ +0 -0
@@ -72,7 +72,8 @@
 		mtdcr(DCRN_UIC_SR(UIC##n), mask);			\
Quoted 8 lines

ppc/syslib/ppc4xx_pic.c line 79

Quoted 8 lines
ppc/syslib/ppc4xx_pic.c renamed from ppc/syslib/ppc4xx_pic.c~ +2 -1
 		ACK_UIC##n##_PARENT					\
 	}								\
-	if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
+	if (!ipipe_root_domain_p ||					\
+	    !(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
 		ppc_cached_irq_mask[n] |= mask;				\
 		mtdcr(DCRN_UIC_ER(UIC##n), ppc_cached_irq_mask[n]);	\
 	}								\

Philippe, could you please explain the problem in more detail? And what are the consequences for other PowerPC ARCs and PICs, also for Linux 2.4?

The issue lies in the fact that PICs *_end() routines may be called over the Xenomai domain, and actually are, most of the time, since xnintr_irq_handler() -which invokes xnarch_end_irq()- is always called from the the Xenomai stage in the Adeos pipeline.

In such a case, we must not check for the Linux-defined IRQ bits (e.g. IRQ_INPROGRESS), and always send the eoi, since those bits are not relevant to the Xenomai context. The patch above ensures this.

Quoted 7 lines
Quoted 3 lines

And yes, the 2.4 patch has the very same problem, which should be fixed the same way for all supported ppc platforms in the various PIC management code. Oops.

And why didn't this render PPC-over-2.4 useless, i.e. what is special about this 405-scenario?

A possible explanation is that configurations only using the timer IRQ are not affected, since the decrementer is not subject to this issue (the tick handler returns XN_ISR_NOENABLE anyway).

Signature · 1 line
Philippe.
#10 lore raw
Quoted 39 lines · Philippe Gerum
Quoted 38 lines · Jan Kiszka
Quoted 37 lines · Philippe Gerum
Quoted 11 lines · Wolfgang Grandegger
Quoted 10 lines · Matthias Fuchs

Hello Philippe,

that helps. I will do some further testing.

Matthias

Quoted 2 lines · Philippe Gerum

It's likely an Adeos issue. Could you try this patch? TIA,

Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
ppc/syslib/ppc4xx_pic.c renamed from ppc/syslib/ppc4xx_pic.c~ +0 -0
@@ -72,7 +72,8 @@
 		mtdcr(DCRN_UIC_SR(UIC##n), mask);			\
Quoted 8 lines

ppc/syslib/ppc4xx_pic.c line 79

Quoted 8 lines
ppc/syslib/ppc4xx_pic.c renamed from ppc/syslib/ppc4xx_pic.c~ +2 -1
 		ACK_UIC##n##_PARENT					\
 	}								\
-	if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
+	if (!ipipe_root_domain_p ||					\
+	    !(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {		\
 		ppc_cached_irq_mask[n] |= mask;				\
 		mtdcr(DCRN_UIC_ER(UIC##n), ppc_cached_irq_mask[n]);	\
 	}								\

Philippe, could you please explain the problem in more detail? And what are the consequences for other PowerPC ARCs and PICs, also for Linux 2.4?

The issue lies in the fact that PICs *_end() routines may be called over the Xenomai domain, and actually are, most of the time, since xnintr_irq_handler() -which invokes xnarch_end_irq()- is always called from the the Xenomai stage in the Adeos pipeline.

In such a case, we must not check for the Linux-defined IRQ bits (e.g. IRQ_INPROGRESS), and always send the eoi, since those bits are not relevant to the Xenomai context. The patch above ensures this.

And yes, the 2.4 patch has the very same problem, which should be fixed the same way for all supported ppc platforms in the various PIC management code. Oops.

Quoted 7 lines
Quoted 3 lines

And why didn't this render PPC-over-2.4 useless, i.e. what is special about this 405-scenario?

A possible explanation is that configurations only using the timer IRQ are not affected, since the decrementer is not subject to this issue (the tick handler returns XN_ISR_NOENABLE anyway).

I run RT-Socket-CAN on a CAN PCI Card on my MPC5200 without any problems, so far (under Linux 2.4). Here the end function of the PIC:

  static void
  mpc5xxx_ic_end(unsigned int irq)
  {
        if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
                mpc5xxx_ic_enable(irq);
  }

Matthias, have you printed out the value of status? I'm just curious.

Wolfgang.

#11 lore raw
Quoted 15 lines · Wolfgang Grandegger
Quoted 4 lines

A possible explanation is that configurations only using the timer IRQ are not affected, since the decrementer is not subject to this issue (the tick handler returns XN_ISR_NOENABLE anyway).

I run RT-Socket-CAN on a CAN PCI Card on my MPC5200 without any problems, so far (under Linux 2.4). Here the end function of the PIC:

   static void
   mpc5xxx_ic_end(unsigned int irq)
   {
         if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
                 mpc5xxx_ic_enable(irq);
   }
Quoted 3 lines

Matthias, have you printed out the value of status? I'm just curious.

Wolfgang.

Here it comes:
bash-3.00# ./bin/rtcansend rtcan0 -i 0 1 2 3 4
_end: status=00000042
bash-3.00# ./bin/rtcansend rtcan0 -i 0 1 2 3 4
_end: status=00000042
bash-3.00# ./bin/rtcansend rtcan0 -i 0 1 2 3 4
_end: status=00000042

So it's IRQ_DISABLED (=2).

Matthias

#12 lore raw
Quoted 25 lines · Matthias Fuchs
Quoted 12 lines · Wolfgang Grandegger
Quoted 3 lines

A possible explanation is that configurations only using the timer IRQ are not affected, since the decrementer is not subject to this issue (the tick handler returns XN_ISR_NOENABLE anyway).

I run RT-Socket-CAN on a CAN PCI Card on my MPC5200 without any problems, so far (under Linux 2.4). Here the end function of the PIC:

   static void
   mpc5xxx_ic_end(unsigned int irq)
   {
         if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
                 mpc5xxx_ic_enable(irq);
   }
Quoted 3 lines

Matthias, have you printed out the value of status? I'm just curious.

Wolfgang.

Here it comes:
bash-3.00# ./bin/rtcansend rtcan0 -i 0 1 2 3 4
_end: status=00000042
bash-3.00# ./bin/rtcansend rtcan0 -i 0 1 2 3 4
_end: status=00000042
bash-3.00# ./bin/rtcansend rtcan0 -i 0 1 2 3 4
_end: status=00000042

Quoted 1 line

So it's IRQ_DISABLED (=2).

In 2.6 the interrupts are disabled by default. Then the attached patch for Xenomai should help.

Wolfgang.

+ diff -u xenomai/ksrc/arch/powerpc/hal.c.IRQEND xenomai/ksrc/arch/powerpc/hal.c

ksrc/arch/powerpc/hal.c renamed from ksrc/arch/powerpc/hal.c.IRQEND +2 -0
@@ -326,6 +326,7 @@
         rthal_irq_descp(irq)->handler->enable == NULL)
         return -ENODEV;
 
+    rthal_irq_descp(irq)->status &= ~IRQ_DISABLED;
     rthal_irq_descp(irq)->handler->enable(irq);
 
     return 0;
@@ -341,6 +342,7 @@
         rthal_irq_descp(irq)->handler->disable == NULL)
         return -ENODEV;
 
+    rthal_irq_descp(irq)->status |= IRQ_DISABLED;
     rthal_irq_descp(irq)->handler->disable(irq);
 
     return 0;
#13 lore raw
Quoted 6 lines · Wolfgang Grandegger

In 2.6 the interrupts are disabled by default. Then the attached patch for Xenomai should help.

Wolfgang.

Your patch also works fine. Now what's the recommended solution? I noticed that Philippe already checked in an Adeos fix.

Matthias

#14 lore raw
Quoted 6 lines · Matthias Fuchs
Quoted 4 lines · Wolfgang Grandegger

In 2.6 the interrupts are disabled by default. Then the attached patch for Xenomai should help.

Wolfgang.

Your patch also works fine. Now what's the recommended solution? I noticed that Philippe already checked in an Adeos fix.

As mentioned, in Linux 2.6 (generic IRQ layer), IRQs are disabled by default in kernel/irq/handle.c:

  irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
        [0 ... NR_IRQS-1] = {
                .status = IRQ_DISABLED,
                .handler = &no_irq_type,
                .lock = SPIN_LOCK_UNLOCKED
        }
  };

Till now, I haven't found IPIPE/Xenomai related code removing the IRQ_DISABLED bit. But I wonder why it's working for x86. Maybe I have missed something.

In Linux 2.4, the "status" field is initialized to 0 (in arch/ppc/kernel/irq.c) not making trouble:

  irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned =
        { [0 ... NR_IRQS-1] = { 0, NULL, NULL, 0, SPIN_LOCK_UNLOCKED}};

At least my CAN PCI card on a MPC5200 works fine.

Philippe, do we really need these ugly PIC patches?

Wolfgang.

#15 lore raw
Quoted 28 lines · Wolfgang Grandegger
Quoted 8 lines · Matthias Fuchs
Quoted 5 lines · Wolfgang Grandegger

In 2.6 the interrupts are disabled by default. Then the attached patch for Xenomai should help.

Wolfgang.

Your patch also works fine. Now what's the recommended solution? I noticed that Philippe already checked in an Adeos fix.

As mentioned, in Linux 2.6 (generic IRQ layer), IRQs are disabled by default in kernel/irq/handle.c:

   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
         [0 ... NR_IRQS-1] = {
                 .status = IRQ_DISABLED,
                 .handler = &no_irq_type,
                 .lock = SPIN_LOCK_UNLOCKED
         }
   };

Till now, I haven't found IPIPE/Xenomai related code removing the IRQ_DISABLED bit. But I wonder why it's working for x86. Maybe I have missed something.

In Linux 2.4, the "status" field is initialized to 0 (in arch/ppc/kernel/irq.c) not making trouble:

Quoted 6 lines
   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned =
         { [0 ... NR_IRQS-1] = { 0, NULL, NULL, 0, SPIN_LOCK_UNLOCKED}};

At least my CAN PCI card on a MPC5200 works fine.

Philippe, do we really need these ugly PIC patches?

Not anymore, since we decided to stop supporting a tortuous use case where some IRQ channel could be shared between a Xenomai ISR and a Linux handler for handling mixed RT/non-RT devices (which was something of a bugous design anyway). Doing so, the patch was about preventing IRQ_INPROGRESS to block IRQ reenabling requests issued from a Xenomai ISR (i.e. in case a RT interrupt preempts the regular Linux handler for the same IRQ channel).

The problem I see now, is that removing the work-arounds from the various PIC code would void the ability to use recent Adeos patches with older Xenomai releases. I'm not opposed to that, provided we backport your fix to 2.1.x and above, but this is an issue we should keep in mind. Perhaps the next Adeos patches should even make un-fixed Xenomai releases choke at compilation time.

Quoted 2 lines

Wolfgang.

Signature · 1 line
Philippe.
#16 lore raw
Quoted 37 lines · Philippe Gerum
Quoted 19 lines · Wolfgang Grandegger
Quoted 6 lines · Matthias Fuchs
Quoted 4 lines · Wolfgang Grandegger

In 2.6 the interrupts are disabled by default. Then the attached patch for Xenomai should help.

Wolfgang.

Your patch also works fine. Now what's the recommended solution? I noticed that Philippe already checked in an Adeos fix.

As mentioned, in Linux 2.6 (generic IRQ layer), IRQs are disabled by default in kernel/irq/handle.c:

   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
         [0 ... NR_IRQS-1] = {
                 .status = IRQ_DISABLED,
                 .handler = &no_irq_type,
                 .lock = SPIN_LOCK_UNLOCKED
         }
   };

Till now, I haven't found IPIPE/Xenomai related code removing the IRQ_DISABLED bit. But I wonder why it's working for x86. Maybe I have missed something.

Quoted 8 lines

In Linux 2.4, the "status" field is initialized to 0 (in arch/ppc/kernel/irq.c) not making trouble:

   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned =
         { [0 ... NR_IRQS-1] = { 0, NULL, NULL, 0, SPIN_LOCK_UNLOCKED}};

At least my CAN PCI card on a MPC5200 works fine.

Philippe, do we really need these ugly PIC patches?

Not anymore, since we decided to stop supporting a tortuous use case where some IRQ channel could be shared between a Xenomai ISR and a Linux handler for handling mixed RT/non-RT devices (which was something of a bugous design anyway). Doing so, the patch was about preventing IRQ_INPROGRESS to block IRQ reenabling requests issued from a Xenomai ISR (i.e. in case a RT interrupt preempts the regular Linux handler for the same IRQ channel).

Quoted 6 lines

The problem I see now, is that removing the work-arounds from the various PIC code would void the ability to use recent Adeos patches with older Xenomai releases. I'm not opposed to that, provided we backport your fix to 2.1.x and above, but this is an issue we should keep in mind. Perhaps the next Adeos patches should even make un-fixed Xenomai releases choke at compilation time.

We could also set the relevant status field bits to 0 somewhere in the IPIPE-patch when the IRQ is requested or overtaken. I think this is a general issue (not only on PowerPC).

Wolfgang.

#17 lore raw
Quoted 51 lines · Wolfgang Grandegger
Quoted 43 lines · Philippe Gerum
Quoted 27 lines · Wolfgang Grandegger
Quoted 8 lines · Matthias Fuchs
Quoted 5 lines · Wolfgang Grandegger

In 2.6 the interrupts are disabled by default. Then the attached patch for Xenomai should help.

Wolfgang.

Your patch also works fine. Now what's the recommended solution? I noticed that Philippe already checked in an Adeos fix.

As mentioned, in Linux 2.6 (generic IRQ layer), IRQs are disabled by default in kernel/irq/handle.c:

   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
         [0 ... NR_IRQS-1] = {
                 .status = IRQ_DISABLED,
                 .handler = &no_irq_type,
                 .lock = SPIN_LOCK_UNLOCKED
         }
   };

Till now, I haven't found IPIPE/Xenomai related code removing the IRQ_DISABLED bit. But I wonder why it's working for x86. Maybe I have missed something.

In Linux 2.4, the "status" field is initialized to 0 (in arch/ppc/kernel/irq.c) not making trouble:

Quoted 6 lines
   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned =
         { [0 ... NR_IRQS-1] = { 0, NULL, NULL, 0, SPIN_LOCK_UNLOCKED}};

At least my CAN PCI card on a MPC5200 works fine.

Philippe, do we really need these ugly PIC patches?

Not anymore, since we decided to stop supporting a tortuous use case where some IRQ channel could be shared between a Xenomai ISR and a Linux handler for handling mixed RT/non-RT devices (which was something of a bugous design anyway). Doing so, the patch was about preventing IRQ_INPROGRESS to block IRQ reenabling requests issued from a Xenomai ISR (i.e. in case a RT interrupt preempts the regular Linux handler for the same IRQ channel).

Quoted 6 lines

The problem I see now, is that removing the work-arounds from the various PIC code would void the ability to use recent Adeos patches with older Xenomai releases. I'm not opposed to that, provided we backport your fix to 2.1.x and above, but this is an issue we should keep in mind. Perhaps the next Adeos patches should even make un-fixed Xenomai releases choke at compilation time.

Quoted 3 lines

We could also set the relevant status field bits to 0 somewhere in the IPIPE-patch when the IRQ is requested or overtaken. I think this is a general issue (not only on PowerPC).

This would not clear the issue for IRQ_INPROGRESS, which is raised upon IRQ handling.

Quoted 4 lines

Wolfgang.

Signature · 1 line
Philippe.
#18 lore raw
Quoted 52 lines · Philippe Gerum
Quoted 51 lines · Wolfgang Grandegger
Quoted 49 lines · Philippe Gerum
Quoted 27 lines · Wolfgang Grandegger
Quoted 8 lines · Matthias Fuchs
Quoted 5 lines · Wolfgang Grandegger

In 2.6 the interrupts are disabled by default. Then the attached patch for Xenomai should help.

Wolfgang.

Your patch also works fine. Now what's the recommended solution? I noticed that Philippe already checked in an Adeos fix.

As mentioned, in Linux 2.6 (generic IRQ layer), IRQs are disabled by default in kernel/irq/handle.c:

   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
         [0 ... NR_IRQS-1] = {
                 .status = IRQ_DISABLED,
                 .handler = &no_irq_type,
                 .lock = SPIN_LOCK_UNLOCKED
         }
   };

Till now, I haven't found IPIPE/Xenomai related code removing the IRQ_DISABLED bit. But I wonder why it's working for x86. Maybe I have missed something.

In Linux 2.4, the "status" field is initialized to 0 (in arch/ppc/kernel/irq.c) not making trouble:

Quoted 6 lines
   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned =
         { [0 ... NR_IRQS-1] = { 0, NULL, NULL, 0, SPIN_LOCK_UNLOCKED}};

At least my CAN PCI card on a MPC5200 works fine.

Philippe, do we really need these ugly PIC patches?

Not anymore, since we decided to stop supporting a tortuous use case where some IRQ channel could be shared between a Xenomai ISR and a Linux handler for handling mixed RT/non-RT devices (which was something of a bugous design anyway). Doing so, the patch was about preventing IRQ_INPROGRESS to block IRQ reenabling requests issued from a Xenomai ISR (i.e. in case a RT interrupt preempts the regular Linux handler for the same IRQ channel).

The problem I see now, is that removing the work-arounds from the various PIC code would void the ability to use recent Adeos patches with older Xenomai releases. I'm not opposed to that, provided we backport your fix to 2.1.x and above, but this is an issue we should keep in mind. Perhaps the next Adeos patches should even make un-fixed Xenomai releases choke at compilation time.

Quoted 6 lines
Quoted 3 lines

We could also set the relevant status field bits to 0 somewhere in the IPIPE-patch when the IRQ is requested or overtaken. I think this is a general issue (not only on PowerPC).

This would not clear the issue for IRQ_INPROGRESS, which is raised upon IRQ handling.

I mean this would not fix all the use cases, but this would be sufficient to solve the non-tortuous ones, I agree. So yes, IRQ_DISABLED could just be cleared in ipipe_virtualize_irq_from(), and that should be enough.

Quoted 5 lines
Quoted 5 lines

Wolfgang.

Signature · 1 line
Philippe.
#19 lore raw
Quoted 45 lines · Philippe Gerum
Quoted 44 lines · Philippe Gerum
Quoted 43 lines · Wolfgang Grandegger
Quoted 42 lines · Philippe Gerum
Quoted 19 lines · Wolfgang Grandegger
Quoted 6 lines · Matthias Fuchs
Quoted 4 lines · Wolfgang Grandegger

In 2.6 the interrupts are disabled by default. Then the attached patch for Xenomai should help.

Wolfgang.

Your patch also works fine. Now what's the recommended solution? I noticed that Philippe already checked in an Adeos fix.

As mentioned, in Linux 2.6 (generic IRQ layer), IRQs are disabled by default in kernel/irq/handle.c:

   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
         [0 ... NR_IRQS-1] = {
                 .status = IRQ_DISABLED,
                 .handler = &no_irq_type,
                 .lock = SPIN_LOCK_UNLOCKED
         }
   };

Till now, I haven't found IPIPE/Xenomai related code removing the IRQ_DISABLED bit. But I wonder why it's working for x86. Maybe I have missed something.

Quoted 8 lines

In Linux 2.4, the "status" field is initialized to 0 (in arch/ppc/kernel/irq.c) not making trouble:

   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned =
         { [0 ... NR_IRQS-1] = { 0, NULL, NULL, 0, SPIN_LOCK_UNLOCKED}};

At least my CAN PCI card on a MPC5200 works fine.

Philippe, do we really need these ugly PIC patches?

Not anymore, since we decided to stop supporting a tortuous use case where some IRQ channel could be shared between a Xenomai ISR and a Linux handler for handling mixed RT/non-RT devices (which was something of a bugous design anyway). Doing so, the patch was about preventing IRQ_INPROGRESS to block IRQ reenabling requests issued from a Xenomai ISR (i.e. in case a RT interrupt preempts the regular Linux handler for the same IRQ channel).

The problem I see now, is that removing the work-arounds from the various PIC code would void the ability to use recent Adeos patches with older Xenomai releases. I'm not opposed to that, provided we backport your fix to 2.1.x and above, but this is an issue we should keep in mind. Perhaps the next Adeos patches should even make un-fixed Xenomai releases choke at compilation time.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

We could also set the relevant status field bits to 0 somewhere in the IPIPE-patch when the IRQ is requested or overtaken. I think this is a general issue (not only on PowerPC).

This would not clear the issue for IRQ_INPROGRESS, which is raised upon IRQ handling.

I mean this would not fix all the use cases, but this would be sufficient to solve the non-tortuous ones, I agree. So yes, IRQ_DISABLED could just be cleared in ipipe_virtualize_irq_from(), and that should be enough.

Ok, should I fix that and remove all PowerPC PIC patches already for the Adeos iPipe PPC patch for 2.6.18rc6 I'm currently working on?

Wolfgang.

#20 lore raw
Quoted 58 lines · Wolfgang Grandegger
Quoted 57 lines · Philippe Gerum
Quoted 55 lines · Philippe Gerum
Quoted 49 lines · Wolfgang Grandegger
Quoted 42 lines · Philippe Gerum
Quoted 27 lines · Wolfgang Grandegger
Quoted 8 lines · Matthias Fuchs
Quoted 5 lines · Wolfgang Grandegger

In 2.6 the interrupts are disabled by default. Then the attached patch for Xenomai should help.

Wolfgang.

Your patch also works fine. Now what's the recommended solution? I noticed that Philippe already checked in an Adeos fix.

As mentioned, in Linux 2.6 (generic IRQ layer), IRQs are disabled by default in kernel/irq/handle.c:

   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
         [0 ... NR_IRQS-1] = {
                 .status = IRQ_DISABLED,
                 .handler = &no_irq_type,
                 .lock = SPIN_LOCK_UNLOCKED
         }
   };

Till now, I haven't found IPIPE/Xenomai related code removing the IRQ_DISABLED bit. But I wonder why it's working for x86. Maybe I have missed something.

In Linux 2.4, the "status" field is initialized to 0 (in arch/ppc/kernel/irq.c) not making trouble:

Quoted 6 lines
   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned =
         { [0 ... NR_IRQS-1] = { 0, NULL, NULL, 0, SPIN_LOCK_UNLOCKED}};

At least my CAN PCI card on a MPC5200 works fine.

Philippe, do we really need these ugly PIC patches?

Not anymore, since we decided to stop supporting a tortuous use case where some IRQ channel could be shared between a Xenomai ISR and a Linux handler for handling mixed RT/non-RT devices (which was something of a bugous design anyway). Doing so, the patch was about preventing IRQ_INPROGRESS to block IRQ reenabling requests issued from a Xenomai ISR (i.e. in case a RT interrupt preempts the regular Linux handler for the same IRQ channel).

Quoted 6 lines

The problem I see now, is that removing the work-arounds from the various PIC code would void the ability to use recent Adeos patches with older Xenomai releases. I'm not opposed to that, provided we backport your fix to 2.1.x and above, but this is an issue we should keep in mind. Perhaps the next Adeos patches should even make un-fixed Xenomai releases choke at compilation time.

Quoted 3 lines

We could also set the relevant status field bits to 0 somewhere in the IPIPE-patch when the IRQ is requested or overtaken. I think this is a general issue (not only on PowerPC).

This would not clear the issue for IRQ_INPROGRESS, which is raised upon IRQ handling.

Quoted 8 lines
Quoted 4 lines

I mean this would not fix all the use cases, but this would be sufficient to solve the non-tortuous ones, I agree. So yes, IRQ_DISABLED could just be cleared in ipipe_virtualize_irq_from(), and that should be enough.

Ok, should I fix that and remove all PowerPC PIC patches already for the Adeos iPipe PPC patch for 2.6.18rc6 I'm currently working on?

I think so. I'm also going to apply the suggested fix to the Xenomai HAL, so that new Xenomai revs will work over old Adeos patches, and the other way around too. TIA,

Quoted 1 line

Wolfgang.

Signature · 1 line
Philippe.
#21 lore raw
In reply to Wolfgang Grandegger
Quoted 58 lines · Wolfgang Grandegger
Quoted 57 lines · Philippe Gerum
Quoted 55 lines · Philippe Gerum
Quoted 49 lines · Wolfgang Grandegger
Quoted 42 lines · Philippe Gerum
Quoted 27 lines · Wolfgang Grandegger
Quoted 8 lines · Matthias Fuchs
Quoted 5 lines · Wolfgang Grandegger

In 2.6 the interrupts are disabled by default. Then the attached patch for Xenomai should help.

Wolfgang.

Your patch also works fine. Now what's the recommended solution? I noticed that Philippe already checked in an Adeos fix.

As mentioned, in Linux 2.6 (generic IRQ layer), IRQs are disabled by default in kernel/irq/handle.c:

   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
         [0 ... NR_IRQS-1] = {
                 .status = IRQ_DISABLED,
                 .handler = &no_irq_type,
                 .lock = SPIN_LOCK_UNLOCKED
         }
   };

Till now, I haven't found IPIPE/Xenomai related code removing the IRQ_DISABLED bit. But I wonder why it's working for x86. Maybe I have missed something.

In Linux 2.4, the "status" field is initialized to 0 (in arch/ppc/kernel/irq.c) not making trouble:

Quoted 6 lines
   irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned =
         { [0 ... NR_IRQS-1] = { 0, NULL, NULL, 0, SPIN_LOCK_UNLOCKED}};

At least my CAN PCI card on a MPC5200 works fine.

Philippe, do we really need these ugly PIC patches?

Not anymore, since we decided to stop supporting a tortuous use case where some IRQ channel could be shared between a Xenomai ISR and a Linux handler for handling mixed RT/non-RT devices (which was something of a bugous design anyway). Doing so, the patch was about preventing IRQ_INPROGRESS to block IRQ reenabling requests issued from a Xenomai ISR (i.e. in case a RT interrupt preempts the regular Linux handler for the same IRQ channel).

Quoted 6 lines

The problem I see now, is that removing the work-arounds from the various PIC code would void the ability to use recent Adeos patches with older Xenomai releases. I'm not opposed to that, provided we backport your fix to 2.1.x and above, but this is an issue we should keep in mind. Perhaps the next Adeos patches should even make un-fixed Xenomai releases choke at compilation time.

Quoted 3 lines

We could also set the relevant status field bits to 0 somewhere in the IPIPE-patch when the IRQ is requested or overtaken. I think this is a general issue (not only on PowerPC).

This would not clear the issue for IRQ_INPROGRESS, which is raised upon IRQ handling.

Quoted 8 lines
Quoted 4 lines

I mean this would not fix all the use cases, but this would be sufficient to solve the non-tortuous ones, I agree. So yes, IRQ_DISABLED could just be cleared in ipipe_virtualize_irq_from(), and that should be enough.

Ok, should I fix that and remove all PowerPC PIC patches already for the Adeos iPipe PPC patch for 2.6.18rc6 I'm currently working on?

This is the way I fixed it for Adeos over ppc, so that I can apply the same logic to all other supported archs:

ipipe/core.c +15 -13
@@ -565,20 +565,22 @@
 	ipd->irqs[irq].acknowledge = acknowledge;
 	ipd->irqs[irq].control = modemask;
 
-	if (irq < NR_IRQS &&
-	    handler != NULL &&
-	    !ipipe_virtual_irq_p(irq) && (modemask & IPIPE_ENABLE_MASK) != 0) {
-		if (ipd != ipipe_current_domain) {
-			/* IRQ enable/disable state is domain-sensitive, so we may
-			   not change it for another domain. What is allowed
-			   however is forcing some domain to handle an interrupt
-			   source, by passing the proper 'ipd' descriptor which
-			   thus may be different from ipipe_current_domain. */
-			err = -EPERM;
-			goto unlock_and_exit;
-		}
+	if (irq < NR_IRQS && handler != NULL && !ipipe_virtual_irq_p(irq)) {
+		__ipipe_enable_irqdesc(irq);
 
-		__ipipe_enable_irq(irq);
+		if ((modemask & IPIPE_ENABLE_MASK) != 0) {
+			if (ipd != ipipe_current_domain) {
+				/* IRQ enable/disable state is domain-sensitive, so we may
+				   not change it for another domain. What is allowed
+				   however is forcing some domain to handle an interrupt
+				   source, by passing the proper 'ipd' descriptor which
+				   thus may be different from ipipe_current_domain. */
+				err = -EPERM;
+				goto unlock_and_exit;
+			}
+			
+			__ipipe_enable_irq(irq);
+		}
 	}
 
 	err = 0;

Index: include/asm-ppc/ipipe.h
===================================================================
RCS file: /var/cvs/adeos/ipipe/v2.6/common/include/asm-ppc/ipipe.h,v retrieving revision 1.28

asm-ppc/ipipe.h +3 -1
diff -u -r1.28 ipipe.h
@@ -146,7 +146,9 @@
 
 #define __ipipe_check_platform()	do { } while(0)
 
-#define __ipipe_enable_irq(irq)		enable_irq(irq)
+#define __ipipe_enable_irqdesc(irq)	do { irq_desc[irq].status &= ~IRQ_DISABLED; } while(0)
+
+#define __ipipe_enable_irq(irq)	enable_irq(irq)
 
 #define __ipipe_disable_irq(irq)	disable_irq(irq)
 
Quoted 1 line

Wolfgang.

Signature · 1 line
Philippe.
#22 lore raw
In reply to Wolfgang Grandegger
Quoted 27 lines · Wolfgang Grandegger
Quoted 26 lines · Matthias Fuchs
Quoted 13 lines · Wolfgang Grandegger
Quoted 3 lines

A possible explanation is that configurations only using the timer IRQ are not affected, since the decrementer is not subject to this issue (the tick handler returns XN_ISR_NOENABLE anyway).

I run RT-Socket-CAN on a CAN PCI Card on my MPC5200 without any problems, so far (under Linux 2.4). Here the end function of the PIC:

   static void
   mpc5xxx_ic_end(unsigned int irq)
   {
         if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
                 mpc5xxx_ic_enable(irq);
   }
Quoted 3 lines

Matthias, have you printed out the value of status? I'm just curious.

Wolfgang.

Here it comes:
bash-3.00# ./bin/rtcansend rtcan0 -i 0 1 2 3 4
_end: status=00000042
bash-3.00# ./bin/rtcansend rtcan0 -i 0 1 2 3 4
_end: status=00000042
bash-3.00# ./bin/rtcansend rtcan0 -i 0 1 2 3 4
_end: status=00000042

Quoted 4 lines
Quoted 1 line

So it's IRQ_DISABLED (=2).

In 2.6 the interrupts are disabled by default. Then the attached patch for Xenomai should help.

Applied, thanks.

Signature · 1 line
Philippe.