From patchwork Wed Jun 16 03:10:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 461694 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9C83C48BE8 for ; Wed, 16 Jun 2021 03:11:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE792611CE for ; Wed, 16 Jun 2021 03:11:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230239AbhFPDNQ (ORCPT ); Tue, 15 Jun 2021 23:13:16 -0400 Received: from mail-bn8nam12on2122.outbound.protection.outlook.com ([40.107.237.122]:54971 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229782AbhFPDNO (ORCPT ); Tue, 15 Jun 2021 23:13:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MihNvVVeub61WIW22I9aRhDbajJ1ENqlVEPjxN8ErTMk15ERrmYjBQ7IJ5OrKE6mwY08oACaPjIsAiuS5c8C9huFvsg83WViPOSUbXxxM+6DyNrybMv2MUxJ345H6FRcofigyB+gljGO/UOOVI7OETk5+zUEn9g4tu15Ma7/z1OIH2M95anM8pvpKGlQBhn/b3TEMPy34JbQGwllviDuhx0PtQqWbWKy6ztnI7tS3yf9Vst2SChkHWxmWjRSGzXX88oY6g0Q3D2YND22/SAtzjNF170zyCVKiHfv15gI4+YDOswLn+zH4WiYDPL0SVUVLWFOFS10Wx+sTFHpQVmweg== 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-SenderADCheck; bh=22s6r96HZ+kD1ry5av/wS/YRBfTfw09xA9MRtlwFDy0=; b=M2Ums2tPWQafrSByrxs7f/EuKIDqkc/95K/8B9KaxVd/rw+arMORbWcatL7ZvX43zkoJYVpEKy7TuBs4d6+yuYQdMNCytU3JZDSd6SLcwQf6MMdx+fvcZCSsh1IkJyNPnfUj78W46xe+o25MHkoyFR0GVDUmPJcfFxDp0idCRzR+JEVrDem45dzOSWTpoRMAxB9NeX2vTgigocNFEmYT8RBkOR7Hwd3+gXhi1WggQHCS6KmcxNH6nyw9oZS/cJl5nc/RBUntUPiHeN/jLTcnH3f8bn0qqhyLoNNqFohMirqG7oIRcCqQ6PefAGcbGrg+0+qTwYij/HzxPjKSV1pamQ== 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=22s6r96HZ+kD1ry5av/wS/YRBfTfw09xA9MRtlwFDy0=; b=advq2SuirlzqO49/cwMlXxmk0Re9r8/rkRuCGeF08QGvzRPlUJTqp8iSM61CG8XoXbsNwo4FkoQ1HYyujnkdQ1IXkXTZHKjwkKGvdNRNNxdsbSxwRk/5tCbNgN4P+AxOSxEr9XnoMlVAcP/brWYRffxIiSgjbklqLjIwIXpsEVI= Authentication-Results: google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=none action=none header.from=os.amperecomputing.com; Received: from MW2PR0102MB3482.prod.exchangelabs.com (2603:10b6:302:c::32) by CO2PR01MB2200.prod.exchangelabs.com (2603:10b6:102:7::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.24; Wed, 16 Jun 2021 03:11:07 +0000 Received: from MW2PR0102MB3482.prod.exchangelabs.com ([fe80::452a:24fb:12cb:9d7e]) by MW2PR0102MB3482.prod.exchangelabs.com ([fe80::452a:24fb:12cb:9d7e%5]) with mapi id 15.20.4219.026; Wed, 16 Jun 2021 03:11:07 +0000 From: Quan Nguyen To: Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , 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: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v2 1/2] i2c: aspeed: Fix unhandled Tx done with NAK Date: Wed, 16 Jun 2021 10:10:45 +0700 Message-Id: <20210616031046.2317-2-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210616031046.2317-1-quan@os.amperecomputing.com> References: <20210616031046.2317-1-quan@os.amperecomputing.com> X-Originating-IP: [118.69.219.201] X-ClientProxiedBy: HKAPR03CA0001.apcprd03.prod.outlook.com (2603:1096:203:c8::6) To MW2PR0102MB3482.prod.exchangelabs.com (2603:10b6:302:c::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from hcm-sw-17.amperecomputing.com (118.69.219.201) by HKAPR03CA0001.apcprd03.prod.outlook.com (2603:1096:203:c8::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.9 via Frontend Transport; Wed, 16 Jun 2021 03:11:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a113aca-59e9-4603-6c0e-08d930746217 X-MS-TrafficTypeDiagnostic: CO2PR01MB2200: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1148; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gd8ls5NziJn+z2h/B1vNDSkEBbbFmeywTUr5qJ0NdVsENyk8JSjKGuqPISwOopkyfOtwbE/5SZTRzc5pWQbFTZTUzU9j6gDJHwELms3Qf81LdJcNDdXv4luyF6hvqArjXt4LuY31Ir8ALvyqT/ieB49azGndQ2tNWo/bFUZTuNGkoc3DP3im9DX2A7fVRQ7Zfk/RSLJ9WJIQSj3NX2PSjiRE/LKEOpDqQTZiT2D7kb+kVYGbr/ct92gd+4XQzKm+QUlkkiO8h8E88OVHUyNDrYw9QJIl2pX/XVxUlIg8/Ti0hcdzK/d7OkUuqpDLan9VaeRSoOszoRIJyTWBG36XMZZ3o5YGUuUEQ88lw3W8rGjRMewBs/wBgSQK1Tm3MZN78LUtwuPEjbX2yCi+sfiYECqRwyY2cNAEqulMuDrHgdip61BzDVtgXpbKUY+/qIRFhFPEH5tKjBk6TMV7Y+F67DXFOMZ56LJfhwjIRRwnWMl1J2P7E6Sb/f7Z1otm/HZ7/xgTGbhRKBw4zE3+5wbmTTQpoqVUxBGwY3q4J6EcXWzyP5udDBTftnXbC8hMFTFjg29/qk12ps4mc7F1eAGiOe1YmRoqnYpjk9rG8n9NHhwAu/RMPiPpWJryYMTno0/RyZdW0BrI5IzMdSiR3rBGxSKZPi5v6pFnreB5+g1vTV+otWBRP6F7djzRZgz+/jw4JejNLPw0ZbDoJ1VObYGCLbEURZIs2980nOpNIJ54i2eslVvmpp4Cn2/Wqj2T5Nft+4+K9usC4H5UIYBww9mVDmBt0L4MkbxuOE7Eb3pU6Ok= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW2PR0102MB3482.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(396003)(366004)(346002)(376002)(136003)(66946007)(956004)(1076003)(186003)(16526019)(921005)(2616005)(38100700002)(38350700002)(6512007)(5660300002)(7416002)(83380400001)(8676002)(2906002)(6506007)(107886003)(4326008)(110136005)(54906003)(26005)(6666004)(6486002)(478600001)(52116002)(966005)(8936002)(86362001)(316002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xjuNcLv8ihmk0bpB4bShB8nEg?= =?utf-8?q?0Kb1aEMicrKxj6pB7RC4I85EdtDse3Xq2TU+g6jlaTKYWqX2dfNUfRsI?= =?utf-8?q?GuXaqU9MaX1XU2FAU59HPTERcvQecBi/fF5Rm2cleo7plWYWcmqI7jn+?= =?utf-8?q?GW+bwqYNsokKNsJ/uvs55MOXM32Nc/qYpFd0gq0SzT8qozNc7zeCWd/q?= =?utf-8?q?vESZzPrNiOONQbHKypc5LJimZguz4QwlzdAQXXQRReTYO56fLIwoY8of?= =?utf-8?q?mlfnr07i7Ts/qcsSvYO0mQ/n92wV/Dh83NwBgmxh0PzUq0j3F5p+C1Wx?= =?utf-8?q?9318yKKg6AJfHOC8/YJUbGEbfl88UCUSzhXcBbQYnIWwMH197fGnUc8p?= =?utf-8?q?CpDar+N9LeHsqI5xwd5uPvQypC2z6a4ume3aymVK335wryDIU+80XZa4?= =?utf-8?q?niGzjmQ9ltNpArjNylKRr/JQ6fYyDPmAYo4OBGMl0ah0ob+vCP0T+UZu?= =?utf-8?q?BseT7LiSynOzTvD6XU1xycyAi79cxFJQOZ4nzL38nBtWZ+Mdkx9/HzdJ?= =?utf-8?q?FgYC+P4B1eHGzh9FXwewW1zcd3nLBShCKi9G8Jekg/uTkQTI2pumL3/l?= =?utf-8?q?xuny52rWHdSIYiIb4IntugqCFK46c/UveQcS9wnWtUGstmKPd9hUhDHg?= =?utf-8?q?FajRSBYYAwMqd30m6TTcEjFD0FZn+eCBS6+zY/OsCMUIUqwL/3m0rMW/?= =?utf-8?q?YZ3cdxUhMp45XkOc6dE6gb/5Eu84ERsR7z4ec0turnslpQ3DwW1mIfe3?= =?utf-8?q?pEcK1MBZCE8bA2uRHGfu9NNrzDGxEvpXsTQavofR7vHBdos1/dg5oK6k?= =?utf-8?q?NcdoXg9oYWOfS0JhGhssnLP84WpgVioWhpULyG5jLeVn/x4UmtPiAO57?= =?utf-8?q?8tP0DBhkETeMLAtV/Wdz7WNhDGjiIu0YwNVVqhLRmr6SDN2BehFWweG6?= =?utf-8?q?xg8OENQ2luc9YY0Y7yekaYLCbp9hY8Xshziji6THH03b3jTS6c7OP9O+?= =?utf-8?q?u5oSiNvbs2/Ai7EiHUkWdLp1f9kxpL0iP6JVeVLK7GVPKdd2PCJV0f81?= =?utf-8?q?ZkRoNzzpUuuSb2NzJT29Ijxa0WcmDGXQ7phhRfIzZ1MRoIzt+scRhVki?= =?utf-8?q?O/J8IRBN1wl7SmEupkKgxDZ6Hyg2jjBeUhtETz65t7cvGSDJxBhurm0O?= =?utf-8?q?x50tOse8ZZ4U0eZkS5HFGM8jBirU46dNbLZ42QR5A424QGP9U6yOTXf8?= =?utf-8?q?zY9k0l9aPoXHRsf2bOIzP0ixSEaXIpjKiqfo/XGXrHUcfOMIOSLqXecj?= =?utf-8?q?/VDgmeVJxRgxN8lQQj0WyWyKjVZPvwcN4E+fbBu2P3I5JZQIdhju8ifL?= =?utf-8?q?u1zdVwNbGUmYvJleSQ+v32X0DNnG2pD?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a113aca-59e9-4603-6c0e-08d930746217 X-MS-Exchange-CrossTenant-AuthSource: MW2PR0102MB3482.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 03:11:07.3405 (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: Xg+1UqL/LM+BDWg2ldJyeITws611Mkj4be2MUmkni9n5Be6i5P7oos2hV5pYciERmA0ZCweUmhxr6xi9fynW+8jfj/lBc2OOwqvbUoRAEYs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR01MB2200 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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://lkml.org/lkml/2021/5/19/205 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 724bf30600d6..3fb37c3f23d4 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -254,6 +254,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 Wed Jun 16 03:10:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 462499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A788AC48BE5 for ; Wed, 16 Jun 2021 03:11:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C53861246 for ; Wed, 16 Jun 2021 03:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230284AbhFPDNT (ORCPT ); Tue, 15 Jun 2021 23:13:19 -0400 Received: from mail-bn8nam12on2103.outbound.protection.outlook.com ([40.107.237.103]:16864 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230299AbhFPDNS (ORCPT ); Tue, 15 Jun 2021 23:13:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GmnLmGOVeFmSHgC2T66BrIqQXQwmo4i2+nbV1tKFLhHtdUuXzHSHTEId7YoFFBEqZnwJcojb4G5ZravcjNbvlfHVNmERrsdH4DNHsx269Vox93b843mU9u8bE/11QNdlx80VuH9KnOHi0MhEalUT8TNFS16d3i9fiquN/kACqY8OjEH8aLSKxD9uyxSEo0duU5rhPrwRMCrc7CIPZzGwsufEXIENA6Vnr0Ng2wej+LN6v24826+MlJA0DtsZXcPS2Bfl45bHf/65JI2RkrE2FqtAPjj+qvz+p0VPUtQhUzbRzWu6eCb8ov9ZwW8nAw0qSokRPuN3CWn/GylEBURitA== 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-SenderADCheck; bh=UaAf3KD4+QzGmbP8YE4+XWgkw1HmY388wpKZqZVh/AY=; b=CwHPKm1vpt18fvMQVkdaGBZVHEx/EtmjY/JciZozKhqm/a+HOKKTl8AW/o6yowBjH9scz0CDzSy4u4byNuD1JS6/KuYW8aRc72vdh/dI5VgAMKuyPiRKbwXC1NvLQCskTXRcBxvUOSHNZ28sewgGT80cw360yWTBG4oYi01jLqH/rn2jYwpdiZcvxr3pQSCod8NtGkUKI1zSQaP8x1e2BimW9EhrlI7XTUNItPte2ae+puJucrAOQrJgAuj+pNC70tAXK4farW6QRSDoIDYNx0u0eCV1y0h6oQJmAILruFdeMCDsaYPXEuHvAiphDDVHF+pEgZRlEi3qILvxmGNpLw== 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=UaAf3KD4+QzGmbP8YE4+XWgkw1HmY388wpKZqZVh/AY=; b=br96KjgjF0ZhLQYzVaB2t/WoZBjCXrwP3Xgsdn2O4FY8j/OpjsxWkLnEeGIKcGhjZYiMjNjelPr7mmiic3o/wcXvFXiWkA2MhVZcPqjG7W1n6aqVeW2Gbrjmd5y1Dmbb/IuLAFxoNqVcdEcAZr9KClS9NKryBOgC52T+2/2rBeE= Authentication-Results: google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=none action=none header.from=os.amperecomputing.com; Received: from MW2PR0102MB3482.prod.exchangelabs.com (2603:10b6:302:c::32) by CO2PR01MB2200.prod.exchangelabs.com (2603:10b6:102:7::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.24; Wed, 16 Jun 2021 03:11:11 +0000 Received: from MW2PR0102MB3482.prod.exchangelabs.com ([fe80::452a:24fb:12cb:9d7e]) by MW2PR0102MB3482.prod.exchangelabs.com ([fe80::452a:24fb:12cb:9d7e%5]) with mapi id 15.20.4219.026; Wed, 16 Jun 2021 03:11:11 +0000 From: Quan Nguyen To: Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , 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: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v2 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late Date: Wed, 16 Jun 2021 10:10:46 +0700 Message-Id: <20210616031046.2317-3-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210616031046.2317-1-quan@os.amperecomputing.com> References: <20210616031046.2317-1-quan@os.amperecomputing.com> X-Originating-IP: [118.69.219.201] X-ClientProxiedBy: HKAPR03CA0001.apcprd03.prod.outlook.com (2603:1096:203:c8::6) To MW2PR0102MB3482.prod.exchangelabs.com (2603:10b6:302:c::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from hcm-sw-17.amperecomputing.com (118.69.219.201) by HKAPR03CA0001.apcprd03.prod.outlook.com (2603:1096:203:c8::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.9 via Frontend Transport; Wed, 16 Jun 2021 03:11:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b9b62b8-f427-4ff0-db3a-08d930746447 X-MS-TrafficTypeDiagnostic: CO2PR01MB2200: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PqwNLb1VQHWBGzZJz9OfKgF5Ew0LNYdzRa3LSMQXUeoVmeFOfx+NAPh0CgVyj08s6/NnfBOxVRHf949jzhGyEC1PxYiHGEB6t4oi68oFcZ3F5cJzhRs81yFleZrZ1eB3cpaZqF4svAWcmrOAN4cIX4jEcookWjCoFUy2JpqZjbWAmqw4WBdABaJSbqawVzgGYLkZQL77/2DrzlWYyWhZvTc8r/O2BEofA3iC793X0tTY6ddr3VhDY2P4uqcEFK3nDxmVGfDyxXFdyZWFg3CZ8SOiA4rY0a2Zcd92y9K7GydM5vq10c37mmwGAO2e/ErHDkKJxKA2ajj/qN8+zkk1TaQa+4qKzcbfC+oW/mvZDWS33nndhYCMEvlCcGGUaMOkXF7R9lvE4HLXKB6DPoR9GaVLisuNbn4mbWjRpKwkIw95XgKoD63P3vabx80WzD7G6/LrwyMIk4QecWNtWig3pG8DcTFcOIUbOpirdyfH7cCwDjgk7BugyYxvxu5GBIHtrCuf2dVGkKHHGM1jO0NaWwVKr+8hE1Wukj0w+aP1CLdFB2PN0+SyLGeagYNz0hXggWv1g/6MUZmZtMEzKmWaoXhLx8HKvn1cxMFd9YbfaFNjHjXsctkHF/6XdSe+GUORfHtuLZdDL+MSM3ceStXojvxtERjzcMfu3yy27y+g7cND+KmmqDsJ1sQCTXAsUjoHyeWVnKDYUHN1OKvUSFND7nqPrGTfTEz/eW6YzLxl5XVKsffQm57OIpqnOn/87xw3J3aACUsxvXy3leGK78YvwiGjIkNdN/Jg5F/oSEN7Nzw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW2PR0102MB3482.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(396003)(366004)(346002)(376002)(136003)(66946007)(956004)(1076003)(186003)(16526019)(921005)(2616005)(38100700002)(38350700002)(6512007)(5660300002)(7416002)(83380400001)(8676002)(2906002)(6506007)(107886003)(4326008)(110136005)(54906003)(26005)(6666004)(6486002)(478600001)(52116002)(966005)(8936002)(86362001)(316002)(66476007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PZtlynXgUlcbgq+bxkQECUP0m4/3l6s0ukGkkFzTug9NdKMlu5Ed81+wUa0iGEuFMWOyu134xa/ghSL+qkDVvOOjXPCSAVL7by7Md3Y+AE1BK5jAd1B7EkfKs0Id5xK1z+MYui1gzef2cEjB6llmdHArD8qrsyJoUxkWqZdSu7RNH0FZNei+rfBTuTNB+ZdWsWiB21VB3IGOUGj01Hm/oQa5GeeSVJiVEpFippGyygHSMphVcm9qEsQEVZFR7nMe/IZEW7PlysAhuwtKQ1prulROiZkuFFkfxJP4spf9S2hP9NJfGFn/byalE7l0VOJIeCsBQ5ko7PZlU/gHweuyPxGvurN6O7YMXxdml6y62k3rA8325FTnWrVByB1AH3U/6jeNpne1oYUEwaPiAmqSPqg+BrZrbqcTMt5y/RqeULTyv4JTl/L7Y+Zd/rNKFOuHbAyJCPDXuy2IdtA2Xv93K2KFbdLhJhICeJeoiE/gUoxl1N0mAzwd6rJJqUDI073dV5dnRm8XUiWBkn6tjXOzanpyDMBDp4125BCqmDTxaSrOhMHC3OT7cAtUw9C+riDIszFkdy3Ecm5DLrgrz9YHr4zqen570uHwuK15VXTKFc40zknruw9S72wJ4OzEwh8PIfrc7RvSgjb/20loTS/6udAI3wkC7QVaZfLJzF5GVr/1NEIKBe/spOdACRnQtlvCZAk8cf7e0DoI3APHvaPQmOsO3f52YGUyqkcd0HMKqGama5SF67hnqb3Gi3xSNLdEYl0pWmuoPBjOVb5xFMsX7F2LEavtjSCT+GEXDL/8vHbVhTTaQggKPiNvrV3j7g8y3zVZ5Cp1yHzjsj+6vFdieYnJSjWbkMRAsesdAhi7pZ4HyTifa1idrB+BgSkdRl1N3/miD4qceokqCyZZ3Cn19eWKEK0iNAvMwDqABRhmKp05ysHlm2IdkZNVXn0Hc/xAaI2GAsBX7PZiM9WMWjs7RtG52sjvAxnuSV2chYckzweh2pz2DleOmXbASDtFtf0v26vHATc+hS9rkxnkGUbHd9OEUwKeNOkknMhyPg/WTbaccxjOLAF+/IZkoYUrYiHeI2Fi0213Y2OPQL1cb1abDADlkbxs7hFq+aEOCBBGpNmtynokfx12XzwQrXTGWpW5BBZN6OwQJ0yK1YUc3I4Tze4L8ZNW8fAQyyGSSlCpV1UidjxASZXRvXglOEbGRCYckVqXypAU+JC8f/GbjVkt0aA3HIs0WBDmkPfl6uHIbNbNjTS5E8HUlxcJm0Xloy8p3j9XLkZ/ll9qDtahbSJ90eWE+9SsoYVO7bdlQ3p2eqFzVyb/r8CF4o8Wa6gc+xzq X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b9b62b8-f427-4ff0-db3a-08d930746447 X-MS-Exchange-CrossTenant-AuthSource: MW2PR0102MB3482.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 03:11:11.2192 (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: W9q9KKdJTR42CsC0jJZgDNVpXm7jWoLbRxsrcS6bB3cOCFCBt9bgPJmVcbAvNPfFNckrqgqZYE4FWkmWqH1oeiYlMUTu/vhssoLA5f/Unno= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR01MB2200 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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://lkml.org/lkml/2021/5/19/205 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 3fb37c3f23d4..0f82b46866a8 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -606,8 +606,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; @@ -652,12 +653,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; }