Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3439823rdh; Mon, 27 Nov 2023 14:33:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBWmfWkzFMmMrHpvpTw77T0iit9EvwFocO0yTETv4Foiwn9UYU+jH6yyP6rOjYEYRuTyGo X-Received: by 2002:a05:6e02:1b85:b0:35c:baec:751c with SMTP id h5-20020a056e021b8500b0035cbaec751cmr6987458ili.7.1701124428601; Mon, 27 Nov 2023 14:33:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701124428; cv=none; d=google.com; s=arc-20160816; b=XknhYVBX9Qi2dCsGC3RU6jIMzmqNHNpEDqVhP3SmS7t7hM3Qnlt6XiKpIPDOteURbS lNRnxUxK3a7yeUwugkKYagYJJmQr/9j/fu6yMOFVipIim4eNJ/f5o43lk7b7XQuAIeDB zze0jn88WLkHWk53kjtulGim7TH6r7kFZBORUKwAcJqTFcNPr9q42QojQMug9X+AwDnU AeT337pJC8iEFqvp3ilp78lwnfBiF9J/ZugkOGAHtJsZaJ060GQSXAeMnMXd5ToVUy0o yO3e38+7mUEV/jFtq2/8B0hyD5dnw3Kx/X/kQ6pVPEMmBiog0EwG2LMNYEJLiGvxKY6+ zBGw== 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=h1DjU44paqMIz82vnTD+RrG6jGC1Ttwt1jdiflrmTbg=; fh=L4xTYft4vgyeqF6QRRtai1J6a3KED0HWOosXUT7nP1U=; b=C0iUqL2/GIeHMWWFM+aZkOWvjXXJgeFFsdI4N7uMCkRcL1Z/kB8FCVQk4Q5OnXuwX3 Z6ghypqoJchjCCbL+yp+ZzGfxE3bBKbI0Kc4LaNnpcSew3cO2Dycz6Y51zXh7GkYJNK6 QRgfpiRoyAnW6uCytHW19hZ/FW3JQSCRYA2+ZugPyqzWKKJG0ngZh0YOLvzTX/HeP3E1 /8XQw6xRQuXmJ/9KnKY2a9G/5y7mLUWh0dcXop0wEOuMi2cg2xdEHYHMZ+uMBtQfbPIP MFBbzlt+EydO0YbIYPLvm2Hrgtp26E8llD00YaoD8A+thqHME8vGPyBeZHPV3JJEasL3 HjBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pjb9M3dg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id e15-20020a631e0f000000b005c219360d9csi11004458pge.50.2023.11.27.14.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:33:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pjb9M3dg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id F169E82C515B; Mon, 27 Nov 2023 14:33:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233380AbjK0WdX (ORCPT + 99 others); Mon, 27 Nov 2023 17:33:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233785AbjK0WdL (ORCPT ); Mon, 27 Nov 2023 17:33:11 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA1201BF5 for ; Mon, 27 Nov 2023 14:25:26 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 870A7C433C8; Mon, 27 Nov 2023 22:25:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701123926; bh=GRyFkV0q85dCw/8aaH+ce1mWfZBdwTA+ebfxJuBFea8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pjb9M3dguGR27IGPgk/7/jJ7HJDeS4kcZHWrGtB6092BMnDwGSeo6greCg8V3ZJMw h+Un3fkdNsnqi2kCK1/1wVmliPfj9ayXqqBZ+i0Rb2ymnHNVXCyGeS7FGCc/ipMIA5 xpyJJ1iLa9qeTTlGGs2qtZ11lSX2hEctXIaxJblHMQcmw7tT3hU9NGiSisDXJtTQ4q fNKPhB9JRF2v1qDFyuPZr39+7oV4r8dQvnqfhl1NElCvV95Qw/cwdKNY8bmZP0UmEj UonC0osEUR63TOcFdhGbXTC1I+8DWlnG/n/Tn5WKfozXD8vuuRyQk+EB06+umtURVW eaS1NLYatfWfg== Date: Mon, 27 Nov 2023 23:25:22 +0100 From: Andi Shyti To: Cosmo Chou Cc: brendan.higgins@linux.dev, benh@kernel.crashing.org, joel@jms.id.au, andrew@codeconstruct.com.au, linux@roeck-us.net, wsa@kernel.org, jae.hyun.yoo@linux.intel.com, 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@quantatw.com Subject: Re: [PATCH] i2c: aspeed: Acknowledge Tx ack late when in SLAVE_READ_PROCESSED Message-ID: <20231127222522.wjdd6btbug6shd7y@zenone.zhora.eu> References: <20231120091746.2866232-1-chou.cosmo@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231120091746.2866232-1-chou.cosmo@gmail.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 howler.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 (howler.vger.email [0.0.0.0]); Mon, 27 Nov 2023 14:33:45 -0800 (PST) Hi Cosmo, On Mon, Nov 20, 2023 at 05:17:46PM +0800, Cosmo Chou wrote: > commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early > in interrupt handler") moved most interrupt acknowledgments to the > start of the interrupt handler to avoid race conditions. However, > slave Tx ack status shouldn't be cleared before SLAVE_READ_PROCESSED > is handled. > > Acknowledge Tx ack status after handling SLAVE_READ_PROCESSED to fix > the problem that the next byte is not sent correctly. > > Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") > Signed-off-by: Cosmo Chou > --- > drivers/i2c/busses/i2c-aspeed.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c > index 28e2a5fc4528..c2d74e4b7e50 100644 > --- a/drivers/i2c/busses/i2c-aspeed.c > +++ b/drivers/i2c/busses/i2c-aspeed.c > @@ -337,6 +337,12 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) > break; > } > > + /* Ack Tx ack */ > + if (irq_handled & ASPEED_I2CD_INTR_TX_ACK) { > + writel(ASPEED_I2CD_INTR_TX_ACK, bus->base + ASPEED_I2C_INTR_STS_REG); > + readl(bus->base + ASPEED_I2C_INTR_STS_REG); > + } > + > return irq_handled; > } > #endif /* CONFIG_I2C_SLAVE */ > @@ -602,13 +608,18 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status) > static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) > { > struct aspeed_i2c_bus *bus = dev_id; > - u32 irq_received, irq_remaining, irq_handled; > + u32 irq_received, irq_remaining, irq_handled, irq_acked; > > 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, > - bus->base + ASPEED_I2C_INTR_STS_REG); > + irq_acked = irq_received & ~ASPEED_I2CD_INTR_RX_DONE; > +#if IS_ENABLED(CONFIG_I2C_SLAVE) > + /* shouldn't ack Slave Tx Ack before it's handled */ > + if (bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) > + irq_acked &= ~ASPEED_I2CD_INTR_TX_ACK; > +#endif > + writel(irq_acked, bus->base + ASPEED_I2C_INTR_STS_REG); which branch are you? You don't look like being in the latest. Please update your branch. Andi > readl(bus->base + ASPEED_I2C_INTR_STS_REG); > irq_received &= ASPEED_I2CD_INTR_RECV_MASK; > irq_remaining = irq_received; > -- > 2.34.1 >