Skip to contentSkip to conversation

powerpc/wdrtas: Update wdrtas_get_interval to use rtas_data_buf

PATCH In review Mark Nelson 3 participants 5 messages Mar 24, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/wdrtas: Update wdrtas_get_interval to use rtas_data_buf

The buffer passed to the ibm,get-system-parameter RTAS call must be in the RMA. To ensure we pass an address in the RMA use rtas_data_buf for the actual RTAS call and then copy the result to value. We can't just make it static because this can be compiled in as a module.

Also add the WDRTAS_SP_SPI_LEN so we don't litter '4' throughout the function.

---

Adrian, does this patch cause any problems for your pxcabs?

Thanks!
Mark

 drivers/watchdog/wdrtas.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/watchdog/wdrtas.c +11 -2
Index: upstream/drivers/watchdog/wdrtas.c
===================================================================
@@ -106,6 +106,8 @@ static int wdrtas_set_interval(int inter
 	return result;
 }
 
+#define WDRTAS_SP_SPI_LEN 4
+
 /**
  * wdrtas_get_interval - returns the current watchdog interval
  * @fallback_value: value (in seconds) to use, if the RTAS call fails
@@ -119,10 +121,17 @@ static int wdrtas_set_interval(int inter
 static int wdrtas_get_interval(int fallback_value)
 {
 	long result;
-	char value[4];
+	char value[WDRTAS_SP_SPI_LEN];
 
+	spin_lock(&rtas_data_buf_lock);
+	memset(rtas_data_buf, 0, WDRTAS_SP_SPI_LEN);
 	result = rtas_call(wdrtas_token_get_sp, 3, 1, NULL,
-			   WDRTAS_SP_SPI, (void *)__pa(&value), 4);
+			   WDRTAS_SP_SPI, __pa(rtas_data_buf),
+			   WDRTAS_SP_SPI_LEN);
+
+	memcpy(value, rtas_data_buf, WDRTAS_SP_SPI_LEN);
+	spin_unlock(&rtas_data_buf_lock);
+
 	if (value[0] != 0 || value[1] != 2 || value[3] != 0 || result < 0) {
 		printk(KERN_WARNING "wdrtas: could not get sp_spi watchdog "
 		       "timeout (%li). Continuing\n", result);
Tested-by on v1 1/1
#1 lore raw
Quoted 5 lines · Mark Nelson

The buffer passed to the ibm,get-system-parameter RTAS call must be in the RMA. To ensure we pass an address in the RMA use rtas_data_buf for the actual RTAS call and then copy the result to value. We can't just make it static because this can be compiled in as a module.

Quoted 7 lines

Also add the WDRTAS_SP_SPI_LEN so we don't litter '4' throughout the function.

---

Adrian, does this patch cause any problems for your pxcabs?

No, it even helps. I have no tried the watchdog until now, but without the patch I get:

wdrtas: could not get sp_spi watchdog timeout (0). Continuing

and with the patch it reads the correct value. So only with your patch it works like it is supposed to. Thanks!

Quoted 29 lines

Thanks!
Mark

 drivers/watchdog/wdrtas.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Index: upstream/drivers/watchdog/wdrtas.c
===================================================================

drivers/watchdog/wdrtas.c +5 -1
@@ -106,6 +106,8 @@ static int wdrtas_set_interval(int inter
 	return result;
 }
 
+#define WDRTAS_SP_SPI_LEN 4
+
 /**
  * wdrtas_get_interval - returns the current watchdog interval
  * @fallback_value: value (in seconds) to use, if the RTAS call fails
@@ -119,10 +121,17 @@ static int wdrtas_set_interval(int inter
 static int wdrtas_get_interval(int fallback_value)
 {
 	long result;
-	char value[4];
+	char value[WDRTAS_SP_SPI_LEN];
 
+	spin_lock(&rtas_data_buf_lock);
+	memset(rtas_data_buf, 0, WDRTAS_SP_SPI_LEN);
 	result = rtas_call(wdrtas_token_get_sp, 3, 1, NULL,

drivers/watchdog/wdrtas.c static int wdrtas_set_interval(int inter · line 137

Quoted 10 lines
drivers/watchdog/wdrtas.c +6 -1
-			   WDRTAS_SP_SPI, (void *)__pa(&value), 4);
+			   WDRTAS_SP_SPI, __pa(rtas_data_buf),
+			   WDRTAS_SP_SPI_LEN);
+
+	memcpy(value, rtas_data_buf, WDRTAS_SP_SPI_LEN);
+	spin_unlock(&rtas_data_buf_lock);
+
 	if (value[0] != 0 || value[1] != 2 || value[3] != 0 || result < 0) {
 		printk(KERN_WARNING "wdrtas: could not get sp_spi watchdog "
 		       "timeout (%li). Continuing\n", result);

Adrian

Signature · 3 lines
Adrian Reber <[email protected]>            http://lisas.de/~adrian/
There's coffee in that nebula!
		-- Capt. Kathryn Janeway, Star Trek: Voyager, "The Cloud"
Acked-by
#2 lore raw

Adrian Reber <[email protected]> wrote on 24.03.2009 13:31:31:

Quoted 9 lines · Mark Nelson
Quoted 8 lines

The buffer passed to the ibm,get-system-parameter RTAS call must be in the RMA. To ensure we pass an address in the RMA use rtas_data_buf for the actual RTAS call and then copy the result to value. We can't just make it static because this can be compiled in as a module.

Also add the WDRTAS_SP_SPI_LEN so we don't litter '4' throughout the function.

Quoted 6 lines
Quoted 4 lines

---

Adrian, does this patch cause any problems for your pxcabs?

No, it even helps. I have no tried the watchdog until now, but without

the

Quoted 8 lines

patch I get:

wdrtas: could not get sp_spi watchdog timeout (0). Continuing

and with the patch it reads the correct value. So only with your patch it works like it is supposed to. Thanks!

looks good to me.

Utz

:wq

#3 lore raw
Quoted 21 lines · Utz Bacher

Adrian Reber <[email protected]> wrote on 24.03.2009 13:31:31:

Quoted 9 lines · Mark Nelson
Quoted 8 lines

The buffer passed to the ibm,get-system-parameter RTAS call must be in the RMA. To ensure we pass an address in the RMA use rtas_data_buf for the actual RTAS call and then copy the result to value. We can't just make it static because this can be compiled in as a module.

Also add the WDRTAS_SP_SPI_LEN so we don't litter '4' throughout the function.

Quoted 6 lines
Quoted 4 lines

---

Adrian, does this patch cause any problems for your pxcabs?

No, it even helps. I have no tried the watchdog until now, but without

the

Quoted 4 lines

patch I get:

wdrtas: could not get sp_spi watchdog timeout (0). Continuing

Quoted 8 lines
Quoted 4 lines

and with the patch it reads the correct value. So only with your patch it works like it is supposed to. Thanks!

looks good to me.

Thanks for looking over it!
Mark

#4 lore raw
In reply to Adrian Reber
Quoted 17 lines · Adrian Reber
Quoted 5 lines · Mark Nelson

The buffer passed to the ibm,get-system-parameter RTAS call must be in the RMA. To ensure we pass an address in the RMA use rtas_data_buf for the actual RTAS call and then copy the result to value. We can't just make it static because this can be compiled in as a module.

Quoted 7 lines

Also add the WDRTAS_SP_SPI_LEN so we don't litter '4' throughout the function.

---

Adrian, does this patch cause any problems for your pxcabs?

No, it even helps. I have no tried the watchdog until now, but without the patch I get:

Quoted 6 lines

wdrtas: could not get sp_spi watchdog timeout (0). Continuing

and with the patch it reads the correct value. So only with your patch it works like it is supposed to. Thanks!

Good to hear

Thanks for testing!
Mark