Skip to content

Commit 2bc3fc8

Browse files
avpatelpalmer-dabbelt
authored andcommitted
RISC-V: Remove CLINT related code from timer and arch
Right now the RISC-V timer driver is convoluted to support: 1. Linux RISC-V S-mode (with MMU) where it will use TIME CSR for clocksource and SBI timer calls for clockevent device. 2. Linux RISC-V M-mode (without MMU) where it will use CLINT MMIO counter register for clocksource and CLINT MMIO compare register for clockevent device. We now have a separate CLINT timer driver which also provide CLINT based IPI operations so let's remove CLINT MMIO related code from arch/riscv directory and RISC-V timer driver. Signed-off-by: Anup Patel <[email protected]> Tested-by: Emil Renner Berhing <[email protected]> Acked-by: Daniel Lezcano <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Palmer Dabbelt <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 2ac6795 commit 2bc3fc8

File tree

12 files changed

+16
-126
lines changed

12 files changed

+16
-126
lines changed

arch/riscv/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ config RISCV
8181
select PCI_DOMAINS_GENERIC if PCI
8282
select PCI_MSI if PCI
8383
select RISCV_INTC
84-
select RISCV_TIMER
84+
select RISCV_TIMER if RISCV_SBI
8585
select SPARSEMEM_STATIC if 32BIT
8686
select SPARSE_IRQ
8787
select SYSCTL_EXCEPTION_TRACE

arch/riscv/Kconfig.socs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ config SOC_SIFIVE
1212

1313
config SOC_VIRT
1414
bool "QEMU Virt Machine"
15+
select CLINT_TIMER if RISCV_M_MODE
1516
select POWER_RESET
1617
select POWER_RESET_SYSCON
1718
select POWER_RESET_SYSCON_POWEROFF
@@ -24,6 +25,7 @@ config SOC_VIRT
2425
config SOC_KENDRYTE
2526
bool "Kendryte K210 SoC"
2627
depends on !MMU
28+
select CLINT_TIMER if RISCV_M_MODE
2729
select SERIAL_SIFIVE if TTY
2830
select SERIAL_SIFIVE_CONSOLE if TTY
2931
select SIFIVE_PLIC

arch/riscv/configs/nommu_virt_defconfig

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ CONFIG_EXPERT=y
2626
CONFIG_SLOB=y
2727
# CONFIG_SLAB_MERGE_DEFAULT is not set
2828
# CONFIG_MMU is not set
29+
CONFIG_SOC_VIRT=y
2930
CONFIG_MAXPHYSMEM_2GB=y
3031
CONFIG_SMP=y
3132
CONFIG_CMDLINE="root=/dev/vda rw earlycon=uart8250,mmio,0x10000000,115200n8 console=ttyS0"
@@ -49,24 +50,20 @@ CONFIG_VIRTIO_BLK=y
4950
# CONFIG_SERIO is not set
5051
# CONFIG_LEGACY_PTYS is not set
5152
# CONFIG_LDISC_AUTOLOAD is not set
52-
# CONFIG_DEVMEM is not set
5353
CONFIG_SERIAL_8250=y
5454
# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
5555
CONFIG_SERIAL_8250_CONSOLE=y
5656
CONFIG_SERIAL_8250_NR_UARTS=1
5757
CONFIG_SERIAL_8250_RUNTIME_UARTS=1
5858
CONFIG_SERIAL_OF_PLATFORM=y
5959
# CONFIG_HW_RANDOM is not set
60+
# CONFIG_DEVMEM is not set
6061
# CONFIG_HWMON is not set
61-
# CONFIG_LCD_CLASS_DEVICE is not set
62-
# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
6362
# CONFIG_VGA_CONSOLE is not set
6463
# CONFIG_HID is not set
6564
# CONFIG_USB_SUPPORT is not set
6665
CONFIG_VIRTIO_MMIO=y
6766
CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
68-
CONFIG_SIFIVE_PLIC=y
69-
# CONFIG_VALIDATE_FS_PARSER is not set
7067
CONFIG_EXT2_FS=y
7168
# CONFIG_DNOTIFY is not set
7269
# CONFIG_INOTIFY_USER is not set

arch/riscv/include/asm/clint.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

arch/riscv/include/asm/timex.h

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,27 @@
77
#define _ASM_RISCV_TIMEX_H
88

99
#include <asm/csr.h>
10-
#include <asm/mmio.h>
1110

1211
typedef unsigned long cycles_t;
1312

14-
extern u64 __iomem *riscv_time_val;
15-
extern u64 __iomem *riscv_time_cmp;
16-
17-
#ifdef CONFIG_64BIT
18-
#define mmio_get_cycles() readq_relaxed(riscv_time_val)
19-
#else
20-
#define mmio_get_cycles() readl_relaxed(riscv_time_val)
21-
#define mmio_get_cycles_hi() readl_relaxed(((u32 *)riscv_time_val) + 1)
22-
#endif
23-
2413
static inline cycles_t get_cycles(void)
2514
{
26-
if (IS_ENABLED(CONFIG_RISCV_SBI))
27-
return csr_read(CSR_TIME);
28-
return mmio_get_cycles();
15+
return csr_read(CSR_TIME);
2916
}
3017
#define get_cycles get_cycles
3118

19+
static inline u32 get_cycles_hi(void)
20+
{
21+
return csr_read(CSR_TIMEH);
22+
}
23+
#define get_cycles_hi get_cycles_hi
24+
3225
#ifdef CONFIG_64BIT
3326
static inline u64 get_cycles64(void)
3427
{
3528
return get_cycles();
3629
}
3730
#else /* CONFIG_64BIT */
38-
static inline u32 get_cycles_hi(void)
39-
{
40-
if (IS_ENABLED(CONFIG_RISCV_SBI))
41-
return csr_read(CSR_TIMEH);
42-
return mmio_get_cycles_hi();
43-
}
44-
4531
static inline u64 get_cycles64(void)
4632
{
4733
u32 hi, lo;

arch/riscv/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ obj-y += cacheinfo.o
3131
obj-y += patch.o
3232
obj-$(CONFIG_MMU) += vdso.o vdso/
3333

34-
obj-$(CONFIG_RISCV_M_MODE) += clint.o traps_misaligned.o
34+
obj-$(CONFIG_RISCV_M_MODE) += traps_misaligned.o
3535
obj-$(CONFIG_FPU) += fpu.o
3636
obj-$(CONFIG_SMP) += smpboot.o
3737
obj-$(CONFIG_SMP) += smp.o

arch/riscv/kernel/clint.c

Lines changed: 0 additions & 63 deletions
This file was deleted.

arch/riscv/kernel/setup.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <linux/swiotlb.h>
1919
#include <linux/smp.h>
2020

21-
#include <asm/clint.h>
2221
#include <asm/cpu_ops.h>
2322
#include <asm/setup.h>
2423
#include <asm/sections.h>
@@ -79,7 +78,6 @@ void __init setup_arch(char **cmdline_p)
7978
#else
8079
unflatten_device_tree();
8180
#endif
82-
clint_init_boot_cpu();
8381

8482
#ifdef CONFIG_SWIOTLB
8583
swiotlb_init(1);

arch/riscv/kernel/smp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <linux/delay.h>
1919
#include <linux/irq_work.h>
2020

21-
#include <asm/clint.h>
2221
#include <asm/sbi.h>
2322
#include <asm/tlbflush.h>
2423
#include <asm/cacheflush.h>

arch/riscv/kernel/smpboot.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <linux/of.h>
2525
#include <linux/sched/task_stack.h>
2626
#include <linux/sched/mm.h>
27-
#include <asm/clint.h>
2827
#include <asm/cpu_ops.h>
2928
#include <asm/irq.h>
3029
#include <asm/mmu_context.h>

0 commit comments

Comments
 (0)