Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Add 40bit DMA bug workaround(BGEF_40BIT_BUG) fro...



details:   https://anonhg.NetBSD.org/src/rev/c380b9f29fe4
branches:  trunk
changeset: 791017:c380b9f29fe4
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Oct 31 06:01:39 2013 +0000

description:
Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD (part of r199670).
This workaround is for 5714/5715 controllers and is not actually a MAC
controller bug but an issue with the embedded PCIe to PCI-X bridge in the
device.
 This change uses bus_dmatag_subregion(), so this workaround won't work on some
archs which doesn't support bus_dmatag_subregion().

diffstat:

 sys/dev/pci/if_bge.c    |  28 ++++++++++++++++++++++++++--
 sys/dev/pci/if_bgereg.h |   3 ++-
 2 files changed, 28 insertions(+), 3 deletions(-)

diffs (73 lines):

diff -r 91bfa66eeffc -r c380b9f29fe4 sys/dev/pci/if_bge.c
--- a/sys/dev/pci/if_bge.c      Thu Oct 31 04:26:40 2013 +0000
+++ b/sys/dev/pci/if_bge.c      Thu Oct 31 06:01:39 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bge.c,v 1.261 2013/10/31 04:26:40 msaitoh Exp $     */
+/*     $NetBSD: if_bge.c,v 1.262 2013/10/31 06:01:39 msaitoh Exp $     */
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.261 2013/10/31 04:26:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.262 2013/10/31 06:01:39 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -3469,6 +3469,14 @@
                break;
        }
 
+       /*
+        * The 40bit DMA bug applies to the 5714/5715 controllers and is
+        * not actually a MAC controller bug but an issue with the embedded
+        * PCIe to PCI-X bridge in the device. Use 40bit DMA workaround.
+        */
+       if (BGE_IS_5714_FAMILY(sc) && ((sc->bge_flags & BGEF_PCIX) != 0))
+               sc->bge_flags |= BGEF_40BIT_BUG;
+
        /* Chips with APE need BAR2 access for APE registers/memory. */
        if ((sc->bge_flags & BGEF_APE) != 0) {
                memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, BGE_PCI_BAR2);
@@ -3715,6 +3723,22 @@
                sc->bge_dmatag = pa->pa_dmat64;
        else
                sc->bge_dmatag = pa->pa_dmat;
+
+       /* 40bit DMA workaround */
+       if (sizeof(bus_addr_t) > 4) {
+               if ((sc->bge_flags & BGEF_40BIT_BUG) != 0) {
+                       bus_dma_tag_t olddmatag = sc->bge_dmatag; /* save */
+
+                       if (bus_dmatag_subregion(olddmatag, 0,
+                               (bus_addr_t)(1ULL << 40), &(sc->bge_dmatag),
+                               BUS_DMA_NOWAIT) != 0) {
+                               aprint_error_dev(self,
+                                   "WARNING: failed to restrict dma range,"
+                                   " falling back to parent bus dma range\n");
+                               sc->bge_dmatag = olddmatag;
+                       }
+               }
+       }
        DPRINTFN(5, ("bus_dmamem_alloc\n"));
        if (bus_dmamem_alloc(sc->bge_dmatag, sizeof(struct bge_ring_data),
                             PAGE_SIZE, 0, &sc->bge_ring_seg, 1,
diff -r 91bfa66eeffc -r c380b9f29fe4 sys/dev/pci/if_bgereg.h
--- a/sys/dev/pci/if_bgereg.h   Thu Oct 31 04:26:40 2013 +0000
+++ b/sys/dev/pci/if_bgereg.h   Thu Oct 31 06:01:39 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bgereg.h,v 1.85 2013/10/31 04:26:40 msaitoh Exp $   */
+/*     $NetBSD: if_bgereg.h,v 1.86 2013/10/31 06:01:39 msaitoh Exp $   */
 /*
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2001
@@ -2627,6 +2627,7 @@
 #define        BGEF_5717_PLUS          0x00020000
 #define        BGEF_57765_FAMILY       0x00040000
 #define        BGEF_57765_PLUS         0x00080000
+#define BGEF_40BIT_BUG         0x00100000
 #define BGEF_RX_ALIGNBUG       0x00800000
 #define BGEF_TXRING_VALID      0x20000000
 #define BGEF_RXRING_VALID      0x40000000



Home | Main Index | Thread Index | Old Index