From patchwork Thu Aug 29 21:13:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783892 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011045.outbound.protection.outlook.com [52.101.65.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E88B189F5A for ; Thu, 29 Aug 2024 21:14:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966094; cv=fail; b=NOg4gVW2qLlYeI9GQt7ETRkgkrKVJvIEzF6X0Xh/MLoh75URR3eXfERu1ccmCuT0pBlKkALTtGh4qmQ8lhF6H1FOnOsOQB9ZoqljXgtWUZ65RKJgRnlFIteeEeONh7G6KDaNTAvlWTQ96QdzvtoSVGgKVVGOU3cPvecQMbaHfJ8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966094; c=relaxed/simple; bh=f1WC+vskhA3R8JbdDiScsOFGTy5BtQ/6Qqg3RFmi3zw=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=MEC/dNUu4prA9mHuPGrDgj/9rV2Gh8qgewoMZSm/xGrY4MZ4tc4TmifLXYJC6VC/iKIARKwRer31NMNoX+u5MMM/pmEcSW3D89BsInPV3Ka10GuNYBAHhQDtt0br0IlttoF5cgW4uugJPv9QDo/JaYRr1HwPbTOh8irWGymMqVk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=LeROZesu; arc=fail smtp.client-ip=52.101.65.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="LeROZesu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ERW9fo1YvgNIJyOrAbcuAIHX16Bz1v4Fx3dEuzFCSnjWe7V7umyzEpMgb/h94RwDZICDyzviv3cBzI46MHPclRz7ha+SL+LCmljnev9hzfzEluVgRK4daSbg17bo4YkDByG9/sKUiGLl6TE3CvV2CD7vnX+3wRhFjDs+MRFmIyRvgEPv9gAQtpZb93Yqu/rWLgjO8782MtwFwUwJFdhrR5rN5HeDi89RnKOhG+e63gsbCZf3fCFhpfRnKVlnBIwbXGcrvnHPb617pIXx33EgQs5wTwYEqj9Ko41oJJruWa988s7/6BlIP62Ek2yHUTgtXKhYK3Em8kq6VJHsvDtg2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wsacC2sM6vudLiEelzwlwh0ehUTpf5ImMKYhC7eTeKY=; b=NfPwFdKrdIGLj6nf1TAo6smVCjYzLB0bw9iBxSu1EKiQRS+j4JP/tEaIfK3jvsWGU0iltvpnni2rokpakUz0qdZcSfIpnHBQkeWoMgr0xsk2/yFjG++TlTeiPRSOBrRoGDy4yXsR/x0bWlIZwevANxw8p7eu9GxHjJYQsA1vo5w2MuPyNBon2lzc6KdNUIw58palx7nzQAGWWso0pxhSa2nG2vUsbIyQwgOBQdjP5FpywgaFA2SYzQtWm+cF81GxJgXrLkwCDDB1LNhw8jVb+Mh0Z4+i8Nvhiu8ZrMhsaSLCGr3iHxinEFqaZlz07QJDCJNikMxVVcsEl7yi5+nE3A== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wsacC2sM6vudLiEelzwlwh0ehUTpf5ImMKYhC7eTeKY=; b=LeROZesu+wfpI+EgPjDaKIqhQ91aMrKCTbt91YlCejRnWqA/uqBRyNAt84DtawzfH2Sg0l0FQzvAzxPdutnax0NYhwFlSPqvnayEBgq6+ttlDebhvOr7RNa4njEv5lwXF9//moAs+DRCWCjBcd9kW1Uq60zlJIcK8Y/1/ZEiqhmNL2Nzw8Kboq/ZToS0zcBaIvhkRuSM7HVK5pivbWYckFOcNzslLYV2oxWiM8oC6WlAsKfsjODBJkZkQJ7Y0Hvnd7IQmzetAzl0WkuStVUSaUO72vdEWWEJEDneyNbjZUnOxGiDOh4UhIP3+tK7EEXN8Cxo5ulDC6oB5QbbQoLRhw== 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 AS8PR04MB7560.eurprd04.prod.outlook.com (2603:10a6:20b:29d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.28; Thu, 29 Aug 2024 21:14:49 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 21:14:49 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:13:58 -0400 Subject: [PATCH v4 01/11] i3c: master: Remove i3c_dev_disable_ibi_locked(olddev) on device hotjoin Message-Id: <20240829-i3c_fix-v4-1-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li , Ravindra Yashvant Shinde X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724966082; l=2753; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=f1WC+vskhA3R8JbdDiScsOFGTy5BtQ/6Qqg3RFmi3zw=; b=J8nMUXgzeslqh5WmJsxxzz0j288LGN5mX+W+tUM/6Crkahe2aycbREfYoE999yFKM+ZxRWOJS yyUmraSHnwCB74PaugzE5z61iE8pBeVIPdBkadPeKBNar0PvXSMUWMs X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB7560:EE_ X-MS-Office365-Filtering-Correlation-Id: d4796f60-dc79-4915-2e1c-08dcc86f9df1 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?G8fKwGtdaxzc0d0UaPfOeqTu5kjtc30?= =?utf-8?q?iVS8kNJoUCLU7A+Ref1MHnIynxCqRQRcSuu3aSXTlLSwG8B+6vYqc29c9tYZA7zpE?= =?utf-8?q?Tdmoi29TVt/YPumd8xYF+ymounExY9lLWPb1t2xHoq+JltzjnXfL9hdHwF4SrCWh/?= =?utf-8?q?jNxGr6xE/IR2D+8Ib2zw1vVrQM0YCCcJJSfE3kGnrM5H9H/b1E9DVqwErABHm69cY?= =?utf-8?q?9Kk0OYfQD1YeDQ0GuHI5vtLMRmUuWM1sAJ7Yf6+J7Im2eXk5jB82EYwLk6SQrD4EF?= =?utf-8?q?+BytMNamwv8xtBtyRpbls2ol01DANxMlHUR+VdSE7UPgN9GFTY4Abvcs553RvpLxv?= =?utf-8?q?i7EZF8HdJflPaOfSA2PAX+2e3NJira127l8VbAegBemfi6ylt3YbKPllplfsxekVd?= =?utf-8?q?FLuJgc0H2x+LccI5UhFePozfRgZ8GcieEMIvkhM8JAPCyWioVk/KR+Wr/bmCJ24Ra?= =?utf-8?q?IL9XRInTiArtkVr30PROaBIGvH9LtL2zSlxAysEzG7rhcQ4/E9jbDpMDn1+BcfarS?= =?utf-8?q?7WdehpC8pJPVSm7+44yvySUXR9HJJWPZBmlgvELoEHeOY4vJa5yupUvp/gYSEp5VG?= =?utf-8?q?gwnAiniEzJv+R/ZR9zbi/hu9CbyPWNN0INaErckxbDKGwDIas0AkRkT/zI3+KjfpF?= =?utf-8?q?7Ju7fM6Eq4Ru9sExNIOUfjV8U606aQjGiuk+LDs7IJEPAmRuLXoZ2RdFkFLnZavSb?= =?utf-8?q?NY/4hu2IG0cSussrjglT1Y+PU9HnlzNo1e3nODbYGS8Z3XOA9veyn4gyiwkPpKgdt?= =?utf-8?q?Jh7VPYNjR7Zpzjs/BDxhJiY96XHLw48oko7I/XR+XqtjOiGlaDd9zWktvkefKfkDu?= =?utf-8?q?0l/wKyh76hMkd8alv2S0xJdzGFL/4vDEq/j/YghgQH03ipV17RfFUI9T9Ti5hR44+?= =?utf-8?q?3IMbP/cfgDUrgvBLW2g7vLOolyO5BdrCMlu0EPdTy12CfVqgPt0L7d4uhw0WdRVCu?= =?utf-8?q?k6+/HZd253UWO77j22HA6R2DnNeWGaIkg3PaIhl6+IS2SNKQ2wyiKBg9I4VqZRGEc?= =?utf-8?q?/3M92HvbzjjiRkSaYtnFM5ajVwI+kcPs/BFe205NDkIAypskgi4ZOG11ypzTQUAVS?= =?utf-8?q?DE6BMQ32J1s+PzvThvToe8IRYOCHxnp+yqsQsuslyDlYZ3u7+1Kk4Ho+hKLaATgZM?= =?utf-8?q?UFFxG/PNptfcfyzk7D3Br6Kvc3Wn0rWAMYlNsDw0lFLwOuIQPFXcHFa1ibgVGTDhy?= =?utf-8?q?xtYCvJdagNDi32tskq/H8f6ThcJeyIu5SKzSutM2D1FH42b5u/+2uEewLtvAjWJQi?= =?utf-8?q?/nnbLFELzh/fyQJiBIzrggz4VrN6w2W2473jy4xNI5Iqvcry8ZTgx/VSaAANFK8O7?= =?utf-8?q?qRbeOQJ8onefNczDW+uHdClBtzyXMPtHUA=3D=3D?= 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:(13230040)(1800799024)(366016)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Qs5h+zniJ+czmqisOErlXeLOMxX6?= =?utf-8?q?wyRwa77IsOjScWei3xFzCgy2MFOcllxxg3xSGC+bzkt8tjFihQ2tIXpAtOBTIpT5L?= =?utf-8?q?T8G6A4UPJLqH6ZDzT+dVE+lcQK2XJg+Zfhh2KBwNrbSunCU+p/Bf+ApfK8+QHnPM5?= =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JPIi/UQC/0hMl1NNOlmtebTog6djCeYA3ErB+TcPQa3FsoJI1Kuxd?= =?utf-8?q?AszgLZNRTho3HufNwnj82YDQw4CzsZ84vUlpe1Kq3QJmk5g+Pn4cCFOYFzNQ3pbs6?= =?utf-8?q?QYU8BFRkdMMX+fmz6KHuSpRKQIJ4DKFTCBu6UIhKsRTutQ3Ge7UBlmdMiCUkErrPT?= =?utf-8?q?HythHyBJquq0qFhqldKnBZ7L3OzbFLDz+TfuVzNCHpvNvVp4NbLtfSsU8c19GH7gS?= =?utf-8?q?ZdEeA52I+6I0e66of+W7dxkzNbXciLrgOgaMhqasMHqahzrH7F3EHSOOsVFRXXnTR?= =?utf-8?q?fCxYutUS783s1oMU1jb1MlQAsdJ2KIhO0n08W2YhtYp4QpDLPuTzJ0aF/TEBKN/fx?= =?utf-8?q?jFT9DfgPRaRRg9rzN8XJ3t+oC5VJqGKTKnfCKNFVwrlx6MXO3c08cXldVVYwW45hA?= =?utf-8?q?+36lO+UsgYMQK5NnO3BW0Mab9crg2v57v2ZWUF8+9/esACdxnxkazZ9P5c7dO3Epx?= =?utf-8?q?CdViLFSKX4tc?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d4796f60-dc79-4915-2e1c-08dcc86f9df1 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:14:49.7382 (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: a3ATcurYXBxOpcPxb16DwgeNBzEBK8erKVBaTYGqX93CwYXU5OifKedr8qSvp4uUrLT0+bnzW+In9GUwUyYfbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7560 When a new device hotjoins, a new dynamic address is assigned. i3c_master_add_i3c_dev_locked() identifies that the device was previously attached to the bus and locates the olddev. i3c_master_add_i3c_dev_locked() { ... olddev = i3c_master_search_i3c_dev_duplicate(newdev); ... if (olddev) { ... i3c_dev_disable_ibi_locked(olddev); ^^^^^^ The olddev should not receive any commands on the i3c bus as it does not exist and has been assigned a new address. This will result in NACK or timeout. So remove it. } i3c_dev_free_ibi_locked(olddev); ^^^^^^^^ This function internally calls i3c_dev_disable_ibi_locked() function causing to send DISEC command with old Address. The olddev should not receive any commands on the i3c bus as it does not exist and has been assigned a new address. This will result in NACK or timeout. So, update the olddev->ibi->enabled flag to false to avoid DISEC with OldAddr. } Include part of Ravindra Yashvant Shinde's work: https://lore.kernel.org/linux-i3c/20240820151917.3904956-1-ravindra.yashvant.shinde@nxp.com/T/#u Fixes: 317bacf960a4 ("i3c: master: add enable(disable) hot join in sys entry") Co-developed-by: Ravindra Yashvant Shinde Signed-off-by: Ravindra Yashvant Shinde Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- change from v3 to v4 - merge https://lore.kernel.org/linux-i3c/20240820151917.3904956-1-ravindra.yashvant.shinde@nxp.com/T/#u - add Miquel Raynal review tag - add Ravindra Yashvant Shinde 's signed-off --- drivers/i3c/master.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 7028f03c2c42e..82f031928e413 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2039,11 +2039,16 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master, ibireq.max_payload_len = olddev->ibi->max_payload_len; ibireq.num_slots = olddev->ibi->num_slots; - if (olddev->ibi->enabled) { + if (olddev->ibi->enabled) enable_ibi = true; - i3c_dev_disable_ibi_locked(olddev); - } - + /* + * The olddev should not receive any commands on the + * i3c bus as it does not exist and has been assigned + * a new address. This will result in NACK or timeout. + * So, update the olddev->ibi->enabled flag to false + * to avoid DISEC with OldAddr. + */ + olddev->ibi->enabled = false; i3c_dev_free_ibi_locked(olddev); } mutex_unlock(&olddev->ibi_lock); From patchwork Thu Aug 29 21:13:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783893 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011045.outbound.protection.outlook.com [52.101.65.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBDA2189F5A for ; Thu, 29 Aug 2024 21:14:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966096; cv=fail; b=qSiW1itXkCqR0f1VRj2dREz8zF/iiBck41qVLa7iAlD1c5UjTZ6e3t6azNQ5O/uRD9cD2v4aAL07MRAgAfntUQdFovIbHo9fUv/uLWB/vVg90V36y6dn6T3e3OmxBs6Vyn0Q8Bdm3hPQZx2nySOeEUwqCEPcjYGbERpLB6Z0O/E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966096; c=relaxed/simple; bh=ZFRph0b9X+/CcyKerJ3YnFLz9ZtABnOTIX6HgBcQtls=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=FmG4dfE0OgGif5sepJXIePoT+Uk7Mpct1qxbHdMF+pajICoVYXqJVJw+BZEC35GfYOCq4ec40jHKrdFKSuCkgAvMzb2kD8MDCVVghxBDbptuU1kFR6BCgmJ3SVpADSZLEWBlccdB2enCGcCS4uBYhObBcOmqfd1Vokvlk9pTBXI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=SN41fT1v; arc=fail smtp.client-ip=52.101.65.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="SN41fT1v" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cEHkyLbY/3nU3aDDyL5/obOg3c9XcoFzyIKR8YiFsLVGxqsQ2PVCOz4wcHTvCtDad7uqWuSCoS4/lrBjed9oergCtTxzl5ZgoDD7iNBa4D0RnUEhfgO2JoQkFaQmKEQ+qmQ7YEjE9R8D3xoY+2BoXvZhJQ+B6zP/pn5es7Nr5eCFdDbar5nqSFR7Z9NY4qsTJqI9fBveh9WHSb7S0uvOYlCzpCOFIywRq1tRQIFKvuG+KwIONaG3c2iZ9PJk+jb/LAyCL3VQ1H+vRNyrb0dKJUpnbfhSUKgjnMdd8Wsyu3RsHQqlZT7HUbw1qWJh/GS0wqOUpHPgr3k0S/RRYkm5kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=+Zw+7Tpjz7a4IHNLJ2t5tmfYoXfsEZBhOfeYqgtMXJE=; b=Gl3BOi84aq8S6WpmTUdLl6UYNYu3fBcy9ujRfzqnSFpzz1YK7TUcOqD49fJre/ZGa0pO7nwWEv+qzC6xNejfn3pbvsmSykYfg950nCwZEfnAK3nDYpMyp9WDF/qKuj+P9FSupiCUQ/sbpIF57rIqnSju0QQFiOJBeNU//S3MpUReyBScWdNH2VfNFzpg8IsvUNqzS3jhTTJBMfg8yFw2F6ee3mAgFGAyHwe5VjuOc2yEU/nbZJPuO/tfhm8WUIUvvV1bYwLVjzlAftIMbY5tX0G/GjsTpNxuPhkW7/9ny4qY9Cd9f/43mqKmwM8ELV5t1DGJUFZfZ17GYWJafvF9Lw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+Zw+7Tpjz7a4IHNLJ2t5tmfYoXfsEZBhOfeYqgtMXJE=; b=SN41fT1vny71FylgoVJLMnQC9NrYL/MK4hwwhIiIBTAQrB58vJ3iriuTBvhAKgNiMIXWMaCEMCejLl13NsYzC2wemPz97oa39E693bcFEnmGIWVCB5P3Jub3bocn3DYJWoyLqe4wZxTUoFeXLUZJ3rHSAyFeGNiGQQZq7HsdvCHXR3kic6B01CbISzbehe2MKP2ezsV8CGjCFc/YvHWxFbTyRGc1AmNh0ifDcAj1GwNGx3MxCIoYHEGeGtkLPDUCgeqd+tp+v0+ee9S5f39NBdMCCI7i1nz2QsK1LwlCFbCs3/3rLEi6vjgMoldGiQySHfIl5ZcxEMKIQ2+EdvC1LQ== 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 AS8PR04MB7560.eurprd04.prod.outlook.com (2603:10a6:20b:29d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.28; Thu, 29 Aug 2024 21:14:52 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 21:14:52 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:13:59 -0400 Subject: [PATCH v4 02/11] i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS Message-Id: <20240829-i3c_fix-v4-2-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724966082; l=2002; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=ZFRph0b9X+/CcyKerJ3YnFLz9ZtABnOTIX6HgBcQtls=; b=JJwat71EjT2Efb5wn7NQ5FjXv7ISFVknI5FLH3pYCOP8kFCQbd9CHHn9qBGDeb3q9VlV1tvex fy9BLeYfXPVARU389gVJolvkRZkVnoI7Nle08lVPAhIbJmbDSHftc0D X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB7560:EE_ X-MS-Office365-Filtering-Correlation-Id: 1420fe84-6d9e-40e4-330f-08dcc86f9fc9 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?fLrHNsQDUzxuCX7eqHCoEBuWnA0Ihb+?= =?utf-8?q?188yvYzatMzmDVkWk3Q4CYFaeg3IYsqHIIbwjsEgTxRqVm3jsHcQG0WgYGKUhlm9P?= =?utf-8?q?GA+41PRM8fQEVVSghedJ651hZy5zP4VvfB7ayUlu1ZyzqbwWd/K+JzIbukzIp1Lz1?= =?utf-8?q?Sl6XqNq9gRgTUEzpmdMYs/MJ0IjPwh7GZSkB3fXJGJV0fCaiufnJJUpnXzziDq2Gx?= =?utf-8?q?A5xWAXSPhy6ZgNfrEV9Z+DTT0wz45vkF0A+TKKSQpFhFMw2Vklo8UVI7ZK/JnWs3h?= =?utf-8?q?4T4NG9V3ZWlYX9pblQcJ+zJjE8ifI9YB8ZVFroVn1qwpLlgKqMwvSXPF+kiyOU3gZ?= =?utf-8?q?H8PGIyYoEFhhfPHVXvNARvFIDgRh1jG5K7s0ViQFfNaPAT374QPsJgxf0Ck5V3cZp?= =?utf-8?q?wZmc0rEDLNa/tYIORsLb+u3rsPt4+M4wsAGkOhSWPaV2kIAspLLv9D8EBp2jRBcBf?= =?utf-8?q?/Hcoq1rRlaDt36UkBI17FuCHVbp3TUE9/MuHxYSFV64Bc4eEdum+JLxgxN1K2zOjj?= =?utf-8?q?b3k1xu2vGYiGWLs9Ed35UhGWfwBM3xnN0Jk7NS/pgIVyIWcjqMulG4+l7+7AQTLV+?= =?utf-8?q?6Zm3m+sKk8dF2QTMphS2WN8OW2n4tCtIRETXqDrd8EbSx1BFNDOHlhZQRgKmGi43m?= =?utf-8?q?NaISB21jN0X7qNnlDkYyfRfCSxU0QB+A1ONJ+nLHF1Tue0HqDX3tqsvz0E+jazvJ+?= =?utf-8?q?UtJ/EAaIBzJQ6IKgX98tLCrKr+8BgRd4y8OXBMJryYJUhhnhJ7lZrl3t3uSeRxXKH?= =?utf-8?q?GYe4Apu7ufUioi8XhWzOPg14PmpqpPwVbxNIKXx30cPleov1zasZh8FOyXCo+0xnw?= =?utf-8?q?arhWAVBk0eUo8/LdHNuAAKUdXW+v5XnftsiQuS90XHm5IcUYpXqSUo/DlFSXISLV6?= =?utf-8?q?QohXSf8f2SuchRRLNJk1IPJKSdVjoN/MYvZahaI6HfXD5bfKbJP1v89gYG/JsIhkV?= =?utf-8?q?rBq4WxpVTmIwEvg7BRrj5oaUknR/3Qvhum+59Fkyfdxx4IpAwq+FT+qavW5DfAqk7?= =?utf-8?q?Aemg8aUyqCkYi3uVtA8or0XnlwCvVLKrQhZDQ7vCbv/sPpOf3NlBrCwOxex2Emqin?= =?utf-8?q?9KDwwBNUn/3rstoJ0pLmEC0OGNkxFpWz9OXHbQBTKHgD+6lqPMLFbdU+eVTp2lL8s?= =?utf-8?q?yEWvRN9XDwhXKCWjsljfa1M2CgDj7ojB3BOtvo6BNQ+jCSMRmK54VmKyEjMZgqA3v?= =?utf-8?q?j2DkxfLEVaby9KD2MM1LyiLvixVn3caq6ZwXyuS2BIEgaVaV8UmuspsdgGWFmOwGK?= =?utf-8?q?YTOQLYSvZ7Tw3OU0MKpbbUJCkqbeUol2ajJlVixEne1peI1a/ww4dayL6EmwZsZEk?= =?utf-8?q?2YnM5VsUI9iYJZjY+gIa8S4zVB4xRG1Qyw=3D=3D?= 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:(13230040)(1800799024)(366016)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?EjI9cHcZ9Y1g56HUMtgasNjm3nWm?=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3k5DHO7g6ZB6eJ7YTU+UWAh4WIe/roN1VRAORnCmufLPOtcfUSo+ovIBE2sPo?= =?utf-8?q?Pwx3yLtvlXCz0q+xZb8n/T+ABaeKXZsYaMpyvzAh0L/np0UWmcSY3gmnrbW/a7Z6j?= =?utf-8?q?g6UtxLefTx4Gaci2oP9I2m2s4gF8j9JUOtq+i3Rv6Jj1AMpcO8P9Ckl+IOj3hBWX4?= =?utf-8?q?fyl63UdGUFCp2zl8cUR5K6AiIjXEEaGhGouTOm6mxWuaWtRl0wEvKSXS4ZsUAvEZg?= =?utf-8?q?a+Y/0deR7gaGgd4qVDLRxMDBKeLN9mGf5wm2o3JuhGBGBrmCAhtU7ue5rRpWmkwwi?= =?utf-8?q?EQOKUy753GlP+AtJWkwoKn/0v5Rx2CRvcJ/2uQlMJOQEDy7Go261d5DB77vAq8Ems?= =?utf-8?q?P0qyg1tks633US9GH4EIddWYncbbHnFWCLll86tDoKxaqwGFYAXEungQ0IFcl3TrE?= =?utf-8?q?uFOC3iGfw0oxCqffGvmjVahZOsdFe9BKRRq5K959DmQypXToIQB0rN2pIEG8A/OIe?= =?utf-8?q?cPZFs31AFpn5YUKBQn+QhiHIcbzF02O3wYBiNhI+xpZg1eJrwJVrmwQTpctQi7+ZB?= =?utf-8?q?KFVEDIPrq6Jc0KyeMoaV9V1y0So1MV1qW0E5C7VQZBXwxxLwusMYPX8a4/6DCCNfH?= =?utf-8?q?V6nG8JfqN3xG?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1420fe84-6d9e-40e4-330f-08dcc86f9fc9 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:14:52.8626 (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: FUhNNkO4u6hgs6jcyKx++fFnWvmDg7RU60dqIDg2GRlIoBPrPmtF/EyqcISpJwp/NAwZ3/iBI/hYr6Saq9bjsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7560 Replace the hardcoded value 2, which indicates 2 bits for I3C address status, with the predefined macro I3C_ADDR_SLOT_STATUS_BITS. Improve maintainability and extensibility of the code. Signed-off-by: Frank Li --- Change from v3 to v4 - rename to I3C_ADDR_SLOT_STATUS_BITS --- drivers/i3c/master.c | 4 ++-- include/linux/i3c/master.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 82f031928e413..2c9d45486ed8b 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -348,7 +348,7 @@ static enum i3c_addr_slot_status i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) { unsigned long status; - int bitpos = addr * 2; + int bitpos = addr * I3C_ADDR_SLOT_STATUS_BITS; if (addr > I2C_MAX_ADDR) return I3C_ADDR_SLOT_RSVD; @@ -362,7 +362,7 @@ i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) static void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr, enum i3c_addr_slot_status status) { - int bitpos = addr * 2; + int bitpos = addr * I3C_ADDR_SLOT_STATUS_BITS; unsigned long *ptr; if (addr > I2C_MAX_ADDR) diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 074f632868d98..2fac4a45ec600 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -299,6 +299,8 @@ enum i3c_addr_slot_status { I3C_ADDR_SLOT_STATUS_MASK = 3, }; +#define I3C_ADDR_SLOT_STATUS_BITS 2 + /** * struct i3c_bus - I3C bus object * @cur_master: I3C master currently driving the bus. Since I3C is multi-master @@ -340,7 +342,7 @@ enum i3c_addr_slot_status { struct i3c_bus { struct i3c_dev_desc *cur_master; int id; - unsigned long addrslots[((I2C_MAX_ADDR + 1) * 2) / BITS_PER_LONG]; + unsigned long addrslots[((I2C_MAX_ADDR + 1) * I3C_ADDR_SLOT_STATUS_BITS) / BITS_PER_LONG]; enum i3c_bus_mode mode; struct { unsigned long i3c; From patchwork Thu Aug 29 21:14:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783894 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012033.outbound.protection.outlook.com [52.101.66.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0E7C18C022 for ; Thu, 29 Aug 2024 21:14:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.33 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966101; cv=fail; b=DjyIeWbJDhww2sAbfgLxvWEg9fWNOvZo3Xs8NLfUfgwgGfiuxrI6ljp6S9zj26nZqYzljP+yagaFs0JpdQMA1QLN08W4aRLiz1tAl6bziCT6jFbxNY0eiGKnU6A6EzaAP1cAtIuY5OtcEcYcPvDmu0Os8tQC0gOaP5vNLNHJ1do= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966101; c=relaxed/simple; bh=HWDamdLNANEwk6vCRoWBJpLPEb6ZbVWcj6qlnnkj070=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=a50F6dD8K/pDOF6i667D4EfXYhT2CBtynsEuR7l8fL3Ut3mKSMcq/YLt7VaeUkai2xDSlEH/LFaJLJfYtzUac2AwYPZcZy60eEuLzbwzAVIIonh3hh0yGDOOE9wNuEGEn3nmKMt2G/fk3fbdtXM/v9jMEK5AAKLRDJ61eX+UvrA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=YoFSExIQ; arc=fail smtp.client-ip=52.101.66.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="YoFSExIQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XWyZqWR/n+pCqmGpo1QwzXREaVS9Slf/BadmgHiyyBWfg8oWEj5u1bwhEvFEba/TEzE1cDTY7a8X9kdsdmQYhVBh46Hrb1caw7+xTtQRRfR3oNfKKHuoCtLrhG8ENR94ubDydkYJn48fiucTA9FJDfDTIoC6lVW33gJiTLZceENifbD7soAEpnIdLQ6dW27GgCA3arDxvIQ5F7obX7eSvXKsOCBUSj1gjedckwpft2Wb7mBi1EsLEf2VZD9Sof/3GzMfw1v/CQipN3RxNMtXI5fddNopF5tJUdZvEQsrGJqr2Qcwqpd9e8rvfse1bmoC5F8t2XBOX7zq8940FrI9xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=TqVyPCbPTJ3sdEA/27481SZaESH46IwUHMWlvgoCoX0=; b=DExqCNgTS7YjaUgh6ZnJ+e3yo9HCvS+hNtv5CgaK6yV0KIdNXOf9HFoqwfWzQ1h2bTBNoUWvloSPHyMmRBZUmrkx2SjDHJ85hz/buK4MZle+wcgJ04nPsgcvNPHrt+cCCs6pmaVUAgcKfhcv9Oxi/IDEGPFEs5IcnoknvBGh3DtgC0CAabnsRhb4bRDdp1RZB6dIZmU4mg+0hb7/kOXhJiNHLrA3qfwze5Cu0YLYxg6q6HRhYDS9E21xpRHpjGeGSDdO9pfZnQAHZ6f6jHxgzzQ9HnuNQ04XzCvqztp0BIbRnIm/MxDS3CMsVgmoEkOLk7zUgKKp1OHeT9yOr7Vm1w== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TqVyPCbPTJ3sdEA/27481SZaESH46IwUHMWlvgoCoX0=; b=YoFSExIQDco130ynxt+gMFv2VSjM9Vfi6c9wbQA2+2Eai72+16S7LkCI6Kdw1kpL1NzqP+0xqeRH4ii8rnIJlmBT8kCVamyPOivFsXoSAC1zMul0VgrkhYnPKQonrCr1jsm3Hv9sJaTXJAv4Iu9orgIs3OcH7RgiW6N9YFyWt8kRmz1Vb7+h3ANbh2J1SQz/FYuDri6OA8nz6Zy8Nq/6zyw2SQa+p9AUECw201J8toQsykJDhtSiN8mbzlKIWeJLeU3eUykwOkfRouKWKMPg+5T86wdwRw285GiN46T6NDIJoCLFy1cLwoV+JCBXDmo5IfdlFwK0akcbO2+7HOHtMA== 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 AS8PR04MB7560.eurprd04.prod.outlook.com (2603:10a6:20b:29d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.28; Thu, 29 Aug 2024 21:14:56 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 21:14:56 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:14:00 -0400 Subject: [PATCH v4 03/11] i3c: master: Extend address status bit to 4 and add I3C_ADDR_SLOT_EXT_INIT Message-Id: <20240829-i3c_fix-v4-3-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724966082; l=9448; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=HWDamdLNANEwk6vCRoWBJpLPEb6ZbVWcj6qlnnkj070=; b=o0DTeRjMQ2dHAzjUlY0ZhP29WKNDnfr5q/pYpbfcM3XVaeFQCVQZm9JJ6DyOp4kOlPEjNdu2p VBYLZjNuE2lA5gtbes8bZXaeKOEK0cVKIcc8YyQkyKhjDP+auXwdBQZ X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB7560:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a45bccb-e3f9-46c2-7689-08dcc86fa1a7 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?99lcKMml1lEKRs9ZoSlw783+6SzBejz?= =?utf-8?q?GM+tWcg3ADksr87lDGKvFVrHV/uBCo53sOI/PHHfG+aCNxw/S8goa8yNT34YV3O2O?= =?utf-8?q?tdliLlHXDSF+uQmEbATZcBqevE3UWOZZhzpf0InWpkZpKmaxSTCPsvu22TJtt0kaW?= =?utf-8?q?qRgWbE9ZIWaVt9C8ZVu0+dHR1bYyvUNTE2YNwN/cHUzWUBx9LLlQGvJDV+Ra7R8rL?= =?utf-8?q?nu4bjVyV/envgAH66uRzq4CPd+jNfVOOQxh/AoXqHOpBSXhxY/em7o2dpwrRG3/9m?= =?utf-8?q?Yc2SknlbhL5WfOejC+choh3nN6jbPqgZkBatei2IsEthnApAsKWezy3oAuInCqlkB?= =?utf-8?q?NcFQOQbjbckA8rKfl9ba68ukcyiJt+i1WY9HS4B+jrZY3SCm/ijysQuCBCLNJ2jPF?= =?utf-8?q?a08Nd7vlM9adKdEnQ8iG9isXiErEz70KqXlpp0xOEmJ/ke69ajMBq/Mf8btoY8Qb4?= =?utf-8?q?PJbYPJsCAl6cm2ahf+mjiXD5SoqKsVo0GP9HjrgWYPD/VvfqSWKwgxeffeaPiDLEa?= =?utf-8?q?8iW57gb1H6UcwOadzhUE2v2y9VdohcwUXVajXV8+GoeRfmHr7PyoZGPL/3qViw/JX?= =?utf-8?q?Ip7/RPdqJEpiaskOg6mi9EbceZromfy7WtKA6DHZQGaSLNLOWqL0Vho6xfm6pMOaD?= =?utf-8?q?840JW+lQOGysP5RTh36Ow82Whf5UyhGHQfJ70/1/9qFhaNPS5Kf6kCBOalDJler/o?= =?utf-8?q?4iy94B37+7bCqwtrh+B+XKT6viO1AiIz4cA5SKkVnk5pmJ1LRfFdAsJqVU9WCXnPP?= =?utf-8?q?rY00c46IWNTBOcFXOHg0dKbUR1R0+CHJVQ/UnS9xd2YlS8X7P9lmqK4m797ig/X+0?= =?utf-8?q?/xeInli2alN37yvCldCH/7xAjSoMSQjA6egRdxXvUJeV4QUyojq8Yz0Hpt5BGz93g?= =?utf-8?q?3KKRHJxS5Hdv4j8LvsIbpvS3mv51Ft+bGy1YHx2nrTv9+lsMrkepGPcIzNyERLZY3?= =?utf-8?q?Ufb2LKkOUlz1TQY/UUyzY5W01w9Fh/G4Kd9kjJpGuLTg8aIDIpqIaHstIj4PlEDPW?= =?utf-8?q?HhoKYECSEqvbfUoAnjk8tz/yBqS6JjNtcscaNhjJ7z3stD6xRmdLmsjAPrA2EVxBt?= =?utf-8?q?RRibPnmlzecuZSV8PsJ9dGiOlPiDmm9ktT92ls8DAlsEgIMYutJ7IqxCwf7YntyKy?= =?utf-8?q?Axfqt4U5b++hUBCbjiRgNUcdfdGqT5niiHRvvItZSWG1Rkzlods5VD7jfUZQwSVoK?= =?utf-8?q?ZeL4EpFCX06CZawNsn7OROBa986n8HUgtU0exixM4/F9hohtkAxDQsKSF1AAHGUyo?= =?utf-8?q?iMG/KBr5/rsiLl5Ed148379HNcOFgM1z4nkTN2OddHrEvl5pwX8wXG6hkizOi6WBD?= =?utf-8?q?ynRNGI14KhNsLfni7+wZiOjsPEcwiLwwUQ=3D=3D?= 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:(13230040)(1800799024)(366016)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-Mess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VuJXoOtcnssO3zxAdAT0QZL2S70p5Mtwl+6r+2f2o7s?= =?utf-8?q?AHJXQLdLAtuDYRRPKkKb4fDieBv8MtiUjUB8w94IHTMmul21KYESFjrSA/aiBZeV6?= =?utf-8?q?gIBJk33H62rqH4MtcWDmogMgjUFDmXfDZbvOpEuW/gtW6NPZwYng64bQUtGY9ihYg?= =?utf-8?q?8EdhFN31L32aIksv61I0aYZMN7pneTeKo75kj5v9/p01tb/O0sg4ZDp2Z9Tc0V/mH?= =?utf-8?q?c6RtE+yoYX140Xnhay4pjGlEge1eD9XNzWAop8AsUaSStg9IUvAhHcWZ4MK9loShW?= =?utf-8?q?0IP7EP+OVu8a17KE/QG8MZXrH3zP3GXvu8vYtsMcm47VlJiatRgxrgiLjQVIPNEWr?= =?utf-8?q?JxZcRY7J0J4fi8DTverhKh60lkLAd5M3h/cmYH0spk5R+w1/r3gru3fdeBV3RTv4h?= =?utf-8?q?K4zfcKEWh9X+oWw7LAae9H/BQK2Y6Q9NbhiYQpdIMijnx/KzV3JrgB47Hi3foSPCV?= =?utf-8?q?YJFk4hClCE6inEFK5QK7xQOfJjjL1vvgMmxP0w7Dl2NUwsowyNDS8iiQw9kpmVQQ8?= =?utf-8?q?mz4zAefCIwOfsWUINRb2DvqUmk2DBVy2u3khuJTdEJrsHODCTIrBkPera6238/Ou6?= =?utf-8?q?TOKWcemaMn2kc1r7CtnFBE9TR7QRdcLheScbija8ajmuHDohBo1GMhUmtI/9lS65O?= =?utf-8?q?AnsT6dWKn3ej?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a45bccb-e3f9-46c2-7689-08dcc86fa1a7 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:14:55.9928 (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: Mny6fsAQNVodahvUWN5sdpCFTNSygTUZS7xwupHNuElMyJTxJQ8OBqMhXLbHK+ERX4Te3rR+KFdLzV/IZ0HXcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7560 Extend the address status bit to 4 and introduce the I3C_ADDR_SLOT_EXT_INIT macro to indicate that a device prefers a specific address. This is generally set by the 'assigned-address' in the device tree source (dts) file. ┌────┬─────────────┬───┬─────────┬───┐ │S/Sr│ 7'h7E RnW=0 │ACK│ ENTDAA │ T ├────┐ └────┴─────────────┴───┴─────────┴───┘ │ ┌─────────────────────────────────────────┘ │ ┌──┬─────────────┬───┬─────────────────┬────────────────┬───┬─────────┐ └─►│Sr│7'h7E RnW=1 │ACK│48bit UID BCR DCR│Assign 7bit Addr│PAR│ ACK/NACK│ └──┴─────────────┴───┴─────────────────┴────────────────┴───┴─────────┘ Some master controllers (such as HCI) need to prepare the entire above transaction before sending it out to the I3C bus. This means that a 7-bit dynamic address needs to be allocated before knowing the target device's UID information. However, some I3C targets want a specific address (called as "init_dyn_addr"), which is typically specified by the DT's assigned-address property. (Lower addresses have higher IBI priority, and the target can adjust this by using the assigned-address property if using DT). The function i3c_master_add_i3c_dev_locked() will switch to this "init_dyn_addr" if it is not in use. Therefore, i3c_bus_get_free_addr() should return a free address that has not been claimed by any target devices as "init_dyn_addr" (indicated by I3C_ADDR_SLOT_EXT_INIT). This allows the device with the "init_dyn_addr" to switch to its "init_dyn_addr" when it hot-joins the I3C bus. Otherwise, if the "init_dyn_addr" is already in use by another I3C device, the target device will not be able to switch to its desired address. If all of above address are already used, i3c_bus_get_free_addr() return one from the claimed as init_dyn_addr and free address slot. This ensures support devices as much as possible. Signed-off-by: Frank Li --- change from v3 to v4 - rewrite commit message and comment for i3c_bus_get_free_addr() --- drivers/i3c/master.c | 68 ++++++++++++++++++++++++++++++++++++++++------ include/linux/i3c/master.h | 7 +++-- 2 files changed, 64 insertions(+), 11 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 2c9d45486ed8b..1dad727e28435 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -345,7 +345,7 @@ const struct bus_type i3c_bus_type = { EXPORT_SYMBOL_GPL(i3c_bus_type); static enum i3c_addr_slot_status -i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) +i3c_bus_get_addr_slot_status_ext(struct i3c_bus *bus, u16 addr) { unsigned long status; int bitpos = addr * I3C_ADDR_SLOT_STATUS_BITS; @@ -356,11 +356,17 @@ i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) status = bus->addrslots[bitpos / BITS_PER_LONG]; status >>= bitpos % BITS_PER_LONG; - return status & I3C_ADDR_SLOT_STATUS_MASK; + return status & I3C_ADDR_SLOT_EXT_STATUS_MASK; } -static void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr, - enum i3c_addr_slot_status status) +static enum i3c_addr_slot_status +i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) +{ + return i3c_bus_get_addr_slot_status_ext(bus, addr) & I3C_ADDR_SLOT_STATUS_MASK; +} + +static void i3c_bus_set_addr_slot_status_mask(struct i3c_bus *bus, u16 addr, + enum i3c_addr_slot_status status, int mask) { int bitpos = addr * I3C_ADDR_SLOT_STATUS_BITS; unsigned long *ptr; @@ -369,11 +375,22 @@ static void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr, return; ptr = bus->addrslots + (bitpos / BITS_PER_LONG); - *ptr &= ~((unsigned long)I3C_ADDR_SLOT_STATUS_MASK << - (bitpos % BITS_PER_LONG)); + *ptr &= ~((unsigned long)mask << (bitpos % BITS_PER_LONG)); *ptr |= (unsigned long)status << (bitpos % BITS_PER_LONG); } +static void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr, + enum i3c_addr_slot_status status) +{ + i3c_bus_set_addr_slot_status_mask(bus, addr, status, I3C_ADDR_SLOT_STATUS_MASK); +} + +static void i3c_bus_set_addr_slot_status_ext(struct i3c_bus *bus, u16 addr, + enum i3c_addr_slot_status status) +{ + i3c_bus_set_addr_slot_status_mask(bus, addr, status, I3C_ADDR_SLOT_EXT_STATUS_MASK); +} + static bool i3c_bus_dev_addr_is_avail(struct i3c_bus *bus, u8 addr) { enum i3c_addr_slot_status status; @@ -383,11 +400,44 @@ static bool i3c_bus_dev_addr_is_avail(struct i3c_bus *bus, u8 addr) return status == I3C_ADDR_SLOT_FREE; } +/* + * ┌────┬─────────────┬───┬─────────┬───┐ + * │S/Sr│ 7'h7E RnW=0 │ACK│ ENTDAA │ T ├────┐ + * └────┴─────────────┴───┴─────────┴───┘ │ + * ┌─────────────────────────────────────────┘ + * │ ┌──┬─────────────┬───┬─────────────────┬────────────────┬───┬─────────┐ + * └─►│Sr│7'h7E RnW=1 │ACK│48bit UID BCR DCR│Assign 7bit Addr│PAR│ ACK/NACK│ + * └──┴─────────────┴───┴─────────────────┴────────────────┴───┴─────────┘ + * Some master controllers (such as HCI) need to prepare the entire above transaction before + * sending it out to the I3C bus. This means that a 7-bit dynamic address needs to be allocated + * before knowing the target device's UID information. + * + * However, some I3C targets want a specific address (called as "init_dyn_addr"), which is + * typically specified by the DT's assigned-address property. (Lower addresses have higher IBI + * priority, and the target can adjust this by using the assigned-address property if using DT). + * The function i3c_master_add_i3c_dev_locked() will switch to this "init_dyn_addr" if it is not + * in use. + * + * Therefore, i3c_bus_get_free_addr() should return a free address that has not been claimed by any + * target devices as "init_dyn_addr". This allows the device with the "init_dyn_addr" to switch to + * its "init_dyn_addr" when it hot-joins the I3C bus. Otherwise, if the "init_dyn_addr" is already + * in use by another I3C device, the target device will not be able to switch to its desired + * address. + * + * If all of above address are already used, i3c_bus_get_free_addr() return one from the claimed as + * init_dyn_addr and free address slot. This ensures support devices as much as possible. + */ static int i3c_bus_get_free_addr(struct i3c_bus *bus, u8 start_addr) { enum i3c_addr_slot_status status; u8 addr; + for (addr = start_addr; addr < I3C_MAX_ADDR; addr++) { + status = i3c_bus_get_addr_slot_status_ext(bus, addr); + if (status == I3C_ADDR_SLOT_FREE) + return addr; + } + for (addr = start_addr; addr < I3C_MAX_ADDR; addr++) { status = i3c_bus_get_addr_slot_status(bus, addr); if (status == I3C_ADDR_SLOT_FREE) @@ -1906,9 +1956,9 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) goto err_rstdaa; } - i3c_bus_set_addr_slot_status(&master->bus, - i3cboardinfo->init_dyn_addr, - I3C_ADDR_SLOT_I3C_DEV); + i3c_bus_set_addr_slot_status_ext(&master->bus, + i3cboardinfo->init_dyn_addr, + I3C_ADDR_SLOT_I3C_DEV | I3C_ADDR_SLOT_EXT_INIT); /* * Only try to create/attach devices that have a static diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 2fac4a45ec600..2c826d17eb571 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -284,7 +284,8 @@ enum i3c_bus_mode { * @I3C_ADDR_SLOT_I2C_DEV: address is assigned to an I2C device * @I3C_ADDR_SLOT_I3C_DEV: address is assigned to an I3C device * @I3C_ADDR_SLOT_STATUS_MASK: address slot mask - * + * @I3C_ADDR_SLOT_EXT_INIT: the bitmask represents addresses that are preferred by some devices, + * such as the "assigned-address" property in a device tree source (DTS). * On an I3C bus, addresses are assigned dynamically, and we need to know which * addresses are free to use and which ones are already assigned. * @@ -297,9 +298,11 @@ enum i3c_addr_slot_status { I3C_ADDR_SLOT_I2C_DEV, I3C_ADDR_SLOT_I3C_DEV, I3C_ADDR_SLOT_STATUS_MASK = 3, + I3C_ADDR_SLOT_EXT_STATUS_MASK = 7, + I3C_ADDR_SLOT_EXT_INIT = BIT(2), }; -#define I3C_ADDR_SLOT_STATUS_BITS 2 +#define I3C_ADDR_SLOT_STATUS_BITS 4 /** * struct i3c_bus - I3C bus object From patchwork Thu Aug 29 21:14:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783895 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012033.outbound.protection.outlook.com [52.101.66.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63C3A18B489 for ; Thu, 29 Aug 2024 21:15:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.33 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966103; cv=fail; b=Y04yW/xwgcJ3d/kx1gki3bYftlQTZ2f3dzsasaFlbMvRNkd40GcT2lR49X7iv0SsA0e22mROm7fURluti1He267vYWs1Oqsv1k40NPoLxgESUnA6TBqxgLBtT25pU1JgxoRzH2roLhfb7BEO0mFc5/DcbPEaMFKy5WnbeumZS6s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966103; c=relaxed/simple; bh=uz6xhxIxIAnIyubwtBkXjuhhwkKj4UjgCJHpQO5eyaA=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=b6OTsooIxbu3lzpvvEg6s+JDOlW9FYIcHixgTkqdP46VvXFIruSkl7vP5uNthCXNa5dvHEJYol+OfL4mxm6r680V+Kk7LoCTCKZ8W/0hDxqjg46y/yx7kXdoM3tg9hAnZCjasOXqa5a1PhSUfhoDlSt3gRgH6oN9VzGDOp/+IR0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=jVc04ghb; arc=fail smtp.client-ip=52.101.66.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="jVc04ghb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CFpgBnIlXQhRVmHvh8crKs7ji8VfLZsCIcqnzCKkJoEo6JIcoVO8QoLp0l63A6tjIZquI9cdJ48yhHbf2QO+oQtlPE3S5wA3QTjXIoRzfen6gLgpOmOVya1ZQ/jePENZgGT/4XkA0upf51cJcpt1SkGaOfHIJsR1QRj+GYgIXckTkdPTPb9RYlTTRBlhcZSMJneDs742IvoWWk3+ozZdE8A5DnvbuTEAOnTjkF/a/+GavhQhAd2HBCOqcyQyGrTXq5WRdZtqss7/WOIc5XPXFs0ZsuwDL/+7uSMkYWrB6FLOm95GMt2lZCMM4LBcHqjzgFgyjWr6Df+YCeJQ9b+BuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=jy77LfzIZBFz5cAmmQqERugeCp1CMhNFr8Kv8JBCwYE=; b=kaYJ7g4G+HQm2J3k5jZBazBJaJdXdmZd2eaDWSkTR3mK85N9bFGsReFGl8F4Uh5kZ+pcr9w64AP2OU4746PtV5t5G4PquF9j603vAq7zitSC9EmhtlyW3TTxzVa6MrruLcH0URGHXIolXFz39gri8y5vAEuaAPq6EtifI2VBbQ6Xpu4uBX4IHHZBGET47jHD9y4fA6e3JveNVtXH+QZNffW8ppzUnFI6vfY9cU42Ol/aBRORxDXbl1C8q9YbkH0i4RfwWtwYLUQVI3l4edCihg+gNHjCJlH5+1XT+HofMeziODfRJ7DT/7vQnnQe5qSEH6e1ievDsStBX2hes8Ipyg== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jy77LfzIZBFz5cAmmQqERugeCp1CMhNFr8Kv8JBCwYE=; b=jVc04ghb6puuup0n/oK65RLio9X9t8KiC4XM4sYNUDCNA+GDNKT8swuw7KosDU4hJhKYTkFnBCJJGOXs9TtUKYQgXrpimQuUKAlBdwLfh1KxM/vEIjsPtl0GolZYkSk0g4jfYElms2fyZwNdMVoTCNF8UXNYAONkUeNLtLBb+s2HPgG9JrjIfhvheGzX27DclEQxVOAcpCDbImLgBA0c1L5ZsdlK9vk/kVTJYF6QpbqsxL3WRDg22RUwMki60TlohNFTrwo26A5i0juWsjL94jwO3k8KZePBlyPOmn8EtYYU8EFVl8sSNsKn3H1CA+WIm6WSbA9G3TvFsLLCYPNU8Q== 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 AS8PR04MB7560.eurprd04.prod.outlook.com (2603:10a6:20b:29d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.28; Thu, 29 Aug 2024 21:14:59 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 21:14:59 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:14:01 -0400 Subject: [PATCH v4 04/11] i3c: master: Fix dynamic address leak when 'assigned-address' is present Message-Id: <20240829-i3c_fix-v4-4-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li , stable@kernel.org X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724966082; l=3667; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=uz6xhxIxIAnIyubwtBkXjuhhwkKj4UjgCJHpQO5eyaA=; b=Roesay8np1PbKxGrXQ3hkNHYDpTVwaMlAy/eHLfxCBNNfSp5d0Pg8m5UwsvQ+rxkiVaEkXloc B0twHo4kYo4C+ZRYex1qK4n+YjFky9AWA9Wk2fUZypDUh6aT+yZfXJD X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB7560:EE_ X-MS-Office365-Filtering-Correlation-Id: 9806d1f2-0fc1-4719-2e36-08dcc86fa3a5 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q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ZqMOUYRctKtyBWFs4RrEhwns7pJQnUr?= =?utf-8?q?zuPCXRcRDsxtc8ojr8wBtpxsyYlmDsgmxPN8CW/cTVDRFocAvL0Hc5Jv/1aI3P1mc?= =?utf-8?q?cOPR/njwFh6J4CmzTh2xOXRL3r0QnxNKJ6nVhIJgiDlHskPx4naeNHqSokotnI5Ce?= =?utf-8?q?L5PSkeH5XX3AInEQsSt84cV9Vn+4A96ahnuEDq5Ya8fzu+dWmeRe+9N4qbXRdRg3F?= =?utf-8?q?0zKSGlh8cZpoMsopeLKsstxQ3hduGu7Wt4KVypG9+xpIa0w+vrHLPqIl2NgVs/HVd?= =?utf-8?q?qXUpc9yhtLH+iVo0kTkjp0WZEWU+twdBBBXyBPBQg1yXfSVwyD5F285gPt6EXrg29?= =?utf-8?q?Ek+6f5j1TN+oOXwBzLJ79REJ13xPntvxpKpHJZ5qR4WE+jjVJ7pObzjitivzzCw6X?= =?utf-8?q?zJPKZzLmC3iRtSiHWH7r43e71exNhzfbDPNmrUXazVeM0FOwiuhT83AWYi2sYl9vI?= =?utf-8?q?oqOpHM7FOs5jvWC7HYKRjq5JYYpw6R7VGA=3D=3D?= 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:(13230040)(1800799024)(366016)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Tr241xkapeYp0Su6zogiYZSOHdiM?= =?utf-8?q?uZvmX/nZR0uu8qZx7t8EQqMugn+vmmwoyTB2o92kVZpzVcXJu3lLNF6OwvElPfJMD?= =?utf-8?q?pnrtdS46qD7YRECtorF0rF8qmFXJiujVKpkT3O+C3YolLMYjUddtKkNsRma07oxDu?= =?utf-8?q?s5HLjhA5RS5IAA7JS1c6MI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QeEwOYUuxY1Ce/QXCS163bE9TJEdx8zqxydtCGSfJzr?= =?utf-8?q?BgI7GO//XifRUTwyXsvweI/BsHo3lKk+kveEYCiJpsBe4BKd0U52jzDYgdIrMPZ3I?= =?utf-8?q?JycDso6D1ZA3tSn0JwlRkvboC9rHCmyVMGjbfs7ND355IzK1o5a4Z7RJXxi+BSCr2?= =?utf-8?q?eljHsxisNEEVtGtYdQBA0NhLbZ5kVFIaM5/HDqWJXBEmeYxnhzPYpTR/TmQ3YXMMF?= =?utf-8?q?Ub7J+dX95Rts3HqeXTtEaTM3h/GCSaXg17MuEBCwGAvBgtRvtM2CPsj5gHaypcx5Z?= =?utf-8?q?etGg9baFCW1oumcHIKp4oTrPLRAizJyHlE5iEpY71viNSxxmrK5+Gd1/eEvWrVq77?= =?utf-8?q?r1E8uVXqItjq1ZUWvbHL4uIgpDE5jD6EOLc+0D5ktrGjI8IwADqkigTWOxo4XDx13?= =?utf-8?q?N1vg5HszRl2roMah2kbOv2ZEieLyGnjt4Cn1GnGm/HMLmVavwZfs2UzEVNiVOLtFH?= =?utf-8?q?Dqs6vdbW6hHS?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9806d1f2-0fc1-4719-2e36-08dcc86fa3a5 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:14:59.3274 (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: r3H+cQ05VSbFTM2aCD5eqJKa18/QlW/lTXvlYtRgh4z+cfcPanplvi+Gnd7UZxCR5QGOPGxrN4rDES9IOVs+aQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7560 If the DTS contains 'assigned-address', a dynamic address leak occurs during hotjoin events. Assume a device have assigned-address 0xb. - Device issue Hotjoin - Call i3c_master_do_daa() - Call driver xxx_do_daa() - Call i3c_master_get_free_addr() to get dynamic address 0x9 - i3c_master_add_i3c_dev_locked(0x9) - expected_dyn_addr = newdev->boardinfo->init_dyn_addr (0xb); - i3c_master_reattach_i3c_dev(newdev(0xb), old_dyn_addr(0x9)); - if (dev->info.dyn_addr != old_dyn_addr && ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0xb != 0x9 -> TRUE (!dev->boardinfo || ^^^^^^^^^^^^^^^ -> FALSE dev->info.dyn_addr != dev->boardinfo->init_dyn_addr)) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0xb != 0xb -> FALSE ... i3c_bus_set_addr_slot_status(&master->bus, old_dyn_addr, I3C_ADDR_SLOT_FREE); ^^^ This will be skipped. So old_dyn_addr never free } - i3c_master_get_free_addr() will return increased sequence number. Remove dev->info.dyn_addr != dev->boardinfo->init_dyn_addr condition check. dev->info.dyn_addr should be checked before calling this function because i3c_master_setnewda_locked() has already been called and the target device has already accepted dyn_addr. It is too late to check if dyn_addr is free in i3c_master_reattach_i3c_dev(). Add check to ensure expected_dyn_addr is free before i3c_master_setnewda_locked(). Fixes: cc3a392d69b6 ("i3c: master: fix for SETDASA and DAA process") Cc: stable@kernel.org Signed-off-by: Frank Li --- Change v3 to v4 - none --- drivers/i3c/master.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 1dad727e28435..7c8fc4378b979 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1556,16 +1556,9 @@ static int i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev, u8 old_dyn_addr) { struct i3c_master_controller *master = i3c_dev_get_master(dev); - enum i3c_addr_slot_status status; int ret; - if (dev->info.dyn_addr != old_dyn_addr && - (!dev->boardinfo || - dev->info.dyn_addr != dev->boardinfo->init_dyn_addr)) { - status = i3c_bus_get_addr_slot_status(&master->bus, - dev->info.dyn_addr); - if (status != I3C_ADDR_SLOT_FREE) - return -EBUSY; + if (dev->info.dyn_addr != old_dyn_addr) { i3c_bus_set_addr_slot_status(&master->bus, dev->info.dyn_addr, I3C_ADDR_SLOT_I3C_DEV); @@ -1956,9 +1949,10 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) goto err_rstdaa; } + /* Not mark as occupied until real device exist in bus */ i3c_bus_set_addr_slot_status_ext(&master->bus, i3cboardinfo->init_dyn_addr, - I3C_ADDR_SLOT_I3C_DEV | I3C_ADDR_SLOT_EXT_INIT); + I3C_ADDR_SLOT_EXT_INIT); /* * Only try to create/attach devices that have a static @@ -2126,7 +2120,8 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master, else expected_dyn_addr = newdev->info.dyn_addr; - if (newdev->info.dyn_addr != expected_dyn_addr) { + if (newdev->info.dyn_addr != expected_dyn_addr && + i3c_bus_get_addr_slot_status(&master->bus, expected_dyn_addr) == I3C_ADDR_SLOT_FREE) { /* * Try to apply the expected dynamic address. If it fails, keep * the address assigned by the master. From patchwork Thu Aug 29 21:14:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783896 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013062.outbound.protection.outlook.com [52.101.67.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F8021BAEC0 for ; Thu, 29 Aug 2024 21:15:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966107; cv=fail; b=jBFcONnweglOwB2DQVEhi+CusNSt6uXLFvjA/lEWKAKXmEKmpuNfhtRZE3c8wspUkFhVW81TkgqmbTjydY/8zj8LMH41RVv7YfsDCIQxMSprsORM+kJp0Th7SxSpp6NplYAjsm2PYkk+d+ixHRA2ByhFUA1n5nNN3pEac0BSaXI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966107; c=relaxed/simple; bh=ri9MIXRiXjqbTg39R5FGovPrvPxflLRVfGXm3ZFPAs0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=bG6LeBs+qBZtqlew4ilpH9MYNNELjOo0m1umQE9HVJkjSSPsAYmXUNvp7QJ+tjSmzJwBxUFvgjAFtq5Po/IpALPHSh4J/GanDRcz2AgbhpKpoLDpRssgo7UH0mMJf+EoIIRQCTCsOV6DZ1Cmt9UfjZ4OEIK1UCAsnO5vN3Rpbgw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=ZfQEBH3M; arc=fail smtp.client-ip=52.101.67.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="ZfQEBH3M" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mDuLDBK/UtzTXF5MWuC0yqfD+jZD405Tgwt9dCnwskhK3gcDZiIw0CcYFHyRTxBtDwcjwj8SZM4WznhcaUda3KxpCHbXgjanb7blaKZlQVo7RzwFI2X2Kkp0r1m+6UjHpTxnyO9Nh0KyJUhozjVQBdl9eXBNlDs+D0493+H7/+XaCD+6IdY6Oalzftpvm5R3WToZXthQk3gJa3vX3mQt86HFoqUXvxFIEpG5jxRm9PZ65Std/jHT47zaJ41fHo9eCOLm+60O/a7eUpYk/ApY68y89I+d2DPFWX2/dqkESvJbL8EvWV30qPs/QMf0MIjr7ChgbrgjUS0/R/Zj8B3tOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Cww+xyydNFuIwjFox6cDRmzfODgCjih+5wH/d19iPXE=; b=Sxrf4BxuH+aW/Pb4Ixx7k+jg6DJKtDWvfp8MRVZ0zvdcx106a6bjWpPvt6QejoszlY5IiIK8em4i0n+sbWudTlseF+UPsLFBZGJwz+I+FKCl2389OmXCgTohrYGBEI6d5oDEU2fT0DEvWAxggJdRAkllvfBnSFRxaFRVHpDH7BXUDwqc54ZiRiBRRE/+GRFv2vQHpl4RPXTzUhQ0ugAiIyS0voytO7XDKpt92uHMKM4OwTr1nzzGhflvR+xfN1ibVg+kSwDpzAk79dxO5IZyFAA8sZfLNKJIYIb5gEwr0/v6CbNDSMZu19pIBXOd+QQTHsfSGOl7/DvXYnZO7KQJ/w== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cww+xyydNFuIwjFox6cDRmzfODgCjih+5wH/d19iPXE=; b=ZfQEBH3MVlHW46+fBA/D6gatcGMuJ9IIbEJt0LzCNW03Nj19CYPHh+uRzF9P1KLP1xzodzCb/jx7nyY9ZzBY1PwHMkANJcOW39xr6nVK7XbSV3Ndt7BLsCXP9jyBT4jSgWmNIkVD4Ihtr16R0JwDfPSQ+6uQbk9jMSnHB88pEDX+lusWBgwMQqiquC8zLe2josFmk13bFqFIy3t5y1U7gHDmtiRbtbEfaNOX7cEDW+Wuo712YPI4MQWYZoInMGqNGhneubSkcUKQny7ZKOIYfrNPT/DCk2j6X8h7QdIoX+4XDJlq5QVztcSvMJT3E9zO5gtpmStHopsuwLvXi5/obg== 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 AS8PR04MB7560.eurprd04.prod.outlook.com (2603:10a6:20b:29d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.28; Thu, 29 Aug 2024 21:15:02 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 21:15:02 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:14:02 -0400 Subject: [PATCH v4 05/11] i3c: master: Fix miss free init_dyn_addr at i3c_master_put_i3c_addrs() Message-Id: <20240829-i3c_fix-v4-5-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li , stable@kernel.org X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724966083; l=1199; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=ri9MIXRiXjqbTg39R5FGovPrvPxflLRVfGXm3ZFPAs0=; b=bMB3QWwqqCes9ly5xS1nICwxaxtWpDAE97V0FjkwcTPA6PrPPoAcKO0qlBcqGKXgJKiF44FnC J74G2fbImxACxUkY7APZ4cT0Ir63tCQoyWBBD+OG7Jzs1B96140vM46 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB7560:EE_ X-MS-Office365-Filtering-Correlation-Id: 80eecb20-d659-453b-e440-08dcc86fa59f X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?a0V5ytwDLX1q7/wPCyOCb2SWSgWAOVl?= =?utf-8?q?zZCfZI/heORGQsSjQgWHPaqay9fqQ4TABPrxc962Om+o9I/2dqY4WfGFtwz08oHtY?= =?utf-8?q?FtF2upcmi1M69oVqSLDs4fouBUGjvVETk4TdKqb+/e9wPdyuR3K87mJdVMvRzdfoC?= =?utf-8?q?bdiqEN+DI8iCurvnowwzbGV+vbVUrhLTDRnCY5JL+FpycRRjoh6QmmmE/tTY74z+E?= =?utf-8?q?x/Cy7Y5OO0+8Alf2CBDq3CwUrIx3TrJTL9evTFibhXnzIn5+Zef3N5H230mQ9iWbf?= =?utf-8?q?catRG4YXlATUVQIIPX4YqYqZWsjIorR/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0uqv5WSidWTjKlpfS/TL5rvHmrHgYJWQukSb?= =?utf-8?q?MdiYCKA+GkFAcHVPkl4aG1anHSs2IGGqtxLJ/0T9qwslXl2euRQcBMHOC8WMHHWeo?= =?utf-8?q?BNkzCyyPTyIXeCYJFFDXPJIDGjDM79R/6Ps1DqhOd0DmogilKsSBYcxsnkYIbEahb?= =?utf-8?q?Mvg9e5l4WTgCmaaJLNfsQ+2uYaOV1OPAtw=3D=3D?= 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:(13230040)(1800799024)(366016)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?vy7yvcNYG+6AcsOZ4BHZOXLQdReN?= =?utf-8?q?2r7PLabbhEuv4AMeXhluGOZQI+Gy4WTkZ0AFY6T2C/Wpa9nbXS4+BY7Pr+8+TdE+a?= =?utf-8?q?kkD+1tvpggdYAOSKeWh0oVFuajUAI731U2VZWyZjV9DGo9XsCEzmkU5CbCFs5RvMm?= =?utf-8?q?yR78ql55YG89mVT6Lt5xmRY6fF/C7kzjF1FnZzTg/0Uv3nX/Hvra+uQmAkdyyjovY?= =?utf-8?q?uCQ5CxmPCipPSFh4PWNKAo8r+CCQ6BQpy7WNzJMqd8T1kMTI7M+KFOU/pcM3EHIxz?= =?utf-8?q?a+NJOljDR/qIdbSZ9//BxrGMeaHTAngy2VXzXadSQ+q0QVqPsnzTvvIpMdUoRrZ2v?= =?utf-8?q?jXcS7BI4EjZz7G1r1tMauORmXOGovhrUrx5tbygOS91HaEsXQTOtBuS+jt+oD9zXL?= =?utf-8?q?yWrsE+rBJfdigeEXGfQ3z3mykVC7+uNc+mpvYYSkL/0CDWFTVeofrxKw12Ps3kDSE?= =?utf-8?q?2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SUbRtkNw9WZ+U8nzSFEAGrGAhF8cjmx6fTx9YFR?= =?utf-8?q?eL3mk2gHxKMMvm/UEl87qdQMO3LmXdyM4x0Io6Ckw6RJ6nZ7j9Bq/k4TnjxcOzNci?= =?utf-8?q?sQMAMQ02VIzrWc+LFvjvjfJQjzPp5B1O1lxONE3qDVoaM6O0avUZch5oSBAFVpNeE?= =?utf-8?q?s2nY3hLD1rzg?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80eecb20-d659-453b-e440-08dcc86fa59f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:15:02.6456 (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: hD8RoeLWP55uPBlTG/xBVidqGl3HzXBtezCYHt4WCcyYPWXsWQPWwubX2yw59+EO68KxLZRtmrvQSH6+WaJcLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7560 if (dev->boardinfo && dev->boardinfo->init_dyn_addr) ^^^ here check "init_dyn_addr" i3c_bus_set_addr_slot_status(&master->bus, dev->info.dyn_addr, ...) ^^^^ free "dyn_addr" Fix copy/paste error "dyn_addr" by replacing it with "init_dyn_addr". Cc: stable@kernel.org Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure") Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- change from v3 to v4 - mention copy/paste error - Add Miquel's review tag --- drivers/i3c/master.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 7c8fc4378b979..e7cbfaf13b599 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1467,7 +1467,7 @@ static void i3c_master_put_i3c_addrs(struct i3c_dev_desc *dev) I3C_ADDR_SLOT_FREE); if (dev->boardinfo && dev->boardinfo->init_dyn_addr) - i3c_bus_set_addr_slot_status(&master->bus, dev->info.dyn_addr, + i3c_bus_set_addr_slot_status(&master->bus, dev->boardinfo->init_dyn_addr, I3C_ADDR_SLOT_FREE); } From patchwork Thu Aug 29 21:14:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783897 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013062.outbound.protection.outlook.com [52.101.67.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C5DA1B9B59 for ; Thu, 29 Aug 2024 21:15:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966109; cv=fail; b=CuFUDshEXRcuGcOA8hXfPlXKarIdGMiMjb9rF3rnaNllI4bVvr+1XefQyQ2FFT0ZyuXl6XqU6nDpu5ZvMeuklSnInK6oKefqVhMmCJTWCbqZsrg6Sej6lXZXT1aw1KTKV4sRK7Cq3IP+bb/0XYNQVNTtJTYcYmP89OAtzXtmwPw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966109; c=relaxed/simple; bh=qoRJEaDC8+N7UD0gElr8zzFjuK4hIVhisZJn1vsj63I=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=YoolUVyHbpUF0qVc4M+YHkacv96NBvycTljmfT1yzXbju9C0vH4Sc9iWlsguE080CFsB8M/7PYX8wH9nUTtSyNLt5EkVsRsQPWxkMFaaB7A6XxvZ7DvAFbFCHORRewBimVB5A0A6a4Px04iBmbWiAkfdAkTn5g5gvWg7deCv7Ks= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Dh6WkxuI; arc=fail smtp.client-ip=52.101.67.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Dh6WkxuI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vZAtHgw8nc9DdHp31vwQUEw6+Hc541LHQBjBgyoNpWCmNB0y06gsfTorv6lTrhZKy24224nQ0Vo1zd4FElXmhodT7Rh/u04yJBfbEvZqoAQbpl8VxLj+mnpQwGq5FXGr/ybi+KOPgnzTLMv49Br2BWLZ8gjO54S2Qyx035fy7ZCZQ6WkwrneeLK0W8F8Ca6Zsr4eiQOMD8qO4HKRllt81iytkT/rEoO6l/suzrMzwOQsn5PqtRUnJUiLxsIOdBZCeT7vhNlcaG2RN8RYgTft2yKJyMAmXG6fc1gfP4Ttc45PwsLrmoXzuOBHIrCFxepo8XCQsCbTMS+vdlpen69pFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Uyx+TpP5xfbE3/AGBE1UbCF/0NSSEri7MUmkmrHirSs=; b=Y9+/G4oVx2XzW2Do6ZPVD6eFDpk76I/UkH/eByXv6l+awDsZiKHPrOMr7Q/bWF/5y29gBmZQOszjlk7wuHLJ+3XuKPyN0rYsRDI4kTViI4vMxTNFNBQ6U3EXMvXD4a/fSiBMgnhbUOXkpxPUhXJqBHJOvW566iB30X1YZt40O8WXD3G7XVHyXMp6KFxvDiLKVFl20TsCXQLmwsO89XILiEyIWILV5oFjCh4DSEQaI7bJe2tjetKQlzJiuPkFG+aq7L1yWhYj3yaRFgJ7AVInBjhcKvRVHf/HW5dA5L9Cb8aJd6yl7fhqk44dTZ9pctc8NwnjR20VQFAX8etbJdK1Cg== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uyx+TpP5xfbE3/AGBE1UbCF/0NSSEri7MUmkmrHirSs=; b=Dh6WkxuIABVTFihQ9u1vQPLkBo4FBv9pSKYhZM+w/HdsvCvCboLve7ywEJWTugKK0Micd2N5CjgaJOB+mgB3/2DKg6sAExLdPM5DjOnWgFH3iwng8gsZDgdKwbC63Ru11LkP2TOm2FehAaNkv1ttWnbEGK3LHd6WzZ/mSK/gBnstHwf6kL+29HUD4yrhCS/NGcNSFyQo0D72t4tu529fB9v8lo5bS5p8JwrN31zy51GJ4pv7hIWq4HvYNi85aXZuvBw2f6ayo47g2VzniBZ7QmtL85yGDucllB1S45nUOj0B5iIqtaydWG5dIX6to4UtwsjQazLxXNDBNw5Ox8siLQ== 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 AS8PR04MB7560.eurprd04.prod.outlook.com (2603:10a6:20b:29d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.28; Thu, 29 Aug 2024 21:15:05 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 21:15:05 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:14:03 -0400 Subject: [PATCH v4 06/11] i3c: master: svc: use repeat start when IBI WIN happens Message-Id: <20240829-i3c_fix-v4-6-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724966083; l=3646; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=qoRJEaDC8+N7UD0gElr8zzFjuK4hIVhisZJn1vsj63I=; b=c/nYztxEZCygiNF55pTkPl7g1jp+0wK+QHV+VrvuzVHhrUuK16zWNzRXqRyGvpyZCNIj4qQNC ldDjtCA3SfZA3rKxSl28TJYXV/0vvWCVtIg1hjIB2UJWGHS9doLFpaz X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB7560:EE_ X-MS-Office365-Filtering-Correlation-Id: df60bbe9-194a-4290-82f9-08dcc86fa77c X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?T/YEUiXPNso+rwnzZH1RxFIw495UnhO?= =?utf-8?q?oBLssULwaNUGbmM7Uu1UYpa3mkUtzE1zMSMrEkiU4AXhaKZs3TXqNkbJjNt2SIHoD?= =?utf-8?q?F7Nyc9S7+oWViNhnspVjeqLtngin0ArP5IsGL/U5OvDYFk1EihZF4KIZOaETlyCzr?= =?utf-8?q?AsTB1zMNP+VwOLD6cS2BqzZoAUvKJqxUBY7PuBib4cgX/ci7AqqrDWlsMbk9o8gH0?= =?utf-8?q?905shs9CTkX1VOxosfZ3LOdLoJbgypkzzErcox8HEPUhltAGniPiIOXjuVeZg44A0?= =?utf-8?q?HumdCyfWmHJLhMyJHyiItjoXXgCEDlv2mGd1eRo7lvPMaYjPAoQofMK4O9v3fU7E8?= =?utf-8?q?BeS7i+SLqLYpKt1ZjutOXzqdHGdTA069u0RREmVQp/iBvYVcHyNPxN4PNgKjlSGwF?= =?utf-8?q?qavlDBwP/it5XXI0MM4VEmQ5f00EAmhUb33JXll/R5pKA4N+w4+kVf359QfDx9Xf+?= =?utf-8?q?xM0Qk556dmt1GqSNFYrht99C+G4fDT0thQUCWofgquD6otfPqQy7CuwEsHBjsxWvT?= =?utf-8?q?kPPuRoiiR28L707rkHygIlqsHYjnPK6su7A5arUy1PJkL35La7ypS26VxFoHq+n/L?= =?utf-8?q?VEI9Aal7IM4P6FjjBh7lTcFsDBMnH1HS7iX8pphPLsV2yMKaZKYyS/Kc3Kf10V/FF?= =?utf-8?q?rHqym7qFu83ww4+wXriVjYr97zpBuBL3Gx7LGa13+To9lZf94IrytTYcPlfowxdmK?= =?utf-8?q?Arqwyb8nbKRlQ/5YWIp5MpPiLlrfzTFcAkaatdSawCIK5ohTcydGel7QNqpNXiz/t?= =?utf-8?q?mnDhUg4iQuNGdxXGEkhr8VDDgGq3PIawIkQjEk0zSR/BXPiI3hSfWeGVa1T+1h7xN?= =?utf-8?q?Gg1gYijpKokL01cw7I+C8EcvG4y7SEwsez0F4Nv2wzIvtt5I1+ywW7lbX3yZXpgR6?= =?utf-8?q?kkkWY3z1pC/IvT1aLIjP/axmZdVP2Zo3Ms2r7msC8ho3xOMC989KtRrXLw50NtsLo?= =?utf-8?q?3QxClrsj2ZHK+inCQ13uPybNtfxGacme75/iopnrf/1TSfypI5X6Hec1n2Gw1ww/6?= =?utf-8?q?3wctz3zg28n/K38oYDDR9c8u6x8Z3PGHhauVWp4mexByQtb4d5t4sdkPuw521gwvC?= =?utf-8?q?FwhDLEc+vWCB1EYQJDyNZ3Dy4kHAuanGVAzcPBIJAFNfNBtK67oyn4SCA2DwD2AwZ?= =?utf-8?q?OzATv9STy6k2wkW4DgU1Mbbs9kaniAe4oUHrl0q2iv0HX0QPZ0KNOolwVBAYTvJ8G?= =?utf-8?q?ydfSf5kKE7cVNtU/BBuyFOcFpBuKCQVnmerL6pUXB+DF+dhCZcO7wPlxNHbSTi0gq?= =?utf-8?q?/mslIxOnIgtF6EUPbuaPvG9W/PQPZNZZ8t7/KKdF70AHbBXqtitGoWFfWZJw+IjmB?= =?utf-8?q?5YiZ/ksi9o+4yC68zdTcvr6SPH0/pj/Ikg=3D=3D?= 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:(13230040)(1800799024)(366016)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8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0e11927NMSeJ0OWrjB2E1yJ?= =?utf-8?q?tjgkvlRrJiK9RR8ElKAiPxrgpzNTQeXNUIIXvlUBm0KZNCuzqVlVTQvCzR7Umm2ke?= =?utf-8?q?g8vgyY5w+aoScRsou+HZDSVSUPYnHkcswQKdyF5I8dsdt0n4Fnav04ApY6ZFZrLgO?= =?utf-8?q?5pD9el/vH33wR8Turmhv+p84xeQdsJhp/cp/3Qf3Z/7P7wluoizXNrRbUnXZOtJVk?= =?utf-8?q?XSnz0DT0cnIMbKkVwK70m1tT6rmTMSztXZv/UWIzOnA7/D1ws+Z2/qM4p31WIbnOJ?= =?utf-8?q?EQHnBd3kTvtq2uoOz8I8M3Rin6LKR3uTea/xJxgFIcQLypXU7NxFiGcD1IvhHexkC?= =?utf-8?q?QVfdzspkVl8ysO2WSd0LF8dfAl1omHWt/Dk5w1vMoltGWURbe4vVFzRtgBMU0dRpP?= =?utf-8?q?CRbvFCiGHOog7dV024xfXYXwvlA/KvfaaUctXyA4767D2jtptLWu4bfMeRn4loQDI?= =?utf-8?q?jb3t3rXcpM+/WIwgRHafYakow59ZbgxYceFs6sw1S1C2xHaStPN+3CJ4J4FXwmDia?= =?utf-8?q?ENx4fyekbxN4iAP26+Ng7IFcZlSOOpP90wwINCJYnpYYY8/xTMGrhinkEUz13Mb05?= =?utf-8?q?rt/zMj65ror7dPxNrddao9cSnklAYvPDjXO06tZlUa8fW6TeBWDRGxjZspESBInWL?= =?utf-8?q?3yDZH0QNQhKy?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: df60bbe9-194a-4290-82f9-08dcc86fa77c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:15:05.8399 (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: 6X7JZFknLS++0EL/jME30IKXe6KQ+FPsN+HnggV5WK1gR1e8GuSsuwKJ9KAQAkcxr+FWNzchTpGd4U1tzsDz7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7560 There is a possibility of an IBI WIN occurring when addressing issues, even when sending CCC commands. Most of the time, returning -EAGAIN is acceptable, but the case below becomes highly complex. When a Hotjoin event occurs: - i3c_master_do_daa() - i3c_master_add_i3c_dev_locked() - A dynamic address (e.g., 0x9) is already set during DAA. - i3c_master_getpid_locked() - Another device issues HJ or IBI here. Returning -EAGAIN causes failure in adding the new device. However, the dynamic address(0x9) has already been assigned to this device. If another device issues HJ, it will get this address 0x9 again, causing two devices on the bus to use the same dynamic address 0x9. - Attempting to send RSTDAA when the first device fails at i3c_master_getpid_locked() could also fail when sending RSTDAA for the same reason. According to the I3C spec, address arbitration only happens at START, never at REPEAT start. Using repeat start when an IBI WIN occurs simplifies this case, as i3c_master_getpid_locked() will not return an error when another device tries to send HJ or IBI. Acked-by: Miquel Raynal Signed-off-by: Frank Li --- change from v3 to v4 - add miquel's ack tag --- drivers/i3c/master/svc-i3c-master.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 71a9359c5c794..ad999a1346686 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1099,6 +1099,24 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, if (ret) goto emit_stop; + /* + * According to I3C spec ver 1.1.1, 5.1.2.2.3 Consequence of Controller Starting a + * Frame with I3C Target Address. + * + * The I3C Controller normally should start a Frame, the Address may be arbitrated, + * and so the Controller shall monitor to see whether an In-Band Interrupt request, + * a Controller Role Request (i.e., Secondary Controller requests to become the + * Active Controller), or a Hot-Join Request has been made. + * + * If missed IBIWON check, the wrong data will be return. When IBIWON happen, issue + * repeat start. Address arbitrate only happen at START, never happen at REPEAT + * start. + */ + if (SVC_I3C_MSTATUS_IBIWON(reg)) { + writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); + continue; + } + 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. @@ -1132,24 +1150,6 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, } } - /* - * According to I3C spec ver 1.1.1, 5.1.2.2.3 Consequence of Controller Starting a Frame - * with I3C Target Address. - * - * The I3C Controller normally should start a Frame, the Address may be arbitrated, and so - * the Controller shall monitor to see whether an In-Band Interrupt request, a Controller - * Role Request (i.e., Secondary Controller requests to become the Active Controller), or - * a Hot-Join Request has been made. - * - * If missed IBIWON check, the wrong data will be return. When IBIWON happen, return failure - * and yield the above events handler. - */ - if (SVC_I3C_MSTATUS_IBIWON(reg)) { - ret = -EAGAIN; - *actual_len = 0; - goto emit_stop; - } - if (rnw) ret = svc_i3c_master_read(master, in, xfer_len); else From patchwork Thu Aug 29 21:14:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783898 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012066.outbound.protection.outlook.com [52.101.66.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38B491BB6BB for ; Thu, 29 Aug 2024 21:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966115; cv=fail; b=eDCP4IiSB8hstIRfamggJKMHW8j8qDCsZUVBlneo5GvHppvfThnSnYQDO37LEC1oxWhL3dXNm3wj0enf1Ss3JrBbDjuWk6vUECOCJMu4MFCz2icMe7BZP8otzIaJsZG7I128lRVZIxCcOw/4bLqwT9CM8raOLdV+yjLT1cDsRNE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966115; c=relaxed/simple; bh=Abu8R9fjCyCOO6LsZNj8SF9ckbtApgfch6j5wEiJ3L0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=s+i6e1Fe4RSpF+D6zJLs3g2b+BHBQlxp7IwsdfwPG77X1NN3ZfZ0lYTnAH6tORwW9Px9s9gKyYA+wc5tyzpFpIO2B6wStfy9mzUDC1ifT/7YHY3e31G7W9dulF+xhjVGy4g6P8Rx0Jrmh7L3eJI0Ib3HPvYKYOrY2l/nx6ICveg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=ZrEPAsl3; arc=fail smtp.client-ip=52.101.66.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="ZrEPAsl3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YobVni+mq3poyw4AzlilK79ka+vFch4UMsAFfqnlU8WjXTE6tIDY0a1OUdnP9ORa26ZIyLMBFtRYKsM8YqFcrcIPLdP79ARB0Sfo76S09ngKKo3KdsVQlSSRq9XLyCG8Xk3UcJXUxrVH2kY0YcFUvPM8cziNU1FPwc8WE6qCvdPvwExEtfj8Qm9yuGAV7buqU17dFV4zdKg9j4xrSo789HmjEFZ9WS7bKBgWvkuwOjFLdVJWpvVJBwpoGFhVSy3QIMEbckdmzpZfwq0iXOY46xGvioxDlVdtOil+jtwZemczQ0l683ZbZHffnieSwgD3ihPS4oe5JkyaEVJ+ecjYng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=JGcdrxq3VsDXfDuenVX/J6JpFFtyfXUUfnacJFSh40Q=; b=qfmWNCUgCsEQrn03ksrdnguOeUVHHLbfMhEQynSyWKrVNcLqAhmCQOmoRGWLfqZxBOiUhCLneWgBhy5e06i1SiwPs8WZZtn9spF8cH4Ag/EbwSmf/4tDsmj7e8y9ragWmrNhiBagODuY1gjMhvbXr1XutcTDkArRrcVwipj23+hsn7COgWKMdFM5L20VoTcXWAXWBC4QNBUf2R8TldMcFsYA3U/Z+4Up+PzGWYB9YXW7/f3AzPXv86dz54NKooiVkjJVE+m+BoDJ4ynsgdyqoWQuOmOwupEpIQx4cy4Z2v9qz0WmUgHRmSs78Gn2RnqM44ybTfANqPnaEvmLkmCBPQ== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JGcdrxq3VsDXfDuenVX/J6JpFFtyfXUUfnacJFSh40Q=; b=ZrEPAsl3Wnb5VVCcyiimPy3atnJTMqZrHsLx3P6uiFa+YnSm/5TYGgA1ZYYrCZFzq0p8dB1RuEHjKFJvod1Vhl3RR1kpiqB7QRsPcbYZYKp0alyxg4vvr/J+yfmENGO/da42moc39t4s5A3wMFqfLx3mA5oWetBjGNgaMIC0Z+dJseb/xWG4mUXJAQROZBcZFKGfdxTbz6Cr5Rk+Z1srftYOl+9T+96aoBZaudDZSlufJ6K+drf0FTMD5px+yXqvyajlXpgB13j7w6cVZW8En5EMi9WGacBCSuZYCr1eqkln156oRnnePw2sZv7EZPT5m5YCTnkFVxHM6a7vAwDRkA== 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 AM9PR04MB8971.eurprd04.prod.outlook.com (2603:10a6:20b:40a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 21:15:09 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 21:15:09 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:14:04 -0400 Subject: [PATCH v4 07/11] i3c: master: svc: manually emit NACK/ACK for hotjoin Message-Id: <20240829-i3c_fix-v4-7-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724966083; l=1870; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Abu8R9fjCyCOO6LsZNj8SF9ckbtApgfch6j5wEiJ3L0=; b=lNyY3IKUOLnuOh7Pz9pmkiRTkyrrKIcQYW38dRa4KN/3ICEhLIlwIyg4n6Rn+rraDgKgXEEKt yX5Auqk4+peAOMeBomHTz9hQvcEX1Qlh93x/U3mt3L1Nhr8loVKww9F X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8971:EE_ X-MS-Office365-Filtering-Correlation-Id: 72c58072-0607-436e-1a65-08dcc86fa963 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Udv2byenybrXbjzwz1desHB6yXi60XK?= =?utf-8?q?N4bZ2vaxUE3U9aFGxUKptvZb5xFq0lq6i7bdjQCB87TN2+mS1f00wDvcTCjtSvhwS?= =?utf-8?q?WEBOuA/m//RBBNLptSp5DIPFmvqzrtjw0O+m9yp2l6feCuuegNZrU09+B3yC1h/cJ?= =?utf-8?q?Vw8EzXxcHDrtTCRfNjYLAqaQ0VyNxjkesFlW4UAMwUzllE2Up5CnJ7KSeXRrUtt12?= =?utf-8?q?ggRnrJJowUhdUvnO2FEmUpu4PgM2Vk3e0toP0jAe9JZC5ty5nT3IlKzUL4lL4fYKK?= =?utf-8?q?IZiTd5QLlQwCrnchrx+meoKw+wsOOp0s3oLM1DRv1Ne098qQxt20JvGg9kVVAv8SE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sGz6g?= =?utf-8?q?oHcIASRmWhJOk8oOTaC1G2Ckcblr5NwMvtRxNXB0EhmJCMSXxUo/fPUyXVrHOHVkK?= =?utf-8?q?57g7uQbIlWrtZp1m8LUkrXhh7Pmb0ULZLU6ODc12ZPIM9FLICx0HE2Mw2qbEYXUbe?= =?utf-8?q?w0NHaimFAdEYunODSMvz3M8KGzlMkbpgjA=3D=3D?= 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:(13230040)(376014)(1800799024)(52116014)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?tOS4IvM4XCRCjzDn79Le9ypG3Hlk?= =?utf-8?q?8df77OaBA9ledW88+o504OEURCeiu5OPm168hTtKRock6W5mO0A3m74q8In6M70Ch?= =?utf-8?q?Wj0GWjVNNP/da+bjY6bjoRODDbIJuS4XJfnIt6PwN+1Pc+eQ+AaDVQdUun4oC1OER?= =?utf-8?q?hNC6tQFy+x59pRGClgDEGUDFf3Jbv3S+f4zdFn9P/YMN65wTW9rS3E4IxxPC70Hfv?= =?utf-8?q?lidXTP5D84NdmUADYz9Ft48CYTWi+6CR21Lqqt+nBw6ml4eQD7A4dogSa+ncB9hrD?= =?utf-8?q?VUQ51pvOpz1PwSaN43gIq9YFnIr75QgZV+F44KoW7tP/i4QuHf1kQqbvhHXcl+QTk?= =?utf-8?q?IsY7ydwINR/tcOjM3cCNO0wpXyzx2er07HJ4xS0U0jYuVfyyHjSM2gxDPjAjUfeEf?= =?utf-8?q?tty6Ia0mULVGMhinZoBmdjR0OJZXaPVc+2MW2D8i3tb4f/M64Ow7IfnykuTX6a2ea?= =?utf-8?q?0raS0Bz4MXf7mCN13pbF44fqTSc5rJxPRmrEuV+oSumBacc4yspku5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g6OKbe7?= =?utf-8?q?3Tuy2HDXYj6UZfa9GfXWzIhLFCxKkTfVJ0W3qgCbY6vWjEIqaF56pdB9NmsVCdE9c?= =?utf-8?q?AnO2RDM6menXcpPQnSwCfVyHv67zjqAowh/R5Oa9EVDCqo/JgTSBTbY1s5SA36SU6?= =?utf-8?q?jn559o0hTw7x?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72c58072-0607-436e-1a65-08dcc86fa963 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:15:08.9330 (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: achJiPKrjX64lc3o/If3jodcW3eXBdJzi6lqSiNx8uSZ+tN4vcKUdrhroUx4e/70cX2Yt5oPjJFUZACiYrD0Eg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8971 When the address is arbitrated at send address, the hardware can auto-send NACK if it is an IBI. However, manual emission of NACK/ACK is needed for hot join or controller request events. Add help function svc_i3c_master_handle_ibi_won() to check event type and send out NACK if the event is not an IBI. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- change from v3 to v4 - add Miquel review tag --- drivers/i3c/master/svc-i3c-master.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index ad999a1346686..122778b51c720 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -405,6 +405,24 @@ static void svc_i3c_master_nack_ibi(struct svc_i3c_master *master) master->regs + SVC_I3C_MCTRL); } +static int svc_i3c_master_handle_ibi_won(struct svc_i3c_master *master, u32 mstatus) +{ + u32 ibitype; + + ibitype = SVC_I3C_MSTATUS_IBITYPE(mstatus); + + writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); + + /* Hardware can't auto emit NACK for hot join and master request */ + switch (ibitype) { + case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN: + case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST: + svc_i3c_master_nack_ibi(master); + } + + return 0; +} + static void svc_i3c_master_ibi_work(struct work_struct *work) { struct svc_i3c_master *master = container_of(work, struct svc_i3c_master, ibi_work); @@ -1113,7 +1131,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, * start. */ if (SVC_I3C_MSTATUS_IBIWON(reg)) { - writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); + svc_i3c_master_handle_ibi_won(master, reg); continue; } From patchwork Thu Aug 29 21:14:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783899 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012066.outbound.protection.outlook.com [52.101.66.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 622431BBBD3 for ; Thu, 29 Aug 2024 21:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966117; cv=fail; b=ofO0U2mqtmR+BfEyqO0FEeDyMr0sZVjf5FvEuwxDQ52TRhRyylSMLUmIV9yFn8zBsDqfD+7MjrKtjl8r2ZuXEi26hMfM2dIMJAS2d95QGMtPZVcFEAU1wm7jmfZMu4GcNHEJNT6kS3s5ZCi5X0o6CbhBvMiMxmJXDL075xPxefc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966117; c=relaxed/simple; bh=/DYmw0y95BWfjnH0G+TXGaKcqfu2vSxvTBSnYz26UNQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Y5nKcsxtVZQN7jfiv/JjSQgmuCx6sSK6yL8tTB1kG9RIMukSubKAGBmhlw40qRdvdZyYPgG9eY0z+mH2uDACD4AjO1IWqB0SQGvA2s1YsQuVTqflDnURMhzDiDFX+YF+L9Jbbw7MXVSAxqtpYFHExFk+YTkmDYrwdDEzSHDC6LU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Fj34TkAu; arc=fail smtp.client-ip=52.101.66.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Fj34TkAu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BsX2kW48RS5AAJY71YG94c/dcZIHX/GM4kUys+iSE3tmXiHrVeV7TgNql0eSVVUziRAB/Zcf+B6nWWUnTwH4oGNISMVlJXacLlymDXWLTDuRzj4MNLbkB8vVjsK/sQxrAZSBCGM5WQoP3nfev8HjunuCg0yVwIpeHLnp2RinCgN209+kbQNgx49xZ8xpSOm1LfC+e/3YCmNdvjxa+U8/VNKNgOuFrvvFCDqhfJDK9SDMxKk4cBLpN95NibBgIm5ZPsa8H0rB9AXU2fe1iYtNpMaRRR1xd0/W6SqBDSjxn2cnd5r7zNLOLr4oNin2l+1nY+8RRrGGGL9Fo1AT0Js22Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=qtHOgUkiY+OlaDnc5CH8FSP37gdSlVXFHj8VUptrrcA=; b=KaRByRs+lwaCQsVAm5QGw92/PfZr9dxZp16iEfzF+9BRwP9oXMRUGDWhESSaFo/P8lO5C5C4yYFxZWoQPmYniowYDXmoYesSgVTydi0bv7l8qmGksEIihjSUFdZISwP4SKwrsx2877JZtGxQ1TZ9hP8AKd365Bccx/I/UgB3uRxCBw1cFbD6Tx/tPw8FLVFYhn2nNuOJiXsWDCzWLtLqbVy/9fBMU70LxdxbGqhGGWtu0GkyIm+J9B/dUoavknZqYsThg/7meIpvgvKtfDzESd/8+tdGmbKPpGlrBNq6saZLO7K8YM8cfWDurWKsfnJQzdAQiy7Z1VrlbE+pOkbcmA== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qtHOgUkiY+OlaDnc5CH8FSP37gdSlVXFHj8VUptrrcA=; b=Fj34TkAuMiEy+/1H9E/3wjvGcTx+YaOm2TTqzx0bzoPLlWrZB4emM47NQ90LkZASua001Dt7DVcg7J5nftOalCxoEMtSE7yTTYlhKiWDCuXPkXCQ7Two40JiLH1zUpTY8ajmdOe5Z5vGB2BxBqci2BIRFQxIeIH8+L7XJ+jfs6poIg2yZbdguBAWiPeEC4aOKUgpnuQoP2SMKiNsFcELhuJvoVvL6lubn5QW4ISmex2LQD45gHeGLHKokqv/fBxQYFCtNhy+3GdXyjfTyXni/4yluwaPYVfd+wrRBP7nhJr3E6ZZtMbqQdcFvZqQHLqwhoKEXC7dPsGKbxbwvxnpZg== 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 AM9PR04MB8971.eurprd04.prod.outlook.com (2603:10a6:20b:40a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 21:15:12 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 21:15:12 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:14:05 -0400 Subject: [PATCH v4 08/11] i3c: master: svc: need check IBIWON for dynamtica address assign Message-Id: <20240829-i3c_fix-v4-8-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724966083; l=1475; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=/DYmw0y95BWfjnH0G+TXGaKcqfu2vSxvTBSnYz26UNQ=; b=5Vj82rVaWs+0HccR5NC8hXRF9i00KOg3u/zGyBPBYlnxkU8IRVYGeT9bO3Hio0KImW7VoY9Hc rWE7ZOzWSnBB+M2njS4l7EHbfy2C7dSeRzFfb34Lfk3f+oVDwlDdJWm X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8971:EE_ X-MS-Office365-Filtering-Correlation-Id: a5af9033-94a6-4a7e-7ca7-08dcc86fab38 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?+Ky+sorg3s9rs+ZBcVB2CNKnbqn1cL9?= =?utf-8?q?Dt6G6DZzUE9b8yR6meY0iqJ5cK6On63VlHtf5YIbDCLfGXeztgrRxEN98rTyObztK?= =?utf-8?q?Fz0L1HcZ2UqhdXoZAJbeLH1s8eurncCOJdpxHfdfXt8H7wpMcGr7gj+mvcOs/+wSK?= =?utf-8?q?5VKukalhL2CK94XxCY72c/AE86/+rxnB/7Je9klkMcXKHOVjH9fVzLNoUR3/WIjpy?= =?utf-8?q?hq03k6TE1kvC+mew0nTPsuzOR157GwTECi6w+YI3C41ViESLBMieV2pRhiO/+gSZv?= =?utf-8?q?yZF8yg4hf8qhyow00dtberrB1UB9QCSmbgJ3BRApe13HUAQNKGWFLql0DOZN04daf?= =?utf-8?q?MkVhNDIozvPSaCfR0pHRRymQGbifs/jNI/NR+OYVDg8Yk151Jdui68YNNbvTmTs/c?= =?utf-8?q?DhCjvFk1q9Nm7vwhfjse6eYYUkpLFwOhZPYohEQqDGbfHI9h1+ADL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wexw8a1d9D+WZpf7pz89RY5?= =?utf-8?q?Xm0y8TP3YwUdMbIWOXSjsSaPVTaXVaeTOw=3D=3D?= 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:(13230040)(376014)(1800799024)(52116014)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?BVxxR2CI2KI0M3J3b3nKHe2VzpSv?= =?utf-8?q?mewWXq9m0gvkiY9lcKr7kpAu8t38/0S0ZJculko7h/cDXE7UdbLwssSHTHxn3L7Xn?= =?utf-8?q?rbOhX5NsoaPcc6ecgGRawDYeuHCaAQ2hIDHZ/sAn4tIMzxnyMrGXrtTEffsU1bPsj?= =?utf-8?q?vcLHD0X1hd3kixhCV65+XBAeVQkA7ACgf1ATgg/M3sI6A4sswdV8M1D2Si3TygYVH?= =?utf-8?q?RuwkxWnfHfYS8gKWPJNQoNgYn7vZsxgdAP7UCwgJb/kNEQwpuIpYDelkq1lue2aMw?= =?utf-8?q?R64wm+qH8O8BwsVe5F3jvqQFnwG2SVXASlKXNmejoDHdGTPacS6SY9sKvpcQnsaP7?= =?utf-8?q?pIE6fJbvIgOlCKu4kE6Dpth6NhSaGZPKLLwCdtYwIkq3AHjvUjhimowpH9ZAEbar6?= =?utf-8?q?njU8GMaXpEZPgXLkOyfpyXFBKY2ksbveBzsDx3N/j1BOl5tJGTr2IVbq+XQ+EXchy?= =?utf-8?q?8ccM/oW9TWJ3Mw1DPjxvjqgTiOL984RUd85jkyKD6Sl8b50Bz+RC70wDTZBzLKo6O?= =?utf-8?q?RMpWAFZq0q22I6RHzazG1ySqKHpp7ux0Zut3EuLK+GvIk4I0hdyc0NMTTOXeyB4BE?= =?utf-8?q?Tq8jFbDwa6cKXDrJWEB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u3l7ePHfA754gZM4ylspKX/TZm3VXYYcB2SveI?= =?utf-8?q?rbjIxdMKfkXE?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5af9033-94a6-4a7e-7ca7-08dcc86fab38 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:15:12.0556 (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: eaNbW2YBOo3bWdwZKQF59/4BtGMaFHbox81GAr/2TGZ5buDaBV8pKeN45KNshDDkPMNQlKH8PibRskVAsBNIlA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8971 When sending REQUEST_PROC_DAA, emit START and address 7E. Address arbitration may occur at this time if other devices trigger HJ, IBI, or CR events. When IBIWON happen during a REQUEST_PROC_DAA, NACK the IBI request then send a repeated start to continue current dynamtica address assign. Signed-off-by: Frank Li --- change from v3 to v4 - rework commit message --- drivers/i3c/master/svc-i3c-master.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 122778b51c720..9f456639d1aad 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -808,6 +808,9 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master, int ret, i; while (true) { + /* clean SVC_I3C_MINT_IBIWON w1c bits */ + writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); + /* SVC_I3C_MCTRL_REQUEST_PROC_DAA have two mode, ENTER DAA or PROCESS DAA. * * ENTER DAA: @@ -859,6 +862,9 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master, ret = svc_i3c_master_readb(master, data, 2); if (ret) break; + } else if (SVC_I3C_MSTATUS_IBIWON(reg)) { + svc_i3c_master_handle_ibi_won(master, reg); + continue; } else if (SVC_I3C_MSTATUS_MCTRLDONE(reg)) { if (SVC_I3C_MSTATUS_STATE_IDLE(reg) && SVC_I3C_MSTATUS_COMPLETE(reg)) { From patchwork Thu Aug 29 21:14:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783900 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012066.outbound.protection.outlook.com [52.101.66.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6049B1BBBD4 for ; Thu, 29 Aug 2024 21:15:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966119; cv=fail; b=UmyAsqPSLQqOZSKFbHvVkq5bBE+HFYprQcw36kbzSYWF2XSyAlsBnjiLXgyDGw4yokcuXhpskAAAe08dcVo8YgSZ5hpToGxGIZQcYBTtNwjAjphepdQCyp1Gx0wWJD2P+OnEu+UsJiZqgUJTzkWwV74Gw7Bx2J7WykJ5H92NvdQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966119; c=relaxed/simple; bh=8g39LLjNh6tgt2AoF/k4PMt/JQ4UPEhwPL8LAWtogv4=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=SzbfRQjAbq/Ev3WGcNqBUaTdQMUfXEXlQn4+r0tw4ab81sMqQ9XejxQXNc5sZp5BtcQZ7JFQ5Z2I0+PDlIDRMG8fK3LxyzsAsVpVDYNsjTiZa53w6ejdOPdF7VBOyvfYZU+ZmkZ5KlmiUMsmnsdSlLx3qj//u6oYL/Iv3px7qyk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=BTe6Cf6V; arc=fail smtp.client-ip=52.101.66.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="BTe6Cf6V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mmzREJ9U/uV7loBj03EKBTIoPWKXY0t3QhLgKVl9kkUilVg+175P+ubyEd4G6qbaA1omknPjyp3COPBUZfenKaolKDe88JFo3Q7fpUZDmxwo2Q1pCV//J9Nt1muW7LhIhibGPhsOnFtxEx0GCiZ0WbY1iFmCIe0tJDZSwBEwQi0y3SEKKvNOT79YvfIXBiINWaOeK9vGkqGOgd2yRhKRHsfBiqJAzDlsdyubbG3WTy9k4s1hNR2rhbALexpX2r05EkRPpZX/Jv6RjiStYHgM/lwzuLfnvha4ZY0PvbKV/ityrLhaI8K5lt8qMQS0iIy/KynHPuFA7ZQXtGbRtIpWSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=OXODyE4M+mQV57wFyvfvGmCTZpGJ/QbF0kDJVOYsNqQ=; b=MODfhhn+77nRCqQcHUib0BC+fIDTZlNkB5nET2U/WR5w6HQzBVkoIvapHBcBo5N2UR1DsbUhkTbQNX5WiYtUO+9kpNtU6Uv5jorOe8hjCtKKZlTysTG40Y+XWp9LE3kCiVaFbcKjYZS+LrsoPuSjwqY8ZUIi9MKWC5Jvd9LCSMr1nqO3JlwB/jDhWm10ONJqKe6paXa8kPBc6j1ZTG9sUvUhE8LRcv0erQ1c7JPHhJiEj1WEVtODRFij61IbnN4ikAM1335cu7kEXQVQ/beXVAO2dO6GkdBwSCMENNjv9bohNzcBX4RNznZcC0kyhJ1Uj6X4gaG8bWJIvu6ZwGMAsQ== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OXODyE4M+mQV57wFyvfvGmCTZpGJ/QbF0kDJVOYsNqQ=; b=BTe6Cf6VVW4seNrN0j+uroQvWYmWLgePqb8ZN+C/pVn2IqHvGkCsDAx4Gc4n3hwR66aHosL7+CbaVoq251KGHku07xvGPtk3l3p7vftwIc2pOiPwnAdV9ELbZy2mtZELbrVqeWP9PtAKRIgPpfzkwx7GjCpFEczXoTcw8ToQJsKwN8j0yYfok5ow2akEDOCuXxDNrvG6hcYzIdNSrGtvflc9Mp8HgYEZr4IaqrNYe09UTUEWqCsaIe2roOPhooYCf7lcEKKp77UAWilNKKMX7o44bN01H4sHdAuVs3Jv8CmMcjjHnz7A+kYGWQ5sHIQzMrg1Ij6to3MjG23eG0dd0w== 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 AM9PR04MB8971.eurprd04.prod.outlook.com (2603:10a6:20b:40a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 21:15:15 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 21:15:15 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:14:06 -0400 Subject: [PATCH v4 09/11] i3c: master: svc: use spin_lock_irqsave at svc_i3c_master_ibi_work() Message-Id: <20240829-i3c_fix-v4-9-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724966083; l=2497; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=8g39LLjNh6tgt2AoF/k4PMt/JQ4UPEhwPL8LAWtogv4=; b=yxdTXFHmhOc2CVduqHWpwSQ6h86NDCqImqQgbUCn+I+/GqB0N6Fdi/3RVzNBubcePafy4vIRZ bD24j/m1eJCBtpC0QCepojrjzHOnVBaFLMk1ErcZny2tQqV1nDZ+8Xg X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8971:EE_ X-MS-Office365-Filtering-Correlation-Id: b242bd20-9255-4397-7a1c-08dcc86fad17 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?JYB33DHMhkn+1rDGhvFouFxIf9QZsRk?= =?utf-8?q?I7NnQ9mOqR8vePeI0ocIBAtJzT6tUJGBLeLB/ucxa6tEYDT/PZ3cOwq5P+G1Kp25q?= =?utf-8?q?hRVQxMPbZpPRIrlFws1MoMRr2DEy0MqqUG2hbqDALbvNSc1+curZE9xiKPDMuslAi?= =?utf-8?q?snYM+NRi5Ea5/m5GpeeEWhgwjuhsi7DEHQ65JqGkFPgTV2LGRblpQTMYjNpQXtMc7?= =?utf-8?q?7z+lXaArc7zBJqec9HWAS3pFp1yMH1RPLmuFKGstkjpc07/Sxr+1Cv9DG1+McCfCG?= =?utf-8?q?gIzH02w8aMrLtYASy7z+SNyt/wKHmc7EgO1hC5+0UsI5W+JDDVi/s/QFMUd7uOai4?= =?utf-8?q?VLCRlvK7BPniyNw1qE5qAwXbhjrKuRObZzWqe8H/D4xgr/T99gf5uH+eZDLUU6PbM?= =?utf-8?q?bjiPGUVSJe3BlL+ogzVnaYeWw3g96qU04lsA9jWotW+XGPp9s3KW/c4eEyBI4sLlW?= =?utf-8?q?HZ7/vVfn0V0QWwrFdtp2OUCoLqTAFk1EqMYWIWxnmPxyr99RNKPCYAR+dKVow2+Ou?= =?utf-8?q?ze0n65U9JcEx5bIcLoW3QenCX7leNMQiT1ml7XapIAUmYSPx0KADQCVzCYKKamhmT?= =?utf-8?q?2TUIirrvMVa+x4Yov5CtvWo93m3On0djRtpC1ixahpADe/89nU/3YxtLHK9nAN5AH?= =?utf-8?q?3mz2jPdwjdSGtkebaId9J9F1prQG6HyBIly5E4tRChoRmq7ea4RUOMLydknCHlZG6?= =?utf-8?q?E5WvF2itk1Fz/nOKval2qF3gE6JTrJD1jdrMGS0MTSUKiO/SttVYJigFWRWqAlQzo?= =?utf-8?q?JhYCW2O3DzmyaLqOUfhSrGMNhxPUDM6J1ESXPvvGgiyd5TKnZ6fHco/SYbLmgg7+k?= =?utf-8?q?eY2BkuOM9snmrMo1esVM+Up1OqX35gd5qgDqf5EUQgabgyZWTK/1MoMpCtGBVckOP?= =?utf-8?q?Qai4WbHlgiuJPzmKHLKK2HaGbX7zBGiARQtplGAX//AnK1f9Agbfvb2hhKSDqISSY?= =?utf-8?q?dfrCMQEPGwXgGhlrnF5SJrYnqAT0ARZRJf8H9G8CHOeK0aba4H8O5X4Vpv+SNrWru?= =?utf-8?q?lIqVRbzCUmcvdjbCYfFa1lNARRPwnd5Rn25l/xRUSiKzgm8YxFHoFOgXU18ld/9wu?= =?utf-8?q?TVR/6SKzgDbyHtsNmq8ucLowSRHe+XLHysmDqg8dooLlNI8QXKrIQmetHdYPwBu9t?= =?utf-8?q?bh8CNaKbgJu5nxcQdxAZ+gBLGFj4y7u92WVbS46h6XkGIGgAGydId5WDFxLjN0sVQ?= =?utf-8?q?S4JBnTOq76/R+IYAggVj5IplTkP+rv6BrIBti7oNS9dmt7W69I+TzujiOlFJ3hgJf?= =?utf-8?q?dk2Gcq8sNZmFdBGO63/GeVwpUHwTCDhFmHI40c30G79F7xtcgMeZgBEQY1tazlKdp?= =?utf-8?q?xFMzgIZj+tY/4jBdRDftS3lcf959AFfdzQ=3D=3D?= 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:(13230040)(376014)(1800799024)(52116014)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?wRcLrP9EdoRJ9WexTA+LXZM5UBIh?= =?utf-8?q?JLwY/L3o47J/7w28J8lfPXtS+MZVsLkZGnkqV9ti/XYunj5sZOCQX6aPW037N1MCk?= =?utf-8?q?yz04ke3uuv4sNnbWPq61AtIa6CwKHsPGLTtp8naoOydzqn0mIHvWTBHsQPIuuhdAY?= =?utf-8?q?VJGvaznyA/fPEYqsMAD6GDPWp+iwM9aUGuxDD9hoIyvn2mHf205kr2+hJKjMSfUhH?= =?utf-8?q?Adi0nqHxykTK03o9oTJqFPtdNyjrX+yL2Y6NnMV1rNhRbKpfAN3FBRYTRQph+4h+5?= =?utf-8?q?pplqYFO4W3WbQjXowhbFojW/6zkeelyWU5DrQXvwAR8lmRSQcTIFUv5X8Li+plgaY?= =?utf-8?q?EQzDPLjkmHbrsVyqqxVToCnDTbUXJlH/ueUoPaGpzpmUbFVF7+HJkHEdR1dCnS/Ri?= =?utf-8?q?nDC8OR5ToFBq/Hb3gBnOuisvQq59R6tEkpN6k3QX00z9L2PjNCTWKElgIXblgw97H?= =?utf-8?q?+y+aNqCq4/RuzQM6UYpUOpwbpu3/7zLrDTqD04indvLI+KUahKkV5+1OLJ15IYmKG?= =?utf-8?q?0nHaVijU203c2Qkc0afIUSlKDP/qDTskslHsjJT1dwQR05aM6seUM1pup5yxL6qPo?= =?utf-8?q?rHWWNw4hz0ctllAe7JXIGE591QAonKZadIhFE02W7VnOoNUw0sxHeAyOcGtLWQJjL?= =?utf-8?q?3Qn+vbEdUtP0a03PwUJXgNJJxaM/q5hffglyc05eEBT+1t+KOc3ETVb9zVYobrWyF?= =?utf-8?q?LFOVPMxRS78llnfPPyZvXFrVzlwq3MdmYfztOy5b/FkrByeX0wzMouLERIWubSi2O?= =?utf-8?q?jlgS5kR4uMJ7PZXu4SWjihiL8ElQb32YfrM7a3rHN8I4tFECPxic0YqQCvZBMRspb?= =?utf-8?q?uweUOTyKqlAPRTG20qzP8UEKQiXaq4n35XBZodlik5kfRRtw/WWS09JOMuroKJo4/?= =?utf-8?q?buwUGxJHtb9y62znC0VpQUkb0xZ6vvQbqf2/Nvy4hjqnT3FMH/2OEpqjk7Zn3fn09?= =?utf-8?q?O/7MB6JeI+JguXilb/+217wznKBTVxyqjfnLkEzPF0klJu/1KOjNigO2qacPEx7Z+?= =?utf-8?q?bFIGx2hz7SMa/2CnEmMOQdVZGSMaEuqVzPCNXMqA8YMEcVvH2/xN+C9/7qb8SUzS/?= =?utf-8?q?qpMFMbAcLfbZ6nFF9kfBpxpHshFoxaebUmCbWoZ11CX3qcHfnghuxFgYAwTJ6WU8u?= =?utf-8?q?xqQRBlT/nk+ciS2mkYqcF8cLYe+zH1fVLnZjQvDuOOv4OplIND/Cvi0BD0Bdg155W?= =?utf-8?q?C+kJQgl8G/xRCRhvhBcZFcg1lc71MHBiV+Rf9arE/nLu3q/CWuUmzugIAjP8Dw2yk?= =?utf-8?q?xEX4wICfhfnyICh+SlLh6tSl2XrP6Yf5LXuhPhT4QWO0XZOZ/x/WuWGPawj91KUpa?= =?utf-8?q?a5C7vt3iN2bS8fUR16lfn0ovVghCirZg81Oi/FoyNkCzTAm7RVKkrzZ6i2QDxxr8O?= =?utf-8?q?m8DGP51S1TmCYOtn2GTjLVbP9UCcocCFk9jPdZGzUccyDSID+P0K8lC+mKQ4ccTuV?= =?utf-8?q?FFxCKlyUvea8yAgdoZmzCL0r7eFm7f9Fq/GYywcalZs0K6D8BBMQR9IxhBlldFPiA?= =?utf-8?q?R0GasdftrOgI?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b242bd20-9255-4397-7a1c-08dcc86fad17 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:15:15.1592 (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: Xnlt+6GOowj4yAugOqKe+ijCX9V1Ak+CIoaGj/eiS8rRTaoG+j4z23ZkiqM9wefmKub4LrDECkfBaBPh3MRBUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8971 According to I3C spec ver 1.1, 09-Jun-2021, section 5.1.2.5: The I3C Controller shall hold SCL low while the Bus is in ACK/NACK Phase of I3C/I2C transfer. But maximum stall time is 100us. The IRQs have to be disabled to prevent schedule during the whole I3C transaction, otherwise, the I3C bus timeout may happen if any irq or schedule happen during transaction. Replace mutex with spin_lock_irqsave() to avoid stalling SCL more than 100us. Signed-off-by: Frank Li --- Change from v3-v4 - improve commit message - needn't mutex here, other place already use spin_lock_saveirq to protent i3c transfer. --- drivers/i3c/master/svc-i3c-master.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 9f456639d1aad..2b000f446f1cc 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -432,7 +432,16 @@ static void svc_i3c_master_ibi_work(struct work_struct *work) u32 status, val; int ret; - mutex_lock(&master->lock); + /* + * According to I3C spec ver 1.1, 09-Jun-2021, section 5.1.2.5: + * + * The I3C Controller shall hold SCL low while the Bus is in ACK/NACK Phase of I3C/I2C + * transfer. But maximum stall time is 100us. The IRQs have to be disabled to prevent + * schedule during the whole I3C transaction, otherwise, the I3C bus timeout may happen if + * any irq or schedule happen during transaction. + */ + guard(spinlock_irqsave)(&master->xferqueue.lock); + /* * IBIWON may be set before SVC_I3C_MCTRL_REQUEST_AUTO_IBI, causing * readl_relaxed_poll_timeout() to return immediately. Consequently, @@ -452,7 +461,7 @@ static void svc_i3c_master_ibi_work(struct work_struct *work) master->regs + SVC_I3C_MCTRL); /* Wait for IBIWON, should take approximately 100us */ - ret = readl_relaxed_poll_timeout(master->regs + SVC_I3C_MSTATUS, val, + ret = readl_relaxed_poll_timeout_atomic(master->regs + SVC_I3C_MSTATUS, val, SVC_I3C_MSTATUS_IBIWON(val), 0, 1000); if (ret) { dev_err(master->dev, "Timeout when polling for IBIWON\n"); @@ -525,7 +534,6 @@ static void svc_i3c_master_ibi_work(struct work_struct *work) reenable_ibis: svc_i3c_master_enable_interrupts(master, SVC_I3C_MINT_SLVSTART); - mutex_unlock(&master->lock); } static irqreturn_t svc_i3c_master_irq_handler(int irq, void *dev_id) From patchwork Thu Aug 29 21:14:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783901 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012066.outbound.protection.outlook.com [52.101.66.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 977A51BC06D for ; Thu, 29 Aug 2024 21:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966121; cv=fail; b=XYhZMtkCG+AE97mNavQBP0baKdxVN/wS5VCZKB9I+svTYM9ZWQXgCGU4nkTF4ZZhMFujKS3vtKtLOsE360V7uz0N4Oj1FNVsqx0Sgxpy6Gk1TW8l4mM3+q5sP+gSquVONh01SmUwhKOsUEKzH4GXM4xXE+yB6lioDdG3Sj2EpVI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966121; c=relaxed/simple; bh=NDB+qerLSlJSMe5Bx3V4/wTHzJgVDT0s38KcjNPNozk=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=YDehaxrzDxIBQzjEKgjMx1JwGnJITjM71Ntrdbd2Lu5dZ8qlOnArrT/GQUaJZ6ZuUB2WIzSHdIZPZxrVcVEKojoEZm9gxFR4ThDdo8elb/ha3zrQUO1wBoMFN+Rw6FxtWOivM4Yrq2zYMD3IQUA6ag4G5cdNeWM4AQSPobjywtk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=cLEZiZsF; arc=fail smtp.client-ip=52.101.66.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="cLEZiZsF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qqyw4T9w8WyvrF0XYfSopzomCqIrf2YjFuiIrREvHP7pV1invaIZebZ/7qwL9vMyqG2T4zuc8Z/BXsgxwrjiE2i8Ksbso4gJgjxRFiNDHI6u/N2BnkWGD0JX98+HHvmsrW28eWrfVpgH4LXg2BvTb8q5B4Sa/KH+yjlHTtDV8gvUmOfA90I518+W+krUXwiP5Cmgbzujd0rNiOCHlJLhwCY+SZiGVRwCSpxB9J3jwHq7sIJeL1ZLnMRuyntT61EVyFIuGPkJOeuV9lRaeWTyhyblSw7SJCiW3Ur8QKWq6DqRyQ78mfvc5YIL8pHXMpohvbnEnZO8Zhk7PLX4GDjCaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=PCE5o8DgP/NdFwqb2zh1wIauPY2CTq86zMl6jwYhWFE=; b=GkLV4daMfEUS5qkS4Dmdh8S01foz75A5Y2uLkjUbERrP4dP2DqUsnDmxDCnXK+op9c3VM3A85k/Bg/Oq+ihlSCnBsbvTDMv7auOqinK2rrtWnFE4wxSwzyP57fvgnY3vJtK8w8J9S7LowDtwd32N76DTtzch2g5oS2y7fAkeYUT8YXTUjyyX4K6if6bDeJsq9bEO26ssRQvKjh5g7CO0LLUP0yxgSUPdQf2T5ParRFOhJUJyetLPB0Fpgn1PPjoo4EJ7F0wkRiLE3E+l+Bm+SYrs5Ya6e2xFHzLZ33bhIJZhMY0VjYddpZbhvu6Fibo//k0rh2jIufYKlx45holRbQ== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PCE5o8DgP/NdFwqb2zh1wIauPY2CTq86zMl6jwYhWFE=; b=cLEZiZsFH/yNERwW0bF0le03C6lglDFj9lYbzKvy6dy9J6B7RGNszHvlV6bAERVYsz8p2ByK8hghNW87SOnCxpA2sb1wpDBRPNcRVofADQ5A+yNHdnV/eO+SgApHYtQynO9DDBS3LqvKKVIvYzo0gIdscCulXeueH5hWS+4A2lbYxr96WGLufsMQ6yZOrlF9nkXZcZrwGzpWD0EUt1tC2/6p4EJWtQosVQkhtPEur2lTRxGclJ80VcvCrNRH/wXDWC957GxsexRIzedZvDRUaHeiePyGaLFEnNzrY8DS1QUzesL04aPSsxfUjP4n0pe45KSXZltVW9yzozjJYMI33g== 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 AM9PR04MB8971.eurprd04.prod.outlook.com (2603:10a6:20b:40a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 21:15:18 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 21:15:18 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:14:07 -0400 Subject: [PATCH v4 10/11] i3c: master: svc: wait for Manual ACK/NACK Done before next step Message-Id: <20240829-i3c_fix-v4-10-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724966083; l=3288; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=NDB+qerLSlJSMe5Bx3V4/wTHzJgVDT0s38KcjNPNozk=; b=q2n5Lsj5KFX1WFbYvjRQ2b8KMqUdUqNDdixIN/PnXZTIUoA6kE4xlWbSYZhZVt0OfStXm3vuc 3YPriMDXn4UCx/fDL6ea+YjqWu7xpajqmG+Hzik5rQcriQTLpbMVc9Z X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8971:EE_ X-MS-Office365-Filtering-Correlation-Id: 67de2b13-e2eb-4948-25f8-08dcc86faef3 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hlmwRrIiqu9exYw4LQTzwSdWQvSFbIS?= =?utf-8?q?LhTsCMBlkddzNmAWuIngRzBYLypzh6ZAhGk7Ci7Bl4ENENQAyP4vBRWXaI6yKaz5s?= =?utf-8?q?pCXG2wykvuamHm9rLOZfjojJUSU2sClUNfcGsoaizJ4Flif1pBbUQxyKdSEH73AtV?= =?utf-8?q?mgDcNk6Egb3LwE2yqUuJ0f4urwwPQSdgGDMpik48U37pHJ9TO/e0PKUH74+IBG63E?= =?utf-8?q?OQIhipta6CdsahOlAWpuE4IdhXy/3Keq7z+LZjDvguhpnkQR2ok9lop8/sEsRjUPz?= =?utf-8?q?DLaJrSRDkJz84hZ/LgZv+LYTK6HG3N1Uf/DM++F5gXteXxt4NsdR0P0qKg1SiBW96?= =?utf-8?q?GWDsvG8SjWBco8155DOAFPKc6TTahfTOK9UejGyNI8JJ4m8PK4zSfx6ZefwP+tGeU?= =?utf-8?q?2Ky7c4UflqviDmibzidIHUXIjYzjx0iETv7VfPU+ZyG+i4m06+I4ifZvktGD/tKMh?= =?utf-8?q?rkYdWmM8QLgorkKS0y7vaIecRmZwF2UHZypfKETVDHERc9HrrtU+qC7kYH+dpaoOo?= =?utf-8?q?9PL4q5AhKegOoz6r/jFpH3Qfu+bA8LQ9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PR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(52116014)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?sLOU22LvS9xqpTJ3/wcohmscTIck?= =?utf-8?q?U9lUF5oDNn6qxXFSSZDXfzIxEZW2Yn9KK5ySCqO5I27o8aQutsKxjCwTldErxvjeT?= =?utf-8?q?s8KouhZnLjVL4Y9uA6lUByMHPB2w83Vs0JEgyDzzw19UFtfsk5+XfaJ0Qq6Z05I40?= =?utf-8?q?0q6QCDnDNu/IkBFkTtxUtnef+9+dDwp8DLIXLQmUjoX80OlD3nOcSawLLLl4Ds7Ix?= =?utf-8?q?DWdv/4eo3G3QGvZGPTAqmIJaBaH92CwsW+uiMx83Acv6M1EdZSEnYUVM6EixWfRtJ?= =?utf-8?q?4HSD5JLyLMF2ETJP4uhwy0Z4jIzkDPZdYA55zSdSMyoA0QQIQ8S7EJNxKcEOvMv14?= =?utf-8?q?QjHv+dmmDzS0Kvs2kKaJuZ64aqkI/akM4AOfaTqYKuERupNCggHpFJWxk/R3HLr/V?= =?utf-8?q?Y8FYeOG8f0x958OdLBdAJymQ3VPlokty2qBUUGGz9/9kZXn1hUZPqMGbWwjEQG4Pq?= =?utf-8?q?5SDp/LXmI8L1CX1Tcurcx5t9HAcX7ty16NMVcUxHxac3rFCP7111hI/PXTjUZkPSL?= =?utf-8?q?x7naMLX4wXINRdXXmpD8nEaJZ/MkSt9B6RJ87GyyHVfHoFFHZ0bLL8WxEbAOaElBa?= =?utf-8?q?6nIVs15K2jQZzXxNx/pfpHSLcqpM9lvOG2C6HUlpW8CHaOWub4KfBjddKlOiuirve?= =?utf-8?q?ySGoaxzd2wypntvxo08f45ntUmoi9X9mxJHPrPV+J+xMjSB+9jjYINj+t/SPnlVQ5?= =?utf-8?q?HBcZewCG7kPDMTSJPnnpCYFKXf2x6fnRkV/uhM5ZjHU0ytyMrriApd3ctaG1BCKTB?= =?utf-8?q?qQVffsHPmkx+DI0V4D0m3bMT/m9Gu2q8A7AuDOOsORzdD651iuFtJsmCGcbKIxuII?= =?utf-8?q?r8NZxFKsbnHRx4IuOdPIHy8ph1hEagf1TOrGTYd3HYWeXy2/pR+4MJ3jgtP5n+sok?= =?utf-8?q?S6jDduiopGVo0TtOT6ExAD6GI29sxxO6eQpx+swxdORyNDKAO3kYYM23yF2qBCns9?= =?utf-8?q?UWk7dyc3eH8R7SrN5m+6YQgPsRVL+xpvlRYsShmaOHXvljPwcHggFv0WDTDTi1bew?= =?utf-8?q?NiaYH77Jcv8vUTWK38ehtnElpe8mA8rBrmXIuRVPZ+yNz7UN/17htwOhmtD/yKL3h?= =?utf-8?q?7OalgiKhwcqnvmxz/BZZldOoCGKf/hncAWfN0mL8IzQhUw5/CSM5IoXI99H4TUa9E?= =?utf-8?q?zoLml9J3QdxC7kUuUEBmHznq+Uryq7ME4yVJxLnpDiDy5efofWCPhEwVDGAJddN1e?= =?utf-8?q?pQdyXvdDvZpts0ibERVCWiG1KNOFg6CLcmX0/zH9TAQ+0PWtp7yQ6E2wc9Wt9QtH6?= =?utf-8?q?9KmN03+Pdk1WJu5fFek6roOR4BUJACwhirh8vK1/ibJl1sUBygGE3hUJpkNc4yDDi?= =?utf-8?q?CsT5Bhq099Lxw/5fVCEI9s8nOEawK6ZuUS+L3q35Knep4MMrX1uZq65v2E0QuoS40?= =?utf-8?q?5KSH5s8DxvBf+dgrCkPqSU8lRmr1i2IxDyjdfPwGF5izxOs+ti88+I5W1U4P6Lr6m?= =?utf-8?q?svRXhSgC/hORfIrMXLGSeJFOjGxvDYUBBcl5DI1JxFwCP8k2seV5MowNEnncTbr+6?= =?utf-8?q?LbQGNvfsb1lr?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67de2b13-e2eb-4948-25f8-08dcc86faef3 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:15:18.2784 (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: 63nWXblq+KeUyN8xSoD53dvQPCOyZ+iXwzI/0ksBqwuQ2Oeit6Q5DRbjac4L+bmCMMveHHXgiUZFF7gUiXawnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8971 Wait for the controller to complete emitting ACK/NACK, otherwise the next command may be omitted by the hardware. A "command done" check in svc_i3c_master_nack(ack)_ibi() and change the return type to int to flag possible timeouts. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- Change from v3 to v4 - rework commit message - add miquel's review tag - directly return readl(...) --- drivers/i3c/master/svc-i3c-master.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 2b000f446f1cc..83b2943074866 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -384,10 +384,11 @@ static int svc_i3c_master_handle_ibi(struct svc_i3c_master *master, return 0; } -static void svc_i3c_master_ack_ibi(struct svc_i3c_master *master, +static int svc_i3c_master_ack_ibi(struct svc_i3c_master *master, bool mandatory_byte) { unsigned int ibi_ack_nack; + u32 reg; ibi_ack_nack = SVC_I3C_MCTRL_REQUEST_IBI_ACKNACK; if (mandatory_byte) @@ -396,18 +397,30 @@ static void svc_i3c_master_ack_ibi(struct svc_i3c_master *master, ibi_ack_nack |= SVC_I3C_MCTRL_IBIRESP_ACK_WITHOUT_BYTE; writel(ibi_ack_nack, master->regs + SVC_I3C_MCTRL); + + return readl_poll_timeout_atomic(master->regs + SVC_I3C_MSTATUS, reg, + SVC_I3C_MSTATUS_MCTRLDONE(reg), 1, 1000); + } -static void svc_i3c_master_nack_ibi(struct svc_i3c_master *master) +static int svc_i3c_master_nack_ibi(struct svc_i3c_master *master) { + int ret; + u32 reg; + writel(SVC_I3C_MCTRL_REQUEST_IBI_ACKNACK | SVC_I3C_MCTRL_IBIRESP_NACK, master->regs + SVC_I3C_MCTRL); + + ret = readl_poll_timeout_atomic(master->regs + SVC_I3C_MSTATUS, reg, + SVC_I3C_MSTATUS_MCTRLDONE(reg), 1, 1000); + return ret; } static int svc_i3c_master_handle_ibi_won(struct svc_i3c_master *master, u32 mstatus) { u32 ibitype; + int ret = 0; ibitype = SVC_I3C_MSTATUS_IBITYPE(mstatus); @@ -417,10 +430,10 @@ static int svc_i3c_master_handle_ibi_won(struct svc_i3c_master *master, u32 msta switch (ibitype) { case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN: case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST: - svc_i3c_master_nack_ibi(master); + ret = svc_i3c_master_nack_ibi(master); } - return 0; + return ret; } static void svc_i3c_master_ibi_work(struct work_struct *work) @@ -871,7 +884,9 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master, if (ret) break; } else if (SVC_I3C_MSTATUS_IBIWON(reg)) { - svc_i3c_master_handle_ibi_won(master, reg); + ret = svc_i3c_master_handle_ibi_won(master, reg); + if (ret) + break; continue; } else if (SVC_I3C_MSTATUS_MCTRLDONE(reg)) { if (SVC_I3C_MSTATUS_STATE_IDLE(reg) && @@ -1145,7 +1160,9 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, * start. */ if (SVC_I3C_MSTATUS_IBIWON(reg)) { - svc_i3c_master_handle_ibi_won(master, reg); + ret = svc_i3c_master_handle_ibi_won(master, reg); + if (ret) + goto emit_stop; continue; } From patchwork Thu Aug 29 21:14:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13783902 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013059.outbound.protection.outlook.com [52.101.67.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10DE21BA286 for ; Thu, 29 Aug 2024 21:15:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966129; cv=fail; b=nh5WIeakMe2YXK+5u6cKHduLawf3WLHEs/JxZd2bI1bycXY6wEngZQn5HwRn6NvmviOWRlYts6Ea7pawuKwRAeF/tUYRBmD4bAQtMz5+tulB4HAOqsQCvNrSFsJ32iJ+aFlrB/v8/VUyY3GsN3Ii56pDKO1AJTNPYrkpp6xLFrE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724966129; c=relaxed/simple; bh=AHcqgly/vmoU+jJ+4HNr0fpgvCz9aPVFw5NId2LgYsM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=pivVC29zJDKl4b65FAhrXf/ZHIhgzMCSUh9ZMD9/uRpVQVL7rUJF3FLlMiDsXSOJ5qiY8tVr3N4bBuNYara3nPWFcLhhamYbXhhdX2sNuqiNAtuvaIgvWhaMatroXDS5nBscHBN9mEQLz4uGcPTvs5pAsA1HVrQYFsZxDP0a0+0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Eyn0RUq5; arc=fail smtp.client-ip=52.101.67.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Eyn0RUq5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZwxaHeP3MN9BaWjLwO61fPQMynQEQKOlRf8rRmHosmxtWF2oudyvDE+WcOEbjjDpQ7PGi4AZrDiGrAxiC0PZc2vwDkdolFhR09f0KbcUBSNIuih8yK4f4x2ssarA0w9v57oHM3SPZLDIcEvr56apXMyW3OwUOcxFLGHpQ2j7fWQUl4IA9sQ7ux4DOtDhbk5lXabMOMV35Tk7nvOE6Z21pia0WFbZy8hF9Vh8Y2wWi4Tqzsr+B5EsVBjMsZ4GhnN6Cc4Mq43BiEHql5AhA6iHDByFbb6QOAkM48vzqUiqtpXRpFQs4hyIFbr4lTx4IHAKC2rmIEAqh3W81hKx24jDtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=l+wM5XFFRbRdoH83tWAzH9EHEDGwXzNFWdNBvKh93EY=; b=sAxTnOIR0/Tc0Abp/IDfQI4nYm4eVEZl+oHhkQAUCB5xQ2BFBuI0osMScw90ppBigPtDb0doav1bYchbsxO2KI90zTn5RgPEdVhrtMAX9K0SN9czlGJiDESSc7zby7kBb34Ojhb6XszdQZbGsZdxupdGvwWAfdr3wYDZmSkG5ye8L5+4fzux9e8P1XvXqYVlOFt7Wnzw/i/2+QzHCzD48FdlJ2hT4gUUEjWq2gOtESio68NIJqX7IC9K293D88UyS4Qo9mg5EzixDWbjxsiOzusEuJGsBXOwovJyAPtU1pCNOc8EHjYxbqlHbg14qO4Tnjf2VGmO1hHk2j0ZWdHc9A== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l+wM5XFFRbRdoH83tWAzH9EHEDGwXzNFWdNBvKh93EY=; b=Eyn0RUq59+ydzykMiopNsweBdpst1oMq5T/MQKL46/pDnEcfx7w2MR0I/9NHu+bhkDc0iruNTwRyZZ5+QGq8qcVh19fRqxfA84Sjq7jxdyD7JPkD/eLrIJvTWuKPjvEicy+dy3KlEbJ+1AtJ0OULS7dTbzLtWhHpRVI6pBdITrHsMDGqc2eIADfDpmRHNMgDC1S7lA6JaZ9eCCUUBZqxOD48le7B8u20i09cu7EZCLLFerpGBZM+CYdMBmP95GY/Qr+Ff4x9cHtJDmvcClA9UCBHlzBKWBxrmgRCA2prWM6W1tmFnoUXOOzVkmNwqcHKdfEvTxcJ6CkK0bJFfGTw0Q== 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 AM9PR04MB8971.eurprd04.prod.outlook.com (2603:10a6:20b:40a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 21:15:21 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 21:15:21 +0000 From: Frank Li Date: Thu, 29 Aug 2024 17:14:08 -0400 Subject: [PATCH v4 11/11] i3c: master: svc: fix possible assignment of the same address to two devices Message-Id: <20240829-i3c_fix-v4-11-ebcbd5efceba@nxp.com> References: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> In-Reply-To: <20240829-i3c_fix-v4-0-ebcbd5efceba@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li , stable@kernel.org X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724966083; l=3184; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=AHcqgly/vmoU+jJ+4HNr0fpgvCz9aPVFw5NId2LgYsM=; b=0VnkJGxAJrsl06sm4Q7m0MJStVDIHL9X8VwXMfWEyiHZdMs19KXgj9cBZzvu/mZoO7o/agbna XxpkRjLB24PBzgJjoLbfBoLT7OIc77CR44IMpbqnnM3g7Vectva8HmV X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0219.namprd13.prod.outlook.com (2603:10b6:a03:2c1::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8971:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a6b77b2-82e0-44f9-a876-08dcc86fb119 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?CzncPul0yZP67tc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ohVpeU2UIvWzc1qKPzC?= =?utf-8?q?VGJF5UZUqdbfvQiJJl9UHpb0YuqoJ0CgsOO5MDzoqJX2tx6BOKPhexquw1X4YJS40?= =?utf-8?q?mzg28MScne2H9QBHVgxrmTZfHmGhEpNlSs3j8k6OjD4bSp5FI1UvyD6CHatGPw8o5?= =?utf-8?q?Rr2sdS0KOyM4S+FVLRKbWLifAtLpwglNrDBvb/NF7CpD0rIsYzVTlZsAqmQgWO1KZ?= =?utf-8?q?TISe44NgrDF+OixPy67yLAd41A9YNUR5bPykJUR9xT4/yOYSCfVWMEfWGxQ17Hnuw?= =?utf-8?q?gsHSyr0nrT76r5fnzkwF1cAihv5Jcoymp6YSdoyYREF47QRzU7/x4NE17CNtsFm25?= =?utf-8?q?f5I8aoUV7Dtst1fr+xMukk0WGtevdN1n3IY3c4etnXq6WqlwcDwZPx8zXOIc40QYK?= =?utf-8?q?rtlHK/hAhRrXGE3T4k4eefk78gVYIuG1dGsBYoATQmTp0QZj0X+7lTwmDVjyxiTGE?= =?utf-8?q?I/xyFttxIYscDbFSwdGw0VTRBH7O6tsKeg=3D=3D?= 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:(13230040)(376014)(1800799024)(52116014)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?e5Mi46ZuIVgbF8bywXyqyKavdtrx?= =?utf-8?q?A83cNA2F2Z4ETRzoAUyX8Tp3fOYoWLo/wlFBmD+SBSxkUfiRU8cIeNkYS8CLEZMrX?= =?utf-8?q?DJOKgdTAN2aInGTy7OLv4q5qY7eajs/28opS2SMPiGOzc7sw4dgfVQelYV2CCH9SP?= =?utf-8?q?6KQq5ghboWF9TUGcTzYgkyeiuAOkCA+a/Bp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XPyhdXgzs0xt729l2yJ6/NT593Gpe6JKY0f4Siim?= =?utf-8?q?oxESaSlbX/mv/OU/Q75rG84NFI81B+7Jh7xKnz9WUX5HL2auixSn2JAemFEYRiP0y?= =?utf-8?q?PlVfYrNo//i2n45j4jOrPeHyud3LK4ksB0YfYiCdXNbm9UuSkGnUlBm75QbhQAZAC?= =?utf-8?q?mk2cfFCRkurTkZ4shzrPtybnS8McNkqTee4k+rVD3+zZOfzS6/IRfDwmSdbaXXydj?= =?utf-8?q?yQfUMwZBOZ69jB9YmuLDfITFN/FbK+zbzYjovT3Dvat3E8tbH+40k2ZQuUec5i6Q7?= =?utf-8?q?7HhJPIyZBIs4a767z2/yOeJRtMJlkTUHTxtBMQynWdeXFRcac6nIelftsA7N/cxZ9?= =?utf-8?q?iEQG//XrGcZV1LyoybYHIGHHsZ7dGpZvmoL1Gimhb3NYBIu/czvw4uZRD9YAxlEsK?= =?utf-8?q?6yNKI3IbgXLgRvoSybk6chKgTRseEgoD/czce69rd8pwlx3qSB5/a50oUXWiriox5?= =?utf-8?q?AQStUOhCk1OY?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a6b77b2-82e0-44f9-a876-08dcc86fb119 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 21:15:21.9011 (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: dQk4Ej28I1weAx7kZza93Ulc0FGfZTaPPfh+f2m/0wC64762D/vT5la70piuHZ9hNO/hcsJSet30MpGBDitU6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8971 svc_i3c_master_do_daa() { ... for (i = 0; i < dev_nb; i++) { ret = i3c_master_add_i3c_dev_locked(m, addrs[i]); if (ret) goto rpm_out; } } If two devices (A and B) are detected in DAA and address 0xa is assigned to device A and 0xb to device B, a failure in i3c_master_add_i3c_dev_locked() for device A (addr: 0xa) could prevent device B (addr: 0xb) from being registered on the bus. The I3C stack might still consider 0xb a free address. If a subsequent Hotjoin occurs, 0xb might be assigned to Device A, causing both devices A and B to use the same address 0xb, violating the I3C specification. The return value for i3c_master_add_i3c_dev_locked() should not be checked because subsequent steps will scan the entire I3C bus, independent of whether i3c_master_add_i3c_dev_locked() returns success. If device A registration fails, there is still a chance to register device B. i3c_master_add_i3c_dev_locked() can reset DAA if a failure occurs while retrieving device information. Cc: stable@kernel.org Fixes: 317bacf960a4 ("i3c: master: add enable(disable) hot join in sys entry") Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- change from v3 to v4 - add comments about not check return value - add miquel's review tag --- drivers/i3c/master/svc-i3c-master.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 83b2943074866..a520f5482b592 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1039,12 +1039,27 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m) if (ret) goto rpm_out; - /* Register all devices who participated to the core */ - for (i = 0; i < dev_nb; i++) { - ret = i3c_master_add_i3c_dev_locked(m, addrs[i]); - if (ret) - goto rpm_out; - } + /* + * Register all devices who participated to the core + * + * If two devices (A and B) are detected in DAA and address 0xa is assigned to + * device A and 0xb to device B, a failure in i3c_master_add_i3c_dev_locked() + * for device A (addr: 0xa) could prevent device B (addr: 0xb) from being + * registered on the bus. The I3C stack might still consider 0xb a free + * address. If a subsequent Hotjoin occurs, 0xb might be assigned to Device A, + * causing both devices A and B to use the same address 0xb, violating the I3C + * specification. + * + * The return value for i3c_master_add_i3c_dev_locked() should not be checked + * because subsequent steps will scan the entire I3C bus, independent of + * whether i3c_master_add_i3c_dev_locked() returns success. + * + * If device A registration fails, there is still a chance to register device + * B. i3c_master_add_i3c_dev_locked() can reset DAA if a failure occurs while + * retrieving device information. + */ + for (i = 0; i < dev_nb; i++) + i3c_master_add_i3c_dev_locked(m, addrs[i]); /* Configure IBI auto-rules */ ret = svc_i3c_update_ibirules(master);