CVS commit: src/sys/dev/pci

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Dec 24 06:27:17 UTC 2019

Modified Files:
src/sys/dev/pci: ichsmb.c piixpm.c

Log Message:
Make ichsmb and piixpm MP-safe:
- Synchronize with the interrupt handler using a mutex.
- Use a condvar to wait for completion, rather than tsleep().
- Mark our interrupt handler as such.

Also, other general correctness fixes:
- Loop around testing the completion condition to protect aginst
  spurious wakes.
- The "i2c exec" function returns an error code, so actually do so.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/pci/ichsmb.c
cvs rdiff -u -r1.59 -r1.60 src/sys/dev/pci/piixpm.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/ichsmb.c
diff -u src/sys/dev/pci/ichsmb.c:1.64 src/sys/dev/pci/ichsmb.c:1.65
--- src/sys/dev/pci/ichsmb.c:1.64	Mon Dec 23 15:34:40 2019
+++ src/sys/dev/pci/ichsmb.c	Tue Dec 24 06:27:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichsmb.c,v 1.64 2019/12/23 15:34:40 thorpej Exp $	*/
+/*	$NetBSD: ichsmb.c,v 1.65 2019/12/24 06:27:17 thorpej Exp $	*/
 /*	$OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $	*/
 
 /*
@@ -22,13 +22,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.64 2019/12/23 15:34:40 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.65 2019/12/24 06:27:17 thorpej Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -62,13 +63,17 @@ struct ichsmb_softc {
 	int			sc_poll;
 	pci_intr_handle_t	*sc_pihp;
 
+	kmutex_t		sc_exec_lock;
+	kcondvar_t		sc_exec_wait;
+
 	struct i2c_controller	sc_i2c_tag;
 	struct {
 		i2c_op_t op;
 		void *   buf;
 		size_t   len;
 		int  flags;
-		volatile int error;
+		int  error;
+		bool done;
 	}			sc_i2c_xfer;
 	device_t		sc_i2c_device;
 };
@@ -161,6 +166,9 @@ ichsmb_attach(device_t parent, device_t 
 
 	pci_aprint_devinfo(pa, NULL);
 
+	mutex_init(>sc_exec_lock, MUTEX_DEFAULT, IPL_BIO);
+	cv_init(>sc_exec_wait, device_xname(self));
+
 	/* Read configuration */
 	conf = pci_conf_read(pa->pa_pc, pa->pa_tag, LPCIB_SMB_HOSTC);
 	DPRINTF(("%s: conf 0x%08x\n", device_xname(sc->sc_dev), conf));
@@ -187,6 +195,8 @@ ichsmb_attach(device_t parent, device_t 
 		if (pci_intr_alloc(pa, >sc_pihp, NULL, 0) == 0) {
 			intrstr = pci_intr_string(pa->pa_pc, sc->sc_pihp[0],
 			intrbuf, sizeof(intrbuf));
+			pci_intr_setattr(pa->pa_pc, >sc_pihp[0],
+			PCI_INTR_MPSAFE, true);
 			sc->sc_ih = pci_intr_establish_xname(pa->pa_pc,
 			sc->sc_pihp[0], IPL_BIO, ichsmb_intr, sc,
 			device_xname(sc->sc_dev));
@@ -262,6 +272,9 @@ ichsmb_detach(device_t self, int flags)
 	if (sc->sc_size != 0)
 		bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_size);
 
+	mutex_destroy(>sc_exec_lock);
+	cv_destroy(>sc_exec_wait);
+
 	return 0;
 }
 
@@ -288,6 +301,8 @@ ichsmb_i2c_exec(void *cookie, i2c_op_t o
 	"flags 0x%02x\n", device_xname(sc->sc_dev), op, addr, cmdlen,
 	len, flags));
 
+	mutex_enter(>sc_exec_lock);
+
 	/* Clear status bits */
 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HS,
 	LPCIB_SMB_HS_INTR | LPCIB_SMB_HS_DEVERR |
@@ -306,15 +321,19 @@ ichsmb_i2c_exec(void *cookie, i2c_op_t o
 	snprintb(fbuf, sizeof(fbuf), LPCIB_SMB_HS_BITS, st);
 	printf("%s: exec: st %s\n", device_xname(sc->sc_dev), fbuf);
 #endif
-	if (st & LPCIB_SMB_HS_BUSY)
-		return (1);
+	if (st & LPCIB_SMB_HS_BUSY) {
+		mutex_exit(>sc_exec_lock);
+		return (EBUSY);
+	}
 
 	if (sc->sc_poll)
 		flags |= I2C_F_POLL;
 
 	if (!I2C_OP_STOP_P(op) || cmdlen > 1 || len > 2 ||
-	(cmdlen == 0 && len > 1))
-		return (1);
+	(cmdlen == 0 && len > 1)) {
+		mutex_exit(>sc_exec_lock);
+		return (EINVAL);
+	}
 
 	/* Setup transfer */
 	sc->sc_i2c_xfer.op = op;
@@ -322,6 +341,7 @@ ichsmb_i2c_exec(void *cookie, i2c_op_t o
 	sc->sc_i2c_xfer.len = len;
 	sc->sc_i2c_xfer.flags = flags;
 	sc->sc_i2c_xfer.error = 0;
+	sc->sc_i2c_xfer.done = false;
 
 	/* Set slave address and transfer direction */
 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_TXSLVA,
@@ -380,14 +400,17 @@ ichsmb_i2c_exec(void *cookie, i2c_op_t o
 		ichsmb_intr(sc);
 	} else {
 		/* Wait for interrupt */
-		if (tsleep(sc, PRIBIO, "iicexec", ICHIIC_TIMEOUT * hz))
-			goto timeout;
+		while (! sc->sc_i2c_xfer.done) {
+			if (cv_timedwait(>sc_exec_wait, >sc_exec_lock,
+	 ICHIIC_TIMEOUT * hz))
+goto timeout;
+		}
 	}
 
-	if (sc->sc_i2c_xfer.error)
-		return (1);
+	int error = sc->sc_i2c_xfer.error;
+	mutex_exit(>sc_exec_lock);
 
-	return (0);
+	return (error);
 
 timeout:
 	/*
@@ -408,7 +431,8 @@ timeout:
 		fbuf);
 	}
 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HS, st);
-	return (1);
+	mutex_exit(>sc_exec_lock);
+	return (ETIMEDOUT);
 }
 
 static int
@@ -435,12 +459,15 @@ ichsmb_intr(void *arg)
 	printf("%s: intr st %s\n", device_xname(sc->sc_dev), fbuf);
 #endif
 
+	if ((sc->sc_i2c_xfer.flags & 

CVS commit: src/sys/dev/ic

2019-12-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 24 05:00:19 UTC 2019

Modified Files:
src/sys/dev/ic: gem.c

Log Message:
Fix error path in gem(4)'s TX checksum offload.

 - Avoid accessing free'd m0 on error. Use m_freem() instead of m_free().
   Reported by maxv@.
 - Tested by martin@, macallan@ and jdc@.


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/dev/ic/gem.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/ic/gem.c
diff -u src/sys/dev/ic/gem.c:1.123 src/sys/dev/ic/gem.c:1.124
--- src/sys/dev/ic/gem.c:1.123	Wed Dec  4 08:21:43 2019
+++ src/sys/dev/ic/gem.c	Tue Dec 24 05:00:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: gem.c,v 1.123 2019/12/04 08:21:43 msaitoh Exp $ */
+/*	$NetBSD: gem.c,v 1.124 2019/12/24 05:00:19 msaitoh Exp $ */
 
 /*
  *
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.123 2019/12/04 08:21:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.124 2019/12/24 05:00:19 msaitoh Exp $");
 
 #include "opt_inet.h"
 
@@ -1388,6 +1388,7 @@ gem_start(struct ifnet *ifp)
 	 * until we drain the queue, or use up all available transmit
 	 * descriptors.
 	 */
+next:
 	while ((txs = SIMPLEQ_FIRST(>sc_txfreeq)) != NULL &&
 	sc->sc_txfree != 0) {
 		/*
@@ -1497,16 +1498,9 @@ gem_start(struct ifnet *ifp)
 			 * and the checksum stuff if we want the hardware
 			 * to do it.
 			 */
-			sc->sc_txdescs[nexttx].gd_addr =
-			GEM_DMA_WRITE(sc, dmamap->dm_segs[seg].ds_addr);
 			flags = dmamap->dm_segs[seg].ds_len & GEM_TD_BUFSIZE;
 			if (nexttx == firsttx) {
 flags |= GEM_TD_START_OF_PACKET;
-if (++sc->sc_txwin > GEM_NTXSEGS * 2 / 3) {
-	sc->sc_txwin = 0;
-	flags |= GEM_TD_INTERRUPT_ME;
-}
-
 #ifdef INET
 /* h/w checksum */
 if (ifp->if_csum_flags_tx & M_CSUM_TCPv4 &&
@@ -1525,8 +1519,10 @@ gem_start(struct ifnet *ifp)
 		break;
 	default:
 		/* unsupported, drop it */
-		m_free(m0);
-		continue;
+		bus_dmamap_unload(sc->sc_dmatag,
+			dmamap);
+		m_freem(m0);
+		goto next;
 	}
 	start += M_CSUM_DATA_IPv4_IPHL(m0->m_pkthdr.csum_data);
 	offset = M_CSUM_DATA_IPv4_OFFSET(m0->m_pkthdr.csum_data) + start;
@@ -1537,7 +1533,13 @@ gem_start(struct ifnet *ifp)
 		 GEM_TD_CXSUM_ENABLE;
 }
 #endif
+if (++sc->sc_txwin > GEM_NTXSEGS * 2 / 3) {
+	sc->sc_txwin = 0;
+	flags |= GEM_TD_INTERRUPT_ME;
+}
 			}
+			sc->sc_txdescs[nexttx].gd_addr =
+			GEM_DMA_WRITE(sc, dmamap->dm_segs[seg].ds_addr);
 			if (seg == dmamap->dm_nsegs - 1) {
 flags |= GEM_TD_END_OF_PACKET;
 			} else {



CVS commit: src/sys/dev/pci

2019-12-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 24 03:43:34 UTC 2019

Modified Files:
src/sys/dev/pci: piixpm.c piixpmreg.h

Log Message:
Don't force using SMBUS0SEL register.

- Use it depending on USE_SMBUS0SEL bit.
- If we use SMBUS0EN_LO register to select the port, update the port
  select bits only.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/pci/piixpm.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/piixpmreg.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/pci/piixpm.c
diff -u src/sys/dev/pci/piixpm.c:1.58 src/sys/dev/pci/piixpm.c:1.59
--- src/sys/dev/pci/piixpm.c:1.58	Mon Dec 23 23:41:43 2019
+++ src/sys/dev/pci/piixpm.c	Tue Dec 24 03:43:34 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpm.c,v 1.58 2019/12/23 23:41:43 msaitoh Exp $ */
+/* $NetBSD: piixpm.c,v 1.59 2019/12/24 03:43:34 msaitoh Exp $ */
 /*	$OpenBSD: piixpm.c,v 1.39 2013/10/01 20:06:02 sf Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.58 2019/12/23 23:41:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.59 2019/12/24 03:43:34 msaitoh Exp $");
 
 #include 
 #include 
@@ -86,6 +86,7 @@ struct piixpm_softc {
 	bus_space_handle_t	sc_smb_ioh;
 	void *			sc_smb_ih;
 	int			sc_poll;
+	bool			sc_sb800_selen; /* Use SMBUS0SEL */
 
 	pci_chipset_tag_t	sc_pc;
 	pcitag_t		sc_pcitag;
@@ -419,6 +420,8 @@ piixpm_sb800_init(struct piixpm_softc *s
 		val = bus_space_read_1(iot, ioh, SB800_INDIRECTIO_DATA) << 8;
 		base_addr = val;
 	} else {
+		uint8_t data;
+
 		bus_space_write_1(iot, ioh, SB800_INDIRECTIO_INDEX,
 		SB800_PM_SMBUS0EN_LO);
 		val = bus_space_read_1(iot, ioh, SB800_INDIRECTIO_DATA);
@@ -433,8 +436,9 @@ piixpm_sb800_init(struct piixpm_softc *s
 
 		bus_space_write_1(iot, ioh, SB800_INDIRECTIO_INDEX,
 		SB800_PM_SMBUS0SELEN);
-		bus_space_write_1(iot, ioh, SB800_INDIRECTIO_DATA,
-		SB800_PM_SMBUS0EN_ENABLE);
+		data = bus_space_read_1(iot, ioh, SB800_INDIRECTIO_DATA);
+		if ((data & SB800_PM_USE_SMBUS0SEL) != 0)
+			sc->sc_sb800_selen = true;
 	}
 
 	sc->sc_sb800_ioh = ioh;
@@ -482,10 +486,23 @@ piixpm_i2c_acquire_bus(void *cookie, int
 		bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
 		SB800_INDIRECTIO_DATA, smbus->sda << 3);
 	} else if (PIIXPM_IS_SB800GRP(sc) || PIIXPM_IS_HUDSON(sc)) {
-		bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
-		SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0SEL);
-		bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
-		SB800_INDIRECTIO_DATA, smbus->sda << 1);
+		if (sc->sc_sb800_selen) {
+			bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+			SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0SEL);
+			bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+			SB800_INDIRECTIO_DATA,
+			__SHIFTIN(smbus->sda, SB800_PM_SMBUS0_MASK_E));
+		} else {
+			uint8_t data;
+
+			bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+			SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0EN_LO);
+			data = bus_space_read_1(sc->sc_iot, sc->sc_sb800_ioh,
+			SB800_INDIRECTIO_DATA) & ~SB800_PM_SMBUS0_MASK_C;
+			data |= __SHIFTIN(smbus->sda, SB800_PM_SMBUS0_MASK_C);
+			bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+			SB800_INDIRECTIO_DATA, data);
+		}
 	}
 
 	return 0;
@@ -500,17 +517,29 @@ piixpm_i2c_release_bus(void *cookie, int
 	if (PIIXPM_IS_KERNCZ(sc)) {
 		bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
 		SB800_INDIRECTIO_INDEX, AMDFCH41_PM_PORT_INDEX);
+		/* Set to port 0 */
 		bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
 		SB800_INDIRECTIO_DATA, 0);
 	} else if (PIIXPM_IS_SB800GRP(sc) || PIIXPM_IS_HUDSON(sc)) {
-		/*
-		 * HP Microserver hangs after reboot if not set to SDA0.
-		 * Also add shutdown hook?
-		 */
-		bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
-		SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0SEL);
-		bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
-		SB800_INDIRECTIO_DATA, 0);
+		if (sc->sc_sb800_selen) {
+			bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+			SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0SEL);
+
+			/* Set to port 0 */
+			bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+			SB800_INDIRECTIO_DATA, 0);
+		} else {
+			uint8_t data;
+
+			bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+			SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0EN_LO);
+
+			/* Set to port 0 */
+			data = bus_space_read_1(sc->sc_iot, sc->sc_sb800_ioh,
+			SB800_INDIRECTIO_DATA) & ~SB800_PM_SMBUS0_MASK_C;
+			bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+			SB800_INDIRECTIO_DATA, data);
+		}
 	}
 }
 

Index: src/sys/dev/pci/piixpmreg.h
diff -u src/sys/dev/pci/piixpmreg.h:1.9 src/sys/dev/pci/piixpmreg.h:1.10
--- src/sys/dev/pci/piixpmreg.h:1.9	Mon Dec 23 23:41:43 2019
+++ src/sys/dev/pci/piixpmreg.h	Tue Dec 24 03:43:34 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpmreg.h,v 1.9 2019/12/23 23:41:43 msaitoh Exp $ */
+/* $NetBSD: piixpmreg.h,v 1.10 2019/12/24 03:43:34 msaitoh Exp $ */
 

CVS commit: src/sys/dev/pci

2019-12-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 23 23:41:43 UTC 2019

Modified Files:
src/sys/dev/pci: piixpm.c piixpmreg.h

Log Message:
- Read SB800_SMB_HOSTC correctly. This register is not in the PCI config space
  but in the I/O space.
- The bit 0 of SB800_SMB_HOSTC is 0 on SMI or 1 on IRQ, so invert the check.
- Modify comment.
- Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/dev/pci/piixpm.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/piixpmreg.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/pci/piixpm.c
diff -u src/sys/dev/pci/piixpm.c:1.57 src/sys/dev/pci/piixpm.c:1.58
--- src/sys/dev/pci/piixpm.c:1.57	Mon Dec 23 23:31:23 2019
+++ src/sys/dev/pci/piixpm.c	Mon Dec 23 23:41:43 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpm.c,v 1.57 2019/12/23 23:31:23 msaitoh Exp $ */
+/* $NetBSD: piixpm.c,v 1.58 2019/12/23 23:41:43 msaitoh Exp $ */
 /*	$OpenBSD: piixpm.c,v 1.39 2013/10/01 20:06:02 sf Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.57 2019/12/23 23:31:23 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.58 2019/12/23 23:41:43 msaitoh Exp $");
 
 #include 
 #include 
@@ -231,12 +231,9 @@ nopowermanagement:
 	if (PIIXPM_IS_FCHGRP(sc) || PIIXPM_IS_SB800GRP(sc)) {
 		if (piixpm_sb800_init(sc) == 0) {
 			/* Read configuration */
-			conf = pci_conf_read(pa->pa_pc, pa->pa_tag,
-			SB800_SMB_HOSTC);
-			DPRINTF(("%s: conf 0x%08x\n", device_xname(self),
-conf));
-
-			usesmi = conf & SB800_SMB_HOSTC_SMI;
+			conf = bus_space_read_1(sc->sc_iot,
+			sc->sc_smb_ioh, SB800_SMB_HOSTC);
+			usesmi = ((conf & SB800_SMB_HOSTC_IRQ) == 0);
 			goto setintr;
 		}
 		aprint_normal_dev(self, "SMBus initialization failed\n");
@@ -444,7 +441,7 @@ piixpm_sb800_init(struct piixpm_softc *s
 	aprint_debug_dev(sc->sc_dev, "SMBus @ 0x%04x\n", base_addr);
 
 	if (bus_space_map(iot, PCI_MAPREG_IO_ADDR(base_addr),
-	PIIX_SMB_SIZE, 0, >sc_smb_ioh)) {
+	SB800_SMB_SIZE, 0, >sc_smb_ioh)) {
 		aprint_error_dev(sc->sc_dev, "can't map smbus I/O space\n");
 		return EBUSY;
 	}

Index: src/sys/dev/pci/piixpmreg.h
diff -u src/sys/dev/pci/piixpmreg.h:1.8 src/sys/dev/pci/piixpmreg.h:1.9
--- src/sys/dev/pci/piixpmreg.h:1.8	Sat Jul 13 09:24:17 2019
+++ src/sys/dev/pci/piixpmreg.h	Mon Dec 23 23:41:43 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpmreg.h,v 1.8 2019/07/13 09:24:17 msaitoh Exp $ */
+/* $NetBSD: piixpmreg.h,v 1.9 2019/12/23 23:41:43 msaitoh Exp $ */
 /*	$OpenBSD: piixreg.h,v 1.3 2006/01/03 22:39:03 grange Exp $	*/
 
 /*-
@@ -66,7 +66,7 @@
 #define PIIX_SMB_HOSTC	0xd0		/* SMBus host configuration */
 #define PIIX_SMB_HOSTC_HSTEN	(1 << 16)	/* enable host controller */
 #define PIIX_SMB_HOSTC_SMI	(0 << 17)	/* SMI */
-#define PIIX_SMB_HOSTC_IRQ	(4 << 17)	/* IRQ */
+#define PIIX_SMB_HOSTC_IRQ	(4 << 17)	/* IRQ 9 */
 #define PIIX_SMB_HOSTC_INTMASK	(7 << 17)
 
 /* SMBus I/O registers */
@@ -113,18 +113,21 @@
 #define SB800_INDIRECTIO_SIZE	2 
 #define SB800_INDIRECTIO_INDEX	0
 #define SB800_INDIRECTIO_DATA	1
- 
+
 #define SB800_PM_SMBUS0EN_LO	0x2c
 #define SB800_PM_SMBUS0EN_HI	0x2d
 #define SB800_PM_SMBUS0SEL	0x2e 
 #define SB800_PM_SMBUS0SELEN	0x2f 
-  
+
 #define SB800_PM_SMBUS0EN_ENABLE 0x0001
 #define SB800_PM_SMBUS0EN_BADDR	0xffe0
 
-/* In the PCI config space */
+/* In the SMBus I/O space */
 #define SB800_SMB_HOSTC		0x10	/* I2C bus configuration */
-#define SB800_SMB_HOSTC_SMI	(1 << 0)	/* SMI */
+#define SB800_SMB_HOSTC_IRQ	(1 << 0)	/* 0:SMI 1:IRQ */
+
+/* Misc */
+#define SB800_SMB_SIZE	0x11		/* SMBus I/O space size */
 
 /*
  * Newer FCH registers in the PMIO space.



CVS commit: src/share/misc

2019-12-23 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Dec 23 23:31:18 UTC 2019

Modified Files:
src/share/misc: acronyms

Log Message:
AVB


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/share/misc/acronyms

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

Modified files:

Index: src/share/misc/acronyms
diff -u src/share/misc/acronyms:1.290 src/share/misc/acronyms:1.291
--- src/share/misc/acronyms:1.290	Mon Nov 11 04:11:53 2019
+++ src/share/misc/acronyms	Mon Dec 23 23:31:18 2019
@@ -1,4 +1,4 @@
-$NetBSD: acronyms,v 1.290 2019/11/11 04:11:53 pgoyette Exp $
+$NetBSD: acronyms,v 1.291 2019/12/23 23:31:18 sevan Exp $
 10Q	thank you
 10X	thanks
 1337	elite ("leet")
@@ -44,6 +44,7 @@ ATEOTD	at the end of the day
 ATM	at the moment
 ATM	{automated,automatic} teller machine
 ATW	around the world
+AVB	alcohol by volume
 AVI	automatic vehicle identification
 AWK	Aho, Weinberger, [and] Kernighan
 AWOL	absent without official leave



CVS commit: src/sys/dev/pci

2019-12-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 23 23:31:23 UTC 2019

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

Log Message:
 Fix number of port for Hudson rev. 0x1f and newer. Same as OpenBSD and Linux.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/pci/piixpm.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/piixpm.c
diff -u src/sys/dev/pci/piixpm.c:1.56 src/sys/dev/pci/piixpm.c:1.57
--- src/sys/dev/pci/piixpm.c:1.56	Mon Dec 23 15:41:34 2019
+++ src/sys/dev/pci/piixpm.c	Mon Dec 23 23:31:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpm.c,v 1.56 2019/12/23 15:41:34 thorpej Exp $ */
+/* $NetBSD: piixpm.c,v 1.57 2019/12/23 23:31:23 msaitoh Exp $ */
 /*	$OpenBSD: piixpm.c,v 1.39 2013/10/01 20:06:02 sf Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.56 2019/12/23 15:41:34 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.57 2019/12/23 23:31:23 msaitoh Exp $");
 
 #include 
 #include 
@@ -230,8 +230,6 @@ nopowermanagement:
 	/* SB800 rev 0x40+, AMD HUDSON and newer need special initialization */
 	if (PIIXPM_IS_FCHGRP(sc) || PIIXPM_IS_SB800GRP(sc)) {
 		if (piixpm_sb800_init(sc) == 0) {
-			sc->sc_numbusses = 4;
-
 			/* Read configuration */
 			conf = pci_conf_read(pa->pa_pc, pa->pa_tag,
 			SB800_SMB_HOSTC);
@@ -399,6 +397,12 @@ piixpm_sb800_init(struct piixpm_softc *s
 	uint16_t val, base_addr;
 	bool enabled;
 
+	if (PIIXPM_IS_KERNCZ(sc) ||
+	(PIIXPM_IS_HUDSON(sc) && (sc->sc_rev >= 0x1f)))
+		sc->sc_numbusses = 2;
+	else
+		sc->sc_numbusses = 4;
+
 	/* Fetch SMB base address */
 	if (bus_space_map(iot,
 	SB800_INDIRECTIO_BASE, SB800_INDIRECTIO_SIZE, 0, )) {



CVS commit: src/doc

2019-12-23 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Dec 23 23:12:00 UTC 2019

Modified Files:
src/doc: 3RDPARTY

Log Message:
bsd-family-tree


To generate a diff of this commit:
cvs rdiff -u -r1.1681 -r1.1682 src/doc/3RDPARTY

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1681 src/doc/3RDPARTY:1.1682
--- src/doc/3RDPARTY:1.1681	Sun Dec 22 12:59:12 2019
+++ src/doc/3RDPARTY	Mon Dec 23 23:12:00 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1681 2019/12/22 12:59:12 wiz Exp $
+#	$NetBSD: 3RDPARTY,v 1.1682 2019/12/23 23:12:00 sevan Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -195,12 +195,12 @@ Todo[4]: Re-entrant functions of net/*
 Todo[5]: Reconcile the doc directory.
 
 Package:	bsd-family-tree
-Version:	354417
-Current Vers:	354417
+Version:	355063
+Current Vers:	355063
 Maintainer:	The FreeBSD Project
 Archive Site:	https://svnweb.freebsd.org/base/head/share/misc/bsd-family-tree
 Home Page:	https://svnweb.freebsd.org/base/head/share/misc/bsd-family-tree
-Date:		2019-11-06
+Date:		2019-12-23
 Mailing List:
 Responsible:
 License:	BSD (2-clause) (see http://www.freebsd.org/cgi/cvsweb.cgi/src/COPYRIGHT)



CVS commit: src/share/misc

2019-12-23 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Dec 23 23:11:01 UTC 2019

Modified Files:
src/share/misc: bsd-family-tree

Log Message:
Update to r355063


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/share/misc/bsd-family-tree

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

Modified files:

Index: src/share/misc/bsd-family-tree
diff -u src/share/misc/bsd-family-tree:1.76 src/share/misc/bsd-family-tree:1.77
--- src/share/misc/bsd-family-tree:1.76	Wed Nov  6 23:43:35 2019
+++ src/share/misc/bsd-family-tree	Mon Dec 23 23:11:01 2019
@@ -400,14 +400,14 @@ FreeBSD 5.2   |  |  
  | |  |   |  |   8.1  |DragonFly 5.6
  | |  |   |  |||
  | |  |   |  ||DragonFly 5.6.1
- | |   FreeBSD|  |||
- | | 11.3 |  |||
+ | |   FreeBSD  macOS|||
+ | | 11.3   10.15|||
  |  FreeBSD   |  |OpenBSD 6.6  |
- |   12.1 |  |||
- | |  |  |||
+ |   12.1   macOS|||
+ | |   10.15.1   ||DragonFly 5.6.2
  | v  |  |||
  ||  |||
-FreeBSD 13 -current   |  NetBSD -current   OpenBSD -current   DragonFly -current
+FreeBSD 13 -current   |  NetBSD -current   OpenBSD -currentDragonFly -current
  ||  |||
  vv  vvv
 
@@ -793,7 +793,10 @@ NetBSD 8.1		2019-06-04 [NBD]
 DragonFly 5.6		2019-06-17 [DFB]
 DragonFly 5.6.1		2019-06-19 [DFB]
 FreeBSD 11.3		2019-07-09 [FBD]
+DragonFly 5.6.2		2019-08-11 [DFB]
 OpenBSD 6.6		2019-10-17 [OBD]
+macOS 10.15		2019-10-07 [APL]
+macOS 10.15.1		2019-10-29 [APL] (security/critical release)
 FreeBSD 12.1		2019-11-04 [FBD]
 
 Bibliography
@@ -859,5 +862,5 @@ Steven M. Schultz for providing 2.8BSD, 
 Copyright (c) 1997-2012 Wolfram Schneider 
 URL: https://svnweb.freebsd.org/base/head/share/misc/bsd-family-tree
 
-$FreeBSD: head/share/misc/bsd-family-tree 354417 2019-11-06 23:40:09Z sevan $
-$NetBSD: bsd-family-tree,v 1.76 2019/11/06 23:43:35 sevan Exp $
+$FreeBSD: head/share/misc/bsd-family-tree 355063 2019-11-24 19:16:57Z eadler $
+$NetBSD: bsd-family-tree,v 1.77 2019/12/23 23:11:01 sevan Exp $



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 21:24:59 UTC 2019

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

Log Message:
- No need to use I2C_F_POLL here.
- Refactor register read / write functions, splitting out i2c bus
  acquire / release everywhere.  This fixes what was almost certainly
  a deadlock in the FDT regulator section of the code (acquire bus ->
  read register, which again acquires bus -> locking against myself).


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/i2c/tps65217pmic.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/tps65217pmic.c
diff -u src/sys/dev/i2c/tps65217pmic.c:1.14 src/sys/dev/i2c/tps65217pmic.c:1.15
--- src/sys/dev/i2c/tps65217pmic.c:1.14	Sun Nov  3 22:55:34 2019
+++ src/sys/dev/i2c/tps65217pmic.c	Mon Dec 23 21:24:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tps65217pmic.c,v 1.14 2019/11/03 22:55:34 jmcneill Exp $ */
+/*	$NetBSD: tps65217pmic.c,v 1.15 2019/12/23 21:24:59 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 #include "opt_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tps65217pmic.c,v 1.14 2019/11/03 22:55:34 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tps65217pmic.c,v 1.15 2019/12/23 21:24:59 thorpej Exp $");
 
 #include 
 #include 
@@ -146,12 +146,14 @@ struct tps_reg_param {
 	bool is_xadj;			/* voltage is adjusted externally */
 
 	uint16_t current_voltage;	/* in mV */
-
 };
 
 static int tps65217pmic_match(device_t, cfdata_t, void *);
 static void tps65217pmic_attach(device_t, device_t, void *);
 
+static int tps65217pmic_i2c_lock(struct tps65217pmic_softc *);
+static void tps65217pmic_i2c_unlock(struct tps65217pmic_softc *);
+
 static uint8_t tps65217pmic_reg_read(struct tps65217pmic_softc *, uint8_t);
 static void tps65217pmic_reg_write(struct tps65217pmic_softc *, uint8_t,
 uint8_t);
@@ -398,11 +400,19 @@ tps65217pmic_power_monitor_init(struct t
 	intrmask = TPS65217PMIC_INT_USBM | TPS65217PMIC_INT_ACM |
 	TPS65217PMIC_INT_PBM;
 
+	if (tps65217pmic_i2c_lock(sc) != 0) {
+		aprint_error_dev(sc->sc_dev,
+		"failed to initialize power monitor\n");
+		return;
+	}
+
 	status = tps65217pmic_reg_read(sc, TPS65217PMIC_STATUS);
 	ppath = tps65217pmic_reg_read(sc, TPS65217PMIC_PPATH);
 	/* acknowledge and disregard whatever interrupt was generated earlier */
 	intr = tps65217pmic_reg_read(sc, TPS65217PMIC_INT);
 
+	tps65217pmic_i2c_unlock(sc);
+
 	sc->sc_usbstatus = status & TPS65217PMIC_STATUS_USBPWR;
 	sc->sc_acstatus = status & TPS65217PMIC_STATUS_ACPWR;
 	sc->sc_usbenabled = ppath & TPS65217PMIC_PPATH_USB_EN;
@@ -430,7 +440,14 @@ tps65217pmic_power_monitor_task(void *au
 
 	mutex_enter(>sc_lock);
 
+	if (tps65217pmic_i2c_lock(sc) != 0) {
+		device_printf(sc->sc_dev,
+		"WARNING: unable to perform power monitor task.\n");
+		return;
+	}
 	status = tps65217pmic_reg_read(sc, TPS65217PMIC_STATUS);
+	tps65217pmic_i2c_unlock(sc);
+
 	usbstatus = status & TPS65217PMIC_STATUS_USBPWR;
 	acstatus = status & TPS65217PMIC_STATUS_ACPWR;
 
@@ -510,11 +527,19 @@ tps65217pmic_wled_init(struct tps65217pm
 		return;
 	}
 
+	if (tps65217pmic_i2c_lock(sc) != 0) {
+		device_printf(sc->sc_dev,
+		"WARNING: unable to configure LED\n");
+		return;
+	}
+
 	tps65217pmic_reg_write(sc, TPS65217PMIC_WLEDCTRL1, val);
 	tps65217pmic_reg_write(sc, TPS65217PMIC_WLEDCTRL2,
 	(brightness - 1) & TPS65217PMIC_WLEDCTRL2_DUTY);
 	val |= TPS65217PMIC_WLEDCTRL1_ISINK_EN;
 	tps65217pmic_reg_write(sc, TPS65217PMIC_WLEDCTRL1, val);
+
+	tps65217pmic_i2c_unlock(sc);
 }
 
 static void
@@ -523,10 +548,18 @@ tps65217pmic_reg_refresh(struct tps65217
 	int i;
 	struct tps_reg_param *c_reg;
 
+	if (tps65217pmic_i2c_lock(sc) != 0) {
+		device_printf(sc->sc_dev,
+		"WARNING: unable to refresh regulators\n");
+		return;
+	}
+
 	for (i = 0; i < NTPS_REG; i++) {
 		c_reg = _regulators[i];
 		tps65217pmic_regulator_read_config(sc, c_reg);
 	}
+
+	tps65217pmic_i2c_unlock(sc);
 }
 
 /* Get version and revision of the chip. */
@@ -535,8 +568,16 @@ tps65217pmic_version(struct tps65217pmic
 {
 	uint8_t chipid;
 
+	if (tps65217pmic_i2c_lock(sc) != 0) {
+		device_printf(sc->sc_dev,
+		"WARNING: unable to get chip ID\n");
+		return;
+	}
+
 	chipid = tps65217pmic_reg_read(sc, TPS65217PMIC_CHIPID);
 
+	tps65217pmic_i2c_unlock(sc);
+
 	sc->sc_version = chipid & TPS65217PMIC_CHIPID_VER_MASK;
 	sc->sc_revision = chipid & TPS65217PMIC_CHIPID_REV_MASK;
 }
@@ -694,32 +735,45 @@ tps65217pmic_print_ppath(struct tps65217
 	aprint_normal("\n");
 }
 
+static int
+tps65217pmic_i2c_lock(struct tps65217pmic_softc *sc)
+{
+	int error;
+
+	error = iic_acquire_bus(sc->sc_tag, 0);
+	if (error) {
+		device_printf(sc->sc_dev,
+		"unable to acquire i2c bus, error %d\n", error);
+	}
+	return error;
+}
+
+static void
+tps65217pmic_i2c_unlock(struct tps65217pmic_softc *sc)
+{
+	iic_release_bus(sc->sc_tag, 

CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 20:49:09 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.  Also fix an uninitialized error variable
in tea5767_read().


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/tea5767.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/tea5767.c
diff -u src/sys/dev/i2c/tea5767.c:1.1 src/sys/dev/i2c/tea5767.c:1.2
--- src/sys/dev/i2c/tea5767.c:1.1	Fri Jul 27 12:02:26 2018
+++ src/sys/dev/i2c/tea5767.c	Mon Dec 23 20:49:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tea5767.c,v 1.1 2018/07/27 12:02:26 rkujawa Exp $	*/
+/*	$NetBSD: tea5767.c,v 1.2 2019/12/23 20:49:09 thorpej Exp $	*/
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tea5767.c,v 1.1 2018/07/27 12:02:26 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tea5767.c,v 1.2 2019/12/23 20:49:09 thorpej Exp $");
 
 #include 
 #include 
@@ -151,22 +151,22 @@ tea5767_write(struct tea5767_softc *sc, 
 {
 	int exec_result;
 
-	if (iic_acquire_bus(sc->sc_i2c_tag, I2C_F_POLL)) {
+	if (iic_acquire_bus(sc->sc_i2c_tag, 0)) {
 		device_printf(sc->sc_dev, "bus acquiration failed.\n");
 		return 1;
 	}
 
 	exec_result = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
-	sc->sc_addr, NULL, 0, reg, 5, I2C_F_POLL);
+	sc->sc_addr, NULL, 0, reg, 5, 0);
 
 	if (exec_result) {
-		iic_release_bus(sc->sc_i2c_tag, I2C_F_POLL);
+		iic_release_bus(sc->sc_i2c_tag, 0);
 		device_printf(sc->sc_dev, "write operation failed %d.\n",
 		exec_result);
 		return 1;
 	}
 
-	iic_release_bus(sc->sc_i2c_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_i2c_tag, 0);
 
 	return 0;
 }
@@ -177,21 +177,21 @@ tea5767_read(struct tea5767_softc *sc, u
 {
 	int exec_result;
 
-	if (iic_acquire_bus(sc->sc_i2c_tag, I2C_F_POLL)) {
+	if (iic_acquire_bus(sc->sc_i2c_tag, 0)) {
 		device_printf(sc->sc_dev, "bus acquiration failed.\n");
 		return 1;
 	}
 
-	iic_exec(sc->sc_i2c_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
-	NULL, 0, reg, 5, I2C_F_POLL);
+	exec_result = iic_exec(sc->sc_i2c_tag, I2C_OP_READ_WITH_STOP,
+	sc->sc_addr, NULL, 0, reg, 5, 0);
 
 	if (exec_result) {
-		iic_release_bus(sc->sc_i2c_tag, I2C_F_POLL);
+		iic_release_bus(sc->sc_i2c_tag, 0);
 		device_printf(sc->sc_dev, "read operation failed.\n");
 		return 1;
 	}
 
-	iic_release_bus(sc->sc_i2c_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_i2c_tag, 0);
 	return 0;
 }
 



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 20:38:08 UTC 2019

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

Log Message:
- Don't use I2C_F_POLL.
- Don't access the i2c from hard interrupt context.  Instead, schedule a
  soft interrupt to do the real work.  (No need to mask the interrupt
  source, since this device has an edge-sensitive interrupt per the DT
  info; will need to be revisited if there's ever a flavor that uses a
  level-sensitive interrupt).
- Split out the i2c bus acquire / release from the register read / write
  functions, allowing us to batch several i2c transactions under a single
  acquire / release cycle.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/i2c/tcakp.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/tcakp.c
diff -u src/sys/dev/i2c/tcakp.c:1.10 src/sys/dev/i2c/tcakp.c:1.11
--- src/sys/dev/i2c/tcakp.c:1.10	Wed Oct 17 16:56:40 2018
+++ src/sys/dev/i2c/tcakp.c	Mon Dec 23 20:38:08 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: tcakp.c,v 1.10 2018/10/17 16:56:40 jmcneill Exp $ */
+/* $NetBSD: tcakp.c,v 1.11 2019/12/23 20:38:08 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcakp.c,v 1.10 2018/10/17 16:56:40 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcakp.c,v 1.11 2019/12/23 20:38:08 thorpej Exp $");
 
 #include 
 #include 
@@ -99,6 +99,7 @@ struct tcakp_softc {
 	uint16_t	sc_keymap[128];
 
 	void		*sc_ih;
+	void		*sc_sih;
 
 	int		sc_enabled;
 	device_t	sc_wskbddev;
@@ -107,6 +108,9 @@ struct tcakp_softc {
 static int	tcakp_match(device_t, cfdata_t, void *);
 static void	tcakp_attach(device_t, device_t, void *);
 
+static int	tcakp_i2c_lock(struct tcakp_softc *);
+static void	tcakp_i2c_unlock(struct tcakp_softc *);
+
 static int	tcakp_read(struct tcakp_softc *, uint8_t, uint8_t *);
 static int	tcakp_write(struct tcakp_softc *, uint8_t, uint8_t);
 
@@ -137,8 +141,28 @@ static int
 tcakp_intr(void *priv)
 {
 	struct tcakp_softc * const sc = priv;
+
+	/*
+	 * Schedule our soft interrupt handler.  We can't access the i2c
+	 * from hard interrupt context, so just go ahead and claim the
+	 * interrupt.
+	 *
+	 * XXX If we ever end up with an instance that uses
+	 * level-sensitive interrupts, we will need to mask
+	 * the interrupt source.
+	 */
+	softint_schedule(sc->sc_sih);
+	return 1;
+}
+
+static void
+tcakp_softintr(void *priv)
+{
+	struct tcakp_softc * const sc = priv;
 	uint8_t stat, ev;
-	int ret = 0;
+
+	if (tcakp_i2c_lock(sc) != 0)
+		return;
 
 	tcakp_read(sc, TCA_INT_STAT, );
 	if (stat & INT_STAT_K_INT) {
@@ -147,6 +171,8 @@ tcakp_intr(void *priv)
 			const bool pressed = __SHIFTOUT(ev, TCA_EVENT_STATE);
 			const uint8_t code = __SHIFTOUT(ev, TCA_EVENT_CODE);
 
+			tcakp_i2c_unlock(sc);
+
 			/* Translate raw code to keymap index */
 			const u_int index = tcakp_decode(sc, code);
 
@@ -157,13 +183,13 @@ tcakp_intr(void *priv)
 			if (sc->sc_wskbddev)
 wskbd_input(sc->sc_wskbddev, type, key);
 
+			if (tcakp_i2c_lock(sc) != 0)
+return;
 			tcakp_read(sc, TCA_EVENT('A'), );
 		}
-		ret = 1;
 	}
 	tcakp_write(sc, TCA_INT_STAT, stat);
-
-	return ret;
+	tcakp_i2c_unlock(sc);
 }
 
 static int
@@ -171,6 +197,7 @@ tcakp_init(struct tcakp_softc *sc)
 {
 	uint32_t mask;
 	uint8_t val;
+	int error;
 
 	if (sc->sc_rows == 0 || sc->sc_cols == 0) {
 		aprint_error_dev(sc->sc_dev, "not configured\n");
@@ -180,6 +207,10 @@ tcakp_init(struct tcakp_softc *sc)
 	mask = __BITS(sc->sc_rows - 1, 0);
 	mask += __BITS(sc->sc_cols - 1, 0) << 8;
 
+	error = tcakp_i2c_lock(sc);
+	if (error)
+		return error;
+
 	/* Lock the keyboard */
 	tcakp_write(sc, TCA_KEY_LCK_EC, KEY_LCK_EC_K_LCK_EN);
 	/* Select keyboard mode */
@@ -196,6 +227,8 @@ tcakp_init(struct tcakp_softc *sc)
 	tcakp_read(sc, TCA_INT_STAT, );
 	tcakp_write(sc, TCA_INT_STAT, val);
 
+	tcakp_i2c_unlock(sc);
+
 	return 0;
 }
 
@@ -234,6 +267,11 @@ static int
 tcakp_enable(void *v, int on)
 {
 	struct tcakp_softc * const sc = v;
+	int error;
+
+	error = tcakp_i2c_lock(sc);
+	if (error)
+		return error;
 
 	if (on) {
 		/* Disable key lock */
@@ -243,6 +281,7 @@ tcakp_enable(void *v, int on)
 		tcakp_write(sc, TCA_KEY_LCK_EC, KEY_LCK_EC_K_LCK_EN);
 	}
 
+	tcakp_i2c_unlock(sc);
 	return 0;
 }
 
@@ -276,6 +315,8 @@ tcakp_cngetc(void *v, u_int *type, int *
 	struct tcakp_softc * const sc = v;
 	uint8_t ev = 0;
 
+	/* XXX i2c bus acquire */
+
 	do {
 		tcakp_read(sc, TCA_EVENT('A'), );
 	} while (ev == 0);
@@ -287,6 +328,8 @@ tcakp_cngetc(void *v, u_int *type, int *
 	*type = pressed ? WSCONS_EVENT_KEY_DOWN :
 			  WSCONS_EVENT_KEY_UP;
 	*data = sc->sc_keymap[index];
+
+	/* XXX i2c bus release */
 }
 
 static void
@@ -345,6 +388,21 @@ tcakp_attach(device_t parent, device_t s
 #ifdef FDT
 	sc->sc_ih = fdtbus_intr_establish(sc->sc_phandle, 0, IPL_VM, 0,
 	tcakp_intr, sc);
+	/*
+	 * 

CVS commit: src/share/tmac

2019-12-23 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Dec 23 20:17:33 UTC 2019

Modified Files:
src/share/tmac: doc2html

Log Message:
Fix if/else syntax in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/share/tmac/doc2html

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

Modified files:

Index: src/share/tmac/doc2html
diff -u src/share/tmac/doc2html:1.69 src/share/tmac/doc2html:1.70
--- src/share/tmac/doc2html:1.69	Tue Dec  3 14:41:00 2019
+++ src/share/tmac/doc2html	Mon Dec 23 20:17:33 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: doc2html,v 1.69 2019/12/03 14:41:00 uwe Exp $
+.\" $NetBSD: doc2html,v 1.70 2019/12/23 20:17:33 uwe Exp $
 .\"
 .\" Copyright (c) 1998, 1999, 2008 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -265,10 +265,11 @@ TODO:
 .em end-macro
 .
 .\" map groff -Tencoding argument to the charset name
-.ie '\*(.T'ascii'  .ds html-charset US-ASCII
-.el .ie '\*(.T'latin1' .ds html-charset ISO-8859-1
-.el .ie '\*(.T'utf8'   .ds html-charset UTF-8
-.el .ab unsupported encoding \*(.T
+.   ie '\*(.T'ascii'  .ds html-charset US-ASCII
+.el \{ .ie '\*(.T'latin1' .ds html-charset ISO-8859-1
+.el \{ .ie '\*(.T'utf8'   .ds html-charset UTF-8
+.el.ab unsupported encoding \*(.T
+.\}\}
 .
 .de init-html
 



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 19:38:58 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/tcagpio.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/tcagpio.c
diff -u src/sys/dev/i2c/tcagpio.c:1.4 src/sys/dev/i2c/tcagpio.c:1.5
--- src/sys/dev/i2c/tcagpio.c:1.4	Tue Jun 26 06:03:57 2018
+++ src/sys/dev/i2c/tcagpio.c	Mon Dec 23 19:38:58 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: tcagpio.c,v 1.4 2018/06/26 06:03:57 thorpej Exp $ */
+/* $NetBSD: tcagpio.c,v 1.5 2019/12/23 19:38:58 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcagpio.c,v 1.4 2018/06/26 06:03:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcagpio.c,v 1.5 2019/12/23 19:38:58 thorpej Exp $");
 
 #include 
 #include 
@@ -102,10 +102,10 @@ tcagpio_write(struct tcagpio_softc *sc, 
 		aprint_error_dev(sc->sc_dev, "error writing reg %#x: %d\n", reg, error);
 }
 
-#define	I2C_READ(sc, reg)	tcagpio_read((sc), (reg), I2C_F_POLL)
-#define	I2C_WRITE(sc, reg, val)	tcagpio_write((sc), (reg), (val), I2C_F_POLL)
-#define	I2C_LOCK(sc)		iic_acquire_bus((sc)->sc_i2c, I2C_F_POLL)
-#define	I2C_UNLOCK(sc)		iic_release_bus((sc)->sc_i2c, I2C_F_POLL)
+#define	I2C_READ(sc, reg)	tcagpio_read((sc), (reg), 0)
+#define	I2C_WRITE(sc, reg, val)	tcagpio_write((sc), (reg), (val), 0)
+#define	I2C_LOCK(sc)		iic_acquire_bus((sc)->sc_i2c, 0)
+#define	I2C_UNLOCK(sc)		iic_release_bus((sc)->sc_i2c, 0)
 
 static int
 tcagpio_gpio_config(struct tcagpio_softc *sc, int pin, int flags)



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 19:35:07 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/sy8106a.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/sy8106a.c
diff -u src/sys/dev/i2c/sy8106a.c:1.4 src/sys/dev/i2c/sy8106a.c:1.5
--- src/sys/dev/i2c/sy8106a.c:1.4	Tue Jun 26 06:03:57 2018
+++ src/sys/dev/i2c/sy8106a.c	Mon Dec 23 19:35:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sy8106a.c,v 1.4 2018/06/26 06:03:57 thorpej Exp $ */
+/* $NetBSD: sy8106a.c,v 1.5 2019/12/23 19:35:07 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sy8106a.c,v 1.4 2018/06/26 06:03:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sy8106a.c,v 1.5 2019/12/23 19:35:07 thorpej Exp $");
 
 #include 
 #include 
@@ -93,10 +93,10 @@ sy8106a_write(struct sy8106a_softc *sc, 
 		aprint_error_dev(sc->sc_dev, "error writing reg %#x: %d\n", reg, error);
 }
 
-#define	I2C_READ(sc, reg)	sy8106a_read((sc), (reg), I2C_F_POLL)
-#define	I2C_WRITE(sc, reg, val)	sy8106a_write((sc), (reg), (val), I2C_F_POLL)
-#define	I2C_LOCK(sc)		iic_acquire_bus((sc)->sc_i2c, I2C_F_POLL)
-#define	I2C_UNLOCK(sc)		iic_release_bus((sc)->sc_i2c, I2C_F_POLL)
+#define	I2C_READ(sc, reg)	sy8106a_read((sc), (reg), 0)
+#define	I2C_WRITE(sc, reg, val)	sy8106a_write((sc), (reg), (val), 0)
+#define	I2C_LOCK(sc)		iic_acquire_bus((sc)->sc_i2c, 0)
+#define	I2C_UNLOCK(sc)		iic_release_bus((sc)->sc_i2c, 0)
 
 static int
 sy8106a_acquire(device_t dev)



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

2019-12-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 23 19:30:12 UTC 2019

Modified Files:
src/sys/arch/ews4800mips/conf: RAMDISK

Log Message:
Add a comment where the other memory disk is defined to avoid future confusion.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/ews4800mips/conf/RAMDISK

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/ews4800mips/conf/RAMDISK
diff -u src/sys/arch/ews4800mips/conf/RAMDISK:1.23 src/sys/arch/ews4800mips/conf/RAMDISK:1.24
--- src/sys/arch/ews4800mips/conf/RAMDISK:1.23	Sat Apr 27 08:08:11 2019
+++ src/sys/arch/ews4800mips/conf/RAMDISK	Mon Dec 23 14:30:12 2019
@@ -1,4 +1,4 @@
-# 	$NetBSD: RAMDISK,v 1.23 2019/04/27 12:08:11 sevan Exp $
+# 	$NetBSD: RAMDISK,v 1.24 2019/12/23 19:30:12 christos Exp $
 #
 # kernel config file with memory disk for installation
 #
@@ -11,6 +11,9 @@ makeoptions	COPTS="-Os -mmemcpy"	# optim
 options 	MEMORY_DISK_HOOKS
 options 	MEMORY_DISK_IS_ROOT	# force root on memory disk
 options 	MEMORY_DISK_SERVER=0	# no userspace memory disk support
+# This sets the memory disk image size for the kernel. There is another
+# memory disk image size defined in the boot blocks:
+# 	src/sys/arch/ews4800mips/stand/boot/Makefile
 options 	MEMORY_DISK_ROOT_SIZE=6144	# size of memory disk, in blocks (12)
 options 	MEMORY_DISK_RBFLAGS=RB_SINGLE	# boot in single-user mode
 



CVS commit: src/sys/uvm

2019-12-23 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Dec 23 19:29:03 UTC 2019

Modified Files:
src/sys/uvm: uvm_pdpolicy_clock.c

Log Message:
uvmpdpol_selectvictim: don't assert wire_count == 0, as we can (safely)
race with object owner and wired pages can very briefly appear on the queue.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/uvm/uvm_pdpolicy_clock.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/uvm/uvm_pdpolicy_clock.c
diff -u src/sys/uvm/uvm_pdpolicy_clock.c:1.21 src/sys/uvm/uvm_pdpolicy_clock.c:1.22
--- src/sys/uvm/uvm_pdpolicy_clock.c:1.21	Sat Dec 21 13:00:25 2019
+++ src/sys/uvm/uvm_pdpolicy_clock.c	Mon Dec 23 19:29:03 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_pdpolicy_clock.c,v 1.21 2019/12/21 13:00:25 ad Exp $	*/
+/*	$NetBSD: uvm_pdpolicy_clock.c,v 1.22 2019/12/23 19:29:03 ad Exp $	*/
 /*	NetBSD: uvm_pdaemon.c,v 1.72 2006/01/05 10:47:33 yamt Exp $	*/
 
 /*
@@ -69,7 +69,7 @@
 #else /* defined(PDSIM) */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clock.c,v 1.21 2019/12/21 13:00:25 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clock.c,v 1.22 2019/12/23 19:29:03 ad Exp $");
 
 #include 
 #include 
@@ -208,8 +208,6 @@ uvmpdpol_selectvictim(kmutex_t **plock)
 			break;
 		}
 		ss->ss_nextpg = TAILQ_NEXT(pg, pageq.queue);
-		KASSERT(pg->wire_count == 0);
-
 		uvmexp.pdscans++;
 
 		/*



CVS commit: src/sys/arch/ews4800mips/stand/boot

2019-12-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 23 19:28:04 UTC 2019

Modified Files:
src/sys/arch/ews4800mips/stand/boot: Makefile

Log Message:
Bump size.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/ews4800mips/stand/boot/Makefile

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/ews4800mips/stand/boot/Makefile
diff -u src/sys/arch/ews4800mips/stand/boot/Makefile:1.23 src/sys/arch/ews4800mips/stand/boot/Makefile:1.24
--- src/sys/arch/ews4800mips/stand/boot/Makefile:1.23	Tue Jan  1 14:41:04 2019
+++ src/sys/arch/ews4800mips/stand/boot/Makefile	Mon Dec 23 14:28:04 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.23 2019/01/01 19:41:04 christos Exp $
+#	$NetBSD: Makefile,v 1.24 2019/12/23 19:28:04 christos Exp $
 
 WARNS		?= 1
 NOMAN		=
@@ -38,7 +38,7 @@ SRCS		+= boot_device.c floppy_2d.c flopp
 #SRCS		+= floppy_2hc.c
 SRCS		+= console.c cons_rom.c cons_fb.c cons_zskbd.c cons_zs.c
 BINKERNEL_C	= ${COMMON}/binkernel.c
-BINKERNEL_SIZE	= '2 * 1024 * 1024 + 32 * 1024'
+BINKERNEL_SIZE	= 2143232	# '2 * 1024 * 1024 + 45 * 1024'
 BINKERNEL_O	= binkernel.o
 BINKERNEL_DUMMY_O= binkernel_dummy.o
 



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 19:22:46 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/fan53555.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/fan53555.c
diff -u src/sys/dev/i2c/fan53555.c:1.4 src/sys/dev/i2c/fan53555.c:1.5
--- src/sys/dev/i2c/fan53555.c:1.4	Tue Nov 12 07:40:04 2019
+++ src/sys/dev/i2c/fan53555.c	Mon Dec 23 19:22:46 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fan53555.c,v 1.4 2019/11/12 07:40:04 mrg Exp $ */
+/* $NetBSD: fan53555.c,v 1.5 2019/12/23 19:22:46 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fan53555.c,v 1.4 2019/11/12 07:40:04 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fan53555.c,v 1.5 2019/12/23 19:22:46 thorpej Exp $");
 
 #include 
 #include 
@@ -124,10 +124,10 @@ fan53555_write(struct fan53555_softc *sc
 		aprint_error_dev(sc->sc_dev, "error writing reg %#x: %d\n", reg, error);
 }
 
-#define	I2C_READ(sc, reg)	fan53555_read((sc), (reg), I2C_F_POLL)
-#define	I2C_WRITE(sc, reg, val)	fan53555_write((sc), (reg), (val), I2C_F_POLL)
-#define	I2C_LOCK(sc)		iic_acquire_bus((sc)->sc_i2c, I2C_F_POLL)
-#define	I2C_UNLOCK(sc)		iic_release_bus((sc)->sc_i2c, I2C_F_POLL)
+#define	I2C_READ(sc, reg)	fan53555_read((sc), (reg), 0)
+#define	I2C_WRITE(sc, reg, val)	fan53555_write((sc), (reg), (val), 0)
+#define	I2C_LOCK(sc)		iic_acquire_bus((sc)->sc_i2c, 0)
+#define	I2C_UNLOCK(sc)		iic_release_bus((sc)->sc_i2c, 0)
 
 static int
 fan53555_acquire(device_t dev)



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 19:20:18 UTC 2019

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

Log Message:
Actually, the local mutex is unnecesary; the i2c bus lock is held
across all register r/m/w cycles, so we can just piggy back on that.
(I misread the code previously.)


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/i2c/max77620.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/max77620.c
diff -u src/sys/dev/i2c/max77620.c:1.7 src/sys/dev/i2c/max77620.c:1.8
--- src/sys/dev/i2c/max77620.c:1.7	Mon Dec 23 18:49:13 2019
+++ src/sys/dev/i2c/max77620.c	Mon Dec 23 19:20:18 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: max77620.c,v 1.7 2019/12/23 18:49:13 thorpej Exp $ */
+/* $NetBSD: max77620.c,v 1.8 2019/12/23 19:20:18 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: max77620.c,v 1.7 2019/12/23 18:49:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: max77620.c,v 1.8 2019/12/23 19:20:18 thorpej Exp $");
 
 #include 
 #include 
@@ -58,13 +58,6 @@ struct max77620_softc {
 	i2c_tag_t	sc_i2c;
 	i2c_addr_t	sc_addr;
 	int		sc_phandle;
-
-	/*
-	 * Locking order:
-	 *
-	 *	max77620 -> i2c
-	 */
-	kmutex_t	sc_lock;
 };
 
 struct max77620_pin {
@@ -115,7 +108,6 @@ max77620_gpio_config(struct max77620_sof
 	uint32_t gpio;
 
 	KASSERT(pin >= 0 && pin < MAX_GPIO_COUNT);
-	KASSERT(mutex_owned(>sc_lock));
 
 	gpio = I2C_READ(sc, MAX_GPIO_REG(pin));
 
@@ -170,11 +162,9 @@ max77620_gpio_acquire(device_t dev, cons
 	if (pin >= MAX_GPIO_COUNT)
 		return NULL;
 
-	mutex_enter(>sc_lock);
 	I2C_LOCK(sc);
 	error = max77620_gpio_config(sc, pin, flags);
 	I2C_UNLOCK(sc);
-	mutex_exit(>sc_lock);
 
 	if (error != 0) {
 		device_printf(dev, "bad pin %d config %#x\n", pin, flags);
@@ -196,11 +186,9 @@ max77620_gpio_release(device_t dev, void
 	struct max77620_softc * const sc = device_private(dev);
 	struct max77620_pin *gpin = priv;
 
-	mutex_enter(>sc_lock);
 	I2C_LOCK(sc);
 	max77620_gpio_config(sc, gpin->pin_num, GPIO_PIN_INPUT|GPIO_PIN_OPENDRAIN);
 	I2C_UNLOCK(sc);
-	mutex_exit(>sc_lock);
 
 	kmem_free(gpin, sizeof(*gpin));
 }
@@ -245,7 +233,6 @@ max77620_gpio_write(device_t dev, void *
 	if (!raw && gpin->pin_actlo)
 		val = !val;
 
-	mutex_enter(>sc_lock);
 	I2C_LOCK(sc);
 	gpio = I2C_READ(sc, MAX_GPIO_REG(gpin->pin_num));
 	gpio &= ~MAX_GPIO_OUTPUT_VAL;
@@ -257,7 +244,6 @@ max77620_gpio_write(device_t dev, void *
 #endif
 	I2C_WRITE(sc, MAX_GPIO_REG(gpin->pin_num), gpio);
 	I2C_UNLOCK(sc);
-	mutex_exit(>sc_lock);
 }
 
 static struct fdtbus_gpio_controller_func max77620_gpio_funcs = {
@@ -297,8 +283,6 @@ max77620_attach(device_t parent, device_
 	sc->sc_addr = ia->ia_addr;
 	sc->sc_phandle = ia->ia_cookie;
 
-	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE);
-
 	aprint_naive("\n");
 	aprint_normal(": MAX77620 Power Management IC\n");
 



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 19:12:22 UTC 2019

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

Log Message:
- Don't read/write the device if iic_acquire_bus() fails.
- axp20x_poweroff(): report the error code if power off fails.
- Don't use polled access in axp20xreg_{get,set}_voltage().


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/i2c/axp20x.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/axp20x.c
diff -u src/sys/dev/i2c/axp20x.c:1.14 src/sys/dev/i2c/axp20x.c:1.15
--- src/sys/dev/i2c/axp20x.c:1.14	Mon Dec 23 02:50:50 2019
+++ src/sys/dev/i2c/axp20x.c	Mon Dec 23 19:12:22 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: axp20x.c,v 1.14 2019/12/23 02:50:50 thorpej Exp $ */
+/* $NetBSD: axp20x.c,v 1.15 2019/12/23 19:12:22 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: axp20x.c,v 1.14 2019/12/23 02:50:50 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axp20x.c,v 1.15 2019/12/23 19:12:22 thorpej Exp $");
 
 #include 
 #include 
@@ -567,10 +567,14 @@ axp20x_read(struct axp20x_softc *sc, uin
 int flags)
 {
 	int ret;
-	iic_acquire_bus(sc->sc_i2c, flags);
-	ret = iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP, sc->sc_addr,
-	, 1, val, len, flags);
-	iic_release_bus(sc->sc_i2c, flags);
+
+	ret = iic_acquire_bus(sc->sc_i2c, flags);
+	if (ret == 0) {
+		ret = iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP, sc->sc_addr,
+		, 1, val, len, flags);
+		iic_release_bus(sc->sc_i2c, flags);
+	}
+
 	return ret;
 
 }
@@ -580,10 +584,14 @@ axp20x_write(struct axp20x_softc *sc, ui
 int flags)
 {
 	int ret;
-	iic_acquire_bus(sc->sc_i2c, flags);
-	ret = iic_exec(sc->sc_i2c, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
-	, 1, val, len, flags);
-	iic_release_bus(sc->sc_i2c, flags);
+
+	ret = iic_acquire_bus(sc->sc_i2c, flags);
+	if (ret == 0) {
+		ret = iic_exec(sc->sc_i2c, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
+		, 1, val, len, flags);
+		iic_release_bus(sc->sc_i2c, flags);
+	}
+
 	return ret;
 }
 
@@ -667,9 +675,13 @@ axp20x_poweroff(device_t dev)
 {
 	struct axp20x_softc * const sc = device_private(dev);
 	uint8_t reg = AXP_SHUTDOWN_CTRL;
+	int error;
 
-	if (axp20x_write(sc, AXP_SHUTDOWN, , 1, I2C_F_POLL) != 0)
-		device_printf(dev, "WARNING: poweroff failed\n");
+	error = axp20x_write(sc, AXP_SHUTDOWN, , 1, I2C_F_POLL);
+	if (error) {
+		device_printf(dev, "WARNING: unable to power off, error %d\n",
+		error);
+	}
 }
 
 #ifdef FDT
@@ -714,7 +726,7 @@ axp20xreg_set_voltage(device_t dev, u_in
 {
 	struct axp20xreg_softc * const sc = device_private(dev);
 	
-	return axp20x_set_dcdc(device_parent(dev), sc->sc_regdef->dcdc, min_uvol / 1000, true);
+	return axp20x_set_dcdc(device_parent(dev), sc->sc_regdef->dcdc, min_uvol / 1000, false);
 }
 
 static int
@@ -723,7 +735,7 @@ axp20xreg_get_voltage(device_t dev, u_in
 	struct axp20xreg_softc * const sc = device_private(dev);
 	int mvol, error;
 
-	error = axp20x_get_dcdc(device_parent(dev), sc->sc_regdef->dcdc, , true);
+	error = axp20x_get_dcdc(device_parent(dev), sc->sc_regdef->dcdc, , false);
 	if (error != 0)
 		return error;
 



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 19:00:59 UTC 2019

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

Log Message:
- No need to use I2C_F_POLL here.
- If iic_acquire_bus() fails, return the error, not false (because false
  looks like "everything A-OK!" to the caller).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/nxt2k.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/nxt2k.c
diff -u src/sys/dev/i2c/nxt2k.c:1.5 src/sys/dev/i2c/nxt2k.c:1.6
--- src/sys/dev/i2c/nxt2k.c:1.5	Thu Jun  1 02:45:10 2017
+++ src/sys/dev/i2c/nxt2k.c	Mon Dec 23 19:00:59 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: nxt2k.c,v 1.5 2017/06/01 02:45:10 chs Exp $ */
+/* $NetBSD: nxt2k.c,v 1.6 2019/12/23 19:00:59 thorpej Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nxt2k.c,v 1.5 2017/06/01 02:45:10 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nxt2k.c,v 1.6 2019/12/23 19:00:59 thorpej Exp $");
 
 #include 
 #include 
@@ -74,16 +74,16 @@ nxt2k_writedata(struct nxt2k *nxt, uint8
 
 	KASSERT((len + 1) <= 384);
 
-	if (iic_acquire_bus(nxt->tag, I2C_F_POLL) != 0)
-		return false;
+	if ((error = iic_acquire_bus(nxt->tag, 0) != 0))
+		return error;
 
 	buffer[0] = reg;
 	memcpy([1], data, len);
 	
 	error = iic_exec(nxt->tag, I2C_OP_WRITE_WITH_STOP, nxt->addr,
-			 buffer, len + 1, NULL, 0, I2C_F_POLL);
+			 buffer, len + 1, NULL, 0, 0);
 	
-	iic_release_bus(nxt->tag, I2C_F_POLL);
+	iic_release_bus(nxt->tag, 0);
 
 	return error;
 }
@@ -93,13 +93,13 @@ nxt2k_readdata(struct nxt2k *nxt, uint8_
 {
 	int error;
 
-	if (iic_acquire_bus(nxt->tag, I2C_F_POLL) != 0)
-		return false;
+	if ((error = iic_acquire_bus(nxt->tag, 0) != 0))
+		return error;
 
 	error = iic_exec(nxt->tag, I2C_OP_READ_WITH_STOP, nxt->addr,
-			 , 1, data, len, I2C_F_POLL);
+			 , 1, data, len, 0);
 
-	iic_release_bus(nxt->tag, I2C_F_POLL);
+	iic_release_bus(nxt->tag, 0);
 
 	return error;
 }



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 18:57:30 UTC 2019

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

Log Message:
- No need to use I2C_F_POLL here.
- Don't write to the device if iic_acquire_bus() fails.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/mt2131.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/mt2131.c
diff -u src/sys/dev/i2c/mt2131.c:1.6 src/sys/dev/i2c/mt2131.c:1.7
--- src/sys/dev/i2c/mt2131.c:1.6	Thu Jun  1 02:45:10 2017
+++ src/sys/dev/i2c/mt2131.c	Mon Dec 23 18:57:30 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: mt2131.c,v 1.6 2017/06/01 02:45:10 chs Exp $ */
+/* $NetBSD: mt2131.c,v 1.7 2019/12/23 18:57:30 thorpej Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mt2131.c,v 1.6 2017/06/01 02:45:10 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mt2131.c,v 1.7 2019/12/23 18:57:30 thorpej Exp $");
 
 #include 
 #include 
@@ -85,9 +85,12 @@ mt2131_open(device_t parent, i2c_tag_t t
 	cmd = reg = 0;
 
 	/* get id reg */
-	iic_acquire_bus(t, I2C_F_POLL);
-	ret = iic_exec(t, I2C_OP_READ_WITH_STOP, a, , 1, , 1, I2C_F_POLL);
-	iic_release_bus(t, I2C_F_POLL);
+	ret = iic_acquire_bus(t, 0);
+	if (ret == 0) {
+		ret = iic_exec(t, I2C_OP_READ_WITH_STOP, a, , 1, , 1,
+		0);
+		iic_release_bus(t, 0);
+	}
 
 	if (ret) {
 		device_printf(parent, "%s(): read fail\n", __func__);
@@ -153,9 +156,12 @@ mt2131_tune_dtv(struct mt2131_softc *sc,
 	b[5] = (d2 & 0x001f);
 	b[6] = r2;
 
-	iic_acquire_bus(sc->tag, I2C_F_POLL);
-	rv = iic_exec(sc->tag, I2C_OP_WRITE_WITH_STOP, sc->addr, b, 7, NULL, 0, I2C_F_POLL);
-	iic_release_bus(sc->tag, I2C_F_POLL);
+	rv = iic_acquire_bus(sc->tag, 0);
+	if (rv == 0) {
+		rv = iic_exec(sc->tag, I2C_OP_WRITE_WITH_STOP, sc->addr, b, 7,
+		NULL, 0, 0);
+		iic_release_bus(sc->tag, 0);
+	}
 
 	regval = (fr - 27501) / 55000;
 
@@ -191,27 +197,27 @@ mt2131_init(struct mt2131_softc *sc)
 {
 	int ret;
 
-	ret = iic_acquire_bus(sc->tag, I2C_F_POLL);
+	ret = iic_acquire_bus(sc->tag, 0);
 	if (ret)
 		return -1;
 	ret = iic_exec(sc->tag, I2C_OP_WRITE_WITH_STOP, sc->addr,
-	mt2131_initstring, sizeof(mt2131_initstring), NULL, 0, I2C_F_POLL);
+	mt2131_initstring, sizeof(mt2131_initstring), NULL, 0, 0);
+	iic_release_bus(sc->tag, 0);
 	if (ret)
 		return -1;
-	iic_release_bus(sc->tag, I2C_F_POLL);
 
 	ret = mt2131_write(sc, UPC_1, 0x09);
 	ret = mt2131_write(sc, MISC_2, 0x47);
 	ret = mt2131_write(sc, PWR, 0xf2);
 	ret = mt2131_write(sc, UPC_1, 0x01);
 
-	ret = iic_acquire_bus(sc->tag, I2C_F_POLL);
+	ret = iic_acquire_bus(sc->tag, 0);
 	if (ret)
 		return -1;
 	ret = iic_exec(sc->tag, I2C_OP_WRITE_WITH_STOP, sc->addr,
 	mt2131_agcinitstring, sizeof(mt2131_agcinitstring),
-	NULL, 0, I2C_F_POLL);
-	iic_release_bus(sc->tag, I2C_F_POLL);
+	NULL, 0, 0);
+	iic_release_bus(sc->tag, 0);
 	if (ret)
 		return -1;
 	
@@ -223,13 +229,13 @@ mt2131_read(struct mt2131_softc *sc, uin
 {
 	int ret;
 
-	ret = iic_acquire_bus(sc->tag, I2C_F_POLL);
+	ret = iic_acquire_bus(sc->tag, 0);
 	if (ret)
 		return ret;
 	ret = iic_exec(sc->tag, I2C_OP_READ_WITH_STOP, sc->addr,
-	, 1, v, 1, I2C_F_POLL);
+	, 1, v, 1, 0);
 
-	iic_release_bus(sc->tag, I2C_F_POLL);
+	iic_release_bus(sc->tag, 0);
 
 	return ret;
 }
@@ -240,14 +246,14 @@ mt2131_write(struct mt2131_softc *sc, ui
 	int ret;
 	uint8_t b[] = { a, v };
 
-	ret = iic_acquire_bus(sc->tag, I2C_F_POLL);
+	ret = iic_acquire_bus(sc->tag, 0);
 	if (ret)
 		return ret;
 
 	ret = iic_exec(sc->tag, I2C_OP_READ_WITH_STOP, sc->addr,
-	b, sizeof(b), NULL, 0, I2C_F_POLL);
+	b, sizeof(b), NULL, 0, 0);
 
-	iic_release_bus(sc->tag, I2C_F_POLL);
+	iic_release_bus(sc->tag, 0);
 
 	return ret;
 }



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 18:49:14 UTC 2019

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

Log Message:
- No need to use I2C_F_POLL here.
- Use a local mutex to protect register read-modify-write cycles.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/max77620.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/max77620.c
diff -u src/sys/dev/i2c/max77620.c:1.6 src/sys/dev/i2c/max77620.c:1.7
--- src/sys/dev/i2c/max77620.c:1.6	Tue Jun 26 06:03:57 2018
+++ src/sys/dev/i2c/max77620.c	Mon Dec 23 18:49:13 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: max77620.c,v 1.6 2018/06/26 06:03:57 thorpej Exp $ */
+/* $NetBSD: max77620.c,v 1.7 2019/12/23 18:49:13 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,10 +27,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: max77620.c,v 1.6 2018/06/26 06:03:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: max77620.c,v 1.7 2019/12/23 18:49:13 thorpej Exp $");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -57,6 +58,13 @@ struct max77620_softc {
 	i2c_tag_t	sc_i2c;
 	i2c_addr_t	sc_addr;
 	int		sc_phandle;
+
+	/*
+	 * Locking order:
+	 *
+	 *	max77620 -> i2c
+	 */
+	kmutex_t	sc_lock;
 };
 
 struct max77620_pin {
@@ -96,10 +104,10 @@ max77620_write(struct max77620_softc *sc
 		aprint_error_dev(sc->sc_dev, "error writing reg %#x: %d\n", reg, error);
 }
 
-#define	I2C_READ(sc, reg)	max77620_read((sc), (reg), I2C_F_POLL)
-#define	I2C_WRITE(sc, reg, val)	max77620_write((sc), (reg), (val), I2C_F_POLL)
-#define	I2C_LOCK(sc)		iic_acquire_bus((sc)->sc_i2c, I2C_F_POLL)
-#define	I2C_UNLOCK(sc)		iic_release_bus((sc)->sc_i2c, I2C_F_POLL)
+#define	I2C_READ(sc, reg)	max77620_read((sc), (reg), 0)
+#define	I2C_WRITE(sc, reg, val)	max77620_write((sc), (reg), (val), 0)
+#define	I2C_LOCK(sc)		iic_acquire_bus((sc)->sc_i2c, 0)
+#define	I2C_UNLOCK(sc)		iic_release_bus((sc)->sc_i2c, 0)
 
 static int
 max77620_gpio_config(struct max77620_softc *sc, int pin, int flags)
@@ -107,6 +115,7 @@ max77620_gpio_config(struct max77620_sof
 	uint32_t gpio;
 
 	KASSERT(pin >= 0 && pin < MAX_GPIO_COUNT);
+	KASSERT(mutex_owned(>sc_lock));
 
 	gpio = I2C_READ(sc, MAX_GPIO_REG(pin));
 
@@ -161,9 +170,11 @@ max77620_gpio_acquire(device_t dev, cons
 	if (pin >= MAX_GPIO_COUNT)
 		return NULL;
 
+	mutex_enter(>sc_lock);
 	I2C_LOCK(sc);
 	error = max77620_gpio_config(sc, pin, flags);
 	I2C_UNLOCK(sc);
+	mutex_exit(>sc_lock);
 
 	if (error != 0) {
 		device_printf(dev, "bad pin %d config %#x\n", pin, flags);
@@ -185,9 +196,11 @@ max77620_gpio_release(device_t dev, void
 	struct max77620_softc * const sc = device_private(dev);
 	struct max77620_pin *gpin = priv;
 
+	mutex_enter(>sc_lock);
 	I2C_LOCK(sc);
 	max77620_gpio_config(sc, gpin->pin_num, GPIO_PIN_INPUT|GPIO_PIN_OPENDRAIN);
 	I2C_UNLOCK(sc);
+	mutex_exit(>sc_lock);
 
 	kmem_free(gpin, sizeof(*gpin));
 }
@@ -200,6 +213,11 @@ max77620_gpio_read(device_t dev, void *p
 	uint8_t gpio;
 	int val;
 
+	/*
+	 * Performing a register read only; no need to acquire
+	 * the max77620 lock.
+	 */
+
 	I2C_LOCK(sc);
 	gpio = I2C_READ(sc, MAX_GPIO_REG(gpin->pin_num));
 	I2C_UNLOCK(sc);
@@ -227,6 +245,7 @@ max77620_gpio_write(device_t dev, void *
 	if (!raw && gpin->pin_actlo)
 		val = !val;
 
+	mutex_enter(>sc_lock);
 	I2C_LOCK(sc);
 	gpio = I2C_READ(sc, MAX_GPIO_REG(gpin->pin_num));
 	gpio &= ~MAX_GPIO_OUTPUT_VAL;
@@ -238,6 +257,7 @@ max77620_gpio_write(device_t dev, void *
 #endif
 	I2C_WRITE(sc, MAX_GPIO_REG(gpin->pin_num), gpio);
 	I2C_UNLOCK(sc);
+	mutex_exit(>sc_lock);
 }
 
 static struct fdtbus_gpio_controller_func max77620_gpio_funcs = {
@@ -277,6 +297,8 @@ max77620_attach(device_t parent, device_
 	sc->sc_addr = ia->ia_addr;
 	sc->sc_phandle = ia->ia_cookie;
 
+	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE);
+
 	aprint_naive("\n");
 	aprint_normal(": MAX77620 Power Management IC\n");
 



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 18:27:11 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/i2c/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/i2c.c
diff -u src/sys/dev/i2c/i2c.c:1.71 src/sys/dev/i2c/i2c.c:1.72
--- src/sys/dev/i2c/i2c.c:1.71	Sun Dec 22 23:23:32 2019
+++ src/sys/dev/i2c/i2c.c	Mon Dec 23 18:27:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c.c,v 1.71 2019/12/22 23:23:32 thorpej Exp $	*/
+/*	$NetBSD: i2c.c,v 1.72 2019/12/23 18:27:11 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.71 2019/12/22 23:23:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.72 2019/12/23 18:27:11 thorpej Exp $");
 
 #include 
 #include 
@@ -353,7 +353,7 @@ iic_search(device_t parent, cfdata_t cf,
 		 * to see if it looks like something is really there.
 		 */
 		if (match_result == I2C_MATCH_ADDRESS_ONLY &&
-		(error = (*probe_func)(sc, , I2C_F_POLL)) != 0)
+		(error = (*probe_func)(sc, , 0)) != 0)
 			continue;
 
 		sc->sc_devices[ia.ia_addr] =



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

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 18:20:02 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_hdmi.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_hdmi.c
diff -u src/sys/arch/arm/sunxi/sunxi_hdmi.c:1.9 src/sys/arch/arm/sunxi/sunxi_hdmi.c:1.10
--- src/sys/arch/arm/sunxi/sunxi_hdmi.c:1.9	Mon Dec 23 00:24:02 2019
+++ src/sys/arch/arm/sunxi/sunxi_hdmi.c	Mon Dec 23 18:20:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_hdmi.c,v 1.9 2019/12/23 00:24:02 thorpej Exp $ */
+/* $NetBSD: sunxi_hdmi.c,v 1.10 2019/12/23 18:20:02 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -29,7 +29,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmi.c,v 1.9 2019/12/23 00:24:02 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmi.c,v 1.10 2019/12/23 18:20:02 thorpej Exp $");
 
 #include 
 #include 
@@ -637,14 +637,14 @@ sunxi_hdmi_read_edid_block(struct sunxi_
 	uint8_t wbuf[2];
 	int error;
 
-	if ((error = iic_acquire_bus(tag, I2C_F_POLL)) != 0)
+	if ((error = iic_acquire_bus(tag, 0)) != 0)
 		return error;
 
 	wbuf[0] = block;	/* start address */
 
 	error = iic_exec(tag, I2C_OP_READ_WITH_STOP, DDC_ADDR, wbuf, 1,
-	data, EDID_BLOCK_SIZE, I2C_F_POLL);
-	iic_release_bus(tag, I2C_F_POLL);
+	data, EDID_BLOCK_SIZE, 0);
+	iic_release_bus(tag, 0);
 	return error;
 }
 



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 18:12:50 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/ddc.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/ddc.c
diff -u src/sys/dev/i2c/ddc.c:1.8 src/sys/dev/i2c/ddc.c:1.9
--- src/sys/dev/i2c/ddc.c:1.8	Mon Sep  3 16:29:31 2018
+++ src/sys/dev/i2c/ddc.c	Mon Dec 23 18:12:50 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ddc.c,v 1.8 2018/09/03 16:29:31 riastradh Exp $ */
+/* $NetBSD: ddc.c,v 1.9 2019/12/23 18:12:50 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
  */ 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ddc.c,v 1.8 2018/09/03 16:29:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ddc.c,v 1.9 2019/12/23 18:12:50 thorpej Exp $");
 
 #include 
 #include 
@@ -102,17 +102,17 @@ ddc_read_edid_block(i2c_tag_t tag, uint8
 	uint8_t wbuf[2];
 	int error;
 
-	if ((error = iic_acquire_bus(tag, I2C_F_POLL)) != 0)
+	if ((error = iic_acquire_bus(tag, 0)) != 0)
 		return error;
 
 	wbuf[0] = block >> 1;	/* start address */
 
 	if ((error = iic_exec(tag, I2C_OP_READ_WITH_STOP, DDC_ADDR, wbuf, 1,
-		edid, sizeof(edid), I2C_F_POLL)) != 0) {
-		iic_release_bus(tag, I2C_F_POLL);
+		edid, sizeof(edid), 0)) != 0) {
+		iic_release_bus(tag, 0);
 		return error;
 	}
-	iic_release_bus(tag, I2C_F_POLL);
+	iic_release_bus(tag, 0);
 
 	if (block & 1) {
 		memcpy(dest, [128], uimin(len, 128));



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 18:09:06 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/i2c/cx24227.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/cx24227.c
diff -u src/sys/dev/i2c/cx24227.c:1.9 src/sys/dev/i2c/cx24227.c:1.10
--- src/sys/dev/i2c/cx24227.c:1.9	Mon Dec 23 18:03:14 2019
+++ src/sys/dev/i2c/cx24227.c	Mon Dec 23 18:09:05 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cx24227.c,v 1.9 2019/12/23 18:03:14 thorpej Exp $ */
+/* $NetBSD: cx24227.c,v 1.10 2019/12/23 18:09:05 thorpej Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cx24227.c,v 1.9 2019/12/23 18:03:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cx24227.c,v 1.10 2019/12/23 18:09:05 thorpej Exp $");
 
 #include 
 #include 
@@ -108,16 +108,16 @@ cx24227_writereg(struct cx24227 *sc, uin
 	int error;
 	uint8_t r[3];
 
-	if ((error = iic_acquire_bus(sc->tag, I2C_F_POLL) != 0))
+	if ((error = iic_acquire_bus(sc->tag, 0) != 0))
 		return error;
 
 	r[0] = reg;
 	r[1] = (data >> 8) & 0xff;
 	r[2] = data & 0xff;
 	error = iic_exec(sc->tag, I2C_OP_WRITE_WITH_STOP, sc->addr,
-	r, 3, NULL, 0, I2C_F_POLL);
+	r, 3, NULL, 0, 0);
 	
-	iic_release_bus(sc->tag, I2C_F_POLL);
+	iic_release_bus(sc->tag, 0);
 
 	return error;
 }
@@ -130,13 +130,13 @@ cx24227_readreg(struct cx24227 *sc, uint
 
 	*data = 0x;
 
-	if ((error = iic_acquire_bus(sc->tag, I2C_F_POLL) != 0))
+	if ((error = iic_acquire_bus(sc->tag, 0) != 0))
 		return error;
 
 	error = iic_exec(sc->tag, I2C_OP_READ_WITH_STOP, sc->addr,
-			 , 1, r, 2, I2C_F_POLL);
+			 , 1, r, 2, 0);
 
-	iic_release_bus(sc->tag, I2C_F_POLL);
+	iic_release_bus(sc->tag, 0);
 
 	*data |= r[0] << 8;
 	*data |= r[1];



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 18:03:14 UTC 2019

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

Log Message:
In cx24227_writereg() / cx24227_readreg(), return the error
from iic_acquire_bus(), not some bogus return value that can
potentially be confused for a real error code.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/cx24227.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/cx24227.c
diff -u src/sys/dev/i2c/cx24227.c:1.8 src/sys/dev/i2c/cx24227.c:1.9
--- src/sys/dev/i2c/cx24227.c:1.8	Thu Jun  1 02:45:10 2017
+++ src/sys/dev/i2c/cx24227.c	Mon Dec 23 18:03:14 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cx24227.c,v 1.8 2017/06/01 02:45:10 chs Exp $ */
+/* $NetBSD: cx24227.c,v 1.9 2019/12/23 18:03:14 thorpej Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cx24227.c,v 1.8 2017/06/01 02:45:10 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cx24227.c,v 1.9 2019/12/23 18:03:14 thorpej Exp $");
 
 #include 
 #include 
@@ -108,8 +108,8 @@ cx24227_writereg(struct cx24227 *sc, uin
 	int error;
 	uint8_t r[3];
 
-	if (iic_acquire_bus(sc->tag, I2C_F_POLL) != 0)
-		return false;
+	if ((error = iic_acquire_bus(sc->tag, I2C_F_POLL) != 0))
+		return error;
 
 	r[0] = reg;
 	r[1] = (data >> 8) & 0xff;
@@ -130,8 +130,8 @@ cx24227_readreg(struct cx24227 *sc, uint
 
 	*data = 0x;
 
-	if (iic_acquire_bus(sc->tag, I2C_F_POLL) != 0)
-		return -1;
+	if ((error = iic_acquire_bus(sc->tag, I2C_F_POLL) != 0))
+		return error;
 
 	error = iic_exec(sc->tag, I2C_OP_READ_WITH_STOP, sc->addr,
 			 , 1, r, 2, I2C_F_POLL);



CVS commit: src/lib/libpam/modules/pam_unix

2019-12-23 Thread Jeremy C. Reed
Module Name:src
Committed By:   reed
Date:   Mon Dec 23 17:51:58 UTC 2019

Modified Files:
src/lib/libpam/modules/pam_unix: pam_unix.8

Log Message:
Simply Subsection headers

There was a formatting issue with mandoc showing the
literal "Ss" macros. I reported this bug to mandoc since groff
didn't have same formatting. It was recommended to simplify
the formatting due to the weird feature.
Note because of this for groff I didn't use the Ux macro but spelled
out UNIX literally for these subsection headers
(since the macro reset the subsection formatting which was why
the Ss macro was repeated before to reactivate it).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libpam/modules/pam_unix/pam_unix.8

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

Modified files:

Index: src/lib/libpam/modules/pam_unix/pam_unix.8
diff -u src/lib/libpam/modules/pam_unix/pam_unix.8:1.8 src/lib/libpam/modules/pam_unix/pam_unix.8:1.9
--- src/lib/libpam/modules/pam_unix/pam_unix.8:1.8	Sat Feb 26 15:59:34 2005
+++ src/lib/libpam/modules/pam_unix/pam_unix.8	Mon Dec 23 17:51:57 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: pam_unix.8,v 1.8 2005/02/26 15:59:34 thorpej Exp $
+.\" $NetBSD: pam_unix.8,v 1.9 2019/12/23 17:51:57 reed Exp $
 .\" Copyright (c) 2001 Mark R V Murray
 .\" All rights reserved.
 .\" Copyright (c) 2001 Networks Associates Technology, Inc.
@@ -62,7 +62,7 @@ and
 .Dq Li account
 features.
 It also provides a null function for session management.
-.Ss Ux Ss Authentication Module
+.Ss UNIX Authentication Module
 The
 .Ux
 authentication component
@@ -137,7 +137,7 @@ and silently allow authentication to suc
 .\" system is not configured to use the specified password database, an
 .\" authentication failure will occur.
 .El
-.Ss Ux Ss Account Management Module
+.Ss UNIX Account Management Module
 The
 .Ux
 account management component
@@ -156,7 +156,7 @@ debugging information at
 .Dv LOG_DEBUG
 level.
 .El
-.Ss Ux Ss Password Management Module
+.Ss UNIX Password Management Module
 The
 .Ux
 password management component



CVS commit: src/share/man/man8

2019-12-23 Thread Jeremy C. Reed
Module Name:src
Committed By:   reed
Date:   Mon Dec 23 17:31:54 UTC 2019

Modified Files:
src/share/man/man8: hpcboot.8

Log Message:
Simplify Subsection formatting

Had a formatting issue with mandoc but not groff.
Reported to mandoc developer. Bug in mandoc
but was recommended to not use the "weird" feature.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/share/man/man8/hpcboot.8

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/man8/hpcboot.8
diff -u src/share/man/man8/hpcboot.8:1.5 src/share/man/man8/hpcboot.8:1.6
--- src/share/man/man8/hpcboot.8:1.5	Tue May 17 13:51:34 2005
+++ src/share/man/man8/hpcboot.8	Mon Dec 23 17:31:54 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: hpcboot.8,v 1.5 2005/05/17 13:51:34 wiz Exp $
+.\"	$NetBSD: hpcboot.8,v 1.6 2019/12/23 17:31:54 reed Exp $
 .\"
 .\" Copyright (c) 2004 Valeriy E. Ushakov
 .\" All rights reserved.
@@ -49,7 +49,7 @@ Click on the
 button to exit
 .Nm .
 .\"
-.Ss Do Ss Kernel Dc Ss Tab
+.Ss Kernel Tab
 .\"
 On this tab you can select the kernel to boot and options to pass to
 the kernel.
@@ -92,7 +92,7 @@ are supported.
 This group of controls is used to pass boot flags to the kernel.
 .El
 .\"
-.Ss Do Ss Option Dc Ss Tab
+.Ss Option Tab
 .\"
 On this tab you can specify miscellaneous options that mostly control the
 .Nm
@@ -124,7 +124,7 @@ In this text field you can specify addit
 kernel.
 .El
 .\"
-.Ss Do Ss Console Dc Ss Tab
+.Ss Console Tab
 .\"
 This tab gets its name from the big text area that
 .Nm



CVS commit: src/sys/dev/dm

2019-12-23 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Mon Dec 23 16:17:36 UTC 2019

Modified Files:
src/sys/dev/dm: dm.h dm_ioctl.c dm_target.c dm_target_error.c
dm_target_zero.c

Log Message:
dm: Make target's ->table() optional

Since ->info() (counter part of ->table() in the original dm design
in Linux kernel in .status where both INFO and TABLE are optional)
is an optional handler, make ->table() optional as well. Some
targets don't have anything to do in ->table() just as in ->info().

taken-from: DragonFlyBSD


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/dm/dm.h
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/dm/dm_ioctl.c
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/dm/dm_target.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/dm/dm_target_error.c
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/dm/dm_target_zero.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/dm/dm.h
diff -u src/sys/dev/dm/dm.h:1.51 src/sys/dev/dm/dm.h:1.52
--- src/sys/dev/dm/dm.h:1.51	Sat Dec 21 16:00:29 2019
+++ src/sys/dev/dm/dm.h	Mon Dec 23 16:17:35 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm.h,v 1.51 2019/12/21 16:00:29 tkusumi Exp $  */
+/*$NetBSD: dm.h,v 1.52 2019/12/23 16:17:35 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -181,19 +181,19 @@ typedef struct dm_target {
 	/* Destroy target_config area */
 	int (*destroy)(dm_table_entry_t *);
 
-	/*
-	 * Info/table routine are called to get params string, which is target
-	 * specific. When dm_table_status_ioctl is called with flag
-	 * DM_STATUS_TABLE_FLAG I have to sent params string back.
-	 */
-	char *(*table)(void *);
 	int (*strategy)(dm_table_entry_t *, struct buf *);
 	int (*upcall)(dm_table_entry_t *, struct buf *);
 
 	/*
 	 * Optional routines.
 	 */
+	/*
+	 * Info/table routine are called to get params string, which is target
+	 * specific. When dm_table_status_ioctl is called with flag
+	 * DM_STATUS_TABLE_FLAG I have to sent params string back.
+	 */
 	char *(*info)(void *);
+	char *(*table)(void *);
 	int (*sync)(dm_table_entry_t *);
 	int (*secsize)(dm_table_entry_t *, unsigned int *);
 
@@ -262,14 +262,12 @@ int dm_target_stripe_secsize(dm_table_en
 
 /* dm_target_error.c */
 int dm_target_error_init(dm_table_entry_t*, int, char **);
-char *dm_target_error_table(void *);
 int dm_target_error_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_error_destroy(dm_table_entry_t *);
 int dm_target_error_upcall(dm_table_entry_t *, struct buf *);
 
 /* dm_target_zero.c */
 int dm_target_zero_init(dm_table_entry_t *, int, char **);
-char *dm_target_zero_table(void *);
 int dm_target_zero_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_zero_destroy(dm_table_entry_t *);
 int dm_target_zero_upcall(dm_table_entry_t *, struct buf *);

Index: src/sys/dev/dm/dm_ioctl.c
diff -u src/sys/dev/dm/dm_ioctl.c:1.48 src/sys/dev/dm/dm_ioctl.c:1.49
--- src/sys/dev/dm/dm_ioctl.c:1.48	Sat Dec 21 11:59:03 2019
+++ src/sys/dev/dm/dm_ioctl.c	Mon Dec 23 16:17:35 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_ioctl.c,v 1.48 2019/12/21 11:59:03 tkusumi Exp $  */
+/* $NetBSD: dm_ioctl.c,v 1.49 2019/12/23 16:17:35 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.48 2019/12/21 11:59:03 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.49 2019/12/23 16:17:35 tkusumi Exp $");
 
 /*
  * Locking is used to synchronise between ioctl calls and between dm_table's
@@ -936,6 +936,7 @@ dm_table_status_ioctl(prop_dictionary_t 
 
 	SLIST_FOREACH(table_en, tbl, next) {
 		char *params;
+		int is_table;
 
 		target_dict = prop_dictionary_create();
 		aprint_debug("%016" PRIu64 ", length %016" PRIu64
@@ -960,10 +961,11 @@ dm_table_status_ioctl(prop_dictionary_t 
 		 */
 		prop_dictionary_set_cstring(target_dict, DM_TABLE_PARAMS, "");
 
-		if (flags & DM_STATUS_TABLE_FLAG)
+		is_table = (flags & DM_STATUS_TABLE_FLAG) ? 1 : 0;
+		if (is_table && table_en->target->table)
 			params = table_en->target->table(
 			table_en->target_config);
-		else if (table_en->target->info)
+		else if (!is_table && table_en->target->info)
 			params = table_en->target->info(
 			table_en->target_config);
 		else

Index: src/sys/dev/dm/dm_target.c
diff -u src/sys/dev/dm/dm_target.c:1.36 src/sys/dev/dm/dm_target.c:1.37
--- src/sys/dev/dm/dm_target.c:1.36	Sat Dec 21 16:00:29 2019
+++ src/sys/dev/dm/dm_target.c	Mon Dec 23 16:17:35 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target.c,v 1.36 2019/12/21 16:00:29 tkusumi Exp $  */
+/*$NetBSD: dm_target.c,v 1.37 2019/12/23 16:17:35 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.36 2019/12/21 

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

2019-12-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Dec 23 15:51:47 UTC 2019

Modified Files:
src/sys/arch/arm/pic: pic.c picvar.h

Log Message:
Add reference counts to intr_mask/intr_unmask as calls can be nested, spotted 
by thorpej


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/pic/picvar.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/arch/arm/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.49 src/sys/arch/arm/pic/pic.c:1.50
--- src/sys/arch/arm/pic/pic.c:1.49	Mon Dec 23 15:34:23 2019
+++ src/sys/arch/arm/pic/pic.c	Mon Dec 23 15:51:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.49 2019/12/23 15:34:23 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.50 2019/12/23 15:51:47 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.49 2019/12/23 15:34:23 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.50 2019/12/23 15:51:47 jmcneill Exp $");
 
 #include 
 #include 
@@ -909,7 +909,8 @@ intr_mask(void *ih)
 	struct pic_softc * const pic = is->is_pic;
 	const int irq = is->is_irq;
 
-	(*pic->pic_ops->pic_block_irqs)(pic, irq & ~0x1f, __BIT(irq & 0x1f));
+	if (atomic_inc_32_nv(>is_mask_count) == 1)
+		(*pic->pic_ops->pic_block_irqs)(pic, irq & ~0x1f, __BIT(irq & 0x1f));
 }
 
 void
@@ -919,7 +920,8 @@ intr_unmask(void *ih)
 	struct pic_softc * const pic = is->is_pic;
 	const int irq = is->is_irq;
 
-	(*pic->pic_ops->pic_unblock_irqs)(pic, irq & ~0x1f, __BIT(irq & 0x1f));
+	if (atomic_dec_32_nv(>is_mask_count) == 0)
+		(*pic->pic_ops->pic_unblock_irqs)(pic, irq & ~0x1f, __BIT(irq & 0x1f));
 }
 
 const char *

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.24 src/sys/arch/arm/pic/picvar.h:1.25
--- src/sys/arch/arm/pic/picvar.h:1.24	Mon Dec 23 15:34:23 2019
+++ src/sys/arch/arm/pic/picvar.h	Mon Dec 23 15:51:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.24 2019/12/23 15:34:23 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.25 2019/12/23 15:51:47 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -126,6 +126,7 @@ struct intrsource {
 	bool is_mpsafe;
 	char is_source[16];
 	char *is_xname;
+	uint32_t is_mask_count;
 };
 
 struct pic_percpu {



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 15:51:50 UTC 2019

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

Log Message:
Oops, missed one more instance of unneeded-I2C_F_POLL.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/i2c/at24cxx.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/at24cxx.c
diff -u src/sys/dev/i2c/at24cxx.c:1.34 src/sys/dev/i2c/at24cxx.c:1.35
--- src/sys/dev/i2c/at24cxx.c:1.34	Mon Dec 23 02:39:47 2019
+++ src/sys/dev/i2c/at24cxx.c	Mon Dec 23 15:51:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: at24cxx.c,v 1.34 2019/12/23 02:39:47 thorpej Exp $	*/
+/*	$NetBSD: at24cxx.c,v 1.35 2019/12/23 15:51:50 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 1.34 2019/12/23 02:39:47 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 1.35 2019/12/23 15:51:50 thorpej Exp $");
 
 #include 
 #include 
@@ -431,7 +431,7 @@ seeprom_bootstrap_read(i2c_tag_t tag, in
 
 		/* Read a single byte. */
 		if (iic_exec(tag, I2C_OP_READ_WITH_STOP, addr,
-			 cmdbuf, cmdlen, rvp, 1, I2C_F_POLL)) {
+			 cmdbuf, cmdlen, rvp, 1, 0)) {
 			iic_release_bus(tag, 0);
 			return (-1);
 		}



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 15:48:51 UTC 2019

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

Log Message:
In as3722_poweroff and as3722_reboot(), check for errors from iic_acquire_bus()
before proceeding with writing to the device.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/i2c/as3722.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/as3722.c
diff -u src/sys/dev/i2c/as3722.c:1.17 src/sys/dev/i2c/as3722.c:1.18
--- src/sys/dev/i2c/as3722.c:1.17	Mon Dec 23 02:35:18 2019
+++ src/sys/dev/i2c/as3722.c	Mon Dec 23 15:48:51 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: as3722.c,v 1.17 2019/12/23 02:35:18 thorpej Exp $ */
+/* $NetBSD: as3722.c,v 1.18 2019/12/23 15:48:51 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -29,7 +29,7 @@
 #include "opt_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.17 2019/12/23 02:35:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.18 2019/12/23 15:48:51 thorpej Exp $");
 
 #include 
 #include 
@@ -852,10 +852,16 @@ as3722_poweroff(device_t dev)
 
 	const int flags = I2C_F_POLL;
 
-	iic_acquire_bus(sc->sc_i2c, flags);
-	error = as3722_write(sc, AS3722_RESET_CTRL_REG,
-	AS3722_RESET_CTRL_POWER_OFF, flags);
-	iic_release_bus(sc->sc_i2c, flags);
+	error = iic_acquire_bus(sc->sc_i2c, flags);
+	if (error == 0) {
+		error = as3722_write(sc, AS3722_RESET_CTRL_REG,
+		AS3722_RESET_CTRL_POWER_OFF, flags);
+		iic_release_bus(sc->sc_i2c, flags);
+	}
+	if (error) {
+		device_printf(dev, "WARNING: unable to power off, error %d\n",
+		error);
+	}
 
 	return error;
 }
@@ -868,10 +874,16 @@ as3722_reboot(device_t dev)
 
 	const int flags = I2C_F_POLL;
 
-	iic_acquire_bus(sc->sc_i2c, flags);
-	error = as3722_write(sc, AS3722_RESET_CTRL_REG,
-	AS3722_RESET_CTRL_FORCE_RESET, flags);
-	iic_release_bus(sc->sc_i2c, flags);
+	error = iic_acquire_bus(sc->sc_i2c, flags);
+	if (error == 0) {
+		error = as3722_write(sc, AS3722_RESET_CTRL_REG,
+		AS3722_RESET_CTRL_FORCE_RESET, flags);
+		iic_release_bus(sc->sc_i2c, flags);
+	}
+	if (error) {
+		device_printf(dev, "WARNING: unable to reboot, error %d\n",
+		error);
+	}
 
 	return error;
 }



CVS commit: src/sys/dev/pci

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 15:41:34 UTC 2019

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

Log Message:
piixpm_i2c_exec(): No need to check 'cold' to force I2C_F_POLL; the i2c
upper layer does it for us.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/pci/piixpm.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/piixpm.c
diff -u src/sys/dev/pci/piixpm.c:1.55 src/sys/dev/pci/piixpm.c:1.56
--- src/sys/dev/pci/piixpm.c:1.55	Sun Dec 22 23:23:32 2019
+++ src/sys/dev/pci/piixpm.c	Mon Dec 23 15:41:34 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpm.c,v 1.55 2019/12/22 23:23:32 thorpej Exp $ */
+/* $NetBSD: piixpm.c,v 1.56 2019/12/23 15:41:34 thorpej Exp $ */
 /*	$OpenBSD: piixpm.c,v 1.39 2013/10/01 20:06:02 sf Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.55 2019/12/22 23:23:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.56 2019/12/23 15:41:34 thorpej Exp $");
 
 #include 
 #include 
@@ -546,7 +546,7 @@ piixpm_i2c_exec(void *cookie, i2c_op_t o
 	if (st & PIIX_SMB_HS_BUSY)
 		return (1);
 
-	if (cold || sc->sc_poll)
+	if (sc->sc_poll)
 		flags |= I2C_F_POLL;
 
 	if (!I2C_OP_STOP_P(op) || cmdlen > 1 || len > 2 ||



CVS commit: src/sys/dev/pci

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 15:34:40 UTC 2019

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

Log Message:
ichsmb_i2c_exec(): No need to check 'cold' to force I2C_F_POLL; the i2c
upper layer does it for us.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/pci/ichsmb.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/ichsmb.c
diff -u src/sys/dev/pci/ichsmb.c:1.63 src/sys/dev/pci/ichsmb.c:1.64
--- src/sys/dev/pci/ichsmb.c:1.63	Sun Dec 22 23:23:32 2019
+++ src/sys/dev/pci/ichsmb.c	Mon Dec 23 15:34:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichsmb.c,v 1.63 2019/12/22 23:23:32 thorpej Exp $	*/
+/*	$NetBSD: ichsmb.c,v 1.64 2019/12/23 15:34:40 thorpej Exp $	*/
 /*	$OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.63 2019/12/22 23:23:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.64 2019/12/23 15:34:40 thorpej Exp $");
 
 #include 
 #include 
@@ -309,7 +309,7 @@ ichsmb_i2c_exec(void *cookie, i2c_op_t o
 	if (st & LPCIB_SMB_HS_BUSY)
 		return (1);
 
-	if (cold || sc->sc_poll)
+	if (sc->sc_poll)
 		flags |= I2C_F_POLL;
 
 	if (!I2C_OP_STOP_P(op) || cmdlen > 1 || len > 2 ||



CVS commit: src/sys/arch/arm

2019-12-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Dec 23 15:34:23 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c
src/sys/arch/arm/pic: pic.c picvar.h

Log Message:
Implement acpi_md_intr_mask and acpi_md_intr_unmask


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/acpi/acpi_machdep.c
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/pic/picvar.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/arch/arm/acpi/acpi_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_machdep.c:1.11 src/sys/arch/arm/acpi/acpi_machdep.c:1.12
--- src/sys/arch/arm/acpi/acpi_machdep.c:1.11	Sun Dec 22 15:57:06 2019
+++ src/sys/arch/arm/acpi/acpi_machdep.c	Mon Dec 23 15:34:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.11 2019/12/22 15:57:06 thorpej Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.12 2019/12/23 15:34:23 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.11 2019/12/22 15:57:06 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.12 2019/12/23 15:34:23 jmcneill Exp $");
 
 #include 
 #include 
@@ -259,15 +259,13 @@ acpi_md_intr_establish(uint32_t irq, int
 void
 acpi_md_intr_mask(void *ih)
 {
-	/* XXX */
-	panic("acpi_md_intr_mask(%p): not implemented", ih);
+	intr_mask(ih);
 }
 
 void
 acpi_md_intr_unmask(void *ih)
 {
-	/* XXX */
-	panic("acpi_md_intr_unmask(%p): not implemented", ih);
+	intr_unmask(ih);
 }
 
 void

Index: src/sys/arch/arm/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.48 src/sys/arch/arm/pic/pic.c:1.49
--- src/sys/arch/arm/pic/pic.c:1.48	Fri Nov 16 15:06:22 2018
+++ src/sys/arch/arm/pic/pic.c	Mon Dec 23 15:34:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.48 2018/11/16 15:06:22 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.49 2019/12/23 15:34:23 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.48 2018/11/16 15:06:22 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.49 2019/12/23 15:34:23 jmcneill Exp $");
 
 #include 
 #include 
@@ -902,6 +902,26 @@ intr_disestablish(void *ih)
 	pic_disestablish_source(is);
 }
 
+void
+intr_mask(void *ih)
+{
+	struct intrsource * const is = ih;
+	struct pic_softc * const pic = is->is_pic;
+	const int irq = is->is_irq;
+
+	(*pic->pic_ops->pic_block_irqs)(pic, irq & ~0x1f, __BIT(irq & 0x1f));
+}
+
+void
+intr_unmask(void *ih)
+{
+	struct intrsource * const is = ih;
+	struct pic_softc * const pic = is->is_pic;
+	const int irq = is->is_irq;
+
+	(*pic->pic_ops->pic_unblock_irqs)(pic, irq & ~0x1f, __BIT(irq & 0x1f));
+}
+
 const char *
 intr_string(intr_handle_t irq, char *buf, size_t len)
 {

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.23 src/sys/arch/arm/pic/picvar.h:1.24
--- src/sys/arch/arm/pic/picvar.h:1.23	Wed Mar 27 07:29:29 2019
+++ src/sys/arch/arm/pic/picvar.h	Mon Dec 23 15:34:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.23 2019/03/27 07:29:29 ryo Exp $	*/
+/*	$NetBSD: picvar.h,v 1.24 2019/12/23 15:34:23 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -90,6 +90,8 @@ void	*intr_establish(int irq, int ipl, i
 void	*intr_establish_xname(int irq, int ipl, int type, int (*func)(void *),
 	void *arg, const char *xname);
 void	intr_disestablish(void *);
+void	intr_mask(void *);
+void	intr_unmask(void *);
 const char *intr_string(intr_handle_t, char *, size_t);
 #ifdef MULTIPROCESSOR
 void	intr_cpu_init(struct cpu_info *);



CVS commit: src/sys/dev/pci

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 15:32:29 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/cxdtv.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/cxdtv.c
diff -u src/sys/dev/pci/cxdtv.c:1.17 src/sys/dev/pci/cxdtv.c:1.18
--- src/sys/dev/pci/cxdtv.c:1.17	Sun Dec 22 23:23:32 2019
+++ src/sys/dev/pci/cxdtv.c	Mon Dec 23 15:32:29 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cxdtv.c,v 1.17 2019/12/22 23:23:32 thorpej Exp $ */
+/* $NetBSD: cxdtv.c,v 1.18 2019/12/23 15:32:29 thorpej Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cxdtv.c,v 1.17 2019/12/22 23:23:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cxdtv.c,v 1.18 2019/12/23 15:32:29 thorpej Exp $");
 
 #include 
 #include 
@@ -1084,13 +1084,13 @@ cxdtv_card_init_hdtvwonder(struct cxdtv_
 	na = 0x0a; /* Nxt2004 address */
  	x = 0;
 
-	iic_acquire_bus(>sc_i2c, I2C_F_POLL);
+	iic_acquire_bus(>sc_i2c, 0);
 
 	for(i = 0; i < 5; i++)
 		x |= iic_exec(>sc_i2c, I2C_OP_WRITE_WITH_STOP, na,
-		nb[i], 2, NULL, 0, I2C_F_POLL);
+		nb[i], 2, NULL, 0, 0);
 
-	iic_release_bus(>sc_i2c, I2C_F_POLL);
+	iic_release_bus(>sc_i2c, 0);
 
 	if (x)
 		aprint_error_dev(sc->sc_dev, "HDTV Wonder tuner init failed");



CVS commit: src/sys/dev/pci

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 15:31:31 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/coram.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/coram.c
diff -u src/sys/dev/pci/coram.c:1.17 src/sys/dev/pci/coram.c:1.18
--- src/sys/dev/pci/coram.c:1.17	Sun Dec 22 23:23:32 2019
+++ src/sys/dev/pci/coram.c	Mon Dec 23 15:31:31 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: coram.c,v 1.17 2019/12/22 23:23:32 thorpej Exp $ */
+/* $NetBSD: coram.c,v 1.18 2019/12/23 15:31:31 thorpej Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: coram.c,v 1.17 2019/12/22 23:23:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coram.c,v 1.18 2019/12/23 15:31:31 thorpej Exp $");
 
 #include 
 #include 
@@ -247,10 +247,10 @@ coram_attach(device_t parent, device_t s
 	bar = 0;
 //	seeprom_bootstrap_read(>sc_i2c, 0x50, 0, 256, foo, 256);
 
-	iic_acquire_bus(>sc_i2c, I2C_F_POLL);
+	iic_acquire_bus(>sc_i2c, 0);
 	iic_exec(>sc_i2c, I2C_OP_READ_WITH_STOP, 0x50, , 1, foo, 256,
-	I2C_F_POLL);
-	iic_release_bus(>sc_i2c, I2C_F_POLL);
+	0);
+	iic_release_bus(>sc_i2c, 0);
 
 	printf("\n");
 	for ( i = 0; i < 256; i++) {



CVS commit: src/sys/dev/ic

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 15:29:36 UTC 2019

Modified Files:
src/sys/dev/ic: pcf8584.c

Log Message:
pcfiic_i2c_exec(): No need to check 'cold' to force I2C_F_POLL; the i2c
upper layer does it for us.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ic/pcf8584.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/ic/pcf8584.c
diff -u src/sys/dev/ic/pcf8584.c:1.16 src/sys/dev/ic/pcf8584.c:1.17
--- src/sys/dev/ic/pcf8584.c:1.16	Sun Dec 22 23:23:32 2019
+++ src/sys/dev/ic/pcf8584.c	Mon Dec 23 15:29:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8584.c,v 1.16 2019/12/22 23:23:32 thorpej Exp $	*/
+/*	$NetBSD: pcf8584.c,v 1.17 2019/12/23 15:29:36 thorpej Exp $	*/
 /*	$OpenBSD: pcf8584.c,v 1.9 2007/10/20 18:46:21 kettenis Exp $ */
 
 /*
@@ -120,7 +120,7 @@ pcfiic_i2c_exec(void *arg, i2c_op_t op, 
 device_xname(sc->sc_dev), op, addr, (int)cmdlen, (int)len, flags);
 #endif
 
-	if (cold || sc->sc_poll)
+	if (sc->sc_poll)
 		flags |= I2C_F_POLL;
 
 	if (sc->sc_master)



CVS commit: src/sys/dev/ic

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 15:28:08 UTC 2019

Modified Files:
src/sys/dev/ic: dwiic.c

Log Message:
dwiic_i2c_exec(): No need to check 'cold' to force I2C_F_POLL; the i2c
upper layer does it for us.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/dwiic.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/ic/dwiic.c
diff -u src/sys/dev/ic/dwiic.c:1.6 src/sys/dev/ic/dwiic.c:1.7
--- src/sys/dev/ic/dwiic.c:1.6	Sun Dec 22 23:23:32 2019
+++ src/sys/dev/ic/dwiic.c	Mon Dec 23 15:28:08 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dwiic.c,v 1.6 2019/12/22 23:23:32 thorpej Exp $ */
+/* $NetBSD: dwiic.c,v 1.7 2019/12/23 15:28:08 thorpej Exp $ */
 
 /* $OpenBSD: dwiic.c,v 1.4 2018/05/23 22:08:00 kettenis Exp $ */
 
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwiic.c,v 1.6 2019/12/22 23:23:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwiic.c,v 1.7 2019/12/23 15:28:08 thorpej Exp $");
 
 #include 
 #include 
@@ -335,7 +335,7 @@ dwiic_i2c_exec(void *cookie, i2c_op_t op
 	const uint8_t *bcmd;
 	uint8_t *bdata;
 
-	if (cold || sc->sc_poll)
+	if (sc->sc_poll)
 		flags |= I2C_F_POLL;
 
 	DPRINTF(("%s: %s: op %d, addr 0x%02x, cmdlen %zu, len %zu, "



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 15:25:08 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/i2c/tvpll.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/tvpll.c
diff -u src/sys/dev/i2c/tvpll.c:1.7 src/sys/dev/i2c/tvpll.c:1.8
--- src/sys/dev/i2c/tvpll.c:1.7	Thu Jun  1 02:45:10 2017
+++ src/sys/dev/i2c/tvpll.c	Mon Dec 23 15:25:08 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: tvpll.c,v 1.7 2017/06/01 02:45:10 chs Exp $ */
+/* $NetBSD: tvpll.c,v 1.8 2019/12/23 15:25:08 thorpej Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tvpll.c,v 1.7 2017/06/01 02:45:10 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tvpll.c,v 1.8 2019/12/23 15:25:08 thorpej Exp $");
 
 #include 
 #include 
@@ -63,11 +63,11 @@ tvpll_open(device_t parent, i2c_tag_t t,
 	tvpll->pll = p;
 
 	if (tvpll->pll->initdata) {
-		iic_acquire_bus(tvpll->tag, I2C_F_POLL);
+		iic_acquire_bus(tvpll->tag, 0);
 		(void)iic_exec(tvpll->tag, I2C_OP_WRITE_WITH_STOP, tvpll->addr,
 		>pll->initdata[1], tvpll->pll->initdata[0],
-		NULL, 0, I2C_F_POLL);
-		iic_release_bus(tvpll->tag, I2C_F_POLL);
+		NULL, 0, 0);
+		iic_release_bus(tvpll->tag, 0);
 	}
 
 	device_printf(parent, "tvpll: %s\n", tvpll->pll->name);
@@ -132,15 +132,15 @@ tvpll_tune_dtv(struct tvpll *tvpll,
 	if((rv = tvpll_algo(tvpll, b, params, )) != 0)
 		return rv;
 
-	iic_acquire_bus(tvpll->tag, I2C_F_POLL);
+	iic_acquire_bus(tvpll->tag, 0);
 	/* gate ctrl? */
 	if (b[4] != TVPLL_IGNORE_AUX) {
 		ab[0] = b[2] | 0x18;
 		ab[1] = b[4];
-		rv = iic_exec(tvpll->tag, I2C_OP_WRITE_WITH_STOP, tvpll->addr, ab, 2, NULL, 0, I2C_F_POLL);
+		rv = iic_exec(tvpll->tag, I2C_OP_WRITE_WITH_STOP, tvpll->addr, ab, 2, NULL, 0, 0);
 	}
-	rv = iic_exec(tvpll->tag, I2C_OP_WRITE_WITH_STOP, tvpll->addr, b, 4, NULL, 0, I2C_F_POLL);
-	iic_release_bus(tvpll->tag, I2C_F_POLL);
+	rv = iic_exec(tvpll->tag, I2C_OP_WRITE_WITH_STOP, tvpll->addr, b, 4, NULL, 0, 0);
+	iic_release_bus(tvpll->tag, 0);
 
 	if (rv != 0)
 		printf("%s\n", __func__);



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 15:07:42 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/i2c/titemp.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/titemp.c
diff -u src/sys/dev/i2c/titemp.c:1.7 src/sys/dev/i2c/titemp.c:1.8
--- src/sys/dev/i2c/titemp.c:1.7	Tue Jun 26 06:03:57 2018
+++ src/sys/dev/i2c/titemp.c	Mon Dec 23 15:07:42 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: titemp.c,v 1.7 2018/06/26 06:03:57 thorpej Exp $ */
+/* $NetBSD: titemp.c,v 1.8 2019/12/23 15:07:42 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: titemp.c,v 1.7 2018/06/26 06:03:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: titemp.c,v 1.8 2019/12/23 15:07:42 thorpej Exp $");
 
 #include 
 #include 
@@ -102,11 +102,11 @@ titemp_match(device_t parent, cfdata_t m
 	if (ia->ia_addr != 0x4c)
 		return 0;
 
-	if (iic_acquire_bus(ia->ia_tag, I2C_F_POLL) != 0)
+	if (iic_acquire_bus(ia->ia_tag, 0) != 0)
 		return 0;
 	error = iic_smbus_read_byte(ia->ia_tag, ia->ia_addr,
-	TITEMP_MFID_REG, , I2C_F_POLL);
-	iic_release_bus(ia->ia_tag, I2C_F_POLL);
+	TITEMP_MFID_REG, , 0);
+	iic_release_bus(ia->ia_tag, 0);
 
 	if (error || mfid != TITEMP_MFID_TMP451)
 		return 0;



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 15:05:32 UTC 2019

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

Log Message:
No need to check 'cold' for I2C_F_POLL; the i2c code does it for us.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/tda19988.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/tda19988.c
diff -u src/sys/dev/i2c/tda19988.c:1.3 src/sys/dev/i2c/tda19988.c:1.4
--- src/sys/dev/i2c/tda19988.c:1.3	Mon Nov  4 10:02:39 2019
+++ src/sys/dev/i2c/tda19988.c	Mon Dec 23 15:05:32 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: tda19988.c,v 1.3 2019/11/04 10:02:39 jmcneill Exp $ */
+/* $NetBSD: tda19988.c,v 1.4 2019/12/23 15:05:32 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015 Oleksandr Tymoshenko 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tda19988.c,v 1.3 2019/11/04 10:02:39 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tda19988.c,v 1.4 2019/12/23 15:05:32 thorpej Exp $");
 
 /*
 * NXP TDA19988 HDMI encoder 
@@ -283,8 +283,7 @@ tda19988_set_page(struct tda19988_softc 
 	uint8_t buf[2] = { TDA_CURPAGE_ADDR, page };
 	int result;
 
-	result = iic_exec(sc->sc_i2c, I2C_OP_WRITE_WITH_STOP, sc->sc_addr, buf, 2, NULL, 0,
-	cold ? I2C_F_POLL : 0);
+	result = iic_exec(sc->sc_i2c, I2C_OP_WRITE_WITH_STOP, sc->sc_addr, buf, 2, NULL, 0, 0);
 	if (result == 0)
 		sc->sc_current_page = page;
 
@@ -294,8 +293,7 @@ tda19988_set_page(struct tda19988_softc 
 static int
 tda19988_cec_read(struct tda19988_softc *sc, uint8_t addr, uint8_t *data)
 {
-	return iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP, sc->sc_cec_addr, , 1, data, 1,
-	cold ? I2C_F_POLL : 0);
+	return iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP, sc->sc_cec_addr, , 1, data, 1, 0);
 }
 
 static int 
@@ -303,8 +301,7 @@ tda19988_cec_write(struct tda19988_softc
 {
 	uint8_t buf[2] = { addr, data };
 
-	return iic_exec(sc->sc_i2c, I2C_OP_WRITE_WITH_STOP, sc->sc_cec_addr, buf, 2, NULL, 0,
-	cold ? I2C_F_POLL : 0);
+	return iic_exec(sc->sc_i2c, I2C_OP_WRITE_WITH_STOP, sc->sc_cec_addr, buf, 2, NULL, 0, 0);
 }
 
 static int
@@ -317,8 +314,7 @@ tda19988_block_read(struct tda19988_soft
 	if (sc->sc_current_page != REGPAGE(addr))
 		tda19988_set_page(sc, REGPAGE(addr));
 
-	return iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP, sc->sc_addr, , 1, data, len,
-	cold ? I2C_F_POLL : 0);
+	return iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP, sc->sc_addr, , 1, data, len, 0);
 }
 
 static int
@@ -331,8 +327,7 @@ tda19988_reg_read(struct tda19988_softc 
 	if (sc->sc_current_page != REGPAGE(addr))
 		tda19988_set_page(sc, REGPAGE(addr));
 
-	return iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP, sc->sc_addr, , 1, data, 1,
-	cold ? I2C_F_POLL : 0);
+	return iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP, sc->sc_addr, , 1, data, 1, 0);
 }
 
 static int
@@ -343,8 +338,7 @@ tda19988_reg_write(struct tda19988_softc
 	if (sc->sc_current_page != REGPAGE(addr))
 		tda19988_set_page(sc, REGPAGE(addr));
 
-	return iic_exec(sc->sc_i2c, I2C_OP_WRITE_WITH_STOP, sc->sc_addr, buf, 2, NULL, 0,
-	cold ? I2C_F_POLL : 0);
+	return iic_exec(sc->sc_i2c, I2C_OP_WRITE_WITH_STOP, sc->sc_addr, buf, 2, NULL, 0, 0);
 }
 
 static int
@@ -359,8 +353,7 @@ tda19988_reg_write2(struct tda19988_soft
 	if (sc->sc_current_page != REGPAGE(address))
 		tda19988_set_page(sc, REGPAGE(address));
 
-	return iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP, sc->sc_addr, buf, 3, NULL, 0,
-	cold ? I2C_F_POLL : 0);
+	return iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP, sc->sc_addr, buf, 3, NULL, 0, 0);
 }
 
 static void
@@ -698,9 +691,9 @@ tda19988_connector_detect(struct drm_con
 	enum drm_connector_status status;
 	uint8_t data = 0;
 
-	iic_acquire_bus(sc->sc_i2c, cold ? I2C_F_POLL : 0);
+	iic_acquire_bus(sc->sc_i2c, 0);
 	tda19988_cec_read(sc, TDA_CEC_RXSHPDLEV, );
-	iic_release_bus(sc->sc_i2c, cold ? I2C_F_POLL : 0);
+	iic_release_bus(sc->sc_i2c, 0);
 
 	status = (data & RXSHPDLEV_HPD) ?
 	connector_status_connected :
@@ -741,10 +734,10 @@ tda19988_connector_get_modes(struct drm_
 	if (sc->sc_edid_valid) {
 		pedid = (struct edid *)sc->sc_edid;
 	} else {
-		iic_acquire_bus(sc->sc_i2c, cold ? I2C_F_POLL : 0);
+		iic_acquire_bus(sc->sc_i2c, 0);
 		if (tda19988_read_edid(sc) == 0)
 			pedid = (struct edid *)sc->sc_edid;
-		iic_release_bus(sc->sc_i2c, cold ? I2C_F_POLL : 0);
+		iic_release_bus(sc->sc_i2c, 0);
 		sc->sc_edid_valid = true;
 	}
 
@@ -838,9 +831,9 @@ tda19988_bridge_mode_set(struct drm_brid
 {
 	struct tda19988_softc * const sc = bridge->driver_private;
 
-	iic_acquire_bus(sc->sc_i2c, cold ? I2C_F_POLL : 0);
+	iic_acquire_bus(sc->sc_i2c, 0);
 	tda19988_init_encoder(sc, adjusted_mode);
-	iic_release_bus(sc->sc_i2c, cold ? I2C_F_POLL : 0);
+	iic_release_bus(sc->sc_i2c, 0);
 }
 
 static bool
@@ -927,9 +920,9 @@ tda19988_attach(device_t parent, device_
 	aprint_naive("\n");
 	aprint_normal(": NXP TDA19988 HDMI transmitter\n");
 
-	

CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 14:55:22 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/i2c/spdmem_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/spdmem_i2c.c
diff -u src/sys/dev/i2c/spdmem_i2c.c:1.17 src/sys/dev/i2c/spdmem_i2c.c:1.18
--- src/sys/dev/i2c/spdmem_i2c.c:1.17	Sat Oct 20 03:23:05 2018
+++ src/sys/dev/i2c/spdmem_i2c.c	Mon Dec 23 14:55:22 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: spdmem_i2c.c,v 1.17 2018/10/20 03:23:05 macallan Exp $ */
+/* $NetBSD: spdmem_i2c.c,v 1.18 2019/12/23 14:55:22 thorpej Exp $ */
 
 /*
  * Copyright (c) 2007 Nicolas Joly
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.17 2018/10/20 03:23:05 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.18 2019/12/23 14:55:22 thorpej Exp $");
 
 #include 
 #include 
@@ -114,9 +114,9 @@ spdmem_reset_page(struct spdmem_i2c_soft
 	 * doesn't exist at the address.
 	 */
 	rv = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, , 1,
-	, 1, I2C_F_POLL);
+	, 1, 0);
 	rv |= iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, , 1,
-	, 1, I2C_F_POLL);
+	, 1, 0);
 	if (rv != 0)
 		goto error;
 
@@ -143,7 +143,7 @@ spdmem_reset_page(struct spdmem_i2c_soft
 		 * I don't know whether our icc_exec()'s API is good or not.
 		 */
 		rv = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_page0,
-		, 1, , 1, I2C_F_POLL);
+		, 1, , 1, 0);
 		if (rv != 0) {
 			/*
 			 * The possibilities are:
@@ -153,7 +153,7 @@ spdmem_reset_page(struct spdmem_i2c_soft
 			 * Is there no way to distinguish them now?
 			 */
 			rv = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
-			sc->sc_page0, , 1, , 1, I2C_F_POLL);
+			sc->sc_page0, , 1, , 1, 0);
 			if (rv == 0) {
 aprint_debug("Page 1 was selected. Page 0 is "
 "selected now.\n");
@@ -269,14 +269,14 @@ spdmem_i2c_read(struct spdmem_softc *sof
 
 	if (addr & 0x100) {
 		rv = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_page1,
-		, 1, , 1, I2C_F_POLL);
+		, 1, , 1, 0);
 		rv |= iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
-		, 1, val, 1, I2C_F_POLL);
+		, 1, val, 1, 0);
 		rv |= iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
-		sc->sc_page0, , 1, , 1, I2C_F_POLL);
+		sc->sc_page0, , 1, , 1, 0);
 	} else {
 		rv = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
-		, 1, val, 1, I2C_F_POLL);
+		, 1, val, 1, 0);
 	}
 
 	iic_release_bus(sc->sc_tag, 0);



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 14:50:44 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/mpl115a.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/mpl115a.c
diff -u src/sys/dev/i2c/mpl115a.c:1.2 src/sys/dev/i2c/mpl115a.c:1.3
--- src/sys/dev/i2c/mpl115a.c:1.2	Sat Jun 16 21:22:13 2018
+++ src/sys/dev/i2c/mpl115a.c	Mon Dec 23 14:50:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpl115a.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
+/*	$NetBSD: mpl115a.c,v 1.3 2019/12/23 14:50:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpl115a.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpl115a.c,v 1.3 2019/12/23 14:50:43 thorpej Exp $");
 
 #include 
 #include 
@@ -154,16 +154,16 @@ mpl115a_load_coeffs(struct mpl115a_softc
 static void 
 mpl115a_reg_write_1(struct mpl115a_softc *sc, uint8_t reg, uint8_t val) 
 {
-	if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL) != 0) {
+	if (iic_acquire_bus(sc->sc_tag, 0) != 0) {
 		aprint_error_dev(sc->sc_dev, "cannot acquire bus for write\n");
 		return;
 	}
 
 	if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr, , 1,
-	, 1, I2C_F_POLL)) {
+	, 1, 0)) {
 		aprint_error_dev(sc->sc_dev, "cannot execute write\n");
 	}
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 }
 
 static uint8_t
@@ -171,7 +171,7 @@ mpl115a_reg_read_1(struct mpl115a_softc 
 {
 	uint8_t rv, wbuf[2];
 
-	if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL) != 0) {
+	if (iic_acquire_bus(sc->sc_tag, 0) != 0) {
 #ifdef MPL115A_DEBUG
 		aprint_error_dev(sc->sc_dev, "cannot acquire bus for read\n");
 #endif /* MPL115A_DEBUG */ 
@@ -181,12 +181,12 @@ mpl115a_reg_read_1(struct mpl115a_softc 
 	wbuf[0] = reg;
 
 	if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, wbuf,
-	1, , 1, I2C_F_POLL)) {
+	1, , 1, 0)) {
+		iic_release_bus(sc->sc_tag, 0);
 		aprint_error_dev(sc->sc_dev, "cannot execute read\n");
-		iic_release_bus(sc->sc_tag, I2C_F_POLL);
 		return 0;
 	}
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 
 	return rv;
 }



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 14:48:58 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/mcp980x.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/mcp980x.c
diff -u src/sys/dev/i2c/mcp980x.c:1.6 src/sys/dev/i2c/mcp980x.c:1.7
--- src/sys/dev/i2c/mcp980x.c:1.6	Sat Jun 16 21:22:13 2018
+++ src/sys/dev/i2c/mcp980x.c	Mon Dec 23 14:48:58 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcp980x.c,v 1.6 2018/06/16 21:22:13 thorpej Exp $ */
+/*	$NetBSD: mcp980x.c,v 1.7 2019/12/23 14:48:58 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mcp980x.c,v 1.6 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcp980x.c,v 1.7 2019/12/23 14:48:58 thorpej Exp $");
 
 #include 
 #include 
@@ -143,18 +143,18 @@ mcp980x_reg_read_2(struct mcp980x_softc 
 {
 	uint16_t rv;
 
-	if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL) != 0) {
+	if (iic_acquire_bus(sc->sc_tag, 0) != 0) {
 		aprint_error_dev(sc->sc_dev, "cannot acquire bus for read\n");
 		return 0;
 	}
 
 	if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, ,
-	1, , 2, I2C_F_POLL)) {
+	1, , 2, 0)) {
+		iic_release_bus(sc->sc_tag, 0);
 		aprint_error_dev(sc->sc_dev, "cannot execute operation\n");
-		iic_release_bus(sc->sc_tag, I2C_F_POLL);
 		return 0;
 	}
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 
 	return be16toh(rv);
 }
@@ -164,18 +164,18 @@ mcp980x_reg_read_1(struct mcp980x_softc 
 {
 	uint8_t rv;
 
-	if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL) != 0) {
+	if (iic_acquire_bus(sc->sc_tag, 0) != 0) {
 		aprint_error_dev(sc->sc_dev, "cannot acquire bus for read\n");
 		return 0;
 	}
 
 	if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, ,
-	1, , 1, I2C_F_POLL)) {
+	1, , 1, 0)) {
+		iic_release_bus(sc->sc_tag, 0);
 		aprint_error_dev(sc->sc_dev, "cannot execute operation\n");
-		iic_release_bus(sc->sc_tag, I2C_F_POLL);
 		return 0;
 	}
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 
 	return rv;
 }
@@ -187,34 +187,34 @@ mcp980x_reg_write_2(struct mcp980x_softc
 
 	beval = htobe16(val);
 
-if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL) != 0) {
+if (iic_acquire_bus(sc->sc_tag, 0) != 0) {
 		aprint_error_dev(sc->sc_dev, "cannot acquire bus for write\n");
 		return;
 	}
 
 if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr, ,
-	1, , 2, I2C_F_POLL)) {
+	1, , 2, 0)) {
 		aprint_error_dev(sc->sc_dev, "cannot execute operation\n");
 }
 
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 
 }
 
 static void
 mcp980x_reg_write_1(struct mcp980x_softc *sc, uint8_t reg, uint8_t val)
 {
-if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL) != 0) {
+if (iic_acquire_bus(sc->sc_tag, 0) != 0) {
 		aprint_error_dev(sc->sc_dev, "cannot acquire bus for write\n");
 		return;
 	}
 
 if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr, ,
-	1, , 1, I2C_F_POLL)) {
+	1, , 1, 0)) {
 		aprint_error_dev(sc->sc_dev, "cannot execute operation\n");
 }
 
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 
 }
 



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 14:43:03 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/i2c/lm87.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/lm87.c
diff -u src/sys/dev/i2c/lm87.c:1.10 src/sys/dev/i2c/lm87.c:1.11
--- src/sys/dev/i2c/lm87.c:1.10	Tue Jun 26 06:03:57 2018
+++ src/sys/dev/i2c/lm87.c	Mon Dec 23 14:43:03 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lm87.c,v 1.10 2018/06/26 06:03:57 thorpej Exp $	*/
+/*	$NetBSD: lm87.c,v 1.11 2019/12/23 14:43:03 thorpej Exp $	*/
 /*	$OpenBSD: lm87.c,v 1.20 2008/11/10 05:19:48 cnst Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lm87.c,v 1.10 2018/06/26 06:03:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm87.c,v 1.11 2019/12/23 14:43:03 thorpej Exp $");
 
 #include 
 #include 
@@ -164,7 +164,7 @@ lmenv_match(device_t parent, cfdata_t ma
 	cmd = LM87_COMPANY_ID;
 	iic_acquire_bus(ia->ia_tag, 0);
 	error = iic_exec(ia->ia_tag, I2C_OP_READ_WITH_STOP, ia->ia_addr,
-	, 1, , 1, I2C_F_POLL);
+	, 1, , 1, 0);
 	iic_release_bus(ia->ia_tag, 0);
 
 	if (error)



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 14:41:41 UTC 2019

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

Log Message:
No need to use I2C_F_POLL here.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/i2c/lm75.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/lm75.c
diff -u src/sys/dev/i2c/lm75.c:1.34 src/sys/dev/i2c/lm75.c:1.35
--- src/sys/dev/i2c/lm75.c:1.34	Wed Feb 20 18:19:46 2019
+++ src/sys/dev/i2c/lm75.c	Mon Dec 23 14:41:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lm75.c,v 1.34 2019/02/20 18:19:46 macallan Exp $	*/
+/*	$NetBSD: lm75.c,v 1.35 2019/12/23 14:41:41 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.34 2019/02/20 18:19:46 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.35 2019/12/23 14:41:41 thorpej Exp $");
 
 #include 
 #include 
@@ -206,7 +206,7 @@ lmtemp_attach(device_t parent, device_t 
 	sc->sc_lmtemp_decode = lmtemptbl[i].lmtemp_decode;
 	sc->sc_lmtemp_encode = lmtemptbl[i].lmtemp_encode;
 
-	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+	iic_acquire_bus(sc->sc_tag, 0);
 
 	/* Read temperature limit(s) and remember initial value(s). */
 	if (i == lmtemp_lm77) {
@@ -214,28 +214,28 @@ lmtemp_attach(device_t parent, device_t 
 		>sc_scrit, 1) != 0) {
 			aprint_error_dev(self,
 			"unable to read low register\n");
-			iic_release_bus(sc->sc_tag, I2C_F_POLL);
+			iic_release_bus(sc->sc_tag, 0);
 			return;
 		}
 		if (lmtemp_temp_read(sc, LM77_REG_TLOW_SET_POINT,
 		>sc_smin, 1) != 0) {
 			aprint_error_dev(self,
 			"unable to read low register\n");
-			iic_release_bus(sc->sc_tag, I2C_F_POLL);
+			iic_release_bus(sc->sc_tag, 0);
 			return;
 		}
 		if (lmtemp_temp_read(sc, LM77_REG_THIGH_SET_POINT,
 		>sc_smax, 1) != 0) {
 			aprint_error_dev(self,
 			"unable to read high register\n");
-			iic_release_bus(sc->sc_tag, I2C_F_POLL);
+			iic_release_bus(sc->sc_tag, 0);
 			return;
 		}
 	} else {	/* LM75 or compatible */
 		if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT,
 		>sc_smax, 1) != 0) {
 			aprint_error_dev(self, "unable to read Tos register\n");
-			iic_release_bus(sc->sc_tag, I2C_F_POLL);
+			iic_release_bus(sc->sc_tag, 0);
 			return;
 		}
 	}
@@ -247,10 +247,10 @@ lmtemp_attach(device_t parent, device_t 
 	/* Set the configuration of the LM75 to defaults. */
 	if (lmtemp_config_write(sc, LM75_CONFIG_FAULT_QUEUE_4) != 0) {
 		aprint_error_dev(self, "unable to write config register\n");
-		iic_release_bus(sc->sc_tag, I2C_F_POLL);
+		iic_release_bus(sc->sc_tag, 0);
 		return;
 	}
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 
 	sc->sc_sme = sysmon_envsys_create();
 	/* Initialize sensor data. */
@@ -297,7 +297,7 @@ lmtemp_config_write(struct lmtemp_softc 
 	cmdbuf[1] = val;
 
 	return iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
-	sc->sc_address, cmdbuf, 1, [1], 1, I2C_F_POLL);
+	sc->sc_address, cmdbuf, 1, [1], 1, 0);
 }
 
 static int
@@ -309,7 +309,7 @@ lmtemp_temp_write(struct lmtemp_softc *s
 	sc->sc_lmtemp_encode(val, [1], degc);
 
 	return iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
-	sc->sc_address, cmdbuf, 1, [1], 2, I2C_F_POLL);
+	sc->sc_address, cmdbuf, 1, [1], 2, 0);
 }
 
 static int
@@ -596,12 +596,12 @@ sysctl_lm75_temp(SYSCTLFN_ARGS)
 
 			temp = *(int *)node.sysctl_data;
 			sc->sc_tmax = temp;
-			iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+			iic_acquire_bus(sc->sc_tag, 0);
 			lmtemp_temp_write(sc, LM75_REG_THYST_SET_POINT,
 			sc->sc_tmax - 5, 1);
 			lmtemp_temp_write(sc, LM75_REG_TOS_SET_POINT,
 			sc->sc_tmax, 1);
-			iic_release_bus(sc->sc_tag, I2C_F_POLL);
+			iic_release_bus(sc->sc_tag, 0);
 
 			/* Synchronise envsys - calls lmtemp_getlim_lm75() */
 			sysmon_envsys_update_limits(sc->sc_sme, >sc_sensor);



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 14:34:23 UTC 2019

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

Log Message:
In axppmic_power_poweroff(), check for errors from iic_acquire_bus()
before proceeding with writing to the device.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/i2c/axppmic.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/axppmic.c
diff -u src/sys/dev/i2c/axppmic.c:1.27 src/sys/dev/i2c/axppmic.c:1.28
--- src/sys/dev/i2c/axppmic.c:1.27	Mon Dec 23 02:57:32 2019
+++ src/sys/dev/i2c/axppmic.c	Mon Dec 23 14:34:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: axppmic.c,v 1.27 2019/12/23 02:57:32 thorpej Exp $ */
+/* $NetBSD: axppmic.c,v 1.28 2019/12/23 14:34:23 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2014-2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.27 2019/12/23 02:57:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.28 2019/12/23 14:34:23 thorpej Exp $");
 
 #include 
 #include 
@@ -557,12 +557,20 @@ static void
 axppmic_power_poweroff(device_t dev)
 {
 	struct axppmic_softc *sc = device_private(dev);
+	int error;
 
 	delay(100);
 
-	iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
-	axppmic_write(sc->sc_i2c, sc->sc_addr, AXP_POWER_DISABLE_REG, AXP_POWER_DISABLE_CTRL, I2C_F_POLL);
-	iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+	error = iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
+	if (error == 0) {
+		error = axppmic_write(sc->sc_i2c, sc->sc_addr,
+		AXP_POWER_DISABLE_REG, AXP_POWER_DISABLE_CTRL, I2C_F_POLL);
+		iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+	}
+	if (error) {
+		device_printf(dev, "WARNING: unable to power off, error %d\n",
+		error);
+	}
 }
 
 static struct fdtbus_power_controller_func axppmic_power_funcs = {



CVS commit: src/sys/dev/i2c

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 14:26:19 UTC 2019

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

Log Message:
Disable the not-in-interrupt assertions for now; more work needs to be
done in several i2c client drivers.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/i2c/i2c_exec.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/i2c_exec.c
diff -u src/sys/dev/i2c/i2c_exec.c:1.13 src/sys/dev/i2c/i2c_exec.c:1.14
--- src/sys/dev/i2c/i2c_exec.c:1.13	Sun Dec 22 23:23:32 2019
+++ src/sys/dev/i2c/i2c_exec.c	Mon Dec 23 14:26:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c_exec.c,v 1.13 2019/12/22 23:23:32 thorpej Exp $	*/
+/*	$NetBSD: i2c_exec.c,v 1.14 2019/12/23 14:26:19 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i2c_exec.c,v 1.13 2019/12/22 23:23:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c_exec.c,v 1.14 2019/12/23 14:26:19 thorpej Exp $");
 
 #include 
 #include 
@@ -98,7 +98,9 @@ int
 iic_acquire_bus(i2c_tag_t tag, int flags)
 {
 
+#if 0	/* XXX Not quite ready for this yet. */
 	KASSERT(!cpu_intr_p());
+#endif
 
 	flags = iic_op_flags(flags);
 
@@ -151,7 +153,9 @@ void
 iic_release_bus(i2c_tag_t tag, int flags)
 {
 
+#if 0	/* XXX Not quite ready for this yet. */
 	KASSERT(!cpu_intr_p());
+#endif
 
 	flags = iic_op_flags(flags);
 
@@ -181,7 +185,9 @@ iic_exec(i2c_tag_t tag, i2c_op_t op, i2c
 	int error;
 	size_t len;
 
+#if 0	/* XXX Not quite ready for this yet. */
 	KASSERT(!cpu_intr_p());
+#endif
 
 	flags = iic_op_flags(flags);
 



CVS commit: src/sys/arch/xen

2019-12-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Dec 23 13:35:37 UTC 2019

Modified Files:
src/sys/arch/xen/include: intr.h
src/sys/arch/xen/x86: xen_intr.c

Log Message:
Provide XEN stubs for intr_mask() / intr_unmask().


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/xen/include/intr.h
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/xen/x86/xen_intr.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/xen/include/intr.h
diff -u src/sys/arch/xen/include/intr.h:1.52 src/sys/arch/xen/include/intr.h:1.53
--- src/sys/arch/xen/include/intr.h:1.52	Sat Feb  2 12:32:55 2019
+++ src/sys/arch/xen/include/intr.h	Mon Dec 23 13:35:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.52 2019/02/02 12:32:55 cherry Exp $	*/
+/*	$NetBSD: intr.h,v 1.53 2019/12/23 13:35:37 thorpej Exp $	*/
 /*	NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp	*/
 
 /*-
@@ -91,6 +91,8 @@ void *xen_intr_establish_xname(int, stru
 void *, bool, const char *);
 void *xen_intr_establish(int, struct pic *, int, int, int, int (*)(void *),
 void *, bool);
+void xen_intr_mask(struct intrhand *);
+void xen_intr_unmask(struct intrhand *);
 void xen_intr_disestablish(struct intrhand *);
 
 #endif /* !_LOCORE */

Index: src/sys/arch/xen/x86/xen_intr.c
diff -u src/sys/arch/xen/x86/xen_intr.c:1.17 src/sys/arch/xen/x86/xen_intr.c:1.18
--- src/sys/arch/xen/x86/xen_intr.c:1.17	Fri Jun  7 12:43:52 2019
+++ src/sys/arch/xen/x86/xen_intr.c	Mon Dec 23 13:35:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_intr.c,v 1.17 2019/06/07 12:43:52 cherry Exp $	*/
+/*	$NetBSD: xen_intr.c,v 1.18 2019/12/23 13:35:37 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.17 2019/06/07 12:43:52 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.18 2019/12/23 13:35:37 thorpej Exp $");
 
 #include 
 #include 
@@ -241,6 +241,26 @@ xen_intr_establish_xname(int legacy_irq,
 }
 
 /*
+ * Mask an interrupt source.
+ */
+void
+xen_intr_mask(struct intrhand *ih)
+{
+	/* XXX */
+	panic("xen_intr_mask: not yet implemented.");
+}
+
+/*
+ * Unmask an interrupt source.
+ */
+void
+xen_intr_unmask(struct intrhand *ih)
+{
+	/* XXX */
+	panic("xen_intr_unmask: not yet implemented.");
+}
+
+/*
  * Deregister an interrupt handler.
  */
 void
@@ -510,6 +530,8 @@ __strong_alias(intr_string, xintr_string
 __strong_alias(intr_create_intrid, xen_intr_create_intrid);
 __strong_alias(intr_establish, xen_intr_establish);
 __strong_alias(intr_establish_xname, xen_intr_establish_xname);
+__strong_alias(intr_mask, xen_intr_mask);
+__strong_alias(intr_unmask, xen_intr_unmask);
 __strong_alias(intr_disestablish, xen_intr_disestablish);
 __strong_alias(cpu_intr_redistribute, xen_cpu_intr_redistribute);
 __strong_alias(cpu_intr_count, xen_cpu_intr_count);



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

2019-12-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 23 09:36:18 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_82598.c ixgbe_82599.c ixgbe_phy.c
ixgbe_type.h ixgbe_x550.c

Log Message:
Add recovery code for unsupported SFP+.

Before this commit:
   If an unsuppored SFP module is inserted before booting, the driver attach
   failed and there was no way to recover form it without rebooting or
   detaching/reattaching drvier (drvctl -d && drvctl -r pciN).
After this commit:
   We can automatically recover any time by replacing it with a supported
   module.


To generate a diff of this commit:
cvs rdiff -u -r1.218 -r1.219 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/ixgbe/ixgbe_82598.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/ixgbe/ixgbe_82599.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/ixgbe/ixgbe_phy.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/ixgbe/ixgbe_x550.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/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.218 src/sys/dev/pci/ixgbe/ixgbe.c:1.219
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.218	Mon Dec 23 09:19:40 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Dec 23 09:36:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.218 2019/12/23 09:19:40 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.219 2019/12/23 09:36:17 msaitoh Exp $ */
 
 /**
 
@@ -776,6 +776,7 @@ ixgbe_attach(device_t parent, device_t d
 	pcireg_t	id, subid;
 	const ixgbe_vendor_info_t *ent;
 	struct pci_attach_args *pa = aux;
+	bool unsupported_sfp = false;
 	const char *str;
 	char buf[256];
 
@@ -954,8 +955,8 @@ ixgbe_attach(device_t parent, device_t d
 		error = IXGBE_SUCCESS;
 	} else if (error == IXGBE_ERR_SFP_NOT_SUPPORTED) {
 		aprint_error_dev(dev, "Unsupported SFP+ module detected!\n");
-		error = EIO;
-		goto err_late;
+		unsupported_sfp = true;
+		error = IXGBE_SUCCESS;
 	} else if (error) {
 		aprint_error_dev(dev, "Hardware initialization failed\n");
 		error = EIO;
@@ -1126,13 +1127,6 @@ ixgbe_attach(device_t parent, device_t d
 		"please contact your Intel or hardware representative "
 		"who provided you with this hardware.\n");
 		break;
-	case IXGBE_ERR_SFP_NOT_SUPPORTED:
-		aprint_error_dev(dev, "Unsupported SFP+ Module\n");
-		error = EIO;
-		goto err_late;
-	case IXGBE_ERR_SFP_NOT_PRESENT:
-		aprint_error_dev(dev, "No SFP+ Module found\n");
-		/* falls thru */
 	default:
 		break;
 	}
@@ -1165,16 +1159,22 @@ ixgbe_attach(device_t parent, device_t d
 			oui, model, rev);
 	}
 
-	/* Enable the optics for 82599 SFP+ fiber */
-	ixgbe_enable_tx_laser(hw);
-
 	/* Enable EEE power saving */
 	if (adapter->feat_cap & IXGBE_FEATURE_EEE)
 		hw->mac.ops.setup_eee(hw,
 		adapter->feat_en & IXGBE_FEATURE_EEE);
 
 	/* Enable power to the phy. */
-	ixgbe_set_phy_power(hw, TRUE);
+	if (!unsupported_sfp) {
+		/* Enable the optics for 82599 SFP+ fiber */
+		ixgbe_enable_tx_laser(hw);
+
+		/*
+		 * XXX Currently, ixgbe_set_phy_power() supports only copper
+		 * PHY, so it's not required to test with !unsupported_sfp.
+		 */
+		ixgbe_set_phy_power(hw, TRUE);
+	}
 
 	/* Initialize statistics */
 	ixgbe_update_stats_counters(adapter);
@@ -3901,6 +3901,7 @@ ixgbe_init_locked(struct adapter *adapte
 	u32		txdctl, mhadd;
 	u32		rxdctl, rxctrl;
 	u32		ctrl_ext;
+	bool		unsupported_sfp = false;
 	int		i, j, err;
 
 	/* XXX check IFF_UP and IFF_RUNNING, power-saving state! */
@@ -3908,6 +3909,7 @@ ixgbe_init_locked(struct adapter *adapte
 	KASSERT(mutex_owned(>core_mtx));
 	INIT_DEBUGOUT("ixgbe_init_locked: begin");
 
+	hw->need_unsupported_sfp_recovery = false;
 	hw->adapter_stopped = FALSE;
 	ixgbe_stop_adapter(hw);
 	callout_stop(>timer);
@@ -4081,12 +4083,14 @@ ixgbe_init_locked(struct adapter *adapte
 	 */
 	if (hw->phy.type == ixgbe_phy_none) {
 		err = hw->phy.ops.identify(hw);
-		if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
-			device_printf(dev,
-			"Unsupported SFP+ module type was detected.\n");
-			return;
-		}
-	}
+		if (err == IXGBE_ERR_SFP_NOT_SUPPORTED)
+			unsupported_sfp = true;
+	} else if (hw->phy.type == ixgbe_phy_sfp_unsupported)
+		unsupported_sfp = true;
+
+	if (unsupported_sfp)
+		device_printf(dev,
+		"Unsupported SFP+ module type was detected.\n");
 
 	/* Set moderation on the Link interrupt */
 	ixgbe_eitr_write(adapter, adapter->vector, IXGBE_LINK_ITR);
@@ -4097,10 +4101,12 @@ ixgbe_init_locked(struct adapter *adapte
 		adapter->feat_en & IXGBE_FEATURE_EEE);
 
 	/* Enable power to the phy. */
-	ixgbe_set_phy_power(hw, TRUE);
+	if (!unsupported_sfp) {
+		ixgbe_set_phy_power(hw, TRUE);
 
-	/* Config/Enable Link */
-	ixgbe_config_link(adapter);
+		/* Config/Enable Link */
+		ixgbe_config_link(adapter);
+	}
 
 	/* Hardware Packet Buffer & 

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

2019-12-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 23 09:19:40 UTC 2019

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

Log Message:
 Add missing core lock in ixgbe_handle_mod().


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/sys/dev/pci/ixgbe/ixgbe.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/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.217 src/sys/dev/pci/ixgbe/ixgbe.c:1.218
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.217	Tue Dec 17 05:49:01 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Dec 23 09:19:40 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.217 2019/12/17 05:49:01 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.218 2019/12/23 09:19:40 msaitoh Exp $ */
 
 /**
 
@@ -4608,6 +4608,7 @@ ixgbe_handle_mod(void *context)
 	device_t	dev = adapter->dev;
 	u32		err, cage_full = 0;
 
+	IXGBE_CORE_LOCK(adapter);
 	++adapter->mod_sicount.ev_count;
 	if (adapter->hw.need_crosstalk_fix) {
 		switch (hw->mac.type) {
@@ -4625,14 +4626,14 @@ ixgbe_handle_mod(void *context)
 		}
 
 		if (!cage_full)
-			return;
+			goto out;
 	}
 
 	err = hw->phy.ops.identify_sfp(hw);
 	if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
 		device_printf(dev,
 		"Unsupported SFP+ module type was detected.\n");
-		return;
+		goto out;
 	}
 
 	if (hw->mac.type == ixgbe_mac_82598EB)
@@ -4643,9 +4644,11 @@ ixgbe_handle_mod(void *context)
 	if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
 		device_printf(dev,
 		"Setup failure - unsupported SFP+ module type.\n");
-		return;
+		goto out;
 	}
 	softint_schedule(adapter->msf_si);
+out:
+	IXGBE_CORE_UNLOCK(adapter);
 } /* ixgbe_handle_mod */