Skip to contentSkip to conversation

powerpc: Fix Book-E watchdog timer interval setting

PATCH Superseded Matthias Fuchs 3 participants 9 messages Aug 7, 2008 – Nov 3, 2008 Watchdog device drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Fix Book-E watchdog timer interval setting

This patch fixes the setting of the Book-E watchdog timer interval setup on initialization and by ioctl().

Tested on PPC440EPx sequoia evaluation board.

---
 drivers/watchdog/booke_wdt.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/watchdog/booke_wdt.c +5 -1
index 7708244..9db5478 100644
@@ -42,8 +42,10 @@ u32 booke_wdt_period = WDT_PERIOD_DEFAULT;
 
 #ifdef	CONFIG_FSL_BOOKE
 #define WDTP(x)		((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15))
+#define WDTP_MASK	(WDTP(63))
 #else
 #define WDTP(x)		(TCR_WP(x))
+#define WDTP_MASK	(TCR_WP_MASK)
 #endif
 
 static DEFINE_SPINLOCK(booke_wdt_lock);
@@ -65,6 +67,7 @@ static void __booke_wdt_enable(void *data)
 	/* clear status before enabling watchdog */
 	__booke_wdt_ping(NULL);
 	val = mfspr(SPRN_TCR);
+	val &= ~WDTP_MASK;
 	val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period));
 
 	mtspr(SPRN_TCR, val);
@@ -106,7 +109,8 @@ static int booke_wdt_ioctl(struct inode *inode, struct file *file,
 	case WDIOC_SETTIMEOUT:
 		if (get_user(booke_wdt_period, p))
 			return -EFAULT;
-		mtspr(SPRN_TCR, (mfspr(SPRN_TCR)&~WDTP(0))|WDTP(booke_wdt_period));
+		tmp = mfspr(SPRN_TCR) & ~WDTP_MASK;
+		mtspr(SPRN_TCR, tmp | WDTP(booke_wdt_period));
 		return 0;
 	case WDIOC_GETTIMEOUT:
 		return put_user(booke_wdt_period, p);
Signature · 1 line
1.5.3
#1 lore raw
Quoted 9 lines · Matthias Fuchs

This patch fixes the setting of the Book-E watchdog timer interval setup on initialization and by ioctl().

Tested on PPC440EPx sequoia evaluation board.

---
drivers/watchdog/booke_wdt.c | 6 +++++-

1 files changed, 5 insertions(+), 1 deletions(-)

can you be more explicit about what the bug was.

- k

#2 lore raw

Sure,

the former line:

mtspr(SPRN_TCR, (mfspr(SPRN_TCR)&~WDTP(0))|WDTP(booke_wdt_period));

tries to mask the wdt interval period bits by and'ing with ~WDTP(0) which is 0xffffffff. So no bits are cleared and or'ing a new value does not change anything. The default interval is '3' which is the maximum, so any attempt to set a new interval keeps the former '3'.

The patch correctly masks the period bits in SPRN_TCR before writing the new value.

That's all.

Matthias

Quoted 19 lines · Kumar Gala
Quoted 10 lines · Matthias Fuchs

This patch fixes the setting of the Book-E watchdog timer interval setup
on initialization and by ioctl().

Tested on PPC440EPx sequoia evaluation board.

---
drivers/watchdog/booke_wdt.c | 6 +++++-

1 files changed, 5 insertions(+), 1 deletions(-)

can you be more explicit about what the bug was.

- k

#3 lore raw
In reply to Kumar Gala

Hi Kumar,

should I resend this my patch? Is there chance to get it applied. It really fixes a bug!

Matthias

Quoted 19 lines · On Thursday 07 August 2008 15:19:10 Kumar Gala wrote:
Quoted 10 lines · Matthias Fuchs

This patch fixes the setting of the Book-E watchdog timer interval setup
on initialization and by ioctl().

Tested on PPC440EPx sequoia evaluation board.

---
drivers/watchdog/booke_wdt.c | 6 +++++-

1 files changed, 5 insertions(+), 1 deletions(-)

can you be more explicit about what the bug was.

- k
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#4 lore raw

Please repost and I'll look at it again.. I'm trying to be more diligent about patchworks.ozlabs.org and tracking things there.

- k

Quoted 28 lines · Matthias Fuchs

Hi Kumar,

should I resend this my patch? Is there chance to get it applied. It really fixes a bug!

Matthias

Quoted 19 lines · On Thursday 07 August 2008 15:19:10 Kumar Gala wrote:
Quoted 10 lines · Matthias Fuchs

This patch fixes the setting of the Book-E watchdog timer interval setup
on initialization and by ioctl().

Tested on PPC440EPx sequoia evaluation board.

---
drivers/watchdog/booke_wdt.c | 6 +++++-

1 files changed, 5 insertions(+), 1 deletions(-)

can you be more explicit about what the bug was.

- k
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#5 lore raw

PATCH v2 1/1 powerpc: Fix Book-E watchdog timer interval setting

This patch fixes the setting of the Book-E watchdog timer interval setup on initialization and by ioctl().

On initialization the period bits have to be masked before setting a new period.

In WDIOC_SETTIMEOUT ioctl we have to use the currect mask.

---
 drivers/watchdog/booke_wdt.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/watchdog/booke_wdt.c +4 -1
index c3b78a7..41ba9b8 100644
@@ -42,8 +42,10 @@ u32 booke_wdt_period = WDT_PERIOD_DEFAULT;
 
 #ifdef	CONFIG_FSL_BOOKE
 #define WDTP(x)		((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15))
+#define WDTP_MASK	(WDTP(63))
 #else
 #define WDTP(x)		(TCR_WP(x))
+#define WDTP_MASK	(TCR_WP_MASK)
 #endif
 
 static DEFINE_SPINLOCK(booke_wdt_lock);
@@ -65,6 +67,7 @@ static void __booke_wdt_enable(void *data)
 	/* clear status before enabling watchdog */
 	__booke_wdt_ping(NULL);
 	val = mfspr(SPRN_TCR);
+	val &= ~WDTP_MASK;
 	val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period));
 
 	mtspr(SPRN_TCR, val);
@@ -114,7 +117,7 @@ static long booke_wdt_ioctl(struct file *file,
 	case WDIOC_SETTIMEOUT:
 		if (get_user(booke_wdt_period, p))
 			return -EFAULT;
-		mtspr(SPRN_TCR, (mfspr(SPRN_TCR) & ~WDTP(0)) |
+		mtspr(SPRN_TCR, (mfspr(SPRN_TCR) & ~WDTP_MASK) |
 						WDTP(booke_wdt_period));
 		return 0;
 	case WDIOC_GETTIMEOUT:
Signature · 1 line
1.5.3
#6 lore raw
Quoted 3 lines · Matthias Fuchs

#ifdef CONFIG_FSL_BOOKE
#define WDTP(x) ((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15))
+#define WDTP_MASK (WDTP(63))

WDTP(63) is "((((63-63)&0x3)<<30)|(((63-63)&0x3c)<<15))", which is equal to 0. Shouldn't WDTP_MASK be equal to "(3 << 30) | (15 << 15)"?

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#7 lore raw

Timur,

I missed you posting. But you are right. My patch is ok for 4xx CPUs and touching the CONFIG_FSL_BOOKE path was not my intention.

So for CONFIG_FSL_BOOKE WDTP_MASK should be WDTP(0). There is still a slightly difference between WDTP(0)="(3 << 30) | (0x3c << 15)" and "(3 << 30) | (15 << 15)". Can you check that please and I will resend my patch.

Thanks for pointing that out.

Matthias

Quoted 9 lines · Timur Tabi
Quoted 3 lines · Matthias Fuchs

#ifdef CONFIG_FSL_BOOKE
#define WDTP(x) ((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15))
+#define WDTP_MASK (WDTP(63))

WDTP(63) is "((((63-63)&0x3)<<30)|(((63-63)&0x3c)<<15))", which is equal to 0. Shouldn't WDTP_MASK be equal to "(3 << 30) | (15 << 15)"?

#8 lore raw
Quoted 8 lines · Matthias Fuchs

Timur,

I missed you posting. But you are right. My patch is ok for 4xx CPUs and touching the CONFIG_FSL_BOOKE path was not my intention.

So for CONFIG_FSL_BOOKE WDTP_MASK should be WDTP(0). There is still a slightly difference between WDTP(0)="(3 << 30) | (0x3c << 15)" and "(3 << 30) | (15 << 15)". Can you check that please and I will resend my patch.

Yes, I think WDTP(0) is correct for Book E.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale