summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2026-06-10lib: sbi: Move RISC-V PMP encoding functions to sbi_pmp.cNicholas Piggin
Create a new file for handling the RISC-V PMP format and the new pmp_t type, as opposed to hart PMP CSR specific access. Signed-off-by: Nicholas Piggin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-06-10lib: sbi: split PMP encoding and CSR accessNicholas Piggin
Allow PMP encoding functions to be shared with non-hart PMP manipulation by splitting encoding / decoding and hart PMP CSR access into their own functions. Signed-off-by: Nicholas Piggin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-06-10lib: sbi: Introduce pmp_t typeNicholas Piggin
To help abstract details of PMP encoding and access, add a new pmp_t type which contains address and cfg in the format of the riscv CSRs. There is no functional change. Signed-off-by: Nicholas Piggin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-06-09lib: sbi_domain_context: Flush TLB after SATP mode switchZishun Yi
When switching between domains with different satp.MODE values (e.g. Sv39 to Sv48), the RISC-V ISA permits hardware to use cached translations from the old virtual-address width if no SFENCE.VMA intervenes. This constrained-unpredictable behavior is clarified in riscv-isa-manual PR #2219. The hart protection re-configuration will anyway do full SFENCE / HFENCE so move the hart protection re-configuration after register context switch in switch_to_next_domain_context() to ensure translations from the new domain's address width are used. Link: https://github.com/riscv/riscv-isa-manual/pull/2219 Signed-off-by: Zishun Yi <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-06-07include: mailbox: rpmi_msgprot: Add RPMI performance domain flag definesDavid E. Garcia Porras
Add bit-field defines for the RPMI performance domain attributes flags and fast-channel attributes flags as specified in the RPMI specification. These are needed by platform implementations that provide RPMI performance services (e.g. DVFS controllers). Also add the missing db_write_value field to rpmi_perf_get_fast_chn_attr_resp to match the RPMI spec layout. Signed-off-by: David E. Garcia Porras <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-22lib: utils/reset: Remove unused match dataSamuel Holland
Some drivers inherited FDT match data from the GPIO/syscon reset drivers, but do not use it for anything. Remove it to avoid confusion. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-22sbi: mpxy: define INVALID_ADDR using unsigned long widthHimanshu Chauhan
INVALID_ADDR is used as an all-ones physical address sentinel. Using -1U only guarantees 32-bit width, so on platforms where unsigned long is wider it may not expand to all ones after assignment. Use -1UL so the conversion to unsigned long preserves an all-ones bit pattern across supported widths. Fixes: 7939bf1329eb ("lib: sbi: Add SBI Message Proxy (MPXY) framework") Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-18lib: utils: fdt_domain: add root-regions-inheritance policyYu-Chien Peter Lin
Introduce root-regions-inheritance DT property to control copying of root domain memregions. Support 'all' and 'm-only' modes, always inheriting firmware and M-only regions; behavior matches m-only policy when property is absent. Signed-off-by: Yu-Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-18lib: sbi: domain FP/Vector context support for context switchDave Patel
This patch adds proper support for per-domain floating-point (FP) and vector (V) contexts in the domain context switch logic. Each domain now maintains its own FP and vector state, which is saved and restored during domain switches. Conditionalize FP and Vector save/restore based on extensions, unconditional save and restore of floating-point (FP) and Vector registers fails on generic platform firmware. This firmware must run on multiple platforms that may lack these extensions. Address this by conditionally executing FP save/restore only if the underlying hart supports the F or D extensions. Similarly, perform Vector save/restore only if the hart supports the Vector extension. This improves support for multi-domain systems with FP and Vector extensions, and prevents corruption of FP/Vector state during domain switches. Signed-off-by: Dave Patel <[email protected]> Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-18lib: sbi: Add floating-point context save/restore support.Dave Patel
Add support for saving and restoring RISC-V floating-point (F/D) extension state in OpenSBI. This introduces a floating-point context structure and helper routines to perform full context save and restore. The floating-point context includes storage for all 32 FPi registers (f0–f31) along with the fcsr control and status register. The register state is saved and restored using double-precision load/store instructions (fsd/fld), and single-precision load/store instructions (fsw/flw) on an RV64 system with F and D-extension support. The implementation follows an eager context switching model where the entire FP state is saved and restored on every context switch. This avoids the need for trap-based lazy management and keeps the design simple and deterministic. Signed-off-by: Dave Patel <[email protected]> Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-18lib: sbi: Add RISC-V vector context save/restore supportDave Patel
Eager context switch: Add support for saving and restoring RISC-V vector extension state in OpenSBI. This introduces a per-hart vector context structure and helper routines to perform full context save and restore. The vector context includes vcsr CSRs along with storage for all 32 vector registers. The register state is saved and restored using byte-wise vector load/store instructions (vs8r/vl8r). The implementation follows an eager context switching model where the entire vector state is saved and restored on every context switch. This provides a simple and deterministic mechanism without requiring lazy trap-based management. Signed-off-by: Dave Patel <[email protected]> Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-12lib: sbi_irqchip: Add support for registering MSI handlersAnup Patel
Some of the drivers (such as APLIC) require capability to registers MSI handlers from the parent interrupt controller (such as IMSIC) so add sbi_irqchip_register_msi_handler() for this purpose. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-12lib: sbi_irqchip: Allow setting hardware interrupt affinityAnup Patel
The irqchip drivers can provide mechanism to set interrupt affinity so add hwirq_set_affinity() callback for irqchip drivers and use it to implement sbi_irqchip_set_affinity() which can be used by other drivers. Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-12lib: sbi_irqchip: Allow marking hardware interrupts as reservedAnup Patel
Some of the hardware interrupts may be special so allow irqchip drivers to make these hardware interrupts as reserved. Introduce sbi_irqchip_register_reserved() for this purpose. Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-12lib: sbi_irqchip: Allow interrupt client to specify line sensingAnup Patel
The interrupt client should be allowed to specify the line sensing type of the hwirqs for which it is registering handler. To support this, add hwirq_flags parameter to hwirq_setup() callback provided by the irqchip driver. Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-12lib: sbi_irqchip: Keep the handler list in sorted order for irqchipAnup Patel
Let's keep the handler list in sorted order for irqchip so that it is easier to allocate unused hardware interrupts based on the sorted list. Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-12lib: sbi_irqchip: Check full range for existing handlers in ↵Anup Patel
sbi_irqchip_register_handler() Currently, the sbi_irqchip_register_handler() only checks the first and the last hardware interrupt for existing handlers which is buggy because there may be existing handlers between the first and the last hardware interrupt. Fixes: 0ab0c470d588 ("lib: sbi_irqchip: Allow registering interrupt handlers") Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-11lib: sbi_domain: reject overflowing address range in check_addr_range()Takumi Hara
sbi_domain_check_addr_range() computes `max = addr + size` without checking for integer overflow. When a caller passes a size large enough to wrap around (e.g. addr=0x80000000, size=0xFFFFFFFF80000000), max becomes less than addr, causing the while(addr < max) validation loop to be skipped entirely. The function then returns true without performing any permission checks. This allows an S-mode caller to bypass domain memory protection and access M-mode memory through SBI extensions that use address range validation (e.g. DBCN console write/read). Add an overflow check after computing max: if size is non-zero and max wrapped to a value <= addr, reject the request. Signed-off-by: Takumi Hara <[email protected]> Reviewed-by: Rahul Pathak <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-11lib: utils/reset: add SpacemiT P1 PMIC supportAurelien Jarno
The SpacemiT P1 is a PMIC commonly found with SpacemiT CPU like K1. Add a reset driver for it. Signed-off-by: Aurelien Jarno <[email protected]> Tested-by: Anand Moon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-11lib: utils/i2c: add minimal SpacemiT I2C driverAurelien Jarno
Add a simple SpacemiT I2C driver for basic byte transfers over the I2C bus, prioritizing simplicity over performance. The driver operates in PIO mode and does not use interrupts, FIFO, or DMA. The controller is reset at the start of each transaction to ensure a known initial state, regardless of prior configuration by the kernel. This also avoids the need for additional error recovery code. This will be used for communication with onboard PMIC to reset and power-off the board. Signed-off-by: Aurelien Jarno <[email protected]> Tested-by: Anand Moon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-11lib: sbi: Fix hw a/d updating defaultsAndrew Jones
The Svade dt-binding description states that Svadu should only be enabled at boot time when only Svadu is present in the DT. Ensure that's the case. Also, when only Svadu is supported, disable FWFT.PTE_AD_HW_UPDATING, as we need both to support toggling. Signed-off-by: Andrew Jones <[email protected]> Reviewed-by: Radim Krčmář <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-11lib: utils/regmap: Fix reg_stride calculation in syscon regmapDavid E. Garcia Porras
The reg_stride field represents the address stride in bytes between consecutive registers. The Linux kernel regmap framework validates register accesses using IS_ALIGNED(reg, map->reg_stride) as an address alignment check (drivers/base/regmap/regmap.c). The Linux kernel syscon driver (drivers/mfd/syscon.c) sets reg_stride directly to reg_io_width: syscon_config.reg_stride = reg_io_width; The current OpenSBI code incorrectly multiplies reg_io_width by 8, converting a byte value to bits. Fix this by using reg_io_width directly as the stride value, consistent with the Linux kernel. Fixes: f21d8f7d5911 ("lib: utils/regmap: Add simple FDT based syscon regmap driver") Signed-off-by: David E. Garcia Porras <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-11lib/sbi_pmu: Don't fallback to fixed counters when sscofpmf && !smcntrpmfMichael Ellerman
Currently when searching for a hardware counter for an event, if no programmable counter is available, the code falls back to using a fixed counter (mcycle/minstret) if one matches the event. However the fallback is incorrect when sscofpmf is present but smcntrpmf is not. That's because with sscofpmf, programmable counters support mode filtering, but the fixed counters do not (without smcntrpmf). Even if the caller didn't configure mode filtering, by default programmable counters don't count M mode when sscofpmf is present, whereas mcycle/minstret do. Fix the logic to not fallback to a fixed counter if sscofpmf is present but smcntrpmf is not. Fixes: 0c304b661965 ("lib: sbi: Allow programmable counters to monitor cycle/instret events") Signed-off-by: Michael Ellerman <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-11docs: platform: update qemu_virt.mdZhang RunMin
When using GDB for debugging, if FW_TEXT_START is not set to 0x80000000 during compilation, the following error occurs: Reading symbols from build/platform/generic/firmware/fw_payload.elf... Remote debugging using localhost:1234 mips_warm_boot () at /home/zrmin/opensbi/platform/generic/mips/mips_warm_boot.S:11 11 j _start_warm (gdb) b _start Breakpoint 1 at 0x0: file /home/zrmin/opensbi/firmware/fw_base.S, line 50. (gdb) c Continuing. Remote connection closed (gdb) With FW_TEXT_START=0x80000000, debugging works correctly: Reading symbols from build/platform/generic/firmware/fw_payload.elf... Remote debugging using localhost:1234 0x0000000000001000 in ?? () (gdb) b _start Breakpoint 1 at 0x80000000: file /home/zrmin/opensbi/firmware/fw_base.S, line 50. (gdb) c Continuing. Breakpoint 1, _start () at /home/zrmin/opensbi/firmware/fw_base.S:50 50 MOV_3R s0, a0, s1, a1, s2, a2 (gdb) This is because QEMU loads OpenSBI at address 0x80000000. When FW_TEXT_START does not match this address, the debug symbols are incorrectly offset, causing GDB to fail to set breakpoints properly. Signed-off-by: Zhang RunMin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-11lib: fdt_domain: Default boot-hart to coldboot HART for multi-domain bootYu-Chien Peter Lin
When "boot-hart" is not specified, dom->boot_hartid was left as -1U, causing domain context switching to fail. Default it to the coldboot HART to enable SMP boot in multi-domain setups, consistent with how next-arg1 is handled. Also update its description in domain_support.md. Signed-off-by: Yu-Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-11lib: utils: Fix LLVM compile error in MPXY client driver for RPMI MMAnup Patel
The following compile error is seen with LLVM compiler: CC platform/generic/lib/utils/mpxy/fdt_mpxy_rpmi_mm.o lib/utils/mpxy/fdt_mpxy_rpmi_mm.c:17:6: error: use of GNU 'missing =' extension in designator [-Werror,-Wgnu-designator] 17 | [0] { | ^ | = lib/utils/mpxy/fdt_mpxy_rpmi_mm.c:24:6: error: use of GNU 'missing =' extension in designator [-Werror,-Wgnu-designator] 24 | [1] { | ^ | = 2 errors generated. Add missing "=" in mm_srvcdata[] array initialization to address the above issue. Fixes: 0b041e58c078 ("lib: utils: Add MPXY client driver for RPMI MM service group") Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Ranbir Singh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-09platform: generic: Tenstorrent Atlantis supportNicholas Piggin
Add the Tenstorrent Atlantis as a generic-platform. This initial support enables the single_fw_region option, and verifies and prints HART PMA CSR configuration. Signed-off-by: Nicholas Piggin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-09lib: sbi_timer: Introduce sbi_timer_compute_delta() and friendsAnup Patel
The users of timer event have to compute next_event (aka timer value in the future) based on desired units and unit frequency. Introduce sbi_timer_compute_delta() and friends to simplify computing next_event for timer event users. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-09lib: sbi_timer: Add support for timer eventsAnup Patel
Currently, the sbi_timer only supports timer events configured via SBI calls. Introduce struct sbi_timer_event and related functions to allow configuring timer events from any part of OpenSBI. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-09lib: sbi_timer: Introduce per-HART timer stateAnup Patel
Currently, only time_delta is per-HART so introduce per-HART timer state for having more per-HART timer information. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-09include: sbi: Add sbi_scratch_hartindex() macroAnup Patel
Add helper macro to extract hart index from scratch pointer. This can be used to check whether scratch pointer belongs to a particular hart or not. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-09platform: Remove kendryte/k210 platformAnup Patel
The kendryte/k210 platform does not have MMU support in S-mode hence only NOMMU kernel which runs in M-mode can be used on this platform. As of now, there is no clear use-case of supporting OpenSBI for kendryte/k210 platform. Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-09lib: sbi: hart: Detect and enable Smrnmi before trap-based feature detectionEvgeny Voevodin
The location of the RNMI/E trap vectors in the Smrnmi extension is implementation-defined, so platforms with vendor-specific NMI vector mechanisms must install the firmware's NMI entry points themselves. Add an smrnmi_handlers_init() callback to sbi_platform_operations that receives the firmware entry points and lets platform code install them at the hardware-specific vector locations. Two pointers are passed: - _trap_rnmi_handler: the dedicated RNMI entry point that saves context using the Smrnmi MN* CSRs and returns via mnret. - _trap_handler: the regular M-mode trap entry since RNME is taken as a regular M-mode trap with NMIE=0. When Smrnmi is present, install the platform's NMI vectors via the new callback, initialize MNSCRATCH with the per-hart scratch pointer, and set MNSTATUS.NMIE. Smrnmi-enabled platforms must register smrnmi_handlers_init; if the extension is detected but no callback is registered, sbi_panic() is called since enabling NMIs without handlers in place would route subsequent traps into nowhere. Signed-off-by: Evgeny Voevodin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/88b1470e1e3348d454b4b995a11a85c01914f7af.1778176768.git.evvoevod@tenstorrent.com Signed-off-by: Anup Patel <[email protected]>
2026-05-09lib: sbi: Move Zkr entropy initialization from fw_base.S to init_coldbootEvgeny Voevodin
Current placement of entropy initialization via Zkr extension requires a trap-based mechanism to handle absent Zkr extension case. In presence of Smrnmi extension no trap-based mechanisms should be used before Smrnmi is detected and enabled otherwise trap will jump to undefined location. Move stack guard initialization into init_coldboot function body after device tree has been parsed so we know if Zkr extension is implemented by the platform which helps to avoid trap-based discovery. init_coldboot() is a safe place to initialize entropy because it doesn't return so no check of __stack_chk_guard against value on entry will be done. Signed-off-by: Evgeny Voevodin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/acd52b0f3468758bc5f09e6a45662341b31d4d87.1778176768.git.evvoevod@tenstorrent.com Signed-off-by: Anup Patel <[email protected]>
2026-05-09lib: sbi: hart: Move device tree features detection before trap-based checksEvgeny Voevodin
Smrnmi detection and enablement in the following commits will happen before any trap-based mechanism. As it relies on device tree, move sbi_platform_extensions_init() to the beginning of hart_detect_features(). Signed-off-by: Evgeny Voevodin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/d066935990f12e1f4f21cd709eb20afba618b134.1778176768.git.evvoevod@tenstorrent.com Signed-off-by: Anup Patel <[email protected]>
2026-05-09firmware: Add RNMI handler infrastructureEvgeny Voevodin
Implement basic Resumable NMI (RNMI) handler support for the RISC-V Smrnmi extension. The new _trap_rnmi_handler assembly entry point saves context using the Smrnmi MN* CSRs (MNSCRATCH, MNEPC, MNSTATUS, MNCAUSE) and returns via mnret. It dispatches to sbi_trap_rnmi_handler(), which optionally calls a platform-specific ops->rnmi_handler callback for actual NMI processing. If no platform handler is registered or it fails, the event is reported as an unhandled NMI. The RNMI handler reuses the generic trap context structure but stores MN* CSR values (MNEPC, MNSTATUS, MNCAUSE) into the corresponding generic fields (mepc, mstatus, cause) for compatibility with existing trap infrastructure. Signed-off-by: Evgeny Voevodin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/050ae6d2762ba8d5b9dfb3cc1960a23aa3d6c549.1778176768.git.evvoevod@tenstorrent.com Signed-off-by: Anup Patel <[email protected]>
2026-05-09lib: sbi: Add Smrnmi extension macros for registers and bitsEvgeny Voevodin
Add CSR definitions (MNSCRATCH, MNSTATUS, MNEPC, MNCAUSE) and bit definitions (MNSTATUS_NMIE, MNSTATUS_MNPV, MNSTATUS_MNPP). Also add SBI_HART_EXT_SMRNMI to the hart extension enumeration. Signed-off-by: Evgeny Voevodin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/1c6feb6d359b9827b3c2ad8f4f0e0a4dfd1de911.1778176768.git.evvoevod@tenstorrent.com Signed-off-by: Anup Patel <[email protected]>
2026-05-09include: sbi_scratch: Add tmp1 scratch space for RNMI context savingEvgeny Voevodin
RNMI handlers use MNSCRATCH instead of MSCRATCH and need separate scratch space from regular trap handling. Add tmp1 for RNMI context while tmp0 remains for regular traps. Signed-off-by: Evgeny Voevodin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/0a5d241fa1db03e71a3f56be24708cbbc8037e28.1778176768.git.evvoevod@tenstorrent.com Signed-off-by: Anup Patel <[email protected]>
2026-04-08lib: sbi_bitmap_test: add tests for bitmap_empty()Yu-Chien Peter Lin
Add tests for bitmap_empty(), covers empty/non-empty bitmaps and edge case nbits=0. Signed-off-by: Yu-Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-04-08include: sbi_bitmap: add bitmap_empty() functionYu-Chien Peter Lin
Add bitmap_empty() to check if bitmap has no bits set. Unlike bitmap_weight() which calls sbi_popcount() on every word, bitmap_empty() uses simple non-zero comparisons with early exit. Signed-off-by: Yu-Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-04-06lib: utils: Add MPXY client driver for RPMI MM service groupRanbir Singh
Add necessary infra for implementing RPMI Management Mode service group on platform microcontroller. Co-authored-by: Sunil V L <[email protected]> Signed-off-by: Ranbir Singh <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-04-06lib: Fix sbi_strchr to correctly handle null terminator searchChen Pei
The original sbi_strchr implementation did not conform to the C standard behavior. According to the C standard and POSIX specification, strchr(s, 0) should return a pointer to the null terminator at the end of string s. The previous implementation used a while loop that would terminate when either reaching the end of string or finding the character, but it would return NULL when searching for the null terminator instead of returning a pointer to the null terminator itself. The fixed implementation uses a do-while loop that ensures even when searching for the null terminator, the function correctly returns a pointer to the null terminator position rather than NULL. This fix ensures sbi_strchr behavior aligns with standard library function semantics, making it more predictable and safe for users expecting standard C library behavior. Signed-off-by: Chen Pei <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-04-06lib: tests: Add test for stringChen Pei
Added unit tests for various string operations using SBI unit test framework. Signed-off-by: Chen Pei <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-04-06sifive_dev_platform: Set default MMIO region when SmePMP is enabledYu-Chien Peter Lin
Set a default MMIO region with a single SmePMP entry, which allows us to save entries for M-mode only devices. The default entry has M-/S-mode shared permission, so system-level resource protection, such as RISC-V World extension and WorldGuard checker, will be introduced to protect M-mode only region access from lower privilege modes. Reviewed-by: Greentime Hu <[email protected]> Reviewed-by: Zong Li <[email protected]> Signed-off-by: Yu-Chien Peter Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-04-06platform: sifive: Add initial support for SiFive development platformYu-Chien Peter Lin
Add initial platform support for SiFive development platforms with the "sifive-dev" compatible string. Reviewed-by: Greentime Hu <[email protected]> Reviewed-by: Zong Li <[email protected]> Signed-off-by: Yu-Chien Peter Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-03-22lib: sbi_init: Call hart init and timer init before platform early initYu-Chien Peter Lin
To allow the platform early drivers to use the sbi_timer_mdelay(), sbi_timer_udelay() and sbi_hart_has_extension() helpers, reorder the initialization sequence must call sbi_hart_init() and sbi_timer_init() prior to sbi_platform_early_init() during both cold and warm boot paths. Reviewed-by: Greentime Hu <[email protected]> Reviewed-by: Zong Li <[email protected]> Signed-off-by: Yu-Chien Peter Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-03-22lib: sbi_irqchip: Allow registering interrupt handlersAnup Patel
To handle external interrupts in M-mode, the sbi_irqchip framework must allow registering interrupt handlers from device drivers. Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-03-22lib: sbi_irqchip: Associate 32-bit unique ID for each irqchip deviceAnup Patel
Allow locating irqchip device instance using a unique 32-bit ID. This 32-bit unique ID can be set by the irqchip driver at the time of adding irqchip device. Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-03-22lib: utils/irqchip: Add unique_id to plic, aplic, and imsic dataAnup Patel
Add a 32-bit unique ID to plic, aplic, and imsic data which can be used to differentiate multiple irqchip devices. Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-03-22lib: sbi_irqchip: Support irqchip device targetting subset of hartsAnup Patel
It is possible to have platform where an irqchip device targets a subset of harts and there are multiple irqchip devices to cover all harts. To support this scenario: 1) Add target_harts hartmask to struct sbi_irqchip_device which represents the set of harts targetted by the irqchip device 2) Call warm_init() and process_hwirqs() callbacks of an irqchip device on a hart only if irqchip device targets that particular hart Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>