Skip to contentSkip to conversation

one-shot fasteoi irqs

Xenomai Gilles Chanteperdrix 4 participants 14 messages Mar 26, 2013 – Apr 11, 2013 IRQ

lore
Share & tools
lore
#0 lore raw

Hi Jan,

I seem to recall you sent patches to fix threaded irqs some time ago. I am having a problem here without SMP, whereas the system works with SMP. A fasteoi irq handler triggers repeatedly while its threaded counterpart never gets triggered. I believe this is because handle_fasteoi_irq unconditionally releases the irq line. The following patch seems to fix the issue though I would prefer a cleaner solution.

kernel/irq/chip.c +5 -2
index 11e75d1..2ff8d3a 100644
@@ -463,8 +463,11 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
 #ifdef CONFIG_IPIPE
 	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */
-	if (desc->irq_data.chip->irq_release)
-		desc->irq_data.chip->irq_release(&desc->irq_data);
+	if (desc->irq_data.chip->irq_release) {
+		if ((!(desc->istate & IRQS_ONESHOT) ||
+		     !desc->threads_oneshot))
+			desc->irq_data.chip->irq_release(&desc->irq_data);
+	}
 out_eoi:
 #else  /* !CONFIG_IPIPE */
 	if (desc->istate & IRQS_ONESHOT)
kernel/irq/manage.c +9 -3
index e49a288..485c2c4 100644
@@ -715,9 +715,15 @@ again:
 
 	desc->threads_oneshot &= ~action->thread_mask;
 
-	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data) &&
-	    irqd_irq_masked(&desc->irq_data))
-		unmask_irq(desc);
+	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data)) {
+#ifdef CONFIG_IPIPE
+		if (desc->irq_data.chip->irq_release)
+			desc->irq_data.chip->irq_release(&desc->irq_data);
+		else 
+#endif
+			if (irqd_irq_masked(&desc->irq_data))
+				unmask_irq(desc);
+	}
 
 out_unlock:
 	raw_spin_unlock_irq(&desc->lock);
Signature · 1 line
                                                                Gilles.
#1 lore raw
Quoted 4 lines · Gilles Chanteperdrix

Hi Jan,

I seem to recall you sent patches to fix threaded irqs some time ago. I

In fact, that was Wolfgang with commits fdda86bca9 and 54d161b85b for 2.6.38 back then.

Quoted 4 lines

am having a problem here without SMP, whereas the system works with SMP. A fasteoi irq handler triggers repeatedly while its threaded counterpart never gets triggered. I believe this is because handle_fasteoi_irq unconditionally releases the irq line.

You mean it doesn't respect the conditions in cond_unmask_irq?

Quoted 36 lines

The following
patch seems to fix the issue though I would prefer a cleaner solution.

kernel/irq/chip.c +5 -2
index 11e75d1..2ff8d3a 100644
@@ -463,8 +463,11 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
 #ifdef CONFIG_IPIPE
 	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */
-	if (desc->irq_data.chip->irq_release)
-		desc->irq_data.chip->irq_release(&desc->irq_data);
+	if (desc->irq_data.chip->irq_release) {
+		if ((!(desc->istate & IRQS_ONESHOT) ||
+		     !desc->threads_oneshot))
+			desc->irq_data.chip->irq_release(&desc->irq_data);
+	}
 out_eoi:
 #else  /* !CONFIG_IPIPE */
 	if (desc->istate & IRQS_ONESHOT)
kernel/irq/manage.c +2 -3
index e49a288..485c2c4 100644
@@ -715,9 +715,15 @@ again:
 
 	desc->threads_oneshot &= ~action->thread_mask;
 
-	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data) &&
-	    irqd_irq_masked(&desc->irq_data))
-		unmask_irq(desc);
+	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data)) {
+#ifdef CONFIG_IPIPE

kernel/irq/manage.c again: · line 729

Quoted 10 lines
kernel/irq/manage.c +7 -0
+		if (desc->irq_data.chip->irq_release)
+			desc->irq_data.chip->irq_release(&desc->irq_data);
+		else 
+#endif
+			if (irqd_irq_masked(&desc->irq_data))
+				unmask_irq(desc);
+	}
 
 out_unlock:
 	raw_spin_unlock_irq(&desc->lock);

So this basically extends I-pipe's held phase of the IRQ to the threaded handler if we are working in oneshot mode, right?

I will have to dig into this again, but without remembering all details, there are some things that do not look OK:
- Shouldn't we just replace unmask_irq with irq_release for the I-pipe case? IOW: There is too much code under #ifdef CONFIG_IPIPE.
- It seems we do not respect masking done by Linux, rather unconditionally release (AKA unmask) the line.

The latter was right in 2.6.38 but apparently got broken during to port from 3.2 to 3.4.

Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20130327/d590dc7c/attachment.pgp>

#2 lore raw
Quoted 66 lines · Jan Kiszka
Quoted 4 lines · Gilles Chanteperdrix

Hi Jan,

I seem to recall you sent patches to fix threaded irqs some time ago. I

In fact, that was Wolfgang with commits fdda86bca9 and 54d161b85b for 2.6.38 back then.

Quoted 4 lines

am having a problem here without SMP, whereas the system works with SMP. A fasteoi irq handler triggers repeatedly while its threaded counterpart never gets triggered. I believe this is because handle_fasteoi_irq unconditionally releases the irq line.

You mean it doesn't respect the conditions in cond_unmask_irq?

Quoted 36 lines

The following
patch seems to fix the issue though I would prefer a cleaner solution.

kernel/irq/chip.c +5 -2
index 11e75d1..2ff8d3a 100644
@@ -463,8 +463,11 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
 #ifdef CONFIG_IPIPE
 	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */
-	if (desc->irq_data.chip->irq_release)
-		desc->irq_data.chip->irq_release(&desc->irq_data);
+	if (desc->irq_data.chip->irq_release) {
+		if ((!(desc->istate & IRQS_ONESHOT) ||
+		     !desc->threads_oneshot))
+			desc->irq_data.chip->irq_release(&desc->irq_data);
+	}
 out_eoi:
 #else  /* !CONFIG_IPIPE */
 	if (desc->istate & IRQS_ONESHOT)
kernel/irq/manage.c +2 -3
index e49a288..485c2c4 100644
@@ -715,9 +715,15 @@ again:
 
 	desc->threads_oneshot &= ~action->thread_mask;
 
-	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data) &&
-	    irqd_irq_masked(&desc->irq_data))
-		unmask_irq(desc);
+	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data)) {
+#ifdef CONFIG_IPIPE

kernel/irq/manage.c again: · line 729

Quoted 10 lines
kernel/irq/manage.c +7 -0
+		if (desc->irq_data.chip->irq_release)
+			desc->irq_data.chip->irq_release(&desc->irq_data);
+		else 
+#endif
+			if (irqd_irq_masked(&desc->irq_data))
+				unmask_irq(desc);
+	}
 
 out_unlock:
 	raw_spin_unlock_irq(&desc->lock);

So this basically extends I-pipe's held phase of the IRQ to the threaded handler if we are working in oneshot mode, right?

Quoted 4 lines

I will have to dig into this again, but without remembering all details, there are some things that do not look OK:
- Shouldn't we just replace unmask_irq with irq_release for the I-pipe case? IOW: There is too much code under #ifdef CONFIG_IPIPE.

No, unmask_irq still has to use ->irq_unmask, while the masking done by the I-pipe has to use ->irq_release.

Quoted 2 lines

- It seems we do not respect masking done by Linux, rather unconditionally release (AKA unmask) the line.

You mean masking which could be done by the interrupt handler?

Quoted 3 lines

The latter was right in 2.6.38 but apparently got broken during to port from 3.2 to 3.4.

fasteoi irqs were reworked with the introduction of ->irq_hold and ->irq_release, because the 2.6.38 was found not to work either...

Signature · 1 line
                                                                Gilles.
#3 lore raw
Quoted 68 lines · Gilles Chanteperdrix
Quoted 66 lines · Jan Kiszka
Quoted 4 lines · Gilles Chanteperdrix

Hi Jan,

I seem to recall you sent patches to fix threaded irqs some time ago. I

In fact, that was Wolfgang with commits fdda86bca9 and 54d161b85b for 2.6.38 back then.

Quoted 4 lines

am having a problem here without SMP, whereas the system works with SMP. A fasteoi irq handler triggers repeatedly while its threaded counterpart never gets triggered. I believe this is because handle_fasteoi_irq unconditionally releases the irq line.

You mean it doesn't respect the conditions in cond_unmask_irq?

Quoted 36 lines

The following
patch seems to fix the issue though I would prefer a cleaner solution.

kernel/irq/chip.c +5 -2
index 11e75d1..2ff8d3a 100644
@@ -463,8 +463,11 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
 #ifdef CONFIG_IPIPE
 	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */
-	if (desc->irq_data.chip->irq_release)
-		desc->irq_data.chip->irq_release(&desc->irq_data);
+	if (desc->irq_data.chip->irq_release) {
+		if ((!(desc->istate & IRQS_ONESHOT) ||
+		     !desc->threads_oneshot))
+			desc->irq_data.chip->irq_release(&desc->irq_data);
+	}
 out_eoi:
 #else  /* !CONFIG_IPIPE */
 	if (desc->istate & IRQS_ONESHOT)
kernel/irq/manage.c +2 -3
index e49a288..485c2c4 100644
@@ -715,9 +715,15 @@ again:
 
 	desc->threads_oneshot &= ~action->thread_mask;
 
-	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data) &&
-	    irqd_irq_masked(&desc->irq_data))
-		unmask_irq(desc);
+	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data)) {
+#ifdef CONFIG_IPIPE

kernel/irq/manage.c again: · line 729

Quoted 10 lines
kernel/irq/manage.c +7 -0
+		if (desc->irq_data.chip->irq_release)
+			desc->irq_data.chip->irq_release(&desc->irq_data);
+		else 
+#endif
+			if (irqd_irq_masked(&desc->irq_data))
+				unmask_irq(desc);
+	}
 
 out_unlock:
 	raw_spin_unlock_irq(&desc->lock);

So this basically extends I-pipe's held phase of the IRQ to the threaded handler if we are working in oneshot mode, right?

Quoted 8 lines
Quoted 4 lines

I will have to dig into this again, but without remembering all details, there are some things that do not look OK:
- Shouldn't we just replace unmask_irq with irq_release for the I-pipe case? IOW: There is too much code under #ifdef CONFIG_IPIPE.

No, unmask_irq still has to use ->irq_unmask, while the masking done by the I-pipe has to use ->irq_release.

No, I mean that unmask should be replaced by release, but we must not apply different conditions on the unmask, at least the logical one. If Linux wants the line to remain masked, we have to respect this. That is currently (also) broken after the last refactoring.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
#4 lore raw
Quoted 75 lines · Jan Kiszka
Quoted 74 lines · Gilles Chanteperdrix
Quoted 70 lines · Jan Kiszka
Quoted 4 lines · Gilles Chanteperdrix

Hi Jan,

I seem to recall you sent patches to fix threaded irqs some time ago. I

In fact, that was Wolfgang with commits fdda86bca9 and 54d161b85b for 2.6.38 back then.

Quoted 4 lines

am having a problem here without SMP, whereas the system works with SMP. A fasteoi irq handler triggers repeatedly while its threaded counterpart never gets triggered. I believe this is because handle_fasteoi_irq unconditionally releases the irq line.

You mean it doesn't respect the conditions in cond_unmask_irq?

Quoted 36 lines

The following
patch seems to fix the issue though I would prefer a cleaner solution.

kernel/irq/chip.c +5 -2
index 11e75d1..2ff8d3a 100644
@@ -463,8 +463,11 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
 #ifdef CONFIG_IPIPE
 	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */
-	if (desc->irq_data.chip->irq_release)
-		desc->irq_data.chip->irq_release(&desc->irq_data);
+	if (desc->irq_data.chip->irq_release) {
+		if ((!(desc->istate & IRQS_ONESHOT) ||
+		     !desc->threads_oneshot))
+			desc->irq_data.chip->irq_release(&desc->irq_data);
+	}
 out_eoi:
 #else  /* !CONFIG_IPIPE */
 	if (desc->istate & IRQS_ONESHOT)
kernel/irq/manage.c +2 -3
index e49a288..485c2c4 100644
@@ -715,9 +715,15 @@ again:
 
 	desc->threads_oneshot &= ~action->thread_mask;
 
-	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data) &&
-	    irqd_irq_masked(&desc->irq_data))
-		unmask_irq(desc);
+	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data)) {
+#ifdef CONFIG_IPIPE

kernel/irq/manage.c again: · line 729

Quoted 10 lines
kernel/irq/manage.c +7 -0
+		if (desc->irq_data.chip->irq_release)
+			desc->irq_data.chip->irq_release(&desc->irq_data);
+		else 
+#endif
+			if (irqd_irq_masked(&desc->irq_data))
+				unmask_irq(desc);
+	}
 
 out_unlock:
 	raw_spin_unlock_irq(&desc->lock);

So this basically extends I-pipe's held phase of the IRQ to the threaded handler if we are working in oneshot mode, right?

I will have to dig into this again, but without remembering all details, there are some things that do not look OK:
- Shouldn't we just replace unmask_irq with irq_release for the I-pipe case? IOW: There is too much code under #ifdef CONFIG_IPIPE.

Quoted 7 lines
Quoted 2 lines

No, unmask_irq still has to use ->irq_unmask, while the masking done by the I-pipe has to use ->irq_release.

No, I mean that unmask should be replaced by release, but we must not apply different conditions on the unmask, at least the logical one. If Linux wants the line to remain masked, we have to respect this. That is currently (also) broken after the last refactoring.

Ok, how about this one:

iff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 11e75d1..47d1d27 100644

kernel/irq/chip.c +14 -6
@@ -256,13 +256,19 @@ void mask_irq(struct irq_desc *desc)
 void unmask_irq(struct irq_desc *desc)
 {
 	unsigned long flags;
-
+	
+	flags = hard_cond_local_irq_save();
+#ifdef CONFIG_IPIPE
+	if (desc->irq_data.chip->irq_release) {
+		desc->irq_data.chip->irq_release(&desc->irq_data);
+		irq_state_clr_masked(desc);
+	} else
+#endif /* CONFIG_IPIPE */
 	if (desc->irq_data.chip->irq_unmask) {
-		flags = hard_cond_local_irq_save();
 		desc->irq_data.chip->irq_unmask(&desc->irq_data);
 		irq_state_clr_masked(desc);
-		hard_cond_local_irq_restore(flags);
 	}
+	hard_cond_local_irq_restore(flags);
 }
 
 /*
@@ -463,8 +469,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
 #ifdef CONFIG_IPIPE
 	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */
-	if (desc->irq_data.chip->irq_release)
-		desc->irq_data.chip->irq_release(&desc->irq_data);
+	cond_unmask_irq(desc);
 out_eoi:
 #else  /* !CONFIG_IPIPE */
 	if (desc->istate & IRQS_ONESHOT)
@@ -682,12 +687,15 @@ void __ipipe_end_level_irq(unsigned irq, struct irq_desc *desc)
 void __ipipe_ack_fasteoi_irq(unsigned irq, struct irq_desc *desc)
 {
 	desc->irq_data.chip->irq_hold(&desc->irq_data);
+	irq_state_set_masked(desc);	
 }
 
 void __ipipe_end_fasteoi_irq(unsigned irq, struct irq_desc *desc)
 {
-	if (desc->irq_data.chip->irq_release)
+	if (desc->irq_data.chip->irq_release) {
+		irq_state_clr_masked(desc);		
 		desc->irq_data.chip->irq_release(&desc->irq_data);
+	}
 }
 
 void __ipipe_ack_edge_irq(unsigned irq, struct irq_desc *desc)
Signature · 1 line
                                                                Gilles.
#5 lore raw
Quoted 7 lines · Gilles Chanteperdrix

Ok, how about this one:

iff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 11e75d1..47d1d27 100644

kernel/irq/chip.c void mask_irq(struct irq_desc *desc) · line 264

Quoted 10 lines
kernel/irq/chip.c +6 -1
@@ -256,13 +256,19 @@ void mask_irq(struct irq_desc *desc)
 void unmask_irq(struct irq_desc *desc)
 {
 	unsigned long flags;
-
+	
+	flags = hard_cond_local_irq_save();
+#ifdef CONFIG_IPIPE
+	if (desc->irq_data.chip->irq_release) {
+		desc->irq_data.chip->irq_release(&desc->irq_data);
+		irq_state_clr_masked(desc);

Are you sure that every call to unmask_irq implies (under I-pipe) that the IRQ was held before so that release_irq is appropriate here? Or did you rather want to patch cond_unmask_irq this way? But that has unfortunately also more users than our fast_eoi path.

Quoted 13 lines
kernel/irq/chip.c +3 -2
+	} else
+#endif /* CONFIG_IPIPE */
 	if (desc->irq_data.chip->irq_unmask) {
-		flags = hard_cond_local_irq_save();
 		desc->irq_data.chip->irq_unmask(&desc->irq_data);
 		irq_state_clr_masked(desc);
-		hard_cond_local_irq_restore(flags);
 	}
+	hard_cond_local_irq_restore(flags);
 }
 
 /*

kernel/irq/chip.c handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) · line 472

Quoted 6 lines
kernel/irq/chip.c +1 -2
@@ -463,8 +469,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
 #ifdef CONFIG_IPIPE
 	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */
-	if (desc->irq_data.chip->irq_release)
-		desc->irq_data.chip->irq_release(&desc->irq_data);
+	cond_unmask_irq(desc);

I'm wondering now why we need this differently for the I-pipe case.

Let's revisit what happens with a fasteoi normally:

- it's masked only if it's a oneshot IRQ before calling the flow handler
- it's unmasked after the flow handling if the thread was not woken up

With I-pipe we already enter handle_fasteoi_irq with the IRQ masked. The conditions and spots to unmask are:
- from handle_fasteoi_irq if the thread wasn't woken up or we have non-threaded or non-oneshot handling
- otherwise on end_irq from the handler thread

Do you think this is correct? If so, I do not think it matches this patch yet.

Jan

Quoted 23 lines
kernel/irq/chip.c +4 -1
 out_eoi:
 #else  /* !CONFIG_IPIPE */
 	if (desc->istate & IRQS_ONESHOT)
@@ -682,12 +687,15 @@ void __ipipe_end_level_irq(unsigned irq, struct irq_desc *desc)
 void __ipipe_ack_fasteoi_irq(unsigned irq, struct irq_desc *desc)
 {
 	desc->irq_data.chip->irq_hold(&desc->irq_data);
+	irq_state_set_masked(desc);	
 }
 
 void __ipipe_end_fasteoi_irq(unsigned irq, struct irq_desc *desc)
 {
-	if (desc->irq_data.chip->irq_release)
+	if (desc->irq_data.chip->irq_release) {
+		irq_state_clr_masked(desc);		
 		desc->irq_data.chip->irq_release(&desc->irq_data);
+	}
 }
 
 void __ipipe_ack_edge_irq(unsigned irq, struct irq_desc *desc)
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
#6 lore raw
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Gilles Chanteperdrix

Ok, how about this one:

iff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 11e75d1..47d1d27 100644

kernel/irq/chip.c +1 -1
@@ -256,13 +256,19 @@ void mask_irq(struct irq_desc *desc)
 void unmask_irq(struct irq_desc *desc)
 {
 	unsigned long flags;
-
+	
Quoted 8 lines

kernel/irq/chip.c void mask_irq(struct irq_desc *desc) · line 264

Quoted 5 lines
kernel/irq/chip.c +5 -0
+	flags = hard_cond_local_irq_save();
+#ifdef CONFIG_IPIPE
+	if (desc->irq_data.chip->irq_release) {
+		desc->irq_data.chip->irq_release(&desc->irq_data);
+		irq_state_clr_masked(desc);

Are you sure that every call to unmask_irq implies (under I-pipe) that the IRQ was held before so that release_irq is appropriate here?

Yes, unmask_irq is always called after testing for irqd_irq_masked, so, since ipipe_ack_fasteoi_irq is modified for setting the corresponding bit, and ipipe_end_fasteoi_irq clearing it, if the bit is set, the irq can be unmasked.

Quoted 3 lines

Or did
you rather want to patch cond_unmask_irq this way? But that has unfortunately also more users than our fast_eoi path.

No, the reason unmask_irq has to be changed that way is because irq_finalize_oneshot, which does not know whether it is dealing with a fasteoi, level, edge, irq, calls unmask_irq unconditionnaly, so, if we want irq_release to be called from that point for fasteoi irqs, we have to change unmask_irq.

Alternatively, we could call ->ipipe_end with a #ifdef CONFIG_IPIPE in irq_finalize_oneshot..

Quoted 15 lines
Quoted 15 lines
kernel/irq/chip.c +3 -2
+	} else
+#endif /* CONFIG_IPIPE */
 	if (desc->irq_data.chip->irq_unmask) {
-		flags = hard_cond_local_irq_save();
 		desc->irq_data.chip->irq_unmask(&desc->irq_data);
 		irq_state_clr_masked(desc);
-		hard_cond_local_irq_restore(flags);
 	}
+	hard_cond_local_irq_restore(flags);
 }
 
 /*
@@ -463,8 +469,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
Quoted 7 lines

kernel/irq/chip.c handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) · line 472

Quoted 5 lines
kernel/irq/chip.c +1 -2
 #ifdef CONFIG_IPIPE
 	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */
-	if (desc->irq_data.chip->irq_release)
-		desc->irq_data.chip->irq_release(&desc->irq_data);
+	cond_unmask_irq(desc);

I'm wondering now why we need this differently for the I-pipe case.

In the non I-pipe case, we have:

	if (desc->istate & IRQS_ONESHOT)
		cond_unmask_irq(desc);

Which is wrong with I-pipe because we want the irq unmasked even for irqs which are not one-host.

Then:

	desc->irq_data.chip->irq_eoi(&desc->irq_data);

Which is wrong because the EOI was already sent as part of the irq_hold callback.

Quoted 10 lines

Let's revisit what happens with a fasteoi normally:

- it's masked only if it's a oneshot IRQ before calling the flow handler
- it's unmasked after the flow handling if the thread was not woken up

With I-pipe we already enter handle_fasteoi_irq with the IRQ masked. The conditions and spots to unmask are:
- from handle_fasteoi_irq if the thread wasn't woken up or we have non-threaded or non-oneshot handling

That is what the unconditional call to cond_unmask_irq does.

Quoted 1 line

- otherwise on end_irq from the handler thread

That is what the call to unmask_irq at the end of irq_finalize_oneshot does.

Quoted 4 lines

Do you think this is correct? If so, I do not think it matches this

patch yet.

Seems to me that it does (and indeed the patched kernel works for me, I tested before sending the patch).

Signature · 1 line
                                                                Gilles.
#7 lore raw
In reply to Jan Kiszka
Quoted 7 lines · Jan Kiszka

I'm wondering now why we need this differently for the I-pipe case.

Let's revisit what happens with a fasteoi normally:

- it's masked only if it's a oneshot IRQ before calling the flow handler
- it's unmasked after the flow handling if the thread was not woken up

Quoted 8 lines

With I-pipe we already enter handle_fasteoi_irq with the IRQ masked. The conditions and spots to unmask are:
- from handle_fasteoi_irq if the thread wasn't woken up or we have non-threaded or non-oneshot handling
- otherwise on end_irq from the handler thread

Do you think this is correct? If so, I do not think it matches this patch yet.

Hi,

here is a much simpler patch:

kernel/irq/chip.c +8 -2
index 11e75d1..a1c9918 100644
@@ -421,6 +421,13 @@ static inline void preflow_handler(struct irq_desc *desc)
 static inline void preflow_handler(struct irq_desc *desc) { }
 #endif
 
+static void cond_release_fasteoi_irq(struct irq_desc *desc)
+{
+	if (desc->irq_data.chip->irq_release && 
+	    !irqd_irq_disabled(&desc->irq_data) && !desc->threads_oneshot)
+		desc->irq_data.chip->irq_release(&desc->irq_data);
+}
+
 /**
  *	handle_fasteoi_irq - irq handler for transparent controllers
  *	@irq:	the interrupt number
@@ -463,8 +470,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
 #ifdef CONFIG_IPIPE
 	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */
-	if (desc->irq_data.chip->irq_release)
-		desc->irq_data.chip->irq_release(&desc->irq_data);
+	cond_release_fasteoi_irq(desc);
 out_eoi:
 #else  /* !CONFIG_IPIPE */
 	if (desc->istate & IRQS_ONESHOT)
kernel/irq/manage.c +5 -0
index e49a288..e7ae8bd 100644
@@ -715,9 +715,14 @@ again:
 
 	desc->threads_oneshot &= ~action->thread_mask;
 
+#ifndef CONFIG_IPIPE
 	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data) &&
 	    irqd_irq_masked(&desc->irq_data))
 		unmask_irq(desc);
+#else /* CONFIG_IPIPE */
+	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data))
+		desc->ipipe_end(desc->irq_data.irq, desc);
+#endif /* CONFIG_IPIPE */
 
 out_unlock:
 	raw_spin_unlock_irq(&desc->lock);
Signature · 1 line
                                                                Gilles.
#8 lore raw
Quoted 41 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka

I'm wondering now why we need this differently for the I-pipe case.

Let's revisit what happens with a fasteoi normally:

- it's masked only if it's a oneshot IRQ before calling the flow handler
- it's unmasked after the flow handling if the thread was not woken up

Quoted 8 lines

With I-pipe we already enter handle_fasteoi_irq with the IRQ masked. The conditions and spots to unmask are:
- from handle_fasteoi_irq if the thread wasn't woken up or we have non-threaded or non-oneshot handling
- otherwise on end_irq from the handler thread

Do you think this is correct? If so, I do not think it matches this patch yet.

Hi,

here is a much simpler patch:

kernel/irq/chip.c +7 -0
index 11e75d1..a1c9918 100644
@@ -421,6 +421,13 @@ static inline void preflow_handler(struct irq_desc *desc)
 static inline void preflow_handler(struct irq_desc *desc) { }
 #endif
 
+static void cond_release_fasteoi_irq(struct irq_desc *desc)
+{
+	if (desc->irq_data.chip->irq_release && 
+	    !irqd_irq_disabled(&desc->irq_data) && !desc->threads_oneshot)
+		desc->irq_data.chip->irq_release(&desc->irq_data);
+}
+
 /**
  *	handle_fasteoi_irq - irq handler for transparent controllers
  *	@irq:	the interrupt number

kernel/irq/chip.c handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) · line 472

Quoted 3 lines
kernel/irq/chip.c +0 -0
@@ -463,8 +470,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
 #ifdef CONFIG_IPIPE
 	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */

Makes me wonder what this comment wants to tell us. That there is an unhandled corner case or that this is intentionally ignored? I support the latter as I-pipe already does EOI when accepting the IRQ, no? Maybe you can clarify that line at this chance.

Quoted 17 lines
kernel/irq/chip.c +1 -2
-	if (desc->irq_data.chip->irq_release)
-		desc->irq_data.chip->irq_release(&desc->irq_data);
+	cond_release_fasteoi_irq(desc);
 out_eoi:
 #else  /* !CONFIG_IPIPE */
 	if (desc->istate & IRQS_ONESHOT)
kernel/irq/manage.c +1 -0
index e49a288..e7ae8bd 100644
@@ -715,9 +715,14 @@ again:
 
 	desc->threads_oneshot &= ~action->thread_mask;
 
+#ifndef CONFIG_IPIPE

kernel/irq/manage.c again: · line 728

Quoted 10 lines
kernel/irq/manage.c +4 -0
 	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data) &&
 	    irqd_irq_masked(&desc->irq_data))
 		unmask_irq(desc);
+#else /* CONFIG_IPIPE */
+	if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data))
+		desc->ipipe_end(desc->irq_data.irq, desc);
+#endif /* CONFIG_IPIPE */
 
 out_unlock:
 	raw_spin_unlock_irq(&desc->lock);

Looks good. I should dig out our test case again and check it on x86. I think it was PCI device assignment with KVM where the IRQ of the assigned device is handled by an IRQ thread of KVM.

Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20130406/ef69ff66/attachment.pgp>

#9 lore raw
Quoted 43 lines · Jan Kiszka
Quoted 42 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka

I'm wondering now why we need this differently for the I-pipe case.

Let's revisit what happens with a fasteoi normally:

- it's masked only if it's a oneshot IRQ before calling the flow handler
- it's unmasked after the flow handling if the thread was not woken up

Quoted 8 lines

With I-pipe we already enter handle_fasteoi_irq with the IRQ masked. The conditions and spots to unmask are:
- from handle_fasteoi_irq if the thread wasn't woken up or we have non-threaded or non-oneshot handling
- otherwise on end_irq from the handler thread

Do you think this is correct? If so, I do not think it matches this patch yet.

Hi,

here is a much simpler patch:

kernel/irq/chip.c +7 -0
index 11e75d1..a1c9918 100644
@@ -421,6 +421,13 @@ static inline void preflow_handler(struct irq_desc *desc)
 static inline void preflow_handler(struct irq_desc *desc) { }
 #endif
 
+static void cond_release_fasteoi_irq(struct irq_desc *desc)
+{
+	if (desc->irq_data.chip->irq_release && 
+	    !irqd_irq_disabled(&desc->irq_data) && !desc->threads_oneshot)
+		desc->irq_data.chip->irq_release(&desc->irq_data);
+}
+
 /**
  *	handle_fasteoi_irq - irq handler for transparent controllers
  *	@irq:	the interrupt number
@@ -463,8 +470,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
Quoted 7 lines

kernel/irq/chip.c handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) · line 472

Quoted 2 lines
kernel/irq/chip.c +0 -0
 #ifdef CONFIG_IPIPE
 	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */

Makes me wonder what this comment wants to tell us. That there is an unhandled corner case or that this is intentionally ignored? I support the latter as I-pipe already does EOI when accepting the IRQ, no? Maybe you can clarify that line at this chance.

I have no idea where this comment come from. I do not think this flag can be handled with the I-pipe kernel, as the EOI is sent before trying to handle the IRQ. The only users are in arch/sparc and arch/powerpc, maybe Philippe knows more?

Signature · 1 line
                                                                Gilles.
#10 lore raw
Quoted 54 lines · Gilles Chanteperdrix
Quoted 43 lines · Jan Kiszka
Quoted 42 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka

I'm wondering now why we need this differently for the I-pipe case.

Let's revisit what happens with a fasteoi normally:

- it's masked only if it's a oneshot IRQ before calling the flow handler
- it's unmasked after the flow handling if the thread was not woken up

Quoted 8 lines

With I-pipe we already enter handle_fasteoi_irq with the IRQ masked. The conditions and spots to unmask are:
- from handle_fasteoi_irq if the thread wasn't woken up or we have non-threaded or non-oneshot handling
- otherwise on end_irq from the handler thread

Do you think this is correct? If so, I do not think it matches this patch yet.

Hi,

here is a much simpler patch:

kernel/irq/chip.c +7 -0
index 11e75d1..a1c9918 100644
@@ -421,6 +421,13 @@ static inline void preflow_handler(struct irq_desc *desc)
  static inline void preflow_handler(struct irq_desc *desc) { }
  #endif
 
+static void cond_release_fasteoi_irq(struct irq_desc *desc)
+{
+	if (desc->irq_data.chip->irq_release &&
+	    !irqd_irq_disabled(&desc->irq_data) && !desc->threads_oneshot)
+		desc->irq_data.chip->irq_release(&desc->irq_data);
+}
+
  /**
   *	handle_fasteoi_irq - irq handler for transparent controllers
   *	@irq:	the interrupt number
@@ -463,8 +470,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
Quoted 7 lines

kernel/irq/chip.c handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) · line 472

Quoted 2 lines
kernel/irq/chip.c +0 -0
  #ifdef CONFIG_IPIPE
  	/* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */

Makes me wonder what this comment wants to tell us. That there is an unhandled corner case or that this is intentionally ignored? I support the latter as I-pipe already does EOI when accepting the IRQ, no? Maybe you can clarify that line at this chance.

Quoted 5 lines

I have no idea where this comment come from. I do not think this flag can be handled with the I-pipe kernel, as the EOI is sent before trying to handle the IRQ. The only users are in arch/sparc and arch/powerpc, maybe Philippe knows more?

Jan is right, we ignore EOI_IF_HANDLED and never send EOI from the regular flow handler, as a consequence of doing eoi+mask when holding the IRQ in the ipipe's flow handler.

Signature · 1 line
Philippe.
#11 lore raw
Quoted 65 lines · Philippe Gerum
Quoted 58 lines · Gilles Chanteperdrix
Quoted 47 lines · Jan Kiszka
Quoted 46 lines · Gilles Chanteperdrix
Quoted 15 lines · Jan Kiszka

I'm wondering now why we need this differently for the I-pipe case.

Let's revisit what happens with a fasteoi normally:

- it's masked only if it's a oneshot IRQ before calling the flow handler
- it's unmasked after the flow handling if the thread was not woken up

With I-pipe we already enter handle_fasteoi_irq with the IRQ masked. The
conditions and spots to unmask are:
- from handle_fasteoi_irq if the thread wasn't woken up or we have non-threaded or non-oneshot handling
- otherwise on end_irq from the handler thread

Quoted 2 lines

Do you think this is correct? If so, I do not think it matches this patch yet.

Hi,

here is a much simpler patch:

kernel/irq/chip.c +7 -0
index 11e75d1..a1c9918 100644
@@ -421,6 +421,13 @@ static inline void preflow_handler(struct
 irq_desc *desc)
  static inline void preflow_handler(struct irq_desc *desc) { }
  #endif
 
+static void cond_release_fasteoi_irq(struct irq_desc *desc)
+{
+    if (desc->irq_data.chip->irq_release &&
+        !irqd_irq_disabled(&desc->irq_data) && !desc->threads_oneshot)
+        desc->irq_data.chip->irq_release(&desc->irq_data);
+}
+
  /**
   *    handle_fasteoi_irq - irq handler for transparent controllers

* @irq: the interrupt number

kernel/irq/chip.c +0 -0
@@ -463,8 +470,7 @@ handle_fasteoi_irq(unsigned int irq, struct
 irq_desc *desc)
 
Quoted 7 lines

kernel/irq/chip.c handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) · line 472

Quoted 2 lines
kernel/irq/chip.c +0 -0
  #ifdef CONFIG_IPIPE
      /* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */

Makes me wonder what this comment wants to tell us. That there is an unhandled corner case or that this is intentionally ignored? I support the latter as I-pipe already does EOI when accepting the IRQ, no? Maybe you can clarify that line at this chance.

Quoted 5 lines

I have no idea where this comment come from. I do not think this flag can be handled with the I-pipe kernel, as the EOI is sent before trying to handle the IRQ. The only users are in arch/sparc and arch/powerpc, maybe Philippe knows more?

Quoted 3 lines

Jan is right, we ignore EOI_IF_HANDLED and never send EOI from the regular flow handler, as a consequence of doing eoi+mask when holding the IRQ in the ipipe's flow handler.

OK, then I'll write a clarification patch for that comment - to get rid of that triple X...

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
#12 lore raw
Quoted 66 lines · Jan Kiszka
Quoted 65 lines · Philippe Gerum
Quoted 63 lines · Gilles Chanteperdrix
Quoted 47 lines · Jan Kiszka
Quoted 46 lines · Gilles Chanteperdrix
Quoted 15 lines · Jan Kiszka

I'm wondering now why we need this differently for the I-pipe case.

Let's revisit what happens with a fasteoi normally:

- it's masked only if it's a oneshot IRQ before calling the flow handler
- it's unmasked after the flow handling if the thread was not woken up

With I-pipe we already enter handle_fasteoi_irq with the IRQ masked. The
conditions and spots to unmask are:
- from handle_fasteoi_irq if the thread wasn't woken up or we have non-threaded or non-oneshot handling
- otherwise on end_irq from the handler thread

Quoted 2 lines

Do you think this is correct? If so, I do not think it matches this patch yet.

Hi,

here is a much simpler patch:

kernel/irq/chip.c +7 -0
index 11e75d1..a1c9918 100644
@@ -421,6 +421,13 @@ static inline void preflow_handler(struct
 irq_desc *desc)
  static inline void preflow_handler(struct irq_desc *desc) { }
  #endif
 
+static void cond_release_fasteoi_irq(struct irq_desc *desc)
+{
+    if (desc->irq_data.chip->irq_release &&
+        !irqd_irq_disabled(&desc->irq_data) && !desc->threads_oneshot)
+        desc->irq_data.chip->irq_release(&desc->irq_data);
+}
+
  /**
   *    handle_fasteoi_irq - irq handler for transparent controllers

* @irq: the interrupt number

kernel/irq/chip.c +0 -0
@@ -463,8 +470,7 @@ handle_fasteoi_irq(unsigned int irq, struct
 irq_desc *desc)
 
Quoted 7 lines

kernel/irq/chip.c handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) · line 472

Quoted 2 lines
kernel/irq/chip.c +0 -0
  #ifdef CONFIG_IPIPE
      /* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */

Makes me wonder what this comment wants to tell us. That there is an unhandled corner case or that this is intentionally ignored? I support the latter as I-pipe already does EOI when accepting the IRQ, no? Maybe you can clarify that line at this chance.

I have no idea where this comment come from. I do not think this flag can be handled with the I-pipe kernel, as the EOI is sent before trying to handle the IRQ. The only users are in arch/sparc and arch/powerpc, maybe Philippe knows more?

Quoted 6 lines
Quoted 3 lines

Jan is right, we ignore EOI_IF_HANDLED and never send EOI from the regular flow handler, as a consequence of doing eoi+mask when holding the IRQ in the ipipe's flow handler.

OK, then I'll write a clarification patch for that comment - to get rid of that triple X...

I understand the flag with a negative sense: do not eoi the interrupt if the handler reports that it has not handled it. Obviously, if that is what the flag means, we can not honour it when the I-pipe is on.

Quoted 3 lines

Jan

Signature · 1 line
                                                                Gilles.
#13 lore raw
Quoted 72 lines · Gilles Chanteperdrix
Quoted 70 lines · Jan Kiszka
Quoted 68 lines · Philippe Gerum
Quoted 58 lines · Gilles Chanteperdrix
Quoted 47 lines · Jan Kiszka
Quoted 46 lines · Gilles Chanteperdrix
Quoted 15 lines · Jan Kiszka

I'm wondering now why we need this differently for the I-pipe case.

Let's revisit what happens with a fasteoi normally:

- it's masked only if it's a oneshot IRQ before calling the flow handler
- it's unmasked after the flow handling if the thread was not woken up

With I-pipe we already enter handle_fasteoi_irq with the IRQ masked. The
conditions and spots to unmask are:
- from handle_fasteoi_irq if the thread wasn't woken up or we have non-threaded or non-oneshot handling
- otherwise on end_irq from the handler thread

Quoted 2 lines

Do you think this is correct? If so, I do not think it matches this patch yet.

Hi,

here is a much simpler patch:

kernel/irq/chip.c +7 -0
index 11e75d1..a1c9918 100644
@@ -421,6 +421,13 @@ static inline void preflow_handler(struct
 irq_desc *desc)
   static inline void preflow_handler(struct irq_desc *desc) { }
   #endif
 
+static void cond_release_fasteoi_irq(struct irq_desc *desc)
+{
+    if (desc->irq_data.chip->irq_release &&
+        !irqd_irq_disabled(&desc->irq_data) && !desc->threads_oneshot)
+        desc->irq_data.chip->irq_release(&desc->irq_data);
+}
+
   /**
    *    handle_fasteoi_irq - irq handler for transparent controllers

* @irq: the interrupt number

kernel/irq/chip.c +0 -0
@@ -463,8 +470,7 @@ handle_fasteoi_irq(unsigned int irq, struct
 irq_desc *desc)
 
Quoted 7 lines

kernel/irq/chip.c handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) · line 472

Quoted 2 lines
kernel/irq/chip.c +0 -0
   #ifdef CONFIG_IPIPE
       /* XXX: IRQCHIP_EOI_IF_HANDLED is ignored. */

Makes me wonder what this comment wants to tell us. That there is an unhandled corner case or that this is intentionally ignored? I support the latter as I-pipe already does EOI when accepting the IRQ, no? Maybe you can clarify that line at this chance.

Quoted 5 lines

I have no idea where this comment come from. I do not think this flag can be handled with the I-pipe kernel, as the EOI is sent before trying to handle the IRQ. The only users are in arch/sparc and arch/powerpc, maybe Philippe knows more?

Jan is right, we ignore EOI_IF_HANDLED and never send EOI from the regular flow handler, as a consequence of doing eoi+mask when holding the IRQ in the ipipe's flow handler.

Quoted 8 lines
Quoted 2 lines

OK, then I'll write a clarification patch for that comment - to get rid of that triple X...

I understand the flag with a negative sense: do not eoi the interrupt if the handler reports that it has not handled it. Obviously, if that is what the flag means, we can not honour it when the I-pipe is on.

Which is the same as saying that we shall ignore EOI_IF_HANDLED because it does not apply when interrupts are pipelined, yes. Hence the comment.

Signature · 1 line
Philippe.