From patchwork Wed Oct 2 14:50:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13819884 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) (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 05C951D1E89 for ; Wed, 2 Oct 2024 14:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880673; cv=fail; b=pMX3WlrUb0/ZPBkUDr2u2q6OulvR8b797JU74bc2DBZoOQMh7mB4/5bBXIUp9TaGVi1gxio2ne7+HNxI7xY+qaUTD7yequfFvv7tYxJaK2fkfSDiFuvUmeOccTXzIM4gJSyQjSjjvIiL9yq/jws6iZ0sErYqJtM2/MW/bblz3Jc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727880673; c=relaxed/simple; bh=G9/ttx8HfBwzcCCJhNo04kopgONzp6KBdwhqa41YDTc=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=esocUvzZcuAB6dk1T5g+vcZchXlBar2h/Gkzsxyd8cBencc8dR1PAe10sXDKJKo4ydbxcnyw9S75363VRTHMfPCZQing6SERsp8UMmFpOIgBYasXnS830rTjno4GykAlEgJwci13hZoOZA9G83j38kPJrPIg6saZQcbe0HaVyMw= 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=PEXUPkii; arc=fail smtp.client-ip=40.107.21.77 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="PEXUPkii" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nXkh5eALk5vyRhsUdVGILm+dGYBIk5oeuRaj+gZOBUDJUkYmXgZPrg6h4dCTO8cpOBaQB8gi4L9kmWK452CWppmH3TOODVrjlb/Djq4XIEP5uOuxs2qhAIbrkbs2NgtbQJQQ8mTUCMCAcbbSMpH5bI+1tOamF9Ievxys5zCVX4LkJRLjMkzW92mcb6Byr87EuLR0WiaTVblRIqhI5JdKkrsuDzhmH335GmLUE0+LjzIAqY1d3eFxBSE3YOvSXa6H6XUXjeT6IcOqbay06XEAHcNdAEb1+QPl9/xMlp09zSQp4Fkdu8jGFxY+a+tx/Vu8u6PpQsSsBjDlj5oNuCysXA== 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=xCabqBI/J+Um2gFtk/c1eujjBGuD7tYM07r5dx9+W6Q=; b=jxdP2DcKPBe0zDSp+8mzcrWWYge39sggik/ye06ecGSDVTLcZkw+y9dmK2p2yryun+GAup7KO8i4naz9XLy+uTOwrhAmXYhSQC7mA4tpiB2Wl/GfbR6mkmGic72Nv+4zRA4nLCmj8/dvY64JEifwdYqUdhnwHdRn6jsFFthID1mQMfuRYINfaUpmGUX3kbS04KXrss5OmJmR9U3Plb4ifmzWt9dcv/Al1unOPC8o9O01XQRyA5Hu8LdQOiIhxvNOLo+qjkXByge6JIhgz7BpA3MPvV1zyAFjY/yVzZtBL7a1j6jPfHoHaIXn7h63M/7OTUIZ1ZneEiZtg7J8XQK4QA== 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=xCabqBI/J+Um2gFtk/c1eujjBGuD7tYM07r5dx9+W6Q=; b=PEXUPkiiO8XmHi0q/MkPrTL4+Bta8iS9vIrlsqMXWLLFKYb6VWEs6EQdyQS3NxFBZNAfsyxoclRM3dEzIUsNKGDGNuvBVwIeIivOs6yfW0GOpQwn6yX50zhHU4nhVxzLurGrZvZpOKMpxWSQhr1slRXju5Dw0MZEHZbns8N8Mqb1Mv49Xv1ekz1Pr3anl0GullU3nqLwZn0BJiavZj1hwKEf3st+o9fGrxxIxU1kORPSwyC7aaV/ISY/4RqL1PktUZATXeWNy8BiLsa7qjU68INIe503EZ0f6VqnpblGvMgbVvM9vcQlBTrpNnXPJvoGNJxDex8H7rzM1N0w4k/f8Q== 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 AS1PR04MB9699.eurprd04.prod.outlook.com (2603:10a6:20b:482::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Wed, 2 Oct 2024 14:51:06 +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; Wed, 2 Oct 2024 14:51:03 +0000 From: Frank Li Date: Wed, 02 Oct 2024 10:50:37 -0400 Subject: [PATCH v6 5/6] i3c: master: svc: wait for Manual ACK/NACK Done before next step Message-Id: <20241002-svc-i3c-hj-v6-5-7e6e1d3569ae@nxp.com> References: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@nxp.com> In-Reply-To: <20241002-svc-i3c-hj-v6-0-7e6e1d3569ae@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=1727880649; l=3372; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=G9/ttx8HfBwzcCCJhNo04kopgONzp6KBdwhqa41YDTc=; b=j0Cy3zpyiNPCgiiRenemJPXQtFjOsLeN0k4YpZehwlftlCPnvrOwh84fLbeXlV3tjg/OQC8vk cLXKwyPyjfWC8euOFJY6eV/24w2f7PuVitZptCbp8suugX96dVVqxqO X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0177.namprd13.prod.outlook.com (2603:10b6:a03:2c7::32) 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_|AS1PR04MB9699:EE_ X-MS-Office365-Filtering-Correlation-Id: 35375ec9-9797-4301-1bff-08dce2f1a324 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?efM1SY8QXvO8tn7bmGT1mXLJ6MhyjoG?= =?utf-8?q?6h3Fg7cQoeWQIKTjMuviqM3WEnA8QFd4MscdZm2b8xgTw7jl1eV16r9mDh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?utf-8?q?+KHNwrVPPe/6gr6HgkuQs+KLwNaNeQU1fUMG+fxbrBxnVu+gb1Qb0pTsHEH/Jsq7o?= =?utf-8?q?7EE8weYi1Ujs8u41fX5w3IoQ6/rOi01vSmIjJPaP9j7uWcQhb/grs6n8jOaveXey9?= =?utf-8?q?nVdGqhecXy+fEpJ3LqdVxQ3qUEe5XWxk/+mwK6jmJo3at6xSX+F6zwwWoG1S/lX7d?= =?utf-8?q?MZjMt0I5W+tlR/RZE2Sp6tgwwj5f/mWiVj2jUcqfhO8L3GPlaujck/T0DJHa8S/QR?= =?utf-8?q?ZlobmJznZdya5FKrHEHbvobtWva1ZYRwDNmTocFgXuvUwyyMFyzznrXzwXt2ieKGF?= =?utf-8?q?01vTvboo9AqsqaFg6sIZHcebqdQNAON5F9A=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)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?qHrZHFVmC4yj4OoUsKw/ZcM9oaIE?= =?utf-8?q?iqzEROKWvsr8ZDtS0IBuBqLgpLowzO1Eihrwq4HQPAL7/P0w5hY26SpRrU/1safVM?= =?utf-8?q?6sVT+zewLpRtd6ZUClw/9ODkQsAC3uveSLSichbiFF9xYCc2GHKRBOnCtK5zsNWbu?= =?utf-8?q?SzupPkhSTU2f4/gMJcR0z5he/TY7/JZvNGvNaWhWLngAN/eu0pvuQ5j4Qy8qjhae/?= =?utf-8?q?ZtTD4op8YyuISTn7C9wM+wsvdJl1t7+szRvC6SRkThMxYHmNBkI4vJUHHZn+SwVbj?= =?utf-8?q?trsuN4mIjuV5w+cC5u7uSDTYDIV5h6AFn04JQLuzGmIIWAIsqGfvGL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uUC93GCXMSzE97vE?= =?utf-8?q?LON6RKedeQskoM/snLQy162gIx7oPJJgpFP0pYMqzAiWZyIPDh8kKUg+zZU45HX6F?= =?utf-8?q?+DqbIxIErQ6jz9j6rXmbtKYcqDHWx6mIGErUcSmx5R/e47pse2BGDyplTxqRvjm0I?= =?utf-8?q?rx6D0fC/2MOYbteRQKa+Jd+UwUaEj8O3o0NVcaHVJJZ3I23H+n5muX7NIJgERAFvq?= =?utf-8?q?il5AH1JeiGqI3+XDBG27ICdCRJK/pM1ugAhpfVWKHL5yCpg5KPSIv84p+A9wBakMP?= =?utf-8?q?UCXlmoNLgTMis6lDuk5BYXN2nlUiN7VlVbrSsvfl/xOU+A0eiQq9IbBBlCd00y17k?= =?utf-8?q?x8YMAQezCkT0?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35375ec9-9797-4301-1bff-08dce2f1a324 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 14:51:03.2566 (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: Cx1JgCw6BMVgYqsPZbDQA7JO//otiwWncNvPum3BFme3Cn73gxxpXcIZZbEz08MHSWJPLzNmvUwfZSAjEpAacA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9699 Wait for the controller to complete emitting ACK/NACK, otherwise the next command may be omitted by the hardware. Add 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 v5 to v6 - add "add a" at commit message - Add Miquel review tag 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 ed3f1bfbea37a..7ef7e50b4b916 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; }