Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev/usb Pull up following revision(s) (requested by r...



details:   https://anonhg.NetBSD.org/src/rev/20b7a3b17a98
branches:  netbsd-9
changeset: 1000780:20b7a3b17a98
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Sep 01 14:03:02 2019 +0000

description:
Pull up following revision(s) (requested by rin in ticket #146):

        sys/arch/arm/conf/Makefile.arm: revision 1.50
        sys/dev/usb/if_axe.c: revision 1.120

PR kern/54486

Workaround for alignment faults on ARMv6+, at least occur with
axe(4) and athn(4) drivers.

For ARMv6+, unaligned access is enabled by default. However, it
cannot be used for non-cacheable memory, which is used as DMA
buffers. This results in alignment faults above. A real fix is
to use cacheable memory as DMA buffers. However, it breaks some
drivers, awge(4) and vchiq(4) at least.

Until we figure out problems and fix them, we choose a fail-safe
workaround here; forbid unaligned memory access for whole kernel.
Affects on performance is negligibly small as far as we can see.

XXX
pullup netbsd-9

 -

PR kern/54486
Revert workaround introduced in rev 1.94:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/usb/if_axe.c#rev1.94

This is a problem specific to ARMv6+, and addressed by
arch/arm/conf/Makefile.arm rev 1.50:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/arm/conf/Makefile.arm#rev1.50

XXX
pullup netbsd-9

diffstat:

 sys/arch/arm/conf/Makefile.arm |  22 +++++++++++++++++++++-
 sys/dev/usb/if_axe.c           |  15 ++-------------
 2 files changed, 23 insertions(+), 14 deletions(-)

diffs (73 lines):

diff -r 8b041641e195 -r 20b7a3b17a98 sys/arch/arm/conf/Makefile.arm
--- a/sys/arch/arm/conf/Makefile.arm    Sun Sep 01 14:00:13 2019 +0000
+++ b/sys/arch/arm/conf/Makefile.arm    Sun Sep 01 14:03:02 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.arm,v 1.49 2018/09/22 12:24:01 rin Exp $
+#      $NetBSD: Makefile.arm,v 1.49.4.1 2019/09/01 14:03:02 martin Exp $
 
 # Makefile for NetBSD
 #
@@ -53,6 +53,26 @@
 CPPFLAGS.cpufunc_asm_arm11.S+= -mcpu=arm1136j-s
 CPPFLAGS.cpufunc_asm_xscale.S+=        -mcpu=xscale
 
+.if !empty(MACHINE_ARCH:Mearmv6*) || !empty(MACHINE_ARCH:Mearmv7*)
+# XXX
+#
+# Workaround for alignment faults on ARMv6+, at least occur with
+# axe(4) and athn(4) drivers.
+#
+# For ARMv6+, unaligned access is enabled by default. However, it
+# cannot be used for non-cacheable memory, which is used as DMA
+# buffers. This results in alignment faults above. A real fix is
+# to use cacheable memory as DMA buffers. However, it breaks some
+# drivers, awge(4) and vchiq(4) at least.
+#
+# Until we figure out problems and fix them, we choose a fail-safe
+# workaround here; forbid unaligned memory access for whole kernel.
+# Affects on performance is negligibly small as far as we can see.
+#
+# See PR kern/54486 for more details.
+CFLAGS+=       -mno-unaligned-access
+.endif
+
 ##
 ## (3) libkern and compat
 ##
diff -r 8b041641e195 -r 20b7a3b17a98 sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c      Sun Sep 01 14:00:13 2019 +0000
+++ b/sys/dev/usb/if_axe.c      Sun Sep 01 14:03:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axe.c,v 1.102.2.1 2019/09/01 13:00:36 martin Exp $  */
+/*     $NetBSD: if_axe.c,v 1.102.2.2 2019/09/01 14:03:02 martin Exp $  */
 /*     $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
 
 /*
@@ -87,7 +87,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.102.2.1 2019/09/01 13:00:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.102.2.2 2019/09/01 14:03:02 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1038,18 +1038,7 @@
                                break;
                        }
 
-#if !defined(__NO_STRICT_ALIGNMENT) && __GNUC_PREREQ__(6, 1)
-                       /*
-                        * XXX hdr is 2-byte aligned in buf, not 4-byte.
-                        * For some architectures, __builtin_memcpy() of
-                        * GCC 6 attempts to copy sizeof(hdr) = 4 bytes
-                        * at onece, which results in alignment error.
-                        */
-                       hdr.len = *(uint16_t *)buf;
-                       hdr.ilen = *(uint16_t *)(buf + sizeof(uint16_t));
-#else
                        memcpy(&hdr, buf, sizeof(hdr));
-#endif
 
                        DPRINTFN(20, "total_len %#jx len %jx ilen %#jx",
                            total_len,



Home | Main Index | Thread Index | Old Index