From patchwork Fri May 31 16:33:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13681888 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF9CEC25B7E for ; Fri, 31 May 2024 16:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=gBeJX8bINx+KDW/tJ5VkCYeUBpPOinRpQvQuYSfGcJI=; b=HYmDeTBNblItQN NHH28G/YpJJ7sgaKfDJazQFyeQd9DZdm5o21jvqEzKCvK4MRjl0JL0Lu/7NsJhv1Vq3UMhmF7AKKL otwp1LorftnAiJcIaA95lwpCN/EeEGjZtwYYdp41CDW/F2ygBpZeZaqFUUvUHoGRaYrNHkUkxDkI7 2Ez1wX5lBZ9T5DEssW3xi1qbice5o+P0RofOac2dick3Zd7+5cb7NpYpwGKUjdLDbl7a7T/BVlm/A YIET365q7pRQ83PD38KKhXLKY8ZfitnANdHodCE47IRwTrK/v+GsN36o/XSzzOPbJKo7YSGESdtM2 Jmz9BuzRkD48M+VeFTGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD5C1-0000000ArPC-0VNd; Fri, 31 May 2024 16:33:25 +0000 Received: from mail-db3eur04on060f.outbound.protection.outlook.com ([2a01:111:f400:fe0c::60f] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD5By-0000000ArMh-17BX for linux-i3c@lists.infradead.org; Fri, 31 May 2024 16:33:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KnKoJOGFV/0n/0JMwI4d6v4o5SAEzD5XVFTpn8vuJ/NdjJbJE5/2mNHqk3SBALl08Hi64pNhayRy5NV3TqiByxLVhBo/H5t71KmICkihHQbwtLvemZNmJq0SXoXsuo91G4y9MA3xAXG7WrHRAzNKlLmnlm4oumvNwMvmmOtv5AtRfif5ez/ptoGDRsmOUC4/lSp49H71Mzm0eVaBnYu0IR1tlrPBYo7NvgvVyMfPsyC6hH6kxQPTaXpIZUwG+cwlx6X95bPNJJ1ThCXCSFc1MEASXoJAxUC2k9NnRTbTGFaM8hplZi7DCA9m7WEZP7TtzAKLSk3XSB4feaFhOwWAAQ== 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=CRJ/O0ryhVZY+/ZZv17Sbp7hjtMigMkBXC8btHCtd8M=; b=mvnmG6fvKn3muzHWUMVMOjuX1Bml9Zbu4+DH0/o6WE+wO8TGJNjXkGxXuXXX4Q2ehOJgrgHM+I1JcvFoSwbs3QPQWfstzwQFT4ykJFCwRoxVYaJdE7NYBdoc29QZUCUdVVoln6sqMRvoqlxKI9iWfu41aNijxZWJgzeOEfOFSWNUM19ysURgmciiqPjix+QO1AA7daSlDu66bqccPX+WC/jF2UmKpkZTdP1ctmcT9X/Ak+62oIE7KBj8xhhVe6GX1IAahQMwW1+St1Vy5MxXbgSMWVqVYcuaYZHypc4WL4+/jy2SAsuDwvC0AQaNz8hUk/fiM/qDh972o+cI9pr62g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CRJ/O0ryhVZY+/ZZv17Sbp7hjtMigMkBXC8btHCtd8M=; b=K8HkuLln799WXnZJUtxksZ6vhYZgD10fLo2+wPf5JX6VBXKe1clw+mUUO9qUSJdtnaNsrcbf7hTVSs0WIsU18eBrBcrwYh1CcByWSHCCqRn9s6U1nqKzx9hlZDNzR7Kz62MoDWN3eIuY8qS862iEaHrYUJFuwDGPM14VWLM+we4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by GVXPR04MB11066.eurprd04.prod.outlook.com (2603:10a6:150:224::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.27; Fri, 31 May 2024 16:33:19 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%2]) with mapi id 15.20.7633.018; Fri, 31 May 2024 16:33:18 +0000 From: Frank Li To: Miquel Raynal , Conor Culhane , Alexandre Belloni , linux-i3c@lists.infradead.org (moderated list:SILVACO I3C DUAL-ROLE MASTER), linux-kernel@vger.kernel.org (open list) Cc: imx@lists.linux.dev Subject: [PATCH 1/1] i3c: master: svc: resend target address when get NACK Date: Fri, 31 May 2024 12:33:00 -0400 Message-Id: <20240531163301.1401281-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR13CA0141.namprd13.prod.outlook.com (2603:10b6:a03:2c6::26) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|GVXPR04MB11066:EE_ X-MS-Office365-Filtering-Correlation-Id: 2080b874-9666-4995-cb5c-08dc818f6107 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|52116005|366007|38350700005; X-Microsoft-Antispam-Message-Info: iPI/iGSMWb/6LO89RXqrVjjd3PpHGrZP/hQZ15fBUNw2pyTm7R9ufSXiJFOpYBj+e2mS3N5jvIRGZpfQAKTUI+on0t5osUKlN++jpWfrTZnkCdxoMMLk5ri5ixfjA7yypNTFkVJuzmBZMR+cL7PAYDXPT+YNi/uKmbZAEa1PBSQQc1W4CQHPNoujv+flDW8oGoTfd17HOSMGxkzSjgPnwm8W6tU9M+6kY/F4RscjtGPLOKUYEWX39inQZaeibmHmbNOzlWS5iqgcGDA8p4KHqt4xihRtqbNfW7+LzgMOa3nWeI1nvew2d6FaB3rKsaz+Z0d6c23sF+0CBw8cv+ZWnrto84ZZknyESDmg+7jLUW3kWO5MFSaIrYT7c+4CmTI4FC2JewpvO1Z+81Uh5ePFa7NZFcJ6vvCf05epKLLhm1fdSKVq8YFrSWpM/61uishItQH8D23kR/oxEZMVqASXk6DPyj4rjKghyzBACSJoNUQNs3OyiJhE8Ick1QWdFksguKzplLbWA0f1Q139ufqn4PgQre5oa51HUIXVJodTG9hkFTVE+MOUz/w/afX+AD/eJdQ0cKqc10jWB4LadWGCFJahArC6xzIuBIgJTZcPNRkYX3V39ppd08yidGpbP3X9BJ++AEnfQoAhDiOlO4+L2EjOxZqIlQ4C8Z2pjAt6goCfpml0YqYcdFmNzk7QKIb864ev4lq7xVWEZFdUVFcPDtA0hpri7Y6SCe7IfPypDiFsz4iN/vxV+qOzk7gzRUWNlbPbdkNJQKtVwCIxXehlq0hUHvmUgsisNGX5qOy5/u5xCtDeALtLV267oZGzD3xFyNVpXASqbBJP19kgNHbGLj4qWVtUSei4qvrNHwX2Tbqx4TtaAOEu8ArVk+BJCq88xudaSroAzgit0lXLU6S+cLmCrxFbf3ZRRnC0mnD+jBxFmaZhFYa5pD7MlGFv4+UstVE+ID3cCYxSRWLHrnWq5PsgRO9YT8OzAwv1PN+7IKEjDPUZLq/H5ayw21YzuxZAomBvTkwDKDwsutjB472ecS2pK+v/f2LP2wPou0HAWW9hUyQ6zrrW1Ng9m6OvgO3QpDGcZ9vkRa3rluyq9KSet/JOE1rISKkQc15vpcJw2IMKzaTheLS4lo6/lIlzttWe6L+y8gW6pAxe3YFn4JLeGDOYyG7GBu38GfPmDDOdQBJgPSaMEh/gwAMNCCu31BmKTx2/KESBIE2ObJWAkXc6oV8Mz76LfXRGJj715avcZl7Nyf2Qm5eAdEkWOmevxtf8evA6a6Rp3y1ZuP7Kwz1qXwsOzGMhCKeX24G8w39GK5GABMuHl5bW7PimrwFfQQ24YUAerbpwYSdAMO837mMI+w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(52116005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 40eMn6Z3wgddlja0rbc2FjygJcnBGapQqutZVFwbHL6DH3tMAhaChlB0tzNU2LV/fGDWtziVjmPjJ5ciqEodRdoqvgR3jzT7v3pW1JQPIdrwgtYjxB5o+MY8bdpQBuBtX60IR6Dit+6mDPrJSbpN0/VvkFxKeXCtNymgA6YkOcHRW9XFSW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ZKboA0n/N7rhVD9AEKTkBm1O+akc/t3lodz6hhPCz7uZZhueVcfeWQUgthCaR514QI7b5KkTEPR9TymWJfnmjGck/3xs2ptjHLDWMHU+hwfZ5A3gaUc/9KEoz+1J5QUVT+fzX/4mRXOcG5UMB20Zb48iDikbYvFxPlXVgoChCLvBrJJxfbHVKLsiu1kJoukCZaIPFZy/FqR2/R4uPhnsBd7mCGNm06J188KD0/42hEPPE2sriDrR/NIZQPjXVb3uv++D550JSPJcyHQmZzO/dIIN5JVfnkJiEA1deIDq77tsQTSB23HROOLMO1GnBsGKGfF1A18X6y2Xc01HkhVtADFsD2Jk X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2080b874-9666-4995-cb5c-08dc818f6107 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2024 16:33:18.9149 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NpaTI5/Hq2fB2reXMJTTbk+GtnMeLNJXlqa+VsSxFk1gEdP1cSvJD3O6f2aX3GZAeE6bFyOV55S1cRyypIC6Sg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB11066 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240531_093322_362297_40C94CAF X-CRM114-Status: GOOD ( 15.43 ) X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org According to I3C Spec 1.1.1, 11-Jun-2021, section: 5.1.2.2.3: If the Controller chooses to start an I3C Message with an I3C Dynamic Address, then special provisions shall be made because that same I3C Target may be initiating an IBI or a Controller Role Request. So, one of three things may happen: (skip 1, 2) 3. The Addresses match and the RnW bits also match, and so neither Controller nor Target will ACK since both are expecting the other side to provide ACK. As a result, each side might think it had "won" arbitration, but neither side would continue, as each would subsequently see that the other did not provide ACK. ... For either value of RnW: Due to the NACK, the Controller shall defer the Private Write or Private Read, and should typically transmit the Target ^^^^^^^^^^^^^^^^^^^ Address again after a Repeated START (i.e., the next one or any one prior ^^^^^^^^^^^^^ to a STOP in the Frame). Since the Address Header following a Repeated START is not arbitrated, the Controller will always win (see Section 5.1.2.2.4). Resend target address again if address is not 7E and controller get NACK. Signed-off-by: Frank Li Reviewed-by: Miquel Raynal --- drivers/i3c/master/svc-i3c-master.c | 58 ++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 032fe032ec433..0b588ed5894ea 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1052,29 +1052,59 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, u8 *in, const u8 *out, unsigned int xfer_len, unsigned int *actual_len, bool continued) { + int retry = 2; u32 reg; int ret; /* clean SVC_I3C_MINT_IBIWON w1c bits */ writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); - writel(SVC_I3C_MCTRL_REQUEST_START_ADDR | - xfer_type | - SVC_I3C_MCTRL_IBIRESP_NACK | - SVC_I3C_MCTRL_DIR(rnw) | - SVC_I3C_MCTRL_ADDR(addr) | - SVC_I3C_MCTRL_RDTERM(*actual_len), - master->regs + SVC_I3C_MCTRL); - ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, + while (retry--) { + writel(SVC_I3C_MCTRL_REQUEST_START_ADDR | + xfer_type | + SVC_I3C_MCTRL_IBIRESP_NACK | + SVC_I3C_MCTRL_DIR(rnw) | + SVC_I3C_MCTRL_ADDR(addr) | + SVC_I3C_MCTRL_RDTERM(*actual_len), + master->regs + SVC_I3C_MCTRL); + + ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, SVC_I3C_MSTATUS_MCTRLDONE(reg), 0, 1000); - if (ret) - goto emit_stop; + if (ret) + goto emit_stop; - if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) { - ret = -ENXIO; - *actual_len = 0; - goto emit_stop; + if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) { + /* + * According to I3C Spec 1.1.1, 11-Jun-2021, section: 5.1.2.2.3. + * If the Controller chooses to start an I3C Message with an I3C Dynamic + * Address, then special provisions shall be made because that same I3C + * Target may be initiating an IBI or a Controller Role Request. So, one of + * three things may happen: (skip 1, 2) + * + * 3. The Addresses match and the RnW bits also match, and so neither + * Controller nor Target will ACK since both are expecting the other side to + * provide ACK. As a result, each side might think it had "won" arbitration, + * but neither side would continue, as each would subsequently see that the + * other did not provide ACK. + * ... + * For either value of RnW: Due to the NACK, the Controller shall defer the + * Private Write or Private Read, and should typically transmit the Target + * Address again after a Repeated START (i.e., the next one or any one prior + * to a STOP in the Frame). Since the Address Header following a Repeated + * START is not arbitrated, the Controller will always win (see Section + * 5.1.2.2.4). + */ + if (retry && addr != 0x7e) { + writel(SVC_I3C_MERRWARN_NACK, master->regs + SVC_I3C_MERRWARN); + } else { + ret = -ENXIO; + *actual_len = 0; + goto emit_stop; + } + } else { + break; + } } /*