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: espi: xec: Add support for eSPI flash channel #24214

Merged
merged 2 commits into from
Apr 22, 2020

Conversation

albertofloyd
Copy link
Collaborator

drivers: espi: xec: Add support for eSPI flash channel

Add driver implementation to support flash read/writ transactions
over eSPI bus.

Depends partially on #23796

Copy link
Collaborator

@scottwcpg scottwcpg left a comment

Choose a reason for hiding this comment

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

I did not see FC interrupt enables set in the read routine. The FC write routine does have interrupt enables for FC Done and channel enable change.

@zephyrbot zephyrbot added area: API Changes to public APIs area: Samples Samples labels Apr 9, 2020
@albertofloyd
Copy link
Collaborator Author

albertofloyd commented Apr 15, 2020

I did not see FC interrupt enables set in the read routine. The FC write routine does have interrupt enables for FC Done and channel enable change.

@scottwcpg I have the FC interrupts enabled during initialization at espi_init_flash(), would that be enough? Should this be done for each transaction?
I was thinking to actually remove interrupt enabling from FC write routine

@scottwcpg
Copy link
Collaborator

I did not see FC interrupt enables set in the read routine. The FC write routine does have interrupt enables for FC Done and channel enable change.

@scottwcpg I have the FC interrupts enabled during initialization at espi_init_flash(), would that be enough? Should this be done for each transaction?
I was thinking to actually remove interrupt enabling from FC write routine

OK, I did not see the interrupt enable in the init routine. You should be OK with interrupt enable in init. The is one corner case if you ever set the ABORT_ACCESS bit then HW will set DONE and ABORTED_BY_SLAVE which will fire the interrupt.

@albertofloyd albertofloyd force-pushed the espi_flash branch 2 times, most recently from 23241f3 to 422b46a Compare April 17, 2020 04:52
@albertofloyd albertofloyd requested a review from scottwcpg April 17, 2020 04:53
Copy link
Collaborator

@scottwcpg scottwcpg left a comment

Choose a reason for hiding this comment

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

The eSPI flash channel status register bits are read-write-1-to-clear. Performing a bit-wise OR to clear one bit results in clearing all active bits at the time the register is read. The other eSPI channels' status registers are the same.

@albertofloyd albertofloyd requested a review from dcpleung April 17, 2020 17:15
@albertofloyd
Copy link
Collaborator Author

The eSPI flash channel status register bits are read-write-1-to-clear. Performing a bit-wise OR to clear one bit results in clearing all active bits at the time the register is read. The other eSPI channels' status registers are the same.

@scottwcpg , could you further clarify? Or add the comment into the line of code?
I think you are referring to the operations inside espi_flash_isr()

  1. read first the flash channel register status into a variable, 2) check for each bit using the saved status 3) finally I clear in each case by writing 1 ( OR'ed with corresponding mask ).
    Are you saying register status gets clear during 1)

@scottwcpg
Copy link
Collaborator

The eSPI flash channel status register bits are read-write-1-to-clear. Performing a bit-wise OR to clear one bit results in clearing all active bits at the time the register is read. The other eSPI channels' status registers are the same.

@scottwcpg , could you further clarify? Or add the comment into the line of code?
I think you are referring to the operations inside espi_flash_isr()

  1. read first the flash channel register status into a variable, 2) check for each bit using the saved status 3) finally I clear in each case by writing 1 ( OR'ed with corresponding mask ).
    Are you saying register status gets clear during 1)

Lines 880 and 886 in espi_mchp_xec.c are both in the ISR but I observe all write to eSPI HW status registers are using bit-wise OR. All the eSPI status register implement read-only or read-write-1-clear bits. The bit-wise OR may clear other bits if the other bits are read as "1" in the read modify write sequence.

@albertofloyd
Copy link
Collaborator Author

The eSPI flash channel status register bits are read-write-1-to-clear. Performing a bit-wise OR to clear one bit results in clearing all active bits at the time the register is read. The other eSPI channels' status registers are the same.

@scottwcpg , could you further clarify? Or add the comment into the line of code?
I think you are referring to the operations inside espi_flash_isr()

  1. read first the flash channel register status into a variable, 2) check for each bit using the saved status 3) finally I clear in each case by writing 1 ( OR'ed with corresponding mask ).
    Are you saying register status gets clear during 1)

Lines 880 and 886 in espi_mchp_xec.c are both in the ISR but I observe all write to eSPI HW status registers are using bit-wise OR. All the eSPI status register implement read-only or read-write-1-clear bits. The bit-wise OR may clear other bits if the other bits are read as "1" in the read modify write sequence.

Got it. We have a widespread problem in the driver that will cause failures in corner cases (more than 1 bit set in these registers) during OR'd
Let me address the flash portion in this PR, will submit these changes for other blocks after perform through analysis and regression tests.

@scottwcpg
Copy link
Collaborator

The eSPI flash channel status register bits are read-write-1-to-clear. Performing a bit-wise OR to clear one bit results in clearing all active bits at the time the register is read. The other eSPI channels' status registers are the same.

@scottwcpg , could you further clarify? Or add the comment into the line of code?
I think you are referring to the operations inside espi_flash_isr()

  1. read first the flash channel register status into a variable, 2) check for each bit using the saved status 3) finally I clear in each case by writing 1 ( OR'ed with corresponding mask ).
    Are you saying register status gets clear during 1)

Lines 880 and 886 in espi_mchp_xec.c are both in the ISR but I observe all write to eSPI HW status registers are using bit-wise OR. All the eSPI status register implement read-only or read-write-1-clear bits. The bit-wise OR may clear other bits if the other bits are read as "1" in the read modify write sequence.

Got it. We have a widespread problem in the driver that will cause failures in corner cases (more than 1 bit set in these registers) during OR'd
Let me address the flash portion in this PR, will submit these changes for other blocks after perform through analysis and regression tests.

Ok, sounds like a plan.

@albertofloyd
Copy link
Collaborator Author

albertofloyd commented Apr 17, 2020

@scottwcpg Created #24464 to fix OOB and maybe peripheral channels

Update register flash status access as indicated.

@zephyrbot
Copy link
Collaborator

zephyrbot commented Apr 17, 2020

All checks are passing now.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

Add driver implementation to support flash read/writ transactions
over eSPI bus.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
Extend sample code to demonstrate the eSPI API to read/write flash.
Remove trailing \n
Use LOG_ERR when applicable instead of LOG_WRN
Treat warnings as errors.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
@carlescufi carlescufi merged commit 3bb73ad into zephyrproject-rtos:master Apr 22, 2020
@albertofloyd albertofloyd deleted the espi_flash branch April 28, 2020 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: Samples Samples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants