Skip to content

Clear CCC and transfer status in Cadence driver - #116261

Merged
nashif merged 1 commit into
zephyrproject-rtos:mainfrom
mborows2:main
Aug 22, 2026
Merged

Clear CCC and transfer status in Cadence driver#116261
nashif merged 1 commit into
zephyrproject-rtos:mainfrom
mborows2:main

Conversation

@mborows2

@mborows2 mborows2 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Clear CCC and transfer status in Cadence driver - #116261

@github-actions

Copy link
Copy Markdown

Hello @mborows2, and thank you very much for your first Pull Request (PR) to the Zephyr Project!

All PRs must pass our Continuous Integration (CI) pipeline before merging. When the pipeline run for your PR completes, you are expected to investigate the results, fix any errors, and update your PR for a fresh round of review.

Since this is your first contribution, a project community member must manually approve your CI run (this helps us avoid abuse of our CI system). A bot should assign some reviewers who can start the run for you soon.

As a heads-up, you will probably have to update your PR to fix CI issues and address review feedback in order to get it ready for merge. Some key rules for updating your PR are:

  • do amend problematic commits on your computer and force push the fixed commits into your PR branch on GitHub
  • don't push new commits just to fix problems in existing PR commits (amend your commits instead)
  • don't close your PR and open an updated one unless reviewers specifically request it (force push to your branch instead)
  • do rebase your PR branch onto our main branch and force push to this PR to resolve merge conflicts
  • don't merge our main branch into your PR branch to fix merge conflicts

Also, see:

If you are stuck or need help, you can join us on Discord and ask questions; many community members try to help new contributors there 😊. Try to pick a Discord channel that is associated with the technical details of your request. If you're not sure, use the #general channel.

@zephyrbot

Copy link
Copy Markdown

@ndrs-pst

You have been identified as a likely reviewer for the code this pull request changes, but could not be added to its review request automatically. Please review it if you are able to.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make the Cadence I3C controller driver proactively clear driver-owned transfer status fields (num_xfer, err) for both CCC transactions and private transfers, preventing callers from consuming stale/uninitialized residue when commands are dropped without producing CMDR completion entries.

Changes:

  • Add a CCC helper to reset i3c_ccc_payload status fields before issuing a CCC.
  • Add a private-transfer helper to reset i3c_msg status fields before issuing I3C transfers.
  • Invoke these reset helpers in both synchronous and callback-based transfer entry points.
Suppressed comments (3)

drivers/i3c/i3c_cdns.c:1793

  • Typo in this comment block ("unitialized"), plus a couple phrasing issues; please correct the text and remove trailing whitespace on the blank line.
 * 
 * The CCC helpers in i3c_ccc.c declare their payloads as unitialized stack
 * locals and read @c num_xfer back as length, so that residue gets consumed
 * as byte count. Clear the fields up front so an incomplete CCC reports zero
 * bytes transferred rather than stack garbage.

drivers/i3c/i3c_cdns.c:2873

  • Typos/grammar in this comment block (e.g., "contract a their", "pior", "00 the document") reduce clarity; please correct the wording.
 * @c num_xfer and @c err carry the same driver-writes-this contract a their
 * CCC counterparts (see @ref i3c_msg) and are populated from the same CMDR
 * completion handler, so a message whose command never retires a CMDR entry
 * leaves both holding the caller's pior contents. Callers that size a
 * subsequent access on @c num_xfer 00 the document way to learn how many

drivers/i3c/i3c_cdns.c:2928

  • This call is indented with spaces; the rest of the file uses tabs for indentation.
    cdns_i3c_msgs_reset_status(msgs, num_msgs);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread drivers/i3c/i3c_cdns.c Outdated
Comment thread drivers/i3c/i3c_cdns.c Outdated
Comment on lines +1783 to +1788
* @c num_xfer and @c err are outputs the controller driver is required to write
* (see @ref i3c_ccc_payload). This driver only writes them from the CMDR
* completion handler, which runs once per command response actually retired by
* the IP. A command that is dropped without producing a CMDR entry therefore
* never update them, while the transaction as a whole can still comple
* successfully -- leaving whatevevr the caller happened to have in the payload.
Comment thread drivers/i3c/i3c_cdns.c Outdated
Comment on lines +2881 to +2887
static void cdns_i3c_msgs_reset_status(struct i3c)msg *msg, uint8_t num_msgs)
{
for (uint8_t i = 0; i < num_msgs; i++) {
msgs[i].num_xfer = 0;
msgs[i].err = I3C_ERROR_CE_NONE;
}
}
Comment thread drivers/i3c/i3c_cdns.c Outdated
static int cdns_i3c_transfer(const struct device *dev, struct i3c_device_desc *target,
struct i3c_msg *msgs, uint8_t num_msgs)
{
cdns_i3c_msgs_reset_status(msgs, num_msgs);
@dcpleung

This comment was marked as outdated.

@mborows2
mborows2 force-pushed the main branch 3 times, most recently from ec983d1 to e5cdf34 Compare August 17, 2026 18:33
@sonarqubecloud

Copy link
Copy Markdown

num_xfer is an output field the controller driver is contractually
required to populate - the struct i3c_ccc_payload documentation states
"It is expected for the driver to write to this after the transfer".
The Cadence RTIO driver does write it, but only from
cdns_i3c_rtio_irq_cmdd_emp(), which iterates the command responses
the IP actually retired. A command that is dropped without producing
a CMDR entry never updates num_xfer, and because sticky is only set
from responses that were seen, the transaction can still complete
successfully. The caller then reads a field the driver never wrote.

Added two helpers to i3c_cdns.c and call them before the transfer
is submitted.

Signed-off-by: Marek Borowski <marek@borowski.com>
@nashif
nashif merged commit d436a8c into zephyrproject-rtos:main Aug 22, 2026
2 checks passed
@github-actions

Copy link
Copy Markdown

Hi @mborows2!

Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

Now that your first PR is merged, CI will run automatically on subsequent PRs that you send from the same GitHub account.

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

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