Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3671067rdh; Mon, 27 Nov 2023 23:53:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEcVrrPZN06hi/3U0rx/K51AdxNG67MW9tToBa+dW0KYwqGnP4dF76g3fGxYGehOPAGEmFD X-Received: by 2002:a05:6871:528c:b0:1fa:261f:ac29 with SMTP id hu12-20020a056871528c00b001fa261fac29mr13558199oac.53.1701158039202; Mon, 27 Nov 2023 23:53:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701158039; cv=pass; d=google.com; s=arc-20160816; b=RVASMEHEfVO+V9hqdYJzf7yTfdLo/Es0mrdTAJS2EPgCcoRYEIWQhZz5JxNE4agKko R5QmV2J0MVQzb1BnKs079hqenijcY36okl7WvQskCpTigjN+Sb203uJDJpo7Fov+bsu7 51Ts4UK/IKROQWlkXiV2jBFJz2Plwmkyw7E5PtIPZXe9Dul2E2VSyEmcrQMxgeuj95O4 KPTxaN9GXv4Jgc/mkn5NmduJarqFSxQoVlFCUnFT+HnzLrKPb5v3LhrQU1pE4d7FFT+4 BIAV9LLZy2x0FWG+TIw9d2AS1cEC61CSneJP/wypKXR1Ia3vo8ivbdFdmc5wzY/xGFl5 wkSQ== 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=x2jqkmQeBWRe1MOsuI0Th9cPqnwGyzjyv0fBjRd58i8=; fh=+sI6aN+l4b+kIAcl3+qRSsHxxZLiE4Ou84B6CaaV0ZI=; b=rNPHWV/j8lgoLDx/IntZguuamzZoiHxt61L0eyYepfn8qGRREZC6QMXkhrZS/4s15Z R/4ag++2dSpTVVTZhrnZQ37j3tFnrGuAxxaLwXqZYiPErz8dKKuiyx/7ix6JOPNniveG nlhDiJL2eWANryhXDMU+dG9cPHAQW/vORXjmysiXP5e7QimyCvDcmuGyTAutrZuEqK5K c4PrOMxKUYZ9IGT9jAE/gzlACwgiP1FwUSoBYTHCjC30XhHBkw0IiyrbrX5DG0o8vHjS a6ChUTitbNo/49uxYjgr0lb/Q1M3rKE81XZpgXrAp2F9RiIpvdn2lvorLx0muG2pv4VV WBcw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=DXE7yREA; 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.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id z4-20020a63c044000000b00578f23273a3si11728737pgi.738.2023.11.27.23.53.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 23:53:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=DXE7yREA; 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.36 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 pete.vger.email (Postfix) with ESMTP id F236C80C5C84; Mon, 27 Nov 2023 23:53:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343912AbjK1HxB (ORCPT + 99 others); Tue, 28 Nov 2023 02:53:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343903AbjK1Hw7 (ORCPT ); Tue, 28 Nov 2023 02:52:59 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2137.outbound.protection.outlook.com [40.107.244.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10E94183; Mon, 27 Nov 2023 23:53:06 -0800 (PST) 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 Cc: Cosmo Chou , Open Source Submission , Phong Vo , "Thang Q . Nguyen" 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> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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?B?eWtuSUEvUmVrVmhKRFIzL25zM0F5LzlQUk1lWGtXVit5MDF1K1dScitMam9T?= =?utf-8?B?eUk1VWUrdUdoaFdMYXV3SHZaVDJZUkk2TFJPQXRIbmFxZENhY2dJTHdLNk8z?= =?utf-8?B?aUZrTkNlZEpmV1czN1BYSlJyRXh5M0x3TUNiVENpS04rYnIxSWJOcHU2R1h5?= =?utf-8?B?UmZTY1NIR2g4ZkNpNm5WS3R3eXk2cURPRlVkaFFQVVgyUjc0OGZuQlk0MUh1?= =?utf-8?B?Uzg1SkJISDUzM25WRnN0WWFzWFJWa3NsQjJoNGdYNlhBUk85RjViQUJ3bVdO?= =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WnI1RUZiTlV2dHZpZXNJMGJmbHRhdFA1Q0NF?= =?utf-8?B?S3RoclJOQndyUDRkSGVUNFViRWIwcHpJeEVyUmxGUm43c1l1Wkt3Y0UxN3J3?= =?utf-8?Q?I8TIMMK3KwbHsQ+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-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 pete.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 (pete.vger.email [0.0.0.0]); Mon, 27 Nov 2023 23:53:56 -0800 (PST) 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; } -- 2.35.1