From patchwork Thu Aug 24 13:43:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13364205 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 7CFA41119C for ; Thu, 24 Aug 2023 13:45:33 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2047.outbound.protection.outlook.com [40.107.244.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF9E119BD for ; Thu, 24 Aug 2023 06:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FB6idi1zH3tN87ReGGD7nkHsdmpYtpYnhcaQwWlkmoIeGCNnv2NpvvREjuUqUuBrE+mTlX/JQpwIlkFHxfwJhY5mGgv3DVrCJ1EeYeFMrAqKx2nAznKGuLTwgW6njWV7ueCk1NyG6SbPhS6nrbXJH7DHVyqvQdy/9wJEN+pNOnmXgRhni0HU3+tauBOrfvCGX0gsQVW+CUYJs+5i1h4QFetkhhrf8sKTfVBysHlKfFMaCKRydm0JJlLoK3lJb7/ckUoTHYCZRrvPokk8BIBlGUMw09SmqLKO90Qt2yl6jNoBJ4AaN6vZy3LTwh4+5OQ44qKZsyqOx92AM3XwwRlTxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qLjjFyzLjJ5F2l0o/806PHhEJz9dt3ywOHAjvyBmcdk=; b=oKb+35Ej8jmn6NV+lBz+ObtQEbqM038EnUKy63gjhK3TGa3im5ClLomrBn33mZE8Erk4R21US/9UOS5AjFgYlPNFF4Ukp1rcP06Xs3d4pre63No0S41Y9z7gJZZLrm2Ia3F+heO8uMwkDMUQpC5IEZl4nkOnVIm7epchG6bB5agbyQN8Sq8xCykoaFoC3HL7MTLFnK/WPNDKx2l7CQToAG4nau4uX5Oqbm/JGEvLk5QBH2hYg/3Hxy2/2dDIMa+RN7R8As/nPhZ0n9RP2yshCiqkL+w7qD5MmfdumsYyZ3Hyddtx8EURLQDGy5F75GBSm54emUu2tDlsmGyWgIwTWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qLjjFyzLjJ5F2l0o/806PHhEJz9dt3ywOHAjvyBmcdk=; b=B2HlTJUzs609qeU+8RDxgeSxM8cUZfomz8sm45vPTENF6yT0a3hfiSj2d99oauH9ivNHrlpUVmlqe2lLPxbwhOHcGpaakg/H73THaw6+2ZKla0POG7J806SDjg1J44sJk8usGqqD8SHpOXXwkdWzIoi2XkE8eSQRv5mLzeIIFA19/TKG9YV9ojFbCjB+x1D6Dw2wi9GKWTOC/iihuL+zaMGBZsFWVnYJIlxPsJQ7q+hIhWaYZw4wGRhkZ4Amc5D0bDrLhEYU8juZ2baZvxcymp3htN6u5JRLiwpl3+bct67HoHWmQy4KwPJlzxK7BSl6GhvcN3pVGGVwl4PXL+BMwQ== Received: from CY5PR13CA0030.namprd13.prod.outlook.com (2603:10b6:930::18) by IA0PR12MB8373.namprd12.prod.outlook.com (2603:10b6:208:40d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 13:43:58 +0000 Received: from CY4PEPF0000E9CE.namprd03.prod.outlook.com (2603:10b6:930:0:cafe::c2) by CY5PR13CA0030.outlook.office365.com (2603:10b6:930::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Thu, 24 Aug 2023 13:43:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000E9CE.mail.protection.outlook.com (10.167.241.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.15 via Frontend Transport; Thu, 24 Aug 2023 13:43:57 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 24 Aug 2023 06:43:49 -0700 Received: from yaviefel.vdiclient.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 24 Aug 2023 06:43:44 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Jiri Pirko" , Vadim Pasternak , Subject: [PATCH net 1/3] mlxsw: i2c: Fix chunk size setting in output mailbox buffer Date: Thu, 24 Aug 2023 15:43:08 +0200 Message-ID: <5745ac4931a39021987addbabd38ca9aec0ab4dd.1692882703.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9CE:EE_|IA0PR12MB8373:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bca2301-84b5-499f-1bb1-08dba4a82aae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8FmoqQKDjQ5esvxQ+S/YnhaX8k6xBxBREMjJM+Nw4iCSgzpyRYMeMbuIVY6NLHR1KBkOLw5OK6bpgUEd7FZWsK3wVbGhZJrIhVRRHzUFX4srNEu9J1oBkvYHCEdK224/FULRR98VqaYR9abk1v7VEGYCTcy9pV4d6m6HcFbrm8A/XS//VcF75wRHjY6jbubG/VCy+cgIZ1MXPJCM0bXPeTWgKLeUJsZZk2zITHtEN5oPbp6Ts3IpmoW/NAs4CWziYsntow9C5l+N3gMNWRoRtDoRVSaguoC9zLFfeaRgWnBHKeGZvBsUrVIra66KfuIDz7uUpnZoLHM/7PdKzGaOpQmdq6G0m5AyghqV/Qrvx+NLMhabeBG2Dt45mCrzndpzfuz5QyGYFrEAW7BO++i304UKm+jTozAU5iLC+pgZ+Gcwz2/toRP1GoPVF+CcSqr49WYYpHC5GWfFyzsxUvvzfp2mF3c0h2ZXdbdTBBtI3zbKJ8cW+xRd0jDSi9MH+oiMEyevCHspukT7uBdP53HZNqUF+EwzwHUXKrcAiv3C9dkNQtRdmIKorbRApOCrAW/EoW7XSMjTzUpcgZFnTIVWq4VLGRXDA5o2Fgf7LeOjpTKCLPVd5NJgGArNbPzkfNlemi07FtCgmj0NnejWz1b3PCuMy6Z/5cXTCWT1bbemUAtW3LsmSgoA8Rc+JrYbYx6GBdf7Aywbn24vWYSZIzqvYJgqX0pllJNbWLg3gW1I+9EOFbU9Cr5ofBIY/BLmm4f2 X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(346002)(376002)(39860400002)(396003)(136003)(186009)(1800799009)(82310400011)(451199024)(46966006)(40470700004)(36840700001)(40460700003)(2616005)(5660300002)(107886003)(8676002)(8936002)(4326008)(336012)(426003)(47076005)(36756003)(83380400001)(15650500001)(7696005)(36860700001)(26005)(16526019)(40480700001)(82740400003)(356005)(7636003)(6666004)(70206006)(70586007)(54906003)(316002)(110136005)(478600001)(41300700001)(2906002)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 13:43:57.9009 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9bca2301-84b5-499f-1bb1-08dba4a82aae X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9CE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8373 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak The driver reads commands output from the output mailbox. If the size of the output mailbox is not a multiple of the transaction / block size, then the driver will not issue enough read transactions to read the entire output, which can result in driver initialization errors. Fix by determining the number of transactions using DIV_ROUND_UP(). Fixes: 3029a693beda ("mlxsw: i2c: Allow flexible setting of I2C transactions size") Signed-off-by: Vadim Pasternak Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/i2c.c b/drivers/net/ethernet/mellanox/mlxsw/i2c.c index 41298835a11e..47af7ef7e4ee 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/i2c.c +++ b/drivers/net/ethernet/mellanox/mlxsw/i2c.c @@ -444,7 +444,7 @@ mlxsw_i2c_cmd(struct device *dev, u16 opcode, u32 in_mod, size_t in_mbox_size, } else { /* No input mailbox is case of initialization query command. */ reg_size = MLXSW_I2C_MAX_DATA_SIZE; - num = reg_size / mlxsw_i2c->block_size; + num = DIV_ROUND_UP(reg_size, mlxsw_i2c->block_size); if (mutex_lock_interruptible(&mlxsw_i2c->cmd.lock) < 0) { dev_err(&client->dev, "Could not acquire lock"); From patchwork Thu Aug 24 13:43:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13364204 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 27F7C1118D for ; Thu, 24 Aug 2023 13:45:33 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2055.outbound.protection.outlook.com [40.107.244.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B63B19B4 for ; Thu, 24 Aug 2023 06:45:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TWSjMGT9iGHR0t218w6QW1rPTHpGiCYq1dkyYE1r0B4oyb4dlKndQfJhqEK4XCoeOyBoC2Xw26HZyVo5cmEAzTiY/HhasYFbVOd3LAhpNM35/lH8jwr/m91xGfx0jwpRcGM3fD1SfCzMepjHuvzCkvfdbbwomDr690fyrE/QtAv8KoD7S3WAM4MaWTRUdIUz6qRUe3Chnjh2QlFpHZOhC8xbjT2Q8bzPRlpmHFVmYDBbIzhacGh7U5/BlXAZ/ijTgNOIDP4+GipXiV2Ul1axkDBsgc1YpBX5ifAOieFKaf1TwkzNfmBJzFtEdF1AESqNM96HLWGu396NWyOBzNBLhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mL4kQVyh/wrQF4o//3OdKeUvHrr7e+lglpX5xTnLVBA=; b=Be7DFMhe8S/q4Kup/vB/10F4AoPTdP6tqCj7boQhU/ZRPpgPCp67PMh5B6O+PJ5mYiz820wZRFF66iifvgK2y5l4Wh4667WAvXIUvPdIOcr6B1UXup4nOxBbaiisgtw6n8VsTDXUNZcoTG8Nyl5dZmPaZot382CLRlBAYPmNmt0CYf2A+yzJ+FMQFbGLWwoyIVKpZvJXjlcopgO3mOghC30A5BFOl/E/em1F/wukXmmSSCN7yP9oacFIjBuS01jbx4N34QhhcHcBNuV8Lz89KuPHtuFnixtXG1bn8rjstwQhGgJ/LNriD0Sg2lWQzgrbIRGzl0rDwzS0HBv8A7KZyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mL4kQVyh/wrQF4o//3OdKeUvHrr7e+lglpX5xTnLVBA=; b=pVp8P9qL5Myt+NTB6hoUlTj8b6i0zpwrC4A8+756NL/opEhOEjJHPaeSenGEw+qbqZ2UEfjezWgWrND32WojQchz/K7yKrHRH1/lrZSKtfivpT8YADTqn5PP6yYsQr7kpuh9HYoOVQc5VjkjhWsu53hEssNp8CVP1kM3R5QGmgg6N4wmEMK8wdGVAgVXNBL7lZip3IQlGD3BkPPbc/u52GTcMpf5xJpO6C3rXCHajS7IhaWF0VufMhe5ANIWbRimWQoRFYpxvJileLuVv8hr5QzDEyfsnpxgCtqb9EfXxbh/OrJJqJrvSIW1OCQwGrk24QHVk9FH1DKyPzO9bEBJdw== Received: from CY5PR17CA0001.namprd17.prod.outlook.com (2603:10b6:930:17::6) by SA1PR12MB7221.namprd12.prod.outlook.com (2603:10b6:806:2bd::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 13:44:05 +0000 Received: from CY4PEPF0000E9CF.namprd03.prod.outlook.com (2603:10b6:930:17:cafe::54) by CY5PR17CA0001.outlook.office365.com (2603:10b6:930:17::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.26 via Frontend Transport; Thu, 24 Aug 2023 13:44:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000E9CF.mail.protection.outlook.com (10.167.241.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.15 via Frontend Transport; Thu, 24 Aug 2023 13:44:04 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 24 Aug 2023 06:43:53 -0700 Received: from yaviefel.vdiclient.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 24 Aug 2023 06:43:49 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Jiri Pirko" , Vadim Pasternak , Subject: [PATCH net 2/3] mlxsw: i2c: Limit single transaction buffer size Date: Thu, 24 Aug 2023 15:43:09 +0200 Message-ID: <8b083ce42e395da966fada1e93524e180660121a.1692882703.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9CF:EE_|SA1PR12MB7221:EE_ X-MS-Office365-Filtering-Correlation-Id: 98ffed1d-dfba-4019-6c11-08dba4a82e7a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Uz+sfv87Tj605mg1YOteVzzAZ/rZIHKdTHHJyUgd8h9S2u9kT1ARca4ukJUqJ5l0XM5yky1mLzrkDk28CwoWkWglJYq7STXAyj10+U3vjvob9Q/nq8/+ZnkRqJeLRcl9NyJFM9QsT98pvRkTIuRwBBBXpRLLuz/4rj2w5wwC8apLJeEW34szdZqGKeESN44RUqwH4Y5P9CCyoJ4YeLnpH2K6X8Z0bHg/smQBbMGku66WlnhNJPUwuZdyRbkG59rU6sanTtzqU4onG49ocPeB/lgipNB4CtkpLzim9H/SjOf3pD2J/H6wqcfBGDAirX1d0FneIB00pIxcHVzzrvZuWAQj/NXv+QDygNHxOF+PxIYjwDvrcoBrjbGkeaJjJxjzVZvJhmZBGBQol1DQZp0OWGPB2Zlf1G1hOoJWHGMA43+RxmnoJMne21DrnSrCbPm67ok8qGdItohsNdd4EU5nOG4sfY2D4Xq+Yj2nAFkBfQqG4MXU3VddMZDle9Gqu5bEgVtzAna/XkzMREOrXiXM4mKvGJf0g9Imywv3R54ntvJ38YHqW7yjFKooF8Uo+Sd1IiInF5hHwICLUHZmIJ1sE91BxnLGNfh84w4Sly1kaJYNZU5Fzefn5/AR80DRDZdpszPAnxWoX+ZeDFDZHmIs+GLCZV9/JqrtcG+yDbeCOJ/UcAzECzbIBi5ngpaqF4nd6IVs9cKnuTafiTrUsfPtxbkdmRhmahZyQCiqK0doh4tjSG9KhPYE/UOmtzGJ7vA X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(376002)(136003)(396003)(346002)(186009)(1800799009)(82310400011)(451199024)(36840700001)(40470700004)(46966006)(54906003)(70206006)(70586007)(316002)(478600001)(110136005)(40480700001)(16526019)(26005)(7636003)(6666004)(82740400003)(41300700001)(7696005)(86362001)(2906002)(356005)(4326008)(8936002)(8676002)(83380400001)(2616005)(40460700003)(107886003)(5660300002)(47076005)(426003)(336012)(36756003)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 13:44:04.2730 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98ffed1d-dfba-4019-6c11-08dba4a82e7a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9CF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7221 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak Maximum size of buffer is obtained from underlying I2C adapter and in case adapter allows I2C transaction buffer size greater than 100 bytes, transaction will fail due to firmware limitation. As a result driver will fail initialization. Limit the maximum size of transaction buffer by 100 bytes to fit to firmware. Remove unnecessary calculation: max_t(u16, MLXSW_I2C_BLK_DEF, quirk_size). This condition can not happened. Fixes: 3029a693beda ("mlxsw: i2c: Allow flexible setting of I2C transactions size") Signed-off-by: Vadim Pasternak Reviewed-by: Petr Machata Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/i2c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/i2c.c b/drivers/net/ethernet/mellanox/mlxsw/i2c.c index 47af7ef7e4ee..d23f293e285c 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/i2c.c +++ b/drivers/net/ethernet/mellanox/mlxsw/i2c.c @@ -48,6 +48,7 @@ #define MLXSW_I2C_MBOX_SIZE_BITS 12 #define MLXSW_I2C_ADDR_BUF_SIZE 4 #define MLXSW_I2C_BLK_DEF 32 +#define MLXSW_I2C_BLK_MAX 100 #define MLXSW_I2C_RETRY 5 #define MLXSW_I2C_TIMEOUT_MSECS 5000 #define MLXSW_I2C_MAX_DATA_SIZE 256 @@ -653,7 +654,7 @@ static int mlxsw_i2c_probe(struct i2c_client *client) return -EOPNOTSUPP; } - mlxsw_i2c->block_size = max_t(u16, MLXSW_I2C_BLK_DEF, + mlxsw_i2c->block_size = min_t(u16, MLXSW_I2C_BLK_MAX, min_t(u16, quirks->max_read_len, quirks->max_write_len)); } else { From patchwork Thu Aug 24 13:43:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13364202 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 AB98128906 for ; Thu, 24 Aug 2023 13:45:16 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::61b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 891091BE3 for ; Thu, 24 Aug 2023 06:44:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M6FZ9F20haPvV9b6EPYtM0pA7IIugdJ82c7MJAJ45k7xDHojxHfHhETfgumRUDWslrNn9p7A6+NZ9Y4HcdZqJ0w1wdTMF7Qs9cGrpqrIVthERQYDy84Xrkj+9u6/Z5dmDQoD1P0+OQCdgs5l7suv6epBODefDys5mJqBOy8w3Vhi+Clp2v+4RTwg982+zNugMoL2Fpe3xkxuN0YYAoVZj1/6FYL85DA3eTBtzocA18UtS7+BcV4Bk3dhdybTmMg5Z6EFkq6FjAycZHWD+tTlnwRQUQA9U3UMW5WJ43lAH8OAMYFVrTDgf5ofpOZ5B92fXexNl5jj71jz00I/9Efvdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1hCHhwmeadIafNIh+CSRRndX8DHSSZ5oMspAXh7i5OU=; b=l0CJAVNttDBkiErnUA7WDqjDaAoUzY1j+vmifi7Aag3l15f/0OCsh8FvmhWlmEKTr4f++TdKyRYnFGwm9l80fGcMu1OvxyvKRqyN9+PUEvtIk2GLvN1KrEjrDa7cYMtBrKyeellN1KobskUUokgWFz9N2gvIS00WgswGXtz9fNcMbQGjhx4Q+ranrwEDUbI8ssJI9edFzIFyOz3yJGqSxfg6nPg8F9+TderqdZG1gAuKI4oda4d1VvHAUUlIffpjO6MQot8zVUR8JM28qSPoZncddi8gsmXycS31/zyyV/g0GLR51tl4MKjpQeHZqb2zDmn15d84jfMVlzF3M70jGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1hCHhwmeadIafNIh+CSRRndX8DHSSZ5oMspAXh7i5OU=; b=WrsEq8Fe+aTTU/lIkR+5Jf+BXEEx0bl8K7Os6qhAU2sp4iyGzvMTA5B24gINdsrAWIhYX5wlzhPV+Z7RTzeHfdwKiQMl6V/pRTKgf1jnyxC2y3Qcr4AwCyXkRu59jEoRkfPjemfRPRV3wBrQ98OZKrwFrRdVMfSeJ7nv70UffjcdsBL/s/RhwcAlukFnVvzuPIobzdZcueiwNbJaFeBTOxNaqxcoGAgTZrhVe558SRDVHigP42OkSOWRZcSiGmnQIp8Pz+umngzWQnYoWXNGaxKPkCdShckf75aqR8gI+ZrHkazc1WeEqgD6+9LhFbjsKlhtTL8LFpjJbKQpCF57yA== Received: from CY5PR15CA0059.namprd15.prod.outlook.com (2603:10b6:930:1b::28) by MW6PR12MB9000.namprd12.prod.outlook.com (2603:10b6:303:24b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 13:44:10 +0000 Received: from CY4PEPF0000E9CD.namprd03.prod.outlook.com (2603:10b6:930:1b:cafe::f4) by CY5PR15CA0059.outlook.office365.com (2603:10b6:930:1b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27 via Frontend Transport; Thu, 24 Aug 2023 13:44:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000E9CD.mail.protection.outlook.com (10.167.241.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.15 via Frontend Transport; Thu, 24 Aug 2023 13:44:09 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 24 Aug 2023 06:43:57 -0700 Received: from yaviefel.vdiclient.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 24 Aug 2023 06:43:53 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Jiri Pirko" , Vadim Pasternak , Subject: [PATCH net 3/3] mlxsw: core_hwmon: Adjust module label names based on MTCAP sensor counter Date: Thu, 24 Aug 2023 15:43:10 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9CD:EE_|MW6PR12MB9000:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a69f8ad-2582-42fa-1a06-08dba4a831b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9C11GX0HdUCy/VAXIiREWU0F69Ku1kwCsbpxI+FNY8wXIWS8Zo+zANmVeh9KPy6ZutAbJdg3EH7RQ49gPgIbn+QOT7woo+VBVFA37rj9unwu8vtKa7SSFmo3H49G2lX2g2Wd//4F7aDyqr7PzpNXOKtAK1fpHjQ5sNh0oq8ndWz4Y/vICoX6zPNNnKqAgIh0Z6KZn4WmLMHogLVY0iJvMSlS6RJ36z+5N722HEf67CTGYe0vkYhztGLm2ttNUSo2j4Zvcl2UOTKQIEPFtJJyN4RZu+1Dvbye/Qe6NvNUQQCx2Ce6Qj7tdNsWoXjShA6f6J4NW4AlVG5SRWLJSMAD1hxS2bPFkeQuMlmm2Mc56dcSquJ1PtiSk9EYzknT0hemHcKEfJaIJnIvMuPyhTIoPEX0sRoStmhrQqu2cbhUgJF7DTGadf6CrYvFy94g0+StAn2G55aP2JMqrNfMsoOyc7a8mLVnb5eNH0DUl2HEuKECwIezYw11J6EulWq2QCtcxART1MKbVb/4MkLKLcyqR1tfmgx5KkSrhxoWR5UaHv40IWXWuPl/6bBQhbx/pMIu+0AaOTZ/Jl0PJ5W8KrxUPE1ZxPJDdsicVrCv3GmR5QCIOlErRcsO4QgcmuaUpjml/TrM3RA0Rl3H98VzgWhFoRNosQnKLLbWLsIHo5GW8z5CKEo6Emkw5lBT+WTMvfqX/hFcG8EnnVC2IVceVCW8dzhTllISJTE4bRa79yNdmY7FFNbwdWbl1u572grJkRA+ X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(396003)(39860400002)(346002)(136003)(376002)(1800799009)(451199024)(82310400011)(186009)(36840700001)(40470700004)(46966006)(86362001)(356005)(82740400003)(7636003)(36756003)(40460700003)(7696005)(6666004)(478600001)(5660300002)(316002)(70586007)(54906003)(2906002)(70206006)(8676002)(110136005)(4326008)(8936002)(40480700001)(26005)(16526019)(426003)(336012)(83380400001)(36860700001)(47076005)(41300700001)(2616005)(107886003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 13:44:09.6580 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a69f8ad-2582-42fa-1a06-08dba4a831b0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9CD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB9000 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak Transceiver module temperature sensors are indexed after ASIC and platform sensors. The current label printing method does not take this into account and simply prints the index of the transceiver module sensor. On new systems that have platform sensors this results in incorrect (shifted) transceiver module labels being printed: $ sensors [...] front panel 002: +37.0°C (crit = +70.0°C, emerg = +75.0°C) front panel 003: +47.0°C (crit = +70.0°C, emerg = +75.0°C) [...] Fix by taking the sensor count into account. After the fix: $ sensors [...] front panel 001: +37.0°C (crit = +70.0°C, emerg = +75.0°C) front panel 002: +47.0°C (crit = +70.0°C, emerg = +75.0°C) [...] Fixes: a53779de6a0e ("mlxsw: core: Add QSFP module temperature label attribute to hwmon") Signed-off-by: Vadim Pasternak Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c index 70735068cf29..0fd290d776ff 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c @@ -405,7 +405,8 @@ mlxsw_hwmon_module_temp_label_show(struct device *dev, container_of(attr, struct mlxsw_hwmon_attr, dev_attr); return sprintf(buf, "front panel %03u\n", - mlxsw_hwmon_attr->type_index); + mlxsw_hwmon_attr->type_index + 1 - + mlxsw_hwmon_attr->mlxsw_hwmon_dev->sensor_count); } static ssize_t