Skip to contentSkip to conversation

powerpc: quick hack to get a functional eHEA with hardirq preemption

PATCH Milton Miller 2 participants 2 messages Sep 25, 2008 – Sep 26, 2008

lore
Share & tools
lore
#0 lore raw

(I trimmed the cc list for the implementation discussion).

Quoted 68 lines
Quoted 21 lines · On Wed, 24 Sep 2008 11:42:15 -0500 Milton Miller <[email protected]> wrote:
Quoted 4 lines · Sebastien Dugue

Hi Milton,

Quoted 1 line · On Wed, 24 Sep 2008 04:58:22 -0500 (CDT) Milton Miller <[email protected]> wrote:

On Mon Sep 15 at 18:04:06 EST in 2008, Sebastien

Dugue wrote: >>> When entering the low level handler, level sensitive interrupts are >>> masked, then eio'd in interrupt context and then unmasked at the >>> end of hardirq processing. That's fine as any interrupt comming >>> in-between will still be processed since the kernel replays those >>> pending interrupts.

Quoted 2 lines
Quoted 2 lines

Is this to generate some kind of software managed

nesting and priority >> of the hardware level interrupts? >

Quoted 6 lines

No, not really. This is only to be sure to not miss
interrupts coming from the same source that were received during threaded hardirq processing. Some instrumentation showed that it never seems to happen in the eHEA interrupt case, so I think we can forget this aspect.

Quoted 4 lines

I don't trust "the interrupt can never happen during hea hardirq", because I think there will be a race between their rearming the next interrupt and the unmask being called.

So do I, it was just to make sure I was not hit by
another interrupt while handling the previous one and thus reduce the number of hypothesis.

I sure do not say that it cannot happen, just that that
path is not taken when I have the eHEA hang.

Quoted 17 lines

I was trying to understand why the mask and early eoi, but I guess its to handle other more limited interrupt controllers where the interrupts stack in hardware instead of software.

Quoted 8 lines

Also, the problem only manifests with the eHEA RX
interrupt. For example,
the IBM Power Raid (ipr) SCSI exhibits absolutely no problem under an RT
kernel. From this I conclude that:

IPR - PCI - XICS is OK
eHEA - IBMEBUS - XICS is broken with hardirq

preemption. >

Quoted 3 lines

I also checked that forcing the eHEA interrupt to
take the non threaded
path does work.

Quoted 8 lines

For a long period of time, XICS dealt only with level
interrupts. First Micro Channel, and later PCI buses.
The IPI is made level by software conventions.
Recently, EHCA, EHEA, and MSI interrupts were added which by their nature are edge based. The logic that converts those interrupts to the XICS layer is responsible for the resend when no cpu can accept them, but not to retrigger after an EOI.

OK

Quoted 4 lines
Quoted 4 lines

Here is a side by side comparison of the fasteoi
flow with and without hardirq
threading (sorry it's a bit wide)

Quoted 8 lines
Quoted 4 lines

(removed)

Quoted 3 lines

the non-threaded flow does (in interrupt context):

mask

Whoops, my bad, in the non threaded case, there's no
mask at all, only an unmask+eoi at the end, maybe that's an oversight!

No, not an oversight. The point is, don't mask/unmask between ack/eoi while handling the interrupt. For many irq controllers, the eoi must be done from the same cpu, hence the mask and eoi before actually handling the
interrupt in the general case. Its a feature of xics
that we don't have to play that game, but can do the cpu and device eoi separately.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

handle interrupt
unmask
eoi

the threaded flow does:

mask
eoi
handle interrupt
unmask

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

If I remove the mask() call, then the eHEA is no
longer hanging.

Hmm, I guess I'm confused. You are saying the irq does not appear if it occurs while it is masked?

Looks like it is, but I cannot say for sure, the only
observable effect is that I do not get any more interrupts coming from the eHEA.

(removed features of xics)

Quoted 3 lines

That may be, but I'm only looking at the code (read no
specifications at hand) and it looks like a black box to me.

"PowerPC External Interrupt Architecture" is defined in appendix A of "Power.org=99 Standard for
Power Architecture=99 Platform Requirements (Workstation, Server)", available to Power.org members. "The developer-level membership in Power.org is free." (see www.power.org).

That said, it likely won't mention the eHEA in enough detail to note that the interrupt gets cleared on unmask.

On the other hand, I have actually seen the source to implementations of the xics logic, so I have a very good understanding of it (and know of a few implementation "features", shall we say).

Quoted 10 lines
Quoted 6 lines

The path lengh for mask and unmask is always VERY slow and single threaded global lock and single context in xics. It is designed and tuned to run at driver startup and shutdown (and adapter reset and reinitalize during pci error processing), not during normal irq processing.

Now, that is quite interesting then. Those mask() and
unmask() should then be called shutdown() and startup() and not at each interrupt or am I misunderstanding you.

Basically, yes. but linux likes to let drivers mask at other times, and that is the facility we have.

Quoted 17 lines
Quoted 4 lines

The XICS hardware implicitly masks the specific source as part of interrupt ack (get_irq), and implicitly
undoes this mask at eoi. In addition, it helps to
manage the cpu priority by supplying the previous

priority as part of the get_irq process and providing for

Quoted 2 lines

the priority to be restored (lowered only) as part of the eoi. The hardware does support setting the cpu

priority independently.

This confirms, then, that the mask and unmask methods
should be empty for the xics.

Quoted 4 lines

We should only be using this implicit masking for xics, and not the explicit masking for any normal interrupt processing.

Quoted 7 lines

OK

Quoted 3 lines

I don't know if
this means making the mask/unmask setting a bit in software,

Used by whom?

The thought here was if we can't change the caller, then maybe we could try to figure out what the caller was trying to accomplish and defer what was requested based
on context. Obviously, we are better off changing the
caller.

Quoted 8 lines
Quoted 4 lines

and the
enable/disable to actually call what we do now on mask/unmask, or if it means we need a new flow type on

real time.

Maybe a new flow type is not necessary considering what
you said.

Maybe not, but I think it would be preferred ... we do have the source to both sides.

Quoted 8 lines
Quoted 6 lines

While call to mask and unmask might work on level interrupts, its really slow and will limit performance if done on every interrupt.

Quoted 3 lines

the non-threaded flow does (in interrupt context):

mask

Same Whoops, no mask is done in the non threaded case

I was just copying for context :=3d)

Quoted 18 lines
Quoted 11 lines
Quoted 10 lines

handle interrupt
unmask
eoi

the threaded flow does:

mask
eoi
handle interrupt
unmask

Quoted 6 lines

I think the flows we want on xics are:

(non-threaded)
getirq (implicit source specific mask until eoi) handle interrupt
eoi (implicit cpu priority restore)

Quoted 8 lines

Yep

Quoted 4 lines

(threaded)
getirq (implicit source specific mask until eoi) explicit cpu priority restore

        ^

How do you go about doing that? Still not clear to me.

xics_set_cpu_priority(0xff)

of course, there needs to be some kind of
struct irq_chip method to call it.

Quoted 6 lines
Quoted 6 lines

handle interrupt
eoi (implicit cpu priority restore to same as
explicit level)
Where the cpu priority restore allows receiving other interrupts of the same priority from the hardware.

Quoted 6 lines
Quoted 2 lines

So I guess the question is can the rt kernel interrupt processing take advantage of xics auto mask,

It should, but even mainline could benefit from it I
guess.

I haven't looked, but are you implying mainline calls mask and unmask for each interrupt, and not just when the driver does unmask/mask/request/free?

Otherwise, I am not sure mainline is doing anything wrong.

Quoted 8 lines
Quoted 5 lines

or does someone need to write state
tracking in the xics code to work around this, changing mask under interrupt to "defer eoi to unmask" (which I can not see as clean, and having shutdown problems).

Thanks a lot Milton for those explanations,

Sebastien.

You're welcome. I don't have time to work on the rt kernel, but I'll be glad to help suggest an implementation that works efficiently.

milton

#1 lore raw
Quoted 1 line · On Thu, 25 Sep 2008 18:40:28 -0500 "Milton Miller" <[email protected]> wrote:

(I trimmed the cc list for the implementation discussion).

Yep, good thing.

<snip>

Quoted 4 lines
Quoted 4 lines

=20
Whoops, my bad, in the non threaded case, there's no
mask at all, only an unmask+eoi at the end, maybe that's an oversight!

Quoted 8 lines

=20
No, not an oversight. The point is, don't mask/unmask between ack/eoi while handling the interrupt. For many irq controllers, the eoi must be done from the same cpu, hence the mask and eoi before actually handling the
interrupt in the general case. Its a feature of xics
that we don't have to play that game, but can do the cpu and device eoi separately.

Ok, will try to play with this a bit more.

<snip>

Quoted 11 lines

=20

Quoted 3 lines

That may be, but I'm only looking at the code (read no
specifications at hand) and it looks like a black box to me.

=20
"PowerPC External Interrupt Architecture" is defined in appendix A of "Power.org=C2=99 Standard for=20 Power Architecture=C2=99 Platform Requirements (Workstation, Server)", available to Power.org members. "The developer-level membership in Power.org is free." (see www.power.org).

I already have that one and started to dig into the interrupt stuff, but =
as
with all normative stuff it's boring to the extreme and not always without flaws. Looks like I know what I'll be reading this WE.

Quoted 9 lines

=20
That said, it likely won't mention the eHEA in enough detail to note that the interrupt gets cleared on unmask.
=20
On the other hand, I have actually seen the source to implementations of the xics logic, so I have a very good understanding of it (and know of a few implementation "features", shall we say).

Good to know.

Quoted 8 lines

=20
=20

Quoted 6 lines
Quoted 6 lines

The path lengh for mask and unmask is always VERY slow and single threaded global lock and single context in xics. It is designed and tuned to run at driver startup and shutdown (and adapter reset and reinitalize during pci error processing), not during normal irq=20 processing.

Quoted 7 lines
Quoted 4 lines

=20
Now, that is quite interesting then. Those mask() and
unmask() should then be called shutdown() and startup() and not at each interrupt or am I misunderstanding you.

=20
Basically, yes. but linux likes to let drivers mask at other times, and that is the facility we have.

Darn, do those drivers really need that heavywheight masking
at the source or something simpler could be accomplished by fiddling with the processor priority in mask and unmask?

Quoted 23 lines

=20

Quoted 22 lines
Quoted 4 lines

The XICS hardware implicitly masks the specific source as part of interrupt ack (get_irq), and implicitly
undoes this mask at eoi. In addition, it helps to
manage the cpu priority by supplying the previous=20

priority as part of the get_irq process and providing for

Quoted 2 lines

the priority to be restored (lowered only) as part of the eoi. The hardware does support setting the cpu

priority independently.
=20
This confirms, then, that the mask and unmask methods
should be empty for the xics.
=20

Quoted 4 lines

=20
We should only be using this implicit masking for xics, and not the explicit masking for any normal interrupt processing.

=20
OK
=20

Quoted 3 lines

I don't know if=20
this means making the mask/unmask setting a bit in software,

Quoted 8 lines
Quoted 2 lines

=20
Used by whom?=20

=20
The thought here was if we can't change the caller, then maybe we could try to figure out what the caller was trying to accomplish and defer what was requested based
on context. Obviously, we are better off changing the
caller.

That will not be so easy as we'll change behaviour for every user of
the genirq layer.

Quoted 5 lines

=20

Quoted 4 lines

=20

Quoted 3 lines

and the=20
enable/disable to actually call what we do now on mask/unmask, or if it means we need a new flow type on

Quoted 7 lines
Quoted 4 lines

real time.
=20
Maybe a new flow type is not necessary considering what
you said.

=20
Maybe not, but I think it would be preferred ... we do have the source to both sides.

That's straightforward to do in the non threaded case, however, in the
threaded case the xics code would have to also manage the hardirq thread as we would not be able to reuse the generic one (because of the unmask it does at the very end).

<snip>

Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

I think the flows we want on xics are:
=20
(non-threaded)
getirq (implicit source specific mask until eoi) handle interrupt
eoi (implicit cpu priority restore)

=20
Yep
=20

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

=20
(threaded)
getirq (implicit source specific mask until eoi) explicit cpu priority restore

        ^

How do you go about doing that? Still not clear to me.

=20
xics_set_cpu_priority(0xff)

OK

Quoted 3 lines

=20
of course, there needs to be some kind of=20 struct irq_chip method to call it.

Yep, excepted that it's currently not provided by irq_chip.

Quoted 9 lines

=20

Quoted 8 lines
Quoted 8 lines

handle interrupt
eoi (implicit cpu priority restore to same as
explicit level)=20
Where the cpu priority restore allows receiving other interrupts of the same priority from the hardware. =20
So I guess the question is can the rt kernel interrupt processing take advantage of xics auto mask,

Quoted 8 lines
Quoted 4 lines

=20
It should, but even mainline could benefit from it I
guess.
=20

=20
I haven't looked, but are you implying mainline calls mask and unmask for each interrupt, and not just when the driver does unmask/mask/request/free?

Nope you're right, I got confused. I only looked at the non threaded case
under preempt-rt which does unmask + eoi (without mask) whereas mainline only does eoi

Quoted 3 lines

=20
Otherwise, I am not sure mainline is doing anything wrong. =20

Right

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

or does someone need to write state=20 tracking in the xics code to work around this, changing mask under interrupt to "defer eoi to unmask" (which I can not see as clean, and having shutdown problems). =20

Quoted 8 lines
Quoted 3 lines

Thanks a lot Milton for those explanations,
=20
Sebastien.

=20
You're welcome. I don't have time to work on the rt kernel, but I'll be glad to help suggest an implementation that works efficiently.
=20

Thanks a lot,

Sebastien.