Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4245219rdh; Tue, 28 Nov 2023 16:33:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHDHA4MIqqISErN2A5TKTx3A9v7dcx/UFRCTbOJtSo0pU+X3uDnETEjhnq+o8oES8qEy/Jh X-Received: by 2002:a05:6a20:9e4c:b0:187:d93f:b0fa with SMTP id mt12-20020a056a209e4c00b00187d93fb0famr20049149pzb.27.1701218038918; Tue, 28 Nov 2023 16:33:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701218038; cv=none; d=google.com; s=arc-20160816; b=omtq8OR9A3c59ygauaz3o2iRX52WOfXiTNk9C1WrDtm8nToaPCi++I/sBV1pFq+sTU Dyt79aK/Vek7AW9cKKWqAB8NN7W7/HzmZnPfehOOZKaBAirVig65WO1G7eY6/3hf9cce /h+tJjU1CJpBIjJSf+h31DbSmgOqP8EDgLwinvvkyqemNMcPdt/4qfq8gyJaz2qdFEUf qJ4Gx7PfrqMV8FBJDwHjZxh/89bSvltB9H1gWEspWOxAV7jHtVBYvxyRPST9XNpqJewl Z/kWIs7XB53uzGsGPbVSBGkZ96wrq8JVamor8ARro/ToDJhRjmpA/d0l8KIz5Ywzd/x9 OgXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=+WS89WTcKCHrEbe/yOsqOJI9VuSu2zv7xlF8oc8yqX8=; fh=yDkQzEl6IxZLQSJVtYl4ZVgHjrQZ2Js7dKd11NaUo5c=; b=DP3foFRjcmszXRxDQHj9e7Lc7NYBnJqSsHqJAb4nsNsOixiACXCVeCYATqyrqhBOyB CkVoUofO0TixkxHOum8jWr0ihHGrGJ2X8An4QhAAANuCchWgioCfr2Lo985NEE08U+j3 W/Lkl6BCo4DvXsLEU/kzI0bqD/9Lm77a67IocZfix4dN/LxighfYI9P1yEFgWUVd4kej E2FOO5qLqgmRmcdCzdKBMCzU3ZUWvoa1OCy5qo+rV4GujncL+7gQmobha9n/NZ+E9M6m SKk77vuLyEVzZGh4PBK/cusmbarc7jemmZvjLNRHDF/G5oEQVo/WsUMqkZu793fMvSgc pxRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=CdESjDWD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeconstruct.com.au Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d35-20020a631d63000000b005c2422cb335si13667459pgm.680.2023.11.28.16.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 16:33:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=CdESjDWD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeconstruct.com.au Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id ECA3A80A5656; Tue, 28 Nov 2023 16:33:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346649AbjK2Adi (ORCPT + 99 others); Tue, 28 Nov 2023 19:33:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbjK2Adh (ORCPT ); Tue, 28 Nov 2023 19:33:37 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD8DC1998; Tue, 28 Nov 2023 16:33:43 -0800 (PST) Received: from [192.168.68.112] (ppp118-210-131-38.adl-adc-lon-bras33.tpg.internode.on.net [118.210.131.38]) by mail.codeconstruct.com.au (Postfix) with ESMTPSA id 6FE6820173; Wed, 29 Nov 2023 08:33:40 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1701218021; bh=+WS89WTcKCHrEbe/yOsqOJI9VuSu2zv7xlF8oc8yqX8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=CdESjDWDMLB0K5t8mldNMDgWHYXdJNIbYBo3NdZ1sS/jPkBR89TnoURcGR2EYdlR7 wVNeuiHIGYL2kLxm/iCtC9vqiCl+b1xiVZT3SH4drgvnGWPIju/Za6bgwGaR/csEXw /ixxbHNVHCMAkWj2GoqKqRqgbG55eUJeZTlKfppfdvYwEuNpSTKSfQ3icgM3LCecD4 A/I2d2gN1K6PwUaDKuHC9kRAS0ZBq39GCdAG2364XZ8FqLqhpWSHZCzLXvbI9YeIqK Y8YJAWcf8oAVAZXN3ujiXJdqs5+EiXXMihjpEfKV2E0za7c0n+GTpjo6gCmMx9iGOr rwNhDHXWrs4UQ== Message-ID: <2186c3b9ac92f03c68e8a2dd9fda871f80a6d664.camel@codeconstruct.com.au> Subject: Re: [PATCH v2 RESEND 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late From: Andrew Jeffery To: Quan Nguyen , Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , Andi Shyti , Wolfram Sang , Jae Hyun Yoo , Guenter Roeck , linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: Cosmo Chou , Open Source Submission , Phong Vo , "Thang Q . Nguyen" Date: Wed, 29 Nov 2023 11:03:39 +1030 In-Reply-To: <20231128075236.2724038-3-quan@os.amperecomputing.com> References: <20231128075236.2724038-1-quan@os.amperecomputing.com> <20231128075236.2724038-3-quan@os.amperecomputing.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 28 Nov 2023 16:33:56 -0800 (PST) On Tue, 2023-11-28 at 14:52 +0700, Quan Nguyen wrote: > Commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in > interrupt handler") acknowledges most interrupts early before the slave > irq handler is executed, except for the "Receive Done Interrupt status" > which is acknowledged late in the interrupt. > However, it is observed that the early acknowledgment of "Transmit Done > Interrupt Status" (with ACK or NACK) often causes the interrupt to be > raised in READ REQUEST state, resulting in "Unexpected ACK on read > request." complaint messages. >=20 > Assuming that the "Transmit Done" interrupt should only be acknowledged > once it is truly processed, this commit fixes this issue by acknowledging > this interrupt for both ACK and NACK cases late in the interrupt handler > also. >=20 > Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in i= nterrupt handler") > Signed-off-by: Quan Nguyen > --- > v2: > + Split to separate series [Joel] > + Added the Fixes line [Joel] > + Fixed multiline comment [Joel] > + Refactor irq clearing code [Joel, Guenter] > + Revised commit message [Joel] > + Revised commit message [Quan] > + About a note to remind why the readl() should immediately follow the > writel() to fix the race condition when clearing irq status from commit > c926c87b8e36 ("i2c: aspeed: Avoid i2c interrupt status clear race > condition"), I think it looks straight forward in this patch and decided > not to add that note. [Joel] >=20 > v1: > + First introduced in > https://lore.kernel.org/all/20210519074934.20712-1-quan@os.amperecomputin= g.com/ > --- > drivers/i2c/busses/i2c-aspeed.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) >=20 > diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-asp= eed.c > index 79476b46285b..3231f430e335 100644 > --- a/drivers/i2c/busses/i2c-aspeed.c > +++ b/drivers/i2c/busses/i2c-aspeed.c > @@ -611,8 +611,9 @@ static irqreturn_t aspeed_i2c_bus_irq(int irq, void *= dev_id) > =20 > spin_lock(&bus->lock); > irq_received =3D readl(bus->base + ASPEED_I2C_INTR_STS_REG); > - /* Ack all interrupts except for Rx done */ > - writel(irq_received & ~ASPEED_I2CD_INTR_RX_DONE, > + /* Ack all interrupts except for Rx done and Tx done with/without ACK *= / I'm not a huge fan of this comment, it just says what the code does. It would be much better to explain *why* the code does what it does. I realise describing what the code does was already the gist of the comment and that you're just updating it to match the change to the code, but that's my entire problem with it. We'd be better off deleting it if we're not going to explain why the masking is necessary. > + writel(irq_received & > + ~(ASPEED_I2CD_INTR_RX_DONE | ASPEED_I2CD_INTR_TX_ACK | ASPEED_I2= CD_INTR_TX_NAK), > bus->base + ASPEED_I2C_INTR_STS_REG); > readl(bus->base + ASPEED_I2C_INTR_STS_REG); > irq_received &=3D ASPEED_I2CD_INTR_RECV_MASK; > @@ -657,12 +658,12 @@ static irqreturn_t aspeed_i2c_bus_irq(int irq, void= *dev_id) > "irq handled !=3D irq. expected 0x%08x, but was 0x%08x\n", > irq_received, irq_handled); > =20 > - /* Ack Rx done */ > - if (irq_received & ASPEED_I2CD_INTR_RX_DONE) { > - writel(ASPEED_I2CD_INTR_RX_DONE, > - bus->base + ASPEED_I2C_INTR_STS_REG); > - readl(bus->base + ASPEED_I2C_INTR_STS_REG); > - } > + /* Ack Rx done and Tx done with/without ACK */ > + writel(irq_received & > + (ASPEED_I2CD_INTR_RX_DONE | ASPEED_I2CD_INTR_TX_ACK | ASPEED_I2C= D_INTR_TX_NAK), > + bus->base + ASPEED_I2C_INTR_STS_REG); > + readl(bus->base + ASPEED_I2C_INTR_STS_REG); I'm not sure why the write was conditional, but I'm not sure that making it unconditional is valid either? Why the change? Why not add the extra interrupt bits to the condition in addition to the value mask for the write? Andrew