CVS commit: [nick-nhusb] src/sys/dev/usb

2017-09-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep  5 07:01:12 UTC 2017

Modified Files:
src/sys/dev/usb [nick-nhusb]: ehci.c

Log Message:
#ifdef DIAGNOSTIC -> KASSERT and add another KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.234.2.109 -r1.234.2.110 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.234.2.109 src/sys/dev/usb/ehci.c:1.234.2.110
--- src/sys/dev/usb/ehci.c:1.234.2.109	Mon Aug 28 17:52:27 2017
+++ src/sys/dev/usb/ehci.c	Tue Sep  5 07:01:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.234.2.109 2017/08/28 17:52:27 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.234.2.110 2017/09/05 07:01:12 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.109 2017/08/28 17:52:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.110 2017/09/05 07:01:12 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -3154,10 +3154,8 @@ ehci_abort_xfer(struct usbd_xfer *xfer, 
 	 */
 	if (xfer->ux_hcflags & UXFER_ABORTING) {
 		DPRINTF("already aborting", 0, 0, 0, 0);
-#ifdef DIAGNOSTIC
-		if (status == USBD_TIMEOUT)
-			printf("ehci_abort_xfer: TIMEOUT while aborting\n");
-#endif
+		KASSERT(status != USBD_TIMEOUT);
+
 		/* Override the status which might be USBD_TIMEOUT. */
 		xfer->ux_status = status;
 		DPRINTF("waiting for abort to finish", 0, 0, 0, 0);
@@ -3313,10 +3311,7 @@ ehci_abort_isoc_xfer(struct usbd_xfer *x
 	if (xfer->ux_hcflags & UXFER_ABORTING) {
 		DPRINTF("already aborting", 0, 0, 0, 0);
 
-#ifdef DIAGNOSTIC
-		if (status == USBD_TIMEOUT)
-			printf("ehci_abort_isoc_xfer: TIMEOUT while aborting\n");
-#endif
+		KASSERT(status != USBD_TIMEOUT);
 
 		xfer->ux_status = status;
 		DPRINTF("waiting for abort to finish", 0, 0, 0, 0);
@@ -3445,6 +3440,7 @@ ehci_timeout_task(void *addr)
 	DPRINTF("xfer=%p", xfer, 0, 0, 0);
 
 	mutex_enter(&sc->sc_lock);
+	KASSERT(xfer->ux_status == USBD_TIMEOUT);
 	ehci_abort_xfer(xfer, USBD_TIMEOUT);
 	mutex_exit(&sc->sc_lock);
 }



CVS commit: [nick-nhusb] src/sys/dev/usb

2017-09-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep  5 07:04:17 UTC 2017

Modified Files:
src/sys/dev/usb [nick-nhusb]: if_kue.c if_kuereg.h

Log Message:
WIP MPification


To generate a diff of this commit:
cvs rdiff -u -r1.81.4.14 -r1.81.4.15 src/sys/dev/usb/if_kue.c
cvs rdiff -u -r1.18.24.3 -r1.18.24.4 src/sys/dev/usb/if_kuereg.h

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/if_kue.c
diff -u src/sys/dev/usb/if_kue.c:1.81.4.14 src/sys/dev/usb/if_kue.c:1.81.4.15
--- src/sys/dev/usb/if_kue.c:1.81.4.14	Mon Aug 28 17:52:27 2017
+++ src/sys/dev/usb/if_kue.c	Tue Sep  5 07:04:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_kue.c,v 1.81.4.14 2017/08/28 17:52:27 skrll Exp $	*/
+/*	$NetBSD: if_kue.c,v 1.81.4.15 2017/09/05 07:04:17 skrll Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.81.4.14 2017/08/28 17:52:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.81.4.15 2017/09/05 07:04:17 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -166,15 +166,20 @@ CFATTACH_DECL_NEW(kue, sizeof(struct kue
 kue_detach, kue_activate);
 
 static int kue_tx_list_init(struct kue_softc *);
+static void kue_tx_list_free(struct kue_softc *);
 static int kue_rx_list_init(struct kue_softc *);
+static void kue_rx_list_free(struct kue_softc *);
 static int kue_send(struct kue_softc *, struct mbuf *, int);
 static int kue_open_pipes(struct kue_softc *);
 static void kue_rxeof(struct usbd_xfer *, void *, usbd_status);
 static void kue_txeof(struct usbd_xfer *, void *, usbd_status);
 static void kue_start(struct ifnet *);
+static void kue_start_locked(struct ifnet *);
 static int kue_ioctl(struct ifnet *, u_long, void *);
 static void kue_init(void *);
+static void kue_init_locked(void *);
 static void kue_stop(struct kue_softc *);
+static void kue_stop_locked(struct kue_softc *);
 static void kue_watchdog(struct ifnet *);
 
 static void kue_setmulti(struct kue_softc *);
@@ -398,7 +403,6 @@ kue_attach(device_t parent, device_t sel
 	struct kue_softc *sc = device_private(self);
 	struct usb_attach_arg *uaa = aux;
 	char			*devinfop;
-	int			s;
 	struct ifnet		*ifp;
 	struct usbd_device *	dev = uaa->uaa_device;
 	struct usbd_interface *	iface;
@@ -479,8 +483,6 @@ kue_attach(device_t parent, device_t sel
 	sc->kue_mcfilters = kmem_alloc(KUE_MCFILTCNT(sc) * ETHER_ADDR_LEN,
 	KM_SLEEP);
 
-	s = splnet();
-
 	/*
 	 * A KLSI chip was detected. Inform the world.
 	 */
@@ -506,7 +508,6 @@ kue_attach(device_t parent, device_t sel
 	RND_TYPE_NET, RND_FLAG_DEFAULT);
 
 	sc->kue_attached = true;
-	splx(s);
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->kue_udev, sc->kue_dev);
 
@@ -599,6 +600,18 @@ kue_rx_list_init(struct kue_softc *sc)
 	return 0;
 }
 
+static void
+kue_rx_list_free(struct kue_softc *sc)
+{
+	/* Free RX resources. */
+	for (int i = 0; i < KUE_RX_LIST_CNT; i++) {
+		if (sc->kue_cdata.kue_rx_chain[i].kue_xfer != NULL) {
+			usbd_destroy_xfer(sc->kue_cdata.kue_rx_chain[i].kue_xfer);
+			sc->kue_cdata.kue_rx_chain[i].kue_xfer = NULL;
+		}
+	}
+}
+
 static int
 kue_tx_list_init(struct kue_softc *sc)
 {
@@ -625,6 +638,18 @@ kue_tx_list_init(struct kue_softc *sc)
 	return 0;
 }
 
+static void
+kue_tx_list_free(struct kue_softc *sc)
+{
+	/* Free TX resources. */
+	for (int i = 0; i < KUE_TX_LIST_CNT; i++) {
+		if (sc->kue_cdata.kue_tx_chain[i].kue_xfer != NULL) {
+			usbd_destroy_xfer(sc->kue_cdata.kue_tx_chain[i].kue_xfer);
+			sc->kue_cdata.kue_tx_chain[i].kue_xfer = NULL;
+		}
+	}
+}
+
 /*
  * A frame has been uploaded: pass the resulting mbuf chain up to
  * the higher level protocols.
@@ -813,6 +838,17 @@ kue_send(struct kue_softc *sc, struct mb
 static void
 kue_start(struct ifnet *ifp)
 {
+	struct kue_softc *sc = ifp->if_softc;
+	KASSERT(ifp->if_extflags & IFEF_START_MPSAFE);
+
+	mutex_enter(&sc->kue_txlock);
+	kue_start_locked(ifp);
+	mutex_exit(&sc->kue_txlock);
+}
+
+static void
+kue_start_locked(struct ifnet *ifp)
+{
 	struct kue_softc	*sc = ifp->if_softc;
 	struct mbuf		*m;
 
@@ -853,9 +889,18 @@ kue_start(struct ifnet *ifp)
 static void
 kue_init(void *xsc)
 {
+	struct kue_softc *sc = xsc;
+
+	mutex_enter(&sc->kue_lock);
+	kue_init_locked(xsc);
+	mutex_exit(&sc->kue_lock);
+}
+
+static void
+kue_init_locked(void *xsc)
+{
 	struct kue_softc	*sc = xsc;
 	struct ifnet		*ifp = GET_IFP(sc);
-	int			s;
 	uint8_t			eaddr[ETHER_ADDR_LEN];
 
 	DPRINTFN(5,("%s: %s: enter\n", device_xname(sc->kue_dev),__func__));
@@ -863,8 +908,6 @@ kue_init(void *xsc)
 	if (ifp->if_flags & IFF_RUNNING)
 		return;
 
-	s = splnet();
-
 	memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr));
 	/* Set MAC address */
 	kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SET_MAC, 0, eaddr, ETHER_ADDR_LEN);
@@ -892,21 +935,18 @@ kue_init(void *xsc)
 
 	if (sc->kue_ep[KUE_ENDPT_RX] == NULL) {
 		if (kue_open_pipes(sc)) {
-			splx(s);
 			retu

CVS commit: [nick-nhusb] src/sys/dev/usb

2017-09-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep  5 07:06:30 UTC 2017

Modified Files:
src/sys/dev/usb [nick-nhusb]: if_upl.c

Log Message:
Remove unnecessary splnet from upl_attach


To generate a diff of this commit:
cvs rdiff -u -r1.47.4.16 -r1.47.4.17 src/sys/dev/usb/if_upl.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/if_upl.c
diff -u src/sys/dev/usb/if_upl.c:1.47.4.16 src/sys/dev/usb/if_upl.c:1.47.4.17
--- src/sys/dev/usb/if_upl.c:1.47.4.16	Sun Feb  5 13:40:46 2017
+++ src/sys/dev/usb/if_upl.c	Tue Sep  5 07:06:30 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_upl.c,v 1.47.4.16 2017/02/05 13:40:46 skrll Exp $	*/
+/*	$NetBSD: if_upl.c,v 1.47.4.17 2017/09/05 07:06:30 skrll Exp $	*/
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.47.4.16 2017/02/05 13:40:46 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.47.4.17 2017/09/05 07:06:30 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -220,7 +220,6 @@ upl_attach(device_t parent, device_t sel
 	struct upl_softc *sc = device_private(self);
 	struct usb_attach_arg *uaa = aux;
 	char			*devinfop;
-	int			s;
 	struct usbd_device *	dev = uaa->uaa_device;
 	struct usbd_interface *	iface;
 	usbd_status		err;
@@ -285,8 +284,6 @@ upl_attach(device_t parent, device_t sel
 		return;
 	}
 
-	s = splnet();
-
 	/* Initialize interface info.*/
 	ifp = &sc->sc_if;
 	ifp->if_softc = sc;
@@ -316,7 +313,6 @@ upl_attach(device_t parent, device_t sel
 	RND_TYPE_NET, RND_FLAG_DEFAULT);
 
 	sc->sc_attached = 1;
-	splx(s);
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev);
 



CVS commit: [nick-nhusb] src/sys/dev/usb

2017-09-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep  5 07:07:15 UTC 2017

Modified Files:
src/sys/dev/usb [nick-nhusb]: TODO.usbmp

Log Message:
Update


To generate a diff of this commit:
cvs rdiff -u -r1.8.4.13 -r1.8.4.14 src/sys/dev/usb/TODO.usbmp

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/TODO.usbmp
diff -u src/sys/dev/usb/TODO.usbmp:1.8.4.13 src/sys/dev/usb/TODO.usbmp:1.8.4.14
--- src/sys/dev/usb/TODO.usbmp:1.8.4.13	Tue Feb 14 06:45:21 2017
+++ src/sys/dev/usb/TODO.usbmp	Tue Sep  5 07:07:15 2017
@@ -1,4 +1,4 @@
-$NetBSD: TODO.usbmp,v 1.8.4.13 2017/02/14 06:45:21 skrll Exp $
+$NetBSD: TODO.usbmp,v 1.8.4.14 2017/09/05 07:07:15 skrll Exp $
 
 
 the majority of the USB MP device interface is documented in usbdivar.h.
@@ -23,7 +23,6 @@ usb_detach_{waitold,wakeup} to cv_{wait,
   if_aue.c
   if_axe.c
   if_axen.c
-  if_smsc.c
   if_udav.c
   if_url.c
   ubt.c
@@ -73,7 +72,6 @@ splusb drivers:
   - if_otus.c
   - if_rum.c
   - if_run.c
-  - if_smsc.c
   - if_udav.c
   - if_upl.c
   - if_ural.c
@@ -121,7 +119,6 @@ missing CALLOUT_MPSAFE drivers:
   - if_otus.c
   - if_rum.c
   - if_run.c
-  - if_smsc.c
   - if_udav.c
   - if_upgt.c
   - if_ural.c
@@ -144,7 +141,6 @@ missing USB_TASKQ_MPSAFE tasks:
   - if_otus.c
   - if_rum.c
   - if_run.c
-  - if_smsc.c
   - if_udav.c
   - if_upgt.c
   - if_ural.c



CVS commit: src/sys/dev/pci

2017-09-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep  5 08:01:43 UTC 2017

Modified Files:
src/sys/dev/pci: files.pci xhci_pci.c

Log Message:
Add an XHCI_DISABLE_MSI option


To generate a diff of this commit:
cvs rdiff -u -r1.390 -r1.391 src/sys/dev/pci/files.pci
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/xhci_pci.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/files.pci
diff -u src/sys/dev/pci/files.pci:1.390 src/sys/dev/pci/files.pci:1.391
--- src/sys/dev/pci/files.pci:1.390	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/files.pci	Tue Sep  5 08:01:43 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.390 2017/08/30 08:49:18 msaitoh Exp $
+#	$NetBSD: files.pci,v 1.391 2017/09/05 08:01:43 skrll Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -635,6 +635,7 @@ file	dev/pci/usb_pci.c		ehci_pci | ehci_
 # xHCI USB controller
 attach	xhci at pci with xhci_pci
 file	dev/pci/xhci_pci.c		xhci_pci
+defflag	opt_xhci_pci.h			XHCI_DISABLE_MSI
 
 # OHCI IEEE 1394 controller
 attach	fwohci at pci with fwohci_pci

Index: src/sys/dev/pci/xhci_pci.c
diff -u src/sys/dev/pci/xhci_pci.c:1.8 src/sys/dev/pci/xhci_pci.c:1.9
--- src/sys/dev/pci/xhci_pci.c:1.8	Thu Jan 19 16:05:00 2017
+++ src/sys/dev/pci/xhci_pci.c	Tue Sep  5 08:01:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.8 2017/01/19 16:05:00 skrll Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.9 2017/09/05 08:01:43 skrll Exp $	*/
 /*	OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp	*/
 
 /*
@@ -32,7 +32,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.8 2017/01/19 16:05:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.9 2017/09/05 08:01:43 skrll Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_xhci_pci.h"
+#endif
 
 #include 
 #include 
@@ -173,8 +177,16 @@ xhci_pci_attach(device_t parent, device_
 	pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG,
 		   csr | PCI_COMMAND_MASTER_ENABLE);
 
+	/* Allocation settings */
+	int counts[PCI_INTR_TYPE_SIZE] = {
+		[PCI_INTR_TYPE_INTX] = 1,
+#ifndef XHCI_DISABLE_MSI
+		[PCI_INTR_TYPE_MSI] = 1,
+#endif
+	};
+
 	/* Allocate and establish the interrupt. */
-	if (pci_intr_alloc(pa, &psc->sc_pihp, NULL, 0)) {
+	if (pci_intr_alloc(pa, &psc->sc_pihp, counts, PCI_INTR_TYPE_MSIX)) {
 		aprint_error_dev(self, "can't allocate handler\n");
 		goto fail;
 	}



CVS commit: src/sys/external/bsd/ipf/netinet

2017-09-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep  5 11:12:33 UTC 2017

Modified Files:
src/sys/external/bsd/ipf/netinet: fil.c

Log Message:
Revert changing the byte order of fi->fi_addr. It is already correct. From
Timo Buhrmester
XXX: pullup 8.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/external/bsd/ipf/netinet/fil.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/ipf/netinet/fil.c
diff -u src/sys/external/bsd/ipf/netinet/fil.c:1.20 src/sys/external/bsd/ipf/netinet/fil.c:1.21
--- src/sys/external/bsd/ipf/netinet/fil.c:1.20	Sun Apr 23 16:47:22 2017
+++ src/sys/external/bsd/ipf/netinet/fil.c	Tue Sep  5 07:12:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fil.c,v 1.20 2017/04/23 20:47:22 christos Exp $	*/
+/*	$NetBSD: fil.c,v 1.21 2017/09/05 11:12:32 christos Exp $	*/
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -138,7 +138,7 @@ extern struct timeout ipf_slowtimer_ch;
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.20 2017/04/23 20:47:22 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.21 2017/09/05 11:12:32 christos Exp $");
 #else
 static const char sccsid[] = "@(#)fil.c	1.36 6/5/96 (C) 1993-2000 Darren Reed";
 static const char rcsid[] = "@(#)Id: fil.c,v 1.1.1.2 2012/07/22 13:45:07 darrenr Exp $";
@@ -1709,7 +1709,7 @@ ipf_pr_ipv4hdr(fr_info_t *fin)
 	fin->fin_crc += fi->fi_saddr;
 	fi->fi_daddr = ip->ip_dst.s_addr;
 	fin->fin_crc += fi->fi_daddr;
-	if (IN_CLASSD(ntohl(fi->fi_daddr)))
+	if (IN_CLASSD(fi->fi_daddr))
 		fin->fin_flx |= FI_MULTICAST|FI_MBCAST;
 
 	/*



CVS commit: src/external/bsd/dhcpcd/dist/src

2017-09-05 Thread Benny Siegert
Module Name:src
Committed By:   bsiegert
Date:   Tue Sep  5 11:58:55 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c

Log Message:
dhcp: Fix classless static routes

Assign the netwask correctly from the message.

Cherry-picked from upstream in
https://dev.marples.name/rDHC510c760cb24ef4b1b16cc14732c5ffe0fbb0d96d.

This fixes route assignments when running on Google Compute Engine,
which uses classless static routes.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r1.2 src/external/bsd/dhcpcd/dist/src/dhcp.c

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

Modified files:

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.1.1.3 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.2
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.1.1.3	Fri Apr 14 09:53:07 2017
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Tue Sep  5 11:58:55 2017
@@ -452,7 +452,7 @@ decode_rfc3442_rt(struct rt_head *routes
 		}
 
 		sa_in_init(&rt->rt_dest, &dest);
-		sa_in_init(&rt->rt_dest, &netmask);
+		sa_in_init(&rt->rt_netmask, &netmask);
 		sa_in_init(&rt->rt_gateway, &gateway);
 
 		/* If CIDR is 32 then it's a host route. */



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

2017-09-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Sep  5 17:21:09 UTC 2017

Modified Files:
src/sys/arch/macppc/dev: ki2c.c

Log Message:
first step to clean up & bus-spacification:
- use i2c addresses with the direction bit shifted out in iic_exec and when
  attaching drivers so things attaching to iic* have a chance of working
- add an empty i2c-devices prop_array_t to keep drivers we don't want from
  attaching to iic*
- printf -> DPRINTF / aprint_*
- usa mapiodev() for now to make this work on G5


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/macppc/dev/ki2c.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/macppc/dev/ki2c.c
diff -u src/sys/arch/macppc/dev/ki2c.c:1.19 src/sys/arch/macppc/dev/ki2c.c:1.20
--- src/sys/arch/macppc/dev/ki2c.c:1.19	Sun Feb 14 19:54:20 2016
+++ src/sys/arch/macppc/dev/ki2c.c	Tue Sep  5 17:21:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ki2c.c,v 1.19 2016/02/14 19:54:20 chs Exp $	*/
+/*	$NetBSD: ki2c.c,v 1.20 2017/09/05 17:21:09 macallan Exp $	*/
 /*	Id: ki2c.c,v 1.7 2002/10/05 09:56:05 tsubai Exp	*/
 
 /*-
@@ -37,6 +37,12 @@
 
 #include 
 
+#ifdef KI2C_DEBUG
+#define DPRINTF printf
+#else
+#define DPRINTF while (0) printf
+#endif
+
 int ki2c_match(device_t, cfdata_t, void *);
 void ki2c_attach(device_t, device_t, void *);
 inline u_int ki2c_readreg(struct ki2c_softc *, int);
@@ -79,10 +85,12 @@ ki2c_attach(device_t parent, device_t se
 	struct ki2c_softc *sc = device_private(self);
 	struct confargs *ca = aux;
 	int node = ca->ca_node;
+	uint32_t addr;
 	int rate, child, namelen, i2cbus;
 	struct ki2c_confargs ka;
 	struct i2cbus_attach_args iba;
-
+	prop_dictionary_t dict = device_properties(self);
+	prop_array_t cfg;
 	char name[32];
 	u_int reg[20];
 
@@ -90,15 +98,16 @@ ki2c_attach(device_t parent, device_t se
 	ca->ca_reg[0] += ca->ca_baseaddr;
 
 	if (OF_getprop(node, "AAPL,i2c-rate", &rate, 4) != 4) {
-		printf(": cannot get i2c-rate\n");
+		aprint_error(": cannot get i2c-rate\n");
 		return;
 	}
-	if (OF_getprop(node, "AAPL,address", &sc->sc_reg, 4) != 4) {
-		printf(": unable to find i2c address\n");
+	if (OF_getprop(node, "AAPL,address", &addr, 4) != 4) {
+		aprint_error(": unable to find i2c address\n");
 		return;
 	}
+	sc->sc_reg = mapiodev(addr, PAGE_SIZE, false);
 	if (OF_getprop(node, "AAPL,address-step", &sc->sc_regstep, 4) != 4) {
-		printf(": unable to find i2c address step\n");
+		aprint_error(": unable to find i2c address step\n");
 		return;
 	}
 
@@ -114,6 +123,10 @@ ki2c_attach(device_t parent, device_t se
 	mutex_init(&sc->sc_buslock, MUTEX_DEFAULT, IPL_NONE);
 	ki2c_writereg(sc, IER,I2C_INT_DATA|I2C_INT_ADDR|I2C_INT_STOP);
 	
+	cfg = prop_array_create();
+	prop_dictionary_set(dict, "i2c-child-devices", cfg);
+	prop_object_release(cfg);
+
 	/* fill in the i2c tag */
 	sc->sc_i2c.ic_cookie = sc;
 	sc->sc_i2c.ic_acquire_bus = ki2c_i2c_acquire_bus;
@@ -162,7 +175,7 @@ ki2c_attach(device_t parent, device_t se
 			sizeof(reg));
 		}
 		if (ok > 0) {
-			ka.ka_addr = reg[0];
+			ka.ka_addr = reg[0] >> 1;
 			ka.ka_tag = &sc->sc_i2c;	
 			config_found_ia(self, "ki2c", &ka, ki2c_print);
 		} 
@@ -315,7 +328,7 @@ ki2c_poll(struct ki2c_softc *sc, int tim
 			ki2c_intr(sc);
 		timo -= 100;
 		if (timo < 0) {
-			printf("i2c_poll: timeout\n");
+			DPRINTF("i2c_poll: timeout\n");
 			return -1;
 		}
 		delay(100);
@@ -350,7 +363,7 @@ ki2c_start(struct ki2c_softc *sc, int ad
 	if (ki2c_poll(sc, timo))
 		return -1;
 	if (sc->sc_flags & I2C_ERROR) {
-		printf("I2C_ERROR\n");
+		DPRINTF("I2C_ERROR\n");
 		return -1;
 	}
 	return 0;
@@ -360,9 +373,7 @@ int
 ki2c_read(struct ki2c_softc *sc, int addr, int subaddr, void *data, int len)
 {
 	sc->sc_flags = I2C_READING;
-	#ifdef KI2C_DEBUG
-		printf("ki2c_read: %02x %d\n", addr, len);
-	#endif
+	DPRINTF("ki2c_read: %02x %d\n", addr, len);
 	return ki2c_start(sc, addr, subaddr, data, len);
 }
 
@@ -370,9 +381,7 @@ int
 ki2c_write(struct ki2c_softc *sc, int addr, int subaddr, void *data, int len)
 {
 	sc->sc_flags = 0;
-	#ifdef KI2C_DEBUG
-		printf("ki2c_write: %02x %d\n",addr,len);
-	#endif
+	DPRINTF("ki2c_write: %02x %d\n",addr,len);
 	return ki2c_start(sc, addr, subaddr, data, len);
 }
 
@@ -442,11 +451,11 @@ ki2c_i2c_exec(void *cookie, i2c_op_t op,
 		}
 	}
 
-	if (ki2c_write(sc, addr, 0, wp, w_len) !=0 )
+	if (ki2c_write(sc, addr << 1, 0, wp, w_len) !=0 )
 		return -1;
 
 	if (I2C_OP_READ_P(op)) {
-		if (ki2c_read(sc, addr, 0, vbuf, buflen) !=0 )
+		if (ki2c_read(sc, addr << 1, 0, vbuf, buflen) !=0 )
 			return -1;
 	}
 	return 0;



CVS commit: src/lib/libedit

2017-09-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep  5 18:07:59 UTC 2017

Modified Files:
src/lib/libedit: el.c el.h readline.c tty.c

Log Message:
For readline emulation, don't reset the tty to "sane" (cooked) mode if we
did not start this way. Also set and reset the tty on entry and exit from
readline() since this is what readline does.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/lib/libedit/el.c
cvs rdiff -u -r1.42 -r1.43 src/lib/libedit/el.h
cvs rdiff -u -r1.142 -r1.143 src/lib/libedit/readline.c
cvs rdiff -u -r1.65 -r1.66 src/lib/libedit/tty.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/libedit/el.c
diff -u src/lib/libedit/el.c:1.94 src/lib/libedit/el.c:1.95
--- src/lib/libedit/el.c:1.94	Tue Jun 27 19:25:13 2017
+++ src/lib/libedit/el.c	Tue Sep  5 14:07:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: el.c,v 1.94 2017/06/27 23:25:13 christos Exp $	*/
+/*	$NetBSD: el.c,v 1.95 2017/09/05 18:07:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)el.c	8.2 (Berkeley) 1/3/94";
 #else
-__RCSID("$NetBSD: el.c,v 1.94 2017/06/27 23:25:13 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.95 2017/09/05 18:07:59 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -67,9 +67,9 @@ el_init(const char *prog, FILE *fin, FIL
 	fileno(ferr));
 }
 
-EditLine *
-el_init_fd(const char *prog, FILE *fin, FILE *fout, FILE *ferr,
-int fdin, int fdout, int fderr)
+libedit_private EditLine *
+el_init_internal(const char *prog, FILE *fin, FILE *fout, FILE *ferr,
+int fdin, int fdout, int fderr, int flags)
 {
 	EditLine *el = el_malloc(sizeof(*el));
 
@@ -95,7 +95,7 @@ el_init_fd(const char *prog, FILE *fin, 
 	/*
  * Initialize all the modules. Order is important!!!
  */
-	el->el_flags = 0;
+	el->el_flags = flags;
 	if (setlocale(LC_CTYPE, NULL) != NULL){
 		if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
 			el->el_flags |= CHARSET_IS_UTF8;
@@ -123,6 +123,12 @@ el_init_fd(const char *prog, FILE *fin, 
 	return el;
 }
 
+EditLine *
+el_init_fd(const char *prog, FILE *fin, FILE *fout, FILE *ferr,
+int fdin, int fdout, int fderr)
+{
+	return el_init_internal(prog, fin, fout, ferr, fdin, fdout, fderr, 0);
+}
 
 /* el_end():
  *	Clean up.

Index: src/lib/libedit/el.h
diff -u src/lib/libedit/el.h:1.42 src/lib/libedit/el.h:1.43
--- src/lib/libedit/el.h:1.42	Tue Jun 27 19:25:13 2017
+++ src/lib/libedit/el.h	Tue Sep  5 14:07:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: el.h,v 1.42 2017/06/27 23:25:13 christos Exp $	*/
+/*	$NetBSD: el.h,v 1.43 2017/09/05 18:07:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -57,6 +57,7 @@
 #define	UNBUFFERED	0x08
 #define	CHARSET_IS_UTF8 0x10
 #define	NARROW_HISTORY	0x40
+#define	NO_RESET	0x80
 
 typedef unsigned char el_action_t;	/* Index to command array	*/
 
@@ -141,6 +142,8 @@ struct editline {
 };
 
 libedit_private int	el_editmode(EditLine *, int, const wchar_t **);
+libedit_private EditLine *el_init_internal(const char *, FILE *, FILE *,
+FILE *, int, int, int, int);
 
 #ifdef DEBUG
 #define	EL_ABORT(a)	do { \

Index: src/lib/libedit/readline.c
diff -u src/lib/libedit/readline.c:1.142 src/lib/libedit/readline.c:1.143
--- src/lib/libedit/readline.c:1.142	Fri Sep  1 06:19:10 2017
+++ src/lib/libedit/readline.c	Tue Sep  5 14:07:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: readline.c,v 1.142 2017/09/01 10:19:10 christos Exp $	*/
+/*	$NetBSD: readline.c,v 1.143 2017/09/05 18:07:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.142 2017/09/01 10:19:10 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.143 2017/09/05 18:07:59 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include 
@@ -290,7 +290,9 @@ rl_initialize(void)
 	if (tcgetattr(fileno(rl_instream), &t) != -1 && (t.c_lflag & ECHO) == 0)
 		editmode = 0;
 
-	e = el_init(rl_readline_name, rl_instream, rl_outstream, stderr);
+	e = el_init_internal(rl_readline_name, rl_instream, rl_outstream,
+	stderr, fileno(rl_instream), fileno(rl_outstream), fileno(stderr),
+	NO_RESET);
 
 	if (!editmode)
 		el_set(e, EL_EDITMODE, 0);
@@ -386,6 +388,8 @@ rl_initialize(void)
 	_resize_fun(e, &rl_line_buffer);
 	_rl_update_pos();
 
+	tty_end(e);
+
 	return 0;
 }
 
@@ -410,15 +414,17 @@ readline(const char *p)
 		rl_did_startup_hook = 1;
 		(*rl_startup_hook)(NULL, 0);
 	}
+	tty_init(e);
 
 
 	rl_done = 0;
 
 	(void)setjmp(topbuf);
+	buf = NULL;
 
 	/* update prompt accordingly to what has been passed */
 	if (rl_set_prompt(prompt) == -1)
-		return NULL;
+		goto out;
 
 	if (rl_pre_input_hook)
 		(*rl_pre_input_hook)(NULL, 0);
@@ -443,7 +449,7 @@ readline(const char *p)
 
 		buf = strdup(ret);
 		if (buf == NULL)
-			return NULL;
+			goto out;
 		lastidx = count - 1;
 		if (bu

CVS commit: src/sbin/gpt

2017-09-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep  5 18:30:46 UTC 2017

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

Log Message:
PR/52522: Piotr Meyer: Don't NUL terminate the gpt label name.
XXX: pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sbin/gpt/gpt.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/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.70 src/sbin/gpt/gpt.c:1.71
--- src/sbin/gpt/gpt.c:1.70	Wed Feb 15 22:32:17 2017
+++ src/sbin/gpt/gpt.c	Tue Sep  5 14:30:46 2017
@@ -35,7 +35,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.70 2017/02/16 03:32:17 christos Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.71 2017/09/05 18:30:46 christos Exp $");
 #endif
 
 #include 
@@ -224,7 +224,6 @@ utf8_to_utf16(const uint8_t *s8, uint16_
 			} else
 s16[s16idx++] = htole16((uint16_t)utfchar);
 			if (s16idx == s16len) {
-s16[--s16idx] = 0;
 return;
 			}
 		}



CVS commit: src/sys/arch/macppc/macppc

2017-09-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Sep  6 03:10:09 UTC 2017

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
downgrade some debug spam to aprint_debug() where it belongs


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/arch/macppc/macppc/machdep.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/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.166 src/sys/arch/macppc/macppc/machdep.c:1.167
--- src/sys/arch/macppc/macppc/machdep.c:1.166	Fri Aug 11 22:55:49 2017
+++ src/sys/arch/macppc/macppc/machdep.c	Wed Sep  6 03:10:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.166 2017/08/11 22:55:49 macallan Exp $	*/
+/*	$NetBSD: machdep.c,v 1.167 2017/09/06 03:10:09 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.166 2017/08/11 22:55:49 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.167 2017/09/06 03:10:09 macallan Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -331,14 +331,14 @@ copy_disp_props(device_t dev, int node, 
 			prop_dictionary_set_uint32(dict, "address", fbaddr);
 	}
 	if (of_to_dataprop(dict, node, "EDID", "EDID")) {
-		aprint_verbose("found EDID property...\n");
+		aprint_debug("found EDID property...\n");
 	} else if (of_to_dataprop(dict, node, "EDID,A", "EDID")) {
-		aprint_verbose("found EDID,A\n");
+		aprint_debug("found EDID,A\n");
 	} else if (of_to_dataprop(dict, node, "EDID,B", "EDID")) {
 		memset(name, 0, sizeof(name));
 		OF_getprop(node, "name", name, sizeof(name));
 		if (strcmp(name, "NVDA,NVMac") == 0) {
-			aprint_verbose("found EDID,B on nvidia - assuming digital output\n");
+			aprint_debug("found EDID,B on nvidia - assuming digital output\n");
 			prop_dictionary_set_bool(dict, "no_palette_control", 1);
 			have_palette = 0;
 		}



CVS commit: src/usr.bin/vmstat

2017-09-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Sep  6 06:05:23 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Don't print "nan" when there is no disk activity.


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/usr.bin/vmstat/vmstat.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.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.217 src/usr.bin/vmstat/vmstat.c:1.218
--- src/usr.bin/vmstat/vmstat.c:1.217	Tue Jul  4 21:19:33 2017
+++ src/usr.bin/vmstat/vmstat.c	Wed Sep  6 06:05:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.217 2017/07/04 21:19:33 mlelstv Exp $ */
+/* $NetBSD: vmstat.c,v 1.218 2017/09/06 06:05:23 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.217 2017/07/04 21:19:33 mlelstv Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.218 2017/09/06 06:05:23 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -1123,8 +1123,11 @@ drvstats(int *ovflwp)
 
 	for (dn = 0; dn < ndrive; ++dn) {
 		/* elapsed time for disk stats */
-		dtime = (double)cur.timestamp[dn].tv_sec +
-			((double)cur.timestamp[dn].tv_usec / (double)100);
+		dtime = cur.cp_etime;
+		if (cur.timestamp[dn].tv_sec || cur.timestamp[dn].tv_usec) {
+			dtime = (double)cur.timestamp[dn].tv_sec +
+((double)cur.timestamp[dn].tv_usec / (double)100);
+		}
 
 		if (!drv_select[dn])
 	 		continue;