Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4433459rdh; Wed, 29 Nov 2023 01:04:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQtPB1VCmE7AK/sMMDmRknl7TfZPt/eolSoJwbSlPiHOXRaupbgooJ/VPo2Ed/1ijuLzYl X-Received: by 2002:a05:6808:1645:b0:3b5:84b0:6be0 with SMTP id az5-20020a056808164500b003b584b06be0mr21167492oib.47.1701248650977; Wed, 29 Nov 2023 01:04:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701248650; cv=pass; d=google.com; s=arc-20160816; b=S01h5FLUcWaekW6PCWpfLPHjJpcvWKEIdzqNxK7WvjhPz0g4yOJKBmG8d1qsPO7o4J QDne3mFx9IbSEqIbojkWUxlyTR2/GrMXff5OQ5gKbp8y7s9gkDLgRxiRFLEkMXtLIv4b VTwUWZ886fszZshcRJAcjjujN+kDtUoSkKtZCHlamCzpEjOvmD5qQ2k+Hof9Qfa0VMSL Pb82KbboiigKNZSka5iq6TKnzp+140Dk2pIPly4CHmHjse5BxQqAB4nnbWWhjAdHA5VW 4dtKF3t3ZZBI88GG5ZpvF89d0htapCEx+rbZNUI9TTuqEV/kHOwnwvA1BzT0sTyu9P50 4A+g== 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=Wygqq8z/0CPcEr74FEEBcCeOJA4WpDMNXwBxwonyepE=; fh=yJZOZD7aiBFw4ig/RBNVIxk/Q/EMSnX+j62jGsqzG5g=; b=vmmKr6rKjVQhUDkmck+HILr5dC7hMPU0F4qjFCPiSL54X7jpAl7JFRTxpehqpxfR3N +Hj75OORaCiMjEgV02N9bLfleweIWUJkrkiZDyW3yMqek/uFmXvkG1fRePcoxrdbTpwy Xg6w5DDXyRNfFNFK2C+vTcJZi5FLqW7c3KmFeS7Yt1BGc3CntX5M418SEFWP/tYT2ay6 XoZvtoxhu6+k0k9iEnYlBQjYyIBv9Yq3vXxADV/Y0VRVzWHOihkRkd/g3eLq9buTEQNK B1Yf/hZ3hg5J42znup2S0tGrWjjQEGQ94dAmvV3ViLvL8ybKydagIPGcKO4+aDefwmEC bPJw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=kzl9nXNy; 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.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h1-20020a63c001000000b005b96c2ab110si13888878pgg.131.2023.11.29.01.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:04:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=kzl9nXNy; 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.37 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 snail.vger.email (Postfix) with ESMTP id BC04380C65C4; Wed, 29 Nov 2023 01:04:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232114AbjK2JD5 (ORCPT + 99 others); Wed, 29 Nov 2023 04:03:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjK2JD4 (ORCPT ); Wed, 29 Nov 2023 04:03:56 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2106.outbound.protection.outlook.com [40.107.243.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD7D5F5; Wed, 29 Nov 2023 01:04:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XINBO/T5/DLu/m8QBNd+YDMtvdQX09VPhl3XAwdZ72ajhOM48vW0FbLiFWVAgpU++BCCGE5LjqNHU9BM7amK3Q6piGi7py7adxsilo3s0GPhgxtQ23lrWKiEhXM3Z75uBihqh9U8kLF0kxnm1BVAvKlKVHQvd/2sh/bsL70zt7fOye+3ut7Ee9F3cN2+TyWhvf3lanyXvlROtNTd28SWVukv0B+KqccCTzt0+mqKJR9RsI/SRw2YxD6iAaL0DyIf35r7JDqaOqIDhe/0HQm0st28zFNEJpfFIgGMW1xKJ8c0asIwzkCsIl5J6qKANKfKzZjvjKlExKco+T2zA2HLiw== 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=Wygqq8z/0CPcEr74FEEBcCeOJA4WpDMNXwBxwonyepE=; b=mC9LMinfF+KAfRIPrCm5PskG5tf53KqxkCdZSBtCg4IBwC35XIqI2fPSqTmWUNwux8oQmdBjCB66M7GdCfwcsal8n0BZNIAMY03Wfsg7ajdrVbx16E1J0NsA+5dE6NnjP46cFTIu+wA4gMsPwpJxF8cf6zhCWals0gXejCJNC6FG2MsccyA7Epa/1yU3pr+VkVX0SDp2CAVqaU0Ew5nUulPiqKdY83tBVjRiySSZXh6blEJw6OnJQqob1tR2X8/tFWaruvsifF+x2cpEnatCl6sLeAeYDUE3Q2Z22NI8TgHpRD3LyQ/gU65Thp2EvfuiiyeOtZ1CHaPDKs306Glktg== 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=Wygqq8z/0CPcEr74FEEBcCeOJA4WpDMNXwBxwonyepE=; b=kzl9nXNyVTdwnA6NOllQ3NbVC2xpXc3tU48ZYAc1wQYJKWLQSMvcUNlxRC+WpvEgaoEg7LqM0laEMDCaR2YJRZo93nTen0oaou0xRTiITSvMnpRiCKk0I0lp7vRNrcgMQ8kllLaJtYZVya+oezruVn31fuyjZZ4X/PPUcb/SqCg= 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 SJ0PR01MB6302.prod.exchangelabs.com (2603:10b6:a03:299::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.29; Wed, 29 Nov 2023 09:03:59 +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; Wed, 29 Nov 2023 09:03:59 +0000 Message-ID: <99dff4f2-cfe1-4a3d-a10b-313b9e7a29b3@os.amperecomputing.com> Date: Wed, 29 Nov 2023 16:03:53 +0700 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 RESEND 1/2] i2c: aspeed: Fix unhandled Tx done with NAK Content-Language: en-CA To: Andrew Jeffery , Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , Andi Shyti , 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: <20231128075236.2724038-1-quan@os.amperecomputing.com> <20231128075236.2724038-2-quan@os.amperecomputing.com> <4a9fe86f0349106adaa4e0c04c5839bab631f26c.camel@codeconstruct.com.au> From: Quan Nguyen In-Reply-To: <4a9fe86f0349106adaa4e0c04c5839bab631f26c.camel@codeconstruct.com.au> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI1PR02CA0017.apcprd02.prod.outlook.com (2603:1096:4:1f4::10) To SN4PR01MB7455.prod.exchangelabs.com (2603:10b6:806:202::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR01MB7455:EE_|SJ0PR01MB6302:EE_ X-MS-Office365-Filtering-Correlation-Id: ea4f85f8-ce31-4754-d044-08dbf0ba1ff0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MnhrG+PCrdXXneQq9zp0j9zewhKPgeg1QEtdXjcPNkXqc94iFFBORF9FQRBNcSri+i1xV0a1rtBTz3zUUJ6JjQ+yy68grhetHp2JYIXARIOMSJmmD+AhCOYLiqQxOcdF3e44WZDl5xw3dKGimpDA9fz6L84LNnSSGB6wYJ5Fd0SiXaW0L6KcLptwkFmSlJ6vV76zcgHp/fOflyYGkuWMr5EgAUVM8T6MVezuY0vcTWOXb4DL9G8sSvRsB4btJpnQm74XMOZLKIRnvTayyYmHHzgavK+BlJvs7FQUJ9hVYclKaIbbPAXsMgBMrC44KnvNikNOMS/100HnKvT5w7N2EO6ZwkVQx0B37ovAyiVUxWf2L4v1tnDvhCrHSYLu8OrnZxPADhHbXQz9LckAZbio4eHXHjKS5Vr5+K2UJnYeiiyhhzi59uLjG7x9FN7Am94U7CTCyMdVwCmu62sms9mxM7KeHDcAbd1GJ1KEhYkdl4kJxGYiCWogWKirA12q7AVe87HbmH4twKrpiUm4c3mv2DO0qgcuicgN/qIH5SdzGmp/t5DXdk7f0WwJogk31X7fp1WiVMqsrhfi9+eS2K+TtQMA5nR9HZQ/J2FDWu5VhElXyVp8sOL+YHY0k62YibJD 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)(376002)(366004)(39850400004)(396003)(346002)(136003)(230922051799003)(64100799003)(451199024)(186009)(1800799012)(41300700001)(83380400001)(921008)(316002)(6512007)(66556008)(66946007)(54906003)(478600001)(66476007)(6506007)(6666004)(31696002)(107886003)(53546011)(5660300002)(6486002)(7416002)(966005)(2906002)(86362001)(26005)(110136005)(4001150100001)(8936002)(8676002)(4326008)(2616005)(31686004)(38100700002)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?b0svbXNvTXczaDlDMVpjUVZSNjdFcUh5ZVJXUEd6Z1AzdHdtYXRQbDZKOSs4?= =?utf-8?B?Q0ZMaWFsSTJwNzFKMnM4T2k3Z2h6ZnZpcFdRb2JYRjhOWEFwOTZPK2ZSWk5s?= =?utf-8?B?T1FGa280OGtrRmNJM1hGa09XUDdYdCtnbVFvST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zBYOG9jU2lrY0NkUU56bEs1VEp1N0JqVm1NakFFelgrbDdZRk5DRFE2RWo5?= =?utf-8?B?OFk4dEV4WXhpck5TZVRvRkNtZjFQbDRhdDFmNEpKWE5aRUU5c2Z3K0ZpK2tI?= =?utf-8?B?QzdmR1V6VzRlS3lmNzR2L21QZ2IrOVE4N1lnU216bUFOcDlmZ2swOWtHb1kz?= =?utf-8?B?ekUwWTl1YnMvVzFHR3RQbkI0RXQzZHBWalZ0RHQwY1BzL1hOTGlHMnRoWldo?= =?utf-8?Q?DNvZETRKSgqjASWGe73Er1g=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea4f85f8-ce31-4754-d044-08dbf0ba1ff0 X-MS-Exchange-CrossTenant-AuthSource: SN4PR01MB7455.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 09:03:59.4725 (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: eLUzdXXcjMg27yui4oFrJoCJ2fPnXeiserFz3GjZQT4vyNsJydAtTtIBJTTBNK5QJjoMtCROzEytyKvjUQky7yZID6ywuNjv8pFGDCDuHAs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6302 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:04:10 -0800 (PST) On 29/11/2023 07:19, Andrew Jeffery wrote: > On Tue, 2023-11-28 at 14:52 +0700, Quan Nguyen wrote: >> 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); >> + } > > So we're already (partially) processing this a bit later on line 287: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/busses/i2c-aspeed.c?h=v6.7-rc3#n287 > Thanks Andrew for the review. I think it's worth noting that the byte mode is used in this case. About the code you mentioned, it is for the general process of single Slave transmission with NAK which should be interpret as I2C_SLAVE_STOP event. In this case, there is a mix of Slave events: + I2C_SLAVE_STOP (due to INTR_TX_NAK, BIT(1) of previous transaction) + Followed by I2C_SLAVE_[READ|WRITE]_REQUESTED (due to INTR_SLAVE_MATCH and INTR_RX_DONE, BIT(7) and BIT(2), of next transaction) That is the reason we need to emit the I2C_SLAVE_STOP first for Slave backend to process. > From the description of the problem in the commit message it sounds > like the ordering of the interrupt processing is incorrect. Yes, this is correct as per my explanation above. Prior to > this patch we have the following abstract ordering of interrupt > processing: > > 1. Process ASPEED_I2CD_INTR_SLAVE_MATCH > 2. Process ASPEED_I2CD_INTR_TX_NAK when in ASPEED_I2C_SLAVE_READ_PROCESSED > From my test, the flow is as below: 1. Process ASPEED_I2CD_INTR_SLAVE_MATCH, slave_state is set to ASPEED_I2C_SLAVE_START 2. As there is INTR_RX_DONE and slave_state is ASPEED_I2C_SLAVE_START, depends on the data received, the slave_state moves to either ASPEED_I2C_SLAVE_[READ|WRITE]_REQUESTED. 3. When reach to the if statement to process INTR_TX_NAK, slave_state is already moves to either ASPEED_I2C_SLAVE_[READ|WRITE]_REQUESTED, not in ASPEED_I2C_SLAVE_READ_PROCESSED anymore. This eventually evaluate as false and the if statement is bypass. IOW, this INTR_TX_NAK is not process. > With this patch we have: > > 1. If ASPEED_I2CD_INTR_SLAVE_MATCH then process ASPEED_I2CD_INTR_TX_NAK when in ASPEED_I2C_SLAVE_READ_PROCESSED > 2. Process ASPEED_I2CD_INTR_SLAVE_MATCH > 3. Process ASPEED_I2CD_INTR_TX_NAK when in ASPEED_I2C_SLAVE_READ_PROCESSED > With this patch: 0. The I2C_SLAVE_STOP is emitted to backend Slave driver first to complete the previous transaction. And let the rest process as before this patch. 1. Process ASPEED_I2CD_INTR_SLAVE_MATCH, slave_state is set to ASPEED_I2C_SLAVE_START 2. As there is INTR_RX_DONE and slave_state is ASPEED_I2C_SLAVE_START, depends on the data received, the slave_state moves to either ASPEED_I2C_SLAVE_[READ|WRITE]_REQUESTED. 3. When reach to the if statement to process INTR_TX_NAK, slave_state is already moves to either ASPEED_I2C_SLAVE_[READ|WRITE]_REQUESTED, not in ASPEED_I2C_SLAVE_READ_PROCESSED anymore. This eventually evaluated as false and the if statement is bypass. IOW, this INTR_TX_NAK is not process. > That feels a bit complex and redundant. What I think we can have is: > > 1. Process ASPEED_I2CD_INTR_TX_NAK when in ASPEED_I2C_SLAVE_READ_PROCESSED > 1. Process ASPEED_I2CD_INTR_SLAVE_MATCH > > Moving back from the abstract to the concrete, implementing what I > believe we need would look something like this patch: > > diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c > index 28e2a5fc4528..98dd0f35c9d3 100644 > --- a/drivers/i2c/busses/i2c-aspeed.c > +++ b/drivers/i2c/busses/i2c-aspeed.c > @@ -251,6 +251,14 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) > > command = readl(bus->base + ASPEED_I2C_CMD_REG); > > + /* Complete any active read */ > + 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); > + bus->slave_state = ASPEED_I2C_SLAVE_STOP; > + } > + It is not confirmed through test yet but I'm afraid the switch case part will emit another I2C_SLAVE_STOP event in case there is no mix of interrupts. > /* Slave was requested, restart state machine. */ > if (irq_status & ASPEED_I2CD_INTR_SLAVE_MATCH) { > irq_handled |= ASPEED_I2CD_INTR_SLAVE_MATCH; > @@ -284,11 +292,6 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) > irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP; > bus->slave_state = ASPEED_I2C_SLAVE_STOP; > } > - if (irq_status & ASPEED_I2CD_INTR_TX_NAK && > - bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { > - irq_handled |= ASPEED_I2CD_INTR_TX_NAK; > - bus->slave_state = ASPEED_I2C_SLAVE_STOP; > - } > > switch (bus->slave_state) { > case ASPEED_I2C_SLAVE_READ_REQUESTED: > > Thoughts? I haven't tested it, it's just something to throw darts at. > > Andrew >