* [PATCH] pinctrl/nomadik: allocate IRQ descriptors dynamically
@ 2012-09-26 17:18 Linus Walleij
2012-09-27 5:13 ` Stephen Warren
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Linus Walleij @ 2012-09-26 17:18 UTC (permalink / raw)
To: linux-arm-kernel
From: Linus Walleij <linus.walleij@linaro.org>
This allocates the IRQ descriptors for the Nomadik pin controller
dynamically so that we don't have to rely on some other mechanism
doing it, and moving a step closer to a linear IRQ domain.
Cc: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/pinctrl/pinctrl-nomadik.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
index 3dde653..29921d1 100644
--- a/drivers/pinctrl/pinctrl-nomadik.c
+++ b/drivers/pinctrl/pinctrl-nomadik.c
@@ -1185,6 +1185,8 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
struct clk *clk;
int secondary_irq;
void __iomem *base;
+ int irq_start;
+ int irq_base;
int irq;
int ret;
@@ -1288,9 +1290,22 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
platform_set_drvdata(dev, nmk_chip);
+ /*
+ * Allocate descriptors and IRQ domain using the legacy model, this
+ * should eventually be replaced with a linear IRQ domain as we get
+ * independent from the irq numbers with the switch to device tree.
+ */
+ irq_start = NOMADIK_GPIO_TO_IRQ(pdata->first_gpio);
+ irq_base = irq_alloc_descs(irq_start, 0, NMK_GPIO_PER_CHIP,
+ numa_node_id());
+ if (IS_ERR_VALUE(irq_base)) {
+ WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
+ irq_start);
+ irq_base = irq_start;
+ }
nmk_chip->domain = irq_domain_add_legacy(np, NMK_GPIO_PER_CHIP,
- NOMADIK_GPIO_TO_IRQ(pdata->first_gpio),
- 0, &nmk_gpio_irq_simple_ops, nmk_chip);
+ irq_base, 0,
+ &nmk_gpio_irq_simple_ops, nmk_chip);
if (!nmk_chip->domain) {
dev_err(&dev->dev, "failed to create irqdomain\n");
ret = -ENOSYS;
--
1.7.11.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] pinctrl/nomadik: allocate IRQ descriptors dynamically
2012-09-26 17:18 [PATCH] pinctrl/nomadik: allocate IRQ descriptors dynamically Linus Walleij
@ 2012-09-27 5:13 ` Stephen Warren
2012-09-27 11:59 ` Linus Walleij
2012-09-27 12:37 ` Rob Herring
2012-09-27 12:53 ` Russell King - ARM Linux
2 siblings, 1 reply; 6+ messages in thread
From: Stephen Warren @ 2012-09-27 5:13 UTC (permalink / raw)
To: linux-arm-kernel
On 09/26/2012 11:18 AM, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
>
> This allocates the IRQ descriptors for the Nomadik pin controller
> dynamically so that we don't have to rely on some other mechanism
> doing it, and moving a step closer to a linear IRQ domain.
>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/pinctrl/pinctrl-nomadik.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
> index 3dde653..29921d1 100644
> --- a/drivers/pinctrl/pinctrl-nomadik.c
> +++ b/drivers/pinctrl/pinctrl-nomadik.c
> @@ -1185,6 +1185,8 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
> struct clk *clk;
> int secondary_irq;
> void __iomem *base;
> + int irq_start;
> + int irq_base;
> int irq;
> int ret;
>
> @@ -1288,9 +1290,22 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
>
> platform_set_drvdata(dev, nmk_chip);
>
> + /*
> + * Allocate descriptors and IRQ domain using the legacy model, this
> + * should eventually be replaced with a linear IRQ domain as we get
> + * independent from the irq numbers with the switch to device tree.
> + */
> + irq_start = NOMADIK_GPIO_TO_IRQ(pdata->first_gpio);
Presumably that's a 1:1 mapping...
> + irq_base = irq_alloc_descs(irq_start, 0, NMK_GPIO_PER_CHIP,
> + numa_node_id());
> + if (IS_ERR_VALUE(irq_base)) {
> + WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
> + irq_start);
> + irq_base = irq_start;
> + }
Hmmm. Is this code targetting the DT case or the non-DT case or both? I
think typically you'd call irq_domain_add_linear without forcing a
particular IRQ base for the DT case, and only call irq_alloc_descs() for
the non-DT case, right?
> nmk_chip->domain = irq_domain_add_legacy(np, NMK_GPIO_PER_CHIP,
> - NOMADIK_GPIO_TO_IRQ(pdata->first_gpio),
> - 0, &nmk_gpio_irq_simple_ops, nmk_chip);
> + irq_base, 0,
> + &nmk_gpio_irq_simple_ops, nmk_chip);
> if (!nmk_chip->domain) {
> dev_err(&dev->dev, "failed to create irqdomain\n");
> ret = -ENOSYS;
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] pinctrl/nomadik: allocate IRQ descriptors dynamically
2012-09-27 5:13 ` Stephen Warren
@ 2012-09-27 11:59 ` Linus Walleij
0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2012-09-27 11:59 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Sep 27, 2012 at 7:13 AM, Stephen Warren <swarren@nvidia.com> wrote:
> On 09/26/2012 11:18 AM, Linus Walleij wrote:
>> + irq_start = NOMADIK_GPIO_TO_IRQ(pdata->first_gpio);
>
> Presumably that's a 1:1 mapping...
Yep, albeit on a legacy domain to be able to keep the start irq.
>> + irq_base = irq_alloc_descs(irq_start, 0, NMK_GPIO_PER_CHIP,
>> + numa_node_id());
>> + if (IS_ERR_VALUE(irq_base)) {
>> + WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
>> + irq_start);
>> + irq_base = irq_start;
>> + }
>
> Hmmm. Is this code targetting the DT case or the non-DT case or both? I
> think typically you'd call irq_domain_add_linear without forcing a
> particular IRQ base for the DT case, and only call irq_alloc_descs() for
> the non-DT case, right?
This is indeed the non-DT case. The irqdomain stuff here doesn't seem
to be properly addressing the DT usecase. I'll cook a v2 version doing
a linear domain for DT and have Lee review it.
Thanks!
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] pinctrl/nomadik: allocate IRQ descriptors dynamically
2012-09-26 17:18 [PATCH] pinctrl/nomadik: allocate IRQ descriptors dynamically Linus Walleij
2012-09-27 5:13 ` Stephen Warren
@ 2012-09-27 12:37 ` Rob Herring
2012-09-27 12:48 ` Linus Walleij
2012-09-27 12:53 ` Russell King - ARM Linux
2 siblings, 1 reply; 6+ messages in thread
From: Rob Herring @ 2012-09-27 12:37 UTC (permalink / raw)
To: linux-arm-kernel
On 09/26/2012 12:18 PM, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
>
> This allocates the IRQ descriptors for the Nomadik pin controller
> dynamically so that we don't have to rely on some other mechanism
> doing it, and moving a step closer to a linear IRQ domain.
>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/pinctrl/pinctrl-nomadik.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
> index 3dde653..29921d1 100644
> --- a/drivers/pinctrl/pinctrl-nomadik.c
> +++ b/drivers/pinctrl/pinctrl-nomadik.c
> @@ -1185,6 +1185,8 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
> struct clk *clk;
> int secondary_irq;
> void __iomem *base;
> + int irq_start;
> + int irq_base;
> int irq;
> int ret;
>
> @@ -1288,9 +1290,22 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
>
> platform_set_drvdata(dev, nmk_chip);
>
> + /*
> + * Allocate descriptors and IRQ domain using the legacy model, this
> + * should eventually be replaced with a linear IRQ domain as we get
> + * independent from the irq numbers with the switch to device tree.
> + */
> + irq_start = NOMADIK_GPIO_TO_IRQ(pdata->first_gpio);
> + irq_base = irq_alloc_descs(irq_start, 0, NMK_GPIO_PER_CHIP,
> + numa_node_id());
> + if (IS_ERR_VALUE(irq_base)) {
> + WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
> + irq_start);
> + irq_base = irq_start;
> + }
> nmk_chip->domain = irq_domain_add_legacy(np, NMK_GPIO_PER_CHIP,
You might as well change to irq_domain_add_simple here.
Perhaps we should just add irq_alloc_descs call into
irq_domain_add_simple in the legacy case. It may need to be conditioned
on SPARSE_IRQ. There's currently no callers, so it wouldn't break anything.
Rob
> - NOMADIK_GPIO_TO_IRQ(pdata->first_gpio),
> - 0, &nmk_gpio_irq_simple_ops, nmk_chip);
> + irq_base, 0,
> + &nmk_gpio_irq_simple_ops, nmk_chip);
> if (!nmk_chip->domain) {
> dev_err(&dev->dev, "failed to create irqdomain\n");
> ret = -ENOSYS;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] pinctrl/nomadik: allocate IRQ descriptors dynamically
2012-09-27 12:37 ` Rob Herring
@ 2012-09-27 12:48 ` Linus Walleij
0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2012-09-27 12:48 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Sep 27, 2012 at 2:37 PM, Rob Herring <robherring2@gmail.com> wrote:
>> nmk_chip->domain = irq_domain_add_legacy(np, NMK_GPIO_PER_CHIP,
>
> You might as well change to irq_domain_add_simple here.
True. I'll fix.
> Perhaps we should just add irq_alloc_descs call into
> irq_domain_add_simple in the legacy case. It may need to be conditioned
> on SPARSE_IRQ. There's currently no callers, so it wouldn't break anything.
OK get ready to ACK, I'll fix.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] pinctrl/nomadik: allocate IRQ descriptors dynamically
2012-09-26 17:18 [PATCH] pinctrl/nomadik: allocate IRQ descriptors dynamically Linus Walleij
2012-09-27 5:13 ` Stephen Warren
2012-09-27 12:37 ` Rob Herring
@ 2012-09-27 12:53 ` Russell King - ARM Linux
2 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux @ 2012-09-27 12:53 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Sep 26, 2012 at 07:18:07PM +0200, Linus Walleij wrote:
> + irq_start = NOMADIK_GPIO_TO_IRQ(pdata->first_gpio);
> + irq_base = irq_alloc_descs(irq_start, 0, NMK_GPIO_PER_CHIP,
> + numa_node_id());
> + if (IS_ERR_VALUE(irq_base)) {
commit 07ab67c8d0d7c1021343b7d5c045033d6bf7be69
Author: Linus Torvalds <torvalds@ppc970.osdl.org>
Date: Thu May 19 22:43:37 2005 -0700
Fix get_unmapped_area sanity tests
As noted by Chris Wright, we need to do the full range of tests regardless
of whether MAP_FIXED is set or not, so re-organize get_unmapped_area()
slightly to do the sanity checks unconditionally.
diff --git a/include/linux/err.h b/include/linux/err.h
index 17c55df..ff71d2a 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -13,6 +13,8 @@
* This should be a per-architecture thing, to allow different
* error and pointer decisions.
*/
+#define IS_ERR_VALUE(x) unlikely((x) > (unsigned long)-1000L)
This is because get_unmapped_area() can return negative numbers which are
not error codes.
My position on this is that IS_ERR_VALUE() should only be used for checking
the return value of a function where some negative numbers are not error
codes, and everywhere else should use "ret < 0".
Just because we have a funky macro is no reason to blindly (ab)use it.
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-09-27 12:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-26 17:18 [PATCH] pinctrl/nomadik: allocate IRQ descriptors dynamically Linus Walleij
2012-09-27 5:13 ` Stephen Warren
2012-09-27 11:59 ` Linus Walleij
2012-09-27 12:37 ` Rob Herring
2012-09-27 12:48 ` Linus Walleij
2012-09-27 12:53 ` Russell King - ARM Linux
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).