From nobody Tue Nov 26 04:38:49 2024 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2044.outbound.protection.outlook.com [40.107.21.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB9D8199FAF for ; Mon, 21 Oct 2024 15:45:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729525532; cv=fail; b=JsB6H60VYnV/aZbsnvgsrA+TkLW0DQPYPk1zqB0TPz+3zBDRUj134hg0ZQmpRgoXqOBu25F59boocHGyg5Cx+/vCvHoyZMXsynMIl2gYv/wKS/C+Ck9XQHbfvkHh7KPPRo6bZzpys6wi1pDQlTg6HzO/vgQi4F1Lt1dGJ/jRwKM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729525532; c=relaxed/simple; bh=RF+K6k5hNWi6XLW985uClu+rYjI9LQWRNm31Nm82054=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=FKEedEKJxJpx3Nj4ZMBf2s/aDfeCwgdPAK90FC08LApa6cZ8YrxvJfSUDAqXlYbbgIftgLvigdJ2eFjHjme5zKUcYPNHT5yt8jx6fM0RSW+spnxdF1VWlShFr+8NihRktUcjtndQZjhI+S8sTB0A2tCLvYASdCcDFIgpfoiCWs8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=OROyzr2D; arc=fail smtp.client-ip=40.107.21.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="OROyzr2D" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NMvHCILlRHLfrCswfDoV5fVIYGAX3vzTrCsmCnf/4F+MQe1x/ZXIRmr1r1Z0j1ruqDwtGlpQa6KdlebHmTIF5NxUpUnLACRDq1rys8YALMafYWdeMs0VcIdY7EMv7wDfFMByUbPtK6y+qBjqT+FANrWCufik0TduwcAlZA2O56ID3WmpF+6m2GM/HCIB8toBPUrbgYC/nZm6alPSOeJBhYG+xMQcEyrlsBiG1j+/74GA1hCpAZmRsRN/wieq2bD2/DO7sdawyZWG4QUImWXqLCp4y7cQrUr+Lh0gBsYSSVCTwSXgGuAjO9qg/PknZ/jw8ZCu3pvIe8pcBpxtG8fzag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7eZFESgy2A7HhzoaZNK6yCDosWtkgT9dE8V/zsOlrEI=; b=N+OaA9WZ6mTTErHb5pV6JO2hmpjNLOHBRqIXDkHWwOP4HqWZo89cpuCJy/Hq6Zws8bGRU7WlZwGVu0avEYKh+RGJKaN/A848YQnMdfBXNNsdfzevSHRfMZ5OzB7HQgvZbO3rqCi1eqFh+16DEqScbsMgMe7RS1JEfu0ewNwc9gSYKi55c4edo+I1HeD7LI/V93gIebCDQYysV/VFq2lYGVUhFC9FcxuQuEHEXkIR6cYVHnZFCBqstRELiqZ7KBDBOIuFzTHa0u2r9J8+XBdopcR1nXaciX1Mg+QSivwMJnXtz52twkQmv9WzKOFpgTO8xkKTQTMe2D0W6vbCGgtFVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7eZFESgy2A7HhzoaZNK6yCDosWtkgT9dE8V/zsOlrEI=; b=OROyzr2Dc5uOjVlcIg8dvyBMxM67HEU+lJ7E0DJ0x93xiyWCPsfBKbb0ixuivUSfpij9R9th7qAcGzNyjVZPuo2ttgtoWCCoNnQWhgl/XseoPwwwYBtcSZc88J0CpeIHF3awuwC1Y+8KGSGlk/9stVoitKu21UWcjgD2jcjglPrBMi3fjk4Az39MSK+AcBtigle6evFn3zUaidvkz2j9GLiQvQ4Y1jkpzT9/uDBOJCy3BjU5RnQEfBur4lIQ+1ybK4U9pqJ9Qo3rZidMnozWVBcaHI1+NLRupeMxIZS5lps14yte49TPUcjwpkelA3hYhS47kyjXFB63r3b0ttc+Sg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) by PAXPR04MB9058.eurprd04.prod.outlook.com (2603:10a6:102:231::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Mon, 21 Oct 2024 15:45:26 +0000 Received: from DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d]) by DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d%3]) with mapi id 15.20.8069.018; Mon, 21 Oct 2024 15:45:26 +0000 From: Frank Li Date: Mon, 21 Oct 2024 11:45:06 -0400 Subject: [PATCH v8 1/3] i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241021-i3c_dts_assign-v8-1-4098b8bde01e@nxp.com> References: <20241021-i3c_dts_assign-v8-0-4098b8bde01e@nxp.com> In-Reply-To: <20241021-i3c_dts_assign-v8-0-4098b8bde01e@nxp.com> To: Alexandre Belloni Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, bbrezillon@kernel.org, boris.brezillon@collabora.com, conor.culhane@silvaco.com, gregkh@linuxfoundation.org, imx@lists.linux.dev, miquel.raynal@bootlin.com, pthombar@cadence.com, ravindra.yashvant.shinde@nxp.com, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1729525518; l=2178; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=RF+K6k5hNWi6XLW985uClu+rYjI9LQWRNm31Nm82054=; b=CSxhsJyAOUE6ysMbYthQdcJruajKe3LuFbt9atMnCijWsJwGhdWDPW4SMM0DHjqyFeUZbl1u3 8vfBTnve4OKAnNCYpzAsJykbEx5joma9gYfqOWnTRw/AHkIvPm2F2db X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0006.namprd08.prod.outlook.com (2603:10b6:a03:100::19) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9626:EE_|PAXPR04MB9058:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a644a80-8d54-45fb-3a85-08dcf1e761c8 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|7416014|376014|1800799024|38350700014;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B?YnR0Wm9BemFTZ2Y0Rk1jby9sa2pRWVFCQlVhM3owN2JRVXVlSGRHR05Uandl?= =?utf-8?Q?RjTQKyYGXd5hsqGOHdRhD91XW5NPyCj8/QeiA=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9626.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(366016)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RkJ6bEFGVEhHVkxkdEZReXM3aTYwczRLMUI5dFdrMG9oY2lTSGtFR3d3bFBp?= =?utf-8?B?dWYvQk9hcTZzRTBraHUrTE91QXI3Nmk1bG9EODlDUTZINmd2aVFGdDZzbStt?= =?utf-8?B?cW83QWV6UFVlSXJqakV2aXJ5cm1CekRaMmRtMzJ2amFFZmZ2WVZ6VkluVTBz?= =?utf-8?B?YlFrWjlNaysxak9WdVJoc2tuTkVmcEFWOHVUZ1YyZ3B4eGh5OGNubWUzY2l5?= =?utf-8?B?MVdNZmN4djRLTDArWklwWkZYOHRDQlZGdnBzRTRoOFIzQ3QrUUloYmRxVnRl?= =?utf-8?B?ejBoamNEVkJHelZtQ05KOFNUQmNuTTR2d00rb3pQaVNPdlpnTXNpd0EvanhL?= =?utf-8?B?cDg3TmNYU3kreXhBSHpBZlVMUGpqNnk5ZmRlbWdXcWpzWk9VQ1JxTTZ4MmRM?= =?utf-8?B?MEVIRXF6dzdCaVRTeXJHOC81TWNRdnNIVy9ZbEZPWVc3b0xVZTNrRkpFY3ov?= =?utf-8?B?dUlrMEwvR1puMHI4NjVRNndpdHdqS2QxZEZpbTJ3cEZkRnNPNWp5dlRPck9O?= =?utf-8?B?dTBVZmVJRmdPRHR6K2R6cmV1bXZualRmOVBKbjg0ZitidTN5b0dkZFhFbUxl?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MUlKUXJmZUUra2dWbHU5OGttS3Y3?= =?utf-8?B?T3NRTjZuYmhScjBtV1J0a3JtMFRaNUFjRnIvTkVnVW5jTDVFNlFIaWdhWU9y?= =?utf-8?B?bTNiaitGVmtVTnhMMzlES2hlbHJwS0tRdUpGY0J5bnlsWWtpTUZWc0w4S3BL?= =?utf-8?B?T3BVVEM5Zk14L28xa0FHVUNyR09iS1pDSWVLVGRWVlBndG0vQnNXaytHUzRj?= =?utf-8?B?dTBySCtaL2dIVDhwWmgrT1o1YkZVOFh4Nzk3Sk1yZzBkcjgyY2NoUUUxdmtG?= =?utf-8?B?RXl1ZnRvRjZRUzJxOU03SWZFT2l3bE9rU2lrVmtrZWdtbTh2QVhac0h6SE1z?= =?utf-8?B?b2hZVGo1ZXdPTzYyZ1FiRXFOdWRtRndyOUlLNzNzYis1Q2t5TWZRajJ2cUVo?= =?utf-8?B?NVlYY2NMWkFldnlrTVRJcS84bExmWkFCdlFobFNLcHorSzdPNVYwbUZVbWZq?= =?utf-8?B?cVNlMlpmbWw5Q0xiYWdJaGNhbVhlbXlGY3VtNmhZa3dXVlRyNC83UUt2dzdK?= =?utf-8?B?bVVhTWZnTzlrMHloVXNmd2cxTG5mUlpobmlDWXBUKzQzSUt4ejBYVFppQWZu?= =?utf-8?B?REZka2E1a3pGOG9rR09OZWNjRWZjaE85YjlWVWRmdElsZGlzOFludEpqWGVI?= =?utf-8?Q?DOzR+qDxQfTkEteHuzcCsvEKE?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a644a80-8d54-45fb-3a85-08dcf1e761c8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 15:45:26.2442 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ChLOMTjXIkXrKNYuYVUuQ/6YYVRq8Z92E6rr/ZaTPeg28yF+f/CLYla+beBOHtBxfv+gCvyyCF43gx7nQDShpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9058 Replace the hardcoded value 2, which indicates 2 bits for I3C address status, with the predefined macro I3C_ADDR_SLOT_STATUS_BITS. Improve maintainability and extensibility of the code. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- Change from v6 to v8 - none Change from v5 to v6 - fix version, should start from v5 - add Miquel's review tag Change from v3 to v4 - rename to I3C_ADDR_SLOT_STATUS_BITS --- drivers/i3c/master.c | 4 ++-- include/linux/i3c/master.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 6f3eb710a75d6..dcf8d23c5941a 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -348,7 +348,7 @@ static enum i3c_addr_slot_status i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) { unsigned long status; - int bitpos =3D addr * 2; + int bitpos =3D addr * I3C_ADDR_SLOT_STATUS_BITS; =20 if (addr > I2C_MAX_ADDR) return I3C_ADDR_SLOT_RSVD; @@ -362,7 +362,7 @@ i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 a= ddr) static void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr, enum i3c_addr_slot_status status) { - int bitpos =3D addr * 2; + int bitpos =3D addr * I3C_ADDR_SLOT_STATUS_BITS; unsigned long *ptr; =20 if (addr > I2C_MAX_ADDR) diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 2a1ed05d5782a..2100547b2d8d2 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -313,6 +313,8 @@ enum i3c_addr_slot_status { I3C_ADDR_SLOT_STATUS_MASK =3D 3, }; =20 +#define I3C_ADDR_SLOT_STATUS_BITS 2 + /** * struct i3c_bus - I3C bus object * @cur_master: I3C master currently driving the bus. Since I3C is multi-m= aster @@ -354,7 +356,7 @@ enum i3c_addr_slot_status { struct i3c_bus { struct i3c_dev_desc *cur_master; int id; - unsigned long addrslots[((I2C_MAX_ADDR + 1) * 2) / BITS_PER_LONG]; + unsigned long addrslots[((I2C_MAX_ADDR + 1) * I3C_ADDR_SLOT_STATUS_BITS) = / BITS_PER_LONG]; enum i3c_bus_mode mode; struct { unsigned long i3c; --=20 2.34.1 From nobody Tue Nov 26 04:38:49 2024 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2061.outbound.protection.outlook.com [40.107.241.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71F2E1C579B for ; Mon, 21 Oct 2024 15:45:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729525536; cv=fail; b=iHVxKPbLCesH6Zg8KNqh5Fru3zM2DrXeaWyu2cLqWDw9y81GO0uA+huBMI6X0yqu9i/9+1Rl87EguFFFP0soqRWJN2zW9tNEKDQg0koeBocZh/MjnBcqi3b5X7OLQzAHqnZdx+eMOak0HW5wCR0omkw/STNGyqPc1rx6nSLtkws= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729525536; c=relaxed/simple; bh=pNrKcPmJml2hm0zxuno1cWhcRRjjWd0ga8g1A/LEMgk=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=rHKMJ2AUa6JV6i2WNH81HgwKtoevDMH+E+ftHIvj/QdpW8oOLmAMcpfHfcq+6wFoflsgWVnWpVfopcVjCNOfTMRL7eta7K21Wz5/XR9AEtsfpr2KSru606OGdOSM3TTMVd5u4FGJastiWTnn3+r2avxMTnPUk9+ybdHEnwuV0kM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=hTbxce0J; arc=fail smtp.client-ip=40.107.241.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="hTbxce0J" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YVPBvWnN4f03pjM/Vpwg+GA6o7NvcyTKDHOmPuW1P0rhmMzkxkV9Ahspfo7C10OPd729dU/u/6g1pXu+XFzfEk9vYI2u66Lpo81dSwg17nHQywwHXBpx4KLA1fFkxIR0EC+uh70RZmq9NtAjNxAS0I4VO3nN1weGQFHQOagdhI3IF5+NRnn3NsRiPCifqMXQrgoVje/M1SFRYOXemFvDSBGXy7GU2wJdGiTUIFrrlXZZxbje8mdfxOcIsFU/fqsTR/9ZVOb1K8rZL+C/SXBjfYdPY/cxIlMLPGZNEpHQziqJPPyFCK9xYRYTtoSfGKXNbO/hhS5JTNj53t5sYwZRBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SMTfyhaF+NaVodvwbB990saGjE+IF+XIqt/Z40FU9rI=; b=b0hmdhjS8auuTJQuCOJqHMaczV98uckbYvAUs0muGdd0CZL964auy3xz4/vkqx7sQpdU9S377zG9OH/AGL/aCYDH1orIopKrirdFvSSNn3FTcYDvkCi+sNxiQQgs0Do2HaUF4v7Thf05BXori4PiNhqQlVGWuRc3Y0lJwbjJ/NmookXgO3N3bKQBgtcYRq5aIcfomtVNC1ZANugEseZwF3MNUSzQp4SjFuWe6XLwgWwGZJHMHbaFP7r3prtpd7gyKqPSJ1/bTgpj8oksN+WlwrGU0dr1zdkwPcWr/sc/8zjmHCsGQ2wUBvZb5FU1SKS9YmIoztwBA8CF7Dsi57Ex4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SMTfyhaF+NaVodvwbB990saGjE+IF+XIqt/Z40FU9rI=; b=hTbxce0JKViYNIpjBAiQKnYk4O9npDjewlGjBSfdD0Wz+pQFs3MFYT5nMZVH6Y/fFEHq7WpErumgOLR7yqGlihEZBHBPHKtAqGXiKFr2w58CheHpja0XSP6nMAvYGmZMKD+zElvi8v0hqBRJE+RFZRWGExCs8bVHns9zhjPcaoW1NwfHOhM1gnx+i2PcoEWbeZKztThwEyRCN3wq0dVX0zhxBFIfaaoL+x1DKl/biaZjQc/HbYGLkWMEBTimeWFnRXP3Ctn2E65ZG6om+TtjB1K6h3/VlChgQWn7ZKpNtle+jj0QADtaH4FswB1UxUgwXcRvxtZcd9cLoeHZsXEM2A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) by AS8PR04MB8417.eurprd04.prod.outlook.com (2603:10a6:20b:3f9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 21 Oct 2024 15:45:29 +0000 Received: from DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d]) by DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d%3]) with mapi id 15.20.8069.018; Mon, 21 Oct 2024 15:45:29 +0000 From: Frank Li Date: Mon, 21 Oct 2024 11:45:07 -0400 Subject: [PATCH v8 2/3] i3c: master: Extend address status bit to 4 and add I3C_ADDR_SLOT_EXT_DESIRED Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241021-i3c_dts_assign-v8-2-4098b8bde01e@nxp.com> References: <20241021-i3c_dts_assign-v8-0-4098b8bde01e@nxp.com> In-Reply-To: <20241021-i3c_dts_assign-v8-0-4098b8bde01e@nxp.com> To: Alexandre Belloni Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, bbrezillon@kernel.org, boris.brezillon@collabora.com, conor.culhane@silvaco.com, gregkh@linuxfoundation.org, imx@lists.linux.dev, miquel.raynal@bootlin.com, pthombar@cadence.com, ravindra.yashvant.shinde@nxp.com, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1729525518; l=9603; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=pNrKcPmJml2hm0zxuno1cWhcRRjjWd0ga8g1A/LEMgk=; b=4aVbOiWH+etVflChU66wmDLzYDpbmx2Ut2aqRNwQpQWs0BkSomMuwHjfeBagw/r1xJlcA8d7b bkV8ucFB1MPA8069Ggb1PTpiPFWbY0qtoAaYJ+HC3eCXnG3VqGgn/Rg X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0006.namprd08.prod.outlook.com (2603:10b6:a03:100::19) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9626:EE_|AS8PR04MB8417:EE_ X-MS-Office365-Filtering-Correlation-Id: a838772f-7571-4255-6de2-08dcf1e763f4 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?aHZRT0ZZU1ArRHFxbW1DOTNyY1dzbVpKUjNaZmVld0ZWZmhnOURxazkraE1q?= =?utf-8?B?QUNtSkJ4RjRHeG92dW56WTZkT3NWL2hFc2Jtam5ySjdna0x4a01iR29qNkdY?= =?utf-8?B?MXBCaVVyZm54Smc3M1hZY0swZ1R0QU5xYWhBQzZrcXhxS3JLanY0dTljOStS?= =?utf-8?B?NFFjZWltWFZtdGwvcUFsMDAxL1RwUWJHQVBKTktRSG5VUGZReDM5UlVFL0RG?= =?utf-8?B?SXJjNW9ZVGRwbExlOHlDZGVsd1J1aFBNWjlPWTJuTEMrRklJRnphZ3BGSEQ4?= =?utf-8?B?TkpaRFlQejRSVXZhVmJxekJpdkU4VmgzT3FhejVaQTNzbDFhN1JpMklBejEw?= =?utf-8?B?WHNQaUhzTUNUVElpeHI4VFR2MW5sNEpYdG1TdEtzODRTaVYvRWhRUDNGR3dR?= =?utf-8?B?VVZ4L0pmNDNyVHpwdWthVTFqeDdWU1lPR0RKWWNOdXZWcHdpUThBcllaSFky?= =?utf-8?B?eVh0ZTlzQTdhQmVEcEpXOTFNUlA1Z0wwUDcvczhyNDV6eXRqVW1IRlN1bGVS?= =?utf-8?B?a1lwcXVJbTVLWlJ4YkV1K1VjZU92WUk4WVVoMEtrUEFkOW84clV3aTFpRy93?= =?utf-8?B?UkNRUUhwQnFHSDByWGRybE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0hmTENjQzE3ZGZiU1Q0QzFpbmdMUDg3RS9SYmZiMWRsQVFpdWRHTlVrRW5y?= =?utf-8?B?YjBid3hLZ3FkQmYyRnBYaFJlVUhndUZDanZqMnNnQjd5UlNTdFovWnZvcFlM?= =?utf-8?B?b1FRbjgyLzZ1Tll3bnRKUEFhVnp3MExsUkRRSkpSUVNWak1mbXlINU80ZVZp?= =?utf-8?B?RndiNFBHbTNZSE5VbGpvZ2NvYUI3WkdjN2JrdTRCUkgzd2ppVkUrU3hIUmNT?= =?utf-8?B?WTlnWE4yQ1FEMm0xQTcwenNzQ0ZnbStkZml6NjAwZWMvVXlNSEFmZ1hMTklX?= =?utf-8?Q?3W8N7qiji1owyM+Mc27CxQTlCMQle5X6uzTXY=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9626.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MGZQZmlRcDRieU5PVmxpeldEZ2xiVmdLZVV0R1l5cVhXUng0bmZRRUNJVmo4?= =?utf-8?B?NVFyNllTRGJCanpFeHBOT2hYRWY4bTZJWTY2Q0VVang5aWFidzdyOUhVK1gv?= =?utf-8?B?MStQbHpJRkU3OVNkOWs2WjlBNUovMDlqVVhIQzk2aDYyYlZQdWx5bTk1RHcr?= =?utf-8?B?WGM4WWdxbDk3VndGMjZLcnhiKzhDNDlkYmJabUtPM2pmSjFZdnNFSlVvbklp?= =?utf-8?B?Y3lDMDNrKzZTeTVzSHZrUW8yUXNkRFYwQjROeHBOd2NJa084cU9rNXlPRGQ5?= =?utf-8?B?U1IzM2Qxcnk4ZktMQmRhOVhndEtnM2tZeS9xWHBvckwwNU5USFBOVG5GeTJl?= =?utf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= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a838772f-7571-4255-6de2-08dcf1e763f4 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 15:45:29.9071 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: H1r52cCXSSLarksp1LgaqTPX57g493gwhR0AsQV8FscRKkPBU3fOXaDJxEvJ+3iUgAMFyD3gqqk0FQrLp7gvtw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8417 Extend the address status bit to 4 and introduce the I3C_ADDR_SLOT_EXT_DESIRED macro to indicate that a device prefers a specific address. This is generally set by the 'assigned-address' in the device tree source (dts) file. =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=AC=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=AC=E2=94=80=E2=94=80=E2=94=80=E2=94=AC=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=AC=E2=94=80=E2=94=80=E2=94=80=E2=94=90 =E2=94=82S/Sr=E2=94=82 7'h7E RnW=3D0 =E2=94=82ACK=E2=94=82 ENTDAA =E2=94= =82 T =E2=94=9C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=B4=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=B4=E2=94=80=E2=94=80=E2=94=80=E2=94=B4=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=B4=E2=94=80=E2=94=80=E2=94=80=E2=94=98 =E2=94=82 =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=98 =E2=94=82 =E2=94=8C=E2=94=80=E2=94=80=E2=94=AC=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=AC=E2=94=80=E2=94=80=E2=94=80=E2=94=AC=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=AC=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=AC= =E2=94=80=E2=94=80=E2=94=80=E2=94=AC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 =E2=94=94=E2=94=80=E2=96=BA=E2=94=82Sr=E2=94=827'h7E RnW=3D1 =E2=94=82ACK= =E2=94=8248bit UID BCR DCR=E2=94=82Assign 7bit Addr=E2=94=82PAR=E2=94=82 AC= K/NACK=E2=94=82 =E2=94=94=E2=94=80=E2=94=80=E2=94=B4=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=B4=E2=94=80=E2=94=80=E2=94=80=E2=94=B4=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=B4=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=B4=E2=94= =80=E2=94=80=E2=94=80=E2=94=B4=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98 Some master controllers (such as HCI) need to prepare the entire above transaction before sending it out to the I3C bus. This means that a 7-bit dynamic address needs to be allocated before knowing the target device's UID information. However, some I3C targets may request specific addresses (called as "init_dyn_addr"), which is typically specified by the DT-'s assigned-address property. Lower addresses having higher IBI priority. If it is available, i3c_bus_get_free_addr() preferably return a free address that is not in the list of desired addresses (called as "init_dyn_addr"). This allows the device with the "init_dyn_addr" to switch to its "init_dyn_addr" when it hot-joins the I3C bus. Otherwise, if the "init_dyn_addr" is already in use by another I3C device, the target device will not be able to switch to its desired address. If the previous step fails, fallback returning one of the remaining unassigned address, regardless of its state in the desired list. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- Change from v7 to v8 - Add Miquel's review tag - align to (, fixed a checkpatch.pl --strict warning Change from v6 to v7 - always use i3c_bus_get_addr_slot_status_mask() in i3c_bus_get_free_addr - ((unsigned long)status & mask) in i3c_bus_set_addr_slot_status_mask() incase status bigger than mask; Change from v5 to v6 - fix version number, should start v5 - change to I3C_ADDR_SLOT_EXT_DESIRED - remove _ext function and direct use _mask function - rework commit message and comments according to Miqu=C3=A8l's feedback. - change mask type to u32 change from v3 to v4 - rewrite commit message and comment for i3c_bus_get_free_addr() --- drivers/i3c/master.c | 65 ++++++++++++++++++++++++++++++++++++++----= ---- include/linux/i3c/master.h | 7 +++-- 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index dcf8d23c5941a..1bf9cb138f77f 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -345,7 +345,7 @@ const struct bus_type i3c_bus_type =3D { EXPORT_SYMBOL_GPL(i3c_bus_type); =20 static enum i3c_addr_slot_status -i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) +i3c_bus_get_addr_slot_status_mask(struct i3c_bus *bus, u16 addr, u32 mask) { unsigned long status; int bitpos =3D addr * I3C_ADDR_SLOT_STATUS_BITS; @@ -356,11 +356,17 @@ i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16= addr) status =3D bus->addrslots[bitpos / BITS_PER_LONG]; status >>=3D bitpos % BITS_PER_LONG; =20 - return status & I3C_ADDR_SLOT_STATUS_MASK; + return status & mask; } =20 -static void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr, - enum i3c_addr_slot_status status) +static enum i3c_addr_slot_status +i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) +{ + return i3c_bus_get_addr_slot_status_mask(bus, addr, I3C_ADDR_SLOT_STATUS_= MASK); +} + +static void i3c_bus_set_addr_slot_status_mask(struct i3c_bus *bus, u16 add= r, + enum i3c_addr_slot_status status, u32 mask) { int bitpos =3D addr * I3C_ADDR_SLOT_STATUS_BITS; unsigned long *ptr; @@ -369,9 +375,14 @@ static void i3c_bus_set_addr_slot_status(struct i3c_bu= s *bus, u16 addr, return; =20 ptr =3D bus->addrslots + (bitpos / BITS_PER_LONG); - *ptr &=3D ~((unsigned long)I3C_ADDR_SLOT_STATUS_MASK << - (bitpos % BITS_PER_LONG)); - *ptr |=3D (unsigned long)status << (bitpos % BITS_PER_LONG); + *ptr &=3D ~((unsigned long)mask << (bitpos % BITS_PER_LONG)); + *ptr |=3D ((unsigned long)status & mask) << (bitpos % BITS_PER_LONG); +} + +static void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr, + enum i3c_addr_slot_status status) +{ + i3c_bus_set_addr_slot_status_mask(bus, addr, status, I3C_ADDR_SLOT_STATUS= _MASK); } =20 static bool i3c_bus_dev_addr_is_avail(struct i3c_bus *bus, u8 addr) @@ -383,13 +394,44 @@ static bool i3c_bus_dev_addr_is_avail(struct i3c_bus = *bus, u8 addr) return status =3D=3D I3C_ADDR_SLOT_FREE; } =20 +/* + * =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=AC=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=AC=E2=94=80=E2=94=80=E2=94=80=E2=94=AC=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=AC=E2=94=80=E2=94=80=E2=94=80=E2=94=90 + * =E2=94=82S/Sr=E2=94=82 7'h7E RnW=3D0 =E2=94=82ACK=E2=94=82 ENTDAA =E2= =94=82 T =E2=94=9C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 + * =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=B4=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=B4=E2=94=80=E2=94=80=E2=94=80=E2=94=B4=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=B4=E2=94=80=E2=94=80=E2=94=80=E2=94=98 =E2=94=82 + * =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=98 + * =E2=94=82 =E2=94=8C=E2=94=80=E2=94=80=E2=94=AC=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=AC=E2=94=80=E2=94=80=E2=94=80=E2=94=AC=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=AC= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =AC=E2=94=80=E2=94=80=E2=94=80=E2=94=AC=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 + * =E2=94=94=E2=94=80=E2=96=BA=E2=94=82Sr=E2=94=827'h7E RnW=3D1 =E2=94=82= ACK=E2=94=8248bit UID BCR DCR=E2=94=82Assign 7bit Addr=E2=94=82PAR=E2=94=82= ACK/NACK=E2=94=82 + * =E2=94=94=E2=94=80=E2=94=80=E2=94=B4=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=B4=E2=94=80=E2=94=80=E2=94=80=E2=94=B4=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=B4=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=B4=E2= =94=80=E2=94=80=E2=94=80=E2=94=B4=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98 + * Some master controllers (such as HCI) need to prepare the entire above = transaction before + * sending it out to the I3C bus. This means that a 7-bit dynamic address = needs to be allocated + * before knowing the target device's UID information. + * + * However, some I3C targets may request specific addresses (called as "in= it_dyn_addr"), which is + * typically specified by the DT-'s assigned-address property. Lower addre= sses having higher IBI + * priority. If it is available, i3c_bus_get_free_addr() preferably return= a free address that is + * not in the list of desired addresses (called as "init_dyn_addr"). This = allows the device with + * the "init_dyn_addr" to switch to its "init_dyn_addr" when it hot-joins = the I3C bus. Otherwise, + * if the "init_dyn_addr" is already in use by another I3C device, the tar= get device will not be + * able to switch to its desired address. + * + * If the previous step fails, fallback returning one of the remaining una= ssigned address, + * regardless of its state in the desired list. + */ static int i3c_bus_get_free_addr(struct i3c_bus *bus, u8 start_addr) { enum i3c_addr_slot_status status; u8 addr; =20 for (addr =3D start_addr; addr < I3C_MAX_ADDR; addr++) { - status =3D i3c_bus_get_addr_slot_status(bus, addr); + status =3D i3c_bus_get_addr_slot_status_mask(bus, addr, + I3C_ADDR_SLOT_EXT_STATUS_MASK); + if (status =3D=3D I3C_ADDR_SLOT_FREE) + return addr; + } + + for (addr =3D start_addr; addr < I3C_MAX_ADDR; addr++) { + status =3D i3c_bus_get_addr_slot_status_mask(bus, addr, + I3C_ADDR_SLOT_STATUS_MASK); if (status =3D=3D I3C_ADDR_SLOT_FREE) return addr; } @@ -1918,9 +1960,10 @@ static int i3c_master_bus_init(struct i3c_master_con= troller *master) goto err_rstdaa; } =20 - i3c_bus_set_addr_slot_status(&master->bus, - i3cboardinfo->init_dyn_addr, - I3C_ADDR_SLOT_I3C_DEV); + i3c_bus_set_addr_slot_status_mask(&master->bus, + i3cboardinfo->init_dyn_addr, + I3C_ADDR_SLOT_I3C_DEV | I3C_ADDR_SLOT_EXT_DESIRED, + I3C_ADDR_SLOT_EXT_STATUS_MASK); =20 /* * Only try to create/attach devices that have a static diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 2100547b2d8d2..6e5328c6c6afd 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -298,7 +298,8 @@ enum i3c_open_drain_speed { * @I3C_ADDR_SLOT_I2C_DEV: address is assigned to an I2C device * @I3C_ADDR_SLOT_I3C_DEV: address is assigned to an I3C device * @I3C_ADDR_SLOT_STATUS_MASK: address slot mask - * + * @I3C_ADDR_SLOT_EXT_DESIRED: the bitmask represents addresses that are p= referred by some devices, + * such as the "assigned-address" property in a device tree sourc= e. * On an I3C bus, addresses are assigned dynamically, and we need to know = which * addresses are free to use and which ones are already assigned. * @@ -311,9 +312,11 @@ enum i3c_addr_slot_status { I3C_ADDR_SLOT_I2C_DEV, I3C_ADDR_SLOT_I3C_DEV, I3C_ADDR_SLOT_STATUS_MASK =3D 3, + I3C_ADDR_SLOT_EXT_STATUS_MASK =3D 7, + I3C_ADDR_SLOT_EXT_DESIRED =3D BIT(2), }; =20 -#define I3C_ADDR_SLOT_STATUS_BITS 2 +#define I3C_ADDR_SLOT_STATUS_BITS 4 =20 /** * struct i3c_bus - I3C bus object --=20 2.34.1 From nobody Tue Nov 26 04:38:49 2024 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2061.outbound.protection.outlook.com [40.107.241.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5BFB1C6888 for ; Mon, 21 Oct 2024 15:45:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729525539; cv=fail; b=pF0VhUTiAnsAch6iTfSGqSu1JV4lDr+KzefVsdlMDt1E5KDQnRI8MWnNVxSHMdomhVWm+gUAMpKIUHBwwHZPHn9V6xkhD6SdiuIMAEZGNsTsFCxGgInrg+c/EmE2CeriWzPi6LcAR62nQudh+LVNr91zvsFgKeoEVAHJCmlMYtc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729525539; c=relaxed/simple; bh=Tya2XmHY6NH6zMFyqVEsaXc69z5sFxx57Xl7UdOsNx0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=uYWMlamZHOuvEVw7Xprnci70jbt660gZ6L568a293pooN3z6G6AFnfczM45icrnFYD78ElyXAWMIMfGzFQNJ+5YSKbG9Be/s43KmlHyZES3BaysJdgdHM5QNBFaT7/zBuDAlE2YlonzOE15C73B3hAaazxpH8n5wO7RcOxyKoVc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=G2fWNOls; arc=fail smtp.client-ip=40.107.241.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="G2fWNOls" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iZcII9FCjwEP1qJSybE1NGLzIEGTQpUhbQlu5I63NmQCIpzO/QakS7upxUaIEq1QZdERXQqtTqqBD4Djo5nMTHuRqepBfaY+D6hk5KAcY8OUW2RfU3M/lmJvJbR+07ZNsS7+lwDVJJs603xkhaSz5EPy+M53jf//DkrT664EAdw5tZn0pFfBUNJ23EvFzRnGBcg3tyHhCs5E38NW4WLIMRiBUpcVeao1rQvbH9bPhWFpiDZ3XmiOMsQEnYWE1jbt5RbnABnibi8TD1bRkTBmWa9wkS/HGgIwbQJkL47Pyq34P7tHABJuS0l555reLdtSOZxKZSTz14e1aYL9AMbI7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dKVFTv98vNzXpRySipXp/ftAZEd9KVV6pcUGJ8L1bP8=; b=AKqYkbbL88IwnXDO6FQqLk68ZFhOkJqzCZlqufAUQZG/cnO6A0go/Xp2LhIjUmRG8IMhDLBt5dDfHCkB/+aVVUyISpAiO/f3vmGemrABl1XoQTPyKGWZWotjj6YPTaMNv1RIoxxlngC0b8eS0dS4u9hc1iwWMVYZdEQ3SLaYGbDhov2SLBZ51QDJrWqhHGe1j2mHBWHT7hC+TOrn5Y7z/L+friuQJiKIpl67Rz/4KxeCo51GYWGxOQIpgikn6pZa/CW0diQdXaJiyEvz2HXTN5q/HDy2HG783MvnQ7zXpTGBU8rNH9XGHIwRUKkIk/qeNKtpglR+bbVEzBWcQDKOeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dKVFTv98vNzXpRySipXp/ftAZEd9KVV6pcUGJ8L1bP8=; b=G2fWNOlsNlgzshf7J6CNrViCxpF/aPO1y4YqrZkioT6UxG+Y7LbNQI974nyBfg+l2fHGZ/01obqmpbuWDHQnIlweyyg37s0m2GnQVD1G/O3wrGYODUVtmpI36AXMseHyaxsoJEyn8PutRYbxQN9gJLfPBb4h0cGQbSVzBTohx9ZuAnGPrzV2omBwbjk36mY3njxx/jAUYzbGujZdo8jR9GA9IZ5gEk8J9W5pXZ5bu9imYwH/byU6Xuerxvzfhc+yfs2TqV9BPHdpx0kOc/iw9Mpj8aaTFhB4s1wBZHrHfBwr+hITBm5mzmSQUP47w7yTSQddFNBbI4fOPoED1ppd0g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) by AS8PR04MB8417.eurprd04.prod.outlook.com (2603:10a6:20b:3f9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 21 Oct 2024 15:45:33 +0000 Received: from DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d]) by DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d%3]) with mapi id 15.20.8069.018; Mon, 21 Oct 2024 15:45:33 +0000 From: Frank Li Date: Mon, 21 Oct 2024 11:45:08 -0400 Subject: [PATCH v8 3/3] i3c: master: Fix dynamic address leak when 'assigned-address' is present Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241021-i3c_dts_assign-v8-3-4098b8bde01e@nxp.com> References: <20241021-i3c_dts_assign-v8-0-4098b8bde01e@nxp.com> In-Reply-To: <20241021-i3c_dts_assign-v8-0-4098b8bde01e@nxp.com> To: Alexandre Belloni Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, bbrezillon@kernel.org, boris.brezillon@collabora.com, conor.culhane@silvaco.com, gregkh@linuxfoundation.org, imx@lists.linux.dev, miquel.raynal@bootlin.com, pthombar@cadence.com, ravindra.yashvant.shinde@nxp.com, Frank Li , stable@kernel.org X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1729525518; l=3908; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Tya2XmHY6NH6zMFyqVEsaXc69z5sFxx57Xl7UdOsNx0=; b=t6uTeFEwP7Ozw7qXtZDcbwHfNdOoyijvYI/e8WeP5EgRYpwboouO+X2Yg5vOjfl/Rj351bRPB mvO5kv1BAwnCaW1CB1zFqBO1KRBqRgauMiCn7Cigk7cglFeDN+nG6xu X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0006.namprd08.prod.outlook.com (2603:10b6:a03:100::19) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9626:EE_|AS8PR04MB8417:EE_ X-MS-Office365-Filtering-Correlation-Id: bcc3e037-4722-4d2f-7751-08dcf1e76642 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?aW1Ga0NYeHpKTFloaWx0TDBvVjFXT2VINk9WbmhxS2JiZmpPVFlNZVpSRzFC?= =?utf-8?B?U3ptZWxlUEU5bUpCL0xMbmZOYkdCaGJBVzcvVXVLTmtPVnBJWGpGUHZEaCt3?= =?utf-8?B?SUlRdFFkR1hENXdXMzJSSWNRRDAyUGROQlcyVVc1bitEMGE1ZDFoNU5NSTNp?= =?utf-8?B?MkszUmxIc0pEcjFiV2hpUHlUSXRwdFJtZXpkWndJZWxHM1JmV0MyWkNVei80?= =?utf-8?B?NzBQeHdnRjlGVUtUTWlZNlc2UkYwNXFFcENBUlFrN0xkNWFZVWRJWTY1dHYr?= =?utf-8?B?KzFhak9OeUNKbnlobDZXT3F3TnBWUkhMMTdFRjVucEVWZlJZZUErcFA0Zzdn?= =?utf-8?B?SmVvQzFzYURmRWVBVjVmRGlmZ1hGWGNvKzZxd1N5VDRKaW9jRUE5eXd6cEJO?= =?utf-8?B?TjN3cmw0RGtRNUpPeGJaM3RSL1duTStCWDlzRUwwTzcwU1doaG1kajZjN3VR?= =?utf-8?B?NXFEbC8vQ2VTbmJPWThITkw5Y05OWERlQnYvUnluRk9zdHdTazEwNVZzOUJw?= =?utf-8?B?OGF4MVBHT0RGZGJpTk9TdGJ0RmEyZk9vZjJzeWFHK0Y0OG84QmkyTGxnRlVr?= =?utf-8?B?RnA2d2pjMFhNb25CTG9OT29hOTRSTlF2dUhudU9vMFoxam5VVEN5eVFyY0x5?= =?utf-8?B?bE1IM1R5NjZBUmREaUFFN04zemc0U2JIcGxnWnJhVktYUUNZelhTQm56MTgz?= =?utf-8?B?dWZKQ1VubjRVNjZsT0U1SFp4WGpFOTFhZWdlaFBYVzExREhMajNNUlFtYjV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NTlwMlowOUUv?= =?utf-8?B?Tzd4VGt0Mks5NUFDb05yZmUvWFNvdDZIUlhlRkE4dUdEUm9KZjhiNDRGc0J2?= =?utf-8?B?UGFmOXdUYjFxQUc5VlY3aUZRbTJwZ1VlQlMxaS9vSTNiVmltNFdMMHd1eDdJ?= =?utf-8?Q?mc5yXEzL8GvB3bBHXHor2IqoxkWMd51gyk8/Q=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9626.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?enhKZXR3bTRWdGdsa0N6UnQ4cFNkUllsbS8vd3NMK29zaWo1aldUWEp2cFFz?= =?utf-8?B?eEkzTEczajhpZm9XQTc0VENNTHpJRlJzdGwwcStXSFcvZUl5MTVnUjJFOTNs?= =?utf-8?B?TlgydEdwTUZjQ3R1SlE1WEV5RUdyYWozM0ZNL3VkN3ZhSlJrTWFaaS9wMTk5?= =?utf-8?B?RjJrRng0SkFyUm4raFo0cEZhYmRxc3dUMTVENW9Ka1RQQUFmU2hTUzNTa2tG?= =?utf-8?B?SFlCSDRxZ2ZIN2RUWWhFVGZ6ajI0TjMwQXE4aEhSSnRrbW01ZzRzZm5jSHRk?= =?utf-8?B?WWxZYm1zQm03cTBhdzY3ODJacDA4U3Z4aUNxbGFET1JsaHZZaGgvSyt6UXpV?= =?utf-8?B?d0VncTJHNUZOSmI5dFlKb3dqcmV4WkJJUEdCdmJtdVdTRCt4OHgwZStVRUZS?= =?utf-8?B?NlB2VDkwNXVDbXdFajFaRlRkcmFlT2N5Mk5La2VROWR4M0YzU0dDek0rL0sr?= =?utf-8?B?UldPVmpQbEgxYmNtaTgrek82WDVHU2l3OURCM2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ZjcU1wSTh6Q2QrckZZQkNU?= =?utf-8?B?MTdDMDNKZFNLeFMrVFhIUHVLVHdqQkJiQ3hjbzFkYllpbktJQWdOOVRyTEx4?= =?utf-8?B?eFRXdWZiYjZCSXI4Z0xUMlNUS1lVNU5JN0Q4Y2RxWm1IeHVERXZSNHAvajV2?= =?utf-8?B?OStIUTA2bFNMVTRaL3V3aGVxRTVkWjZvaFJlc25nMzFicHE1K2tZWFdyY0FD?= =?utf-8?B?L2tib2lCZW94M2VSUEg5K0pWVWpkNXByOUdVckVWbkFZT1pRY1BMYW1UUVcx?= =?utf-8?B?VXlHQmpLS1dUSTJkREZ3VjVjR3QvYlU5eXc2bnkvS25mWkloTzVtUnpxKytu?= =?utf-8?B?SXJxZE9STVlWbXc1L1V2Y0lkd2tpb0xZOXFqSGJmdGJ2TGxaN2tDVEJaKzUr?= =?utf-8?B?THJKMmhhV0w4b3lvTTZIbTBGRFlvdCtTL20wYTJxOWdaZE13OGQ4WlhweGhs?= =?utf-8?B?d1BkblNvUDV5NjM1SzBqSUY2SDg2N3JmVUxEQktqbXBmU2tUZjNlTG50bngw?= =?utf-8?B?TldkR2tWZFJpRDNrNGVHSC9mWHNOdjhPQVNFMDdoNkViZjFMak9ocnJlU2Ex?= =?utf-8?B?OW5NWFhNeUNQQkQxT1dKaWpYV3llZkY0THA1eDgvNC84WWN5cjhjRTI0K1Er?= =?utf-8?B?LzRnekJYN2xYaE5hQ0pFcjZYWHpwdmprMnMzUUFNV0E1Q0NKUDA4YkpJZkdh?= =?utf-8?Q?ReY2IByWqVgnvAMx8ztDsgWV3?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcc3e037-4722-4d2f-7751-08dcf1e76642 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 15:45:33.7812 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UvcSn+Fteg0Ld9qCCTMphcg28P9u2NjWLBPSSeS9b5oYXevIy6ikTWgWJeDenIINaqYotn40rw0Ehfqmz1bXcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8417 If the DTS contains 'assigned-address', a dynamic address leak occurs during hotjoin events. Assume a device have assigned-address 0xb. - Device issue Hotjoin - Call i3c_master_do_daa() - Call driver xxx_do_daa() - Call i3c_master_get_free_addr() to get dynamic address 0x9 - i3c_master_add_i3c_dev_locked(0x9) - expected_dyn_addr =3D newdev->boardinfo->init_dyn_addr (0xb); - i3c_master_reattach_i3c_dev(newdev(0xb), old_dyn_addr(0x9)); - if (dev->info.dyn_addr !=3D old_dyn_addr && ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0xb !=3D 0x9 -> TRUE (!dev->boardinfo || ^^^^^^^^^^^^^^^ -> FALSE dev->info.dyn_addr !=3D dev->boardinfo->init_dyn_addr)) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0xb !=3D 0xb -> FALSE ... i3c_bus_set_addr_slot_status(&master->bus, old_dyn_addr, I3C_ADDR_SLOT_FREE); ^^^ This will be skipped. So old_dyn_addr never free } - i3c_master_get_free_addr() will return increased sequence number. Remove dev->info.dyn_addr !=3D dev->boardinfo->init_dyn_addr condition chec= k. dev->info.dyn_addr should be checked before calling this function because i3c_master_setnewda_locked() has already been called and the target device has already accepted dyn_addr. It is too late to check if dyn_addr is free in i3c_master_reattach_i3c_dev(). Add check to ensure expected_dyn_addr is free before i3c_master_setnewda_locked(). Fixes: cc3a392d69b6 ("i3c: master: fix for SETDASA and DAA process") Cc: stable@kernel.org Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- Change from v7 to v8 - Add miquel review tag Chagne v6 to v7 - none Chagne v5 to v6 - fixed version number to v5 - fix merge conflict because change function name and macro name. Change v3 to v4 - none --- drivers/i3c/master.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 1bf9cb138f77f..5a089be7e0728 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1548,16 +1548,9 @@ static int i3c_master_reattach_i3c_dev(struct i3c_de= v_desc *dev, u8 old_dyn_addr) { struct i3c_master_controller *master =3D i3c_dev_get_master(dev); - enum i3c_addr_slot_status status; int ret; =20 - if (dev->info.dyn_addr !=3D old_dyn_addr && - (!dev->boardinfo || - dev->info.dyn_addr !=3D dev->boardinfo->init_dyn_addr)) { - status =3D i3c_bus_get_addr_slot_status(&master->bus, - dev->info.dyn_addr); - if (status !=3D I3C_ADDR_SLOT_FREE) - return -EBUSY; + if (dev->info.dyn_addr !=3D old_dyn_addr) { i3c_bus_set_addr_slot_status(&master->bus, dev->info.dyn_addr, I3C_ADDR_SLOT_I3C_DEV); @@ -1960,9 +1953,10 @@ static int i3c_master_bus_init(struct i3c_master_con= troller *master) goto err_rstdaa; } =20 + /* Do not mark as occupied until real device exist in bus */ i3c_bus_set_addr_slot_status_mask(&master->bus, i3cboardinfo->init_dyn_addr, - I3C_ADDR_SLOT_I3C_DEV | I3C_ADDR_SLOT_EXT_DESIRED, + I3C_ADDR_SLOT_EXT_DESIRED, I3C_ADDR_SLOT_EXT_STATUS_MASK); =20 /* @@ -2126,7 +2120,8 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_c= ontroller *master, else expected_dyn_addr =3D newdev->info.dyn_addr; =20 - if (newdev->info.dyn_addr !=3D expected_dyn_addr) { + if (newdev->info.dyn_addr !=3D expected_dyn_addr && + i3c_bus_get_addr_slot_status(&master->bus, expected_dyn_addr) =3D=3D = I3C_ADDR_SLOT_FREE) { /* * Try to apply the expected dynamic address. If it fails, keep * the address assigned by the master. --=20 2.34.1