* [PATCH 2/4] irqdomain: augment add_simple() to allocate descs
@ 2012-09-27 13:13 Linus Walleij
2012-09-27 13:41 ` Rob Herring
2012-09-27 13:54 ` Paul Mundt
0 siblings, 2 replies; 4+ messages in thread
From: Linus Walleij @ 2012-09-27 13:13 UTC (permalink / raw)
To: linux-arm-kernel
From: Linus Walleij <linus.walleij@linaro.org>
Currently we rely on all IRQ chip instances to dynamically
allocate their IRQ descriptors unless they use the linear
IRQ domain. So for irqdomain_add_legacy() and
irqdomain_add_simple() the caller need to make sure that
descriptors are allocated.
Let's slightly augment the yet unused irqdomain_add_simple()
to also allocate descriptors as a means to simplify usage
and avoid code duplication throughout the kernel.
We warn if descriptors cannot be allocated, e.g. if a
platform has the bad habit of hogging descriptors at boot
time.
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Rob/Grant/Thomas if you ACK this I will take it through the
pinctrl tree since I introduce its only user right there.
---
kernel/irq/irqdomain.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 49a7772..a0655b6 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -148,7 +148,8 @@ static unsigned int irq_domain_legacy_revmap(struct irq_domain *domain,
* @host_data: Controller private data pointer
*
* Allocates a legacy irq_domain if irq_base is positive or a linear
- * domain otherwise.
+ * domain otherwise. For the legacy domain, IRQ descriptors will also
+ * be allocated.
*
* This is intended to implement the expected behaviour for most
* interrupt controllers which is that a linear mapping should
@@ -162,11 +163,21 @@ struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
const struct irq_domain_ops *ops,
void *host_data)
{
- if (first_irq > 0)
- return irq_domain_add_legacy(of_node, size, first_irq, 0,
+ if (first_irq > 0) {
+ int irq_base;
+
+ irq_base = irq_alloc_descs(first_irq, 0, size, numa_node_id());
+ if (irq_base < 0) {
+ WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
+ first_irq);
+ irq_base = first_irq;
+ }
+ return irq_domain_add_legacy(of_node, size, irq_base, 0,
ops, host_data);
- else
- return irq_domain_add_linear(of_node, size, ops, host_data);
+ }
+
+ /* A linear domain is the default */
+ return irq_domain_add_linear(of_node, size, ops, host_data);
}
/**
--
1.7.11.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/4] irqdomain: augment add_simple() to allocate descs
2012-09-27 13:13 [PATCH 2/4] irqdomain: augment add_simple() to allocate descs Linus Walleij
@ 2012-09-27 13:41 ` Rob Herring
2012-11-26 20:22 ` Grant Likely
2012-09-27 13:54 ` Paul Mundt
1 sibling, 1 reply; 4+ messages in thread
From: Rob Herring @ 2012-09-27 13:41 UTC (permalink / raw)
To: linux-arm-kernel
On 09/27/2012 08:13 AM, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
>
> Currently we rely on all IRQ chip instances to dynamically
> allocate their IRQ descriptors unless they use the linear
> IRQ domain. So for irqdomain_add_legacy() and
> irqdomain_add_simple() the caller need to make sure that
> descriptors are allocated.
>
> Let's slightly augment the yet unused irqdomain_add_simple()
> to also allocate descriptors as a means to simplify usage
> and avoid code duplication throughout the kernel.
>
> We warn if descriptors cannot be allocated, e.g. if a
> platform has the bad habit of hogging descriptors at boot
> time.
>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Rob/Grant/Thomas if you ACK this I will take it through the
> pinctrl tree since I introduce its only user right there.
You really should have Grant's ack here.
> ---
> kernel/irq/irqdomain.c | 21 ++++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 49a7772..a0655b6 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -148,7 +148,8 @@ static unsigned int irq_domain_legacy_revmap(struct irq_domain *domain,
> * @host_data: Controller private data pointer
> *
> * Allocates a legacy irq_domain if irq_base is positive or a linear
> - * domain otherwise.
> + * domain otherwise. For the legacy domain, IRQ descriptors will also
> + * be allocated.
> *
> * This is intended to implement the expected behaviour for most
> * interrupt controllers which is that a linear mapping should
> @@ -162,11 +163,21 @@ struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
> const struct irq_domain_ops *ops,
> void *host_data)
> {
> - if (first_irq > 0)
> - return irq_domain_add_legacy(of_node, size, first_irq, 0,
> + if (first_irq > 0) {
> + int irq_base;
> +
> + irq_base = irq_alloc_descs(first_irq, 0, size, numa_node_id());
This will always fail for !SPARSE_IRQ, so we probably don't want warn in
that case. So perhaps something like this:
int irq_base = first_irq;
if (is_enabled(CONFIG_SPARSE_IRQ)) {
irq_base = irq_alloc_descs(first_irq, 0, size, numa_node_id());
if (irq_base < 0) {
WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
first_irq);
irq_base = first_irq;
}
}
> + if (irq_base < 0) {
> + WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
> + first_irq);
> + irq_base = first_irq;
> + }
> + return irq_domain_add_legacy(of_node, size, irq_base, 0,
> ops, host_data);
> - else
> - return irq_domain_add_linear(of_node, size, ops, host_data);
> + }
> +
> + /* A linear domain is the default */
> + return irq_domain_add_linear(of_node, size, ops, host_data);
> }
>
> /**
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/4] irqdomain: augment add_simple() to allocate descs
2012-09-27 13:13 [PATCH 2/4] irqdomain: augment add_simple() to allocate descs Linus Walleij
2012-09-27 13:41 ` Rob Herring
@ 2012-09-27 13:54 ` Paul Mundt
1 sibling, 0 replies; 4+ messages in thread
From: Paul Mundt @ 2012-09-27 13:54 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Sep 27, 2012 at 03:13:45PM +0200, Linus Walleij wrote:
> + if (first_irq > 0) {
> + int irq_base;
> +
> + irq_base = irq_alloc_descs(first_irq, 0, size, numa_node_id());
> + if (irq_base < 0) {
> + WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
> + first_irq);
> + irq_base = first_irq;
> + }
> + return irq_domain_add_legacy(of_node, size, irq_base, 0,
> ops, host_data);
If first_irq is specified you presumably want irq_alloc_desc_at()
behaviour, so you should use irq_alloc_descs(first_irq, first_irq, ...),
similar to what irq_create_strict_mappings() does.
Also don't use numa_node_id() for this, of_node_to_nid() handles both the
OF and non-OF cases.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/4] irqdomain: augment add_simple() to allocate descs
2012-09-27 13:41 ` Rob Herring
@ 2012-11-26 20:22 ` Grant Likely
0 siblings, 0 replies; 4+ messages in thread
From: Grant Likely @ 2012-11-26 20:22 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, 27 Sep 2012 08:41:53 -0500, Rob Herring <robherring2@gmail.com> wrote:
> On 09/27/2012 08:13 AM, Linus Walleij wrote:
> > ---
> > kernel/irq/irqdomain.c | 21 ++++++++++++++++-----
> > 1 file changed, 16 insertions(+), 5 deletions(-)
> >
> > diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> > index 49a7772..a0655b6 100644
> > --- a/kernel/irq/irqdomain.c
> > +++ b/kernel/irq/irqdomain.c
> > @@ -148,7 +148,8 @@ static unsigned int irq_domain_legacy_revmap(struct irq_domain *domain,
> > * @host_data: Controller private data pointer
> > *
> > * Allocates a legacy irq_domain if irq_base is positive or a linear
> > - * domain otherwise.
> > + * domain otherwise. For the legacy domain, IRQ descriptors will also
> > + * be allocated.
> > *
> > * This is intended to implement the expected behaviour for most
> > * interrupt controllers which is that a linear mapping should
> > @@ -162,11 +163,21 @@ struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
> > const struct irq_domain_ops *ops,
> > void *host_data)
> > {
> > - if (first_irq > 0)
> > - return irq_domain_add_legacy(of_node, size, first_irq, 0,
> > + if (first_irq > 0) {
> > + int irq_base;
> > +
> > + irq_base = irq_alloc_descs(first_irq, 0, size, numa_node_id());
>
> This will always fail for !SPARSE_IRQ, so we probably don't want warn in
> that case. So perhaps something like this:
>
> int irq_base = first_irq;
>
> if (is_enabled(CONFIG_SPARSE_IRQ)) {
> irq_base = irq_alloc_descs(first_irq, 0, size, numa_node_id());
> if (irq_base < 0) {
> WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
> first_irq);
> irq_base = first_irq;
> }
> }
Also, warn seems a little over-loud in this case. If the controller is
legitimately claiming irqs in the reserved range, then dumping out a
backtrace is kind of nasty.
g.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-26 20:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-27 13:13 [PATCH 2/4] irqdomain: augment add_simple() to allocate descs Linus Walleij
2012-09-27 13:41 ` Rob Herring
2012-11-26 20:22 ` Grant Likely
2012-09-27 13:54 ` Paul Mundt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).