Skip to content

Conversation

@alvsun
Copy link
Contributor

@alvsun alvsun commented May 28, 2025

This patch introduces handling for the target reset request (RSTACT) in the I3C controller.
It enables the controller to send a broadcast RSTACT command along with the target reset pattern in a single frame.

/* Currently handle broadcast RSTACT command only */
if (payload->ccc.id == I3C_CCC_RSTACT(true)) {
/* Only process defined reset-action bytes (0x00 ~ 0x04) */
if (payload->ccc.data[0] <= I3C_CCC_RSTACT_VIRTUAL_TARGET_DETECT) {
Copy link
Member

Choose a reason for hiding this comment

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

swap the condition, handle the error in the branch and normal execution inline, plus I suppose the error condition should also sett err and goto out_do_ccc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if (payload->ccc.id == I3C_CCC_RSTACT(true)) {
/* Only process defined reset-action bytes (0x00 ~ 0x04) */
if (payload->ccc.data[0] <= I3C_CCC_RSTACT_VIRTUAL_TARGET_DETECT) {
ret = npcx_i3c_request_tgt_reset(inst);
Copy link
Member

Choose a reason for hiding this comment

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

this is a bit of a weird pattern, is it ok to override ret here? it was xferd_len, now it becomes an actual return value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It’s a little ambiguous at first glance, but the intention here is:
In npcx_i3c_xfer_write_fifo(), xfered_len is used to capture the result of a FIFO transfer, which can either be:
a positive number, meaning the number of bytes transferred, or a negative value, representing an error code
(e.g. -ETIMEDOUT, etc.).

We only assign xfered_len to ret when it’s xfered_len < 0, meaning an actual error occurred. Otherwise, we intentionally preserve the previous value of ret (which is usually 0) to avoid mistakenly returning a positive length as an error code.

This patch introduces handling for the target reset request (RSTACT)
in the I3C controller.
It enables the controller to send a broadcast RSTACT command along with
the target reset pattern in a single frame.

Signed-off-by: Alvis Sun <yfsun@nuvoton.com>
@alvsun alvsun force-pushed the npcx_i3c_ccc_rstact branch from 8fa90f4 to f3eb8f1 Compare May 29, 2025 05:36
@alvsun alvsun requested a review from fabiobaltieri May 29, 2025 06:45
@sonarqubecloud
Copy link

@kartben kartben merged commit c2f45ca into zephyrproject-rtos:main Jun 6, 2025
26 checks passed
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.

6 participants