summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKinsey Moore <kinsey.moore@oarcorp.com>2023-03-29 10:52:15 -0500
committerJoel Sherrill <joel@rtems.org>2023-03-31 08:13:33 -0500
commit1e45b312f159ddd475e630c8ff16387b04dfe3f7 (patch)
tree4139d221c14dd5b5ffbfc3a1638aebcb18d897c7
parentwscript: Build a header instead of using -D (diff)
downloadrtems-lwip-1e45b312f159ddd475e630c8ff16387b04dfe3f7.tar.bz2
rtemslwip/xil_shims: Avoid hang in IRQ context
Do not try to alter IRQ server handlers while executing in the IRQ server thread context. This change avoids a deadlock in CGEM error condition handling that causes a reinitialization of the driver which attempts to reinstall the IRQ handler from within the IRQ handler. This deadlocks inside the IRQ server handler installation code while holding the lwIP system protection lock thus deadlocking all threads that try to access lwIP functionality.
-rw-r--r--rtemslwip/zynqmp/xil_shims.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/rtemslwip/zynqmp/xil_shims.c b/rtemslwip/zynqmp/xil_shims.c
index ec9ed12..2eda0c5 100644
--- a/rtemslwip/zynqmp/xil_shims.c
+++ b/rtemslwip/zynqmp/xil_shims.c
@@ -27,8 +27,10 @@
#include "xil_mmu.h"
#include <rtems/rtems/cache.h>
#include <rtems/rtems/intr.h>
+#include <rtems/score/threadimpl.h>
#include <libcpu/mmu-vmsav8-64.h>
#include <stdio.h>
+#include <string.h>
#define TWO_MB (2*1024*1024)
#define ONE_GB (1024*1024*1024)
@@ -67,6 +69,15 @@ BaseType_t xPortInstallInterruptHandler(
void *pvCallBackRef
)
{
+ char name[10];
+
+ /* Is this running in the context of any interrupt server tasks? */
+ _Thread_Get_name( _Thread_Get_executing(), name, sizeof( name ) );
+ if (strcmp(name, "IRQS") == 0) {
+ /* Can't run this from within an IRQ Server thread context */
+ return RTEMS_ILLEGAL_ON_SELF;
+ }
+
rtems_status_code sc = rtems_interrupt_server_handler_install(
RTEMS_INTERRUPT_SERVER_DEFAULT,
ucInterruptID,