CVS commit: src/sys/dev/pci

2017-07-21 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri Jul 21 21:01:13 UTC 2017

Modified Files:
src/sys/dev/pci: aceride.c pciide_acer_reg.h

Log Message:
Apply workaround from FreeBSD to fix read data corruption observed
on Fire V100 and mSATA-SSD with mSATA to IDE adapter.

The patch is from port-sparc64@.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/pci/aceride.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/pciide_acer_reg.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/aceride.c
diff -u src/sys/dev/pci/aceride.c:1.36 src/sys/dev/pci/aceride.c:1.37
--- src/sys/dev/pci/aceride.c:1.36	Mon Oct  7 19:51:55 2013
+++ src/sys/dev/pci/aceride.c	Fri Jul 21 21:01:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: aceride.c,v 1.36 2013/10/07 19:51:55 jakllsch Exp $	*/
+/*	$NetBSD: aceride.c,v 1.37 2017/07/21 21:01:13 nakayama Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: aceride.c,v 1.36 2013/10/07 19:51:55 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aceride.c,v 1.37 2017/07/21 21:01:13 nakayama Exp $");
 
 #include 
 #include 
@@ -194,8 +194,13 @@ acer_chip_map(struct pciide_softc *sc, c
 	interface = PCI_INTERFACE(pci_conf_read(sc->sc_pc, sc->sc_tag,
 	PCI_CLASS_REG));
 
-	/* From linux: enable "Cable Detection" */
 	if (rev >= 0xC2) {
+		/* From FreeBSD: use device interrupt as byte count end */
+		pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_0x4A,
+		pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_0x4A)
+		| ACER_0x4A_BCEINT);
+
+		/* From linux: enable "Cable Detection" */
 		pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_0x4B,
 		pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_0x4B)
 		| ACER_0x4B_CDETECT);

Index: src/sys/dev/pci/pciide_acer_reg.h
diff -u src/sys/dev/pci/pciide_acer_reg.h:1.12 src/sys/dev/pci/pciide_acer_reg.h:1.13
--- src/sys/dev/pci/pciide_acer_reg.h:1.12	Mon Oct 19 18:41:15 2009
+++ src/sys/dev/pci/pciide_acer_reg.h	Fri Jul 21 21:01:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pciide_acer_reg.h,v 1.12 2009/10/19 18:41:15 bouyer Exp $	*/
+/*	$NetBSD: pciide_acer_reg.h,v 1.13 2017/07/21 21:01:13 nakayama Exp $	*/
 
 /*
  * Copyright (c) 1999 Manuel Bouyer.
@@ -37,6 +37,8 @@
  * bit 1 is 0 -> secondary has 80 pin cable
  */
 #define ACER_0x4A_80PIN(chan)	(0x1 << (chan))
+/* From FreeBSD, use device interrupt as byte count end */
+#define ACER_0x4A_BCEINT	0x20
 
 /* From FreeBSD, for UDMA mode > 2 */
 #define ACER_0x4B	0x4b



CVS commit: src/usr.sbin/crash

2017-07-21 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri Jul 21 20:58:44 UTC 2017

Modified Files:
src/usr.sbin/crash: Makefile

Log Message:
sparc has db_machdep.c now.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/crash/Makefile

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

Modified files:

Index: src/usr.sbin/crash/Makefile
diff -u src/usr.sbin/crash/Makefile:1.36 src/usr.sbin/crash/Makefile:1.37
--- src/usr.sbin/crash/Makefile:1.36	Mon Apr 10 12:05:52 2017
+++ src/usr.sbin/crash/Makefile	Fri Jul 21 20:58:44 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.36 2017/04/10 12:05:52 christos Exp $
+#	$NetBSD: Makefile,v 1.37 2017/07/21 20:58:44 nakayama Exp $
 
 PROG=		crash
 MAN=		crash.8
@@ -21,9 +21,7 @@ DPADD+=	${LIBUTIL} ${LIBKVM} ${LIBEDIT} 
 || (${MACHINE_CPU} == "arm" && ${MACHINE} != "acorn26") \
 || ${MACHINE_ARCH} == "m68k"
 SRCS+=	db_trace.c
-.if ${MACHINE_ARCH} == "sparc"
-SRCS+=	db_interface.c
-.elif ${MACHINE_ARCH} != "m68k"
+.if ${MACHINE_ARCH} != "m68k"
 SRCS+=	db_machdep.c
 .endif
 REALCRASH=yes



CVS commit: src/sys/arch/sparc

2017-07-21 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri Jul 21 20:56:10 UTC 2017

Modified Files:
src/sys/arch/sparc/conf: files.sparc
src/sys/arch/sparc/sparc: db_interface.c
Added Files:
src/sys/arch/sparc/sparc: db_machdep.c

Log Message:
Move the ddb registers and empty command table used for crash(8) into
db_machdep.c like other archs.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/arch/sparc/conf/files.sparc
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sparc/sparc/db_interface.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc/sparc/db_machdep.c

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

Modified files:

Index: src/sys/arch/sparc/conf/files.sparc
diff -u src/sys/arch/sparc/conf/files.sparc:1.156 src/sys/arch/sparc/conf/files.sparc:1.157
--- src/sys/arch/sparc/conf/files.sparc:1.156	Sat Apr 30 05:24:45 2016
+++ src/sys/arch/sparc/conf/files.sparc	Fri Jul 21 20:56:10 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc,v 1.156 2016/04/30 05:24:45 macallan Exp $
+#	$NetBSD: files.sparc,v 1.157 2017/07/21 20:56:10 nakayama Exp $
 
 # @(#)files.sparc	8.1 (Berkeley) 7/19/93
 # sparc-specific configuration info
@@ -317,6 +317,7 @@ file	arch/sparc/sparc/trap.c
 file	arch/sparc/sparc/vm_machdep.c
 
 file	arch/sparc/sparc/db_interface.c	ddb | kgdb
+file	arch/sparc/sparc/db_machdep.c	ddb
 file	arch/sparc/sparc/db_trace.c	ddb
 file	arch/sparc/sparc/db_disasm.c	ddb
 

Index: src/sys/arch/sparc/sparc/db_interface.c
diff -u src/sys/arch/sparc/sparc/db_interface.c:1.93 src/sys/arch/sparc/sparc/db_interface.c:1.94
--- src/sys/arch/sparc/sparc/db_interface.c:1.93	Wed Dec 14 18:50:56 2016
+++ src/sys/arch/sparc/sparc/db_interface.c	Fri Jul 21 20:56:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.93 2016/12/14 18:50:56 mrg Exp $ */
+/*	$NetBSD: db_interface.c,v 1.94 2017/07/21 20:56:10 nakayama Exp $ */
 
 /*
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.93 2016/12/14 18:50:56 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.94 2017/07/21 20:56:10 nakayama Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -113,8 +113,6 @@ db_write_bytes(vaddr_t addr, size_t size
 }
 #endif
 
-db_regs_t *ddb_regp;
-
 #if defined(DDB)
 
 /*
@@ -132,81 +130,6 @@ cpu_Debugger(void)
 
 #if defined(DDB) || defined(_KMEMUSER)
 
-static long nil;
-
-/*
- * Machine register set.
- */
-#define dbreg(xx) (long *)offsetof(db_regs_t, db_tf.tf_ ## xx)
-#define dbregfr(xx) (long *)offsetof(db_regs_t, db_fr.fr_ ## xx)
-
-static int db_sparc_regop(const struct db_variable *, db_expr_t *, int);
-
-const struct db_variable db_regs[] = {
-	{ "psr",	dbreg(psr),		db_sparc_regop, NULL, },
-	{ "pc",		dbreg(pc),		db_sparc_regop, NULL, },
-	{ "npc",	dbreg(npc),		db_sparc_regop, NULL, },
-	{ "y",		dbreg(y),		db_sparc_regop, NULL, },
-	{ "wim",	dbreg(global[0]),	db_sparc_regop, NULL, }, /* see reg.h */
-	{ "g0",		,			FCN_NULL, 	NULL, },
-	{ "g1",		dbreg(global[1]),	db_sparc_regop, NULL, },
-	{ "g2",		dbreg(global[2]),	db_sparc_regop, NULL, },
-	{ "g3",		dbreg(global[3]),	db_sparc_regop, NULL, },
-	{ "g4",		dbreg(global[4]),	db_sparc_regop, NULL, },
-	{ "g5",		dbreg(global[5]),	db_sparc_regop, NULL, },
-	{ "g6",		dbreg(global[6]),	db_sparc_regop, NULL, },
-	{ "g7",		dbreg(global[7]),	db_sparc_regop, NULL, },
-	{ "o0",		dbreg(out[0]),		db_sparc_regop, NULL, },
-	{ "o1",		dbreg(out[1]),		db_sparc_regop, NULL, },
-	{ "o2",		dbreg(out[2]),		db_sparc_regop, NULL, },
-	{ "o3",		dbreg(out[3]),		db_sparc_regop, NULL, },
-	{ "o4",		dbreg(out[4]),		db_sparc_regop, NULL, },
-	{ "o5",		dbreg(out[5]),		db_sparc_regop, NULL, },
-	{ "o6",		dbreg(out[6]),		db_sparc_regop, NULL, },
-	{ "o7",		dbreg(out[7]),		db_sparc_regop, NULL, },
-	{ "l0",		dbregfr(local[0]),	db_sparc_regop, NULL, },
-	{ "l1",		dbregfr(local[1]),	db_sparc_regop, NULL, },
-	{ "l2",		dbregfr(local[2]),	db_sparc_regop, NULL, },
-	{ "l3",		dbregfr(local[3]),	db_sparc_regop, NULL, },
-	{ "l4",		dbregfr(local[4]),	db_sparc_regop, NULL, },
-	{ "l5",		dbregfr(local[5]),	db_sparc_regop, NULL, },
-	{ "l6",		dbregfr(local[6]),	db_sparc_regop, NULL, },
-	{ "l7",		dbregfr(local[7]),	db_sparc_regop, NULL, },
-	{ "i0",		dbregfr(arg[0]),	db_sparc_regop, NULL, },
-	{ "i1",		dbregfr(arg[1]),	db_sparc_regop, NULL, },
-	{ "i2",		dbregfr(arg[2]),	db_sparc_regop, NULL, },
-	{ "i3",		dbregfr(arg[3]),	db_sparc_regop, NULL, },
-	{ "i4",		dbregfr(arg[4]),	db_sparc_regop, NULL, },
-	{ "i5",		dbregfr(arg[5]),	db_sparc_regop, NULL, },
-	{ "i6",		dbregfr(fp),		db_sparc_regop, NULL, },
-	{ "i7",		dbregfr(pc),		db_sparc_regop, NULL, },
-};
-const struct db_variable * const db_eregs =
-db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
-
-static int
-db_sparc_regop (const struct db_variable *vp, db_expr_t *val, int opcode)
-{
-	db_expr_t *regaddr =
-	(db_expr_t *)(((uint8_t *)DDB_REGS) + ((size_t)vp->valuep));
-
-	switch (opcode) {
-	case 

CVS commit: [perseant-stdc-iso10646] src/lib/libc

2017-07-21 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Fri Jul 21 20:22:29 UTC 2017

Modified Files:
src/lib/libc/citrus [perseant-stdc-iso10646]: citrus_ctype.c
citrus_ctype.h citrus_ctype_fallback.c citrus_ctype_fallback.h
citrus_ctype_local.h citrus_ctype_template.h citrus_iconv.h
citrus_iconv_local.h citrus_namespace.h citrus_none.c
citrus_stdenc.h citrus_stdenc_local.h citrus_stdenc_template.h
src/lib/libc/citrus/modules [perseant-stdc-iso10646]: citrus_big5.c
citrus_dechanyu.c citrus_euc.c citrus_euctw.c citrus_gbk2k.c
citrus_hz.c citrus_iconv_none.c citrus_iconv_std.c citrus_iso2022.c
citrus_johab.c citrus_mskanji.c citrus_ues.c citrus_utf1632.c
citrus_utf7.c citrus_utf8.c citrus_viqr.c citrus_zw.c
src/lib/libc/locale [perseant-stdc-iso10646]: Makefile.inc _wctrans.c
_wctrans_local.h _wctype.c iswctype_mb.c multibyte.h
multibyte_amd1.c multibyte_c90.c rune.c
Added Files:
src/lib/libc/citrus/modules [perseant-stdc-iso10646]:
citrus_big5_data.h citrus_euc_data.h citrus_iso2022_data.h
citrus_mskanji_data.h
Removed Files:
src/lib/libc/locale [perseant-stdc-iso10646]: rune_iso10646.c
rune_iso10646.h u2k.h

Log Message:
Move Unicode <-> ku/ten mapping into the individual codec modules.
Mapping is based on existing iconv data for single-byte encodings,
and included for several, but not all, multibyte encodings.


To generate a diff of this commit:
cvs rdiff -u -r1.7.22.1 -r1.7.22.2 src/lib/libc/citrus/citrus_ctype.c
cvs rdiff -u -r1.3 -r1.3.22.1 src/lib/libc/citrus/citrus_ctype.h \
src/lib/libc/citrus/citrus_ctype_fallback.c
cvs rdiff -u -r1.2 -r1.2.22.1 src/lib/libc/citrus/citrus_ctype_fallback.h
cvs rdiff -u -r1.4 -r1.4.22.1 src/lib/libc/citrus/citrus_ctype_local.h
cvs rdiff -u -r1.36 -r1.36.22.1 src/lib/libc/citrus/citrus_ctype_template.h
cvs rdiff -u -r1.5.64.1 -r1.5.64.2 src/lib/libc/citrus/citrus_iconv.h
cvs rdiff -u -r1.3.64.1 -r1.3.64.2 src/lib/libc/citrus/citrus_iconv_local.h
cvs rdiff -u -r1.8.42.1 -r1.8.42.2 src/lib/libc/citrus/citrus_namespace.h
cvs rdiff -u -r1.22.2.1 -r1.22.2.2 src/lib/libc/citrus/citrus_none.c
cvs rdiff -u -r1.4.80.1 -r1.4.80.2 src/lib/libc/citrus/citrus_stdenc.h
cvs rdiff -u -r1.4.64.1 -r1.4.64.2 src/lib/libc/citrus/citrus_stdenc_local.h \
src/lib/libc/citrus/citrus_stdenc_template.h
cvs rdiff -u -r1.15.18.1 -r1.15.18.2 \
src/lib/libc/citrus/modules/citrus_big5.c
cvs rdiff -u -r0 -r1.1.2.1 src/lib/libc/citrus/modules/citrus_big5_data.h \
src/lib/libc/citrus/modules/citrus_euc_data.h \
src/lib/libc/citrus/modules/citrus_iso2022_data.h \
src/lib/libc/citrus/modules/citrus_mskanji_data.h
cvs rdiff -u -r1.5.22.1 -r1.5.22.2 \
src/lib/libc/citrus/modules/citrus_dechanyu.c \
src/lib/libc/citrus/modules/citrus_zw.c
cvs rdiff -u -r1.17.20.1 -r1.17.20.2 src/lib/libc/citrus/modules/citrus_euc.c
cvs rdiff -u -r1.12.22.1 -r1.12.22.2 \
src/lib/libc/citrus/modules/citrus_euctw.c
cvs rdiff -u -r1.8.22.1 -r1.8.22.2 src/lib/libc/citrus/modules/citrus_gbk2k.c
cvs rdiff -u -r1.4.18.1 -r1.4.18.2 src/lib/libc/citrus/modules/citrus_hz.c
cvs rdiff -u -r1.3.38.1 -r1.3.38.2 \
src/lib/libc/citrus/modules/citrus_iconv_none.c
cvs rdiff -u -r1.16.34.1 -r1.16.34.2 \
src/lib/libc/citrus/modules/citrus_iconv_std.c
cvs rdiff -u -r1.23.22.1 -r1.23.22.2 \
src/lib/libc/citrus/modules/citrus_iso2022.c
cvs rdiff -u -r1.6.10.1 -r1.6.10.2 src/lib/libc/citrus/modules/citrus_johab.c
cvs rdiff -u -r1.14.22.1 -r1.14.22.2 \
src/lib/libc/citrus/modules/citrus_mskanji.c
cvs rdiff -u -r1.4.22.1 -r1.4.22.2 src/lib/libc/citrus/modules/citrus_ues.c
cvs rdiff -u -r1.12.34.1 -r1.12.34.2 \
src/lib/libc/citrus/modules/citrus_utf1632.c
cvs rdiff -u -r1.6.22.1 -r1.6.22.2 src/lib/libc/citrus/modules/citrus_utf7.c \
src/lib/libc/citrus/modules/citrus_viqr.c
cvs rdiff -u -r1.18.22.1 -r1.18.22.2 \
src/lib/libc/citrus/modules/citrus_utf8.c
cvs rdiff -u -r1.64.20.1 -r1.64.20.2 src/lib/libc/locale/Makefile.inc
cvs rdiff -u -r1.17 -r1.17.40.1 src/lib/libc/locale/_wctrans.c
cvs rdiff -u -r1.9 -r1.9.40.1 src/lib/libc/locale/_wctrans_local.h
cvs rdiff -u -r1.9.40.1 -r1.9.40.2 src/lib/libc/locale/_wctype.c
cvs rdiff -u -r1.13.22.1 -r1.13.22.2 src/lib/libc/locale/iswctype_mb.c
cvs rdiff -u -r1.6 -r1.6.20.1 src/lib/libc/locale/multibyte.h
cvs rdiff -u -r1.14.20.1 -r1.14.20.2 src/lib/libc/locale/multibyte_amd1.c
cvs rdiff -u -r1.12.20.1 -r1.12.20.2 src/lib/libc/locale/multibyte_c90.c
cvs rdiff -u -r1.46.22.1 -r1.46.22.2 src/lib/libc/locale/rune.c
cvs rdiff -u -r1.1.2.1 -r0 src/lib/libc/locale/rune_iso10646.c \
src/lib/libc/locale/rune_iso10646.h src/lib/libc/locale/u2k.h

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

diffs are larger than 1MB and have been omitted


CVS commit: [jdolecek-ncq] src/sys/dev/ic

2017-07-21 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Jul 21 18:36:47 UTC 2017

Modified Files:
src/sys/dev/ic [jdolecek-ncq]: ahcisata_core.c

Log Message:
use free slot for drive reset, rather than always using slot zero; if we can't
get the slot, fallback to channel reset as usual

note this increases the odds of not being able to do the reset, when all slots
happen to be active

this is in same area as problem reported by PR kern/52372 but I
don't believe that this change actually make any change for it - during
probe/attach there shouldn't be any paralell request with drive reset


To generate a diff of this commit:
cvs rdiff -u -r1.57.6.18 -r1.57.6.19 src/sys/dev/ic/ahcisata_core.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/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.57.6.18 src/sys/dev/ic/ahcisata_core.c:1.57.6.19
--- src/sys/dev/ic/ahcisata_core.c:1.57.6.18	Wed Jul 19 20:21:42 2017
+++ src/sys/dev/ic/ahcisata_core.c	Fri Jul 21 18:36:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.57.6.18 2017/07/19 20:21:42 jdolecek Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.57.6.19 2017/07/21 18:36:47 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.57.6.18 2017/07/19 20:21:42 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.57.6.19 2017/07/21 18:36:47 jdolecek Exp $");
 
 #include 
 #include 
@@ -650,7 +650,7 @@ ahci_reset_drive(struct ata_drive_datas 
 
 /* return error code from ata_bio */
 static int
-ahci_exec_fis(struct ata_channel *chp, int timeout, int flags)
+ahci_exec_fis(struct ata_channel *chp, int timeout, int flags, int slot)
 {
 	struct ahci_channel *achp = (struct ahci_channel *)chp;
 	struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
@@ -667,11 +667,13 @@ ahci_exec_fis(struct ata_channel *chp, i
 	else
 		timeout = timeout / 10;
 
-	AHCI_CMDH_SYNC(sc, achp, 0, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+	AHCI_CMDH_SYNC(sc, achp, slot,
+	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 	/* start command */
-	AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1 << 0);
+	AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1 << slot);
 	for (i = 0; i < timeout; i++) {
-		if ((AHCI_READ(sc, AHCI_P_CI(chp->ch_channel)) & 1 << 0) == 0)
+		if ((AHCI_READ(sc, AHCI_P_CI(chp->ch_channel)) & (1 << slot)) ==
+		0)
 			return 0;
 		is = AHCI_READ(sc, AHCI_P_IS(chp->ch_channel));
 		if (is & (AHCI_P_IX_TFES | AHCI_P_IX_HBFS | AHCI_P_IX_HBDS |
@@ -708,6 +710,7 @@ ahci_do_reset_drive(struct ata_channel *
 	struct ahci_cmd_header *cmd_h;
 	int i;
 	uint32_t sig;
+	struct ata_xfer *xfer = NULL;
 
 	KASSERT((AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_CR) == 0);
 again:
@@ -732,9 +735,15 @@ again:
 		goto skip_reset;
 
 	/* polled command, assume interrupts are disabled */
-	/* use slot 0 to send reset, the channel is idle */
-	cmd_h = >ahcic_cmdh[0];
-	cmd_tbl = achp->ahcic_cmd_tbl[0];
+	/* use available slot to send reset, if none available fail */
+	xfer = ata_get_xfer_ext(chp, false, 0);
+	if (xfer == NULL) {
+		printf("%s: no xfer\n", __func__);
+		return 1;
+	}
+
+	cmd_h = >ahcic_cmdh[xfer->c_slot];
+	cmd_tbl = achp->ahcic_cmd_tbl[xfer->c_slot];
 	cmd_h->cmdh_flags = htole16(AHCI_CMDH_F_RST | AHCI_CMDH_F_CBSY |
 	RHD_FISLEN / 4 | (drive << AHCI_CMDH_F_PMP_SHIFT));
 	cmd_h->cmdh_prdbc = 0;
@@ -742,7 +751,7 @@ again:
 	cmd_tbl->cmdt_cfis[fis_type] = RHD_FISTYPE;
 	cmd_tbl->cmdt_cfis[rhd_c] = drive;
 	cmd_tbl->cmdt_cfis[rhd_control] = WDCTL_RST;
-	switch(ahci_exec_fis(chp, 100, flags)) {
+	switch(ahci_exec_fis(chp, 100, flags, xfer->c_slot)) {
 	case ERR_DF:
 	case TIMEOUT:
 		aprint_error("%s channel %d: setting WDCTL_RST failed "
@@ -760,7 +769,7 @@ again:
 	cmd_tbl->cmdt_cfis[fis_type] = RHD_FISTYPE;
 	cmd_tbl->cmdt_cfis[rhd_c] = drive;
 	cmd_tbl->cmdt_cfis[rhd_control] = 0;
-	switch(ahci_exec_fis(chp, 310, flags)) {
+	switch(ahci_exec_fis(chp, 310, flags, xfer->c_slot)) {
 	case ERR_DF:
 	case TIMEOUT:
 		if ((sc->sc_ahci_quirks & AHCI_QUIRK_BADPMPRESET) != 0 &&
@@ -811,6 +820,8 @@ skip_reset:
 	AHCINAME(sc), chp->ch_channel, sig,
 	AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel))), DEBUG_PROBE);
 end:
+	if (xfer != NULL)
+		ata_free_xfer(chp, xfer);
 	ahci_channel_stop(sc, chp, flags);
 	ata_delay(500, "ahcirst", flags);
 	/* clear port interrupt register */



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

2017-07-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul 21 18:25:25 UTC 2017

Modified Files:
src/sys/arch/arm/nvidia: tegra_soctherm.c

Log Message:
Fix of_search_compatible usage


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/nvidia/tegra_soctherm.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/nvidia/tegra_soctherm.c
diff -u src/sys/arch/arm/nvidia/tegra_soctherm.c:1.5 src/sys/arch/arm/nvidia/tegra_soctherm.c:1.6
--- src/sys/arch/arm/nvidia/tegra_soctherm.c:1.5	Thu Jul 20 01:46:15 2017
+++ src/sys/arch/arm/nvidia/tegra_soctherm.c	Fri Jul 21 18:25:25 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_soctherm.c,v 1.5 2017/07/20 01:46:15 jmcneill Exp $ */
+/* $NetBSD: tegra_soctherm.c,v 1.6 2017/07/21 18:25:25 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_soctherm.c,v 1.5 2017/07/20 01:46:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_soctherm.c,v 1.6 2017/07/21 18:25:25 jmcneill Exp $");
 
 #include 
 #include 
@@ -213,7 +213,7 @@ tegra_soctherm_attach(device_t parent, d
 	aprint_naive("\n");
 	aprint_normal(": SOC_THERM\n");
 
-	sc->sc_config = (const void *)of_search_compatible(phandle, compat_data);
+	sc->sc_config = (void *)of_search_compatible(phandle, compat_data)->data;
 	if (sc->sc_config == NULL) {
 		aprint_error_dev(self, "unsupported SoC\n");
 		return;



CVS commit: [jdolecek-ncq] src/sys/dev/ata

2017-07-21 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Jul 21 18:12:37 UTC 2017

Modified Files:
src/sys/dev/ata [jdolecek-ncq]: ata.c

Log Message:
add checksum verification for data returned by READ LOG EXT; this is mostly
just paranoia for eventual driver/hw DMA bugs

this doesn't make difference for QEMU, as there the command actually always
just fails (it's not implemented)


To generate a diff of this commit:
cvs rdiff -u -r1.132.8.19 -r1.132.8.20 src/sys/dev/ata/ata.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/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.132.8.19 src/sys/dev/ata/ata.c:1.132.8.20
--- src/sys/dev/ata/ata.c:1.132.8.19	Wed Jul 19 19:39:28 2017
+++ src/sys/dev/ata/ata.c	Fri Jul 21 18:12:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata.c,v 1.132.8.19 2017/07/19 19:39:28 jdolecek Exp $	*/
+/*	$NetBSD: ata.c,v 1.132.8.20 2017/07/21 18:12:37 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.19 2017/07/19 19:39:28 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.20 2017/07/21 18:12:37 jdolecek Exp $");
 
 #include "opt_ata.h"
 
@@ -1039,7 +1039,7 @@ ata_read_log_ext_ncq(struct ata_drive_da
 	int rv;
 	struct ata_channel *chp = drvp->chnl_softc;
 	struct atac_softc *atac = chp->ch_atac;
-	uint8_t *tb;
+	uint8_t *tb, cksum, page;
 
 	ATADEBUG_PRINT(("%s\n", __func__), DEBUG_FUNCS);
 
@@ -1072,12 +1072,12 @@ ata_read_log_ext_ncq(struct ata_drive_da
 	 */
 	xfer->c_flags |= C_IMMEDIATE;
 	xfer->c_ata_c.r_command = WDCC_READ_LOG_EXT;
-	xfer->c_ata_c.r_lba = WDCC_LOG_PAGE_NCQ;
+	xfer->c_ata_c.r_lba = page = WDCC_LOG_PAGE_NCQ;
 	xfer->c_ata_c.r_st_bmask = WDCS_DRDY;
 	xfer->c_ata_c.r_st_pmask = WDCS_DRDY;
 	xfer->c_ata_c.r_count = 1;
 	xfer->c_ata_c.r_device = WDSD_LBA;
-	xfer->c_ata_c.flags = AT_READ | AT_LBA | flags;
+	xfer->c_ata_c.flags = AT_READ | AT_LBA | AT_LBA48 | flags;
 	xfer->c_ata_c.timeout = 1000; /* 1s */
 	xfer->c_ata_c.data = tb;
 	xfer->c_ata_c.bcount = DEV_BSIZE;
@@ -1092,10 +1092,19 @@ ata_read_log_ext_ncq(struct ata_drive_da
 		goto out2;
 	}
 
-	/* XXX verify checksum and refuse if not correct (QEMU) */
+	cksum = 0;
+	for (int i = 0; i < DEV_BSIZE; i++)
+		cksum += tb[i];
+	if (cksum != 0) {
+		aprint_error_dev(drvp->drv_softc,
+		"invalid checksum %x for READ LOG EXT page %x\n",
+		cksum, page);
+		rv = EINVAL;
+		goto out2;
+	}
 
 	if (tb[0] & WDCC_LOG_NQ) {
-		/* not a NCQ command */
+		/* not queued command */
 		rv = EOPNOTSUPP;
 		goto out2;
 	}



CVS commit: [jdolecek-ncq] src/sys/dev/ata

2017-07-21 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Jul 21 17:32:27 UTC 2017

Modified Files:
src/sys/dev/ata [jdolecek-ncq]: atavar.h wd.c

Log Message:
KASSERT() that chaosed xfer actually ends up with error; might end up being
returned as successful due to bugs in error recovery code


To generate a diff of this commit:
cvs rdiff -u -r1.92.8.17 -r1.92.8.18 src/sys/dev/ata/atavar.h
cvs rdiff -u -r1.428.2.27 -r1.428.2.28 src/sys/dev/ata/wd.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/ata/atavar.h
diff -u src/sys/dev/ata/atavar.h:1.92.8.17 src/sys/dev/ata/atavar.h:1.92.8.18
--- src/sys/dev/ata/atavar.h:1.92.8.17	Wed Jul 19 19:39:28 2017
+++ src/sys/dev/ata/atavar.h	Fri Jul 21 17:32:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: atavar.h,v 1.92.8.17 2017/07/19 19:39:28 jdolecek Exp $	*/
+/*	$NetBSD: atavar.h,v 1.92.8.18 2017/07/21 17:32:27 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -186,6 +186,7 @@ struct ata_xfer {
 #define	C_NCQ		0x0100		/* command is queued  */
 #define C_IMMEDIATE	0x0200		/* execute command without queuing */
 #define C_WAITTIMO	0x0400		/* race vs. timeout */
+#define C_CHAOS		0x0800		/* forced error xfer */
 
 /* reasons for c_kill_xfer() */
 #define KILL_GONE 1		/* device is gone while xfer was active */

Index: src/sys/dev/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.428.2.27 src/sys/dev/ata/wd.c:1.428.2.28
--- src/sys/dev/ata/wd.c:1.428.2.27	Wed Jul 19 19:46:52 2017
+++ src/sys/dev/ata/wd.c	Fri Jul 21 17:32:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.428.2.27 2017/07/19 19:46:52 jdolecek Exp $ */
+/*	$NetBSD: wd.c,v 1.428.2.28 2017/07/21 17:32:27 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.27 2017/07/19 19:46:52 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.28 2017/07/21 17:32:27 jdolecek Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -713,6 +713,7 @@ wdstart1(struct wd_softc *wd, struct buf
 		aprint_normal_dev(wd->sc_dev, "%s: chaos xfer %d\n",
 		__func__, xfer->c_slot);
 		xfer->c_bio.blkno = 777 + wd->sc_capacity;
+		xfer->c_flags |= C_CHAOS;
 	}
 #endif
 
@@ -893,6 +894,9 @@ out:
 noerror:	if ((xfer->c_bio.flags & ATA_CORR) || xfer->c_retries > 0)
 			aprint_error_dev(wd->sc_dev,
 			"soft error (corrected)\n");
+#ifdef WD_CHAOS_MONKEY
+		KASSERT((xfer->c_flags & C_CHAOS) == 0);
+#endif
 		break;
 	case ERR_NODEV:
 		bp->b_error = EIO;



CVS commit: src/tests/libexec/ld.elf_so

2017-07-21 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Jul 21 16:39:20 UTC 2017

Modified Files:
src/tests/libexec/ld.elf_so: h_thread_local_dtor.c

Log Message:
Avoid a race condition between dlclose and thread termination.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/libexec/ld.elf_so/h_thread_local_dtor.c

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

Modified files:

Index: src/tests/libexec/ld.elf_so/h_thread_local_dtor.c
diff -u src/tests/libexec/ld.elf_so/h_thread_local_dtor.c:1.1 src/tests/libexec/ld.elf_so/h_thread_local_dtor.c:1.2
--- src/tests/libexec/ld.elf_so/h_thread_local_dtor.c:1.1	Tue Jul 11 15:21:36 2017
+++ src/tests/libexec/ld.elf_so/h_thread_local_dtor.c	Fri Jul 21 16:39:20 2017
@@ -75,10 +75,6 @@ main(void)
 	pthread_cond_wait(, );
 	pthread_mutex_unlock();
 
-	pthread_mutex_lock();
-	pthread_cond_signal();
-	pthread_mutex_unlock();
-
 	printf("before dlclose\n");
 	dlclose(dso);
 	printf("after dlclose\n");
@@ -86,6 +82,11 @@ main(void)
 	if (dso == NULL)
 		errx(1, "%s", dlerror());
 	dlclose(dso);
+
+	pthread_mutex_lock();
+	pthread_cond_signal();
+	pthread_mutex_unlock();
+
 	if (pthread_join(thread, NULL))
 		err(1, "pthread_join");
 	return 0;



CVS commit: src/share/man/man8

2017-07-21 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Jul 21 12:48:02 UTC 2017

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

Log Message:
Update packages link. suggest https. bump date


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/share/man/man8/afterboot.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/afterboot.8
diff -u src/share/man/man8/afterboot.8:1.58 src/share/man/man8/afterboot.8:1.59
--- src/share/man/man8/afterboot.8:1.58	Mon Jul  3 21:31:00 2017
+++ src/share/man/man8/afterboot.8	Fri Jul 21 12:48:01 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: afterboot.8,v 1.58 2017/07/03 21:31:00 wiz Exp $
+.\"	$NetBSD: afterboot.8,v 1.59 2017/07/21 12:48:01 maya Exp $
 .\"	$OpenBSD: afterboot.8,v 1.72 2002/02/22 02:02:33 miod Exp $
 .\"
 .\" Originally created by Marshall M. Midden -- 1997-10-20, m...@umn.edu
@@ -59,7 +59,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd March 14, 2017
+.Dd July 21, 2017
 .Dt AFTERBOOT 8
 .Os
 .Sh NAME
@@ -861,11 +861,11 @@ The
 .Nx
 packages collection, pkgsrc, includes a large set of third-party software.
 A lot of it is available as binary packages that you can download from
-.Lk ftp://ftp.NetBSD.org/pub/NetBSD/packages/
+.Lk https://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/
 or a mirror, and install using
 .Xr pkg_add 1 .
 See
-.Lk http://www.NetBSD.org/docs/pkgsrc/
+.Lk https://www.NetBSD.org/docs/pkgsrc/
 and
 .Pa pkgsrc/doc/pkgsrc.txt
 for more details.



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

2017-07-21 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Fri Jul 21 12:27:48 UTC 2017

Modified Files:
src/sys/arch/x86/isa: isa_machdep.c

Log Message:
Fix uninitialised use of variable mpih

Pointed out by joerg@


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/x86/isa/isa_machdep.c

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

Modified files:

Index: src/sys/arch/x86/isa/isa_machdep.c
diff -u src/sys/arch/x86/isa/isa_machdep.c:1.35 src/sys/arch/x86/isa/isa_machdep.c:1.36
--- src/sys/arch/x86/isa/isa_machdep.c:1.35	Sun Jul 16 06:14:23 2017
+++ src/sys/arch/x86/isa/isa_machdep.c	Fri Jul 21 12:27:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: isa_machdep.c,v 1.35 2017/07/16 06:14:23 cherry Exp $	*/
+/*	$NetBSD: isa_machdep.c,v 1.36 2017/07/21 12:27:48 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.35 2017/07/16 06:14:23 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.36 2017/07/21 12:27:48 cherry Exp $");
 
 #include 
 #include 
@@ -211,7 +211,7 @@ isa_intr_establish_xname(isa_chipset_tag
 	struct pic *pic;
 	int pin;
 #if NIOAPIC > 0
-	intr_handle_t mpih;
+	intr_handle_t mpih = 0;
 	struct ioapic_softc *ioapic = NULL;
 #endif
 



CVS commit: src/external/apache2/mDNSResponder/dist/mDNSShared

2017-07-21 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Jul 21 08:49:05 UTC 2017

Modified Files:
src/external/apache2/mDNSResponder/dist/mDNSShared: dnssd_clientstub.c

Log Message:
Fix format strings to reflect exactly the types used.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/external/apache2/mDNSResponder/dist/mDNSShared/dnssd_clientstub.c

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

Modified files:

Index: src/external/apache2/mDNSResponder/dist/mDNSShared/dnssd_clientstub.c
diff -u src/external/apache2/mDNSResponder/dist/mDNSShared/dnssd_clientstub.c:1.7 src/external/apache2/mDNSResponder/dist/mDNSShared/dnssd_clientstub.c:1.8
--- src/external/apache2/mDNSResponder/dist/mDNSShared/dnssd_clientstub.c:1.7	Mon Mar 31 23:26:30 2014
+++ src/external/apache2/mDNSResponder/dist/mDNSShared/dnssd_clientstub.c	Fri Jul 21 08:49:05 2017
@@ -177,8 +177,8 @@ static int write_all(dnssd_sock_t sd, ch
 			else
 syslog(LOG_INFO, "dnssd_clientstub write_all(%d) DEFUNCT", sd);
 			#else
-			syslog(LOG_WARNING, "dnssd_clientstub write_all(%d) failed %zd/%ld %d %s", sd,
-(long)num_written, (long)len,
+			syslog(LOG_WARNING, "dnssd_clientstub write_all(%d) failed %zd/%zu %d %s", sd,
+num_written, len,
 (num_written < 0) ? dnssd_errno : 0,
 (num_written < 0) ? dnssd_strerror(dnssd_errno) : "");
 			#endif