[PATCH v3 0/5] Fix paths unexpectedly returning Mx error codes
From: Jorge Marques
Date: Mon Mar 23 2026 - 12:35:57 EST
A smatch warning on the iio/adc/ad4062.c driver raised that many i3c
methods that documented returning "0 on success or negative error code"
but actually propagate positive Mx error codes (I3C_ERROR_M0=1, M1=2,
M2=3) from i3c_master_send_ccc_cmd_locked().
Close paths returning positive Mx error codes when 0 for success or
negative error code otherwise are explicitly stated, ambiguous or
expected.
If any Mx error code is present, for each controller:
- adi: returns -EIO
- cdns: returns -EIO
- dw:
- RESPONSE_ERROR_IBA_NACK -> I3C_ERROR_M2 : returns -EIO
- RESPONSE_ERROR_ADDRESS_NACK : returns -EINVAL
- renesas :
- NRSPQP_ERROR_IBA_NACK : returns -EIO
- NRSPQP_ERROR_ADDRESS_NACK : returns -EINVAL
- svc : Unclear ret value, but cmd->err = I3C_ERROR_M2 for any ret
Each i3c_master_send_ccc_cmd_locked caller handles cmd->err directly.
There are three exceptions all related to the bus initialization:
* RSTDAA -> i3c_master_rstdaa_locked
* ENTDAA -> i3c_master_entdaa_locked
* DISEC (broadcast address only) -> i3c_master_enec_disec_locked
For direct enable ibi, disable ibi to a target, error code M2 should not
be suppressed, the device must acknowledge it.
The patch series start with moving the error check suppressions, then
does the actual change in i3c_master_send_ccc_cmd_locked to return
0 on success or negative error code otherwise (drops the positive Mx
error codes). Then ends with returning the xfer->err at
adi_i3c_master_end_xfer_locked.
The series was tested with adi-i3c-master.c and iio/adc/ad4062.c.
Link: https://lore.kernel.org/linux-iio/aYXvT5FW0hXQwhm_@stanley.mountain/
Signed-off-by: Jorge Marques <jorge.marques@xxxxxxxxxx>
---
Changes in v3:
- At mutitple commits: 'Prepares to fix' -> 'Prepare to fix'
- Remove no longer needed {}.
- Add () to i3c_master_send_ccc_cmd_locked at commit message.
- Fixup commit text wrap.
- List the titles of the prerequisite patches for the fix at the
"Fix error codes at send_ccc_cmd" commit.
- Link to v2: https://lore.kernel.org/r/20260312-ad4062-positive-error-fix-v2-0-1c933b5c7ed8@xxxxxxxxxx
Changes in v2:
- Restore rstret to continue to do_daa on any RSTDAA error.
Note 1:
This patch also solves
mipi-i3c-hci/code.c@i3c_hci_resume_common returning positive error
code at dev_err, since the Mx error codes are not propagated to ret.
Note 2:
It is safe to do the DAA again on devices that lost power
(hibernation, ...) but already had the driver probed, since the PID
is unique and i3c_master_search_i3c_dev_duplicate() searches and
recovers the previous instance.
- Update the commit messages to explain the commits that prepare for the
actual fix commit.
- Move premature method return documentation change to fix commit.
- Link to v1: https://lore.kernel.org/r/20260308-ad4062-positive-error-fix-v1-0-72d3c5290b4a@xxxxxxxxxx
---
Jorge Marques (5):
i3c: master: Move rstdaa error suppression
i3c: master: Move entdaa error suppression
i3c: master: Move bus_init error suppression
i3c: master: Fix error codes at send_ccc_cmd
i3c: master: adi: Fix error propagation for CCCs
drivers/i3c/master.c | 70 +++++++++++++++++++-----------------
drivers/i3c/master/adi-i3c-master.c | 5 ++-
drivers/i3c/master/i3c-master-cdns.c | 2 +-
3 files changed, 41 insertions(+), 36 deletions(-)
---
base-commit: abaa7682a784a0ba4ddebb08a46ed8b76859d1e6
change-id: 20260305-ad4062-positive-error-fix-dc833cd2f088
Best regards,
--
Jorge Marques <jorge.marques@xxxxxxxxxx>