mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-13 02:46:15 +07:00
eb7c825bf7
This tag contains fixes, defconfig, and DT data changes for the v5.2-rc series. The fixes are relatively straightforward: - Addition of a TLB fence in the vmalloc_fault path, so the CPU doesn't enter an infinite page fault loop; - Readdition of the pm_power_off export, so device drivers that reassign it can now be built as modules; - A udelay() fix for RV32, fixing a miscomputation of the delay time; - Removal of deprecated smp_mb__*() barriers. The tag also adds initial DT data infrastructure for arch/riscv, along with initial data for the SiFive FU540-C000 SoC and the corresponding HiFive Unleashed board. We also update the RV64 defconfig to include some core drivers for the FU540 in the build. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEElRDoIDdEz9/svf2Kx4+xDQu9KksFAl0HtEkACgkQx4+xDQu9 KkuRIw//f2vSrUyMh44sevr6euVD0K++hQ0AbteQ94cGHqYWWaNxfwMHFD91Gxbj wowTwgssq7H9nePsKANjiiLULnZNIkWXAlIncjzv3aXkH6JG3f9nEGR49yzvCbIZ yN8wgElJ8rcVWLd096E53Su84CzxuJJ2o3wOI1nQi8aI4h3LwkM2b/O4GxZFpnWb vIhWXqjvbUb8XL7Y+VPewtxnZItOUDHkuIkup4kP2bTgl2iDW93hzWwxNKbt6v+m 9wTzAChjcepCAXSmEGeeZ/h2HNqw2crs+NWOe0drcKxL2vKPZ6gS8ZRX/NuIoDr4 JgMILzYSO28z8N6w1cJJUdN4eGhCTvdxVTQXvkk/yZoT08X6M0xb5A1MbtizgOJ6 mZK/vM9gtuoUSZG0SRNeNoqHbWu1tIm29z435Be8hWAtzXlEfewJm8ntgFO4dGmb E8TRSgjLzdHY0Nvwx/KVtvYmE/TMybVVRsxJJ525dqJlHT7f3VuRstvw7VQJQpz2 +JfsZbYk1KjbUc25QpAqF1LUxrRQFn2JL0Cqw+L49J8eshY77rsTcAKP6ZZWiSFZ qodU0oPF4BkS1t0bnFuNwlqsAr/q9EiAnQO7+SvqQY/ZUnMNk9gCNn5k/rHMCfyD 2Dyo6iAbj+Yyb1rrQxX6QnlbHgpFxsG3N4s9E5jOPgKyEQM4JQ4= =aotJ -----END PGP SIGNATURE----- Merge tag 'riscv-for-v5.2/fixes-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux Pull RISC-V fixes from Paul Walmsley: "This contains fixes, defconfig, and DT data changes for the v5.2-rc series. The fixes are relatively straightforward: - Addition of a TLB fence in the vmalloc_fault path, so the CPU doesn't enter an infinite page fault loop - Readdition of the pm_power_off export, so device drivers that reassign it can now be built as modules - A udelay() fix for RV32, fixing a miscomputation of the delay time - Removal of deprecated smp_mb__*() barriers This also adds initial DT data infrastructure for arch/riscv, along with initial data for the SiFive FU540-C000 SoC and the corresponding HiFive Unleashed board. We also update the RV64 defconfig to include some core drivers for the FU540 in the build" * tag 'riscv-for-v5.2/fixes-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: remove unused barrier defines riscv: mm: synchronize MMU after pte change riscv: dts: add initial board data for the SiFive HiFive Unleashed riscv: dts: add initial support for the SiFive FU540-C000 SoC dt-bindings: riscv: convert cpu binding to json-schema dt-bindings: riscv: sifive: add YAML documentation for the SiFive FU540 arch: riscv: add support for building DTB files from DT source data riscv: Fix udelay in RV32. riscv: export pm_power_off again RISC-V: defconfig: enable clocks, serial console
104 lines
2.7 KiB
C
104 lines
2.7 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
*/
|
|
|
|
#include <linux/delay.h>
|
|
#include <linux/param.h>
|
|
#include <linux/timex.h>
|
|
#include <linux/export.h>
|
|
|
|
/*
|
|
* This is copies from arch/arm/include/asm/delay.h
|
|
*
|
|
* Loop (or tick) based delay:
|
|
*
|
|
* loops = loops_per_jiffy * jiffies_per_sec * delay_us / us_per_sec
|
|
*
|
|
* where:
|
|
*
|
|
* jiffies_per_sec = HZ
|
|
* us_per_sec = 1000000
|
|
*
|
|
* Therefore the constant part is HZ / 1000000 which is a small
|
|
* fractional number. To make this usable with integer math, we
|
|
* scale up this constant by 2^31, perform the actual multiplication,
|
|
* and scale the result back down by 2^31 with a simple shift:
|
|
*
|
|
* loops = (loops_per_jiffy * delay_us * UDELAY_MULT) >> 31
|
|
*
|
|
* where:
|
|
*
|
|
* UDELAY_MULT = 2^31 * HZ / 1000000
|
|
* = (2^31 / 1000000) * HZ
|
|
* = 2147.483648 * HZ
|
|
* = 2147 * HZ + 483648 * HZ / 1000000
|
|
*
|
|
* 31 is the biggest scale shift value that won't overflow 32 bits for
|
|
* delay_us * UDELAY_MULT assuming HZ <= 1000 and delay_us <= 2000.
|
|
*/
|
|
#define MAX_UDELAY_US 2000
|
|
#define MAX_UDELAY_HZ 1000
|
|
#define UDELAY_MULT (2147UL * HZ + 483648UL * HZ / 1000000UL)
|
|
#define UDELAY_SHIFT 31
|
|
|
|
#if HZ > MAX_UDELAY_HZ
|
|
#error "HZ > MAX_UDELAY_HZ"
|
|
#endif
|
|
|
|
/*
|
|
* RISC-V supports both UDELAY and NDELAY. This is largely the same as above,
|
|
* but with different constants. I added 10 bits to the shift to get this, but
|
|
* the result is that I need a 64-bit multiply, which is slow on 32-bit
|
|
* platforms.
|
|
*
|
|
* NDELAY_MULT = 2^41 * HZ / 1000000000
|
|
* = (2^41 / 1000000000) * HZ
|
|
* = 2199.02325555 * HZ
|
|
* = 2199 * HZ + 23255550 * HZ / 1000000000
|
|
*
|
|
* The maximum here is to avoid 64-bit overflow, but it isn't checked as it
|
|
* won't happen.
|
|
*/
|
|
#define MAX_NDELAY_NS (1ULL << 42)
|
|
#define MAX_NDELAY_HZ MAX_UDELAY_HZ
|
|
#define NDELAY_MULT ((unsigned long long)(2199ULL * HZ + 23255550ULL * HZ / 1000000000ULL))
|
|
#define NDELAY_SHIFT 41
|
|
|
|
#if HZ > MAX_NDELAY_HZ
|
|
#error "HZ > MAX_NDELAY_HZ"
|
|
#endif
|
|
|
|
void __delay(unsigned long cycles)
|
|
{
|
|
u64 t0 = get_cycles();
|
|
|
|
while ((unsigned long)(get_cycles() - t0) < cycles)
|
|
cpu_relax();
|
|
}
|
|
EXPORT_SYMBOL(__delay);
|
|
|
|
void udelay(unsigned long usecs)
|
|
{
|
|
u64 ucycles = (u64)usecs * lpj_fine * UDELAY_MULT;
|
|
|
|
if (unlikely(usecs > MAX_UDELAY_US)) {
|
|
__delay((u64)usecs * riscv_timebase / 1000000ULL);
|
|
return;
|
|
}
|
|
|
|
__delay(ucycles >> UDELAY_SHIFT);
|
|
}
|
|
EXPORT_SYMBOL(udelay);
|
|
|
|
void ndelay(unsigned long nsecs)
|
|
{
|
|
/*
|
|
* This doesn't bother checking for overflow, as it won't happen (it's
|
|
* an hour) of delay.
|
|
*/
|
|
unsigned long long ncycles = nsecs * lpj_fine * NDELAY_MULT;
|
|
__delay(ncycles >> NDELAY_SHIFT);
|
|
}
|
|
EXPORT_SYMBOL(ndelay);
|