Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3718253imu; Tue, 18 Dec 2018 03:05:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/XqefPDJ5bigrIRZKTkz1hA9TiMrBr7BEiRDpKISlgFHmz9wqcpe9Qa4jXQxf7+r083hCmB X-Received: by 2002:a63:1d59:: with SMTP id d25mr15649661pgm.180.1545131119573; Tue, 18 Dec 2018 03:05:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545131119; cv=none; d=google.com; s=arc-20160816; b=rSKm8ujA2hCQlWMTcMndu5kouCA/j64+3CV7vsdxMBfNqA0DrSL34s86jrfZX6uoNy n6HNwVtg3QjWQw6cwWIS6jxGzAebWStWdJhrQiWmqchiMc7rzfQECKapyjTJsQWFjKTV H3q6gk1OKKyos5I+JmYXodjbJJsxsscUTSrBx/qMV6OSnzC+sRysk5NPin6nRoEDKfRn DGt9X01uEQFn4+we9VBw0i4OeV7cUkmaZBdfLgeFHsSvdtW5UVzcLpz9NcVuM3FNYWuz ftJ4TDIY5Amv/o/AJthNn8jzysQXtAvtBYFvHTnfBYnGl6MCxXgmNvVbMlG5dTOC3drH I0LA== 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=2iF4aR6Me5PlmeDoUff7UOBSTEZB+N+tt5lsSV7OcyM=; b=NB7FTOGU2fEuOuE3PWAfniUNyd8kK7e+ZCMRImLmOfa5WxtvWSPcypG6Cp4khTe0Ur GLIshlVSCD0mSy/6LYC6IEXRO3awsolLjAsQ0UVg0f5uKpXdwBJjU/as7AA1lQJRhs4F 5IeqKn0Klxn07uorKucG7foHSG5MPRKFkqRiUs+1fD+7qmrXrlm5OBm5vGXHFVYWN7mU iKxPuRtWXtqJGYvqRPehJnArjP7ueK7R/uUVkZVdGFeBRUzTQ6l5esRQZ17W7hhPtpOg bQ5y5s78CiHT37h8oaIKaUxC6AKyOuMzqFjASkgvqgQ+VTTIZZDfMJwsNOZR5mWJEDaX oCBQ== 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 f65si14205463pfb.194.2018.12.18.03.05.00; Tue, 18 Dec 2018 03:05:19 -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 S1726828AbeLRLCk (ORCPT + 99 others); Tue, 18 Dec 2018 06:02:40 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:16591 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726704AbeLRLCM (ORCPT ); Tue, 18 Dec 2018 06:02:12 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 1A9A35D8A993F; Tue, 18 Dec 2018 19:02:08 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.408.0; Tue, 18 Dec 2018 19:01:59 +0800 From: Peng Li To: CC: , , , , , Subject: [PATCH net-next 12/12] net: hns3: fix a SSU buffer checking bug Date: Tue, 18 Dec 2018 19:37:59 +0800 Message-ID: <1545133079-79605-13-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1545133079-79605-1-git-send-email-lipeng321@huawei.com> References: <1545133079-79605-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: Yunsheng Lin When caculating the SSU buffer, it first allocate tx and rx private buffer, then the remaining buffer is for rx shared buffer. The remaining buffer size should be at least bigger than or equal to the shared_std, which is the minimum shared buffer size required by the driver, but currently if the remaining buffer size is equal to the shared_std, it returns failure, which causes SSU buffer allocation failure problem. This patch fixes this problem by rounding up shared_std before checking the the remaining buffer size bigger than or equal to the shared_std. Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index f847fde..d0e84de 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1403,10 +1403,11 @@ static bool hclge_is_rx_buf_ok(struct hclge_dev *hdev, shared_buf_tc = pfc_enable_num * aligned_mps + (tc_num - pfc_enable_num) * aligned_mps / 2 + aligned_mps; - shared_std = max_t(u32, shared_buf_min, shared_buf_tc); + shared_std = roundup(max_t(u32, shared_buf_min, shared_buf_tc), + HCLGE_BUF_SIZE_UNIT); rx_priv = hclge_get_rx_priv_buff_alloced(buf_alloc); - if (rx_all <= rx_priv + shared_std) + if (rx_all < rx_priv + shared_std) return false; shared_buf = rounddown(rx_all - rx_priv, HCLGE_BUF_SIZE_UNIT); -- 1.9.1