From patchwork Thu Aug 29 21:14:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783889 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 4DD82CA0EC0 for ; Thu, 29 Aug 2024 21:15:23 +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=tTPfwbFMfN6Bf1c4HXJF6pLJp7OehfNBLGkqz13jgdI=; b=y8jBx2hSld+hB1xFOHdGv2k3MW ap6P8Yxq80XjF/wWNf+vDbTzqk/6BimKjI00StNUt3vkt/xSOfE9l9a9aI6WtbYVCf7RvmFQIfxrO FX0ogYsO1rEID+Mfj+33BjrztIPkCYsFdaB5G0jmdXXzz/fTr9VS26c8fvd8fV7VzDUgKWsSUNJJL zYsXmIUm9MQZVtEEw8cY1vAlr+lprmhvRB1qE0SBqxzjqeu4nk3oN0q+fGc5cyti8iILMk/eOsveo ylJ5IRfA5cLf6VGm9vx/MVNRqNlEuK7OrSZ5aE3KUcxmbXaGS789LUP7QJ5QplbHGPwBttA1zu3l/ 3ZbICvvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjmUE-00000003f0h-3d1K; Thu, 29 Aug 2024 21:15:22 +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 1sjmUC-00000003ev3-0ITw for linux-i3c@lists.infradead.org; Thu, 29 Aug 2024 21:15:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qqyw4T9w8WyvrF0XYfSopzomCqIrf2YjFuiIrREvHP7pV1invaIZebZ/7qwL9vMyqG2T4zuc8Z/BXsgxwrjiE2i8Ksbso4gJgjxRFiNDHI6u/N2BnkWGD0JX98+HHvmsrW28eWrfVpgH4LXg2BvTb8q5B4Sa/KH+yjlHTtDV8gvUmOfA90I518+W+krUXwiP5Cmgbzujd0rNiOCHlJLhwCY+SZiGVRwCSpxB9J3jwHq7sIJeL1ZLnMRuyntT61EVyFIuGPkJOeuV9lRaeWTyhyblSw7SJCiW3Ur8QKWq6DqRyQ78mfvc5YIL8pHXMpohvbnEnZO8Zhk7PLX4GDjCaw== 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=PCE5o8DgP/NdFwqb2zh1wIauPY2CTq86zMl6jwYhWFE=; b=GkLV4daMfEUS5qkS4Dmdh8S01foz75A5Y2uLkjUbERrP4dP2DqUsnDmxDCnXK+op9c3VM3A85k/Bg/Oq+ihlSCnBsbvTDMv7auOqinK2rrtWnFE4wxSwzyP57fvgnY3vJtK8w8J9S7LowDtwd32N76DTtzch2g5oS2y7fAkeYUT8YXTUjyyX4K6if6bDeJsq9bEO26ssRQvKjh5g7CO0LLUP0yxgSUPdQf2T5ParRFOhJUJyetLPB0Fpgn1PPjoo4EJ7F0wkRiLE3E+l+Bm+SYrs5Ya6e2xFHzLZ33bhIJZhMY0VjYddpZbhvu6Fibo//k0rh2jIufYKlx45holRbQ== 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=PCE5o8DgP/NdFwqb2zh1wIauPY2CTq86zMl6jwYhWFE=; b=cLEZiZsFH/yNERwW0bF0le03C6lglDFj9lYbzKvy6dy9J6B7RGNszHvlV6bAERVYsz8p2ByK8hghNW87SOnCxpA2sb1wpDBRPNcRVofADQ5A+yNHdnV/eO+SgApHYtQynO9DDBS3LqvKKVIvYzo0gIdscCulXeueH5hWS+4A2lbYxr96WGLufsMQ6yZOrlF9nkXZcZrwGzpWD0EUt1tC2/6p4EJWtQosVQkhtPEur2lTRxGclJ80VcvCrNRH/wXDWC957GxsexRIzedZvDRUaHeiePyGaLFEnNzrY8DS1QUzesL04aPSsxfUjP4n0pe45KSXZltVW9yzozjJYMI33g== 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 AM9PR04MB8971.eurprd04.prod.outlook.com (2603:10a6:20b:40a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 21:15:18 +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:18 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:14:07 -0400 Subject: [PATCH v4 10/11] i3c: master: svc: wait for Manual ACK/NACK Done before next step Message-Id: <20240829-i3c_fix-v4-10-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=3288; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=NDB+qerLSlJSMe5Bx3V4/wTHzJgVDT0s38KcjNPNozk=; b=q2n5Lsj5KFX1WFbYvjRQ2b8KMqUdUqNDdixIN/PnXZTIUoA6kE4xlWbSYZhZVt0OfStXm3vuc 3YPriMDXn4UCx/fDL6ea+YjqWu7xpajqmG+Hzik5rQcriQTLpbMVc9Z 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_|AM9PR04MB8971:EE_ X-MS-Office365-Filtering-Correlation-Id: 67de2b13-e2eb-4948-25f8-08dcc86faef3 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|376014|1800799024|52116014|7416014|366016|38350700014; X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nswP/soSNU/0g92KAghO3DQqY7fH6oqidUWdNl+VHWsNM/KXMfdlRvpt?= =?utf-8?q?ktdu7mTMimXBOOANBKgYS2//0d20VD09ffnIxFB6vH5LGNx3pov32LwZvTEA4/Oan?= =?utf-8?q?+Nl1ARb+PYtdwWv3k7uiQXyofKz0cmaO/WN56l3ue2HZixHkBX/HTUHUTztopDpIS?= =?utf-8?q?bRIpl8Vah+F9/BIi8TiV2ROAOb7riMQb9WyzRuXCPTz0bftihN1Hd7Xl6F6hxk7H7?= =?utf-8?q?N4bD+a5O5uzog63XKKaeeKP3MmnKQc63aT7906cVfgGE7S0Q24C3Ai32vCV6prlGN?= =?utf-8?q?T2CTEbUA2DURRHHtCwLBhtS1xFnECQJhNogURnnzFWciJIQ9wUTabL3ZFlOqXgBFZ?= =?utf-8?q?2Qo85gvIhQtvZb3SED/SoKSDzSGSndANYDALBJ9L1e+3lE2fART5fm/6+odmOoJLM?= =?utf-8?q?jb1Fq3odf5ITYB3+lYt2EVkfN/WNl3m9KBQijwl+Q1CG6TPuwbYjqb9sYSntw668f?= =?utf-8?q?MO3TEK5OpNYrr6+rHK4CvH5rOmalixdV6Q=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(52116014)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?sLOU22LvS9xqpTJ3/wcohmscTIck?= =?utf-8?q?U9lUF5oDNn6qxXFSSZDXfzIxEZW2Yn9KK5ySCqO5I27o8aQutsKxjCwTldErxvjeT?= =?utf-8?q?s8KouhZnLjVL4Y9uA6lUByMHPB2w83Vs0JEgyDzzw19UFtfsk5+XfaJ0Qq6Z05I40?= =?utf-8?q?0q6QCDnD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cv8vUTWK38ehtnElpe8mA8rBrmXIuRVPZ+yNz7UN/17htwOhmtD/yKL3h?= =?utf-8?q?7OalgiKhwcqnvmxz/BZZldOoCGKf/hncAWfN0mL8IzQhUw5/CSM5IoXI99H4TUa9E?= =?utf-8?q?zoLml9J3QdxC7kUuUEBmHznq+Uryq7ME4yVJxLnpDiDy5efofWCPhEwVDGAJddN1e?= =?utf-8?q?pQdyXvdDvZpts0ibERVCWiG1KNOFg6CLcmX0/zH9TAQ+0PWtp7yQ6E2wc9Wt9QtH6?= =?utf-8?q?9KmN03+Pdk1WJu5fFek6roOR4BUJACwhirh8vK1/ibJl1sUBygGE3hUJpkNc4yDDi?= =?utf-8?q?CsT5Bhq099Lxw/5fVCEI9s8nOEawK6ZuUS+L3q35Knep4MMrX1uZq65v2E0QuoS40?= =?utf-8?q?5KSH5s8DxvBf+dgrCkPqSU8lRmr1i2IxDyjdfPwGF5izxOs+ti88+I5W1U4P6Lr6m?= =?utf-8?q?svRXhSgC/hORfIrMXLGSeJFOjGxvDYUBBcl5DI1JxFwCP8k2seV5MowNEnncTbr+6?= =?utf-8?q?LbQGNvfsb1lr?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67de2b13-e2eb-4948-25f8-08dcc86faef3 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:18.2784 (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: 63nWXblq+KeUyN8xSoD53dvQPCOyZ+iXwzI/0ksBqwuQ2Oeit6Q5DRbjac4L+bmCMMveHHXgiUZFF7gUiXawnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8971 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240829_141520_177145_C9DDFF97 X-CRM114-Status: GOOD ( 15.55 ) 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 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 2b000f446f1cc..83b2943074866 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -384,10 +384,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) @@ -396,18 +397,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); @@ -417,10 +430,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) @@ -871,7 +884,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) && @@ -1145,7 +1160,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; }