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

Chris Johns chrisj at rtems.org
Thu Mar 30 22:59:50 UTC 2023


OK

Chris

On 31/3/2023 3:49 am, Kinsey Moore wrote:
> 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 devel mailing list