# \[PULL 2/5\] tools/virtio/ringtest: tweaks for s390

- From: Cornelia Huck \<hidden\>
- Date: 2017-01-16 14:04:30 
- List: virtualization
- Page: https://ratatoskr.run/virtualization/2017/01/14635630
- Thread: https://ratatoskr.run/linux-s390/2017/01/14635627/t.md

```text
From: Halil Pasic <redacted>

Make ringtest work on s390 too.

Signed-off-by: Halil Pasic <redacted>
Acked-by: Sascha Silbe <redacted>
Signed-off-by: Cornelia Huck <redacted>
---
 tools/virtio/ringtest/main.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tools/virtio/ringtest/main.h b/tools/virtio/ringtest/main.h
index 34e63cc4c572..14142faf040b 100644
--- a/tools/virtio/ringtest/main.h
+++ b/tools/virtio/ringtest/main.h
@@ -26,6 +26,16 @@ static inline void wait_cycles(unsigned long long cycles)
 #define VMEXIT_CYCLES 500
 #define VMENTRY_CYCLES 500
 
+#elif defined(__s390x__)
+static inline void wait_cycles(unsigned long long cycles)
+{
+	asm volatile("0: brctg %0,0b" : : "d" (cycles));
+}
+
+/* tweak me */
+#define VMEXIT_CYCLES 200
+#define VMENTRY_CYCLES 200
+
 #else
 static inline void wait_cycles(unsigned long long cycles)
 {
@@ -81,6 +91,8 @@ extern unsigned ring_size;
 /* Is there a portable way to do this? */
 #if defined(__x86_64__) || defined(__i386__)
 #define cpu_relax() asm ("rep; nop" ::: "memory")
+#elif defined(__s390x__)
+#define cpu_relax() barrier()
 #else
 #define cpu_relax() assert(0)
 #endif
-- 
2.11.0
```
