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 From patchwork Tue Oct 1 16:02:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13818330 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 60F4E1CB512 for ; Tue, 1 Oct 2024 16:03:45 +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=1727798627; cv=fail; b=A2MAw7DlI6yDkXcYk/I1x11VyY8ty+XeAvqOI3uoktIBwOBti2ig6JPBZu4d7GIDSxXLCSksr2da0cZxFEk/qBwftCnyuNVwQrXRL6gvHvmk23DUzQj47rgrO0x7F7GFHyTMXdG20MrcmKpnlDmW/zbIKeOZjUYrPJhPnHg8FfE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727798627; c=relaxed/simple; bh=HGmPEBh3mp0etKTNyLcYhyNHTes4xfDtOurveSww8os=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=q7NKWO2g6VAP7RVo+Gt4M54ugxj2lwSppPemdhV32U6VMcCly9zTfSDtShOYcgtedq10gFEY5ABum5lYSP032oppGe2+Ybutf/FBxawao/elQml33dp21atJDczuYZRcGLmCwiJDzc+CKbodLBV+iPulmm0g+bnx5DmTyQfu+0k= 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=D/oRgZFT; 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="D/oRgZFT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Bv8oIuO3d/wNoWfiduoIRsfCyyVSry+j/hSDC4ADfgBOEXlVUDyFoExXGwDz3S1yUJBhI+pExYSn1lhT3IdqpuAhoKOxUEv1+TjipW8DRIn0eZq6y1LhtCR0/5X/2o8rUnAfbA7AAtwPeU2IRyKdW24PzGeA1bKs6RaZNQmEmLDrtN/aPtEE8fluPTPYD/RYxMwa2k6aFuKXTjRZ5kGsGNg99hVySG+RZzpTiepbta2lNHSj2U8xF+taf3csTQdee7IJ0R3cE6WKY4nFXfQ2sQckVlBxF72KuzapNJ7ixy7FvEs0gYkxmRggayqfG5uHg9NGM+6cq8rfIk5IuhUwpA== 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=phGcqpjKBhpboIAfePzMU+xlXCV/r2VDbu5UN0qglSI=; b=F3gVSIQf9JtAl+zIWYyduXLB/GKe58KN5J000left4RKB898OzpyvsDMrsoKGRpO81w0Jj8ix8XemZMTRnDseNifaszZxJS9q3nG7p8r5AG+buMXqo6VwnnUbCOqFQ0+5gW4gg1inaHMcl6zAYaeVAXqN7E/Y6Iu9prwEPBE+V8s17DT5O70u6OMUVQGb3EzYMftgGpkqgazCH9NPYXmuqmQCZOngrWcrpUJVn8t6F+UsevwYj053lspK8QqYTZlxr8ursw8D+zrk9SRyysOOG+Gr0I4+IhxEH4+BXJrqkAQ9kFFbNntYmgfRi5xFdZ3EOhc8Wv+o91YO1hRjVfgEw== 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=phGcqpjKBhpboIAfePzMU+xlXCV/r2VDbu5UN0qglSI=; b=D/oRgZFTz4AS5e2soZYQ9QnFh9u6uTr0ok+id/5XJBwJUeY7q9+6tmZMM/6tNCEiwpLJAw2SWXek0nYRj1SrLIkizak33kkJHeExPLB9XM913ueVb+5uuS4PXMJ0qm2XYOfcuHqg+IB/wHVWKrj4QVVe4aa8tkLEcQdqYv3cxssu2FNebNPWuefSJ1ii3Y2oGtlAV47lrW47C/yc+B5r8iT3wkMYcR3eZEgr4L5XJ72x3mv4pO8b6szSxeWIc8N0jij7clJuTER/qEYdDpEhzZhhyu6+yStA9rE5vph8QLnUJN20pGbMbJe7S5CjcJokpECv6+A7ueZStCHzqI4ALA== 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:41 +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:41 +0000 From: Frank Li Date: Tue, 01 Oct 2024 12:02:51 -0400 Subject: [PATCH v5 2/6] i3c: master: svc: manually emit NACK/ACK for hotjoin Message-Id: <20241001-svc-i3c-hj-v5-2-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=1870; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=HGmPEBh3mp0etKTNyLcYhyNHTes4xfDtOurveSww8os=; b=oUeixh/hE6hKHFP0GFQxi5DGSNggf9MDispFIBBJzUmMXx+VmMdMRY+iyFkW2dMpSXsBdp/6S jsMtmNlUCy/Ai2Bd6TrmoLQ2uE5uPYWFjHP1NpeVRZpEkPujcFRw8Wt 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: 45b9b58d-ef8a-487c-ac79-08dce2329e39 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?SE/F0aZMInTkGV/DqWbteTX+6StCjxu?= =?utf-8?q?m+Lj3KtBL8nNi6yT3tKOyYI6XlMtR8549iCDxesVZcFziGzWwgOjTuSarwq7gndZ7?= =?utf-8?q?mpRtY8JFMLR+yo3i5PS6TlXhgtDKtqCQacEPhOfUZrOJQyN/pV+UhZhQTa/2K0btN?= =?utf-8?q?hduXJrN/q4VYMH04xNIwdUBopHVCzdAGJtlQnVrkgoS5OQvnFD1Ud9l5imdQClZ8F?= =?utf-8?q?YXiouhmh+byMY1a9+2x9pJFCSpaNltJ7ja2jHQCin5YwHjbGFyZgxrDMod2zCbYuK?= =?utf-8?q?fYwGUINC39t97tGH9+UZ/lTAjT0i8788cwvjKFgYb8JwMtVTWRIDYv5weaKiBmuZh?= =?utf-8?q?FanlozRKlGIPjf4hplIW4IjJINN/vYJgMM5nlHzm8lVlkZURbTqjZBK+/O4zfnn8M?= =?utf-8?q?wCwpbL3p+SiPf4qlga79EVOkdQ0U8pfqNiJnjgi3mGOdk9MNDkMCr8+zueCYkPHbC?= =?utf-8?q?H7+ppfocOM+gBrAgwDBzrfJeOBTfPZq1qGUmsM7qHKvUROboFc3NPiPCYPnoMaYju?= =?utf-8?q?RrA8ViaG9PyA1vamg0Jy9/WEskV/mvhr25kM8GHU0b6M7GjyGguDMHy5xY4TPNz2y?= =?utf-8?q?4QTmtFtE06ioHfy/M7k9vCUXIvAbBXBYeMwuTphEpmzpAbLcEASYpr81PSlv+QS30?= =?utf-8?q?qqqGLxQ582eL945wRU/JMGOysmiKJKSvjc5M5r9jt39SyE8FnhdNvryTdNRP1BRB7?= =?utf-8?q?8UA+ZmoR9vufSwP739/W/sFvHM85T1zklXZGoEsIEFGRm22Hv5+F0paQIBrIzaTS0?= =?utf-8?q?waHBsL30b/LV+WzxouORzlX+I4MvHTvpfZLXZ+vUQWvd2Wy8j6bXAqWcb6e0aK4Ou?= =?utf-8?q?oJVUgCCNKGTJPLFyOiriDChxXOkoS9faBAs5VxtNn6ZlCTR0AI/pTLPKp+LVxV8SX?= =?utf-8?q?ktiZ7c1Mel0jwaZ5TYVI6rtw65+OdjLMEQkZI2OR8KcWl/+zryfE2GPzBnYqproeR?= =?utf-8?q?2ciuOSoq29W0l5NwPHYMH192MyiN2EHbgtQyFB1dLV2WHpgqrVvQchg9JUg8lznUE?= =?utf-8?q?n+uUiL8t4jQJBFb7GpoGNrKDZi59k+YE2vbl1sIwd4eoK0vux3G3x7ApBBFIbF7k/?= =?utf-8?q?WAO47BrPCWGTPh/YSAeePZD7fx5klke1FyPMY+Jy9a1KjQfD/E6xXvs7c9hCg9qmY?= =?utf-8?q?y3R2z04y8aOtbxDYw5NE7qXmdYKBnHKHIcs/+A9rLT2pjvzA/UzzJ8Q9Doan9Agtq?= =?utf-8?q?il5iLazOcyfU+yvUzDozX2P/U4pzwvOJzX3Fk54EXsqYl2dN/83RX9MlU0ElU/9NR?= =?utf-8?q?TeXMKH11acd9wvji5+66dHWTqYeKrySPFvQ=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?2WcMzU0tp+1H1wSH/wAyF1KFuI+E?= =?utf-8?q?ypdIrBCTsto9LFKDPKc9vwadFz/gBpTudgkcBmyscBQzA64hcFIGaL0LsA7zb04Na?= =?utf-8?q?So6k2DMjh2EXYbXPFgDl9LAHD2JPT3s2ikK+IiM9Xru6ZXFAPwSx/H5B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f-8?q?Y6P/HuUK1B2tXOcBnZ2B1Fa7qAQX7qzBmZ8N2ehPpGXGhYdfbv1VkFUZqWZ++jBPM?= =?utf-8?q?1CRUtXoszL7Q7WKdY1/GwnzbwN5X2xlxHLy61J4AayBU14AbtxD2CWgGzC/nDW5x0?= =?utf-8?q?6zecxVqxOZooHWRpSlNaNPrE6+1zJnUKBYl+0Os5zOWVOGtYGwHM7rp6LMTruvi61?= =?utf-8?q?KLH9T2nBy3Wqb95pOodFLqzc/vYvVq+aNKLpSvNKyw1pzby5mR+kfvhEZDikNB/uR?= =?utf-8?q?wuH5Xn8rzGAdEvzvExud51VTn1M8GihcvTUu1tXKTIKgqiBNvzBiwDd1DrcSYdh+R?= =?utf-8?q?dtm9+vnudTguCUmpwlEiKJJFItGJXZLSMaCTBeWFEgLv0IGe7UHNXD5IwXd3U8IkF?= =?utf-8?q?9AnRaUYXNcvLFo/A6Dzne7y1COYftplN2NQr5XhXEPWbTT/g4rK8UfbO4CQmEnxfa?= =?utf-8?q?ke2kNtQFWBosLoeuAdeVdFY/PToxlnJFxbUlv9WUblRm2i4E+Z5xfiHc=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45b9b58d-ef8a-487c-ac79-08dce2329e39 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:41.1224 (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: i2M5T9zxo17/dyGgUsFkdI6kFprxRMoPMkl+16KR6SstpTfo3N1lsvVLuhpnWbi5Uvx4IklzVBeNd1U7oVTgAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7879 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 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 Tue Oct 1 16:02:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13818331 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 6A2C31CB529 for ; Tue, 1 Oct 2024 16:03:47 +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=1727798629; cv=fail; b=NXe2aoboPpbknmgCQOPVNDhvUDJ7HeJlgGuqL0ZS0rsCZlFnZRh2t5/ItnBStnPcJ90e5LQ380IAVkIKRDKNbnZzVMib2CjkBpPV2XDzE4eDGuz3cyyGdYt88leKJ+4hjnUzxAPkYEe6U00hB9aKeoOmbwKgYq+LJrz/dVRKsHU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727798629; c=relaxed/simple; bh=5hg7uu3KNVcviCnomxqa4vxVoteMSlT4Rrc8jGI+OEE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=oTpicHKHefmdWO2DBwovyM91o/cIzGcN3dxc6DNw/pnzSxpDKH5jQu7O6zriXi74+ysGi3whKjm+oLvur25bElqsvwgPatUcz3KVoQdBoCOUP1aNAE4kLpkKfV4I4z4mnqD40XRuoGw8geNgJpHkkhDGtezyXP//Eh5lVUIICGs= 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=CDNwJYbG; 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="CDNwJYbG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SxvXFreaBpM3G/CMFh19pulmyk3nacLoVdqqKm125YUpGWJYyFwGaqiS6w+Kn3EqeO+MwJgoErzozcFN3zoGQoxBu4twSqEfRcgLfabp6EkJIdMvvl4xc7034tnwJORB5ya7E7a5qHDDrsgdSbudYRZjJNyOim5+w4eymCYEPgOAwKEgpFrdaE1X1NlHkhdqkTceSFEVMPwRqKt9Q1moLdNloz03O+uaj78DjYdl2eY3hVWv7n1vQoD+ZY5juCPCEinpXeLAWRm4fARscc7pd7RYDnC5u5aAQ7xW6AYJq50+EvVOURrveD0yMVm9x1PNgQaecpAO8LUbIoGlV8KKQA== 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=9oXAbN36WQRhBVwudaXIG+hmQyEgD5nBYHVHoW4R6ZU=; b=zOqb/is/KEKmmuQTK1EY7x9TmOY1xYNtFqoo0TyH6WkovQZPmzIQZNLCSeX69CjNUS0qmKCi+RtNOaI/h8H34Us4ZWz91QISgT1arNJngdc796TXqRkrfEnvI0n9GG78+qYyhDRBZvQRUUhjAyF1RVfiMKGjJuIsagaIsDIQTVScAPJlV/FpfJbHqqr6NYbFvuekaBtDkgjS24i2hp354fUrWWNUpE9u9yaDeaO4+ObxHPq8x8aoJmcWL/M2OcdsGbhnzmUzq3izO28lhPO0vDzQsJpYBAJX+vElzkHhyI2V97X997zE4SOuvOsdWdwuXpA5fMwcIt2kCcVsfwGPMQ== 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=9oXAbN36WQRhBVwudaXIG+hmQyEgD5nBYHVHoW4R6ZU=; b=CDNwJYbGk5I301mgOqUigMccxy8XvMlFvvnT+isNigR0KJ4pc22He4WeUcPfwQW3UM6FSXkbTMt9CvuBNhZI7OV8d/qDxmKg/DlcAPX+/0dm6Gzf4KIuJTBZ2OprkW2OQ3wLJ0/QhKoHg2ikU10c+9Q4QmlMmB2egtz744EDQhVwFztnhv26JLfJiF8Rweiiqg5ihUoPxNIoq1HucYl9lSm/tOtHLAgzWZo+GePcimvWkosaLZMT61WUNoDmahTOo5jLIUcTMBR9keyHABchtyZcQl2i69te8qpqbukZiNK3S4ZjRxPSBJsawnB11QSBSNoaflcD5Q4eHcvXFGAgPQ== 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:42 +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:42 +0000 From: Frank Li Date: Tue, 01 Oct 2024 12:02:52 -0400 Subject: [PATCH v5 3/6] i3c: master: svc: need check IBIWON for dynamtica address assign Message-Id: <20241001-svc-i3c-hj-v5-3-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=1475; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=5hg7uu3KNVcviCnomxqa4vxVoteMSlT4Rrc8jGI+OEE=; b=RaGDDl3paO5Y3iPR8cn2q9wxLJBhgtjwir4nr0D2bSvHrSDguxriS7fWJcYgeM14dp8mFSeAw Xpm+72YuUc7CABna6aPBKgJEonTi710+PMi9NdOQdbTN8+mCt+s4Yl2 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: 169f58d9-b9b5-40c7-8ed8-08dce2329f18 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?3ucU6SJX9ANTlQZHRXEAjEyTGKpO2lX?= =?utf-8?q?DYWgJC2M3gcjGlBDTTRojNjpJdhcLeH9qffLlbK4ZS74t4Ii77ntgrQ5pR3DTXoEC?= =?utf-8?q?fQSroaqOg4tHnmu1dAhIyNCt/YEtiswjnZa7bm0Iw+lx/Zn5E8GU3IublkvOSk61H?= =?utf-8?q?NYQc7+fNTDK9OSubFKegQ1vYJ3oqUvnjwQpr2c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Tc3yGsgKDh4Dd7z8r7w?= =?utf-8?q?B4k/N6E2Lh4w/pmQ5EETHYZGGANVpqBGvgVK+5kDBJBBNxJ1ssrWLEjll1a/dpUAQ?= =?utf-8?q?BxkQI7Dq37dTDJsqo45mrnV9TZfketnTH4a3JswqQ6tCgCRdN+cP1TlIO1F/m5Gfs?= =?utf-8?q?8O3mprkDcocIEHp1ST4KD9ZrQOqSdV6O1yD6ObKGXTQ3D1Tmc75Dd5oSUGHPu2oVV?= =?utf-8?q?kfSOE8jlE6PfVQI3ScPw4/afcunsxDbZ9Vg=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?CRLSiPY35aN6cvYnKuOca0SjX++r?= =?utf-8?q?zAN03ndmikUeqyy6gNp3C9eFc4F2DMe8oVcRVs4Rva/Il3Hjl75EIn5B7poIc/BEK?= =?utf-8?q?3YrrFRRZ2MUNEIgpZrHXJP+U2l4rm1jMGPAlPf8ww7n4G3qZ7lFntx+RIGsfT163k?= =?utf-8?q?xZY/mROXaK/5MYuMmgSXAZ/syRMmP61JdaEzd6gQqNr/B9Fqn6n0vSzbdYlMqCSAy?= =?utf-8?q?qhJF/Gj+TGDIyGgnaU4bRPZfkYeb1rmWRNwLhFS6A9erxdyzr0RdbVMXsmD+1grP1?= =?utf-8?q?/Nwr00fFnqXzZ7Os+qCOc2g2ZSO8wAoLV5CSkzgB3X84uVbiuy/EZaotSPRP8FBRw?= =?utf-8?q?bgg/aUXkvJTNWlDtoMDR7TGV89RThnh31/HfRBAHcK9srGlLz1R5WnjAkjqKYjO+M?= =?utf-8?q?Fo2ITka0uN31slfkC9forv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vKK6ACfUKZkmMe8ACEv/aqJhenQkwb715l9QNUK?= =?utf-8?q?X75EA4YDR7SHIPZz5gUzi69DvHWrLD928L0AqlDa1AEYkYAXx4U/Ic3Cwb0AuRD1r?= =?utf-8?q?kZ+vdeKIv/fmewM9DU1PlKSf3QLfgizeTFjspUXV3u7UCdq1iy+ZYPLJYAK2kuawD?= =?utf-8?q?ijY99B5eJ8iWYiz2ecg4jie+CRBDvYuHRC2IdxX7/TrkHjOsgxCLKP5A=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 169f58d9-b9b5-40c7-8ed8-08dce2329f18 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:42.6151 (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: RXb26tUBbJMkf3/v4WYjv5UPJATZbsSAaiUOFv+WD0oglBzG4vulw50lUTm7B88JzKTxdwpRSY92dX0ZDgJK3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7879 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 dynamtica address assign. Signed-off-by: Frank Li Reviewed-by: Miquel Raynal --- 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 Tue Oct 1 16:02:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13818332 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 5FC061CB53F for ; Tue, 1 Oct 2024 16:03:49 +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=1727798631; cv=fail; b=mR25/A1YFteeQpLD0aBvUU7S7M1loE2U7qzl6n6NqOKkO2Jz4+CFxPjCL1h8rBxfzOU5k4x73JHK9b+qUVMU+Bpt26qAP2vBF0L98yKfheWEO6vEar66BvD//d4oqbfUiiylZgXtW7wJIw4enniyTXpy5YeEZNz8wXecfRGnBy4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727798631; c=relaxed/simple; bh=bXdIg5zPM9BaWXsC+SgKZ7H7HKQdnYJSf5AlhHtZq7U=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=R62Woyb7BKzr61Yzawz6A7EKcKNnMqWKrji3VJhVQcc9IaNVTM9cm/+N2ACF4zcijN9KCulKJFIQ0AyVvOGCRw58qLtC+tbosMH1h7n4P2qgT14e3vQM0lvV9OZaIE+y9ikcQgs3t79NIHgWDOqq4nlPgXqQ5HYdFQDxQ8Qcnyo= 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=md4eq4uU; 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="md4eq4uU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WCzFaRsniwF/UmqiKbka3S5AcXtYCbESh6lO+CBw6yZ898bP3NtUTdggYSBwAAXhdci8IEMG33jplc89WoRvn7AqcUDy0v79xW3Ha0nZuSXrPynMZ4Kd1mFmkfSTDKqgtb1onS1NKDWoOz5roW3bwyt4MidCkQeOqH45jZKsE37OJw5cpNmvtCeZBUvZ7DMya0hkI7KA/JhjfuB1+xdcD42SQ8euR+tgUfcXNStRRPyOfuWdLxXWRSV6ApIK42eUwIBPfFHPrQfKSndgrSjVn9o5UaLyY9lIV5n+wfREOBUBo0DCZsbWq00BTqrSFrvtNrSg27LDxglTN8A7anCxXQ== 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=lUG3B5sw0m9FDBnZS2WFp6KjUgxzk050Wfyb+JjQsVc=; b=nPHBgzNGQ7FHHJ2Y1QM+Th1meQvnmzPtRu2XGbQ0uw9BB728gBg1Q7qhF9o2YCZFGNTY5tjNF/O+WjN7X3NIpO9+71ZMz1VFG1xWU7jsVIh/LvTiyyp0BSECi+oDpMH+tMMvoAQrNMvu0JbQsGamCGyaCzllbX3bsf9JlSw+diTRbqjY1ipd8sDR3sb70fI8yrLluEzhLs+jgyy7uQUwZfVke2xmDNA81ezwtT50m96HwDMaKHIjGmJiEpIA/6LQCOlg4HhhFmP6kZVQGa/F3smOHXvRYAEw/0wFQxtaJcFVaAiMbIiXIvh61sotUo/CpzttIgi6qAAwbNY40K+EdQ== 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=lUG3B5sw0m9FDBnZS2WFp6KjUgxzk050Wfyb+JjQsVc=; b=md4eq4uU3YIqrhIx10tW90ezYrUtS3P/wemPY/SX1XTB1J6bK5WTKLkXF8OrDYhiWDadcPLncah/X42l8m4y1fqUsehTYTI4X/Dfy49elXJiUGBNYWWv9GgifZXQiqxKzhyJlgm594cXIqpe4JEE/8r21/5sTYK9VYHa9sgf4jRWcU0t3SlRl2dAyZH9Q2YLrqSZrL/2jETWD6LYbKEQyE1r6N4CEXbyOj/XiaoDSfXAko1RJbU7jVa+NPoK5P2ugXhLEAkFx9Z4tZpgc7fX0k6nIv7tRd6Cdk/mx3MvY7rYdALL0sDioKrXvtIl5UfJALb1n1/+WcyjOLi8HjXIKg== 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:44 +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:44 +0000 From: Frank Li Date: Tue, 01 Oct 2024 12:02:53 -0400 Subject: [PATCH v5 4/6] i3c: master: svc: use spin_lock_irqsave at svc_i3c_master_ibi_work() Message-Id: <20241001-svc-i3c-hj-v5-4-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=2497; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=bXdIg5zPM9BaWXsC+SgKZ7H7HKQdnYJSf5AlhHtZq7U=; b=3dJeBl7aVLwecgJrIlp8kF/ymDU4ZRPIwNY3GrPbPaPg5DF6K3DRd7q8IXlQKUFDcB0pdSDg6 WLMO7iSISDsBqIjxFMOpXjLIx/p8WY2WSaM9GbMwwRbYe3xwfW2RksI 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: 2b594cf1-5c5a-4e69-1aec-08dce2329ff9 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?V67RefDIH7fqkalFqeVFkrHeVtSCYK8?= =?utf-8?q?9ApaMwKnmvS82Kr9zfdoxud+oKpjO5RCiQ7/5twOWxfbVGwm+6CfgQdxGb/hwcMHk?= =?utf-8?q?Z3ss13TDOpRaKprltYy0tk1qA296fPG+nQKovPn4p5JqtwLjDWwYvqiylW/Q7svJl?= =?utf-8?q?GInkE+coNtFkEXErsW/wPEhppqituK7JpV/qvhM3p3Nx3ra1Zv+ylRAHfmMsXJpOb?= =?utf-8?q?4m8s7BT17U672eHXhSN0G/5aC0m+IKhuAkiAk96mGVnxiGNW0QwN2t1Grs4uhQlYK?= =?utf-8?q?25D/wsuKeGTrO4YtXDxlfGeNjuYkWr+p8cHClFZvCXbCMwYr3mWY8MjrQ5gX+5MQz?= =?utf-8?q?z26msMDt4XsqJq57KEKagEVDzoBEwqQYTy3VwahbSPRRArHw2uC2d5ANQkRD4F/4f?= =?utf-8?q?aypDijSlApQCClkiMo4g7KDNzSv8qa2keeAKxOdP4Y9KgjmGP2eucp/NDHdsv18Rr?= =?utf-8?q?sjHDcfMqcD6bodm+iggrPVyxherFxB1DL6APi1YQPmJ1v4qYoQVXW9bpZ0U0PXvjv?= =?utf-8?q?cnH+H34dA2xrjvD6w/nyw6/DmqScEOkGsYDc78RBRaVgDG4KWbx0ZjUlStpqO8E8H?= =?utf-8?q?55AFwDZcgsOdLyfKhjE9Txzxd8ZCaFmzwi+C4liT9yf8e8CQ0Tihtb9ELmQyADZL0?= =?utf-8?q?OfX+5SB27Ik1fHSna0+RMfWjDI332JAndG+9xeEmANYeFJAX5kRcEu5bVlvKBZdFL?= =?utf-8?q?8dYY0F4h1sSOK7CguGoSUgQO9vNkvfx0vVFe0BUTjCiJE2cswxPdUM8nApdBV3T6K?= =?utf-8?q?nUzpL6hJ28JHjc1pNF314Sue5ghdKgE2Rt+xR3B5T6SJkQfZKlZLTW67oJAeg9m2n?= =?utf-8?q?CQKasWxKvaUNLgE0rVz0GcYo3Wxm5UjHjeptxWHVSGMp8Gxos0RNSNof4f25Rpdgu?= =?utf-8?q?/Iyu7UYhzofJgpduTApnuCR7X8Ouy8GOqFTyIGa74i0jrqIpQmoCaRuqbi2I7tO+A?= =?utf-8?q?aHJcLU3nwL+CjjJlCtdQTTk8il+F4za1fN68ySqmCoc3xy5bC8bl57PQk6IUYZNEw?= =?utf-8?q?EhHjwvy0We6u/uJzDH08VAtBBF17QUW5+Rf0nVKTc1byExRQo3tUJijeIExL6oJnb?= =?utf-8?q?30Ww+y9qkY+O/NCMmHMmNtP0xtA+lJA9AjP4BgI6e63+/ciO4U9orMOnpE5i7YU9k?= =?utf-8?q?rVX8BjCmvrwJerM1z1pkE9+Wseim9z+HysHLBWylyaxPOx7aX7hLyDXya127hhyAY?= =?utf-8?q?r3rSv/qgrB/kEo0xRDh0oWdeluY736BgkUanrb4LpZiho/JxyIt6xNavo4/u3ZV+E?= =?utf-8?q?c95fGRnpM/xGjZo2pu9Y7Nhu3onE8fKBDQg=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:O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x4MqEkU6A05WP72d7GS/NC7K4YAZQCi1DE?= =?utf-8?q?iHzMWLe0Jwso7EGY9CEthAbodNeNxRVhEgIngyysCtNfe92dSJB3VQCklou/GnqHN?= =?utf-8?q?10M8bNVLFfkDF5wEry8tOxesTMmceV2S0vjDsWWepj8/p83XqC6OUYw6UlaKKzupO?= =?utf-8?q?jhyznU0BJIKXOwrBquq4bmCUTWqjCoCIYpZ1wUNp/FYyqADuL7WlXhFAizWChAhVY?= =?utf-8?q?wDdsHC8ZZptjcqXUChZxIY8bPFQyLqtyag8F/VtapnN1iTvCaDjT1HzvAKgwbmBch?= =?utf-8?q?Ba9+WM+Z83p5LUgVJhqAuoi9EMnOyeK7SRHnECdWtq1HN6iIWuOJPByUh5/OB47EM?= =?utf-8?q?YwCNfM/auY2gGtqfUG59qpjH2lvIzoo2gENhyKg+4Kvk9Lyxo9oBzkHCnUqzrLptb?= =?utf-8?q?z3me+/mISrcvE9O64veU3M3x8/vcbe3L9XHl+4m+RKTUwSGHsEQh2SwO+vP4pxSVF?= =?utf-8?q?i0zpDtKKIDrKAhIK5hBam7wR2nFJzIW2rolVnbLJzqHGubXKX7MDLZc8pR/U4Gw+O?= =?utf-8?q?0k0Ol5v9c3UYGaFGWwEJsyUV4hggXinoIGzyAtP/BIanWL94dd6/XD2NKMoCFOiDb?= =?utf-8?q?zA5p6YFrOpFfPQtX69WsotzOrY3CsjL3hSmvsxr3EH8byO68PsoqZ6UqNCECLGQwI?= =?utf-8?q?Ey2lI4SzA0OwiAu6NNkfCV13q8aGYjbrtC/mz5GX9ICDHl/z3Q9WV7ns=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b594cf1-5c5a-4e69-1aec-08dce2329ff9 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:44.0625 (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: 8F40fmGiCNXghkeQ8H75uUvFv2KDiFAGFfPVmeAmb6H9AL42g/dfjDSQMOK58w9ddLOC+kfV3Y3voRR4d9DknA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7879 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. Signed-off-by: Frank Li Reviewed-by: Miquel Raynal --- 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 5df0ec02d73ce..1ee6ce186195c 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,7 +465,7 @@ 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, + ret = readl_relaxed_poll_timeout_atomic(master->regs + SVC_I3C_MSTATUS, val, SVC_I3C_MSTATUS_IBIWON(val), 0, 1000); if (ret) { dev_err(master->dev, "Timeout when polling for IBIWON\n"); @@ -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 Tue Oct 1 16:02:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13818333 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2075.outbound.protection.outlook.com [40.107.21.75]) (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 1AEC81CBE82 for ; Tue, 1 Oct 2024 16:03:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727798632; cv=fail; b=f3AAiBcApvxbXPVcdFHnoH7kyWfq8gPDsC8vPYg85beZCfbg8ORryVNtbzX/lLCJ7SSjPQS2E8x4zV5n97td5r7QKB2ljl4WZpbAm7g6F1jm3frDUXiMJPUDq5YBUGdQ1s8+pdsd38f60So4W1XuZ07H4/6hy8GNVPdUFn0isw8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727798632; c=relaxed/simple; bh=pwmMPQ+ocskT4O4TSE+gJnxlQ1bipztOKdsbjLcczOM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=pGoMCIuE3hgMHHkF7bOv89mCV+eOdmp0Jy0v7F2L2YNfRJwpRQzYjPZxJqPOQSD2fl4HIdzMeo2v4FphoFHmcGGqqR0ggvTWskTx6pNMPtbXejsIjcoshxWVd0zd2vank6BER7CpLLYzVsha88IfC14GztNYcIYDqrbJyRajx9Y= 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=WEaLVngP; arc=fail smtp.client-ip=40.107.21.75 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="WEaLVngP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dnmbQX7IFixK+5S2jn2hldzmxwqYWdbuJoPfH1cT61Qsud/73tfEsF3CxFUx9GLrbW/jLLhqJG2K3RS2+dzr7HEh5XD9LjPXI95dXUEPviudHdIlySaiQlB3pVJECz+S/H32Q0MBCbt5iaKegANlzEpPBK8sxx8xOl6uCvmXHVOsG/vVz72dF7rWU16/9f4m/ZBCVBksIJ3ExZcG3vacWkcAk4fPW8q5pCn4XcxkMys7mukHhRz94d6vrsw8RXgwh5q0EjtXa56qrDb1JnQvxvoqasFf7ydtBKC2cPfKCACHCmdyiEpxOlKAxQy3ecMKvwNuSG/GK+EkQGiLu7ypRQ== 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=i+OzaKZA6ebzx86iqa64+hJKH2qCqmdVir1M259mJ4c=; b=WWhaZ+QpLkbfH5q+GxURcCAnJE9eLOsP5OpgX3aWVxGGC58gwVcTTLA2CX3T1Fi8p6t2W/VWIkH+Ncswpbg9QjK4iPVy8kHCHvbc5yoraJ9wbCffxq1XEL2BGCQi/mWkpaawfDtpU7B/9fQo5ny9qeVK80nJ8tVp52xLQOWURYTVVrp1O+LVvTh0szvWLxix0i86MBPwET+AbJhyQ8JlpBsTL6T41a+1xM5X64iBRJ6y6zS3X89UXZF5ZyWM9R9nxjQ41/ly40E4denq6W0stRDt8bZcRp0iC9ycl1EH5JRNYlR+Cf4XDg7+IYMyP42m8Hw/mYIVmEb/UnRwRCAcsg== 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=i+OzaKZA6ebzx86iqa64+hJKH2qCqmdVir1M259mJ4c=; b=WEaLVngPa2qsT8oxqluRd1UDjeFzXXI4GQ8uHLyaGmca9olqmtiXNcN0j7a2JjlJiv0jLpHjpLkm9ND9fLg4EiRVsMR9mYoG1fOAodpAWgHGFQxMhpmk9aIJqyAVBpvBVk318T9PmEBOx7CZlRFQEbwsMGzGWR64I6OA50ZKFfKq0GArplQNzREiR/rkdBZkuEbd23X8ABVSW062b3uDVLdkIFfwJs7kEh9t1dsuvNeLho0OKCDPC68AVDjTVCLffXEYvYWAjO4MHMdJcgtJx4aQyZc3PLP57HHjbHNauJUR+jPxvxQFMo/alesH7QMSzGY00v+szs0E2b9B1Pwxpg== 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 VI0PR04MB10437.eurprd04.prod.outlook.com (2603:10a6:800:216::16) 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:45 +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:45 +0000 From: Frank Li Date: Tue, 01 Oct 2024 12:02:54 -0400 Subject: [PATCH v5 5/6] i3c: master: svc: wait for Manual ACK/NACK Done before next step Message-Id: <20241001-svc-i3c-hj-v5-5-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=3288; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=pwmMPQ+ocskT4O4TSE+gJnxlQ1bipztOKdsbjLcczOM=; b=pnkIDMq8WXknCTRdmARsA1Ks+epfrvLNkLd3IlcLWzautELYeEsYtsbCbbRgqtyYydHsPARA+ sY6vVAsoEbrDmDLJunWpSFdTvavXysaLaPNn5BYvYQTywkPHolNFaEX 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_|VI0PR04MB10437:EE_ X-MS-Office365-Filtering-Correlation-Id: 70597d2c-eecb-4a3e-03da-08dce232a0d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4F+oLT4WXoAlHiNOYTpLJH6m+8dRbba?= =?utf-8?q?N0TJ3R5/cN8K4N25xtOOeeSHfi7kx9o2crRdupnKcW3mnxf3bDXfOz0E0jEDPeW4G?= =?utf-8?q?SHWfDX0VbIClBJA+8ycfk4yOfMBzxAzWxxinZ8O99Pxs3kk0QFvNb3wKSuPb7AZsH?= =?utf-8?q?5VHCzGIMBjawjvRaBFKAyUhzhivejkS3XQCDUWBkQULMIW/HXNIGWInfIty/SErY3?= =?utf-8?q?AcrRam/DyrWgBeGUJ0q00zxdm2/TbGB6atOeX76HfYNyeVaZf0osTqlYh84H52hgZ?= =?utf-8?q?IuLXxQJOE3QrAjRGv+h/bCSIuPrH5sLny+V9Q3MoNG3KMHqDUGGMvMnOMGB7oRGTK?= =?utf-8?q?bnHA9L4P1cQWocOIgYcDK10PMPvVK6WQRcdToa/dvUWe5YaSA2OGVpyZXYIGR85ck?= =?utf-8?q?x2LcFrQZy6h2SKyrEMipV2ifPu119lrkUimVRqrBgsqGzY9cU8JcZC/0bKm/lBquH?= =?utf-8?q?FPBhDzRSgCeRmc2R9fS4fdVVtXfTUyB54FirAyJdb0ENgeWEzXlDoP81St5MViziK?= =?utf-8?q?K6RLq2BekdR+iCX3IlXGvP9st+9dt6BcsQUfAKH/2kdAxzeE4VYJ0h8+sD5zCRWju?= =?utf-8?q?FsTDGVtHukGmuZU+VxN0QJpn8wmcZk3BaUkgobNwhwyIif9A2UbeRAv3XVe91l4fp?= =?utf-8?q?TgXTHNAEEAYN0WR83hxTeiX0PzMQKpzO4j9VLCUXABlIrDZUHOm6uA+4US+uUUaBS?= =?utf-8?q?bL9DH+319pUTmudxN5/sBi1UrYDsJ363evjmvcCEBAl0A6vY6BUxHgJ0KqiGZaRDm?= =?utf-8?q?JuWh8hRcAJUI3+892jFTPC6K62Qt5OcoIUE1R3QMBOIQ6iudxSShG221Z0UvUD8Ny?= =?utf-8?q?oDUoBTVi+Hlb0nheANJij4QIU9h/eFLpiPB8A4tyrAsJIAKj5MpcMl611iUuG4UE/?= =?utf-8?q?Vj063n6Qv/9zdV3+Mh6p6s+M1Lzyc2iIehxUJXEcULeynRcJidqO7Q1CeHR4qEGlv?= =?utf-8?q?UIe9WsUA1QhgoelzVWG4pndNtcgXZPd14vH66yIHUvGDpMNOmMi3VfAbAN8wYteRq?= =?utf-8?q?IrDtZwRPktfvx/qkJtI6wMDEQZDKMJkPTg43bfejRu+0Hc8SEAa4j92NgwDO5WfT3?= =?utf-8?q?FJ7n9tSWb1yKtRs/bLtpO8hAYOBM4wLK4/K8HSt6d5td+49t73YHSW+9r7JjQVcYl?= =?utf-8?q?0zISK1AL89zqnNb98wIq1b3WEDiovyhsLuIzX0hZuS/SedbmWeWUt+hNlJxCoWd0y?= =?utf-8?q?oLtHMcH3X1+S9GmUa6w2w0VKC2jI0i+z6NyNaCJwvQRNtSdJzBkPjfomco4mOoHvG?= =?utf-8?q?ohVY88PKi0POd5wufkrKsAjZZ7Oa9OrCfS34T/ONPPo/vlcq8ROTZQIn643IJGUJY?= =?utf-8?q?6lRpa7JifmVt/BHTfbK66IS9jTKSijkXYg=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)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP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4OI0N5gcjk4Kov3ggGy9oY61C9?= =?utf-8?q?sA5mS4DpT2w/ASL2rTweDfKjnzs+OIvymIPaXzthw2Z0Q4HASW8eTjcRbgxoyucw1?= =?utf-8?q?oSX9WmYNNx+VwqRmf09lECXVm6bOOaLbjNzeA2pqKWs8kMr50oh5MqBqlqpwtemM7?= =?utf-8?q?7JqIsfqt0gmSP8D+9f4y8WS/iJCtZCz9c/stQ4+ZTEavd1zBUwRpL0DJs+mJkpg+L?= =?utf-8?q?3fW1WIDpZtbkgHSjdGqDKtdq4xP16WVTZWNKY4ypQSvfxh7mFj+iVJ7oqLU++hPhv?= =?utf-8?q?Q64uEcOEfTM19PqtfYBdk7nsCnkd7G0qMcvKBI0Jel5aYoeyJh81nqF8kn/lfHuL3?= =?utf-8?q?E7CBCW/tYs1jbjbA08ai+I+6yNuWz3CagD6+5WZOUZclksYKnozkFFdxW0uggolCB?= =?utf-8?q?jRTd1ACen7Ef0S2aZery+fj166UmqPTRCp1ybsnJky7um9Yt/afFJXAa/+AznO9WX?= =?utf-8?q?qkyDaWI6LAqXAVTMuWpUHt4siZSunewtPzlEVgnDzhrNJWkEkuhvAgm/PqF9Y0XTb?= =?utf-8?q?vuNmvZYC2mf678zc32pJM07hdBIJSor14zaCtrAM+pyf7Ubtp4+KYMwN5loCEs7bd?= =?utf-8?q?rtXVDyURvn6hCByLx0sLFm2lug6N84Rji0ISxGWiugVSm7DhY8iu6DBLAym3hXGb5?= =?utf-8?q?//gkZ7SWWgW7t/BiaYq0pZhfOIw0RWzVb9Y/HwivdQ9juQwIMDdpSsew=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70597d2c-eecb-4a3e-03da-08dce232a0d5 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:45.5321 (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: UNqwfkAxW/8lnJMcUZP1gsUcwURx8VnYcXtHFEB3DRu3D7ami5i0KFPEbIm3jTrV2iRsAUtiTnD7KsAzXp8xrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10437 Wait for the controller to complete emitting ACK/NACK, otherwise the next command may be omitted by the hardware. 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 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 1ee6ce186195c..3388c9af63fcc 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 Tue Oct 1 16:02:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13818334 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2075.outbound.protection.outlook.com [40.107.21.75]) (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 36B181CB339 for ; Tue, 1 Oct 2024 16:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727798635; cv=fail; b=mNflGqwdYa4oLuBz0bag/G918Xs3kkJ5hy6KiKKehX39wURNM1nujDmlbkxlCWTRcCsxVmgFoQT5h4dIk1c2aCe3HNMd6AAX7b45XQgC0ONGOIIM13/dsREz0V50u/9guD2lZXxKm7u/yMB8YhLIl1UwsLEy11zK6XbCBBAee9c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727798635; c=relaxed/simple; bh=Lzz1dEezZFI4AwXDduLO9+qDTwqAGzmLOSOsxS0fuR4=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=hYpY6zPfboH5AN2pzICD5qjx+ExsQ4zP4SWvbKFrC4/hrrQ3zqtvFxEIFS+K09gVcalqycL1qiV6t16Qjzl5m2SOrp/LMM/+rd16eA8thcW3ifpM59h1WqsmOQnjDUL6QQyYkDLcTmkG7tburKMmfhYeRjaxCOKmMz2TyrEcSsU= 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=Iusyqb+h; arc=fail smtp.client-ip=40.107.21.75 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="Iusyqb+h" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CX7JH/69AAEYU85xxdbHUz7zfutJFhkzK4dVtVNxKLDvURXCVBGkAl1QRaGkPkbeHx5zrBYONJ7ytvSlKb2I+yt5IrxdzvRnr8CjDjfwYU8NGl6zoDoWHHsiVzQx+LvZCxBOid3xYYSV3zXmCZ61vXKV5G3/0gfT8LmxtREbxG9JMLPNKCyvX4rITRmWRDkjgOkaFqngojmo7zijm43bPZppuxjAstC5hi54ns1WEhKvdb1Tse4HNIwi+Ni5ViZnY4geNlIytUJkYP4I/fubOcejzqbev0/YuVgM2Mart4PFtQXwTUwEKUDntCRhdm/tzktzKTBoQgTeDDBWbmH9VQ== 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=5cRfK2j38fogPonMcQkqHwej6AD1wb6XToeJuSU7HUk=; b=swipQALJinw05jynUvaosaQuylaulEVHifKmmjCbynuavD42L8mMtqp2HelBJ+RYY5QgE53EvnywTTPd6U4Yde56Ymoa6BmyCeVn5tgjj2ixmdst2Z2gPE63mdYYUs3gOxOD5ScMCej+bmXiAkNc2v07OcLG9izuQe9PJ5P2SAGN/oEN478Rd/eeH4eu92kk4hLsyZR0EV9T2vbnacL7zeob6ldj01W8ENguH1T5fcvCk+dtmWS6wNCXqB9/6FQO8X5NKe12qlYiCRM9fn37fKYuAZhHZjwl3tsaGwSugBp4/TF/27F/13MfdpusGfkNRjZFm2IJHxyebiS/WFmSyg== 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=5cRfK2j38fogPonMcQkqHwej6AD1wb6XToeJuSU7HUk=; b=Iusyqb+hjM/wIDyvF7O+GGlDmACAn6r5Zo9DMmOTtA/EZ5CDxH00I3j47iemPxCzQ1lmjIom1qndPLaXJV+Y6zsbWhXK0B3q2Yg5VvjYGmotZ5NiyorC1gzVr25nUbuwTM5rWHc/RAj2AiYOOlnWa5+I7qkA62TipveQYIWsZ1A1CudX1FQoyatZEwAGKadqCfrldlhRzEBm3luJGcK7683Eo3NawmsQU3ufUL2ItpF9quItOVriy1E2OwKpsee4aIDBIJwqByH6Lr+2+C/8t05TKDEalHCsSp2FcXEQlmDJP9AmCTDB45dsewSOLBBK32cT9OGQ+B8jp96kHWTPVg== 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 VI0PR04MB10437.eurprd04.prod.outlook.com (2603:10a6:800:216::16) 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:47 +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:47 +0000 From: Frank Li Date: Tue, 01 Oct 2024 12:02:55 -0400 Subject: [PATCH v5 6/6] i3c: master: svc: fix possible assignment of the same address to two devices Message-Id: <20241001-svc-i3c-hj-v5-6-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 , stable@kernel.org X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1727798616; l=3184; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Lzz1dEezZFI4AwXDduLO9+qDTwqAGzmLOSOsxS0fuR4=; b=TEXoN3k0liEFXoQbSInw+FiOr88enzOfH63V69sf7J/hRdxFHRKNOpX6qM5ZoBKPzNlJpLOAt xLOfabkDbAlAdRypyYDKOEaM4PFYpLyRZOM0vs04xLapuGC51v5u0FW 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_|VI0PR04MB10437:EE_ X-MS-Office365-Filtering-Correlation-Id: e8c6114b-3274-49aa-bc1e-08dce232a1cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?C305Qg/ZW72UQdXisG4TfnLendPe1SU?= =?utf-8?q?h1HQpH2zTjlWR2RzJb8DtSsKiD0VPpRKR6D8ZnrG3Lg+0IpbGQJLQA3z7wco9xNU7?= =?utf-8?q?7c2RmXjXcJevLc+qaw3naaPGRjNObSixiusLX+Ayi3tRaxNjmx3lrxJNHWI+WNGG/?= =?utf-8?q?fLIyvuY6yaYEZgYGPjkULWhwzpDY04aQSmvPoVb0B/cmm/0Le42qRNABfqJkvhOnS?= =?utf-8?q?sGJ0Q8/HdTY0E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OKCiTn8RHX2yANTVb1OgwCyhTNxo+k4H0lBs6YTIL2MbR?= =?utf-8?q?xskMbBHDPyLupYDLa+odewW1VrQ2Dk6lh01kKP6ipRYiVYUUCnTi8M3Pj6/Y/sZ24?= =?utf-8?q?HjP64vNNG0d46tq6O/aCaKf63Sl+ABiXEsBxrpdnofBrq6JJJcDlAWYWEEgr8OWmS?= =?utf-8?q?ZHXqWmoS9/Okw3LIbs6om5KfNySwKQsT2ZpTJPuzmAqZAY7DgSmLQF8FYoznoduKq?= =?utf-8?q?Vrg5E+/i6c2suA6QbHW7xYugAVpcqRW6KA=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)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RyCfm40cn0QYXjWepkd9IrgNCA9T?= =?utf-8?q?N/vkLu5wOx3zCIp77CBNeNNuSnlJKKsLeTrC1UU2qKu8MQVaDA1ostP9V4RoXEu7a?= =?utf-8?q?aBOmUKsfRvRSx2RTWoSb376KWpz+WbK9yqvdUupVl+cl6KLS8q/Xog2LL00TschKh?= =?utf-8?q?ArJYg5cbsk7UCVBLqZ0RhcaefkXawOHdZA/tBcTmBAb9/zcnYKFd700l6o+vYeHRY?= =?utf-8?q?PKanKSf0Jg/PJ6Q75zJUuY2CJ+8RVPBqYv/JJ64I/OidsNXl5QOBXj1vXvQy9DS/X?= =?utf-8?q?ROx5bF0hyamZHZuorl41S4cDYo/wiowA70BAm+2Z5IguUPulUhd7XTqi1zpMdczJ8?= =?utf-8?q?cCLlGmZSx2XTpjLIf250tX0ddfgK0ONv+Onf/9tWWHp9Zw7K3M4miPsGLEXeHXf7u?= =?utf-8?q?rDVAna7eivg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P1ykzSZJ4YaW+7sZUn+5KLJLUrUq2wAVwPH3?= =?utf-8?q?Bz6bk2NYtv/ANBRLbPHLUCQZAylePFYr4lhBAjmT/E6oAaK6mB/ukpHEu3SwUxc4d?= =?utf-8?q?0+Vnd22rbccIwmqYgiRlGPYi1R63KwiQw6uwQe9jbkbBJA25JaAN0C2NjaCOZrjCC?= =?utf-8?q?g1y8M57ggFDSo7ABFgT5ZR4VFU5KOSLgwZGmDpptukU/wj/q3mr8v6L8=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8c6114b-3274-49aa-bc1e-08dce232a1cc 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:47.1323 (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: Ethg2vEHRd6OS0onETZUDnWLTAFeEJH6+QrxXx8RWpOejfhxNDLx5QETYcr4WJNE17NzSJywseWDD1ZYuxt2GQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10437 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 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 3388c9af63fcc..7dc52111ee0f1 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);