linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/powernv: Don't alloc IRQ map if necessary
@ 2015-01-08  5:42 Gavin Shan
  2015-01-22  5:54 ` Michael Ellerman
  0 siblings, 1 reply; 3+ messages in thread
From: Gavin Shan @ 2015-01-08  5:42 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Gavin Shan

On PowerNV platform, the OPAL interrupts are exported by firmware
through device-node property (/ibm,opal::opal-interrupts). Under
some extreme circumstances (e.g. simulator), we don't have this
property found from the device tree. For that case, we shouldn't
allocate the interrupt map. Otherwise, slab complains allocating
zero sized memory chunk.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/opal.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index f10b9ec..e61cefe 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -726,11 +726,14 @@ static int __init opal_init(void)
 
 	/* Find all OPAL interrupts and request them */
 	irqs = of_get_property(opal_node, "opal-interrupts", &irqlen);
+	opal_irq_count = irqs ? (irqlen / 4) : 0;
+	if (opal_irq_count)
+		opal_irqs = kzalloc(opal_irq_count * sizeof(unsigned int),
+				    GFP_KERNEL);
 	pr_debug("opal: Found %d interrupts reserved for OPAL\n",
-		 irqs ? (irqlen / 4) : 0);
-	opal_irq_count = irqlen / 4;
-	opal_irqs = kzalloc(opal_irq_count * sizeof(unsigned int), GFP_KERNEL);
-	for (i = 0; irqs && i < (irqlen / 4); i++, irqs++) {
+		 opal_irq_count);
+
+	for (i = 0; opal_irqs && i < opal_irq_count; i++, irqs++) {
 		unsigned int hwirq = be32_to_cpup(irqs);
 		unsigned int irq = irq_create_mapping(NULL, hwirq);
 		if (irq == NO_IRQ) {
@@ -775,7 +778,7 @@ void opal_shutdown(void)
 	long rc = OPAL_BUSY;
 
 	/* First free interrupts, which will also mask them */
-	for (i = 0; i < opal_irq_count; i++) {
+	for (i = 0; opal_irqs && i < opal_irq_count; i++) {
 		if (opal_irqs[i])
 			free_irq(opal_irqs[i], NULL);
 		opal_irqs[i] = 0;
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: powerpc/powernv: Don't alloc IRQ map if necessary
  2015-01-08  5:42 [PATCH] powerpc/powernv: Don't alloc IRQ map if necessary Gavin Shan
@ 2015-01-22  5:54 ` Michael Ellerman
  2015-01-22  6:22   ` Gavin Shan
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2015-01-22  5:54 UTC (permalink / raw)
  To: Gavin Shan, linuxppc-dev; +Cc: Gavin Shan

On Thu, 2015-08-01 at 05:42:32 UTC, Gavin Shan wrote:
> On PowerNV platform, the OPAL interrupts are exported by firmware
> through device-node property (/ibm,opal::opal-interrupts). Under
> some extreme circumstances (e.g. simulator), we don't have this
> property found from the device tree. For that case, we shouldn't
> allocate the interrupt map. Otherwise, slab complains allocating
> zero sized memory chunk.
 
That sounds fine. But the implementation is a bit messy.

Can you do a precursor patch which moves the logic into opal_irq_init(), that
way when you find no interrupts you can just return.

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: powerpc/powernv: Don't alloc IRQ map if necessary
  2015-01-22  5:54 ` Michael Ellerman
@ 2015-01-22  6:22   ` Gavin Shan
  0 siblings, 0 replies; 3+ messages in thread
From: Gavin Shan @ 2015-01-22  6:22 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Gavin Shan

On Thu, Jan 22, 2015 at 04:54:59PM +1100, Michael Ellerman wrote:
>On Thu, 2015-08-01 at 05:42:32 UTC, Gavin Shan wrote:
>> On PowerNV platform, the OPAL interrupts are exported by firmware
>> through device-node property (/ibm,opal::opal-interrupts). Under
>> some extreme circumstances (e.g. simulator), we don't have this
>> property found from the device tree. For that case, we shouldn't
>> allocate the interrupt map. Otherwise, slab complains allocating
>> zero sized memory chunk.
>
>That sounds fine. But the implementation is a bit messy.
>
>Can you do a precursor patch which moves the logic into opal_irq_init(), that
>way when you find no interrupts you can just return.
>

Sure, I'll change the code accordingly and repost.

Thanks,
Gavin

>cheers
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-22  6:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08  5:42 [PATCH] powerpc/powernv: Don't alloc IRQ map if necessary Gavin Shan
2015-01-22  5:54 ` Michael Ellerman
2015-01-22  6:22   ` Gavin Shan

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).