Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp4054693pxb; Sun, 27 Mar 2022 11:03:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl94+JJPoLG1uWhnPJ9iewR+DZo4auqJpRWtDmSpvkEHMWkI2qgxEQiECsa0d5BjtW7yx0 X-Received: by 2002:a17:90b:3881:b0:1c7:c02b:bcf8 with SMTP id mu1-20020a17090b388100b001c7c02bbcf8mr21793701pjb.131.1648404199644; Sun, 27 Mar 2022 11:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648404199; cv=none; d=google.com; s=arc-20160816; b=m11X1Tek25sp4DlVyyeXRew4w1IE+Qfzx8kIhNUr6SkJBmzc2t8v9/wiGSKcSuqA8T /a6M++7Re194LYKZrEXje22ftMkksfrP4x0evLcgDYvGwaKEHqGITQgBRs3PcCgjx8FT iOMygmSzT8riIIeY0AH/hLdwWwdqJ7HWqzCh71LyFeGwuMRvHhRFLPTdH44lxj7yO3eK MiAiLZLwc+C6yKaElMkQQYqlwuQ1J1rjI7sXHnQGy7WXGkOX2ZObWhysv6447zh/DrEu 2FOwTU1PemL4i8onV+kKDpm7ZP+qmiVDTU7uC+6B/J42B3Uy5GJ9g4YXMWMzKlrNHwZ8 2JeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iJ3EnkC22tj4mZ12gjuSES4CYLVHg58H4ZIURfdTs2k=; b=dMYwHjhmQEXBygtSTTH1qWoIRPr0UVAILaAyk3tamet1ne8Y6Ga7W/vKXpBz1fZ+JO bgAK1MIZSdI+D8Gw8KQzOplKBRE8pXs2VZGF4HQBarTfzwJLDmlLfem8auJAKyuHR9B2 6YP46ds9vsvwWqQXkHC4E2WE+AtkfDSV7HEN0Q+8vVdz0cNcnPndKZH+1/ObEeWTrryI FmmQ1kW1GohnRgktrBN4NRlbFkIg8Mazs1YCo1+gAIrqsVIvYGGfonWaDn44Xg6MQBVO eLLP5CvlDHxFNn1mUAMuqx0QM/AgmeCmYnmRxQaHafnlOAI/b24OzxlaXOj5wTvkLcdz lyVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np7-20020a17090b4c4700b001c6855ece44si10658274pjb.184.2022.03.27.11.02.41; Sun, 27 Mar 2022 11:03:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232369AbiCZJ6n (ORCPT + 99 others); Sat, 26 Mar 2022 05:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232298AbiCZJ6O (ORCPT ); Sat, 26 Mar 2022 05:58:14 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EC2B167DE; Sat, 26 Mar 2022 02:56:37 -0700 (PDT) Received: from kwepemi100011.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KQZ5044Pbz9t0r; Sat, 26 Mar 2022 17:52:36 +0800 (CST) Received: from kwepemm600016.china.huawei.com (7.193.23.20) by kwepemi100011.china.huawei.com (7.221.188.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Sat, 26 Mar 2022 17:56:35 +0800 Received: from localhost.localdomain (10.67.165.24) by kwepemm600016.china.huawei.com (7.193.23.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Sat, 26 Mar 2022 17:56:35 +0800 From: Guangbin Huang To: , CC: , , , , Subject: [PATCH net 2/6] net: hns3: add max order judgement for tx spare buffer Date: Sat, 26 Mar 2022 17:51:01 +0800 Message-ID: <20220326095105.54075-3-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220326095105.54075-1-huangguangbin2@huawei.com> References: <20220326095105.54075-1-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600016.china.huawei.com (7.193.23.20) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hao Chen Add max order judgement for tx spare buffer to avoid triggering call trace, print related fail information instead, when user set tx spare buf size to a large value which causes order exceeding 10. Fixes: e445f08af2b1 ("net: hns3: add support to set/get tx copybreak buf size via ethtool for hns3 driver") Signed-off-by: Hao Chen Signed-off-by: Guangbin Huang --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 16137238ddbf..530ba8bef503 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1038,6 +1038,12 @@ static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring) return; order = get_order(alloc_size); + if (order >= MAX_ORDER) { + if (net_ratelimit()) + dev_warn(ring_to_dev(ring), "failed to allocate tx spare buffer, exceed to max order\n"); + return; + } + tx_spare = devm_kzalloc(ring_to_dev(ring), sizeof(*tx_spare), GFP_KERNEL); if (!tx_spare) { -- 2.33.0