You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[APL] SOF test result depends on the speed of frmware loading #3157
but sometimes I don't rebuild the firmware image and instead want to re-test the existing one. Then I reboot the test device and skip the scp and proceed from the second line. And in some cases the results are consistently different between the two cases. I've seen this multiple times, but I typically discarded this as a human error. Now I again have such a case with a very consistent reproduction. The only explanation I could come up with is that when copying the image over, it's still in kernel's page cache, so, loading it is faster. To verify this theory I rebooted and read-in the image by doing cat x.ri > /dev/null. The test produced the same result as when the image was moved to the firmware directory.
I am not sure what the mitigation should be. We could try to work around this issue by pre-loading the firmware and the topology very early before any hardware access. But then we miss all the bugs that would result from a slow firmware loading. We could also add a parametrised delay where firmware is currently loaded, but then testing volume would grow a lot.
@marc-hb reported issues when changing the firmware, precisely because the old one remains in the kernel cache.
I am not sure how loading the firmware faster would have any impact on results. Loading is either pass or fail, can you elaborate on what you mean by 'fail'? Does the DSP sometimes not boot and run? or do you mean the behavior is different post-boot?
Of course you should NOT use these scripts when trying to reproduce this bug as they will change timings and many other things. I just don't want anyone reading this bug to get the wrong impression that each SOF developer has to write their own scp scripts.
@marc-hb reported issues when changing the firmware, precisely because the old one remains in the kernel cache.
I am not sure how loading the firmware faster would have any impact on results. Loading is either pass or fail, can you elaborate on what you mean by 'fail'? Does the DSP sometimes not boot and run? or do you mean the behavior is different post-boot?
@plbossart I wish I knew why that happens! As I said it's (almost) too close to the miracle status to be acting upon for me, but I've had such cases often enough now and yesterday I really was able to reproduce it reliably for a significant length of time. But no, I don't think it's about a wrong image. There's no other image on the system at that moment (well, not at the path used by the kernel). I checked dmesg - the difference between pre-cached and freshly read-in firmware was like 1-2 vs. 4-5ms. The firmware wasn't failing to load, but the runtime behaviour was different. And I'm putting this in past tense because after a couple of hours that behaviour disappeared. Maybe I hit different NAND cells with a new copy or whatever has happened.
This doesn't seem like a wide-spread problem so far, but it affected me enough to put it up here. Let's see if anyone else observes anything similar. But we could also make an experiment - move firmware loading to very early in probing. Maybe we're missing a delay in our hardware initialisation sequence and in most cases firmware loading creates that delay for us, but sometimes it doesn't.
@lyakh I am still not clear on the errors that you see. Is this post-initialization e.g. while trying to play/record audio, or is this in boot/suspend-resume?
And in some cases the results are consistently different between the two cases.
Can you give an example of a difference?
the difference between pre-cached and freshly read-in firmware was like 1-2 vs. 4-5ms.
No test should behave differently because of 3ms delay. The test should just be delayed by 3ms and that's all. If the test behaves differently because of a 3ms delay then there is a race condition and a bug, either in the test itself or in the kernel or in the firmware
The easiest to reproduce race conditions like these is to manually insert an artificial 3ms delay at the right place in the code - in this case somewhere near the firmware loading?
@lyakh I am still not clear on the errors that you see. Is this post-initialization e.g. while trying to play/record audio, or is this in boot/suspend-resume?
@plbossart runtime. In this specific case I was running multiple-pause-resume.
@lyakh, did you observed the runtime failure in case the firmware is loaded 'faster' or when the firmware is loaded 'slower', that is the firmware loading from filesystem.
@lyakh, did you observed the runtime failure in case the firmware is loaded 'faster' or when the firmware is loaded 'slower', that is the firmware loading from filesystem.
@ujfalusi I think the "fast loading" was failing. I.e. when pre-cached by either a fresh scp to the system of a simple cat x.ri > /dev/null, but since this was more than 2 weeks ago, I might be wrong.
Activity
plbossart commentedon Sep 14, 2021
@marc-hb reported issues when changing the firmware, precisely because the old one remains in the kernel cache.
I am not sure how loading the firmware faster would have any impact on results. Loading is either pass or fail, can you elaborate on what you mean by 'fail'? Does the DSP sometimes not boot and run? or do you mean the behavior is different post-boot?
marc-hb commentedon Sep 14, 2021
This was fixed by #2954. Also note still mysterious (to me) thesofproject/sof#4419
Finally, the following FW crash still requires a Linux reboot, reloading the FW is not enough!
I suspect the FW more this time.
thesofproject/sof@f1531b0810566d
marc-hb commentedon Sep 14, 2021
Digression sorry:
The recent "installer" makefile lets you combine these commands (and more) with a fast, incremental FW build in just one command. It can also deploy the sof-logger and dictionary. It's documented at https://thesofproject.github.io/latest/getting_started/build-guide/build-from-scratch.html#step-3-build-and-sign-firmware-binaries
The official scripts to unload and reload all drivers in the right order can be found https://github.com/thesofproject/sof-test/tree/main/tools/kmod They're used in CI and validation hundreds of times a day.
Of course you should NOT use these scripts when trying to reproduce this bug as they will change timings and many other things. I just don't want anyone reading this bug to get the wrong impression that each SOF developer has to write their own
scpscripts.Digression over sorry.
lyakh commentedon Sep 15, 2021
@plbossart I wish I knew why that happens! As I said it's (almost) too close to the miracle status to be acting upon for me, but I've had such cases often enough now and yesterday I really was able to reproduce it reliably for a significant length of time. But no, I don't think it's about a wrong image. There's no other image on the system at that moment (well, not at the path used by the kernel). I checked dmesg - the difference between pre-cached and freshly read-in firmware was like 1-2 vs. 4-5ms. The firmware wasn't failing to load, but the runtime behaviour was different. And I'm putting this in past tense because after a couple of hours that behaviour disappeared. Maybe I hit different NAND cells with a new copy or whatever has happened.
This doesn't seem like a wide-spread problem so far, but it affected me enough to put it up here. Let's see if anyone else observes anything similar. But we could also make an experiment - move firmware loading to very early in probing. Maybe we're missing a delay in our hardware initialisation sequence and in most cases firmware loading creates that delay for us, but sometimes it doesn't.
plbossart commentedon Sep 15, 2021
@lyakh I am still not clear on the errors that you see. Is this post-initialization e.g. while trying to play/record audio, or is this in boot/suspend-resume?
marc-hb commentedon Sep 15, 2021
Can you give an example of a difference?
No test should behave differently because of 3ms delay. The test should just be delayed by 3ms and that's all. If the test behaves differently because of a 3ms delay then there is a race condition and a bug, either in the test itself or in the kernel or in the firmware
The easiest to reproduce race conditions like these is to manually insert an artificial 3ms delay at the right place in the code - in this case somewhere near the firmware loading?
lyakh commentedon Sep 20, 2021
@plbossart runtime. In this specific case I was running multiple-pause-resume.
lyakh commentedon Sep 20, 2021
@marc-hb multiple-pause-resume was failing or passing
ujfalusi commentedon Oct 6, 2021
@lyakh, did you observed the runtime failure in case the firmware is loaded 'faster' or when the firmware is loaded 'slower', that is the firmware loading from filesystem.
lyakh commentedon Oct 7, 2021
@ujfalusi I think the "fast loading" was failing. I.e. when pre-cached by either a fresh scp to the system of a simple
cat x.ri > /dev/null, but since this was more than 2 weeks ago, I might be wrong.plbossart commentedon Jun 29, 2022
@lyakh can we close this issue or is this still relevant?
lyakh commentedon Jun 30, 2022
yes, let's close