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: 13818323 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 BBC7CCEACDD for ; Tue, 1 Oct 2024 16:03:57 +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=mKzuv6BERRg+8mpyLsEmKBnIC8vTbGtHRS59Hc6fa14=; b=VXWEcpDpac5s0rJcA2ueFdV/GY AI3AIV1OsLALeeQctsA1eZOqYtzyrCX1zHPsEYiuLrcWZxE6Rjsn5G95zOY0AS+pISFmo7ukFR4wQ w5xYrhKPXieLfYX5LAeM2j7wXO6LgdjEZHTI3EKr9gCLpGR7flpzQJdQTvbuxynwD6YNxlm7xGWNW Gokx9hi8Ugf0D76JXh+8pHwJK5A3EAe94kJzn3xBLRDgFOLxWe7KdEHwrsvPLQjxwrIjW1VMbNjgD lO7a4PeyH2eJ99mhypnAN/1xXS+dHR3fKZgH+1Sedmho21JGs6XNa5wVCMmid5SKPeiq2ZVln9Sam GzTgi24w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svfLw-00000003PxK-3UGo; Tue, 01 Oct 2024 16:03:56 +0000 Received: from mail-vi1eur05on20629.outbound.protection.outlook.com ([2a01:111:f403:2613::629] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svfLu-00000003PvI-08pJ for linux-i3c@lists.infradead.org; Tue, 01 Oct 2024 16:03:55 +0000 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) 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/cN8K4N25xtOOeeSHfi7kx9o2crRdupnKcW3mnxf3bDXf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EGlv?= =?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:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?9Uv0Eyp4MK6G331JhC9XbiN6Axbj?= =?utf-8?q?pjrn03fXInnFOVhcHt5mZhrS+XRmihc4D7kuijk/AuUVyGf2qyVKK/wgIRfu5NvxO?= =?utf-8?q?U+Gy1YNJMj0nowgiula0qqbzjaiiXSveQ7u36AZWwJ1u/Tz/p3MW+42l2vhK0QBGs?= =?utf-8?q?nPYkxM8knvygZFSUe3Om2iTjfXHVMpHd1+bwvWh61TU9TM3zv0+0QB8FYtyDQ1meU?= =?utf-8?q?YYiHRHNU/TTJVP9sxrbEpAsGZDttA43kSRsp6dY9XJNxYS+En88vp9NQXgz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nqF8kn/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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241001_090354_117825_2192485C X-CRM114-Status: GOOD ( 14.80 ) 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 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; }