lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20230915080204.2701640-1-aniketmaurya@google.com>
Date:   Fri, 15 Sep 2023 08:02:04 +0000
From:   Aniket <aniketmaurya@...gle.com>
To:     Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Jeremy Kerr <jk@...econstruct.com.au>,
        Joel Stanley <joel@....id.au>,
        "Uwe Kleine-König" 
        <u.kleine-koenig@...gutronix.de>
Cc:     linux-i3c@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Aniket <aniketmaurya@...gle.com>
Subject: [RFC] i3c: master: Simplify table prep for ENTDAA

Before ENTDAA, device address table is populated with
the dynamic addresses to be assigned to the discovered
devices.
Since these addresses are referenced using consecutive
indices of the table, simply get indices starting
from the last unused position of free_pos. Subsequent
positions are expected to be empty.

Signed-off-by: Aniket <aniketmaurya@...gle.com>
---
 The current way of preparing table seems unnecessarily compilcated.
 The device table index is incremented one by one, so we anyways assume
 that all positions are empty after the last occupied one. So we can
 omit those checks.
 drivers/i3c/master/dw-i3c-master.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index 9332ae5f6419..dbbc96bc1587 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -782,17 +782,15 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
 	struct dw_i3c_master *master = to_dw_i3c_master(m);
 	struct dw_i3c_xfer *xfer;
 	struct dw_i3c_cmd *cmd;
-	u32 olddevs, newdevs;
 	u8 p, last_addr = 0;
-	int ret, pos;
+	int ret, pos, start_idx, end_idx;
 
-	olddevs = ~(master->free_pos);
+	start_idx = dw_i3c_master_get_free_pos(master);
+	if (start_idx < 0)
+		return start_idx;
 
 	/* Prepare DAT before launching DAA. */
-	for (pos = 0; pos < master->maxdevs; pos++) {
-		if (olddevs & BIT(pos))
-			continue;
-
+	for (pos = start_idx; pos < master->maxdevs; pos++) {
 		ret = i3c_master_get_free_addr(m, last_addr + 1);
 		if (ret < 0)
 			return -ENOSPC;
@@ -811,15 +809,10 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
 	if (!xfer)
 		return -ENOMEM;
 
-	pos = dw_i3c_master_get_free_pos(master);
-	if (pos < 0) {
-		dw_i3c_master_free_xfer(xfer);
-		return pos;
-	}
 	cmd = &xfer->cmds[0];
 	cmd->cmd_hi = 0x1;
-	cmd->cmd_lo = COMMAND_PORT_DEV_COUNT(master->maxdevs - pos) |
-		      COMMAND_PORT_DEV_INDEX(pos) |
+	cmd->cmd_lo = COMMAND_PORT_DEV_COUNT(master->maxdevs - start_idx) |
+		      COMMAND_PORT_DEV_INDEX(start_idx) |
 		      COMMAND_PORT_CMD(I3C_CCC_ENTDAA) |
 		      COMMAND_PORT_ADDR_ASSGN_CMD |
 		      COMMAND_PORT_TOC |
@@ -829,13 +822,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);
-	newdevs &= ~olddevs;
+	end_idx = master->maxdevs - cmd->rx_len;
 
-	for (pos = 0; pos < master->maxdevs; pos++) {
-		if (newdevs & BIT(pos))
-			i3c_master_add_i3c_dev_locked(m, master->devs[pos].addr);
-	}
+	for (pos = start_idx; pos < end_idx; pos++)
+		i3c_master_add_i3c_dev_locked(m, master->devs[pos].addr);
 
 	dw_i3c_master_free_xfer(xfer);
 
-- 
2.42.0.459.ge4e396fd5e-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ