From patchwork Mon Aug 19 16:02:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13768549 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012037.outbound.protection.outlook.com [52.101.66.37]) (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 B6FDB18784A for ; Mon, 19 Aug 2024 16:02:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.37 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724083356; cv=fail; b=FewAUoUYExgDX+w7H+Vd0mj0prTT0oYbi924aCmgAJ67eAkLQKXbqe/HZcG4ftRFXW3iyEmNuR5fE/d+zt8oQ5xf7JeQZOYbr0uW+uSKK15eklMhf1+5bCqyD81jdaGGOQp4CuD3OwvQbTHsHGtwMYhK9JqPjYhhXibejvs0V0Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724083356; c=relaxed/simple; bh=Hh0q3o0ccZLTR2dgGNnC93iysep2t/1zblPjKc+L/EE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=c62t5v4bb7Y2ftKyS3Kfdd+iH3G36SHTfcmZZiS87ediIXFwqATYKpytaChVLVjHjxd3swOr8rkxCJwZYpGoR1TAGYd/R7AxGvb2Z3VITZo1uJJEaktKmvPAuQWrojDxSykkaDVCkyakVfAbLiGOc5bPP4QjtqmWr4/o5aaqO2c= 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=eYKAB4pj; arc=fail smtp.client-ip=52.101.66.37 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="eYKAB4pj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wO8Ml8bpm8pCOMfrFfmKQfvrmmlH7wG2mbUJBWJdZ/waYY/00M/VvbhfEV0Rmp4QsYhpNtcAQUlkUxbRPr4p35tg1/Eym2CTXPIcJNOCuUE9PyH4dp4NEHo0TcpQDf9LeJZZrPTSxC76ijM8jW8zGVpKtp7vXmglASFYGNHfMT+fqTCl0hrGHEMxanwsdlwIDMYqLKrI7aXS8Lunb+Xhw9IjROM2671Nrt09efiblTZHG4pUKEUC1brBO/AdElKMJhiIpO9fjCboIO5RNw926JOrupJMiOjtUH2Q5TmQTclxhyqSihv4fnQfUkokxdEjEdrgN1Ng4DVfu7jp6vGgjw== 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=MEdVL+pyB93zAIEI3T1O9Db0QOqRxjZN/Oi8sHzMIOo=; b=UHxvUSRQOVwVzuPUvg6QdSV3Dg/94AVd/IXLDCpYPU4dhZ4b9aH1D74VLMvCN0woV7Kf6d/rQ0NzpIy8h6TdllfMUSxRBNF47+7umvht8eFQlJIYbLo1C7kCLVPhKXEVhQGPXYraiXyOdKzrGRVNlds3v8E4bViQmOSW40YRDkcEQBg6lyu4O4fTThX1c15YFZm/UgFEBoJGA+VCTabXc+44LcVsxq0Y3Am94LRClIHq7c8r8lW/VDHOPvlVEqWDov6aMExsPtTV0LCHGhYQmrokSvMhzrUetgHXxLfjog/r/GLIrpk/FnX9GH3Fnv1BmedmtF5YOs07zgcEBLqigg== 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=MEdVL+pyB93zAIEI3T1O9Db0QOqRxjZN/Oi8sHzMIOo=; b=eYKAB4pjFgSf3QTFZ0YWxv9roZu0FfoPGqcZfZ+yMRhLeSt919KpVTvR0+JgIP7yyjLx38sRTRxLsMzZ75WssE06IH3K9OxX+XNhiMvmE6pcmiJQ0GhXNVjz6CpsRAupwH71m7/AQJsgEYg+zBgHrquVI5qAPxPKrWvLQQ1kaInvcRZXC3e5YcQUO+UdS2WhJZd0NdVxLnQCBLHoMWD8jDwPYOw6sRsKeGRLQRW6du3U9uWISXEORaA/Nx9gQGhcswayd0/VlNWpi5whSMuiYdzxPxzhJ+ey4WA6nNZPFhyLZGakZzEBq+YCIQy0cH+9EbutyovEJMJzSKTSAHN4gQ== 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 DU0PR04MB9659.eurprd04.prod.outlook.com (2603:10a6:10:320::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Mon, 19 Aug 2024 16:02:30 +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.7875.019; Mon, 19 Aug 2024 16:02:30 +0000 From: Frank Li Date: Mon, 19 Aug 2024 12:02:04 -0400 Subject: [PATCH v3 10/11] i3c: master: svc: wait for Manual ACK/NACK Done before next step Message-Id: <20240819-i3c_fix-v3-10-7d69f7b0a05e@nxp.com> References: <20240819-i3c_fix-v3-0-7d69f7b0a05e@nxp.com> In-Reply-To: <20240819-i3c_fix-v3-0-7d69f7b0a05e@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=1724083326; l=3150; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Hh0q3o0ccZLTR2dgGNnC93iysep2t/1zblPjKc+L/EE=; b=7BuLoeBKoGN+8U+MgzzIxW/CbXsgpGth92q7FZLdgrl75sujgcY3Vn770RRHmPkABe5ZpElHX ZKTjPmremckD55edf0juU7bOPzxS60Bd+TmfOVafXzq/946HBi2H9zF X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SA9PR03CA0005.namprd03.prod.outlook.com (2603:10b6:806:20::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_|DU0PR04MB9659:EE_ X-MS-Office365-Filtering-Correlation-Id: 36f76cd1-dbde-48c2-03b6-08dcc068549c 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|366016|1800799024|376014|7416014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?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ZCnweltePuQlSmAXt?= =?utf-8?q?JxMUmdhtzMFQ2Xh7kokG/UAlM8R5frjMlwkqdiJ/f4TpAk95GLAe5TY1ZxDL5+H5u?= =?utf-8?q?f5bA5GYuyrzvzQwe66LIw3o3ntOlVNuLfmRIfeFLQpBtc6QoHmaSQuu0gsmDd9pMC?= =?utf-8?q?3M+5Zv8ks/k2Yumbg2EZnuu31t8WKwqWS2d7RqYB9e0NNtt+aBRhncX5t5ZHWtP8A?= =?utf-8?q?EcXUS7FHtzAEOquEwkC+rLzr1zZyYyTxFMvGmPEuij4dRa1W6zeP3d/V0pXmjYEmt?= =?utf-8?q?Dklk0iOS2d2LxPG2w/Oh3qUrgilBtcXXBHBrC5UcpQlt2zXdG6roZV1LwLfcBy3TO?= =?utf-8?q?/PxSsFJE0T0MokXbNQq3zrztANoL9kzRVmfXudoHFh3G0PSOCgQVNOU9GRArjfMVg?= =?utf-8?q?ZAeRCKkQokE1iz6CgwyAoejVQ5KZ09pdgNlua2aG/eS8m+6Fgwg6mwXYVh0lCYhvB?= =?utf-8?q?HykNu0DBUoPz+wCAzv476SpV3uUUeQw7ow=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)(1800799024)(376014)(7416014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?v+YT0f9mdRerNAV/AUX2R0qpIQMS?= =?utf-8?q?9gCjXG4xlf03SnTH9UfgBzIZb1YC75NX9kALwdyugZTnnMOZmQTgXYmAdr7nOWv0/?= =?utf-8?q?+g2q/FfGAT3R3P8A0UW4eOQuzs2pUlska0rVkLIfgY+yK1IT83vElsc0/04SFJg6e?= =?utf-8?q?R/WE2g4vicCH77yDvGhVT+pur5LhzPlu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OSkRkxoNlQAwELezevY?= =?utf-8?q?dDM12blYPBEoF1QOr6x+POrlHIp9aH16Z+/Jou4U+xeobrGSQxCfAlHiQc7YhWG4V?= =?utf-8?q?AWNdiDb5pft9ytdTZ2vYvV4nQZeXcuXYmCgaAIH8qohJsCA4wGhCWa9YORU//XZiE?= =?utf-8?q?IhA7YV3wJ9W17g/Aut1YAP95Qou+2cho1gSqBT8bWdO7rVBNwgcgxH/6xrQSLXTob?= =?utf-8?q?SKAOTesRi04W7Mq1sYQDCaO1RZWinqJsPUnJK/98hw92TQ34/PzTqyt7BQzJurnnk?= =?utf-8?q?jmXts94axm67wGO2s5kvPa6I+jw/Oiao09dOabOXroliI15R+ibJEAiXwvP8qT1MW?= =?utf-8?q?tXCc3RUkPvZ5scTglEBVaNNlVVzKckw90R1vaAy9aN81G/yBFuvq88lOm2aK5i00y?= =?utf-8?q?N9gbV3mbZZU125EPniX3yPPhNiAuVbDmUkKiT8BFOIkbZLgjJH5Pl0GfKFMc4n/x5?= =?utf-8?q?JX5H/ptcx8Ce?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36f76cd1-dbde-48c2-03b6-08dcc068549c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2024 16:02:30.9044 (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: 7STn8EcBqX61Fw6yVPmEaWm82TI9VvttR976QGZjKtAzbxUvYXlpbCbDGgCypTUREKon4Z1pQCFpWX5dqN365g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9659 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 Reviewed-by: Miquel Raynal --- drivers/i3c/master/svc-i3c-master.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index fbb6cef405577..2010495906eb3 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,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 +1162,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; }