Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3670963rdh; Mon, 27 Nov 2023 23:53:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IH2qqnlDrIpOrjYW4cFFZb9+RSo9MaojOIdZxpl/BHqOANqRxItiFZuiLua40t6Oawytnkv X-Received: by 2002:a81:65d7:0:b0:577:189b:ad4 with SMTP id z206-20020a8165d7000000b00577189b0ad4mr15920237ywb.48.1701158017888; Mon, 27 Nov 2023 23:53:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701158017; cv=pass; d=google.com; s=arc-20160816; b=MJcaRKLOMDSdKQzlx/CfdQRir9j85Ivt9fFZ7RQRE3rGIvNszUas3VTb+Wt+knE4Jm kdfg0c1uuszddrPJPD1/Jz4lN+9PcdxoSf3N9HdFRhG1yHCAFUTs0F5zQoOe0waCumze hQh9CeNy/SDib5etftzeE4M1nfcX5D5tG6hMt+RRfrAvj/lePEqyA60fSGTBUBYB7evy hSZb4SBu7hgXMk+iJ2rkXzu6UDg06ArN/13x1DhhtazAp5xsXu5WJGSbty5O+QEaYWX+ d8KxUSIaeWLn8fZqMuFel4Zr4fuTTA8+aOOd3nh72VFTCF/NWOm2+SoOnzHNyTFaNc8s mpuA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UtkZ2h9mXhBtLKfMjfYUHJA7XpLTI7D4PNWPTVAPXh4=; fh=+sI6aN+l4b+kIAcl3+qRSsHxxZLiE4Ou84B6CaaV0ZI=; b=Qg50MYlClvbJdqPiH+xemBfLiaAD9eQ8O9gf7hu5FnhapIOPDllraGb0ttgA/bTK91 ZRYxsgq/PNPYS7ZRtmZMEYwQIDxGfIUJYJAohIwvrp3bh3I6rC+Ev1jgnLNO0X4HD8qf OicxlfHxSSQDnMc3PXLev2z7COiM2164F/46NjsAEV57jGXlFCzEZ049OO+l3Gr34EU0 37nn99CTzo+Q7vs0LY1t4FCluTL684X6e66mAlnbRI5yeVUMjkZeEisF7kwta6Y+0ejN Ap0gUH5jBfkXRp7KlaGGqvAgtN8a7fvbVUYbjsfxt94FZAseP5DQ7Zi4yX1G7YGQ7gLV RCzA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b="qN/z3KEP"; 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 2620:137:e000::3:2 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. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id t25-20020a6564d9000000b005b8dd557b38si11396241pgv.14.2023.11.27.23.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 23:53:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b="qN/z3KEP"; 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 2620:137:e000::3:2 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 F1B8E8058B4F; Mon, 27 Nov 2023 23:53:34 -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 S1343953AbjK1HxP (ORCPT + 99 others); Tue, 28 Nov 2023 02:53:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234641AbjK1HxK (ORCPT ); Tue, 28 Nov 2023 02:53:10 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2118.outbound.protection.outlook.com [40.107.244.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D44DDD5A; Mon, 27 Nov 2023 23:53:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MBnw+PSOzkptiu5+dXANgvBFy9geNQLq77U0zCFw4h0ffBRfcZgwzKOlXK+ANEqFrsnh7gjoBpQ0kWDGuTUu39cJIBXErnM7SbvuO0qG1UYRIVxiC7/+ErKZGDvLOzjtNd8inGR4lNIbFNK3A/JQsesURXf+kEwi94DQqWkI12tweDpaD5kYYPxHR/zcL18/ai6ZeK70dnBytwDlrhtpkXtJhNT/74uQ7Jr5MfAnNeDg1PSVtKnuOy4RiLvnwwtHxtydf4D5o8PJeC0LfKxiEp3BL1dl8WUixskzaDzFUBYtNSurc0ZabKKNc2ov5Xo/+BKxeTilDXCxcB5jQJiwBQ== 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=UtkZ2h9mXhBtLKfMjfYUHJA7XpLTI7D4PNWPTVAPXh4=; b=RytnGyCpw6ZZx+rss/89UyrQ52Lw97X/97b1y6DWiGRGUr3a1A0EK0XEcULryqshOghGG2uiqJlSBW0UAZMuq/rzYj82HIFIttoWHSHiiQgu+VSokz+CpfpYM+wXS56nXgjfVESiAogDnCR6samsKOUEUqurQsc6+aG0zkW2lkd/Ughjg5Fq6jeLvT0gzGitbuaJnVVPnOu0e4JGMnO639S3PLcHhgBgX8l7sU0khBWK28l3Wm1mzs0kPy5eLOswuU7th8ydibYpmuQMrPPSVNCfSPH4zsdJNiiLdJ35Jvc0SFy0sVd8Wk5ujpOoJ97dU/+SHB5a2Xpzgrd+nt0B7g== 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=UtkZ2h9mXhBtLKfMjfYUHJA7XpLTI7D4PNWPTVAPXh4=; b=qN/z3KEPS9Tnf6gyatWB2S9fG64+OFo9+3mXEmdGjBGjo9NBv4vn7g/RTraO8Xti6t1JM32wWFUPC+pZMV0MYuuSdgCHa1ER98kpJzPi+A6jJ/bc9W4y9+WV6VuDj4CFPcb59KOox8cmjhlT3MZibHGcxgtp/g3/K45WSYlNLyo= 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 PH0PR01MB7895.prod.exchangelabs.com (2603:10b6:510:28a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.29; Tue, 28 Nov 2023 07:53:09 +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.7025.022; Tue, 28 Nov 2023 07:53:09 +0000 From: Quan Nguyen 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" Subject: [PATCH v2 RESEND 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late Date: Tue, 28 Nov 2023 14:52:36 +0700 Message-Id: <20231128075236.2724038-3-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20231128075236.2724038-1-quan@os.amperecomputing.com> References: <20231128075236.2724038-1-quan@os.amperecomputing.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2P153CA0032.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::23) To SN4PR01MB7455.prod.exchangelabs.com (2603:10b6:806:202::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR01MB7455:EE_|PH0PR01MB7895:EE_ X-MS-Office365-Filtering-Correlation-Id: 9048d942-9b4a-42da-45ff-08dbefe70ff8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EbKx9Li1zjFHsJJOcnQcx6yC7ba1vB2Cnexy2jAn/a7ajwcbABPon9oRHQB5AF2IFIVdgtcYoYF5UZNmcyCIQlYR/jfr/+9sep4Wb/7OZAqLoNiErCxjvKTKq9p1dvfnT2/E610Vyiq0iblHsLEIygDFf/Q7PgXA1hT0WYMeY6fX8K7ALW7dMPuRSG04oo2RIr4fs/Apq627CQBHCmwKKwWd69HmBNLAO4I90vUAwLX6061Hjx6/3inhOkIoalHV7SITf01ar0X1zR0n9amPTgg+4ULeTsKNg1DDPlxtVpLVS655mqV2qyAidECwumfdCPoz9Vt/+cG1sIojMhUqKKvfbwyZOJjc41AKQ1FHGe3FO60I7BbokxlbWeU8lSEso7dMQIVZcmiaNEV3cNGPkR6alYyNCuElf3wF6iAd2hVd9/UHsPidUoZ6d1P5k7ficmEEMLv4csYLBcufuhwGXT0ljVk+W2Sb1I+2rVPdjc/L0gTwtTMeh3SHRGzNQQp7hIxYfTW8qF42cz7+oqft9Lapn+3ATvG9WvRlwxELO7ctgt7s2kKMmfJJ9pfB6znXbeDigiUNUdGs3piErYTb1QpAQv6uYUvSRvlwcm2FhjqQCsFAqMaE4Pt7x2MjqyTx 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)(396003)(376002)(346002)(136003)(366004)(39850400004)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(4326008)(41300700001)(8936002)(2906002)(8676002)(6512007)(2616005)(6506007)(52116002)(86362001)(107886003)(316002)(66556008)(66476007)(921008)(66946007)(38350700005)(7416002)(54906003)(5660300002)(1076003)(478600001)(6666004)(26005)(6486002)(110136005)(966005)(83380400001)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?P/6TwgBolVNVVBEIJfsfm7kmfNHVZzbaSPmgq7NWjaeTo19fJqjwpfjAONqN?= =?us-ascii?Q?orTJEL4psbyoD4cq87dDba+aQlM2gpd2gkOxZzBLjjJOEwMJmT4KsvwWZvAF?= =?us-ascii?Q?bnyswp3jIupQ4v/+PW76DPodTEN80sV/BmHo1YzxPj4yRiYLNJ3lQ8cCkElA?= =?us-ascii?Q?HXV+tbfS9Ue0neR73hWaIpYdJXKnPZF6rZLk7Ehm44sbtjnvyTLWNSavbOl5?= =?us-ascii?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s8io3gdUXNBTa0D8JbDd2Mi7J?= =?us-ascii?Q?a0jiMtOj68dk8F3AxkXHYdWFGbvohgft9BH8fbZqCDM1ZyRQZoLteKUnTeMj?= =?us-ascii?Q?x3cNEOdMhJiRtZXfQ+xRQC5sl/RJKYWJOXDBT463pnJk6JW0hRR43JIMxIYt?= =?us-ascii?Q?yutuoMhoPEWCJi7DTn1EiwQFIN/1vxts40xKUjnsgENsT/HJb5c6qWhFg6Zf?= =?us-ascii?Q?fjSY9nxkMC+USd2Yj5VR3fslmIm289Mqtkt+txM7dwezVqG+QARJfPzdwTY0?= =?us-ascii?Q?weZgtvdZtGpMl1VY+cmDqLP0ZFt9D5wtGKKxiRbRxS9c9FKHF86jitl+eGUF?= =?us-ascii?Q?KlkeLk7S+53Hg7xXPWMH3+AIMc/f0H/w0PR549Cipg+j5TxVzSj0Y96N/f7A?= =?us-ascii?Q?0l05EFdy/HdcbpbP7rK9W1TiY4hT74DUIcive/+CMfMM9UO8DEf6gSBachVv?= =?us-ascii?Q?PGFXpgdqc4b+JV7GHgthah8/BUPF3fuvOn4W13TYqavZw3Qe0deXJbJ0meFF?= =?us-ascii?Q?hW+CKT3Kh94+zeiLmC4IEDc=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9048d942-9b4a-42da-45ff-08dbefe70ff8 X-MS-Exchange-CrossTenant-AuthSource: SN4PR01MB7455.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2023 07:53:08.9241 (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: gW+M3wKwjgOURJulrCb61DrhQGGIpIYaxkDpCMe8t2Jt18WmTqntA2bGMo/AZtymN0063TggJGYxQq6HFih7xo8rJY+gsIJsG7BMnwjsKzs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB7895 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]); Mon, 27 Nov 2023 23:53:35 -0800 (PST) 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); + spin_unlock(&bus->lock); return irq_remaining ? IRQ_NONE : IRQ_HANDLED; } -- 2.35.1