Skip to contentSkip to conversation

powerpc/pseries: make max polling consistent for longer H_CALLs

PATCH Applied Nayna Jain 3 participants 3 messages Apr 18, 2024 – May 3, 2024 PowerPC

lore
Share & tools
lore

Nayna Jain

author
#0 lore raw

PATCH v4 1/1 powerpc/pseries: make max polling consistent for longer H_CALLs

Currently, plpks_confirm_object_flushed() function polls for 5msec in total instead of 5sec.

Keep max polling time consistent for all the H_CALLs, which take longer than expected, to be 5sec. Also, make use of fsleep() everywhere to insert delay.

Fixes 2454a7af0f2a ("powerpc/pseries: define driver for Platform KeyStore")

---
v4:
* As per Andrew's feedback, squashed Patch 2 with Patch 1.
Now it is single patch.

v3:
* Addition to Patch 1 timeout patch based on Andrew's feedback.

v2:
* Updated based on feedback from Michael Ellerman Replaced usleep_range with fsleep.
Since there is no more need to specify range, sleep time is
reverted back to 10 msec.

 arch/powerpc/include/asm/plpks.h       |  5 ++---
 arch/powerpc/platforms/pseries/plpks.c | 10 +++++-----
 2 files changed, 7 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/plpks.h +2 -3
index 23b77027c916..7a84069759b0 100644
@@ -44,9 +44,8 @@
 #define PLPKS_MAX_DATA_SIZE		4000
 
 // Timeouts for PLPKS operations
-#define PLPKS_MAX_TIMEOUT		5000 // msec
-#define PLPKS_FLUSH_SLEEP		10 // msec
-#define PLPKS_FLUSH_SLEEP_RANGE		400
+#define PLPKS_MAX_TIMEOUT		(5 * USEC_PER_SEC)
+#define PLPKS_FLUSH_SLEEP		10000 // usec
 
 struct plpks_var {
 	char *component;
arch/powerpc/platforms/pseries/plpks.c +5 -5
index febe18f251d0..4a595493d28a 100644
@@ -415,8 +415,7 @@ static int plpks_confirm_object_flushed(struct label *label,
 			break;
 		}
 
-		usleep_range(PLPKS_FLUSH_SLEEP,
-			     PLPKS_FLUSH_SLEEP + PLPKS_FLUSH_SLEEP_RANGE);
+		fsleep(PLPKS_FLUSH_SLEEP);
 		timeout = timeout + PLPKS_FLUSH_SLEEP;
 	} while (timeout < PLPKS_MAX_TIMEOUT);
 
@@ -464,9 +463,10 @@ int plpks_signed_update_var(struct plpks_var *var, u64 flags)
 
 		continuetoken = retbuf[0];
 		if (pseries_status_to_err(rc) == -EBUSY) {
-			int delay_ms = get_longbusy_msecs(rc);
-			mdelay(delay_ms);
-			timeout += delay_ms;
+			int delay_us = get_longbusy_msecs(rc) * 1000;
+
+			fsleep(delay_us);
+			timeout += delay_us;
 		}
 		rc = pseries_status_to_err(rc);
 	} while (rc == -EBUSY && timeout < PLPKS_MAX_TIMEOUT);
Signature · 1 line
2.31.1
Reviewed-by on v4 1/1
#1 lore raw
Quoted 8 lines · Nayna Jain

Currently, plpks_confirm_object_flushed() function polls for 5msec in total instead of 5sec.

Keep max polling time consistent for all the H_CALLs, which take longer
than expected, to be 5sec. Also, make use of fsleep() everywhere to insert delay.

Quoted 5 lines
Fixes 2454a7af0f2a ("powerpc/pseries: define driver for Platform

KeyStore")

Quoted 68 lines

---
v4:
 * As per Andrew's feedback, squashed Patch 2 with Patch 1. Now it is single patch.

v3:
 * Addition to Patch 1 timeout patch based on Andrew's feedback.

v2:
* Updated based on feedback from Michael Ellerman Replaced usleep_range with fsleep.
        Since there is no more need to specify range, sleep time is reverted back to 10 msec.

 arch/powerpc/include/asm/plpks.h       |  5 ++--- arch/powerpc/platforms/pseries/plpks.c | 10 +++++-----

 2 files changed, 7 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/plpks.h +0 -0
index 23b77027c916..7a84069759b0 100644
@@ -44,9 +44,8 @@
  #define PLPKS_MAX_DATA_SIZE		4000


 // Timeouts for PLPKS operations

arch/powerpc/include/asm/plpks.h +2 -3
-#define PLPKS_MAX_TIMEOUT		5000 // msec
-#define PLPKS_FLUSH_SLEEP		10 // msec
-#define PLPKS_FLUSH_SLEEP_RANGE		400
+#define PLPKS_MAX_TIMEOUT		(5 * USEC_PER_SEC)
+#define PLPKS_FLUSH_SLEEP		10000 // usec


 struct plpks_var {
  char *component;

arch/powerpc/platforms/pseries/plpks.c +0 -0
index febe18f251d0..4a595493d28a 100644
@@ -415,8 +415,7 @@ static int plpks_confirm_object_flushed(struct
 label *label,
  			break;
  		}

arch/powerpc/platforms/pseries/plpks.c +0 -2
-		usleep_range(PLPKS_FLUSH_SLEEP,
-			     PLPKS_FLUSH_SLEEP +

PLPKS_FLUSH_SLEEP_RANGE);

arch/powerpc/platforms/pseries/plpks.c +1 -0
+		fsleep(PLPKS_FLUSH_SLEEP);

  timeout = timeout + PLPKS_FLUSH_SLEEP; } while (timeout < PLPKS_MAX_TIMEOUT);

arch/powerpc/platforms/pseries/plpks.c +0 -0
@@ -464,9 +463,10 @@ int plpks_signed_update_var(struct plpks_var
 *var, u64 flags)


  continuetoken = retbuf[0];
  if (pseries_status_to_err(rc) == -EBUSY) {

arch/powerpc/platforms/pseries/plpks.c +1 -3
-			int delay_ms = get_longbusy_msecs(rc);
-			mdelay(delay_ms);
-			timeout += delay_ms;
+			int delay_us = get_longbusy_msecs(rc) *

1000;

arch/powerpc/platforms/pseries/plpks.c +3 -0
+
+			fsleep(delay_us);
+			timeout += delay_us;

  }
  rc = pseries_status_to_err(rc);
  } while (rc == -EBUSY && timeout < PLPKS_MAX_TIMEOUT);

Signature · 2 lines
Andrew Donnellan    OzLabs, ADL Canberra
[email protected]   IBM Australia Limited
#2 lore raw
In reply to Nayna Jain
Quoted 8 lines · Nayna Jain

Currently, plpks_confirm_object_flushed() function polls for 5msec in total instead of 5sec.

Keep max polling time consistent for all the H_CALLs, which take longer than expected, to be 5sec. Also, make use of fsleep() everywhere to insert delay.

[...]

Applied to powerpc/fixes.

[1/1] powerpc/pseries: make max polling consistent for longer H_CALLs

      https://git.kernel.org/powerpc/c/784354349d2c988590c63a5a001ca37b2a6d4da1

cheers