Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1806455rwb; Thu, 29 Sep 2022 02:28:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6X57xLYxyP38Y2uB2ievEnZv1aS6dNIm5D4QGH5W5vjEedWEA3spHUSoj8OhilMC75XLL1 X-Received: by 2002:aa7:d1c4:0:b0:456:c93c:5344 with SMTP id g4-20020aa7d1c4000000b00456c93c5344mr2372897edp.306.1664443681344; Thu, 29 Sep 2022 02:28:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664443681; cv=pass; d=google.com; s=arc-20160816; b=wEXBDRcbq3K+D1mMOiHw6Jnof09PiCagBkU946YNbmL9rXRuYeWYphyAfrq4Hh0G04 kRCkwnrSsyoIz8d7ocnJ5px4mepgVPyhsPmCxPic2mq5AHrrwy9eov4hD+ajDVYlB2Xr Np4ZggX8gcsFXnUjW+ig7rRIA9mSTzWf53zSsJOr+WjyYpkuWeAN2TKfOjVav9IcBsmv YL9FuYIDwm1h042jvp3W5H7YVbkfQhT9gzsu+jc9BAWJzNYSvfFotNEvqzfQM934Dn28 j/NQLl2KBaLeKs6nKcaMnCkVZOONYTkyzTZkfZHoHZ7+0g1Mn+w6cZtWgslGgPDAcQoK qqrA== 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=7QI35EmryoGoSqB1mpdelSOtphsBg4oGQO04/RFUkv0=; b=FB0qicOnRpxx6Sjkna21FpUMrsZUOkFItiWkqA1C1gG7kmtehf38egpMaOyaf2kXIN o5r1ILHyU4uD3Zi2Ru5SSuoafWFukk1gnTV5NL79pbjpq4cEYVq7sfabwTc18da/b+Z1 etf4eiaO4RlcwdeWgewP8c4sMzQSHNr9Bvtyz7LZo/tjI/I19er/fWHsafZ4JKR1dgu/ eK3dvQRnXbaf6nnkgqR8mRQrTxM8qUNapsK9blN/CbP7LHWfMxkDmQ1K+6M7N5qFsDm+ RpLt4uMZktHK1invrGCRRqJQ23fMn663W4CCpU2qL8RL0wkAS2dMUfUgwpoDzyVER/2g 6ZEw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=tFV3nTan; 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 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c15-20020aa7c98f000000b00457d6a92180si5500070edt.538.2022.09.29.02.27.36; Thu, 29 Sep 2022 02:28:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=tFV3nTan; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234630AbiI2IEa (ORCPT + 99 others); Thu, 29 Sep 2022 04:04:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235349AbiI2IEY (ORCPT ); Thu, 29 Sep 2022 04:04:24 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2131.outbound.protection.outlook.com [40.107.243.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EBA437FAF; Thu, 29 Sep 2022 01:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aojGLdVD/ySSx2Fw0FISos91TCDnz8TGjb39EuFH+h8EB9cDiX4dJVTLoIgpjYkeQ2rbtO4qU03wVOcWYRSyaIo0phk2GpnnQ4D5zuyxBDFLcKekXOlHtexduT+ouWgp73cToqVg8P7fgECoWeF4NKCyBRsfl1cELIeSVGVPZQZfGQ0Kf2BdoIxKwUdlXcrBwWh1BbdXj0U+RdoDoj/Mgu28XavzrzM7LOHJfrkJc+I3WlWeEjPlwX/YhCrwJwYs9JZg2uurASTiCycSdCLHf8MNLpwEhy3B0jlhLnH0rjEUA2AENg61sAuKxNB33KO/7T5A5OCCUYP6Egd1MSIz/Q== 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=7QI35EmryoGoSqB1mpdelSOtphsBg4oGQO04/RFUkv0=; b=PE38Gsqlrr0eVK8j2dVLq12qCa4DoiebumoVFBin8ROX0mxB+MsWZsXFnGm//A2f+5yZlfKYPunKp7ANwNQYyAbo0z1y07dX43GH37uVy9gvt3rfk7kzgbLmLDrbvZQo0PDF1r8AOmhBMh2mm9KEBoAFbpmPYAv3xYHgSvqZyosxin+Jmg21VfPmIbnqwGqGhNdPHmEFNH5ud0M4fW8hyr/m9vwjYEx3jKdlC6VoTudISNGHk5GT+dfWPG1zRJiD9zd/X9nR5KtSejaUCW1ymclkm8jI5W9q1lhvZiqw8rQycTo/6bemrmPEhSE3sC6WUGrPANT2WHM5Ghgwd4lUFg== 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=7QI35EmryoGoSqB1mpdelSOtphsBg4oGQO04/RFUkv0=; b=tFV3nTanQNJDprCjark/w7oQPu9V/4dh73LeUs25985Jur4ulGgiuvE+bXzopbprTxcS/fPhjSHt4MKZllOzqQYEpdjvdydPfA+DEd+YMAdrXNdYsIbx87pLspema0OokXiksfDhgQCOPBwKkgrgf21VxJsxbewKjIfIzC6BSGk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by LV2PR01MB7885.prod.exchangelabs.com (2603:10b6:408:17f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.15; Thu, 29 Sep 2022 08:04:08 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::7d50:e907:8e2e:1ff0]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::7d50:e907:8e2e:1ff0%3]) with mapi id 15.20.5676.017; Thu, 29 Sep 2022 08:04:08 +0000 From: Quan Nguyen To: Randy Dunlap , Wolfram Sang , Corey Minyard , Rob Herring , Krzysztof Kozlowski , Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , Andrew Jeffery , openipmi-developer@lists.sourceforge.net, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, Open Source Submission Cc: Phong Vo , thang@os.amperecomputing.com, Quan Nguyen Subject: [PATCH v9 3/3] i2c: aspeed: Assert NAK when slave is busy Date: Thu, 29 Sep 2022 15:03:26 +0700 Message-Id: <20220929080326.752907-4-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220929080326.752907-1-quan@os.amperecomputing.com> References: <20220929080326.752907-1-quan@os.amperecomputing.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2P153CA0002.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::16) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR01MB7282:EE_|LV2PR01MB7885:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d3a2bbf-9b77-43a6-b866-08daa1f12f21 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UW1JvqVEgtgZQPmksH8z/BjfdaN5QpQPdugsDmJsVi0Bdb1MCedABJBFwC5s/X3FlhcNHwpgORJN2FQvr/323qPb1xa0hwJwwvSsa7j8/iDEEhA43nineydNZ/2oh+ir/84zCbzuZ0CDP3mES4YtpL3IBtD5nXe+GjNbynx0Fq/FH2q4bkVMj9IigYKLQcYganN+p5+Jlo5cYfer/2taHRIKWohf5BEli4UVLuIdsHeHKVNUu5lnpEb3uA3oAznlZlz85uyKqGXk2qV4OWEZJmlkLolR+Ol4caLTmTsiun+U2hqn/dmpXLxedA9VGzG8p2a1kAA0eRiCVFAt3aXR07ildHJ+g4lMxIAbbit07WPm9cWZPaJWK/6PLA9OD4qbJvCeuG9FN5SvqvEX72egWf38CibwA5jDCuSqqRB2eKAJMpMhjU+QEY5rzFBr0QNMC4yUzj9uQH0TRntpFJzHi1OESdh5X3wCvkvATO6mRuAHdfrc7bNCmZimQJf33cMkl1tvUqjrtV/mRZ1eWp9DJAIKSZTDlx2H3W1Xalc210scryBWrUGhFdBmUb7GqeSfyR4Pgu2pw89aNCy2L1ZMXalPteqcEl2owcI9kuQyq/aDszyTEUlOyNxYg8v6Ol6dkpkiZqar+xeNodADdirNz9XCpNTK0Wl5ko+v+230uhF6d3iX3bQTNRVzKxbSUYOUJ+L6ny4oIwiAheVwQtMMi7tbQ7S8rsjz2UpSCawZMlgYx+syMenj1qHAxgwi5hh16CS7rB1jQNxNIj1MKkrtkxoaf4IEvpTEJ85zCYYWq00= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR01MB7282.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(346002)(376002)(136003)(39850400004)(396003)(451199015)(6666004)(107886003)(2906002)(8936002)(66476007)(26005)(6506007)(6512007)(66946007)(4326008)(86362001)(54906003)(7416002)(66556008)(5660300002)(38350700002)(38100700002)(110136005)(921005)(41300700001)(6486002)(316002)(478600001)(52116002)(8676002)(186003)(2616005)(1076003)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?I3xAM2ng10qs5iuCu8+l0sNkf265/sPTxKXGKS3p8Yh+SNr1I9PtkrQOT6Rx?= =?us-ascii?Q?CaE7/pkI6suONwY1zqOpKVSw8FztHlHEsr6qApQZkN1gSedEeaqYxgRbi1h8?= =?us-ascii?Q?TtGLA3W56M8U2Saire/TwioltqGFYcXQFjXe0AjFGuwUk2sdB5FLyS7QJYvJ?= =?us-ascii?Q?7Lj+8/VBnNMKpPsbXsyaufnoDSjvZBy43vFlYWpIB3g947y5yymP16QB9J9S?= =?us-ascii?Q?kmUGkWWI03wKRuXCTjqmWEArJ+PEeyszcckfXTcLpcS/Eqqr4FCzFFZyw3Vf?= =?us-ascii?Q?Q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ZEj8Vfb9?= =?us-ascii?Q?nxfMHrNVTEqKOZkIPa/GScTcUwr0/ytvkig+0ytd01aNe26FnK2XdXhnjuLp?= =?us-ascii?Q?1sCdGfgPQxNHas/cfLRyGRDMcQelXYKsZ4q8i8zXrco9dcQxHtPAjprKgTDx?= =?us-ascii?Q?RcyuAwvMWKRh043udLNHh0rOHrY/f4N1/V92QRQNAaLHdXfrHaAzyKtqVWsg?= =?us-ascii?Q?E/f0iRcxAw1WunVRxz5VjW872haBm9ZTXsLdDGgIgVtl7u3A7jBhT0vHaCHi?= =?us-ascii?Q?nBWQmc618ov7+A1SsO1CfoapOuIq+EBvQyPd5UHb9Nik7vyDV9jbd4Jg4dP7?= =?us-ascii?Q?ktxcgkb/VYk7M0eCfuJD6weq90VpCJq88UTugp49FCOVMPZJr32ZL0VRU2VZ?= =?us-ascii?Q?+v6OPnCwQoi3NwUqVfUlggRRnRhkzr/CeqFlEVn0ZP/fYRhlwb7wRYlG2ewl?= =?us-ascii?Q?2n/gJExPPebE4Y0KT1mJyjg=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d3a2bbf-9b77-43a6-b866-08daa1f12f21 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2022 08:04:07.9087 (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: lTYurY18aZlSlaf38HWKrI0i1TdHXImBAKW8mo14Vj5pFO87CUvgNw+ioUa+K26EQF7Aod7EPXON5MohbOCEReQNWmr24yl79h64pRfIoAs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR01MB7885 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS 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 On I2C_SLAVE_WRITE_REQUESTED event, Slave already ACK'ed on the address phase. But as the backend driver is busy and unable to process any request from Master, issue RxCmdLast for Slave to auto send NACK on next incoming byte. Signed-off-by: Quan Nguyen --- v9: + Update commit message and add comment to explain the effect of issuing RxCmdLast when Slave busy [Quan] v7 -> v8: + None v6: + New introduced in v6 [Quan] drivers/i2c/busses/i2c-aspeed.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 185dedfebbac..3d70f1ce6c6a 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -244,6 +244,7 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) u32 command, irq_handled = 0; struct i2c_client *slave = bus->slave; u8 value; + int ret; if (!slave) return 0; @@ -311,7 +312,13 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) break; case ASPEED_I2C_SLAVE_WRITE_REQUESTED: bus->slave_state = ASPEED_I2C_SLAVE_WRITE_RECEIVED; - i2c_slave_event(slave, I2C_SLAVE_WRITE_REQUESTED, &value); + ret = i2c_slave_event(slave, I2C_SLAVE_WRITE_REQUESTED, &value); + /* + * Slave ACK's on this address phase already but as the backend driver insists it + * is busy, turn on RxCmdLast for Slave to NACK on the next Rx byte. + */ + if (ret == -EBUSY) + writel(ASPEED_I2CD_M_S_RX_CMD_LAST, bus->base + ASPEED_I2C_CMD_REG); break; case ASPEED_I2C_SLAVE_WRITE_RECEIVED: i2c_slave_event(slave, I2C_SLAVE_WRITE_RECEIVED, &value); -- 2.35.1