Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp404818rwb; Tue, 25 Jul 2023 18:16:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlFH+UyJWkR+Sg9NWBjou2d4/NGxQgH83lqSIL07PEZ8rFa4VzF1XG8M9tMwnE6CmqNPyo95 X-Received: by 2002:aa7:d689:0:b0:522:4c7a:d5a9 with SMTP id d9-20020aa7d689000000b005224c7ad5a9mr383968edr.3.1690334160608; Tue, 25 Jul 2023 18:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690334160; cv=none; d=google.com; s=arc-20160816; b=J5+TyF8VFNpa+dyuntuQRvbEexz4UNQbCFRkx9z4zqrYTrsOsipflYFSFRjalBHxx4 rtL5iC66Yz1wWS56IPkf35sbckIKddYP6d1XoOqrRVJBvNzc2lhHq9o/FsxH22XWu5ht BtlymWq6Y8HJ4AVLPslAJ+EvV8YmUoAMUOlq421uVaZTuLz5ytCrvm7DlAowxXfdV3Ok 9wI9yunIQA359pkJDbttEHrlfHE2/9Eijm/lmmJPVm5WJyWx+LjZDHfHXzyHR/+ig5Cx ORHrBd8EUY7D9Kwos4BAdasxhJ9IHam/8P8vWYERvcQQEb7eUY+XXwHy37O8iLpR/lgS T0Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oGo0uPrUno5M3qB+wWU2gVLFBqQejCPkgGEzYIXw4sg=; fh=oHDq6HeANobeUeJVnZCPcL/u54La4fz1gb6fm126Zn0=; b=PO4Wb+QlI0Eu+5tXO0UAwmPqiKSDoK7UMy2ZlTlR7l3+YZFw5WPr+52x5eeH+23Kg+ ktfBcsS/BY3XB7z2pkZuQwYR2rOUPviheMLreo9ZiIpfOF2FU9KZCjy9gJzhOy7QSfNh dgsUmqFLv7S/xttfWNblRJ1HTM9qWcOAZNAfMWRFpoYSNKebxYRuSqBiPSvUo7wA5N1h TGJpQ7if3yRHG+SU0c1U7BBBw1++pog1191mlHXtbHFSsM5JmzTWrEFmdx1CQJTZ3NnQ HoRTAUSi51fwn275WB+rBW58+TNTReHHVsSSR2KkEC1b4xc6XfDRroFFkhcH+nqmxY57 RhvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KzOGvR8V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p13-20020a05640210cd00b005221fa80fd8si5147423edu.617.2023.07.25.18.15.36; Tue, 25 Jul 2023 18:16:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KzOGvR8V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230248AbjGYXzS (ORCPT + 99 others); Tue, 25 Jul 2023 19:55:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbjGYXzR (ORCPT ); Tue, 25 Jul 2023 19:55:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 641E0E7; Tue, 25 Jul 2023 16:55:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 028A660F8A; Tue, 25 Jul 2023 23:55:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2C2CC433C7; Tue, 25 Jul 2023 23:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690329315; bh=LaWGO6FB51BoI4x0QvDk+gLLZfsA9FHjkVjMztqhaeA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KzOGvR8VoaUt/GJ6o7tu6QMZ8nY3rZDbM55d7kFUMQ7ypch0td9RTh9EM4aKuPgYq 4eCKXJggIQEN4Vum1R+hpD8KvcaFG8iLkW8SMpFwv+/Pd3goEmQkaJ0CdhWF5KRpVI cz0m0BxdOjqv5LkaI41z5k+NmK4jshwHXedo4XzCxOtzmbNOzL+smiEj6gMIgMkJgt AznnAqJGeKIzWBsMXogcU+qSE9aSf4hGgsoSkhTABaWytqBNsVHooyRjhBI1kGoLGM 48S+6P+7zYCY+RzMZDzGp1sFQlpOeUzDwhcB23sY3Dezp70I80Y3MD2r5nGocxV/W+ LlRlgJ0EyEU+A== Date: Wed, 26 Jul 2023 01:55:11 +0200 From: Andi Shyti To: carlos.song@nxp.com Cc: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.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: Re: [PATCH v2 1/3] i2c: imx-lpi2c: directly return ISR when detect a NACK Message-ID: <20230725235511.lt62ubfw7geu5cfu@intel.intel> References: <20230724105546.1964059-1-carlos.song@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230724105546.1964059-1-carlos.song@nxp.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Carlos, On Mon, Jul 24, 2023 at 06:55:44PM +0800, carlos.song@nxp.com wrote: > From: Gao Pan > > A NACK flag in ISR means i2c bus error. In such codition, > there is no need to do read/write operation. It's better > to return ISR directly and then stop i2c transfer. > > Fixes: a55fa9d0e42e ("i2c: imx-lpi2c: add low power i2c bus driver") > Signed-off-by: Gao Pan > Signed-off-by: Carlos Song > --- > drivers/i2c/busses/i2c-imx-lpi2c.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c > index c3287c887c6f..158de0b7f030 100644 > --- a/drivers/i2c/busses/i2c-imx-lpi2c.c > +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c > @@ -514,15 +514,14 @@ static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id) > temp = readl(lpi2c_imx->base + LPI2C_MSR); > temp &= enabled; > > - if (temp & MSR_RDF) > + if (temp & MSR_NDF) { > + complete(&lpi2c_imx->complete); > + return IRQ_HANDLED; you can actually remove the return here if (temp & MSR_NDF) complete(); else if (temp & MSR_RDF) exfifo(); else if (temp & MSR_TDF) txfifo(); return IRQ_HANDLED; BTW, the logic here is changing, as well and it's not described in the commit log. This patch is not only stopping when a nack is received (MSR_NDF), but it's also making mutually exclusive read/write (which I guess are MSR_RDF and MSR_TDF). Is this what you want? If so, can you please describe it in the commit log or add a comment describing that the three states are all mutually exclusive. Thanks, Andi > + } else if (temp & MSR_RDF) > lpi2c_imx_read_rxfifo(lpi2c_imx); > - > - if (temp & MSR_TDF) > + else if (temp & MSR_TDF) > lpi2c_imx_write_txfifo(lpi2c_imx); > > - if (temp & MSR_NDF) > - complete(&lpi2c_imx->complete); > - > return IRQ_HANDLED; > } > > -- > 2.34.1 >