Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4250661rdh; Tue, 28 Nov 2023 16:47:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtsCYCCRgaVeG1vpW0JwyM21ZKwYBYOrDXUzW+L/8RQ8MG0AMGy+0GelZkSHUx03RLyu23 X-Received: by 2002:a05:6870:3c8b:b0:1f0:15f4:41df with SMTP id gl11-20020a0568703c8b00b001f015f441dfmr20539841oab.37.1701218822623; Tue, 28 Nov 2023 16:47:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701218822; cv=none; d=google.com; s=arc-20160816; b=pT74Vft3xXkd24+itEoD9WBLEC8yq4frXB8vHdcdz1i0IkvC4EDi/SH834LLXnYsSo ZpUe4NC58Bij+SbhHB5w797nOc/BDiuuwyt4RqphEhphJS0/2KItkeUP1cQ1tmbNUiBY oqQJoPLcVtgVnVMOHkhAK0WZtjkx7PZtNQt5/y2Rq8gG1KcJaG0Rp2YWhRfHMDKFCFf/ z+6VN+oER3dOANldG6GAWhEOyMOie5ERblZ3ylk5MpGpIICRVC0ymtRjRfZzA1Ch3HDF CZRRDIpSz1ZQAvGNKV139snZVAOk+5shvSu7xGqKAYGng22m+TqnPbWZ+lGAeg4kzSjw zj8g== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=CezVVdx6GMdL63IfVjbPUFnyPrONCLPzR6A4FjBsYYw=; fh=ABkbQnYy7mj1U0IlDg0dsudt5Oa+PeG9h2yzCz5KuJE=; b=wNJufhGjRj41JOeejxxy765X8GiEQ9FC/TJi+FQgmpBG3aIvCePB8DKEkb//MBiNAj 6tGQhLrEzk/PFuVFwW6UfJL8YjqkzOUH3YYJFjYY3iOXeKwXh19XWRgekGRz0iOuazom IFyJf8Si/xIr1KhjwcLMLRI4eO1IZW03bSJGJICTlAHQwKh0vIonUKL/SuODrNr50jbv 6BB7VWh9woFqQEOPj6y8ObN3Sdp5Grz7r93FG5E9uOSVMPn5mhCA9ym8nAukbi3DaJcs svxj7p1zqlitZXAxoWfZrYumYEGNjXJQiIcaH+pEJ3wChFRxRVMOEMCETgJw622sdcUx ynug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Q+c/QVVl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id fd19-20020a056a002e9300b006cb75e0f91bsi14045185pfb.45.2023.11.28.16.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 16:47:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Q+c/QVVl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 13CEC81F8402; Tue, 28 Nov 2023 16:47:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbjK2ApH (ORCPT + 99 others); Tue, 28 Nov 2023 19:45:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjK2ApG (ORCPT ); Tue, 28 Nov 2023 19:45:06 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECF9019A6 for ; Tue, 28 Nov 2023 16:45:12 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C78E4C433C7; Wed, 29 Nov 2023 00:45:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701218712; bh=BoDVFsUwHvuFZBXmTakeJFuui2uZQsPNMqQoXk1kNR8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Q+c/QVVlFt+4XBozCUgCmmdawfa41r0LR0C0rmMKZavCT4ks2DZVIA/7g4tpDjbZA D+4vAHH+Z3nDvsqsGxlYgioWFDizCwTyExQcZ4DIAaozf4IOE/lb4EwH2FcuzfUS7u WI8AU8MQ2Gk9Oc68S3WD7SqOG4HOWYGJ/xK6e3//MbbPpHdLB+IS4aGEQdZwD1mw60 3QCh07zZTWZpudVjCmniRaNIO3stHLKDG/IbQFKnK+R/b7+ttxFieOGowaz2w7dZ03 x7ecp7hwRyK7AM4bCcl8nDcbVzD+v4N8mY3b50gTDdClQ274lEB59KPvwWcR1is+5v YcnIOBhcd/Ukw== Date: Wed, 29 Nov 2023 01:45:09 +0100 From: Andi Shyti To: Quan Nguyen Cc: Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , Andrew Jeffery , 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, Cosmo Chou , Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: Re: [PATCH v2 RESEND 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late Message-ID: <20231129004509.ilriuwm3hulvy67l@zenone.zhora.eu> References: <20231128075236.2724038-1-quan@os.amperecomputing.com> <20231128075236.2724038-3-quan@os.amperecomputing.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231128075236.2724038-3-quan@os.amperecomputing.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 28 Nov 2023 16:47:00 -0800 (PST) Hi Quan, On Tue, Nov 28, 2023 at 02:52:36PM +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. > > 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. > > Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt 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] > > v1: > + First introduced in > https://lore.kernel.org/all/20210519074934.20712-1-quan@os.amperecomputing.com/ > --- > drivers/i2c/busses/i2c-aspeed.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.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) > > spin_lock(&bus->lock); > irq_received = 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 */ > + writel(irq_received & > + ~(ASPEED_I2CD_INTR_RX_DONE | ASPEED_I2CD_INTR_TX_ACK | ASPEED_I2CD_INTR_TX_NAK), > bus->base + ASPEED_I2C_INTR_STS_REG); > readl(bus->base + ASPEED_I2C_INTR_STS_REG); > irq_received &= ASPEED_I2CD_INTR_RECV_MASK; > @@ -657,12 +658,12 @@ static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) > "irq handled != irq. expected 0x%08x, but was 0x%08x\n", > irq_received, irq_handled); > > - /* 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_I2CD_INTR_TX_NAK), > + bus->base + ASPEED_I2C_INTR_STS_REG); > + readl(bus->base + ASPEED_I2C_INTR_STS_REG); So, you are acknowledging everything here. Why wasn’t it done this way in the first place? I would appreciate a comment here from Guenter, whose commit you are fixing. Thanks, Andi > spin_unlock(&bus->lock); > return irq_remaining ? IRQ_NONE : IRQ_HANDLED; > } > -- > 2.35.1 >