From patchwork Mon Jan 30 15:32:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13121370 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 84D6CC54EED for ; Mon, 30 Jan 2023 15:36:51 +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=PPG5N5QmrAco6F7OTyD2i5TTuOWZ667/0TuzyBogsyw=; b=UuUwijgSmStSA7 TFH8Su9IcccZe3AWeqYW3tl0LKMK0d3HPEyyDmdRZtnmb391tvoAnTwsTTTiquPRR6eGeHEPp2Tcg kVtybaf6Z2VOoS7nLfMtqhwg7mfaEIbxh4r+GFcPH7oPNq54PjRFHpi7vDGw3T3QviSW7NrJq/ZXN X+b4SNZYYMe9DnWwIKdnQmpmjlWa9QDb8dTHI/3n8Ymvzom4zqI03ZNoXuong/PgZDzsIsUzO0FAc AHbdmHqiXNPhrl0R6aQVhVAOkx3anbjNLV9IOL6f2ZQcfoNkdpnT45rg/LgN6rUu5ZcGHVFBPVHWH 3cHplmQsh+eazZuBsehg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMWAy-0043FM-7o; Mon, 30 Jan 2023 15:34:32 +0000 Received: from mx1.tq-group.com ([93.104.207.81]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMW9e-00432E-Nb for linux-arm-kernel@lists.infradead.org; Mon, 30 Jan 2023 15:33:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1675092790; x=1706628790; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YXkQPJ4Fwf72eWcx4a6gkKFeKJ2We9s1nTw8/musS0w=; b=aqA+YYQW+jG7bfgPxbOrVLEy4GMvwWKW1XgLPd/b8vcOMwJg7RQfxGPk 1TQDY1NF3MYcEa/2vH33S+H6jG4U6AukFf/fl7mcpo4PTYjbjYDCKsmi6 1M/dH/yDZQLTnosmmqHLdEGyEbSR60xmdQpNq887Ope/YFdcl4si0GCMX PQlldSnospBCSrZtW55i2E655tpY3SKVNtBrrT+o0BGHJlf6Mk1qMcQfh bwn5wAYV26+50hxOhZrn+cBjDnPsBwbt/Ih6b6LcZkwofq9ijnISGit0R b9yy9p7zix6MOlZtKFfmSX4SSpQDHK4sJMJUhfSs2dl+dUw5Czi4XcMKp Q==; X-IronPort-AV: E=Sophos;i="5.97,258,1669071600"; d="scan'208";a="28747102" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 30 Jan 2023 16:32:53 +0100 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Mon, 30 Jan 2023 16:32:53 +0100 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Mon, 30 Jan 2023 16:32:53 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1675092773; x=1706628773; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YXkQPJ4Fwf72eWcx4a6gkKFeKJ2We9s1nTw8/musS0w=; b=CNz6HSvQa3xdE6hN3Ef1Zu3RPMyQwTYZ19vnEDqYnCOYb37h9ZN/4wm3 4EAv3Xs7N4JUsGWkK0HhSMgyx1xMd+V8VW2XoAttQgyfIUsiuOK7cx5MT 6wNRMtv609jBV87BL+4VqVUwgCKHJSgAkZUjbz5xKbAWKWyIaTM2wXXlC Ct8KCAr8BpcvN6MQFbhknC8D1QyyXhWEfZoXA0LLrRoobYqx6txZ/Hau4 GS5sYXKFRRys5rDt3eP5rxlJTLoBVdrZdLVQCnXMa1diMTtkRZvI3zxbJ 6aK4pkLDwa+ofWYsE+jscCn6HCUkTGnphe9Tl8Lm9bVEjRuagwR/sqQJq A==; X-IronPort-AV: E=Sophos;i="5.97,258,1669071600"; d="scan'208";a="28747101" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 30 Jan 2023 16:32:52 +0100 Received: from steina-w.tq-net.de (unknown [10.123.53.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id 41AA6280072; Mon, 30 Jan 2023 16:32:52 +0100 (CET) From: Alexander Stein To: Dong Aisheng , Shawn Guo , Sascha Hauer , Fabio Estevam , NXP Linux Team Cc: Alexander Stein , Pengutronix Kernel Team , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] i2c: imx-lpi2c: check only for enabled interrupt flags Date: Mon, 30 Jan 2023 16:32:47 +0100 Message-Id: <20230130153247.445027-2-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230130153247.445027-1-alexander.stein@ew.tq-group.com> References: <20230130153247.445027-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230130_073311_095141_6FBFA6D9 X-CRM114-Status: GOOD ( 16.93 ) 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 When reading from I2C, the Tx watermark is set to 0. Unfortunately the TDF (transmit data flag) is enabled when Tx FIFO entries is equal or less than watermark. So it is set in every case, hence the reset default of 1. This results in the MSR_RDF _and_ MSR_TDF flags to be set thus trying to send Tx data on a read message. Mask the IRQ status to filter for wanted flags only. Fixes: a55fa9d0e42e ("i2c: imx-lpi2c: add low power i2c bus driver") Signed-off-by: Alexander Stein --- To be honest I'm wondering why this didn't occur to somebody else before. The behaviour also matches the downstream kernel which does > if (temp & MSR_RDF) > lpi2c_imx_read_rxfifo(lpi2c_imx); > else if (temp & MSR_TDF) > lpi2c_imx_write_txfifo(lpi2c_imx); avoiding handling both Rx and Tx events. drivers/i2c/busses/i2c-imx-lpi2c.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index c6d0225246e6..a49b14d52a98 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -505,10 +505,14 @@ static int lpi2c_imx_xfer(struct i2c_adapter *adapter, static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id) { struct lpi2c_imx_struct *lpi2c_imx = dev_id; + unsigned int enabled; unsigned int temp; + enabled = readl(lpi2c_imx->base + LPI2C_MIER); + lpi2c_imx_intctrl(lpi2c_imx, 0); temp = readl(lpi2c_imx->base + LPI2C_MSR); + temp &= enabled; if (temp & MSR_RDF) lpi2c_imx_read_rxfifo(lpi2c_imx);