- Dec 19, 2023
-
-
Yong-Xuan Wang authored
We can enhance the code by creating 2 unified interface with macro for privilege mode and extensions detection, which relies on supported privilege modes and CSRs. Signed-off-by:
Yong-Xuan Wang <yongxuan.wang@sifive.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Dec 18, 2023
-
-
Xiang W authored
The original code has multiple conversions between hartid and hartindex. Can call sbi_hartmask_set_hartindex directly to avoid conversion. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Samuel Holland authored
sbi_ipi_event_create() disallows registering an IPI event with a NULL .process callback, so the function pointer will never be NULL here. Signed-off-by:
Samuel Holland <samuel.holland@sifive.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Reviewed-by:
Xiang W <wxjstz@126.com>
-
Samuel Holland authored
An IPI sent to the local hart can be processed directly instead of triggering the IPI device. This is more efficient, and it avoids a deadlock when the .sync callback is defined. Since interrupts are disabled while handling an ecall, the IPI would not get delivered until the next mret, but sbi_ipi_sync() is called before then. Signed-off-by:
Samuel Holland <samuel.holland@sifive.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Reviewed-by:
Xiang W <wxjstz@126.com>
-
Samuel Holland authored
Currently, failures in sbi_ipi_send() are silently ignored, which makes them difficult to debug. Instead, abort sending the IPI and pass back the error, but still synchronize any IPIs already sent. Signed-off-by:
Samuel Holland <samuel.holland@sifive.com> Signed-off-by:
Anup Patel <anup@brainfault.org>
-
- Dec 11, 2023
-
-
Samuel Holland authored
The tlb_update() callback is called for each destination hart. Move the size check earlier, so it is executed only once. Signed-off-by:
Samuel Holland <samuel.holland@sifive.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
Currently, the fdt_parse_aclint_node() follows a fixed order to parse ACLINT timer. This may cause the undesirable result when the ACLINT device does not support mtime without adding an empty entry for it in the DT. To be robust, make fdt_parse_aclint_node() support "reg-names" property, so it can parse the DT in an order independent way. For compatibility, fdt_parse_aclint_node() only use "reg-names" when parsing ACLINT timer, and will fallback to the old way if "reg-names" property is not found. Link: https://lore.kernel.org/all/20231114-skedaddle-precinct-66c8897227bb@squawk/ Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup patel <anup@brainfault.org>
-
Xiang W authored
When warmboot via HSM, coolboot has been completed and wait_for_coldboot can be skipped to speed up. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
Previous patch introduced a change that using hart count as the default number of tlb entries in the fifo. This makes the default tlb fifo size grow in square with the number of harts. So the default heap size is not enough to allocate tlb fifo when the hart count is big. Fixes: 52fd64b8 ("platform: Uses hart count as the default size of tlb info") Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Dec 10, 2023
-
-
Nick Hu authored
Current interruptible hart mask doesn't include the hart which HSM state is SBI_HSM_STATE_RESUME_PENDING. So when there is a request to send an IPI to the hart which is in the resume process, this hart would miss the IPI forever. Put the SBI_HSM_STATE_RESUME_PENDING hart in the interruptible hart mask to fix the issue. Signed-off-by:
Nick Hu <nick.hu@sifive.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Dec 09, 2023
-
-
Matt Waltz authored
These sections are only intended to hold data, and should not be executable. Signed-off-by:
Matt Waltz <matthewwaltzis@gmail.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Atish Patra authored
The counter info should only return valid hardware counters for the ones set in the counter mask. Otherwise, it will report incorrect number of hardware counters to the supervisor if the platform has discontiguous counters. Fixes: c744ed77 ("lib: sbi_pmu: Enable noncontigous hpm event and counters") Signed-off-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Atish Patra authored
OpenSBI doesn't support SBI PMU snapshot yet as there is not much benefit unless the multiple counters overflow at the same time. Just add the definition and return not supported error at this moment. The default returned error is also not supported. Thus, no functional change intended. Reviewed-by:
Anup Patel <anup@brainfault.org> Signed-off-by:
Atish Patra <atishp@rivosinc.com>
-
Samuel Holland authored
This minimizes the need to call log2roundup() to recover the log value. Signed-off-by:
Samuel Holland <samuel.holland@sifive.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Dec 08, 2023
-
-
Xiang W authored
Multiple harts may try to send IPI to a particular target hart A in which case the send_ipi() should be called only when the old value of the hart A ipi_type is zero. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Anup Patel authored
Simplify atomic-related bit operations through __atomic intrinsics. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Xiang W authored
The original code returns the value of the word before modification. When modifying the upper 32 bits under RV64, the value returned via int return will have no meaning. Corrected to return the value of the bit. And modify the function description. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Xiang W authored
lr/sc is part of the A extension. If the A extension is not supported, lr/sc cannot be used. So remove xchg/cmpxchg. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Dec 06, 2023
-
-
Yu Chien Peter Lin authored
Add PMU node example for event index to counter index mapping and selector value translation of Andes' CPUs. Currently, there are 4 HPM counters that can be used to monitor all of the events for each hart. Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Locus Wei-Han Chen <locus84@andestech.com> Reviewed-by:
Leo Yu-Chi Liang <ycliang@andestech.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Reviewed-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
-
Yu Chien Peter Lin authored
The valid entry count is tracking by hw_event_count so there is no need to check the whole table. Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
To allow platform override pmu_init() filling the translation table fdt_pmu_evt_select[] when PMU node doesn't provide such information, we need to share the table and its entry counter with other .c file. We also define the structures of PMU property in fdt_helper.h, so we can initialize the mappings in arrays. Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
We will need is_andes(45) in the following patch, so factor out the code that parses marchid to make it reusable for checking any Andes CPU variants. Also improves the comment in ae350_hart_start(). Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
Add a Kconfig option to control PMU fixup, so the next stage software can dump the PMU node including event mapping information for debugging purposes. Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
Enable Andes PMU extension support for RZ/Five. We also staticize renesas_rzfive_early_init() as it is not used outside of this unit. Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Leo Yu-Chi Liang <ycliang@andestech.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Tested-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
Enable Andes PMU extension support for AE350 platforms. Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Leo Yu-Chi Liang <ycliang@andestech.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Tested-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
Before the ratification of Sscofpmf, the Andes PMU extension was designed to support the sampling and filtering with hardware performance counters (zihpm), it works with the current SBI PMU extension and Linux SBI PMU driver. We implement 1) the PMU device callbacks that update the corresponding bits on custom CSRs, 2) extentions_init() to detect the hardware support of Andes PMU and initialize the per-hart PMU related CSR, and 3) pmu_init() to register PMU device and populate event mappings. Also define a andes_pmu_setup() function which is in preparation for adding default PMU mappings in andes_hpm.h Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Leo Yu-Chi Liang <ycliang@andestech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
Add pmu_init() platform override, which will be used to register PMU device and populate event mappings. Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
Add CSR definitions for Andes PMU extension. Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Leo Yu-Chi Liang <ycliang@andestech.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Reviewed-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Tested-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
-
Yu Chien Peter Lin authored
Add support for custom PMU extensions to set inhibit bits on custom CSRs by introducing the PMU device callback hw_counter_filter_mode(). This allows the perf tool to restrict event counting under a specified privileged mode by appending a modifier, e.g. perf record -e event:k to count events only happening in kernel mode. Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Leo Yu-Chi Liang <ycliang@andestech.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
Add the custom extension to hart extension list. Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Tested-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
This patch makes the following changes: - As sbi_platform_pmu_init() returns a negative error code on failure, let sbi_pmu_init() print out the error code with sbi_dprintf(). - In order to distinguish the SBI_EFAIL error returned by sbi_pmu_add_*_counter_map(), return SBI_ENOENT to indicate that fdt_pmu_setup() failed to locate "riscv,pmu" node, and generic_pmu_init() ignores such case. Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Reviewed-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
Leo Yu-Chi Liang authored
The old scheme doesn't allow sending hart0 self-IPI as the corresponding bit on pending register is hardwired to 0, this could lead to unhandle IPIs on SMP systems, esp. on single-core. Furthermore, the limitation of old scheme is 8-core, instead of reserving source hart information, we assign bit (x + 1) as the enable and pending bit of hartx, this also expands the bootable hart number. The following diagram shows the enable bits of the new scheme on 32-core Andes platform. Pending regs: 0x1000 x---0---0---0---0------0---0 Pending hart ID: 0 1 2 3 ... 30 31 Interrupt ID: 0 1 2 3 4 ... 31 32 | | | | | | | Enable regs: 0x2000 x---1---0---0---0-...--0---0---> hart0 | | | | | | | 0x2080 x---0---1---0---0-...--0---0---> hart1 | | | | | | | 0x2100 x---0---0---1---0-...--0---0---> hart2 | | | | | | | 0x2180 x---0---0---0---1-...--0---0---> hart3 . . . . . . . . . . . . . . . . . . . . . 0x2f00 x---0---0---0---0-...--1---0---> hart30 | | | | | | | 0x2f80 x---0---0---0---0-...--0---1---> hart31 <-------- word 0 -------><--- word 1 ---> To send IPI to hart0, for example, another hart (including hart0 itself) will set bit 1 of first word on the pending register. We also fix indentation in andes_plicsw.h along with this patch. Fixes: ce7c4907 ("lib: utils/ipi: Add Andes fdt ipi driver support") Signed-off-by:Leo Yu-Chi Liang <ycliang@andestech.com> Reviewed-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Randolph <randolph@andestech.com> Reported-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Link: https://lists.infradead.org/pipermail/opensbi/2023-October/005665.html Reviewed-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Tested-by:
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Nov 26, 2023
-
-
Anup Patel authored
Currently, there are no barriers before or after the ipi_clear() device callback which forces ipi_clear() device callback to always use non-relaxed MMIO writes. Instead of above, we use wmb() in after the ipi_clear() device callback which pairs with the wmb() done before the ipi_send() device callback. This also allows device ipi_clear() callback to use relaxed MMIO writes. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reported-by:
Bo Gan <ganboing@gmail.com>
-
Anup Patel authored
Currently, we have a smp_wmb() between atomic_raw_set_bit() and ipi_send() device callback whereas the MMIO writes done by the device ipi_send() callback will also include a barrier. We can avoid unnecessary/redundant barriers described above by allowing relaxed MMIO writes in device ipi_send() callback. To achieve this, we simply use wmb() instead of smp_wmb() before calling device ipi_send(). Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reported-by:
Bo Gan <ganboing@gmail.com>
-
- Nov 24, 2023
-
-
Anup Patel authored
Each APLIC CLRIE register allows disabling 32 interrupt sources at a time by writing -1 so no need to write CLRIE register separately for each interrupt source. Fixes: 99792653 ("lib: utils/irqchip: Add APLIC initialization library") Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
- Nov 22, 2023
-
-
Heinrich Schuchardt authored
total_ctrs is bounded by SBI_PMU_FW_CTR_MAX + SBI_PMU_HW_CTR_MAX) == 48 which exceeds BITS_PER_LONG on 32 bit systems. Iterating over the bits of &cmask results in a buffer overflow when looking for a bit >= BITS_PER_LONG. Adjust the iterators in sbi_pmu_ctr_start() and sbi_pmu_ctr_stop() accordingly. Signed-off-by:Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Anup Patel authored
The sbi_hart_map_saddr() must create PMP mapping of size greater than or equal to PMP granularity otherwise PMP mapping does not work when size parameter less than sbi_hart_pmp_granularity(scratch). Fixes: 6e44ef68 ("lib: sbi: Add functions to map/unmap shared memory") Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Samuel Holland <samuel.holland@sifive.com>
-
- Nov 17, 2023
-
-
Xiang W authored
For some debuggers that do not implement SYSWRITEC and SYSREADC operations, we have to use SYSWRITE and SYSREAD. Instead of implementing semihosting_putc() using SYSWRITE, let us simply remove semihosting_putc() because console_putc/console_puts are now interchangeable. Signed-off-by:
Chen Pei <cp0613@linux.alibaba.com> Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Guo Ren <guoren@kernel.org> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Xiang W authored
console_puts/console_putc should replace each other, but the previous sbi_putc can only use console_putc. This patch addresses this problem. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Guo Ren <guoren@kernel.org> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Xiang W authored
In the future there may be a lot of ISA extensions, a 'long' may not be able to accommodate, changed to an array for the future. Addresses-Coverity-ID: 1568357 Out-of-bounds access Fixes: 6259b2ec ("lib: utils/fdt: Fix fdt_parse_isa_extensions() implementation") Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-