Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2916827pxb; Sat, 25 Sep 2021 23:14:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxO+gBNp5EuL6PYm1r43A2vuxff5Fm/CM9nHhPDj3sdBQ7iIKAhL2+XRFCLhRacDwwIQKQE X-Received: by 2002:a17:906:7848:: with SMTP id p8mr20307499ejm.212.1632636860491; Sat, 25 Sep 2021 23:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632636860; cv=none; d=google.com; s=arc-20160816; b=QpyEz9e2TWX4QWdg2NkZXun/aJoWjbesHkA0zV5/LMCp2uaCquZ9gEizQyaubUsT55 SWUG3Ej+tXmcFLXcegoD0FJ13qlVZnTeIcWHX4jahZnLJHlL757p8v5NatEeUULCSHt9 1qgiYiun3rrRDfv9iI82EsDVkNaE/zBgT2O9Oe6uueAaMegkJDe+PmPSILvRoDyuKigW uR3pBB2XPCrJ13Wi/k8uPruVV5bd//qiio7aN0j5pH7AQDBxm5k0344xQQj8mxcNyRW2 0g0kjQTM41YDp2393+qggDLcczxVOTCkmmEXuAlm3PToRy3rnz/7MNg4cLRoMTKu62ph 0SlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=3DxYBEV39gF5PFoqP1xeihr8tZSJ6sZREukx1pzqdvI=; b=tXG/DUnXm5U2BKBmRHQ+Jx/hfjZeOeK/xmzHClwbNoGMZXy0P7iiUISZ9UDWMxEN+U eTx61ACFHq3hiwIJVueCBgFqAiqwe8Oe2kuMBNDJbZWunV4s0I+PzmxL0UtppmBCErGu i0/f3h8CzSgjmqkledjutKiBYz4LwQTZODloxTN8+Jue+Q8l+39iqSZ0UGz9VL2P0OW+ MTdUKh5xjSWtEEeOFnVAYlBggFG1HQgkNIL5kmW+4twrdR+QVF+CeDVFWSWVikWsToZL YHQltUpvBElyN0CuMkAwvSnu+Qu1rvLpUGTyi+3Y1SbheNIdvU9Q8qLy63OmnPheZzmQ 74dw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 10si14078427ejt.595.2021.09.25.23.13.57; Sat, 25 Sep 2021 23:14:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbhIZGND (ORCPT + 99 others); Sun, 26 Sep 2021 02:13:03 -0400 Received: from mx24.baidu.com ([111.206.215.185]:48010 "EHLO baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230453AbhIZGNC (ORCPT ); Sun, 26 Sep 2021 02:13:02 -0400 Received: from BC-Mail-Ex14.internal.baidu.com (unknown [172.31.51.54]) by Forcepoint Email with ESMTPS id 087A09B7E3555FBF0B76; Sun, 26 Sep 2021 14:11:16 +0800 (CST) Received: from BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) by BC-Mail-Ex14.internal.baidu.com (172.31.51.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2242.12; Sun, 26 Sep 2021 14:11:15 +0800 Received: from LAPTOP-UKSR4ENP.internal.baidu.com (172.31.63.8) by BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Sun, 26 Sep 2021 14:11:15 +0800 From: Cai Huoqing To: CC: "David S. Miller" , Jakub Kicinski , Cristobal Forno , Michael Ellerman , Benjamin Herrenschmidt , "Paul Mackerras" , , , Subject: [PATCH] ibmveth: Use dma_alloc_coherent() instead of kmalloc/dma_map_single() Date: Sun, 26 Sep 2021 14:11:07 +0800 Message-ID: <20210926061108.229-1-caihuoqing@baidu.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.31.63.8] X-ClientProxiedBy: BC-Mail-Ex22.internal.baidu.com (172.31.51.16) To BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replacing kmalloc/kfree/dma_map_single/dma_unmap_single() with dma_alloc_coherent/dma_free_coherent() helps to reduce code size, and simplify the code, and coherent DMA will not clear the cache every time. Signed-off-by: Cai Huoqing --- drivers/net/ethernet/ibm/Kconfig | 4 ++-- drivers/net/ethernet/ibm/ibmveth.c | 25 +++++++++---------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/ibm/Kconfig b/drivers/net/ethernet/ibm/Kconfig index c0c112d95b89..926c0642784d 100644 --- a/drivers/net/ethernet/ibm/Kconfig +++ b/drivers/net/ethernet/ibm/Kconfig @@ -19,7 +19,7 @@ if NET_VENDOR_IBM config IBMVETH tristate "IBM LAN Virtual Ethernet support" - depends on PPC_PSERIES + depends on PPC_PSERIES || COMPILE_TEST help This driver supports virtual ethernet adapters on newer IBM iSeries and pSeries systems. @@ -40,7 +40,7 @@ config EHEA config IBMVNIC tristate "IBM Virtual NIC support" - depends on PPC_PSERIES + depends on PPC_PSERIES || COMPILE_TEST help This driver supports Virtual NIC adapters on IBM i and IBM System p systems. diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index 3d9b4f99d357..3aedb680adb8 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c @@ -605,17 +605,13 @@ static int ibmveth_open(struct net_device *netdev) } rc = -ENOMEM; - adapter->bounce_buffer = - kmalloc(netdev->mtu + IBMVETH_BUFF_OH, GFP_KERNEL); - if (!adapter->bounce_buffer) - goto out_free_irq; - adapter->bounce_buffer_dma = - dma_map_single(&adapter->vdev->dev, adapter->bounce_buffer, - netdev->mtu + IBMVETH_BUFF_OH, DMA_BIDIRECTIONAL); - if (dma_mapping_error(dev, adapter->bounce_buffer_dma)) { - netdev_err(netdev, "unable to map bounce buffer\n"); - goto out_free_bounce_buffer; + adapter->bounce_buffer = dma_alloc_coherent(&adapter->vdev->dev, + netdev->mtu + IBMVETH_BUFF_OH, + &adapter->bounce_buffer_dma, GFP_KERNEL); + if (!adapter->bounce_buffer) { + netdev_err(netdev, "unable to alloc bounce buffer\n"); + goto out_free_irq; } netdev_dbg(netdev, "initial replenish cycle\n"); @@ -627,8 +623,6 @@ static int ibmveth_open(struct net_device *netdev) return 0; -out_free_bounce_buffer: - kfree(adapter->bounce_buffer); out_free_irq: free_irq(netdev->irq, netdev); out_free_buffer_pools: @@ -702,10 +696,9 @@ static int ibmveth_close(struct net_device *netdev) ibmveth_free_buffer_pool(adapter, &adapter->rx_buff_pool[i]); - dma_unmap_single(&adapter->vdev->dev, adapter->bounce_buffer_dma, - adapter->netdev->mtu + IBMVETH_BUFF_OH, - DMA_BIDIRECTIONAL); - kfree(adapter->bounce_buffer); + dma_free_coherent(&adapter->vdev->dev, + adapter->netdev->mtu + IBMVETH_BUFF_OH, + adapter->bounce_buffer, adapter->bounce_buffer_dma); netdev_dbg(netdev, "close complete\n"); -- 2.25.1