From patchwork Mon Aug 19 16:02:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13768534 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 9ED26C54722 for ; Mon, 19 Aug 2024 16:03:21 +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=PLT1wrK/ofsaDMhIuqCnpOzGQ/QxHeXKPDe8awHPxAY=; b=K/KBITvqhPAFZzn5ZbeU95OtYa PPKkLAVXdZ7a27RJw8nwbu3HedY5mLLOpLfwd+mqU6JjuqTVMvTrN+FEBt6n3LWcu8tXEU79zhw0M w98XslUeTrDZeDGp4g64+hah7UgbbKKqLyVAwkv4Yi/JQygjG6GbTKkA3XwWyugUh6PkFcUWQlgkU n7DkCB7YBXRsvP5hTn8edHl7yzD/bHclGnYLIKlKhDRAtUMlew/kJY5013bAJbKRki2XjmZBNRu8L s+LlkDDUW1aYag6iz/K13K+YluA0jruI1mvhHsZiidXUk/nWV6q12N5bsc0gli+ll/u3+s7uu7kQG qL0yXESg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg4qn-000000024iR-12sA; Mon, 19 Aug 2024 16:03:21 +0000 Received: from mail-westeuropeazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c201::] helo=AM0PR83CU005.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg4q6-000000024DK-2ADb for linux-i3c@lists.infradead.org; Mon, 19 Aug 2024 16:02:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NsReliGiUowy30l+4RgCrLFb99vT0cnfktYBq9iJF7hLoj28msq0gA3nUXXfos3JzyOX/s8rrWRd8ZAuLRx6y8sRcd3i6cVbHrOB9uhqcLsHpFUU7aj56BGjMoAOMsyuyPW38OKyI8YvWF3gu2hHnoTvrTwALP2ddpFpv+EmlsVHYGbX0ddtUuZ+RY1sWFVh+S4Bj41td+QVnJd+C12i144oPdeNf9jTP9nHIxRc+6oNTl4nJaTdetDmVnDnH4t4iLpM2F4ERimCEHl0iOiVHwdbE9YKxuIhTMvXSqXFkmL0V+FiDhtx3HKfDywXuacXrwL33SNy7ft2Vn11nuZbBg== 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=psJ88Gb4FD4lUAbUg/9rOviAsw1/2Fd63jvBW3I/fwpQZhXcInQV/VLiBHZkQgpokk3ZjcocedZtxntSIBE5BlgSlAUMs4fc/Ci6oPnoSf8HjJVGeqqXfFh9CfHJRqUdfr6lZJY5NVKLoA8Fy/pujOpQC0aTObE1cMOYrGpeKAThT0RI5PP656WwRy9aaK08RD8mgKumRFzqufRscw8zLmgvv4xVlPhTdiW+nJIvDVKpMwxZEnrGNBYsWEFVD7nyqyUxoCtr4Ee2lPh614A19Ousk8SKRaze0tsa8MImui1xNj2zFnIluHyel11XbFj2LjH7JARbXRcaZVmbHlHDHA== 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=fZJg5PRYWkOiN2bC8h3UYozQjeW2SY57hVHkcsaoCOOBSr2tuTLjBQmZO2hLoUqrst33OBZ/DCsIN86hqbAaxMqm4HGP9Oibq1rtLUIWbVyXTizYVRlNouD/Z1+U901fvH90C5P8xFvUQyodR2Q4377GmI2PP9Yav3FWXwP2qNJewjFinRk77II35eiTIZ8j2iv9/fDE/xuXd7fqM2//tqCbT8LngC/i/YyzipPdS2PfBzIxYM6Q36LUEhU+POXcTxdjQQRw1yv/gZrxIA3UJUy2H8w/Tj9tQneTSI4ze5jqiNWSJLfAxuIp1gCLNj4lI1tYXW3p6/rs6/6tFw5llg== 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 DU0PR04MB9659.eurprd04.prod.outlook.com (2603:10a6:10:320::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Mon, 19 Aug 2024 16:02:22 +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.7875.019; Mon, 19 Aug 2024 16:02:22 +0000 From: Frank Li Date: Mon, 19 Aug 2024 12:02:00 -0400 Subject: [PATCH v3 06/11] i3c: master: svc: use repeat start when IBI WIN happens Message-Id: <20240819-i3c_fix-v3-6-7d69f7b0a05e@nxp.com> References: <20240819-i3c_fix-v3-0-7d69f7b0a05e@nxp.com> In-Reply-To: <20240819-i3c_fix-v3-0-7d69f7b0a05e@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=1724083326; l=3542; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=An63rdNKf8siEFmhpUTOtrd2drbSwaCzp/D7qZONW80=; b=U2Nu86+MwI/9suQLnHtXPMrp2ou+GnLcJelxmoeibsrAu75XESa3qrNRY2K5Aj4Bq3gim7jEy FWMd0ltnxafDYH4Q4K6WvxdtSjen2bIeELbiCZsIz1O6heU1WUCmFhR X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SA9PR03CA0005.namprd03.prod.outlook.com (2603:10b6:806:20::10) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9659:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d1fa9b3-01fc-4168-9ba5-08dcc0684f7c 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|1800799024|376014|7416014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?1O/Jder1r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Ck7IOHq39g?= =?utf-8?q?qD18Pg1Vj9x+s2/2AuecUKGMcliOnfT6Hxf0RSiBowQLNcwElKHZzg1pMKyuwQYS8?= =?utf-8?q?MNryLvH5MhkWEpt7LcsBn487cjZ9wjn4J1N4EryQ+4wnZfe7iXhoGWOOWRBUeywnh?= =?utf-8?q?1jvGuryRVep+G9cXG5LZ/rUh3peyTgd8wOdAxOn1PUNjpU3oAG7OVN1EKisYqQ5eG?= =?utf-8?q?r4DPzZe1vwOUhooGnGx6EQdiNY+LSMvDY5b93ukKDFM9CPGV5K9veTdx5tyuZBDNK?= =?utf-8?q?OzjyQtF4ShaiGMGhEP8bYTwzIRaozvX4AOuDELkKQxYqSEwUw0jlOlP1pHXKMkg+k?= =?utf-8?q?PIyuAAIt9Fax5ZulsWJiYg2CsfcpDB7zbNMr4q6oQD3qiDJF7mUKwM38wZxBIdxtR?= =?utf-8?q?G9onr1gMYKkxpSeW5dtL88S6KUjuKi7mamzesYfPD6M2UsS7REFD64+IbZul0Oq87?= =?utf-8?q?1X+BMiA5QWhpNlqr6/SJqPDZaf+mub4rmQ=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)(1800799024)(376014)(7416014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?tNkxPaVdMKCT2L9uc4R3eVYy45C5?= =?utf-8?q?kqArKtDDhOL1xmGeFfPo6dY95SbVvk7t4sWucowXObnm2bI/Bm+Ks8+2yfkqxFQX3?= =?utf-8?q?IzH7tg84eus4nF4KiiVvIeQyu33L5Y4TAh4A0qcvnmeKMhfe4ogwKYIs2vu+YnmF2?= =?utf-8?q?E37ol6Su1FbWStMLU0MBsFmEQBikvcq0GWv3vYFisH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QeqZyh/NmyjlBSwGV?= =?utf-8?q?PiWiq3h6NMkXPCuMjV7EnN/ZOdsq1/2qYdWOUBFqU/rSQzMIcFRvQVPmdm9+v+jgk?= =?utf-8?q?aT/c1D0NYD5bxhexLe6Bg9jmg+IKyErsQdsKTgsugjevrbK7nhjqlaRYOZwfvVDZn?= =?utf-8?q?kaPnj7aEsgAHgQAtS66bZhbnRZELVRtqHxovEQ0Ckkg/lvwSrHckaq1FdcWKyNv9P?= =?utf-8?q?gZnVdfVGXq57rUVQIaxFg7sRUF3HJMosnxHp4yB8NpA4JmuWN5sFpUut1NCUgZGiG?= =?utf-8?q?aEi3X9ESJMhBzJ95+1BsaZHS9ax+u0kIwV3h6kvU1hJklmj/7S1yEd/PtyUUwd1st?= =?utf-8?q?QYuwoJZ9vzsml4jU/rU2EfqhCcZqs+bQEmphR3vycCyn81Neo5ge3cPYIJW2dvrz7?= =?utf-8?q?7CBMcpEtCh6VYjbA90apyZ9VS44+PEZNL9MTv8+gs+1aQ3JuVeTzadQDgbApGeC3Q?= =?utf-8?q?3BTLXJbyBOna?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d1fa9b3-01fc-4168-9ba5-08dcc0684f7c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2024 16:02:22.3259 (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: 1/+C04wQwhAf+mLzruQKVhqnAFKq5HFl5CGvkKy1EhBhauxBwLMY07EHPzsKZIdqrj1QE9COpHQRAnVckUWd2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9659 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240819_090238_799454_590C96DB X-CRM114-Status: GOOD ( 17.97 ) 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. Signed-off-by: Frank Li Acked-by: Miquel Raynal --- 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