| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * sgiseeq.c: Seeq8003 ethernet driver for SGI machines. |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 111 | 112 | |
|---|
| 112 | 113 | static inline void dma_sync_desc_cpu(struct net_device *dev, void *addr) |
|---|
| 113 | 114 | { |
|---|
| 114 | | - dma_cache_sync(dev->dev.parent, addr, sizeof(struct sgiseeq_rx_desc), |
|---|
| 115 | | - DMA_FROM_DEVICE); |
|---|
| 115 | + struct sgiseeq_private *sp = netdev_priv(dev); |
|---|
| 116 | + |
|---|
| 117 | + dma_sync_single_for_cpu(dev->dev.parent, VIRT_TO_DMA(sp, addr), |
|---|
| 118 | + sizeof(struct sgiseeq_rx_desc), DMA_BIDIRECTIONAL); |
|---|
| 116 | 119 | } |
|---|
| 117 | 120 | |
|---|
| 118 | 121 | static inline void dma_sync_desc_dev(struct net_device *dev, void *addr) |
|---|
| 119 | 122 | { |
|---|
| 120 | | - dma_cache_sync(dev->dev.parent, addr, sizeof(struct sgiseeq_rx_desc), |
|---|
| 121 | | - DMA_TO_DEVICE); |
|---|
| 123 | + struct sgiseeq_private *sp = netdev_priv(dev); |
|---|
| 124 | + |
|---|
| 125 | + dma_sync_single_for_device(dev->dev.parent, VIRT_TO_DMA(sp, addr), |
|---|
| 126 | + sizeof(struct sgiseeq_rx_desc), DMA_BIDIRECTIONAL); |
|---|
| 122 | 127 | } |
|---|
| 123 | 128 | |
|---|
| 124 | 129 | static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs) |
|---|
| .. | .. |
|---|
| 402 | 407 | rd = &sp->rx_desc[sp->rx_new]; |
|---|
| 403 | 408 | dma_sync_desc_cpu(dev, rd); |
|---|
| 404 | 409 | } |
|---|
| 410 | + dma_sync_desc_dev(dev, rd); |
|---|
| 411 | + |
|---|
| 405 | 412 | dma_sync_desc_cpu(dev, &sp->rx_desc[orig_end]); |
|---|
| 406 | 413 | sp->rx_desc[orig_end].rdma.cntinfo &= ~(HPCDMA_EOR); |
|---|
| 407 | 414 | dma_sync_desc_dev(dev, &sp->rx_desc[orig_end]); |
|---|
| .. | .. |
|---|
| 442 | 449 | dma_sync_desc_cpu(dev, td); |
|---|
| 443 | 450 | } |
|---|
| 444 | 451 | if (td->tdma.cntinfo & HPCDMA_XIU) { |
|---|
| 452 | + dma_sync_desc_dev(dev, td); |
|---|
| 445 | 453 | hregs->tx_ndptr = VIRT_TO_DMA(sp, td); |
|---|
| 446 | 454 | hregs->tx_ctrl = HPC3_ETXCTRL_ACTIVE; |
|---|
| 447 | 455 | } |
|---|
| .. | .. |
|---|
| 475 | 483 | if (!(td->tdma.cntinfo & (HPCDMA_XIU))) |
|---|
| 476 | 484 | break; |
|---|
| 477 | 485 | if (!(td->tdma.cntinfo & (HPCDMA_ETXD))) { |
|---|
| 486 | + dma_sync_desc_dev(dev, td); |
|---|
| 478 | 487 | if (!(status & HPC3_ETXCTRL_ACTIVE)) { |
|---|
| 479 | 488 | hregs->tx_ndptr = VIRT_TO_DMA(sp, td); |
|---|
| 480 | 489 | hregs->tx_ctrl = HPC3_ETXCTRL_ACTIVE; |
|---|
| .. | .. |
|---|
| 644 | 653 | return NETDEV_TX_OK; |
|---|
| 645 | 654 | } |
|---|
| 646 | 655 | |
|---|
| 647 | | -static void timeout(struct net_device *dev) |
|---|
| 656 | +static void timeout(struct net_device *dev, unsigned int txqueue) |
|---|
| 648 | 657 | { |
|---|
| 649 | 658 | printk(KERN_NOTICE "%s: transmit timed out, resetting\n", dev->name); |
|---|
| 650 | 659 | sgiseeq_reset(dev); |
|---|
| .. | .. |
|---|
| 739 | 748 | sp = netdev_priv(dev); |
|---|
| 740 | 749 | |
|---|
| 741 | 750 | /* Make private data page aligned */ |
|---|
| 742 | | - sr = dma_alloc_attrs(&pdev->dev, sizeof(*sp->srings), &sp->srings_dma, |
|---|
| 743 | | - GFP_KERNEL, DMA_ATTR_NON_CONSISTENT); |
|---|
| 751 | + sr = dma_alloc_noncoherent(&pdev->dev, sizeof(*sp->srings), |
|---|
| 752 | + &sp->srings_dma, DMA_BIDIRECTIONAL, GFP_KERNEL); |
|---|
| 744 | 753 | if (!sr) { |
|---|
| 745 | 754 | printk(KERN_ERR "Sgiseeq: Page alloc failed, aborting.\n"); |
|---|
| 746 | 755 | err = -ENOMEM; |
|---|
| .. | .. |
|---|
| 801 | 810 | return 0; |
|---|
| 802 | 811 | |
|---|
| 803 | 812 | err_out_free_attrs: |
|---|
| 804 | | - dma_free_attrs(&pdev->dev, sizeof(*sp->srings), sp->srings, |
|---|
| 805 | | - sp->srings_dma, DMA_ATTR_NON_CONSISTENT); |
|---|
| 813 | + dma_free_noncoherent(&pdev->dev, sizeof(*sp->srings), sp->srings, |
|---|
| 814 | + sp->srings_dma, DMA_BIDIRECTIONAL); |
|---|
| 806 | 815 | err_out_free_dev: |
|---|
| 807 | 816 | free_netdev(dev); |
|---|
| 808 | 817 | |
|---|
| .. | .. |
|---|
| 816 | 825 | struct sgiseeq_private *sp = netdev_priv(dev); |
|---|
| 817 | 826 | |
|---|
| 818 | 827 | unregister_netdev(dev); |
|---|
| 819 | | - dma_free_attrs(&pdev->dev, sizeof(*sp->srings), sp->srings, |
|---|
| 820 | | - sp->srings_dma, DMA_ATTR_NON_CONSISTENT); |
|---|
| 828 | + dma_free_noncoherent(&pdev->dev, sizeof(*sp->srings), sp->srings, |
|---|
| 829 | + sp->srings_dma, DMA_BIDIRECTIONAL); |
|---|
| 821 | 830 | free_netdev(dev); |
|---|
| 822 | 831 | |
|---|
| 823 | 832 | return 0; |
|---|