Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2726221ybx; Sun, 3 Nov 2019 02:36:04 -0800 (PST) X-Google-Smtp-Source: APXvYqwCZhlLI16R0Z4FnR9Rjp4SoJl8bQeh6fyE9C4Yn+9WYGVihnQG6Cl+24qwq1D4L0aSZdQG X-Received: by 2002:aa7:df87:: with SMTP id b7mr2431745edy.296.1572777364050; Sun, 03 Nov 2019 02:36:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572777364; cv=none; d=google.com; s=arc-20160816; b=snzhcRY0pjtroQWJ53i5e0xm8Y5c0cXDzD44lfv8zbaxqjVicxDmphNyffaxa2NM+K W3X2cJBQuh8RdtPxZyOaiapRvONEUni0SlyUA+gmLJjYcmlT9pWqGnAR7BR9NK6BV8RZ NQUtLAPOXCP6VD4HfJ0GlzyZV1CriumiL4Bjzbr9zzwd5ruNHYE5jl9QwnWeGWaOIrZS JuzGaLSjyZRaGuuBqpGIImdL0RXwo8rNx8hbSGF2U791KXkDkWvNK4HNXlzSpU/aAn6J 45yN9LVGJE+UcRxQNywxsUZuF3k38twqz4tVPh5hvFRTR9NTfLb/neS22IxkgW1bPx94 dqNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=8sLz1j3trFK0scNew0u0LxhSS/e221rUIsSIECNxQrM=; b=C1yx9vSykwSouUgipq4DvPnaL62U4Srax5TvjFDoMYaVqa/dsE89ogdkuHL3uGyykq vYapiiXKRFJmwXMBrBT+qckAjuCpPDneohhynAJKoZVuuIsaKOpPtDJyp1Bxpo/Hs2qi zf5vCRMSDXFxH9jyzd7c3UbLIAKYi4hJkAdoJRBS4aOWg0gFM1E86owmouVZdRjNwqg3 3T6jmM58xMvycIisUW2VL1+ZF+ydj6Yl5A3SvZDl7Dkrak3USEF8UDPTD0Fl2kE3xTX4 pGZouUcpJilMXiOOFULmO5NrHmVDi9i8YkqeaSiGxWHCvRpEGsVoNdrUJO+QGiHR6kr/ 8oLQ== 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 l19si5015036edj.414.2019.11.03.02.35.40; Sun, 03 Nov 2019 02:36:04 -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 S1727647AbfKCKfI (ORCPT + 99 others); Sun, 3 Nov 2019 05:35:08 -0500 Received: from mx2.suse.de ([195.135.220.15]:56864 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726408AbfKCKfG (ORCPT ); Sun, 3 Nov 2019 05:35:06 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3CAFAB13E; Sun, 3 Nov 2019 10:35:04 +0000 (UTC) From: Thomas Bogendoerfer To: Ralf Baechle , "David S. Miller" , linux-mips@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christoph Hellwig Subject: [net v2 1/4] net: sgi: ioc3-eth: don't abuse dma_direct_* calls Date: Sun, 3 Nov 2019 11:34:30 +0100 Message-Id: <20191103103433.26826-1-tbogendoerfer@suse.de> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig dma_direct_ is a low-level API that must never be used by drivers directly. Switch to use the proper DMA API instead. Change in v2: - ensure that tx ring is 16kB aligned Fixes: ed870f6a7aa2 ("net: sgi: ioc3-eth: use dma-direct for dma allocations") Signed-off-by: Christoph Hellwig --- drivers/net/ethernet/sgi/ioc3-eth.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c index deb636d653f3..4879dedf1f60 100644 --- a/drivers/net/ethernet/sgi/ioc3-eth.c +++ b/drivers/net/ethernet/sgi/ioc3-eth.c @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include @@ -89,6 +89,7 @@ struct ioc3_private { struct device *dma_dev; u32 *ssram; unsigned long *rxr; /* pointer to receiver ring */ + void *tx_ring; struct ioc3_etxd *txr; dma_addr_t rxr_dma; dma_addr_t txr_dma; @@ -1242,8 +1243,8 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ioc3_stop(ip); /* Allocate rx ring. 4kb = 512 entries, must be 4kb aligned */ - ip->rxr = dma_direct_alloc_pages(ip->dma_dev, RX_RING_SIZE, - &ip->rxr_dma, GFP_ATOMIC, 0); + ip->rxr = dma_alloc_coherent(ip->dma_dev, RX_RING_SIZE, &ip->rxr_dma, + GFP_ATOMIC); if (!ip->rxr) { pr_err("ioc3-eth: rx ring allocation failed\n"); err = -ENOMEM; @@ -1251,14 +1252,16 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } /* Allocate tx rings. 16kb = 128 bufs, must be 16kb aligned */ - ip->txr = dma_direct_alloc_pages(ip->dma_dev, TX_RING_SIZE, - &ip->txr_dma, - GFP_KERNEL | __GFP_ZERO, 0); - if (!ip->txr) { + ip->tx_ring = dma_alloc_coherent(ip->dma_dev, TX_RING_SIZE + SZ_16K - 1, + &ip->txr_dma, GFP_KERNEL | __GFP_ZERO); + if (!ip->tx_ring) { pr_err("ioc3-eth: tx ring allocation failed\n"); err = -ENOMEM; goto out_stop; } + /* Align TX ring */ + ip->txr = PTR_ALIGN(ip->tx_ring, SZ_16K); + ip->txr_dma = ALIGN(ip->txr_dma, SZ_16K); ioc3_init(dev); @@ -1313,11 +1316,11 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) out_stop: del_timer_sync(&ip->ioc3_timer); if (ip->rxr) - dma_direct_free_pages(ip->dma_dev, RX_RING_SIZE, ip->rxr, - ip->rxr_dma, 0); - if (ip->txr) - dma_direct_free_pages(ip->dma_dev, TX_RING_SIZE, ip->txr, - ip->txr_dma, 0); + dma_free_coherent(ip->dma_dev, RX_RING_SIZE, ip->rxr, + ip->rxr_dma); + if (ip->tx_ring) + dma_free_coherent(ip->dma_dev, TX_RING_SIZE, ip->tx_ring, + ip->txr_dma); out_res: pci_release_regions(pdev); out_free: @@ -1335,10 +1338,8 @@ static void ioc3_remove_one(struct pci_dev *pdev) struct net_device *dev = pci_get_drvdata(pdev); struct ioc3_private *ip = netdev_priv(dev); - dma_direct_free_pages(ip->dma_dev, RX_RING_SIZE, ip->rxr, - ip->rxr_dma, 0); - dma_direct_free_pages(ip->dma_dev, TX_RING_SIZE, ip->txr, - ip->txr_dma, 0); + dma_free_coherent(ip->dma_dev, RX_RING_SIZE, ip->rxr, ip->rxr_dma); + dma_free_coherent(ip->dma_dev, TX_RING_SIZE, ip->tx_ring, ip->txr_dma); unregister_netdev(dev); del_timer_sync(&ip->ioc3_timer); -- 2.16.4