* [PATCH RFC] genirq: Genric chip: Use DIV_ROUND_UP to count numchips
@ 2013-07-05 9:13 Axel Lin
2013-07-05 9:48 ` [tip:irq/urgent] genirq: generic chip: Use DIV_ROUND_UP to calculate numchips tip-bot for Axel Lin
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2013-07-05 9:13 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: Grant Likely, Tony Lindgren, Arnd Bergmann, linux-kernel
The number of interrupts in a domain may be not divisible by the number of
interrupts each chip handles.
Integer division may truncate the result, thus use DIV_ROUND_UP to count
numchips.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
Seems all users of irq_alloc_domain_generic_chips() in current code do not
have this issue. I just found the issue while reading the code.
In the commit 02c981c0 of "ARM: CSR: Adding CSR SiRFprimaII board support"
It set SIRFSOC_INTENAL_IRQ_END to 59.
So I think this might be a possible case for some hardware.
kernel/irq/generic-chip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index 10e663a..452d6f2 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -275,7 +275,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
if (d->gc)
return -EBUSY;
- numchips = d->revmap_size / irqs_per_chip;
+ numchips = DIV_ROUND_UP(d->revmap_size, irqs_per_chip);
if (!numchips)
return -EINVAL;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip:irq/urgent] genirq: generic chip: Use DIV_ROUND_UP to calculate numchips
2013-07-05 9:13 [PATCH RFC] genirq: Genric chip: Use DIV_ROUND_UP to count numchips Axel Lin
@ 2013-07-05 9:48 ` tip-bot for Axel Lin
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Axel Lin @ 2013-07-05 9:48 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, grant.likely, hpa, mingo, tony, arnd, tglx,
axel.lin
Commit-ID: 002fca5df168922103a2bb52748f9984e6de80b2
Gitweb: http://git.kernel.org/tip/002fca5df168922103a2bb52748f9984e6de80b2
Author: Axel Lin <axel.lin@ingics.com>
AuthorDate: Fri, 5 Jul 2013 17:13:12 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 5 Jul 2013 11:39:25 +0200
genirq: generic chip: Use DIV_ROUND_UP to calculate numchips
The number of interrupts in a domain may be not divisible by the
number of interrupts each chip handles. Integer division may truncate
the result, thus use DIV_ROUND_UP to count numchips.
Seems all users of irq_alloc_domain_generic_chips() in current code do
not have this issue. I just found the issue while reading the code.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: http://lkml.kernel.org/r/1373015592.18252.2.camel@phoenix
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/irq/generic-chip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index 1c39ecc..2f274f3 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -278,7 +278,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
if (d->revmap_type != IRQ_DOMAIN_MAP_LINEAR)
return -EINVAL;
- numchips = d->revmap_data.linear.size / irqs_per_chip;
+ numchips = DIV_ROUND_UP(d->revmap_data.linear.size, irqs_per_chip);
if (!numchips)
return -EINVAL;
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-07-05 9:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-05 9:13 [PATCH RFC] genirq: Genric chip: Use DIV_ROUND_UP to count numchips Axel Lin
2013-07-05 9:48 ` [tip:irq/urgent] genirq: generic chip: Use DIV_ROUND_UP to calculate numchips tip-bot for Axel Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox