diff mbox

[1/7] x86: lib: Add busy-loop delay util

Message ID 1521674594-12085-2-git-send-email-liran.alon@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Liran Alon March 21, 2018, 11:23 p.m. UTC
From: Arbel Moshe <arbel.moshe@oracle.com>

Add a delay utility to x86 arch.
The delay is in number of busy-loop iterations running 'pause'.

Signed-off-by: Arbel Moshe <arbel.moshe@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
---
 lib/x86/delay.c     | 8 ++++++++
 lib/x86/delay.h     | 8 ++++++++
 x86/Makefile.common | 1 +
 3 files changed, 17 insertions(+)
 create mode 100644 lib/x86/delay.c
 create mode 100644 lib/x86/delay.h

Comments

Paolo Bonzini March 23, 2018, 7:23 p.m. UTC | #1
On 22/03/2018 00:23, Liran Alon wrote:
> From: Arbel Moshe <arbel.moshe@oracle.com>
> 
> Add a delay utility to x86 arch.
> The delay is in number of busy-loop iterations running 'pause'.
> 
> Signed-off-by: Arbel Moshe <arbel.moshe@oracle.com>
> Signed-off-by: Liran Alon <liran.alon@oracle.com>
> Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>

This last should be a Reviewed-by.  I queued the patches, thanks.

Paolo

> ---
>  lib/x86/delay.c     | 8 ++++++++
>  lib/x86/delay.h     | 8 ++++++++
>  x86/Makefile.common | 1 +
>  3 files changed, 17 insertions(+)
>  create mode 100644 lib/x86/delay.c
>  create mode 100644 lib/x86/delay.h
> 
> diff --git a/lib/x86/delay.c b/lib/x86/delay.c
> new file mode 100644
> index 000000000000..595ad24fec69
> --- /dev/null
> +++ b/lib/x86/delay.c
> @@ -0,0 +1,8 @@
> +#include "delay.h"
> +
> +void delay(u64 count)
> +{
> +	while (count--)
> +		asm volatile("pause");
> +}
> +
> diff --git a/lib/x86/delay.h b/lib/x86/delay.h
> new file mode 100644
> index 000000000000..a9bf89485509
> --- /dev/null
> +++ b/lib/x86/delay.h
> @@ -0,0 +1,8 @@
> +#ifndef __X86_DELAY__
> +#define __X86_DELAY__
> +
> +#include "libcflat.h"
> +
> +void delay(u64 count);
> +
> +#endif
> diff --git a/x86/Makefile.common b/x86/Makefile.common
> index 5f7eac4a26be..57f0bc7d16c3 100644
> --- a/x86/Makefile.common
> +++ b/x86/Makefile.common
> @@ -19,6 +19,7 @@ cflatobjs += lib/x86/desc.o
>  cflatobjs += lib/x86/isr.o
>  cflatobjs += lib/x86/acpi.o
>  cflatobjs += lib/x86/stack.o
> +cflatobjs += lib/x86/delay.o
>  
>  OBJDIRS += lib/x86
>  
>
diff mbox

Patch

diff --git a/lib/x86/delay.c b/lib/x86/delay.c
new file mode 100644
index 000000000000..595ad24fec69
--- /dev/null
+++ b/lib/x86/delay.c
@@ -0,0 +1,8 @@ 
+#include "delay.h"
+
+void delay(u64 count)
+{
+	while (count--)
+		asm volatile("pause");
+}
+
diff --git a/lib/x86/delay.h b/lib/x86/delay.h
new file mode 100644
index 000000000000..a9bf89485509
--- /dev/null
+++ b/lib/x86/delay.h
@@ -0,0 +1,8 @@ 
+#ifndef __X86_DELAY__
+#define __X86_DELAY__
+
+#include "libcflat.h"
+
+void delay(u64 count);
+
+#endif
diff --git a/x86/Makefile.common b/x86/Makefile.common
index 5f7eac4a26be..57f0bc7d16c3 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -19,6 +19,7 @@  cflatobjs += lib/x86/desc.o
 cflatobjs += lib/x86/isr.o
 cflatobjs += lib/x86/acpi.o
 cflatobjs += lib/x86/stack.o
+cflatobjs += lib/x86/delay.o
 
 OBJDIRS += lib/x86