2003-01-04 11:55:14

by Andrey Panin

[permalink] [raw]
Subject: [RFC] irq handling code consolidation, second try (ppc part)


Hi all,

attached patch is a second try of IRQ handling code consolidation.
This is a ppc specific patch (compiled successfuly).

Beware, this patch removes some old(?) and crappy code:
- irq_kmalloc(), irq_kfree() removed. If ppc need to register
irqs early, it should use setup_irq() as all decent people do :))
- request_irq() with NULL handler argument == free_irq(), does
anyone use this kludge ?

Best regards.

--
Andrey Panin | Embedded systems software developer
[email protected] | PGP key: wwwkeys.pgp.net


Attachments:
(No filename) (528.00 B)
patch-irq-ppc-2.5.53 (11.67 kB)
Download all attachments

2003-01-04 12:50:31

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [RFC] irq handling code consolidation, second try (ppc part)

On Sat, 2003-01-04 at 12:59, Andrey Panin wrote:
> Hi all,
>
> attached patch is a second try of IRQ handling code consolidation.
> This is a ppc specific patch (compiled successfuly).
>
> Beware, this patch removes some old(?) and crappy code:
> - irq_kmalloc(), irq_kfree() removed. If ppc need to register
> irqs early, it should use setup_irq() as all decent people do :))
> - request_irq() with NULL handler argument == free_irq(), does
> anyone use this kludge ?
>

After a quick look, things look fine some of this old PPC crap should indeed
be killed now.

There's something else I would like to implement one of these days, and your
consolidation work makes it easier (except for archs that won't use it...).
Basically, I want some (few and rare enough though) drivers to be able
to define interrupt controllers and thus create their own IRQs.

The typical example for which I need that is cardbus. I need the cardbus
controller on PCI to be seen as a real cascaded controller, that is I want
devices below it (either PCI or PCMCIA) calls to request/free/enable/disable_irq
for their to be caught by the cardbus driver.
This is the only sane way to properly enable/disable bridging of the
interrupt upon request from the driver. Without that, I still can frequent
lockups with various pcmcia cards when inserted/removed due to IRQ line
beeing stuck down on slot shutdown or other crappy things happening
typically with legacy PCMCIA stuffs (ATA is a good example of crappy behaviour).

The "easy" way here to implement that is to make the irq_desc array larger than
NR_IRQs (or rather split NR_IRQs into NR_SYS_IRQS + NR_DYNAMIC_IRQS). The
additional "slots" could then easily be allocated/freed. Thus, keeping my
cardbus example, the cardbus driver can allocate a couple of slots (that is IRQ
numbers) dynamically, and use it's own startup/shutdown/enable/disable/...
hooks for them, dealing itself with the cascade from the PCI irq. (Of course,
this is not for systems using cardbus routed to legacy IRQs, but for systems
like PPC where the PCI irq is mux'ing both the device IRQs and the controller
own IRQ).

Ben.


2003-01-04 17:38:44

by Linus Torvalds

[permalink] [raw]
Subject: Re: [RFC] irq handling code consolidation, second try (ppc part)


On 4 Jan 2003, Benjamin Herrenschmidt wrote:
>
> The "easy" way here to implement that is to make the irq_desc array larger than
> NR_IRQs (or rather split NR_IRQs into NR_SYS_IRQS + NR_DYNAMIC_IRQS). The
> additional "slots" could then easily be allocated/freed. Thus, keeping my
> cardbus example, the cardbus driver can allocate a couple of slots (that is IRQ
> numbers) dynamically, and use it's own startup/shutdown/enable/disable/...
> hooks for them, dealing itself with the cascade from the PCI irq.

Linearizing a space like this is always a bad idea, I think.

It would be entirely possible to just add the irq routing information to
the "struct device" tree, and have a "dev_request_irq(dev, ...)", along
with a few helper functions like "pci_request_irq(pci_dev, ...)".

And the old "request_irq()" would just use the system root device as the
device.

Linus

2003-01-05 00:19:52

by Anton Blanchard

[permalink] [raw]
Subject: Re: [RFC] irq handling code consolidation, second try (ppc part)


> The "easy" way here to implement that is to make the irq_desc array
> larger than NR_IRQs (or rather split NR_IRQs into NR_SYS_IRQS +
> NR_DYNAMIC_IRQS). The additional "slots" could then easily be
> allocated/freed.

On ppc64 irqs are sparse and can be very large (> 1000) so we have a
mapping between them and slots in irq_desc[NR_IRQS]. I wonder how
hard it would be to kill irq_desc and just dynamically allocate
irq_desc stuff. That would solve my problem.

Anton

2003-01-05 00:44:15

by Anton Blanchard

[permalink] [raw]
Subject: Re: [RFC] irq handling code consolidation, second try (ppc part)


> attached patch is a second try of IRQ handling code consolidation.
> This is a ppc specific patch (compiled successfuly).
>
> Beware, this patch removes some old(?) and crappy code:
> - irq_kmalloc(), irq_kfree() removed. If ppc need to register
> irqs early, it should use setup_irq() as all decent people do :))
> - request_irq() with NULL handler argument == free_irq(), does
> anyone use this kludge ?

Similar issues on ppc64 (since it started life as a copy of the ppc32 code :)
Im interested in moving to something generic.

Anton

2003-01-05 08:44:31

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [RFC] irq handling code consolidation, second try (ppc part)

On Sat, 2003-01-04 at 18:41, Linus Torvalds wrote:
> On 4 Jan 2003, Benjamin Herrenschmidt wrote:
> >
> > The "easy" way here to implement that is to make the irq_desc array larger than
> > NR_IRQs (or rather split NR_IRQs into NR_SYS_IRQS + NR_DYNAMIC_IRQS). The
> > additional "slots" could then easily be allocated/freed. Thus, keeping my
> > cardbus example, the cardbus driver can allocate a couple of slots (that is IRQ
> > numbers) dynamically, and use it's own startup/shutdown/enable/disable/...
> > hooks for them, dealing itself with the cascade from the PCI irq.
>
> Linearizing a space like this is always a bad idea, I think.

I fully agree, I was just proposing a "simple" solution that would fit
in a feature-frozen kernel ;)

Note that if we go the full way abstracting interrupts, then the
interrupt "tree" should be separate from the device tree. The interrupt
"parent" of a device may not be (and is not in a whole lot of cases I
have to deal with on pmacs and embedded) the "bus" parent of a given
device.

I suppose there may be similar "issues" with x86 PCI chips routed to
legacy irqs, but then, I'm completely unfamiliar with the story of
interrupt routing on x86's...

on pmacs, all interrupts end up in a single interrupt controller located
in a "combo" ASIC along with other devices. This ASIC is a PCI device,
but is really the root of the interrupt tree just below the CPU itself,
regardless of the actual interrupt sources beeing located on other PCI
busses or not. On embedded, the design can be as funky as a HW designer
can imagine...

Do you think this is still 2.5 work ?

> It would be entirely possible to just add the irq routing information to
> the "struct device" tree, and have a "dev_request_irq(dev, ...)", along
> with a few helper functions like "pci_request_irq(pci_dev, ...)".
>
> And the old "request_irq()" would just use the system root device as the
> device.
>
> Linus
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Benjamin Herrenschmidt <[email protected]>

2003-01-05 19:01:57

by Linus Torvalds

[permalink] [raw]
Subject: Re: [RFC] irq handling code consolidation, second try (ppc part)


On 5 Jan 2003, Benjamin Herrenschmidt wrote:
>
> Note that if we go the full way abstracting interrupts, then the
> interrupt "tree" should be separate from the device tree. The interrupt
> "parent" of a device may not be (and is not in a whole lot of cases I
> have to deal with on pmacs and embedded) the "bus" parent of a given
> device.

I disagree. The pmac braindamage is a pmac problem, and not worth
uglifying the generic device layer over. Besides, as far as I know, it is
trivially solved by just making the pmac irq controller be a root
controller, and that's it. There are no other irq controllers there that
are worth worrying about.

> Do you think this is still 2.5 work ?

No.

Linus

2003-01-05 21:51:46

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [RFC] irq handling code consolidation, second try (ppc part)

On Sun, 2003-01-05 at 20:05, Linus Torvalds wrote:
> On 5 Jan 2003, Benjamin Herrenschmidt wrote:
> >
> > Note that if we go the full way abstracting interrupts, then the
> > interrupt "tree" should be separate from the device tree. The interrupt
> > "parent" of a device may not be (and is not in a whole lot of cases I
> > have to deal with on pmacs and embedded) the "bus" parent of a given
> > device.
>
> I disagree. The pmac braindamage is a pmac problem, and not worth
> uglifying the generic device layer over. Besides, as far as I know, it is
> trivially solved by just making the pmac irq controller be a root
> controller, and that's it. There are no other irq controllers there that
> are worth worrying about.

Right, though some other machines (CHRP for example) with cascaded
legacy 8259 on top or below OpenPIC may also want more flexibility
regarding interrupt routing.

It seems quite common (at least it is in embedded world) to actually
wire interrupt sources rather randomly to the closest device than can
act as an interrupt controller regardless of the actual bus layout ;)

But I agree this can be solved by defining the "main" PIC as root
controller regardless of it's actual bus location.

> > Do you think this is still 2.5 work ?
>
> No.

Makes sense. Though the simple tweak of allocating more irq_descs in the
existing array (by slightly extending the array) may be worth trying for
fixing some of the pcmcia problems now. I need to experient more, it
might actually be enough to just disable IRQ routing on the pcmcia
bridge when the slot is shut down.

Ben.