From nobody Wed Nov 27 16:44:21 2024 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011015.outbound.protection.outlook.com [52.101.70.15]) (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 4BFA31E0081 for ; Tue, 8 Oct 2024 15:18:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728400733; cv=fail; b=rt+O5Nz302HmQ3pS6QuP9zGDoB54QiB2ThgbWPa79MkkEhn56PuMLNsbxHylFgBBBqejn6EekQhCYTtPWB07ix/PJDrxO4GuYQUd2xdzOVdU88Ppfd9ovmlLoQDf6VrsE/lPHyOkOmNEN8Rae/1Zk0LAR7FwF35coK8MA12Zsbo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728400733; c=relaxed/simple; bh=mJQ2NVwjODXELkcDKNUIEYw/DZI0LGJGAQy+lGen7bE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=LDOR8qeqr0IzxFkJSxSrw3iv1/fWiN+s9D/bqiPge79thF1Q+3PbvVh5RWxNfs6qmpEbX8MxADk9keC8zZW92QK6tX4Yq9tylEDnE78aRNfgZBvvJ1g4cgBnckHEcGhfTyd31CnJbGrK1PVZQYjeseCG87Xz4XCYan+O3d1Srbo= 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=aDHwHjT6; arc=fail smtp.client-ip=52.101.70.15 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="aDHwHjT6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L2V2LYdcjEA0jgBTzCYfg8KcJF2zvjpDwo2mVgvhaSmCZKlUMQ0etZ2QyeZnexMjkKgmPUboBIiRKg/w1jsMAjXRMSM2ksreHo83yhMI3wpedEPsOeqRzaux6E3YkacWhEeQPKljlPz86VnSOPaRS1T7lf7gosqnoKxNkuSGhd3nswLwR3wXUokHk4p1dWSnJwt39H6xrB3WPLmU5Jk7x5wIsDMoQ9wqMB2VWmmFNDQFk/TxchVQqJYERSgvubPthgDQPLanL/T6xKG7w8awbp+qQdo8Yp/Vj5vEONm+EOtvKTceLRsQZ2NcBJa+Gqz6qPFGXuE8ueYIF9vvA/qVnA== 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=CtrMS8OXbe0qcYxmNRu2SlrZq9vhMYyZCg5B65vBMeY=; b=soocErKvx1hSo5ye/7oSqx8Y+s6/UooqD4cj5i35hKZSTz/a3KB9YZo62cQTGShfOjSyFcx+57tuh2TAjLUfHZyr8yuVeVCNoMPwirporRDydLcyxxl4qzJzwtDmDQ//WPnhRg7bRo+++TZAt9FZVXNydQU0udEySLUpbilqKU04GaagRN8yHqdmFMPOtkrmeOpMvcKNi6EQwhTAigFJvvZD1Y+PGVJvkfLBp9SOQAL/F5AvnSAQ/ZaANad6BoF4wZleZYrSM8k7hdMLXRwE2Eo0TjlJ4eRz+StH6M7qMxnvNWSVPFiJtdIoRvlyaOUTgyqBmGcfZCjXjTUClKI0MA== 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=CtrMS8OXbe0qcYxmNRu2SlrZq9vhMYyZCg5B65vBMeY=; b=aDHwHjT6R3oBw8A2rX3nt/STBxD1aODnZtXarkBNXrJnYeR7w1serANqLxLcPPqcngJgJXUI4lqXfgFEkiFM9GL/rt1tUOYWSsM7BiM0E2Y4VRGLpAn0OhpgF2WBXlUsFtXGI9ZiRD1+IQcMjhkcI3bp/ZOVgQ02DyYJYOuKXTsWjjeuh5jcucUePo9kf+L+CyjPI8auPAmqUucyjQjGwC3NgZBkfWtP87l4+Z150taaSsnPeY3EuOZHX0R9euH4TsCBqz5HTgVYqcMZQFx6oGh91u5JS9+tj1TGBvYzYoLdG6FZT/o9Qq58dUFNvkEHMgxbySHwgv1ZmZ8+5GIt7w== 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 DB8PR04MB7194.eurprd04.prod.outlook.com (2603:10a6:10:127::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Tue, 8 Oct 2024 15:18:47 +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.8026.019; Tue, 8 Oct 2024 15:18:47 +0000 From: Frank Li Date: Tue, 08 Oct 2024 11:18:24 -0400 Subject: [PATCH v7 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: <20241008-i3c_dts_assign-v7-1-96ec93d1f34c@nxp.com> References: <20241008-i3c_dts_assign-v7-0-96ec93d1f34c@nxp.com> In-Reply-To: <20241008-i3c_dts_assign-v7-0-96ec93d1f34c@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=1728400720; l=2178; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=mJQ2NVwjODXELkcDKNUIEYw/DZI0LGJGAQy+lGen7bE=; b=UnbOBSsYXxfymZwvnMKhf6Sj/J6XWt0gN36MJyZunF41KlP0gmWvL/QhEQ82FL183JmvlROKG 00ALDPU/NVyAP0Zf4eLkR/JyXjkaQxwKyAF7afIoDtL2fERVCQmqUcR X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR11CA0101.namprd11.prod.outlook.com (2603:10b6:a03:f4::42) To DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) 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_|DB8PR04MB7194:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e3c7333-6db8-4aa6-61d0-08dce7ac8156 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|52116014|376014|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?YmgxYk5jays4cWFad0t5Z0laTUxERHBqL2ZmVGxRMXRublZ2ejkyN0V4czlT?= =?utf-8?B?ZHM5dVZCRFB4Q1hwMmQ1ODlZMEZySEptRjA3ZkdiYmRsbnBsN0hvZkh4cVRU?= =?utf-8?B?eHlJNHloOGhza1M4WktRSVZxTHZJRHFaM2xZM0VxRDJ1MEptMnJaVng3ck9F?= =?utf-8?B?eXU0T2oxQm5uK3FJZnk3SnpXQjdoTmFQMkJJUlJMNkZBNVdUcGdoU0Vic3NW?= =?utf-8?B?ZmRLODRvbm80NzR6cFBsSk9XdFVXait5eU9rWTlCazdleE5sTnlIMXE4VlVm?= =?utf-8?B?V0hoNDhnbTFsNGtuVS85ZzRYSGczVUhUUWRKQ0ZnSGlUcHkyVUFLQmpoTXgr?= =?utf-8?B?WUlIQnJDR3I2eWJOUk1BdHVzNmhvTVg5eGN0bGZadWY1ZjAvQngyYnZPZDFp?= =?utf-8?B?MkhWSEw5NEozbzN1NExSWWc3cGwrY0RmR3pXVjVJUHZzNTdiOTZEVW56eTlN?= =?utf-8?B?b2NMWXVSSk01aEppUWJaaXJlSUt1L0RHS2d2d3dMbHFoMWludjZEYWVYR3o1?= =?utf-8?B?clNrcEhPblpvK08rL1djMXc0REl2dW1rb2RTTHJaSXpMdFZZVldsQkh2dGto?= =?utf-8?B?OXJDK1YyYXQyWmlQclNiUWRqWStQUnhTMEdKQmFHQWFjNktzQzZuRmlHNDJI?= =?utf-8?B?SzZTazRidE82WEd1dUdsdWFTQWtud3hXNHBZaTJ1M214VThwYVdBYWVQN0dv?= =?utf-8?B?RkVPMEFBdlduZk5HNzJxa1NsblNHZ1NNNDZzSldJdnlyYldWcHE2WE91dzdN?= =?utf-8?B?dFBsS0R3R1lKcVRiZU1OcGZQZktpb0tsbksweUtCWkFEZTNGVlVOTlhrU0xu?= =?utf-8?B?QjFwVWRLZ0ZrMnhBS0ZmZ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hQMmNaRUJSZXZZWHBvUFpMMHd4OE8xM1NORnZaSWZtdWI0OThucGFXdlpr?= =?utf-8?B?dDVGR3VpQjdtYW1Jd1Y3UT09?= 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)(52116014)(376014)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TlY2M3ZWUCtmQmlpcVM0Q3BzWDFvY2s2ekViU2xQTk1FODVLZHFEaEpXaUoz?= =?utf-8?B?cTIxaG1YUUE1aC9lb2Z1ZmRYL3cxY2Qwck5WYlJmN1U4bzhJOTEwQmgzN1Ez?= =?utf-8?B?VWVuYmFYMWlOYUVnNEFIN2M5czRSUmYrUGY5T1lFTTlrWTg0OUlEMENpMXFR?= =?utf-8?B?WVNZR3lWNjdkb1R4NGtUMmJvUjZ3L1l2ajdxdVA0S3BjUE1FdXZRSm52UFpQ?= =?utf-8?B?ZkpodU9VKzkzTW1iWTJOOUlxT2NBNldEVzZyMjNydDlNUUZMWGpGZFhBRndj?= =?utf-8?B?ZWNRRVJ0UlhESHVMTTVzV0VnbHRCSUxQY0J6MXUxVTJUaDdzVy9NVGxHcjlK?= =?utf-8?B?MGlNRFZOeFNNTnZ3YWh0VitqTks0RjRqMTIyZ25RRmQyYlNvRnBxdWNtbjdS?= =?utf-8?B?emdaMjlOeDBBM1B2UkJDaU1oQXFLWWhuZzNiTk1lQ0FMYVJPRTM3YWVVVm9I?= =?utf-8?B?Ym80TXMveFpZdGd3Q0FOWENtT25aUW1qWjVQWk43YnhDQ3ZmZDlYOVRWOGhx?= =?utf-8?B?VlI5MHNZQzlPcFd0dDJnbFJjZ3ZLVDYxS1I5cHZmT3krVjl5Ky9UTG9QY1d1?= =?ut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lFcW13a0d6b1Rn?= =?utf-8?B?c0RtUFhKYTRXUjVZOElKN1JJd3IzL0RjRDdZR3RQZ3o1NlFqOFNMSlBWN0Ix?= =?utf-8?B?WjZpSm1Wc2pPYmNyM1lRcGtnSzlZcThDZmdGWnQvQ0V0MGpFeU4rb0JFTjRh?= =?utf-8?B?eUp5eWNXaGZ2Z2dBblJDZklMby9Ic013dk1iek1Pbmk3MERKeGdvTUZwVjJn?= =?utf-8?B?Vjh6d050K0VvWFZ3YTJHK3VhZ0MveWJEZ0JGSUpnNnY1aGF0WUpxbVcxcTVL?= =?utf-8?B?T3hxakdIcnJjQm4yNlpoeGNKMVVwYWhMWTFPTnVQSzhlQ1ZpNmJ4UTBycFFC?= =?utf-8?B?ejRnR0xvZWRDVkxXbjZiYkY4NjRWU0tPNzJvUlZmNU1MVklxT1dhK3NpRVl4?= =?utf-8?B?cCtuY3h0ZlBvM056VVdVUW5OTXU5a2k3ZGZRTmU4V096UHZYUEVTRmVCeFow?= =?utf-8?B?a1hOS2UyS0pHQjk1aE82TEFsNjZxMmkyWjdFcW1EcDNUZXpqWXZQdmltdGM2?= =?utf-8?B?ejF4V0toSVk3clE2MSs4Rml1THJ2Z1lLVytzZm56OUI5eU81MURPWTdicWtN?= =?utf-8?B?ZlNrRHQ3aUJGK010VXpCQlpDTExGZXl3amxlZk50UkZuWEtIalN0R0xOcXlk?= =?utf-8?Q?ob74=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e3c7333-6db8-4aa6-61d0-08dce7ac8156 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9626.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2024 15:18:47.1137 (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: 1Yj42lLtg32gIdIQBoCSe6mwHyiSIugfzpGMYfpN7YT3u338H8Io7SMOIX4AiIQigdtMLWmi9PfWTfcuWLz9KA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7194 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 v7 - 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 Wed Nov 27 16:44:21 2024 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012011.outbound.protection.outlook.com [52.101.66.11]) (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 E7A591E04B7 for ; Tue, 8 Oct 2024 15:18:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728400737; cv=fail; b=MLsbZCrd5BDs3T/8Jh80j71MBp5nQq2gR2S50HSyz9u0HdtIl+97BjsfhHI8dwKz3kyGxB0ULmdProxgLq6l8GNq4GP+UdwpsXd0/6SQ26mVIPcigV/Hmg57VLkb21h6hnaNXx7WK14gp1YfZ88NFKmusFnfO5HsCgFRxEmKwr4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728400737; c=relaxed/simple; bh=DM49R5v8+YMNDR9//TMHOLBKzBjtV69ySuusFjVM3qY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=vAZOrXokIsqANpteRhQ2twXbpiFrpoHdByhg8yDpdI6Vm5pbiNR6cwuIXp0t3rGsdi8WjCFk5kQrYjez28bjNGfMaqp3h2TvyRjT5ElEt/mRC5UXxpSNvahpixu8MqPz2u281AP7ubGtF05sNbRz/YHykgIRIbI6X9LkZLfCoCY= 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=S0sc6oP+; arc=fail smtp.client-ip=52.101.66.11 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="S0sc6oP+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HGreRLiFMWsTP2plL6yEGXGK2OMRE/WOj5M4zmOfgrawzjqy9h/tKvFOHmsRarN4wzNjbUr3HwIr0vc54WEXJUJ1nMjmmCTTUv5gd9EHRFEcJM4qv68omoBYN5yAc+j7lUXVX9rxkUNTei8jmGCLtB2ntifBheRUHEaa1yf0pabExgKetgskufYIVGR0hMqIzAvBHP8oEyZ6I7n+3PCJMjN/1O0Sw98u506eDS3IFb0lXSn9pZeD93+qzaFSlB71MlsDDEkPLEGtf6v9Y9f3XEXNyMbf/g9el+Hoh4InEW8TObCo/3sSuHLxOfZNNsHDRZ8sCiwp7TObdhluz7Wf+g== 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=08TqXfMeHDz+1O9efCr97YY0qpO561DtJ9QcljgnDAw=; b=ARwXktwgsQdGZFloA04YHGUl17okMYFF2oyugjB+IO2o2xpBRw1I2aZDypsCTJyTRPw/e5ygmrNtY0Y8R37zyyifK7Ab8BCJe6t/Z5zrFWv+7fRf75g4BR4bOt7T361nRQ24r2xirLhJRC47V2r+fJWfxLmDzCbZPSY3bbW4rxWdcvdEKYsoiEHbpYFnCZFgENQZJtXTdUp3AtibZ63feeawCBEydQfbYckFz/SciJXxoqVFnCcTvRB5pfy4osM7j6ZTFz1uA5IryXLBu+wjrgiMt5249XpjpYvPliPvsvMieb/mctol0bxJpUik+yGlDu4UJeFdshskFU2LbkgJPA== 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=08TqXfMeHDz+1O9efCr97YY0qpO561DtJ9QcljgnDAw=; b=S0sc6oP+IiLDsmXL7w/UOdobBdHR2y3beiar0Hee0BJBRjAk36UriAGXAGU5Yik5xGybKXx0jPEa1KjtkNGNnfK7G10lcf5/sUbjsfoEuz3kPHLNzkeGoA/A0Wf7akDizIhNgKrflEoEXgDyg5vIoR/a8jdJFZ0k5claPReXE7h1blaO9sp3ea1Mb0GpeGjhg5bofOJ1MLZ4KGJ3TVdHIJ/gMSJFhc049tEeRKiHMzoY7Hp8ly7eNNR4hQlzpNYjySIokNKjbvosdS7xkEpyhjzyMCbaOHf9X+BFA6nsttealP6Cl/m2GUNdYJT//Ji9HNiKEJAIeMJh3dPq1IAEOQ== 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 GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Tue, 8 Oct 2024 15:18:50 +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.8026.019; Tue, 8 Oct 2024 15:18:50 +0000 From: Frank Li Date: Tue, 08 Oct 2024 11:18:25 -0400 Subject: [PATCH v7 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: <20241008-i3c_dts_assign-v7-2-96ec93d1f34c@nxp.com> References: <20241008-i3c_dts_assign-v7-0-96ec93d1f34c@nxp.com> In-Reply-To: <20241008-i3c_dts_assign-v7-0-96ec93d1f34c@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=1728400720; l=9439; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=DM49R5v8+YMNDR9//TMHOLBKzBjtV69ySuusFjVM3qY=; b=Y/5zhBvg8X6/Qsayadwo5NAKGThxoscxMRhH+p4wkb8KLg+9IwTPxgB5IvDzYkMViMwicvkBc aEgBOYryRubDxlAQ21oYyKlQGt/iMC68Szt/8mE1L4gZR772P74L46N X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR11CA0101.namprd11.prod.outlook.com (2603:10b6:a03:f4::42) To DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) 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_|GV1PR04MB9151:EE_ X-MS-Office365-Filtering-Correlation-Id: 75433974-652d-4c6e-05ad-08dce7ac835c 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|7416014|366016|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?ZXpkZlNTNER3dkxTUGd2Rm9sSm83czkyK2ZOc2xZMmlSZE0xVkU1bHJqcTRD?= =?utf-8?B?dFhabkcwNTRjNTdhMGFTMWoxdGRCVXorVS84Y3VCNmdOYmUwbU5oSFczUWpi?= =?utf-8?B?NzlNTUZuZS8rOFhiWEpoeVNWd2c0dzZ3VzV4MEg2dU1jSUNaZks3alYycGZh?= =?utf-8?B?SUxNSDZmdFJ3YjNUMjZMdnFha1dxZGtmYjhWaXRmNDBGY2l3dmQzUnI4cVRX?= =?utf-8?B?UGRKRHE0dUdUN2Vyd1pDc3QwUTZ5emNMRGpYcWZQNlZ6TkZkeVRJcVBVSmRk?= =?utf-8?B?RERFUG1LMWVOcUkxMFFlMzRZU0RyOEYzM0thL1FzRWN0dFQ3ZFEyTXNkdytS?= =?utf-8?B?VHR4dE0xQlFYNkI5bXd6czJDOWpqTnpwYkdxUVlNK1h6SDc5Q2pWVmJWN2cw?= =?utf-8?B?enZtMUdlRzlOaFNwckFKOXEvREJjY2Y0N1ZtRkR3Z3pHd3F6VytBazRyMno2?= =?utf-8?B?dTFvcjZITERqQ0JITVJVSGc5R2tocWVzb2ZrdHdLS2Z3NXNOdDBWdnNWMkYz?= =?utf-8?B?aXllR3h0aGwzRzZWVTJha2kzTlFKQ1pJTlpZNG1RanFISmcwMjQybks5V0xm?= =?utf-8?B?MHkxUEd4WFZQZWJ4NEZRSVFFTC9kNlVob283VUtzL21sMnJCQVhvUGJ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VrbVYrSUdPcXY0clBxWTF4?= =?utf-8?B?OXJ6aXN4YzFpaitzMURxeEgwd09VZG9Rek9DK3h2WWdHV0YweXhCT1NMd3Qx?= =?utf-8?B?cnE2K1o5ZlV6YVgyT3JCUHJlRUR6eWZMS0dPTU9IdVQ5N0lPKzFZcCtqZ2kx?= =?utf-8?B?d05FWXZhTVBDZ1gwa2hRTDhxRkVOSkdzUFJNWll6OEx4NTkyQ0hIVi90OEYw?= =?utf-8?B?VG5rMlFPaS9KUmlwbFViZWovRFZZQ09wNk8wYUl5cVgwTGlLM2JFNGlrSUtC?= =?utf-8?B?NUtrVm5GMkhldGVkR3BSdz09?= 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)(7416014)(366016)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?d1ZsMFh2KzFsVGVHT3Erc25aYlBicHBBUE1zNmFzUCtLUEtyeEFPTDNBa2V3?= =?utf-8?B?YitBbTdnS0tuSXpDZFpvLzlpN2dJcnFsdTY0a09VYm16bFdNL0J5Q05razhB?= =?utf-8?B?MG9oZTVkR3dCRlBBb2Y1bFhwRXFCNWxhU3lkT2FXZlppalRyT09zZDZ3QW1F?= =?utf-8?B?SnNTbk02TWc5VFhtUFZIbEIwRHNPR1JFVFZ2RTVpc1JTb2Zmd0NLQnJzNDcv?= =?utf-8?B?U3NWNTRsYkd1MHhtcW1saGFLN05VemFrQS9tYVpXb01neXVQQzFoRTVCOWFL?= =?utf-8?B?YzE3dDZVSGV3YUhiNWdUbktrYjlWWS9zZFNUYnBnWUVFUFp3RlB1YzQ0RVpn?= =?utf-8?B?bjB2Q3cyMWVuYnNYSFdma0NyQ25PeERkZWZkQk5SdlRaM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qK3RnRlZqM3hSM3R3OVhUaWVOL2di?= =?utf-8?B?Nms2bHFUR0lFamRUTlBEZE81cVNEK2lTaS81YThJaWR3Z2UrUVh6SHVWa2hp?= =?utf-8?B?R0lZQmZrcnFnb09weFpXSzcrcDdsSGN0MWRFdGdhaStjMGgxay9RRjUwS1lB?= =?utf-8?B?d2NEK1dyTzB3YUl5Yzd5c1FjeGQzWmhYS0xaS055NFcrQXB4NURLTlpTa20z?= =?utf-8?B?QUcvR2wvN3UvcWo5VEFzMnVTYTdJQXFOTzVlMWUxbzhqbUhnVXdWL3ZmUVVm?= =?utf-8?B?R0VWSWtrbWwzVGJkUUUvUmdkU1NIeHdHckVKVU84NXp4b2dWZFFDRHpwUWgx?= =?utf-8?B?K2FOYkZmbm1uTXh0bU1udWVURWJPODYwalVHbEJvcXd3SHdSZCtmeWhubGJJ?= =?utf-8?B?bGVoVEMySjZvSVdQSzhrbVI1OGsvVWZzekhDVVdEQ0xwSEVROHdLb1c4cDFB?= =?utf-8?B?dVhoeVc3aHJJMDYzeXRQemNERHMwQUdKMUtGM1dEUGtPa1VGcU0wTEZGRGg0?= =?utf-8?B?TWpjd0JTSGhhNHhXQU52RjlFQmM3cHc4c1dGTHF1em5WQmMxOElvSEFVWFI1?= =?utf-8?B?ZXA5cFRkZkdUYmFkWFVWbm1VTkhnZ2dKRTVoT2p6MHJObWpwVjEyWmV5eGo0?= =?utf-8?B?SDE1eW1TTVRGUHBvOExBYnRJMElqR1d2RDRtL0ZSSTlMVWdVN1lBTi9iT0NZ?= =?utf-8?B?STdOYmo5V2h2a2VXeVZKR2JVaDZ3VVc5OHRoUU93ZlBrQjFSakEzallub3dM?= =?utf-8?B?eU1tQUpYSEhqejNZTmc1M1gwSTdRK2RsNFBjMktYZGRac0VJYlhxazFoZXpL?= =?utf-8?Q?1LwU=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75433974-652d-4c6e-05ad-08dce7ac835c X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9626.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2024 15:18:50.4993 (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: Wbt7H1okrLvUtjQKUkve1STdF9THYaOShL/9FHvedbXdSQB81BuERBg7eRXqmtRwLybTqbePVKdlqXwg/0Fysg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9151 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. Signed-off-by: Frank Li Reviewed-by: Miquel Raynal --- 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..e0962a17de7f0 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 Wed Nov 27 16:44:21 2024 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012011.outbound.protection.outlook.com [52.101.66.11]) (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 A51FA1E0B8C for ; Tue, 8 Oct 2024 15:18:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728400739; cv=fail; b=Bma+/0NQ+RE0UZ4QUP5I53tVXyQZH2p30+fFgvcDviuYda9Gw5n32fCl0bWAA0Ju580qZfSz+6xaQug76y6PrxflRCmJyk032y0EGh4+WH9WsJBCNcViC7KkhnHUbHhG84rea8q4EOCEFijj8wvE/E4eEEZobJ1vSuBDqeT4pA0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728400739; c=relaxed/simple; bh=fYQXCdK74snyRv7MsUE/w/+rHiPoijiH/nm36eU6gIs=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=TP7rl9GKQRGxz81d6WvAvoBo1Seqma1VDU0EhwhRSp5MmTvXOyzQeXpQmCjVmcRFh3HdHN2dzjpI+dyZP9shAGXz9MS2dVZfd447sC68gQs+vjRBBFTV/SFfojWU4bn1dxupSRWO8349WdNcMmjZN6ZW82c5UjPGtiZ+aVNtjas= 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=cPuEWmBS; arc=fail smtp.client-ip=52.101.66.11 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="cPuEWmBS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TqwLvup6EdrLHRJ414dPRWhGjnhrA1AkGTRUGFkWl7aKQrql83+lbSVEKcZCRibe3ML4hq4RnMphLG7e3RvLXEOC7hMjFV0i3zlJDSzeEYy1ONXBpntMoVcHpPxCKhBRSDyGIrhLGoqnx35jEwJKYL+ymH8pE4kav9tjaXlLVtg0Tqgjg9BCiR6JYZxM9LetYUuMOp8RUNONtEg5hs23/0rtsTaWntAthsL5RCrp6n28ilk595JvbO8F+njMfEO/Pn1A6H0LL6RDu9VpFOjHqu5k5g1lcF+Pskdr3TEqrjryiZfTkP8lBd7RFzKlcUlUE8CIVBPeli4oSyxDZLM6+Q== 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=seUGrhq7525Aji8QqixFCyRDtakFX5/Xp2TzxWHsoBo=; b=ZspkfjTWVEsxMGBpUOgZkJv/KhTx8NswpCAUSXPGyWKOhT5KzBE113DOwW/wDuoAXEXKJsdGMQICODBf1xWpSzSkOknB5+6uriAf6nowi8v+hwXaeJLppXcpgoMsQaTFxivUsEbK8pZf24IQG3c7KfJD83r2OfvdqYEtEwSOPZSIgdKs+50J2CTc6wAMMgvxYyDeH5AOL2T+HDq4mnMLxgGQKkD0AIBmL4w2+b8BSVT/NiaLmOiMo/8KXxmEwRiajNZA9E1j4jVa1kAxLOB6SfxYkLYgJxrzxG2t2BScRXFQApuT2pTnWvjk8hYJFlNCkzIPx24P4Vf7q/AdqPmj9Q== 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=seUGrhq7525Aji8QqixFCyRDtakFX5/Xp2TzxWHsoBo=; b=cPuEWmBSz2OzFXF2vGAicNujW/AoF467Zg4+4IAYduv6Sx6SZ9/f0MJuyf5Bk5B+TaaOtBFSdso4l2RC9K2yeKFHaJRoCqrM10dtCllgMJTolvMyZ4v1N+k2h+YvwsPveFqE+IBfvMXgdlhRL8CktbrPYhmUQaHThB7SC9m+XR522sDLa5yverifAJ4Bz60KZTRobTh7JfXXj/WO1qmEg6qHtmF5NGXqjkgzV4C2HtN8Q7TeNmmLHT5uoHxOmsZzVf3BMjtKL8WWigK52oeULGzjZFWZwfON5NCqWzIYuy+ACIhoKCHwQqLlcTtMhDB0a5QcVBF4Ojl+smj66qkiiQ== 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 GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Tue, 8 Oct 2024 15:18:54 +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.8026.019; Tue, 8 Oct 2024 15:18:53 +0000 From: Frank Li Date: Tue, 08 Oct 2024 11:18:26 -0400 Subject: [PATCH v7 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: <20241008-i3c_dts_assign-v7-3-96ec93d1f34c@nxp.com> References: <20241008-i3c_dts_assign-v7-0-96ec93d1f34c@nxp.com> In-Reply-To: <20241008-i3c_dts_assign-v7-0-96ec93d1f34c@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=1728400720; l=3796; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=fYQXCdK74snyRv7MsUE/w/+rHiPoijiH/nm36eU6gIs=; b=fWsH4+cyiVF/9mzhKugs22BvUe9clSOdxCT1bXI5Bgz4y689aIN7eUb0FtFKIHI6be7lQrHO3 nuPZK+209xKCOPxfesfwwoMuXAU5Gr56ar5Dv4NqrtXME+t41GT0Rmr X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR11CA0101.namprd11.prod.outlook.com (2603:10b6:a03:f4::42) To DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) 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_|GV1PR04MB9151:EE_ X-MS-Office365-Filtering-Correlation-Id: 8985153a-0e14-4ddf-f2b1-08dce7ac8561 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|7416014|366016|376014|1800799024|38350700014; X-Microsoft-Antispam-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tNNWk0dnNpNkFLUXh2QmxvVjhpb0t0?= =?utf-8?B?NEw1MzMzR2NDaXNIS3VFZz09?= 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)(7416014)(366016)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?azFHZy9GQ0RGOXJnYnozWER6UUNTU0Q2SmpSeG40bDVld05RNjB5cXJHZk5H?= =?utf-8?B?ZUJLTzlvM3dERTJIK2tmQVgxcDRvT3psU0VMalFydFFDMGdSaXVYU0JSZmNk?= =?utf-8?B?RFZpNHRCak9DaUJjV1VaU3k3SzE5VGxRdDRZd3A5THZrc1Bjcm8ra2pnWU1z?= =?utf-8?B?TW9MK2hhUzVtdGltNmI3UnJUSkZ3Qk01MDBrYk9tM0xjZ0wvVnhyMTBwNE5m?= =?utf-8?B?THFwd29nV25xTTRIbmpvem5hT0RtK3VDWnZsK3ZvTG52RHJpbURXTXpBOWxH?= =?utf-8?B?M04wcHNKdTdwZ3NYSXlGY1pzOW9QVWF0TVh4N2pWRUlsSTVoeS9weWt3SFRz?= =?utf-8?B?cktZMUx0djhIQU5ZZE1nbFFYTXdmekxrTk9OOWhVVHp3dVIvYlhNVVI1OGNJ?= =?utf-8?B?dzlIRjNadWFkZlJrM3E3d3lTQUpBRmlaWjkvdnJVdVB3V09Ma1Jkc2wrdWly?= =?utf-8?B?aWV2YndyUCt4aVgwYS94M3VranR1M1BtTjVzUFJVV1JHd21uRHpMaS9lcW9a?= =?utf-8?B?U3NqZTdaSmpQdHVEekdneGRoanQ3STRTamZ5ZXZEV3VYczFsTlBzOXBYdk84?= =?utf-8?B?UWVubHpBU0p6enBMQmsrYWxyWkthazVHL0gzUzFCRXhyK1hlW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UwTDMwT2E1Syt3cEJOc0QwQ0la?= =?utf-8?B?a0k5eDhyc2hidG5IeithcXJnb2oyd2RIR0IvWndFSy9HQzY5RDJ2dURiZmRF?= =?utf-8?B?ODIwL1Y4eG4yV3pjckxqYUJ3c3RaLzJ6eEQrKzhiNUtaSW9lWHF0S0VzOU5C?= =?utf-8?B?NEZ0L2o1R09Id0pkUkxDbStnbmJCeHNia2RLR0hPRmN0QXBDSWE2VDhPcnJn?= =?utf-8?B?U1dLdjlBY0RLTGdVV05vM2M4aWkrYUxuR2l5VUI4UkQ0VVhpb0lnRG1IK0xp?= =?utf-8?B?NFQrT050OUxqempOaitTOHEwcVBFMXI2UVZudEtoMTl5ejNUY1BVRFFXeE42?= =?utf-8?B?SVB3M09QeXFrQzZEYWxybnJHWCtsMC9xakd0ZlV6bTZvSlA1aEY5cEFtWkRE?= =?utf-8?B?cHlqbk1KOE9vNUVHa0Z6SkwzdkNjL01rUC9qTS9vY01hV3Y1WlczeUVsaUR1?= =?utf-8?B?OFA1MlllelYycGo0MEJqQVhSbTc3VHpRS1JjVzZNdUxIT0MydnpPNjcydjhl?= =?utf-8?B?a3FPUFRNbDFQL0lwaWt0VTEwbS9aWjVsLzA3R3JSQk9VbU5Qc3VBREdLeGlL?= =?utf-8?Q?dOig=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8985153a-0e14-4ddf-f2b1-08dce7ac8561 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9626.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2024 15:18:53.9025 (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: 2373gy8CNq5op3mKurhu64q+HZIqSF9+0gg/9Kjlit+VnXWEvhSbzjWCw4tLQxl9DhytBQXWc7dikFF8SaBxUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9151 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 Signed-off-by: Frank Li Reviewed-by: Miquel Raynal --- 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 e0962a17de7f0..9ccfabf849c42 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 + /* 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