[PATCH 6/7] MPIC MSI allocator
Michael Ellerman
michael at ellerman.id.au
Mon Apr 23 14:04:22 EST 2007
On Sat, 2007-04-21 at 18:17 -0500, Milton Miller wrote:
> On Apr 19, 2007, Michael Ellerman wrote:
> > To support MSI on MPIC we need a way to reserve and allocate hardware
> > irq
> > numbers, this patch implements an allocator for that.
>
> > Index: msi-new/arch/powerpc/sysdev/mpic_msi.c
> > ===================================================================
> > --- /dev/null
> > +++ msi-new/arch/powerpc/sysdev/mpic_msi.c
> ...
> > +irq_hw_number_t mpic_msi_alloc_hwirqs(struct mpic *mpic, int num)
> > +{
> > + unsigned long flags;
> > + int offset, order = fls(num) - 1;
>
> get_count_order would be more clear. Also it has
> a correction factor. (Applies several places).
I was hoping someone would point out something better than fls, fixed.
> > +#ifdef CONFIG_MPIC_BROKEN_U3
> > +static int mpic_msi_reserve_u3_hwirqs(struct mpic *mpic)
> > +{
> > + irq_hw_number_t hwirq;
> > + struct irq_host_ops *ops = mpic->irqhost->ops;
> > + struct device_node *np;
> > + int flags, index, i;
> > + struct of_irq oirq;
> > +
> > + pr_debug("mpic: found U3, guessing msi allocator setup\n");
> > +
> > + /* Reserve source numbers we know are reserved in the HW */
> > + for (i = 0; i < 8; i++) __mpic_msi_reserve_hwirq(mpic, i);
> > + for (i = 42; i < 46; i++) __mpic_msi_reserve_hwirq(mpic, i);
> > + for (i = 100; i < 105; i++) __mpic_msi_reserve_hwirq(mpic, i);
>
> More lines please.
>
> > +#else
> > +static int mpic_msi_reserve_u3_hwirqs(struct mpic *mpic) { return -1;
> > }
>
> and here.
Blank lines aren't free you know!
>
> > + if (len % 8 != 0) {
> > + printk(KERN_WARNING "mpic: Malformed msi-available-ranges "
> > + "property on %s\n", mpic->of_node->full_name);
> > + return -EINVAL;
> > + }
> > +
> > + bitmap_allocate_region(mpic->hwirq_bitmap, 0,
> > + fls(mpic->irq_count) - 1);
> > +
> > + /* Format is: (<u32 start> <u32 count>)+ */
> > + len /= sizeof(u32);
> > + for (i = 0; i < len / 2; i++, p += 2)
>
> how about just dividing by the calculated 8 above? or use
> count = len / 8.
I'm not sure I follow. If you can think of a clearer way I'm all ears,
or are you just trying to save a divide :)
>
> > + mpic_msi_free_hwirqs(mpic, *p, *(p + 1));
> > +
> > + return 0;
> > +}
> > +
> > +int mpic_msi_init_allocator(struct mpic *mpic)
> > +{
> > + int rc, size;
> > +
> > + BUG_ON(mpic->hwirq_bitmap);
> > + spin_lock_init(&mpic->bitmap_lock);
> > +
> > + size = mpic->irq_count / 8;
> > + pr_debug("mpic: allocator bitmap size is 0x%x bytes\n", size);
>
> BITS_TO_LONGS() * sizeof(long). We need to round up to longs to
> use bitmask_*, especially being a big endian architecture.
Eww, sorry that's horrible. Fixed.
cheers
--
Michael Ellerman
OzLabs, IBM Australia Development Lab
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)
We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20070423/3865fa5d/attachment.pgp>
More information about the Linuxppc-dev
mailing list