This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM625: Possible race condition between audio controller driver (davinci-mcasp) and simple sound card

Part Number: AM625
Hello,

We are experiencing a peculiar issue related to the audio sound card on the AM62.
Occasionally, our AM62 is unable to play/record audio unless we reboot it. However,
everything appears to be functioning correctly:

* The TI driver (davinci-mcasp.c) is probed and initialized properly.
* The audio codec (wm8904.c) is probed and initialized properly.
* The sound card (using simple-card.c) is created and can be accessed from userspace (/proc/asound).
* Amixer works (so I2C communication with the external codec is OK).

After some debugging, we were able to reproduce the issue by plugging a USB pen
drive into one of the USB host ports on our board. Every 3-6 reboots, the issue
reappears. Once it appears, any audio command for playing/recording stops working.

During kernel debugging, it seems that the DMA is not initialized within the PCM
engine when the error occurs. The TI driver is responsible for registering the
DMA to the sound subsystem. When everything is functioning correctly, it's
possible to observe the audio core calling the DMA. However, when the problem
occurs, the DMA is not being called, although it appears to be registered with
the audio core. The problem appears to be some sort of race condition between the order of the probe between simple-card.c
and the ti driver davinci-mcasp.c . When the issue appears, the simple card probe finishes the  before the davinci-mcasp driver.
Both of them are compiled as modules.

I am attaching (https://share.toradex.com/dr9u688rvxyonyq) FTRACE logs and some custom logs for probe order check for both the working case and the problematic one. Also,
the test scripts I am using: one to reboot my system automatically until the error
happens and another to generate the FTRACE logs. 

Do you have any information or experience with similar issues? Any insights or related problems would be greatly appreciated.

We are using the latest TI kernel [1] with DT: for the board [2] and for the SOM [3].

Regards,

João Paulo