From patchwork Tue Nov 28 07:52:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 1869148 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.a=rsa-sha256 header.s=selector2 header.b=DXE7yREA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SfZV84MkFz1yST for ; Tue, 28 Nov 2023 18:54:24 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.a=rsa-sha256 header.s=selector2 header.b=DXE7yREA; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4SfZV83FVCz3c5j for ; Tue, 28 Nov 2023 18:54:24 +1100 (AEDT) X-Original-To: linux-aspeed@lists.ozlabs.org Delivered-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.a=rsa-sha256 header.s=selector2 header.b=DXE7yREA; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=os.amperecomputing.com (client-ip=2a01:111:f400:fe5a::71e; helo=nam12-mw2-obe.outbound.protection.outlook.com; envelope-from=quan@os.amperecomputing.com; receiver=lists.ozlabs.org) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2071e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::71e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4SfZSy2Dhwz3bPM; Tue, 28 Nov 2023 18:53:22 +1100 (AEDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lkDe0qi8+3zEViVLYAUCIBabUHSGVyMCY4USRzZprnCJuCGztDNg1I5ixTM6J94WGoEHw60S5ippQPYu+tR7BUjUpzWIraOJylAzRFgEUq/1pjZqM1yIF9N2XRSqrsWT9RGwRqWmWd5egTSuvUdv+CxOw6ndFn5G+PbwTgoSDQqndfjZsJMX0a/JmIHnsPwqU5yIODXn7D6H+N5+IQXaLXe1pwByphGI5T4DLm1gljmauyrzQq8exHl7K/Xhc7IgV2N7KWPqy1XwX5kYXYGbEOxFtzi7H4nJSAQ+E0KSATRURHWt2kOwMguIey4TvWiCfjqTCIHNJNsMdTOLN1JdOQ== 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=x2jqkmQeBWRe1MOsuI0Th9cPqnwGyzjyv0fBjRd58i8=; b=HmleX7csArypFDGhO5tvZqV8Icvk09MLQ4R5voFlxx77VZJtU4eJV+hpxfP5s52HSpqnWK8hl2yrZdlYu26MsBtnKMONIqfns3Ix/aw0FUFh2eJpkvFbVsZGVywbrdN4TuTwZOU/tS9kuUxl20H/yW+hj++ny7qj8FLz/04XD1fzTePfzYVAEf7xzRnpSAo9fgcQq7Atka4+ll3DWKIfdK7oaEvXIYscE7MRzZkXpO4oEd0TG5Q8slFywft1A2jNYR3ACmoso5UIghUNK9J/cbMqXW2und0f5QMC1ws99K4AsZudNjVuBnrR9O+dTlKg2On5JflDc1NfohC5U+UiGQ== 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=x2jqkmQeBWRe1MOsuI0Th9cPqnwGyzjyv0fBjRd58i8=; b=DXE7yREA/Sivo6aDgEU/68t9SiuXqFxkKzRvzNM8fnlQH3DAd5EgFjEpF9PqLeASdkaU9hPAhj72XSRyTf7x6RmmPHW2DLJyBTx+JU46EGpXMl3tYQnsYQTslauPK3zizxSoCixvSgMj4jN2op6A6t+zqVXWpJROrziFNLIL1XA= 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:03 +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:03 +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 Subject: [PATCH v2 RESEND 1/2] i2c: aspeed: Fix unhandled Tx done with NAK Date: Tue, 28 Nov 2023 14:52:35 +0700 Message-Id: <20231128075236.2724038-2-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> 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: 1eadd8e9-0c1a-4f35-3126-08dbefe70cad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ys36CIJi5Rxwl9e2oZ81Sx/WdByDMAYoDifWC77Y3jIu82R1pcDxutOhy8mKReGD2mRFKsXxWYK+3HbwvZT818VVhryh12CfR+Y6CzqQ9eyQPDw1xWGXdP4sAIibOrLlF4y2cG17Ok9QgN6qT+y02NORC3mcns5Hy9Hijo7fOT22WKBdEOn+k7i4hkOfB3xOrPqAf+IA9IHr3+PCvD+ywlABpEtAzy8HLhe6b6QTpH7zsZFeVEuZzlweMCDGbymhwt7loDqWe1auSOD4Ad0eiDI+NxCkUuPijNsiMVnoWyCuLhINLqS5UVHGZxku1A5zdp+ea+2+usOthNc9yy8LdciOikoq3Sygm0inmIrCFo9JzocoC9ypnFzP5Lgt3clwHFXZtWdgphC+d8wF2HbqLH15/SDBCAD23TNBy9QBk1y6KG52yu2fJl7zsE8P0B98o4TK9zIlijBK3ihC57dy2aquBN5Eqm1sIP1ozgOxezHeHc5wBBlmUi9xU5sJE7OBIHkTaHGauSlM+JyRhM36UZYCK9qDRMebsMvi2gqxAAkbN/yb9kVf5Wt1wxA/zstWpcq86N4+PSsN8djgHhepcSFPSlmlgDzw9zwYwLrYEJU+KhtE4rWISDA8/B7EFNKp 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: =?utf-8?q?yknIA/RekVhJDR3/ns3Ay/9PRMeX?= =?utf-8?q?kWV+y01u+WRr+LjoSyI5Ue+uGhhWLauwHvZT2YRI6LROAtHnaqdCacgILwK6O3iFk?= =?utf-8?q?NCedJfWW37PXJRrExy3LwMCbTCiKN+br1IbNpu6GXyRfScSHGh8fCi6nVKtwyy6qD?= =?utf-8?q?OFUdhQPUX2R748fnBY41HuS85JBHH533nVFstYasXRVkslB2h4gX6XARO9F5bABwm?= =?utf-8?q?WN3jvbnbuF7ohXY4tuKeK0X6reD40ScCAtYVjptKr/9vihhM32LbWnXema4nr5ZQa?= =?utf-8?q?r+PY2U7CxhMc2A/Zoh/s5JwDPdFENKnYb6JzKWUiqi+BWCjQqEeEG7R9AS0VbKanM?= =?utf-8?q?epdAb+oJyWxMb141owNLZyYIB6EvoZDCXEGva5Xm2WGW/zeJ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aiWWC92b4HCMQ7J?= =?utf-8?q?1HseYUrtlpnUGOtieUFxJQgPdgInCTRhLzu4lTTGQDHMlsjZABkbtRN6l5aQXktKU?= =?utf-8?q?k1ylczP4+4StfnC5nRp07n6I2/uScMshbV2PDvFS21QswcRra0nEf4pD0n2dKnQJs?= =?utf-8?q?oejjlcOne0jEfzovs3AVepbMPtqbwAewWvGiefKWrMqpkkK+V6q6NcK9rqEqWUTfz?= =?utf-8?q?eIyaaTFmjLT4RHkCM5I4BSxvqZr5EFbNUvtviesI0bfltatP5CCEKthrRNBwrP4dH?= =?utf-8?q?eT4UbEb0pzIxErRlFRn7sYuZKwcE17rwI8TIMMK3KwbHsQ+WZlMS9EU=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1eadd8e9-0c1a-4f35-3126-08dbefe70cad 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:03.5932 (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: CkUj1KW4UY4MD1YJegZzUY40UghVetA4cYtb5V6sna9uiXItDO1/XREnh5i+YhRfkgAeOL7ilNKIvJlKq17y0N4FJQBldZmugUirGgRLUkE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB7895 X-BeenThere: linux-aspeed@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux ASPEED SoC development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cosmo Chou , Open Source Submission , "Thang Q . Nguyen" , Phong Vo Errors-To: linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linux-aspeed" 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); + } irq_handled |= ASPEED_I2CD_INTR_SLAVE_MATCH; bus->slave_state = ASPEED_I2C_SLAVE_START; } From patchwork Tue Nov 28 07:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 1869153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.a=rsa-sha256 header.s=selector2 header.b=qN/z3KEP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SfZXL1Whbz1yRW for ; Tue, 28 Nov 2023 18:56:18 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.a=rsa-sha256 header.s=selector2 header.b=qN/z3KEP; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4SfZXK5q2nz3cT7 for ; Tue, 28 Nov 2023 18:56:17 +1100 (AEDT) X-Original-To: linux-aspeed@lists.ozlabs.org Delivered-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.a=rsa-sha256 header.s=selector2 header.b=qN/z3KEP; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=os.amperecomputing.com (client-ip=2a01:111:f400:fe5a::71e; helo=nam12-mw2-obe.outbound.protection.outlook.com; envelope-from=quan@os.amperecomputing.com; receiver=lists.ozlabs.org) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2071e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::71e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4SfZSy5r64z3bPM; Tue, 28 Nov 2023 18:53:22 +1100 (AEDT) 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 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> 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: P/6TwgBolVNVVBEIJfsfm7kmfNHVZzbaSPmgq7NWjaeTo19fJqjwpfjAONqNorTJEL4psbyoD4cq87dDba+aQlM2gpd2gkOxZzBLjjJOEwMJmT4KsvwWZvAFbnyswp3jIupQ4v/+PW76DPodTEN80sV/BmHo1YzxPj4yRiYLNJ3lQ8cCkElAHXV+tbfS9Ue0neR73hWaIpYdJXKnPZF6rZLk7Ehm44sbtjnvyTLWNSavbOl5fXfJnpOqjjANrXesnVrLRHDFrfCwtyO7q8arC1CB84Qy7TUJus+j3PLj57lWbq3cJWJ+LWCNNnW9/x0NLgqFuNQYms8G2Xs3RLM05lAD7UITr5VJoX+yn5PB27Jh/XN5mb/sZiNoXFmJQbAaCo3ZZf3Us4qnl3IcIW2xMPooRX0k5PfUsFu0m6bpcY0IZuyuT2KwD41zMr+HKDVkhi+tqFqzuhx14k/IOikMaJe90aPGZHAS8uAs71hI7WIYEQ9YblGkMFJoS0/RHqWGe6ujqfaoVLh+AtvPLB0d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0deXJbJ0meFFhW+CKT3Kh94+zeiLmC4IEDc= 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-BeenThere: linux-aspeed@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux ASPEED SoC development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cosmo Chou , Open Source Submission , "Thang Q . Nguyen" , Phong Vo Errors-To: linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linux-aspeed" 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; }