Skip to contentSkip to conversation

lib: sbi: Enable M-mode external interrupt only for AIA

PATCH New Atish Patra 3 participants 8 messages Feb 18, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: sbi: Enable M-mode external interrupt only for AIA

Some platforms may inject spurious M-mode external interrupt if the external interrupt bit is enabled in mie. We really don't need to enable M-mode external interrupts for platforms without AIA. This issue is observed in HiFive unmatched.

Keep the M-mode external interrupt disabled for non-AIA platforms.

---
 lib/sbi/sbi_init.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
lib/sbi/sbi_init.c +12 -2
index 6876eb2f0f22..76b7c5d953ec 100644
@@ -276,7 +276,12 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
 			   __func__, rc);
 		sbi_hart_hang();
 	}
-	csr_set(CSR_MIE, MIP_MEIP);
+	/**
+	 * HiFive unmatched platform generates spurious interrupt if external
+	 * interrupt is enabled in mie. Enable it only if AIA is present.
+	 */
+	if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+		csr_set(CSR_MIE, MIP_MEIP);
 
 	rc = sbi_ipi_init(scratch, TRUE);
 	if (rc) {
@@ -377,7 +382,12 @@ static void init_warm_startup(struct sbi_scratch *scratch, u32 hartid)
 	rc = sbi_platform_irqchip_init(plat, FALSE);
 	if (rc)
 		sbi_hart_hang();
-	csr_set(CSR_MIE, MIP_MEIP);
+	/**
+	 * HiFive unmatched platform generates spurious interrupt if external
+	 * interrupt is enabled in mie. Enable it only if AIA is present.
+	 */
+	if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+		csr_set(CSR_MIE, MIP_MEIP);
 
 	rc = sbi_ipi_init(scratch, FALSE);
 	if (rc)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/1 lib: sbi: Enable M-mode external interrupt only for AIA

Quoted 7 lines · Atish Patra

Some platforms may inject spurious M-mode external interrupt if the external interrupt bit is enabled in mie. We really don't need to enable M-mode external interrupts for platforms without AIA. This issue is observed in HiFive unmatched.

Keep the M-mode external interrupt disabled for non-AIA platforms.

Is this for UART1 (https://forums.sifive.com/t/spurious-interrupts-from-m-2-e-key-uart1/5478)?

Seems to be OpenSBI should not be enabling any external interrupts in the PLIC that it doesn?t want, which should render this patch unnecessary (though you could perhaps argue you still might as well not unmask external interrupts if you don?t expect any). Otherwise you just risk the same thing happening for AIA hardware and needing to do the proper fix at a later date.

As it stands this patch is quite dubious without further exploration and explanation of where these external interrupts are coming from.

Jess

Quoted 45 lines

---
lib/sbi/sbi_init.c | 14 ++++++++++++--

1 file changed, 12 insertions(+), 2 deletions(-)
lib/sbi/sbi_init.c +12 -2
index 6876eb2f0f22..76b7c5d953ec 100644
@@ -276,7 +276,12 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
 			   __func__, rc);
 		sbi_hart_hang();
 	}
-	csr_set(CSR_MIE, MIP_MEIP);
+	/**
+	 * HiFive unmatched platform generates spurious interrupt if external
+	 * interrupt is enabled in mie. Enable it only if AIA is present.
+	 */
+	if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+		csr_set(CSR_MIE, MIP_MEIP);
 
 	rc = sbi_ipi_init(scratch, TRUE);
 	if (rc) {
@@ -377,7 +382,12 @@ static void init_warm_startup(struct sbi_scratch *scratch, u32 hartid)
 	rc = sbi_platform_irqchip_init(plat, FALSE);
 	if (rc)
 		sbi_hart_hang();
-	csr_set(CSR_MIE, MIP_MEIP);
+	/**
+	 * HiFive unmatched platform generates spurious interrupt if external
+	 * interrupt is enabled in mie. Enable it only if AIA is present.
+	 */
+	if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+		csr_set(CSR_MIE, MIP_MEIP);
 
 	rc = sbi_ipi_init(scratch, FALSE);
 	if (rc)
Signature · 7 lines
2.30.2


-- 
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
#2 lore raw

PATCH 1/1 lib: sbi: Enable M-mode external interrupt only for AIA

Quoted 10 lines · Jessica Clarke
Quoted 7 lines · Atish Patra

Some platforms may inject spurious M-mode external interrupt if the external interrupt bit is enabled in mie. We really don't need to enable M-mode external interrupts for platforms without AIA. This issue is observed in HiFive unmatched.

Keep the M-mode external interrupt disabled for non-AIA platforms.

Quoted 8 lines

Is this for UART1 (https://forums.sifive.com/t/spurious-interrupts-from-m-2-e-key-uart1/5478)?

Seems to be OpenSBI should not be enabling any external interrupts in the PLIC that it doesn?t want, which should render this patch unnecessary (though you could perhaps argue you still might as well not unmask external interrupts if you don?t expect any). Otherwise you just risk the same thing happening for AIA hardware and needing to do the proper fix at a later date.

On platforms with IMSIC, the IPIs are through IMSIC since there is no CLINT or MSWI on these platforms. To support IPIs over IMSIC, we have to enable external interrupt on platforms with IMSIC.

Unfortunately, this leads to possible spurious interrupts on platforms (e.g. SiFive Unmatched) with traditional PLIC.

Regards,
Anup

Quoted 57 lines

As it stands this patch is quite dubious without further exploration and explanation of where these external interrupts are coming from.

Jess

Quoted 41 lines

---
lib/sbi/sbi_init.c | 14 ++++++++++++--

1 file changed, 12 insertions(+), 2 deletions(-)
lib/sbi/sbi_init.c +12 -3
index 6876eb2f0f22..76b7c5d953ec 100644
@@ -276,7 +276,12 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
                         __func__, rc);
              sbi_hart_hang();
      }
-     csr_set(CSR_MIE, MIP_MEIP);
+     /**
+      * HiFive unmatched platform generates spurious interrupt if external
+      * interrupt is enabled in mie. Enable it only if AIA is present.
+      */
+     if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+             csr_set(CSR_MIE, MIP_MEIP);
 
      rc = sbi_ipi_init(scratch, TRUE);
      if (rc) {
@@ -377,7 +382,12 @@ static void init_warm_startup(struct sbi_scratch *scratch, u32 hartid)
      rc = sbi_platform_irqchip_init(plat, FALSE);
      if (rc)
              sbi_hart_hang();
-     csr_set(CSR_MIE, MIP_MEIP);
+     /**
+      * HiFive unmatched platform generates spurious interrupt if external
+      * interrupt is enabled in mie. Enable it only if AIA is present.
+      */
+     if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+             csr_set(CSR_MIE, MIP_MEIP);
 
      rc = sbi_ipi_init(scratch, FALSE);
      if (rc)
--

2.30.2

Quoted 4 lines

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

#3 lore raw

PATCH 1/1 lib: sbi: Enable M-mode external interrupt only for AIA

Quoted 21 lines · Anup Patel
Quoted 10 lines · Jessica Clarke
Quoted 7 lines · Atish Patra

Some platforms may inject spurious M-mode external interrupt if the external interrupt bit is enabled in mie. We really don't need to enable M-mode external interrupts for platforms without AIA. This issue is observed in HiFive unmatched.

Keep the M-mode external interrupt disabled for non-AIA platforms.

Quoted 8 lines

Is this for UART1 (https://forums.sifive.com/t/spurious-interrupts-from-m-2-e-key-uart1/5478)?

Seems to be OpenSBI should not be enabling any external interrupts in the PLIC that it doesn?t want, which should render this patch unnecessary (though you could perhaps argue you still might as well not unmask external interrupts if you don?t expect any). Otherwise you just risk the same thing happening for AIA hardware and needing to do the proper fix at a later date.

Quoted 6 lines

On platforms with IMSIC, the IPIs are through IMSIC since there is no CLINT or MSWI on these platforms. To support IPIs over IMSIC, we have to enable external interrupt on platforms with IMSIC.

Unfortunately, this leads to possible spurious interrupts on platforms (e.g. SiFive Unmatched) with traditional PLIC.

Why? If you correctly configure the PLIC you shouldn?t get any, surely?

Jess

Quoted 60 lines

Regards,
Anup

Quoted 57 lines

As it stands this patch is quite dubious without further exploration and explanation of where these external interrupts are coming from.

Jess

Quoted 41 lines

---
lib/sbi/sbi_init.c | 14 ++++++++++++--

1 file changed, 12 insertions(+), 2 deletions(-)
lib/sbi/sbi_init.c +12 -3
index 6876eb2f0f22..76b7c5d953ec 100644
@@ -276,7 +276,12 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
                        __func__, rc);
             sbi_hart_hang();
     }
-     csr_set(CSR_MIE, MIP_MEIP);
+     /**
+      * HiFive unmatched platform generates spurious interrupt if external
+      * interrupt is enabled in mie. Enable it only if AIA is present.
+      */
+     if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+             csr_set(CSR_MIE, MIP_MEIP);
 
     rc = sbi_ipi_init(scratch, TRUE);
     if (rc) {
@@ -377,7 +382,12 @@ static void init_warm_startup(struct sbi_scratch *scratch, u32 hartid)
     rc = sbi_platform_irqchip_init(plat, FALSE);
     if (rc)
             sbi_hart_hang();
-     csr_set(CSR_MIE, MIP_MEIP);
+     /**
+      * HiFive unmatched platform generates spurious interrupt if external
+      * interrupt is enabled in mie. Enable it only if AIA is present.
+      */
+     if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+             csr_set(CSR_MIE, MIP_MEIP);
 
     rc = sbi_ipi_init(scratch, FALSE);
     if (rc)
--

2.30.2

Quoted 4 lines

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

#4 lore raw

PATCH 1/1 lib: sbi: Enable M-mode external interrupt only for AIA

Quoted 23 lines · Jessica Clarke
Quoted 21 lines · Anup Patel
Quoted 18 lines · Jessica Clarke
Quoted 7 lines · Atish Patra

Some platforms may inject spurious M-mode external interrupt if the external interrupt bit is enabled in mie. We really don't need to enable M-mode external interrupts for platforms without AIA. This issue is observed in HiFive unmatched.

Keep the M-mode external interrupt disabled for non-AIA platforms.

Is this for UART1 (https://forums.sifive.com/t/spurious-interrupts-from-m-2-e-key-uart1/5478)?

Seems to be OpenSBI should not be enabling any external interrupts in the PLIC that it doesn?t want, which should render this patch unnecessary (though you could perhaps argue you still might as well not unmask external interrupts if you don?t expect any). Otherwise you just risk the same thing happening for AIA hardware and needing to do the proper fix at a later date.

Quoted 9 lines
Quoted 6 lines

On platforms with IMSIC, the IPIs are through IMSIC since there is no CLINT or MSWI on these platforms. To support IPIs over IMSIC, we have to enable external interrupt on platforms with IMSIC.

Unfortunately, this leads to possible spurious interrupts on platforms (e.g. SiFive Unmatched) with traditional PLIC.

Why? If you correctly configure the PLIC you shouldn?t get any, surely?

All M-mode interrupt contexts are disabled in PLIC.
https://github.com/riscv-software-src/opensbi/blob/master/lib/utils/fdt/fdt_fixup.c#L114
This code has been there from ages.

The spurious external interrupt happens once Linux kernel invokes wfi. I am assuming this is a hardware
bug where M-mode external interrupts are generated even if PLIC contexts are disabled.

The issue only happens after the patch
55e79f823dfa (lib: sbi: Enable mie.MEIE bit for IPIs based on external interrupts.)

Quoted 63 lines

Jess

Quoted 60 lines

Regards,
Anup

Quoted 57 lines

As it stands this patch is quite dubious without further exploration and explanation of where these external interrupts are coming from.

Jess

Quoted 41 lines

---
lib/sbi/sbi_init.c | 14 ++++++++++++--

1 file changed, 12 insertions(+), 2 deletions(-)
lib/sbi/sbi_init.c +12 -3
index 6876eb2f0f22..76b7c5d953ec 100644
@@ -276,7 +276,12 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
                        __func__, rc);
             sbi_hart_hang();
     }
-     csr_set(CSR_MIE, MIP_MEIP);
+     /**
+      * HiFive unmatched platform generates spurious interrupt if external
+      * interrupt is enabled in mie. Enable it only if AIA is present.
+      */
+     if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+             csr_set(CSR_MIE, MIP_MEIP);
 
     rc = sbi_ipi_init(scratch, TRUE);
     if (rc) {
@@ -377,7 +382,12 @@ static void init_warm_startup(struct sbi_scratch *scratch, u32 hartid)
     rc = sbi_platform_irqchip_init(plat, FALSE);
     if (rc)
             sbi_hart_hang();
-     csr_set(CSR_MIE, MIP_MEIP);
+     /**
+      * HiFive unmatched platform generates spurious interrupt if external
+      * interrupt is enabled in mie. Enable it only if AIA is present.
+      */
+     if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+             csr_set(CSR_MIE, MIP_MEIP);
 
     rc = sbi_ipi_init(scratch, FALSE);
     if (rc)
--

2.30.2

Quoted 4 lines

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

#5 lore raw

PATCH 1/1 lib: sbi: Enable M-mode external interrupt only for AIA

Quoted 29 lines · Atish Kumar Patra
Quoted 27 lines · Jessica Clarke
Quoted 25 lines · Anup Patel
Quoted 10 lines · Jessica Clarke
Quoted 7 lines · Atish Patra

Some platforms may inject spurious M-mode external interrupt if the external interrupt bit is enabled in mie. We really don't need to enable M-mode external interrupts for platforms without AIA. This issue is observed in HiFive unmatched.

Keep the M-mode external interrupt disabled for non-AIA platforms.

Quoted 8 lines

Is this for UART1 (https://forums.sifive.com/t/spurious-interrupts-from-m-2-e-key-uart1/5478)?

Seems to be OpenSBI should not be enabling any external interrupts in the PLIC that it doesn?t want, which should render this patch unnecessary (though you could perhaps argue you still might as well not unmask external interrupts if you don?t expect any). Otherwise you just risk the same thing happening for AIA hardware and needing to do the proper fix at a later date.

On platforms with IMSIC, the IPIs are through IMSIC since there is no CLINT or MSWI on these platforms. To support IPIs over IMSIC, we have to enable external interrupt on platforms with IMSIC.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Unfortunately, this leads to possible spurious interrupts on platforms (e.g. SiFive Unmatched) with traditional PLIC.

Why? If you correctly configure the PLIC you shouldn?t get any, surely?

All M-mode interrupt contexts are disabled in PLIC.
https://github.com/riscv-software-src/opensbi/blob/master/lib/utils/fdt/fdt_fixup.c#L114
This code has been there from ages.

That doesn?t do anything to the PLIC. It just patches the device tree?s description of the PLIC. But ok, I found the code that clears the PLIC IE bits and sets the thresholds to the max of 7 (for SiFive?s implementation).

Having said that, the device tree in U-Boot (even the -uboot variant) has the PLIC?s interrupts-extended property pre-mangled with -1 for the M-mode contexts. Is it possible that?s all that?s going on, and OpenSBI has no opportunity to initialise the PLIC, with plic_hartid2context[hartid][0] being left as 0 for every hart (i.e. mapping to the S core?s context)? The same also appears to be true for the fu540/unleashed device tree. Though why it?d only show up during WFI I can?t say.

Jess

Quoted 71 lines

The spurious external interrupt happens once Linux kernel invokes wfi. I am assuming this is a hardware
bug where M-mode external interrupts are generated even if PLIC contexts are disabled.

The issue only happens after the patch
55e79f823dfa (lib: sbi: Enable mie.MEIE bit for IPIs based on external interrupts.)

Quoted 62 lines

Jess

Quoted 60 lines

Regards,
Anup

Quoted 57 lines

As it stands this patch is quite dubious without further exploration and explanation of where these external interrupts are coming from.

Jess

Quoted 41 lines

---
lib/sbi/sbi_init.c | 14 ++++++++++++--

1 file changed, 12 insertions(+), 2 deletions(-)
lib/sbi/sbi_init.c +12 -3
index 6876eb2f0f22..76b7c5d953ec 100644
@@ -276,7 +276,12 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
                       __func__, rc);
            sbi_hart_hang();
    }
-     csr_set(CSR_MIE, MIP_MEIP);
+     /**
+      * HiFive unmatched platform generates spurious interrupt if external
+      * interrupt is enabled in mie. Enable it only if AIA is present.
+      */
+     if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+             csr_set(CSR_MIE, MIP_MEIP);
 
    rc = sbi_ipi_init(scratch, TRUE);
    if (rc) {
@@ -377,7 +382,12 @@ static void init_warm_startup(struct sbi_scratch *scratch, u32 hartid)
    rc = sbi_platform_irqchip_init(plat, FALSE);
    if (rc)
            sbi_hart_hang();
-     csr_set(CSR_MIE, MIP_MEIP);
+     /**
+      * HiFive unmatched platform generates spurious interrupt if external
+      * interrupt is enabled in mie. Enable it only if AIA is present.
+      */
+     if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+             csr_set(CSR_MIE, MIP_MEIP);
 
    rc = sbi_ipi_init(scratch, FALSE);
    if (rc)
--

2.30.2

Quoted 4 lines

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

#6 lore raw

PATCH 1/1 lib: sbi: Enable M-mode external interrupt only for AIA

In reply to Jessica Clarke
Quoted 23 lines · Jessica Clarke
Quoted 21 lines · Anup Patel
Quoted 18 lines · Jessica Clarke
Quoted 7 lines · Atish Patra

Some platforms may inject spurious M-mode external interrupt if the external interrupt bit is enabled in mie. We really don't need to enable M-mode external interrupts for platforms without AIA. This issue is observed in HiFive unmatched.

Keep the M-mode external interrupt disabled for non-AIA platforms.

Is this for UART1 (https://forums.sifive.com/t/spurious-interrupts-from-m-2-e-key-uart1/5478)?

Seems to be OpenSBI should not be enabling any external interrupts in the PLIC that it doesn?t want, which should render this patch unnecessary (though you could perhaps argue you still might as well not unmask external interrupts if you don?t expect any). Otherwise you just risk the same thing happening for AIA hardware and needing to do the proper fix at a later date.

Quoted 8 lines
Quoted 6 lines

On platforms with IMSIC, the IPIs are through IMSIC since there is no CLINT or MSWI on these platforms. To support IPIs over IMSIC, we have to enable external interrupt on platforms with IMSIC.

Unfortunately, this leads to possible spurious interrupts on platforms (e.g. SiFive Unmatched) with traditional PLIC.

Why? If you correctly configure the PLIC you shouldn?t get any, surely?

We are definitely disabling interrupts for M-mode in PLIC but something is off. I certainly agree that we should investigate this issue in the PLIC driver but separately we should also ensure that mie.MEIE is enabled only for platforms requiring it.

Regards,
Anup

Quoted 64 lines

Jess

Quoted 60 lines

Regards,
Anup

Quoted 57 lines

As it stands this patch is quite dubious without further exploration and explanation of where these external interrupts are coming from.

Jess

Quoted 41 lines

---
lib/sbi/sbi_init.c | 14 ++++++++++++--

1 file changed, 12 insertions(+), 2 deletions(-)
lib/sbi/sbi_init.c +12 -3
index 6876eb2f0f22..76b7c5d953ec 100644
@@ -276,7 +276,12 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
                        __func__, rc);
             sbi_hart_hang();
     }
-     csr_set(CSR_MIE, MIP_MEIP);
+     /**
+      * HiFive unmatched platform generates spurious interrupt if external
+      * interrupt is enabled in mie. Enable it only if AIA is present.
+      */
+     if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+             csr_set(CSR_MIE, MIP_MEIP);
 
     rc = sbi_ipi_init(scratch, TRUE);
     if (rc) {
@@ -377,7 +382,12 @@ static void init_warm_startup(struct sbi_scratch *scratch, u32 hartid)
     rc = sbi_platform_irqchip_init(plat, FALSE);
     if (rc)
             sbi_hart_hang();
-     csr_set(CSR_MIE, MIP_MEIP);
+     /**
+      * HiFive unmatched platform generates spurious interrupt if external
+      * interrupt is enabled in mie. Enable it only if AIA is present.
+      */
+     if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+             csr_set(CSR_MIE, MIP_MEIP);
 
     rc = sbi_ipi_init(scratch, FALSE);
     if (rc)
--

2.30.2

Quoted 4 lines

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

#7 lore raw

PATCH 1/1 lib: sbi: Enable M-mode external interrupt only for AIA

In reply to Atish Patra
Quoted 18 lines · Atish Patra

Some platforms may inject spurious M-mode external interrupt if the external interrupt bit is enabled in mie. We really don't need to enable M-mode external interrupts for platforms without AIA. This issue is observed in HiFive unmatched.

Keep the M-mode external interrupt disabled for non-AIA platforms.

---
 lib/sbi/sbi_init.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
lib/sbi/sbi_init.c +0 -0
index 6876eb2f0f22..76b7c5d953ec 100644

lib/sbi/sbi_init.c static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid) · line 283

Quoted 9 lines
lib/sbi/sbi_init.c +5 -1
@@ -276,7 +276,12 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
                           __func__, rc);
                sbi_hart_hang();
        }
-       csr_set(CSR_MIE, MIP_MEIP);
+       /**
+        * HiFive unmatched platform generates spurious interrupt if external
+        * interrupt is enabled in mie. Enable it only if AIA is present.
+        */
+       if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))

Actually, we have to check for AIA IMSIC and not just AIA.

Regards,
Anup

Quoted 26 lines
lib/sbi/sbi_init.c +7 -2
+               csr_set(CSR_MIE, MIP_MEIP);
 
        rc = sbi_ipi_init(scratch, TRUE);
        if (rc) {
@@ -377,7 +382,12 @@ static void init_warm_startup(struct sbi_scratch *scratch, u32 hartid)
        rc = sbi_platform_irqchip_init(plat, FALSE);
        if (rc)
                sbi_hart_hang();
-       csr_set(CSR_MIE, MIP_MEIP);
+       /**
+        * HiFive unmatched platform generates spurious interrupt if external
+        * interrupt is enabled in mie. Enable it only if AIA is present.
+        */
+       if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
+               csr_set(CSR_MIE, MIP_MEIP);
 
        rc = sbi_ipi_init(scratch, FALSE);
        if (rc)
--

2.30.2

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi