From patchwork Wed Jan 10 18:03:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10155779 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA54B602D8 for ; Wed, 10 Jan 2018 18:04:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1232209CE for ; Wed, 10 Jan 2018 18:04:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5D00285AB; Wed, 10 Jan 2018 18:04:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F4E9209CE for ; Wed, 10 Jan 2018 18:04:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752447AbeAJSDh (ORCPT ); Wed, 10 Jan 2018 13:03:37 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:37279 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752437AbeAJSDf (ORCPT ); Wed, 10 Jan 2018 13:03:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=o/12fo4g8vzwHrIqCN74GA0TDQz1qLr30jZeZdypapE=; b=huSNgraaMvmK2N6QZGKB8RBSp x64y1EHel0aumqcK4baD/gTFDbJZxhutVq/edrBzPIYMZlcq5xxF0ZTQr3zntQAhlh7Hd9RirZNUN W46vJN7sw+Wtbwjf8QiMD0LRjA8+nrgWMhc4gIkrjW9+BO2+/p+bzBmgOFFF7o/wZnl+XIgLgvw4g E0RBTMFjv5Y8h8tmEHuNcRf1ONaVZvnbcunPM7mw4XRa3nOusEsuu8m5M0oB2Ank8OdXyLA6UsvlJ DU0J5jj2ld/JNOHWUfB44UhLajQqhNYzqbQvxf9I83pg9QnjLzUILqoMC+WSyLOhC8v49w6q8FLAR ROYJkccxg==; Received: from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eZKir-0000bz-QI; Wed, 10 Jan 2018 18:03:34 +0000 From: Christoph Hellwig To: Bjorn Helgaas , Mauro Carvalho Chehab Cc: Kong Lai , linux-pci@vger.kernel.org, linux-media@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] tsi108_eth: use dma API properly Date: Wed, 10 Jan 2018 19:03:21 +0100 Message-Id: <20180110180322.30186-4-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180110180322.30186-1-hch@lst.de> References: <20180110180322.30186-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to pass a struct device to the dma API, even if some architectures still support that for legacy reasons, and should not mix it with the old PCI dma API. Note that the driver also seems to never actually unmap its dma mappings, but to fix that we'll need someone more familar with the driver. Signed-off-by: Christoph Hellwig --- drivers/net/ethernet/tundra/tsi108_eth.c | 36 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/tundra/tsi108_eth.c b/drivers/net/ethernet/tundra/tsi108_eth.c index 0624b71ab5d4..edcd1e60b30d 100644 --- a/drivers/net/ethernet/tundra/tsi108_eth.c +++ b/drivers/net/ethernet/tundra/tsi108_eth.c @@ -152,6 +152,8 @@ struct tsi108_prv_data { u32 msg_enable; /* debug message level */ struct mii_if_info mii_if; unsigned int init_media; + + struct platform_device *pdev; }; /* Structure for a device driver */ @@ -703,17 +705,18 @@ static int tsi108_send_packet(struct sk_buff * skb, struct net_device *dev) data->txskbs[tx] = skb; if (i == 0) { - data->txring[tx].buf0 = dma_map_single(NULL, skb->data, - skb_headlen(skb), DMA_TO_DEVICE); + data->txring[tx].buf0 = dma_map_single(&data->pdev->dev, + skb->data, skb_headlen(skb), + DMA_TO_DEVICE); data->txring[tx].len = skb_headlen(skb); misc |= TSI108_TX_SOF; } else { const skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1]; - data->txring[tx].buf0 = skb_frag_dma_map(NULL, frag, - 0, - skb_frag_size(frag), - DMA_TO_DEVICE); + data->txring[tx].buf0 = + skb_frag_dma_map(&data->pdev->dev, frag, + 0, skb_frag_size(frag), + DMA_TO_DEVICE); data->txring[tx].len = skb_frag_size(frag); } @@ -808,9 +811,9 @@ static int tsi108_refill_rx(struct net_device *dev, int budget) if (!skb) break; - data->rxring[rx].buf0 = dma_map_single(NULL, skb->data, - TSI108_RX_SKB_SIZE, - DMA_FROM_DEVICE); + data->rxring[rx].buf0 = dma_map_single(&data->pdev->dev, + skb->data, TSI108_RX_SKB_SIZE, + DMA_FROM_DEVICE); /* Sometimes the hardware sets blen to zero after packet * reception, even though the manual says that it's only ever @@ -1308,15 +1311,15 @@ static int tsi108_open(struct net_device *dev) data->id, dev->irq, dev->name); } - data->rxring = dma_zalloc_coherent(NULL, rxring_size, &data->rxdma, - GFP_KERNEL); + data->rxring = dma_zalloc_coherent(&data->pdev->dev, rxring_size, + &data->rxdma, GFP_KERNEL); if (!data->rxring) return -ENOMEM; - data->txring = dma_zalloc_coherent(NULL, txring_size, &data->txdma, - GFP_KERNEL); + data->txring = dma_zalloc_coherent(&data->pdev->dev, txring_size, + &data->txdma, GFP_KERNEL); if (!data->txring) { - pci_free_consistent(NULL, rxring_size, data->rxring, + dma_free_coherent(&data->pdev->dev, rxring_size, data->rxring, data->rxdma); return -ENOMEM; } @@ -1428,10 +1431,10 @@ static int tsi108_close(struct net_device *dev) dev_kfree_skb(skb); } - dma_free_coherent(0, + dma_free_coherent(&data->pdev->dev, TSI108_RXRING_LEN * sizeof(rx_desc), data->rxring, data->rxdma); - dma_free_coherent(0, + dma_free_coherent(&data->pdev->dev, TSI108_TXRING_LEN * sizeof(tx_desc), data->txring, data->txdma); @@ -1576,6 +1579,7 @@ tsi108_init_one(struct platform_device *pdev) printk("tsi108_eth%d: probe...\n", pdev->id); data = netdev_priv(dev); data->dev = dev; + data->pdev = pdev; pr_debug("tsi108_eth%d:regs:phyresgs:phy:irq_num=0x%x:0x%x:0x%x:0x%x\n", pdev->id, einfo->regs, einfo->phyregs,