Skip to content

Flexio SPI loopback test failed on fast speed(16Mbps) #88877

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Raymond0225
Copy link
Collaborator

@Raymond0225 Raymond0225 commented Apr 21, 2025

drivers: spi: nxp: flexiospi spi_loopback test failed on flexio spi

Several reason cause loopback test failed:
a) FlexIO input frequency is not correct, on RT11xx, input freq is 24M,
while max bandrate can reach 1/4 of input freq, so it can only support
6Mbps.
b) Flexio shift register depend on correct timer output to triggger TX
and TX, if timer comparison value is not accurate, RX error happens on
high band rate. This is the reason why test fails on RT1060.

also fix a error on FlexIO clock ID calculation.

test: drivers: spi_loopback: Flexio spi support for RT1060 EVKC and RT1170 EVK

Add overlay file for RT1170 EVK and simply existing flexio spi overlay
file for RT1060 and RT1064 EVK. One flexio-spi interface for both slow
and fast tests. Fast bandrate set to 16Mbps now.

fix this issue: #77992

@Raymond0225 Raymond0225 force-pushed the flexIO_spi_input_freq_fix branch from 17d6aa5 to 15439f7 Compare April 22, 2025 16:32
@Raymond0225 Raymond0225 requested a review from JarmouniA April 22, 2025 16:36
@Raymond0225 Raymond0225 force-pushed the flexIO_spi_input_freq_fix branch 2 times, most recently from 79f39f0 to 457bbe3 Compare April 24, 2025 18:08
@asingh-GiN
Copy link
Contributor

asingh-GiN commented May 7, 2025

Hello @Raymond0225,

I tested the changes you proposed on my target device, and they seem to be working for me now. 😊

That said, I wanted to highlight a performance concern. It appears the issue stems from the busy wait condition inside the ISR. As seen in this line, there's a 100-microsecond wait, which seems to negatively impact performance.

When I reduced the delay to just 1 or 2 cycles, I noticed a significant performance improvement. It might be worth considering removing or minimizing such waits in the ISR to keep its execution time as short as possible.

@mmahadevan108, what are your thoughts on this?
This could also fix the other issue I posted. :)

@Raymond0225
Copy link
Collaborator Author

Hello @Raymond0225,

I tested the changes you proposed on my target device, and they seem to be working for me now. 😊

That said, I wanted to highlight a performance concern. It appears the issue stems from the busy wait condition inside the ISR. As seen in this line, there's a 100-microsecond wait, which seems to negatively impact performance.

When I reduced the delay to just 1 or 2 cycles, I noticed a significant performance improvement. It might be worth considering removing or minimizing such waits in the ISR to keep its execution time as short as possible.

@mmahadevan108, what are your thoughts on this? This could also fix the other issue I posted. :)

thanks @asingh-GiN for your feedback.
you are right, in this wait, we should not use a fix delay time. I think we need calculate a delay based on band rate.

@Raymond0225
Copy link
Collaborator Author

Raymond0225 commented May 7, 2025

Did a lot of tests just now, I am sure we can remove that delay completely. But so far, we can't, if we remove that delay, loop_spi test fails. There are bugs and I will submit another PR to address this issue and fix it.
Even we removed this delay, the efficiency is not so good, you can see a 4xx ns delay on the end of each frame (1 byte), it means although band rate is 16Mbps, the real speed may be about 8Mbps. This limitation is due to the nature of FLEXIO itself.

@asingh-GiN
Copy link
Contributor

asingh-GiN commented May 8, 2025

@Raymond0225 Thanks for checking it out as well. :)
Please tag me or the other issue, in the new PR so that I am also in the loop.
According to a discussion I had with the NXP support team, they said that the maximum recommended clock freq for FLEXIO SPI is 20MHz. I believe the issue might be where the flags are handled if thats the case.

@Raymond0225 Raymond0225 force-pushed the flexIO_spi_input_freq_fix branch from 457bbe3 to 505f980 Compare May 19, 2025 19:56
@Raymond0225 Raymond0225 force-pushed the flexIO_spi_input_freq_fix branch from 505f980 to 6329f07 Compare May 19, 2025 20:05
@Raymond0225 Raymond0225 requested a review from JarmouniA May 19, 2025 20:06
@Raymond0225 Raymond0225 force-pushed the flexIO_spi_input_freq_fix branch from 6329f07 to 78ecaf2 Compare May 28, 2025 15:36
@Raymond0225 Raymond0225 requested a review from JarmouniA May 28, 2025 15:43
@Raymond0225 Raymond0225 force-pushed the flexIO_spi_input_freq_fix branch from 78ecaf2 to 69bb782 Compare May 28, 2025 16:18
@JarmouniA JarmouniA dismissed their stale review May 28, 2025 16:34

addressed.

@dleach02 dleach02 requested a review from JarmouniA May 28, 2025 18:07
@Raymond0225 Raymond0225 force-pushed the flexIO_spi_input_freq_fix branch from 69bb782 to e401ad2 Compare May 28, 2025 18:17
Several reason cause loopback test failed:
a) FlexIO input frequency is not correct, on RT11xx, input freq is 24M,
while max bandrate can reach 1/4 of input freq, so it can only support
6Mbps.
b) Flexio shift register depend on correct timer output to triggger TX
and TX, if timer comparison value is not accurate, RX error happens on
high band rate. This is the reason why test fails on RT1060.

also fix a error on FlexIO clock ID calculation.

Signed-off-by: Raymond Lei <raymond.lei@nxp.com>
Add overlay file for RT1170 EVK and simply existing flexio spi overlay
file for RT1060 EVKC and RT1064 EVK. One flexio-spi interface for both slow
and fast tests. Fast bandrate set to 16Mbps now.

Signed-off-by: Raymond Lei <raymond.lei@nxp.com>
@Raymond0225 Raymond0225 force-pushed the flexIO_spi_input_freq_fix branch from e401ad2 to 6e3c6dc Compare May 28, 2025 19:05
Copy link

Copy link
Collaborator

@JarmouniA JarmouniA left a comment

Choose a reason for hiding this comment

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

baud rate to be corrected in commits messages.

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

Successfully merging this pull request may close these issues.

4 participants