From patchwork Wed Oct 2 14:50:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13819880 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) (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 978373D994 for ; Wed, 2 Oct 2024 14:50:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880660; cv=fail; b=c/dbembXxggJvHMMYHorXHtQnvbY1yYucuf4PH/X6H81BbqZU39f5GVHNvcApoCpcGgWc86/nxlFYv7l7D9hsfjhWZ+A2Oe1r8jD+Y2saVULglMajjarzjS6LMcSWyjDLcc/ndyw3n6FogkNsgICOIQaUMRjBylrw/03Do83Xnc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880660; c=relaxed/simple; bh=PBBSfHDVYCdWWJVtSVLzuz59brGY1sY/p66hu57yrIo=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Kz3tmrh3X+p3EHxkMkcQM7eMYzhVgnDWgOGEeQ1gPToWDjh84tls5cB0plQUnC1KIzAaS117adH9bxQrrPaWt2GHuuPTu+WVeY+1EadQUz7tYUZ9sBUz49ysOzBsqG2ktt7sT8NlhxqqRI0+91D9sh3yrm5h3+uN/GRRlRPi8w0= 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=gK6zHIDD; arc=fail smtp.client-ip=40.107.21.77 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="gK6zHIDD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mcqAXDoRfpbPsI54GXq03TzX0VQBfiT5ZCQ0LL9agOLnvPz7Uf/aYQ+dG0X1lEblO1CZk4B//nkRtoI4/ABpujInduq6BoduNcLWsZObUJnB8VBSmV1M5GIENeWdqH1wZlhpPkq9ZLivrListtoYYfenBjwqY8jAWBDpfId5aU5mU6iS1dC9UWWx0ImT8S7F8kDQAhDydIglHVvEpmINz6sZZW9bgvmysmVyx9AqWT3sJgE5Aelr9MZuMMtp47T50MaEbtdyDRjqY7XF3vHqZ//e+ZxZyL814XRs84oL0GO7+LY7SM9btyedW52g5Jx5+7XSbPKSs71tNA4JDObafA== 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=igRMisCW/2kVicUCWragCOXWuSz9w6K+xZKwl+FSnWA=; b=MoyRAvCs7ebSBBiP3vo08gOqWtbUu4IrLxnfEPfhv36rSWcC3ABceIFV1Zb0YusSyd3FzkroCaeHBcPldJoFDnnyvCeoV39IWBMP0NEEnMJA1qKub94Qkv6awoqGdLQLVYCyyKdZlBzYdcfPqumD0et7ja3RCLLZjAAPQUBkkJ3AQjuU9+F2XWzuZVUW5Y2Iz5tNe/78EB88fpt9qgKc5TOqw8mlp8dZOXaPJ/65vsxiMiJvPGL3sn6DjXXkMkxPKnSGKywVGbc3ax1JWlX2lze2DLXJUcwXG4wZALKzTgqjOrO/bsbRssQc1tVreak82YTbemkfq7lBCk+5aLsrVQ== 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=igRMisCW/2kVicUCWragCOXWuSz9w6K+xZKwl+FSnWA=; b=gK6zHIDDBdNjhJfxVjBNAeaMg65Yp+PVGznW+g0E+LDALYXkc+P22EziQhnBVW7aW71U8oxdMzJzUYxwa0MVmuOxylXuSE96K+v8OeUfftCPcy256tLLTpgJ0Hj91cki6y2ocajcaUeaHnP9Y56kfHSfuGkPHAF7K2qvH9PB9swy+Tru9Y7uD5+m6e22QWSBTuM1/Rgl7zAw4rJ7H9c/s5V1KBgowtirTvzRcNt8L1Uu6pYMQjFuSTNmW4tReoPjY+Dt3x612+fI8fLi+V/qjBYBelObAjNay+3Mh/Q3LB4RCqn748PPSFV9ZRBK3zYcAfHqsnDPynyOxJ5fVnU+0A== 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 AS1PR04MB9699.eurprd04.prod.outlook.com (2603:10a6:20b:482::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Wed, 2 Oct 2024 14:50:54 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8005.024; Wed, 2 Oct 2024 14:50:54 +0000 From: Frank Li Date: Wed, 02 Oct 2024 10:50:33 -0400 Subject: [PATCH v6 1/6] i3c: master: svc: use repeat start when IBI WIN happens Message-Id: <20241002-svc-i3c-hj-v6-1-7e6e1d3569ae@nxp.com> References: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> In-Reply-To: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> To: Miquel Raynal , Conor Culhane , Alexandre Belloni 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=1727880649; l=3676; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=PBBSfHDVYCdWWJVtSVLzuz59brGY1sY/p66hu57yrIo=; b=RfKmOMlSE5qLM+Nbfkb7OcOpVIojBrrVkI7oYYjq/k2xEK4mPjR4p/NDeLqFAMQk9kuxPo7hP GoZ/z9mtBUBCkLaz/ohcB8fAEyYN8nbyvSSb8TOdD4dx34U4tWnKN82 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0177.namprd13.prod.outlook.com (2603:10b6:a03:2c7::32) 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_|AS1PR04MB9699:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ecbda3e-4031-4a2f-ee76-08dce2f19d8e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?1OWCdXOjWIVUSe0Rn+uFW7HS+r5631J?= =?utf-8?q?pQJztr1RQNzCykxtaPuN532Vm4zVYO3nMOJE4Oig6zVHNq3CimxE9xlfn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= =?utf-8?q?/8LxhGUezKGGiYgQ8/IEBdNtxW36vaErNQkdbATpjesNw8TdxDdVwlALBpE8zUQ3E?= =?utf-8?q?L5/BfFC1410yDylk/5aeD0Kz+Fnt7E5kmD5gMaaHp0EyfxaOl3PPjrmTGOiF6HNW/?= =?utf-8?q?rmpMeCOX6PsUFyYlhY7qDhGFLRtv4A5JcwtOLZuClBFpk+2es4RdGOjeN0fUyLFJo?= =?utf-8?q?qRuFIrhsHgxaNk4JXZ6yYQsSR7ANtltud4S0hFX6k5Mhu0rgXdVTOO6+bB/m4BYB9?= =?utf-8?q?1RJNtKBn8di/5AXkRbPd++XKlaerrGfYPb50G23TNXTYS5J0WP7Ruym2ZuNapE2wR?= =?utf-8?q?Jd7vHfqzW5dpLtsWE3pvN2BEB5CpYnQifrw=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)(376014)(1800799024)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?hvcevlEf0tTi6f6dZEoU3178V6Um?= =?utf-8?q?kbezJiJnhDg141z+pEHOMyX5oX9nM1P2cyDXLRPr5TEJjCq/Bvl5S63h9ByKNWZuR?= =?utf-8?q?LUQZOciA/eRhZ2SHz9+TVIfr98NHruBmChBluCXC40iMzKiROAZtCEFFuOvihQ38p?= =?utf-8?q?5yp8vQ6TM1G8vj61eQai3Hn1+3qpiYZVtv0e0abdzZCkV3zNHNsi1/eDzmV/xBPxJ?= =?utf-8?q?Kx9bzz3Zzq5yFjvNBj9eM9NkoGSBzNJwrDjvJXG8yM/06V7LI4B89eYFnRlkeCfdR?= =?utf-8?q?57n8Q4EDXztdiap3j164QNXRDmoY+UD9Y1ThdzNIINWILK2j1fjdKwlv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q?NkQbnqL2kIF7mKYNUdtqaP0usb/9Jz19KAer9dDlwKL6dQ6sQxCQaZbcqQEwVqXfK?= =?utf-8?q?90glurYnjDxKhpztQEjRPZwv9lQRUxMGIsC4MvT92LVm9+bHF07gnYftEJbmO0K08?= =?utf-8?q?wt4p9LNS41OW1VvirBO1xxeCf7r9to6GpMzQ7TU15I8SQ7H7kWeypmWW8JUk4YSqZ?= =?utf-8?q?Nc8VbQHq5KhLVEs/LUIAILcutUkmQjpJSU3ACTXUU7DUE0U8jvddPxx2EBWvO4Puw?= =?utf-8?q?PpVFOqJe42jtOAJjlxzo/hJLqZvwXfT+mrKC9uwykjJtHFLDxxmQqcJNPFm4C0WYJ?= =?utf-8?q?JvRVPZbSMA3q?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ecbda3e-4031-4a2f-ee76-08dce2f19d8e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 14:50:53.9236 (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: xgQn+ppliJUAE4CYVlgW0/1CVPGOCVwgSFgS+HBRvz6xygEQHObz4ABtUtjfAzMb791+5K0wZ4xhIfyMT/NoIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9699 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. Acked-by: Miquel Raynal Signed-off-by: Frank Li --- Chagne from v4 to v6 - none change from v3 to v4 - add miquel's ack tag --- 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 a7bfc678153e6..7cd3ce2643f1a 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1163,6 +1163,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. @@ -1196,24 +1214,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 From patchwork Wed Oct 2 14:50:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13819881 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) (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 CF3351D1503 for ; Wed, 2 Oct 2024 14:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880662; cv=fail; b=jnbMc3qNCVXVNDPEsuBt8Ycte6Z30mjfI5bSsrDQ4q2iTkdxcECzvOca5StXyfu0nJ1r1wxdNFMnqa3cRYlRWDw+icw7CspwJoxSlHvIpadbklCn1RA2dsMOD/1WaYXLpidKbNiZgZa/cTqtp9MSRTN7btlbLTU+vstYXc3wNWg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880662; c=relaxed/simple; bh=Gqd0wCYgtoBFMpBxtk0AaOasL9R8L0WjBcTL6xq2nd0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=X6Hft+r8+DsRpRfAywJoadc98Z3YrGDr/zYouSxoo407bNesZgclo2wTQzMQemusS1m8PN9AWefumyEJBCM/w4mfCzyI+zACE2/nqAVNVztimchWeVU2tjcdwiBik5MOCRrSrtuqBvGXcFcFuHK5TyJ41gJgvRLGJyWeebuzY+o= 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=e7iwHWOW; arc=fail smtp.client-ip=40.107.21.77 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="e7iwHWOW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KkYZ+zE2rMHlnc70VSAQ100789i18tAaO8SQTNbW4kg5CWGN+r4Cp1ETZG5/L0hjL6H698ejpvxYORdf4ouqDoAEidFXkvSEolcOoP2k1MNvNtrvsEF4eBp9qXNHDUqgc0R8GbVGeOWteNRhTfkHdqBmsXslG8CYevugKWB6Ym5ITHvL+G1ML5Js60SJHIR7X7lEl/YK46L0p2mK+DKpIpLA+fDLgD7tqhSFFXtKJf8v23MFQOBYWUV22wGN5CqnmbH2oKoTGnexE3WIMJgw0i2XpOmIq2Mh/Fq8ppYSodws+dmteD6QFp4ES93tCQW9JU8lbU+RqMpgq0GmemYm8w== 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=X3g4JdrXttj+9kVg/nPdSIQfctPvNkrRl+XAcULKDEM=; b=S9pdwUc1dRVSoCrkEhdsicNH+Hg1hivnE+JDuV8sOsXdT0uJ2hzHRSzFuR+JSUEW6z15qdYM0J5XsCaV+wQayL7WjWrtbYitcuNcqUNN2H8cps8vCOH2qONTIqW5FLu3Jkiank8iMerZPXo9rJM0lX91alPCsQxWTv1E31cyCqby3uOQM3ay/pXw7lcVnMHZdLJssmxYzqG19su0ZOKWtH4ustrYiLAk/IEwk0XRy/Af7hvaNNGxcn3201ilSFjdkyS5PZMKjxPzWyAn2ih8llcEp2PsBwRCXc7JPiOwtSLzINYfVAY5rmkDdqDjqr9N3WjHMxyluipIzlbeaXdZlg== 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=X3g4JdrXttj+9kVg/nPdSIQfctPvNkrRl+XAcULKDEM=; b=e7iwHWOW942zd9e1aU+MKBpxV6Krlc+S+tkBT0jQKHO+LM3Sz0qlQKeu+mW0XREBFhTxGvANa0xsv690yhgGb3rdDm6RQuK9fSOSFWNLcwpevJYwwEKEcJlXaE7kiK8KumBDfV/uDJEOV8ZbNtucVzyJ2xZH8XJdC29+7G4j8f3pEdMkCzQBlGKbhv7zxZ5SWh/TdC1h2yflwhscszxNxfNQ0uV/NC816BUyEwr8d76CSsJLm5qHE/KOfICS6ulIkIUpSV2C6dpCFvCJZ4fJ1gNS6qyO9qUfsTOVTe8grBBKq5jO/S25rEwyQDdQNmurwKpHBy5qGDaOa/3hbmZM+A== 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 AS1PR04MB9699.eurprd04.prod.outlook.com (2603:10a6:20b:482::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Wed, 2 Oct 2024 14:50:56 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8005.024; Wed, 2 Oct 2024 14:50:56 +0000 From: Frank Li Date: Wed, 02 Oct 2024 10:50:34 -0400 Subject: [PATCH v6 2/6] i3c: master: svc: manually emit NACK/ACK for hotjoin Message-Id: <20241002-svc-i3c-hj-v6-2-7e6e1d3569ae@nxp.com> References: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> In-Reply-To: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> To: Miquel Raynal , Conor Culhane , Alexandre Belloni 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=1727880649; l=1900; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Gqd0wCYgtoBFMpBxtk0AaOasL9R8L0WjBcTL6xq2nd0=; b=yTdOKTPn+Hk4AHdfqpLCafDEvmCl2BrJJxQOVbedY6RqaFUBlJ0BGf+gflgCusCn1PCsnkUsn f8OQ7scY4pHAVImiva3L8kVM/j/nVX33oQCoyxzyx9Gom48JoOQtYYI X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0177.namprd13.prod.outlook.com (2603:10b6:a03:2c7::32) 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_|AS1PR04MB9699:EE_ X-MS-Office365-Filtering-Correlation-Id: 48628745-f4cb-472f-994f-08dce2f19f01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?RAXKm7raruJPlahhfrbiNGRIomxExaH?= =?utf-8?q?pIt0g04XnQValLf/rt8jjxypQKyshG88wGjgxFi8Vh0FVP6CvLvACTz5bcOGw/oC0?= =?utf-8?q?Uhqno4OHvSQ0gLlH+Tx7V06rS8zkJey0rHntOnueUn04Vb2p6HyRmq+DJnPSTHO0M?= =?utf-8?q?nhZAc8G/85HNXPSCdl1p6RWVxvjRlGim+jDeA+NbqdmHJTI765SLlwS82CA1IWzyJ?= =?utf-8?q?Dbn+Qw4sETDR+7QtQiTgmMgpthkx/IqbIS38kZlj/n4Gtt47lSvnNPxkLvYdS1djN?= =?utf-8?q?eevoPWqWIuVFw9tWDYV9b0rJMgokI1MtDIvMtwp2qNBrxZwRS8pxgKQuiHYRR5k7d?= =?utf-8?q?R/8cA1QlmIq9K+h2asPj7rFs9i68sFyTRVwzcYLHbwTaDulD2Y7NJjm04jt97xhus?= =?utf-8?q?foATnyyDwEOrVfLqb7On5gF81J9gaysuZsBHc6Sn3M8RXIqZk8iFHSUqYN72FKK4c?= =?utf-8?q?AipVMNC8RX4B6jqqbSK9DfL/AHqfxgRduNTGSknptgnRu3cjnSIYxoOa2BlcDnDUh?= =?utf-8?q?Ku4VEdXKatAkvPQ9LzeM2AKG8exenIv3nEFpMYbQ/C84cFCfFPgpiFIIWM5calrJu?= =?utf-8?q?9sEwhBB72aWJ8S+/eDWqmSzxjgLDN75YtHP+oS3xJDKAyajQEwrTuaeFYyJZxOIfq?= =?utf-8?q?8veQ0tbVIkW9DfNO3FHQ2vlxgzjcv/Xxdk4czttc7cRg6Uje5TXDbJeyO1ItwKiHi?= =?utf-8?q?QxRSwJCwsJAH/n7jbzFtJig1LZJYvQHEFw/p3j97P7hzg92UFGgPUUItaTxAnP3sJ?= =?utf-8?q?c8JlO86Z2y4MJJWElOOs+Am1zX2t11K0AEK1vHQ/pWBtipnZBKiq7mYDcHFuuYkI6?= =?utf-8?q?caZq6cv3ffI0OjCJSyhg8mWVzIHX7okNKflyEIRjMsmj8apvu+H0FXOfa8NvC+fYI?= =?utf-8?q?bmOmiVGGybmIYAC8L//PQomd40YSJdqwWmhOCTm/LOBKnpw2YS0mNwaQX2tFk6kPX?= =?utf-8?q?ySEEoedF4LjdXtEDLMMCulejLKiGgKWN8OuS+DFo0s3JsvtP3ivOPKdfNmU2LkL6K?= =?utf-8?q?wY9qkgNgt1xxjMhwcdFdfmOIyGkH/4gn8sadvPFqBX7x93mkvSLyi2MV7SBeUf1zM?= =?utf-8?q?a3GqF1jGCY5eTljJ24pCklxPMnc4QdIxrAX+yIrsBOjd1xVrU1JSr3bAF4mTbO2YX?= =?utf-8?q?x5xaRUhWRURyWGA0jE/2J3popSh8hnnWBrb6U7DlQXL1zmbCKs5PHhCLFVa+/DjDn?= =?utf-8?q?E/+/VxckybCYfumGqNRuhKLAWQ6/n2eGSh2teyL4PdDyGD1r0s/ALx3C8b1JMLXiq?= =?utf-8?q?gVl/9D2e/OsBI+1oCslcQBoqFjnYs5e05gA=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)(376014)(1800799024)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?QOaeM/6qBKhXImNdykHBLIgF6Qq8?= =?utf-8?q?4SG3VVA7nxeqZSjPUtkauUussLeXWLeQYykEwPWWOp+4jzKxqtU6l4mXxHWIkJV9f?= =?utf-8?q?nvW3yaXSmtaP8zJ1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latRswleRdZLxNO11O7O5Z1409QbX5XC?= =?utf-8?q?e2OVYsJ9nBX1SPOtyoEMEWrevOA0X6PPZHoHGiXbykDHhhOsnLOT0NBRCWxOPFrlk?= =?utf-8?q?LK7AzZPMMsugZav984Ma4nbrra70yi8/xQw/pu/Yl/+qmlFe7LbkQbhZMkEsUO7oc?= =?utf-8?q?blGDKH9KXIR61jY4z9JOMCfUMaDhEbpFxTbrMgwhYuWm8gnJiJBvrkfTu98MFfqJm?= =?utf-8?q?4GHhgWBeupadoTcWxQ0FavJeyshLvmnm+MSVWC6eUA4R+wq2zSy0prpTsHsEJnqZU?= =?utf-8?q?fwI/sc3ezVnV8yjKGHCHpk5Bfcrmys50B6PobT6pfSwxQgenZGuP4QFU4BviKuriW?= =?utf-8?q?j0I9+J7bew/GUmKNce/2uh5mcGG+4kqy/LbYHZBTEX8gwPep9V6qdK5E4MwLg0MhD?= =?utf-8?q?j/fYCa6tBVGIH9sn/WBp2Q/5zRCkinHZ7/K4xXl2HxSxfOLRACD5pN2w0a7+k5gQJ?= =?utf-8?q?tk/JS1GJq8tNaN8En9o3NHjR9Aav2LJi0+lZQ7Eb5jljVmfygVtLDsp9m9ASoon3X?= =?utf-8?q?0ZeW2srdWYDl?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48628745-f4cb-472f-994f-08dce2f19f01 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 14:50:56.3360 (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: 1xd52IG72cRUZpMsDz/QlwkyrX7bmWjP/Z3fgFCd74g2Z8DugpepE4TYdLBAoSNp6M49Le+7PR5fBnqzQqx5zA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9699 When the address is arbitrated at send address, the hardware can auto-send NACK if it is an IBI. However, manual emission of NACK/ACK is needed for hot join or controller request events. Add help function svc_i3c_master_handle_ibi_won() to check event type and send out NACK if the event is not an IBI. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- Change form v4 to v6 - none change from v3 to v4 - add Miquel review tag --- drivers/i3c/master/svc-i3c-master.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 7cd3ce2643f1a..c35a228f0c2f4 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -409,6 +409,24 @@ static void svc_i3c_master_nack_ibi(struct svc_i3c_master *master) master->regs + SVC_I3C_MCTRL); } +static int svc_i3c_master_handle_ibi_won(struct svc_i3c_master *master, u32 mstatus) +{ + u32 ibitype; + + ibitype = SVC_I3C_MSTATUS_IBITYPE(mstatus); + + writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); + + /* Hardware can't auto emit NACK for hot join and master request */ + switch (ibitype) { + case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN: + case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST: + svc_i3c_master_nack_ibi(master); + } + + return 0; +} + static void svc_i3c_master_ibi_work(struct work_struct *work) { struct svc_i3c_master *master = container_of(work, struct svc_i3c_master, ibi_work); @@ -1177,7 +1195,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, * start. */ if (SVC_I3C_MSTATUS_IBIWON(reg)) { - writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); + svc_i3c_master_handle_ibi_won(master, reg); continue; } From patchwork Wed Oct 2 14:50:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13819882 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) (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 0AA2B1D1519 for ; Wed, 2 Oct 2024 14:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880668; cv=fail; b=LgGc0plNMIPtyKTQJOSI9/vVcLx97ZfJyOI2Fn+75i3unQ1IozTVghU6N8OLPXUkaanDR5f1+pISnRoJ/+JnDmrY3841I8AxzZgHPYTLsQATsa2+4LXVXCApPg+8Cs40lPe75MSPQVsqhvkq/U6aDLCgY8+OrSxaN0WvO+9aPEY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880668; c=relaxed/simple; bh=km8jyYKynVS8oCIdOvA4qQ3oLe8hXP9gLirgD+wv2WM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=kLVxf3i0qF6x1btMSi6h2Zn6vwxfrSOuxtPg/26N8wUCRkchPygW1ugLan6Qbag0gQl6ga3pQX3Gmc46pcCucBKU3J+efTKqP3RCAQGEfEOi72kcr6dzd13cCQWfDhvm7xAG+ZxPmdGynVsu8zN2P28PDNu9WE/3TB30uhWPHog= 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=dX2GyIFr; arc=fail smtp.client-ip=40.107.21.77 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="dX2GyIFr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nR06q5A3kMQGujjCFnBRQuNNXDVXH+ifM1ZnidTMmNMHVWOxLjPNFkUnsLrJqeDqMOZ3ewoMKjT0j3W0m5B0zHP7vCCHJz5Zb7AsAiUbVCtyXc/SHYcrouTpgWvKdxnes8g8Nr3Am4sY/53+I2JfU//R61odn6T/NPESErKQOHALScwhEYSN3VwvhFfFp39SB7x/wz2WXUKUkpc2wwRQnfWMS5YNMEeJOGpSZGiXTU6VbWHoXTHN4Vskw4HVrbd/udHiSctq05/2V/3ww+JP/gG6r/8tRV6uC1rntC0CRs0yFUG12TFKU04CC51J7nIx4jI4HQCEsUfyBxTevw1RvA== 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=tR98+9LS9quTYVdmJkr0U97KPEN31FgGaNrzukbSyTU=; b=ngAQCtXhEKIN2pKvVBPhD6z4BozYzjiKxtZsAk8tpGpBvCSSQF9dkILp1EH+mWfMWnOiEhB//ZRYCd3In7vtEF5OBFt//HbL2JuseggNWLRRg/FmEZAkT2qAPHrPb1o5Htios2ei7acaUVtr9F9r4RAPrhRdhQU7K9u2dZXjo9yylKCcwn7P7CsJRESPTIAsfF5/B1ifJPS4g5wxWscVZquWHVdi7YNuNujyeRlYTcqWOGwo9tdK5TBTqf1rhBPAQ6CF8aGFdvJASHlANxZwmSlgMaigTkde6vIA/WqAFxcVGUb3CkCATZ/zD/2rmsSQHLo8GHx+MvRBEnSw1zywQQ== 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=tR98+9LS9quTYVdmJkr0U97KPEN31FgGaNrzukbSyTU=; b=dX2GyIFrJmkKFj9e+KCMf+dDujzSDQc/g3RH8Z4qIS5FR63PiGoVODS+wMYCqcV3R6MvF6Avyxcpus9W0Gv47EDC7YaYg0qjjQRlssjvQl0BLMV5Ut/KQ6Xn/fw/2IgHgnLaL6J/rO2dIifT2odGO/ve6WJgKo0HbBdDfromPJO4ALBRhezDQ5q9iUp8mDO4pNNUk9KU/ABPFTzdvwB4MCYxmLjYGhiMfV29xez+HPP/f8D70NZBsj0fDK7RBapjiX7oEDuLcMqLnTiQy7IqcrefwRNEXMcXynKFgpJ3ewm+Z9rz5WbnftBrEJnZNdbYbKeyAp0pBt2QpJRTmfTCkA== 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 AS1PR04MB9699.eurprd04.prod.outlook.com (2603:10a6:20b:482::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Wed, 2 Oct 2024 14:50:58 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8005.024; Wed, 2 Oct 2024 14:50:58 +0000 From: Frank Li Date: Wed, 02 Oct 2024 10:50:35 -0400 Subject: [PATCH v6 3/6] i3c: master: svc: need check IBIWON for dynamic address assignment Message-Id: <20241002-svc-i3c-hj-v6-3-7e6e1d3569ae@nxp.com> References: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> In-Reply-To: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> To: Miquel Raynal , Conor Culhane , Alexandre Belloni 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=1727880649; l=1618; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=km8jyYKynVS8oCIdOvA4qQ3oLe8hXP9gLirgD+wv2WM=; b=0/6zj+o5ZrjhO8E6paIbmVG6vIWC79f/0qAGiqEpTKUA6UaeH+V+GT8AZLzdrcqDZpy6QO+jK iBpO642BkxUAHGV4zp4/aIdKEWubL/LXeKK8BdWmtfzQStd89qp0tlv X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0177.namprd13.prod.outlook.com (2603:10b6:a03:2c7::32) 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_|AS1PR04MB9699:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c6e1e14-3da9-4524-f278-08dce2f1a065 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?+h32W4VXZxLe9k0hUWhB+H3XKhDx9c6?= =?utf-8?q?c8fX/V/pd4jU+SAdZdZCBW3a8DYblnRcqBAIc846h5wYHoFdMd6drKLvkziDQavMO?= =?utf-8?q?BKNSP64uZ0UA/06MGqasXUXgAUI9lGHe/w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gcrhiHSMQHAw80ncY?= =?utf-8?q?ShbEPFkD6Jd4lTBZEwDooh9+C5WHyHocK4ymCy2mnzWFkqZsLhKs4QDCpIkXBqDB6?= =?utf-8?q?S1CV6+JuZxL4Kmo0Ho5rTX1Y7PQjca6jP29Ep6dyUeTVDTpReHGFppLN8U6ha4o5P?= =?utf-8?q?dMo4Z319efIahNVC8H09K5Brr5vwNqqojpeI4xWlyoRgELC4HXD2nV+qH1ajlGa40?= =?utf-8?q?0ou+g0sjwkmGnP6PJfxjktiyKaRJF9JqOl/cLVi23eHKbAyS/uEWzvfW3BXSJ92PR?= =?utf-8?q?Ok3wO/cqD4yi2cRugBtGY479IlviZO4343w=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)(376014)(1800799024)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?PtFgac0qfZJzPRu+z9rmPE/pP9nc?= =?utf-8?q?qNeePDRxPfYY2cwp7DqN76kAAREA6q4dGMMIWX46ozu9vc/FBnmxI4mYXM5roo2e+?= =?utf-8?q?jU6R3fHRwZIe8A1+JEXX+VYDraZgOhvdYgjhw0Jt4QgDst9DsOJbX3GwudTuv/kZP?= =?utf-8?q?ormEksmsu8B+OJjguFKK+GOZpeBn97jgvwJeaXjV2UwfzKsC/NVP5rmdkrORi8dqq?= =?utf-8?q?pho8TharTTaV/KXye7pxxjewzmXobW249KBhP2CV2v4NXKAuLdE7OrXvOY1UL1y7X?= =?utf-8?q?jHInndbWRUX4d/ZYzXqCuEZ/DBV/RKTtApM8mh2HIOqvxMxyIyTUP7OwiCfQooDyx?= =?utf-8?q?uR07DRcQu8NFHD91hKuUtCL+Hjzbq7df9KWPYHfr1EdcbWXSf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uugO0jJ20ioi+jAB9Kj2bDBGI?= =?utf-8?q?rDQOtbY82ONeuN9OFUO1naJPPc0nPH9d/K8PBgUHmkJZ2D0e6opGlqow4O5FXEQUQ?= =?utf-8?q?ewGWco38DZc0oGguMGM6GNWu3scOp4GzCpRit8AwawZ5+TgufmzokYbKvOAm2yJA7?= =?utf-8?q?JRJsOZdGFr7FbQiszXXiQ4AQDV9X6/FTXiHlR9idXdIh4ssi8WbT0mIsikvz7SN79?= =?utf-8?q?WxjowWMqinfozzl69kYZ44wHEmCTZ0GmGmQHJsfimuDcsTqvRjNDmUyTDMmWMSNxb?= =?utf-8?q?WLqs7mfakwN8?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c6e1e14-3da9-4524-f278-08dce2f1a065 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 14:50:58.6696 (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: n24dRHriu/wBjuesMWjXukQn0onb3SG7pSsQaUUeLHRT7JEcjLTA+ecB6fGhTn9p2VCqHuit22u+O5OMuXRTiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9699 When sending REQUEST_PROC_DAA, emit START and address 7E. Address arbitration may occur at this time if other devices trigger HJ, IBI, or CR events. When IBIWON happen during a REQUEST_PROC_DAA, NACK the IBI request then send a repeated start to continue current dynamic address assignment. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- Change from v5 to v6 - use 'dynamic address assignment' - add Miquel review tag change from v3 to v4 - rework commit message --- drivers/i3c/master/svc-i3c-master.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index c35a228f0c2f4..5df0ec02d73ce 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -872,6 +872,9 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master, int ret, i; while (true) { + /* clean SVC_I3C_MINT_IBIWON w1c bits */ + writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); + /* SVC_I3C_MCTRL_REQUEST_PROC_DAA have two mode, ENTER DAA or PROCESS DAA. * * ENTER DAA: @@ -923,6 +926,9 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master, ret = svc_i3c_master_readb(master, data, 2); if (ret) break; + } else if (SVC_I3C_MSTATUS_IBIWON(reg)) { + svc_i3c_master_handle_ibi_won(master, reg); + continue; } else if (SVC_I3C_MSTATUS_MCTRLDONE(reg)) { if (SVC_I3C_MSTATUS_STATE_IDLE(reg) && SVC_I3C_MSTATUS_COMPLETE(reg)) { From patchwork Wed Oct 2 14:50:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13819883 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) (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 9559C1D1E7F for ; Wed, 2 Oct 2024 14:51:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880670; cv=fail; b=XrpQbJ0l1RvnCNmlJ1mpUc51jQYE1EowVCfAxMWoG/mWWtuDq7dO9yekGP5u7itJhA8wH56c/RCV/LjO93GNiqL8XoS8LLPj1TFrMMuCjqK8fxPjEBkRIwUpWTLHGdrHIQzQBsjkJVuoOK9RLRs6d/EnOpdk4F3nSQ7hzvSm3Z0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880670; c=relaxed/simple; bh=AHvZeWDy6/xYEqoA2DrJdTLBov3b0kSpblBok0ICshQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=qNkW2MZ8lMatX1MGk59430vrvmEuY2JNDW4V72J7pjK/CYNVEPh/Cv7L1uPPQEhlUsVRTuFDXAEA93pc1oH93Z5JhJxJreA0Pa/5jGtx5aF8SV4s2PVnQDbr9M/CZl19Tn+4yH/iY5rtKTNtZTuww23o796+1R22lxXuA0iohG0= 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=dfdl3C36; arc=fail smtp.client-ip=40.107.21.77 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="dfdl3C36" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EXCgQmjw4FqVXa+2pcHmMRHXwJlwNe/owNrJ7VKWnEIJtDc0/NnmTZUPwdIjSzL9qX+fhpmTOVUbbOJA2KGdKbT6qOQufvBovZYr6EGisFcBk6COx9VyXc3x89rC+fHGYwTN1VvsL7d0dVE8aj/dU2/Yvx/0IQimYrlk4NAOdWlBx6Hd/UNxfLXpfUxATddwIooQJ7UPuB87G5wqPoolLosV67g9/qgGLOhx0qZ8ZxxZJW7yBtesijBiRlVOwCAdhQyGqGJE1BY10xpueRbbF9wcUz/8tiJ0bfOXkVTU/TUmZECHlDva1xB1lg+xwKMWqfRFIrihjF4xsh6GITAUzg== 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=LWw8O34Z1PaA0bIpNMoMDZht14UG39YKCT4LXoVb5rY=; b=lUGvaUtRRtHlk66NlAWYcun9d9Knf7vaFByYIoh4YVOMVDXHs9LxD1+N9vozXYvJQBcx6QJeqFU0xb0q5BtxliBuR97KWbJuX2XBi5rNCetxKuRsSTS0p9FTUmS8wU5P2dLGiaXMS6E+Le/juQE+y1s38SB8voipZKUTLGGFxXubIXbErgj2R68mjGXG9YGEGm+AyMdi9t3A3AFt4TludHEUKYOCxUq7sXINuk0PhLmtBmDg5PUz2MkIhCchH5rDqv+DYyyJNZuFKEuxgjTCA954+peu+42Ijl9yHc+FcxtZ8bm7GOsJLcs1ZH5uubLhEG6ECYhO62/Ocb1qGihhKA== 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=LWw8O34Z1PaA0bIpNMoMDZht14UG39YKCT4LXoVb5rY=; b=dfdl3C36PIFZX14Mk4cVwg7Lm1AqK8VELgG+jXqq3Bg0A1eNPyt3ex03n+SKbJ1boWbKAGMu4EAYuQyOHwa2mdrkMf5uD8DcmkkuyYPS1d48Wes+6H4YbFV7hgB5DluKpQFcQEULNEFK+jSdtDnwjjfLszFhUx1Pg6jsKnUoeeQc672x8pvZjYrSt8nnU4Y7IKEB26oz+Wf6+YrjKdVp1KkRat8+w1WrjtBtcUhKbjnka0FgHYEWdL+TiHLwZGgdoXhPYUfEFyfzfrQOtkV2TKg49DLRDYg2xxAFz04D9o5H30ro2TJbG21qc9X73HEvap09nod9fmdw3pFvKzXRSw== 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 AS1PR04MB9699.eurprd04.prod.outlook.com (2603:10a6:20b:482::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Wed, 2 Oct 2024 14:51:01 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8005.024; Wed, 2 Oct 2024 14:51:01 +0000 From: Frank Li Date: Wed, 02 Oct 2024 10:50:36 -0400 Subject: [PATCH v6 4/6] i3c: master: svc: use spin_lock_irqsave at svc_i3c_master_ibi_work() Message-Id: <20241002-svc-i3c-hj-v6-4-7e6e1d3569ae@nxp.com> References: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> In-Reply-To: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> To: Miquel Raynal , Conor Culhane , Alexandre Belloni 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=1727880649; l=2752; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=AHvZeWDy6/xYEqoA2DrJdTLBov3b0kSpblBok0ICshQ=; b=E9naYrDh21bcxEeOMa+vTbTy6zWSgauI4eieu801Jp/W05Hufc/Xrb1eTHaMVezNDN0Y1sfVO 2+1cW0Ih0TRAQOvFQxNuVyKgXv+9vzFnxgm8skshKaoPQkELanThnDT X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0177.namprd13.prod.outlook.com (2603:10b6:a03:2c7::32) 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_|AS1PR04MB9699:EE_ X-MS-Office365-Filtering-Correlation-Id: 68d26252-9578-4d03-ed30-08dce2f1a1c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?RQvvLL2U+GkpGRL/rWs6LYOxRvM/OvJ?= =?utf-8?q?z8z5CB6ZrKcGYah7s7i4PjDWV+YKxMjNymvFhczXfqTTBaH3RqfdY3xYKT2+3HgNv?= =?utf-8?q?uLbvK6uF/PuTfpHKda56SP0x0q6bZ24Jrd3BWFR1rShvhOr+BnAY9vPueu1edGBiu?= =?utf-8?q?KgGKSezFBOgjCKu70uGOwVUHdA277kSRa1NWwn9bzRHrjTC4lMvX/Ga54EJdfye9p?= =?utf-8?q?65haUC9g17jmWO68sFdGAPoWRRD5CAFpYmghpFXHk94Kbk/bFsubc/rLacO1I83yI?= =?utf-8?q?yF8F8v1yk9CRGP7tlD2zcysEk9HwBDiDngDkfqGieqe266wB1s3MGdtyNJ3dcZoXt?= =?utf-8?q?3C6W7BWR8hDF8Q6orIYVe1FZ+pY0otevTI0H2nxkExCUu/0g3WtG/QFcN5n1F62vW?= =?utf-8?q?kirLLkXExXKbZZVo2S7r2cmTBgOyIrfjoV0hTH2QtebBucYbg7SScSf87f1e8+m22?= =?utf-8?q?KfEbuXlGe5ay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SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?4PxHd1VB2F6S97f0m2TIXAju5xPN?= =?utf-8?q?DaK670hlpib4Uu3pZOIQ2mPxQ/cjIxKAZBIzKg/kOudnxcuD5UFbjQPrV9z3JuMNG?= =?utf-8?q?2BduaQ0UEx8tl3fyXiHpHD14n4qqzhCO2c+LyRCVVbIXHxJwNBR9bJGqm0iqcY+nt?= =?utf-8?q?nrx0cWHBJY/0c2KJTc7oMIe0juunn+GGLgjgEvlyY8C4kcMOEyTcWUaz/p5OXksk6?= =?utf-8?q?cOuCP0uoT4OnM0enZLki9Vo4Zj1uOmqt8+512nCU7fw9Py0d6F3nY4OSfwYVAgj70?= =?utf-8?q?tdDzL3z1WuDlGCx7CFGbQxCGKtXHPpNhHbwmrbPdG2P33R16wU8rai+JKgYfhsLmF?= =?utf-8?q?2YpwJ0lNDXlUZNzexYcCaKQhyHFZ/JAUuk1kLP1rCF7M0mjp7kIQ75A3IavA7I64y?= =?utf-8?q?JdkB4kFJnbf/sVP1rb+ciXbKo+Dafp0EwqIdaf3mS7AzBrZJV38qvqWA8O8JJM3mW?= =?utf-8?q?npc1uCjgNQciEtn6m5g659ICdPH1K4sWHnWf9ScUlfx9i7sBZotYGUl/ZXEbK+Oqq?= =?utf-8?q?D/sYZl81ABSOdARtEWnN2raQbDd/QMaphx8tiXGqpPrBsVja20EagagWqoedNH3UB?= =?utf-8?q?n4niCrqYjc47HogTiTHoQnFF62wDqo8LuOgy3XTY6c2x2qsMxLJtDEiweTAgWjyQF?= =?utf-8?q?4Q923/KjQii6AFPI0CYYFskwyu2IiPO49KQLaMqYI5MTrw/FZyi2IvPhO2LyjYbve?= =?utf-8?q?MpSj28EcA3lDUjxP7mu3t1dNvErCnZKkDu0iXLqCsTXcDuVf8QwH6XuUCGGBJpkmr?= =?utf-8?q?BCrEky55P+q1g5NeIcDprmtWG+oJealwm7CPLdMDCZXmwIGOwsXhfURvmqkk2aOG6?= =?utf-8?q?CKO1i4Uzx0UixolSkGnu2Ji+LcDVVgUiLEhXKeJZGj90svJ39mBxXriwL8IuuXWij?= =?utf-8?q?pwvNeQ4iItRF6Vw5L3hbDhvWZEWdfr1x5W419IHxwb2ak/PVcvGDyQeXK3OqTJEDr?= =?utf-8?q?6nf7dxaeo/s4gNlvSR4OXcBwy5uoGh02fGNqQ122kN0D78Ri1RfwqNJQPNEJu98bz?= =?utf-8?q?pDP69ItuYxb3Wi26ajHpDooo81OrbnfswsU5jkqrp0I3dowX/PWA2z/IKEahwu5+z?= =?utf-8?q?SvPhgkUJRTM28ID7T1hcnMloyoh3sAtFRPoRiAswZxsB7Cb2J9iSgx9NYNmy59MHN?= =?utf-8?q?wxXhYhoRhQiRY5cnbkwgmsYbiM//84LzRGwWIe1BUyA+/KaLNcH8PrvMUtdeO9WpX?= =?utf-8?q?IDxmVwoK+SxmVqFuAtOUSPRQ18tWrWG4FyllORMZ67ZXctOYsqElmv9UlxbFpCf5H?= =?utf-8?q?RwycCPvMOtikv3F0COb7DR8B097+f8363lg0ObMq7wuTPkWSruoiTiJEcH+lXU6hg?= =?utf-8?q?DNOhH8MiSPZ6lDeuc2S9wJLRb8HwBbqIoWlrf3IEpqHYoywWn1aqEZ4rY9WxDsiXc?= =?utf-8?q?GD8zxh5053KDQ6sEeQBVkYjRj+LvzBGQQ/zwS41joTcyGeolKT7n+4sTqB6PDRlZ0?= =?utf-8?q?UygKuyBBtcibdXdgJpAAZMhvBdqA7EvsCNvKYjBhBOJ2sOq4obSicfgL0aq+TCwEv?= =?utf-8?q?ud7Pm3lDtgqA?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68d26252-9578-4d03-ed30-08dce2f1a1c4 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 14:51:00.9681 (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: nL0mxQ1QKI3wM3AqqmtH9vozwrF+KuB6h+RSW2i3d7fg3rIHHtSNhfaeeMlanGNsedJJG7LhSBh/I4IPjKu8OA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9699 According to I3C spec ver 1.1, 09-Jun-2021, section 5.1.2.5: The I3C Controller shall hold SCL low while the Bus is in ACK/NACK Phase of I3C/I2C transfer. But maximum stall time is 100us. The IRQs have to be disabled to prevent schedule during the whole I3C transaction, otherwise, the I3C bus timeout may happen if any irq or schedule happen during transaction. Replace mutex with spin_lock_irqsave() to avoid stalling SCL more than 100us. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- Change from v5 to v6 - reduce timeout to 100us, normal get IBIWIN at 9th SCL. 100us will timeout by i3c spec. Change from v3-v4 - improve commit message - needn't mutex here, other place already use spin_lock_saveirq to protent i3c transfer. --- drivers/i3c/master/svc-i3c-master.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 5df0ec02d73ce..ed3f1bfbea37a 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -436,7 +436,16 @@ static void svc_i3c_master_ibi_work(struct work_struct *work) u32 status, val; int ret; - mutex_lock(&master->lock); + /* + * According to I3C spec ver 1.1, 09-Jun-2021, section 5.1.2.5: + * + * The I3C Controller shall hold SCL low while the Bus is in ACK/NACK Phase of I3C/I2C + * transfer. But maximum stall time is 100us. The IRQs have to be disabled to prevent + * schedule during the whole I3C transaction, otherwise, the I3C bus timeout may happen if + * any irq or schedule happen during transaction. + */ + guard(spinlock_irqsave)(&master->xferqueue.lock); + /* * IBIWON may be set before SVC_I3C_MCTRL_REQUEST_AUTO_IBI, causing * readl_relaxed_poll_timeout() to return immediately. Consequently, @@ -456,8 +465,8 @@ static void svc_i3c_master_ibi_work(struct work_struct *work) master->regs + SVC_I3C_MCTRL); /* Wait for IBIWON, should take approximately 100us */ - ret = readl_relaxed_poll_timeout(master->regs + SVC_I3C_MSTATUS, val, - SVC_I3C_MSTATUS_IBIWON(val), 0, 1000); + ret = readl_relaxed_poll_timeout_atomic(master->regs + SVC_I3C_MSTATUS, val, + SVC_I3C_MSTATUS_IBIWON(val), 0, 100); if (ret) { dev_err(master->dev, "Timeout when polling for IBIWON\n"); svc_i3c_master_emit_stop(master); @@ -529,7 +538,6 @@ static void svc_i3c_master_ibi_work(struct work_struct *work) reenable_ibis: svc_i3c_master_enable_interrupts(master, SVC_I3C_MINT_SLVSTART); - mutex_unlock(&master->lock); } static irqreturn_t svc_i3c_master_irq_handler(int irq, void *dev_id) From patchwork Wed Oct 2 14:50:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13819884 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) (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 05C951D1E89 for ; Wed, 2 Oct 2024 14:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880673; cv=fail; b=pMX3WlrUb0/ZPBkUDr2u2q6OulvR8b797JU74bc2DBZoOQMh7mB4/5bBXIUp9TaGVi1gxio2ne7+HNxI7xY+qaUTD7yequfFvv7tYxJaK2fkfSDiFuvUmeOccTXzIM4gJSyQjSjjvIiL9yq/jws6iZ0sErYqJtM2/MW/bblz3Jc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880673; c=relaxed/simple; bh=G9/ttx8HfBwzcCCJhNo04kopgONzp6KBdwhqa41YDTc=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=esocUvzZcuAB6dk1T5g+vcZchXlBar2h/Gkzsxyd8cBencc8dR1PAe10sXDKJKo4ydbxcnyw9S75363VRTHMfPCZQing6SERsp8UMmFpOIgBYasXnS830rTjno4GykAlEgJwci13hZoOZA9G83j38kPJrPIg6saZQcbe0HaVyMw= 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=PEXUPkii; arc=fail smtp.client-ip=40.107.21.77 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="PEXUPkii" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nXkh5eALk5vyRhsUdVGILm+dGYBIk5oeuRaj+gZOBUDJUkYmXgZPrg6h4dCTO8cpOBaQB8gi4L9kmWK452CWppmH3TOODVrjlb/Djq4XIEP5uOuxs2qhAIbrkbs2NgtbQJQQ8mTUCMCAcbbSMpH5bI+1tOamF9Ievxys5zCVX4LkJRLjMkzW92mcb6Byr87EuLR0WiaTVblRIqhI5JdKkrsuDzhmH335GmLUE0+LjzIAqY1d3eFxBSE3YOvSXa6H6XUXjeT6IcOqbay06XEAHcNdAEb1+QPl9/xMlp09zSQp4Fkdu8jGFxY+a+tx/Vu8u6PpQsSsBjDlj5oNuCysXA== 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=xCabqBI/J+Um2gFtk/c1eujjBGuD7tYM07r5dx9+W6Q=; b=jxdP2DcKPBe0zDSp+8mzcrWWYge39sggik/ye06ecGSDVTLcZkw+y9dmK2p2yryun+GAup7KO8i4naz9XLy+uTOwrhAmXYhSQC7mA4tpiB2Wl/GfbR6mkmGic72Nv+4zRA4nLCmj8/dvY64JEifwdYqUdhnwHdRn6jsFFthID1mQMfuRYINfaUpmGUX3kbS04KXrss5OmJmR9U3Plb4ifmzWt9dcv/Al1unOPC8o9O01XQRyA5Hu8LdQOiIhxvNOLo+qjkXByge6JIhgz7BpA3MPvV1zyAFjY/yVzZtBL7a1j6jPfHoHaIXn7h63M/7OTUIZ1ZneEiZtg7J8XQK4QA== 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=xCabqBI/J+Um2gFtk/c1eujjBGuD7tYM07r5dx9+W6Q=; b=PEXUPkiiO8XmHi0q/MkPrTL4+Bta8iS9vIrlsqMXWLLFKYb6VWEs6EQdyQS3NxFBZNAfsyxoclRM3dEzIUsNKGDGNuvBVwIeIivOs6yfW0GOpQwn6yX50zhHU4nhVxzLurGrZvZpOKMpxWSQhr1slRXju5Dw0MZEHZbns8N8Mqb1Mv49Xv1ekz1Pr3anl0GullU3nqLwZn0BJiavZj1hwKEf3st+o9fGrxxIxU1kORPSwyC7aaV/ISY/4RqL1PktUZATXeWNy8BiLsa7qjU68INIe503EZ0f6VqnpblGvMgbVvM9vcQlBTrpNnXPJvoGNJxDex8H7rzM1N0w4k/f8Q== 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 AS1PR04MB9699.eurprd04.prod.outlook.com (2603:10a6:20b:482::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Wed, 2 Oct 2024 14:51:06 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8005.024; Wed, 2 Oct 2024 14:51:03 +0000 From: Frank Li Date: Wed, 02 Oct 2024 10:50:37 -0400 Subject: [PATCH v6 5/6] i3c: master: svc: wait for Manual ACK/NACK Done before next step Message-Id: <20241002-svc-i3c-hj-v6-5-7e6e1d3569ae@nxp.com> References: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> In-Reply-To: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> To: Miquel Raynal , Conor Culhane , Alexandre Belloni 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=1727880649; l=3372; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=G9/ttx8HfBwzcCCJhNo04kopgONzp6KBdwhqa41YDTc=; b=j0Cy3zpyiNPCgiiRenemJPXQtFjOsLeN0k4YpZehwlftlCPnvrOwh84fLbeXlV3tjg/OQC8vk cLXKwyPyjfWC8euOFJY6eV/24w2f7PuVitZptCbp8suugX96dVVqxqO X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0177.namprd13.prod.outlook.com (2603:10b6:a03:2c7::32) 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_|AS1PR04MB9699:EE_ X-MS-Office365-Filtering-Correlation-Id: 35375ec9-9797-4301-1bff-08dce2f1a324 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?efM1SY8QXvO8tn7bmGT1mXLJ6MhyjoG?= =?utf-8?q?6h3Fg7cQoeWQIKTjMuviqM3WEnA8QFd4MscdZm2b8xgTw7jl1eV16r9mDhTbhLUsI?= =?utf-8?q?niZRO52YFuFzyiXMyvsdl79Dd35vOvCjIUY2q1ihbtnWKxCRYv8GwolcfHNpxPzL8?= =?utf-8?q?EO7UaqkuRQFeA9O3T9mGCJnf7eIE1w/Crcw0c3w5t/WDIbm/OpgfplG+92jrlqcP5?= =?utf-8?q?4yXo5sUmBYl0x3IWE2hxIRgDw9MfKJdhRWCEMPtqnLaK2YyW0OcHwKZT3Chjsu8sr?= =?utf-8?q?B468z6KREOQlhcFD9TO/liB2axxIxbFC38UQea8X5W0GuEilodo1g2Jar5TbO5W5n?= =?utf-8?q?vBR6klN2qlFJEHZZxNYBfbLHDuUHYYXR5HQ3HPt3kN1svH7TpL40vwN29xz1DzevN?= =?utf-8?q?M1W1ko2MCYsVETv1tpw8S+Oaszd8x2nzC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=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)(376014)(1800799024)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?qHrZHFVmC4yj4OoUsKw/ZcM9oaIE?= =?utf-8?q?iqzEROKWvsr8ZDtS0IBuBqLgpLowzO1Eihrwq4HQPAL7/P0w5hY26SpRrU/1safVM?= =?utf-8?q?6sVT+zewLpRtd6ZUClw/9ODkQsAC3uveSLSichbiFF9xYCc2GHKRBOnCtK5zsNWbu?= =?utf-8?q?SzupPkhSTU2f4/gMJcR0z5he/TY7/JZvNGvNaWhWLngAN/eu0pvuQ5j4Qy8qjhae/?= =?utf-8?q?ZtTD4op8YyuISTn7C9wM+wsvdJl1t7+szRvC6SRkThMxYHmNBkI4vJUHHZn+SwVbj?= =?utf-8?q?trsuN4mIjuV5w+cC5u7uSDTYDIV5h6AFn04JQLuzGmIIWAIsqGfvGLk0+x9dWzOnn?= =?utf-8?q?eqr24C357J1GSL+KbmmySA8xzOF5QOK+faLCH4N2YJMww3cGQKlrIC1q+gqfJxFgz?= =?utf-8?q?M0X+7h6Iq0pGxTY43iqpVzgYZJ/rHDh2p/YzZuwONisEwLlP6swtGFBFybquJoGlq?= =?utf-8?q?Zy1zdSu/Sfm3QEEC8V38cVaUWx/ERXYM1iQcOe+Hmf7/E65lNKyeiBrse90MFh8+s?= =?utf-8?q?TLakQehTj+kav7qLeAZ9wSH0lk/WlhZv+jM9j7xOJ5wovdHhVlgOJahbKV3THfTVY?= =?utf-8?q?YWZ5ayLD2RiOEGxWHlDFnqFAUO8fnawfXhIXspU3gsZN1PJZ46Tw+WTg60ieWf53u?= =?utf-8?q?k6KLYA6wJEkZ/shcmyx+Zt/cp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p.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35375ec9-9797-4301-1bff-08dce2f1a324 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 14:51:03.2566 (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: Cx1JgCw6BMVgYqsPZbDQA7JO//otiwWncNvPum3BFme3Cn73gxxpXcIZZbEz08MHSWJPLzNmvUwfZSAjEpAacA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9699 Wait for the controller to complete emitting ACK/NACK, otherwise the next command may be omitted by the hardware. Add a "command done" check in svc_i3c_master_nack(ack)_ibi() and change the return type to int to flag possible timeouts. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- Change from v5 to v6 - add "add a" at commit message - Add Miquel review tag Change from v3 to v4 - rework commit message - add miquel's review tag - directly return readl(...) --- drivers/i3c/master/svc-i3c-master.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index ed3f1bfbea37a..7ef7e50b4b916 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -388,10 +388,11 @@ static int svc_i3c_master_handle_ibi(struct svc_i3c_master *master, return 0; } -static void svc_i3c_master_ack_ibi(struct svc_i3c_master *master, +static int svc_i3c_master_ack_ibi(struct svc_i3c_master *master, bool mandatory_byte) { unsigned int ibi_ack_nack; + u32 reg; ibi_ack_nack = SVC_I3C_MCTRL_REQUEST_IBI_ACKNACK; if (mandatory_byte) @@ -400,18 +401,30 @@ static void svc_i3c_master_ack_ibi(struct svc_i3c_master *master, ibi_ack_nack |= SVC_I3C_MCTRL_IBIRESP_ACK_WITHOUT_BYTE; writel(ibi_ack_nack, master->regs + SVC_I3C_MCTRL); + + return readl_poll_timeout_atomic(master->regs + SVC_I3C_MSTATUS, reg, + SVC_I3C_MSTATUS_MCTRLDONE(reg), 1, 1000); + } -static void svc_i3c_master_nack_ibi(struct svc_i3c_master *master) +static int svc_i3c_master_nack_ibi(struct svc_i3c_master *master) { + int ret; + u32 reg; + writel(SVC_I3C_MCTRL_REQUEST_IBI_ACKNACK | SVC_I3C_MCTRL_IBIRESP_NACK, master->regs + SVC_I3C_MCTRL); + + ret = readl_poll_timeout_atomic(master->regs + SVC_I3C_MSTATUS, reg, + SVC_I3C_MSTATUS_MCTRLDONE(reg), 1, 1000); + return ret; } static int svc_i3c_master_handle_ibi_won(struct svc_i3c_master *master, u32 mstatus) { u32 ibitype; + int ret = 0; ibitype = SVC_I3C_MSTATUS_IBITYPE(mstatus); @@ -421,10 +434,10 @@ static int svc_i3c_master_handle_ibi_won(struct svc_i3c_master *master, u32 msta switch (ibitype) { case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN: case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST: - svc_i3c_master_nack_ibi(master); + ret = svc_i3c_master_nack_ibi(master); } - return 0; + return ret; } static void svc_i3c_master_ibi_work(struct work_struct *work) @@ -935,7 +948,9 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master, if (ret) break; } else if (SVC_I3C_MSTATUS_IBIWON(reg)) { - svc_i3c_master_handle_ibi_won(master, reg); + ret = svc_i3c_master_handle_ibi_won(master, reg); + if (ret) + break; continue; } else if (SVC_I3C_MSTATUS_MCTRLDONE(reg)) { if (SVC_I3C_MSTATUS_STATE_IDLE(reg) && @@ -1209,7 +1224,9 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, * start. */ if (SVC_I3C_MSTATUS_IBIWON(reg)) { - svc_i3c_master_handle_ibi_won(master, reg); + ret = svc_i3c_master_handle_ibi_won(master, reg); + if (ret) + goto emit_stop; continue; } From patchwork Wed Oct 2 14:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13819885 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) (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 5130D1D1E89 for ; Wed, 2 Oct 2024 14:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880675; cv=fail; b=QSY1GInFh/ByX+TPa23ftQYz2aVntmRkN9MmQkil4PMZjeXP9UPV8f+jZZRFs5aQSODy/V+oNuL8pdiSt0+pf6hgibSggDodP0YPwCTuEBFWJjit+BzKhOwMydFpMJncpblP006Uu8IvtNu9UUQtnWMOXXKXAAQX8Lh2e1R1RBU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880675; c=relaxed/simple; bh=mTP2BQfrL2ajg1eLnU3vD3yNZnTqEe/2FbB25MGO4Kg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=EGfAjx7NJMoy8+0luKGJiQdXzVKpeVtSgagHgMEjY7mKHWZGMAtPzijpLKqIXUVGCIWyMpAOYcImWGeCnKd2a4d0jIC+itDgJVs7yg7W62OgXyd7re+lNfPeuKg91Gl1lxxZfgQPx1ar6ex6h69r90/lTpbAntv7JIR1CF+cECA= 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=L0G+Cpc5; arc=fail smtp.client-ip=40.107.21.77 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="L0G+Cpc5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KDpFlRKOfqscIwMUlv7EmR0JPzXfERhf5kzhGgvzgfuglacLItBOphybdR2wGm9qnLTqQBF+WaWDEN76TAUhVmpKyWj7KRRnwWGtFUZ/ZsQLaD4FF2i2/REGYQVziBEb5VSAavARVHM96xq4E7Zb6KoEPugMYQsNVMjYNiFjFUOUHeBLurd+A6Jr+LdpYYffnMaQDO33Kmnc8K8L0VSNMyE6gDvVDQTAo0iK8HAsitvwFqt4EtlkQxWX5Cm37+hJeS346FTXlbejNeSeRPs0BeJQOONJvZ8QfXIB4dBiQfzNasknDfLGGrfhhopALeKtmwAZadeNtUH/cZri1x/Evw== 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=pG/i8HsPY7XlHxdpjxt1xiQs79KpN78+7TFWBBmUyn4=; b=jxEEVW8MphB3BXTuBR8FpkTTR+mWupxlrp3fQri/sBjRbd1Ks/IWJay7FkFRKf/dN/++Rtnoxf3usMfkGKhFbhFN0GgcBtrpQAmJuJMTk4+RoH/Y+QeLNzI1A9DybRwgDbfIwV67ccA3tNbPf0OUdDhuNiWjhtTjrLygrbXcGdr9znxYlEhLlrD1T0VavfUR7b70A5c5B8V4pP9qv/je2zi4AUVOPw1mGVp3FN8528Oi/96roDzmO4TyHjhJ/1+7gjE0Tkx5UeLfGxGH9jfmb3AanHoMYYPvzc+HgiPI+hJhJYwKsKsUuHvvisqFew7v16VmMaKOgzECH7zmCUpo5Q== 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=pG/i8HsPY7XlHxdpjxt1xiQs79KpN78+7TFWBBmUyn4=; b=L0G+Cpc5QKvJ7BH2Kn8+2DTYUrWO731v3SHmSCgxqZw9gliH8iSJhwJNad0x208PGFvIOWJvH8rMLEPuwZWdm40/0aqIK6+UgAle03nAx+BTN/GM0abssWPlHvcqvEqmW6Xw8hkQeiY/T+VvLEvZ5Xu712au3YIclXRgtxEKObLUDd6OOx+60PNgjZpttXlT3C0eS8H4m+Y8+mrPB0OzL4GhSQMhVqXWhBIy76te5XmvOC/o+04Cx9h9/2FV7M6wh2nn/bA4JH5twsFAFvehVsHzItIlsj0GNIwNGEjAXpagvdXhaf1a7w22+sy6yxLyVJrcJhMtoddS6ZAuMT2jkg== 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 AS1PR04MB9699.eurprd04.prod.outlook.com (2603:10a6:20b:482::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Wed, 2 Oct 2024 14:51:06 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8005.024; Wed, 2 Oct 2024 14:51:06 +0000 From: Frank Li Date: Wed, 02 Oct 2024 10:50:38 -0400 Subject: [PATCH v6 6/6] i3c: master: svc: fix possible assignment of the same address to two devices Message-Id: <20241002-svc-i3c-hj-v6-6-7e6e1d3569ae@nxp.com> References: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> In-Reply-To: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> To: Miquel Raynal , Conor Culhane , Alexandre Belloni Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li , stable@kernel.org X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1727880649; l=3214; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=mTP2BQfrL2ajg1eLnU3vD3yNZnTqEe/2FbB25MGO4Kg=; b=/j4Z1kpOPNXOtRhpr8OSpnJ12IrkyS73HdhZikRFyEIZYibXeJA60RWSmusqukin5vvXGJLfy O4s91/3DMDaDl4843Cf4eMchhEJFNT4Zbg9ubDnITeTjYzQ9qwBkgQC X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0177.namprd13.prod.outlook.com (2603:10b6:a03:2c7::32) 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_|AS1PR04MB9699:EE_ X-MS-Office365-Filtering-Correlation-Id: 4417582f-8a88-49e5-3935-08dce2f1a4a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?FjubGUGi3uJOepWT3rC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P2XBwsPPo+z1?= =?utf-8?q?sXZVZdErHbS109UgY/rblqA1/RmdBC7kObgC1izZp1Pm2wBwxFKS1ojdsssVN0AOC?= =?utf-8?q?YSzQBKTLH+l7xHBxV+03M71qHLSrAHNh/vL4w7qm0QieMJ3MNYGfJ3bEpltvmiPqS?= =?utf-8?q?xPWykHSzDmO75FiJ7BWnydQ2a/LHLfdCJ5KeplJgTLTWj2PeM4WEp8tTD54i1A/ea?= =?utf-8?q?HE5WBCORZpxd9cpU513ZraAgINxQBEJUIqhhkCQ5TPSAWe8C6yXY2xragADV2x1ep?= =?utf-8?q?iBauUhlwlm6Lx1D2eSxWTNM4GUb/XrjzRRPKrVwEucDS6CAZgWxs5luCQbP5p66xJ?= =?utf-8?q?uFupwr2wzUf0IGJ0Rtck4unUqfGUDU/NOr1qu0sh8XXtJe1fF9/5087kba7b65dEF?= =?utf-8?q?HCdu3W/eTiUg4pC8x4fmhzJAkVgKb5XVqZw=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)(376014)(1800799024)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?EZQU6cP24CUVUBhgidL1Pw0aA0j9?= =?utf-8?q?gCe9E00+eRM291d0oHXYpo/h9t6adMS3DZDI40kmlmcRqOgZ8yNKWvXukV/vAX5pN?= =?utf-8?q?+iRMSWNfDQCgjlsv0Y9/Z/h0dZOohnJUW6n2OCStN3Vlb5ejxuyoj9gyd+BPI2X7W?= =?utf-8?q?QGkUBx7Zrh0Tv0WN0RqLEZivjRGxUI3womyN36HsRCdqjx9maloRiEBUF7NVe3t5o?= =?utf-8?q?W5mi9rvpYDgNnK8EZ3W0EAblOCbvwnGQgoqRkV1eP76pLW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FQK45s?= =?utf-8?q?ya2HUZm7RaZ2A1p/n8iXWFM0OKva+yrDmhn8G1e2/TazNegc8QtcYvIvPUb2NHOA2?= =?utf-8?q?85wm2RMaoCj6Uy60rhMI2zZjP7i0ntyTG7nR6cdt70aaR25PnMQq18tsH+9hoYT9Y?= =?utf-8?q?7OUPvIAczmO7GwzytxLdCMuuuwB+KjaORBbimozRRS9uRK+gtMlBS+l1IjHRoaZv8?= =?utf-8?q?WeFQ0KA2Ggo9dZtHcWm8KB3TzJlURo17uzLU1fjx8SgXehTHdLf+rE8vohnxMc6oa?= =?utf-8?q?DkPw/PtG0vTp9FcLZJGnBWJ2DY/IjfXelLz8vUL9rN9AmqB9L6/rRKm21AsSWjYTJ?= =?utf-8?q?6jdx0wLagTcWWU5excWeANMs2gTlAbfV3LhryUjfP9wJUCkX7guR5jmbObwqv9MWj?= =?utf-8?q?y52iTudqCP9n?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4417582f-8a88-49e5-3935-08dce2f1a4a1 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 14:51:05.7505 (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: BUUt7pytChGHV8EOUenVS2yxr5bhQsjm5AXpNcVWdH0WiuzfH80YMGHg4NyqFa7R4lqd9wJPSD/XjOytB84qgQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9699 svc_i3c_master_do_daa() { ... for (i = 0; i < dev_nb; i++) { ret = i3c_master_add_i3c_dev_locked(m, addrs[i]); if (ret) goto rpm_out; } } If two devices (A and B) are detected in DAA and address 0xa is assigned to device A and 0xb to device B, a failure in i3c_master_add_i3c_dev_locked() for device A (addr: 0xa) could prevent device B (addr: 0xb) from being registered on the bus. The I3C stack might still consider 0xb a free address. If a subsequent Hotjoin occurs, 0xb might be assigned to Device A, causing both devices A and B to use the same address 0xb, violating the I3C specification. The return value for i3c_master_add_i3c_dev_locked() should not be checked because subsequent steps will scan the entire I3C bus, independent of whether i3c_master_add_i3c_dev_locked() returns success. If device A registration fails, there is still a chance to register device B. i3c_master_add_i3c_dev_locked() can reset DAA if a failure occurs while retrieving device information. Cc: stable@kernel.org Fixes: 317bacf960a4 ("i3c: master: add enable(disable) hot join in sys entry") Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- change from v4 to v6 - none change from v3 to v4 - add comments about not check return value - add miquel's review tag --- drivers/i3c/master/svc-i3c-master.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 7ef7e50b4b916..e9c8e340d861b 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1103,12 +1103,27 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m) if (ret) goto rpm_out; - /* Register all devices who participated to the core */ - for (i = 0; i < dev_nb; i++) { - ret = i3c_master_add_i3c_dev_locked(m, addrs[i]); - if (ret) - goto rpm_out; - } + /* + * Register all devices who participated to the core + * + * If two devices (A and B) are detected in DAA and address 0xa is assigned to + * device A and 0xb to device B, a failure in i3c_master_add_i3c_dev_locked() + * for device A (addr: 0xa) could prevent device B (addr: 0xb) from being + * registered on the bus. The I3C stack might still consider 0xb a free + * address. If a subsequent Hotjoin occurs, 0xb might be assigned to Device A, + * causing both devices A and B to use the same address 0xb, violating the I3C + * specification. + * + * The return value for i3c_master_add_i3c_dev_locked() should not be checked + * because subsequent steps will scan the entire I3C bus, independent of + * whether i3c_master_add_i3c_dev_locked() returns success. + * + * If device A registration fails, there is still a chance to register device + * B. i3c_master_add_i3c_dev_locked() can reset DAA if a failure occurs while + * retrieving device information. + */ + for (i = 0; i < dev_nb; i++) + i3c_master_add_i3c_dev_locked(m, addrs[i]); /* Configure IBI auto-rules */ ret = svc_i3c_update_ibirules(master);