From patchwork Thu Jul 27 03:03:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Song X-Patchwork-Id: 13328695 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 B6FD2C0015E for ; Thu, 27 Jul 2023 03:00:33 +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: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:In-Reply-To:References: List-Owner; bh=RLMxKX1iIGbTs+V94v/bl629ckVBUtdjNYVEb/hXcxg=; b=EH+LAIYn+khATL UbhoLlDG7q+RMJlxL+95MnURunT1rpBJpd6a6nM4zK/j12rAJLLYRr+JiZaQR7eQ0FoM/qFa5Rp4j Qi5y89HWdREHco3ua6IApkaL6jLJHUCSR2mHeQShtk//C5nTGCrPaQk6G3apthbYyLPCIRF1mue18 o9mFI3zYNkgBt3OQBRRnOgNBk7MfETVk2FDWCeai7t8q0lQ4nIP6Dezo4zv4cLFvs40cVasWcW55B H0UbxcYln51zG1ZltpWnL0puUyy9zBMPBFczdQPFiECwgwbYpCc5sZMLYCfr8Jrp93q1Ibbov8/uU UJWmelQ6JaETHdUW/j9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qOrEY-00BzGN-0b; Thu, 27 Jul 2023 03:00:10 +0000 Received: from mail-dbaeur03on2061a.outbound.protection.outlook.com ([2a01:111:f400:fe1a::61a] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qOrEV-00BzG0-0U for linux-arm-kernel@lists.infradead.org; Thu, 27 Jul 2023 03:00:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WOWMH1+DT9b+cZq15aSoFGjXAMrjKkM+T7N2zB2/Q6cpQZ3QD8bIf29UAbeyX24kNbnNpidKOAOscGzdXeARu7adwz21YM7bqC33HRa8lHmGFi0flmPhGmlsNUmWvRryLEHbhvIbemSiv4gH+UxlIncqfgQPnP8b8WvqlsB8uRlsEyRB9jupimcLHgE6I7VYtfeSJfy8FlU7dCzNeELRnmKd3l4sqyZIlDYLbadlgKeovNNPeGHWJjqDLEv9POkNem6CyyYS4Qpx1EeXyeL8UKdIokHm8WbWWJCWezw9Xm3gLmoyuut7SNnroWYwO+5tDim+VfmmtRIgovsnrpZ/+A== 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=K/gx94XGuv9bsYJzsFWSDpd4ivJxor3uYmCS54gD/Do=; b=KIzF5boDUTaRdaROxZoq3pVeRMfcNnL851K2habOLtWrv1H9mEySiXcYuLupiPoSOh1zTd7X2U4lk1Rh6ulC4EskkxvgQpSBqTVscUkfAAaNTmIz/73oMWcuHgj4+Pro3N1P0I1HGTJb3NT1mU1E9jwEliZExZHwRlS8L5ta57RwrcPNlmgeQiQcSHQ+9feD/XdOoHpyg6i2P7IXQ+Wc6UzwxCYXh/DZOdeTL88q2dldWwU0FFKKPXWwJi06uAVN0oyvGYvlbRaFgHm5roEUtPll1yV5dPsb/3uFrdZ/iPrtfydrBFcFM681U8s+zrgAjyPcmQUPUaK/LJrVoj5OFQ== 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=K/gx94XGuv9bsYJzsFWSDpd4ivJxor3uYmCS54gD/Do=; b=mttTRB79HmqH9kSJ0bRxYJszgf71w8lKtJMtxQSU7R9JdGAk9YPCq67Dv6fl4Zof3JToBK53R+bzORa2eUTP0uW0h3W7Fgb2KUoUJvvZz0/3Q/+ojcvCNwa7U6wmprhbjt/qeBevK+IOQqloZUnBFFNURDn985FjGgRvAgkOp10= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) by AM9PR04MB8259.eurprd04.prod.outlook.com (2603:10a6:20b:3e4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29; Thu, 27 Jul 2023 03:00:01 +0000 Received: from VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::ea2b:9b70:e669:f0e4]) by VI1PR04MB5005.eurprd04.prod.outlook.com ([fe80::ea2b:9b70:e669:f0e4%3]) with mapi id 15.20.6609.032; Thu, 27 Jul 2023 03:00:01 +0000 From: carlos.song@nxp.com To: andi.shyti@kernel.org, aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com Cc: carlos.song@nxp.com, xiaoning.wang@nxp.com, haibo.chen@nxp.com, linux-imx@nxp.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4] i2c: imx-lpi2c: directly return ISR when detect a NACK Date: Thu, 27 Jul 2023 11:03:47 +0800 Message-Id: <20230727030347.3552992-1-carlos.song@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG2PR06CA0233.apcprd06.prod.outlook.com (2603:1096:4:ac::17) To VI1PR04MB5005.eurprd04.prod.outlook.com (2603:10a6:803:57::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5005:EE_|AM9PR04MB8259:EE_ X-MS-Office365-Filtering-Correlation-Id: 860ba24d-944d-40e2-d9c1-08db8e4d9175 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9uQd/EINC0aBZ0PN1REWIy4Rx33muOecJocIXZ5MLnWroVvvGm8E2eyZMISotEL+FyD7kaKB1Kt0p70ZDmy4qUow51MMEK1FNsOIF+5U5L9xGOU7AmKeDjgA8PwoiE2bE3R7cpLMQdgQOCc3U3SAzDZ3Ah44QGBNcYfvXynZwgoTpKrSfoEj5y7IJBJu3JxY7cRAJLfI5FjQ6yXHbSGb3paW/ysrvg66oXpWqdWODMEHsdfUnApZDok4YcUqzsTt2g/zDx8rptwpR12G43xMhj8CuVYgXuo9Iup5YIxNorsQFkNQ2K3msZ+0WybS6eK1mmqBj38ETVhhaOJmY1VC1eJ3bJVVv56lEtQ0rW7jdPWtL1ftq+zPSfIIF4o5gV57WmV81fVKdzXBMx6y8L7I98vmcGcWx9FTiVO9Jn2EiZiKMp3+r+AZB9Qmyrz6BZNERFvj73JepjfrF5d5hqmK7Tua+o4qaDx9iA35ditetTm7deszj00nbhbfMRwytX+JHvOuNtUWrFEB+gqeOthkTIzfWgFITcm3gS2p8ivCqxKgtwjs4IplFJUvgR87/f9p3RgdY23nZ6Pbe82+zcJQXagfH97MtUOL6qgfNOKqC5xb1i72er8ux61oikpQjA5a X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5005.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(52116002)(478600001)(9686003)(6486002)(6512007)(6666004)(26005)(186003)(1076003)(6506007)(2616005)(2906002)(66556008)(66476007)(316002)(4326008)(5660300002)(8936002)(66946007)(41300700001)(8676002)(38350700002)(38100700002)(86362001)(36756003)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sUM8BozRvX0NzQPgZ7oSGaVw5ZTB3ywlkTMJmuO57nNFqZOWNpdoPJFgk9l2LXugFwNc8vDLedDJcDuapjV82cQplrR4xTDj14MmcOybWU0Oz5hxDQZQjODaOhrRD4kB6ysoy5D0Ds0QsWeHHRaiBzh/uKTMn1+TVL0OkbyJx4CwxK9ljlNP/m13Krd2TZAiku3J/ab9ZjHfZlAyEAAmKedq05UPQIPtrB26Yw0ZFgQY2CCTc3EGN2MWbAvOq2IRro2i+9W7ebBXneyfthVQVwS/h6lDNgtY3p7LgGGMRj1mjaIsY5U5tPK3eemfGE0Uj48XlnuwPdCPzOwjFo8dvtEQWX3tFRIFEWicO+eAqDsG9nl7oy+FvgZTCrelViPY9+KhXFNv96fHWlh/GCHOaisVoUKXWD7yxHIxnSH+vXd8Or8NwKDEmNhHuBrdWIPyKgflFeiwd7BtPN2r0VXLSLHejhzv+m85scRC4lM6bEGipsaMWrZjvKt2Pp0z5U6vxisAgAVe777LFrHDH5Dn89ATnImjce5nnLkO9tv7Vw/BbtH6aXAblbNc9lhNxdRLq2gvXvJOMFMCUnEflLEokEFictVBnZVTT+zcTbsDIHdCTEZbjp6iRunIimk55YKyq2PzaSO/D4EswoWiZt7N9IG/IqLaLy0VtbX6RpoMxRIAUpKZdO+Wf7BVcbdlsrkaX1fKrvs1BnYmqlKOWGUvdp6nHhFFakmaGwGN8zQn7OAc78WQzX/g4Nw1IWwL2qgQl04ihCrM/KDft6YoMzQ5ZW2Fasn038zKngglagBf+9FwI6mtltUpXW3rgivV61fybIW5wkclgsbfaUym7iRt5tzQz8omsyBHjSCLd+zAt/K2W+56AJfg9XLVd5UgwpfzB1wtLv5Oma3GbJAv4RyPoKJRQXIwRpigpItBA1ixyUjn4GyzURt2d9CJ3J2Gy55jXdG9a358/tpt8sxXmcBRNxgBjx6mCs+I7e0f/d7ptEBsxNgrYs03pLUaiB0g51vW1jugfy3C+hoBEVB5/XErDPra4x2uwz8YfyOeYHXesydcuGzAEB/ErVZ7NaybhXGyJSeU8dKrm0X2Y7uSbdF48YEtLjAZdFdKlrpoaCm1iPp1yH8kbwlp3Q3+hP3O+n+IooYVabBpBC/7ftN+U/pfzsKwUIff5bicE4BvwIyhVk8H3sNIV+wYTnE9a1vWkc1hTJkO1sDd+tB2NRIBCypE55/4gmf/t6clq3twLAUwW30VDv/E1k3O6M6v4J+2XLdP8/0VUVroBBTcGfGCMlI8koAW9yKc/EZm3e1tmG1bMf1Sy8h0gSXREqq52u1/o6ZwMnEs4FTFBSVowOKc9lWawzbmLdDN8/wG56NAXJP2bkvqRDyg0LvhwkS+2rUtrwzm3TGdEpW3DdM/cqrNmVJa4Qhs9a9AnkthlcRIFNJ+iTBQwYDr7baC8/+jlwX6y6JYC8IJ1vznNZ5hN+AZX++JC9gR3RA0LIJPATyR0OQTgQ0ZSUfW0fC4xENi5sXTku5f3mAjT4Jm0S/Dv4zwFV/LFEuYTtNZweTZcqTnNEavBRENRXMmCfip50ResQUjsHES X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 860ba24d-944d-40e2-d9c1-08db8e4d9175 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5005.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2023 03:00:01.0731 (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: L9PlSXb4hIM92WDx6IiXdMxjJGwZfa3N8VX/rRQGCHQacTJxHY5qghr9uHz3NAyJoJNs3i87LlcKctBY5V8NEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8259 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230726_200007_215648_67A8AD12 X-CRM114-Status: GOOD ( 11.16 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Carlos Song A NACK flag in ISR means i2c bus error. In such condition, there is no need to do read/write operation. In this patch, i2c will check MSR_NDF, MSR_RDF and MSR_TDF flag in turn, it's making mutually exclusive NACK/read/write. So when a NACK is received(MSR_NDF), i2c will return ISR directly and then stop i2c transfer. Signed-off-by: Carlos Song Reviewed-by: Andi Shyti --- drivers/i2c/busses/i2c-imx-lpi2c.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 150d923ca7f1..9a3e3a1bc4ee 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -517,14 +517,12 @@ static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id) temp = readl(lpi2c_imx->base + LPI2C_MSR); temp &= enabled; - if (temp & MSR_RDF) - lpi2c_imx_read_rxfifo(lpi2c_imx); - - if (temp & MSR_TDF) - lpi2c_imx_write_txfifo(lpi2c_imx); - if (temp & MSR_NDF) complete(&lpi2c_imx->complete); + else if (temp & MSR_RDF) + lpi2c_imx_read_rxfifo(lpi2c_imx); + else if (temp & MSR_TDF) + lpi2c_imx_write_txfifo(lpi2c_imx); return IRQ_HANDLED; }