From patchwork Tue Oct 1 16:02:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13818329 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012013.outbound.protection.outlook.com [52.101.66.13]) (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 415C11CB33B for ; Tue, 1 Oct 2024 16:03:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.13 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727798625; cv=fail; b=qWEvk8ZyU/D/BmdDoI0Yhi2khlvM+3RThZLljJ4X5fb9P0VH4vZDUDv4z0r96u+ZahPKgMmZ6aNymt2LIsc6Mx6j1poyVrIcKEAQBYa22puClgLPGuLjGppmUzBufRw2xLOeNZAgoAmiNT+MkAFs1CJH/t5g8qtHWC9UQ4twlRs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727798625; c=relaxed/simple; bh=mlCSC0VaHU0gag3oDLASEUXde0oQXAqLaFA8VZFk1O8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=pYIkqn+ymnBBoCadW2Os/NQaYJqBKbPgIaL3oZq6/w6dAXq1OGFeYvJmyaBb+bXCKzepu5pekm+DOBFHTSUZOroLbQfnTPw9/vrRsfV9Q4FY/WGZJrgf2Bp3upkeCWcovkOlpkotBpp82k7jdvW+YEfoLr139MBRil7U3sfV8Vw= 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=OFLycSlm; arc=fail smtp.client-ip=52.101.66.13 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="OFLycSlm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rTmQYAesZj9bO1XhpXUdPQ3wHq11Ye6r+ICC+8K0URiVn2YIcGL19C3+ugkKn1FbN3tl+thvEbXhyqVfcMgXvfNL6Gd2NDq1awutHFIP+Qpv1nPpfUluFkMxKwWRNF0Ngmbl0X8SxwUBPYKwrFzwruKoFo6rOnpUgwRxLhPw5p8ssAjeF5pzF8tNGoq7Bx1YOlVxMJC/O8uSsbyQhYawSlWDL89IQtseqpPxU9r/lOEGP2aODYHGhZChuUNEbahkVQgaqmdZ6VwejqxO+B4f4oEzA460pFXsyqKCfnw+0SFkkaia7VZULx++DFKBXYG6++h6bZcL3t4Bk8ohKyud7w== 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=kNlnoBuNCW/sQt1dCN12m568rUIM6SNKoMlIERg3C+Q=; b=KPi3OPTyXMs7/UTWTDPypL5jkGHLWv1gtKzn8YG7mcEitkgIoHEWZI2WxCksk0MJh7Vrf63fKeICWNFtST2eXudcA4uclJ+wFDKW+jzsuYum+nK5cfpq9A5FlVs2fq8yKpAmOV+7EM/N67Ams4AhEFcSIdNhI3KWNOg6/Cu2KnsUVkn2CM7HunpG/ay6y4Zk/KjN4dAeTCj6bXQ8Tpq0X5cs+vGgtwO3oV/fWxrpVyzfWFA9QQHeOoKvFsWSknve+mxI5XGIlejDnLeyh/h/pz0D8JYPIU1bE34VzqO6I57dJqR3EWoMggP/cNK8dG3dGJPV3NgFeK8DN1omF9oGRg== 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=kNlnoBuNCW/sQt1dCN12m568rUIM6SNKoMlIERg3C+Q=; b=OFLycSlmIuW+ej/B0GKGONK5tyF4FY3sc5LTJRb8I9gO/fX3iSktubHVRqtWk7h7aXYgkSfI36k51psp3m+vmScPGoJ6Qi5NY2bmNkeyozDfQRnPdJ4a/HsoJFEsLC5A+zWKLwVSKEembyxc/HIQ0uesGXx3jsq26wopZXdbyp08W3F/D+5VnOPYgMOfNXaYKqhdFafKTKIJA9Hy+KvGG+egLfhKvwsw4plDE7Mf94iwWydNfr0CZHIWfc2qdQ2fl7QRo/fyX71m1AW6RvoYfbRvAaD9gLJ2tQPUX90/aoeRfANeVYS+FvO5MgrDVbJFbW2s3YtcjbrAuR0LCJkWGQ== 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 AS8PR04MB7879.eurprd04.prod.outlook.com (2603:10a6:20b:2a4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Tue, 1 Oct 2024 16:03: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%4]) with mapi id 15.20.8005.024; Tue, 1 Oct 2024 16:03:39 +0000 From: Frank Li Date: Tue, 01 Oct 2024 12:02:50 -0400 Subject: [PATCH v5 1/6] i3c: master: svc: use repeat start when IBI WIN happens Message-Id: <20241001-svc-i3c-hj-v5-1-480ab8aed849@nxp.com> References: <20241001-svc-i3c-hj-v5-0-480ab8aed849@nxp.com> In-Reply-To: <20241001-svc-i3c-hj-v5-0-480ab8aed849@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=1727798616; l=3646; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=mlCSC0VaHU0gag3oDLASEUXde0oQXAqLaFA8VZFk1O8=; b=o4Imjvf6RbsxwWO49VEa9Ge5hfkUkRRdLcqLeuRT6N21mSzVn4OpUy+pJG6L0rBXQUvszRKK8 T4cBxqle4xaAd1SfeyqCD4daB5MrbOxGrYSnle6mFobtNDTbX2x7Gz3 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SA1P222CA0045.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:2d0::22) 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_|AS8PR04MB7879:EE_ X-MS-Office365-Filtering-Correlation-Id: eaf691f3-0a2b-49ef-5a73-08dce2329d5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?OH7eKjV/YyH6HiMhX0RONbFPvMUlz/H?= =?utf-8?q?oDXc2n+neVsUw9eqyND2FNArCeXE6tasSPs674U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/ke9MqeUvvlcGO8OH0JgKSIYL?= =?utf-8?q?hvIlGqVRp2b1VIBNI8tyahoWUm+pDRGRVguEWlHcZCBbfxpc8oHVMff8/kr+tGskh?= =?utf-8?q?8X1Ipst291HDL+MCjhHXLCBGKuJPZi0otpmOC3woDwnEFvfyYDhs9+By1ME/SonlR?= =?utf-8?q?BeAh8Umy7rOhkMu8lf7FxjpVkxqGEuY0h+14Io42Yu7QWaOV1IHQ76m9tWktueaBb?= =?utf-8?q?EANTY4GVuD5cNfvZgwhP7EMh8k0ieWcqjLKJOU6ApRmaOm9T4V8QynpR8ufw8nG1e?= =?utf-8?q?UuAr4SQww/7LEBZHVHKXpfOSRiHF7kCv9cPz1X2XQw28sGycY4lyWgGLdjd4iwJnB?= =?utf-8?q?YKR97JgWlVJNZgulsDltpLuYBsXkJqnKxqg=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)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?s57SUYxNBQs9BaelgF3N9neIdTPO?= =?utf-8?q?ftwjxAQ/wqfVh07EbabHXswjvDilr/u9MJYBDZx+Ezct5D8POSzd/hkYSLrOz5emc?= =?utf-8?q?dlLI7n894epxNrdkF8x1nezWY5iybzgtEqDgtGZ/PZnxN/wxT8acR8G9y3PKjZC+Z?= =?utf-8?q?wUXuUWlfFXk0HqcdldyeONXhp5NFasdqFJA+8zzcg6wrxOGJI54qbdwpECE0t7uFy?= =?utf-8?q?DalWSr93MvQSx/8KcEF0NZYFMwySSH6Sas3B/9LBTg0paGyFy30JmwgClj21az3Ds?= =?utf-8?q?On/ldxlvqezzMt16XeF5IZTppmFmkcu3rNrYbaBIaFOQLrHza1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lktz4KYlMEUP?= =?utf-8?q?QKMHw+AxYg9xVb9ztSZqwCnK/GRWldvRIWr8VXdRhOydY0xmA/CT4nJLOVajmzBqv?= =?utf-8?q?3DrFHdvsZlRheRH0itY3zVLS9Qu7fhy6IPQPHoydLnTjOdK5zgwjee08q+YukGs0K?= =?utf-8?q?Po+4aYZ0hxzm+yWCx9gUbLgV0Dc6HT+MTRHY4ZhCz4mXJ8/ElfKFFyviUVi0UZGaG?= =?utf-8?q?H++M4XBCr8UBh5l0Iz2gWoX8V2Vgagm1N4rXka8JaAKrZCIa9GwZHzqZ36F+rEWlz?= =?utf-8?q?a6zjHPPQwxM+7hWqI0THfMy5xwJSbnnG6s5ZjHT6RFHk6Cg7gRE4qZFo=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: eaf691f3-0a2b-49ef-5a73-08dce2329d5d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2024 16:03:39.6720 (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: b50/mPtJFIPD5o0qHxWgtFfenYli6R5eN7jrpVqzLmKzf9Y0ifbA/kBwpeRt0mg8oduKcE4CEcybMZsgvlY1Kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7879 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 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