Skip to contentSkip to conversation

net: fec: check DMA addressing limitations

PATCH Applied Stefan Agner 4 participants 4 messages Aug 2, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: fec: check DMA addressing limitations

Check DMA addressing limitations as suggested by the DMA API how-to. This does not fix a particular issue seen but is considered good style.

---
 drivers/net/ethernet/freescale/fec_main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +8 -0
index c729665107f5..cdf2f5447910 100644
@@ -3136,6 +3136,7 @@ static int fec_enet_init(struct net_device *ndev)
 	unsigned dsize = fep->bufdesc_ex ? sizeof(struct bufdesc_ex) :
 			sizeof(struct bufdesc);
 	unsigned dsize_log2 = __fls(dsize);
+	int ret;
 
 	WARN_ON(dsize != (1 << dsize_log2));
 #if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
@@ -3146,6 +3147,13 @@ static int fec_enet_init(struct net_device *ndev)
 	fep->tx_align = 0x3;
 #endif
 
+	/* Check mask of the streaming and coherent API */
+	ret = dma_set_mask_and_coherent(&fep->pdev->dev, DMA_BIT_MASK(32));
+	if (ret < 0) {
+		dev_warn(&fep->pdev->dev, "No suitable DMA available\n");
+		return ret;
+	}
+
 	fec_enet_alloc_queue(ndev);
 
 	bd_size = (fep->total_tx_ring_size + fep->total_rx_ring_size) * dsize;
Signature · 1 line
2.18.0
Acked-by on v2 1/1
#1 lore raw

From: Stefan Agner <[email protected]> Sent: 2018年8月2日 16:43

Quoted 4 lines

Check DMA addressing limitations as suggested by the DMA API how-to. This does not fix a particular issue seen but is considered good style.

Quoted 35 lines
---
 drivers/net/ethernet/freescale/fec_main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +1 -0
index c729665107f5..cdf2f5447910 100644
@@ -3136,6 +3136,7 @@ static int fec_enet_init(struct net_device
 *ndev)
 	unsigned dsize = fep->bufdesc_ex ? sizeof(struct bufdesc_ex) :
 			sizeof(struct bufdesc);
 	unsigned dsize_log2 = __fls(dsize);
+	int ret;
 
 	WARN_ON(dsize != (1 << dsize_log2));

#if defined(CONFIG_ARM) || defined(CONFIG_ARM64) @@ -3146,6
+3147,13 @@ static int fec_enet_init(struct net_device *ndev)

drivers/net/ethernet/freescale/fec_main.c +2 -0
 	fep->tx_align = 0x3;
 #endif
 
+	/* Check mask of the streaming and coherent API */
+	ret = dma_set_mask_and_coherent(&fep->pdev->dev,

DMA_BIT_MASK(32));

drivers/net/ethernet/freescale/fec_main.c +5 -1
+	if (ret < 0) {
+		dev_warn(&fep->pdev->dev, "No suitable DMA available\n");
+		return ret;
+	}
+
 	fec_enet_alloc_queue(ndev);
 
 	bd_size = (fep->total_tx_ring_size + fep->total_rx_ring_size) * dsize;
--

2.18.0

Reviewed-by on v2 1/1
#2 lore raw
In reply to Stefan Agner
Quoted 3 lines · Stefan Agner

Check DMA addressing limitations as suggested by the DMA API how-to. This does not fix a particular issue seen but is considered good style.

Quoted 32 lines
---
  drivers/net/ethernet/freescale/fec_main.c | 8 ++++++++
  1 file changed, 8 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +8 -0
index c729665107f5..cdf2f5447910 100644
@@ -3136,6 +3136,7 @@ static int fec_enet_init(struct net_device *ndev)
  	unsigned dsize = fep->bufdesc_ex ? sizeof(struct bufdesc_ex) :
  			sizeof(struct bufdesc);
  	unsigned dsize_log2 = __fls(dsize);
+	int ret;
 
  	WARN_ON(dsize != (1 << dsize_log2));
  #if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
@@ -3146,6 +3147,13 @@ static int fec_enet_init(struct net_device *ndev)
  	fep->tx_align = 0x3;
  #endif
 
+	/* Check mask of the streaming and coherent API */
+	ret = dma_set_mask_and_coherent(&fep->pdev->dev, DMA_BIT_MASK(32));
+	if (ret < 0) {
+		dev_warn(&fep->pdev->dev, "No suitable DMA available\n");
+		return ret;
+	}
+
  	fec_enet_alloc_queue(ndev);
 
  	bd_size = (fep->total_tx_ring_size + fep->total_rx_ring_size) * dsize;