sgiseeq: convert to dma_alloc_noncoherent
Use the new non-coherent DMA API including proper ownership transfers. This includes adding additional calls to dma_sync_desc_dev as the old syncing was rather ad-hoc. Thanks to Thomas Bogendoerfer for debugging the ownership transfer issues. Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
This commit is contained in:
parent
00718b23a4
commit
7f3bb7f53a
@ -112,14 +112,18 @@ struct sgiseeq_private {
|
|||||||
|
|
||||||
static inline void dma_sync_desc_cpu(struct net_device *dev, void *addr)
|
static inline void dma_sync_desc_cpu(struct net_device *dev, void *addr)
|
||||||
{
|
{
|
||||||
dma_cache_sync(dev->dev.parent, addr, sizeof(struct sgiseeq_rx_desc),
|
struct sgiseeq_private *sp = netdev_priv(dev);
|
||||||
DMA_FROM_DEVICE);
|
|
||||||
|
dma_sync_single_for_cpu(dev->dev.parent, VIRT_TO_DMA(sp, addr),
|
||||||
|
sizeof(struct sgiseeq_rx_desc), DMA_BIDIRECTIONAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dma_sync_desc_dev(struct net_device *dev, void *addr)
|
static inline void dma_sync_desc_dev(struct net_device *dev, void *addr)
|
||||||
{
|
{
|
||||||
dma_cache_sync(dev->dev.parent, addr, sizeof(struct sgiseeq_rx_desc),
|
struct sgiseeq_private *sp = netdev_priv(dev);
|
||||||
DMA_TO_DEVICE);
|
|
||||||
|
dma_sync_single_for_device(dev->dev.parent, VIRT_TO_DMA(sp, addr),
|
||||||
|
sizeof(struct sgiseeq_rx_desc), DMA_BIDIRECTIONAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs)
|
static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs)
|
||||||
@ -403,6 +407,8 @@ memory_squeeze:
|
|||||||
rd = &sp->rx_desc[sp->rx_new];
|
rd = &sp->rx_desc[sp->rx_new];
|
||||||
dma_sync_desc_cpu(dev, rd);
|
dma_sync_desc_cpu(dev, rd);
|
||||||
}
|
}
|
||||||
|
dma_sync_desc_dev(dev, rd);
|
||||||
|
|
||||||
dma_sync_desc_cpu(dev, &sp->rx_desc[orig_end]);
|
dma_sync_desc_cpu(dev, &sp->rx_desc[orig_end]);
|
||||||
sp->rx_desc[orig_end].rdma.cntinfo &= ~(HPCDMA_EOR);
|
sp->rx_desc[orig_end].rdma.cntinfo &= ~(HPCDMA_EOR);
|
||||||
dma_sync_desc_dev(dev, &sp->rx_desc[orig_end]);
|
dma_sync_desc_dev(dev, &sp->rx_desc[orig_end]);
|
||||||
@ -443,6 +449,7 @@ static inline void kick_tx(struct net_device *dev,
|
|||||||
dma_sync_desc_cpu(dev, td);
|
dma_sync_desc_cpu(dev, td);
|
||||||
}
|
}
|
||||||
if (td->tdma.cntinfo & HPCDMA_XIU) {
|
if (td->tdma.cntinfo & HPCDMA_XIU) {
|
||||||
|
dma_sync_desc_dev(dev, td);
|
||||||
hregs->tx_ndptr = VIRT_TO_DMA(sp, td);
|
hregs->tx_ndptr = VIRT_TO_DMA(sp, td);
|
||||||
hregs->tx_ctrl = HPC3_ETXCTRL_ACTIVE;
|
hregs->tx_ctrl = HPC3_ETXCTRL_ACTIVE;
|
||||||
}
|
}
|
||||||
@ -476,6 +483,7 @@ static inline void sgiseeq_tx(struct net_device *dev, struct sgiseeq_private *sp
|
|||||||
if (!(td->tdma.cntinfo & (HPCDMA_XIU)))
|
if (!(td->tdma.cntinfo & (HPCDMA_XIU)))
|
||||||
break;
|
break;
|
||||||
if (!(td->tdma.cntinfo & (HPCDMA_ETXD))) {
|
if (!(td->tdma.cntinfo & (HPCDMA_ETXD))) {
|
||||||
|
dma_sync_desc_dev(dev, td);
|
||||||
if (!(status & HPC3_ETXCTRL_ACTIVE)) {
|
if (!(status & HPC3_ETXCTRL_ACTIVE)) {
|
||||||
hregs->tx_ndptr = VIRT_TO_DMA(sp, td);
|
hregs->tx_ndptr = VIRT_TO_DMA(sp, td);
|
||||||
hregs->tx_ctrl = HPC3_ETXCTRL_ACTIVE;
|
hregs->tx_ctrl = HPC3_ETXCTRL_ACTIVE;
|
||||||
@ -740,8 +748,8 @@ static int sgiseeq_probe(struct platform_device *pdev)
|
|||||||
sp = netdev_priv(dev);
|
sp = netdev_priv(dev);
|
||||||
|
|
||||||
/* Make private data page aligned */
|
/* Make private data page aligned */
|
||||||
sr = dma_alloc_attrs(&pdev->dev, sizeof(*sp->srings), &sp->srings_dma,
|
sr = dma_alloc_noncoherent(&pdev->dev, sizeof(*sp->srings),
|
||||||
GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
|
&sp->srings_dma, DMA_BIDIRECTIONAL, GFP_KERNEL);
|
||||||
if (!sr) {
|
if (!sr) {
|
||||||
printk(KERN_ERR "Sgiseeq: Page alloc failed, aborting.\n");
|
printk(KERN_ERR "Sgiseeq: Page alloc failed, aborting.\n");
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
@ -802,8 +810,8 @@ static int sgiseeq_probe(struct platform_device *pdev)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_out_free_attrs:
|
err_out_free_attrs:
|
||||||
dma_free_attrs(&pdev->dev, sizeof(*sp->srings), sp->srings,
|
dma_free_noncoherent(&pdev->dev, sizeof(*sp->srings), sp->srings,
|
||||||
sp->srings_dma, DMA_ATTR_NON_CONSISTENT);
|
sp->srings_dma, DMA_BIDIRECTIONAL);
|
||||||
err_out_free_dev:
|
err_out_free_dev:
|
||||||
free_netdev(dev);
|
free_netdev(dev);
|
||||||
|
|
||||||
@ -817,8 +825,8 @@ static int sgiseeq_remove(struct platform_device *pdev)
|
|||||||
struct sgiseeq_private *sp = netdev_priv(dev);
|
struct sgiseeq_private *sp = netdev_priv(dev);
|
||||||
|
|
||||||
unregister_netdev(dev);
|
unregister_netdev(dev);
|
||||||
dma_free_attrs(&pdev->dev, sizeof(*sp->srings), sp->srings,
|
dma_free_noncoherent(&pdev->dev, sizeof(*sp->srings), sp->srings,
|
||||||
sp->srings_dma, DMA_ATTR_NON_CONSISTENT);
|
sp->srings_dma, DMA_BIDIRECTIONAL);
|
||||||
free_netdev(dev);
|
free_netdev(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user