From patchwork Thu Aug 29 21:14:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0003BCA0EC0 for ; Thu, 29 Aug 2024 21:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=YTccM8y6xnroWC0LQhZTZWZiF4+PixIsXOvK3cP77Zg=; b=EApJd+6r7MbzwVriELE1a20yGo BOHQIUVziBjVN3VAT/FPZWv5KPdJodfLlVT9t/nM2aaOKwlfHKEXiQdhnDHWOa+Cufoc8JushsrdS yBxojjeDpfT76i8QoiJxok6aM13MNKEpvB7Ykww/tjAbiiGh71KnlfP5XRO+7ozVlzaO7u3nVtlFX 4Nb4sJWeFzAVyq4EmqklTrH8odBfiygsW4PIdr71mxT1f64IzgoJESgePy46VKeRBwFOZCJKQXaAw PP0QMWujqG4HLmqw7fu0g4JUeRQP2E0a0eYC8QLRlPkf4DWJnRQI/giqo7iXWrlKwsk1tiXMsoqK9 HfckIhmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjmU2-00000003eu6-2d8x; Thu, 29 Aug 2024 21:15:10 +0000 Received: from mail-northeuropeazlp170110001.outbound.protection.outlook.com ([2a01:111:f403:c200::1] helo=DB3PR0202CU003.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjmTz-00000003en9-3nyZ for linux-i3c@lists.infradead.org; Thu, 29 Aug 2024 21:15:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vZAtHgw8nc9DdHp31vwQUEw6+Hc541LHQBjBgyoNpWCmNB0y06gsfTorv6lTrhZKy24224nQ0Vo1zd4FElXmhodT7Rh/u04yJBfbEvZqoAQbpl8VxLj+mnpQwGq5FXGr/ybi+KOPgnzTLMv49Br2BWLZ8gjO54S2Qyx035fy7ZCZQ6WkwrneeLK0W8F8Ca6Zsr4eiQOMD8qO4HKRllt81iytkT/rEoO6l/suzrMzwOQsn5PqtRUnJUiLxsIOdBZCeT7vhNlcaG2RN8RYgTft2yKJyMAmXG6fc1gfP4Ttc45PwsLrmoXzuOBHIrCFxepo8XCQsCbTMS+vdlpen69pFQ== 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=Uyx+TpP5xfbE3/AGBE1UbCF/0NSSEri7MUmkmrHirSs=; b=Y9+/G4oVx2XzW2Do6ZPVD6eFDpk76I/UkH/eByXv6l+awDsZiKHPrOMr7Q/bWF/5y29gBmZQOszjlk7wuHLJ+3XuKPyN0rYsRDI4kTViI4vMxTNFNBQ6U3EXMvXD4a/fSiBMgnhbUOXkpxPUhXJqBHJOvW566iB30X1YZt40O8WXD3G7XVHyXMp6KFxvDiLKVFl20TsCXQLmwsO89XILiEyIWILV5oFjCh4DSEQaI7bJe2tjetKQlzJiuPkFG+aq7L1yWhYj3yaRFgJ7AVInBjhcKvRVHf/HW5dA5L9Cb8aJd6yl7fhqk44dTZ9pctc8NwnjR20VQFAX8etbJdK1Cg== 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=Uyx+TpP5xfbE3/AGBE1UbCF/0NSSEri7MUmkmrHirSs=; b=Dh6WkxuIABVTFihQ9u1vQPLkBo4FBv9pSKYhZM+w/HdsvCvCboLve7ywEJWTugKK0Micd2N5CjgaJOB+mgB3/2DKg6sAExLdPM5DjOnWgFH3iwng8gsZDgdKwbC63Ru11LkP2TOm2FehAaNkv1ttWnbEGK3LHd6WzZ/mSK/gBnstHwf6kL+29HUD4yrhCS/NGcNSFyQo0D72t4tu529fB9v8lo5bS5p8JwrN31zy51GJ4pv7hIWq4HvYNi85aXZuvBw2f6ayo47g2VzniBZ7QmtL85yGDucllB1S45nUOj0B5iIqtaydWG5dIX6to4UtwsjQazLxXNDBNw5Ox8siLQ== 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 AS8PR04MB7560.eurprd04.prod.outlook.com (2603:10a6:20b:29d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.28; Thu, 29 Aug 2024 21:15:05 +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.7897.027; Thu, 29 Aug 2024 21:15:05 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:14:03 -0400 Subject: [PATCH v4 06/11] i3c: master: svc: use repeat start when IBI WIN happens Message-Id: <20240829-i3c_fix-v4-6-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@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=1724966083; l=3646; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=qoRJEaDC8+N7UD0gElr8zzFjuK4hIVhisZJn1vsj63I=; b=c/nYztxEZCygiNF55pTkPl7g1jp+0wK+QHV+VrvuzVHhrUuK16zWNzRXqRyGvpyZCNIj4qQNC ldDjtCA3SfZA3rKxSl28TJYXV/0vvWCVtIg1hjIB2UJWGHS9doLFpaz X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB7560:EE_ X-MS-Office365-Filtering-Correlation-Id: df60bbe9-194a-4290-82f9-08dcc86fa77c X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-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Ivtt5I1+ywW7lbX3yZXpgR6?= =?utf-8?q?kkkWY3z1pC/IvT1aLIjP/axmZdVP2Zo3Ms2r7msC8ho3xOMC989KtRrXLw50NtsLo?= =?utf-8?q?3QxClrsj2ZHK+inCQ13uPybNtfxGacme75/iopnrf/1TSfypI5X6Hec1n2Gw1ww/6?= =?utf-8?q?3wctz3zg28n/K38oYDDR9c8u6x8Z3PGHhauVWp4mexByQtb4d5t4sdkPuw521gwvC?= =?utf-8?q?FwhDLEc+vWCB1EYQJDyNZ3Dy4kHAuanGVAzcPBIJAFNfNBtK67oyn4SCA2DwD2AwZ?= =?utf-8?q?OzATv9STy6k2wkW4DgU1Mbbs9kaniAe4oUHrl0q2iv0HX0QPZ0KNOolwVBAYTvJ8G?= =?utf-8?q?ydfSf5kKE7cVNtU/BBuyFOcFpBuKCQVnmerL6pUXB+DF+dhCZcO7wPlxNHbSTi0gq?= =?utf-8?q?/mslIxOnIgtF6EUPbuaPvG9W/PQPZNZZ8t7/KKdF70AHbBXqtitGoWFfWZJw+IjmB?= =?utf-8?q?5YiZ/ksi9o+4yC68zdTcvr6SPH0/pj/Ikg=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)(1800799024)(366016)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?5FgFTkEbpAwB8YTUlg4xeeBFlbXc?= =?utf-8?q?4OvjsVhARunf5R/BPgs5L7/S3KfVa/hB29+6TT3aOHGIlb4Cv4N5lsbJSi9BIerPa?= =?utf-8?q?ZTF5MwrdOxbi9+/O70t5JfVNH9eN4Yf44Wn5dEhZuwGzkV3j9KAVysjyD6QvYD/CT?= =?utf-8?q?rM6YObwMnMUc2phc/F/00J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/cp/3Qf3Z/7P7wluoizXNrRbUnXZOtJVk?= =?utf-8?q?XSnz0DT0cnIMbKkVwK70m1tT6rmTMSztXZv/UWIzOnA7/D1ws+Z2/qM4p31WIbnOJ?= =?utf-8?q?EQHnBd3kTvtq2uoOz8I8M3Rin6LKR3uTea/xJxgFIcQLypXU7NxFiGcD1IvhHexkC?= =?utf-8?q?QVfdzspkVl8ysO2WSd0LF8dfAl1omHWt/Dk5w1vMoltGWURbe4vVFzRtgBMU0dRpP?= =?utf-8?q?CRbvFCiGHOog7dV024xfXYXwvlA/KvfaaUctXyA4767D2jtptLWu4bfMeRn4loQDI?= =?utf-8?q?jb3t3rXcpM+/WIwgRHafYakow59ZbgxYceFs6sw1S1C2xHaStPN+3CJ4J4FXwmDia?= =?utf-8?q?ENx4fyekbxN4iAP26+Ng7IFcZlSOOpP90wwINCJYnpYYY8/xTMGrhinkEUz13Mb05?= =?utf-8?q?rt/zMj65ror7dPxNrddao9cSnklAYvPDjXO06tZlUa8fW6TeBWDRGxjZspESBInWL?= =?utf-8?q?3yDZH0QNQhKy?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: df60bbe9-194a-4290-82f9-08dcc86fa77c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:15:05.8399 (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: 6X7JZFknLS++0EL/jME30IKXe6KQ+FPsN+HnggV5WK1gR1e8GuSsuwKJ9KAQAkcxr+FWNzchTpGd4U1tzsDz7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7560 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240829_141507_990996_A9D7F372 X-CRM114-Status: GOOD ( 18.34 ) X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org 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 --- 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 71a9359c5c794..ad999a1346686 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