CVS commit: src/sys/external/bsd/drm2/radeon

2019-11-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Nov  6 07:31:20 UTC 2019

Modified Files:
src/sys/external/bsd/drm2/radeon: radeondrmkmsfb.c

Log Message:
remove stray ;


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/drm2/radeon/radeondrmkmsfb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/radeon/radeondrmkmsfb.c
diff -u src/sys/external/bsd/drm2/radeon/radeondrmkmsfb.c:1.12 src/sys/external/bsd/drm2/radeon/radeondrmkmsfb.c:1.13
--- src/sys/external/bsd/drm2/radeon/radeondrmkmsfb.c:1.12	Fri May 31 03:41:32 2019
+++ src/sys/external/bsd/drm2/radeon/radeondrmkmsfb.c	Wed Nov  6 07:31:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeondrmkmsfb.c,v 1.12 2019/05/31 03:41:32 maya Exp $	*/
+/*	$NetBSD: radeondrmkmsfb.c,v 1.13 2019/11/06 07:31:20 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeondrmkmsfb.c,v 1.12 2019/05/31 03:41:32 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeondrmkmsfb.c,v 1.13 2019/11/06 07:31:20 mrg Exp $");
 
 #include 
 #include 
@@ -119,7 +119,6 @@ radeonfb_detach(device_t self, int flags
 
 	if (sc->sc_scheduled)
 		return EBUSY;
-;
 
 	if (sc->sc_attached) {
 		pmf_device_deregister(self);



CVS commit: src/sys/dev/usb

2019-11-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Nov  6 07:30:59 UTC 2019

Modified Files:
src/sys/dev/usb: usbnet.c

Log Message:
add a note about ifnet lock vs usbnet locks.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/usb/usbnet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/external/bsd/drm2/radeon

2019-11-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Nov  6 07:31:20 UTC 2019

Modified Files:
src/sys/external/bsd/drm2/radeon: radeondrmkmsfb.c

Log Message:
remove stray ;


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/drm2/radeon/radeondrmkmsfb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2019-11-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Nov  6 07:30:59 UTC 2019

Modified Files:
src/sys/dev/usb: usbnet.c

Log Message:
add a note about ifnet lock vs usbnet locks.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/usb/usbnet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.29 src/sys/dev/usb/usbnet.c:1.30
--- src/sys/dev/usb/usbnet.c:1.29	Fri Sep 13 07:55:07 2019
+++ src/sys/dev/usb/usbnet.c	Wed Nov  6 07:30:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.29 2019/09/13 07:55:07 msaitoh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.30 2019/11/06 07:30:59 mrg Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.29 2019/09/13 07:55:07 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.30 2019/11/06 07:30:59 mrg Exp $");
 
 #include 
 #include 
@@ -64,6 +64,8 @@ struct usbnet_private {
 	 *	ifnet lock -> unp_lock -> unp_rxlock -> unp_txlock
 	 *  unp_lock -> unp_miilock
 	 * and unp_lock may be dropped after taking unp_miilock.
+	 * - ifnet lock is not needed for unp_lock, but if ifnet lock is
+	 *   involved, it must be taken first
 	 */
 	kmutex_t		unp_lock;
 	kmutex_t		unp_miilock;



CVS commit: src/sbin/savecore

2019-11-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Nov  6 07:29:08 UTC 2019

Modified Files:
src/sbin/savecore: savecore.c

Log Message:
elide recently introduced warnings that trigger in normal cases, eg:

savecore: dump_exists:471: kvm_read newdumpmag: _kvm_kvatop(8180030c)


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sbin/savecore/savecore.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/savecore/savecore.c
diff -u src/sbin/savecore/savecore.c:1.88 src/sbin/savecore/savecore.c:1.89
--- src/sbin/savecore/savecore.c:1.88	Thu Dec 27 21:25:46 2018
+++ src/sbin/savecore/savecore.c	Wed Nov  6 07:29:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: savecore.c,v 1.88 2018/12/27 21:25:46 mrg Exp $	*/
+/*	$NetBSD: savecore.c,v 1.89 2019/11/06 07:29:08 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1986, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1986, 19
 #if 0
 static char sccsid[] = "@(#)savecore.c	8.5 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: savecore.c,v 1.88 2018/12/27 21:25:46 mrg Exp $");
+__RCSID("$NetBSD: savecore.c,v 1.89 2019/11/06 07:29:08 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -74,11 +74,17 @@ __RCSID("$NetBSD: savecore.c,v 1.88 2018
 extern FILE *zopen(const char *fname, const char *mode);
 
 /*
- * Note that KREAD_LOGWARN takes a variable name, not pointer to it, unlike
- * KREAD() itself.
+ * Note that KREAD_LOGWARN and KREAD_ERR take a variable name, not
+ * pointer to it, unlike KREAD() itself.
  */
 #define	KREAD(kd, addr, p)\
 	(kvm_read(kd, addr, (char *)(p), sizeof(*(p))) != sizeof(*(p)))
+#define KREAD_ERR(kd, addr, p, err)	\
+do {	\
+	if (KREAD(kd, addr, &(p)) != 0) {\
+		err;			\
+	}\
+} while (0) 
 #define KREAD_LOGWARN(kd, addr, p, err)	\
 do {	\
 	if (KREAD(kd, addr, &(p)) != 0) {\
@@ -468,8 +474,8 @@ dump_exists(int verbose)
 	u_int32_t newdumpmag;
 
 	/* Read the dump magic and size. */
-	KREAD_LOGWARN(kd_dump, dump_nl[X_DUMPMAG].n_value, newdumpmag, return 0);
-	KREAD_LOGWARN(kd_dump, dump_nl[X_DUMPSIZE].n_value, dumpsize, return 0);
+	KREAD_ERR(kd_dump, dump_nl[X_DUMPMAG].n_value, newdumpmag, return 0);
+	KREAD_ERR(kd_dump, dump_nl[X_DUMPSIZE].n_value, dumpsize, return 0);
 
 	dumpbytes = (off_t)dumpsize * getpagesize();
 



CVS commit: src/sbin/savecore

2019-11-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Nov  6 07:29:08 UTC 2019

Modified Files:
src/sbin/savecore: savecore.c

Log Message:
elide recently introduced warnings that trigger in normal cases, eg:

savecore: dump_exists:471: kvm_read newdumpmag: _kvm_kvatop(8180030c)


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sbin/savecore/savecore.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tools/gcc

2019-11-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Nov  6 07:26:31 UTC 2019

Modified Files:
src/tools/gcc: Makefile

Log Message:
add something to auto-detect when GCC has changed from gcc to gcc.old
or back and auto-cleandir tools/gcc.

based upon the code for PREVIOUSTOOLDIR in tools/Makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/tools/gcc/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tools/gcc/Makefile
diff -u src/tools/gcc/Makefile:1.96 src/tools/gcc/Makefile:1.97
--- src/tools/gcc/Makefile:1.96	Thu Oct 24 03:19:14 2019
+++ src/tools/gcc/Makefile	Wed Nov  6 07:26:31 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.96 2019/10/24 03:19:14 christos Exp $
+#	$NetBSD: Makefile,v 1.97 2019/11/06 07:26:31 mrg Exp $
 
 .include 
 
@@ -254,6 +254,27 @@ MKENV_BUILD_MAKE=cd .native && ${MKNATIV
 	true
 	@touch $@
 
+.if !defined(PREV_GCC)
+.  if exists(PREV_GCC)
+PREV_GCC!=	cat PREV_GCC
+.  else
+PREV_GCC=
+.  endif
+.endif
+
+CLEANFILES+=	PREV_GCC
+
+realall realdepend: .MAKE
+.if !empty(PREV_GCC) && "${PREV_GCC}" != "${EXTERNAL_GCC_SUBDIR}-${HAVE_GCC}"
+	@echo "*** WARNING: GCC has changed version?"
+	@echo "*** PREV_GCC '${PREV_GCC}'"
+	@echo "*** !=  EXTERNAL_GCC_SUBDIR-HAVE_GCC '${EXTERNAL_GCC_SUBDIR}-${HAVE_GCC}'"
+	@echo "*** Cleaning mis-matched tools/gcc"
+	rm -f PREV_GCC
+	(cd ${.CURDIR} && ${MAKE} cleandir)
+.endif
+	echo ${EXTERNAL_GCC_SUBDIR}-${HAVE_GCC} >PREV_GCC
+
 clean: clean.native
 clean.native:
 	-rm -r -f .native



CVS commit: src/tools/gcc

2019-11-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Nov  6 07:26:31 UTC 2019

Modified Files:
src/tools/gcc: Makefile

Log Message:
add something to auto-detect when GCC has changed from gcc to gcc.old
or back and auto-cleandir tools/gcc.

based upon the code for PREVIOUSTOOLDIR in tools/Makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/tools/gcc/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys

2019-11-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Nov  6 06:57:22 UTC 2019

Modified Files:
src/sys/arch/amd64/include: csan.h
src/sys/kern: subr_csan.c

Log Message:
Change kcsan_md_is_avail() to always return true; I was testing with
interrupts disabled as debugging. Change the delay/sample parameters
to have better fluidity.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amd64/include/csan.h
cvs rdiff -u -r1.1 -r1.2 src/sys/kern/subr_csan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/include/csan.h
diff -u src/sys/arch/amd64/include/csan.h:1.1 src/sys/arch/amd64/include/csan.h:1.2
--- src/sys/arch/amd64/include/csan.h:1.1	Tue Nov  5 20:19:17 2019
+++ src/sys/arch/amd64/include/csan.h	Wed Nov  6 06:57:22 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: csan.h,v 1.1 2019/11/05 20:19:17 maxv Exp $	*/
+/*	$NetBSD: csan.h,v 1.2 2019/11/06 06:57:22 maxv Exp $	*/
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 static inline bool
 kcsan_md_is_avail(void)
 {
-	return (x86_read_psl() & PSL_I) == 0;
+	return true;
 }
 
 static inline void

Index: src/sys/kern/subr_csan.c
diff -u src/sys/kern/subr_csan.c:1.1 src/sys/kern/subr_csan.c:1.2
--- src/sys/kern/subr_csan.c:1.1	Tue Nov  5 20:19:17 2019
+++ src/sys/kern/subr_csan.c	Wed Nov  6 06:57:22 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_csan.c,v 1.1 2019/11/05 20:19:17 maxv Exp $	*/
+/*	$NetBSD: subr_csan.c,v 1.2 2019/11/06 06:57:22 maxv Exp $	*/
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_csan.c,v 1.1 2019/11/05 20:19:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_csan.c,v 1.2 2019/11/06 06:57:22 maxv Exp $");
 
 #include "opt_kcsan.h"
 
@@ -69,8 +69,8 @@ static bool kcsan_enabled __read_mostly;
 
 #define __RET_ADDR	(uintptr_t)__builtin_return_address(0)
 
-#define KCSAN_NACCESSES	2000
-#define KCSAN_DELAY	1	/* 10 milliseconds */
+#define KCSAN_NACCESSES	1024
+#define KCSAN_DELAY	10	/* 10 microseconds */
 
 /* -- */
 



CVS commit: src/sys

2019-11-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Nov  6 06:57:22 UTC 2019

Modified Files:
src/sys/arch/amd64/include: csan.h
src/sys/kern: subr_csan.c

Log Message:
Change kcsan_md_is_avail() to always return true; I was testing with
interrupts disabled as debugging. Change the delay/sample parameters
to have better fluidity.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amd64/include/csan.h
cvs rdiff -u -r1.1 -r1.2 src/sys/kern/subr_csan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci/ixgbe

2019-11-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov  6 04:17:16 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe: ixv.c

Log Message:
ixv(4): disable RSS configuration on 82599 and X540 VFs.

Those VFs share their RSS configuration with PF and, thus,
they cannot be configured independently. From FreeBSD r354349.


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.139 src/sys/dev/pci/ixgbe/ixv.c:1.140
--- src/sys/dev/pci/ixgbe/ixv.c:1.139	Tue Oct  1 10:04:11 2019
+++ src/sys/dev/pci/ixgbe/ixv.c	Wed Nov  6 04:17:16 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.139 2019/10/01 10:04:11 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.140 2019/11/06 04:17:16 msaitoh Exp $*/
 
 /**
 
@@ -1920,7 +1920,8 @@ ixv_initialize_receive_units(struct adap
 			adapter->num_rx_desc - 1);
 	}
 
-	ixv_initialize_rss_mapping(adapter);
+	if (adapter->hw.mac.type >= ixgbe_mac_X550_vf)
+		ixv_initialize_rss_mapping(adapter);
 } /* ixv_initialize_receive_units */
 
 /



CVS commit: src/sys/dev/pci/ixgbe

2019-11-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov  6 04:17:16 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe: ixv.c

Log Message:
ixv(4): disable RSS configuration on 82599 and X540 VFs.

Those VFs share their RSS configuration with PF and, thus,
they cannot be configured independently. From FreeBSD r354349.


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/sunxi

2019-11-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  5 23:31:23 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_drm.c

Log Message:
Reserve enough memory at boot to support the drmfb buffer plus a 4K buffer
for Xorg.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_drm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_drm.c
diff -u src/sys/arch/arm/sunxi/sunxi_drm.c:1.7 src/sys/arch/arm/sunxi/sunxi_drm.c:1.8
--- src/sys/arch/arm/sunxi/sunxi_drm.c:1.7	Wed Feb  6 03:07:08 2019
+++ src/sys/arch/arm/sunxi/sunxi_drm.c	Tue Nov  5 23:31:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_drm.c,v 1.7 2019/02/06 03:07:08 jmcneill Exp $ */
+/* $NetBSD: sunxi_drm.c,v 1.8 2019/11/05 23:31:23 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.7 2019/02/06 03:07:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.8 2019/11/05 23:31:23 jmcneill Exp $");
 
 #include 
 #include 
@@ -50,6 +50,9 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,
 
 #include 
 
+#define	SUNXI_DRM_MAX_WIDTH	3840
+#define	SUNXI_DRM_MAX_HEIGHT	2160
+
 static TAILQ_HEAD(, sunxi_drm_endpoint) sunxi_drm_endpoints =
 TAILQ_HEAD_INITIALIZER(sunxi_drm_endpoints);
 
@@ -68,6 +71,7 @@ static int	sunxi_drm_match(device_t, cfd
 static void	sunxi_drm_attach(device_t, device_t, void *);
 
 static void	sunxi_drm_init(device_t);
+static vmem_t	*sunxi_drm_alloc_cma_pool(struct drm_device *, size_t);
 
 static int	sunxi_drm_set_busid(struct drm_device *, struct drm_master *);
 
@@ -176,6 +180,25 @@ sunxi_drm_init(device_t dev)
 	driver->date, sc->sc_ddev->primary->index);
 }
 
+static vmem_t *
+sunxi_drm_alloc_cma_pool(struct drm_device *ddev, size_t cma_size)
+{
+	struct sunxi_drm_softc * const sc = sunxi_drm_private(ddev);
+	bus_dma_segment_t segs[1];
+	int nsegs;
+	int error;
+
+	error = bus_dmamem_alloc(sc->sc_dmat, cma_size, PAGE_SIZE, 0,
+	segs, 1, , BUS_DMA_NOWAIT);
+	if (error) {
+		aprint_error_dev(sc->sc_dev, "couldn't allocate CMA pool\n");
+		return NULL;
+	}
+
+	return vmem_create("sunxidrm", segs[0].ds_addr, segs[0].ds_len,
+	PAGE_SIZE, NULL, NULL, NULL, 0, VM_SLEEP, IPL_NONE);
+}
+
 static int
 sunxi_drm_set_busid(struct drm_device *ddev, struct drm_master *master)
 {
@@ -280,6 +303,7 @@ sunxi_drm_fb_probe(struct drm_fb_helper 
 	struct sunxi_drm_framebuffer *sfb = to_sunxi_drm_framebuffer(helper->fb);
 	struct drm_framebuffer *fb = helper->fb;
 	struct sunxi_drmfb_attach_args sfa;
+	size_t cma_size;
 	int error;
 
 	const u_int width = sizes->surface_width;
@@ -288,6 +312,15 @@ sunxi_drm_fb_probe(struct drm_fb_helper 
 
 	const size_t size = roundup(height * pitch, PAGE_SIZE);
 
+	/* Reserve enough memory for the FB console plus a 4K plane, rounded to 1MB */
+	cma_size = size;
+	cma_size += (SUNXI_DRM_MAX_WIDTH * SUNXI_DRM_MAX_HEIGHT * 4);
+	cma_size = roundup(cma_size, 1024 * 1024);
+	sc->sc_ddev->cma_pool = sunxi_drm_alloc_cma_pool(sc->sc_ddev, cma_size);
+	if (sc->sc_ddev->cma_pool != NULL)
+		aprint_normal_dev(sc->sc_dev, "reserved %u MB DRAM for CMA\n",
+		(u_int)(cma_size / (1024 * 1024)));
+
 	sfb->obj = drm_gem_cma_create(ddev, size);
 	if (sfb->obj == NULL) {
 		DRM_ERROR("failed to allocate memory for framebuffer\n");
@@ -340,8 +373,8 @@ sunxi_drm_load(struct drm_device *ddev, 
 	drm_mode_config_init(ddev);
 	ddev->mode_config.min_width = 0;
 	ddev->mode_config.min_height = 0;
-	ddev->mode_config.max_width = 3840;
-	ddev->mode_config.max_height = 2160;
+	ddev->mode_config.max_width = SUNXI_DRM_MAX_WIDTH;
+	ddev->mode_config.max_height = SUNXI_DRM_MAX_HEIGHT;
 	ddev->mode_config.funcs = _drm_mode_config_funcs;
 
 	num_crtc = 0;



CVS commit: src/sys/arch/arm/sunxi

2019-11-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  5 23:31:23 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_drm.c

Log Message:
Reserve enough memory at boot to support the drmfb buffer plus a 4K buffer
for Xorg.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_drm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/external/bsd/drm2

2019-11-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  5 23:29:28 UTC 2019

Modified Files:
src/sys/external/bsd/drm2/dist/include/drm: drmP.h drm_gem_cma_helper.h
src/sys/external/bsd/drm2/drm: drm_gem_cma_helper.c
src/sys/external/bsd/drm2/include/drm: drm_os_netbsd.h

Log Message:
Add support for DRM GEM/CMA helpers using a driver provided vmem arena.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/external/bsd/drm2/dist/include/drm/drmP.h
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/include/drm/drm_gem_cma_helper.h
cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c
cvs rdiff -u -r1.14 -r1.15 \
src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2019-11-05 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Nov  5 22:22:42 UTC 2019

Modified Files:
src/lib/libc/tls: tls.c
src/libexec/ld.elf_so: tls.c

Log Message:
Use alignof and not size_t for platforms with non-natural base
alignments.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/tls/tls.c
cvs rdiff -u -r1.13 -r1.14 src/libexec/ld.elf_so/tls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/tls/tls.c
diff -u src/lib/libc/tls/tls.c:1.10 src/lib/libc/tls/tls.c:1.11
--- src/lib/libc/tls/tls.c:1.10	Mon Nov  4 12:45:10 2019
+++ src/lib/libc/tls/tls.c	Tue Nov  5 22:22:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.10 2019/11/04 12:45:10 joerg Exp $	*/
+/*	$NetBSD: tls.c,v 1.11 2019/11/05 22:22:42 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: tls.c,v 1.10 2019/11/04 12:45:10 joerg Exp $");
+__RCSID("$NetBSD: tls.c,v 1.11 2019/11/05 22:22:42 joerg Exp $");
 
 #include "namespace.h"
 
@@ -46,6 +46,7 @@ __RCSID("$NetBSD: tls.c,v 1.10 2019/11/0
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -85,7 +86,7 @@ _rtld_tls_allocate(void)
 
 	if (initial_thread_tcb == NULL) {
 #ifdef __HAVE_TLS_VARIANT_II
-		tls_size = roundup2(tls_size, sizeof(max_align_t));
+		tls_size = roundup2(tls_size, alignof(max_align_t));
 #endif
 		tls_allocation = tls_size + sizeof(*tcb);
 

Index: src/libexec/ld.elf_so/tls.c
diff -u src/libexec/ld.elf_so/tls.c:1.13 src/libexec/ld.elf_so/tls.c:1.14
--- src/libexec/ld.elf_so/tls.c:1.13	Mon Nov  4 12:45:10 2019
+++ src/libexec/ld.elf_so/tls.c	Tue Nov  5 22:22:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.13 2019/11/04 12:45:10 joerg Exp $	*/
+/*	$NetBSD: tls.c,v 1.14 2019/11/05 22:22:42 joerg Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,11 +29,12 @@
  */
 
 #include 
-__RCSID("$NetBSD: tls.c,v 1.13 2019/11/04 12:45:10 joerg Exp $");
+__RCSID("$NetBSD: tls.c,v 1.14 2019/11/05 22:22:42 joerg Exp $");
 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "debug.h"
@@ -100,7 +101,7 @@ _rtld_tls_initial_allocation(void)
 
 #ifndef __HAVE_TLS_VARIANT_I
 	_rtld_tls_static_space = roundup2(_rtld_tls_static_space,
-	sizeof(max_align_t));
+	alignof(max_align_t));
 #endif
 	dbg(("_rtld_tls_static_space %zu", _rtld_tls_static_space));
 



CVS commit: src

2019-11-05 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Nov  5 22:22:42 UTC 2019

Modified Files:
src/lib/libc/tls: tls.c
src/libexec/ld.elf_so: tls.c

Log Message:
Use alignof and not size_t for platforms with non-natural base
alignments.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/tls/tls.c
cvs rdiff -u -r1.13 -r1.14 src/libexec/ld.elf_so/tls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/share/man/man9

2019-11-05 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Tue Nov  5 22:19:43 UTC 2019

Modified Files:
src/share/man/man9: vmem.9

Log Message:
Fix typo: vmem_add(9) does not actually take an `addrp` argument.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/share/man/man9/vmem.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/vmem.9
diff -u src/share/man/man9/vmem.9:1.17 src/share/man/man9/vmem.9:1.18
--- src/share/man/man9/vmem.9:1.17	Mon Jul  3 21:28:48 2017
+++ src/share/man/man9/vmem.9	Tue Nov  5 22:19:43 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: vmem.9,v 1.17 2017/07/03 21:28:48 wiz Exp $
+.\"	$NetBSD: vmem.9,v 1.18 2019/11/05 22:19:43 dyoung Exp $
 .\"
 .\" Copyright (c)2006 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -25,7 +25,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" 
-.Dd February 28, 2016
+.Dd November 5, 2019
 .Dt VMEM 9
 .Os
 .\" 
@@ -52,7 +52,7 @@
 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 .Ft int
 .Fn vmem_add \
-"vmem_t *vm" "vmem_addr_t addr" "vmem_size_t size" "vm_flag_t flags" "vmem_addr_t *addrp"
+"vmem_t *vm" "vmem_addr_t addr" "vmem_size_t size" "vm_flag_t flags"
 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 .Ft int
 .Fn vmem_xalloc \



CVS commit: src/share/man/man9

2019-11-05 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Tue Nov  5 22:19:43 UTC 2019

Modified Files:
src/share/man/man9: vmem.9

Log Message:
Fix typo: vmem_add(9) does not actually take an `addrp` argument.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/share/man/man9/vmem.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src

2019-11-05 Thread Kamil Rytarowski
On 05.11.2019 22:08, m...@netbsd.org wrote:
> On Tue, Nov 05, 2019 at 09:01:06PM +, m...@netbsd.org wrote:
>> On Tue, Nov 05, 2019 at 08:19:18PM +, Maxime Villard wrote:
>>> Module Name:src
>>> Committed By:   maxv
>>> Date:   Tue Nov  5 20:19:18 UTC 2019
>>>
>>> Modified Files:
>>> src/share/mk: bsd.sys.mk
>>> src/sys/arch/amd64/amd64: machdep.c mptramp.S
>>> src/sys/arch/amd64/conf: GENERIC Makefile.amd64
>>> src/sys/arch/x86/x86: cpu.c
>>> src/sys/conf: files
>>> src/sys/kern: files.kern
>>> src/sys/lib/libkern: libkern.h
>>> src/sys/sys: atomic.h bus_proto.h cdefs.h systm.h
>>> Added Files:
>>> src/sys/arch/amd64/include: csan.h
>>> src/sys/kern: subr_csan.c
>>> src/sys/sys: csan.h
>>>
>>> Log Message:
>>> Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
>>> to detect race conditions at runtime. It is a variation of TSan that is
>>> easy to implement and more suited to kernel internals, albeit theoretically
>>> less precise than TSan's happens-before.
>>>
>>> We do basically two things:
>>>
>>>  - On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
>>>describing the access, and delay the calling CPU (10ms).
>>>
>>>  - On all memory accesses, we verify if the memory we're reading/writing
>>>is referenced in a cell already.
>>>
>>> The combination of the two means that, if for example cpu0 does a read that
>>> is selected and cpu1 does a write at the same address, kCSan will fire,
>>> because cpu1's write collides with cpu0's read cell.
>>>
>>> The coverage of the instrumentation is the same as that of kASan. Also, the
>>> code is organized in a way similar to kASan, so it is easy to add support
>>> for more architectures than amd64. kCSan is compatible with KCOV.
>>>
>>> Reviewed by Kamil.
>>>
>>
>> I don't understand how you can distinguish a race from this condition:
>>
>>  CPU0CPU1
>>
>>
>>  mutex_enter
>>  write (recorded to cell)
>>  mutex_exit
>>
>>  read (checked against record)
>>
>> Which is legitimate.^W
> would be if I used a mutex on CPU0, but the point still stands. :-)
> 

This sanitizer checks whether a violation is occurring now. TSan would
check whether it is possible and triggers false positives in the kernel.



signature.asc
Description: OpenPGP digital signature


Re: CVS commit: src

2019-11-05 Thread Maxime Villard

Le 05/11/2019 à 22:01, m...@netbsd.org a écrit :

On Tue, Nov 05, 2019 at 08:19:18PM +, Maxime Villard wrote:

Module Name:src
Committed By:   maxv
Date:   Tue Nov  5 20:19:18 UTC 2019

Modified Files:
src/share/mk: bsd.sys.mk
src/sys/arch/amd64/amd64: machdep.c mptramp.S
src/sys/arch/amd64/conf: GENERIC Makefile.amd64
src/sys/arch/x86/x86: cpu.c
src/sys/conf: files
src/sys/kern: files.kern
src/sys/lib/libkern: libkern.h
src/sys/sys: atomic.h bus_proto.h cdefs.h systm.h
Added Files:
src/sys/arch/amd64/include: csan.h
src/sys/kern: subr_csan.c
src/sys/sys: csan.h

Log Message:
Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

  - On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

  - On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.



I don't understand how you can distinguish a race from this condition:

CPU0CPU1


mutex_enter
write (recorded to cell)
mutex_exit

read (checked against record)

Which is legitimate.


When you "record", it remains recorded for 10ms, but it is then cleared
once the cpu continues execution. Ie, the "longevity" of the write above
is increased, and in that time period each access by another cpu will be
detected.

That's a watchpoint-based algorithm, different from the happens-before
algorithm, which is more powerful but also significantly more complicated
to implement in kernels (a lot of implicit synchronization, etc).


+   for (i = 0; i < ncpu; i++) {
+   __builtin_memcpy(, _cpus[i].cell, sizeof(old));
+
+   if (old.addr + old.size <= new.addr)
+   continue;
+   if (new.addr + new.size <= old.addr)
+   continue;
+   if (__predict_true(!old.write && !new.write))
+   continue;
+   if (__predict_true(kcsan_access_is_atomic(, )))
+   continue;
+
+   kcsan_report(, cpu_number(), , i);
+   break;
+   }

It looks like you are checking the current CPU too?


Yes, but that doesn't matter, since on the current CPU the cell is
cleared.


Re: CVS commit: src

2019-11-05 Thread maya
On Tue, Nov 05, 2019 at 09:01:06PM +, m...@netbsd.org wrote:
> On Tue, Nov 05, 2019 at 08:19:18PM +, Maxime Villard wrote:
> > Module Name:src
> > Committed By:   maxv
> > Date:   Tue Nov  5 20:19:18 UTC 2019
> > 
> > Modified Files:
> > src/share/mk: bsd.sys.mk
> > src/sys/arch/amd64/amd64: machdep.c mptramp.S
> > src/sys/arch/amd64/conf: GENERIC Makefile.amd64
> > src/sys/arch/x86/x86: cpu.c
> > src/sys/conf: files
> > src/sys/kern: files.kern
> > src/sys/lib/libkern: libkern.h
> > src/sys/sys: atomic.h bus_proto.h cdefs.h systm.h
> > Added Files:
> > src/sys/arch/amd64/include: csan.h
> > src/sys/kern: subr_csan.c
> > src/sys/sys: csan.h
> > 
> > Log Message:
> > Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
> > to detect race conditions at runtime. It is a variation of TSan that is
> > easy to implement and more suited to kernel internals, albeit theoretically
> > less precise than TSan's happens-before.
> > 
> > We do basically two things:
> > 
> >  - On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
> >describing the access, and delay the calling CPU (10ms).
> > 
> >  - On all memory accesses, we verify if the memory we're reading/writing
> >is referenced in a cell already.
> > 
> > The combination of the two means that, if for example cpu0 does a read that
> > is selected and cpu1 does a write at the same address, kCSan will fire,
> > because cpu1's write collides with cpu0's read cell.
> > 
> > The coverage of the instrumentation is the same as that of kASan. Also, the
> > code is organized in a way similar to kASan, so it is easy to add support
> > for more architectures than amd64. kCSan is compatible with KCOV.
> > 
> > Reviewed by Kamil.
> > 
> 
> I don't understand how you can distinguish a race from this condition:
> 
>   CPU0CPU1
> 
> 
>   mutex_enter
>   write (recorded to cell)
>   mutex_exit
> 
>   read (checked against record)
> 
> Which is legitimate.^W
would be if I used a mutex on CPU0, but the point still stands. :-)


Re: CVS commit: src

2019-11-05 Thread maya
On Tue, Nov 05, 2019 at 08:19:18PM +, Maxime Villard wrote:
> Module Name:  src
> Committed By: maxv
> Date: Tue Nov  5 20:19:18 UTC 2019
> 
> Modified Files:
>   src/share/mk: bsd.sys.mk
>   src/sys/arch/amd64/amd64: machdep.c mptramp.S
>   src/sys/arch/amd64/conf: GENERIC Makefile.amd64
>   src/sys/arch/x86/x86: cpu.c
>   src/sys/conf: files
>   src/sys/kern: files.kern
>   src/sys/lib/libkern: libkern.h
>   src/sys/sys: atomic.h bus_proto.h cdefs.h systm.h
> Added Files:
>   src/sys/arch/amd64/include: csan.h
>   src/sys/kern: subr_csan.c
>   src/sys/sys: csan.h
> 
> Log Message:
> Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
> to detect race conditions at runtime. It is a variation of TSan that is
> easy to implement and more suited to kernel internals, albeit theoretically
> less precise than TSan's happens-before.
> 
> We do basically two things:
> 
>  - On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
>describing the access, and delay the calling CPU (10ms).
> 
>  - On all memory accesses, we verify if the memory we're reading/writing
>is referenced in a cell already.
> 
> The combination of the two means that, if for example cpu0 does a read that
> is selected and cpu1 does a write at the same address, kCSan will fire,
> because cpu1's write collides with cpu0's read cell.
> 
> The coverage of the instrumentation is the same as that of kASan. Also, the
> code is organized in a way similar to kASan, so it is easy to add support
> for more architectures than amd64. kCSan is compatible with KCOV.
> 
> Reviewed by Kamil.
> 

I don't understand how you can distinguish a race from this condition:

CPU0CPU1


mutex_enter
write (recorded to cell)
mutex_exit

read (checked against record)

Which is legitimate.


+   for (i = 0; i < ncpu; i++) {
+   __builtin_memcpy(, _cpus[i].cell, sizeof(old));
+ 
+   if (old.addr + old.size <= new.addr)
+   continue;
+   if (new.addr + new.size <= old.addr)
+   continue;
+   if (__predict_true(!old.write && !new.write))
+   continue;
+   if (__predict_true(kcsan_access_is_atomic(, )))  
+   continue;
+   
+   kcsan_report(, cpu_number(), , i);
+   break;
+   }

It looks like you are checking the current CPU too?


CVS commit: src/doc

2019-11-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov  5 20:23:44 UTC 2019

Modified Files:
src/doc: CHANGES

Log Message:
Note kCSan.


To generate a diff of this commit:
cvs rdiff -u -r1.2608 -r1.2609 src/doc/CHANGES

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2608 src/doc/CHANGES:1.2609
--- src/doc/CHANGES:1.2608	Mon Nov  4 09:11:00 2019
+++ src/doc/CHANGES	Tue Nov  5 20:23:44 2019
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2608 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2609 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -69,3 +69,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 		[msaitoh 20191101]
 	evbarm: Update TI OMAP3 SoC support to use FDT based configuration.
 		[jmcneill 20191101]
+	amd64: Add support for kCSan - Kernel Concurrency Sanitizer.
+		[maxv 20191105]



CVS commit: src/doc

2019-11-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov  5 20:23:44 UTC 2019

Modified Files:
src/doc: CHANGES

Log Message:
Note kCSan.


To generate a diff of this commit:
cvs rdiff -u -r1.2608 -r1.2609 src/doc/CHANGES

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/x86/acpi

2019-11-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov  5 20:21:34 UTC 2019

Modified Files:
src/sys/arch/x86/acpi: acpi_cpu_md.c

Log Message:
Add the __nocsan attribute on this function. Races on ci_want_resched are
accepted (part of the design).


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/x86/acpi/acpi_cpu_md.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2019-11-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov  5 20:19:18 UTC 2019

Modified Files:
src/share/mk: bsd.sys.mk
src/sys/arch/amd64/amd64: machdep.c mptramp.S
src/sys/arch/amd64/conf: GENERIC Makefile.amd64
src/sys/arch/x86/x86: cpu.c
src/sys/conf: files
src/sys/kern: files.kern
src/sys/lib/libkern: libkern.h
src/sys/sys: atomic.h bus_proto.h cdefs.h systm.h
Added Files:
src/sys/arch/amd64/include: csan.h
src/sys/kern: subr_csan.c
src/sys/sys: csan.h

Log Message:
Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

 - On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
   describing the access, and delay the calling CPU (10ms).

 - On all memory accesses, we verify if the memory we're reading/writing
   is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/share/mk/bsd.sys.mk
cvs rdiff -u -r1.337 -r1.338 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/amd64/amd64/mptramp.S
cvs rdiff -u -r1.544 -r1.545 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/amd64/conf/Makefile.amd64
cvs rdiff -u -r0 -r1.1 src/sys/arch/amd64/include/csan.h
cvs rdiff -u -r1.173 -r1.174 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.1240 -r1.1241 src/sys/conf/files
cvs rdiff -u -r1.35 -r1.36 src/sys/kern/files.kern
cvs rdiff -u -r0 -r1.1 src/sys/kern/subr_csan.c
cvs rdiff -u -r1.132 -r1.133 src/sys/lib/libkern/libkern.h
cvs rdiff -u -r1.15 -r1.16 src/sys/sys/atomic.h
cvs rdiff -u -r1.9 -r1.10 src/sys/sys/bus_proto.h
cvs rdiff -u -r1.147 -r1.148 src/sys/sys/cdefs.h
cvs rdiff -u -r0 -r1.1 src/sys/sys/csan.h
cvs rdiff -u -r1.287 -r1.288 src/sys/sys/systm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/mk/bsd.sys.mk
diff -u src/share/mk/bsd.sys.mk:1.294 src/share/mk/bsd.sys.mk:1.295
--- src/share/mk/bsd.sys.mk:1.294	Tue Oct 15 15:05:00 2019
+++ src/share/mk/bsd.sys.mk	Tue Nov  5 20:19:17 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.sys.mk,v 1.294 2019/10/15 15:05:00 christos Exp $
+#	$NetBSD: bsd.sys.mk,v 1.295 2019/11/05 20:19:17 maxv Exp $
 #
 # Build definitions used for NetBSD source tree builds.
 
@@ -246,7 +246,8 @@ CFLAGS+=	${KLEAKFLAGS.${.IMPSRC:T}:U${KL
 
 .if ${KCOV:U0} > 0
 KCOVFLAGS=	-fsanitize-coverage=trace-pc
-.for f in subr_kcov.c subr_lwp_specificdata.c subr_specificdata.c subr_asan.c
+.for f in subr_kcov.c subr_lwp_specificdata.c subr_specificdata.c subr_asan.c \
+	subr_csan.c
 KCOVFLAGS.${f}=		# empty
 .endfor
 CFLAGS+=	${KCOVFLAGS.${.IMPSRC:T}:U${KCOVFLAGS}}

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.337 src/sys/arch/amd64/amd64/machdep.c:1.338
--- src/sys/arch/amd64/amd64/machdep.c:1.337	Sat Oct 12 06:31:03 2019
+++ src/sys/arch/amd64/amd64/machdep.c	Tue Nov  5 20:19:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.337 2019/10/12 06:31:03 maxv Exp $	*/
+/*	$NetBSD: machdep.c,v 1.338 2019/11/05 20:19:17 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.337 2019/10/12 06:31:03 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.338 2019/11/05 20:19:17 maxv Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -152,6 +152,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 #include 
 #include 
+#include 
 
 #ifdef KGDB
 #include 
@@ -1761,6 +1762,7 @@ init_x86_64(paddr_t first_avail)
 #ifdef KASAN
 	kasan_init();
 #endif
+	kcsan_init();
 
 	pmap_growkernel(VM_MIN_KERNEL_ADDRESS + 32 * 1024 * 1024);
 

Index: src/sys/arch/amd64/amd64/mptramp.S
diff -u src/sys/arch/amd64/amd64/mptramp.S:1.26 src/sys/arch/amd64/amd64/mptramp.S:1.27
--- src/sys/arch/amd64/amd64/mptramp.S:1.26	Sun Nov 26 14:54:43 2017
+++ src/sys/arch/amd64/amd64/mptramp.S	Tue Nov  5 20:19:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mptramp.S,v 1.26 2017/11/26 14:54:43 maxv Exp $	*/
+/*	$NetBSD: mptramp.S,v 1.27 2019/11/05 20:19:17 maxv Exp $	*/
 
 /*
  * Copyright (c) 2000, 2016 The NetBSD Foundation, Inc.
@@ -75,6 +75,7 @@
  */
 
 #include "assym.h"
+#include "opt_kcsan.h"
 #include 
 #include 
 #include 
@@ 

CVS commit: src

2019-11-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov  5 20:19:18 UTC 2019

Modified Files:
src/share/mk: bsd.sys.mk
src/sys/arch/amd64/amd64: machdep.c mptramp.S
src/sys/arch/amd64/conf: GENERIC Makefile.amd64
src/sys/arch/x86/x86: cpu.c
src/sys/conf: files
src/sys/kern: files.kern
src/sys/lib/libkern: libkern.h
src/sys/sys: atomic.h bus_proto.h cdefs.h systm.h
Added Files:
src/sys/arch/amd64/include: csan.h
src/sys/kern: subr_csan.c
src/sys/sys: csan.h

Log Message:
Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

 - On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
   describing the access, and delay the calling CPU (10ms).

 - On all memory accesses, we verify if the memory we're reading/writing
   is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/share/mk/bsd.sys.mk
cvs rdiff -u -r1.337 -r1.338 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/amd64/amd64/mptramp.S
cvs rdiff -u -r1.544 -r1.545 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/amd64/conf/Makefile.amd64
cvs rdiff -u -r0 -r1.1 src/sys/arch/amd64/include/csan.h
cvs rdiff -u -r1.173 -r1.174 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.1240 -r1.1241 src/sys/conf/files
cvs rdiff -u -r1.35 -r1.36 src/sys/kern/files.kern
cvs rdiff -u -r0 -r1.1 src/sys/kern/subr_csan.c
cvs rdiff -u -r1.132 -r1.133 src/sys/lib/libkern/libkern.h
cvs rdiff -u -r1.15 -r1.16 src/sys/sys/atomic.h
cvs rdiff -u -r1.9 -r1.10 src/sys/sys/bus_proto.h
cvs rdiff -u -r1.147 -r1.148 src/sys/sys/cdefs.h
cvs rdiff -u -r0 -r1.1 src/sys/sys/csan.h
cvs rdiff -u -r1.287 -r1.288 src/sys/sys/systm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/gpl3/gcc

2019-11-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov  5 20:07:21 UTC 2019

Modified Files:
src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64:
backtrace-supported.h config.h
src/external/gpl3/gcc/lib/libgcc/arch/powerpc64: auto-target.h defs.mk
src/external/gpl3/gcc/lib/libgcc/libgcov/arch/powerpc64: gcov-iov.h
src/external/gpl3/gcc/lib/libgomp/arch/powerpc64: libgomp_f.h omp.h
src/external/gpl3/gcc/lib/libiberty: defs.mk
src/external/gpl3/gcc/lib/libiberty/arch/powerpc64: config.h
src/external/gpl3/gcc/lib/libobjc/arch/powerpc64: defs.mk
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64: c++config.h
cxxabi_tweaks.h defs.mk gstdint.h symver-config.h
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64: auto-host.h
bversion.h configargs.h defs.mk gtyp-input.list insn-modes.h
plugin-version.h tm.h
src/external/gpl3/gcc/usr.bin/include/arch: powerpc64.mk
src/external/gpl3/gcc/usr.bin/libcpp/arch/powerpc64: config.h

Log Message:
regen powerpc64


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/backtrace-supported.h
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/config.h
cvs rdiff -u -r1.5 -r1.6 \
src/external/gpl3/gcc/lib/libgcc/arch/powerpc64/auto-target.h
cvs rdiff -u -r1.9 -r1.10 \
src/external/gpl3/gcc/lib/libgcc/arch/powerpc64/defs.mk
cvs rdiff -u -r1.9 -r1.10 \
src/external/gpl3/gcc/lib/libgcc/libgcov/arch/powerpc64/gcov-iov.h
cvs rdiff -u -r1.5 -r1.6 \
src/external/gpl3/gcc/lib/libgomp/arch/powerpc64/libgomp_f.h
cvs rdiff -u -r1.6 -r1.7 \
src/external/gpl3/gcc/lib/libgomp/arch/powerpc64/omp.h
cvs rdiff -u -r1.22 -r1.23 src/external/gpl3/gcc/lib/libiberty/defs.mk
cvs rdiff -u -r1.4 -r1.5 \
src/external/gpl3/gcc/lib/libiberty/arch/powerpc64/config.h
cvs rdiff -u -r1.4 -r1.5 \
src/external/gpl3/gcc/lib/libobjc/arch/powerpc64/defs.mk
cvs rdiff -u -r1.18 -r1.19 \
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h
cvs rdiff -u -r1.5 -r1.6 \
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/cxxabi_tweaks.h
cvs rdiff -u -r1.11 -r1.12 \
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/defs.mk
cvs rdiff -u -r1.13 -r1.14 \
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/gstdint.h
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/symver-config.h
cvs rdiff -u -r1.13 -r1.14 \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/auto-host.h \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/defs.mk
cvs rdiff -u -r1.8 -r1.9 \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/bversion.h \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/plugin-version.h
cvs rdiff -u -r1.19 -r1.20 \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/configargs.h
cvs rdiff -u -r1.9 -r1.10 \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/gtyp-input.list \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/tm.h
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/insn-modes.h
cvs rdiff -u -r1.1 -r1.2 \
src/external/gpl3/gcc/usr.bin/include/arch/powerpc64.mk
cvs rdiff -u -r1.6 -r1.7 \
src/external/gpl3/gcc/usr.bin/libcpp/arch/powerpc64/config.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/backtrace-supported.h
diff -u src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/backtrace-supported.h:1.5 src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/backtrace-supported.h:1.6
--- src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/backtrace-supported.h:1.5	Tue Feb  5 07:01:43 2019
+++ src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/backtrace-supported.h	Tue Nov  5 15:07:20 2019
@@ -1,9 +1,9 @@
 /* This file is automatically generated.  DO NOT EDIT! */
-/* Generated from: NetBSD: mknative-gcc,v 1.99 2019/02/04 01:46:59 mrg Exp  */
+/* Generated from: NetBSD: mknative-gcc,v 1.103 2019/10/24 03:19:14 christos Exp  */
 /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
 
 /* backtrace-supported.h.in -- Whether stack backtrace is supported.
-   Copyright (C) 2012-2017 Free Software Foundation, Inc.
+   Copyright (C) 2012-2018 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
 
 Redistribution and use in source and binary forms, with or without

Index: src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/config.h
diff -u src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/config.h:1.3 src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/config.h:1.4
--- src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/config.h:1.3	Thu Jun  9 19:30:18 2016
+++ src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/config.h	Tue 

CVS commit: src/external/gpl3/gcc/dist/gcc/config/rs6000

2019-11-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov  5 20:06:41 UTC 2019

Modified Files:
src/external/gpl3/gcc/dist/gcc/config/rs6000: netbsd64.h

Log Message:
- Use EXTRA_SPECS like we did for aarch64 instead of SUBSUBTARGET_EXTRA_SPECS
  so that assembly specs get propagated (they were lost before)
- adjust the block register padding (like the other OS's) so that code compiles
- XXX: linker still broken for shared libraries because the os specific spec
  is not chosen


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 \
src/external/gpl3/gcc/dist/gcc/config/rs6000/netbsd64.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/gpl3/gcc

2019-11-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov  5 20:07:21 UTC 2019

Modified Files:
src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64:
backtrace-supported.h config.h
src/external/gpl3/gcc/lib/libgcc/arch/powerpc64: auto-target.h defs.mk
src/external/gpl3/gcc/lib/libgcc/libgcov/arch/powerpc64: gcov-iov.h
src/external/gpl3/gcc/lib/libgomp/arch/powerpc64: libgomp_f.h omp.h
src/external/gpl3/gcc/lib/libiberty: defs.mk
src/external/gpl3/gcc/lib/libiberty/arch/powerpc64: config.h
src/external/gpl3/gcc/lib/libobjc/arch/powerpc64: defs.mk
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64: c++config.h
cxxabi_tweaks.h defs.mk gstdint.h symver-config.h
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64: auto-host.h
bversion.h configargs.h defs.mk gtyp-input.list insn-modes.h
plugin-version.h tm.h
src/external/gpl3/gcc/usr.bin/include/arch: powerpc64.mk
src/external/gpl3/gcc/usr.bin/libcpp/arch/powerpc64: config.h

Log Message:
regen powerpc64


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/backtrace-supported.h
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libbacktrace/arch/powerpc64/config.h
cvs rdiff -u -r1.5 -r1.6 \
src/external/gpl3/gcc/lib/libgcc/arch/powerpc64/auto-target.h
cvs rdiff -u -r1.9 -r1.10 \
src/external/gpl3/gcc/lib/libgcc/arch/powerpc64/defs.mk
cvs rdiff -u -r1.9 -r1.10 \
src/external/gpl3/gcc/lib/libgcc/libgcov/arch/powerpc64/gcov-iov.h
cvs rdiff -u -r1.5 -r1.6 \
src/external/gpl3/gcc/lib/libgomp/arch/powerpc64/libgomp_f.h
cvs rdiff -u -r1.6 -r1.7 \
src/external/gpl3/gcc/lib/libgomp/arch/powerpc64/omp.h
cvs rdiff -u -r1.22 -r1.23 src/external/gpl3/gcc/lib/libiberty/defs.mk
cvs rdiff -u -r1.4 -r1.5 \
src/external/gpl3/gcc/lib/libiberty/arch/powerpc64/config.h
cvs rdiff -u -r1.4 -r1.5 \
src/external/gpl3/gcc/lib/libobjc/arch/powerpc64/defs.mk
cvs rdiff -u -r1.18 -r1.19 \
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h
cvs rdiff -u -r1.5 -r1.6 \
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/cxxabi_tweaks.h
cvs rdiff -u -r1.11 -r1.12 \
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/defs.mk
cvs rdiff -u -r1.13 -r1.14 \
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/gstdint.h
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/symver-config.h
cvs rdiff -u -r1.13 -r1.14 \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/auto-host.h \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/defs.mk
cvs rdiff -u -r1.8 -r1.9 \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/bversion.h \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/plugin-version.h
cvs rdiff -u -r1.19 -r1.20 \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/configargs.h
cvs rdiff -u -r1.9 -r1.10 \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/gtyp-input.list \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/tm.h
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/insn-modes.h
cvs rdiff -u -r1.1 -r1.2 \
src/external/gpl3/gcc/usr.bin/include/arch/powerpc64.mk
cvs rdiff -u -r1.6 -r1.7 \
src/external/gpl3/gcc/usr.bin/libcpp/arch/powerpc64/config.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/gpl3/gcc/dist/gcc/config/rs6000

2019-11-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov  5 20:06:41 UTC 2019

Modified Files:
src/external/gpl3/gcc/dist/gcc/config/rs6000: netbsd64.h

Log Message:
- Use EXTRA_SPECS like we did for aarch64 instead of SUBSUBTARGET_EXTRA_SPECS
  so that assembly specs get propagated (they were lost before)
- adjust the block register padding (like the other OS's) so that code compiles
- XXX: linker still broken for shared libraries because the os specific spec
  is not chosen


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 \
src/external/gpl3/gcc/dist/gcc/config/rs6000/netbsd64.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc/dist/gcc/config/rs6000/netbsd64.h
diff -u src/external/gpl3/gcc/dist/gcc/config/rs6000/netbsd64.h:1.23 src/external/gpl3/gcc/dist/gcc/config/rs6000/netbsd64.h:1.24
--- src/external/gpl3/gcc/dist/gcc/config/rs6000/netbsd64.h:1.23	Fri May 10 22:37:58 2019
+++ src/external/gpl3/gcc/dist/gcc/config/rs6000/netbsd64.h	Tue Nov  5 15:06:41 2019
@@ -204,8 +204,8 @@ extern int dot_symbols;
 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \
   ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
 
-#undef	SUBSUBTARGET_EXTRA_SPECS
-#define SUBSUBTARGET_EXTRA_SPECS \
+#undef	EXTRA_SPECS
+#define EXTRA_SPECS \
   { "asm_spec_common",		ASM_SPEC_COMMON },			\
   { "asm_spec32",		ASM_SPEC32 },\
   { "asm_spec64",		ASM_SPEC64 },\
@@ -296,7 +296,7 @@ extern int dot_symbols;
registers and memory.  FIRST is nonzero if this is the only
element.  */
 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
-  (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
+  (!(FIRST) ? PAD_UPWARD : targetm.calls.function_arg_padding (MODE, TYPE))
 
 /* NetBSD doesn't support saving and restoring 64-bit regs in a 32-bit
process.  */



CVS commit: src/sys/dev/i2c

2019-11-05 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Nov  5 19:59:35 UTC 2019

Modified Files:
src/sys/dev/i2c: ssdfb_i2c.c

Log Message:
ssdfb: fix i2c transfer error with some controllers

If the controller doesn't support the full 128 byte transfer size we need,
then split the write across multiple transactions.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/ssdfb_i2c.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/i2c

2019-11-05 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Nov  5 19:59:35 UTC 2019

Modified Files:
src/sys/dev/i2c: ssdfb_i2c.c

Log Message:
ssdfb: fix i2c transfer error with some controllers

If the controller doesn't support the full 128 byte transfer size we need,
then split the write across multiple transactions.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/ssdfb_i2c.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/ssdfb_i2c.c
diff -u src/sys/dev/i2c/ssdfb_i2c.c:1.4 src/sys/dev/i2c/ssdfb_i2c.c:1.5
--- src/sys/dev/i2c/ssdfb_i2c.c:1.4	Sat Nov  2 14:23:59 2019
+++ src/sys/dev/i2c/ssdfb_i2c.c	Tue Nov  5 19:59:35 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb_i2c.c,v 1.4 2019/11/02 14:23:59 tnn Exp $ */
+/* $NetBSD: ssdfb_i2c.c,v 1.5 2019/11/05 19:59:35 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.4 2019/11/02 14:23:59 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.5 2019/11/05 19:59:35 tnn Exp $");
 
 #include 
 #include 
@@ -43,12 +43,16 @@ struct ssdfb_i2c_softc {
 	struct		ssdfb_softc sc;
 	i2c_tag_t	sc_i2c_tag;
 	i2c_addr_t	sc_i2c_addr;
+	size_t		sc_transfer_size;
 };
 
 static int	ssdfb_i2c_match(device_t, cfdata_t, void *);
 static void	ssdfb_i2c_attach(device_t, device_t, void *);
 static int	ssdfb_i2c_detach(device_t, int);
 
+static int	ssdfb_i2c_probe_transfer_size(struct ssdfb_i2c_softc *, bool);
+static int	ssdfb_i2c_transfer(struct ssdfb_i2c_softc *, uint8_t, uint8_t *,
+size_t, int);
 static int	ssdfb_i2c_cmd(void *, uint8_t *, size_t, bool);
 static int	ssdfb_i2c_transfer_rect(void *, uint8_t, uint8_t, uint8_t,
 uint8_t, uint8_t *, size_t, bool);
@@ -132,6 +136,61 @@ ssdfb_i2c_detach(device_t self, int flag
 }
 
 static int
+ssdfb_i2c_probe_transfer_size(struct ssdfb_i2c_softc *sc, bool usepoll)
+{
+	int flags = usepoll ? I2C_F_POLL : 0;
+	uint8_t cb = SSDFB_I2C_CTRL_BYTE_DATA_MASK;
+	int error;
+	uint8_t buf[128];
+	size_t len;
+
+	error = iic_acquire_bus(sc->sc_i2c_tag, flags);
+	if (error)
+		return error;
+	len = sizeof(buf);
+	memset(buf, 0, len);
+	while (len > 0) {
+		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
+		sc->sc_i2c_addr, , sizeof(cb), buf, len, flags);
+		if (!error) {
+			break;
+		}
+		len >>= 1;
+	}
+	if (!error && len < 2) {
+		error = E2BIG;
+	} else {
+		sc->sc_transfer_size = len;
+	}
+	(void) iic_release_bus(sc->sc_i2c_tag, flags);
+
+	return error;
+}
+
+static int
+ssdfb_i2c_transfer(struct ssdfb_i2c_softc *sc, uint8_t cb, uint8_t *data,
+		   size_t len, int flags)
+{
+	int error;
+	size_t xfer_size = sc->sc_transfer_size;
+
+	while (len >= xfer_size) {
+		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
+		sc->sc_i2c_addr, , sizeof(cb), data, xfer_size, flags);
+		if (error)
+			return error;
+		len -= xfer_size;
+		data += xfer_size;
+	}
+	if (len > 0) {
+		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
+		sc->sc_i2c_addr, , sizeof(cb), data, len, flags);
+	}
+
+	return error;
+}
+
+static int
 ssdfb_i2c_cmd(void *cookie, uint8_t *cmd, size_t len, bool usepoll)
 {
 	struct ssdfb_i2c_softc *sc = (struct ssdfb_i2c_softc *)cookie;
@@ -154,9 +213,6 @@ ssdfb_i2c_transfer_rect(void *cookie, ui
 uint8_t frompage, uint8_t topage, uint8_t *p, size_t stride, bool usepoll)
 {
 	struct ssdfb_i2c_softc *sc = (struct ssdfb_i2c_softc *)cookie;
-	int flags = usepoll ? I2C_F_POLL : 0;
-	uint8_t cb = SSDFB_I2C_CTRL_BYTE_DATA_MASK;
-	uint8_t data[] = {0, 0, 0};
 	uint8_t cmd[2];
 	int error;
 
@@ -177,13 +233,12 @@ ssdfb_i2c_transfer_rect(void *cookie, ui
 	}
 
 	if (sc->sc.sc_transfer_rect != ssdfb_smbus_transfer_rect) {
-		error = iic_acquire_bus(sc->sc_i2c_tag, flags);
+		error = ssdfb_i2c_probe_transfer_size(sc, usepoll);
 		if (error)
 			return error;
-		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
-		sc->sc_i2c_addr, , sizeof(cb), data, sizeof(data), flags);
-		(void) iic_release_bus(sc->sc_i2c_tag, flags);
-		if (error) {
+		aprint_verbose_dev(sc->sc.sc_dev, "%zd-byte transfers\n",
+		sc->sc_transfer_size);
+		if (sc->sc_transfer_size == 2) {
 			sc->sc.sc_transfer_rect = ssdfb_smbus_transfer_rect;
 		}
 	}
@@ -238,8 +293,7 @@ ssdfb_i2c_transfer_rect_ssd1306(void *co
 	if (error)
 		goto out;
 	while (frompage <= topage) {
-		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
-		sc->sc_i2c_addr, , sizeof(cb), p, len, flags);
+		error = ssdfb_i2c_transfer(sc, cb, p, len, flags);
 		if (error)
 			goto out;
 		frompage++;
@@ -278,8 +332,7 @@ ssdfb_i2c_transfer_rect_sh1106(void *coo
 		sc->sc_i2c_addr, , sizeof(cc), cmds, sizeof(cmds), flags);
 		if (error)
 			goto out;
-		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
-		sc->sc_i2c_addr, , sizeof(cb), p, len, flags);
+		error = ssdfb_i2c_transfer(sc, cb, p, len, 

CVS commit: src/sys/arch/sparc64/conf

2019-11-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov  5 12:59:55 UTC 2019

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Add GPT wedge autodiscovery


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/sys/arch/sparc64/conf/GENERIC

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.217 src/sys/arch/sparc64/conf/GENERIC:1.218
--- src/sys/arch/sparc64/conf/GENERIC:1.217	Tue Nov  5 12:28:23 2019
+++ src/sys/arch/sparc64/conf/GENERIC	Tue Nov  5 12:59:54 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.217 2019/11/05 12:28:23 martin Exp $
+# $NetBSD: GENERIC,v 1.218 2019/11/05 12:59:54 martin Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.217 $"
+#ident		"GENERIC-$Revision: 1.218 $"
 
 maxusers	64
 
@@ -138,6 +138,14 @@ options 	COMPAT_NETBSD32	# NetBSD/sparc 
 options 	EXEC_AOUT	# execve(2) support for a.out binaries
 options 	EXEC_ELF32	# Exec module for SunOS 5.x binaries.
 
+# Wedge support
+options 	DKWEDGE_AUTODISCOVER	# Automatically add dk(4) instances
+options 	DKWEDGE_METHOD_GPT	# Supports GPT partitions as wedges
+#options 	DKWEDGE_METHOD_BSDLABEL	# Support disklabel entries as wedges
+#options 	DKWEDGE_METHOD_MBR	# Support MBR partitions as wedges
+#options 	DKWEDGE_METHOD_APPLE	# Support Apple partitions as wedges
+#options 	DKWEDGE_METHOD_RDB	# Support RDB partitions as wedges
+
 ## File systems.
 include "conf/filesystems.config"
 



CVS commit: src/sys/arch/sparc64/conf

2019-11-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov  5 12:59:55 UTC 2019

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Add GPT wedge autodiscovery


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/sys/arch/sparc64/conf/GENERIC

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sparc64/conf

2019-11-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov  5 12:28:23 UTC 2019

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Add siisata* at pci (no idea why it was missing)


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/sys/arch/sparc64/conf/GENERIC

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.216 src/sys/arch/sparc64/conf/GENERIC:1.217
--- src/sys/arch/sparc64/conf/GENERIC:1.216	Mon May  6 02:24:37 2019
+++ src/sys/arch/sparc64/conf/GENERIC	Tue Nov  5 12:28:23 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.216 2019/05/06 02:24:37 sevan Exp $
+# $NetBSD: GENERIC,v 1.217 2019/11/05 12:28:23 martin Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.216 $"
+#ident		"GENERIC-$Revision: 1.217 $"
 
 maxusers	64
 
@@ -353,6 +353,7 @@ optiide* at pci? dev ? function ?	# Opti
 pdcide* at pci? dev ? function ?	# Promise IDE controllers
 pdcsata* at pci? dev ? function ?	# Promise SATA150 controllers
 satalink* at pci? dev ? function ?	# SiI SATALink controllers
+siisata* at pci? dev ? function ?	# SiI SteelVine controllers
 siside* at pci? dev ? function ?	# SiS IDE controllers
 slide*	at pci? dev ? function ?	# Symphony Labs IDE controllers
 viaide* at pci? dev ? function ?	# VIA/AMD/Nvidia IDE controllers



CVS commit: src/sys/arch/sparc64/conf

2019-11-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov  5 12:28:23 UTC 2019

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Add siisata* at pci (no idea why it was missing)


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/sys/arch/sparc64/conf/GENERIC

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/arm32

2019-11-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  5 10:21:31 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: bus_dma.c

Log Message:
Do not try to use direct map for prefetchable mappings


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/arm/arm32/bus_dma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm32/bus_dma.c
diff -u src/sys/arch/arm/arm32/bus_dma.c:1.117 src/sys/arch/arm/arm32/bus_dma.c:1.118
--- src/sys/arch/arm/arm32/bus_dma.c:1.117	Tue Nov  5 09:57:47 2019
+++ src/sys/arch/arm/arm32/bus_dma.c	Tue Nov  5 10:21:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.117 2019/11/05 09:57:47 jmcneill Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.118 2019/11/05 10:21:31 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include "opt_cputypes.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.117 2019/11/05 09:57:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.118 2019/11/05 10:21:31 jmcneill Exp $");
 
 #include 
 #include 
@@ -1339,7 +1339,7 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma
 	 * contiguous area then this area is already mapped.  Let's see if we
 	 * avoid having a separate mapping for it.
 	 */
-	if (nsegs == 1) {
+	if (nsegs == 1 && (flags & BUS_DMA_PREFETCHABLE) == 0) {
 		/*
 		 * If this is a non-COHERENT mapping, then the existing kernel
 		 * mapping is already compatible with it.



CVS commit: src/sys/arch/arm/arm32

2019-11-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  5 10:21:31 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: bus_dma.c

Log Message:
Do not try to use direct map for prefetchable mappings


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/arm/arm32/bus_dma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/external/bsd/drm2/drm

2019-11-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  5 09:59:16 UTC 2019

Modified Files:
src/sys/external/bsd/drm2/drm: drm_gem_cma_helper.c

Log Message:
Map buffer objects with BUS_DMA_PREFETCHABLE.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/external/bsd/drm2/drm

2019-11-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  5 09:59:16 UTC 2019

Modified Files:
src/sys/external/bsd/drm2/drm: drm_gem_cma_helper.c

Log Message:
Map buffer objects with BUS_DMA_PREFETCHABLE.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c
diff -u src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c:1.7 src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c:1.8
--- src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c:1.7	Fri Mar  8 02:53:22 2019
+++ src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c	Tue Nov  5 09:59:16 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_gem_cma_helper.c,v 1.7 2019/03/08 02:53:22 mrg Exp $ */
+/* $NetBSD: drm_gem_cma_helper.c,v 1.8 2019/11/05 09:59:16 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_gem_cma_helper.c,v 1.7 2019/03/08 02:53:22 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_gem_cma_helper.c,v 1.8 2019/11/05 09:59:16 jmcneill Exp $");
 
 #include 
 #include 
@@ -55,7 +55,8 @@ drm_gem_cma_create_internal(struct drm_d
 	if (error)
 		goto failed;
 	error = bus_dmamem_map(obj->dmat, obj->dmasegs, nsegs,
-	obj->dmasize, >vaddr, BUS_DMA_WAITOK | BUS_DMA_COHERENT);
+	obj->dmasize, >vaddr,
+	BUS_DMA_WAITOK | BUS_DMA_PREFETCHABLE);
 	if (error)
 		goto free;
 	error = bus_dmamap_create(obj->dmat, obj->dmasize, 1,



CVS commit: src/sys/arch/arm/arm32

2019-11-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  5 09:57:47 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: bus_dma.c

Log Message:
bus_dmamem_map: honour BUS_DMA_PREFETCHABLE hint


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/arm/arm32/bus_dma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/arm32

2019-11-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  5 09:57:47 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: bus_dma.c

Log Message:
bus_dmamem_map: honour BUS_DMA_PREFETCHABLE hint


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/arm/arm32/bus_dma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm32/bus_dma.c
diff -u src/sys/arch/arm/arm32/bus_dma.c:1.116 src/sys/arch/arm/arm32/bus_dma.c:1.117
--- src/sys/arch/arm/arm32/bus_dma.c:1.116	Sat Aug 24 11:51:26 2019
+++ src/sys/arch/arm/arm32/bus_dma.c	Tue Nov  5 09:57:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.116 2019/08/24 11:51:26 jmcneill Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.117 2019/11/05 09:57:47 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include "opt_cputypes.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.116 2019/08/24 11:51:26 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.117 2019/11/05 09:57:47 jmcneill Exp $");
 
 #include 
 #include 
@@ -1426,6 +1426,7 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma
 		pa < (segs[curseg].ds_addr + segs[curseg].ds_len);
 		pa += PAGE_SIZE, va += PAGE_SIZE, size -= PAGE_SIZE) {
 			bool uncached = (flags & BUS_DMA_COHERENT);
+			bool prefetchable = (flags & BUS_DMA_PREFETCHABLE);
 #ifdef DEBUG_DMA
 			printf("wiring p%lx to v%lx", pa, va);
 #endif	/* DEBUG_DMA */
@@ -1443,8 +1444,14 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma
 uncached = false;
 			}
 
+			u_int pmap_flags = PMAP_WIRED;
+			if (prefetchable)
+pmap_flags |= PMAP_WRITE_COMBINE;
+			else if (uncached)
+pmap_flags |= PMAP_NOCACHE;
+
 			pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE,
-			PMAP_WIRED | (uncached ? PMAP_NOCACHE : 0));
+			pmap_flags);
 		}
 	}
 	pmap_update(pmap_kernel());