aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/memory-barriers.txt42
-rw-r--r--arch/alpha/include/asm/barrier.h51
-rw-r--r--arch/arm/include/asm/barrier.h4
-rw-r--r--arch/arm64/include/asm/barrier.h3
-rw-r--r--arch/blackfin/include/asm/barrier.h51
-rw-r--r--arch/ia64/include/asm/barrier.h25
-rw-r--r--arch/metag/include/asm/barrier.h19
-rw-r--r--arch/mips/include/asm/barrier.h61
-rw-r--r--arch/powerpc/include/asm/barrier.h19
-rw-r--r--arch/s390/include/asm/barrier.h7
-rw-r--r--arch/sparc/include/asm/barrier_64.h7
-rw-r--r--arch/x86/include/asm/barrier.h70
-rw-r--r--arch/x86/um/asm/barrier.h20
-rw-r--r--drivers/net/dsa/bcm_sf2.c23
-rw-r--r--drivers/net/ethernet/cadence/macb.c456
-rw-r--r--drivers/net/ethernet/cadence/macb.h36
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4.h2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c13
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h2
-rw-r--r--drivers/net/ethernet/davicom/Kconfig2
-rw-r--r--drivers/net/ethernet/intel/fm10k/fm10k_main.c6
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c6
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c9
-rw-r--r--drivers/net/ethernet/jme.c12
-rw-r--r--drivers/net/ethernet/realtek/r8169.c53
-rw-r--r--drivers/net/ethernet/smsc/Kconfig4
-rw-r--r--drivers/net/phy/fixed.c1
-rw-r--r--drivers/scsi/cxgbi/cxgb4i/cxgb4i.c144
-rw-r--r--drivers/scsi/cxgbi/libcxgbi.c4
-rw-r--r--drivers/scsi/cxgbi/libcxgbi.h4
-rw-r--r--include/asm-generic/barrier.h8
-rw-r--r--include/linux/interrupt.h6
-rw-r--r--net/8021q/vlan_dev.c7
-rw-r--r--net/dsa/slave.c16
-rw-r--r--net/ipv4/fib_trie.c3
35 files changed, 771 insertions, 425 deletions
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index 7ee2ae6d5451..70a09f8a0383 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -1633,6 +1633,48 @@ There are some more advanced barrier functions:
1633 operations" subsection for information on where to use these. 1633 operations" subsection for information on where to use these.
1634 1634
1635 1635
1636 (*) dma_wmb();
1637 (*) dma_rmb();
1638
1639 These are for use with consistent memory to guarantee the ordering
1640 of writes or reads of shared memory accessible to both the CPU and a
1641 DMA capable device.
1642
1643 For example, consider a device driver that shares memory with a device
1644 and uses a descriptor status value to indicate if the descriptor belongs
1645 to the device or the CPU, and a doorbell to notify it when new
1646 descriptors are available:
1647
1648 if (desc->status != DEVICE_OWN) {
1649 /* do not read data until we own descriptor */
1650 dma_rmb();
1651
1652 /* read/modify data */
1653 read_data = desc->data;
1654 desc->data = write_data;
1655
1656 /* flush modifications before status update */
1657 dma_wmb();
1658
1659 /* assign ownership */
1660 desc->status = DEVICE_OWN;
1661
1662 /* force memory to sync before notifying device via MMIO */
1663 wmb();
1664
1665 /* notify device of new descriptors */
1666 writel(DESC_NOTIFY, doorbell);
1667 }
1668
1669 The dma_rmb() allows us guarantee the device has released ownership
1670 before we read the data from the descriptor, and he dma_wmb() allows
1671 us to guarantee the data is written to the descriptor before the device
1672 can see it now has ownership. The wmb() is needed to guarantee that the
1673 cache coherent memory writes have completed before attempting a write to
1674 the cache incoherent MMIO region.
1675
1676 See Documentation/DMA-API.txt for more information on consistent memory.
1677
1636MMIO WRITE BARRIER 1678MMIO WRITE BARRIER
1637------------------ 1679------------------
1638 1680
diff --git a/arch/alpha/include/asm/barrier.h b/arch/alpha/include/asm/barrier.h
index 3832bdb794fe..77516c87255d 100644
--- a/arch/alpha/include/asm/barrier.h
+++ b/arch/alpha/include/asm/barrier.h
@@ -7,6 +7,57 @@
7#define rmb() __asm__ __volatile__("mb": : :"memory") 7#define rmb() __asm__ __volatile__("mb": : :"memory")
8#define wmb() __asm__ __volatile__("wmb": : :"memory") 8#define wmb() __asm__ __volatile__("wmb": : :"memory")
9 9
10/**
11 * read_barrier_depends - Flush all pending reads that subsequents reads
12 * depend on.
13 *
14 * No data-dependent reads from memory-like regions are ever reordered
15 * over this barrier. All reads preceding this primitive are guaranteed
16 * to access memory (but not necessarily other CPUs' caches) before any
17 * reads following this primitive that depend on the data return by
18 * any of the preceding reads. This primitive is much lighter weight than
19 * rmb() on most CPUs, and is never heavier weight than is
20 * rmb().
21 *
22 * These ordering constraints are respected by both the local CPU
23 * and the compiler.
24 *
25 * Ordering is not guaranteed by anything other than these primitives,
26 * not even by data dependencies. See the documentation for
27 * memory_barrier() for examples and URLs to more information.
28 *
29 * For example, the following code would force ordering (the initial
30 * value of "a" is zero, "b" is one, and "p" is "&a"):
31 *
32 * <programlisting>
33 * CPU 0 CPU 1
34 *
35 * b = 2;
36 * memory_barrier();
37 * p = &b; q = p;
38 * read_barrier_depends();
39 * d = *q;
40 * </programlisting>
41 *
42 * because the read of "*q" depends on the read of "p" and these
43 * two reads are separated by a read_barrier_depends(). However,
44 * the following code, with the same initial values for "a" and "b":
45 *
46 * <programlisting>
47 * CPU 0 CPU 1
48 *
49 * a = 2;
50 * memory_barrier();
51 * b = 3; y = b;
52 * read_barrier_depends();
53 * x = a;
54 * </programlisting>
55 *
56 * does not enforce ordering, since there is no data dependency between
57 * the read of "a" and the read of "b". Therefore, on some CPUs, such
58 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
59 * in cases like this where there are no data dependencies.
60 */
10#define read_barrier_depends() __asm__ __volatile__("mb": : :"memory") 61#define read_barrier_depends() __asm__ __volatile__("mb": : :"memory")
11 62
12#ifdef CONFIG_SMP 63#ifdef CONFIG_SMP
diff --git a/arch/arm/include/asm/barrier.h b/arch/arm/include/asm/barrier.h
index c6a3e73a6e24..d2f81e6b8c1c 100644
--- a/arch/arm/include/asm/barrier.h
+++ b/arch/arm/include/asm/barrier.h
@@ -43,10 +43,14 @@
43#define mb() do { dsb(); outer_sync(); } while (0) 43#define mb() do { dsb(); outer_sync(); } while (0)
44#define rmb() dsb() 44#define rmb() dsb()
45#define wmb() do { dsb(st); outer_sync(); } while (0) 45#define wmb() do { dsb(st); outer_sync(); } while (0)
46#define dma_rmb() dmb(osh)
47#define dma_wmb() dmb(oshst)
46#else 48#else
47#define mb() barrier() 49#define mb() barrier()
48#define rmb() barrier() 50#define rmb() barrier()
49#define wmb() barrier() 51#define wmb() barrier()
52#define dma_rmb() barrier()
53#define dma_wmb() barrier()
50#endif 54#endif
51 55
52#ifndef CONFIG_SMP 56#ifndef CONFIG_SMP
diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
index 6389d60574d9..a5abb0062d6e 100644
--- a/arch/arm64/include/asm/barrier.h
+++ b/arch/arm64/include/asm/barrier.h
@@ -32,6 +32,9 @@
32#define rmb() dsb(ld) 32#define rmb() dsb(ld)
33#define wmb() dsb(st) 33#define wmb() dsb(st)
34 34
35#define dma_rmb() dmb(oshld)
36#define dma_wmb() dmb(oshst)
37
35#ifndef CONFIG_SMP 38#ifndef CONFIG_SMP
36#define smp_mb() barrier() 39#define smp_mb() barrier()
37#define smp_rmb() barrier() 40#define smp_rmb() barrier()
diff --git a/arch/blackfin/include/asm/barrier.h b/arch/blackfin/include/asm/barrier.h
index 420006877998..dfb66fe88b34 100644
--- a/arch/blackfin/include/asm/barrier.h
+++ b/arch/blackfin/include/asm/barrier.h
@@ -22,6 +22,57 @@
22# define mb() do { barrier(); smp_check_barrier(); smp_mark_barrier(); } while (0) 22# define mb() do { barrier(); smp_check_barrier(); smp_mark_barrier(); } while (0)
23# define rmb() do { barrier(); smp_check_barrier(); } while (0) 23# define rmb() do { barrier(); smp_check_barrier(); } while (0)
24# define wmb() do { barrier(); smp_mark_barrier(); } while (0) 24# define wmb() do { barrier(); smp_mark_barrier(); } while (0)
25/*
26 * read_barrier_depends - Flush all pending reads that subsequents reads
27 * depend on.
28 *
29 * No data-dependent reads from memory-like regions are ever reordered
30 * over this barrier. All reads preceding this primitive are guaranteed
31 * to access memory (but not necessarily other CPUs' caches) before any
32 * reads following this primitive that depend on the data return by
33 * any of the preceding reads. This primitive is much lighter weight than
34 * rmb() on most CPUs, and is never heavier weight than is
35 * rmb().
36 *
37 * These ordering constraints are respected by both the local CPU
38 * and the compiler.
39 *
40 * Ordering is not guaranteed by anything other than these primitives,
41 * not even by data dependencies. See the documentation for
42 * memory_barrier() for examples and URLs to more information.
43 *
44 * For example, the following code would force ordering (the initial
45 * value of "a" is zero, "b" is one, and "p" is "&a"):
46 *
47 * <programlisting>
48 * CPU 0 CPU 1
49 *
50 * b = 2;
51 * memory_barrier();
52 * p = &b; q = p;
53 * read_barrier_depends();
54 * d = *q;
55 * </programlisting>
56 *
57 * because the read of "*q" depends on the read of "p" and these
58 * two reads are separated by a read_barrier_depends(). However,
59 * the following code, with the same initial values for "a" and "b":
60 *
61 * <programlisting>
62 * CPU 0 CPU 1
63 *
64 * a = 2;
65 * memory_barrier();
66 * b = 3; y = b;
67 * read_barrier_depends();
68 * x = a;
69 * </programlisting>
70 *
71 * does not enforce ordering, since there is no data dependency between
72 * the read of "a" and the read of "b". Therefore, on some CPUs, such
73 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
74 * in cases like this where there are no data dependencies.
75 */
25# define read_barrier_depends() do { barrier(); smp_check_barrier(); } while (0) 76# define read_barrier_depends() do { barrier(); smp_check_barrier(); } while (0)
26#endif 77#endif
27 78
diff --git a/arch/ia64/include/asm/barrier.h b/arch/ia64/include/asm/barrier.h
index a48957c7b445..f6769eb2bbf9 100644
--- a/arch/ia64/include/asm/barrier.h
+++ b/arch/ia64/include/asm/barrier.h
@@ -35,26 +35,25 @@
35 * it's (presumably) much slower than mf and (b) mf.a is supported for 35 * it's (presumably) much slower than mf and (b) mf.a is supported for
36 * sequential memory pages only. 36 * sequential memory pages only.
37 */ 37 */
38#define mb() ia64_mf() 38#define mb() ia64_mf()
39#define rmb() mb() 39#define rmb() mb()
40#define wmb() mb() 40#define wmb() mb()
41#define read_barrier_depends() do { } while(0) 41
42#define dma_rmb() mb()
43#define dma_wmb() mb()
42 44
43#ifdef CONFIG_SMP 45#ifdef CONFIG_SMP
44# define smp_mb() mb() 46# define smp_mb() mb()
45# define smp_rmb() rmb()
46# define smp_wmb() wmb()
47# define smp_read_barrier_depends() read_barrier_depends()
48
49#else 47#else
50
51# define smp_mb() barrier() 48# define smp_mb() barrier()
52# define smp_rmb() barrier()
53# define smp_wmb() barrier()
54# define smp_read_barrier_depends() do { } while(0)
55
56#endif 49#endif
57 50
51#define smp_rmb() smp_mb()
52#define smp_wmb() smp_mb()
53
54#define read_barrier_depends() do { } while (0)
55#define smp_read_barrier_depends() do { } while (0)
56
58#define smp_mb__before_atomic() barrier() 57#define smp_mb__before_atomic() barrier()
59#define smp_mb__after_atomic() barrier() 58#define smp_mb__after_atomic() barrier()
60 59
diff --git a/arch/metag/include/asm/barrier.h b/arch/metag/include/asm/barrier.h
index c7591e80067c..d703d8e26a65 100644
--- a/arch/metag/include/asm/barrier.h
+++ b/arch/metag/include/asm/barrier.h
@@ -4,8 +4,6 @@
4#include <asm/metag_mem.h> 4#include <asm/metag_mem.h>
5 5
6#define nop() asm volatile ("NOP") 6#define nop() asm volatile ("NOP")
7#define mb() wmb()
8#define rmb() barrier()
9 7
10#ifdef CONFIG_METAG_META21 8#ifdef CONFIG_METAG_META21
11 9
@@ -41,13 +39,13 @@ static inline void wr_fence(void)
41 39
42#endif /* !CONFIG_METAG_META21 */ 40#endif /* !CONFIG_METAG_META21 */
43 41
44static inline void wmb(void) 42/* flush writes through the write combiner */
45{ 43#define mb() wr_fence()
46 /* flush writes through the write combiner */ 44#define rmb() barrier()
47 wr_fence(); 45#define wmb() mb()
48}
49 46
50#define read_barrier_depends() do { } while (0) 47#define dma_rmb() rmb()
48#define dma_wmb() wmb()
51 49
52#ifndef CONFIG_SMP 50#ifndef CONFIG_SMP
53#define fence() do { } while (0) 51#define fence() do { } while (0)
@@ -82,7 +80,10 @@ static inline void fence(void)
82#define smp_wmb() barrier() 80#define smp_wmb() barrier()
83#endif 81#endif
84#endif 82#endif
85#define smp_read_barrier_depends() do { } while (0) 83
84#define read_barrier_depends() do { } while (0)
85#define smp_read_barrier_depends() do { } while (0)
86
86#define set_mb(var, value) do { var = value; smp_mb(); } while (0) 87#define set_mb(var, value) do { var = value; smp_mb(); } while (0)
87 88
88#define smp_store_release(p, v) \ 89#define smp_store_release(p, v) \
diff --git a/arch/mips/include/asm/barrier.h b/arch/mips/include/asm/barrier.h
index d0101dd0575e..2b8bbbcb9be0 100644
--- a/arch/mips/include/asm/barrier.h
+++ b/arch/mips/include/asm/barrier.h
@@ -10,58 +10,6 @@
10 10
11#include <asm/addrspace.h> 11#include <asm/addrspace.h>
12 12
13/*
14 * read_barrier_depends - Flush all pending reads that subsequents reads
15 * depend on.
16 *
17 * No data-dependent reads from memory-like regions are ever reordered
18 * over this barrier. All reads preceding this primitive are guaranteed
19 * to access memory (but not necessarily other CPUs' caches) before any
20 * reads following this primitive that depend on the data return by
21 * any of the preceding reads. This primitive is much lighter weight than
22 * rmb() on most CPUs, and is never heavier weight than is
23 * rmb().
24 *
25 * These ordering constraints are respected by both the local CPU
26 * and the compiler.
27 *
28 * Ordering is not guaranteed by anything other than these primitives,
29 * not even by data dependencies. See the documentation for
30 * memory_barrier() for examples and URLs to more information.
31 *
32 * For example, the following code would force ordering (the initial
33 * value of "a" is zero, "b" is one, and "p" is "&a"):
34 *
35 * <programlisting>
36 * CPU 0 CPU 1
37 *
38 * b = 2;
39 * memory_barrier();
40 * p = &b; q = p;
41 * read_barrier_depends();
42 * d = *q;
43 * </programlisting>
44 *
45 * because the read of "*q" depends on the read of "p" and these
46 * two reads are separated by a read_barrier_depends(). However,
47 * the following code, with the same initial values for "a" and "b":
48 *
49 * <programlisting>
50 * CPU 0 CPU 1
51 *
52 * a = 2;
53 * memory_barrier();
54 * b = 3; y = b;
55 * read_barrier_depends();
56 * x = a;
57 * </programlisting>
58 *
59 * does not enforce ordering, since there is no data dependency between
60 * the read of "a" and the read of "b". Therefore, on some CPUs, such
61 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
62 * in cases like this where there are no data dependencies.
63 */
64
65#define read_barrier_depends() do { } while(0) 13#define read_barrier_depends() do { } while(0)
66#define smp_read_barrier_depends() do { } while(0) 14#define smp_read_barrier_depends() do { } while(0)
67 15
@@ -127,20 +75,21 @@
127 75
128#include <asm/wbflush.h> 76#include <asm/wbflush.h>
129 77
130#define wmb() fast_wmb()
131#define rmb() fast_rmb()
132#define mb() wbflush() 78#define mb() wbflush()
133#define iob() wbflush() 79#define iob() wbflush()
134 80
135#else /* !CONFIG_CPU_HAS_WB */ 81#else /* !CONFIG_CPU_HAS_WB */
136 82
137#define wmb() fast_wmb()
138#define rmb() fast_rmb()
139#define mb() fast_mb() 83#define mb() fast_mb()
140#define iob() fast_iob() 84#define iob() fast_iob()
141 85
142#endif /* !CONFIG_CPU_HAS_WB */ 86#endif /* !CONFIG_CPU_HAS_WB */
143 87
88#define wmb() fast_wmb()
89#define rmb() fast_rmb()
90#define dma_wmb() fast_wmb()
91#define dma_rmb() fast_rmb()
92
144#if defined(CONFIG_WEAK_ORDERING) && defined(CONFIG_SMP) 93#if defined(CONFIG_WEAK_ORDERING) && defined(CONFIG_SMP)
145# ifdef CONFIG_CPU_CAVIUM_OCTEON 94# ifdef CONFIG_CPU_CAVIUM_OCTEON
146# define smp_mb() __sync() 95# define smp_mb() __sync()
diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h
index bab79a110c7b..a3bf5be111ff 100644
--- a/arch/powerpc/include/asm/barrier.h
+++ b/arch/powerpc/include/asm/barrier.h
@@ -33,12 +33,9 @@
33#define mb() __asm__ __volatile__ ("sync" : : : "memory") 33#define mb() __asm__ __volatile__ ("sync" : : : "memory")
34#define rmb() __asm__ __volatile__ ("sync" : : : "memory") 34#define rmb() __asm__ __volatile__ ("sync" : : : "memory")
35#define wmb() __asm__ __volatile__ ("sync" : : : "memory") 35#define wmb() __asm__ __volatile__ ("sync" : : : "memory")
36#define read_barrier_depends() do { } while(0)
37 36
38#define set_mb(var, value) do { var = value; mb(); } while (0) 37#define set_mb(var, value) do { var = value; mb(); } while (0)
39 38
40#ifdef CONFIG_SMP
41
42#ifdef __SUBARCH_HAS_LWSYNC 39#ifdef __SUBARCH_HAS_LWSYNC
43# define SMPWMB LWSYNC 40# define SMPWMB LWSYNC
44#else 41#else
@@ -46,20 +43,26 @@
46#endif 43#endif
47 44
48#define __lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory") 45#define __lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
46#define dma_rmb() __lwsync()
47#define dma_wmb() __asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
48
49#ifdef CONFIG_SMP
50#define smp_lwsync() __lwsync()
49 51
50#define smp_mb() mb() 52#define smp_mb() mb()
51#define smp_rmb() __lwsync() 53#define smp_rmb() __lwsync()
52#define smp_wmb() __asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory") 54#define smp_wmb() __asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
53#define smp_read_barrier_depends() read_barrier_depends()
54#else 55#else
55#define __lwsync() barrier() 56#define smp_lwsync() barrier()
56 57
57#define smp_mb() barrier() 58#define smp_mb() barrier()
58#define smp_rmb() barrier() 59#define smp_rmb() barrier()
59#define smp_wmb() barrier() 60#define smp_wmb() barrier()
60#define smp_read_barrier_depends() do { } while(0)
61#endif /* CONFIG_SMP */ 61#endif /* CONFIG_SMP */
62 62
63#define read_barrier_depends() do { } while (0)
64#define smp_read_barrier_depends() do { } while (0)
65
63/* 66/*
64 * This is a barrier which prevents following instructions from being 67 * This is a barrier which prevents following instructions from being
65 * started until the value of the argument x is known. For example, if 68 * started until the value of the argument x is known. For example, if
@@ -72,7 +75,7 @@
72#define smp_store_release(p, v) \ 75#define smp_store_release(p, v) \
73do { \ 76do { \
74 compiletime_assert_atomic_type(*p); \ 77 compiletime_assert_atomic_type(*p); \
75 __lwsync(); \ 78 smp_lwsync(); \
76 ACCESS_ONCE(*p) = (v); \ 79 ACCESS_ONCE(*p) = (v); \
77} while (0) 80} while (0)
78 81
@@ -80,7 +83,7 @@ do { \
80({ \ 83({ \
81 typeof(*p) ___p1 = ACCESS_ONCE(*p); \ 84 typeof(*p) ___p1 = ACCESS_ONCE(*p); \
82 compiletime_assert_atomic_type(*p); \ 85 compiletime_assert_atomic_type(*p); \
83 __lwsync(); \ 86 smp_lwsync(); \
84 ___p1; \ 87 ___p1; \
85}) 88})
86 89
diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h
index b5dce6544d76..8d724718ec21 100644
--- a/arch/s390/include/asm/barrier.h
+++ b/arch/s390/include/asm/barrier.h
@@ -24,11 +24,14 @@
24 24
25#define rmb() mb() 25#define rmb() mb()
26#define wmb() mb() 26#define wmb() mb()
27#define read_barrier_depends() do { } while(0) 27#define dma_rmb() rmb()
28#define dma_wmb() wmb()
28#define smp_mb() mb() 29#define smp_mb() mb()
29#define smp_rmb() rmb() 30#define smp_rmb() rmb()
30#define smp_wmb() wmb() 31#define smp_wmb() wmb()
31#define smp_read_barrier_depends() read_barrier_depends() 32
33#define read_barrier_depends() do { } while (0)
34#define smp_read_barrier_depends() do { } while (0)
32 35
33#define smp_mb__before_atomic() smp_mb() 36#define smp_mb__before_atomic() smp_mb()
34#define smp_mb__after_atomic() smp_mb() 37#define smp_mb__after_atomic() smp_mb()
diff --git a/arch/sparc/include/asm/barrier_64.h b/arch/sparc/include/asm/barrier_64.h
index 305dcc3dc721..76648941fea7 100644
--- a/arch/sparc/include/asm/barrier_64.h
+++ b/arch/sparc/include/asm/barrier_64.h
@@ -37,7 +37,9 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
37#define rmb() __asm__ __volatile__("":::"memory") 37#define rmb() __asm__ __volatile__("":::"memory")
38#define wmb() __asm__ __volatile__("":::"memory") 38#define wmb() __asm__ __volatile__("":::"memory")
39 39
40#define read_barrier_depends() do { } while(0) 40#define dma_rmb() rmb()
41#define dma_wmb() wmb()
42
41#define set_mb(__var, __value) \ 43#define set_mb(__var, __value) \
42 do { __var = __value; membar_safe("#StoreLoad"); } while(0) 44 do { __var = __value; membar_safe("#StoreLoad"); } while(0)
43 45
@@ -51,7 +53,8 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
51#define smp_wmb() __asm__ __volatile__("":::"memory") 53#define smp_wmb() __asm__ __volatile__("":::"memory")
52#endif 54#endif
53 55
54#define smp_read_barrier_depends() do { } while(0) 56#define read_barrier_depends() do { } while (0)
57#define smp_read_barrier_depends() do { } while (0)
55 58
56#define smp_store_release(p, v) \ 59#define smp_store_release(p, v) \
57do { \ 60do { \
diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
index 0f4460b5636d..2ab1eb33106e 100644
--- a/arch/x86/include/asm/barrier.h
+++ b/arch/x86/include/asm/barrier.h
@@ -24,78 +24,28 @@
24#define wmb() asm volatile("sfence" ::: "memory") 24#define wmb() asm volatile("sfence" ::: "memory")
25#endif 25#endif
26 26
27/**
28 * read_barrier_depends - Flush all pending reads that subsequents reads
29 * depend on.
30 *
31 * No data-dependent reads from memory-like regions are ever reordered
32 * over this barrier. All reads preceding this primitive are guaranteed
33 * to access memory (but not necessarily other CPUs' caches) before any
34 * reads following this primitive that depend on the data return by
35 * any of the preceding reads. This primitive is much lighter weight than
36 * rmb() on most CPUs, and is never heavier weight than is
37 * rmb().
38 *
39 * These ordering constraints are respected by both the local CPU
40 * and the compiler.
41 *
42 * Ordering is not guaranteed by anything other than these primitives,
43 * not even by data dependencies. See the documentation for
44 * memory_barrier() for examples and URLs to more information.
45 *
46 * For example, the following code would force ordering (the initial
47 * value of "a" is zero, "b" is one, and "p" is "&a"):
48 *
49 * <programlisting>
50 * CPU 0 CPU 1
51 *
52 * b = 2;
53 * memory_barrier();
54 * p = &b; q = p;
55 * read_barrier_depends();
56 * d = *q;
57 * </programlisting>
58 *
59 * because the read of "*q" depends on the read of "p" and these
60 * two reads are separated by a read_barrier_depends(). However,
61 * the following code, with the same initial values for "a" and "b":
62 *
63 * <programlisting>
64 * CPU 0 CPU 1
65 *
66 * a = 2;
67 * memory_barrier();
68 * b = 3; y = b;
69 * read_barrier_depends();
70 * x = a;
71 * </programlisting>
72 *
73 * does not enforce ordering, since there is no data dependency between
74 * the read of "a" and the read of "b". Therefore, on some CPUs, such
75 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
76 * in cases like this where there are no data dependencies.
77 **/
78
79#define read_barrier_depends() do { } while (0)
80
81#ifdef CONFIG_SMP
82#define smp_mb() mb()
83#ifdef CONFIG_X86_PPRO_FENCE 27#ifdef CONFIG_X86_PPRO_FENCE
84# define smp_rmb() rmb() 28#define dma_rmb() rmb()
85#else 29#else
86# define smp_rmb() barrier() 30#define dma_rmb() barrier()
87#endif 31#endif
32#define dma_wmb() barrier()
33
34#ifdef CONFIG_SMP
35#define smp_mb() mb()
36#define smp_rmb() dma_rmb()
88#define smp_wmb() barrier() 37#define smp_wmb() barrier()
89#define smp_read_barrier_depends() read_barrier_depends()
90#define set_mb(var, value) do { (void)xchg(&var, value); } while (0) 38#define set_mb(var, value) do { (void)xchg(&var, value); } while (0)
91#else /* !SMP */ 39#else /* !SMP */
92#define smp_mb() barrier() 40#define smp_mb() barrier()
93#define smp_rmb() barrier() 41#define smp_rmb() barrier()
94#define smp_wmb() barrier() 42#define smp_wmb() barrier()
95#define smp_read_barrier_depends() do { } while (0)
96#define set_mb(var, value) do { var = value; barrier(); } while (0) 43#define set_mb(var, value) do { var = value; barrier(); } while (0)
97#endif /* SMP */ 44#endif /* SMP */
98 45
46#define read_barrier_depends() do { } while (0)
47#define smp_read_barrier_depends() do { } while (0)
48
99#if defined(CONFIG_X86_PPRO_FENCE) 49#if defined(CONFIG_X86_PPRO_FENCE)
100 50
101/* 51/*
diff --git a/arch/x86/um/asm/barrier.h b/arch/x86/um/asm/barrier.h
index cc04e67bfd05..2d7d9a1f5b53 100644
--- a/arch/x86/um/asm/barrier.h
+++ b/arch/x86/um/asm/barrier.h
@@ -29,20 +29,18 @@
29 29
30#endif /* CONFIG_X86_32 */ 30#endif /* CONFIG_X86_32 */
31 31
32#define read_barrier_depends() do { } while (0)
33
34#ifdef CONFIG_SMP
35
36#define smp_mb() mb()
37#ifdef CONFIG_X86_PPRO_FENCE 32#ifdef CONFIG_X86_PPRO_FENCE
38#define smp_rmb() rmb() 33#define dma_rmb() rmb()
39#else /* CONFIG_X86_PPRO_FENCE */ 34#else /* CONFIG_X86_PPRO_FENCE */
40#define smp_rmb() barrier() 35#define dma_rmb() barrier()
41#endif /* CONFIG_X86_PPRO_FENCE */ 36#endif /* CONFIG_X86_PPRO_FENCE */
37#define dma_wmb() barrier()
42 38
43#define smp_wmb() barrier() 39#ifdef CONFIG_SMP
44 40
45#define smp_read_barrier_depends() read_barrier_depends() 41#define smp_mb() mb()
42#define smp_rmb() dma_rmb()
43#define smp_wmb() barrier()
46#define set_mb(var, value) do { (void)xchg(&var, value); } while (0) 44#define set_mb(var, value) do { (void)xchg(&var, value); } while (0)
47 45
48#else /* CONFIG_SMP */ 46#else /* CONFIG_SMP */
@@ -50,11 +48,13 @@
50#define smp_mb() barrier() 48#define smp_mb() barrier()
51#define smp_rmb() barrier() 49#define smp_rmb() barrier()
52#define smp_wmb() barrier() 50#define smp_wmb() barrier()
53#define smp_read_barrier_depends() do { } while (0)
54#define set_mb(var, value) do { var = value; barrier(); } while (0) 51#define set_mb(var, value) do { var = value; barrier(); } while (0)
55 52
56#endif /* CONFIG_SMP */ 53#endif /* CONFIG_SMP */
57 54
55#define read_barrier_depends() do { } while (0)
56#define smp_read_barrier_depends() do { } while (0)
57
58/* 58/*
59 * Stop RDTSC speculation. This is needed when you need to use RDTSC 59 * Stop RDTSC speculation. This is needed when you need to use RDTSC
60 * (or get_cycles or vread that possibly accesses the TSC) in a defined 60 * (or get_cycles or vread that possibly accesses the TSC) in a defined
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 4f4c2a7888e5..feb29c4526f7 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -684,10 +684,9 @@ static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port,
684 struct fixed_phy_status *status) 684 struct fixed_phy_status *status)
685{ 685{
686 struct bcm_sf2_priv *priv = ds_to_priv(ds); 686 struct bcm_sf2_priv *priv = ds_to_priv(ds);
687 u32 link, duplex, pause, speed; 687 u32 duplex, pause, speed;
688 u32 reg; 688 u32 reg;
689 689
690 link = core_readl(priv, CORE_LNKSTS);
691 duplex = core_readl(priv, CORE_DUPSTS); 690 duplex = core_readl(priv, CORE_DUPSTS);
692 pause = core_readl(priv, CORE_PAUSESTS); 691 pause = core_readl(priv, CORE_PAUSESTS);
693 speed = core_readl(priv, CORE_SPDSTS); 692 speed = core_readl(priv, CORE_SPDSTS);
@@ -701,22 +700,26 @@ static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port,
701 * which means that we need to force the link at the port override 700 * which means that we need to force the link at the port override
702 * level to get the data to flow. We do use what the interrupt handler 701 * level to get the data to flow. We do use what the interrupt handler
703 * did determine before. 702 * did determine before.
703 *
704 * For the other ports, we just force the link status, since this is
705 * a fixed PHY device.
704 */ 706 */
705 if (port == 7) { 707 if (port == 7) {
706 status->link = priv->port_sts[port].link; 708 status->link = priv->port_sts[port].link;
707 reg = core_readl(priv, CORE_STS_OVERRIDE_GMIIP_PORT(7));
708 reg |= SW_OVERRIDE;
709 if (status->link)
710 reg |= LINK_STS;
711 else
712 reg &= ~LINK_STS;
713 core_writel(priv, reg, CORE_STS_OVERRIDE_GMIIP_PORT(7));
714 status->duplex = 1; 709 status->duplex = 1;
715 } else { 710 } else {
716 status->link = !!(link & (1 << port)); 711 status->link = 1;
717 status->duplex = !!(duplex & (1 << port)); 712 status->duplex = !!(duplex & (1 << port));
718 } 713 }
719 714
715 reg = core_readl(priv, CORE_STS_OVERRIDE_GMIIP_PORT(port));
716 reg |= SW_OVERRIDE;
717 if (status->link)
718 reg |= LINK_STS;
719 else
720 reg &= ~LINK_STS;
721 core_writel(priv, reg, CORE_STS_OVERRIDE_GMIIP_PORT(port));
722
720 switch (speed) { 723 switch (speed) {
721 case SPDSTS_10: 724 case SPDSTS_10:
722 status->speed = SPEED_10; 725 status->speed = SPEED_10;
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index b6bc318b148e..0987d2a77f9f 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -66,23 +66,25 @@ static unsigned int macb_tx_ring_wrap(unsigned int index)
66 return index & (TX_RING_SIZE - 1); 66 return index & (TX_RING_SIZE - 1);
67} 67}
68 68
69static struct macb_dma_desc *macb_tx_desc(struct macb *bp, unsigned int index) 69static struct macb_dma_desc *macb_tx_desc(struct macb_queue *queue,
70 unsigned int index)
70{ 71{
71 return &bp->tx_ring[macb_tx_ring_wrap(index)]; 72 return &queue->tx_ring[macb_tx_ring_wrap(index)];
72} 73}
73 74
74static struct macb_tx_skb *macb_tx_skb(struct macb *bp, unsigned int index) 75static struct macb_tx_skb *macb_tx_skb(struct macb_queue *queue,
76 unsigned int index)
75{ 77{
76 return &bp->tx_skb[macb_tx_ring_wrap(index)]; 78 return &queue->tx_skb[macb_tx_ring_wrap(index)];
77} 79}
78 80
79static dma_addr_t macb_tx_dma(struct macb *bp, unsigned int index) 81static dma_addr_t macb_tx_dma(struct macb_queue *queue, unsigned int index)
80{ 82{
81 dma_addr_t offset; 83 dma_addr_t offset;
82 84
83 offset = macb_tx_ring_wrap(index) * sizeof(struct macb_dma_desc); 85 offset = macb_tx_ring_wrap(index) * sizeof(struct macb_dma_desc);
84 86
85 return bp->tx_ring_dma + offset; 87 return queue->tx_ring_dma + offset;
86} 88}
87 89
88static unsigned int macb_rx_ring_wrap(unsigned int index) 90static unsigned int macb_rx_ring_wrap(unsigned int index)
@@ -490,38 +492,49 @@ static void macb_tx_unmap(struct macb *bp, struct macb_tx_skb *tx_skb)
490 492
491static void macb_tx_error_task(struct work_struct *work) 493static void macb_tx_error_task(struct work_struct *work)
492{ 494{
493 struct macb *bp = container_of(work, struct macb, tx_error_task); 495 struct macb_queue *queue = container_of(work, struct macb_queue,
496 tx_error_task);
497 struct macb *bp = queue->bp;
494 struct macb_tx_skb *tx_skb; 498 struct macb_tx_skb *tx_skb;
499 struct macb_dma_desc *desc;
495 struct sk_buff *skb; 500 struct sk_buff *skb;
496 unsigned int tail; 501 unsigned int tail;
502 unsigned long flags;
503
504 netdev_vdbg(bp->dev, "macb_tx_error_task: q = %u, t = %u, h = %u\n",
505 (unsigned int)(queue - bp->queues),
506 queue->tx_tail, queue->tx_head);
497 507
498 netdev_vdbg(bp->dev, "macb_tx_error_task: t = %u, h = %u\n", 508 /* Prevent the queue IRQ handlers from running: each of them may call
499 bp->tx_tail, bp->tx_head); 509 * macb_tx_interrupt(), which in turn may call netif_wake_subqueue().
510 * As explained below, we have to halt the transmission before updating
511 * TBQP registers so we call netif_tx_stop_all_queues() to notify the
512 * network engine about the macb/gem being halted.
513 */
514 spin_lock_irqsave(&bp->lock, flags);
500 515
501 /* Make sure nobody is trying to queue up new packets */ 516 /* Make sure nobody is trying to queue up new packets */
502 netif_stop_queue(bp->dev); 517 netif_tx_stop_all_queues(bp->dev);
503 518
504 /* 519 /*
505 * Stop transmission now 520 * Stop transmission now
506 * (in case we have just queued new packets) 521 * (in case we have just queued new packets)
522 * macb/gem must be halted to write TBQP register
507 */ 523 */
508 if (macb_halt_tx(bp)) 524 if (macb_halt_tx(bp))
509 /* Just complain for now, reinitializing TX path can be good */ 525 /* Just complain for now, reinitializing TX path can be good */
510 netdev_err(bp->dev, "BUG: halt tx timed out\n"); 526 netdev_err(bp->dev, "BUG: halt tx timed out\n");
511 527
512 /* No need for the lock here as nobody will interrupt us anymore */
513
514 /* 528 /*
515 * Treat frames in TX queue including the ones that caused the error. 529 * Treat frames in TX queue including the ones that caused the error.
516 * Free transmit buffers in upper layer. 530 * Free transmit buffers in upper layer.
517 */ 531 */
518 for (tail = bp->tx_tail; tail != bp->tx_head; tail++) { 532 for (tail = queue->tx_tail; tail != queue->tx_head; tail++) {
519 struct macb_dma_desc *desc; 533 u32 ctrl;
520 u32 ctrl;
521 534
522 desc = macb_tx_desc(bp, tail); 535 desc = macb_tx_desc(queue, tail);
523 ctrl = desc->ctrl; 536 ctrl = desc->ctrl;
524 tx_skb = macb_tx_skb(bp, tail); 537 tx_skb = macb_tx_skb(queue, tail);
525 skb = tx_skb->skb; 538 skb = tx_skb->skb;
526 539
527 if (ctrl & MACB_BIT(TX_USED)) { 540 if (ctrl & MACB_BIT(TX_USED)) {
@@ -529,7 +542,7 @@ static void macb_tx_error_task(struct work_struct *work)
529 while (!skb) { 542 while (!skb) {
530 macb_tx_unmap(bp, tx_skb); 543 macb_tx_unmap(bp, tx_skb);
531 tail++; 544 tail++;
532 tx_skb = macb_tx_skb(bp, tail); 545 tx_skb = macb_tx_skb(queue, tail);
533 skb = tx_skb->skb; 546 skb = tx_skb->skb;
534 } 547 }
535 548
@@ -558,45 +571,56 @@ static void macb_tx_error_task(struct work_struct *work)
558 macb_tx_unmap(bp, tx_skb); 571 macb_tx_unmap(bp, tx_skb);
559 } 572 }
560 573
574 /* Set end of TX queue */
575 desc = macb_tx_desc(queue, 0);
576 desc->addr = 0;
577 desc->ctrl = MACB_BIT(TX_USED);
578
561 /* Make descriptor updates visible to hardware */ 579 /* Make descriptor updates visible to hardware */
562 wmb(); 580 wmb();
563 581
564 /* Reinitialize the TX desc queue */ 582 /* Reinitialize the TX desc queue */
565 macb_writel(bp, TBQP, bp->tx_ring_dma); 583 queue_writel(queue, TBQP, queue->tx_ring_dma);
566 /* Make TX ring reflect state of hardware */ 584 /* Make TX ring reflect state of hardware */
567 bp->tx_head = bp->tx_tail = 0; 585 queue->tx_head = 0;
568 586 queue->tx_tail = 0;
569 /* Now we are ready to start transmission again */
570 netif_wake_queue(bp->dev);
571 587
572 /* Housework before enabling TX IRQ */ 588 /* Housework before enabling TX IRQ */
573 macb_writel(bp, TSR, macb_readl(bp, TSR)); 589 macb_writel(bp, TSR, macb_readl(bp, TSR));
574 macb_writel(bp, IER, MACB_TX_INT_FLAGS); 590 queue_writel(queue, IER, MACB_TX_INT_FLAGS);
591
592 /* Now we are ready to start transmission again */
593 netif_tx_start_all_queues(bp->dev);
594 macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(TSTART));
595
596 spin_unlock_irqrestore(&bp->lock, flags);
575} 597}
576 598
577static void macb_tx_interrupt(struct macb *bp) 599static void macb_tx_interrupt(struct macb_queue *queue)
578{ 600{
579 unsigned int tail; 601 unsigned int tail;
580 unsigned int head; 602 unsigned int head;
581 u32 status; 603 u32 status;
604 struct macb *bp = queue->bp;
605 u16 queue_index = queue - bp->queues;
582 606
583 status = macb_readl(bp, TSR); 607 status = macb_readl(bp, TSR);
584 macb_writel(bp, TSR, status); 608 macb_writel(bp, TSR, status);
585 609
586 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) 610 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
587 macb_writel(bp, ISR, MACB_BIT(TCOMP)); 611 queue_writel(queue, ISR, MACB_BIT(TCOMP));
588 612
589 netdev_vdbg(bp->dev, "macb_tx_interrupt status = 0x%03lx\n", 613 netdev_vdbg(bp->dev, "macb_tx_interrupt status = 0x%03lx\n",
590 (unsigned long)status); 614 (unsigned long)status);
591 615
592 head = bp->tx_head; 616 head = queue->tx_head;
593 for (tail = bp->tx_tail; tail != head; tail++) { 617 for (tail = queue->tx_tail; tail != head; tail++) {
594 struct macb_tx_skb *tx_skb; 618 struct macb_tx_skb *tx_skb;
595 struct sk_buff *skb; 619 struct sk_buff *skb;
596 struct macb_dma_desc *desc; 620 struct macb_dma_desc *desc;
597 u32 ctrl; 621 u32 ctrl;
598 622
599 desc = macb_tx_desc(bp, tail); 623 desc = macb_tx_desc(queue, tail);
600 624
601 /* Make hw descriptor updates visible to CPU */ 625 /* Make hw descriptor updates visible to CPU */
602 rmb(); 626 rmb();
@@ -611,7 +635,7 @@ static void macb_tx_interrupt(struct macb *bp)
611 635
612 /* Process all buffers of the current transmitted frame */ 636 /* Process all buffers of the current transmitted frame */
613 for (;; tail++) { 637 for (;; tail++) {
614 tx_skb = macb_tx_skb(bp, tail); 638 tx_skb = macb_tx_skb(queue, tail);
615 skb = tx_skb->skb; 639 skb = tx_skb->skb;
616 640
617 /* First, update TX stats if needed */ 641 /* First, update TX stats if needed */
@@ -634,11 +658,11 @@ static void macb_tx_interrupt(struct macb *bp)
634 } 658 }
635 } 659 }
636 660
637 bp->tx_tail = tail; 661 queue->tx_tail = tail;
638 if (netif_queue_stopped(bp->dev) 662 if (__netif_subqueue_stopped(bp->dev, queue_index) &&
639 && CIRC_CNT(bp->tx_head, bp->tx_tail, 663 CIRC_CNT(queue->tx_head, queue->tx_tail,
640 TX_RING_SIZE) <= MACB_TX_WAKEUP_THRESH) 664 TX_RING_SIZE) <= MACB_TX_WAKEUP_THRESH)
641 netif_wake_queue(bp->dev); 665 netif_wake_subqueue(bp->dev, queue_index);
642} 666}
643 667
644static void gem_rx_refill(struct macb *bp) 668static void gem_rx_refill(struct macb *bp)
@@ -949,11 +973,12 @@ static int macb_poll(struct napi_struct *napi, int budget)
949 973
950static irqreturn_t macb_interrupt(int irq, void *dev_id) 974static irqreturn_t macb_interrupt(int irq, void *dev_id)
951{ 975{
952 struct net_device *dev = dev_id; 976 struct macb_queue *queue = dev_id;
953 struct macb *bp = netdev_priv(dev); 977 struct macb *bp = queue->bp;
978 struct net_device *dev = bp->dev;
954 u32 status; 979 u32 status;
955 980
956 status = macb_readl(bp, ISR); 981 status = queue_readl(queue, ISR);
957 982
958 if (unlikely(!status)) 983 if (unlikely(!status))
959 return IRQ_NONE; 984 return IRQ_NONE;
@@ -963,11 +988,13 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
963 while (status) { 988 while (status) {
964 /* close possible race with dev_close */ 989 /* close possible race with dev_close */
965 if (unlikely(!netif_running(dev))) { 990 if (unlikely(!netif_running(dev))) {
966 macb_writel(bp, IDR, -1); 991 queue_writel(queue, IDR, -1);
967 break; 992 break;
968 } 993 }
969 994
970 netdev_vdbg(bp->dev, "isr = 0x%08lx\n", (unsigned long)status); 995 netdev_vdbg(bp->dev, "queue = %u, isr = 0x%08lx\n",
996 (unsigned int)(queue - bp->queues),
997 (unsigned long)status);
971 998
972 if (status & MACB_RX_INT_FLAGS) { 999 if (status & MACB_RX_INT_FLAGS) {
973 /* 1000 /*
@@ -977,9 +1004,9 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
977 * is already scheduled, so disable interrupts 1004 * is already scheduled, so disable interrupts
978 * now. 1005 * now.
979 */ 1006 */
980 macb_writel(bp, IDR, MACB_RX_INT_FLAGS); 1007 queue_writel(queue, IDR, MACB_RX_INT_FLAGS);
981 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) 1008 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
982 macb_writel(bp, ISR, MACB_BIT(RCOMP)); 1009 queue_writel(queue, ISR, MACB_BIT(RCOMP));
983 1010
984 if (napi_schedule_prep(&bp->napi)) { 1011 if (napi_schedule_prep(&bp->napi)) {
985 netdev_vdbg(bp->dev, "scheduling RX softirq\n"); 1012 netdev_vdbg(bp->dev, "scheduling RX softirq\n");
@@ -988,17 +1015,17 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
988 } 1015 }
989 1016
990 if (unlikely(status & (MACB_TX_ERR_FLAGS))) { 1017 if (unlikely(status & (MACB_TX_ERR_FLAGS))) {
991 macb_writel(bp, IDR, MACB_TX_INT_FLAGS); 1018 queue_writel(queue, IDR, MACB_TX_INT_FLAGS);
992 schedule_work(&bp->tx_error_task); 1019 schedule_work(&queue->tx_error_task);
993 1020
994 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) 1021 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
995 macb_writel(bp, ISR, MACB_TX_ERR_FLAGS); 1022 queue_writel(queue, ISR, MACB_TX_ERR_FLAGS);
996 1023
997 break; 1024 break;
998 } 1025 }
999 1026
1000 if (status & MACB_BIT(TCOMP)) 1027 if (status & MACB_BIT(TCOMP))
1001 macb_tx_interrupt(bp); 1028 macb_tx_interrupt(queue);
1002 1029
1003 /* 1030 /*
1004 * Link change detection isn't possible with RMII, so we'll 1031 * Link change detection isn't possible with RMII, so we'll
@@ -1013,7 +1040,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
1013 bp->hw_stats.macb.rx_overruns++; 1040 bp->hw_stats.macb.rx_overruns++;
1014 1041
1015 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) 1042 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
1016 macb_writel(bp, ISR, MACB_BIT(ISR_ROVR)); 1043 queue_writel(queue, ISR, MACB_BIT(ISR_ROVR));
1017 } 1044 }
1018 1045
1019 if (status & MACB_BIT(HRESP)) { 1046 if (status & MACB_BIT(HRESP)) {
@@ -1025,10 +1052,10 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
1025 netdev_err(dev, "DMA bus error: HRESP not OK\n"); 1052 netdev_err(dev, "DMA bus error: HRESP not OK\n");
1026 1053
1027 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) 1054 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
1028 macb_writel(bp, ISR, MACB_BIT(HRESP)); 1055 queue_writel(queue, ISR, MACB_BIT(HRESP));
1029 } 1056 }
1030 1057
1031 status = macb_readl(bp, ISR); 1058 status = queue_readl(queue, ISR);
1032 } 1059 }
1033 1060
1034 spin_unlock(&bp->lock); 1061 spin_unlock(&bp->lock);
@@ -1043,10 +1070,14 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
1043 */ 1070 */
1044static void macb_poll_controller(struct net_device *dev) 1071static void macb_poll_controller(struct net_device *dev)
1045{ 1072{
1073 struct macb *bp = netdev_priv(dev);
1074 struct macb_queue *queue;
1046 unsigned long flags; 1075 unsigned long flags;
1076 unsigned int q;
1047 1077
1048 local_irq_save(flags); 1078 local_irq_save(flags);
1049 macb_interrupt(dev->irq, dev); 1079 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
1080 macb_interrupt(dev->irq, queue);
1050 local_irq_restore(flags); 1081 local_irq_restore(flags);
1051} 1082}
1052#endif 1083#endif
@@ -1058,10 +1089,11 @@ static inline unsigned int macb_count_tx_descriptors(struct macb *bp,
1058} 1089}
1059 1090
1060static unsigned int macb_tx_map(struct macb *bp, 1091static unsigned int macb_tx_map(struct macb *bp,
1092 struct macb_queue *queue,
1061 struct sk_buff *skb) 1093 struct sk_buff *skb)
1062{ 1094{
1063 dma_addr_t mapping; 1095 dma_addr_t mapping;
1064 unsigned int len, entry, i, tx_head = bp->tx_head; 1096 unsigned int len, entry, i, tx_head = queue->tx_head;
1065 struct macb_tx_skb *tx_skb = NULL; 1097 struct macb_tx_skb *tx_skb = NULL;
1066 struct macb_dma_desc *desc; 1098 struct macb_dma_desc *desc;
1067 unsigned int offset, size, count = 0; 1099 unsigned int offset, size, count = 0;
@@ -1075,7 +1107,7 @@ static unsigned int macb_tx_map(struct macb *bp,
1075 while (len) { 1107 while (len) {
1076 size = min(len, bp->max_tx_length); 1108 size = min(len, bp->max_tx_length);
1077 entry = macb_tx_ring_wrap(tx_head); 1109 entry = macb_tx_ring_wrap(tx_head);
1078 tx_skb = &bp->tx_skb[entry]; 1110 tx_skb = &queue->tx_skb[entry];
1079 1111
1080 mapping = dma_map_single(&bp->pdev->dev, 1112 mapping = dma_map_single(&bp->pdev->dev,
1081 skb->data + offset, 1113 skb->data + offset,
@@ -1104,7 +1136,7 @@ static unsigned int macb_tx_map(struct macb *bp,
1104 while (len) { 1136 while (len) {
1105 size = min(len, bp->max_tx_length); 1137 size = min(len, bp->max_tx_length);
1106 entry = macb_tx_ring_wrap(tx_head); 1138 entry = macb_tx_ring_wrap(tx_head);
1107 tx_skb = &bp->tx_skb[entry]; 1139 tx_skb = &queue->tx_skb[entry];
1108 1140
1109 mapping = skb_frag_dma_map(&bp->pdev->dev, frag, 1141 mapping = skb_frag_dma_map(&bp->pdev->dev, frag,
1110 offset, size, DMA_TO_DEVICE); 1142 offset, size, DMA_TO_DEVICE);
@@ -1143,14 +1175,14 @@ static unsigned int macb_tx_map(struct macb *bp,
1143 i = tx_head; 1175 i = tx_head;
1144 entry = macb_tx_ring_wrap(i); 1176 entry = macb_tx_ring_wrap(i);
1145 ctrl = MACB_BIT(TX_USED); 1177 ctrl = MACB_BIT(TX_USED);
1146 desc = &bp->tx_ring[entry]; 1178 desc = &queue->tx_ring[entry];
1147 desc->ctrl = ctrl; 1179 desc->ctrl = ctrl;
1148 1180
1149 do { 1181 do {
1150 i--; 1182 i--;
1151 entry = macb_tx_ring_wrap(i); 1183 entry = macb_tx_ring_wrap(i);
1152 tx_skb = &bp->tx_skb[entry]; 1184 tx_skb = &queue->tx_skb[entry];
1153 desc = &bp->tx_ring[entry]; 1185 desc = &queue->tx_ring[entry];
1154 1186
1155 ctrl = (u32)tx_skb->size; 1187 ctrl = (u32)tx_skb->size;
1156 if (eof) { 1188 if (eof) {
@@ -1167,17 +1199,17 @@ static unsigned int macb_tx_map(struct macb *bp,
1167 */ 1199 */
1168 wmb(); 1200 wmb();
1169 desc->ctrl = ctrl; 1201 desc->ctrl = ctrl;
1170 } while (i != bp->tx_head); 1202 } while (i != queue->tx_head);
1171 1203
1172 bp->tx_head = tx_head; 1204 queue->tx_head = tx_head;
1173 1205
1174 return count; 1206 return count;
1175 1207
1176dma_error: 1208dma_error:
1177 netdev_err(bp->dev, "TX DMA map failed\n"); 1209 netdev_err(bp->dev, "TX DMA map failed\n");
1178 1210
1179 for (i = bp->tx_head; i != tx_head; i++) { 1211 for (i = queue->tx_head; i != tx_head; i++) {
1180 tx_skb = macb_tx_skb(bp, i); 1212 tx_skb = macb_tx_skb(queue, i);
1181 1213
1182 macb_tx_unmap(bp, tx_skb); 1214 macb_tx_unmap(bp, tx_skb);
1183 } 1215 }
@@ -1187,14 +1219,16 @@ dma_error:
1187 1219
1188static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) 1220static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
1189{ 1221{
1222 u16 queue_index = skb_get_queue_mapping(skb);
1190 struct macb *bp = netdev_priv(dev); 1223 struct macb *bp = netdev_priv(dev);
1224 struct macb_queue *queue = &bp->queues[queue_index];
1191 unsigned long flags; 1225 unsigned long flags;
1192 unsigned int count, nr_frags, frag_size, f; 1226 unsigned int count, nr_frags, frag_size, f;
1193 1227
1194#if defined(DEBUG) && defined(VERBOSE_DEBUG) 1228#if defined(DEBUG) && defined(VERBOSE_DEBUG)
1195 netdev_vdbg(bp->dev, 1229 netdev_vdbg(bp->dev,
1196 "start_xmit: len %u head %p data %p tail %p end %p\n", 1230 "start_xmit: queue %hu len %u head %p data %p tail %p end %p\n",
1197 skb->len, skb->head, skb->data, 1231 queue_index, skb->len, skb->head, skb->data,
1198 skb_tail_pointer(skb), skb_end_pointer(skb)); 1232 skb_tail_pointer(skb), skb_end_pointer(skb));
1199 print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_OFFSET, 16, 1, 1233 print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_OFFSET, 16, 1,
1200 skb->data, 16, true); 1234 skb->data, 16, true);
@@ -1214,16 +1248,16 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
1214 spin_lock_irqsave(&bp->lock, flags); 1248 spin_lock_irqsave(&bp->lock, flags);
1215 1249
1216 /* This is a hard error, log it. */ 1250 /* This is a hard error, log it. */
1217 if (CIRC_SPACE(bp->tx_head, bp->tx_tail, TX_RING_SIZE) < count) { 1251 if (CIRC_SPACE(queue->tx_head, queue->tx_tail, TX_RING_SIZE) < count) {
1218 netif_stop_queue(dev); 1252 netif_stop_subqueue(dev, queue_index);
1219 spin_unlock_irqrestore(&bp->lock, flags); 1253 spin_unlock_irqrestore(&bp->lock, flags);
1220 netdev_dbg(bp->dev, "tx_head = %u, tx_tail = %u\n", 1254 netdev_dbg(bp->dev, "tx_head = %u, tx_tail = %u\n",
1221 bp->tx_head, bp->tx_tail); 1255 queue->tx_head, queue->tx_tail);
1222 return NETDEV_TX_BUSY; 1256 return NETDEV_TX_BUSY;
1223 } 1257 }
1224 1258
1225 /* Map socket buffer for DMA transfer */ 1259 /* Map socket buffer for DMA transfer */
1226 if (!macb_tx_map(bp, skb)) { 1260 if (!macb_tx_map(bp, queue, skb)) {
1227 dev_kfree_skb_any(skb); 1261 dev_kfree_skb_any(skb);
1228 goto unlock; 1262 goto unlock;
1229 } 1263 }
@@ -1235,8 +1269,8 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
1235 1269
1236 macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(TSTART)); 1270 macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(TSTART));
1237 1271
1238 if (CIRC_SPACE(bp->tx_head, bp->tx_tail, TX_RING_SIZE) < 1) 1272 if (CIRC_SPACE(queue->tx_head, queue->tx_tail, TX_RING_SIZE) < 1)
1239 netif_stop_queue(dev); 1273 netif_stop_subqueue(dev, queue_index);
1240 1274
1241unlock: 1275unlock:
1242 spin_unlock_irqrestore(&bp->lock, flags); 1276 spin_unlock_irqrestore(&bp->lock, flags);
@@ -1304,20 +1338,24 @@ static void macb_free_rx_buffers(struct macb *bp)
1304 1338
1305static void macb_free_consistent(struct macb *bp) 1339static void macb_free_consistent(struct macb *bp)
1306{ 1340{
1307 if (bp->tx_skb) { 1341 struct macb_queue *queue;
1308 kfree(bp->tx_skb); 1342 unsigned int q;
1309 bp->tx_skb = NULL; 1343
1310 }
1311 bp->macbgem_ops.mog_free_rx_buffers(bp); 1344 bp->macbgem_ops.mog_free_rx_buffers(bp);
1312 if (bp->rx_ring) { 1345 if (bp->rx_ring) {
1313 dma_free_coherent(&bp->pdev->dev, RX_RING_BYTES, 1346 dma_free_coherent(&bp->pdev->dev, RX_RING_BYTES,
1314 bp->rx_ring, bp->rx_ring_dma); 1347 bp->rx_ring, bp->rx_ring_dma);
1315 bp->rx_ring = NULL; 1348 bp->rx_ring = NULL;
1316 } 1349 }
1317 if (bp->tx_ring) { 1350
1318 dma_free_coherent(&bp->pdev->dev, TX_RING_BYTES, 1351 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
1319 bp->tx_ring, bp->tx_ring_dma); 1352 kfree(queue->tx_skb);
1320 bp->tx_ring = NULL; 1353 queue->tx_skb = NULL;
1354 if (queue->tx_ring) {
1355 dma_free_coherent(&bp->pdev->dev, TX_RING_BYTES,
1356 queue->tx_ring, queue->tx_ring_dma);
1357 queue->tx_ring = NULL;
1358 }
1321 } 1359 }
1322} 1360}
1323 1361
@@ -1354,12 +1392,27 @@ static int macb_alloc_rx_buffers(struct macb *bp)
1354 1392
1355static int macb_alloc_consistent(struct macb *bp) 1393static int macb_alloc_consistent(struct macb *bp)
1356{ 1394{
1395 struct macb_queue *queue;
1396 unsigned int q;
1357 int size; 1397 int size;
1358 1398
1359 size = TX_RING_SIZE * sizeof(struct macb_tx_skb); 1399 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
1360 bp->tx_skb = kmalloc(size, GFP_KERNEL); 1400 size = TX_RING_BYTES;
1361 if (!bp->tx_skb) 1401 queue->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size,
1362 goto out_err; 1402 &queue->tx_ring_dma,
1403 GFP_KERNEL);
1404 if (!queue->tx_ring)
1405 goto out_err;
1406 netdev_dbg(bp->dev,
1407 "Allocated TX ring for queue %u of %d bytes at %08lx (mapped %p)\n",
1408 q, size, (unsigned long)queue->tx_ring_dma,
1409 queue->tx_ring);
1410
1411 size = TX_RING_SIZE * sizeof(struct macb_tx_skb);
1412 queue->tx_skb = kmalloc(size, GFP_KERNEL);
1413 if (!queue->tx_skb)
1414 goto out_err;
1415 }
1363 1416
1364 size = RX_RING_BYTES; 1417 size = RX_RING_BYTES;
1365 bp->rx_ring = dma_alloc_coherent(&bp->pdev->dev, size, 1418 bp->rx_ring = dma_alloc_coherent(&bp->pdev->dev, size,
@@ -1370,15 +1423,6 @@ static int macb_alloc_consistent(struct macb *bp)
1370 "Allocated RX ring of %d bytes at %08lx (mapped %p)\n", 1423 "Allocated RX ring of %d bytes at %08lx (mapped %p)\n",
1371 size, (unsigned long)bp->rx_ring_dma, bp->rx_ring); 1424 size, (unsigned long)bp->rx_ring_dma, bp->rx_ring);
1372 1425
1373 size = TX_RING_BYTES;
1374 bp->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size,
1375 &bp->tx_ring_dma, GFP_KERNEL);
1376 if (!bp->tx_ring)
1377 goto out_err;
1378 netdev_dbg(bp->dev,
1379 "Allocated TX ring of %d bytes at %08lx (mapped %p)\n",
1380 size, (unsigned long)bp->tx_ring_dma, bp->tx_ring);
1381
1382 if (bp->macbgem_ops.mog_alloc_rx_buffers(bp)) 1426 if (bp->macbgem_ops.mog_alloc_rx_buffers(bp))
1383 goto out_err; 1427 goto out_err;
1384 1428
@@ -1391,15 +1435,22 @@ out_err:
1391 1435
1392static void gem_init_rings(struct macb *bp) 1436static void gem_init_rings(struct macb *bp)
1393{ 1437{
1438 struct macb_queue *queue;
1439 unsigned int q;
1394 int i; 1440 int i;
1395 1441
1396 for (i = 0; i < TX_RING_SIZE; i++) { 1442 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
1397 bp->tx_ring[i].addr = 0; 1443 for (i = 0; i < TX_RING_SIZE; i++) {
1398 bp->tx_ring[i].ctrl = MACB_BIT(TX_USED); 1444 queue->tx_ring[i].addr = 0;
1445 queue->tx_ring[i].ctrl = MACB_BIT(TX_USED);
1446 }
1447 queue->tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
1448 queue->tx_head = 0;
1449 queue->tx_tail = 0;
1399 } 1450 }
1400 bp->tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
1401 1451
1402 bp->rx_tail = bp->rx_prepared_head = bp->tx_head = bp->tx_tail = 0; 1452 bp->rx_tail = 0;
1453 bp->rx_prepared_head = 0;
1403 1454
1404 gem_rx_refill(bp); 1455 gem_rx_refill(bp);
1405} 1456}
@@ -1418,16 +1469,21 @@ static void macb_init_rings(struct macb *bp)
1418 bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP); 1469 bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP);
1419 1470
1420 for (i = 0; i < TX_RING_SIZE; i++) { 1471 for (i = 0; i < TX_RING_SIZE; i++) {
1421 bp->tx_ring[i].addr = 0; 1472 bp->queues[0].tx_ring[i].addr = 0;
1422 bp->tx_ring[i].ctrl = MACB_BIT(TX_USED); 1473 bp->queues[0].tx_ring[i].ctrl = MACB_BIT(TX_USED);
1474 bp->queues[0].tx_head = 0;
1475 bp->queues[0].tx_tail = 0;
1423 } 1476 }
1424 bp->tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP); 1477 bp->queues[0].tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
1425 1478
1426 bp->rx_tail = bp->tx_head = bp->tx_tail = 0; 1479 bp->rx_tail = 0;
1427} 1480}
1428 1481
1429static void macb_reset_hw(struct macb *bp) 1482static void macb_reset_hw(struct macb *bp)
1430{ 1483{
1484 struct macb_queue *queue;
1485 unsigned int q;
1486
1431 /* 1487 /*
1432 * Disable RX and TX (XXX: Should we halt the transmission 1488 * Disable RX and TX (XXX: Should we halt the transmission
1433 * more gracefully?) 1489 * more gracefully?)
@@ -1442,8 +1498,10 @@ static void macb_reset_hw(struct macb *bp)
1442 macb_writel(bp, RSR, -1); 1498 macb_writel(bp, RSR, -1);
1443 1499
1444 /* Disable all interrupts */ 1500 /* Disable all interrupts */
1445 macb_writel(bp, IDR, -1); 1501 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
1446 macb_readl(bp, ISR); 1502 queue_writel(queue, IDR, -1);
1503 queue_readl(queue, ISR);
1504 }
1447} 1505}
1448 1506
1449static u32 gem_mdc_clk_div(struct macb *bp) 1507static u32 gem_mdc_clk_div(struct macb *bp)
@@ -1540,6 +1598,9 @@ static void macb_configure_dma(struct macb *bp)
1540 1598
1541static void macb_init_hw(struct macb *bp) 1599static void macb_init_hw(struct macb *bp)
1542{ 1600{
1601 struct macb_queue *queue;
1602 unsigned int q;
1603
1543 u32 config; 1604 u32 config;
1544 1605
1545 macb_reset_hw(bp); 1606 macb_reset_hw(bp);
@@ -1565,16 +1626,18 @@ static void macb_init_hw(struct macb *bp)
1565 1626
1566 /* Initialize TX and RX buffers */ 1627 /* Initialize TX and RX buffers */
1567 macb_writel(bp, RBQP, bp->rx_ring_dma); 1628 macb_writel(bp, RBQP, bp->rx_ring_dma);
1568 macb_writel(bp, TBQP, bp->tx_ring_dma); 1629 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
1630 queue_writel(queue, TBQP, queue->tx_ring_dma);
1631
1632 /* Enable interrupts */
1633 queue_writel(queue, IER,
1634 MACB_RX_INT_FLAGS |
1635 MACB_TX_INT_FLAGS |
1636 MACB_BIT(HRESP));
1637 }
1569 1638
1570 /* Enable TX and RX */ 1639 /* Enable TX and RX */
1571 macb_writel(bp, NCR, MACB_BIT(RE) | MACB_BIT(TE) | MACB_BIT(MPE)); 1640 macb_writel(bp, NCR, MACB_BIT(RE) | MACB_BIT(TE) | MACB_BIT(MPE));
1572
1573 /* Enable interrupts */
1574 macb_writel(bp, IER, (MACB_RX_INT_FLAGS
1575 | MACB_TX_INT_FLAGS
1576 | MACB_BIT(HRESP)));
1577
1578} 1641}
1579 1642
1580/* 1643/*
@@ -1736,7 +1799,7 @@ static int macb_open(struct net_device *dev)
1736 /* schedule a link state check */ 1799 /* schedule a link state check */
1737 phy_start(bp->phy_dev); 1800 phy_start(bp->phy_dev);
1738 1801
1739 netif_start_queue(dev); 1802 netif_tx_start_all_queues(dev);
1740 1803
1741 return 0; 1804 return 0;
1742} 1805}
@@ -1746,7 +1809,7 @@ static int macb_close(struct net_device *dev)
1746 struct macb *bp = netdev_priv(dev); 1809 struct macb *bp = netdev_priv(dev);
1747 unsigned long flags; 1810 unsigned long flags;
1748 1811
1749 netif_stop_queue(dev); 1812 netif_tx_stop_all_queues(dev);
1750 napi_disable(&bp->napi); 1813 napi_disable(&bp->napi);
1751 1814
1752 if (bp->phy_dev) 1815 if (bp->phy_dev)
@@ -1895,8 +1958,8 @@ static void macb_get_regs(struct net_device *dev, struct ethtool_regs *regs,
1895 regs->version = (macb_readl(bp, MID) & ((1 << MACB_REV_SIZE) - 1)) 1958 regs->version = (macb_readl(bp, MID) & ((1 << MACB_REV_SIZE) - 1))
1896 | MACB_GREGS_VERSION; 1959 | MACB_GREGS_VERSION;
1897 1960
1898 tail = macb_tx_ring_wrap(bp->tx_tail); 1961 tail = macb_tx_ring_wrap(bp->queues[0].tx_tail);
1899 head = macb_tx_ring_wrap(bp->tx_head); 1962 head = macb_tx_ring_wrap(bp->queues[0].tx_head);
1900 1963
1901 regs_buff[0] = macb_readl(bp, NCR); 1964 regs_buff[0] = macb_readl(bp, NCR);
1902 regs_buff[1] = macb_or_gem_readl(bp, NCFGR); 1965 regs_buff[1] = macb_or_gem_readl(bp, NCFGR);
@@ -1909,8 +1972,8 @@ static void macb_get_regs(struct net_device *dev, struct ethtool_regs *regs,
1909 1972
1910 regs_buff[8] = tail; 1973 regs_buff[8] = tail;
1911 regs_buff[9] = head; 1974 regs_buff[9] = head;
1912 regs_buff[10] = macb_tx_dma(bp, tail); 1975 regs_buff[10] = macb_tx_dma(&bp->queues[0], tail);
1913 regs_buff[11] = macb_tx_dma(bp, head); 1976 regs_buff[11] = macb_tx_dma(&bp->queues[0], head);
1914 1977
1915 if (macb_is_gem(bp)) { 1978 if (macb_is_gem(bp)) {
1916 regs_buff[12] = gem_readl(bp, USRIO); 1979 regs_buff[12] = gem_readl(bp, USRIO);
@@ -2061,16 +2124,44 @@ static void macb_configure_caps(struct macb *bp)
2061 netdev_dbg(bp->dev, "Cadence caps 0x%08x\n", bp->caps); 2124 netdev_dbg(bp->dev, "Cadence caps 0x%08x\n", bp->caps);
2062} 2125}
2063 2126
2127static void macb_probe_queues(void __iomem *mem,
2128 unsigned int *queue_mask,
2129 unsigned int *num_queues)
2130{
2131 unsigned int hw_q;
2132 u32 mid;
2133
2134 *queue_mask = 0x1;
2135 *num_queues = 1;
2136
2137 /* is it macb or gem ? */
2138 mid = __raw_readl(mem + MACB_MID);
2139 if (MACB_BFEXT(IDNUM, mid) != 0x2)
2140 return;
2141
2142 /* bit 0 is never set but queue 0 always exists */
2143 *queue_mask = __raw_readl(mem + GEM_DCFG6) & 0xff;
2144 *queue_mask |= 0x1;
2145
2146 for (hw_q = 1; hw_q < MACB_MAX_QUEUES; ++hw_q)
2147 if (*queue_mask & (1 << hw_q))
2148 (*num_queues)++;
2149}
2150
2064static int __init macb_probe(struct platform_device *pdev) 2151static int __init macb_probe(struct platform_device *pdev)
2065{ 2152{
2066 struct macb_platform_data *pdata; 2153 struct macb_platform_data *pdata;
2067 struct resource *regs; 2154 struct resource *regs;
2068 struct net_device *dev; 2155 struct net_device *dev;
2069 struct macb *bp; 2156 struct macb *bp;
2157 struct macb_queue *queue;
2070 struct phy_device *phydev; 2158 struct phy_device *phydev;
2071 u32 config; 2159 u32 config;
2072 int err = -ENXIO; 2160 int err = -ENXIO;
2073 const char *mac; 2161 const char *mac;
2162 void __iomem *mem;
2163 unsigned int hw_q, queue_mask, q, num_queues, q_irq = 0;
2164 struct clk *pclk, *hclk, *tx_clk;
2074 2165
2075 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2166 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2076 if (!regs) { 2167 if (!regs) {
@@ -2078,72 +2169,112 @@ static int __init macb_probe(struct platform_device *pdev)
2078 goto err_out; 2169 goto err_out;
2079 } 2170 }
2080 2171
2081 err = -ENOMEM; 2172 pclk = devm_clk_get(&pdev->dev, "pclk");
2082 dev = alloc_etherdev(sizeof(*bp)); 2173 if (IS_ERR(pclk)) {
2083 if (!dev) 2174 err = PTR_ERR(pclk);
2084 goto err_out;
2085
2086 SET_NETDEV_DEV(dev, &pdev->dev);
2087
2088 bp = netdev_priv(dev);
2089 bp->pdev = pdev;
2090 bp->dev = dev;
2091
2092 spin_lock_init(&bp->lock);
2093 INIT_WORK(&bp->tx_error_task, macb_tx_error_task);
2094
2095 bp->pclk = devm_clk_get(&pdev->dev, "pclk");
2096 if (IS_ERR(bp->pclk)) {
2097 err = PTR_ERR(bp->pclk);
2098 dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err); 2175 dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err);
2099 goto err_out_free_dev; 2176 goto err_out;
2100 } 2177 }
2101 2178
2102 bp->hclk = devm_clk_get(&pdev->dev, "hclk"); 2179 hclk = devm_clk_get(&pdev->dev, "hclk");
2103 if (IS_ERR(bp->hclk)) { 2180 if (IS_ERR(hclk)) {
2104 err = PTR_ERR(bp->hclk); 2181 err = PTR_ERR(hclk);
2105 dev_err(&pdev->dev, "failed to get hclk (%u)\n", err); 2182 dev_err(&pdev->dev, "failed to get hclk (%u)\n", err);
2106 goto err_out_free_dev; 2183 goto err_out;
2107 } 2184 }
2108 2185
2109 bp->tx_clk = devm_clk_get(&pdev->dev, "tx_clk"); 2186 tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
2110 2187
2111 err = clk_prepare_enable(bp->pclk); 2188 err = clk_prepare_enable(pclk);
2112 if (err) { 2189 if (err) {
2113 dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err); 2190 dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err);
2114 goto err_out_free_dev; 2191 goto err_out;
2115 } 2192 }
2116 2193
2117 err = clk_prepare_enable(bp->hclk); 2194 err = clk_prepare_enable(hclk);
2118 if (err) { 2195 if (err) {
2119 dev_err(&pdev->dev, "failed to enable hclk (%u)\n", err); 2196 dev_err(&pdev->dev, "failed to enable hclk (%u)\n", err);
2120 goto err_out_disable_pclk; 2197 goto err_out_disable_pclk;
2121 } 2198 }
2122 2199
2123 if (!IS_ERR(bp->tx_clk)) { 2200 if (!IS_ERR(tx_clk)) {
2124 err = clk_prepare_enable(bp->tx_clk); 2201 err = clk_prepare_enable(tx_clk);
2125 if (err) { 2202 if (err) {
2126 dev_err(&pdev->dev, "failed to enable tx_clk (%u)\n", 2203 dev_err(&pdev->dev, "failed to enable tx_clk (%u)\n",
2127 err); 2204 err);
2128 goto err_out_disable_hclk; 2205 goto err_out_disable_hclk;
2129 } 2206 }
2130 } 2207 }
2131 2208
2132 bp->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs)); 2209 err = -ENOMEM;
2133 if (!bp->regs) { 2210 mem = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
2211 if (!mem) {
2134 dev_err(&pdev->dev, "failed to map registers, aborting.\n"); 2212 dev_err(&pdev->dev, "failed to map registers, aborting.\n");
2135 err = -ENOMEM;
2136 goto err_out_disable_clocks; 2213 goto err_out_disable_clocks;
2137 } 2214 }
2138 2215
2139 dev->irq = platform_get_irq(pdev, 0); 2216 macb_probe_queues(mem, &queue_mask, &num_queues);
2140 err = devm_request_irq(&pdev->dev, dev->irq, macb_interrupt, 0, 2217 dev = alloc_etherdev_mq(sizeof(*bp), num_queues);
2141 dev->name, dev); 2218 if (!dev)
2142 if (err) {
2143 dev_err(&pdev->dev, "Unable to request IRQ %d (error %d)\n",
2144 dev->irq, err);
2145 goto err_out_disable_clocks; 2219 goto err_out_disable_clocks;
2220
2221 SET_NETDEV_DEV(dev, &pdev->dev);
2222
2223 bp = netdev_priv(dev);
2224 bp->pdev = pdev;
2225 bp->dev = dev;
2226 bp->regs = mem;
2227 bp->num_queues = num_queues;
2228 bp->pclk = pclk;
2229 bp->hclk = hclk;
2230 bp->tx_clk = tx_clk;
2231
2232 spin_lock_init(&bp->lock);
2233
2234 /* set the queue register mapping once for all: queue0 has a special
2235 * register mapping but we don't want to test the queue index then
2236 * compute the corresponding register offset at run time.
2237 */
2238 for (hw_q = 0; hw_q < MACB_MAX_QUEUES; ++hw_q) {
2239 if (!(queue_mask & (1 << hw_q)))
2240 continue;
2241
2242 queue = &bp->queues[q_irq];
2243 queue->bp = bp;
2244 if (hw_q) {
2245 queue->ISR = GEM_ISR(hw_q - 1);
2246 queue->IER = GEM_IER(hw_q - 1);
2247 queue->IDR = GEM_IDR(hw_q - 1);
2248 queue->IMR = GEM_IMR(hw_q - 1);
2249 queue->TBQP = GEM_TBQP(hw_q - 1);
2250 } else {
2251 /* queue0 uses legacy registers */
2252 queue->ISR = MACB_ISR;
2253 queue->IER = MACB_IER;
2254 queue->IDR = MACB_IDR;
2255 queue->IMR = MACB_IMR;
2256 queue->TBQP = MACB_TBQP;
2257 }
2258
2259 /* get irq: here we use the linux queue index, not the hardware
2260 * queue index. the queue irq definitions in the device tree
2261 * must remove the optional gaps that could exist in the
2262 * hardware queue mask.
2263 */
2264 queue->irq = platform_get_irq(pdev, q_irq);
2265 err = devm_request_irq(&pdev->dev, queue->irq, macb_interrupt,
2266 0, dev->name, queue);
2267 if (err) {
2268 dev_err(&pdev->dev,
2269 "Unable to request IRQ %d (error %d)\n",
2270 queue->irq, err);
2271 goto err_out_free_irq;
2272 }
2273
2274 INIT_WORK(&queue->tx_error_task, macb_tx_error_task);
2275 q_irq++;
2146 } 2276 }
2277 dev->irq = bp->queues[0].irq;
2147 2278
2148 dev->netdev_ops = &macb_netdev_ops; 2279 dev->netdev_ops = &macb_netdev_ops;
2149 netif_napi_add(dev, &bp->napi, macb_poll, 64); 2280 netif_napi_add(dev, &bp->napi, macb_poll, 64);
@@ -2219,7 +2350,7 @@ static int __init macb_probe(struct platform_device *pdev)
2219 err = register_netdev(dev); 2350 err = register_netdev(dev);
2220 if (err) { 2351 if (err) {
2221 dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); 2352 dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
2222 goto err_out_disable_clocks; 2353 goto err_out_free_irq;
2223 } 2354 }
2224 2355
2225 err = macb_mii_init(bp); 2356 err = macb_mii_init(bp);
@@ -2242,15 +2373,17 @@ static int __init macb_probe(struct platform_device *pdev)
2242 2373
2243err_out_unregister_netdev: 2374err_out_unregister_netdev:
2244 unregister_netdev(dev); 2375 unregister_netdev(dev);
2376err_out_free_irq:
2377 for (q = 0, queue = bp->queues; q < q_irq; ++q, ++queue)
2378 devm_free_irq(&pdev->dev, queue->irq, queue);
2379 free_netdev(dev);
2245err_out_disable_clocks: 2380err_out_disable_clocks:
2246 if (!IS_ERR(bp->tx_clk)) 2381 if (!IS_ERR(tx_clk))
2247 clk_disable_unprepare(bp->tx_clk); 2382 clk_disable_unprepare(tx_clk);
2248err_out_disable_hclk: 2383err_out_disable_hclk:
2249 clk_disable_unprepare(bp->hclk); 2384 clk_disable_unprepare(hclk);
2250err_out_disable_pclk: 2385err_out_disable_pclk:
2251 clk_disable_unprepare(bp->pclk); 2386 clk_disable_unprepare(pclk);
2252err_out_free_dev:
2253 free_netdev(dev);
2254err_out: 2387err_out:
2255 return err; 2388 return err;
2256} 2389}
@@ -2259,6 +2392,8 @@ static int __exit macb_remove(struct platform_device *pdev)
2259{ 2392{
2260 struct net_device *dev; 2393 struct net_device *dev;
2261 struct macb *bp; 2394 struct macb *bp;
2395 struct macb_queue *queue;
2396 unsigned int q;
2262 2397
2263 dev = platform_get_drvdata(pdev); 2398 dev = platform_get_drvdata(pdev);
2264 2399
@@ -2270,11 +2405,14 @@ static int __exit macb_remove(struct platform_device *pdev)
2270 kfree(bp->mii_bus->irq); 2405 kfree(bp->mii_bus->irq);
2271 mdiobus_free(bp->mii_bus); 2406 mdiobus_free(bp->mii_bus);
2272 unregister_netdev(dev); 2407 unregister_netdev(dev);
2408 queue = bp->queues;
2409 for (q = 0; q < bp->num_queues; ++q, ++queue)
2410 devm_free_irq(&pdev->dev, queue->irq, queue);
2411 free_netdev(dev);
2273 if (!IS_ERR(bp->tx_clk)) 2412 if (!IS_ERR(bp->tx_clk))
2274 clk_disable_unprepare(bp->tx_clk); 2413 clk_disable_unprepare(bp->tx_clk);
2275 clk_disable_unprepare(bp->hclk); 2414 clk_disable_unprepare(bp->hclk);
2276 clk_disable_unprepare(bp->pclk); 2415 clk_disable_unprepare(bp->pclk);
2277 free_netdev(dev);
2278 } 2416 }
2279 2417
2280 return 0; 2418 return 0;
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 517c09d72c4a..084191b6fad2 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -12,6 +12,7 @@
12 12
13#define MACB_GREGS_NBR 16 13#define MACB_GREGS_NBR 16
14#define MACB_GREGS_VERSION 1 14#define MACB_GREGS_VERSION 1
15#define MACB_MAX_QUEUES 8
15 16
16/* MACB register offsets */ 17/* MACB register offsets */
17#define MACB_NCR 0x0000 18#define MACB_NCR 0x0000
@@ -89,6 +90,13 @@
89#define GEM_DCFG6 0x0294 90#define GEM_DCFG6 0x0294
90#define GEM_DCFG7 0x0298 91#define GEM_DCFG7 0x0298
91 92
93#define GEM_ISR(hw_q) (0x0400 + ((hw_q) << 2))
94#define GEM_TBQP(hw_q) (0x0440 + ((hw_q) << 2))
95#define GEM_RBQP(hw_q) (0x0480 + ((hw_q) << 2))
96#define GEM_IER(hw_q) (0x0600 + ((hw_q) << 2))
97#define GEM_IDR(hw_q) (0x0620 + ((hw_q) << 2))
98#define GEM_IMR(hw_q) (0x0640 + ((hw_q) << 2))
99
92/* Bitfields in NCR */ 100/* Bitfields in NCR */
93#define MACB_LB_OFFSET 0 101#define MACB_LB_OFFSET 0
94#define MACB_LB_SIZE 1 102#define MACB_LB_SIZE 1
@@ -376,6 +384,10 @@
376 __raw_readl((port)->regs + GEM_##reg) 384 __raw_readl((port)->regs + GEM_##reg)
377#define gem_writel(port, reg, value) \ 385#define gem_writel(port, reg, value) \
378 __raw_writel((value), (port)->regs + GEM_##reg) 386 __raw_writel((value), (port)->regs + GEM_##reg)
387#define queue_readl(queue, reg) \
388 __raw_readl((queue)->bp->regs + (queue)->reg)
389#define queue_writel(queue, reg, value) \
390 __raw_writel((value), (queue)->bp->regs + (queue)->reg)
379 391
380/* 392/*
381 * Conditional GEM/MACB macros. These perform the operation to the correct 393 * Conditional GEM/MACB macros. These perform the operation to the correct
@@ -597,6 +609,23 @@ struct macb_config {
597 unsigned int dma_burst_length; 609 unsigned int dma_burst_length;
598}; 610};
599 611
612struct macb_queue {
613 struct macb *bp;
614 int irq;
615
616 unsigned int ISR;
617 unsigned int IER;
618 unsigned int IDR;
619 unsigned int IMR;
620 unsigned int TBQP;
621
622 unsigned int tx_head, tx_tail;
623 struct macb_dma_desc *tx_ring;
624 struct macb_tx_skb *tx_skb;
625 dma_addr_t tx_ring_dma;
626 struct work_struct tx_error_task;
627};
628
600struct macb { 629struct macb {
601 void __iomem *regs; 630 void __iomem *regs;
602 631
@@ -607,9 +636,8 @@ struct macb {
607 void *rx_buffers; 636 void *rx_buffers;
608 size_t rx_buffer_size; 637 size_t rx_buffer_size;
609 638
610 unsigned int tx_head, tx_tail; 639 unsigned int num_queues;
611 struct macb_dma_desc *tx_ring; 640 struct macb_queue queues[MACB_MAX_QUEUES];
612 struct macb_tx_skb *tx_skb;
613 641
614 spinlock_t lock; 642 spinlock_t lock;
615 struct platform_device *pdev; 643 struct platform_device *pdev;
@@ -618,7 +646,6 @@ struct macb {
618 struct clk *tx_clk; 646 struct clk *tx_clk;
619 struct net_device *dev; 647 struct net_device *dev;
620 struct napi_struct napi; 648 struct napi_struct napi;
621 struct work_struct tx_error_task;
622 struct net_device_stats stats; 649 struct net_device_stats stats;
623 union { 650 union {
624 struct macb_stats macb; 651 struct macb_stats macb;
@@ -626,7 +653,6 @@ struct macb {
626 } hw_stats; 653 } hw_stats;
627 654
628 dma_addr_t rx_ring_dma; 655 dma_addr_t rx_ring_dma;
629 dma_addr_t tx_ring_dma;
630 dma_addr_t rx_buffers_dma; 656 dma_addr_t rx_buffers_dma;
631 657
632 struct macb_or_gem_ops macbgem_ops; 658 struct macb_or_gem_ops macbgem_ops;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index a18d33fdb271..5ab5c3133acd 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -392,7 +392,7 @@ struct port_info {
392 s16 xact_addr_filt; /* index of exact MAC address filter */ 392 s16 xact_addr_filt; /* index of exact MAC address filter */
393 u16 rss_size; /* size of VI's RSS table slice */ 393 u16 rss_size; /* size of VI's RSS table slice */
394 s8 mdio_addr; 394 s8 mdio_addr;
395 u8 port_type; 395 enum fw_port_type port_type;
396 u8 mod_type; 396 u8 mod_type;
397 u8 port_id; 397 u8 port_id;
398 u8 tx_chan; 398 u8 tx_chan;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 973dbb7938c3..ccf3436024bc 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2325,7 +2325,7 @@ static int identify_port(struct net_device *dev,
2325 return t4_identify_port(adap, adap->fn, netdev2pinfo(dev)->viid, val); 2325 return t4_identify_port(adap, adap->fn, netdev2pinfo(dev)->viid, val);
2326} 2326}
2327 2327
2328static unsigned int from_fw_linkcaps(unsigned int type, unsigned int caps) 2328static unsigned int from_fw_linkcaps(enum fw_port_type type, unsigned int caps)
2329{ 2329{
2330 unsigned int v = 0; 2330 unsigned int v = 0;
2331 2331
@@ -2354,14 +2354,20 @@ static unsigned int from_fw_linkcaps(unsigned int type, unsigned int caps)
2354 SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full | 2354 SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full |
2355 SUPPORTED_10000baseKX4_Full; 2355 SUPPORTED_10000baseKX4_Full;
2356 else if (type == FW_PORT_TYPE_FIBER_XFI || 2356 else if (type == FW_PORT_TYPE_FIBER_XFI ||
2357 type == FW_PORT_TYPE_FIBER_XAUI || type == FW_PORT_TYPE_SFP) { 2357 type == FW_PORT_TYPE_FIBER_XAUI ||
2358 type == FW_PORT_TYPE_SFP ||
2359 type == FW_PORT_TYPE_QSFP_10G ||
2360 type == FW_PORT_TYPE_QSA) {
2358 v |= SUPPORTED_FIBRE; 2361 v |= SUPPORTED_FIBRE;
2359 if (caps & FW_PORT_CAP_SPEED_1G) 2362 if (caps & FW_PORT_CAP_SPEED_1G)
2360 v |= SUPPORTED_1000baseT_Full; 2363 v |= SUPPORTED_1000baseT_Full;
2361 if (caps & FW_PORT_CAP_SPEED_10G) 2364 if (caps & FW_PORT_CAP_SPEED_10G)
2362 v |= SUPPORTED_10000baseT_Full; 2365 v |= SUPPORTED_10000baseT_Full;
2363 } else if (type == FW_PORT_TYPE_BP40_BA) 2366 } else if (type == FW_PORT_TYPE_BP40_BA ||
2367 type == FW_PORT_TYPE_QSFP) {
2364 v |= SUPPORTED_40000baseSR4_Full; 2368 v |= SUPPORTED_40000baseSR4_Full;
2369 v |= SUPPORTED_FIBRE;
2370 }
2365 2371
2366 if (caps & FW_PORT_CAP_ANEG) 2372 if (caps & FW_PORT_CAP_ANEG)
2367 v |= SUPPORTED_Autoneg; 2373 v |= SUPPORTED_Autoneg;
@@ -2396,6 +2402,7 @@ static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2396 cmd->port = PORT_FIBRE; 2402 cmd->port = PORT_FIBRE;
2397 else if (p->port_type == FW_PORT_TYPE_SFP || 2403 else if (p->port_type == FW_PORT_TYPE_SFP ||
2398 p->port_type == FW_PORT_TYPE_QSFP_10G || 2404 p->port_type == FW_PORT_TYPE_QSFP_10G ||
2405 p->port_type == FW_PORT_TYPE_QSA ||
2399 p->port_type == FW_PORT_TYPE_QSFP) { 2406 p->port_type == FW_PORT_TYPE_QSFP) {
2400 if (p->mod_type == FW_PORT_MOD_TYPE_LR || 2407 if (p->mod_type == FW_PORT_MOD_TYPE_LR ||
2401 p->mod_type == FW_PORT_MOD_TYPE_SR || 2408 p->mod_type == FW_PORT_MOD_TYPE_SR ||
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index beaf80a6214b..291b6f219708 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -560,6 +560,7 @@ enum fw_flowc_mnem {
560 FW_FLOWC_MNEM_RCVNXT, 560 FW_FLOWC_MNEM_RCVNXT,
561 FW_FLOWC_MNEM_SNDBUF, 561 FW_FLOWC_MNEM_SNDBUF,
562 FW_FLOWC_MNEM_MSS, 562 FW_FLOWC_MNEM_MSS,
563 FW_FLOWC_MNEM_TXDATAPLEN_MAX,
563}; 564};
564 565
565struct fw_flowc_mnemval { 566struct fw_flowc_mnemval {
@@ -2470,6 +2471,7 @@ enum fw_port_type {
2470 FW_PORT_TYPE_BP4_AP, 2471 FW_PORT_TYPE_BP4_AP,
2471 FW_PORT_TYPE_QSFP_10G, 2472 FW_PORT_TYPE_QSFP_10G,
2472 FW_PORT_TYPE_QSFP, 2473 FW_PORT_TYPE_QSFP,
2474 FW_PORT_TYPE_QSA,
2473 FW_PORT_TYPE_BP40_BA, 2475 FW_PORT_TYPE_BP40_BA,
2474 2476
2475 FW_PORT_TYPE_NONE = FW_PORT_CMD_PTYPE_M 2477 FW_PORT_TYPE_NONE = FW_PORT_CMD_PTYPE_M
diff --git a/drivers/net/ethernet/davicom/Kconfig b/drivers/net/ethernet/davicom/Kconfig
index 316c5e5a92ad..7ec2d74f94d3 100644
--- a/drivers/net/ethernet/davicom/Kconfig
+++ b/drivers/net/ethernet/davicom/Kconfig
@@ -4,7 +4,7 @@
4 4
5config DM9000 5config DM9000
6 tristate "DM9000 support" 6 tristate "DM9000 support"
7 depends on ARM || BLACKFIN || MIPS || COLDFIRE 7 depends on ARM || BLACKFIN || MIPS || COLDFIRE || NIOS2
8 select CRC32 8 select CRC32
9 select MII 9 select MII
10 ---help--- 10 ---help---
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
index ee1ecb146df7..eb088b129bc7 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
@@ -615,14 +615,14 @@ static bool fm10k_clean_rx_irq(struct fm10k_q_vector *q_vector,
615 615
616 rx_desc = FM10K_RX_DESC(rx_ring, rx_ring->next_to_clean); 616 rx_desc = FM10K_RX_DESC(rx_ring, rx_ring->next_to_clean);
617 617
618 if (!fm10k_test_staterr(rx_desc, FM10K_RXD_STATUS_DD)) 618 if (!rx_desc->d.staterr)
619 break; 619 break;
620 620
621 /* This memory barrier is needed to keep us from reading 621 /* This memory barrier is needed to keep us from reading
622 * any other fields out of the rx_desc until we know the 622 * any other fields out of the rx_desc until we know the
623 * RXD_STATUS_DD bit is set 623 * descriptor has been written back
624 */ 624 */
625 rmb(); 625 dma_rmb();
626 626
627 /* retrieve a buffer from the ring */ 627 /* retrieve a buffer from the ring */
628 skb = fm10k_fetch_rx_buffer(rx_ring, rx_desc, skb); 628 skb = fm10k_fetch_rx_buffer(rx_ring, rx_desc, skb);
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 2e526d4904a6..ff59897a9463 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6910,14 +6910,14 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget)
6910 6910
6911 rx_desc = IGB_RX_DESC(rx_ring, rx_ring->next_to_clean); 6911 rx_desc = IGB_RX_DESC(rx_ring, rx_ring->next_to_clean);
6912 6912
6913 if (!igb_test_staterr(rx_desc, E1000_RXD_STAT_DD)) 6913 if (!rx_desc->wb.upper.status_error)
6914 break; 6914 break;
6915 6915
6916 /* This memory barrier is needed to keep us from reading 6916 /* This memory barrier is needed to keep us from reading
6917 * any other fields out of the rx_desc until we know the 6917 * any other fields out of the rx_desc until we know the
6918 * RXD_STAT_DD bit is set 6918 * descriptor has been written back
6919 */ 6919 */
6920 rmb(); 6920 dma_rmb();
6921 6921
6922 /* retrieve a buffer from the ring */ 6922 /* retrieve a buffer from the ring */
6923 skb = igb_fetch_rx_buffer(rx_ring, rx_desc, skb); 6923 skb = igb_fetch_rx_buffer(rx_ring, rx_desc, skb);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 798b05556e1b..2ed2c7de2304 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -2009,15 +2009,14 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
2009 2009
2010 rx_desc = IXGBE_RX_DESC(rx_ring, rx_ring->next_to_clean); 2010 rx_desc = IXGBE_RX_DESC(rx_ring, rx_ring->next_to_clean);
2011 2011
2012 if (!ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_DD)) 2012 if (!rx_desc->wb.upper.status_error)
2013 break; 2013 break;
2014 2014
2015 /* 2015 /* This memory barrier is needed to keep us from reading
2016 * This memory barrier is needed to keep us from reading
2017 * any other fields out of the rx_desc until we know the 2016 * any other fields out of the rx_desc until we know the
2018 * RXD_STAT_DD bit is set 2017 * descriptor has been written back
2019 */ 2018 */
2020 rmb(); 2019 dma_rmb();
2021 2020
2022 /* retrieve a buffer from the ring */ 2021 /* retrieve a buffer from the ring */
2023 skb = ixgbe_fetch_rx_buffer(rx_ring, rx_desc); 2022 skb = ixgbe_fetch_rx_buffer(rx_ring, rx_desc);
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index 4a1be34d7214..44ce7d88f554 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -1364,8 +1364,8 @@ err_out_free_rx_resources:
1364 jme_free_rx_resources(jme); 1364 jme_free_rx_resources(jme);
1365out_enable_tasklet: 1365out_enable_tasklet:
1366 tasklet_enable(&jme->txclean_task); 1366 tasklet_enable(&jme->txclean_task);
1367 tasklet_hi_enable(&jme->rxclean_task); 1367 tasklet_enable(&jme->rxclean_task);
1368 tasklet_hi_enable(&jme->rxempty_task); 1368 tasklet_enable(&jme->rxempty_task);
1369out: 1369out:
1370 atomic_inc(&jme->link_changing); 1370 atomic_inc(&jme->link_changing);
1371} 1371}
@@ -2408,8 +2408,8 @@ static inline void jme_resume_rx(struct jme_adapter *jme)
2408 if (test_bit(JME_FLAG_POLL, &jme->flags)) { 2408 if (test_bit(JME_FLAG_POLL, &jme->flags)) {
2409 JME_NAPI_ENABLE(jme); 2409 JME_NAPI_ENABLE(jme);
2410 } else { 2410 } else {
2411 tasklet_hi_enable(&jme->rxclean_task); 2411 tasklet_enable(&jme->rxclean_task);
2412 tasklet_hi_enable(&jme->rxempty_task); 2412 tasklet_enable(&jme->rxempty_task);
2413 } 2413 }
2414 dpi->cur = PCC_P1; 2414 dpi->cur = PCC_P1;
2415 dpi->attempt = PCC_P1; 2415 dpi->attempt = PCC_P1;
@@ -3290,8 +3290,8 @@ jme_suspend(struct device *dev)
3290 } 3290 }
3291 3291
3292 tasklet_enable(&jme->txclean_task); 3292 tasklet_enable(&jme->txclean_task);
3293 tasklet_hi_enable(&jme->rxclean_task); 3293 tasklet_enable(&jme->rxclean_task);
3294 tasklet_hi_enable(&jme->rxempty_task); 3294 tasklet_enable(&jme->rxempty_task);
3295 3295
3296 jme_powersave_phy(jme); 3296 jme_powersave_phy(jme);
3297 3297
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 3dad7e884952..14a1c5cec3a5 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -5919,7 +5919,7 @@ static void rtl_hw_start_8411(struct rtl8169_private *tp)
5919 rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0x0000, ERIAR_EXGMAC); 5919 rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0x0000, ERIAR_EXGMAC);
5920} 5920}
5921 5921
5922static void rtl_hw_start_8168g_1(struct rtl8169_private *tp) 5922static void rtl_hw_start_8168g(struct rtl8169_private *tp)
5923{ 5923{
5924 void __iomem *ioaddr = tp->mmio_addr; 5924 void __iomem *ioaddr = tp->mmio_addr;
5925 struct pci_dev *pdev = tp->pci_dev; 5925 struct pci_dev *pdev = tp->pci_dev;
@@ -5954,6 +5954,24 @@ static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)
5954 rtl_pcie_state_l2l3_enable(tp, false); 5954 rtl_pcie_state_l2l3_enable(tp, false);
5955} 5955}
5956 5956
5957static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)
5958{
5959 void __iomem *ioaddr = tp->mmio_addr;
5960 static const struct ephy_info e_info_8168g_1[] = {
5961 { 0x00, 0x0000, 0x0008 },
5962 { 0x0c, 0x37d0, 0x0820 },
5963 { 0x1e, 0x0000, 0x0001 },
5964 { 0x19, 0x8000, 0x0000 }
5965 };
5966
5967 rtl_hw_start_8168g(tp);
5968
5969 /* disable aspm and clock request before access ephy */
5970 RTL_W8(Config2, RTL_R8(Config2) & ~ClkReqEn);
5971 RTL_W8(Config5, RTL_R8(Config5) & ~ASPM_en);
5972 rtl_ephy_init(tp, e_info_8168g_1, ARRAY_SIZE(e_info_8168g_1));
5973}
5974
5957static void rtl_hw_start_8168g_2(struct rtl8169_private *tp) 5975static void rtl_hw_start_8168g_2(struct rtl8169_private *tp)
5958{ 5976{
5959 void __iomem *ioaddr = tp->mmio_addr; 5977 void __iomem *ioaddr = tp->mmio_addr;
@@ -5964,7 +5982,7 @@ static void rtl_hw_start_8168g_2(struct rtl8169_private *tp)
5964 { 0x1e, 0xffff, 0x20eb } 5982 { 0x1e, 0xffff, 0x20eb }
5965 }; 5983 };
5966 5984
5967 rtl_hw_start_8168g_1(tp); 5985 rtl_hw_start_8168g(tp);
5968 5986
5969 /* disable aspm and clock request before access ephy */ 5987 /* disable aspm and clock request before access ephy */
5970 RTL_W8(Config2, RTL_R8(Config2) & ~ClkReqEn); 5988 RTL_W8(Config2, RTL_R8(Config2) & ~ClkReqEn);
@@ -5983,7 +6001,7 @@ static void rtl_hw_start_8411_2(struct rtl8169_private *tp)
5983 { 0x1e, 0x0000, 0x2000 } 6001 { 0x1e, 0x0000, 0x2000 }
5984 }; 6002 };
5985 6003
5986 rtl_hw_start_8168g_1(tp); 6004 rtl_hw_start_8168g(tp);
5987 6005
5988 /* disable aspm and clock request before access ephy */ 6006 /* disable aspm and clock request before access ephy */
5989 RTL_W8(Config2, RTL_R8(Config2) & ~ClkReqEn); 6007 RTL_W8(Config2, RTL_R8(Config2) & ~ClkReqEn);
@@ -6605,6 +6623,9 @@ static inline void rtl8169_mark_to_asic(struct RxDesc *desc, u32 rx_buf_sz)
6605{ 6623{
6606 u32 eor = le32_to_cpu(desc->opts1) & RingEnd; 6624 u32 eor = le32_to_cpu(desc->opts1) & RingEnd;
6607 6625
6626 /* Force memory writes to complete before releasing descriptor */
6627 dma_wmb();
6628
6608 desc->opts1 = cpu_to_le32(DescOwn | eor | rx_buf_sz); 6629 desc->opts1 = cpu_to_le32(DescOwn | eor | rx_buf_sz);
6609} 6630}
6610 6631
@@ -6612,7 +6633,6 @@ static inline void rtl8169_map_to_asic(struct RxDesc *desc, dma_addr_t mapping,
6612 u32 rx_buf_sz) 6633 u32 rx_buf_sz)
6613{ 6634{
6614 desc->addr = cpu_to_le64(mapping); 6635 desc->addr = cpu_to_le64(mapping);
6615 wmb();
6616 rtl8169_mark_to_asic(desc, rx_buf_sz); 6636 rtl8169_mark_to_asic(desc, rx_buf_sz);
6617} 6637}
6618 6638
@@ -7073,16 +7093,18 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
7073 7093
7074 skb_tx_timestamp(skb); 7094 skb_tx_timestamp(skb);
7075 7095
7076 wmb(); 7096 /* Force memory writes to complete before releasing descriptor */
7097 dma_wmb();
7077 7098
7078 /* Anti gcc 2.95.3 bugware (sic) */ 7099 /* Anti gcc 2.95.3 bugware (sic) */
7079 status = opts[0] | len | (RingEnd * !((entry + 1) % NUM_TX_DESC)); 7100 status = opts[0] | len | (RingEnd * !((entry + 1) % NUM_TX_DESC));
7080 txd->opts1 = cpu_to_le32(status); 7101 txd->opts1 = cpu_to_le32(status);
7081 7102
7082 tp->cur_tx += frags + 1; 7103 /* Force all memory writes to complete before notifying device */
7083
7084 wmb(); 7104 wmb();
7085 7105
7106 tp->cur_tx += frags + 1;
7107
7086 RTL_W8(TxPoll, NPQ); 7108 RTL_W8(TxPoll, NPQ);
7087 7109
7088 mmiowb(); 7110 mmiowb();
@@ -7181,11 +7203,16 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
7181 struct ring_info *tx_skb = tp->tx_skb + entry; 7203 struct ring_info *tx_skb = tp->tx_skb + entry;
7182 u32 status; 7204 u32 status;
7183 7205
7184 rmb();
7185 status = le32_to_cpu(tp->TxDescArray[entry].opts1); 7206 status = le32_to_cpu(tp->TxDescArray[entry].opts1);
7186 if (status & DescOwn) 7207 if (status & DescOwn)
7187 break; 7208 break;
7188 7209
7210 /* This barrier is needed to keep us from reading
7211 * any other fields out of the Tx descriptor until
7212 * we know the status of DescOwn
7213 */
7214 dma_rmb();
7215
7189 rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb, 7216 rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
7190 tp->TxDescArray + entry); 7217 tp->TxDescArray + entry);
7191 if (status & LastFrag) { 7218 if (status & LastFrag) {
@@ -7280,11 +7307,16 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
7280 struct RxDesc *desc = tp->RxDescArray + entry; 7307 struct RxDesc *desc = tp->RxDescArray + entry;
7281 u32 status; 7308 u32 status;
7282 7309
7283 rmb();
7284 status = le32_to_cpu(desc->opts1) & tp->opts1_mask; 7310 status = le32_to_cpu(desc->opts1) & tp->opts1_mask;
7285
7286 if (status & DescOwn) 7311 if (status & DescOwn)
7287 break; 7312 break;
7313
7314 /* This barrier is needed to keep us from reading
7315 * any other fields out of the Rx descriptor until
7316 * we know the status of DescOwn
7317 */
7318 dma_rmb();
7319
7288 if (unlikely(status & RxRES)) { 7320 if (unlikely(status & RxRES)) {
7289 netif_info(tp, rx_err, dev, "Rx ERROR. status = %08x\n", 7321 netif_info(tp, rx_err, dev, "Rx ERROR. status = %08x\n",
7290 status); 7322 status);
@@ -7346,7 +7378,6 @@ process_pkt:
7346 } 7378 }
7347release_descriptor: 7379release_descriptor:
7348 desc->opts2 = 0; 7380 desc->opts2 = 0;
7349 wmb();
7350 rtl8169_mark_to_asic(desc, rx_buf_sz); 7381 rtl8169_mark_to_asic(desc, rx_buf_sz);
7351 } 7382 }
7352 7383
diff --git a/drivers/net/ethernet/smsc/Kconfig b/drivers/net/ethernet/smsc/Kconfig
index 753630f5d3d3..627926800ff3 100644
--- a/drivers/net/ethernet/smsc/Kconfig
+++ b/drivers/net/ethernet/smsc/Kconfig
@@ -6,7 +6,7 @@ config NET_VENDOR_SMSC
6 bool "SMC (SMSC)/Western Digital devices" 6 bool "SMC (SMSC)/Western Digital devices"
7 default y 7 default y
8 depends on ARM || ISA || MAC || ARM64 || MIPS || M32R || SUPERH || \ 8 depends on ARM || ISA || MAC || ARM64 || MIPS || M32R || SUPERH || \
9 BLACKFIN || MN10300 || COLDFIRE || XTENSA || PCI || PCMCIA 9 BLACKFIN || MN10300 || COLDFIRE || XTENSA || NIOS2 || PCI || PCMCIA
10 ---help--- 10 ---help---
11 If you have a network (Ethernet) card belonging to this class, say Y 11 If you have a network (Ethernet) card belonging to this class, say Y
12 and read the Ethernet-HOWTO, available from 12 and read the Ethernet-HOWTO, available from
@@ -39,7 +39,7 @@ config SMC91X
39 select CRC32 39 select CRC32
40 select MII 40 select MII
41 depends on (ARM || M32R || SUPERH || MIPS || BLACKFIN || \ 41 depends on (ARM || M32R || SUPERH || MIPS || BLACKFIN || \
42 MN10300 || COLDFIRE || ARM64 || XTENSA) 42 MN10300 || COLDFIRE || ARM64 || XTENSA || NIOS2)
43 ---help--- 43 ---help---
44 This is a driver for SMC's 91x series of Ethernet chipsets, 44 This is a driver for SMC's 91x series of Ethernet chipsets,
45 including the SMC91C94 and the SMC91C111. Say Y if you want it 45 including the SMC91C94 and the SMC91C111. Say Y if you want it
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index 47872caa0081..3ad0e6e16c39 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -274,6 +274,7 @@ struct phy_device *fixed_phy_register(unsigned int irq,
274 274
275 return phy; 275 return phy;
276} 276}
277EXPORT_SYMBOL_GPL(fixed_phy_register);
277 278
278static int __init fixed_mdio_bus_init(void) 279static int __init fixed_mdio_bus_init(void)
279{ 280{
diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
index 69fbfc89efb6..a83d2ceded83 100644
--- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
+++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
@@ -75,6 +75,7 @@ typedef void (*cxgb4i_cplhandler_func)(struct cxgbi_device *, struct sk_buff *);
75static void *t4_uld_add(const struct cxgb4_lld_info *); 75static void *t4_uld_add(const struct cxgb4_lld_info *);
76static int t4_uld_rx_handler(void *, const __be64 *, const struct pkt_gl *); 76static int t4_uld_rx_handler(void *, const __be64 *, const struct pkt_gl *);
77static int t4_uld_state_change(void *, enum cxgb4_state state); 77static int t4_uld_state_change(void *, enum cxgb4_state state);
78static inline int send_tx_flowc_wr(struct cxgbi_sock *);
78 79
79static const struct cxgb4_uld_info cxgb4i_uld_info = { 80static const struct cxgb4_uld_info cxgb4i_uld_info = {
80 .name = DRV_MODULE_NAME, 81 .name = DRV_MODULE_NAME,
@@ -157,12 +158,6 @@ static struct scsi_transport_template *cxgb4i_stt;
157#define RCV_BUFSIZ_MASK 0x3FFU 158#define RCV_BUFSIZ_MASK 0x3FFU
158#define MAX_IMM_TX_PKT_LEN 128 159#define MAX_IMM_TX_PKT_LEN 128
159 160
160static inline void set_queue(struct sk_buff *skb, unsigned int queue,
161 const struct cxgbi_sock *csk)
162{
163 skb->queue_mapping = queue;
164}
165
166static int push_tx_frames(struct cxgbi_sock *, int); 161static int push_tx_frames(struct cxgbi_sock *, int);
167 162
168/* 163/*
@@ -172,10 +167,14 @@ static int push_tx_frames(struct cxgbi_sock *, int);
172 * Returns true if a packet can be sent as an offload WR with immediate 167 * Returns true if a packet can be sent as an offload WR with immediate
173 * data. We currently use the same limit as for Ethernet packets. 168 * data. We currently use the same limit as for Ethernet packets.
174 */ 169 */
175static inline int is_ofld_imm(const struct sk_buff *skb) 170static inline bool is_ofld_imm(const struct sk_buff *skb)
176{ 171{
177 return skb->len <= (MAX_IMM_TX_PKT_LEN - 172 int len = skb->len;
178 sizeof(struct fw_ofld_tx_data_wr)); 173
174 if (likely(cxgbi_skcb_test_flag(skb, SKCBF_TX_NEED_HDR)))
175 len += sizeof(struct fw_ofld_tx_data_wr);
176
177 return len <= MAX_IMM_TX_PKT_LEN;
179} 178}
180 179
181static void send_act_open_req(struct cxgbi_sock *csk, struct sk_buff *skb, 180static void send_act_open_req(struct cxgbi_sock *csk, struct sk_buff *skb,
@@ -388,13 +387,19 @@ static void send_abort_req(struct cxgbi_sock *csk)
388 387
389 if (unlikely(csk->state == CTP_ABORTING) || !skb || !csk->cdev) 388 if (unlikely(csk->state == CTP_ABORTING) || !skb || !csk->cdev)
390 return; 389 return;
390
391 if (!cxgbi_sock_flag(csk, CTPF_TX_DATA_SENT)) {
392 send_tx_flowc_wr(csk);
393 cxgbi_sock_set_flag(csk, CTPF_TX_DATA_SENT);
394 }
395
391 cxgbi_sock_set_state(csk, CTP_ABORTING); 396 cxgbi_sock_set_state(csk, CTP_ABORTING);
392 cxgbi_sock_set_flag(csk, CTPF_ABORT_RPL_PENDING); 397 cxgbi_sock_set_flag(csk, CTPF_ABORT_RPL_PENDING);
393 cxgbi_sock_purge_write_queue(csk); 398 cxgbi_sock_purge_write_queue(csk);
394 399
395 csk->cpl_abort_req = NULL; 400 csk->cpl_abort_req = NULL;
396 req = (struct cpl_abort_req *)skb->head; 401 req = (struct cpl_abort_req *)skb->head;
397 set_queue(skb, CPL_PRIORITY_DATA, csk); 402 set_wr_txq(skb, CPL_PRIORITY_DATA, csk->port_id);
398 req->cmd = CPL_ABORT_SEND_RST; 403 req->cmd = CPL_ABORT_SEND_RST;
399 t4_set_arp_err_handler(skb, csk, abort_arp_failure); 404 t4_set_arp_err_handler(skb, csk, abort_arp_failure);
400 INIT_TP_WR(req, csk->tid); 405 INIT_TP_WR(req, csk->tid);
@@ -420,7 +425,7 @@ static void send_abort_rpl(struct cxgbi_sock *csk, int rst_status)
420 csk, csk->state, csk->flags, csk->tid, rst_status); 425 csk, csk->state, csk->flags, csk->tid, rst_status);
421 426
422 csk->cpl_abort_rpl = NULL; 427 csk->cpl_abort_rpl = NULL;
423 set_queue(skb, CPL_PRIORITY_DATA, csk); 428 set_wr_txq(skb, CPL_PRIORITY_DATA, csk->port_id);
424 INIT_TP_WR(rpl, csk->tid); 429 INIT_TP_WR(rpl, csk->tid);
425 OPCODE_TID(rpl) = cpu_to_be32(MK_OPCODE_TID(CPL_ABORT_RPL, csk->tid)); 430 OPCODE_TID(rpl) = cpu_to_be32(MK_OPCODE_TID(CPL_ABORT_RPL, csk->tid));
426 rpl->cmd = rst_status; 431 rpl->cmd = rst_status;
@@ -491,20 +496,40 @@ static inline unsigned int calc_tx_flits_ofld(const struct sk_buff *skb)
491 return flits + sgl_len(cnt); 496 return flits + sgl_len(cnt);
492} 497}
493 498
494static inline void send_tx_flowc_wr(struct cxgbi_sock *csk) 499#define FLOWC_WR_NPARAMS_MIN 9
500static inline int tx_flowc_wr_credits(int *nparamsp, int *flowclenp)
501{
502 int nparams, flowclen16, flowclen;
503
504 nparams = FLOWC_WR_NPARAMS_MIN;
505 flowclen = offsetof(struct fw_flowc_wr, mnemval[nparams]);
506 flowclen16 = DIV_ROUND_UP(flowclen, 16);
507 flowclen = flowclen16 * 16;
508 /*
509 * Return the number of 16-byte credits used by the FlowC request.
510 * Pass back the nparams and actual FlowC length if requested.
511 */
512 if (nparamsp)
513 *nparamsp = nparams;
514 if (flowclenp)
515 *flowclenp = flowclen;
516
517 return flowclen16;
518}
519
520static inline int send_tx_flowc_wr(struct cxgbi_sock *csk)
495{ 521{
496 struct sk_buff *skb; 522 struct sk_buff *skb;
497 struct fw_flowc_wr *flowc; 523 struct fw_flowc_wr *flowc;
498 int flowclen, i; 524 int nparams, flowclen16, flowclen;
499 525
500 flowclen = 80; 526 flowclen16 = tx_flowc_wr_credits(&nparams, &flowclen);
501 skb = alloc_wr(flowclen, 0, GFP_ATOMIC); 527 skb = alloc_wr(flowclen, 0, GFP_ATOMIC);
502 flowc = (struct fw_flowc_wr *)skb->head; 528 flowc = (struct fw_flowc_wr *)skb->head;
503 flowc->op_to_nparams = 529 flowc->op_to_nparams =
504 htonl(FW_WR_OP_V(FW_FLOWC_WR) | FW_FLOWC_WR_NPARAMS_V(8)); 530 htonl(FW_WR_OP_V(FW_FLOWC_WR) | FW_FLOWC_WR_NPARAMS_V(nparams));
505 flowc->flowid_len16 = 531 flowc->flowid_len16 =
506 htonl(FW_WR_LEN16_V(DIV_ROUND_UP(72, 16)) | 532 htonl(FW_WR_LEN16_V(flowclen16) | FW_WR_FLOWID_V(csk->tid));
507 FW_WR_FLOWID_V(csk->tid));
508 flowc->mnemval[0].mnemonic = FW_FLOWC_MNEM_PFNVFN; 533 flowc->mnemval[0].mnemonic = FW_FLOWC_MNEM_PFNVFN;
509 flowc->mnemval[0].val = htonl(csk->cdev->pfvf); 534 flowc->mnemval[0].val = htonl(csk->cdev->pfvf);
510 flowc->mnemval[1].mnemonic = FW_FLOWC_MNEM_CH; 535 flowc->mnemval[1].mnemonic = FW_FLOWC_MNEM_CH;
@@ -523,12 +548,10 @@ static inline void send_tx_flowc_wr(struct cxgbi_sock *csk)
523 flowc->mnemval[7].val = htonl(csk->advmss); 548 flowc->mnemval[7].val = htonl(csk->advmss);
524 flowc->mnemval[8].mnemonic = 0; 549 flowc->mnemval[8].mnemonic = 0;
525 flowc->mnemval[8].val = 0; 550 flowc->mnemval[8].val = 0;
526 for (i = 0; i < 9; i++) { 551 flowc->mnemval[8].mnemonic = FW_FLOWC_MNEM_TXDATAPLEN_MAX;
527 flowc->mnemval[i].r4[0] = 0; 552 flowc->mnemval[8].val = 16384;
528 flowc->mnemval[i].r4[1] = 0; 553
529 flowc->mnemval[i].r4[2] = 0; 554 set_wr_txq(skb, CPL_PRIORITY_DATA, csk->port_id);
530 }
531 set_queue(skb, CPL_PRIORITY_DATA, csk);
532 555
533 log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK, 556 log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK,
534 "csk 0x%p, tid 0x%x, %u,%u,%u,%u,%u,%u,%u.\n", 557 "csk 0x%p, tid 0x%x, %u,%u,%u,%u,%u,%u,%u.\n",
@@ -537,6 +560,8 @@ static inline void send_tx_flowc_wr(struct cxgbi_sock *csk)
537 csk->advmss); 560 csk->advmss);
538 561
539 cxgb4_ofld_send(csk->cdev->ports[csk->port_id], skb); 562 cxgb4_ofld_send(csk->cdev->ports[csk->port_id], skb);
563
564 return flowclen16;
540} 565}
541 566
542static inline void make_tx_data_wr(struct cxgbi_sock *csk, struct sk_buff *skb, 567static inline void make_tx_data_wr(struct cxgbi_sock *csk, struct sk_buff *skb,
@@ -545,10 +570,11 @@ static inline void make_tx_data_wr(struct cxgbi_sock *csk, struct sk_buff *skb,
545 struct fw_ofld_tx_data_wr *req; 570 struct fw_ofld_tx_data_wr *req;
546 unsigned int submode = cxgbi_skcb_ulp_mode(skb) & 3; 571 unsigned int submode = cxgbi_skcb_ulp_mode(skb) & 3;
547 unsigned int wr_ulp_mode = 0, val; 572 unsigned int wr_ulp_mode = 0, val;
573 bool imm = is_ofld_imm(skb);
548 574
549 req = (struct fw_ofld_tx_data_wr *)__skb_push(skb, sizeof(*req)); 575 req = (struct fw_ofld_tx_data_wr *)__skb_push(skb, sizeof(*req));
550 576
551 if (is_ofld_imm(skb)) { 577 if (imm) {
552 req->op_to_immdlen = htonl(FW_WR_OP_V(FW_OFLD_TX_DATA_WR) | 578 req->op_to_immdlen = htonl(FW_WR_OP_V(FW_OFLD_TX_DATA_WR) |
553 FW_WR_COMPL_F | 579 FW_WR_COMPL_F |
554 FW_WR_IMMDLEN_V(dlen)); 580 FW_WR_IMMDLEN_V(dlen));
@@ -597,16 +623,32 @@ static int push_tx_frames(struct cxgbi_sock *csk, int req_completion)
597 int dlen = skb->len; 623 int dlen = skb->len;
598 int len = skb->len; 624 int len = skb->len;
599 unsigned int credits_needed; 625 unsigned int credits_needed;
626 int flowclen16 = 0;
600 627
601 skb_reset_transport_header(skb); 628 skb_reset_transport_header(skb);
602 if (is_ofld_imm(skb)) 629 if (is_ofld_imm(skb))
603 credits_needed = DIV_ROUND_UP(dlen + 630 credits_needed = DIV_ROUND_UP(dlen, 16);
604 sizeof(struct fw_ofld_tx_data_wr), 16);
605 else 631 else
606 credits_needed = DIV_ROUND_UP(8*calc_tx_flits_ofld(skb) 632 credits_needed = DIV_ROUND_UP(
607 + sizeof(struct fw_ofld_tx_data_wr), 633 8 * calc_tx_flits_ofld(skb),
634 16);
635
636 if (likely(cxgbi_skcb_test_flag(skb, SKCBF_TX_NEED_HDR)))
637 credits_needed += DIV_ROUND_UP(
638 sizeof(struct fw_ofld_tx_data_wr),
608 16); 639 16);
609 640
641 /*
642 * Assumes the initial credits is large enough to support
643 * fw_flowc_wr plus largest possible first payload
644 */
645 if (!cxgbi_sock_flag(csk, CTPF_TX_DATA_SENT)) {
646 flowclen16 = send_tx_flowc_wr(csk);
647 csk->wr_cred -= flowclen16;
648 csk->wr_una_cred += flowclen16;
649 cxgbi_sock_set_flag(csk, CTPF_TX_DATA_SENT);
650 }
651
610 if (csk->wr_cred < credits_needed) { 652 if (csk->wr_cred < credits_needed) {
611 log_debug(1 << CXGBI_DBG_PDU_TX, 653 log_debug(1 << CXGBI_DBG_PDU_TX,
612 "csk 0x%p, skb %u/%u, wr %d < %u.\n", 654 "csk 0x%p, skb %u/%u, wr %d < %u.\n",
@@ -615,8 +657,8 @@ static int push_tx_frames(struct cxgbi_sock *csk, int req_completion)
615 break; 657 break;
616 } 658 }
617 __skb_unlink(skb, &csk->write_queue); 659 __skb_unlink(skb, &csk->write_queue);
618 set_queue(skb, CPL_PRIORITY_DATA, csk); 660 set_wr_txq(skb, CPL_PRIORITY_DATA, csk->port_id);
619 skb->csum = credits_needed; 661 skb->csum = credits_needed + flowclen16;
620 csk->wr_cred -= credits_needed; 662 csk->wr_cred -= credits_needed;
621 csk->wr_una_cred += credits_needed; 663 csk->wr_una_cred += credits_needed;
622 cxgbi_sock_enqueue_wr(csk, skb); 664 cxgbi_sock_enqueue_wr(csk, skb);
@@ -627,12 +669,6 @@ static int push_tx_frames(struct cxgbi_sock *csk, int req_completion)
627 csk->wr_cred, csk->wr_una_cred); 669 csk->wr_cred, csk->wr_una_cred);
628 670
629 if (likely(cxgbi_skcb_test_flag(skb, SKCBF_TX_NEED_HDR))) { 671 if (likely(cxgbi_skcb_test_flag(skb, SKCBF_TX_NEED_HDR))) {
630 if (!cxgbi_sock_flag(csk, CTPF_TX_DATA_SENT)) {
631 send_tx_flowc_wr(csk);
632 skb->csum += 5;
633 csk->wr_cred -= 5;
634 csk->wr_una_cred += 5;
635 }
636 len += cxgbi_ulp_extra_len(cxgbi_skcb_ulp_mode(skb)); 672 len += cxgbi_ulp_extra_len(cxgbi_skcb_ulp_mode(skb));
637 make_tx_data_wr(csk, skb, dlen, len, credits_needed, 673 make_tx_data_wr(csk, skb, dlen, len, credits_needed,
638 req_completion); 674 req_completion);
@@ -807,6 +843,13 @@ static void csk_act_open_retry_timer(unsigned long data)
807 843
808} 844}
809 845
846static inline bool is_neg_adv(unsigned int status)
847{
848 return status == CPL_ERR_RTX_NEG_ADVICE ||
849 status == CPL_ERR_KEEPALV_NEG_ADVICE ||
850 status == CPL_ERR_PERSIST_NEG_ADVICE;
851}
852
810static void do_act_open_rpl(struct cxgbi_device *cdev, struct sk_buff *skb) 853static void do_act_open_rpl(struct cxgbi_device *cdev, struct sk_buff *skb)
811{ 854{
812 struct cxgbi_sock *csk; 855 struct cxgbi_sock *csk;
@@ -828,7 +871,7 @@ static void do_act_open_rpl(struct cxgbi_device *cdev, struct sk_buff *skb)
828 "csk 0x%p,%u,0x%lx. ", (&csk->saddr), (&csk->daddr), 871 "csk 0x%p,%u,0x%lx. ", (&csk->saddr), (&csk->daddr),
829 atid, tid, status, csk, csk->state, csk->flags); 872 atid, tid, status, csk, csk->state, csk->flags);
830 873
831 if (status == CPL_ERR_RTX_NEG_ADVICE) 874 if (is_neg_adv(status))
832 goto rel_skb; 875 goto rel_skb;
833 876
834 module_put(THIS_MODULE); 877 module_put(THIS_MODULE);
@@ -934,8 +977,7 @@ static void do_abort_req_rss(struct cxgbi_device *cdev, struct sk_buff *skb)
934 (&csk->saddr), (&csk->daddr), 977 (&csk->saddr), (&csk->daddr),
935 csk, csk->state, csk->flags, csk->tid, req->status); 978 csk, csk->state, csk->flags, csk->tid, req->status);
936 979
937 if (req->status == CPL_ERR_RTX_NEG_ADVICE || 980 if (is_neg_adv(req->status))
938 req->status == CPL_ERR_PERSIST_NEG_ADVICE)
939 goto rel_skb; 981 goto rel_skb;
940 982
941 cxgbi_sock_get(csk); 983 cxgbi_sock_get(csk);
@@ -989,6 +1031,27 @@ rel_skb:
989 __kfree_skb(skb); 1031 __kfree_skb(skb);
990} 1032}
991 1033
1034static void do_rx_data(struct cxgbi_device *cdev, struct sk_buff *skb)
1035{
1036 struct cxgbi_sock *csk;
1037 struct cpl_rx_data *cpl = (struct cpl_rx_data *)skb->data;
1038 unsigned int tid = GET_TID(cpl);
1039 struct cxgb4_lld_info *lldi = cxgbi_cdev_priv(cdev);
1040 struct tid_info *t = lldi->tids;
1041
1042 csk = lookup_tid(t, tid);
1043 if (!csk) {
1044 pr_err("can't find connection for tid %u.\n", tid);
1045 } else {
1046 /* not expecting this, reset the connection. */
1047 pr_err("csk 0x%p, tid %u, rcv cpl_rx_data.\n", csk, tid);
1048 spin_lock_bh(&csk->lock);
1049 send_abort_req(csk);
1050 spin_unlock_bh(&csk->lock);
1051 }
1052 __kfree_skb(skb);
1053}
1054
992static void do_rx_iscsi_hdr(struct cxgbi_device *cdev, struct sk_buff *skb) 1055static void do_rx_iscsi_hdr(struct cxgbi_device *cdev, struct sk_buff *skb)
993{ 1056{
994 struct cxgbi_sock *csk; 1057 struct cxgbi_sock *csk;
@@ -1408,6 +1471,7 @@ cxgb4i_cplhandler_func cxgb4i_cplhandlers[NUM_CPL_CMDS] = {
1408 [CPL_SET_TCB_RPL] = do_set_tcb_rpl, 1471 [CPL_SET_TCB_RPL] = do_set_tcb_rpl,
1409 [CPL_RX_DATA_DDP] = do_rx_data_ddp, 1472 [CPL_RX_DATA_DDP] = do_rx_data_ddp,
1410 [CPL_RX_ISCSI_DDP] = do_rx_data_ddp, 1473 [CPL_RX_ISCSI_DDP] = do_rx_data_ddp,
1474 [CPL_RX_DATA] = do_rx_data,
1411}; 1475};
1412 1476
1413int cxgb4i_ofld_init(struct cxgbi_device *cdev) 1477int cxgb4i_ofld_init(struct cxgbi_device *cdev)
@@ -1485,7 +1549,7 @@ static int ddp_ppod_write_idata(struct cxgbi_device *cdev, unsigned int port_id,
1485 return -ENOMEM; 1549 return -ENOMEM;
1486 } 1550 }
1487 req = (struct ulp_mem_io *)skb->head; 1551 req = (struct ulp_mem_io *)skb->head;
1488 set_queue(skb, CPL_PRIORITY_CONTROL, NULL); 1552 set_wr_txq(skb, CPL_PRIORITY_CONTROL, 0);
1489 1553
1490 ulp_mem_io_set_hdr(lldi, req, wr_len, dlen, pm_addr); 1554 ulp_mem_io_set_hdr(lldi, req, wr_len, dlen, pm_addr);
1491 idata = (struct ulptx_idata *)(req + 1); 1555 idata = (struct ulptx_idata *)(req + 1);
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 7da59c38a69e..eb58afcfb73b 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -2294,10 +2294,12 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
2294 return err; 2294 return err;
2295 } 2295 }
2296 2296
2297 kfree_skb(skb);
2298 log_debug(1 << CXGBI_DBG_ISCSI | 1 << CXGBI_DBG_PDU_TX, 2297 log_debug(1 << CXGBI_DBG_ISCSI | 1 << CXGBI_DBG_PDU_TX,
2299 "itt 0x%x, skb 0x%p, len %u/%u, xmit err %d.\n", 2298 "itt 0x%x, skb 0x%p, len %u/%u, xmit err %d.\n",
2300 task->itt, skb, skb->len, skb->data_len, err); 2299 task->itt, skb, skb->len, skb->data_len, err);
2300
2301 kfree_skb(skb);
2302
2301 iscsi_conn_printk(KERN_ERR, task->conn, "xmit err %d.\n", err); 2303 iscsi_conn_printk(KERN_ERR, task->conn, "xmit err %d.\n", err);
2302 iscsi_conn_failure(task->conn, ISCSI_ERR_XMIT_FAILED); 2304 iscsi_conn_failure(task->conn, ISCSI_ERR_XMIT_FAILED);
2303 return err; 2305 return err;
diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h
index 2c7cb1c0c453..aba1af720df6 100644
--- a/drivers/scsi/cxgbi/libcxgbi.h
+++ b/drivers/scsi/cxgbi/libcxgbi.h
@@ -317,8 +317,8 @@ static inline void cxgbi_skcb_clear_flag(struct sk_buff *skb,
317 __clear_bit(flag, &(cxgbi_skcb_flags(skb))); 317 __clear_bit(flag, &(cxgbi_skcb_flags(skb)));
318} 318}
319 319
320static inline int cxgbi_skcb_test_flag(struct sk_buff *skb, 320static inline int cxgbi_skcb_test_flag(const struct sk_buff *skb,
321 enum cxgbi_skcb_flags flag) 321 enum cxgbi_skcb_flags flag)
322{ 322{
323 return test_bit(flag, &(cxgbi_skcb_flags(skb))); 323 return test_bit(flag, &(cxgbi_skcb_flags(skb)));
324} 324}
diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h
index 1402fa855388..f5c40b0fadc2 100644
--- a/include/asm-generic/barrier.h
+++ b/include/asm-generic/barrier.h
@@ -42,6 +42,14 @@
42#define wmb() mb() 42#define wmb() mb()
43#endif 43#endif
44 44
45#ifndef dma_rmb
46#define dma_rmb() rmb()
47#endif
48
49#ifndef dma_wmb
50#define dma_wmb() wmb()
51#endif
52
45#ifndef read_barrier_depends 53#ifndef read_barrier_depends
46#define read_barrier_depends() do { } while (0) 54#define read_barrier_depends() do { } while (0)
47#endif 55#endif
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 69517a24bc50..d9b05b5bf8c7 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -556,12 +556,6 @@ static inline void tasklet_enable(struct tasklet_struct *t)
556 atomic_dec(&t->count); 556 atomic_dec(&t->count);
557} 557}
558 558
559static inline void tasklet_hi_enable(struct tasklet_struct *t)
560{
561 smp_mb__before_atomic();
562 atomic_dec(&t->count);
563}
564
565extern void tasklet_kill(struct tasklet_struct *t); 559extern void tasklet_kill(struct tasklet_struct *t);
566extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu); 560extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
567extern void tasklet_init(struct tasklet_struct *t, 561extern void tasklet_init(struct tasklet_struct *t,
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 376805005cc7..118956448cf6 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -579,11 +579,12 @@ static int vlan_dev_init(struct net_device *dev)
579 (1<<__LINK_STATE_PRESENT); 579 (1<<__LINK_STATE_PRESENT);
580 580
581 dev->hw_features = NETIF_F_ALL_CSUM | NETIF_F_SG | 581 dev->hw_features = NETIF_F_ALL_CSUM | NETIF_F_SG |
582 NETIF_F_FRAGLIST | NETIF_F_ALL_TSO | 582 NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE |
583 NETIF_F_HIGHDMA | NETIF_F_SCTP_CSUM | 583 NETIF_F_HIGHDMA | NETIF_F_SCTP_CSUM |
584 NETIF_F_ALL_FCOE; 584 NETIF_F_ALL_FCOE;
585 585
586 dev->features |= real_dev->vlan_features | NETIF_F_LLTX; 586 dev->features |= real_dev->vlan_features | NETIF_F_LLTX |
587 NETIF_F_GSO_SOFTWARE;
587 dev->gso_max_size = real_dev->gso_max_size; 588 dev->gso_max_size = real_dev->gso_max_size;
588 if (dev->features & NETIF_F_VLAN_FEATURES) 589 if (dev->features & NETIF_F_VLAN_FEATURES)
589 netdev_warn(real_dev, "VLAN features are set incorrectly. Q-in-Q configurations may not work correctly.\n"); 590 netdev_warn(real_dev, "VLAN features are set incorrectly. Q-in-Q configurations may not work correctly.\n");
@@ -648,7 +649,7 @@ static netdev_features_t vlan_dev_fix_features(struct net_device *dev,
648 features |= NETIF_F_RXCSUM; 649 features |= NETIF_F_RXCSUM;
649 features = netdev_intersect_features(features, real_dev->features); 650 features = netdev_intersect_features(features, real_dev->features);
650 651
651 features |= old_features & NETIF_F_SOFT_FEATURES; 652 features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE);
652 features |= NETIF_F_LLTX; 653 features |= NETIF_F_LLTX;
653 654
654 return features; 655 return features;
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 528380a3e296..515569ffde8a 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -512,7 +512,7 @@ static int dsa_slave_fixed_link_update(struct net_device *dev,
512} 512}
513 513
514/* slave device setup *******************************************************/ 514/* slave device setup *******************************************************/
515static void dsa_slave_phy_setup(struct dsa_slave_priv *p, 515static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
516 struct net_device *slave_dev) 516 struct net_device *slave_dev)
517{ 517{
518 struct dsa_switch *ds = p->parent; 518 struct dsa_switch *ds = p->parent;
@@ -533,7 +533,7 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
533 ret = of_phy_register_fixed_link(port_dn); 533 ret = of_phy_register_fixed_link(port_dn);
534 if (ret) { 534 if (ret) {
535 netdev_err(slave_dev, "failed to register fixed PHY\n"); 535 netdev_err(slave_dev, "failed to register fixed PHY\n");
536 return; 536 return ret;
537 } 537 }
538 phy_is_fixed = true; 538 phy_is_fixed = true;
539 phy_dn = port_dn; 539 phy_dn = port_dn;
@@ -555,12 +555,17 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
555 */ 555 */
556 if (!p->phy) { 556 if (!p->phy) {
557 p->phy = ds->slave_mii_bus->phy_map[p->port]; 557 p->phy = ds->slave_mii_bus->phy_map[p->port];
558 if (!p->phy)
559 return -ENODEV;
560
558 phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, 561 phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
559 p->phy_interface); 562 p->phy_interface);
560 } else { 563 } else {
561 netdev_info(slave_dev, "attached PHY at address %d [%s]\n", 564 netdev_info(slave_dev, "attached PHY at address %d [%s]\n",
562 p->phy->addr, p->phy->drv->name); 565 p->phy->addr, p->phy->drv->name);
563 } 566 }
567
568 return 0;
564} 569}
565 570
566int dsa_slave_suspend(struct net_device *slave_dev) 571int dsa_slave_suspend(struct net_device *slave_dev)
@@ -653,12 +658,17 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
653 p->old_link = -1; 658 p->old_link = -1;
654 p->old_duplex = -1; 659 p->old_duplex = -1;
655 660
656 dsa_slave_phy_setup(p, slave_dev); 661 ret = dsa_slave_phy_setup(p, slave_dev);
662 if (ret) {
663 free_netdev(slave_dev);
664 return NULL;
665 }
657 666
658 ret = register_netdev(slave_dev); 667 ret = register_netdev(slave_dev);
659 if (ret) { 668 if (ret) {
660 netdev_err(master, "error %d registering interface %s\n", 669 netdev_err(master, "error %d registering interface %s\n",
661 ret, slave_dev->name); 670 ret, slave_dev->name);
671 phy_disconnect(p->phy);
662 free_netdev(slave_dev); 672 free_netdev(slave_dev);
663 return NULL; 673 return NULL;
664 } 674 }
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index e9cb2588e416..18bcaf2ff2fd 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1143,8 +1143,9 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
1143 put_child(tp, cindex, (struct rt_trie_node *)tn); 1143 put_child(tp, cindex, (struct rt_trie_node *)tn);
1144 } else { 1144 } else {
1145 rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn); 1145 rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn);
1146 tp = tn;
1147 } 1146 }
1147
1148 tp = tn;
1148 } 1149 }
1149 1150
1150 if (tp && tp->pos + tp->bits > 32) 1151 if (tp && tp->pos + tp->bits > 32)