Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: dma: intel-adsp-gpdma: Account for LLPL wrapping #77747

Merged

Conversation

ujfalusi
Copy link
Collaborator

In case the LLP wraps we need to re-read the LLPU to make sure we return the correct value.

Suggested-by: Pierre-Louis Bossart [email protected]

In case the LLP wraps we need to re-read the LLPU to make sure we return
the correct value.

Suggested-by: Pierre-Louis Bossart <[email protected]>
Signed-off-by: Peter Ujfalusi <[email protected]>
@zephyrbot zephyrbot added the area: DMA Direct Memory Access label Aug 29, 2024
if (tmp > *llp_l) {
/* re-read the LLPU value, as LLPL just wrapped */
*llp_u = dw_read(dev_cfg->shim, GPDMA_CHLLPU(channel));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this always called with interrupts blocked or can this be preempted? If the latter, at least in theory it could wrap again between lines 136 and 139? I think a traditional way to do this is to perform 3 measurements and after that to check for consistency. Potentially in a loop. Something line

for (l2 = read_low(), l1 = l2 + 1; l2 < l1; l2 = read_low()) {
    h = read_high();
    l1 = l2;
} 

or

for (h2 = read_high(), h1 = h2 + 1; h1 != h2; h2 = read_high()) {
    l = read_low();
    h1 = h2;
}

Copy link
Collaborator Author

@ujfalusi ujfalusi Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it reasonable to think that the DMA moves 4294967295 bytes right after it has just wrapped?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course not, "this error can never happen" (TM) ;-) But that's the reason why this isn't a blocker, but just a comment. Also it "this error is purely theoretical" but it costs me almost nothing to account for it, I might as well decide to do so

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the point of covering for a case which by the laws of physics and electronics cannot happen.
If the llp_l wraps again just after it has wrapped while we read llp_u (u32) register, that would mean that the DMA managed to copy 4GB. Given that we use the GPDMA for audio, that would likely take some time...

I prefer simple code compared to something that you need to spend time to figure out what is going on and I'm still not sure if I follow the two snippets you presented, but that is just me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ujfalusi can this be interrupted? If this is running in a simple thread context, it can be preempted for a while

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can but likely for shorter period than 1.53 hours (96KHz, S32_LE, stereo)

@nashif nashif merged commit a8ac02f into zephyrproject-rtos:main Nov 16, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: DMA Direct Memory Access
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants