Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2655761imj; Mon, 11 Feb 2019 06:33:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IaDWs2B3pUVPaszGDZZzGbep3L1YdaJcadDvkpwLbozJqdsmFKf6BJog7JfHKfySdVHHnGX X-Received: by 2002:a62:4bcf:: with SMTP id d76mr38348023pfj.170.1549895602115; Mon, 11 Feb 2019 06:33:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895602; cv=none; d=google.com; s=arc-20160816; b=V/fGitgosr5qpdgrqlQ8svhzaubjC34zbgRzM0B2SNC0tshGE5uKyIrytkXERdPiAG KVODeSki5XOXfMsr4UtQbxBvXJet77xeHSzSSwfoH3wJr8CuKIl1mH/t4yhefteRVu+r Aq8XJU/8ze1Xb1vUDgQPKQEKgGqiR7s8VmHFYZ/S6O23/GtNptZbfY9W3k+R10bmYWes 4+URm2yZmCqBYy+K9CR2ZCYg5IuHCfA6PgsfsS8jmdaPobMCtUrLDjEzPrWuHpt1TQHP 4RAidGMBS7A9dzrFZfWLMP1BtCCnuEbd53F9T5BGcUJKpNUTI8wnrHA2lXbKEPcyAIOi 2Sxw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AKxZXM0WSn+hETJzz4IWooRMLfYEO8TlM3SusNx+S90=; b=EN2sb/WF5zr2wM3uMb+tI6QvJ9pwOCPVuhlT26aYlETe0mKOI2p1tDxz9IpCoGftok Ms6x5TqODHsNS25z23XpxJQC9CQvIPtxZFGRWq5VndSlwMJdG7ANTU5ho9yzDs7ZYr49 GQr5m6vgsvVlioAsbhabYHszInwzsTibAXc+9YgwLQZSSaPoPL4CnwTnMXKQZYQyiORb WFTKIlaTqZCgd1CnWoRElJktRLi+hYPpXICekJMy7GYO79n2f2zLE14K5CG9noZwH/BI MCw3PM2cTwnfuNnkQHcKGouNbrCrTN9ANVsyP7D2IlQJzp6qjftUD0tmR7kzDddbToFM hUeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d+srbdSM; 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 33si7892763plu.169.2019.02.11.06.33.06; Mon, 11 Feb 2019 06:33:22 -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=d+srbdSM; 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 S1729998AbfBKOct (ORCPT + 99 others); Mon, 11 Feb 2019 09:32:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:40280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729928AbfBKOcq (ORCPT ); Mon, 11 Feb 2019 09:32:46 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3D93D20675; Mon, 11 Feb 2019 14:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895565; bh=0vq8Lh3acN5xdI9yshL+2ZCPa/oz0WO7o7FQ6Wow0Lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d+srbdSMtwHlvo5yxyObIfy8xVLSoXw1npFzr51mVKb5DrdBbhkynwH7vASXIMvvc R77wo0ZplrLgRZhMHtnD3K1CfERGghnBEydjP2+rF9g7bC4HHks3zXGzQzj1pcHcIH 2Aj595MUYHVBNbdsO0Xx1toHN/tDU/5+jiIii6Es= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jian Shen , Peng Li , "David S. Miller" , Sasha Levin Subject: [PATCH 4.20 218/352] net: hns3: add max vector number check for pf Date: Mon, 11 Feb 2019 15:17:25 +0100 Message-Id: <20190211141901.085157942@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 85d534a24f2c..beb5dbd5e98d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2902,6 +2902,8 @@ map_ring_fail: 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; @@ -2914,6 +2916,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