linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [10/18] smc911x: pass struct device to DMA API functions
@ 2019-02-01  8:47 Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2019-02-01  8:47 UTC (permalink / raw)
  To: John Crispin, Vinod Koul, Dmitry Tarnyagin, Nicolas Ferre,
	Sudip Mukherjee, Felipe Balbi, linux-mips, linux-kernel,
	dmaengine, netdev, linux-usb, linux-fbdev, alsa-devel
  Cc: iommu

The DMA API generally relies on a struct device to work properly, and
only barely works without one for legacy reasons.  Pass the easily
available struct device from the platform_device to remedy this.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/net/ethernet/smsc/smc911x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c
index 8355dfbb8ec3..b550e624500d 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -1188,7 +1188,7 @@ smc911x_tx_dma_irq(void *data)
 
 	DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, dev, "TX DMA irq handler\n");
 	BUG_ON(skb == NULL);
-	dma_unmap_single(NULL, tx_dmabuf, tx_dmalen, DMA_TO_DEVICE);
+	dma_unmap_single(lp->dev, tx_dmabuf, tx_dmalen, DMA_TO_DEVICE);
 	netif_trans_update(dev);
 	dev_kfree_skb_irq(skb);
 	lp->current_tx_skb = NULL;
@@ -1219,7 +1219,7 @@ smc911x_rx_dma_irq(void *data)
 
 	DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
 	DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA, dev, "RX DMA irq handler\n");
-	dma_unmap_single(NULL, rx_dmabuf, rx_dmalen, DMA_FROM_DEVICE);
+	dma_unmap_single(lp->dev, rx_dmabuf, rx_dmalen, DMA_FROM_DEVICE);
 	BUG_ON(skb == NULL);
 	lp->current_rx_skb = NULL;
 	PRINT_PKT(skb->data, skb->len);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [10/18] smc911x: pass struct device to DMA API functions
@ 2019-02-01 14:14 Robin Murphy
  0 siblings, 0 replies; 3+ messages in thread
From: Robin Murphy @ 2019-02-01 14:14 UTC (permalink / raw)
  To: Christoph Hellwig, John Crispin, Vinod Koul, Dmitry Tarnyagin,
	Nicolas Ferre, Sudip Mukherjee, Felipe Balbi, linux-mips,
	linux-kernel, dmaengine, netdev, linux-usb, linux-fbdev,
	alsa-devel
  Cc: iommu

On 01/02/2019 08:47, Christoph Hellwig wrote:
> The DMA API generally relies on a struct device to work properly, and
> only barely works without one for legacy reasons.  Pass the easily
> available struct device from the platform_device to remedy this.

Hmm, as far as I'm aware these are PIO chips with external DMA 
handshaking, rather than actual DMA masters...

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/net/ethernet/smsc/smc911x.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c
> index 8355dfbb8ec3..b550e624500d 100644
> --- a/drivers/net/ethernet/smsc/smc911x.c
> +++ b/drivers/net/ethernet/smsc/smc911x.c
> @@ -1188,7 +1188,7 @@ smc911x_tx_dma_irq(void *data)
>   
>   	DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, dev, "TX DMA irq handler\n");
>   	BUG_ON(skb == NULL);
> -	dma_unmap_single(NULL, tx_dmabuf, tx_dmalen, DMA_TO_DEVICE);
> +	dma_unmap_single(lp->dev, tx_dmabuf, tx_dmalen, DMA_TO_DEVICE);

..so while the wrong device is still better than no device at all, this 
probably wants lp->txdma->device->dev.

>   	netif_trans_update(dev);
>   	dev_kfree_skb_irq(skb);
>   	lp->current_tx_skb = NULL;
> @@ -1219,7 +1219,7 @@ smc911x_rx_dma_irq(void *data)
>   
>   	DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
>   	DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA, dev, "RX DMA irq handler\n");
> -	dma_unmap_single(NULL, rx_dmabuf, rx_dmalen, DMA_FROM_DEVICE);
> +	dma_unmap_single(lp->dev, rx_dmabuf, rx_dmalen, DMA_FROM_DEVICE);

And equivalently for rxdma here. However, given that this all seems only 
relevant to antique ARCH_PXA platforms which are presumably managing to 
work as-is, it's probably not worth tinkering too much. I'd just stick a 
note in the commit message that we're still only making these 
self-consistent with the existing dma_map_single() calls rather than 
necessarily correct.

Robin.

>   	BUG_ON(skb == NULL);
>   	lp->current_rx_skb = NULL;
>   	PRINT_PKT(skb->data, skb->len);
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [10/18] smc911x: pass struct device to DMA API functions
@ 2019-02-01 16:11 Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2019-02-01 16:11 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Christoph Hellwig, John Crispin, Vinod Koul, Dmitry Tarnyagin,
	Nicolas Ferre, Sudip Mukherjee, Felipe Balbi, linux-mips,
	linux-kernel, dmaengine, netdev, linux-usb, linux-fbdev,
	alsa-devel, iommu

On Fri, Feb 01, 2019 at 02:14:34PM +0000, Robin Murphy wrote:
> And equivalently for rxdma here. However, given that this all seems only 
> relevant to antique ARCH_PXA platforms which are presumably managing to 
> work as-is, it's probably not worth tinkering too much. I'd just stick a 
> note in the commit message that we're still only making these 
> self-consistent with the existing dma_map_single() calls rather than 
> necessarily correct.

Sounds good.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-01 16:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-01 16:11 [10/18] smc911x: pass struct device to DMA API functions Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2019-02-01 14:14 Robin Murphy
2019-02-01  8:47 Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).