From patchwork Tue Aug 13 15:15:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13762224 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011063.outbound.protection.outlook.com [52.101.70.63]) (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 C37C21A0AF0 for ; Tue, 13 Aug 2024 15:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723562149; cv=fail; b=IALsM7aQ2XgnH8Ua9a3s/fa2d4jwZXvlS7rZr8y4p7/ZMS17a7xfKrClSD6NxfHscPsW2w8yhNFeBVWy1kLAesHoazkdx3CELVKnxNgq3Z/q27VVfAQKW6fo1jg4Q3BYVcPYdxDSKt9h2S7s5skeQJkog13l8+wBy+MOkLJ+kME= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723562149; c=relaxed/simple; bh=An63rdNKf8siEFmhpUTOtrd2drbSwaCzp/D7qZONW80=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=AAo46xgoevFfxUezQ4SX72if7/lR0OXTftQaFZ3YmlYVFqce1hzVgBMY+fbQoN8pTIBNKxE34bcRl8NhXyUWorOYr/AjNjRT52e6lHKD4GBiz6fSNqIcIp3oCo7eVEBW38bHdS6KGNcH7trFzTxF7OZMATzP4vRLn0FDzYGxGHw= 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=buYRvvH7; arc=fail smtp.client-ip=52.101.70.63 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="buYRvvH7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IPauQw4BIFSzfCwqqEC8WKgcjJuP64L9ALR8BlR/jT+ZLnWj0shV1WCkAbshOEJ41NYLIlb+Pe72pd9vhvYJptQ+j9QHxrWAtOc3uF6f9Z4uIdI6EmgsCgPsCGAPaYaHz6K7WsaH0riLbaETWt4FLY2uzw6RQi4qOSZdoRNlHCMHEVErsN1yCB7s07ku0Ve+oUEnY5ZJ9bFLI4xD8pL/7ASSAbtDYVI2d8ALP8553cWWxI69SvlPTOZ1IJCm67gJq3AZaUAUmFR84ZO7uDNTj1tK9GOxrBFYIKsk1vfHqtZ2HCX+gDN/KleUZjrFV5KkIlADswE+7IW0WWdfx/nRrg== 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=DDbmmbFgBxhKaOhHOUp/UpYi2/c+KPJaw5dvLjPdxrI=; b=t6rWn0/UxNUY1VJHt0XYTN431SF2niS2PpwvFgDN4wn3BXmVjZmYT4gxzNJE2ux0gIl1BuTG6txnoPetqge1Nc9xjTcxwa5wCOcqEiAVgUDfjFC3YtNLEQdEKrVnP5/Gf1TK3fe89pouTWwy4JphJMFwWTRzB9gMQ/PGRTgAg14fK3us/GAJDEzXdkDHIN/iC/I7yzYCeAURG5GH/3oQ6Q04BdOsyOBk9TX8kKKgd6cWlTzxcXTebVrAqR6QASVAcf4a10eXPbpvxiu1NiRyeRhi79PFk/Qx9YGwBLupjT+WC1oNYereRtslghsgmkI8HtGHB2dOBP7jyoK9+gpolQ== 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=DDbmmbFgBxhKaOhHOUp/UpYi2/c+KPJaw5dvLjPdxrI=; b=buYRvvH7fP32ZJURl+KNcepblO2k6vRVYAJC1zTFIikXy8L2dZnWpt1rV1xrIQ0wlSg6zXXzMN0EAFJxemtW4PjAo4EgzEr7562E4LdR+k/vRI1kCotftYhh9RAa/bJjxA8Kc9Y+QHbRWH3Yitei/4puY6OpJyD4UqmpNE5Yfv0epgoq8F24th8kmnhL5fWyHFF2f/SpmcRDHx0SihNcpF4rS+nmCKeQik9oVDMZZ5nbdsOwtBAO7uePXMya9cZxBsY80MnUOeG8wC1thCymsFw8FGQgTz183F2hvY/LF6UYhAZEy0Xwbuq+Y/cgXxkMRzhzSwyztfHGgk6H0DLNhA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AS8PR04MB8404.eurprd04.prod.outlook.com (2603:10a6:20b:3f8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.22; Tue, 13 Aug 2024 15:15:39 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%3]) with mapi id 15.20.7849.019; Tue, 13 Aug 2024 15:15:39 +0000 From: Frank Li Date: Tue, 13 Aug 2024 11:15:04 -0400 Subject: [PATCH v2 06/11] i3c: master: svc: use repeat start when IBI WIN happens Message-Id: <20240813-i3c_fix-v2-6-68fe4a050188@nxp.com> References: <20240813-i3c_fix-v2-0-68fe4a050188@nxp.com> In-Reply-To: <20240813-i3c_fix-v2-0-68fe4a050188@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1723562115; l=3542; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=An63rdNKf8siEFmhpUTOtrd2drbSwaCzp/D7qZONW80=; b=GSS/gw4GojrWatSW1LvUBE9BTakbtuHGDQlwuo4o99k6ZGQ60UuOoY5oYQqbmC03xloO/SQrR GFYNL4yb2WFCXdjSvRCpurSuBGhYaeU4N+4/DwpKYIq2LfSdqP2Enwj X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0125.namprd05.prod.outlook.com (2603:10b6:a03:33d::10) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB8404:EE_ X-MS-Office365-Filtering-Correlation-Id: 8990f59e-35e6-499e-232a-08dcbbaaca6a 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|366016|7416014|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?ut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f75gV5MCPHGds37aQHODrzXNO5OTdUnfERNBVMBYtz7?= =?utf-8?q?dZAU8CCCmWeUh8QbIFHRsZs+mlbHeSeuBT25rT8hDGVIzFRHA3YeuNnzx/KFp6fHw?= =?utf-8?q?4egJfKLckg8qJ33B2yU0PBvrrdXFr9SLlG8FjoifDg1YexsDg17fVFzPwPsagbgRR?= =?utf-8?q?SDG1BXebKsQAtm9yfeaGNc8o9hO/QOvlIN7Atg0QIQ+d8vrUhk1VweXk/k0HIXe+0?= =?utf-8?q?vmzXTzTpS70b7NcYHO0GBqIrj03BaoMt5p0rcKu1dW5h783KUj94NAWmObdAIfi97?= =?utf-8?q?gC7TqgDy5xCbvLx4sXDElCrWi08B3PRQ2LnD0EpUzAsXCwdvBz4XuOeYvhav55+OI?= =?utf-8?q?tK5MFmcpptV6i1N3BAUelbPAydvgK8v+SKPMAiOvhwc/KpJOu2/pTjxD2IOZ2Sf+p?= =?utf-8?q?RoIK0JSbTtlLZWNLJoUItIxHpaVqbO9/vlsFl1jN7V6MlI8svWPdl7ivo5ug1+qqu?= =?utf-8?q?j9lxRFiqQWg+6ab0MZjRDV+Sk+1KjTVxlA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(7416014)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?dreb9sKe2NBxGIlQYHQP3uBA4LRG?= =?utf-8?q?UXZA3zDpBPLwj/pE0r8EhnzorfeMeNalKbuFBci1r9YV2MKBW7ViPI1sYCkSfM76+?= =?utf-8?q?wqIs58UoJ/8fh+PbU20V2M2x7PUPO3zq4osvKAdRT/TxEHyw7Gl7ppbKat6M+QT1N?= =?utf-8?q?jru5W6j6ArX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BTO4SaJ6ZfylT5iDx2KONcUA6GZ54MgbJgrLDK8SB0l2YXf1Zzo5LbQHo?= =?utf-8?q?qKDlN0zS+qJw6+oQP4qZ5ojVh7B74uzYzGIDwhjd9LOPYvnTQbynFRDlWlLy4IdB6?= =?utf-8?q?vC9gCm+PmxSig26572PHG6Av6ABbRQL7uWiJT8CSODS/5VWtwRN+Z4dbrDAGx83pB?= =?utf-8?q?L886jCcAhIXuzEdL4LBxzGf9ptyXm9DjITb6Qfs+t23atuqtq5JP6kSFvuSJVKlO0?= =?utf-8?q?+h1v0AFprxIZPYaQCRe305LkLfp7MlOEVUZzCUKl6qnpRL8D3BAYpNQocWo1R7Z8K?= =?utf-8?q?k+pdDlyIm+VEtZwahiRJkIWH7cjQFdEMvGBqh1Dsb52VxrTCREELiuI+UfkNIvcx8?= =?utf-8?q?75XYLxfSOg5tX/cLNMqjefkxA4+j6q6IOIZGWyFAgrncGWHai1HSAUrqn5kOLswaJ?= =?utf-8?q?xqY/j4VvFUX6BH0JxiTaFrc9xITD19TUpG6BDTrk1NKnsKkbs+Tzk84c=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8990f59e-35e6-499e-232a-08dcbbaaca6a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 15:15:39.5414 (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: BDk9XidUxZzH7CGiOTIPxUS4Ifa8P/wIpkp2pjkTAIX2DknUVu56HwDjdLLXShddwBg1viopkgN3RwI3fEIDLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8404 There is a possibility of an IBI WIN occurring when addressing issues, even when sending CCC commands. Most of the time, returning -EAGAIN is acceptable, but the case below becomes highly complex. When a Hotjoin event occurs: - i3c_master_do_daa() - i3c_master_add_i3c_dev_locked() - A dynamic address (e.g., 0x9) is already set during DAA. - i3c_master_getpid_locked() - Another device issues HJ or IBI here. Returning -EAGAIN causes failure in adding the new device. However, the dynamic address(0x9) has already been assigned to this device. If another device issues HJ, it will get this address 0x9 again, causing two devices on the bus to use the same dynamic address 0x9. - Attempting to send RSTDAA when the first device fails at i3c_master_getpid_locked() could also fail when sending RSTDAA for the same reason. According to the I3C spec, address arbitration only happens at START, never at REPEAT start. Using repeat start when an IBI WIN occurs simplifies this case, as i3c_master_getpid_locked() will not return an error when another device tries to send HJ or IBI. Signed-off-by: Frank Li --- drivers/i3c/master/svc-i3c-master.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index e80c002991f75..5d19251238ff8 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1099,6 +1099,24 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, if (ret) goto emit_stop; + /* + * According to I3C spec ver 1.1.1, 5.1.2.2.3 Consequence of Controller Starting a + * Frame with I3C Target Address. + * + * The I3C Controller normally should start a Frame, the Address may be arbitrated, + * and so the Controller shall monitor to see whether an In-Band Interrupt request, + * a Controller Role Request (i.e., Secondary Controller requests to become the + * Active Controller), or a Hot-Join Request has been made. + * + * If missed IBIWON check, the wrong data will be return. When IBIWON happen, issue + * repeat start. Address arbitrate only happen at START, never happen at REPEAT + * start. + */ + if (SVC_I3C_MSTATUS_IBIWON(reg)) { + writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); + continue; + } + if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) { /* * According to I3C Spec 1.1.1, 11-Jun-2021, section: 5.1.2.2.3. @@ -1132,24 +1150,6 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, } } - /* - * According to I3C spec ver 1.1.1, 5.1.2.2.3 Consequence of Controller Starting a Frame - * with I3C Target Address. - * - * The I3C Controller normally should start a Frame, the Address may be arbitrated, and so - * the Controller shall monitor to see whether an In-Band Interrupt request, a Controller - * Role Request (i.e., Secondary Controller requests to become the Active Controller), or - * a Hot-Join Request has been made. - * - * If missed IBIWON check, the wrong data will be return. When IBIWON happen, return failure - * and yield the above events handler. - */ - if (SVC_I3C_MSTATUS_IBIWON(reg)) { - ret = -EAGAIN; - *actual_len = 0; - goto emit_stop; - } - if (rnw) ret = svc_i3c_master_read(master, in, xfer_len); else