From patchwork Thu Sep 29 08:03:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 610692 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE9BFC6FA82 for ; Thu, 29 Sep 2022 08:04:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235370AbiI2IE0 (ORCPT ); Thu, 29 Sep 2022 04:04:26 -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> 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); D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GUcXaTzvVe1q5jF6kz+/ttgtFLHv4P0S6huSTpdtmDtdAwmb3ZfEv4lx8okUN49MvFEwG5mCkGGrvgMDWVQ0u35ukeX0Y2aA8cvv1PdUYYTNuhod/IsPEkFRKRepv5dCEF6cZx11nxJA+QYselLENjiZ7RCnFaTAxgsvheBceVFUnMxZEj8Vfb9nxfMHrNVTEqKOZkIPa/GScTcUwr0/ytvkig+0ytd01aNe26FnK2XdXhnjuLp1sCdGfgPQxNHas/cfLRyGRDMcQelXYKsZ4q8i8zXrco9dcQxHtPAjprKgTDxRcyuAwvMWKRh043udLNHh0rOHrY/f4N1/V92QRQNAaLHdXfrHaAzyKtqVWsgE/f0iRcxAw1WunVRxz5VjW872haBm9ZTXsLdDGgIgVtl7u3A7jBhT0vHaCHinBWQmc618ov7+A1SsO1CfoapOuIq+EBvQyPd5UHb9Nik7vyDV9jbd4Jg4dP7ktxcgkb/VYk7M0eCfuJD6weq90VpCJq88UTugp49FCOVMPZJr32ZL0VRU2VZ+v6OPnCwQoi3NwUqVfUlggRRnRhkzr/CeqFlEVn0ZP/fYRhlwb7wRYlG2ewl2n/gJExPPebE4Y0KT1mJyjg= 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 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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);