Skip to contentSkip to conversation

s3c24xx fix: freeze during suspend/resume on s3c24xx if some GPIO banks not present

PATCH New Pinkava J. 3 participants 6 messages May 23, 2010 – May 24, 2010

Subsystems (2)
lore
Share & tools
lore

Pinkava J.

author
#0 lore raw

PATCH 1/1 s3c24xx fix: freeze during suspend/resume on s3c24xx if some GPIO banks not present

When saving GPIOs during suspend/resume we need skip missing GPIO banks, not trying get corresponding chip again and again in infinite loop.

---
 arch/arm/plat-samsung/pm-gpio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/plat-samsung/pm-gpio.c +6 -2
index d50ab9d..7df03f8 100644
@@ -331,8 +331,10 @@ void s3c_pm_save_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
 		s3c_pm_save_gpio(ourchip);
 
@@ -369,8 +371,10 @@ void s3c_pm_restore_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
 		s3c_pm_resume_gpio(ourchip);
 
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 s3c24xx fix: freeze during suspend/resume on s3c24xx if some GPIO banks not present

Hello.

Quoted 2 lines · Pinkava J.

When saving GPIOs during suspend/resume we need skip missing GPIO banks, not trying get corresponding chip again and again in infinite loop.

I didn't see any infinite loops there -- *continue* itself leads to
incrementing 'gpio_nr', no?

Quoted 22 lines
---
 arch/arm/plat-samsung/pm-gpio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/plat-samsung/pm-gpio.c +3 -1
index d50ab9d..7df03f8 100644
@@ -331,8 +331,10 @@ void s3c_pm_save_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
 		s3c_pm_save_gpio(ourchip);
 

arch/arm/plat-samsung/pm-gpio.c void s3c_pm_restore_gpios(void) · line 379

Quoted 10 lines
arch/arm/plat-samsung/pm-gpio.c +3 -1
@@ -369,8 +371,10 @@ void s3c_pm_restore_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
 		s3c_pm_resume_gpio(ourchip);

WBR, Sergei

author
#2 lore raw

PATCH 1/1 s3c24xx fix: freeze during suspend/resume on s3c24xx if some GPIO banks not present

Dne 23.5.2010 11:19, Sergei Shtylyov napsal(a):

Quoted 9 lines

Hello.

Quoted 2 lines · Pinkava J.

When saving GPIOs during suspend/resume we need skip missing GPIO banks, not trying get corresponding chip again and again in infinite loop.

I didn't see any infinite loops there -- *continue* itself leads to
incrementing 'gpio_nr', no?

No, it would have to be:

for (gpio_nr = 0; gpio_nr < S3C_GPIO_END; gpio_nr++) {
...

try create simple test program for your self

/* test.c */
main()

{
	int x;
	for(x = 0; x < 10; /* x++ */ )
	{
		printf("x  = %d", x);
	}
}

Compile usign:

gcc test.c

Run

./a.out

Quoted 35 lines
Quoted 23 lines
---
 arch/arm/plat-samsung/pm-gpio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/plat-samsung/pm-gpio.c +3 -1
index d50ab9d..7df03f8 100644
@@ -331,8 +331,10 @@ void s3c_pm_save_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
 		s3c_pm_save_gpio(ourchip);
 

arch/arm/plat-samsung/pm-gpio.c void s3c_pm_restore_gpios(void) · line 379

Quoted 10 lines
arch/arm/plat-samsung/pm-gpio.c +3 -1
@@ -369,8 +371,10 @@ void s3c_pm_restore_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
 		s3c_pm_resume_gpio(ourchip);

WBR, Sergei

author
#5 lore raw

PATCH 1/1 s3c24xx fix: freeze during suspend/resume on s3c24xx if some GPIO banks not present

In reply to Pinkava J.

Dne 23.5.2010 06:42, Pinkava J. napsal(a):

Quoted 13 lines

When saving GPIOs during suspend/resume we need skip missing GPIO banks, not trying get corresponding chip again and again in infinite loop.

---
 arch/arm/plat-samsung/pm-gpio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/plat-samsung/pm-gpio.c +0 -0
index d50ab9d..7df03f8 100644

arch/arm/plat-samsung/pm-gpio.c void s3c_pm_save_gpios(void) · line 332

Quoted 2 lines
arch/arm/plat-samsung/pm-gpio.c +0 -0
@@ -331,8 +331,10 @@ void s3c_pm_save_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {

Note that there is in for-linus/samsung4 working version usign

for (gpio_nr = 0; gpio_nr < S3C_GPIO_END; gpio_nr++) {

but into linus kernel was introduced a bug by last commit.

Quoted 21 lines
arch/arm/plat-samsung/pm-gpio.c +6 -2
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
 		s3c_pm_save_gpio(ourchip);
 
@@ -369,8 +371,10 @@ void s3c_pm_restore_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
 		s3c_pm_resume_gpio(ourchip);
 
#4 lore raw

PATCH 1/1 s3c24xx fix: freeze during suspend/resume on s3c24xx if some GPIO banks not present

In reply to Sergei Shtylyov
Quoted 9 lines · Sergei Shtylyov

Hello.

Quoted 2 lines · Pinkava J.

When saving GPIOs during suspend/resume we need skip missing GPIO banks, not trying get corresponding chip again and again in infinite loop.

I didn't see any infinite loops there -- *continue* itself leads to
incrementing 'gpio_nr', no?

no, I made a bit of a mess playing with this patch, so this should fix it (now applied).

Really I could do with a list of all registered s3c_gpio_chips to allow for a more efficient implementation, but it is a bit late for that for this merge window.

Quoted 39 lines
Quoted 22 lines
---
 arch/arm/plat-samsung/pm-gpio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/plat-samsung/pm-gpio.c +3 -1
index d50ab9d..7df03f8 100644
@@ -331,8 +331,10 @@ void s3c_pm_save_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
 		s3c_pm_save_gpio(ourchip);
 

arch/arm/plat-samsung/pm-gpio.c void s3c_pm_restore_gpios(void) · line 379

Quoted 10 lines
arch/arm/plat-samsung/pm-gpio.c +3 -1
@@ -369,8 +371,10 @@ void s3c_pm_restore_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
 		s3c_pm_resume_gpio(ourchip);

WBR, Sergei

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 5 lines
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
#3 lore raw

PATCH 1/1 s3c24xx fix: freeze during suspend/resume on s3c24xx if some GPIO banks not present

In reply to Pinkava J.

Hello.

Quoted 22 lines · Pinkava J.
Quoted 4 lines
Quoted 2 lines

When saving GPIOs during suspend/resume we need skip missing GPIO banks, not trying get corresponding chip again and again in infinite loop.

I didn't see any infinite loops there -- *continue* itself leads to
incrementing 'gpio_nr', no?

No, it would have to be:

for (gpio_nr = 0; gpio_nr < S3C_GPIO_END; gpio_nr++) {
...

try create simple test program for your self

/* test.c */
main()

{
	int x;
	for(x = 0; x < 10; /* x++ */ )
	{
		printf("x  = %d", x);
	}
}
Quoted 7 lines

Compile usign:

gcc test.c

Run

./a.out

Ah, I missed the empty 3rd expression in *for*, sorry. :-<
Strange loop though...

Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
---
 arch/arm/plat-samsung/pm-gpio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/plat-samsung/pm-gpio.c +6 -2
index d50ab9d..7df03f8 100644
@@ -331,8 +331,10 @@ void s3c_pm_save_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
 		s3c_pm_save_gpio(ourchip);
 
@@ -369,8 +371,10 @@ void s3c_pm_restore_gpios(void)
 
 	for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) {
 		ourchip = s3c_gpiolib_getchip(gpio_nr);
-		if (!ourchip)
+		if (!ourchip) {
+			gpio_nr++;
 			continue;
+		}
 
Quoted 1 line
Quoted 1 line

arch/arm/plat-samsung/pm-gpio.c void s3c_pm_restore_gpios(void) · line 379

Quoted 1 line
arch/arm/plat-samsung/pm-gpio.c +0 -0
 		s3c_pm_resume_gpio(ourchip);

WBR, Sergei