Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp110733rdb; Wed, 29 Nov 2023 22:53:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IESD6/zNn0KWUhF/tQorIE4rC8KlkrV4545x9DkyN2uTIzeYg3u22Q3cn3sgIfY9JE6ymJB X-Received: by 2002:a17:902:6947:b0:1cf:c2dc:1c1c with SMTP id k7-20020a170902694700b001cfc2dc1c1cmr17621862plt.29.1701327231574; Wed, 29 Nov 2023 22:53:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701327231; cv=pass; d=google.com; s=arc-20160816; b=Fa9DGPBGuLkXNwLNniB+MDMshGRuxmv8iDwIR04aTn7aX+VAsCpoFzhiHYoMlo5mxv KmeKouC7w4jvXdGwY7xg0VmqrM2og4TTNonrslctmRNgupJYh5ZsE8cVzFWxzAY3WEkn 4kJFEZXxz6DnuMUO3J0dK9HcHwCmz49uhHysYFD53iEroeBXSQxLQONyrbVDUbV/Fmv5 EvWU6I1PArKUPnLqxbqk2KG+VLTJ3jhHfhJQvsJsI42P860E0r1VD1BAXHA+cKszW2Kk 3eYizt+aUFU/Fqtwv2SkDarXoSSv9f9iEgjnSKJ5wyfADKtiTn7wO7nZygPQU4nRR6ks Gfag== 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=QstX0oUovXITfXSNz2qRU0uKNbgkVM9/YaMS2McO0Tk=; fh=fDV2kHKRZyQJzGaB8rKZy+G5r76YYDkRhDRoC4GaaQI=; b=srBC0daiXRa+mU+CqLOHqAamG9BU8BH0W7jYK8StzxgI1owrK+Wg4NvOCnqZ3l5BO+ 4Md1rfEF2G6zdJ4QXlm8o7QeIAQIrAl9afVj2ZJCb4kw4EsSCrWkZuR+3iMF1FZ4WImv nmvWnN3IEyZ5MGw7/h22zyI6CpcDOLUrZV3uVn4lGCwAuN7mDQ0cOeW6ZaRlOX/kHU0H bZ9KHHaGf0X0S/5y/VbhiPhB++1ZoU6u+yoLjGn5zRHrBGKmKGQaM7OddyOtqz1k+QTH vF/x+7a4YzonbDplJxqYZ4vKM6hafhkcaVqXcfKXN8NvS0mqe8/z/U8h4Xt0aQleGUln SyCg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=RSSOOOIu; 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 m10-20020a170902db0a00b001cf8be14168si580942plx.552.2023.11.29.22.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 22:53:51 -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=RSSOOOIu; 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 B485081F393D; Wed, 29 Nov 2023 22:53:47 -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 S234962AbjK3Gx2 (ORCPT + 99 others); Thu, 30 Nov 2023 01:53:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbjK3GxZ (ORCPT ); Thu, 30 Nov 2023 01:53:25 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2127.outbound.protection.outlook.com [40.107.212.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 562A710E5; Wed, 29 Nov 2023 22:53:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZboDBgDocarYd8kjzoEglGh+qpBrzFvFS0YFZ4I3Tx+oOrHhZVz9hsWsVP24Axq7oNjXnDxn6/Q5Ac1mq0CzPuM3OF8ZC9h+UF2cT0PqBp8yrL71HFPQGJ7xfu1GE3tPQTZMzpYxBXe3Uid6UW2ezP9CbgiK9M6Zcdm/46VAYaHtmvz1EIzDi70JjTma674Cz7WcJTQuxEM3fUQUhY9Ja85hStPzzwKw5IK8sJYt5HZOH7aHHfWbde02yDiBG65IpAe2MtKQ3A0csoNqFkD2r1zIzGKilhsuX/Sf4LxucPInHzQIwuKvXo0YauhtcTIyHnKN59t2ypqfoDPzlwpNuA== 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=QstX0oUovXITfXSNz2qRU0uKNbgkVM9/YaMS2McO0Tk=; b=M8viMY4V0kEbCyh6KZ51FtgLAtFzmT7qSJZUCyKjMfqbvKgUu/ZAWxopfjvQV+Yp5RK/ZJZ7tSY8unQJ/z6ecleutRPmR00oHk+0pmPeQFyhVkRtw1o4f4iNOxCcFRVkEjaoA/kbYV+wROtFj0lX4UsPnSt7ujvsdPVMLrTT/S3r/hmfN2/ApWyxG7eDPCwHIzn/hWNQO6olB853Ts1MRvmoUN7Tfholz3y4FIQCtiR/LiiuBESS65dQZIW4ux69r6YPQKU6uTbSeLfdLMWlWJNHdmIaA8U/m+bdF+WpQZscD1ePY5JxvIBVQqKwG3nDTI0OTji91krZszNmbONfuw== 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=QstX0oUovXITfXSNz2qRU0uKNbgkVM9/YaMS2McO0Tk=; b=RSSOOOIuxjqfOPbDRiPpPx04lZy+5P2nbhp7BoPPUzEYZ4AgFfpfOTBE41Id0slslrKGjPEGZdKFeIjRZ9qz4B84YEuwAq/CwFa7JtApa0Yo7p9Zr9CZa9zrt7qS3ndOx/eUqhAr0VZCHtNsuCTr8/fqlerldSN798lBdzQBm10= 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 CH0PR01MB6953.prod.exchangelabs.com (2603:10b6:610:106::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.23; Thu, 30 Nov 2023 06:53:28 +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; Thu, 30 Nov 2023 06:53:27 +0000 Message-ID: <9ec9b363-0e70-496e-9083-6382a579a0bf@os.amperecomputing.com> Date: Thu, 30 Nov 2023 13:53:22 +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: Andi Shyti Cc: 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, 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> <20231129003542.jfhhotebweb3uwyb@zenone.zhora.eu> <3f37c359-1c71-421f-b7d9-054696735adc@os.amperecomputing.com> <20231129212552.3uy7oqm5fz5h2m6b@zenone.zhora.eu> From: Quan Nguyen In-Reply-To: <20231129212552.3uy7oqm5fz5h2m6b@zenone.zhora.eu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI1PR02CA0049.apcprd02.prod.outlook.com (2603:1096:4:1f5::18) To SN4PR01MB7455.prod.exchangelabs.com (2603:10b6:806:202::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN4PR01MB7455:EE_|CH0PR01MB6953:EE_ X-MS-Office365-Filtering-Correlation-Id: 38c66bf3-f305-4516-c85e-08dbf1710e5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jjlMxQwTKfhjVk/t6IlWRoV6BPysqrkJ3m+kl82KY3M1QRltfKcZbWSCup0QAgM07DOJGQ0YKBNNaIrkg35MVzckwysDB+SqT8Zamdg8kNrbKSELXmEN3OPuY3A3ogY0Rw3EXhpMJROxSttkkCcpiRh/eWpGiz52i3gvV/jg5DFQrakmUpa939KW7tU3UcPd0nUx/3OUQdormB2W6hZXqbfbeqQS/4yWbs931DoiwdsQP18nxMNYOg0aWAis9rzgqeIHvjnvW1lbKz/6IEkjfxvW/xpQwqueDBtn20kWPFECDnFMJEVhFXsD1s0KxfbYKOEDkPru2OpsB2ueYw/qlqMrEjIXGhmhajLqECXVvrahe8MaEWENRswMc4/Vjv9iHNGRNsG1lUbKHbp2Ull54YYmceykMusCY7ArhsvsXI2A6oBxh7aFfc21F1kgg0G0XLp4IJI9HYth+5SfHd4Wecch05OOFkWvu9CcOTDWmuY6jz5ojNA/nT8tUDuVv89GGk+SD6PgF+V9+L+Yls6t6jDOx9OWIe5JePoYsbeFMVfVPJqjifGzkVIbnvUvV6EbMqYbs8w5aRkiM2OP4iz7JXX20FuUemSfc5Y96Pag+4RXjqSV/qLPoJeJbM4WKDDj+o9KoEGD6UPbx6ghkH5qOA== 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)(39850400004)(376002)(346002)(396003)(366004)(136003)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(41300700001)(66946007)(66556008)(66476007)(54906003)(6916009)(31696002)(83380400001)(31686004)(4326008)(38100700002)(8676002)(478600001)(6486002)(966005)(2906002)(7416002)(5660300002)(316002)(8936002)(86362001)(202311291699003)(6666004)(6512007)(53546011)(6506007)(2616005)(107886003)(26005)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?S0M2Syt6dmVjMnp2RTY4MjJJM21UZWNiK280cGlHZ0dGK3ZpWDkybUI0UE5u?= =?utf-8?B?NzJ1c0MzZmk3TXdUZ1BSQXFRK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?= =?utf-8?B?ZElFeUg0Ujk3WkxDRHF2dnR1Y2VPRlBsWTZLQjZudlNkQ09meGRzODRNYjhp?= =?utf-8?B?TTV4OFFKNjBISjZrTW0xQzJnaDZ2QlU4djdIN2pIN3p6bWxEL240eGpXc0ph?= =?utf-8?B?WERieSt3ZnRXeFoxYzUyMXJIQUtFSWxXbWIxVXJKRkJWZmQ5L2E4Smd4UlhT?= =?utf-8?B?a1ZXVHQ4dnR0WUpFVzV4ZFVpdkNRYlpJbGZxeGNGSFRQeDRFR3dKdVpDTE5t?= =?utf-8?B?RXBkcFQxMEVFYXUwaUhCeTZwVVR3TldpNlpJWmV4Z0FWTWpnVjZjWVpnc08r?= =?utf-8?Q?uvf25l+VytdStmCi+dL5ods=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38c66bf3-f305-4516-c85e-08dbf1710e5b X-MS-Exchange-CrossTenant-AuthSource: SN4PR01MB7455.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2023 06:53:27.9022 (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: CCpFRDp+ZcgfmPH0Dq914T4AXqdI6Iz+MHhbAEWKGzIc7ZY/cldIampIk1tux/QD/SONwmDKp+qlY1V5TtONkOi0MOTUjFVvyIBZP85jejk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR01MB6953 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]); Wed, 29 Nov 2023 22:53:47 -0800 (PST) On 30/11/2023 04:25, Andi Shyti wrote: > Hi Quan, > >> On 29/11/2023 07:35, Andi Shyti wrote: >>> Hi Quan, >>> >>> On Tue, Nov 28, 2023 at 02:52:35PM +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); >>>> + } >>> >>> this is a duplicate of a later "if (...)" satement. What is the >>> need for having them both? >>> >> Thanks Andi for the review. >> >> I assumed the if statement you mentioned is here in [1]. If so, then that is >> not duplicate. >> >> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/busses/i2c-aspeed.c?h=v6.7-rc3#n287 >> >> >> The if statement is to process the case when Slave sending data to Master >> but being NAK, the I2C_SLAVE_STOP event will emit later in switch-case >> statement. But it is only for the case INTR_TX_NAK without INTR_SLAVE_MATCH. >> >> The new code is for the case of INTR_TX_NAK with INTR_SLAVE_MATCH. What it >> does is to detect if there is a mix of INTR_TX_NAK of previous i2c >> transaction and the start of new i2c transaction, indicate by >> INTR_SLAVE_MATCH which is only raised when Slave found its address matched >> on the first byte it received. If so, the new code will try to emit the >> I2C_SLAVE_STOP first to complete the previous transaction and process the >> rest as a new request. >> >> So if this was the case (with INTR_SLAVE_MATCH), the INTR_RX_DONE should >> always raise with INTR_SLAVE_MATCH because Slave did receive the data which >> matched with its Slave address. And this will be translated into either >> I2C_SLAVE_[READ|WRITE]_REQUESTED and that make the if statement you >> mentioned [1] evaluate to false and skip. >> >> So, in short, the new code is trying to handle the case of INTR_TX_NAK with >> INTR_SLAVE_MATCH first before let the rest process as normal. > > yes, I saw that, but wasn't it easier to do something like this: > > 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; > > if (irq_status & ASPEED_I2CD_INTR_SLAVE_MATCH) > i2c_slave_event(slave, I2C_SLAVE_STOP, &value); > > } > > But I see that Andrew has done some similar comment, also for > patch 2. You can answer both in the same mail, not to duplicate > the answer :-) > > We can wait for him to reply. > I think Andrew's idea to handle the STOP conditions prior is much better. Will test and post the next version ASAP. Thanks a lot for the review - Quan