foss-for-synopsys-dwc-arc-processors / linux

Helpful resources for users & developers of Linux kernel for ARC
22 stars 13 forks source link

[linux kernel 5.16, HS38x2, EV71] openamp host side not got UIO driver IRQ event when openamp EV side send message. #137

Open joshualin-petaio opened 11 months ago

joshualin-petaio commented 11 months ago

Hi expert,

There has a simple question about openamp host side IRQ. Could you please help me to clarify it? Thanks. As I know, openamp host side use UIO driver IRQ to check EV side had send openamp message or not. So, I try to use echo test to verify it. I modify the openamp host side echo test become wait message after send message directly. And EV side become send message after 2 second delay when got message. But I didn’t see any UIO driver IRQ event. Why EV side didn’t trigger host side UIO driver IRQ ???

Test flow: 1 EV side Wait message 2 Host side Send message to EV 3 EV side Got message 4 EV side Wait 2 second 5 EV side Send message to host 6 Host side Got message (no UIO IRQ??)

Thanks, Joshua

EvgeniiDidin commented 11 months ago

Hi @joshualin-petaio,

In the host-side part of the driver we have polling mechanism as a backup if irq is not presented. Please check if platform_poll() function is called. For device->host IRQ testing I would recommend you to write some simple baremetal test to ensure that IRQ event is happenning.

Thanks, Evgeniy

joshualin-petaio commented 11 months ago

Hi Evgeniy,

Thanks for your quickly. My test flow works fine. Openamp host can get message but I don't see the host into UIO driver IRQ handler. So, I am very confuse why host side knows that message coming without trigger UIO IRQ handler ??

Thanks, Joshua

joshualin-petaio commented 11 months ago

Hi Evgeniy,

There has another two test flow. The test result is strange also.

Test flow1 (step 1 to 4 repeat): 1 Host side Send message to EV (go into UIO IRQ handler here ???) and wait 5 second 2 EV side Got message 3 EV side Send message to host without wait 4 Host side Got message

Test flow2 (step 1 to 4 repeat, no any UIO IRQ handler found): 1 Host side Send message to EV and wait 5 second 2 EV side Got message 3 EV side Send message to host without wait 4 Host side Got message and wait 5 second

EvgeniiDidin commented 11 months ago

Hi Joshua,

On the host-side there is a thread, which is calling "remoteproc_get_notification" in a while loop. If there is a message from the device, remoteproc_get_notification will catch and handle the message. Note, this polling mechanism is using shared memory to get events, not IRQ's. So that is why it is working in your test scenarios. You can probably try comment out pthread_create(poll_thread...) line in platform_init call and see if the message is received on the host-side.

joshualin-petaio commented 11 months ago

Hi Evgenii,

After I comment out pthread_create(poll_thread...) line in platform_init. It stuck after message "metal: info: ev_runtime version 2022.09". I think the openamp handshake fail because host side didn't get some message. So, host side uses poll mode to check openamp message only, right ??? So, what is the function of the UIO IRQ when openamp running ??

Thanks, Joshua

EvgeniiDidin commented 11 months ago

Hi Joshua,

Polling is a backup mechanism and it occupies enough host CPU resources, so it is not preferable to use it in production. UIO IRQ probably should be a target here, so I would recommend you to double check if the IRQ is properly generated on the device side and delivered/handled by the Host.

Thanks, Evgeniy

joshualin-petaio commented 11 months ago

Hi Evgeniy,

I know what you mean now. So, after I comment out the poll thread. It should be works fine, right ? The UIO IRQ seems happened at wrong time, like my test scenario 1. Do you have any recommend to debug it ??

Thanks, Joshua

EvgeniiDidin commented 11 months ago

Hi Joshua,

If IRQs are correctly comming from the EV, polling can be commented out. One thing confuses me is that host is getting UIO IRQ even if device didn't process the message from the host. Do I understand this correctly? Could it be that IRQ is generated by another HW block(irq num mismatch)?

Thanks, Evgeniy

joshualin-petaio commented 11 months ago

Hi Evgeniy,

" host is getting UIO IRQ even if device didn't process the message from the host", yes, you are right. This is confuse me also. I'll check with HW team first.

Thanks, Joshua

joshualin-petaio commented 11 months ago

Hi Evgenii,

After I comment out the pthread_create(poll_thread...), the linux is stuck after show "metal: emergency: ev_runtime version 2022.09". Then I monitor the following IRQ registers,

  1. interrupt enable register equal 1 means IRQ enable.
  2. interrupt trigger register equal 0 means use level sensitive. <= this is strange, why it is not pulse sensitive ??

Thanks, Joshua

joshualin-petaio commented 11 months ago

Hi Evgenii,

I found a Note in spec. "Though each common interrupt can be programmed to be either level-triggered or edge-triggered, the interrupt is registered inside the IDU and is always distributed to the core as a level interrupt (from the cores perspective)." So, I think interrupt trigger register equal 0 is right.

There has another thing is when I try to monitor ARConnect setting. I don't see the openamp UIO IRQ unmask after setup mode done. Do you know it need unmask or not when openamp running ??

Thanks, Joshua

EvgeniiDidin commented 10 months ago

Hi Joshua,

Sorry for being silent for some time. Regarding your last question about IRQ masking/unmsking. I didn't find a place where IRQ are masked in open-amp/libmetal. Could you please tell me function name where it is called?

Thanks, Evgeniy