Skip to contentSkip to conversation

i3c: dw: reduce do_daa time if there's no client

PATCH Superseded Jisheng Zhang 3 participants 3 messages Aug 14 – Aug 18

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i3c: dw: reduce do_daa time if there's no client

dw_i3c_master_daa() derives the number of newly assigned dynamic addresses from cmd->rx_len, the ISR sets it to the number of address slots ENTDAA left unassigned. It starts out as zero, which already means "every address was assigned", so a timed out transfer leaves that value in place and it gets used as a result.

If there's no client connected, the addr assign cmd times out, then the driver calls i3c_master_add_i3c_dev_locked() to add devices that are not there, each costing about 1s, thus adds non necessary boot time up to (maxdev * 1)s.

Start from maxdevs instead: no address is assigned before ENTDAA runs, and make newdevs as 0 if the existing rx_len >= maxdevs.

---

since v1:
- use another method to remove the non-necessary calling of i3c_master_add_i3c_dev_locked() if there's no client
- update commit msg

 drivers/i3c/master/dw-i3c-master.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/i3c/master/dw-i3c-master.c +5 -1
index 1053cfb05c05..883b542c7bfc 100644
@@ -876,6 +876,7 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
 		goto rpm_out;
 	}
 	cmd = &xfer->cmds[0];
+	cmd->rx_len = master->maxdevs;
 	cmd->cmd_hi = COMMAND_PORT_TRANSFER_ARG;
 	cmd->cmd_lo = COMMAND_PORT_DEV_COUNT(master->maxdevs - pos) |
 		      COMMAND_PORT_DEV_INDEX(pos) |
@@ -888,7 +889,10 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
 	if (!wait_for_completion_timeout(&xfer->comp, XFER_TIMEOUT))
 		dw_i3c_master_dequeue_xfer(master, xfer);
 
-	newdevs = GENMASK(master->maxdevs - cmd->rx_len - 1, 0);
+	if (cmd->rx_len >= master->maxdevs)
+		newdevs = 0;
+	else
+		newdevs = GENMASK(master->maxdevs - cmd->rx_len - 1, 0);
 	newdevs &= ~olddevs;
 
 	for (pos = 0; pos < master->maxdevs; pos++) {
Signature · 1 line
2.51.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Jisheng Zhang

dw_i3c_master_daa() derives the number of newly assigned dynamic addresses from cmd->rx_len, the ISR sets it to the number of address slots ENTDAA left unassigned. It starts out as zero, which already means "every address was assigned", so a timed out transfer leaves that value in place and it gets used as a result.

If there's no client connected, the addr assign cmd times out, then the driver calls i3c_master_add_i3c_dev_locked() to add devices that are not there, each costing about 1s, thus adds non necessary boot time up to (maxdev * 1)s.

Quoted 5 lines

Start from maxdevs instead: no address is assigned before ENTDAA runs, and make newdevs as 0 if the existing rx_len >= maxdevs.

---

Quoted 36 lines

since v1:
- use another method to remove the non-necessary calling of i3c_master_add_i3c_dev_locked() if there's no client
- update commit msg

 drivers/i3c/master/dw-i3c-master.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/i3c/master/dw-i3c-master.c +5 -2
index 1053cfb05c05..883b542c7bfc 100644
@@ -876,6 +876,7 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
 		goto rpm_out;
 	}
 	cmd = &xfer->cmds[0];
+	cmd->rx_len = master->maxdevs;
 	cmd->cmd_hi = COMMAND_PORT_TRANSFER_ARG;
 	cmd->cmd_lo = COMMAND_PORT_DEV_COUNT(master->maxdevs - pos) |
 		      COMMAND_PORT_DEV_INDEX(pos) |
@@ -888,7 +889,10 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
 	if (!wait_for_completion_timeout(&xfer->comp, XFER_TIMEOUT))
 		dw_i3c_master_dequeue_xfer(master, xfer);
 
-	newdevs = GENMASK(master->maxdevs - cmd->rx_len - 1, 0);
+	if (cmd->rx_len >= master->maxdevs)
+		newdevs = 0;
+	else
+		newdevs = GENMASK(master->maxdevs - cmd->rx_len - 1, 0);
 	newdevs &= ~olddevs;
 
 	for (pos = 0; pos < master->maxdevs; pos++) {
--

2.51.0

#2 lore raw
In reply to Jisheng Zhang

Hi Jisheng,

Quoted 17 lines · Jisheng Zhang

dw_i3c_master_daa() derives the number of newly assigned dynamic addresses from cmd->rx_len, the ISR sets it to the number of address slots ENTDAA left unassigned. It starts out as zero, which already means "every address was assigned", so a timed out transfer leaves that value in place and it gets used as a result.

If there's no client connected, the addr assign cmd times out, then the driver calls i3c_master_add_i3c_dev_locked() to add devices that are not there, each costing about 1s, thus adds non necessary boot time up to (maxdev * 1)s.

Start from maxdevs instead: no address is assigned before ENTDAA runs, and make newdevs as 0 if the existing rx_len >= maxdevs.

---

Quoted 8 lines

since v1:
- use another method to remove the non-necessary calling of i3c_master_add_i3c_dev_locked() if there's no client
- update commit msg

 drivers/i3c/master/dw-i3c-master.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

You'd have to rebase this one on i3c/next as it doesn't apply cleanly anymore.

Quoted 27 lines
drivers/i3c/master/dw-i3c-master.c +5 -1
index 1053cfb05c05..883b542c7bfc 100644
@@ -876,6 +876,7 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
 		goto rpm_out;
 	}
 	cmd = &xfer->cmds[0];
+	cmd->rx_len = master->maxdevs;
 	cmd->cmd_hi = COMMAND_PORT_TRANSFER_ARG;
 	cmd->cmd_lo = COMMAND_PORT_DEV_COUNT(master->maxdevs - pos) |
 		      COMMAND_PORT_DEV_INDEX(pos) |
@@ -888,7 +889,10 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
 	if (!wait_for_completion_timeout(&xfer->comp, XFER_TIMEOUT))
 		dw_i3c_master_dequeue_xfer(master, xfer);
 
-	newdevs = GENMASK(master->maxdevs - cmd->rx_len - 1, 0);
+	if (cmd->rx_len >= master->maxdevs)
+		newdevs = 0;
+	else
+		newdevs = GENMASK(master->maxdevs - cmd->rx_len - 1, 0);
 	newdevs &= ~olddevs;
 
 	for (pos = 0; pos < master->maxdevs; pos++) {
Signature · 1 line
2.51.0
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com