CVS commit: src/sys/dev/pci

2018-01-28 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jan 29 04:17:32 UTC 2018

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Fix unmatched return type. The return value of wm_txeof() is not useded yet.


To generate a diff of this commit:
cvs rdiff -u -r1.560 -r1.561 src/sys/dev/pci/if_wm.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/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.560 src/sys/dev/pci/if_wm.c:1.561
--- src/sys/dev/pci/if_wm.c:1.560	Mon Jan 29 03:42:30 2018
+++ src/sys/dev/pci/if_wm.c	Mon Jan 29 04:17:32 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.560 2018/01/29 03:42:30 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.561 2018/01/29 04:17:32 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.560 2018/01/29 03:42:30 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.561 2018/01/29 04:17:32 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -8044,7 +8044,6 @@ wm_txeof(struct wm_txqueue *txq, u_int l
 	struct wm_softc *sc = txq->txq_sc;
 	struct ifnet *ifp = >sc_ethercom.ec_if;
 	struct wm_txsoft *txs;
-	bool processed = false;
 	int count = 0;
 	int i;
 	uint8_t status;
@@ -8085,7 +8084,6 @@ wm_txeof(struct wm_txqueue *txq, u_int l
 			break;
 		}
 
-		processed = true;
 		count++;
 		DPRINTF(WM_DEBUG_TX,
 		("%s: TX: job %d done: descs %d..%d\n",
@@ -8142,7 +8140,7 @@ wm_txeof(struct wm_txqueue *txq, u_int l
 	if (txq->txq_sfree == WM_TXQUEUELEN(txq))
 		ifp->if_timer = 0;
 
-	return processed;
+	return count;
 }
 
 static inline uint32_t



CVS commit: src/sys/netinet6

2018-01-28 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan 29 03:42:53 UTC 2018

Modified Files:
src/sys/netinet6: nd6.c

Log Message:
One more from christos@

No need to initialize fill_func


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/sys/netinet6/nd6.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/netinet6/nd6.c
diff -u src/sys/netinet6/nd6.c:1.243 src/sys/netinet6/nd6.c:1.244
--- src/sys/netinet6/nd6.c:1.243	Mon Jan 29 03:35:23 2018
+++ src/sys/netinet6/nd6.c	Mon Jan 29 03:42:53 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.243 2018/01/29 03:35:23 pgoyette Exp $	*/
+/*	$NetBSD: nd6.c,v 1.244 2018/01/29 03:42:53 pgoyette Exp $	*/
 /*	$KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.243 2018/01/29 03:35:23 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.244 2018/01/29 03:42:53 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2503,8 +2503,6 @@ nd6_sysctl(
 
 	p = NULL;
 
-	fill_func = NULL;
-
 	switch (name) {
 	case ICMPV6CTL_ND6_DRLIST:
 		fill_func = fill_drlist;



CVS commit: src/sys/dev/pci

2018-01-28 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jan 29 03:42:30 UTC 2018

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Fix if_wm.c:r1.557 merge miss, sorry.


To generate a diff of this commit:
cvs rdiff -u -r1.559 -r1.560 src/sys/dev/pci/if_wm.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/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.559 src/sys/dev/pci/if_wm.c:1.560
--- src/sys/dev/pci/if_wm.c:1.559	Fri Jan 26 16:25:28 2018
+++ src/sys/dev/pci/if_wm.c	Mon Jan 29 03:42:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.559 2018/01/26 16:25:28 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.560 2018/01/29 03:42:30 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.559 2018/01/26 16:25:28 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.560 2018/01/29 03:42:30 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2983,9 +2983,7 @@ wm_watchdog_txq_locked(struct ifnet *ifp
 	 * Since we're using delayed interrupts, sweep up
 	 * before we report an error.
 	 */
-	mutex_enter(txq->txq_lock);
 	wm_txeof(txq, UINT_MAX);
-	mutex_exit(txq->txq_lock);
 
 	if (txq->txq_free != WM_NTXDESC(txq)) {
 #ifdef WM_DEBUG



CVS commit: src/sys/netinet6

2018-01-28 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan 29 03:35:23 UTC 2018

Modified Files:
src/sys/netinet6: nd6.c

Log Message:
More simplification, this time from ozaki-r@

No need to break after return.


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.243 src/sys/netinet6/nd6.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/netinet6/nd6.c
diff -u src/sys/netinet6/nd6.c:1.242 src/sys/netinet6/nd6.c:1.243
--- src/sys/netinet6/nd6.c:1.242	Mon Jan 29 03:29:26 2018
+++ src/sys/netinet6/nd6.c	Mon Jan 29 03:35:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.242 2018/01/29 03:29:26 pgoyette Exp $	*/
+/*	$NetBSD: nd6.c,v 1.243 2018/01/29 03:35:23 pgoyette Exp $	*/
 /*	$KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.242 2018/01/29 03:29:26 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.243 2018/01/29 03:35:23 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2516,11 +2516,9 @@ nd6_sysctl(
 
 	case ICMPV6CTL_ND6_MAXQLEN:
 		return 0;
-		break;
 
 	default:
 		return ENOPROTOOPT;
-		break;
 	}
 
 	error = (*fill_func)(p, oldlenp);	/* calc len needed */



CVS commit: src/sys/netinet6

2018-01-28 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan 29 03:29:26 UTC 2018

Modified Files:
src/sys/netinet6: nd6.c

Log Message:
Simplify, from christos@


To generate a diff of this commit:
cvs rdiff -u -r1.241 -r1.242 src/sys/netinet6/nd6.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/netinet6/nd6.c
diff -u src/sys/netinet6/nd6.c:1.241 src/sys/netinet6/nd6.c:1.242
--- src/sys/netinet6/nd6.c:1.241	Mon Jan 29 02:02:14 2018
+++ src/sys/netinet6/nd6.c	Mon Jan 29 03:29:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.241 2018/01/29 02:02:14 pgoyette Exp $	*/
+/*	$NetBSD: nd6.c,v 1.242 2018/01/29 03:29:26 pgoyette Exp $	*/
 /*	$KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.241 2018/01/29 02:02:14 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.242 2018/01/29 03:29:26 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2515,24 +2515,23 @@ nd6_sysctl(
 		break;
 
 	case ICMPV6CTL_ND6_MAXQLEN:
+		return 0;
 		break;
 
 	default:
-		error = ENOPROTOOPT;
+		return ENOPROTOOPT;
 		break;
 	}
 
-	if (fill_func) {
-		error = (*fill_func)(p, oldlenp);	/* calc len needed */
-		if (error == 0 && oldp && *oldlenp > 0 ) {
-			p = kmem_alloc(*oldlenp, KM_SLEEP);
-			bufsize = *oldlenp;
-			error = (*fill_func)(p, oldlenp);
-			if (!error && oldp != NULL)
-error = copyout(p, oldp, min(ol, *oldlenp));
-			if (*oldlenp > ol)
-error = ENOMEM;
-		}
+	error = (*fill_func)(p, oldlenp);	/* calc len needed */
+	if (error == 0 && oldp && *oldlenp > 0 ) {
+		p = kmem_alloc(*oldlenp, KM_SLEEP);
+		bufsize = *oldlenp;
+		error = (*fill_func)(p, oldlenp);
+		if (!error && oldp != NULL)
+			error = copyout(p, oldp, min(ol, *oldlenp));
+		if (*oldlenp > ol)
+			error = ENOMEM;
 	}
 	if (p)
 		kmem_free(p, bufsize);



CVS commit: src/sys/netinet6

2018-01-28 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan 29 02:02:14 UTC 2018

Modified Files:
src/sys/netinet6: nd6.c

Log Message:
Use existing fill_[pd]rlist() functions to calculate size of buffer to
allocate, rather than relying on an arbitrary length passed in from
userland.

Allow copyout() of partial results if the user buffer is too small, to
be consistent with the way sysctl(3) is documented.

Garbage-collect now-unused third parrameter in the fill_[pd]rlist()
functions.

As discussed on IRC.
OK kamil@ and christos@

XXX Needs pull-up to netbsd-8 branch.


To generate a diff of this commit:
cvs rdiff -u -r1.240 -r1.241 src/sys/netinet6/nd6.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/netinet6/nd6.c
diff -u src/sys/netinet6/nd6.c:1.240 src/sys/netinet6/nd6.c:1.241
--- src/sys/netinet6/nd6.c:1.240	Fri Dec 15 04:03:46 2017
+++ src/sys/netinet6/nd6.c	Mon Jan 29 02:02:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.240 2017/12/15 04:03:46 ozaki-r Exp $	*/
+/*	$NetBSD: nd6.c,v 1.241 2018/01/29 02:02:14 pgoyette Exp $	*/
 /*	$KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.240 2017/12/15 04:03:46 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.241 2018/01/29 02:02:14 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -124,8 +124,8 @@ static callout_t nd6_timer_ch;
 static struct workqueue	*nd6_timer_wq;
 static struct work	nd6_timer_wk;
 
-static int fill_drlist(void *, size_t *, size_t);
-static int fill_prlist(void *, size_t *, size_t);
+static int fill_drlist(void *, size_t *);
+static int fill_prlist(void *, size_t *);
 
 static struct ifnet *nd6_defifp;
 static int nd6_defifindex;
@@ -2491,6 +2491,7 @@ nd6_sysctl(
 	size_t ol;
 	int error;
 	size_t bufsize = 0;
+	int (*fill_func)(void *, size_t *);
 
 	error = 0;
 
@@ -2500,22 +2501,17 @@ nd6_sysctl(
 		return EINVAL;
 	ol = oldlenp ? *oldlenp : 0;
 
-	if (oldp && *oldlenp > 0) {
-		p = kmem_alloc(*oldlenp, KM_SLEEP);
-		bufsize = *oldlenp;
-	} else
-		p = NULL;
+	p = NULL;
+
+	fill_func = NULL;
+
 	switch (name) {
 	case ICMPV6CTL_ND6_DRLIST:
-		error = fill_drlist(p, oldlenp, ol);
-		if (!error && p != NULL && oldp != NULL)
-			error = copyout(p, oldp, *oldlenp);
+		fill_func = fill_drlist;
 		break;
 
 	case ICMPV6CTL_ND6_PRLIST:
-		error = fill_prlist(p, oldlenp, ol);
-		if (!error && p != NULL && oldp != NULL)
-			error = copyout(p, oldp, *oldlenp);
+		fill_func = fill_prlist;
 		break;
 
 	case ICMPV6CTL_ND6_MAXQLEN:
@@ -2525,6 +2521,19 @@ nd6_sysctl(
 		error = ENOPROTOOPT;
 		break;
 	}
+
+	if (fill_func) {
+		error = (*fill_func)(p, oldlenp);	/* calc len needed */
+		if (error == 0 && oldp && *oldlenp > 0 ) {
+			p = kmem_alloc(*oldlenp, KM_SLEEP);
+			bufsize = *oldlenp;
+			error = (*fill_func)(p, oldlenp);
+			if (!error && oldp != NULL)
+error = copyout(p, oldp, min(ol, *oldlenp));
+			if (*oldlenp > ol)
+error = ENOMEM;
+		}
+	}
 	if (p)
 		kmem_free(p, bufsize);
 
@@ -2532,7 +2541,7 @@ nd6_sysctl(
 }
 
 static int
-fill_drlist(void *oldp, size_t *oldlenp, size_t ol)
+fill_drlist(void *oldp, size_t *oldlenp)
 {
 	int error = 0;
 	struct in6_defrouter *d = NULL, *de = NULL;
@@ -2571,10 +2580,6 @@ fill_drlist(void *oldp, size_t *oldlenp,
 	}
 	ND6_UNLOCK();
 
-	if (oldp) {
-		if (l > ol)
-			error = ENOMEM;
-	}
 	if (oldlenp)
 		*oldlenp = l;	/* (void *)d - (void *)oldp */
 
@@ -2582,7 +2587,7 @@ fill_drlist(void *oldp, size_t *oldlenp,
 }
 
 static int
-fill_prlist(void *oldp, size_t *oldlenp, size_t ol)
+fill_prlist(void *oldp, size_t *oldlenp)
 {
 	int error = 0;
 	struct nd_prefix *pr;
@@ -2678,11 +2683,7 @@ fill_prlist(void *oldp, size_t *oldlenp,
 	}
 	ND6_UNLOCK();
 
-	if (oldp) {
-		*oldlenp = l;	/* (void *)d - (void *)oldp */
-		if (l > ol)
-			error = ENOMEM;
-	} else
+	if (oldlenp)
 		*oldlenp = l;
 
 	return error;



CVS commit: src/sys/kern

2018-01-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 28 22:24:58 UTC 2018

Modified Files:
src/sys/kern: subr_interrupt.c

Log Message:
- don't return ENOMEM for errors not related to memory
- don't overload return values (-error/+size)
- don't allocate kernel memory from user supplied length.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/kern/subr_interrupt.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/kern/subr_interrupt.c
diff -u src/sys/kern/subr_interrupt.c:1.3 src/sys/kern/subr_interrupt.c:1.4
--- src/sys/kern/subr_interrupt.c:1.3	Sat Jan 13 08:53:36 2018
+++ src/sys/kern/subr_interrupt.c	Sun Jan 28 17:24:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_interrupt.c,v 1.3 2018/01/13 13:53:36 reinoud Exp $	*/
+/*	$NetBSD: subr_interrupt.c,v 1.4 2018/01/28 22:24:58 christos Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_interrupt.c,v 1.3 2018/01/13 13:53:36 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_interrupt.c,v 1.4 2018/01/28 22:24:58 christos Exp $");
 
 #include 
 #include 
@@ -133,7 +133,7 @@ interrupt_avert_intr(u_int cpu_idx)
 
 	ii_handler = interrupt_construct_intrids(cpuset);
 	if (ii_handler == NULL) {
-		error = ENOMEM;
+		error = EINVAL;
 		goto out;
 	}
 	nids = ii_handler->iih_nids;
@@ -180,25 +180,24 @@ interrupt_intrio_list_line_size(void)
  * Return the size of interrupts list data on success.
  * Reterun 0 on failed.
  */
-static size_t
-interrupt_intrio_list_size(void)
+static int
+interrupt_intrio_list_size(size_t *ilsize)
 {
 	struct intrids_handler *ii_handler;
-	size_t ilsize;
 
-	ilsize = 0;
+	*ilsize = 0;
 
 	/* buffer header */
-	ilsize += sizeof(struct intrio_list);
+	*ilsize += sizeof(struct intrio_list);
 
 	/* il_line body */
 	ii_handler = interrupt_construct_intrids(kcpuset_running);
 	if (ii_handler == NULL)
-		return 0;
-	ilsize += interrupt_intrio_list_line_size() * (ii_handler->iih_nids);
+		return EOPNOTSUPP;
+	*ilsize += interrupt_intrio_list_line_size() * ii_handler->iih_nids;
 
 	interrupt_destruct_intrids(ii_handler);
-	return ilsize;
+	return 0;
 }
 
 /*
@@ -207,28 +206,17 @@ interrupt_intrio_list_size(void)
  * If "data" == NULL, simply return list structure bytes.
  */
 static int
-interrupt_intrio_list(struct intrio_list *il, int length)
+interrupt_intrio_list(struct intrio_list *il, size_t ilsize)
 {
 	struct intrio_list_line *illine;
 	kcpuset_t *assigned, *avail;
 	struct intrids_handler *ii_handler;
 	intrid_t *ids;
-	size_t ilsize;
 	u_int cpu_idx;
-	int nids, intr_idx, ret, line_size;
-
-	ilsize = interrupt_intrio_list_size();
-	if (ilsize == 0)
-		return -ENOMEM;
-
-	if (il == NULL)
-		return ilsize;
-
-	if (length < ilsize)
-		return -ENOMEM;
+	int nids, intr_idx, error, line_size;
 
 	illine = (struct intrio_list_line *)
-		((char *)il + sizeof(struct intrio_list));
+	((char *)il + sizeof(struct intrio_list));
 	il->il_lineoffset = (off_t)((uintptr_t)illine - (uintptr_t)il);
 
 	kcpuset_create(, true);
@@ -238,19 +226,19 @@ interrupt_intrio_list(struct intrio_list
 	ii_handler = interrupt_construct_intrids(kcpuset_running);
 	if (ii_handler == NULL) {
 		DPRINTF(("%s: interrupt_construct_intrids() failed\n",
-			__func__));
-		ret = -ENOMEM;
+		__func__));
+		error = EOPNOTSUPP;
 		goto out;
 	}
 
 	line_size = interrupt_intrio_list_line_size();
-	/* ensure interrupts are not added after interrupt_intrio_list_size(). */
+	/* ensure interrupts are not added after interrupt_intrio_list_size() */
 	nids = ii_handler->iih_nids;
 	ids = ii_handler->iih_intrids;
 	if (ilsize < sizeof(struct intrio_list) + line_size * nids) {
 		DPRINTF(("%s: interrupts are added during execution.\n",
-			__func__));
-		ret = -ENOMEM;
+		__func__));
+		error = EAGAIN;
 		goto destruct_out;
 	}
 
@@ -264,19 +252,19 @@ interrupt_intrio_list(struct intrio_list
 		interrupt_get_assigned(ids[intr_idx], assigned);
 		for (cpu_idx = 0; cpu_idx < ncpu; cpu_idx++) {
 			struct intrio_list_line_cpu *illcpu =
->ill_cpu[cpu_idx];
+			>ill_cpu[cpu_idx];
 
 			illcpu->illc_assigned =
-kcpuset_isset(assigned, cpu_idx) ? true : false;
+			kcpuset_isset(assigned, cpu_idx);
 			illcpu->illc_count =
-interrupt_get_count(ids[intr_idx], cpu_idx);
+			interrupt_get_count(ids[intr_idx], cpu_idx);
 		}
 
 		illine = (struct intrio_list_line *)
-			((char *)illine + line_size);
+		((char *)illine + line_size);
 	}
 
-	ret = ilsize;
+	error = 0;
 	il->il_version = INTRIO_LIST_VERSION;
 	il->il_ncpus = ncpu;
 	il->il_nintrs = nids;
@@ -289,7 +277,7 @@ interrupt_intrio_list(struct intrio_list
 	kcpuset_destroy(assigned);
 	kcpuset_destroy(avail);
 
-	return ret;
+	return error;
 }
 
 /*
@@ -298,42 +286,39 @@ interrupt_intrio_list(struct intrio_list
 static int
 interrupt_intrio_list_sysctl(SYSCTLFN_ARGS)
 {
-	int ret, 

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

2018-01-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 28 18:31:41 UTC 2018

Modified Files:
src/sys/arch/arm/dts: sun50i-h5-nanopi-neo-plus2.dts

Log Message:
Enable CPU frequency scaling and thermal sensors.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/dts/sun50i-h5-nanopi-neo-plus2.dts

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/dts/sun50i-h5-nanopi-neo-plus2.dts
diff -u src/sys/arch/arm/dts/sun50i-h5-nanopi-neo-plus2.dts:1.1 src/sys/arch/arm/dts/sun50i-h5-nanopi-neo-plus2.dts:1.2
--- src/sys/arch/arm/dts/sun50i-h5-nanopi-neo-plus2.dts:1.1	Sun Dec 31 00:53:29 2017
+++ src/sys/arch/arm/dts/sun50i-h5-nanopi-neo-plus2.dts	Sun Jan 28 18:31:41 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i-h5-nanopi-neo-plus2.dts,v 1.1 2017/12/31 00:53:29 jakllsch Exp $ */
+/* $NetBSD: sun50i-h5-nanopi-neo-plus2.dts,v 1.2 2018/01/28 18:31:41 jmcneill Exp $ */
 
 /*
  *  and _mdio portions lifted from
@@ -49,6 +49,7 @@
  */
 
 #include "../../../external/gpl2/dts/dist/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo-plus2.dts"
+#include "sun50i-h5.dtsi"
 
  {
 	pinctrl-names = "default";
@@ -65,3 +66,26 @@
 		reg = <7>;
 	};
 };
+
+/ {
+	cpus {
+		cpu@0 {
+			cpu-supply = <_cpux>;
+			operating-points = <
+/* kHz	  uV */
+1152000	110
+1104000	110
+1008000	110
+816000	110
+624000	110
+>;
+		};
+	};
+
+	vcc_cpux: reg_vcc_cpux {
+		compatible = "regulator-fixed";
+		regulator-name = "cpux-1v1";
+		regulator-min-microvolt = <110>;
+		regulator-max-microvolt = <110>;
+	};
+};



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

2018-01-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 28 18:31:15 UTC 2018

Added Files:
src/sys/arch/arm/dts: sun50i-h5.dtsi

Log Message:
Add support for H5 simple framebuffer, CPUX clocks, R_I2C controller, SID
controller, and thermal sensors.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/dts/sun50i-h5.dtsi

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

Added files:

Index: src/sys/arch/arm/dts/sun50i-h5.dtsi
diff -u /dev/null src/sys/arch/arm/dts/sun50i-h5.dtsi:1.1
--- /dev/null	Sun Jan 28 18:31:15 2018
+++ src/sys/arch/arm/dts/sun50i-h5.dtsi	Sun Jan 28 18:31:15 2018
@@ -0,0 +1,33 @@
+/* $NetBSD: sun50i-h5.dtsi,v 1.1 2018/01/28 18:31:15 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2018 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "sun8i-h3.dtsi"
+
+ {
+	compatible = "allwinner,sun50i-h5-ts";
+};



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

2018-01-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 28 18:24:51 UTC 2018

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

Log Message:
Add support for H5 CPU and GPU thermal sensors.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_thermal.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_thermal.c
diff -u src/sys/arch/arm/sunxi/sunxi_thermal.c:1.4 src/sys/arch/arm/sunxi/sunxi_thermal.c:1.5
--- src/sys/arch/arm/sunxi/sunxi_thermal.c:1.4	Wed Dec 13 21:37:10 2017
+++ src/sys/arch/arm/sunxi/sunxi_thermal.c	Sun Jan 28 18:24:50 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_thermal.c,v 1.4 2017/12/13 21:37:10 jmcneill Exp $ */
+/* $NetBSD: sunxi_thermal.c,v 1.5 2018/01/28 18:24:50 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016-2017 Jared McNeill 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_thermal.c,v 1.4 2017/12/13 21:37:10 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_thermal.c,v 1.5 2018/01/28 18:24:50 jmcneill Exp $");
 
 #include 
 #include 
@@ -108,6 +108,20 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_therma
 #define	H3_INIT_ALARM		90	/* degC */
 #define	H3_INIT_SHUT		105	/* degC */
 
+#define	H5_ADC_ACQUIRE_TIME	0x1df
+#define	H5_FILTER		0x6
+#define	H5_INTC			0x3a070
+#define	H5_TEMP_DIV		20
+#define	H5_TEMP_BASE_L		233832448
+#define	H5_TEMP_MUL_L		124885
+#define	H5_TEMP_BASE_H_0	271581184
+#define	H5_TEMP_MUL_H_0		152253
+#define	H5_TEMP_BASE_H_1	289406976
+#define	H5_TEMP_MUL_H_1		166723
+#define	H5_CLK_RATE		2400
+#define	H5_INIT_ALARM		105	/* degC */
+#define	H5_INIT_SHUT		120	/* degC */
+
 #define	TEMP_C_TO_K		27315
 #define	SENSOR_ENABLE_ALL	(SENSOR0_EN|SENSOR1_EN|SENSOR2_EN)
 #define	SHUT_INT_ALL		(SHUT_INT0_STS|SHUT_INT1_STS|SHUT_INT2_STS)
@@ -137,17 +151,14 @@ struct sunxi_thermal_config {
 	intadc_cali_en;
 	uint32_t			filter;
 	uint32_t			intc;
-	int(*to_temp)(uint32_t);
-	uint32_t			(*to_reg)(int);
-	inttemp_base;
-	inttemp_mul;
-	inttemp_div;
+	int(*to_temp)(u_int, uint32_t);
+	uint32_t			(*to_reg)(u_int, int);
 	intcalib0, calib1;
 	uint32_t			calib0_mask, calib1_mask;
 };
 
 static int
-a83t_to_temp(uint32_t val)
+a83t_to_temp(u_int sensor, uint32_t val)
 {
 	return ((A83T_TEMP_BASE - (val * A83T_TEMP_MUL)) / A83T_TEMP_DIV);
 }
@@ -179,7 +190,7 @@ static const struct sunxi_thermal_config
 };
 
 static int
-a64_to_temp(uint32_t val)
+a64_to_temp(u_int sensor, uint32_t val)
 {
 	return ((A64_TEMP_BASE - (val * A64_TEMP_MUL)) / A64_TEMP_DIV);
 }
@@ -208,13 +219,13 @@ static const struct sunxi_thermal_config
 };
 
 static int
-h3_to_temp(uint32_t val)
+h3_to_temp(u_int sensor, uint32_t val)
 {
 	return (H3_TEMP_BASE - ((val * H3_TEMP_MUL) / H3_TEMP_DIV));
 }
 
 static uint32_t
-h3_to_reg(int val)
+h3_to_reg(u_int sensor, int val)
 {
 	return ((H3_TEMP_MINUS - (val * H3_TEMP_DIV)) / H3_TEMP_MUL);
 }
@@ -238,10 +249,67 @@ static const struct sunxi_thermal_config
 	.calib0_mask = 0xfff,
 };
 
+static int
+h5_to_temp(u_int sensor, uint32_t val)
+{
+	int base, mul;
+
+	if (val >= 0x500) {
+		base = H5_TEMP_BASE_L;
+		mul = H5_TEMP_MUL_L;
+	} else {
+		base = sensor == 0 ? H5_TEMP_BASE_H_0 : H5_TEMP_BASE_H_1;
+		mul = sensor == 0 ? H5_TEMP_MUL_H_1 : H5_TEMP_MUL_H_1;
+	}
+
+	return (base - val * mul) >> H5_TEMP_DIV;
+}
+
+static uint32_t
+h5_to_reg(u_int sensor, int val)
+{
+	int base, mul;
+
+	if (val <= 70) {
+		base = H5_TEMP_BASE_L;
+		mul = H5_TEMP_MUL_L;
+	} else {
+		base = sensor == 0 ? H5_TEMP_BASE_H_0 : H5_TEMP_BASE_H_1;
+		mul = sensor == 0 ? H5_TEMP_MUL_H_1 : H5_TEMP_MUL_H_1;
+	}
+
+	return (base - (val << H5_TEMP_DIV)) / mul;
+}
+
+static const struct sunxi_thermal_config h5_config = {
+	.nsensors = 2,
+	.sensors = {
+		[0] = {
+			.name = "cpu",
+			.desc = "CPU temperature",
+			.init_alarm = H5_INIT_ALARM,
+			.init_shut = H5_INIT_SHUT,
+		},
+		[1] = {
+			.name = "gpu",
+			.desc = "GPU temperature",
+			.init_alarm = H5_INIT_ALARM,
+			.init_shut = H5_INIT_SHUT,
+		},
+	},
+	.clk_rate = H5_CLK_RATE,
+	.adc_acquire_time = H5_ADC_ACQUIRE_TIME,
+	.filter = H5_FILTER,
+	.intc = H5_INTC,
+	.to_temp = h5_to_temp,
+	.to_reg = h5_to_reg,
+};
+
 static struct of_compat_data compat_data[] = {
 	{ "allwinner,sun8i-a83t-ts",	(uintptr_t)_config },
 	{ "allwinner,sun8i-h3-ts",	(uintptr_t)_config },
 	{ "allwinner,sun50i-a64-ts",	(uintptr_t)_config },
+	{ "allwinner,sun50i-h5-ts",	(uintptr_t)_config },
 	{ NULL,(uintptr_t)NULL }
 };
 
@@ -311,7 +379,7 @@ sunxi_thermal_gettemp(struct sunxi_therm
 
 	val = RD4(sc, THS_DATA0 + (sensor * 4));
 
-	return sc->conf->to_temp(val);
+	return sc->conf->to_temp(sensor, val);
 }
 
 static int
@@ -322,7 +390,7 @@ sunxi_thermal_getshut(struct sunxi_therm
 	val = RD4(sc, THS_SHUTDOWN0_CTRL + (sensor * 4));
 	val = (val >> SHUT_T_HOT_SHIFT) & SHUT_T_HOT_MASK;
 
-	return 

CVS commit: src/sys/dev/fdt

2018-01-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 28 18:21:52 UTC 2018

Modified Files:
src/sys/dev/fdt: fixedregulator.c

Log Message:
Allow set_voltage/get_voltage to succeed on a fixed regulator so long as
the requested range overlaps with the fixed rate defined in the devicetree.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/fixedregulator.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/fdt/fixedregulator.c
diff -u src/sys/dev/fdt/fixedregulator.c:1.5 src/sys/dev/fdt/fixedregulator.c:1.6
--- src/sys/dev/fdt/fixedregulator.c:1.5	Mon Apr 24 10:55:26 2017
+++ src/sys/dev/fdt/fixedregulator.c	Sun Jan 28 18:21:52 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fixedregulator.c,v 1.5 2017/04/24 10:55:26 jmcneill Exp $ */
+/* $NetBSD: fixedregulator.c,v 1.6 2018/01/28 18:21:52 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fixedregulator.c,v 1.5 2017/04/24 10:55:26 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fixedregulator.c,v 1.6 2018/01/28 18:21:52 jmcneill Exp $");
 
 #include 
 #include 
@@ -44,11 +44,15 @@ static void	fixedregulator_attach(device
 static int	fixedregulator_acquire(device_t);
 static void 	fixedregulator_release(device_t);
 static int	fixedregulator_enable(device_t, bool);
+static int	fixedregulator_set_voltage(device_t, u_int, u_int);
+static int	fixedregulator_get_voltage(device_t, u_int *);
 
 struct fdtbus_regulator_controller_func fixedregulator_funcs = {
 	.acquire = fixedregulator_acquire,
 	.release = fixedregulator_release,
-	.enable = fixedregulator_enable
+	.enable = fixedregulator_enable,
+	.set_voltage = fixedregulator_set_voltage,
+	.get_voltage = fixedregulator_get_voltage,
 };
 
 struct fixedregulator_softc {
@@ -60,6 +64,8 @@ struct fixedregulator_softc {
 	bool		sc_boot_on;
 	bool		sc_enable_val;
 	uint32_t	sc_delay;
+	uint32_t	sc_min_uvol;
+	uint32_t	sc_max_uvol;
 
 	int		sc_gpioflags;
 	bool		sc_deferred;
@@ -113,6 +119,8 @@ fixedregulator_attach(device_t parent, d
 	sc->sc_enable_val = of_getprop_bool(phandle, "enable-active-high");
 	if (of_getprop_uint32(phandle, "startup-delay-us", >sc_delay) != 0)
 		sc->sc_delay = 0;
+	of_getprop_uint32(phandle, "regulator-min-microvolt", >sc_min_uvol);
+	of_getprop_uint32(phandle, "regulator-max-microvolt", >sc_max_uvol);
 
 	sc->sc_pin = fdtbus_gpio_acquire(phandle, "gpio", sc->sc_gpioflags);
 	if (sc->sc_pin == NULL)
@@ -166,3 +174,24 @@ fixedregulator_enable(device_t dev, bool
 	}
 	return 0;
 }
+
+static int
+fixedregulator_set_voltage(device_t dev, u_int min_uvol, u_int max_uvol)
+{
+	struct fixedregulator_softc * const sc = device_private(dev);
+
+	if (sc->sc_min_uvol > max_uvol || sc->sc_max_uvol < min_uvol)
+		return EINVAL;
+
+	return 0;
+}
+
+static int
+fixedregulator_get_voltage(device_t dev, u_int *uvol)
+{
+	struct fixedregulator_softc * const sc = device_private(dev);
+
+	*uvol = sc->sc_min_uvol;
+
+	return 0;
+}



CVS commit: xsrc/external/mit/fontconfig/dist/src

2018-01-28 Thread Christos Zoulas
Module Name:xsrc
Committed By:   christos
Date:   Sun Jan 28 16:44:15 UTC 2018

Modified Files:
xsrc/external/mit/fontconfig/dist/src: fcmatch.c

Log Message:
CID-1428671: Unchecked malloc/strdup


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 xsrc/external/mit/fontconfig/dist/src/fcmatch.c

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

Modified files:

Index: xsrc/external/mit/fontconfig/dist/src/fcmatch.c
diff -u xsrc/external/mit/fontconfig/dist/src/fcmatch.c:1.9 xsrc/external/mit/fontconfig/dist/src/fcmatch.c:1.10
--- xsrc/external/mit/fontconfig/dist/src/fcmatch.c:1.9	Wed Aug 30 16:11:59 2017
+++ xsrc/external/mit/fontconfig/dist/src/fcmatch.c	Sun Jan 28 11:44:15 2018
@@ -703,6 +703,12 @@ FcFontSetMatchInternal (FcFontSet   **se
 	FcBool f = FcTrue;
 
 	ss = s = strdup (env);
+	if (ss == NULL)
+	{
+		fprintf (stderr, "Fontconfig Error: %s\n",
+			strerror (errno));
+		exit (1);
+	}
 	os = FcObjectSetCreate ();
 	while (f)
 	{
@@ -719,6 +725,12 @@ FcFontSetMatchInternal (FcFontSet   **se
 		len = (p - s) + 1;
 		}
 		x = malloc (sizeof (char) * len);
+		if (x == NULL)
+		{
+			fprintf (stderr, "Fontconfig Error: %s\n",
+			strerror (errno));
+			exit (1);
+		}
 		strncpy (x, s, len - 1);
 		x[len - 1] = 0;
 		if (FcObjectFromName (x) > 0)



CVS commit: xsrc/external/mit/fontconfig/dist/src

2018-01-28 Thread Christos Zoulas
Module Name:xsrc
Committed By:   christos
Date:   Sun Jan 28 16:43:32 UTC 2018

Modified Files:
xsrc/external/mit/fontconfig/dist/src: fcstat.c

Log Message:
CID-1428670: Uncheck malloc


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 xsrc/external/mit/fontconfig/dist/src/fcstat.c

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

Modified files:

Index: xsrc/external/mit/fontconfig/dist/src/fcstat.c
diff -u xsrc/external/mit/fontconfig/dist/src/fcstat.c:1.7 xsrc/external/mit/fontconfig/dist/src/fcstat.c:1.8
--- xsrc/external/mit/fontconfig/dist/src/fcstat.c:1.7	Tue Aug 29 04:38:50 2017
+++ xsrc/external/mit/fontconfig/dist/src/fcstat.c	Sun Jan 28 11:43:32 2018
@@ -202,7 +202,7 @@ FcScandir (const char		*dirp,
 if (!d)
 	return -1;
 
-dlist = (struct dirent **) malloc (sizeof (struct dirent *) * lsize);
+dlist = malloc (sizeof (struct dirent *) * lsize);
 if (!dlist)
 {
 	closedir (d);
@@ -217,14 +217,17 @@ FcScandir (const char		*dirp,
 	{
 	size_t dentlen = FcPtrToOffset (dent, dent->d_name) + strlen (dent->d_name) + 1;
 	dentlen = ((dentlen + ALIGNOF_VOID_P - 1) & ~(ALIGNOF_VOID_P - 1));
-	p = (struct dirent *) malloc (dentlen);
+	p = malloc (dentlen);
+	if (!p) 
+		goto out;
 	memcpy (p, dent, dentlen);
 	if ((n + 1) >= lsize)
 	{
 		lsize += 128;
-		dlp = (struct dirent **) realloc (dlist, sizeof (struct dirent *) * lsize);
+		dlp = realloc (dlist, sizeof (struct dirent *) * lsize);
 		if (!dlp)
 		{
+out:
 		free_dirent (dlist);
 		closedir (d);
 		errno = ENOMEM;



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

2018-01-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 28 16:32:43 UTC 2018

Modified Files:
src/sys/arch/x86/x86: cpu_topology.c

Log Message:
Compute Core/SMT-IDs for AMD family 17h (Ryzen).


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/x86/cpu_topology.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/x86/x86/cpu_topology.c
diff -u src/sys/arch/x86/x86/cpu_topology.c:1.12 src/sys/arch/x86/x86/cpu_topology.c:1.13
--- src/sys/arch/x86/x86/cpu_topology.c:1.12	Sun Jan 28 16:15:41 2018
+++ src/sys/arch/x86/x86/cpu_topology.c	Sun Jan 28 16:32:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_topology.c,v 1.12 2018/01/28 16:15:41 mlelstv Exp $	*/
+/*	$NetBSD: cpu_topology.c,v 1.13 2018/01/28 16:32:43 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2009 Mindaugas Rasiukevicius ,
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.12 2018/01/28 16:15:41 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.13 2018/01/28 16:32:43 mlelstv Exp $");
 
 #include 
 #include 
@@ -151,6 +151,16 @@ x86_cpu_topology(struct cpu_info *ci)
 		}
 	}
 
+	/* Family 0x17 supports SMT */
+	if (cpu_vendor == CPUVENDOR_AMD && cpu_family == 0x17) { /* XXX */
+		x86_cpuid(0x801e, descs);
+		const u_int threads = ((descs[1] >> 8) & 0xff) + 1;
+
+		KASSERT(smt_bits == 0 && smt_bits <= core_bits);
+		smt_bits = ilog2(threads);
+		core_bits -= smt_bits;
+	}
+
 	if (smt_bits + core_bits) {
 		if (smt_bits + core_bits < sizeof(apic_id) * NBBY)
 			ci->ci_package_id = apic_id >> (smt_bits + core_bits);



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

2018-01-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 28 16:15:41 UTC 2018

Modified Files:
src/sys/arch/x86/x86: cpu_topology.c

Log Message:
CPUID tells the ApicIdCoreIdSize in bits.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x86/x86/cpu_topology.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/x86/x86/cpu_topology.c
diff -u src/sys/arch/x86/x86/cpu_topology.c:1.11 src/sys/arch/x86/x86/cpu_topology.c:1.12
--- src/sys/arch/x86/x86/cpu_topology.c:1.11	Sun Jan 28 15:00:42 2018
+++ src/sys/arch/x86/x86/cpu_topology.c	Sun Jan 28 16:15:41 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_topology.c,v 1.11 2018/01/28 15:00:42 mlelstv Exp $	*/
+/*	$NetBSD: cpu_topology.c,v 1.12 2018/01/28 16:15:41 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2009 Mindaugas Rasiukevicius ,
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.11 2018/01/28 15:00:42 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.12 2018/01/28 16:15:41 mlelstv Exp $");
 
 #include 
 #include 
@@ -108,6 +108,7 @@ x86_cpu_topology(struct cpu_info *ci)
 			core_max = lp_max;
 			break;
 		}
+
 		/* Number of Cores (NC) per package (ecx[7:0]). */
 		x86_cpuid(0x8008, descs);
 		core_max = (descs[2] & 0xff) + 1;
@@ -116,9 +117,9 @@ x86_cpu_topology(struct cpu_info *ci)
 		if (n != 0) {
 			/*
 			 * Extended Method.
-			 * core_bits = 2 ^ n (power of two)
+			 * core_max = 2 ^ n (power of two)
 			 */
-			core_bits = 1 << n;
+			core_bits = n;
 		}
 		break;
 	default:



CVS commit: src/sys/dev/pci

2018-01-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 28 16:12:41 UTC 2018

Modified Files:
src/sys/dev/pci: if_iwn.c

Log Message:
add an annotation.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/dev/pci/if_iwn.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/if_iwn.c
diff -u src/sys/dev/pci/if_iwn.c:1.87 src/sys/dev/pci/if_iwn.c:1.88
--- src/sys/dev/pci/if_iwn.c:1.87	Tue Jan 16 02:05:24 2018
+++ src/sys/dev/pci/if_iwn.c	Sun Jan 28 11:12:41 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwn.c,v 1.87 2018/01/16 07:05:24 maxv Exp $	*/
+/*	$NetBSD: if_iwn.c,v 1.88 2018/01/28 16:12:41 christos Exp $	*/
 /*	$OpenBSD: if_iwn.c,v 1.135 2014/09/10 07:22:09 dcoppa Exp $	*/
 
 /*-
@@ -22,7 +22,7 @@
  * adapters.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.87 2018/01/16 07:05:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.88 2018/01/28 16:12:41 christos Exp $");
 
 #define IWN_USE_RBUF	/* Use local storage for RX */
 #undef IWN_HWCRYPTO	/* XXX does not even compile yet */
@@ -3394,6 +3394,10 @@ iwn_cmd(struct iwn_softc *sc, int code, 
 	cmd->flags = 0;
 	cmd->qid = ring->qid;
 	cmd->idx = ring->cur;
+	/*
+	 * Coverity:[OUT_OF_BOUNDS]
+	 * false positive since, allocated in mbuf if it does not fit
+	 */
 	memcpy(cmd->data, buf, size);
 
 	desc->nsegs = 1;



CVS commit: src/sys/fs/union

2018-01-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 28 15:48:44 UTC 2018

Modified Files:
src/sys/fs/union: union_subr.c

Log Message:
CID-1428639: make sure we always initialiaze hash, because if ultimately
the file is not found and we end up looping we need them.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/fs/union/union_subr.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/fs/union/union_subr.c
diff -u src/sys/fs/union/union_subr.c:1.76 src/sys/fs/union/union_subr.c:1.77
--- src/sys/fs/union/union_subr.c:1.76	Mon Jul 17 05:22:36 2017
+++ src/sys/fs/union/union_subr.c	Sun Jan 28 10:48:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: union_subr.c,v 1.76 2017/07/17 09:22:36 hannken Exp $	*/
+/*	$NetBSD: union_subr.c,v 1.77 2018/01/28 15:48:44 christos Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.76 2017/07/17 09:22:36 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.77 2018/01/28 15:48:44 christos Exp $");
 
 #include 
 #include 
@@ -377,11 +377,6 @@ union_allocvp(
 		lowervp = NULLVP;
 	}
 
-	if (!docache) {
-		un = NULL;
-		goto found;
-	}
-
 	/*
 	 * If both uppervp and lowervp are not NULL we have to
 	 * search union nodes with one vnode as NULL too.
@@ -394,6 +389,11 @@ union_allocvp(
 		hash[2] = UNION_HASH(NULLVP, lowervp);
 	}
 
+	if (!docache) {
+		un = NULL;
+		goto found;
+	}
+
 loop:
 	mutex_enter(_lock);
 



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

2018-01-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 28 15:00:42 UTC 2018

Modified Files:
src/sys/arch/x86/x86: cpu_topology.c

Log Message:
Check for undefined behaviour when doing right-shift.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x86/x86/cpu_topology.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/x86/x86/cpu_topology.c
diff -u src/sys/arch/x86/x86/cpu_topology.c:1.10 src/sys/arch/x86/x86/cpu_topology.c:1.11
--- src/sys/arch/x86/x86/cpu_topology.c:1.10	Thu Sep  7 06:40:42 2017
+++ src/sys/arch/x86/x86/cpu_topology.c	Sun Jan 28 15:00:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_topology.c,v 1.10 2017/09/07 06:40:42 msaitoh Exp $	*/
+/*	$NetBSD: cpu_topology.c,v 1.11 2018/01/28 15:00:42 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2009 Mindaugas Rasiukevicius ,
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.10 2017/09/07 06:40:42 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.11 2018/01/28 15:00:42 mlelstv Exp $");
 
 #include 
 #include 
@@ -151,7 +151,10 @@ x86_cpu_topology(struct cpu_info *ci)
 	}
 
 	if (smt_bits + core_bits) {
-		ci->ci_package_id = apic_id >> (smt_bits + core_bits);
+		if (smt_bits + core_bits < sizeof(apic_id) * NBBY)
+			ci->ci_package_id = apic_id >> (smt_bits + core_bits);
+		else
+			ci->ci_package_id = 0;
 	}
 	if (core_bits) {
 		u_int core_mask = __BITS(smt_bits, smt_bits + core_bits - 1);



CVS commit: src/usr.sbin/sysinst

2018-01-28 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sun Jan 28 14:34:26 UTC 2018

Modified Files:
src/usr.sbin/sysinst: partman.c

Log Message:
Fix copy paste error. from coverity.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/sysinst/partman.c

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

Modified files:

Index: src/usr.sbin/sysinst/partman.c
diff -u src/usr.sbin/sysinst/partman.c:1.15 src/usr.sbin/sysinst/partman.c:1.16
--- src/usr.sbin/sysinst/partman.c:1.15	Thu Jan 12 17:38:08 2017
+++ src/usr.sbin/sysinst/partman.c	Sun Jan 28 14:34:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: partman.c,v 1.15 2017/01/12 17:38:08 christos Exp $ */
+/*	$NetBSD: partman.c,v 1.16 2018/01/28 14:34:26 maya Exp $ */
 
 /*
  * Copyright 2012 Eugene Lozovoy
@@ -2742,7 +2742,7 @@ partman(void)
 
 		if (!have_cgd)
 			remove_cgd_options();
-		else if (!(cgds = calloc(sizeof(*vnds), MAX_CGD)))
+		else if (!(cgds = calloc(sizeof(*cgds), MAX_CGD)))
 			have_cgd = 0;
 
 		if (!have_lvm)



CVS commit: src/sys/dev/sdmmc

2018-01-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 28 14:34:06 UTC 2018

Modified Files:
src/sys/dev/sdmmc: sdmmc_cis.c

Log Message:
Don't print an error when we find a CIS tuple code in the vendor-unique
range (80h-8Fh).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/sdmmc_cis.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/sdmmc/sdmmc_cis.c
diff -u src/sys/dev/sdmmc/sdmmc_cis.c:1.4 src/sys/dev/sdmmc/sdmmc_cis.c:1.5
--- src/sys/dev/sdmmc/sdmmc_cis.c:1.4	Wed Feb  1 22:34:43 2012
+++ src/sys/dev/sdmmc/sdmmc_cis.c	Sun Jan 28 14:34:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_cis.c,v 1.4 2012/02/01 22:34:43 matt Exp $	*/
+/*	$NetBSD: sdmmc_cis.c,v 1.5 2018/01/28 14:34:06 jmcneill Exp $	*/
 /*	$OpenBSD: sdmmc_cis.c,v 1.1 2006/06/01 21:53:41 uwe Exp $	*/
 
 /*
@@ -20,7 +20,7 @@
 /* Routines to decode the Card Information Structure of SD I/O cards */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.4 2012/02/01 22:34:43 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.5 2018/01/28 14:34:06 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -260,9 +260,14 @@ sdmmc_read_cis(struct sdmmc_function *sf
 			break;
 
 		default:
-			aprint_error_dev(dev,
-			"unknown tuple code %#x, length %d\n",
-			tplcode, tpllen);
+			/*
+			 * Tuple codes between 80h-8Fh are vendor unique.
+			 * Print a warning about all other codes.
+			 */
+			if ((tplcode & 0xf0) != 0x80)
+aprint_error_dev(dev,
+"unknown tuple code %#x, length %d\n",
+tplcode, tpllen);
 			reg += tpllen;
 			break;
 		}



CVS commit: src/sys/arch/atari/pci

2018-01-28 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jan 28 14:22:23 UTC 2018

Modified Files:
src/sys/arch/atari/pci: pci_milan.c

Log Message:
Replace CRTC register values with ones taken from sys/dev/ic/vga_subr.c.

This fixes noise around column 3 and 4 and makes screen output clearer
on Milan with S3 Trio64V.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/atari/pci/pci_milan.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/atari/pci/pci_milan.c
diff -u src/sys/arch/atari/pci/pci_milan.c:1.14 src/sys/arch/atari/pci/pci_milan.c:1.15
--- src/sys/arch/atari/pci/pci_milan.c:1.14	Fri Oct  2 05:22:50 2015
+++ src/sys/arch/atari/pci/pci_milan.c	Sun Jan 28 14:22:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_milan.c,v 1.14 2015/10/02 05:22:50 msaitoh Exp $	*/
+/*	$NetBSD: pci_milan.c,v 1.15 2018/01/28 14:22:23 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_milan.c,v 1.14 2015/10/02 05:22:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_milan.c,v 1.15 2018/01/28 14:22:23 tsutsui Exp $");
 
 #include 
 #include 
@@ -120,19 +120,41 @@ pci_intr_disestablish(pci_chipset_tag_t 
 
 /*
  * VGA related stuff...
- * XXX: Currently, you can only boot the Milan through loadbsd.ttp, hence the
- *  text mode ;-)
+ *  
  * It looks like the Milan BIOS is initializing the VGA card in a reasonably
  * standard text mode. However, the screen mode is 640*480 instead of 640*400.
  * Since wscons does not handle the right by default, the card is reprogrammed
  * to 640*400 using only 'standard' VGA registers (I hope!). So this ought to
  * work on cards other than the S3Trio card I have tested it on.
  */
-static u_char crt_tab[] = {
-	0x60, 0x53, 0x4f, 0x14, 0x56, 0x05, 0xc1, 0x1f,
-	0x00, 0x4f, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00,
-	0x98, 0x3d, 0x8f, 0x28, 0x0f, 0x8f, 0xc1, 0xc3,
-	0xff };
+static const uint8_t crt_tab[] = {
+	/* taken from vga_crtc[] in sys/dev/ic/vga_subr.c */
+	0x5f,	/* 00: horizontal total */
+	0x4f,	/* 01: horizontal display-enable end */
+	0x50,	/* 02: start horizontal blanking */
+	0x82,	/* 03: display skew control / end horizontal blanking */
+	0x55,	/* 04: start horizontal retrace pulse */
+	0x81,	/* 05: horizontal retrace delay / end horizontal retrace */
+	0xbf,	/* 06: vertical total */
+	0x1f,	/* 07: overflow register */
+	0x00,	/* 08: preset row scan */
+	0x4f,	/* 09: overflow / maximum scan line */
+	0x0d,	/* 0A: cursor off / cursor start */
+	0x0e,	/* 0B: cursor skew / cursor end */
+	0x00,	/* 0C: start regenerative buffer address high */
+	0x00,	/* 0D: start regenerative buffer address low */
+	0x00,	/* 0E: cursor location high */
+	0x00,	/* 0F: cursor location low */
+	0x9c,	/* 10: vertical retrace start */
+	0x8e,	/* 11: vertical interrupt / vertical retrace end */
+	0x8f,	/* 12: vertical display enable end */
+	0x28,	/* 13: logical line width */
+	0x00,	/* 14: underline location */
+	0x96,	/* 15: start vertical blanking */
+	0xb9,	/* 16: end vertical blanking */
+	0xa3,	/* 17: CRT mode control */
+	0xff	/* 18: line compare */
+};
 
 /*
  * XXX: Why are we repeating this everywhere! (Leo)



CVS commit: src/libexec/httpd

2018-01-28 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sun Jan 28 13:37:39 UTC 2018

Modified Files:
src/libexec/httpd: bozohttpd.c

Log Message:
Use a protocol-agnostic URL (don't degrade HTTPS->HTTP)

Suggested by Travis Paul in PR bin/52958.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/libexec/httpd/bozohttpd.c

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

Modified files:

Index: src/libexec/httpd/bozohttpd.c
diff -u src/libexec/httpd/bozohttpd.c:1.86 src/libexec/httpd/bozohttpd.c:1.87
--- src/libexec/httpd/bozohttpd.c:1.86	Sun Feb  5 01:55:03 2017
+++ src/libexec/httpd/bozohttpd.c	Sun Jan 28 13:37:39 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bozohttpd.c,v 1.86 2017/02/05 01:55:03 mrg Exp $	*/
+/*	$NetBSD: bozohttpd.c,v 1.87 2018/01/28 13:37:39 maya Exp $	*/
 
 /*	$eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $	*/
 
@@ -1990,7 +1990,7 @@ bozo_http_error(bozohttpd_t *httpd, int 
 		"%s\n"
 		"%s\n"
 		"%s%s: %s\n"
- 		"http://%s%s/\;>%s%s\n"
+ 		"%s%s\n"
 		"\n",
 		header, header,
 		user ? user : "", file,



CVS commit: src/sys/ufs/ffs

2018-01-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Jan 28 10:02:01 UTC 2018

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Prevent use-after-free where genfs_node_destroy() would destroy
a lock residing in the just freed inode data.


To generate a diff of this commit:
cvs rdiff -u -r1.355 -r1.356 src/sys/ufs/ffs/ffs_vfsops.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/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.355 src/sys/ufs/ffs/ffs_vfsops.c:1.356
--- src/sys/ufs/ffs/ffs_vfsops.c:1.355	Wed Nov 15 21:21:18 2017
+++ src/sys/ufs/ffs/ffs_vfsops.c	Sun Jan 28 10:02:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.355 2017/11/15 21:21:18 christos Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.356 2018/01/28 10:02:00 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.355 2017/11/15 21:21:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.356 2018/01/28 10:02:00 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -2024,14 +2024,14 @@ ffs_deinit_vnode(struct ufsmount *ump, s
 {
 	struct inode *ip = VTOI(vp);
 
+	genfs_node_destroy(vp);
+	vp->v_data = NULL;
+
 	if (ump->um_fstype == UFS1)
 		pool_cache_put(ffs_dinode1_cache, ip->i_din.ffs1_din);
 	else
 		pool_cache_put(ffs_dinode2_cache, ip->i_din.ffs2_din);
 	pool_cache_put(ffs_inode_cache, ip);
-
-	genfs_node_destroy(vp);
-	vp->v_data = NULL;
 }
 
 /*



CVS commit: src/sys/ufs/ufs

2018-01-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Jan 28 10:01:18 UTC 2018

Modified Files:
src/sys/ufs/ufs: ufs_inode.c

Log Message:
Make sure inode blocks and size are zero when VOP_INACTIVE()
finalises a now unlinked inode.
Counterpart of the check in ffs_newvnode().


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/ufs/ufs/ufs_inode.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/ufs/ufs/ufs_inode.c
diff -u src/sys/ufs/ufs/ufs_inode.c:1.102 src/sys/ufs/ufs/ufs_inode.c:1.103
--- src/sys/ufs/ufs/ufs_inode.c:1.102	Sat Oct 28 00:37:13 2017
+++ src/sys/ufs/ufs/ufs_inode.c	Sun Jan 28 10:01:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_inode.c,v 1.102 2017/10/28 00:37:13 pgoyette Exp $	*/
+/*	$NetBSD: ufs_inode.c,v 1.103 2018/01/28 10:01:18 hannken Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.102 2017/10/28 00:37:13 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.103 2018/01/28 10:01:18 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -149,6 +149,15 @@ out:
 	 */
 	*ap->a_recycle = (ip->i_mode == 0);
 
+	if (ip->i_mode == 0 && (DIP(ip, size) != 0 || DIP(ip, blocks) != 0)) {
+		printf("%s: unlinked ino %" PRId64 " on \"%s\" has"
+		" non zero size %" PRIx64 " or blocks %" PRIx64
+		" with allerror %d\n",
+		__func__, ip->i_number, mp->mnt_stat.f_mntonname,
+		DIP(ip, size), DIP(ip, blocks), allerror);
+		panic("%s: dirty filesystem?", __func__);
+	}
+
 	return (allerror);
 }
 



CVS commit: src/sys/arch/amiga/dev

2018-01-28 Thread Jukka Andberg
Module Name:src
Committed By:   jandberg
Date:   Sun Jan 28 10:00:31 UTC 2018

Modified Files:
src/sys/arch/amiga/dev: amidisplaycc.c

Log Message:
Make the console framebuffer visible when polling mode console input is used.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/amiga/dev/amidisplaycc.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/amiga/dev/amidisplaycc.c
diff -u src/sys/arch/amiga/dev/amidisplaycc.c:1.30 src/sys/arch/amiga/dev/amidisplaycc.c:1.31
--- src/sys/arch/amiga/dev/amidisplaycc.c:1.30	Sat Feb  6 20:20:18 2016
+++ src/sys/arch/amiga/dev/amidisplaycc.c	Sun Jan 28 10:00:31 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: amidisplaycc.c,v 1.30 2016/02/06 20:20:18 jandberg Exp $ */
+/*	$NetBSD: amidisplaycc.c,v 1.31 2018/01/28 10:00:31 jandberg Exp $ */
 
 /*-
  * Copyright (c) 2000 Jukka Andberg.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amidisplaycc.c,v 1.30 2016/02/06 20:20:18 jandberg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amidisplaycc.c,v 1.31 2018/01/28 10:00:31 jandberg Exp $");
 
 /*
  * wscons interface to amiga custom chips. Contains the necessary functions
@@ -438,6 +438,7 @@ amidisplaycc_attach(device_t parent, dev
 		   aga_enable ? "(AGA)" : "");
 
 		if (amidisplaycc_consolescreen.isconsole) {
+			amidisplaycc_consolescreen.device = adp;
 			adp->currentscreen = _consolescreen;
 			printf(" (console)");
 		} else
@@ -1060,11 +1061,6 @@ amidisplaycc_ioctl(void *dp, void *vs, u
 	   (struct wsdisplay_cmap*)data));
 	}
 
-	dprintf("amidisplaycc: unknown ioctl %lx (grp:'%c' num:%d)\n",
-		(long)cmd,
-		(char)((cmd&0xff00)>>8),
-		(int)(cmd&0xff));
-
 	return (EPASSTHROUGH);
 
 #undef UINTDATA
@@ -1878,6 +1874,22 @@ amidisplaycc_getbuiltinfont(void)
 void
 amidisplaycc_pollc(void *cookie, int on)
 {
+	if (amidisplaycc_consolescreen.isconsole)
+	{
+		if (on) 
+		{
+			/* About to use console, so make it visible */
+			grf_display_view(amidisplaycc_consolescreen.view);
+		}
+		if (!on && 
+		amidisplaycc_consolescreen.isconsole && 
+		amidisplaycc_consolescreen.device != NULL && 
+		amidisplaycc_consolescreen.device->currentscreen != NULL) 
+		{
+			/* Restore the correct view after done with console use */
+			grf_display_view(amidisplaycc_consolescreen.device->currentscreen->view);
+		}
+	}
 }
 
 /*