Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3743749rdb; Sun, 10 Dec 2023 20:07:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUh7R4i0kb6cHyHgkaIdVatvP6MyRpoLrYmCbfpujI5HY5cqehvSy1MPnqtLihAwn4XPqx X-Received: by 2002:a05:6e02:18cc:b0:35d:a75b:6109 with SMTP id s12-20020a056e0218cc00b0035da75b6109mr6738429ilu.43.1702267625705; Sun, 10 Dec 2023 20:07:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702267625; cv=pass; d=google.com; s=arc-20160816; b=tJ9c7VL4bUEWeQd0JDU3+k/4UINljyMF1wvIdR5M1vR2o5+TDPzsnUlRMrFlq94867 ZSCuNJ3JDAbAEsDoVjOuR6KS26FckMKtLc1QHvZK8MM3b+oTvvplTJGCkvjnJKDZqz/y 9Mj7rwfzd2wuAWq/7ig8NWMGrUXcFoOGEYEIc7P62N7nJ9HXbiz7IlK/+OkgSx9oVQWd 5tk2pTG8BMEN3R87r3H3or1WbMlvNXxas/pxCDOOBiGODMTvZMIS6BSLDurXf0jtI9pu 8QigzDf1Dj8uqtIyLKMtlqBloBR+8Z1aqaYUBFePA9Sb9UjqgMQBI+SDSnJxBRrR3vrk Xkkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=1RuLEcFv8sKNk1UYJyP9qSg6zaau5RM162yX2EBQ0rY=; fh=+sI6aN+l4b+kIAcl3+qRSsHxxZLiE4Ou84B6CaaV0ZI=; b=lvNvnayBKk65B3Kgiqm9u2KPHYdCPdVZcyqA2VN0kOhMbRm/XNcrC2q7ZilpBRfExv sFwQly+QygslaTu1Lz/pRNUEiEJrDx9n4PZufrLYBjWiDMFf5k63/qb+ZD+htC3dKmHo q0/Jo5+J2jGH49pmUdj+14rxh8AklqRm+cb0zS84Bv5lI7vOHKinaMxsaDTcbVWAMxR2 LLWOCRPpfVLnrEXkmduyu+spXC8qu204Y4fkPo/shd/M51EENyIzqqenMQxdnC6Rp3di BNBj2Ni8XMbsfPqubYmhPnlyQNq/veQ/jB22YuwBGed5FcF+CswERuCluS2gSWus10R9 fo5w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=qnazsROS; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id b12-20020a17090a9bcc00b002865a80ceb3si6831673pjw.2.2023.12.10.20.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 20:07:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=qnazsROS; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E867D80677C6; Sun, 10 Dec 2023 20:07:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232965AbjLKEGg (ORCPT + 99 others); Sun, 10 Dec 2023 23:06:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232837AbjLKEG3 (ORCPT ); Sun, 10 Dec 2023 23:06:29 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2093.outbound.protection.outlook.com [40.107.243.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E505F1; Sun, 10 Dec 2023 20:06:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dDXk6Rv+VjdAlL98H8LPKostv/4WbTD2fwzYN4SS4lr5XuJHied57Zm1RcqFYtLbdZ3cWi4cX8/ML7ncDivQ6ELr8/MVR050uh8CHtvNZVEy881DpvOhqfaACsGsqNbOjUYTAWKOU+OsrI2ZcK5PAAcwUkC4JUQLgqtk5a9wvktTViEUlqvdrqXO2En6alllTADR9bpRTDUoRFBC3pq4pvoajcyFvJsM0/BeawlSsJei3Aj1nDnOonr/a0rSnmfFSHd+MwM3+TjsxsKegsk+JddrwQaJ6vI7R0LE1S0AxxzIU53M5DybM8lAaF29XOp/U6sLFH+eP2dQvD/eSlxlkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1RuLEcFv8sKNk1UYJyP9qSg6zaau5RM162yX2EBQ0rY=; b=RN/5+GfXhPghVsqae2+aLIQxnH+2oEsvrSPQVyU2nRNAAK6r8WQJnTxTYgbrwTY1nq9lyIFe6qaxABaR03c0GF1rkAZYhpa5EyrhlHaNGpK+esUGF1N08OA2HSJqd70GLEe6F6cc/XnQazXuF4K0bytbtvsNoxc5QTe9w7R0vPH5Esu6f6V8/g3zNiTKrUBawr4CCUGdtlmq/qGnRr4zmB/7TmsfFFWyCd2YK2ga9SZ+WLWHqp9iJYg8Usr41XHfTzlgAZjXSz3F3VzKPJHD8Bk12H/PgPE3cQnzzPEgsiGS9sQUjAODv+3ZEq3dUHHbtkSSr7zLBFJJ1lmj/fflKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1RuLEcFv8sKNk1UYJyP9qSg6zaau5RM162yX2EBQ0rY=; b=qnazsROS9BpFPPZfFS3j0pHUTDzZdY2Xe/be+HLBhsoMgGCGNedsMtgQsnIn6jQSbXcH+VfUpIXzdHOa/PwuaNrNyZFnh+eMWzod63aLfDR+wbATUi+KQYxh6EQpAre7WpPn5tj/ANW3IUYvuzMKaAfhUE3UL/ZsEWrOUmOUXmc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SN4PR01MB7455.prod.exchangelabs.com (2603:10b6:806:202::11) by PH7PR01MB7821.prod.exchangelabs.com (2603:10b6:510:1d9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 04:06:33 +0000 Received: from SN4PR01MB7455.prod.exchangelabs.com ([fe80::5682:1d84:171a:1d68]) by SN4PR01MB7455.prod.exchangelabs.com ([fe80::5682:1d84:171a:1d68%3]) with mapi id 15.20.7068.031; Mon, 11 Dec 2023 04:06:33 +0000 Message-ID: Date: Mon, 11 Dec 2023 11:06:27 +0700 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late Content-Language: en-CA To: Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , Andi Shyti , 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 Cc: Cosmo Chou , Open Source Submission , Phong Vo , "Thang Q . Nguyen" References: <20231208033142.1673232-1-quan@os.amperecomputing.com> <20231208033142.1673232-3-quan@os.amperecomputing.com> From: Quan Nguyen In-Reply-To: <20231208033142.1673232-3-quan@os.amperecomputing.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CH0P221CA0022.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:11c::22) To SN4PR01MB7455.prod.exchangelabs.com (2603:10b6:806:202::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR01MB7455:EE_|PH7PR01MB7821:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e7882fe-6a78-4f21-fede-08dbf9fe8fa4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G4TLnwVCbMGY5bOSe467rnGxJYsE6hIKhb7DuMKAgvJblsOwGPqg6iT18wx+Kz9d7OQjIBp2jOF0AkDCXOWaSN8+1PYwcUWkNa3BcK2EtdrC7mviCNZoaBVCwi80MQ3VdJTy5hbSrD4MzhzG6Hjl23TEswmRJX1e2po8L7iT5Sq74SwJDjYffeAdD2rBfjXceTlbvROpk3LdLqaR5CTKKuGz+763qTtJgRWcXTZm/90w1KEx0Wa1P5B96XDZxo3/JzHn0i9IPzcZFz3bu6lmMBDgYIZATDacC+vy2sXHZkrSHc51z74tEVBGaD0XJNbEiAfOi5c2PAQCcADMn1r3RYS4vjZLoMCQElN4NkI73AATyNyxUV+8SlfERgPCYYGoEodNIsOzAHFn8g/1mqQ6lqrS4kj7n4Nc6IZ5p071w7a5YnM6Pipe3+DTCkDirBmtulmpPi1bs0K9S756oQ5CpevfM1bmNh9wYKtOXhlAWcZcTo1zfKLew9+5VUuZmV200OQhMsNkiTHJD3r714abnRg+F8CX0UF9/IOGeabHmPepSYKGoc+3vSRzWtXClsdjJpGhv5ntgSIB2WbaMMw9VUhy8vAgxAZ4gKJ9oEz5+kgAuuL2ug179+jFiNSUauXT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN4PR01MB7455.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(376002)(39850400004)(346002)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(6512007)(6506007)(53546011)(5660300002)(26005)(2616005)(107886003)(7416002)(54906003)(66476007)(66556008)(66946007)(6486002)(966005)(2906002)(83380400001)(31686004)(921008)(41300700001)(478600001)(86362001)(8676002)(8936002)(4326008)(31696002)(110136005)(316002)(38100700002)(6666004)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bDlFN0JYcUt3OFA2QW8yblBiQVdCNVhodGtGNWg2R3Y3dzNpMVNBMEZTeEV6?= =?utf-8?B?T3d1MXBGdWJGM1RWYjczU0xWallib0w2SlhuTnp6SzJtNUpoNkxoYjcyUmQr?= =?utf-8?B?aksxM0ZpakNwU1h3aHFxWHNjL1V2elFXM1M2M2E4VFB4aGcveXRKYWZNU0ZD?= =?utf-8?B?UTJGaURQWjZCbHMxalJ5TGRlcVlDN1pKRkU5ci92MjdCa0FPZUI2TEQrdG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FZ3V3MWVnU1BvclNJZUxpQ1hqeUxVSThPeFhJUVovY1F0S0Q1?= =?utf-8?B?ZGl3RnZEQWNsTERaWDBCZzRVelNBRTdvSTRwTnc0aUtDQjlZQStUL2crMXhY?= =?utf-8?B?TzR2TjdHalFkMTZkMkNOK2QzMStLWXBmTE93anUrbi9PQ0lIbDBGK0JaOWY2?= =?utf-8?Q?pnsdlzy0NCNHxnc02VlldTs=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e7882fe-6a78-4f21-fede-08dbf9fe8fa4 X-MS-Exchange-CrossTenant-AuthSource: SN4PR01MB7455.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 04:06:33.1421 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yhhFD9jdKnZgIkwg7jAbggRV6XF6PGci72KtDwhx5KN6h2dqgNVBsm1uQ4hXhjzTWjOuVEAS+mDjCtMQU16LXRWfGokfaBO5mbET2ZRK8BY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR01MB7821 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 agentk.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 (agentk.vger.email [0.0.0.0]); Sun, 10 Dec 2023 20:07:03 -0800 (PST) On 08/12/2023 10:31, 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 has been 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, that shows the > "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 that issue by acknowledging > interrupts for both ACK and NACK cases late in the interrupt handler. > > Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") > Signed-off-by: Quan Nguyen > --- > v3: > + Fix the unconditinal write when ack the irqs [Andrew] > + Refactor the code to enhance code readability [Quan] > + Fix grammar in commit message [Quan] > > 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 | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c > index 1c2a4f4c4e1b..967a26dd4ffa 100644 > --- a/drivers/i2c/busses/i2c-aspeed.c > +++ b/drivers/i2c/busses/i2c-aspeed.c > @@ -617,13 +617,19 @@ 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_ack_last; > > 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); > + > + /* > + * Early acking of INTR_RX_DONE and INTR_TX_[ACK|NAK] would indicate HW to > + * start receiving or sending new data, and this may cause a race condition > + * as the irq handler has not yet handled these irqs but is being acked. > + * Let's ack them late at the end of the irq handler when those are truly processed. > + */ > + irq_ack_last = ASPEED_I2CD_INTR_RX_DONE | ASPEED_I2CD_INTR_TX_ACK | ASPEED_I2CD_INTR_TX_NAK; > + writel(irq_received & ~irq_ack_last, bus->base + ASPEED_I2C_INTR_STS_REG); As there will be v4, I'd like to improve this line of code a bit. During debug, there are significant number of times when the irq_received has the value of 0x00000004 (INTR_RX_DONE) or 0x00000001 (INTR_TX_ACK). This makes the "irq_received & ~irq_ack_last" turn out to be 0. AFAIK, it does not make sense to keep repeatedly writing the 0 to the HW then try to re-read it with readl() every time. I'd like to change this HW access conditionally to avoid those unnecessary access. The change would looks like below: diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 5511fd46a65e..0f67218cf04a 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -93,6 +93,10 @@ ASPEED_I2CD_INTR_RX_DONE | \ ASPEED_I2CD_INTR_TX_NAK | \ ASPEED_I2CD_INTR_TX_ACK) +#define ASPEED_I2CD_INTR_ACK_RX_TX \ + (ASPEED_I2CD_INTR_RX_DONE | \ + ASPEED_I2CD_INTR_TX_ACK | \ + ASPEED_I2CD_INTR_TX_NAK) /* 0x14 : I2CD Command/Status Register */ #define ASPEED_I2CD_SCL_LINE_STS BIT(18) @@ -622,10 +626,19 @@ 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, - bus->base + ASPEED_I2C_INTR_STS_REG); - readl(bus->base + ASPEED_I2C_INTR_STS_REG); + + /* + * Early acking of INTR_RX_DONE and INTR_TX_[ACK|NAK] would + ... + */ + if (irq_received & ~ASPEED_I2CD_INTR_ACK_RX_TX) { + writel(irq_received & ~ASPEED_I2CD_INTR_ACK_RX_TX, + bus->base + ASPEED_I2C_INTR_STS_REG); + readl(bus->base + ASPEED_I2C_INTR_STS_REG); + } + irq_received &= ASPEED_I2CD_INTR_RECV_MASK; irq_remaining = irq_received; Thanks, - Quan