Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp431962imu; Wed, 19 Dec 2018 22:27:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ub7NCT/YB5eKcfEfvxw2+d0EXlVP7p+GKsNz3shmQdxMOBAovKoRHBae6BIG8fLndls/Vr X-Received: by 2002:a62:2606:: with SMTP id m6mr22715511pfm.133.1545287274123; Wed, 19 Dec 2018 22:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545287274; cv=none; d=google.com; s=arc-20160816; b=nWp0OxMz5+ghdDFv9N32B2kW1dQu30utn9+MGQvMgsrmLBRg3L3a3wLHILYdbGEO6E cME87nu0knvVh3ZmKlUX7ad5NebdUd+uJ6JU/0bt2/ptez+0sKUhgNFH4S7fbqVyIROi wRqFfUp30p7vkEdboB+Ls5rQhYl9MM0WjuKhUXbMENYCHkQiYJdqtCINBL5thrtcN68/ Qer3jK/epyE84II+GOFi0clU4Kq2fbzebhhsa8RYeE8Oi3uE/xkuH5ywJk38YvtvJ8GE sM9INwI5vBm8maPB5Vn3mQiFaxa02u2LEN2PQjCGqhQHTL6/aj0omOt+TExVLBHgfxgX KKxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=H28g14R7gA2T8QP/dmVMxZZ2g8nrTsP3XRYcYNaqDYw=; b=H3157uaa14Wec8BudgQpRDt/bYqyN6ZrLXPUph0iRdBspXITWMM4LfzgxLusRY9ifj okEj+HdHURM81OSJyBd++z2Se4VtsN08cQ0ImCde2jZg7cJYjo9AQsqH1YOQ+I4OQl7W uZtKMt4xa1VQbFeG6EtQbl8x6TYJ0rPylHYftAQ9bTFbe42RdWZnqZO+qHeQ0H96bTwJ bVrvW+0ZIbTTDOjutiqmbDw1f35l1TtVcmppSPL+NGT6dfEGuGZE9dp3zF2Ay5ZykX7n lc6nXSZohvDBEkXYq/ResTuVCO4J1vbHjV36qVSMO07q2C8nJlk2jr5WySqcKgUFCAMx 2Fqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si18202707pgj.542.2018.12.19.22.27.32; Wed, 19 Dec 2018 22:27:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729793AbeLTDQ3 (ORCPT + 99 others); Wed, 19 Dec 2018 22:16:29 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:59699 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728552AbeLTDQX (ORCPT ); Wed, 19 Dec 2018 22:16:23 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E58741008DECA; Thu, 20 Dec 2018 11:16:19 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.408.0; Thu, 20 Dec 2018 11:16:15 +0800 From: Peng Li To: CC: , , , , , Subject: [PATCH net-next 4/9] net: hns3: add max vector number check for pf Date: Thu, 20 Dec 2018 11:52:01 +0800 Message-ID: <1545277926-66432-5-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1545277926-66432-1-git-send-email-lipeng321@huawei.com> References: <1545277926-66432-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jian Shen Each pf supports max 64 vectors and 128 tqps. For 2p/4p core scenario, there may be more than 64 cpus online. So the result of min_t(u16, num_Online_cpus(), tqp_num) may be more than 64. This patch adds check for the vector number. Fixes: dd38c72604dc ("net: hns3: fix for coalesce configuration lost during reset") Signed-off-by: Jian Shen Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index becbf86..624b8a7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3118,6 +3118,8 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv) static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv) { +#define HNS3_VECTOR_PF_MAX_NUM 64 + struct hnae3_handle *h = priv->ae_handle; struct hns3_enet_tqp_vector *tqp_vector; struct hnae3_vector_info *vector; @@ -3130,6 +3132,8 @@ static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv) /* RSS size, cpu online and vector_num should be the same */ /* Should consider 2p/4p later */ vector_num = min_t(u16, num_online_cpus(), tqp_num); + vector_num = min_t(u16, vector_num, HNS3_VECTOR_PF_MAX_NUM); + vector = devm_kcalloc(&pdev->dev, vector_num, sizeof(*vector), GFP_KERNEL); if (!vector) -- 1.9.1