From patchwork Tue Aug 13 15:15:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13762228 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012012.outbound.protection.outlook.com [52.101.66.12]) (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 438E41A2C06 for ; Tue, 13 Aug 2024 15:15:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.12 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723562158; cv=fail; b=j3dZJSo7/TmD3fnm6/70ZE00TUwff+ggOA2UQtCNNB8B77y/Yi6tvxtgYWxw8rpt7c3ZeGgxrcDixZ9IvXZ8yBvJxrA5MykXkH6YCJLw1nr1tiejdagE82BYGPgXnNmrj0T3MzZ59qLgKUpTyom9c9rF6IwVuVEVcYONG029+SY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723562158; c=relaxed/simple; bh=AMTPnbXTPolpzXHYUs+QhAi1wFjOHFjoAF8ZsoKsfw4=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=GkZZWfV4Tto0l/0AghJD6uDTfxjEKGgXFFWXRgi3+RYD29MyiFZkEufg7ruzGtkeexXl+3dLfweo6kkO27eAG/RaFvLeVbwwF3fmaem8KgkYjIM9BSBwLcOdkHaWA9VuUBrww8kkFKsnQEQh96PljTXiNMjWCOMPQITPfV9kJ4Y= 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=m97DvH6I; arc=fail smtp.client-ip=52.101.66.12 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="m97DvH6I" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Rm0PdZMoQ0683DEm+/9gq1nZYP5sfk4331q4t2BvRz4gBslGkfurf9LQJlDHvZTZ5JID6vGpMm7CfqAbD9cxU4XE2EVm8zHlXuvvdZO9V1AB0QflZFktFXGGqbRk/ESm2bp0sLIJpgoVTi+BIBR4Fu5hinAi+acxDbjrjxoE7tm7Mvaxy8RGa94yKPkHQEyX/YpjkuVCgFXsvU7oKXEQXpNc3ft4v3zw9EP07vjJw3+IAGs621SQkgUm6VPMJ04kCXhCKKxJmzseuLKyEpnCmM1700PTgEGeUeK/cn6kPCAjw7RE9HUjWUfRPbdTQfuViVnVDH4WdaX+Z26egTzh3w== 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=oC5qMOvDsNYDhyMbU1awxVhjBYex/SQ12ahjS1n1Eqo=; b=MRDlfkTjbfbPe2z9q5YiPkF6EFIEYqaVtbfctGNJv2jEGezQ0eQonHAveaewL6zXI7YPtja6mbQ8qN43Ps+AAQqWWQO9zmFHecmKjmWHvtiNJMGhtsOl4fyprkn91RhpsHGhE7bfM7HuZyz1TEWCpz97bsK5WKghNLdZq1gOnIhPTgf7mCDjBQWYOwIUjcOeBZbFnbtsnVTaqLH5gZ+jQGMD1ktUe8AlGUAOrPQ53S5lr/pPoyjFuKtXxRIXkjYVp8RL/qgfes7tqarkvuzhCmzrHm3gMUQZ2JvERFhRIvYUCdDRUEgCreLbGwFIy3+DqjJhFET6L389+vNQAHTfIA== 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=oC5qMOvDsNYDhyMbU1awxVhjBYex/SQ12ahjS1n1Eqo=; b=m97DvH6I6Rrgo4EQEsW41P7Qs72Q/9i7f118+d8J3bkQLU36EmH0gg0vvggTM7LAgjB/eKL8/gllbk8xyR53dFSwmQLj9WM95E5E3f5qNZq91vaw0CgV34OME21s6FVoTVlwltFzFSHsPpBBvGVOocQvB5u71POLF3zN0ZagFBqgEZaTAPrZb0A87xhIUtK+ykw2TjknKlGbfmgrwyDhuSfAfsy84U8MhRJgFOoUy9dET/r815AjYFqQ9fKlXKnQgyJaxoWlHIZwQccxK2H0frs8oPbb9nfGCt8ZPGb/91BxXd89XJ12/+4t3l3MtpokY0TIMOgTvtvbwpnrCeYrQw== 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 DU4PR04MB10623.eurprd04.prod.outlook.com (2603:10a6:10:580::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.20; Tue, 13 Aug 2024 15:15:53 +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.7849.019; Tue, 13 Aug 2024 15:15:53 +0000 From: Frank Li Date: Tue, 13 Aug 2024 11:15:08 -0400 Subject: [PATCH v2 10/11] i3c: master: svc: wait for Manual ACK/NACK Done before next step Message-Id: <20240813-i3c_fix-v2-10-68fe4a050188@nxp.com> References: <20240813-i3c_fix-v2-0-68fe4a050188@nxp.com> In-Reply-To: <20240813-i3c_fix-v2-0-68fe4a050188@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=1723562115; l=3116; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=AMTPnbXTPolpzXHYUs+QhAi1wFjOHFjoAF8ZsoKsfw4=; b=pb8vKftqEcjI7lnZGcpOwloHzr7ggeIr4lRIHTgWrQSDvhmuKOWGszesMsjGrBGoM9ilpBk1p yD+1yu0vtzDDXArVTWD35Sst2+37CyO7HUpqzzNd5Rxy9vMdTcdrhLU X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0125.namprd05.prod.outlook.com (2603:10b6:a03:33d::10) 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_|DU4PR04MB10623:EE_ X-MS-Office365-Filtering-Correlation-Id: 2306c555-2115-49dc-bb5f-08dcbbaad26b X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|7416014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf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9UHyuRVhtfi89RWpDgyvsp+xGHNNFLp9A8?= =?utf-8?q?yke0qky0kgILH2TPNiGdx0vfDTEarv8DAlFnHi+JlbwBR4fgIe+lmcpk2vPNIkF/z?= =?utf-8?q?v4BoD40TTmDJMZEuGmNc226SLWdQUnyCTYT/yykZIfeBvF5cpQRoRepr2gUTAhP4D?= =?utf-8?q?XgSy290p39v1QQz1wFOyz3veTviWbsGuCnw9Ilv9jsvL0LORI6Od081n2QtF/pPLQ?= =?utf-8?q?vjTB5FMsUsdoe5yqkDAKNGOeh1E1W7c4QSN8IgBoL79vxnnh6C8dbSr7c+HgfBxcK?= =?utf-8?q?3zubyVPq1r5ghrSxEbYqbMnDPIm+N9HpyjytCdqutSYnF85yj5NcEWEQ4MaW6OTh+?= =?utf-8?q?j2iL1xCB/ptEe/PAL+bnGOT7Xt7yBmmqLIk17mFO8VAFn0Ja0RgrMzY8r2QTuqrJq?= =?utf-8?q?M4YqgIjriFjSiu/VHQKQbreaOKdQ1K5lNARm363JOd+yl58Xvu5bxSuIEjkcBYkll?= =?utf-8?q?cI4G+zvdIgVB1R2uIyZ9qQT5aDKlOTCReA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(52116014)(7416014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?9FhpG3O7b3KcJwBLTXelQ6V3GWPH?= =?utf-8?q?MkT3aCwBLMrpO8FwCi+6aXopuLjnNVvGPCNskSSGODyTFznugO7CRc3993Tm32fz0?= =?utf-8?q?/i7XyA4+LoMQCKWeWN+ZsmNU5cz5FFdxlV0VOeuHUdvWHQAo3T5hb4kshS0UnVyGU?= =?utf-8?q?8PXpTci4+9L6xoZtUmZ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SGGcS/lNyUM4zDOZ40R1iWI8wrYyLOi45+v+ctsTNvWlAI5izJunGKA/e7Vm?= =?utf-8?q?0cY6oX0tqfChEna98ZCq1pO2jx10Ad56au4/E0g23Zlk4ftdZDdvh2/uxzWQrE7nL?= =?utf-8?q?J2xe8YSPp5s69/NxOLTzy9brKaXDip4/2bLfEuvqBBpTcOiOk6Co105RDuy+BDkF+?= =?utf-8?q?8bcub91SkCwaPcbhBTkqGLPmCELhrQ8FMan0nFrVIGSWNch2UBh8D+FYshR8QXIKA?= =?utf-8?q?X5lIxUHMEEFppEgQM+bVj0POQwIPhHitL4lqbCC/8ksUEHmnTlJ+Ll4l7r8OLGWUP?= =?utf-8?q?21jk9+R6mye2Kzj2vjMaD6pF2GFtOR7Axo434pB1zCtDbtT/uRc5noHLR9zMpqZmX?= =?utf-8?q?SFCAvblguD/Wqmn16HHq5UoEDzBsJkBLkB7/X+gbhHkgth9eIrmrI5W5GFAD57daM?= =?utf-8?q?nQ47rmFUP3NB7AyuHpan3p54qWDc+ZLrrV3PhGHkzAGcRdq6KgR2wYOY=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2306c555-2115-49dc-bb5f-08dcbbaad26b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 15:15:53.0303 (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: k78ry2i9Nu/pu9P7WKtueN2lrLyq0ueZOg/lcdBy6rONDFIQxP2bMEx27aUtkL0uqQfEugx/kl2wsXOogbBMiw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB10623 Wait for the controller to complete emitting ACK/NACK, otherwise the next command may be omitted by the hardware. Add command done check at svc_i3c_master_nack(ack)_ibi() and change return type to int to indicate wait done timeout. Signed-off-by: Frank Li --- 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 fbb6cef405577..0de95f406c95b 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -384,10 +384,12 @@ 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; + int ret; + u32 reg; ibi_ack_nack = SVC_I3C_MCTRL_REQUEST_IBI_ACKNACK; if (mandatory_byte) @@ -396,18 +398,31 @@ 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); + + ret = readl_poll_timeout_atomic(master->regs + SVC_I3C_MSTATUS, reg, + SVC_I3C_MSTATUS_MCTRLDONE(reg), 1, 1000); + return ret; + } -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 +432,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 +886,8 @@ 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); + if (svc_i3c_master_handle_ibi_won(master, reg)) + break; continue; } else if (SVC_I3C_MSTATUS_MCTRLDONE(reg)) { if (SVC_I3C_MSTATUS_STATE_IDLE(reg) && @@ -1145,7 +1161,8 @@ 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); + if (svc_i3c_master_handle_ibi_won(master, reg)) + goto emit_stop; continue; }