public inbox for linux-i3c@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Fix paths unexpectedly returning Mx error codes
@ 2026-03-12 16:38 Jorge Marques
  2026-03-12 16:38 ` [PATCH v2 1/5] i3c: master: Move rstdaa error suppression Jorge Marques
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Jorge Marques @ 2026-03-12 16:38 UTC (permalink / raw)
  To: Alexandre Belloni, Frank Li, Przemysław Gaj
  Cc: linux-i3c, linux-kernel, Dan Carpenter, Jonathan Cameron,
	Jorge Marques

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@analog.com>
---
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@analog.com

---
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                 | 67 ++++++++++++++++++++----------------
 drivers/i3c/master/adi-i3c-master.c  |  5 ++-
 drivers/i3c/master/i3c-master-cdns.c |  2 +-
 3 files changed, 40 insertions(+), 34 deletions(-)
---
base-commit: abaa7682a784a0ba4ddebb08a46ed8b76859d1e6
change-id: 20260305-ad4062-positive-error-fix-dc833cd2f088

Best regards,
-- 
Jorge Marques <jorge.marques@analog.com>


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-03-23 16:05 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 16:38 [PATCH v2 0/5] Fix paths unexpectedly returning Mx error codes Jorge Marques
2026-03-12 16:38 ` [PATCH v2 1/5] i3c: master: Move rstdaa error suppression Jorge Marques
2026-03-13 18:43   ` Adrian Hunter
2026-03-18 14:16   ` Frank Li
2026-03-12 16:38 ` [PATCH v2 2/5] i3c: master: Move entdaa " Jorge Marques
2026-03-13 18:43   ` Adrian Hunter
2026-03-18 14:17   ` Frank Li
2026-03-12 16:38 ` [PATCH v2 3/5] i3c: master: Move bus_init " Jorge Marques
2026-03-13 18:45   ` Adrian Hunter
2026-03-18 14:18   ` Frank Li
2026-03-12 16:38 ` [PATCH v2 4/5] i3c: master: Fix error codes at send_ccc_cmd Jorge Marques
2026-03-13 18:45   ` Adrian Hunter
2026-03-23 16:04     ` Jorge Marques
2026-03-18 14:27   ` Frank Li
2026-03-23 16:04     ` Jorge Marques
2026-03-12 16:38 ` [PATCH v2 5/5] i3c: master: adi: Fix error propagation for CCCs Jorge Marques
2026-03-12 19:58   ` Frank Li
2026-03-13 18:46   ` Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox