Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3634604imu; Mon, 28 Jan 2019 08:11:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN6Pj1EyyYlcWgKfAs0BWyNtCNOdAgNWtE9/V9048tUHJspPRA8wqH57BT2o9wryQEuHfyFN X-Received: by 2002:a17:902:66e6:: with SMTP id e93mr21818618plk.92.1548691871221; Mon, 28 Jan 2019 08:11:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691871; cv=none; d=google.com; s=arc-20160816; b=YGzv1Y3jDBonVF5pHJTlK5iEZknpfV+5sT2CfBFZMVo497RG9tJU/W0R1MFfo7NQsS biML3x0Z4hGNIRVqQtqWihVUaFur/a2CJDgo2GcncjYS4pCt0AtvF7W/GD7pSvflrF5W 4xBwQObk/SIfQ957NhmmR9U3LjcgubCVsxjl1i2ib1WqqDVYhkOiCv8pHI17dMngF18j AVCoBRHPgmRLQ3WtFlSF+N7bCyyIcqBw2gexFIGKmS7+PBEOa5VjctcXUsOhy1jZjFmi NEPXupmgHEGs3z2RuuMEauRJTKOM2PQsfVEBmA+r5N8BDXflrUVIHc07zHeeZQQ3B2c+ 9uyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qUc3zA/TijGsq9ppNHAT3v3/nrYG2TQNVmwauCDKFac=; b=rI8fkRK69lInYL7CLLpZnUZOlBEFcWwoHteCE526Wvobe4LeqcIdzWtHnWsF0KufQm T0jCkWizkZmscbdZ5xNDQSnQ8HYs/rW2f0+vsliZymovmMR9NJ3fXFbneu1nCBFYNg+n YDjaluH88rUlyRq6KtXjS3GXJtEvD6xj6JZ2s70TLIAmDUJVC3FEZBo93caj4iTF32Gh MApDbGTU9JinyPgbRzOUz2WI9fCm55MvwaHzf5PhydpwJSi9hPydN9ebhwH9N+1Aj3d1 zbys6FYgZkRMDcBvQzwOMl2/cOF79vqrGXEViu0CHGIVvTR/WDxbZLdb4A06oaTAhA68 LYmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y4SpTjsU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ca6si17609219plb.141.2019.01.28.08.10.56; Mon, 28 Jan 2019 08:11:11 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Y4SpTjsU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731316AbfA1QIg (ORCPT + 99 others); Mon, 28 Jan 2019 11:08:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:60434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732398AbfA1QIb (ORCPT ); Mon, 28 Jan 2019 11:08:31 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 51D0A20989; Mon, 28 Jan 2019 16:08:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691710; bh=gJ+FAV6UJQyeu8zI+YPZADRrBEfEI+ucPMXy2Dc45+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y4SpTjsUDLqP/W0UzB69Usfwrhj1e/ZIN0nccrd8Ba/xb9t83ZilDB8ldJqHQojnh fMQYMG9ivFeQZM72sqtvL0PGkkUq9T6SVIXa4JpHGrLrdHEpDrk7sOZLScQEvvhQH4 cKI0PJG6K9CACthm46Jqb4yN3jHUcj2EhEzHAbsE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jian Shen , Peng Li , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 194/258] net: hns3: add max vector number check for pf Date: Mon, 28 Jan 2019 10:58:20 -0500 Message-Id: <20190128155924.51521-194-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jian Shen [ Upstream commit 75edb610860fda65ceedb017fc69afabd2806b8b ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 d5f15d8d18a9..0ccfa6a84535 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2691,6 +2691,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; @@ -2703,6 +2705,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) -- 2.19.1