linux-remoteproc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Race condition between Linux and M4 app with rpmsg link init
@ 2023-03-27 11:49 Frieder Schrempf
  2023-03-28  2:06 ` Peng Fan
  0 siblings, 1 reply; 2+ messages in thread
From: Frieder Schrempf @ 2023-03-27 11:49 UTC (permalink / raw)
  To: linux-remoteproc, linux-arm-kernel
  Cc: Mathieu Poirier, Bjorn Andersson, Peng Fan, NXP Linux Team

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?

Thanks for any help!

Best regards
Frieder

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: Race condition between Linux and M4 app with rpmsg link init
  2023-03-27 11:49 Race condition between Linux and M4 app with rpmsg link init Frieder Schrempf
@ 2023-03-28  2:06 ` Peng Fan
  0 siblings, 0 replies; 2+ messages in thread
From: Peng Fan @ 2023-03-28  2:06 UTC (permalink / raw)
  To: Frieder Schrempf, linux-remoteproc, linux-arm-kernel
  Cc: Mathieu Poirier, Bjorn Andersson, dl-linux-imx

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-28  2:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 11:49 Race condition between Linux and M4 app with rpmsg link init Frieder Schrempf
2023-03-28  2:06 ` Peng Fan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).