summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2023-03-10lib: sbi: Clear IPIs before init_warm_startup in non-boot hartsHEADVF2_v3.8.2VF2_v3.7.5VF2_v3.6.1VF2_v3.4.5VF2_v3.1.5VF2_v3.0.4VF2_v2.11.5VF2_6.1_v3.8.2VF2_6.1_v3.7.5JH7110_VF2_6.6_v5.12.0JH7110_VF2_6.1_v5.12.0JH7110_VF2_6.1_v5.11.4JH7110_VF2_6.1_v5.11.3JH7110_VF2_6.1_v5.10.3JH7110_VF2_6.1_v3.9.3JH7110_VF2_515_v5.12.0JH7110_VF2_515_v5.11.4JH7110_VF2_515_v5.11.3JH7110_VF2_515_v5.10.3JH7110_VF2_515_v3.9.3masterJH7110_VisionFive2_develEvgenii Shatokhin2-2/+10
Since commit 50d4fde1c5a4 ("lib: Remove redundant sbi_platform_ipi_clear() calls"), the IPI sent from the boot hart in wake_coldboot_harts() is not cleared in the secondary harts until they reach sbi_ipi_init(). However, sbi_hsm_init() and sbi_hsm_hart_wait() are called earlier, so a secondary hart might enter sbi_hsm_hart_wait() with an already pending IPI. sbi_hsm_hart_wait() makes sure the hart leaves the loop only when it is actually ready, so a pending unrelated IPI should not cause safety issues. However, it might be inefficient on certain hardware, because it prevents "wfi" from stalling the hart even if the hardware supports this, making the hart needlessly spin in a "busy-wait" loop. This behaviour can be observed, for example, in a QEMU VM (QEMU 7.2.0) with "-machine virt" running a Linux guest. Inserting delays in sbi_hsm_hart_start() allows reproducing the issue more reliably. The comment in wait_for_coldboot() suggests that the initial IPI is needed in the warm resume path, so let us clear it before init_warm_startup() only. To do this, sbi_ipi_raw_clear() was created similar to sbi_ipi_raw_send(). Signed-off-by: Evgenii Shatokhin <e.shatokhin@yadro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-10lib: sbi: Set the state of a hart to START_PENDING after the hart is readyEvgenii Shatokhin1-16/+67
When a boot hart executes sbi_hsm_hart_start() to start a secondary hart, next_arg1, next_addr and next_mode for the latter are stored in the scratch area after the state has been set to SBI_HSM_STATE_START_PENDING. The secondary hart waits in the loop with wfi() in sbi_hsm_hart_wait() at that time. However, "wfi" instruction is not guaranteed to wait for an interrupt to be received by the hart, it is just a hint for the CPU. According to RISC-V Privileged Architectures spec. v20211203, even an implementation of "wfi" as "nop" is legal. So, the secondary might leave the loop in sbi_hsm_hart_wait() as soon as its state has been set to SBI_HSM_STATE_START_PENDING, even if it got no IPI or it got an IPI unrelated to sbi_hsm_hart_start(). This could lead to the following race condition when booting Linux, for example: Boot hart (#0) Secondary hart (#1) runs Linux startup code waits in sbi_hsm_hart_wait() sbi_ecall(SBI_EXT_HSM, SBI_EXT_HSM_HART_START, ...) enters sbi_hsm_hart_start() sets state of hart #1 to START_PENDING leaves sbi_hsm_hart_wait() runs to the end of init_warmboot() returns to scratch->next_addr (next_addr can be garbage here) sets next_addr, etc. for hart #1 (no good: hart #1 has already left) sends IPI to hart #1 (no good either) If this happens, the secondary hart jumps to a wrong next_addr at the end of init_warmboot(), which leads to a system hang or crash. To reproduce the issue more reliably, one could add a delay in sbi_hsm_hart_start() after setting the hart's state but before sending IPI to that hart: hstate = atomic_cmpxchg(&hdata->state, SBI_HSM_STATE_STOPPED, SBI_HSM_STATE_START_PENDING); ... + sbi_timer_mdelay(10); init_count = sbi_init_count(hartid); rscratch->next_arg1 = arg1; rscratch->next_addr = saddr; The issue can be reproduced, for example, in a QEMU VM with '-machine virt' and 2 or more CPUs, with Linux as the guest OS. This patch moves writing of next_arg1, next_addr and next_mode for the secondary hart before setting its state to SBI_HSM_STATE_START_PENDING. In theory, it is possible that two or more harts enter sbi_hsm_hart_start() for the same target hart simultaneously. To make sure the current hart has exclusive access to the scratch area of the target hart at that point, a per-hart 'start_ticket' is used. It is initially 0. The current hart tries to acquire the ticket first (set it to 1) at the beginning of sbi_hsm_hart_start() and only proceeds if it has successfully acquired it. The target hart reads next_addr, etc., and then the releases the ticket (sets it to 0) before calling sbi_hart_switch_mode(). This way, even if some other hart manages to enter sbi_hsm_hart_start() after the ticket has been released but before the target hart jumps to next_addr, it will not cause problems. atomic_cmpxchg() already has "acquire" semantics, among other things, so no additional barriers are needed in hsm_start_ticket_acquire(). No hart can perform or observe the update of *rscratch before setting of 'start_ticket' to 1. atomic_write() only imposes ordering of writes, so an explicit barrier is needed in hsm_start_ticket_release() to ensure its "release" semantics. This guarantees that reads of scratch->next_addr, etc., in sbi_hsm_hart_start_finish() cannot happen after 'start_ticket' has been released. Signed-off-by: Evgenii Shatokhin <e.shatokhin@yadro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-10lib: sbi: Refactor the calls to sbi_hart_switch_mode()Evgenii Shatokhin2-14/+19
Move them into sbi_hsm_hart_start_finish() and sbi_hsm_hart_resume_finish() to make them easier to manage. This will be used by subsequent patches. Suggested-by: Anup Patel <anup@brainfault.org> Signed-off-by: Evgenii Shatokhin <e.shatokhin@yadro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-10lib: sbi_pmu: Add hartid parameter PMU device opsMayuresh Chitale1-10/+15
Platform specific firmware event handler may leverage the hartid to program per hart specific registers for a given counter. Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-10lib: sbi_pmu: Introduce fw_counter_write_value APIMayuresh Chitale1-12/+13
Add fw_counter_write_value API for platform specific firmware events which separates setting the counter's initial value from starting the counter. This is required so that the fw_event_data array can be reused to save the event data received. Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-10lib: sbi_pmu: Use dedicated event code for platform firmware eventsMayuresh Chitale1-13/+52
For all platform specific firmware event operations use the dedicated event code (0xFFFF) when matching against the input firmware event. Furthermore save the real platform specific firmware event code received as the event data for future use. Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-10lib: sbi_pmu: Update sbi_pmu dev opsMayuresh Chitale1-13/+17
Update fw_event_validate_code, fw_counter_match_code and fw_counter_start ops which used a 32 bit event code to use the 64 bit event data instead. Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-10lib: sbi_pmu: Rename fw_counter_valueMayuresh Chitale1-9/+13
Rename and reuse fw_counter_value array to save both the counter values for the SBI firmware events and event data for the SBI platform specific firmware events. Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
2023-03-10lib: sbi_pmu: Implement sbi_pmu_counter_fw_read_hiMayuresh Chitale1-0/+8
To support 64 bit firmware counters on RV32 systems, we implement sbi_pmu_counter_fw_read_hi() which returns the upper 32 bits of the firmware counter value. On RV64 (or higher) systems, this function will always return zero. Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-10lib: sbi_pmu: add callback for counter widthMayuresh Chitale1-0/+6
This patch adds a callback to fetch the number of bits implemented for a custom firmware counter. If the callback fails or is not implemented then width defaults to 63. Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-09lib: serial: Cadence: Enable compatibility for cdns,uart-r1p8Mayuresh Chitale1-0/+1
The Cadence driver does not use the RX byte status feature and hence can be advertised to be compatible with cdns,uart-r1p8 as well. Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-09lib: utils/i2c: Add minimal StarFive jh7110 I2C driverMinda Chen4-0/+265
Starfive JH7110 I2C IP is synopsys designware. Minimum StarFIve I2C driver to read/send bytes over I2C bus. This allows querying information and perform operation of onboard PMIC, as well as power-off and reset. Signed-off-by: Minda Chen <minda.chen@starfivetech.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-01gpio/starfive: add gpio driver and support gpio resetminda.chen3-0/+123
Add gpio driver and gpio reset function in Starfive JH7110 SOC platform. Signed-off-by: minda.chen <minda.chen@starfivetech.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27platform: generic: Add system suspend testAndrew Jones1-0/+31
When the system-suspend-test property is present in the domain config node as shown below, implement system suspend with a simple 5 second delay followed by a WFI. This allows testing system suspend when the low-level firmware doesn't support it. / { chosen { opensbi-domains { compatible = "opensbi,domain,config"; system-suspend-test; }; Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi: Implement system suspendAndrew Jones1-1/+56
Fill the implementation of the system suspend ecall. A platform implementation of the suspend callbacks is still required for this to do anything. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi: Add system_suspend_allowed domain propertyAndrew Jones2-0/+11
Only privileged domains should be allowed to suspend the entire system. Give the root domain this property by default and allow other domains to be given the property by specifying it in the DT. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi: Add system suspend skeletonAndrew Jones5-0/+85
Add the SUSP extension probe and ecall support, but for now the system suspend function is just a stub. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi_hsm: Export some functionsAndrew Jones1-2/+10
A coming patch can make use of a few internal hsm functions if we export them. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi_hsm: Remove unnecessary includeAndrew Jones1-2/+2
Also remove a superfluous semicolon and add a blank line. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi_hsm: Move misplaced commentAndrew Jones1-2/+4
While non-retentive suspend is not allowed for M-mode, the comment at the top of sbi_hsm_hart_suspend() implied suspend wasn't allowed for M-mode at all. Move the comment above the mode check which is inside a suspend type is non-retentive check. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi_hsm: Ensure errors are consistent with specAndrew Jones1-3/+3
HSM functions define when SBI_ERR_INVALID_PARAM should be returned. Ensure it's not used for reasons that don't meet the definitions by using the catch-all code, SBI_ERR_FAILED, for those reasons instead. Also, in one case sbi_hart_suspend() may have returned SBI_ERR_DENIED, which isn't defined for that function at all. Use SBI_ERR_FAILED for that case too. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi_hsm: Don't try to restore state on failed changeAndrew Jones1-5/+2
When a state change fails there's no need to restore the original state as it remains the same. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi_hsm: Factor out invalid state detectionAndrew Jones1-41/+24
Remove some redundant code by creating an invalid state detection macro. No functional change intended. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: utils/fdt/fdt_domain: Simplify region access permission checkBin Meng1-6/+4
The region access permission check in __fdt_parse_region() can be simplified as masking SBI_DOMAIN_MEMREGION_{M,SU}_ACCESS_MASK is enough. While we are here, update the confusing comments to match the codes. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi/sbi_domain: cosmetic style fixesBin Meng1-2/+2
Minor updates to the comments for language and style fixes. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi: sbi_ecall: Check the range of SBI errorYu Chien Peter Lin1-1/+1
We should also check if the return error code is greater than 0 (SBI_SUCCESS), as this is an invalid error. Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27include: sbi: Remove extid parameter from vendor_ext_provider() callbackAnup Patel1-1/+1
The extid parameter of vendor_ext_provider() is redundant so let us remove it. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2023-02-27lib: sbi: Align SBI vendor extension id with mvendorid CSRAnup Patel1-2/+17
As-per the SBI specification, the lower 24bits of the SBI vendor extension id is same as lower 24bits of the mvendorid CSR. We update the SBI vendor extension id checking based on above. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2023-02-27lib: sbi_hart: Enable hcontext and scontextNylon Chen1-0/+1
According to the description in "riscv-state-enable[0]", to access h/scontext in S-Mode, we need to enable the 57th bit. If it is not enabled, an "illegal instruction" error will occur. Link: https://github.com/riscv/riscv-state-enable/blob/a28bfae443f350d5b4c42874f428367d5b322ffe/content.adoc [0] Signed-off-by: Nylon Chen <nylon.chen@sifive.com> Reviewed-by: Zong Li <zong.li@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: utils: fdt_fixup: Fix compile errorXiang W1-5/+8
When building with GCC-10 or older versions, it throws the following error: CC-DEP platform/generic/lib/utils/fdt/fdt_fixup.dep CC platform/generic/lib/utils/fdt/fdt_fixup.o lib/utils/fdt/fdt_fixup.c: In function 'fdt_reserved_memory_fixup': lib/utils/fdt/fdt_fixup.c:376:2: error: label at end of compound statement 376 | next_entry: | ^~~~~~~~~~ Remove the goto statement. Resolves: https://github.com/riscv-software-src/opensbi/issues/288 Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org> Reviewed-by: Bin Meng <bmeng@tinylab.org>
2023-02-27lib: utils/fdt: Fix fdt_pmu.c header dependencyBin Meng1-0/+1
The code calls sbi_scratch_thishart_ptr() from sbi_scratch.h which is not directly included. Fix such dependency. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-10lib: sbi: Speed-up sbi_printf() and friends using nputs()Anup Patel1-22/+54
The sbi_printf() is slow for semihosting because it prints one character at a time. To speed-up sbi_printf() for semihosting, we use a temporary buffer and nputs(). Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
2023-02-10lib: utils/serial: Implement console_puts() for semihostingAnup Patel1-0/+37
We implement console_puts() for semihosting serial driver to speed-up semihosting based prints. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
2023-02-10lib: sbi: Add console_puts() callback in the console deviceAnup Patel1-7/+22
We add console_puts() callback in the console device which allows console drivers (such as semihosting) to implement a specialized way to output character string. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
2023-02-10lib: sbi: Implement SBI debug console extensionAnup Patel3-0/+79
We implement SBI debug console extension as one of the replacement SBI extensions. This extension is only available when OpenSBI platform provides a console device to generic library. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Bin Meng <bmeng@tinylab.org>
2023-02-10lib: sbi: Add sbi_domain_check_addr_range() functionAnup Patel1-0/+69
We add sbi_domain_check_addr_range() helper function to check whether a given address range is accessible under a particular domain. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
2023-02-09lib: sbi: Add sbi_ngets() functionAnup Patel1-0/+15
We add new sbi_ngets() which help us read characters into a physical memory location. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
2023-02-09lib: sbi: Add sbi_nputs() functionAnup Patel1-0/+12
We add new sbi_nputs() which help us print a fixed number of characters from a physical memory location. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Xiang W <wxjstz@126.com>
2023-02-08include: types: Add typedefs for endiannessRahul Pathak1-3/+3
If any variable/memory-location follows certain endianness then its important to annotate it properly so that proper conversion can be done before read/write from that variable/memory. Also, use these new typedefs in libfdt_env.h for deriving its own custom fdtX_t types Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-08lib: utils/fdt: Use byteorder conversion functions in libfdt_env.hRahul Pathak1-19/+10
FDT follows big-endian and CPU can be little or big endian as per the implementation. libfdt_env.h defines function for conversion between fdt and cpu byteorder according to the endianness. Currently, libfdt_env.h defines custom byte swapping macros and then undefines them. Instead, use the generic endianness conversion functions Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-08lib: sbi: Ensure domidx_to_domain_table is null-terminatedAndrew Jones1-1/+5
sbi_domain_for_each() requires domidx_to_domain_table[] to be null-terminated. Allocate one extra element which will always be null. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-08lib: utils: Mark only the largest region as reserved in FDTHimanshu Chauhan1-4/+30
In commit 230278dcf, RX and RW regions were marked separately. When the RW region grows (e.g. with more harts) and it isn't a power-of-two, sbi_domain_memregion_init will upgrade the region to the next power-of-two. This will make RX and RW both start at the same base address, like so (with 64 harts): Domain0 Region01 : 0x0000000080000000-0x000000008001ffff M: (R,X) S/U: () Domain0 Region02 : 0x0000000080000000-0x00000000800fffff M: (R,W) S/U: () This doesn't break the permission enforcement because of static priorities in PMP but makes the kernel complain about the regions overlapping each other. Like so: [ 0.000000] OF: reserved mem: OVERLAP DETECTED! [ 0.000000] mmode_resv0@80000000 (0x0000000080000000--0x0000000080020000) \ overlaps with mmode_resv1@80000000 (0x0000000080000000--0x0000000080100000) To fix this warning, among the multiple regions having same base address but different sizes, add only the largest region as reserved region during fdt fixup. Fixes: 230278dcf (lib: sbi: Add separate entries for firmware RX and RW regions) Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-08lib: sbi_hsm: Use csr_set to restore the MIPNick Hu1-1/+1
If we use the csr_write to restore the MIP, we may clear the SEIP. In generic behavior of QEMU, if the pending bits of PLIC are set and we clear the SEIP, the QEMU may not set it back immediately. It may cause the interrupts won't be handled anymore until the new interrupts arrived and QEMU set the bits back. Signed-off-by: Nick Hu <nick.hu@sifive.com> Signed-off-by: Jim Shu <jim.shu@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-01-24lib: utils: Add fdt_add_cpu_idle_states() helper functionSamuel Holland1-0/+85
Since the availability and latency properties of CPU idle states depend on the specific SBI HSM implementation, it is appropriate that the idle states are added to the devicetree at runtime by that implementation. This helper function adds a platform-provided array of idle states to the devicetree, following the SBI idle state binding. Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Samuel Holland <samuel@sholland.org>
2023-01-23lib: sbi: Add separate entries for firmware RX and RW regionsHimanshu Chauhan1-2/+22
Add two entries for firmware in the root domain: 1. TEXT: fw_start to _fw_rw_offset with RX permissions 2. DATA: _fw_rw_offset to fw_size with RW permissions These permissions are still not enforced from M-mode but lay the ground work for enforcing them for M-mode. SU-mode don't have any access to these regions. Sample output: Domain0 Region01 : 0x0000000080000000-0x000000008001ffff M: (R,X) S/U: () Domain0 Region02 : 0x0000000080020000-0x000000008003ffff M: (R,W) S/U: () Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-01-23lib: sbi: Print the RW section offsetHimanshu Chauhan1-0/+1
Print the RW section offset when firmware base and size is being printed. Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-01-22lib: utils: Fix reserved memory node for firmware memoryMayuresh Chitale1-3/+3
The commit 9e0ba090 introduced more fine grained permissions for memory regions and did not update the fdt_reserved_memory_fixup() function. As a result, the fdt_reserved_memory_fixup continued to use the older coarse permissions which causes the reserved memory node to be not inserted into the DT. To fix the above issue, we correct the flags used for memory region permission checks in the fdt_reserved_memory_fixup() function. Fixes: 9e0ba090 ("include: sbi: Fine grain the permissions for M and SU modes") Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-01-22lib: reset/fdt_reset_atcwdt200: Use defined macros and function in atcsmu.hYu Chien Peter Lin2-13/+9
Reuse the smu related macros and function in atcsmu.h. Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-01-22lib: utils: atcsmu: Add Andes System Management Unit supportYu Chien Peter Lin3-0/+97
This patch adds atcsmu support for Andes AE350 platforms. The SMU provides system management capabilities, including clock, reset and power control based on power domain partitions. Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-01-22lib: sbi_hsm: handle failure when hart_stop returns SBI_ENOTSUPPYu Chien Peter Lin1-4/+3
Make use of generic warm-boot path when platform hart_stop callback returns SBI_ENOTSUPP, in case certain hart can not turn off its power domain, or it detects some error occured in power management unit, it can fall through warm-boot flow and wait for interrupt in sbi_hsm_hart_wait(). Also improves comment in sbi_hsm_hart_wait(). Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>