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
Unified · Split
| @@ -103,7 +103,7 @@ choice · 102 unmodified lines | ||
| 103 | 103 | prompt "Base ISA" |
| 104 | 104 | default ARCH_RV64I |
| 105 | 105 | 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 | |
| 107 | 107 | the target platform. |
| 108 | 108 | |
| 109 | 109 | config ARCH_RV32I |
| @@ -13,8 +13,6 @@ CONFIG_BLK_DEV_INITRD=y · 12 unmodified lines | ||
| 13 | 13 | CONFIG_EXPERT=y |
| 14 | 14 | CONFIG_BPF_SYSCALL=y |
| 15 | 15 | CONFIG_SMP=y |
| 16 | −CONFIG_PCI=y | |
| 17 | −CONFIG_PCIE_XILINX=y | |
| 18 | 16 | CONFIG_MODULES=y |
| 19 | 17 | CONFIG_MODULE_UNLOAD=y |
| 20 | 18 | CONFIG_NET=y |
| @@ -28,6 +26,10 @@ CONFIG_IP_PNP_DHCP=y · 7 unmodified lines | ||
| 28 | 26 | CONFIG_IP_PNP_BOOTP=y |
| 29 | 27 | CONFIG_IP_PNP_RARP=y |
| 30 | 28 | CONFIG_NETLINK_DIAG=y |
| 29 | +CONFIG_PCI=y | |
| 30 | +CONFIG_PCIEPORTBUS=y | |
| 31 | +CONFIG_PCI_HOST_GENERIC=y | |
| 32 | +CONFIG_PCIE_XILINX=y | |
| 31 | 33 | CONFIG_DEVTMPFS=y |
| 32 | 34 | CONFIG_BLK_DEV_LOOP=y |
| 33 | 35 | CONFIG_VIRTIO_BLK=y |
| @@ -63,7 +65,6 @@ CONFIG_USB_STORAGE=y · 29 unmodified lines | ||
| 63 | 65 | CONFIG_USB_UAS=y |
| 64 | 66 | CONFIG_VIRTIO_MMIO=y |
| 65 | 67 | CONFIG_SIFIVE_PLIC=y |
| 66 | −CONFIG_RAS=y | |
| 67 | 68 | CONFIG_EXT4_FS=y |
| 68 | 69 | CONFIG_EXT4_FS_POSIX_ACL=y |
| 69 | 70 | CONFIG_AUTOFS4_FS=y |
| @@ -77,5 +78,6 @@ CONFIG_NFS_V4_1=y · 7 unmodified lines | ||
| 77 | 78 | CONFIG_NFS_V4_2=y |
| 78 | 79 | CONFIG_ROOT_NFS=y |
| 79 | 80 | CONFIG_CRYPTO_USER_API_HASH=y |
| 81 | +CONFIG_CRYPTO_DEV_VIRTIO=y | |
| 80 | 82 | CONFIG_PRINTK_TIME=y |
| 81 | 83 | # CONFIG_RCU_TRACE is not set |
| @@ -80,7 +80,7 @@ typedef struct page *pgtable_t; · 79 unmodified lines | ||
| 80 | 80 | #define __pgd(x) ((pgd_t) { (x) }) |
| 81 | 81 | #define __pgprot(x) ((pgprot_t) { (x) }) |
| 82 | 82 | |
| 83 | −#ifdef CONFIG_64BITS | |
| 83 | +#ifdef CONFIG_64BIT | |
| 84 | 84 | #define PTE_FMT "%016lx" |
| 85 | 85 | #else |
| 86 | 86 | #define PTE_FMT "%08lx" |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | * This decides where the kernel will search for a free chunk of vm |
| 23 | 23 | * space during mmap's. |
| 24 | 24 | */ |
| 25 | −#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE >> 1) | |
| 25 | +#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3) | |
| 26 | 26 | |
| 27 | 27 | #define STACK_TOP TASK_SIZE |
| 28 | 28 | #define STACK_TOP_MAX STACK_TOP |
| @@ -39,6 +39,7 @@ void asm_offsets(void) · 38 unmodified lines | ||
| 39 | 39 | OFFSET(TASK_STACK, task_struct, stack); |
| 40 | 40 | OFFSET(TASK_TI, task_struct, thread_info); |
| 41 | 41 | OFFSET(TASK_TI_FLAGS, task_struct, thread_info.flags); |
| 42 | + OFFSET(TASK_TI_PREEMPT_COUNT, task_struct, thread_info.preempt_count); | |
| 42 | 43 | OFFSET(TASK_TI_KERNEL_SP, task_struct, thread_info.kernel_sp); |
| 43 | 44 | OFFSET(TASK_TI_USER_SP, task_struct, thread_info.user_sp); |
| 44 | 45 | OFFSET(TASK_TI_CPU, task_struct, thread_info.cpu); |
| @@ -144,6 +144,10 @@ _save_context: · 143 unmodified lines | ||
| 144 | 144 | REG_L x2, PT_SP(sp) |
| 145 | 145 | .endm |
| 146 | 146 | |
| 147 | +#if !IS_ENABLED(CONFIG_PREEMPT) | |
| 148 | +.set resume_kernel, restore_all | |
| 149 | +#endif | |
| 150 | + | |
| 147 | 151 | ENTRY(handle_exception) |
| 148 | 152 | SAVE_ALL |
| 149 | 153 | |
| @@ -228,7 +232,7 @@ ret_from_exception: · 78 unmodified lines | ||
| 228 | 232 | REG_L s0, PT_SSTATUS(sp) |
| 229 | 233 | csrc sstatus, SR_SIE |
| 230 | 234 | andi s0, s0, SR_SPP |
| 231 | − bnez s0, restore_all | |
| 235 | + bnez s0, resume_kernel | |
| 232 | 236 | |
| 233 | 237 | resume_userspace: |
| 234 | 238 | /* Interrupts must be disabled here so flags are checked atomically */ |
| @@ -250,6 +254,18 @@ restore_all: · 15 unmodified lines | ||
| 250 | 254 | RESTORE_ALL |
| 251 | 255 | sret |
| 252 | 256 | |
| 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 | + | |
| 253 | 269 | work_pending: |
| 254 | 270 | /* Enter slow path for supplementary processing */ |
| 255 | 271 | la ra, ret_from_exception |
| @@ -181,7 +181,7 @@ static void __init setup_bootmem(void) · 180 unmodified lines | ||
| 181 | 181 | BUG_ON(mem_size == 0); |
| 182 | 182 | |
| 183 | 183 | 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()); | |
| 185 | 185 | |
| 186 | 186 | #ifdef CONFIG_BLK_DEV_INITRD |
| 187 | 187 | setup_initrd(); |
| @@ -57,15 +57,12 @@ void __init setup_smp(void) · 56 unmodified lines | ||
| 57 | 57 | |
| 58 | 58 | while ((dn = of_find_node_by_type(dn, "cpu"))) { |
| 59 | 59 | hart = riscv_of_processor_hartid(dn); |
| 60 | − if (hart < 0) { | |
| 61 | − of_node_put(dn); | |
| 60 | + if (hart < 0) | |
| 62 | 61 | continue; |
| 63 | − } | |
| 64 | 62 | |
| 65 | 63 | if (hart == cpuid_to_hartid_map(0)) { |
| 66 | 64 | BUG_ON(found_boot_cpu); |
| 67 | 65 | found_boot_cpu = 1; |
| 68 | − of_node_put(dn); | |
| 69 | 66 | continue; |
| 70 | 67 | } |
| 71 | 68 | |
| @@ -73,7 +70,6 @@ void __init setup_smp(void) · 1 unmodified line | ||
| 73 | 70 | set_cpu_possible(cpuid, true); |
| 74 | 71 | set_cpu_present(cpuid, true); |
| 75 | 72 | cpuid++; |
| 76 | − of_node_put(dn); | |
| 77 | 73 | } |
| 78 | 74 | |
| 79 | 75 | BUG_ON(!found_boot_cpu); |
| @@ -28,7 +28,8 @@ static void __init zone_sizes_init(void) · 27 unmodified lines | ||
| 28 | 28 | unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; |
| 29 | 29 | |
| 30 | 30 | #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))); | |
| 32 | 33 | #endif |
| 33 | 34 | max_zone_pfns[ZONE_NORMAL] = max_low_pfn; |
| 34 | 35 | |
| @@ -10,13 +10,16 @@ · 9 unmodified lines | ||
| 10 | 10 | #include <linux/serial_core.h> |
| 11 | 11 | #include <asm/sbi.h> |
| 12 | 12 | |
| 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) | |
| 15 | 14 | { |
| 16 | − int i; | |
| 15 | + sbi_console_putchar(c); | |
| 16 | +} | |
| 17 | 17 | |
| 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); | |
| 20 | 23 | } |
| 21 | 24 | |
| 22 | 25 | static int __init early_sbi_setup(struct earlycon_device *device, |