From 58d07ca01dc6452536d593a4e7f8d8a16094ee8f Mon Sep 17 00:00:00 2001 From: Han Gao Date: Mon, 15 Jul 2024 23:51:22 +0800 Subject: [PATCH 092/219] fix: eswin: load kvm module failed riscv_noncoherent_supported should not be called multiple times in the sifive_errata_probe function [ 72.659708] Unable to handle kernel paging request at virtual address ffffffff81389380 [ 72.667661] Oops [#1] [ 72.669934] Modules linked in: es_iommu_rsv es_dev_dma_buf es_vdec es_rsvmem_heap es_buddy_driver nfnetlink ip_tables x_tables sha1_generic hmac ipv6 pvrsrvkm [ 72.684133] CPU: 0 PID: 696 Comm: modprobe Not tainted 6.6.36-win2030 #10 [ 72.690922] Hardware name: ESWIN EIC7700 (DT) [ 72.695277] epc : riscv_noncoherent_supported+0x10/0x3e [ 72.700507] ra : sifive_errata_patch_func+0x44/0x1e2 [ 72.705560] epc : ffffffff8000bff6 ra : ffffffff8000c4da sp : ffff8f8008273ac0 [ 72.712781] gp : ffffffff81948e40 tp : ffffaf80b1115400 t0 : 0000000000000000 [ 72.720001] t1 : 0000000000000000 t2 : 0000000000000002 s0 : ffff8f8008273b30 [ 72.727221] s1 : ffffffff01d5e388 a0 : ffffffff01d5e388 a1 : ffffffff01d5e3c8 [ 72.734441] a2 : 8000000000000008 a3 : 0000000006220425 a4 : ffffffff81388ff2 [ 72.741661] a5 : 0000000000000001 a6 : 0000000000000006 a7 : 0000000000000010 [ 72.748881] s2 : ffffffff01d5e3c8 s3 : 8000000000000008 s4 : 0000000000000001 [ 72.756101] s5 : 0000000006220425 s6 : ffffffff8180f660 s7 : 0000000000000001 [ 72.763321] s8 : ffff8f8008273d58 s9 : ffffffff01dcb8c0 s10: ffffffff01dcb758 [ 72.770542] s11: 0000000000000000 t3 : ffffffffffffffff t4 : ffffffffffffffff [ 72.777761] t5 : ffffffffffffffff t6 : ffffaf82a5ecc1c8 [ 72.783071] status: 0000000200000120 badaddr: ffffffff81389380 cause: 000000000000000f [ 72.790986] [] riscv_noncoherent_supported+0x10/0x3e [ 72.797514] [] _apply_alternatives+0x84/0x86 [ 72.803348] [] apply_module_alternatives+0x10/0x18 [ 72.809701] [] module_finalize+0x5e/0x74 [ 72.815193] [] load_module+0x1110/0x18b4 [ 72.820682] [] init_module_from_file+0x76/0xaa [ 72.826688] [] __riscv_sys_finit_module+0x1e2/0x2a8 [ 72.833129] [] do_trap_ecall_u+0xbe/0x130 [ 72.838703] [] ret_from_exception+0x0/0x64 [ 72.844376] Code: 0009 b7ed e797 0193 a783 12e7 c799 4785 d717 0137 (0723) 38f7 [ 72.851970] ---[ end trace 0000000000000000 ]--- Signed-off-by: Han Gao Signed-off-by: Han Gao --- arch/riscv/errata/sifive/errata.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/riscv/errata/sifive/errata.c b/arch/riscv/errata/sifive/errata.c index 20dcbd9e76f4..57fac9c2ccba 100644 --- a/arch/riscv/errata/sifive/errata.c +++ b/arch/riscv/errata/sifive/errata.c @@ -63,12 +63,6 @@ static u32 __init_or_module sifive_errata_probe(unsigned long archid, int idx; u32 cpu_req_errata = 0; -#if IS_ENABLED(CONFIG_ARCH_ESWIN_EIC770X_SOC_FAMILY) - /* Set this just to make core cbo code happy */ - riscv_cbom_block_size = 1; - riscv_noncoherent_supported(); -#endif - for (idx = 0; idx < ERRATA_SIFIVE_NUMBER; idx++) if (errata_list[idx].check_func(archid, impid)) cpu_req_errata |= (1U << idx); @@ -101,6 +95,14 @@ void sifive_errata_patch_func(struct alt_entry *begin, struct alt_entry *end, if (stage == RISCV_ALTERNATIVES_EARLY_BOOT) return; +#if IS_ENABLED(CONFIG_ARCH_ESWIN_EIC770X_SOC_FAMILY) + /* Set this just to make core cbo code happy */ + if (stage == RISCV_ALTERNATIVES_BOOT) { + riscv_cbom_block_size = 1; + riscv_noncoherent_supported(); + } +#endif + cpu_req_errata = sifive_errata_probe(archid, impid); for (alt = begin; alt < end; alt++) { -- 2.47.0