Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3426920pxb; Sat, 26 Mar 2022 19:18:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3+cBUm7FgPxBMmpGR1oU+x1uscI0+qOwqKbm5AYlM2DEdWZkQvvCo9uHU4wgueqnAPPhP X-Received: by 2002:a17:906:2a97:b0:6b4:143f:37c6 with SMTP id l23-20020a1709062a9700b006b4143f37c6mr19916570eje.133.1648347512067; Sat, 26 Mar 2022 19:18:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648347512; cv=none; d=google.com; s=arc-20160816; b=nocuqDP12VvRpCFLCa0m7vzI+vLTwxbEW/Nn2N4xuHW9pLCgvh/AOBoq/g4cleENmL USh2sOvo7kPyIKWzp9/xMbDVnGcxgqaTakf9H+ZSbwB0sVp/FAEsn5T3hb1Zqf91+mIi wo+gJeJna/ToZb8Z9j6j4gazooeO7468Jc7WT4rmJSlp7rUcj8IFLs2oiy2KtvTO7fwp nndlNHFl2pJ96GZxZatqCcl/TJ3OtrpbkPY7yoguB+zFwnRF3np47ofLuIcrO64u1ITm MjPbsEUwNET0bTTUI+HCI/sbCjMqUUK/xhXmyAD9nWVXSz25Dauue7K6ZUJBcHdFLm0v zTyg== 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=nF7RFwnNA0qJWoPO2huQyEN/uPItGB4JvHPYvyJwGr8=; b=Bq6Thb/THnzvvmg3JG7gGC5aDBgJK0pko/23inOvUpoHRtD1x3Wp+3Uz8VPc+Ps8YY N+hcFZt3mPew0UNOXhXzuBQYiWmOeYGBCaq2F+NGUZ2IgjQKb1/mJ0+NPHWDNjW47iIl DsGlw5QY53CP3FnGpddZTKinXA9NqDHqEpryqT1u7m8/vKPs+iSVVZnQA8UQE2duCroB jHC/KrqMh3nDMdaw6l9OMxmM4DU4O8ArUj7JKTFcfc9y+5ORN8tBLTRyyMZ8sG0R41XA +jFsUU1un+Nu0K5kbeoekScxhFE0NDijYc036MY1Bn+NQ7l/j2EtS31fkicT5ufET4Zt fomA== 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 fh10-20020a1709073a8a00b006df76385d56si7278953ejc.502.2022.03.26.19.17.41; Sat, 26 Mar 2022 19:18:32 -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 S232319AbiCZJ6Q (ORCPT + 99 others); Sat, 26 Mar 2022 05:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230028AbiCZJ6O (ORCPT ); Sat, 26 Mar 2022 05:58:14 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02BBF1EAD7; Sat, 26 Mar 2022 02:56:37 -0700 (PDT) Received: from kwepemi100012.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KQZ7l66fSzfZVs; Sat, 26 Mar 2022 17:54:59 +0800 (CST) Received: from kwepemm600016.china.huawei.com (7.193.23.20) by kwepemi100012.china.huawei.com (7.221.188.202) 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:34 +0800 From: Guangbin Huang To: , CC: , , , , Subject: [PATCH net 1/6] net: hns3: fix ethtool tx copybreak buf size indicating not aligned issue Date: Sat, 26 Mar 2022 17:51:00 +0800 Message-ID: <20220326095105.54075-2-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 When use ethtoool set tx copybreak buf size to a large value which causes order exceeding 10 or memory is not enough, it causes allocating tx copybreak buffer failed and print "the active tx spare buf is 0, not enabled tx spare buffer", however, use --get-tunable parameter query tx copybreak buf size and it indicates setting value not 0. So, it's necessary to change the print value from setting value to 0. Set kinfo.tx_spare_buf_size to 0 when set tx copybreak buf size failed. 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 --- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 20 +++++++++++-------- .../ethernet/hisilicon/hns3/hns3_ethtool.c | 3 ++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 0b8a73c40b12..16137238ddbf 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1028,13 +1028,12 @@ static bool hns3_can_use_tx_sgl(struct hns3_enet_ring *ring, static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring) { + u32 alloc_size = ring->tqp->handle->kinfo.tx_spare_buf_size; struct hns3_tx_spare *tx_spare; struct page *page; - u32 alloc_size; dma_addr_t dma; int order; - alloc_size = ring->tqp->handle->kinfo.tx_spare_buf_size; if (!alloc_size) return; @@ -1044,30 +1043,35 @@ static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring) if (!tx_spare) { /* The driver still work without the tx spare buffer */ dev_warn(ring_to_dev(ring), "failed to allocate hns3_tx_spare\n"); - return; + goto devm_kzalloc_error; } page = alloc_pages_node(dev_to_node(ring_to_dev(ring)), GFP_KERNEL, order); if (!page) { dev_warn(ring_to_dev(ring), "failed to allocate tx spare pages\n"); - devm_kfree(ring_to_dev(ring), tx_spare); - return; + goto alloc_pages_error; } dma = dma_map_page(ring_to_dev(ring), page, 0, PAGE_SIZE << order, DMA_TO_DEVICE); if (dma_mapping_error(ring_to_dev(ring), dma)) { dev_warn(ring_to_dev(ring), "failed to map pages for tx spare\n"); - put_page(page); - devm_kfree(ring_to_dev(ring), tx_spare); - return; + goto dma_mapping_error; } tx_spare->dma = dma; tx_spare->buf = page_address(page); tx_spare->len = PAGE_SIZE << order; ring->tx_spare = tx_spare; + return; + +dma_mapping_error: + put_page(page); +alloc_pages_error: + devm_kfree(ring_to_dev(ring), tx_spare); +devm_kzalloc_error: + ring->tqp->handle->kinfo.tx_spare_buf_size = 0; } /* Use hns3_tx_spare_space() to make sure there is enough buffer diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 6469238ae090..ae30dbe7ef52 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -1818,7 +1818,8 @@ static int hns3_set_tunable(struct net_device *netdev, old_tx_spare_buf_size = h->kinfo.tx_spare_buf_size; new_tx_spare_buf_size = *(u32 *)data; ret = hns3_set_tx_spare_buf_size(netdev, new_tx_spare_buf_size); - if (ret) { + if (ret || + (!priv->ring->tx_spare && new_tx_spare_buf_size != 0)) { int ret1; netdev_warn(netdev, -- 2.33.0