From patchwork Mon May 6 16:40:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13655760 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 68F69C25B74 for ; Mon, 6 May 2024 16:40:46 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ANOextUdEkly0CsrTTuC6MwAV+MBwZatqmbAiJ8JeMs=; b=CrUal283Ry2fnJ QStoRi+HK8pr/Oagb1WVzViC4Chct0a+rzsKfWp4C7tyVNDdnQF572veM5M6HRB5iztzu9Tp5v9Bc cPoqfgf4Wyb7m1ODjbSIoo/7UCGfGOMOsESAWU+bznwFgStIhRoFZRoWU//F6FGF9N7PpxaEaIRm8 rE60nDUjL22F1HmCzHZ9DeFpM95b5XbNR+SqwmidPoEjCjN39mIJ3pRZGjjWc7RickEWt44QSnLFC ClIVYGDPehWVVhc/bGl6hNUnnqHm3nM0puge4HpIr4W3/rdwjzrjjrRBFPWrBNZW96PlZMGI+Zpyn T85TdCqX/eqzNQFLBBVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s41OQ-0000000874u-0TzW; Mon, 06 May 2024 16:40:46 +0000 Received: from mail-db3eur04on0618.outbound.protection.outlook.com ([2a01:111:f400:fe0c::618] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s41OM-000000086xi-3BKe for linux-i3c@lists.infradead.org; Mon, 06 May 2024 16:40:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gwVUGCCC3t0KsPFijnDflNxBgLPfKq0zz6KCkYH4T6JQZi3jdA/RVGY8PRej4ZZMIlUS5lHomYjfEPQoE2PvgtdOAWcagKjKyaZLTkkEI4Rc1R9G1pjEmjnIQXvH5lIdWlTPXSerCoi93khj71epUxRpmStA1vZmLSW3aessGA1U54wJ41kihVMIm6niqxbMQbRSKOK1FL+IV7JlDrc5Kh2l4WWH1+ItTWJWdWaX+73INdNtItvcX52W+DfJr9bNlWqgVKjbl9Qdg2DsHBOkLpleHoAFkdNN5GQ1jyVJt/EAdTFK21AvGUvHHVDc893aZYWJ0p4x8jeWXQls5ZdNmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=BbvQuI+RZS4jJsJ68lAJ22P2VWHR5xpSScaRT/EAudg=; b=RnyJjj61NuzfWFjnSiW2mSLRIGG9sXf8+gEtk9c+xUC4ztL7CSSqYGO6Qu7aF0oGeExa7RLtra9RUh1X4zOa32MGiLyLz1xtuTag1e/WbzjMSj4gWovcOc+2mFroWO/QZYDlrs2yU5WRvfZG0TPtrX+JHcZz08BYe/h5V1kXY8/nJXgmj4C2MHwndpRiEucK9wo4nMMLUMFJ0/dsch3dRFl7/WvOSJ2AwgjwRKTIh0cn+jT44lIHDpObxpxGTlUQKD7abXLHQwc6vO+VKCtufQFRxMcFVmOHMdkUmdM0Y97R5KvTaXFcW/+YMo27CeC1uUOlp+oTLVrImKeOPq/dXA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BbvQuI+RZS4jJsJ68lAJ22P2VWHR5xpSScaRT/EAudg=; b=jLpsBhWQ3QIV30M2iKKrBb6SN+wMTf9JjzeAUrZvIbG139ihkUL993dtbC+Q1A60BoEuu10fNCQhmmHwl6ckAy1/mxrHqxk2VDtkvFEoJV9ZpEgM2cDLlZLxXfUQ2b6o9o1bYt+mmhrvtM4AZxhBuORr9MVAnvonJYDLRPQPjJk= 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 DU2PR04MB9049.eurprd04.prod.outlook.com (2603:10a6:10:2e4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 16:40:30 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7544.039; Mon, 6 May 2024 16:40:30 +0000 From: Frank Li To: miquel.raynal@bootlin.com Cc: Frank.Li@nxp.com, alexandre.belloni@bootlin.com, conor.culhane@silvaco.com, imx@lists.linux.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] i3c: master: svc: fix invalidate IBI type and miss call client IBI handler Date: Mon, 6 May 2024 12:40:09 -0400 Message-Id: <20240506164009.21375-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506164009.21375-1-Frank.Li@nxp.com> References: <20240506164009.21375-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0296.namprd03.prod.outlook.com (2603:10b6:a03:39e::31) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU2PR04MB9049:EE_ X-MS-Office365-Filtering-Correlation-Id: 8dcc8de6-610e-4adf-8555-08dc6deb3e24 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|52116005|376005|366007|38350700005; X-Microsoft-Antispam-Message-Info: QIQdGs/fhdrvuxoLLcYgHHoSVoEID3uUucIGDYLkh1aRq3S2ZWiHPbVf5DDNzsU+08jZGEUkGitGVdWBSOWADU6atV1UnNRf9Y74boX/PGy3BUNkf1d0KxU5fIe6CKCGNKjwmRLRWp+dYwRkYn93XiX/5lUhfrGAkh5dNsnhaSnw37bn9jUkNmcb856o0g3qYtb4qI60PfUCCR+zjDVzRuiQra6s2MDouYRAsaOxV5PgJHTav+82NtrbAcCn2+lI8WFHweIotuqpmf7/zA2wqNaIpuUjXYrVx02I6+rids9CTX9urn/s8z3XfHzFpgYd2ux8B8Nl4fjENXXNprU5aZTiAYJgXe7qIkx0MYyDDrYr6VRd19O9u03uJyUr9R4HzcxcUc5WQ63EaSRiHItQusYb9TvItlbxtY/SfLgg5lRQvHwmy/BO2fPob9OIyBLJr3U4fhvMmD3dvfx6Q3+jCCf5AMV88Bzh1lgbLi5zuktE+kFPcCCDoFSTJmLeQwMFcdEcyh5CJMS78/s4Eeiq/in/gROv4IUPhKg9FFBiZQkPO/dMRsLRomTAr7skzPvdf5bwQryy2WjVo7Xwp4prsXo+Fk4Z+3pHWdNjrN6fFcyL7bpdg2qJeT+/lmUO5UgDVvwYMg+2WeHR7z0D+vrP7W3S2EM1th/94+AZboTctyROnA642n2kWKCXDht99QPkXd26Cd2phi8SDket6AQSz9coRVzF8TkPxm0FW4NTvq/Bwfagp35FwGstgfDpMfMsB9UucEe9/PPdw6XUsUOdUwZ72WW9G/0KLnCFLT5se3QhrWUn6gC87iGDhFALe9gM4RbRdfS038NoaPSe1Z26IW9L/9mWEqn8ozGtrEx7MuaMSu2ZlcsvrM94wTl6RclVxsUT5WngGhXbm4CQpQ3j8tO0JyBRE6KdmF7xPbcqPfd+TXXVYjW4GtAUNle5k50otZYs/a/wx+6rwYs2sAWCDJGVksdJJNJbwHQla7mswxqnPccAgdlur9ie7VOjMZF2iYBpwCFP3NbtMrOMcPGipFYBFc1wfJmETHYBaK8WaczjEzQq3D/1oAgW+lm/XEw9n0BnRNTNYC+PWWQuCn6iuhttCWENT+VcJO/E7CaMrbRuheVUjkG1ifhak8GMg1gtub+/tp1V7ovj2T0WfBwtoh16/xrXcwaA5TPU1E6o0ZQj2rY4OD3UnfA1Wel5X16W6UIQUf5pSt6UlFcGoszYrw5oKxMOYoZPQwMDlxBYnk5DNWcQaz8wzBefgyEB1sK6yuwKRRQk/W3SYzyR9o/g18B6k21o7PEBhbnTjtL0QKjMPEvt4zPiDSLBVo/I2ZJ18agmU/nb9fSUfHLSStNLbw== 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:(13230031)(1800799015)(52116005)(376005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kqzO3sLF9Ga6mbYlSA96/3EfqPyW4taSin6j7wnUDiWgje8XrTlnW3qLLJKlJtj3AedJACBo0e8S13V864Brhqrv1McPMCNjvP8h81e8IH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oyHDL/sNfwq4dayVYJMuODH1QHFdrWTHFq6OwMmMeIQieGvgSNQLpB1sz3BTtyyCyYkJz09g4Hm47UqOKQoIELBA6oc/u1MIFP1EYuO2M6D8XUCtX+MFpDDNyFp5wDZW6mvEISzirspgM85SkWdCK1Zo+cnjJSPNKZd7tJikRA2JehyILfHcbtmA1t04IZcKI5h5iqD3mB4MuV71i1v8ehGYTmPWrjz3Zgh8kkNJCDqsOEfIEBrpBuKc8LXUCMM3l61XVjRKsuVZhG32tzWG0qjHSLHi6bRdsp60hWkXzHeLsd+h41yyXtjJ65eajZpe+sBBcCGjjtgBa47tBxGFSYCWTl56NE8u3fhu7cujfi9TpUY0uoSYQ5LLg5mG1987dg6gnr+FyzqGZGlmY877K4= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8dcc8de6-610e-4adf-8555-08dc6deb3e24 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 16:40:30.8384 (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: U23bqU1BIpZ0WIQDYK5bwhEH++OLpwlLD045WtK4EgkOcqU5vqVvPb0W0scYClNdPttYGKBkCI83BXNTu6tMWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9049 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240506_094043_335758_C7D71D84 X-CRM114-Status: GOOD ( 12.58 ) 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 In an In-Band Interrupt (IBI) handle, the code logic is as follows: 1: writel(SVC_I3C_MCTRL_REQUEST_AUTO_IBI | SVC_I3C_MCTRL_IBIRESP_AUTO, master->regs + SVC_I3C_MCTRL); 2: ret = readl_relaxed_poll_timeout(master->regs + SVC_I3C_MSTATUS, val, SVC_I3C_MSTATUS_IBIWON(val), 0, 1000); ... 3: ibitype = SVC_I3C_MSTATUS_IBITYPE(status); ibiaddr = SVC_I3C_MSTATUS_IBIADDR(status); SVC_I3C_MSTATUS_IBIWON may be set before step 1. Thus, step 2 will return immediately, and the I3C controller has not sent out the 9th SCL yet. Consequently, ibitype and ibiaddr are 0, resulting in an unknown IBI type occurrence and missing call I3C client driver's IBI handler. A typical case is that SVC_I3C_MSTATUS_IBIWON is set when an IBI occurs during the controller send start frame in svc_i3c_master_xfer(). Clear SVC_I3C_MSTATUS_IBIWON before issue SVC_I3C_MCTRL_REQUEST_AUTO_IBI to fix this issue. Cc: stable@vger.kernel.org Fixes: 5e5e3c92e748 ("i3c: master: svc: fix wrong data return when IBI happen during start frame") Signed-off-by: Frank Li Reviewed-by: Miquel Raynal --- Notes: Change from v1 to v2 - improve comments. drivers/i3c/master/svc-i3c-master.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 94e4954509558..032fe032ec433 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -415,6 +415,19 @@ static void svc_i3c_master_ibi_work(struct work_struct *work) int ret; mutex_lock(&master->lock); + /* + * IBIWON may be set before SVC_I3C_MCTRL_REQUEST_AUTO_IBI, causing + * readl_relaxed_poll_timeout() to return immediately. Consequently, + * ibitype will be 0 since it was last updated only after the 8th SCL + * cycle, leading to missed client IBI handlers. + * + * A typical scenario is when IBIWON occurs and bus arbitration is lost + * at svc_i3c_master_priv_xfers(). + * + * Clear SVC_I3C_MINT_IBIWON before sending SVC_I3C_MCTRL_REQUEST_AUTO_IBI. + */ + writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); + /* Acknowledge the incoming interrupt with the AUTOIBI mechanism */ writel(SVC_I3C_MCTRL_REQUEST_AUTO_IBI | SVC_I3C_MCTRL_IBIRESP_AUTO, @@ -429,9 +442,6 @@ static void svc_i3c_master_ibi_work(struct work_struct *work) goto reenable_ibis; } - /* Clear the interrupt status */ - writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); - status = readl(master->regs + SVC_I3C_MSTATUS); ibitype = SVC_I3C_MSTATUS_IBITYPE(status); ibiaddr = SVC_I3C_MSTATUS_IBIADDR(status);