CVS commit: [netbsd-9] src/sys/dev/ic

2024-03-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar 12 09:59:31 UTC 2024

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1817):

sys/dev/ic/nvme.c: revision 1.69

nvme(4): Disestablish admin q interrupt while suspended.

And re-establish on resume.  Fixes nvmectl(8) after a suspend/resume
cycle on some systems.

Adapted from a patch by mrg@.

PR kern/58025


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.6 -r1.44.2.7 src/sys/dev/ic/nvme.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/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.44.2.6 src/sys/dev/ic/nvme.c:1.44.2.7
--- src/sys/dev/ic/nvme.c:1.44.2.6	Mon Jun 21 17:25:48 2021
+++ src/sys/dev/ic/nvme.c	Tue Mar 12 09:59:31 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.44.2.6 2021/06/21 17:25:48 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.44.2.7 2024/03/12 09:59:31 martin Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.6 2021/06/21 17:25:48 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.7 2024/03/12 09:59:31 martin Exp $");
 
 #include 
 #include 
@@ -552,7 +552,6 @@ nvme_detach(struct nvme_softc *sc, int f
 		return error;
 
 	/* from now on we are committed to detach, following will never fail */
-	sc->sc_intr_disestablish(sc, NVME_ADMIN_Q);
 	for (i = 0; i < sc->sc_nq; i++)
 		nvme_q_free(sc, sc->sc_q[i]);
 	kmem_free(sc->sc_q, sizeof(*sc->sc_q) * sc->sc_nq);
@@ -582,6 +581,11 @@ nvme_resume(struct nvme_softc *sc)
 	}
 
 	nvme_q_reset(sc, sc->sc_admin_q);
+	if (sc->sc_intr_establish(sc, NVME_ADMIN_Q, sc->sc_admin_q)) {
+		error = EIO;
+		device_printf(sc->sc_dev, "unable to establish admin q\n");
+		goto disable;
+	}
 
 	error = nvme_enable(sc, ffs(sc->sc_mps) - 1);
 	if (error) {
@@ -643,6 +647,8 @@ nvme_shutdown(struct nvme_softc *sc)
 	if (disabled)
 		goto disable;
 
+	sc->sc_intr_disestablish(sc, NVME_ADMIN_Q);
+
 	cc = nvme_read4(sc, NVME_CC);
 	CLR(cc, NVME_CC_SHN_MASK);
 	SET(cc, NVME_CC_SHN(NVME_CC_SHN_NORMAL));



CVS commit: [netbsd-9] src/sys/dev/ic

2024-03-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar 12 09:59:31 UTC 2024

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1817):

sys/dev/ic/nvme.c: revision 1.69

nvme(4): Disestablish admin q interrupt while suspended.

And re-establish on resume.  Fixes nvmectl(8) after a suspend/resume
cycle on some systems.

Adapted from a patch by mrg@.

PR kern/58025


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.6 -r1.44.2.7 src/sys/dev/ic/nvme.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2023-08-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug  4 15:06:50 UTC 2023

Modified Files:
src/sys/dev/ic [netbsd-9]: rtl8169.c rtl81x9reg.h rtl81x9var.h

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1705):

sys/dev/ic/rtl81x9var.h: revision 1.58
sys/dev/ic/rtl81x9reg.h: revision 1.54
sys/dev/ic/rtl8169.c: revision 1.167
sys/dev/ic/rtl8169.c: revision 1.168

re(4): misc chip revision support changes
 * remove impossible-to-match chip revision cases
 * bring support for modern chips in line with FreeBSD and OpenBSD
  * adds support for RTL8168GU

Addresses PR kern/56312.

- Print chip revision. From OpenBSD.
- Rename RTK_HWREV_8168_SPIN[123] to RTK_HWREV_8168'B'_SPIN[123].
  Same as other *BSDs.
- Rename RTK_HWREV_8168G_SPIN4 to RTK_HWREV_8411B. Same as other *BSDs.
- Add definition of RTK_HWREV_8169_8110SCE.


To generate a diff of this commit:
cvs rdiff -u -r1.159.2.1 -r1.159.2.2 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.50.4.1 -r1.50.4.2 src/sys/dev/ic/rtl81x9reg.h
cvs rdiff -u -r1.56.18.1 -r1.56.18.2 src/sys/dev/ic/rtl81x9var.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/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.159.2.1 src/sys/dev/ic/rtl8169.c:1.159.2.2
--- src/sys/dev/ic/rtl8169.c:1.159.2.1	Tue Jan 28 11:12:30 2020
+++ src/sys/dev/ic/rtl8169.c	Fri Aug  4 15:06:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.159.2.1 2020/01/28 11:12:30 martin Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.159.2.2 2023/08/04 15:06:50 martin Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159.2.1 2020/01/28 11:12:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159.2.2 2023/08/04 15:06:50 martin Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -172,6 +172,54 @@ static void re_miibus_statchg(struct ifn
 
 static void re_reset(struct rtk_softc *);
 
+static const struct re_revision {
+	uint32_t		re_chipid;
+	const char		*re_name;
+} re_revisions[] = {
+	{ RTK_HWREV_8100,	"RTL8100" },
+	{ RTK_HWREV_8100E,	"RTL8100E" },
+	{ RTK_HWREV_8100E_SPIN2, "RTL8100E 2" },
+	{ RTK_HWREV_8101,	"RTL8101" },
+	{ RTK_HWREV_8101E,	"RTL8101E" },
+	{ RTK_HWREV_8102E,	"RTL8102E" },
+	{ RTK_HWREV_8106E,	"RTL8106E" },
+	{ RTK_HWREV_8401E,	"RTL8401E" },
+	{ RTK_HWREV_8402,	"RTL8402" },
+	{ RTK_HWREV_8411,	"RTL8411" },
+	{ RTK_HWREV_8411B,	"RTL8411B" },
+	{ RTK_HWREV_8102EL,	"RTL8102EL" },
+	{ RTK_HWREV_8102EL_SPIN1, "RTL8102EL 1" },
+	{ RTK_HWREV_8103E,   "RTL8103E" },
+	{ RTK_HWREV_8110S,	"RTL8110S" },
+	{ RTK_HWREV_8139CPLUS,	"RTL8139C+" },
+	{ RTK_HWREV_8168B_SPIN1, "RTL8168 1" },
+	{ RTK_HWREV_8168B_SPIN2, "RTL8168 2" },
+	{ RTK_HWREV_8168B_SPIN3, "RTL8168 3" },
+	{ RTK_HWREV_8168C,	"RTL8168C/8111C" },
+	{ RTK_HWREV_8168C_SPIN2, "RTL8168C/8111C" },
+	{ RTK_HWREV_8168CP,	"RTL8168CP/8111CP" },
+	{ RTK_HWREV_8168F,	"RTL8168F/8111F" },
+	{ RTK_HWREV_8168G,	"RTL8168G/8111G" },
+	{ RTK_HWREV_8168GU,	"RTL8168GU/8111GU" },
+	{ RTK_HWREV_8168H,	"RTL8168H/8111H" },
+	{ RTK_HWREV_8105E,	"RTL8105E" },
+	{ RTK_HWREV_8105E_SPIN1, "RTL8105E" },
+	{ RTK_HWREV_8168D,	"RTL8168D/8111D" },
+	{ RTK_HWREV_8168DP,	"RTL8168DP/8111DP" },
+	{ RTK_HWREV_8168E,	"RTL8168E/8111E" },
+	{ RTK_HWREV_8168E_VL,	"RTL8168E/8111E-VL" },
+	{ RTK_HWREV_8168EP,	"RTL8168EP/8111EP" },
+	{ RTK_HWREV_8168FP,	"RTL8168FP/8117" },
+	{ RTK_HWREV_8169,	"RTL8169" },
+	{ RTK_HWREV_8169_8110SB, "RTL8169/8110SB" },
+	{ RTK_HWREV_8169_8110SBL, "RTL8169SBL" },
+	{ RTK_HWREV_8169_8110SC, "RTL8169/8110SCd" },
+	{ RTK_HWREV_8169_8110SCE, "RTL8169/8110SCe" },
+	{ RTK_HWREV_8169S,	"RTL8169S" },
+
+	{ 0, NULL }
+};
+
 static inline void
 re_set_bufaddr(struct re_desc *d, bus_addr_t addr)
 {
@@ -562,13 +610,26 @@ re_attach(struct rtk_softc *sc)
 	struct ifnet *ifp;
 	struct mii_data *mii = >mii;
 	int error = 0, i;
+	const struct re_revision *rr;
+	const char *re_name = NULL;
 
 	if ((sc->sc_quirk & RTKQ_8139CPLUS) == 0) {
-		uint32_t hwrev;
-
 		/* Revision of 8169/8169S/8110s in bits 30..26, 23 */
-		hwrev = CSR_READ_4(sc, RTK_TXCFG) & RTK_TXCFG_HWREV;
-		switch (hwrev) {
+		sc->sc_hwrev = CSR_READ_4(sc, RTK_TXCFG) & RTK_TXCFG_HWREV;
+
+		for (rr = re_revisions; rr->re_name != NULL; rr++) {
+			if (rr->re_chipid == sc->sc_hwrev)
+re_name = rr->re_name;
+		}
+
+		if (re_name == NULL)
+			aprint_normal_dev(sc->sc_dev,
+			"unknown ASIC (0x%04x)\n", sc->sc_hwrev >> 16);
+		else
+			aprint_normal_dev(sc->sc_dev,
+			"%s (0x%04x)\n", re_name, sc->sc_hwrev >> 16);
+
+		switch (sc->sc_hwrev) {
 		case RTK_HWREV_8169:
 			sc->sc_quirk |= RTKQ_8169NONS;
 			break;
@@ -579,9 +640,9 @@ re_attach(struct rtk_softc *sc)
 		case RTK_HWREV_8169_8110SC:
 			sc->sc_quirk |= RTKQ_MACLDPS;
 			break;
-		case RTK_HWREV_8168_SPIN1:
-		case RTK_HWREV_8168_SPIN2:
-		case 

CVS commit: [netbsd-9] src/sys/dev/ic

2023-08-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug  4 15:06:50 UTC 2023

Modified Files:
src/sys/dev/ic [netbsd-9]: rtl8169.c rtl81x9reg.h rtl81x9var.h

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1705):

sys/dev/ic/rtl81x9var.h: revision 1.58
sys/dev/ic/rtl81x9reg.h: revision 1.54
sys/dev/ic/rtl8169.c: revision 1.167
sys/dev/ic/rtl8169.c: revision 1.168

re(4): misc chip revision support changes
 * remove impossible-to-match chip revision cases
 * bring support for modern chips in line with FreeBSD and OpenBSD
  * adds support for RTL8168GU

Addresses PR kern/56312.

- Print chip revision. From OpenBSD.
- Rename RTK_HWREV_8168_SPIN[123] to RTK_HWREV_8168'B'_SPIN[123].
  Same as other *BSDs.
- Rename RTK_HWREV_8168G_SPIN4 to RTK_HWREV_8411B. Same as other *BSDs.
- Add definition of RTK_HWREV_8169_8110SCE.


To generate a diff of this commit:
cvs rdiff -u -r1.159.2.1 -r1.159.2.2 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.50.4.1 -r1.50.4.2 src/sys/dev/ic/rtl81x9reg.h
cvs rdiff -u -r1.56.18.1 -r1.56.18.2 src/sys/dev/ic/rtl81x9var.h

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



CVS commit: [netbsd-9] src/sys/dev/ic

2022-08-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 12 15:12:29 UTC 2022

Modified Files:
src/sys/dev/ic [netbsd-9]: dwc_gmac.c

Log Message:
Pull up following revision(s) (requested by sekiya in ticket #1499):

sys/dev/ic/dwc_gmac.c: revision 1.76-1.77

Turn off AWIN_GMAC_MAC_CONF_ACS, so that all received packets retain FCS
bytes.
ether_input() can now trust M_HASFCS to accurately represent the packet
contents.

Discussed on tech-net@


To generate a diff of this commit:
cvs rdiff -u -r1.64.2.1 -r1.64.2.2 src/sys/dev/ic/dwc_gmac.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/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.64.2.1 src/sys/dev/ic/dwc_gmac.c:1.64.2.2
--- src/sys/dev/ic/dwc_gmac.c:1.64.2.1	Tue Aug 11 17:14:21 2020
+++ src/sys/dev/ic/dwc_gmac.c	Fri Aug 12 15:12:29 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.64.2.1 2020/08/11 17:14:21 martin Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.64.2.2 2022/08/12 15:12:29 martin Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.64.2.1 2020/08/11 17:14:21 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.64.2.2 2022/08/12 15:12:29 martin Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -812,7 +812,6 @@ dwc_gmac_miibus_statchg(struct ifnet *if
 	conf |= AWIN_GMAC_MAC_CONF_FRAMEBURST
 	| AWIN_GMAC_MAC_CONF_DISABLERXOWN
 	| AWIN_GMAC_MAC_CONF_DISABLEJABBER
-	| AWIN_GMAC_MAC_CONF_ACS
 	| AWIN_GMAC_MAC_CONF_RXENABLE
 	| AWIN_GMAC_MAC_CONF_TXENABLE;
 	switch (IFM_SUBTYPE(mii->mii_media_active)) {



CVS commit: [netbsd-9] src/sys/dev/ic

2022-08-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 12 15:12:29 UTC 2022

Modified Files:
src/sys/dev/ic [netbsd-9]: dwc_gmac.c

Log Message:
Pull up following revision(s) (requested by sekiya in ticket #1499):

sys/dev/ic/dwc_gmac.c: revision 1.76-1.77

Turn off AWIN_GMAC_MAC_CONF_ACS, so that all received packets retain FCS
bytes.
ether_input() can now trust M_HASFCS to accurately represent the packet
contents.

Discussed on tech-net@


To generate a diff of this commit:
cvs rdiff -u -r1.64.2.1 -r1.64.2.2 src/sys/dev/ic/dwc_gmac.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2021-07-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jul  3 10:18:16 UTC 2021

Modified Files:
src/sys/dev/ic [netbsd-9]: ax88190.c dl10019.c dp8390.c

Log Message:
Pull up following revision(s) (requested by thorpej in ticket #1311):

sys/dev/ic/dp8390.c: revision 1.99
sys/dev/ic/dl10019.c: revision 1.17
sys/dev/ic/ax88190.c: revision 1.18

Make sure the media / mii members in struct ethercom are initialized
so that the media-related ioctls work.  Problem reported by Bj�rn Johannesson
on current-users@.

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/dev/ic/ax88190.c
cvs rdiff -u -r1.14 -r1.14.2.1 src/sys/dev/ic/dl10019.c
cvs rdiff -u -r1.95 -r1.95.2.1 src/sys/dev/ic/dp8390.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2021-07-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jul  3 10:18:16 UTC 2021

Modified Files:
src/sys/dev/ic [netbsd-9]: ax88190.c dl10019.c dp8390.c

Log Message:
Pull up following revision(s) (requested by thorpej in ticket #1311):

sys/dev/ic/dp8390.c: revision 1.99
sys/dev/ic/dl10019.c: revision 1.17
sys/dev/ic/ax88190.c: revision 1.18

Make sure the media / mii members in struct ethercom are initialized
so that the media-related ioctls work.  Problem reported by Bj�rn Johannesson
on current-users@.

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/dev/ic/ax88190.c
cvs rdiff -u -r1.14 -r1.14.2.1 src/sys/dev/ic/dl10019.c
cvs rdiff -u -r1.95 -r1.95.2.1 src/sys/dev/ic/dp8390.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/ax88190.c
diff -u src/sys/dev/ic/ax88190.c:1.15 src/sys/dev/ic/ax88190.c:1.15.2.1
--- src/sys/dev/ic/ax88190.c:1.15	Wed May 29 06:17:28 2019
+++ src/sys/dev/ic/ax88190.c	Sat Jul  3 10:18:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ax88190.c,v 1.15 2019/05/29 06:17:28 msaitoh Exp $	*/
+/*	$NetBSD: ax88190.c,v 1.15.2.1 2021/07/03 10:18:16 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ax88190.c,v 1.15 2019/05/29 06:17:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ax88190.c,v 1.15.2.1 2021/07/03 10:18:16 martin Exp $");
 
 #include 
 #include 
@@ -86,6 +86,8 @@ ax88190_media_init(struct dp8390_softc *
 	struct ifnet *ifp = >sc_ec.ec_if;
 	struct mii_data *mii = >sc_mii;
 
+	sc->sc_ec.ec_mii = mii;
+
 	mii->mii_ifp = ifp;
 	mii->mii_readreg = ax88190_mii_readreg;
 	mii->mii_writereg = ax88190_mii_writereg;

Index: src/sys/dev/ic/dl10019.c
diff -u src/sys/dev/ic/dl10019.c:1.14 src/sys/dev/ic/dl10019.c:1.14.2.1
--- src/sys/dev/ic/dl10019.c:1.14	Wed May 29 06:17:28 2019
+++ src/sys/dev/ic/dl10019.c	Sat Jul  3 10:18:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dl10019.c,v 1.14 2019/05/29 06:17:28 msaitoh Exp $	*/
+/*	$NetBSD: dl10019.c,v 1.14.2.1 2021/07/03 10:18:16 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dl10019.c,v 1.14 2019/05/29 06:17:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dl10019.c,v 1.14.2.1 2021/07/03 10:18:16 martin Exp $");
 
 #include 
 #include 
@@ -119,6 +119,8 @@ dl10019_media_init(struct dp8390_softc *
 	struct ifnet *ifp = >sc_ec.ec_if;
 	struct mii_data *mii = >sc_mii;
 
+	sc->sc_ec.ec_mii = mii;
+
 	mii->mii_ifp = ifp;
 	mii->mii_readreg = dl10019_mii_readreg;
 	mii->mii_writereg = dl10019_mii_writereg;

Index: src/sys/dev/ic/dp8390.c
diff -u src/sys/dev/ic/dp8390.c:1.95 src/sys/dev/ic/dp8390.c:1.95.2.1
--- src/sys/dev/ic/dp8390.c:1.95	Wed May 29 10:07:29 2019
+++ src/sys/dev/ic/dp8390.c	Sat Jul  3 10:18:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dp8390.c,v 1.95 2019/05/29 10:07:29 msaitoh Exp $	*/
+/*	$NetBSD: dp8390.c,v 1.95.2.1 2021/07/03 10:18:16 martin Exp $	*/
 
 /*
  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@@ -14,7 +14,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.95 2019/05/29 10:07:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.95.2.1 2021/07/03 10:18:16 martin Exp $");
 
 #include "opt_inet.h"
 
@@ -66,7 +66,6 @@ void
 dp8390_media_init(struct dp8390_softc *sc)
 {
 
-	sc->sc_ec.ec_ifmedia = >sc_media;
 	ifmedia_init(>sc_media, 0, dp8390_mediachange, dp8390_mediastatus);
 	ifmedia_add(>sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL);
 	ifmedia_set(>sc_media, IFM_ETHER | IFM_MANUAL);
@@ -131,7 +130,13 @@ dp8390_config(struct dp8390_softc *sc)
 	aprint_normal_dev(sc->sc_dev, "Ethernet address %s\n",
 	ether_sprintf(sc->sc_enaddr));
 
-	/* Initialize media goo. */
+	/*
+	 * Initialize media structures.  We'll default to pointing ec_ifmedia
+	 * at our embedded media structure.  A card front-end can initialize
+	 * ec_mii if it has an MII interface.  (Note that sc_media is an
+	 * alias of sc_mii.mii_media in dp8390_softc.)
+	 */
+	sc->sc_ec.ec_ifmedia = >sc_media;
 	(*sc->sc_media_init)(sc);
 
 	/* We can support 802.1Q VLAN-sized frames. */



CVS commit: [netbsd-9] src/sys/dev/ic

2021-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar  9 15:47:07 UTC 2021

Modified Files:
src/sys/dev/ic [netbsd-9]: mb89352.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1228):

sys/dev/ic/mb89352.c: revision 1.58

Fix a possible race condition in spc_msgin() in NO_MANUAL_XFER case.

To avoid the race, check SSTS and INTS after XFR command as
spc_pio_datain() does.

Reported from isaki@, observed on nono emulator.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.57.4.1 src/sys/dev/ic/mb89352.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2021-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar  9 15:47:07 UTC 2021

Modified Files:
src/sys/dev/ic [netbsd-9]: mb89352.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1228):

sys/dev/ic/mb89352.c: revision 1.58

Fix a possible race condition in spc_msgin() in NO_MANUAL_XFER case.

To avoid the race, check SSTS and INTS after XFR command as
spc_pio_datain() does.

Reported from isaki@, observed on nono emulator.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.57.4.1 src/sys/dev/ic/mb89352.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/mb89352.c
diff -u src/sys/dev/ic/mb89352.c:1.57 src/sys/dev/ic/mb89352.c:1.57.4.1
--- src/sys/dev/ic/mb89352.c:1.57	Mon Sep  3 16:29:31 2018
+++ src/sys/dev/ic/mb89352.c	Tue Mar  9 15:47:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mb89352.c,v 1.57 2018/09/03 16:29:31 riastradh Exp $	*/
+/*	$NetBSD: mb89352.c,v 1.57.4.1 2021/03/09 15:47:07 martin Exp $	*/
 /*	NecBSD: mb89352.c,v 1.4 1998/03/14 07:31:20 kmatsuda Exp	*/
 
 /*-
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mb89352.c,v 1.57 2018/09/03 16:29:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mb89352.c,v 1.57.4.1 2021/03/09 15:47:07 martin Exp $");
 
 #ifdef DDB
 #define	integrate
@@ -932,6 +932,7 @@ nextbyte:
 	 */
 	for (;;) {
 #ifdef NO_MANUAL_XFER /* XXX */
+		uint8_t intstat;
 		if (bus_space_read_1(iot, ioh, INTS) != 0) {
 			/*
 			 * Target left MESSAGE IN, probably because it
@@ -960,12 +961,18 @@ nextbyte:
 #else
 		bus_space_write_1(iot, ioh, SCMD, SCMD_XFR | SCMD_PROG_XFR);
 #endif
+		intstat = 0;
 		for (;;) {
 			if ((bus_space_read_1(iot, ioh, SSTS) &
 			SSTS_DREG_EMPTY) == 0)
 break;
-			if (bus_space_read_1(iot, ioh, INTS) != 0)
+			/*
+			 * We have to read INTS before checking SSTS to avoid
+			 * race between SSTS_DREG_EMPTY and INTS_CMD_DONE.
+			 */
+			if (intstat != 0)
 goto out;
+			intstat = bus_space_read_1(iot, ioh, INTS);
 		}
 		msg = bus_space_read_1(iot, ioh, DREG);
 #else



CVS commit: [netbsd-9] src/sys/dev/ic

2020-12-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec  7 20:04:07 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1144):

sys/dev/ic/nvme.c: revision 1.53

PR kern/55839:

handle multiple nvme_rescan()s correctly by doing the
name-space identify only once per nsid.
fixes issue where modloading triggers multiple
rescans.


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.4 -r1.44.2.5 src/sys/dev/ic/nvme.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/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.44.2.4 src/sys/dev/ic/nvme.c:1.44.2.5
--- src/sys/dev/ic/nvme.c:1.44.2.4	Sun Sep 27 10:30:16 2020
+++ src/sys/dev/ic/nvme.c	Mon Dec  7 20:04:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.44.2.4 2020/09/27 10:30:16 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.44.2.5 2020/12/07 20:04:07 martin Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.4 2020/09/27 10:30:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.5 2020/12/07 20:04:07 martin Exp $");
 
 #include 
 #include 
@@ -628,6 +628,12 @@ nvme_ns_identify(struct nvme_softc *sc, 
 
 	KASSERT(nsid > 0);
 
+	ns = nvme_ns_get(sc, nsid);
+	KASSERT(ns);
+
+	if (ns->ident != NULL)
+		return 0;
+
 	ccb = nvme_ccb_get(sc->sc_admin_q, false);
 	KASSERT(ccb != NULL); /* it's a bug if we don't have spare ccb here */
 
@@ -665,9 +671,6 @@ nvme_ns_identify(struct nvme_softc *sc, 
 	/* Convert data to host endian */
 	nvme_identify_namespace_swapbytes(identify);
 
-	ns = nvme_ns_get(sc, nsid);
-	KASSERT(ns);
-	KASSERT(ns->ident == NULL);
 	ns->ident = identify;
 
 done:



CVS commit: [netbsd-9] src/sys/dev/ic

2020-12-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec  7 20:04:07 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1144):

sys/dev/ic/nvme.c: revision 1.53

PR kern/55839:

handle multiple nvme_rescan()s correctly by doing the
name-space identify only once per nsid.
fixes issue where modloading triggers multiple
rescans.


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.4 -r1.44.2.5 src/sys/dev/ic/nvme.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2020-09-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 27 10:30:16 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: ld_nvme.c nvme.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1094):

sys/dev/ic/ld_nvme.c: revision 1.24
sys/dev/ic/nvme.c: revision 1.50

PR kern/55674:
move name space availability check from ld_nvme.c:ld_nvme_attach()
to nvme.c:nvme_rescan().
this avoids allocation of ld(4) instances for every possible
name space, even if it is not usable. it also reduces the device
node flood generated from that strategy.


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.1 -r1.22.2.2 src/sys/dev/ic/ld_nvme.c
cvs rdiff -u -r1.44.2.3 -r1.44.2.4 src/sys/dev/ic/nvme.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2020-09-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 27 10:30:16 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: ld_nvme.c nvme.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1094):

sys/dev/ic/ld_nvme.c: revision 1.24
sys/dev/ic/nvme.c: revision 1.50

PR kern/55674:
move name space availability check from ld_nvme.c:ld_nvme_attach()
to nvme.c:nvme_rescan().
this avoids allocation of ld(4) instances for every possible
name space, even if it is not usable. it also reduces the device
node flood generated from that strategy.


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.1 -r1.22.2.2 src/sys/dev/ic/ld_nvme.c
cvs rdiff -u -r1.44.2.3 -r1.44.2.4 src/sys/dev/ic/nvme.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/ld_nvme.c
diff -u src/sys/dev/ic/ld_nvme.c:1.22.2.1 src/sys/dev/ic/ld_nvme.c:1.22.2.2
--- src/sys/dev/ic/ld_nvme.c:1.22.2.1	Mon Oct 28 18:30:43 2019
+++ src/sys/dev/ic/ld_nvme.c	Sun Sep 27 10:30:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_nvme.c,v 1.22.2.1 2019/10/28 18:30:43 martin Exp $	*/
+/*	$NetBSD: ld_nvme.c,v 1.22.2.2 2020/09/27 10:30:16 martin Exp $	*/
 
 /*-
  * Copyright (C) 2016 NONAKA Kimihiro 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.22.2.1 2019/10/28 18:30:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.22.2.2 2020/09/27 10:30:16 martin Exp $");
 
 #include 
 #include 
@@ -86,7 +86,6 @@ ld_nvme_attach(device_t parent, device_t
 	struct nvme_attach_args *naa = aux;
 	struct nvme_namespace *ns;
 	struct nvm_namespace_format *f;
-	int error;
 
 	ld->sc_dv = self;
 	sc->sc_nvme = nsc;
@@ -95,28 +94,11 @@ ld_nvme_attach(device_t parent, device_t
 	aprint_naive("\n");
 	aprint_normal("\n");
 
-	error = nvme_ns_identify(sc->sc_nvme, sc->sc_nsid);
-	if (error) {
-		aprint_error_dev(self, "couldn't identify namespace\n");
-		return;
-	}
-
 	ns = nvme_ns_get(sc->sc_nvme, sc->sc_nsid);
 	KASSERT(ns);
-	f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
 
-	/*
-	 * NVME1.0e 6.11 Identify command
-	 *
-	 * LBADS values smaller than 9 are not supported, a value
-	 * of zero means that the format is not used.
-	 */
-	if (f->lbads < 9) {
-		if (f->lbads > 0)
-			aprint_error_dev(self,
-			"unsupported logical data size %u\n", f->lbads);
-		return;
-	}
+	f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
+	KASSERT(f->lbads >= 9); /* only valid LBS data sizes allowed here */
 
 	ld->sc_secsize = 1 << f->lbads;
 	ld->sc_secperunit = ns->ident->nsze;

Index: src/sys/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.44.2.3 src/sys/dev/ic/nvme.c:1.44.2.4
--- src/sys/dev/ic/nvme.c:1.44.2.3	Mon Nov 11 17:15:42 2019
+++ src/sys/dev/ic/nvme.c	Sun Sep 27 10:30:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.44.2.3 2019/11/11 17:15:42 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.44.2.4 2020/09/27 10:30:16 martin Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.3 2019/11/11 17:15:42 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.4 2020/09/27 10:30:16 martin Exp $");
 
 #include 
 #include 
@@ -471,23 +471,52 @@ nvme_rescan(device_t self, const char *a
 {
 	struct nvme_softc *sc = device_private(self);
 	struct nvme_attach_args naa;
+	struct nvm_namespace_format *f;
+	struct nvme_namespace *ns;
 	uint64_t cap;
 	int ioq_entries = nvme_ioq_size;
 	int i;
+	int error;
 
 	cap = nvme_read8(sc, NVME_CAP);
 	if (ioq_entries > NVME_CAP_MQES(cap))
 		ioq_entries = NVME_CAP_MQES(cap);
 
-	for (i = 0; i < sc->sc_nn; i++) {
-		if (sc->sc_namespaces[i].dev)
+	for (i = 1; i <= sc->sc_nn; i++) {
+		if (sc->sc_namespaces[i - 1].dev)
+			continue;
+
+		/* identify to check for availability */
+		error = nvme_ns_identify(sc, i);
+		if (error) {
+			aprint_error_dev(self, "couldn't identify namespace #%d\n", i);
+			continue;
+		}
+
+		ns = nvme_ns_get(sc, i);
+		KASSERT(ns);
+
+		f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
+
+		/*
+		 * NVME1.0e 6.11 Identify command
+		 *
+		 * LBADS values smaller than 9 are not supported, a value
+		 * of zero means that the format is not used.
+		 */
+		if (f->lbads < 9) {
+			if (f->lbads > 0)
+aprint_error_dev(self,
+		 "unsupported logical data size %u\n", f->lbads);
 			continue;
+		}
+
 		memset(, 0, sizeof(naa));
-		naa.naa_nsid = i + 1;
+		naa.naa_nsid = i;
 		naa.naa_qentries = (ioq_entries - 1) * sc->sc_nq;
 		naa.naa_maxphys = sc->sc_mdts;
 		naa.naa_typename = sc->sc_modelname;
-		sc->sc_namespaces[i].dev = config_found(sc->sc_dev, ,
+		sc->sc_namespaces[i - 1].dev = config_found(sc->sc_dev, ,
 		nvme_print);
 	}
 	return 0;



CVS commit: [netbsd-9] src/sys/dev/ic

2020-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 16 13:29:53 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: mpt_netbsd.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1085):

sys/dev/ic/mpt_netbsd.c: revision 1.37

max_devices is a 8bit value and zero is interpreted as 256. This value
can be reported by an mpt device emulated by VMware ESXi.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.36.2.1 src/sys/dev/ic/mpt_netbsd.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2020-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 16 13:29:53 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: mpt_netbsd.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1085):

sys/dev/ic/mpt_netbsd.c: revision 1.37

max_devices is a 8bit value and zero is interpreted as 256. This value
can be reported by an mpt device emulated by VMware ESXi.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.36.2.1 src/sys/dev/ic/mpt_netbsd.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/mpt_netbsd.c
diff -u src/sys/dev/ic/mpt_netbsd.c:1.36 src/sys/dev/ic/mpt_netbsd.c:1.36.2.1
--- src/sys/dev/ic/mpt_netbsd.c:1.36	Wed May  8 06:32:01 2019
+++ src/sys/dev/ic/mpt_netbsd.c	Wed Sep 16 13:29:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpt_netbsd.c,v 1.36 2019/05/08 06:32:01 cnst Exp $	*/
+/*	$NetBSD: mpt_netbsd.c,v 1.36.2.1 2020/09/16 13:29:53 martin Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.36 2019/05/08 06:32:01 cnst Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.36.2.1 2020/09/16 13:29:53 martin Exp $");
 
 #include "bio.h"
 
@@ -150,7 +150,7 @@ mpt_scsipi_attach(mpt_softc_t *mpt)
 	chan->chan_channel = 0;
 	chan->chan_flags = 0;
 	chan->chan_nluns = 8;
-	chan->chan_ntargets = mpt->mpt_max_devices;
+	chan->chan_ntargets = mpt->mpt_max_devices ? mpt->mpt_max_devices : 256;
 	chan->chan_id = mpt->mpt_ini_id;
 
 	/*



CVS commit: [netbsd-9] src/sys/dev/ic

2020-04-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 14 17:02:28 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: spdmem.c spdmemvar.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #832):

sys/dev/ic/spdmemvar.h: revision 1.15
sys/dev/ic/spdmemvar.h: revision 1.16
sys/dev/ic/spdmem.c: revision 1.32
sys/dev/ic/spdmem.c: revision 1.33
sys/dev/ic/spdmem.c: revision 1.34
sys/dev/ic/spdmem.c: revision 1.35

  Print DDR3's row and column correctly.

KNF. No functional change.

- Define some new parameters of DDR3 SPD ROM.
- Use fine timebase parameters for time calculation on DDR3. This change
   makes PC3- value more correctly on newer DDR3.

Calculate DDR3's tRAS correctly.

  Fix unused area size found by pgoyette@.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.31.4.1 src/sys/dev/ic/spdmem.c
cvs rdiff -u -r1.14 -r1.14.4.1 src/sys/dev/ic/spdmemvar.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/ic/spdmem.c
diff -u src/sys/dev/ic/spdmem.c:1.31 src/sys/dev/ic/spdmem.c:1.31.4.1
--- src/sys/dev/ic/spdmem.c:1.31	Sun Apr  7 01:39:12 2019
+++ src/sys/dev/ic/spdmem.c	Tue Apr 14 17:02:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: spdmem.c,v 1.31 2019/04/07 01:39:12 pgoyette Exp $ */
+/* $NetBSD: spdmem.c,v 1.31.4.1 2020/04/14 17:02:28 martin Exp $ */
 
 /*
  * Copyright (c) 2007 Nicolas Joly
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.31 2019/04/07 01:39:12 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.31.4.1 2020/04/14 17:02:28 martin Exp $");
 
 #include 
 #include 
@@ -340,12 +340,12 @@ spdmem_common_attach(struct spdmem_softc
 	device_xname(self), NULL, NULL, 0, NULL, 0,
 	CTL_HW, CTL_CREATE, CTL_EOL);
 	if (node != NULL && spd_len != 0)
-sysctl_createv(>sc_sysctl_log, 0, NULL, NULL,
-0,
-CTLTYPE_STRUCT, "spd_data",
+		sysctl_createv(>sc_sysctl_log, 0, NULL, NULL,
+		0,
+		CTLTYPE_STRUCT, "spd_data",
 		SYSCTL_DESCR("raw spd data"), NULL,
-0, s, spd_len,
-CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
+		0, s, spd_len,
+		CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
 
 	/*
 	 * Decode and print key SPD contents
@@ -411,7 +411,7 @@ spdmem_common_attach(struct spdmem_softc
 			strlcat(sc->sc_type, " NVDIMM hybrid",
 			SPDMEM_TYPE_MAXLEN);
 	}
-	
+
 	if (node != NULL)
 		sysctl_createv(>sc_sysctl_log, 0, NULL, NULL,
 		0,
@@ -615,7 +615,7 @@ decode_sdram(const struct sysctlnode *no
 		freq = 0;
 	switch (freq) {
 		/*
-		 * Must check cycle time since some PC-133 DIMMs 
+		 * Must check cycle time since some PC-133 DIMMs
 		 * actually report PC-100
 		 */
 	case 100:
@@ -756,6 +756,30 @@ print_part(const char *part, size_t pnsi
 	aprint_normal(": %.*s\n", (int)(p - part), part);
 }
 
+static u_int
+ddr3_value_pico(struct spdmem *s, uint8_t txx_mtb, uint8_t txx_ftb)
+{
+	u_int mtb, ftb; /* in picoseconds */
+	intmax_t signed_txx_ftb;
+	u_int val;
+
+	mtb = (u_int)s->sm_ddr3.ddr3_mtb_dividend * 1000 /
+	s->sm_ddr3.ddr3_mtb_divisor;
+	ftb = (u_int)s->sm_ddr3.ddr3_ftb_dividend * 1000 /
+	s->sm_ddr3.ddr3_ftb_divisor;
+
+	/* tXX_ftb is signed value */
+	signed_txx_ftb = (int8_t)txx_ftb;
+	val = txx_mtb * mtb +
+	((txx_ftb > 127) ? signed_txx_ftb : txx_ftb) * ftb / 1000;
+
+	return val;
+}
+
+#define __DDR3_VALUE_PICO(s, field)\
+	ddr3_value_pico(s, s->sm_ddr3.ddr3_##field##_mtb,	\
+	s->sm_ddr3.ddr3_##field##_ftb)
+
 static void
 decode_ddr3(const struct sysctlnode *node, device_t self, struct spdmem *s)
 {
@@ -786,10 +810,7 @@ decode_ddr3(const struct sysctlnode *nod
 		(s->sm_ddr3.ddr3_chipwidth + 2);
 	dimm_size = (1 << dimm_size) * (s->sm_ddr3.ddr3_physbanks + 1);
 
-	cycle_time = (1000 * s->sm_ddr3.ddr3_mtb_dividend + 
-			(s->sm_ddr3.ddr3_mtb_divisor / 2)) /
-		 s->sm_ddr3.ddr3_mtb_divisor;
-	cycle_time *= s->sm_ddr3.ddr3_tCKmin;
+	cycle_time = __DDR3_VALUE_PICO(s, tCKmin);
 	bits = 1 << (s->sm_ddr3.ddr3_datawidth + 3);
 	decode_size_speed(self, node, dimm_size, cycle_time, 2, bits, FALSE,
 			  "PC3", 0);
@@ -797,17 +818,21 @@ decode_ddr3(const struct sysctlnode *nod
 	aprint_verbose_dev(self,
 	"%d rows, %d cols, %d log. banks, %d phys. banks, "
 	"%d.%03dns cycle time\n",
-	s->sm_ddr3.ddr3_rows + 9, s->sm_ddr3.ddr3_cols + 12,
+	s->sm_ddr3.ddr3_rows + 12, s->sm_ddr3.ddr3_cols + 9,
 	1 << (s->sm_ddr3.ddr3_logbanks + 3),
 	s->sm_ddr3.ddr3_physbanks + 1,
 	cycle_time/1000, cycle_time % 1000);
 
-#define	__DDR3_CYCLES(field) (s->sm_ddr3.field / s->sm_ddr3.ddr3_tCKmin)
+#define	__DDR3_CYCLES(val)		\
+	((val / cycle_time) + ((val % cycle_time) ? 1 : 0))
 
-	aprint_verbose_dev(self, LATENCY, __DDR3_CYCLES(ddr3_tAAmin),
-		__DDR3_CYCLES(ddr3_tRCDmin), 

CVS commit: [netbsd-9] src/sys/dev/ic

2020-04-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 14 17:02:28 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: spdmem.c spdmemvar.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #832):

sys/dev/ic/spdmemvar.h: revision 1.15
sys/dev/ic/spdmemvar.h: revision 1.16
sys/dev/ic/spdmem.c: revision 1.32
sys/dev/ic/spdmem.c: revision 1.33
sys/dev/ic/spdmem.c: revision 1.34
sys/dev/ic/spdmem.c: revision 1.35

  Print DDR3's row and column correctly.

KNF. No functional change.

- Define some new parameters of DDR3 SPD ROM.
- Use fine timebase parameters for time calculation on DDR3. This change
   makes PC3- value more correctly on newer DDR3.

Calculate DDR3's tRAS correctly.

  Fix unused area size found by pgoyette@.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.31.4.1 src/sys/dev/ic/spdmem.c
cvs rdiff -u -r1.14 -r1.14.4.1 src/sys/dev/ic/spdmemvar.h

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



CVS commit: [netbsd-9] src/sys/dev/ic

2020-03-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 21 20:24:36 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: dwc_mmc.c dwc_mmc_reg.h dwc_mmc_var.h

Log Message:
Pull up following revision(s) (requested by skrll in ticket #800):

sys/dev/ic/dwc_mmc_var.h: revision 1.14
sys/dev/ic/dwc_mmc_reg.h: revision 1.10
sys/dev/ic/dwc_mmc.c: revision 1.23
sys/dev/ic/dwc_mmc.c: revision 1.24
sys/dev/ic/dwc_mmc.c: revision 1.25
sys/dev/ic/dwc_mmc.c: revision 1.26

Release the sc_intr_lock on error

Trailing whitespace

Add DWC_MMC_VERID_280A

Remember / use sc_verid

Disable thrctrl or now and note why


To generate a diff of this commit:
cvs rdiff -u -r1.17.2.2 -r1.17.2.3 src/sys/dev/ic/dwc_mmc.c
cvs rdiff -u -r1.7.8.1 -r1.7.8.2 src/sys/dev/ic/dwc_mmc_reg.h
cvs rdiff -u -r1.8.2.2 -r1.8.2.3 src/sys/dev/ic/dwc_mmc_var.h

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



CVS commit: [netbsd-9] src/sys/dev/ic

2020-03-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 21 20:24:36 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: dwc_mmc.c dwc_mmc_reg.h dwc_mmc_var.h

Log Message:
Pull up following revision(s) (requested by skrll in ticket #800):

sys/dev/ic/dwc_mmc_var.h: revision 1.14
sys/dev/ic/dwc_mmc_reg.h: revision 1.10
sys/dev/ic/dwc_mmc.c: revision 1.23
sys/dev/ic/dwc_mmc.c: revision 1.24
sys/dev/ic/dwc_mmc.c: revision 1.25
sys/dev/ic/dwc_mmc.c: revision 1.26

Release the sc_intr_lock on error

Trailing whitespace

Add DWC_MMC_VERID_280A

Remember / use sc_verid

Disable thrctrl or now and note why


To generate a diff of this commit:
cvs rdiff -u -r1.17.2.2 -r1.17.2.3 src/sys/dev/ic/dwc_mmc.c
cvs rdiff -u -r1.7.8.1 -r1.7.8.2 src/sys/dev/ic/dwc_mmc_reg.h
cvs rdiff -u -r1.8.2.2 -r1.8.2.3 src/sys/dev/ic/dwc_mmc_var.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/ic/dwc_mmc.c
diff -u src/sys/dev/ic/dwc_mmc.c:1.17.2.2 src/sys/dev/ic/dwc_mmc.c:1.17.2.3
--- src/sys/dev/ic/dwc_mmc.c:1.17.2.2	Tue Feb 25 18:40:43 2020
+++ src/sys/dev/ic/dwc_mmc.c	Sat Mar 21 20:24:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_mmc.c,v 1.17.2.2 2020/02/25 18:40:43 martin Exp $ */
+/* $NetBSD: dwc_mmc.c,v 1.17.2.3 2020/03/21 20:24:36 martin Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwc_mmc.c,v 1.17.2.2 2020/02/25 18:40:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc_mmc.c,v 1.17.2.3 2020/03/21 20:24:36 martin Exp $");
 
 #include 
 #include 
@@ -439,7 +439,7 @@ dwc_mmc_bus_width(sdmmc_chipset_handle_t
 	}
 
 	sc->sc_mmc_width = width;
-	
+
 	return 0;
 }
 
@@ -662,11 +662,21 @@ dwc_mmc_exec_command(sdmmc_chipset_handl
 		MMC_WRITE(sc, DWC_MMC_BLKSZ, cmd->c_blklen);
 		MMC_WRITE(sc, DWC_MMC_BYTECNT,
 		nblks > 1 ? nblks * cmd->c_blklen : cmd->c_datalen);
+
+#if 0
+		/*
+		 * The following doesn't work on the 250a verid IP in Odroid-XU4.
+		*
+		 * thrctl should only be used for UHS/HS200 and faster timings on
+		 * >=240a
+		 */
+
 		if (ISSET(cmd->c_flags, SCF_CMD_READ)) {
 			MMC_WRITE(sc, DWC_MMC_CARDTHRCTL,
 			__SHIFTIN(cmd->c_blklen, DWC_MMC_CARDTHRCTL_RDTHR) |
 			DWC_MMC_CARDTHRCTL_RDTHREN);
 		}
+#endif
 	}
 
 	MMC_WRITE(sc, DWC_MMC_IMASK, imask | sc->sc_intr_card);
@@ -717,6 +727,7 @@ dwc_mmc_exec_command(sdmmc_chipset_handl
 		if (error != 0) {
 			cmd->c_error = error;
 			SET(cmd->c_flags, SCF_ITSDONE);
+			mutex_exit(>sc_intr_lock);
 			goto done;
 		}
 	}
@@ -806,11 +817,11 @@ dwc_mmc_init(struct dwc_mmc_softc *sc)
 {
 	uint32_t val;
 
-	if (sc->sc_fifo_reg == 0) {
-		val = MMC_READ(sc, DWC_MMC_VERID);
-		const u_int id = __SHIFTOUT(val, DWC_MMC_VERID_ID);
+	val = MMC_READ(sc, DWC_MMC_VERID);
+	sc->sc_verid = __SHIFTOUT(val, DWC_MMC_VERID_ID);
 
-		if (id < DWC_MMC_VERID_240A)
+	if (sc->sc_fifo_reg == 0) {
+		if (sc->sc_verid < DWC_MMC_VERID_240A)
 			sc->sc_fifo_reg = 0x100;
 		else
 			sc->sc_fifo_reg = 0x200;

Index: src/sys/dev/ic/dwc_mmc_reg.h
diff -u src/sys/dev/ic/dwc_mmc_reg.h:1.7.8.1 src/sys/dev/ic/dwc_mmc_reg.h:1.7.8.2
--- src/sys/dev/ic/dwc_mmc_reg.h:1.7.8.1	Tue Feb 25 18:40:43 2020
+++ src/sys/dev/ic/dwc_mmc_reg.h	Sat Mar 21 20:24:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_mmc_reg.h,v 1.7.8.1 2020/02/25 18:40:43 martin Exp $ */
+/* $NetBSD: dwc_mmc_reg.h,v 1.7.8.2 2020/03/21 20:24:36 martin Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -153,6 +153,7 @@
 
 #define DWC_MMC_VERID_ID		__BITS(15,0)
 #define DWC_MMC_VERID_240A		0x240a
+#define DWC_MMC_VERID_280A		0x280a
 
 #define DWC_MMC_IDST_HOST_ABT		__BIT(10)
 #define DWC_MMC_IDST_ABNORMAL_INT_SUM	__BIT(9)

Index: src/sys/dev/ic/dwc_mmc_var.h
diff -u src/sys/dev/ic/dwc_mmc_var.h:1.8.2.2 src/sys/dev/ic/dwc_mmc_var.h:1.8.2.3
--- src/sys/dev/ic/dwc_mmc_var.h:1.8.2.2	Tue Feb 25 18:40:43 2020
+++ src/sys/dev/ic/dwc_mmc_var.h	Sat Mar 21 20:24:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_mmc_var.h,v 1.8.2.2 2020/02/25 18:40:43 martin Exp $ */
+/* $NetBSD: dwc_mmc_var.h,v 1.8.2.3 2020/03/21 20:24:36 martin Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -45,6 +45,7 @@ struct dwc_mmc_softc {
 	u_int sc_clock_freq;
 	u_int sc_bus_width;
 	bool sc_card_inited;
+	u_int sc_verid;
 
 	void *sc_ih;
 	kmutex_t sc_lock;



CVS commit: [netbsd-9] src/sys/dev/ic

2020-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb 11 08:41:28 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: elinkxl.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #695):

sys/dev/ic/elinkxl.c: revision 1.137

  Restore an register read for RX_FRAMES_OK which was removed in rev. 1.133.

All statistics registers should be read to ACK the interrupt. Fixes PR#54920.
XXX pullup-[89]


To generate a diff of this commit:
cvs rdiff -u -r1.131.2.1 -r1.131.2.2 src/sys/dev/ic/elinkxl.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/elinkxl.c
diff -u src/sys/dev/ic/elinkxl.c:1.131.2.1 src/sys/dev/ic/elinkxl.c:1.131.2.2
--- src/sys/dev/ic/elinkxl.c:1.131.2.1	Wed Nov  6 09:59:38 2019
+++ src/sys/dev/ic/elinkxl.c	Tue Feb 11 08:41:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: elinkxl.c,v 1.131.2.1 2019/11/06 09:59:38 martin Exp $	*/
+/*	$NetBSD: elinkxl.c,v 1.131.2.2 2020/02/11 08:41:27 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: elinkxl.c,v 1.131.2.1 2019/11/06 09:59:38 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: elinkxl.c,v 1.131.2.2 2020/02/11 08:41:27 martin Exp $");
 
 #include 
 #include 
@@ -1514,6 +1514,7 @@ ex_getstats(struct ex_softc *sc)
 	(void)bus_space_read_1(iot, ioh, TX_AFTER_1_COLLISION);
 	(void)bus_space_read_1(iot, ioh, TX_NO_SQE);
 	(void)bus_space_read_1(iot, ioh, TX_CD_LOST);
+	(void)bus_space_read_1(iot, ioh, RX_FRAMES_OK);
 	GO_WINDOW(4);
 	(void)bus_space_read_1(iot, ioh, ELINK_W4_BADSSD);
 	GO_WINDOW(1);



CVS commit: [netbsd-9] src/sys/dev/ic

2020-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb 11 08:41:28 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: elinkxl.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #695):

sys/dev/ic/elinkxl.c: revision 1.137

  Restore an register read for RX_FRAMES_OK which was removed in rev. 1.133.

All statistics registers should be read to ACK the interrupt. Fixes PR#54920.
XXX pullup-[89]


To generate a diff of this commit:
cvs rdiff -u -r1.131.2.1 -r1.131.2.2 src/sys/dev/ic/elinkxl.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2020-01-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jan 28 11:12:30 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: rtl8169.c rtl81x9.c rtl81x9reg.h
rtl81x9var.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #667):

sys/dev/ic/rtl81x9var.h: revision 1.57
sys/dev/ic/rtl81x9.c: revision 1.107
sys/dev/ic/rtl81x9reg.h: revision 1.51
sys/dev/ic/rtl8169.c: revision 1.160
sys/dev/ic/rtl81x9reg.h: revision 1.52
sys/dev/ic/rtl8169.c: revision 1.161

 Use unsigned in rtk_setmulti() to avoid undefined behavior. Found bk kUBSan.
8168H model didn't link up well. some models seems to require to enable TX/RX 
after configuration.
RTKQ_TXRXEN_LATER quirk flag added. it may be able to unify with 
RTKQ_RXDV_GATED flag?
 Sort RTK_HWREV_* by value.

Improve some chip revisions support:
 - Add 8168FP, 8411, 8168G, 8401E, 8105E, 8105E_SPIN1, 8106E and 8402 from
   {Free,Open}BSD.
 - Renumber RTK_HWREV_8103E from 0x24C0 to 0x34c0. 0x24C0 is newly
   used as RTK_HWREV_8102EL_SPIN1. Same as {Free,Open}BSD.


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.159.2.1 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.106 -r1.106.2.1 src/sys/dev/ic/rtl81x9.c
cvs rdiff -u -r1.50 -r1.50.4.1 src/sys/dev/ic/rtl81x9reg.h
cvs rdiff -u -r1.56 -r1.56.18.1 src/sys/dev/ic/rtl81x9var.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/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.159 src/sys/dev/ic/rtl8169.c:1.159.2.1
--- src/sys/dev/ic/rtl8169.c:1.159	Thu May 30 02:32:18 2019
+++ src/sys/dev/ic/rtl8169.c	Tue Jan 28 11:12:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.159 2019/05/30 02:32:18 msaitoh Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.159.2.1 2020/01/28 11:12:30 martin Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159 2019/05/30 02:32:18 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159.2.1 2020/01/28 11:12:30 martin Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -607,17 +607,24 @@ re_attach(struct rtk_softc *sc)
 			sc->sc_quirk |= RTKQ_NOJUMBO;
 			break;
 		case RTK_HWREV_8168E:
-		case RTK_HWREV_8168H:
 		case RTK_HWREV_8168H_SPIN1:
 			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
 			RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM |
 			RTKQ_NOJUMBO;
 			break;
+		case RTK_HWREV_8168H:
+		case RTK_HWREV_8168FP:
+			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
+			RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM |
+			RTKQ_NOJUMBO | RTKQ_RXDV_GATED | RTKQ_TXRXEN_LATER;
+			break;
 		case RTK_HWREV_8168E_VL:
 		case RTK_HWREV_8168F:
+		case RTK_HWREV_8411:
 			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
 			RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO;
 			break;
+		case RTK_HWREV_8168EP:
 		case RTK_HWREV_8168G:
 		case RTK_HWREV_8168G_SPIN1:
 		case RTK_HWREV_8168G_SPIN2:
@@ -633,10 +640,27 @@ re_attach(struct rtk_softc *sc)
 			break;
 		case RTK_HWREV_8102E:
 		case RTK_HWREV_8102EL:
-		case RTK_HWREV_8103E:
+		case RTK_HWREV_8102EL_SPIN1:
 			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
 			RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO;
 			break;
+		case RTK_HWREV_8103E:
+			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
+			RTKQ_MACSTAT | RTKQ_CMDSTOP;
+			break;
+		case RTK_HWREV_8401E:
+		case RTK_HWREV_8105E:
+		case RTK_HWREV_8105E_SPIN1:
+		case RTK_HWREV_8106E:
+			sc->sc_quirk |= RTKQ_PHYWAKE_PM |
+			RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT |
+			RTKQ_CMDSTOP;
+			break;
+		case RTK_HWREV_8402:
+			sc->sc_quirk |= RTKQ_PHYWAKE_PM |
+			RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT |
+			RTKQ_CMDSTOP; /* CMDSTOP_WAIT_TXQ */
+			break;
 		default:
 			aprint_normal_dev(sc->sc_dev,
 			"Unknown revision (0x%08x)\n", hwrev);
@@ -1873,7 +1897,8 @@ re_init(struct ifnet *ifp)
 	/*
 	 * Enable transmit and receive.
 	 */
-	CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB);
+	if ((sc->sc_quirk & RTKQ_TXRXEN_LATER) == 0)
+		CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB);
 
 	/*
 	 * Set the initial TX and RX configuration.
@@ -1915,6 +1940,12 @@ re_init(struct ifnet *ifp)
 	rtk_setmulti(sc);
 
 	/*
+	 * some chips require to enable TX/RX *AFTER* TX/RX configuration
+	 */
+	if ((sc->sc_quirk & RTKQ_TXRXEN_LATER) != 0)
+		CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB);
+
+	/*
 	 * Enable interrupts.
 	 */
 	if (sc->re_testmode)

Index: src/sys/dev/ic/rtl81x9.c
diff -u src/sys/dev/ic/rtl81x9.c:1.106 src/sys/dev/ic/rtl81x9.c:1.106.2.1
--- src/sys/dev/ic/rtl81x9.c:1.106	Tue May 28 07:41:48 2019
+++ src/sys/dev/ic/rtl81x9.c	Tue Jan 28 11:12:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl81x9.c,v 1.106 2019/05/28 07:41:48 msaitoh Exp $	*/
+/*	$NetBSD: rtl81x9.c,v 1.106.2.1 2020/01/28 

CVS commit: [netbsd-9] src/sys/dev/ic

2020-01-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jan 28 11:12:30 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: rtl8169.c rtl81x9.c rtl81x9reg.h
rtl81x9var.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #667):

sys/dev/ic/rtl81x9var.h: revision 1.57
sys/dev/ic/rtl81x9.c: revision 1.107
sys/dev/ic/rtl81x9reg.h: revision 1.51
sys/dev/ic/rtl8169.c: revision 1.160
sys/dev/ic/rtl81x9reg.h: revision 1.52
sys/dev/ic/rtl8169.c: revision 1.161

 Use unsigned in rtk_setmulti() to avoid undefined behavior. Found bk kUBSan.
8168H model didn't link up well. some models seems to require to enable TX/RX 
after configuration.
RTKQ_TXRXEN_LATER quirk flag added. it may be able to unify with 
RTKQ_RXDV_GATED flag?
 Sort RTK_HWREV_* by value.

Improve some chip revisions support:
 - Add 8168FP, 8411, 8168G, 8401E, 8105E, 8105E_SPIN1, 8106E and 8402 from
   {Free,Open}BSD.
 - Renumber RTK_HWREV_8103E from 0x24C0 to 0x34c0. 0x24C0 is newly
   used as RTK_HWREV_8102EL_SPIN1. Same as {Free,Open}BSD.


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.159.2.1 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.106 -r1.106.2.1 src/sys/dev/ic/rtl81x9.c
cvs rdiff -u -r1.50 -r1.50.4.1 src/sys/dev/ic/rtl81x9reg.h
cvs rdiff -u -r1.56 -r1.56.18.1 src/sys/dev/ic/rtl81x9var.h

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



CVS commit: [netbsd-9] src/sys/dev/ic

2020-01-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan  8 11:50:58 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: gem.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #610):

sys/dev/ic/gem.c: revision 1.124

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.120 -r1.120.2.1 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.



CVS commit: [netbsd-9] src/sys/dev/ic

2020-01-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan  8 11:50:58 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-9]: gem.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #610):

sys/dev/ic/gem.c: revision 1.124

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.120 -r1.120.2.1 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.120 src/sys/dev/ic/gem.c:1.120.2.1
--- src/sys/dev/ic/gem.c:1.120	Tue May 28 08:59:34 2019
+++ src/sys/dev/ic/gem.c	Wed Jan  8 11:50:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: gem.c,v 1.120 2019/05/28 08:59:34 msaitoh Exp $ */
+/*	$NetBSD: gem.c,v 1.120.2.1 2020/01/08 11:50:57 martin Exp $ */
 
 /*
  *
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.120 2019/05/28 08:59:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.120.2.1 2020/01/08 11:50:57 martin Exp $");
 
 #include "opt_inet.h"
 
@@ -1389,6 +1389,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) {
 		/*
@@ -1498,16 +1499,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 &&
@@ -1526,8 +1520,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;
@@ -1538,7 +1534,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: [netbsd-9] src/sys/dev/ic

2019-12-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 24 17:34:33 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: ahcisata_core.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #576):

sys/dev/ic/ahcisata_core.c: revision 1.79

When resetting a drive, if the command list is running and CLO is not
supported, attempt to stop the drive first and fail gracefully if that
fails instead of triggering a KASSERT on DIAGNOSTIC kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.75.4.1 -r1.75.4.2 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.75.4.1 src/sys/dev/ic/ahcisata_core.c:1.75.4.2
--- src/sys/dev/ic/ahcisata_core.c:1.75.4.1	Wed Oct 23 18:06:46 2019
+++ src/sys/dev/ic/ahcisata_core.c	Tue Dec 24 17:34:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.75.4.1 2019/10/23 18:06:46 martin Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.75.4.2 2019/12/24 17:34:33 martin Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.75.4.1 2019/10/23 18:06:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.75.4.2 2019/12/24 17:34:33 martin Exp $");
 
 #include 
 #include 
@@ -807,7 +807,7 @@ ahci_do_reset_drive(struct ata_channel *
 	struct ahci_cmd_tbl *cmd_tbl;
 	struct ahci_cmd_header *cmd_h;
 	int i, error = 0;
-	uint32_t sig;
+	uint32_t sig, cmd;
 	int noclo_retry = 0;
 
 	ata_channel_lock_owned(chp);
@@ -825,6 +825,19 @@ again:
 		ahci_channel_start(sc, chp, flags, 1);
 	} else {
 		/* Can't handle command still running without CLO */
+		cmd = AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel));
+		if ((cmd & AHCI_P_CMD_CR) != 0) {
+			ahci_channel_stop(sc, chp, flags);
+			cmd = AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel));
+			if ((cmd & AHCI_P_CMD_CR) != 0) {
+aprint_error("%s port %d: DMA engine busy "
+"for drive %d\n", AHCINAME(sc),
+chp->ch_channel, drive);
+error = EBUSY;
+goto end;
+			}
+		}
+
 		KASSERT((AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_CR) == 0);
 
 		ahci_channel_start(sc, chp, flags, 0);



CVS commit: [netbsd-9] src/sys/dev/ic

2019-12-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 24 17:34:33 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: ahcisata_core.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #576):

sys/dev/ic/ahcisata_core.c: revision 1.79

When resetting a drive, if the command list is running and CLO is not
supported, attempt to stop the drive first and fail gracefully if that
fails instead of triggering a KASSERT on DIAGNOSTIC kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.75.4.1 -r1.75.4.2 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.



CVS commit: [netbsd-9] src/sys/dev/ic

2019-11-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov 11 17:15:42 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #415):

sys/dev/ic/nvme.c: revision 1.47

nvme(4): Use the SET_FEATURES command to get the number of allocated queues.


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.2 -r1.44.2.3 src/sys/dev/ic/nvme.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2019-11-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov 11 17:15:42 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #415):

sys/dev/ic/nvme.c: revision 1.47

nvme(4): Use the SET_FEATURES command to get the number of allocated queues.


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.2 -r1.44.2.3 src/sys/dev/ic/nvme.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/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.44.2.2 src/sys/dev/ic/nvme.c:1.44.2.3
--- src/sys/dev/ic/nvme.c:1.44.2.2	Thu Sep 26 19:13:14 2019
+++ src/sys/dev/ic/nvme.c	Mon Nov 11 17:15:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.44.2.2 2019/09/26 19:13:14 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.44.2.3 2019/11/11 17:15:42 martin Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.2 2019/09/26 19:13:14 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.3 2019/11/11 17:15:42 martin Exp $");
 
 #include 
 #include 
@@ -116,7 +116,8 @@ static void	nvme_pt_done(struct nvme_que
 static int	nvme_command_passthrough(struct nvme_softc *,
 		struct nvme_pt_command *, uint16_t, struct lwp *, bool);
 
-static int	nvme_get_number_of_queues(struct nvme_softc *, u_int *);
+static int	nvme_set_number_of_queues(struct nvme_softc *, u_int, u_int *,
+		u_int *);
 
 #define NVME_TIMO_QOP		5	/* queue create and delete timeout */
 #define NVME_TIMO_IDENT		10	/* probe identify timeout */
@@ -339,7 +340,7 @@ nvme_attach(struct nvme_softc *sc)
 	uint32_t reg;
 	u_int dstrd;
 	u_int mps = PAGE_SHIFT;
-	u_int ioq_allocated;
+	u_int ncq, nsq;
 	uint16_t adminq_entries = nvme_adminq_size;
 	uint16_t ioq_entries = nvme_ioq_size;
 	int i;
@@ -413,13 +414,15 @@ nvme_attach(struct nvme_softc *sc)
 
 	if (sc->sc_use_mq) {
 		/* Limit the number of queues to the number allocated in HW */
-		if (nvme_get_number_of_queues(sc, _allocated) != 0) {
+		if (nvme_set_number_of_queues(sc, sc->sc_nq, , ) != 0) {
 			aprint_error_dev(sc->sc_dev,
 			"unable to get number of queues\n");
 			goto disable;
 		}
-		if (sc->sc_nq > ioq_allocated)
-			sc->sc_nq = ioq_allocated;
+		if (sc->sc_nq > ncq)
+			sc->sc_nq = ncq;
+		if (sc->sc_nq > nsq)
+			sc->sc_nq = nsq;
 	}
 
 	sc->sc_q = kmem_zalloc(sizeof(*sc->sc_q) * sc->sc_nq, KM_SLEEP);
@@ -1579,20 +1582,21 @@ nvme_fill_identify(struct nvme_queue *q,
 }
 
 static int
-nvme_get_number_of_queues(struct nvme_softc *sc, u_int *nqap)
+nvme_set_number_of_queues(struct nvme_softc *sc, u_int nq, u_int *ncqa,
+u_int *nsqa)
 {
 	struct nvme_pt_state state;
 	struct nvme_pt_command pt;
 	struct nvme_ccb *ccb;
-	uint16_t ncqa, nsqa;
 	int rv;
 
 	ccb = nvme_ccb_get(sc->sc_admin_q, false);
 	KASSERT(ccb != NULL); /* it's a bug if we don't have spare ccb here */
 
 	memset(, 0, sizeof(pt));
-	pt.cmd.opcode = NVM_ADMIN_GET_FEATURES;
-	pt.cmd.cdw10 = NVM_FEATURE_NUMBER_OF_QUEUES;
+	pt.cmd.opcode = NVM_ADMIN_SET_FEATURES;
+	htolem32(, NVM_FEATURE_NUMBER_OF_QUEUES);
+	htolem32(, ((nq - 1) << 16) | (nq - 1));
 
 	memset(, 0, sizeof(state));
 	state.pt = 
@@ -1604,13 +1608,12 @@ nvme_get_number_of_queues(struct nvme_so
 	rv = nvme_poll(sc, sc->sc_admin_q, ccb, nvme_pt_fill, NVME_TIMO_QOP);
 
 	if (rv != 0) {
-		*nqap = 0;
+		*ncqa = *nsqa = 0;
 		return EIO;
 	}
 
-	ncqa = pt.cpl.cdw0 >> 16;
-	nsqa = pt.cpl.cdw0 & 0x;
-	*nqap = MIN(ncqa, nsqa) + 1;
+	*ncqa = (pt.cpl.cdw0 >> 16) + 1;
+	*nsqa = (pt.cpl.cdw0 & 0x) + 1;
 
 	return 0;
 }



CVS commit: [netbsd-9] src/sys/dev/ic

2019-10-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct 28 18:30:43 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: ld_nvme.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #383):

sys/dev/ic/ld_nvme.c: revision 1.23

Don't attach an ld device if the format descriptor is unsupported/unused.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.22.2.1 src/sys/dev/ic/ld_nvme.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2019-10-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct 28 18:30:43 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: ld_nvme.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #383):

sys/dev/ic/ld_nvme.c: revision 1.23

Don't attach an ld device if the format descriptor is unsupported/unused.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.22.2.1 src/sys/dev/ic/ld_nvme.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/ld_nvme.c
diff -u src/sys/dev/ic/ld_nvme.c:1.22 src/sys/dev/ic/ld_nvme.c:1.22.2.1
--- src/sys/dev/ic/ld_nvme.c:1.22	Fri Apr 26 14:28:40 2019
+++ src/sys/dev/ic/ld_nvme.c	Mon Oct 28 18:30:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_nvme.c,v 1.22 2019/04/26 14:28:40 mlelstv Exp $	*/
+/*	$NetBSD: ld_nvme.c,v 1.22.2.1 2019/10/28 18:30:43 martin Exp $	*/
 
 /*-
  * Copyright (C) 2016 NONAKA Kimihiro 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.22 2019/04/26 14:28:40 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.22.2.1 2019/10/28 18:30:43 martin Exp $");
 
 #include 
 #include 
@@ -105,6 +105,19 @@ ld_nvme_attach(device_t parent, device_t
 	KASSERT(ns);
 	f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
 
+	/*
+	 * NVME1.0e 6.11 Identify command
+	 *
+	 * LBADS values smaller than 9 are not supported, a value
+	 * of zero means that the format is not used.
+	 */
+	if (f->lbads < 9) {
+		if (f->lbads > 0)
+			aprint_error_dev(self,
+			"unsupported logical data size %u\n", f->lbads);
+		return;
+	}
+
 	ld->sc_secsize = 1 << f->lbads;
 	ld->sc_secperunit = ns->ident->nsze;
 	ld->sc_maxxfer = naa->naa_maxphys;



CVS commit: [netbsd-9] src/sys/dev/ic

2019-10-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct 23 18:06:46 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: ahcisata_core.c

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #357):

sys/dev/ic/ahcisata_core.c: revision 1.76

Ensure cmdh_prdtl is 0 in ahci_do_reset_drive().
(I'm probably just being paranoid here.)


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.75.4.1 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.75 src/sys/dev/ic/ahcisata_core.c:1.75.4.1
--- src/sys/dev/ic/ahcisata_core.c:1.75	Sun Apr  7 17:46:49 2019
+++ src/sys/dev/ic/ahcisata_core.c	Wed Oct 23 18:06:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.75 2019/04/07 17:46:49 bouyer Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.75.4.1 2019/10/23 18:06:46 martin Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.75 2019/04/07 17:46:49 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.75.4.1 2019/10/23 18:06:46 martin Exp $");
 
 #include 
 #include 
@@ -842,6 +842,7 @@ again:
 	cmd_tbl = achp->ahcic_cmd_tbl[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_prdtl = 0;
 	cmd_h->cmdh_prdbc = 0;
 	memset(cmd_tbl->cmdt_cfis, 0, 64);
 	cmd_tbl->cmdt_cfis[fis_type] = RHD_FISTYPE;



CVS commit: [netbsd-9] src/sys/dev/ic

2019-10-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct 23 18:06:46 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: ahcisata_core.c

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #357):

sys/dev/ic/ahcisata_core.c: revision 1.76

Ensure cmdh_prdtl is 0 in ahci_do_reset_drive().
(I'm probably just being paranoid here.)


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.75.4.1 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.



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 19:13:14 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #248):

sys/dev/ic/nvme.c: revision 1.46

nvme(4): Don't attach the device, if namespace not found.


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.1 -r1.44.2.2 src/sys/dev/ic/nvme.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/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.44.2.1 src/sys/dev/ic/nvme.c:1.44.2.2
--- src/sys/dev/ic/nvme.c:1.44.2.1	Sun Sep 22 12:18:56 2019
+++ src/sys/dev/ic/nvme.c	Thu Sep 26 19:13:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.44.2.1 2019/09/22 12:18:56 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.44.2.2 2019/09/26 19:13:14 martin Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.1 2019/09/22 12:18:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.2 2019/09/26 19:13:14 martin Exp $");
 
 #include 
 #include 
@@ -399,6 +399,10 @@ nvme_attach(struct nvme_softc *sc)
 		aprint_error_dev(sc->sc_dev, "unable to identify controller\n");
 		goto disable;
 	}
+	if (sc->sc_nn == 0) {
+		aprint_error_dev(sc->sc_dev, "namespace not found\n");
+		goto disable;
+	}
 
 	/* we know how big things are now */
 	sc->sc_max_sgl = sc->sc_mdts / sc->sc_mps;



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 19:13:14 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #248):

sys/dev/ic/nvme.c: revision 1.46

nvme(4): Don't attach the device, if namespace not found.


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.1 -r1.44.2.2 src/sys/dev/ic/nvme.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:18:56 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #218):

sys/dev/ic/nvme.c: revision 1.45

Don't set Phase Tag bit of Completion Queue entry at nvme_poll_done().

A new completion queue entry check incorrectly determined that there was
a Completion Queue entry for a command that was not submitted.

Fix PR kern/54275, PR kern/54503, PR kern/54532.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/sys/dev/ic/nvme.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:18:56 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #218):

sys/dev/ic/nvme.c: revision 1.45

Don't set Phase Tag bit of Completion Queue entry at nvme_poll_done().

A new completion queue entry check incorrectly determined that there was
a Completion Queue entry for a command that was not submitted.

Fix PR kern/54275, PR kern/54503, PR kern/54532.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/sys/dev/ic/nvme.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/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.44 src/sys/dev/ic/nvme.c:1.44.2.1
--- src/sys/dev/ic/nvme.c:1.44	Fri Jun 28 15:08:47 2019
+++ src/sys/dev/ic/nvme.c	Sun Sep 22 12:18:56 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.44 2019/06/28 15:08:47 jmcneill Exp $	*/
+/*	$NetBSD: nvme.c,v 1.44.2.1 2019/09/22 12:18:56 martin Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44 2019/06/28 15:08:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.1 2019/09/22 12:18:56 martin Exp $");
 
 #include 
 #include 
@@ -1302,8 +1302,8 @@ nvme_poll_done(struct nvme_queue *q, str
 {
 	struct nvme_poll_state *state = ccb->ccb_cookie;
 
-	SET(cqe->flags, htole16(NVME_CQE_PHASE));
 	state->c = *cqe;
+	SET(state->c.flags, htole16(NVME_CQE_PHASE));
 
 	ccb->ccb_cookie = state->cookie;
 	state->done(q, ccb, >c);



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:13:33 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: i82557.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #217):

sys/dev/ic/i82557.c: revision 1.155

Fix direction of the loop.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.154.2.1 src/sys/dev/ic/i82557.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:13:33 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: i82557.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #217):

sys/dev/ic/i82557.c: revision 1.155

Fix direction of the loop.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.154.2.1 src/sys/dev/ic/i82557.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/i82557.c
diff -u src/sys/dev/ic/i82557.c:1.154 src/sys/dev/ic/i82557.c:1.154.2.1
--- src/sys/dev/ic/i82557.c:1.154	Tue Jul  9 08:46:58 2019
+++ src/sys/dev/ic/i82557.c	Sun Sep 22 12:13:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82557.c,v 1.154 2019/07/09 08:46:58 msaitoh Exp $	*/
+/*	$NetBSD: i82557.c,v 1.154.2.1 2019/09/22 12:13:33 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.154 2019/07/09 08:46:58 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.154.2.1 2019/09/22 12:13:33 martin Exp $");
 
 #include 
 #include 
@@ -1892,7 +1892,7 @@ fxp_init(struct ifnet *ifp)
 	CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->sc_cddma + FXP_CDIASOFF);
 	fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_START);
 	/* ...and wait for it to complete. */
-	for (i = 1000; i > 0; i++) {
+	for (i = 1000; i > 0; i--) {
 		FXP_CDIASSYNC(sc,
 		BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 		status = le16toh(cb_ias->cb_status);