aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2010-03-30 18:35:50 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-01 22:53:12 -0400
commit5acbbd428db47b12f137a8a2aa96b3c0a96b744e (patch)
tree20ffdc4e418a086411f6fa8ff4ead2d488bda8da /net/core/dev.c
parent4fd89b7af28292e190650b9b9bc4308658d81dd1 (diff)
net: change illegal_highdma to use dma_mask
Robert Hancock pointed out two problems about NETIF_F_HIGHDMA: -Many drivers only set the flag when they detect they can use 64-bit DMA, since otherwise they could receive DMA addresses that they can't handle (which on platforms without IOMMU/SWIOTLB support is fatal). This means that if 64-bit support isn't available, even buffers located below 4GB will get copied unnecessarily. -Some drivers set the flag even though they can't actually handle 64-bit DMA, which would mean that on platforms without IOMMU/SWIOTLB they would get a DMA mapping error if the memory they received happened to be located above 4GB. http://lkml.org/lkml/2010/3/3/530 We can use the dma_mask if we need bouncing or not here. Then we can safely fix drivers that misuse NETIF_F_HIGHDMA. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 427cd53c118d..e19cdae49fef 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -129,6 +129,7 @@
129#include <linux/jhash.h> 129#include <linux/jhash.h>
130#include <linux/random.h> 130#include <linux/random.h>
131#include <trace/events/napi.h> 131#include <trace/events/napi.h>
132#include <linux/pci.h>
132 133
133#include "net-sysfs.h" 134#include "net-sysfs.h"
134 135
@@ -1804,14 +1805,21 @@ static inline int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
1804{ 1805{
1805#ifdef CONFIG_HIGHMEM 1806#ifdef CONFIG_HIGHMEM
1806 int i; 1807 int i;
1808 if (!(dev->features & NETIF_F_HIGHDMA)) {
1809 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
1810 if (PageHighMem(skb_shinfo(skb)->frags[i].page))
1811 return 1;
1812 }
1807 1813
1808 if (dev->features & NETIF_F_HIGHDMA) 1814 if (PCI_DMA_BUS_IS_PHYS) {
1809 return 0; 1815 struct device *pdev = dev->dev.parent;
1810
1811 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
1812 if (PageHighMem(skb_shinfo(skb)->frags[i].page))
1813 return 1;
1814 1816
1817 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1818 dma_addr_t addr = page_to_phys(skb_shinfo(skb)->frags[i].page);
1819 if (!pdev->dma_mask || addr + PAGE_SIZE - 1 > *pdev->dma_mask)
1820 return 1;
1821 }
1822 }
1815#endif 1823#endif
1816 return 0; 1824 return 0;
1817} 1825}