f55d281536
The main improvement is that mcux_i3c_transfer() and mcux_i3c_i2c_api_transfer() will try much harder to not return an error that could be caused by the bus being busy. The bus could be busy because of IBI handling, especially if there are multiple I3C devices all raising IBI that need to be processed, which can involve a number of context switches and delays and take considerable time such that an application initiated I3C transfer request might have returned busy. Replaced the code that polled for idle state with a timeout with an infinite loop on a condvar. The condvar is broadcast to at the end of every stop, which should be when the bus goes idle. Details of other changes: * Remove ibi_lock, which seemed not useful. Use the single lock (switched from semaphore to mutex so it can be released by condvar) for both IBI handling and application requests. * Remove code that disables i3c controller interrupts during transfers. Since the only interrupt is SLVSTART, and that just posts a work, it didn't seem necessary to disable that interrupt. * Don't clear SLVSTART interrupt in mcux_i3c_status_clear_all(), to prevent any application transfers from accidentally clearing the SLVSTART interrupt or the handling of one IBI clearing the START initiated by another I3C device immeidately as the other one finishes. The only clearing of SLVSTART is in the isr. * Add back a wait in mcux_i3c_request_auto_ibi(), otherwise the ibitype could be 0 if the processor is faster than the auto ibi handling. An earlier change removed a wait for MCTRLDONE, which isn't always set when AUTO_IBI is requested, but that could mean we try to read the ibitype before it's ready. Waiting for IBIWON instead should be correct and better, since the AUTO_IBI should result in IBIWON status bit being set (and MCTRLDONE being set would not guarantee that IBIWON was set). * Change mcux_i3c_request_emit_stop() to still wait for idle if requested, even if the STOP wasn't actually issued, and add the release of the new condvar * Change mcux_i3c_do_one_xfer_read() to handle the IBI use case differently than the regular application requested transfer case. In the application requested transfer case, the rx_len is known and set in RDTERM, so we could check for the COMPLETE status bit, but for IBI transfers, we just do a read to the payload buffer without knowing how many bytes the target may send us so never get a COMPLETE. Rather than check for a COMPLETE bit that might never occur, just have both cases read until we either read all requested bytes or we get a timeout error. But for the timeout error, if it's IBI and non-zero bytes were received, return the bytes received instead of an error. * Change mcux_i3c_do_one_xfer() to return the error returned by mcux_i3c_do_one_xfer_read/write(). * Remove spurious return -EIO from end of mcux_i3c_do_daa() * Change mcux_i3c_ibi_enable() to restore SLVSTART on error, and add some LOG_ERR() messages for error cases. Also add check to make sure idx is valid since there is a limit to how many IBI this controller can support. * Change mcux_i3c_ibi_disable() to always reenable SLVSTART interrupt, even if the CCC to tell the target to disable IBI events fails. * Change mcux_i3c_isr() to reenable SLVSTART interrupt if the work_enqueue() fails. Signed-off-by: Mike J. Chen <mjchen@google.com> |
||
---|---|---|
.github | ||
arch | ||
boards | ||
cmake | ||
doc | ||
drivers | ||
dts | ||
include/zephyr | ||
kernel | ||
lib | ||
misc | ||
modules | ||
samples | ||
scripts | ||
share | ||
snippets | ||
soc | ||
submanifests | ||
subsys | ||
tests | ||
.checkpatch.conf | ||
.clang-format | ||
.codecov.yml | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.gitlint | ||
.mailmap | ||
.yamllint | ||
CMakeLists.txt | ||
CODE_OF_CONDUCT.md | ||
CODEOWNERS | ||
CONTRIBUTING.rst | ||
Kconfig | ||
Kconfig.zephyr | ||
LICENSE | ||
MAINTAINERS.yml | ||
README.rst | ||
SDK_VERSION | ||
VERSION | ||
version.h.in | ||
west.yml | ||
zephyr-env.cmd | ||
zephyr-env.sh |
.. raw:: html <a href="https://www.zephyrproject.org"> <p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="doc/_static/images/logo-readme-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="doc/_static/images/logo-readme-light.svg"> <img src="doc/_static/images/logo-readme-light.svg"> </picture> </p> </a> <a href="https://bestpractices.coreinfrastructure.org/projects/74"><img src="https://bestpractices.coreinfrastructure.org/projects/74/badge"></a> <a href="https://github.com/zephyrproject-rtos/zephyr/actions/workflows/twister.yaml?query=branch%3Amain"> <img src="https://github.com/zephyrproject-rtos/zephyr/actions/workflows/twister.yaml/badge.svg?event=push"></a> The Zephyr Project is a scalable real-time operating system (RTOS) supporting multiple hardware architectures, optimized for resource constrained devices, and built with security in mind. The Zephyr OS is based on a small-footprint kernel designed for use on resource-constrained systems: from simple embedded environmental sensors and LED wearables to sophisticated smart watches and IoT wireless gateways. The Zephyr kernel supports multiple architectures, including ARM (Cortex-A, Cortex-R, Cortex-M), Intel x86, ARC, Nios II, Tensilica Xtensa, and RISC-V, SPARC, MIPS, and a large number of `supported boards`_. .. below included in doc/introduction/introduction.rst Getting Started *************** Welcome to Zephyr! See the `Introduction to Zephyr`_ for a high-level overview, and the documentation's `Getting Started Guide`_ to start developing. .. start_include_here Community Support ***************** Community support is provided via mailing lists and Discord; see the Resources below for details. .. _project-resources: Resources ********* Here's a quick summary of resources to help you find your way around: Getting Started --------------- | 📖 `Zephyr Documentation`_ | 🚀 `Getting Started Guide`_ | 🙋🏽 `Tips when asking for help`_ | 💻 `Code samples`_ Code and Development -------------------- | 🌐 `Source Code Repository`_ | 📦 `Releases`_ | 🤝 `Contribution Guide`_ Community and Support --------------------- | 💬 `Discord Server`_ for real-time community discussions | 📧 `User mailing list (users@lists.zephyrproject.org)`_ | 📧 `Developer mailing list (devel@lists.zephyrproject.org)`_ | 📬 `Other project mailing lists`_ | 📚 `Project Wiki`_ Issue Tracking and Security --------------------------- | 🐛 `GitHub Issues`_ | 🔒 `Security documentation`_ | 🛡️ `Security Advisories Repository`_ | ⚠️ Report security vulnerabilities at vulnerabilities@zephyrproject.org Additional Resources -------------------- | 🌐 `Zephyr Project Website`_ | 📺 `Zephyr Tech Talks`_ .. _Zephyr Project Website: https://www.zephyrproject.org .. _Discord Server: https://chat.zephyrproject.org .. _supported boards: https://docs.zephyrproject.org/latest/boards/index.html .. _Zephyr Documentation: https://docs.zephyrproject.org .. _Introduction to Zephyr: https://docs.zephyrproject.org/latest/introduction/index.html .. _Getting Started Guide: https://docs.zephyrproject.org/latest/develop/getting_started/index.html .. _Contribution Guide: https://docs.zephyrproject.org/latest/contribute/index.html .. _Source Code Repository: https://github.com/zephyrproject-rtos/zephyr .. _GitHub Issues: https://github.com/zephyrproject-rtos/zephyr/issues .. _Releases: https://github.com/zephyrproject-rtos/zephyr/releases .. _Project Wiki: https://github.com/zephyrproject-rtos/zephyr/wiki .. _User mailing list (users@lists.zephyrproject.org): https://lists.zephyrproject.org/g/users .. _Developer mailing list (devel@lists.zephyrproject.org): https://lists.zephyrproject.org/g/devel .. _Other project mailing lists: https://lists.zephyrproject.org/g/main/subgroups .. _Code samples: https://docs.zephyrproject.org/latest/samples/index.html .. _Security documentation: https://docs.zephyrproject.org/latest/security/index.html .. _Security Advisories Repository: https://github.com/zephyrproject-rtos/zephyr/security .. _Tips when asking for help: https://docs.zephyrproject.org/latest/develop/getting_started/index.html#asking-for-help .. _Zephyr Tech Talks: https://www.zephyrproject.org/tech-talks