public inbox for linux-i3c@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Fix paths unexpectedly returning Mx error codes
@ 2026-03-08 16:47 Jorge Marques
  2026-03-08 16:47 ` [PATCH 1/5] i3c: master: Move rstdaa error suppression Jorge Marques
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Jorge Marques @ 2026-03-08 16:47 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>
---
Jorge Marques (5):
      i3c: master: Move rstdaa error suppression
      i3c: master: Move entdaa error suppression
      i3c: master: Move bus_init error suppression
      i3c: master: Negative error codes at send_ccc_cmd
      i3c: master: adi: Return xfer->ret at send CCC

 drivers/i3c/master.c                 | 62 +++++++++++++++++++++---------------
 drivers/i3c/master/adi-i3c-master.c  |  5 ++-
 drivers/i3c/master/i3c-master-cdns.c |  2 +-
 3 files changed, 39 insertions(+), 30 deletions(-)
---
base-commit: df8d8e0a9edaec6f1083870f8fb6724e9c663508
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] 17+ messages in thread

end of thread, other threads:[~2026-03-12 15:50 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-08 16:47 [PATCH 0/5] Fix paths unexpectedly returning Mx error codes Jorge Marques
2026-03-08 16:47 ` [PATCH 1/5] i3c: master: Move rstdaa error suppression Jorge Marques
2026-03-09 11:39   ` Adrian Hunter
2026-03-09 12:17     ` Jorge Marques
2026-03-09 12:34       ` Adrian Hunter
2026-03-10  8:05         ` Jorge Marques
2026-03-10 19:13           ` Adrian Hunter
2026-03-10 19:13   ` Adrian Hunter
2026-03-08 16:47 ` [PATCH 2/5] i3c: master: Move entdaa " Jorge Marques
2026-03-10 19:13   ` Adrian Hunter
2026-03-08 16:47 ` [PATCH 3/5] i3c: master: Move bus_init " Jorge Marques
2026-03-10 19:14   ` Adrian Hunter
2026-03-08 16:47 ` [PATCH 4/5] i3c: master: Negative error codes at send_ccc_cmd Jorge Marques
2026-03-10 19:14   ` Adrian Hunter
2026-03-08 16:47 ` [PATCH 5/5] i3c: master: adi: Return xfer->ret at send CCC Jorge Marques
2026-03-10 19:15   ` Adrian Hunter
2026-03-12 15:50     ` Jorge Marques

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