Skip to content

Commit 49775af

Browse files
gastmaieralexandrebelloni
authored andcommitted
i3c: master: Move bus_init error suppression
Prepare to fix improper Mx positive error propagation in later commits by handling Mx error codes where the i3c_ccc_cmd command is allocated. The CCC DISEC to broadcast address is invoked with i3c_master_enec_disec_locked() and yields error I3C_ERROR_M2 if there are no devices active on the bus. This is expected at the bus initialization stage, where it is not known yet that there are no active devices on the bus. Add bool suppress_m2 argument to i3c_master_enec_disec_locked() and update the call site at i3c_master_bus_init() with the exact corner case to not require propagating positive Mx error codes. Other call site should not suppress the error code, for example, if a driver requests to peripheral to disable events and the transfer is not acknowledged, this is an error and should not proceed. Reviewed-by: Frank Li <Frank.Li@nxp.com> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Jorge Marques <jorge.marques@analog.com> Link: https://patch.msgid.link/20260323-ad4062-positive-error-fix-v3-3-30bdc68004be@analog.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent 42247ff commit 49775af

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

drivers/i3c/master.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,8 @@ int i3c_master_entdaa_locked(struct i3c_master_controller *master)
10861086
EXPORT_SYMBOL_GPL(i3c_master_entdaa_locked);
10871087

10881088
static int i3c_master_enec_disec_locked(struct i3c_master_controller *master,
1089-
u8 addr, bool enable, u8 evts)
1089+
u8 addr, bool enable, u8 evts,
1090+
bool suppress_m2)
10901091
{
10911092
struct i3c_ccc_events *events;
10921093
struct i3c_ccc_cmd_dest dest;
@@ -1106,6 +1107,9 @@ static int i3c_master_enec_disec_locked(struct i3c_master_controller *master,
11061107
ret = i3c_master_send_ccc_cmd_locked(master, &cmd);
11071108
i3c_ccc_cmd_dest_cleanup(&dest);
11081109

1110+
if (suppress_m2 && ret && cmd.err == I3C_ERROR_M2)
1111+
ret = 0;
1112+
11091113
return ret;
11101114
}
11111115

@@ -1126,7 +1130,7 @@ static int i3c_master_enec_disec_locked(struct i3c_master_controller *master,
11261130
int i3c_master_disec_locked(struct i3c_master_controller *master, u8 addr,
11271131
u8 evts)
11281132
{
1129-
return i3c_master_enec_disec_locked(master, addr, false, evts);
1133+
return i3c_master_enec_disec_locked(master, addr, false, evts, false);
11301134
}
11311135
EXPORT_SYMBOL_GPL(i3c_master_disec_locked);
11321136

@@ -1147,7 +1151,7 @@ EXPORT_SYMBOL_GPL(i3c_master_disec_locked);
11471151
int i3c_master_enec_locked(struct i3c_master_controller *master, u8 addr,
11481152
u8 evts)
11491153
{
1150-
return i3c_master_enec_disec_locked(master, addr, true, evts);
1154+
return i3c_master_enec_disec_locked(master, addr, true, evts, false);
11511155
}
11521156
EXPORT_SYMBOL_GPL(i3c_master_enec_locked);
11531157

@@ -2134,11 +2138,14 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)
21342138
goto err_bus_cleanup;
21352139
}
21362140

2137-
/* Disable all slave events before starting DAA. */
2138-
ret = i3c_master_disec_locked(master, I3C_BROADCAST_ADDR,
2139-
I3C_CCC_EVENT_SIR | I3C_CCC_EVENT_MR |
2140-
I3C_CCC_EVENT_HJ);
2141-
if (ret && ret != I3C_ERROR_M2)
2141+
/*
2142+
* Disable all slave events before starting DAA. When no active device
2143+
* is on the bus, returns Mx error code M2, this error is ignored.
2144+
*/
2145+
ret = i3c_master_enec_disec_locked(master, I3C_BROADCAST_ADDR, false,
2146+
I3C_CCC_EVENT_SIR | I3C_CCC_EVENT_MR |
2147+
I3C_CCC_EVENT_HJ, true);
2148+
if (ret)
21422149
goto err_bus_cleanup;
21432150

21442151
/*

0 commit comments

Comments
 (0)