[{"id":3683327,"web_url":"http://patchwork.ozlabs.org/comment/3683327/","msgid":"<41960ee3-8645-4d79-0a01-e9642b674a6b@nabladev.com>","list_archive_url":null,"date":"2026-04-28T09:55:08","subject":"Re: [PATCH] i2c: imx_lpi2c: Fix MSR status check issue in STOP","submitter":{"id":91409,"url":"http://patchwork.ozlabs.org/api/people/91409/","name":"Heiko Schocher","email":"hs@nabladev.com"},"content":"Hello Ye Li,\n\nOn 28.04.26 10:53, Ye Li wrote:\n> In bus_i2c_stop, the MSR SDF is checked in a loop after stop command\n> is sent. Meanwhile, some error status in MSR is also checked by\n> imx_lpci2c_check_clear_error. But the imx_lpci2c_check_clear_error\n> will clear the MSR.\n> \n> It causes problem in below situation:\n> In current loop, SDF does not set, but error status is found by\n> imx_lpci2c_check_clear_error (for example, NDF), then NDF will be cleared\n> and result has NDF error. However, because SDF does not set in this loop,\n> it goes not next loop. When SDF is set in next loop,\n> imx_lpci2c_check_clear_error is re-executed, but as the MSR is cleared,\n> the result is 0. Then the stop return 0. But it should return NDF error.\n> \n> Signed-off-by: Ye Li <ye.li@nxp.com>\n> ---\n>   drivers/i2c/imx_lpi2c.c | 4 +++-\n>   1 file changed, 3 insertions(+), 1 deletion(-)\n> \n> diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c\n> index a309fd6f07c..e2b4fd334ec 100644\n> --- a/drivers/i2c/imx_lpi2c.c\n> +++ b/drivers/i2c/imx_lpi2c.c\n> @@ -239,7 +239,6 @@ static int bus_i2c_stop(struct udevice *bus)\n>   \tstart_time = get_timer(0);\n>   \twhile (1) {\n>   \t\tstatus = readl(&regs->msr);\n> -\t\tresult = imx_lpci2c_check_clear_error(regs);\n\nWouldn;t it be better to evaluate bits in result too, and return\nif error bits found?\n\n>   \t\t/* stop detect flag */\n>   \t\tif (status & LPI2C_MSR_SDF_MASK) {\n>   \t\t\t/* clear stop flag */\n> @@ -250,10 +249,13 @@ static int bus_i2c_stop(struct udevice *bus)\n>   \n>   \t\tif (get_timer(start_time) > LPI2C_NACK_TOUT_MS) {\n>   \t\t\tdebug(\"stop timeout\\n\");\n> +\t\t\tresult = imx_lpci2c_check_clear_error(regs);\n>   \t\t\treturn -ETIMEDOUT;\n>   \t\t}\n>   \t}\n>   \n> +\tresult = imx_lpci2c_check_clear_error(regs);\n> +\n>   \treturn result;\n>   }\n>   \n> \n\nbye,\nHeiko","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=nabladev.com header.i=@nabladev.com header.a=rsa-sha256\n header.s=dkim header.b=N7G64aAG;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=pass (p=reject dis=none) header.from=nabladev.com","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=nabladev.com header.i=@nabladev.com\n header.b=\"N7G64aAG\";\n\tdkim-atps=neutral","phobos.denx.de; dmarc=pass (p=reject dis=none)\n header.from=nabladev.com","phobos.denx.de; spf=pass smtp.mailfrom=hs@nabladev.com"],"Received":["from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4bQq20gWz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 19:55:31 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 8A01184659;\n\tTue, 28 Apr 2026 11:55:28 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id 68FED84669; Tue, 28 Apr 2026 11:55:26 +0200 (CEST)","from mx.nabladev.com (mx.nabladev.com [178.251.229.89])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 5A09E84658\n for <u-boot@lists.denx.de>; Tue, 28 Apr 2026 11:55:24 +0200 (CEST)","from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon)\n with ESMTPSA id CBF9B112D53; Tue, 28 Apr 2026 11:55:22 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham\n autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=nabladev.com;\n s=dkim; t=1777370123;\n h=from:subject:date:message-id:to:cc:mime-version:content-type:\n content-transfer-encoding:content-language:in-reply-to:references;\n bh=4ISnnAaEg4+nyke7Eh7a9f981z0OR4h1wU/DmWR5JIw=;\n b=N7G64aAG+XXFpbNvr/g7lHzuvEN7+P3QRkPoVbmxYNqBL9E7ItOVem9dTsUJSXiH3+vbD0\n aI2zFLddMc0Nxhh7wvDmsasrPaQZ6LSJ6muO9beYuamam1MgrXUQGoLrkIwkZROzfBUDSI\n z+TZGxPCmHpyW3Kudc1621dL/ftln538bKoPogz8pd+ejrvIrDBLxQS1jDxqmogGpn8su2\n Xw0xbmkm30vEnLRiiVLEXZ7mgoDdOGKASJr5wTNaEFh2jNFFRVU9pVU0l6ucsOAQvU5x3Q\n 1VSQmiZwzm9JHTo9p/vQJ4wuMcbibLv21snfwse6MIPQV9waM88olgrZIr61wA==","Message-ID":"<41960ee3-8645-4d79-0a01-e9642b674a6b@nabladev.com>","Date":"Tue, 28 Apr 2026 11:55:08 +0200","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n Thunderbird/91.2.0","Subject":"Re: [PATCH] i2c: imx_lpi2c: Fix MSR status check issue in STOP","Content-Language":"en-US","To":"Ye Li <ye.li@nxp.com>, festevam@gmail.com, u-boot@lists.denx.de,\n peng.fan@nxp.com","Cc":"uboot-imx@nxp.com","References":"<20260428085312.1808358-1-ye.li@nxp.com>","From":"Heiko Schocher <hs@nabladev.com>","In-Reply-To":"<20260428085312.1808358-1-ye.li@nxp.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","X-Last-TLS-Session-Version":"TLSv1.3","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"}}]