Skip to contentSkip to conversation

pxa: fix system resume issue on pxa27x and pxa3xx

PATCH New Haojian Zhuang 4 participants 6 messages Nov 2, 2009 – Nov 3, 2009

Subsystems (3)
lore
Share & tools
lore

Haojian Zhuang

author maintainer
#0 lore raw

PATCH 1/1 pxa: fix system resume issue on pxa27x and pxa3xx

#1 lore raw

PATCH 1/1 pxa: fix system resume issue on pxa27x and pxa3xx

Quoted 8 lines · Haojian Zhuang
Quoted 1 line

From 1764e836424d42a0654b8b73c402a2dddb118dc4 Mon Sep 17 00:00:00 2001

From: Haojian Zhuang <[email protected]>
Date: Mon, 2 Nov 2009 14:02:21 -0500
Subject: [PATCH] pxa: fix system resume issue on pxa27x and pxa3xx

Since interrupt handler is changed to use interrupt priority, we also need to save and restore these interrupt controller registers in suspend/resume routine.

Since we've just been struggling with discovering why something doesn't suspend/resume, is this:

Review static int pxa_irq_suspend(struct sys_device · line 165

Quoted 7 lines
(quoted diff) +2 -0
@@ -159,6 +160,10 @@ static int pxa_irq_suspend(struct sys_device
 *dev, pm_message_t state)
 		saved_icmr[i] = _ICMR(irq);
 		_ICMR(irq) = 0;
 	}
+	if (pxa_internal_irq_nr > 128)
+		BUG();

really appropriate. If we have more than 128 interrupts, do we really want to cause the kernel to OOPS at this point?

What about:

	if (WARN_ON(pxa_internal_irq_nr > 128))
		return -EINVAL;

so that we refuse to sleep _and_ log the reason why?

This way, the platform will still be alive, and if you didn't see it via the console, at least it'll be available via dmesg - which is a lot better than trying to work out why the machine gets stuck during suspend.

Such a check should also be a little higher up - since we're already looping over the number of irqs for ICMR.

#2 lore raw

PATCH 1/1 pxa: fix system resume issue on pxa27x and pxa3xx

Quoted 29 lines · Russell King - ARM Linux
Quoted 8 lines · Haojian Zhuang
Quoted 1 line

From 1764e836424d42a0654b8b73c402a2dddb118dc4 Mon Sep 17 00:00:00 2001

From: Haojian Zhuang <[email protected]>
Date: Mon, 2 Nov 2009 14:02:21 -0500
Subject: [PATCH] pxa: fix system resume issue on pxa27x and pxa3xx

Since interrupt handler is changed to use interrupt priority, we also need to save and restore these interrupt controller registers in suspend/resume routine.

Since we've just been struggling with discovering why something doesn't suspend/resume, is this:

Review static int pxa_irq_suspend(struct sys_device · line 165

Quoted 7 lines
(quoted diff) +2 -0
@@ -159,6 +160,10 @@ static int pxa_irq_suspend(struct sys_device
 *dev, pm_message_t state)
 ? ? ? ? ? ? ? saved_icmr[i] = _ICMR(irq);
 ? ? ? ? ? ? ? _ICMR(irq) = 0;
 ? ? ? }
+ ? ? if (pxa_internal_irq_nr > 128)
+ ? ? ? ? ? ? BUG();

really appropriate. ?If we have more than 128 interrupts, do we really want to cause the kernel to OOPS at this point?

What about:

? ? ? ?if (WARN_ON(pxa_internal_irq_nr > 128))
? ? ? ? ? ? ? ?return -EINVAL;

Quoted 9 lines

so that we refuse to sleep _and_ log the reason why?

This way, the platform will still be alive, and if you didn't see it via the console, at least it'll be available via dmesg - which is a lot better than trying to work out why the machine gets stuck during suspend.

Such a check should also be a little higher up - since we're already looping over the number of irqs for ICMR.

Yes, I'd prefer such a check could be done earlier in pxa_init_irq() instead.

maintainer
#3 lore raw

PATCH 1/1 pxa: fix system resume issue on pxa27x and pxa3xx

In reply to Haojian Zhuang
Quoted 11 lines · Haojian Zhuang

From 1764e836424d42a0654b8b73c402a2dddb118dc4 Mon Sep 17 00:00:00 2001
From: Haojian Zhuang <[email protected]>
Date: Mon, 2 Nov 2009 14:02:21 -0500
Subject: [PATCH] pxa: fix system resume issue on pxa27x and pxa3xx

Since interrupt handler is changed to use interrupt priority, we also need to save and restore these interrupt controller registers in suspend/resume routine.

Yes, the fix does work for my platform too, well done.

As a side note, the "128" magic number may have deserved a little define somewhere.

Cheers.

--
Robert

author maintainer
#4 lore raw

PATCH 1/1 pxa: fix system resume issue on pxa27x and pxa3xx

Quoted 17 lines · Robert Jarzmik
Quoted 11 lines · Haojian Zhuang

From 1764e836424d42a0654b8b73c402a2dddb118dc4 Mon Sep 17 00:00:00 2001
From: Haojian Zhuang <[email protected]>
Date: Mon, 2 Nov 2009 14:02:21 -0500
Subject: [PATCH] pxa: fix system resume issue on pxa27x and pxa3xx

Since interrupt handler is changed to use interrupt priority, we also need to save and restore these interrupt controller registers in suspend/resume routine.

Yes, the fix does work for my platform too, well done.

Quoted 8 lines

As a side note, the "128" magic number may have deserved a little define somewhere.

Cheers.

--
Robert

Thanks of all good comments. Now I move the check into the initialization code. If internal irq number is larger than 128, the larger irqs won't be initialized. So suspend resume routine needn't access the larger IPR registers. Patch is in below and attached.

Thanks
Haojian

#5 lore raw

PATCH 1/1 pxa: fix system resume issue on pxa27x and pxa3xx

The changes might be too much, I simplified it to the one below and merged into 'fix':

commit c482ae4dcf23fd241321595d71bbe8aee33eabf5

Author: Haojian Zhuang <[email protected]>
Date:   Mon Nov 2 14:02:21 2009 -0500

[ARM] pxa: fix resume failure by saving/restoring IPRx registers

Since interrupt handler is changed to use interrupt priority, we also need to save and restore these interrupt controller registers in suspend/resume routine.

arch/arm/mach-pxa/irq.c +6 -1
index d694ce2..6112af4 100644
@@ -25,6 +25,8 @@
 
 #include "generic.h"
 
+#define MAX_INTERNAL_IRQS      128
+
 #define IRQ_BIT(n)     (((n) - PXA_IRQ(0)) & 0x1f)
 #define _ICMR(n)       (*((((n) - PXA_IRQ(0)) & ~0x1f) ? &ICMR2 : &ICMR))
 #define _ICLR(n)       (*((((n) - PXA_IRQ(0)) & ~0x1f) ? &ICLR2 : &ICLR))
@@ -122,6 +124,8 @@ void __init pxa_init_irq(int irq_nr, set_wake_t fn)
 {
        int irq, i;
 
+       BUG_ON(irq_nr > MAX_INTERNAL_IRQS);
+
        pxa_internal_irq_nr = irq_nr;
 
        for (irq = PXA_IRQ(0); irq < PXA_IRQ(irq_nr); irq += 32) {
@@ -149,7 +153,8 @@ void __init pxa_init_irq(int irq_nr, set_wake_t fn)
 }
 
 #ifdef CONFIG_PM
-static unsigned long saved_icmr[2];
+static unsigned long saved_icmr[MAX_INTERNAL_IRQS/32];
+static unsigned long saved_ipr[MAX_INTERNAL_IRQS];
 
 static int pxa_irq_suspend(struct sys_device *dev, pm_message_t state)
 {
@@ -159,6 +164,8 @@ static int pxa_irq_suspend(struct sys_device *dev,

pm_message_t state)

                saved_icmr[i] = _ICMR(irq);
                _ICMR(irq) = 0;
        }

+ for (i = 0; i < pxa_internal_irq_nr; i++)
+ saved_ipr[i] = IPR(i);

        return 0;
 }
@@ -171,6 +178,8 @@ static int pxa_irq_resume(struct sys_device *dev)
                _ICMR(irq) = saved_icmr[i];
                _ICLR(irq) = 0;
        }

+ for (i = 0; i < pxa_internal_irq_nr; i++)
+ IPR(i) = saved_ipr[i];

        ICCR = 1;
        return 0;