[chip dv] Fix plic_all_irqs_test for Verilator
...and FPGA.
The logging mechanism which uses UART0 in Verilator and FPGA setups
messes up this test, which is meant to enable and test ALL interrupts
from all peripherals in the device, including UART0. The fix is to skip
testing UART0 interrupts for Verilator and FPGA.
Fixes #8656.
Signed-off-by: Srikrishna Iyer <sriyer@google.com>
diff --git a/sw/device/tests/autogen/plic_all_irqs_test.c b/sw/device/tests/autogen/plic_all_irqs_test.c
index 94de38a..715a161 100644
--- a/sw/device/tests/autogen/plic_all_irqs_test.c
+++ b/sw/device/tests/autogen/plic_all_irqs_test.c
@@ -971,8 +971,12 @@
dif_spi_host_irq_restore_all(&spi_host1, &spi_host_irqs));
CHECK_DIF_OK(
dif_sysrst_ctrl_irq_restore_all(&sysrst_ctrl_aon, &sysrst_ctrl_irqs));
- CHECK_DIF_OK(
- dif_uart_irq_restore_all(&uart0, &uart_irqs));
+ // lowrisc/opentitan#8656: Skip UART0 in non-DV setups due to interference
+ // from the logging facility.
+ if (kDeviceType == kDeviceSimDV) {
+ CHECK_DIF_OK(
+ dif_uart_irq_restore_all(&uart0, &uart_irqs));
+ }
CHECK_DIF_OK(
dif_uart_irq_restore_all(&uart1, &uart_irqs));
CHECK_DIF_OK(
@@ -1305,17 +1309,21 @@
LOG_INFO("IRQ %d from sysrst_ctrl_aon is serviced.", irq);
}
- peripheral_expected = kTopEarlgreyPlicPeripheralUart0;
- for (dif_uart_irq_t irq = kDifUartIrqTxWatermark;
- irq <= kDifUartIrqRxParityErr; ++irq) {
- uart_irq_expected = irq;
- LOG_INFO("Triggering uart0 IRQ %d.", irq);
- CHECK_DIF_OK(dif_uart_irq_force(&uart0, irq));
+ // lowrisc/opentitan#8656: Skip UART0 in non-DV setups due to interference
+ // from the logging facility.
+ if (kDeviceType == kDeviceSimDV) {
+ peripheral_expected = kTopEarlgreyPlicPeripheralUart0;
+ for (dif_uart_irq_t irq = kDifUartIrqTxWatermark;
+ irq <= kDifUartIrqRxParityErr; ++irq) {
+ uart_irq_expected = irq;
+ LOG_INFO("Triggering uart0 IRQ %d.", irq);
+ CHECK_DIF_OK(dif_uart_irq_force(&uart0, irq));
- CHECK(uart_irq_serviced == irq,
- "Incorrect uart0 IRQ serviced: exp = %d, obs = %d", irq,
- uart_irq_serviced);
- LOG_INFO("IRQ %d from uart0 is serviced.", irq);
+ CHECK(uart_irq_serviced == irq,
+ "Incorrect uart0 IRQ serviced: exp = %d, obs = %d", irq,
+ uart_irq_serviced);
+ LOG_INFO("IRQ %d from uart0 is serviced.", irq);
+ }
}
peripheral_expected = kTopEarlgreyPlicPeripheralUart1;
diff --git a/util/topgen/templates/plic_all_irqs_test.c.tpl b/util/topgen/templates/plic_all_irqs_test.c.tpl
index 2b733c7..64a03fc 100644
--- a/util/topgen/templates/plic_all_irqs_test.c.tpl
+++ b/util/topgen/templates/plic_all_irqs_test.c.tpl
@@ -146,8 +146,22 @@
<%
if p.name == "aon_timer": continue
%>\
- CHECK_DIF_OK(
- dif_${p.name}_irq_restore_all(${args(p)}, &${p.name}_irqs));
+<%
+ indent = ""
+%>\
+ % if p.inst_name == "uart0":
+<%
+ indent = " "
+%>\
+ // lowrisc/opentitan#8656: Skip UART0 in non-DV setups due to interference
+ // from the logging facility.
+ if (kDeviceType == kDeviceSimDV) {
+ % endif
+ ${indent}CHECK_DIF_OK(
+ ${indent} dif_${p.name}_irq_restore_all(${args(p)}, &${p.name}_irqs));
+ % if p.inst_name == "uart0":
+ }
+ % endif
% endfor
}
@@ -162,18 +176,32 @@
*/
static void peripheral_irqs_trigger(void) {
% for p in helper.irq_peripherals:
- peripheral_expected = ${p.plic_name};
- for (dif_${p.name}_irq_t irq = ${p.start_irq};
- irq <= ${p.end_irq}; ++irq) {
- ${p.name}_irq_expected = irq;
- LOG_INFO("Triggering ${p.inst_name} IRQ %d.", irq);
- CHECK_DIF_OK(dif_${p.name}_irq_force(&${p.inst_name}, irq));
+<%
+ indent = ""
+%>\
+ % if p.inst_name == "uart0":
+<%
+ indent = " "
+%>\
+ // lowrisc/opentitan#8656: Skip UART0 in non-DV setups due to interference
+ // from the logging facility.
+ if (kDeviceType == kDeviceSimDV) {
+ % endif
+ ${indent}peripheral_expected = ${p.plic_name};
+ ${indent}for (dif_${p.name}_irq_t irq = ${p.start_irq};
+ ${indent} irq <= ${p.end_irq}; ++irq) {
+ ${indent} ${p.name}_irq_expected = irq;
+ ${indent} LOG_INFO("Triggering ${p.inst_name} IRQ %d.", irq);
+ ${indent} CHECK_DIF_OK(dif_${p.name}_irq_force(&${p.inst_name}, irq));
- CHECK(${p.name}_irq_serviced == irq,
- "Incorrect ${p.inst_name} IRQ serviced: exp = %d, obs = %d", irq,
- ${p.name}_irq_serviced);
- LOG_INFO("IRQ %d from ${p.inst_name} is serviced.", irq);
+ ${indent} CHECK(${p.name}_irq_serviced == irq,
+ ${indent} "Incorrect ${p.inst_name} IRQ serviced: exp = %d, obs = %d", irq,
+ ${indent} ${p.name}_irq_serviced);
+ ${indent} LOG_INFO("IRQ %d from ${p.inst_name} is serviced.", irq);
+ ${indent}}
+ % if p.inst_name == "uart0":
}
+ % endif
${"" if loop.last else "\n"}\
% endfor
}