Skip to content

Commit 74b13e7

Browse files
committed
Merge tag 'riscv-for-linus-5.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux
Pull RISC-V fixes from Palmer Dabbelt: "This contains a handful of mostly-independent patches: - make our port respect TIF_NEED_RESCHED, which fixes CONFIG_PREEMPT=y kernels - fix double-put of OF nodes - fix a misspelling of target in our Kconfig - generic PCIe is enabled in our defconfig - fix our SBI early console to properly handle line endings - fix max_low_pfn being counted in PFNs - a change to TASK_UNMAPPED_BASE to match what other arches do This has passed my standard 'boot Fedora' flow" * tag 'riscv-for-linus-5.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux: riscv: Adjust mmap base address at a third of task size riscv: fixup max_low_pfn with PFN_DOWN. tty/serial: use uart_console_write in the RISC-V SBL early console RISC-V: defconfig: Add CRYPTO_DEV_VIRTIO=y RISC-V: defconfig: Enable Generic PCIE by default RISC-V: defconfig: Move CONFIG_PCI{,E_XILINX} RISC-V: Kconfig: fix spelling mistake "traget" -> "target" RISC-V: asm/page.h: fix spelling mistake "CONFIG_64BITS" -> "CONFIG_64BIT" RISC-V: fix bad use of of_node_put RISC-V: Add _TIF_NEED_RESCHED check for kernel thread when CONFIG_PREEMPT=y
2 parents c8864cb + ae662ee commit 74b13e7

File tree

10 files changed

+38
-19
lines changed

10 files changed

+38
-19
lines changed

arch/riscv/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ choice
103103
prompt "Base ISA"
104104
default ARCH_RV64I
105105
help
106-
This selects the base ISA that this kernel will traget and must match
106+
This selects the base ISA that this kernel will target and must match
107107
the target platform.
108108

109109
config ARCH_RV32I

arch/riscv/configs/defconfig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ CONFIG_BLK_DEV_INITRD=y
1313
CONFIG_EXPERT=y
1414
CONFIG_BPF_SYSCALL=y
1515
CONFIG_SMP=y
16-
CONFIG_PCI=y
17-
CONFIG_PCIE_XILINX=y
1816
CONFIG_MODULES=y
1917
CONFIG_MODULE_UNLOAD=y
2018
CONFIG_NET=y
@@ -28,6 +26,10 @@ CONFIG_IP_PNP_DHCP=y
2826
CONFIG_IP_PNP_BOOTP=y
2927
CONFIG_IP_PNP_RARP=y
3028
CONFIG_NETLINK_DIAG=y
29+
CONFIG_PCI=y
30+
CONFIG_PCIEPORTBUS=y
31+
CONFIG_PCI_HOST_GENERIC=y
32+
CONFIG_PCIE_XILINX=y
3133
CONFIG_DEVTMPFS=y
3234
CONFIG_BLK_DEV_LOOP=y
3335
CONFIG_VIRTIO_BLK=y
@@ -63,7 +65,6 @@ CONFIG_USB_STORAGE=y
6365
CONFIG_USB_UAS=y
6466
CONFIG_VIRTIO_MMIO=y
6567
CONFIG_SIFIVE_PLIC=y
66-
CONFIG_RAS=y
6768
CONFIG_EXT4_FS=y
6869
CONFIG_EXT4_FS_POSIX_ACL=y
6970
CONFIG_AUTOFS4_FS=y
@@ -77,5 +78,6 @@ CONFIG_NFS_V4_1=y
7778
CONFIG_NFS_V4_2=y
7879
CONFIG_ROOT_NFS=y
7980
CONFIG_CRYPTO_USER_API_HASH=y
81+
CONFIG_CRYPTO_DEV_VIRTIO=y
8082
CONFIG_PRINTK_TIME=y
8183
# CONFIG_RCU_TRACE is not set

arch/riscv/include/asm/page.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ typedef struct page *pgtable_t;
8080
#define __pgd(x) ((pgd_t) { (x) })
8181
#define __pgprot(x) ((pgprot_t) { (x) })
8282

83-
#ifdef CONFIG_64BITS
83+
#ifdef CONFIG_64BIT
8484
#define PTE_FMT "%016lx"
8585
#else
8686
#define PTE_FMT "%08lx"

arch/riscv/include/asm/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* This decides where the kernel will search for a free chunk of vm
2323
* space during mmap's.
2424
*/
25-
#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE >> 1)
25+
#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
2626

2727
#define STACK_TOP TASK_SIZE
2828
#define STACK_TOP_MAX STACK_TOP

arch/riscv/kernel/asm-offsets.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ void asm_offsets(void)
3939
OFFSET(TASK_STACK, task_struct, stack);
4040
OFFSET(TASK_TI, task_struct, thread_info);
4141
OFFSET(TASK_TI_FLAGS, task_struct, thread_info.flags);
42+
OFFSET(TASK_TI_PREEMPT_COUNT, task_struct, thread_info.preempt_count);
4243
OFFSET(TASK_TI_KERNEL_SP, task_struct, thread_info.kernel_sp);
4344
OFFSET(TASK_TI_USER_SP, task_struct, thread_info.user_sp);
4445
OFFSET(TASK_TI_CPU, task_struct, thread_info.cpu);

arch/riscv/kernel/entry.S

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ _save_context:
144144
REG_L x2, PT_SP(sp)
145145
.endm
146146

147+
#if !IS_ENABLED(CONFIG_PREEMPT)
148+
.set resume_kernel, restore_all
149+
#endif
150+
147151
ENTRY(handle_exception)
148152
SAVE_ALL
149153

@@ -228,7 +232,7 @@ ret_from_exception:
228232
REG_L s0, PT_SSTATUS(sp)
229233
csrc sstatus, SR_SIE
230234
andi s0, s0, SR_SPP
231-
bnez s0, restore_all
235+
bnez s0, resume_kernel
232236

233237
resume_userspace:
234238
/* Interrupts must be disabled here so flags are checked atomically */
@@ -250,6 +254,18 @@ restore_all:
250254
RESTORE_ALL
251255
sret
252256

257+
#if IS_ENABLED(CONFIG_PREEMPT)
258+
resume_kernel:
259+
REG_L s0, TASK_TI_PREEMPT_COUNT(tp)
260+
bnez s0, restore_all
261+
need_resched:
262+
REG_L s0, TASK_TI_FLAGS(tp)
263+
andi s0, s0, _TIF_NEED_RESCHED
264+
beqz s0, restore_all
265+
call preempt_schedule_irq
266+
j need_resched
267+
#endif
268+
253269
work_pending:
254270
/* Enter slow path for supplementary processing */
255271
la ra, ret_from_exception

arch/riscv/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void __init setup_bootmem(void)
181181
BUG_ON(mem_size == 0);
182182

183183
set_max_mapnr(PFN_DOWN(mem_size));
184-
max_low_pfn = memblock_end_of_DRAM();
184+
max_low_pfn = PFN_DOWN(memblock_end_of_DRAM());
185185

186186
#ifdef CONFIG_BLK_DEV_INITRD
187187
setup_initrd();

arch/riscv/kernel/smpboot.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,19 @@ void __init setup_smp(void)
5757

5858
while ((dn = of_find_node_by_type(dn, "cpu"))) {
5959
hart = riscv_of_processor_hartid(dn);
60-
if (hart < 0) {
61-
of_node_put(dn);
60+
if (hart < 0)
6261
continue;
63-
}
6462

6563
if (hart == cpuid_to_hartid_map(0)) {
6664
BUG_ON(found_boot_cpu);
6765
found_boot_cpu = 1;
68-
of_node_put(dn);
6966
continue;
7067
}
7168

7269
cpuid_to_hartid_map(cpuid) = hart;
7370
set_cpu_possible(cpuid, true);
7471
set_cpu_present(cpuid, true);
7572
cpuid++;
76-
of_node_put(dn);
7773
}
7874

7975
BUG_ON(!found_boot_cpu);

arch/riscv/mm/init.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ static void __init zone_sizes_init(void)
2828
unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
2929

3030
#ifdef CONFIG_ZONE_DMA32
31-
max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, max_low_pfn));
31+
max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G,
32+
(unsigned long) PFN_PHYS(max_low_pfn)));
3233
#endif
3334
max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
3435

drivers/tty/serial/earlycon-riscv-sbi.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
#include <linux/serial_core.h>
1111
#include <asm/sbi.h>
1212

13-
static void sbi_console_write(struct console *con,
14-
const char *s, unsigned int n)
13+
static void sbi_putc(struct uart_port *port, int c)
1514
{
16-
int i;
15+
sbi_console_putchar(c);
16+
}
1717

18-
for (i = 0; i < n; ++i)
19-
sbi_console_putchar(s[i]);
18+
static void sbi_console_write(struct console *con,
19+
const char *s, unsigned n)
20+
{
21+
struct earlycon_device *dev = con->data;
22+
uart_console_write(&dev->port, s, n, sbi_putc);
2023
}
2124

2225
static int __init early_sbi_setup(struct earlycon_device *device,

0 commit comments

Comments
 (0)