From 00479aea29892e7969bb4db23e6c764c64478e0d Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Wed, 23 Mar 2022 13:28:43 +0100 Subject: [PATCH] lx_emul(x86): shadow cpu_relax to advance jiffies The i2c code has a busy loop (see commit for the location), which expects that the jiffies advances without a cooperative scheduling decision. Issue #4450 --- .../intel/pc/shadow/asm/vdso/processor.h | 42 +++++++++++++++++++ .../drivers/framebuffer/intel/pc/target.inc | 2 + 2 files changed, 44 insertions(+) create mode 100644 repos/pc/src/drivers/framebuffer/intel/pc/shadow/asm/vdso/processor.h diff --git a/repos/pc/src/drivers/framebuffer/intel/pc/shadow/asm/vdso/processor.h b/repos/pc/src/drivers/framebuffer/intel/pc/shadow/asm/vdso/processor.h new file mode 100644 index 0000000000..db54ee6637 --- /dev/null +++ b/repos/pc/src/drivers/framebuffer/intel/pc/shadow/asm/vdso/processor.h @@ -0,0 +1,42 @@ +/** + * \brief Shadow copy of asm/vdso/processor.h + * \author Alexander Boettcher + * \date 2022-03-23 + */ + +/* + * Copyright (C) 2022 Genode Labs GmbH + * + * This file is distributed under the terms of the GNU General Public License + * version 2. + */ + +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ASM_VDSO_PROCESSOR_H +#define __ASM_VDSO_PROCESSOR_H + +#ifndef __ASSEMBLY__ + +#include +#include + +extern u64 jiffies_64; + + +static __always_inline void rep_nop(void) +{ + asm volatile("rep; nop" ::: "memory"); +} + + +static __always_inline void cpu_relax(void) +{ + /* break busy loop of slchi() in drivers/i2c/algos/i2c-algo-bit.c */ + u64 const us = jiffies_to_usecs(1); + usleep_range(us, us); +} + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASM_VDSO_PROCESSOR_H */ diff --git a/repos/pc/src/drivers/framebuffer/intel/pc/target.inc b/repos/pc/src/drivers/framebuffer/intel/pc/target.inc index 2a42f703cc..ed74f5240e 100644 --- a/repos/pc/src/drivers/framebuffer/intel/pc/target.inc +++ b/repos/pc/src/drivers/framebuffer/intel/pc/target.inc @@ -6,6 +6,8 @@ TARGET := pc_intel_fb_drv LIBS := base pc_lx_emul blit INC_DIR += $(REL_PRG_DIR) +INC_DIR += $(REL_PRG_DIR)/shadow + SRC_CC += main.cc SRC_CC += misc.cc SRC_CC += time.cc