netdma: adding alignment check for NETDMA ops
authorDave Jiang <dave.jiang@intel.com>
Wed, 4 Apr 2012 23:10:46 +0000 (16:10 -0700)
committerDan Williams <dan.j.williams@intel.com>
Thu, 5 Apr 2012 22:27:12 +0000 (15:27 -0700)
This is the fallout from adding memcpy alignment workaround for certain
IOATDMA hardware. NetDMA will only use DMA engine that can handle byte align
ops.

Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/dma/dmaengine.c
include/linux/dmaengine.h
net/ipv4/tcp.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv6/tcp_ipv6.c

index a6c6051ec85811041277c64d675810f14d9da851..0f1ca74fe0bb9edc21b54119dbb1b82754e9b703 100644 (file)
@@ -332,6 +332,20 @@ struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)
 }
 EXPORT_SYMBOL(dma_find_channel);
 
+/*
+ * net_dma_find_channel - find a channel for net_dma
+ * net_dma has alignment requirements
+ */
+struct dma_chan *net_dma_find_channel(void)
+{
+       struct dma_chan *chan = dma_find_channel(DMA_MEMCPY);
+       if (chan && !is_dma_copy_aligned(chan->device, 1, 1, 1))
+               return NULL;
+
+       return chan;
+}
+EXPORT_SYMBOL(net_dma_find_channel);
+
 /**
  * dma_issue_pending_all - flush all pending operations across all channels
  */
index 679b349d9b66695f65bb3597b2a530e3e9709600..a5bb3ad5c7a5a6a89d16d529c564f6e2e3274642 100644 (file)
@@ -948,6 +948,7 @@ int dma_async_device_register(struct dma_device *device);
 void dma_async_device_unregister(struct dma_device *device);
 void dma_run_dependencies(struct dma_async_tx_descriptor *tx);
 struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type);
+struct dma_chan *net_dma_find_channel(void);
 #define dma_request_channel(mask, x, y) __dma_request_channel(&(mask), x, y)
 
 /* --- Helper iov-locking functions --- */
index 22ef5f9fd2ff2e92dc4955dc9a2ac450d8a435fa..8712c5d4f91de3064a27b12999ac6b4927185fd7 100644 (file)
@@ -1450,7 +1450,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                if ((available < target) &&
                    (len > sysctl_tcp_dma_copybreak) && !(flags & MSG_PEEK) &&
                    !sysctl_tcp_low_latency &&
-                   dma_find_channel(DMA_MEMCPY)) {
+                   net_dma_find_channel()) {
                        preempt_enable_no_resched();
                        tp->ucopy.pinned_list =
                                        dma_pin_iovec_pages(msg->msg_iov, len);
@@ -1665,7 +1665,7 @@ do_prequeue:
                if (!(flags & MSG_TRUNC)) {
 #ifdef CONFIG_NET_DMA
                        if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
-                               tp->ucopy.dma_chan = dma_find_channel(DMA_MEMCPY);
+                               tp->ucopy.dma_chan = net_dma_find_channel();
 
                        if (tp->ucopy.dma_chan) {
                                tp->ucopy.dma_cookie = dma_skb_copy_datagram_iovec(
index b5e315f13641d683c2ab9031c0d52969c6c0873a..27c676dfea336017faf91d69028c9a10eead4296 100644 (file)
@@ -5190,7 +5190,7 @@ static int tcp_dma_try_early_copy(struct sock *sk, struct sk_buff *skb,
                return 0;
 
        if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
-               tp->ucopy.dma_chan = dma_find_channel(DMA_MEMCPY);
+               tp->ucopy.dma_chan = net_dma_find_channel();
 
        if (tp->ucopy.dma_chan && skb_csum_unnecessary(skb)) {
 
index fd54c5f8a255e81f490846e13fa827da9aaf77ac..3810b6fe0a1e801ed7820072b6776bc94a6fa0c5 100644 (file)
@@ -1727,7 +1727,7 @@ process:
 #ifdef CONFIG_NET_DMA
                struct tcp_sock *tp = tcp_sk(sk);
                if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
-                       tp->ucopy.dma_chan = dma_find_channel(DMA_MEMCPY);
+                       tp->ucopy.dma_chan = net_dma_find_channel();
                if (tp->ucopy.dma_chan)
                        ret = tcp_v4_do_rcv(sk, skb);
                else
index 3edd05ae4388741176949e9c72f3543fa8d52c87..fcb3e4f0010ee3bf25b07fdfdbd61cc68c291b8d 100644 (file)
@@ -1755,7 +1755,7 @@ process:
 #ifdef CONFIG_NET_DMA
                struct tcp_sock *tp = tcp_sk(sk);
                if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
-                       tp->ucopy.dma_chan = dma_find_channel(DMA_MEMCPY);
+                       tp->ucopy.dma_chan = net_dma_find_channel();
                if (tp->ucopy.dma_chan)
                        ret = tcp_v6_do_rcv(sk, skb);
                else