Messages in this thread |  | | | From | Grant Likely <> | | Subject | Re: [PATCH 2/2] irqdomain: Support for static IRQ mapping and association. | | Date | Fri, 25 May 2012 19:50:49 -0600 |
| |
On Mon, 21 May 2012 14:06:32 +0900, Paul Mundt <lethal@linux-sh.org> wrote: > +/** > + * irq_domain_associate_many() - Associate a range of hw irqs with linux irqs > + * @domain: domain owning the interrupt range > + * @irq_base: beginning of linux IRQ range > + * @hwirq_base: beginning of hardware IRQ range > + * @count: Number of interrupts to associate > + * > + * This routine takes care of creating an association between a range of > + * hardware and linux IRQs using pre-existing IRQ allocations. For use by > + * controllers that do their own irq_desc management. > + */ > +int irq_domain_associate_many(struct irq_domain *domain, unsigned int irq_base, > + irq_hw_number_t hwirq_base, int count) > +{ > + int i, ret; > + > + for (i = 0; i < count; i++) { > + ret = irq_domain_associate(domain, irq_base + i, > + hwirq_base + i); > + if (unlikely(ret)) > + goto unmap; > + } > + > + return 0; > + > +unmap: > + while (--i >= 0) { > + if (domain->ops->unmap) > + domain->ops->unmap(domain, irq_base + i); > + > + irq_set_status_flags(irq_base + i, IRQ_NOREQUEST); > + } > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(irq_domain_associate_many);
Looks good, but I've flipped around the patch to make irq_domain_associate() a simple wrapper around irq_domain_associate_many() instead of the other way around. It makes for a bigger change to the existing irq_setup_virq() code, but in the end I think it makes more to keep all the logic in one place. I'll post my revised version.
I've also added sanity checks to make sure only allocated irq_descs can get associated. Otherwise the kernel will oops.
> +/** > + * irq_create_strict_mappings() - Map a range of hw irqs to fixed linux irqs > + * @domain: domain owning the interrupt range > + * @irq_base: beginning of linux IRQ range > + * @hwirq_base: beginning of hardware IRQ range > + * @count: Number of interrupts to map > + * > + * This routine is used for allocating and mapping a range of hardware > + * irqs to linux irqs where the linux irq numbers are at pre-defined > + * locations. For use by controllers that already have static mappings > + * to insert in to the domain. > + * > + * Non-linear users can use irq_create_identity_mapping() for IRQ-at-a-time > + * domain insertion. > + * > + * 0 is returned upon success, while any failure to establish a static > + * mapping is treated as an error. > + */ > +int irq_create_strict_mappings(struct irq_domain *domain, unsigned int irq_base, > + irq_hw_number_t hwirq_base, int count) > +{ > + int ret; > + > + ret = irq_alloc_descs(irq_base, irq_base, count, > + of_node_to_nid(domain->of_node)); > + if (unlikely(ret < 0)) > + return ret; > + > + ret = irq_domain_associate_many(domain, irq_base, hwirq_base, count); > + if (unlikely(ret < 0)) { > + irq_free_descs(irq_base, count); > + return ret; > + }
It would be really good to make sure the hwirqs aren't already associated before trying to associate them again. Unfortunately that can't be done (nicely) until I get rid of the slow path lookup. I've got a patch for that which I'll rebase on top of this one and post soon.
g.
> + > + return 0; > +} > +EXPORT_SYMBOL_GPL(irq_create_strict_mappings); > + > unsigned int irq_create_of_mapping(struct device_node *controller, > const u32 *intspec, unsigned int intsize) > { > -- > 1.7.9.rc0.28.g0e1cf >
-- Grant Likely, B.Sc, P.Eng. Secret Lab Technologies, Ltd.
|  |