From f6a24955ffdc7f270b9bbb69e1c42bb4360420b1 Mon Sep 17 00:00:00 2001 From: Chiqijun Date: Wed, 12 Aug 2020 15:05:44 +0000 Subject: [PATCH] net/hinic: Add the maximum value of the module parameter poll_weight driver inclusion category: bugfix bugzilla: 4472 ----------------------------------------------------------------------- When the module parameter poll_weight is set to 2^32-1, driver cannot receive packets. We limit the maximum value of poll weight with queue depth(4K). Signed-off-by: Chiqijun Reviewed-by: Zengweiliang Signed-off-by: Yang Yingliang --- drivers/net/ethernet/huawei/hinic/hinic_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c index d4b2f42ef462..1679c24eba9d 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c @@ -2527,12 +2527,23 @@ static int hinic_validate_parameters(struct hinic_lld_dev *lld_dev) bp_upper_thd = HINIC_RX_BP_UPPER_THD; } + /* Check poll_weight value, default poll_weight is 64. + * The poll_weight isn't more than max queue depth, + * so the valid value range is 1~4096. + */ if (!poll_weight) { nic_warn(&pdev->dev, "Module Parameter poll_weight can not be 0, resetting to %d\n", DEFAULT_POLL_WEIGHT); poll_weight = DEFAULT_POLL_WEIGHT; } + if (poll_weight > HINIC_MAX_QUEUE_DEPTH) { + nic_warn(&pdev->dev, "Module Parameter poll_weight value %u is out of 1~%d, resetting to max value %d\n", + poll_weight, HINIC_MAX_QUEUE_DEPTH, + HINIC_MAX_QUEUE_DEPTH); + poll_weight = HINIC_MAX_QUEUE_DEPTH; + } + /* check rx_buff value, default rx_buff is 2KB. * Invalid rx_buff include 2KB/4KB/8KB/16KB. */ -- GitLab