Skip to content

Conversation

@decsny
Copy link
Member

@decsny decsny commented Sep 21, 2024

Driver was totally unreadable and tangled up in all sorts of conditional compilations and duplicated code, this PR addresses it, and makes the paths way more obvious to facilitate making changes much easier

No major functional changes intended by this PR.

There are a lot of commits so that one merge conflict doesnt cause a giant problem when rebasing.

@decsny
Copy link
Member Author

decsny commented Oct 11, 2024

dropped the dma path cleanup commit for now because something after recent merged patch makes the dma transfers wrong by one byte, not sure why yet

Copy link
Contributor

@EmilioCBen EmilioCBen left a comment

Choose a reason for hiding this comment

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

Thank you for your effort on this PR,
the only concern I have is of those checks
I mentioned otherwise LGTM!

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the '!!' here required?

Copy link
Member Author

@decsny decsny Oct 15, 2024

Choose a reason for hiding this comment

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

probably not, I can remove that if I need to push again

Copy link
Contributor

Choose a reason for hiding this comment

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

(non blocking) ping on this- looks like it could be removed

Copy link
Member Author

Choose a reason for hiding this comment

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

it's how the spi_context code does these types of checks with returns, is why I did it

EmilioCBen
EmilioCBen previously approved these changes Oct 24, 2024
@dleach02 dleach02 added this to the v4.0.0 milestone Oct 24, 2024
danieldegrasse
danieldegrasse previously approved these changes Oct 24, 2024
Copy link
Contributor

@danieldegrasse danieldegrasse left a comment

Choose a reason for hiding this comment

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

Few non-blocking nits

Copy link
Contributor

Choose a reason for hiding this comment

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

(non blocking) ping on this- looks like it could be removed

dleach02
dleach02 previously approved these changes Oct 24, 2024
@dleach02 dleach02 removed this from the v4.0.0 milestone Oct 31, 2024
@dkalowsk dkalowsk added this to the v4.1.0 milestone Oct 31, 2024
@decsny decsny dismissed stale reviews from dleach02, danieldegrasse, and EmilioCBen via 5cb58a6 November 8, 2024 21:56
@decsny
Copy link
Member Author

decsny commented Nov 8, 2024

found the bug in the DMA cleanup commit, re--added

@decsny decsny force-pushed the fix/lpspi_cleanup2 branch from 5cb58a6 to aec6af1 Compare November 8, 2024 22:16
@decsny
Copy link
Member Author

decsny commented Nov 8, 2024

rebased and added change to fix RT platforms from upstream

Copy link
Contributor

@yvanderv yvanderv left a comment

Choose a reason for hiding this comment

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

Consider comments on the git commit messages of this PR

Declan Snyder added 18 commits November 20, 2024 18:41
Organize #includes and #defines for less redundancy
and more readability.

Shorten some macros to avoid multi line statements.

Add some comments.

Signed-off-by: Declan Snyder <[email protected]>
Remove parent_dev from config struct, and simplify code for the
definition and use of the irq config function.

Signed-off-by: Declan Snyder <[email protected]>
Move init function to bottom of file by custom.

Signed-off-by: Declan Snyder <[email protected]>
Do initializations in a more logical order,
remove unnecessarily duplicated code,
reorder stack variables to be in reverse christmas tree order.

Signed-off-by: Declan Snyder <[email protected]>
Create helper functions for duplicated code related to
checking for DMA devices, with readable names.

Also remove unneeded function prototype.

Signed-off-by: Declan Snyder <[email protected]>
Add closing comment for #ifdef and remove unnecessary
indentation of an else block. Also move the transcieve_rtio
function to be near the other rtio functions. And move function
prototypes to top of file.

Signed-off-by: Declan Snyder <[email protected]>
Small change to consolidate the amount of lines of code in
the spi_mcux_isr by making a macro for the argument and removing
a line of code that was commented out.

Also move the ISR to be the first function in the file which is
common in many other drivers, instead of randomly in the middle of the
file. And move the isr callback to be next to the isr.

Signed-off-by: Declan Snyder <[email protected]>
Group the actual API functions to be next to each other.

Signed-off-by: Declan Snyder <[email protected]>
Move transceive funtions next to each other and clean up the wrapping of
functions to eliminate the ifdefs.

Signed-off-by: Declan Snyder <[email protected]>
This line doesn't need to be in multiple places.

Signed-off-by: Declan Snyder <[email protected]>
Remove lines of code that are commented out.

Signed-off-by: Declan Snyder <[email protected]>
Next packet function is way more complicated than it needs to be. Clean
it up by simplifying the code and making readable helper functions.

Signed-off-by: Declan Snyder <[email protected]>
All the master transfer seemed to use the same config flags,
reuse with a macro.

Signed-off-by: Declan Snyder <[email protected]>
Log the device name and status if the transfer could not start,
same way as in non-RTIO path.

Signed-off-by: Declan Snyder <[email protected]>
Remove unneeded prepare_start function since all uses of it are paired
with the start function. Also, probably should not mess with chip select
before deciding to do the transfer. And just return on some error like
the rest of the driver does instead of assert.

Signed-off-by: Declan Snyder <[email protected]>
Do all input validation etc BEFORE setting up configuration,
instead of mixing these things everywhere. Also condense the formatting
of the code.

Signed-off-by: Declan Snyder <[email protected]>
Optimize DMA callback by cleaning up the code and storing less debug
logging strings.

Signed-off-by: Declan Snyder <[email protected]>
Clean up DMA path of code.

Signed-off-by: Declan Snyder <[email protected]>
@decsny
Copy link
Member Author

decsny commented Nov 21, 2024

updated commit titles and removed the !! and rebased

}
#endif
#else
#define lpspi_inst_has_dma(arg) arg != arg
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the #else required? This function is only needed when CONFIG_SPI_MCUX_LPSPI_DMA is defined.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes otherwise there will be a build error

@mmahadevan108
Copy link
Contributor

@decsny, how was this PR tested?

@decsny
Copy link
Member Author

decsny commented Nov 21, 2024

@decsny, how was this PR tested?

i ran all combinations of rtio, async, dma configs on the spi loopback test on mcxn to see if it had the same behavior as before , but that was a while ago, and there was some rebases since then

@mmahadevan108
Copy link
Contributor

@tbursztyka , can you help review

@nashif nashif merged commit 7271000 into zephyrproject-rtos:main Nov 28, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: SPI SPI bus platform: NXP Drivers NXP Semiconductors, drivers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants