Race condition between Linux and M4 app with rpmsg link init

Peng Fan peng.fan at nxp.com
Mon Mar 27 19:06:57 PDT 2023


Hi Frieder,

> Subject: Race condition between Linux and M4 app with rpmsg link init
> 
> Hi,
> 
> I have a problem with a kind of race condition between Linux
> remoteproc/rpmsg on the A53 core and the app on the M4 core when
> starting the remote core and initializing the rpmsg link. This is what
> happens:
> 
> | A53                          |  M4                         |
> | ---------------------------- | --------------------------- |
> | * load the ELF file          |                             |
> | * start the M4 core          |                             |
> | rproc_start()                |                             |
> |   imx_rproc_start()          |                             |
> |                              | * M4 app starts             |
> |   rproc_start_subdevices()   |                             |
> |                              | * M4 receives mailbox IRQ   |
> |                              | * M4 app doesn't handle     |
> |                              |   IRQ as they are not       |
> |                              |   registered yet            |
> |                              | * M4 registers IRQ handlers |
> 
> 
> When I add a delay in rproc_start() between the calls to
> imx_rproc_start() and rproc_start_subdevices() this give the M4 app enough
> time to fully start and register the IRQ handlers. In this case the rpmsg link is
> initialized correctly.
> 
> What is the proper way to fix this? Is there already a mechanism to handle
> such cases?
I had patches [1], but those were rejected. I not find proper way to address the issue
in upstream kernel.
[1] https://lore.kernel.org/lkml/20221104153303.GB1873068@p14s/t/#md0c56e96f61f6a423852ae697147d0394c7f0367

Regards,
Peng.
> 
> Thanks for any help!
> 
> Best regards
> Frieder


More information about the linux-arm-kernel mailing list