From: Grant Likely <grant.likely@secretlab.ca>
To: Paul Mundt <lethal@linux-sh.org>
Cc: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org,
Paul Mundt <lethal@linux-sh.org>
Subject: Re: [PATCH 2/2] irqdomain: Support for static IRQ mapping and association.
Date: Fri, 25 May 2012 19:50:49 -0600 [thread overview]
Message-ID: <20120526015049.1616D3E2336@localhost> (raw)
In-Reply-To: <1337576792-5347-2-git-send-email-lethal@linux-sh.org>
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.
next prev parent reply other threads:[~2012-05-26 13:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-21 5:06 [PATCH 1/2] irqdomain: Simple NUMA awareness Paul Mundt
2012-05-21 5:06 ` [PATCH 2/2] irqdomain: Support for static IRQ mapping and association Paul Mundt
2012-05-26 1:50 ` Grant Likely [this message]
2012-06-11 3:25 ` Paul Mundt
2012-06-11 5:02 ` Grant Likely
2012-06-13 7:31 ` Paul Mundt
2012-05-26 1:10 ` [PATCH 1/2] irqdomain: Simple NUMA awareness Grant Likely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120526015049.1616D3E2336@localhost \
--to=grant.likely@secretlab.ca \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox