diff mbox series

[RFC,1/4] b44: Add DMA_ATTR_NO_WARN to dma_map_single attempts

Message ID 201912080835.xB88Z74s014619@sdf.org
State RFC
Delegated to: David Miller
Headers show
Series [RFC,1/4] b44: Add DMA_ATTR_NO_WARN to dma_map_single attempts | expand

Commit Message

George Spelvin Dec. 8, 2019, 8:35 a.m. UTC
The b44 family of fast ethernet chips have a hardware bug limiting
DMA to the low 30 bits of address space.  The driver implements its
own bouncing through ZONE_DMA if buffers are outside this range,
but not before the DMA layer tries the SWIOTLB driver for help.

The latter is designed only for helping devices with a 32-bit DMA
restriction, is not even initialized on machines with < 4GB of RAM,
and proceeds to spam the log with:

b44 0000:02:00.0: swiotlb buffer is full (sz: 66 bytes), total 0 (slots), used 0 (slots)
b44 0000:02:00.0: swiotlb buffer is full (sz: 72 bytes), total 0 (slots), used 0 (slots)
b44 0000:02:00.0: swiotlb buffer is full (sz: 401 bytes), total 0 (slots), used 0 (slots)
swiotlb_tbl_map_single: 7 callbacks suppressed
b44 0000:02:00.0: swiotlb buffer is full (sz: 90 bytes), total 0 (slots), used 0 (slots)
b44 0000:02:00.0: swiotlb buffer is full (sz: 74 bytes), total 0 (slots), used 0 (slots)
b44 0000:02:00.0: swiotlb buffer is full (sz: 74 bytes), total 0 (slots), used 0 (slots)
b44 0000:02:00.0: swiotlb buffer is full (sz: 74 bytes), total 0 (slots), used 0 (slots)
b44 0000:02:00.0: swiotlb buffer is full (sz: 66 bytes), total 0 (slots), used 0 (slots)
b44 0000:02:00.0: swiotlb buffer is full (sz: 426 bytes), total 0 (slots), used 0 (slots)

DMA_ATTR_NO_WARN on the first (non-ZONE_DMA) attempt turns off this
repeated complaint.

There still is a remaining bug: kernel/dma/direct.c:report_addr() throws
a WARN_ON_ONCE the first time this happens.  I'm less certain how to fix
that, but it's less annoying.

Signed-off-by: George Spelvin <lkml@sdf.org>
---
 drivers/net/ethernet/broadcom/b44.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

This is the only substantive patch in the series.  The other three are
relatively minor issues that I ran into while studying the surrounding
code.  (Although #3/4 actually fixes a resource leak.)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 97ab0dd25552..394671230c1c 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -674,9 +674,9 @@  static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
 	if (skb == NULL)
 		return -ENOMEM;
 
-	mapping = dma_map_single(bp->sdev->dma_dev, skb->data,
-				 RX_PKT_BUF_SZ,
-				 DMA_FROM_DEVICE);
+	mapping = dma_map_single_attrs(bp->sdev->dma_dev, skb->data,
+				       RX_PKT_BUF_SZ, DMA_FROM_DEVICE,
+				       DMA_ATTR_NO_WARN);
 
 	/* Hardware bug work-around, the chip is unable to do PCI DMA
 	   to/from anything above 1GB :-( */
@@ -988,7 +988,8 @@  static netdev_tx_t b44_start_xmit(struct sk_buff *skb, struct net_device *dev)
 		goto err_out;
 	}
 
-	mapping = dma_map_single(bp->sdev->dma_dev, skb->data, len, DMA_TO_DEVICE);
+	mapping = dma_map_single_attrs(bp->sdev->dma_dev, skb->data, len,
+				       DMA_TO_DEVICE, DMA_ATTR_NO_WARN);
 	if (dma_mapping_error(bp->sdev->dma_dev, mapping) || mapping + len > DMA_BIT_MASK(30)) {
 		struct sk_buff *bounce_skb;