From patchwork Wed Apr 24 19:00:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13642400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2082.outbound.protection.outlook.com [40.107.22.82]) (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 903D91C697 for ; Wed, 24 Apr 2024 19:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713985261; cv=fail; b=EWmSCCdpUYnrZ3m8NLW6McmWjyETqrs7Mu238w2KCCwnNum6Oqk2iZ+yMyTRE1Qe44y9tb7eae2hUW4MufdjU5I0kZuWDZ+j60cvw85vZmiKyHLIpOM2VcWqDbGoRaLZ/wtpvYJVKYwjmoE3CFHT+gCyXgJP1Puuy8AAmUTFkWI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713985261; c=relaxed/simple; bh=usakbb/pkUG0ZSqJWoqs/JiAcze9ChoErdSOazsomeg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=kEWElM7U7Fp/uPuK2ZbuGErAdi4rX5OeaeYS6BU6oKStHrmccoPl/fcKV/SGLE2N2eQCKTgRIx9Vslb44tfg7Dv890yKjaH+O15QemMhPX5r34KwE8JlM8XrqHYiyUCd/KjLsxWyYuULPAOJDS3gmID7MDpXqG8iPUJr3QKMWpQ= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=o9QhJ/CN; arc=fail smtp.client-ip=40.107.22.82 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="o9QhJ/CN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DOKhUAEryr3WWjI1nFGScBDHrSTvwC/vkwdwI14fsSWed0R7nGVKhJWdf4D+jiD+zZbg8haTAjIguYCTIUNn86Lk0Y2iWidhT/uhpx3WUq9SJqSc8kBgh4lqi/5IMuQDZsPSAh8rs5WHP2jXde0Fl/HXcCPYPJ6MzddaOQ38RcLFqmajQz6g4OBRASLlr1npVOMeaQsrD0Vp02Q97s1WMfqZ7FDDs41V29CX75IlAxvBCq62+W3B/474MpwBCQbiABeiUJaLr895+RgBw+USkEjE2plY/cpsGCnVFJLZS85RU50zVPk7BAx13QxncEiiMz50poPg/XRH3jZgHAiT7A== 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=z+YBcMUL5XXP6oscrSbOAbS1OdWMpYOXFiXqijM3Ltc=; b=CDJXGeS1AwmzYsASOHG3Exs37mF89kiennaBtmEMLUnrAUu4DPG4Xt6a/tcRenupjO29JwkyTvtoQiRS2GfD0cGk5xQ5p21MNNRkX4wgINWupwR0upurPL4AI41hd0M1F0kCcQCK+kiFQSEt8XHcI/aalo9Cx+EaekkUV3l75rmMpJ5tZHu/09myEbJiHIyg6A70NI3hGr0OugU8hbmvwQ+tQPU5BMOnaoiLCEJsSSgDYMLIdmAouAdIklfJEZTfh+HnQRNHzLS9x5uX9Y27byZ/hTi7APGQY5IKLJH/t5okrfP37PFm6anxc3p265PCBK9bZQjvY1nxTDwQUfLYog== 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=z+YBcMUL5XXP6oscrSbOAbS1OdWMpYOXFiXqijM3Ltc=; b=o9QhJ/CNDxm7YI4FCBXeriQjzV0loa0VSFLxgDbyxn7NTZIddKkDE8Z5iWwhaA50ZwkXPuXp7K85H8FdiYnHbbR9hZ9zPrdjQPjoJb1q3+lT88yNYN9xFXmnQMK1eNEd93kl880ous5lovzNk6Ruyx64c6uq8pQZjggQPqttby8= 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 AM9PR04MB8617.eurprd04.prod.outlook.com (2603:10a6:20b:438::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Wed, 24 Apr 2024 19:00:50 +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.7472.044; Wed, 24 Apr 2024 19:00:50 +0000 From: Frank Li To: Miquel Raynal , Conor Culhane , Alexandre Belloni , linux-i3c@lists.infradead.org (moderated list:SILVACO I3C DUAL-ROLE MASTER), linux-kernel@vger.kernel.org (open list) Cc: imx@lists.linux.dev Subject: [PATCH 2/2] i3c: master: svc: fix invalidate IBI type and miss call client IBI handler Date: Wed, 24 Apr 2024 15:00:30 -0400 Message-Id: <20240424190030.857632-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424190030.857632-1-Frank.Li@nxp.com> References: <20240424190030.857632-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR04CA0002.namprd04.prod.outlook.com (2603:10b6:a03:217::7) 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_|AM9PR04MB8617:EE_ X-MS-Office365-Filtering-Correlation-Id: 7aa66eca-0268-4396-1d20-08dc6490dbe3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|366007|52116005|38350700005; X-Microsoft-Antispam-Message-Info: kni+LZfycHMpYCCcxIiSJJmABD73mL6KoJVKl86R7z+0qVq18Z/EU+mQraG4GU9Y3i1W44IlzQoV1xegKtLdRojoMfx7MdlIA0csQJXW8lmPffqtpGCb/94lHyhvqbMlPeoTyr6HdMZ1BvPUH7c0BXv9WS1nUWhbact/vsdMSGToh4igLYn3nUFDkejuBqWLey0vrXC0yvtfWS1m/SdTZJ+A9JzEvIm3qY2F6gcCQ7hVs+BxHT+oPwL4LcKEivXKTXTxK7bX+PEdq9DSnx5ujv8ySfBJUAsGyTJkPAFL2oT9tA1tlMd6iUqCLF6vWtTCljqfmcnOipQmOZSdC+jLC3d5rWoCVkqG1zXpFlG6YiG1f+EHU6w/siOXC3Rzn7x4RIBbQl9+q1tZ2qT7nTpNxoWMPZ72UF/d1cdTG82at2kuKd5CBioqke40D18qqe+bL7q8DYnDGyT/o2wAPsRgwuzcDyD7wn2lKpIOEkldun5tB83SwMe/nHVKU7KqHwZYopt5U3Rdl4F8ktP3qnFR/XunB6wKA5LauCBcy2/6FS079KY516ZMy0OAzEtBq19WFb03MwcbhZFaHogkhrV1IYERroDV0zQRrnvfOI3lW0PHOkPqXjQKCdQWYUaDYtPoylKpuJatba9eExYGX+OLKOVtCTm8+WeBCqawLSQwnm23pgAggFSL7F/viTc4vN7i/olt9qe3eD4ylbKJWLHv/PMK8KjzLlzf+ZryMZuYoJVf0PMJrCkI9K13lYgefanPkCUd3tIxe/F4omrmzpK3NkQoBwEiHqeUei9ACXucDdmNHF+clebfN//zjtslQQ6gGXXfe/jbnmadhxnmY5Igy27MpDeUk2lnPGamRnH1tPJQF4X1IImHx41V9KXTlU78eMp8qFl+zfPAYZUF7UGyCb5yL3qroF02xY4wMTxX1hD0S0IbVU6yhx7FNDTb3122r+lfyWn/bGcuhLpMtF+Y/qXWT+C+Js3x8j9FhLfezR4HPNvA7jtSKJvqUh7m9KK0sEmaXHQO/59+XziPnnBCDaS06ZrZZyaR9IYNawkIoN2IanVf7QQlMo82iw6+NmyPXherUBazAhCwyMjqqfaBnxCIgTF7nfpwgRPXG1P2vYBqeOc84wlNGg3g3+KoRhpEKq7Vo0yVVTGyU7C2VmV3NAE7LLiKeOZgKGtYvlJO9SchTeJccH1HCuWP2YV3mhe9c1wQfkHjC8UZDKPnbAq1i8GqsBuQQgWbpEK77qn47NtFPXAui63ocnKozcpBqiOLNy9rAHTaRX48Hj/LDaSye9utGY0Scd09iX+U9cVDjbOwOfxNeWpAg2IvJQchQLQQ8pFrPnbp/JFQq9GP4L6ZXg== 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)(376005)(366007)(52116005)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: urObOgaEvln+zQBbL4o5nAN9AIX5w71JRptYX2YEPJQES7dz3TxnxGak35X6lUVAS7A4fRbwauVCxkZSrCptDDwxauWCEbEd4Z0e0/IOTuSER0oo4cbK3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9lsbranHXMXKZ5sKAy8cOeRJd8m7AcMDoCjlXGVnID9TUZ/ZOInzGyaTf9pnFefuwRbPNVE6GPq7uKm+xBQVt59tHrmHbdDx5+TWp8bOExanGtFny4sRbylQMN06e7D7XpoV8bHhw2gT4BxlJGGIZv4qstR/WgEHNN8rNa4eaYgbXCWT2Xuuc0vwgnZr65z3XlT7zpGr2oMye7+PTvUnSWWkaaDPmPy0CHrtP+f5hozmFAhGmtQu2feQ2KY3lRjuG5hJTzFhzPdP4cYxNt5zODG7gIGyE/Tn8IeVqdPd9bB030g1Gq5/nijJAXs2va/EW+BM4IwizwXQdTJCVDiNzFt9SUhaPeq7ytT8FKiDgM76yOwKs/yQ2yCutHDZvldriKobVvEEG7fcXq8Zum6ziMJI5Km3Rd X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7aa66eca-0268-4396-1d20-08dc6490dbe3 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 19:00:50.8295 (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: RzihTBMi/xtlsytgkymG2jUSvnjp0IMwPnMUL5ksucqsJG3ln79kI4M6ICZHSUKbfOkH9/5YZbgw3OgF3Bygyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8617 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 --- drivers/i3c/master/svc-i3c-master.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index a2298ab460a37..3bfe8e694f840 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -415,6 +415,9 @@ static void svc_i3c_master_ibi_work(struct work_struct *work) int ret; mutex_lock(&master->lock); + /* Clear the interrupt status */ + 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 +432,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);