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

write stuck in while(1) #38

Open
Memarnejad opened this issue Dec 28, 2021 · 2 comments
Open

write stuck in while(1) #38

Memarnejad opened this issue Dec 28, 2021 · 2 comments

Comments

@Memarnejad
Copy link

Hi,
In function process_write_data, repeat condition may lead to while(1).
Suppose that user does not specify --tx-bytes:
int repeat = (_cl_tx_bytes == 0);
so the repeat condition will be 1 and if the following condition is not satisfied, we will stuck in while(1)
if (c < actual_write_size) { _write_count_value = _write_data[c]; repeat = 0; }
If driver can send all data, then c = actual_write_size which leads the condition not being satisfied and we stuck in while(1)

But the question is that why does it work with some devices?
I guess that's because drivers can't send 1024bytes in ONE round (the remaining will be send in the next round ... handled in userspace) and the c < actual_write_size is satisfied and we don't stuck in while(1). But what if the driver can send 1024bytes? Unfortunately, it will get stuck in while(1)

I fixed this issue by simply replacing < with <=. Here is the modification:
if (c <= actual_write_size) { _write_count_value = _write_data[c]; repeat = 0; }

@Goshik92
Copy link

Hi @Memarnejad, I have the same issue, and it looks like the solution you proposed fixes it. Please consider opening a PR for merging your fix into the main branch.

@andy-shev
Copy link
Contributor

andy-shev commented Apr 11, 2024

FWIW, It's not uncommon that driver can send even more than 1kB at once with a help of DMA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants