From patchwork Thu Sep 5 06:36:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhen X-Patchwork-Id: 13791781 X-Patchwork-Delegate: kuba@kernel.org Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2081.outbound.protection.outlook.com [40.107.255.81]) (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 7F58018950D; Thu, 5 Sep 2024 06:37:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725518281; cv=fail; b=QKE6y8/f+hXbVJQFLY6AEqQF4sPavYOdLwT3nwzs9yuOGKHxdzhmcS+jjymxxhv7P04HgCHqqN9WBqV6BVQaJsT8TocLsa4arx+k0HaA+Mxr4JkhfbOcbYotECDqTrPMPEJl23LpKMmkC6YBNDV/a4LHtgBlxMGleNT6dV4Bzq8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725518281; c=relaxed/simple; bh=tiisjBbrLwZypdTNDZ9PSaS37876/53LN0IZrJ1R9SA=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=GWdgTDsGX01lKwh3mPm//pqoCdGl+81U+It5ZgTb1rB+pUlxdfhSa3L5W7hiSxy4WiQNjDsOsaC4Tr29ItL7OWkBXGt59RSIu5r6z6QevBKhtuVokSH3pwMYVRPkanip+f901zDWylV9cXXyYDe8DWsOrMmuq0eNlT665tBRerI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=QV+AJ2vZ; arc=fail smtp.client-ip=40.107.255.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="QV+AJ2vZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=y7PcX+AoeWnpnRGTYomk0+MOpbMJySSeUfFtBMsOTaDTbYAEyrL1QM5S7MOEwAAFN3tlgpkmUpa4HtYpdWenxWhgElL0S5ZueovxbNRXV2VMq2cgsntvaojGDC1fHFEglrLfvuaccFBMwstQNCN2rAEEzsfrPEVaFRkMb9cocuJds6Kf4w1ElUkBAtmPi11ZOdYXetQSRmcmAaB8cRSQ/iAmTa4XbyHeuCFBNDuwNK4FyV6oJwVPT16lVREhfGvcgiYblLfoTKDJLXhs4GrlSyYKvdqgM54u0EAbYE/lGEZA5P0aUqa3CWc+HF1TM8/r5JQawQ1vcoobuQFKXhvlfg== 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=rNQYWPseIk7CBR08AKfqy/HQzs5vgzBPjvw0T9xw0i4=; b=dUu2sywY0JKnMHNCXYE4TQtUdXNq0ypc1AoW9v443fVBhYEM4xyAnSv+vaEZylRGHHA7ryKYNBFaT/IwwzrQE8QzGpYLFQlT58kLlmG4/88CQk6hygswEhn3wuvkrg2K33+rFO+CTbhgYal1U4BmVj3kD7MfqZhZ9dLujrh2nLEpYnrKB4FsdRJtpH8OqmgZC8YLi+ouGHqt3zCaW7biXXbnq1zKNXfjrNmeOCkiL4w4NWnb4obfF0jegJed0RaFkViTZhwR413OJFfyGdAX9OJtOg8AJJammSeTQKxnU7NoIOnu+TUhlEubtkH/UrG+d6Aq1b8fXW3epnfQnegGSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rNQYWPseIk7CBR08AKfqy/HQzs5vgzBPjvw0T9xw0i4=; b=QV+AJ2vZ5SQX1PL/2TNA9sI3R2peteOAberNXVM2+QsreuJKBymuNI8cH6zhun0NgJFv1Nqq1apbwVGAZSWvVo8vSTK5HX01EB6YaGkzr3Itr5ZvfFs9czi16n0JgD4PtjxtYMB57+1gai8EY5YWdciWSwdjIMVFhjT9IVN/XMwvNT19ygMHy0Wnr35dQ3pKjADE2A5GwExIY2M7scxqQgGCVx3GuNv5McbbYxKREt0WZhw580jrqgypTa2boYabGF4Cj69H9p9YYTaH4BeERO4VzgJMRSyTu8x0PTd/eBeozYpFaQHuUKVCC6eQPd7roTOpRDlzANQdJyBt0mpgFQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from KL1PR0601MB4113.apcprd06.prod.outlook.com (2603:1096:820:31::7) by TY0PR06MB5754.apcprd06.prod.outlook.com (2603:1096:400:270::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Thu, 5 Sep 2024 06:37:55 +0000 Received: from KL1PR0601MB4113.apcprd06.prod.outlook.com ([fe80::7e85:dad0:3f7:78a1]) by KL1PR0601MB4113.apcprd06.prod.outlook.com ([fe80::7e85:dad0:3f7:78a1%4]) with mapi id 15.20.7918.024; Thu, 5 Sep 2024 06:37:55 +0000 From: Yan Zhen To: marcin.s.wojtas@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, openkernel.kernel@vivo.com, horms@kernel.org, David.Laight@aculab.com, Yan Zhen Subject: [PATCH net-next v1] net: mvneta: Avoid the misuse of the '_t' variants Date: Thu, 5 Sep 2024 14:36:45 +0800 Message-Id: <20240905063645.586354-1-yanzhen@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: TYBP286CA0001.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:ce::13) To KL1PR0601MB4113.apcprd06.prod.outlook.com (2603:1096:820:31::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR0601MB4113:EE_|TY0PR06MB5754:EE_ X-MS-Office365-Filtering-Correlation-Id: 740da947-50a5-4c50-2b42-08dccd754645 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: S+bcI1KQK1eub3IIR17eyO7BD+cpqOS0vZ2NEXi6Gnu55xdkLHlV1WJgrqtCnGqiBds/5p7Gx2vADrptvH/xoU8gC4K1tHzSS0TUw8v4Gvq4DdrhfTlAOy43F2UCrdf6wgHNYe1SCOsA/YCLwm/FknskKutK+lrW5ovWL6n6C/H7uqzjnv/MC0X0+SzZtd1LkHYERrtC6BNrd9Tu2g9etIUYdya8ZM/EMuklPFLBgld8IGdZOM2gkdyAYEUtTJ/TbywL4lyTJ+u1O+kSRJbyja9Kd6ooBjQ7rG66zvBt3mLuN8htXGtwqR7X2q5SIaP808rsbUn7MBwoBEfil45jbyV9EGvzSoKXI+SwoCzNFLDHyycSxaSm5BFrxQUA3Xmv0I7oYPewnrGzhiRERitS2dGtsyY3QzvyqAp64hHzDUWBOsfw8eOOZEhFlLZa2xqGON7JAMG/vH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S:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zJClqe1Qwfg+oKVz8tyW3Xl9KY34dQG9YYGInWkA1/Y0eA6+de6bWPceiGcZtqRmVJ9xuuiHPx2D4vgnt/r+1BBJbVlIm8ipMQAk6W4bdQEQyEApPaGjmleJSL7EBI1VNrPKLSx56QWejKItEmvMWuJs8Q6nnUAVI7RvRvMQjNaP770afPlWORnXFsYSXWzYmFLCcGbB7KOKyHhau8/auEC1rH9hoWGUTLNwkXm07+5Z4oL+0u04g0aJL+SE3YPrSMYCrJQ6SzB/o0cN79iC/5GKlwhPhLuEMdgPMrw7BavxVmQL/+L7j0ISYfHyFNMpdqXMZRVUGl4WWU5V8YUsqkeG/I+tHQBQEv8MXt59lIwFHO32/0G0qVk/CVN0Md5FI/shSZzSsNnt571nYpWjvcwen7xfxgeJwWNTxoUafJuHmD3YBD2MHPJwT7jjgsS93asMZbvT1Amz60AqceiWTQCu6OtLAemz78C5jyEy05zUVM0uo6Uye1pkRGhJWzGbBsq+3MSRkOiUPM7m2buAEjBzNYhnq7IdUWbArdXaW6AiV51Hujpvjm5r8kZxEmrBYOsBDCOOMUow/upnJnzllPnl9xY3DnXA0e+Q6RwJ38dniwmpDUu8Ed1tW+S60sdPWiXhlq0makc14fs1MB0GN0g3Nm7+nzypdU2m2+H1WMVMUWE8Rra7OuNy3/90Z/JCzbmQi3rAjaBLfYRG7MMC9hwv8nIpVVvAT6QBPCzUi/C9++XUWreXYSkUNo3rrGsWgkwfobGXeTMKtFojMS8lQ6JeAdfwQBXk0igzAlL0pDWIEumf4rYd/1KkLuvj7PbrD11aBMXxxYT0rH5r5vMZh3MDkBIQ52IEE9sFmSaWT6guaNJSkqB7uzzaMeBOx4YwAj2vmogK44oOTJI9Vu7b24GOrPT8NwkRkwWKWEzZmoMGX/uD1aF+97F+7JcWwbfwi5vyDiiDfYQK8qNv2B4NfQd8o3WQLdCswd+ySBGcl8BRxf4WrBfna1fbH1OBaTELz4s8TKA+JYt20SNS9UWO8vAav48NM8aFkyi3HLh4qludGLlu5VTNpOYozWaUtbnqpgaaE/RhlwV+yk0PMtS0enJ7yBUx1dPyquNFrt8NJSSetKWUaMSOPR62NXxcayAX+UDKwx4Jr68Ay0axzR5LUpXWDr+s9rjVWPJtqmum5Etb3HaTCLjgO079PSpoKsilyU+ZSHGdmXRnV6/bAjS9aS11Ohmo9TMxwFDfmtXwMZfs7ysGtU58/9Z+d8wqECV0ZgesoPp9XI5pBt/NkVFGfoZ1XCOVyokKAQmvQLyRJ7NQi/3GxJlez95/zZwLVbn3lL2G9M/mNfMPyC+i0W9azan0LJMwmyHzJIOML4DZeFYDRQErp5B8g8hTccph+q1U4bNLQ+5CsvXtoipNi5myrsO7vc+NGVUYAQu9zCr9h5hBKX0BmMi5HxPGuJdUlXkgbcJgk2bB/GGBjAquaDNM7a72QvOz3pCxPa0BdL7I3couPirjU6xie/9MreiiLzl/Wqi5D32u/yH//j8EhIVdi6+/+8MNGgedsAuGELHqzcH7Yds894w+WI21Mw2ai48B X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 740da947-50a5-4c50-2b42-08dccd754645 X-MS-Exchange-CrossTenant-AuthSource: KL1PR0601MB4113.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2024 06:37:55.5155 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8PNBkMwNR+cgqYosxAwjDQAjDg0peT8/RwGHoK7JdvOW+Lzpw8lRJ2ClGCqELBSSjH4cSFh17npTAaLo4l03gA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5754 X-Patchwork-Delegate: kuba@kernel.org Type conversions (especially when narrowing down types) can lead to unexpected behavior and should be done with extreme caution. In this case if someone tries to set the tx_pending to 65536(0x10000), after forcing it to convert to u16, it becomes 0x0000, they will get the minimum supported size and not the maximum. Based on previous discussions [1], such behavior may confuse users or even create unexpected errors. [1] https://lore.kernel.org/netdev/d23dfbf563714d7090d163a075ca9a51@AcuMS.aculab.com/ Signed-off-by: Yan Zhen Reviewed-by: david.laight@aculab.com --- drivers/net/ethernet/marvell/mvneta.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index d72b2d5f96db..b41de182cc88 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -4753,8 +4753,8 @@ mvneta_ethtool_set_ringparam(struct net_device *dev, pp->rx_ring_size = ring->rx_pending < MVNETA_MAX_RXD ? ring->rx_pending : MVNETA_MAX_RXD; - pp->tx_ring_size = clamp_t(u16, ring->tx_pending, - MVNETA_MAX_SKB_DESCS * 2, MVNETA_MAX_TXD); + pp->tx_ring_size = clamp(ring->tx_pending, + MVNETA_MAX_SKB_DESCS * 2, MVNETA_MAX_TXD); if (pp->tx_ring_size != ring->tx_pending) netdev_warn(dev, "TX queue size set to %u (requested %u)\n", pp->tx_ring_size, ring->tx_pending);