]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[riscv] Ignore riscv,isa property in favour of direct CSR testing
authorMichael Brown <mcb30@ipxe.org>
Mon, 26 May 2025 20:12:12 +0000 (21:12 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 26 May 2025 20:34:11 +0000 (21:34 +0100)
The riscv,isa devicetree property appears not to be fully populated on
some real-world systems.  For example, the Sipeed Lichee Pi 4A
(running the vendor U-Boot) reports itself as "rv64imafdcvsu", which
does not include the "zicntr" extension even though the time CSR is
present and functional.

Ignore the riscv,isa property and rely solely on CSR testing to
determine whether or not extensions are present.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/riscv/core/zicntr.c
src/arch/riscv/core/zkr.c

index 7ea9f96adde385b25370f99d8c4e98561343a23d..fb632b8c016c42d28ac447d66074d21bc2f519b8 100644 (file)
@@ -32,7 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <string.h>
 #include <errno.h>
 #include <ipxe/fdt.h>
-#include <ipxe/hart.h>
+#include <ipxe/csr.h>
 #include <ipxe/timer.h>
 
 /** Timer increment per microsecond */
@@ -145,10 +145,10 @@ static int zicntr_probe ( void ) {
        } u;
        int rc;
 
-       /* Check if Zicntr extension is supported */
-       if ( ( rc = hart_supported ( "_zicntr" ) ) != 0 ) {
-               DBGC ( colour, "ZICNTR not supported: %s\n", strerror ( rc ) );
-               return rc;
+       /* Check if time CSR can be read */
+       if ( ! csr_can_read ( "time" ) ) {
+               DBGC ( colour, "ZICNTR cannot read TIME CSR\n" );
+               return -ENOTSUP;
        }
 
        /* Get timer frequency */
index 4b6316ea0415639f536c40c1a15664fddaa004d0..b27a7f07625820c6326cf5a27c6b8a183fc87a58 100644 (file)
@@ -30,7 +30,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  */
 
 #include <errno.h>
-#include <ipxe/hart.h>
 #include <ipxe/csr.h>
 #include <ipxe/entropy.h>
 #include <ipxe/drbg.h>
@@ -53,13 +52,6 @@ struct entropy_source zkr_entropy __entropy_source ( ENTROPY_PREFERRED );
  * @ret rc             Return status code
  */
 static int zkr_entropy_enable ( void ) {
-       int rc;
-
-       /* Check if Zkr extension is supported */
-       if ( ( rc = hart_supported ( "_zkr" ) ) != 0 ) {
-               DBGC ( colour, "ZKR not supported: %s\n", strerror ( rc ) );
-               return rc;
-       }
 
        /* Check if seed CSR is accessible in S-mode */
        if ( ! csr_can_write ( "seed", 0 ) ) {