Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1886114pxj; Wed, 19 May 2021 16:45:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb4Q9HpwiqS3H00tl7Jk6RtJKbNPNFfVGd5WF3oJkhYQx9SCz3MT+1W/aviYRynzU9JHQq X-Received: by 2002:a05:6402:498:: with SMTP id k24mr1770977edv.80.1621467914120; Wed, 19 May 2021 16:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621467914; cv=none; d=google.com; s=arc-20160816; b=e5FLVM5ugwRHsHBb9beM/JltcM/UG2j3i2xWC6j3JaTtFicTeqpRR4L7LAfQ4d8Lz4 kN1/8bsexuHL75hXab9K2pDboB6/rtK82g7iKm+d8PV9x30yP2ptI+uDSddd1TogV7kN Am83M0+FJAsSLRjN+DvySRcgXkdCSwmDBFKCgx0RHMG4plKF6Rq+tsEHevZDCHmbEjE3 t+2pO3HhORzAD2K0F0RdPL/xt4CyGKbP0Omn2kpWB6MglOAA8nJH1rRIrHBZmrfokXui WIFPxE/8eWhZuCdJppPKfAIy03/ku+7OwvWFASwklppMVKsp3AO5+mDwSRmvG/qXuveZ JXYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=jZj61H+nZldX9VF8Rk7SoLRZEnhdWQ15nrHYMIdlXL8=; b=o1/fFaI0SndCcRireQXaq3TYFs/R6NJx1/TF/wp2DmFta2S3ditOTN37u9Yekdcp1c Sd/1Fkz9wA5H+dMWOct9j5kZ0Lc+u9tu565+aDxPfex900SV+/SvJWg4dwF2ki6xXMeL EbpRHqmRfzJt+9Z+bX54C+7QnHkUTfL6W4eFP5wbPeNP/CjEJSAYY+77oFu5CJ3jWlMq 1NYxBQEIiD1jK+gwdz9kkuiRyjn7M6KexVez4cUVtzzMICKD4nO8O8g9ANE3rnx9z4iQ B4TRpIplYP52xg8dcARkSh6qZeILcU3wk8whOpN53sVyBZ2DjRhGQ2o6adI0e+tCX3BZ 8v2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jms.id.au header.s=google header.b=hV289Pn1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f24si665685edx.231.2021.05.19.16.44.51; Wed, 19 May 2021 16:45:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@jms.id.au header.s=google header.b=hV289Pn1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229808AbhESXoo (ORCPT + 99 others); Wed, 19 May 2021 19:44:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229465AbhESXon (ORCPT ); Wed, 19 May 2021 19:44:43 -0400 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78163C061574; Wed, 19 May 2021 16:43:21 -0700 (PDT) Received: by mail-qk1-x732.google.com with SMTP id 82so3150720qki.8; Wed, 19 May 2021 16:43:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jms.id.au; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jZj61H+nZldX9VF8Rk7SoLRZEnhdWQ15nrHYMIdlXL8=; b=hV289Pn1fzt0l5vYzw9Zco9XFbeqr0tKlwl117wL+ReIbVLezHs/xFwIcMKafGIL/r Ceq9AJkQHisWMOwWZVoe+E3BdzypGyKrbGtP5GVg+wjxmevjIE5q30D1Z3rQCTBmbzyl JopSkzzu13aCRFAkE3C3pYN93lb/AFgpuiOcI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jZj61H+nZldX9VF8Rk7SoLRZEnhdWQ15nrHYMIdlXL8=; b=lp61uGh8Hi7ghuYkGlyKVBIBYtXo81zHvu83/yEYPxuGl0V6SC5xvEMDX69NMdeQo+ SmTmaWdybKle19AZbz3pHQYb79aGXegDIaoor97qCmBgXUU4VuLU6joIxnBsjKSK0t7E ODq9vHxpJ0LYoP2d1x6vgmZPX6jnGqh1crUM6USvjx88kJKNN2jM9bwyyp/CeDz3X0zx C76Wyfuy1R2O5uan39xGCV9swGTB8zcPje4fNbjS6jZjT4YdBfuLbEb7ECs/eoNwcAc9 tb0vX6yNwTOvG8dxaG9mRCnKcYOtRL33pwMtyun17LDB5BwmA9c/1GFVG1WbkrB853mJ TVvw== X-Gm-Message-State: AOAM53317Vs6W6Mi4Cra3YLZSRjLWcnefHfKOzOkZHUJObQHc06W0k+D pCKirJrVUlprkdUJjsEUk2zRvFe3E14Tjk+x0gM= X-Received: by 2002:a05:620a:704:: with SMTP id 4mr1331345qkc.66.1621467800517; Wed, 19 May 2021 16:43:20 -0700 (PDT) MIME-Version: 1.0 References: <20210519074934.20712-1-quan@os.amperecomputing.com> <20210519074934.20712-5-quan@os.amperecomputing.com> In-Reply-To: <20210519074934.20712-5-quan@os.amperecomputing.com> From: Joel Stanley Date: Wed, 19 May 2021 23:43:08 +0000 Message-ID: Subject: Re: [PATCH v3 4/7] i2c: aspeed: Acknowledge Tx done w/wo ACK irq late To: Quan Nguyen , Guenter Roeck Cc: Corey Minyard , Rob Herring , Andrew Jeffery , Brendan Higgins , Benjamin Herrenschmidt , Wolfram Sang , Philipp Zabel , openipmi-developer@lists.sourceforge.net, devicetree , Linux ARM , linux-aspeed , Linux Kernel Mailing List , linux-i2c@vger.kernel.org, Open Source Submission , Phong Vo , "Thang Q . Nguyen" , OpenBMC Maillist Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 19 May 2021 at 07:50, Quan Nguyen wrote: > > With Tx done w/wo ACK are ack'ed early at beginning of irq handler, Is w/wo a typo? If not, please write the full words ("with and without") > it is observed that, usually, the Tx done with Ack irq raises in the > READ REQUESTED state. This is unexpected and complaint as below appear: > "Unexpected Ack on read request" > > Assumed that Tx done should only be ack'ed once it was truly processed, > switch to late ack'ed this two irqs and seen this issue go away through > test with AST2500.. Please read Guneter's commit message 2be6b47211e17e6c90ead40d24d2a5cc815f2d5c to confirm that your changes do not invalidate the fix that they made. Add them to CC for review. Again, this is a fix that is independent of the ssif work. Please send it separately with a Fixes line. > > Signed-off-by: Quan Nguyen > --- > v3: > + First introduce in v3 [Quan] > > drivers/i2c/busses/i2c-aspeed.c | 26 ++++++++++++++++++-------- > 1 file changed, 18 insertions(+), 8 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c > index 3fb37c3f23d4..b2e9c8f0ddf7 100644 > --- a/drivers/i2c/busses/i2c-aspeed.c > +++ b/drivers/i2c/busses/i2c-aspeed.c > @@ -606,8 +606,12 @@ 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 Nit: this comment can be on one line. > + */ > + 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; > @@ -652,12 +656,18 @@ 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 */ > + /* Note: Re-use irq_handled variable */ I'm not sure what this note means. > + irq_handled = 0; > + if (irq_received & ASPEED_I2CD_INTR_RX_DONE) > + irq_handled |= ASPEED_I2CD_INTR_RX_DONE; > + if (irq_received & ASPEED_I2CD_INTR_TX_ACK) > + irq_handled |= ASPEED_I2CD_INTR_TX_ACK; > + if (irq_received & ASPEED_I2CD_INTR_TX_NAK) > + irq_handled |= ASPEED_I2CD_INTR_TX_NAK; > + writel(irq_handled, bus->base + ASPEED_I2C_INTR_STS_REG); Are you intentionally only acking the bits that are set when we read from STS_REG at the start of the handler? If not, we could write this instead: writel(ASPEED_I2CD_INTR_RX_DONE | ASPEED_I2CD_INTR_TX_ACK | ASPEED_I2CD_INTR_TX_NAK, bus->base + ASPEED_I2C_INTR_STS_REG); If you only want to ack the bits that are set, then do this: 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); That way, you can avoid all of the tests. > + readl(bus->base + ASPEED_I2C_INTR_STS_REG); When you move this, please add a comment that reminds us why we do a write-then-read (see commit c926c87b8e36dcc0ea5c2a0a0227ed4f32d0516a). > + > spin_unlock(&bus->lock); > return irq_remaining ? IRQ_NONE : IRQ_HANDLED; > } > -- > 2.28.0 >