Skip to content

Commit

Permalink
net: sgi: ioc3-eth: ensure tx ring is 16k aligned.
Browse files Browse the repository at this point in the history
IOC3 hardware needs a 16k aligned TX ring.

Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Thomas Bogendoerfer authored and David S. Miller committed Nov 4, 2019
1 parent 7ca2c4c commit 369a782
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions drivers/net/ethernet/sgi/ioc3-eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1236,13 +1237,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_alloc_coherent(ip->dma_dev, TX_RING_SIZE, &ip->txr_dma,
GFP_KERNEL);
if (!ip->txr) {
ip->tx_ring = dma_alloc_coherent(ip->dma_dev, TX_RING_SIZE + SZ_16K - 1,
&ip->txr_dma, GFP_KERNEL);
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);

Expand Down Expand Up @@ -1299,8 +1303,8 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ip->rxr)
dma_free_coherent(ip->dma_dev, RX_RING_SIZE, ip->rxr,
ip->rxr_dma);
if (ip->txr)
dma_free_coherent(ip->dma_dev, TX_RING_SIZE, ip->txr,
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);
Expand All @@ -1320,7 +1324,7 @@ static void ioc3_remove_one(struct pci_dev *pdev)
struct ioc3_private *ip = netdev_priv(dev);

dma_free_coherent(ip->dma_dev, RX_RING_SIZE, ip->rxr, ip->rxr_dma);
dma_free_coherent(ip->dma_dev, TX_RING_SIZE, ip->txr, ip->txr_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);
Expand Down

0 comments on commit 369a782

Please sign in to comment.