Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4246425rdh; Tue, 28 Nov 2023 16:36:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8Ig6/8Wad9AGu4ayYhtGoUC2tHJ8EG7MZG+XYkqc2HDkOk4TP7scGGbZJblp677n27tyJ X-Received: by 2002:a17:902:ecc5:b0:1cf:c2c8:7f96 with SMTP id a5-20020a170902ecc500b001cfc2c87f96mr12091498plh.48.1701218190823; Tue, 28 Nov 2023 16:36:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701218190; cv=none; d=google.com; s=arc-20160816; b=0W6SZiVb1XPnYpqmlkuD46Sx1inUwk/fmMowz5n0Ajc7tc4bpJjVsEHyGr6PVw8gJn bUnYXwR/ZKE4fKhhF+zstoEennWM/PlgMzW9mfdg9p1GpW802CCTICRl0thCFJDhdgii WMDtgyxQ6JWg3ldVweLTZd+wmOH1Ldj/2w8gkkKMi58wWiIGKrLNV1e8ay51mkyF+Fc/ sLxgVf4h9qO1yU5quY+UO1jfWDoHHGSzYFjluU+jPVnCjE6y3z5TaVRpnqQwzWYsHC73 Nv3UZGm7Og3ReVzxqSZWir54N81MZ9BqAHXHRKbkgd4FxPDg6LPjmWib/G11+CPgRDh0 cC8A== 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=PZrpNQKaQ4aZo8JcTAp60oruIzxl77ugQn2glwNF5Jw=; fh=ABkbQnYy7mj1U0IlDg0dsudt5Oa+PeG9h2yzCz5KuJE=; b=MsAlOXE1uerxSdKPWiv4l+zclyj5IwLgHIHFIz0ptGgHkxR8IHuL8/Ojpuy+QGqEkS ktYxohne2B3aSvOXEe8s1hEgrvGyFktK5gTaFUF5SO+dK4N2HddGk+zO99PSuA+llz8n PKSHjLKQkk4P9dl89PjVOoT89+Xw2+jXvWwJsgtKQrQlM4UnvMmcosRXJ4eMFcJUtX2d b3AtBdbrDlvLe3ooRN/NP9I4s5f1AW/aO7bDdEJ4rLj/yo4oWSJOMZRddpWiDsvUf38a 3tfV6igmmqntgcz7I/343tJjyjweBzN8oLTfPRbxled/PNz9I/okfX+UR01MiU9+qCNB GQ9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ujwKHO23; 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=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id b8-20020a170902d88800b001cfcc0f484asi5656204plz.464.2023.11.28.16.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 16:36:30 -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=@kernel.org header.s=k20201202 header.b=ujwKHO23; 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=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C65A9805E01A; Tue, 28 Nov 2023 16:36:02 -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 S1376695AbjK2Afn (ORCPT + 99 others); Tue, 28 Nov 2023 19:35:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376683AbjK2Afk (ORCPT ); Tue, 28 Nov 2023 19:35:40 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53C0B19A6 for ; Tue, 28 Nov 2023 16:35:46 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FD2CC433C8; Wed, 29 Nov 2023 00:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701218146; bh=CEyKgl9exP4XEknYN9UDsJmLxQMgn2xe10MjBsA+2Rk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ujwKHO23grlfzlnd0pvsWiou2vfCGyav3Rf2RrCygDfh2jSoPPcv9jNDzJRo9tP3S H/Om4NjxC0ZIYNEmNoJSXekdmoT9sno3LV82jwmo3Wm4MnLi/14WEzzDq8Z1A+Gr3B 4GhSvp3i7COC2HRpAXHDGwrkyMPM5p6jOfewEyRPPgbloX4NRFp+ZOsnTfHiI2DzCK TX05jGApV4o6HvJPeU3nJsrycy/4lreBoQf7OM+nVtsmSxC2RCBrBypqXEuh4XhPJX Vt2iZ6WMcKqAA2hlgoWhnYZ/OgLsv1iGofep+vnd5mt5jMePKIHY/H8hat/HJ76GgK Of3wVqe1InEjw== Date: Wed, 29 Nov 2023 01:35:42 +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 1/2] i2c: aspeed: Fix unhandled Tx done with NAK Message-ID: <20231129003542.jfhhotebweb3uwyb@zenone.zhora.eu> References: <20231128075236.2724038-1-quan@os.amperecomputing.com> <20231128075236.2724038-2-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-2-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 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:36:03 -0800 (PST) Hi Quan, On Tue, Nov 28, 2023 at 02:52:35PM +0700, Quan Nguyen wrote: > Under normal conditions, after the last byte is sent by the Slave, the > TX_NAK interrupt is raised. However, it is also observed that > sometimes the Master issues the next transaction too quickly while the > Slave IRQ handler is not yet invoked and the TX_NAK interrupt for the > last byte of the previous READ_PROCESSED state has not been ack’ed. > This TX_NAK interrupt is then raised together with SLAVE_MATCH interrupt > and RX_DONE interrupt of the next coming transaction from Master. The > Slave IRQ handler currently handles the SLAVE_MATCH and RX_DONE, but > ignores the TX_NAK, causing complaints such as > "aspeed-i2c-bus 1e78a040.i2c-bus: irq handled != irq. Expected > 0x00000086, but was 0x00000084" > > This commit adds code to handle this case by emitting a SLAVE_STOP event > for the TX_NAK before processing the RX_DONE for the coming transaction > from the Master. > > Fixes: f9eb91350bb2 ("i2c: aspeed: added slave support for Aspeed I2C driver") > Signed-off-by: Quan Nguyen > --- > v2: > + Split to separate series [Joel] > + Added the Fixes line [Joel] > + Revised commit message [Quan] > > v1: > + First introduced in > https://lore.kernel.org/all/20210519074934.20712-1-quan@os.amperecomputing.com/ > --- > drivers/i2c/busses/i2c-aspeed.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c > index 28e2a5fc4528..79476b46285b 100644 > --- a/drivers/i2c/busses/i2c-aspeed.c > +++ b/drivers/i2c/busses/i2c-aspeed.c > @@ -253,6 +253,11 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) > > /* Slave was requested, restart state machine. */ > if (irq_status & ASPEED_I2CD_INTR_SLAVE_MATCH) { > + if (irq_status & ASPEED_I2CD_INTR_TX_NAK && > + bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { > + irq_handled |= ASPEED_I2CD_INTR_TX_NAK; > + i2c_slave_event(slave, I2C_SLAVE_STOP, &value); > + } this is a duplicate of a later "if (...)" satement. What is the need for having them both? Andi > irq_handled |= ASPEED_I2CD_INTR_SLAVE_MATCH; > bus->slave_state = ASPEED_I2C_SLAVE_START; > } > -- > 2.35.1 >