[rtems-lwip commit] rtemslwip/xil_shims: Avoid hang in IRQ context

Joel Sherrill joel at rtems.org
Fri Mar 31 12:55:29 UTC 2023


Module:    rtems-lwip
Branch:    master
Commit:    1e45b312f159ddd475e630c8ff16387b04dfe3f7
Changeset: http://git.rtems.org/rtems-lwip/commit/?id=1e45b312f159ddd475e630c8ff16387b04dfe3f7

Author:    Kinsey Moore <kinsey.moore at oarcorp.com>
Date:      Wed Mar 29 10:52:15 2023 -0500

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.

---

 rtemslwip/zynqmp/xil_shims.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

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,



More information about the vc mailing list