On 28.08.20 10:44, Alice Guo wrote:
> Ensure that wait sufficiently on faster CPUs.
>
> Signed-off-by: Alice Guo <alice....@nxp.com>
> ---
>  hypervisor/arch/arm-common/Kbuild             |  2 +-
>  .../arch/arm-common/include/asm/timing.h      | 17 ++++++++
>  hypervisor/arch/arm-common/timing.c           | 39 +++++++++++++++++++
>  3 files changed, 57 insertions(+), 1 deletion(-)
>  create mode 100644 hypervisor/arch/arm-common/include/asm/timing.h
>  create mode 100644 hypervisor/arch/arm-common/timing.c
>
> diff --git a/hypervisor/arch/arm-common/Kbuild 
> b/hypervisor/arch/arm-common/Kbuild
> index ab86eca6..86ef9b86 100644
> --- a/hypervisor/arch/arm-common/Kbuild
> +++ b/hypervisor/arch/arm-common/Kbuild
> @@ -17,6 +17,6 @@ ccflags-$(CONFIG_JAILHOUSE_GCOV) += -fprofile-arcs 
> -ftest-coverage
>  objs-y += dbg-write.o lib.o psci.o control.o paging.o mmu_cell.o setup.o
>  objs-y += irqchip.o pci.o ivshmem.o uart-pl011.o uart-xuartps.o uart-mvebu.o
>  objs-y += uart-hscif.o uart-scifa.o uart-imx.o uart-imx-lpuart.o
> -objs-y += gic-v2.o gic-v3.o smccc.o
> +objs-y += gic-v2.o gic-v3.o smccc.o timing.o
>
>  common-objs-y = $(addprefix ../arm-common/,$(objs-y))
> diff --git a/hypervisor/arch/arm-common/include/asm/timing.h 
> b/hypervisor/arch/arm-common/include/asm/timing.h
> new file mode 100644
> index 00000000..145beb6c
> --- /dev/null
> +++ b/hypervisor/arch/arm-common/include/asm/timing.h
> @@ -0,0 +1,17 @@
> +/*
> + * Jailhouse, a Linux-based partitioning hypervisor
> + *
> + * Copyright 2020 NXP
> + *
> + * Authors:
> + *  Alice Guo <alice....@nxp.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.  See
> + * the COPYING file in the top-level directory.
> + */
> +
> +#include <jailhouse/types.h>
> +
> +unsigned long timer_get_frequency(void);
> +u64 timer_get_ticks(void);
> +void delay_us(unsigned long microsecs);
> diff --git a/hypervisor/arch/arm-common/timing.c 
> b/hypervisor/arch/arm-common/timing.c
> new file mode 100644
> index 00000000..ad4a5a86
> --- /dev/null
> +++ b/hypervisor/arch/arm-common/timing.c
> @@ -0,0 +1,39 @@
> +/*
> + * Jailhouse, a Linux-based partitioning hypervisor
> + *
> + * Copyright 2020 NXP
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.  See
> + * the COPYING file in the top-level directory.
> + *
> + * Partly derived from inmates/lib/arm-common/timing.c
> + */
> +
> +#include <asm/processor.h>
> +#include <asm/sysregs.h>
> +#include <asm/timing.h>
> +
> +unsigned long timer_get_frequency(void)
> +{
> +     unsigned long freq;
> +
> +     arm_read_sysreg(CNTFRQ_EL0, freq);
> +     return freq;
> +}
> +
> +u64 timer_get_ticks(void)
> +{
> +     u64 pct64;
> +
> +     arm_read_sysreg(CNTPCT_EL0, pct64);
> +     return pct64;
> +}
> +
> +void delay_us(unsigned long microsecs)
> +{
> +     unsigned long long timeout = timer_get_ticks() +
> +             microsecs * (timer_get_frequency() / 1000 / 1000);
> +
> +     while ((long long)(timeout - timer_get_ticks()) > 0)
> +             cpu_relax();
> +}
>

My comment on v1 was likely misleading: The Jailhouse core has no notion
of time, and that shall remain like this as long as possible. Exposing
such an API bears the risk that it will not only be used for the more
harmless case in the SMMUv2. So this implementation should not be added.

Looking at the concrete use case, we can do much simpler anyway. Will
comment on that patch.

Jan

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jailhouse-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/4d070388-0507-26b2-f7e4-a307d43cad05%40web.de.

Reply via email to