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

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

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

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

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.40.6.4 -r1.40.6.5 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.40.6.4 src/sys/dev/ic/dwc_gmac.c:1.40.6.5
--- src/sys/dev/ic/dwc_gmac.c:1.40.6.4	Mon Jun 18 15:39:49 2018
+++ src/sys/dev/ic/dwc_gmac.c	Fri Aug 12 15:13:45 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.40.6.4 2018/06/18 15:39:49 martin Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.40.6.5 2022/08/12 15:13:45 martin Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.40.6.4 2018/06/18 15:39:49 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.40.6.5 2022/08/12 15:13:45 martin Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -722,7 +722,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-8] src/sys/dev/ic

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

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

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

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.40.6.4 -r1.40.6.5 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-8] src/sys/dev/ic

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

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

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

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.30.2.6 -r1.30.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-8] src/sys/dev/ic

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

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

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

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.30.2.6 -r1.30.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.30.2.6 src/sys/dev/ic/nvme.c:1.30.2.7
--- src/sys/dev/ic/nvme.c:1.30.2.6	Thu Sep 26 18:23:13 2019
+++ src/sys/dev/ic/nvme.c	Mon Nov 11 17:17:22 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.30.2.6 2019/09/26 18:23:13 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.30.2.7 2019/11/11 17:17:22 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.30.2.6 2019/09/26 18:23:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.7 2019/11/11 17:17:22 martin Exp $");
 
 #include 
 #include 
@@ -114,7 +114,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 */
@@ -337,7 +338,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;
@@ -411,13 +412,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);
@@ -1471,20 +1474,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 = 
@@ -1496,13 +1500,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-8] src/sys/dev/ic

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

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

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

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.16.2.3 -r1.16.2.4 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.16.2.3 src/sys/dev/ic/ld_nvme.c:1.16.2.4
--- src/sys/dev/ic/ld_nvme.c:1.16.2.3	Thu Apr 19 15:37:56 2018
+++ src/sys/dev/ic/ld_nvme.c	Mon Oct 28 18:27:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_nvme.c,v 1.16.2.3 2018/04/19 15:37:56 martin Exp $	*/
+/*	$NetBSD: ld_nvme.c,v 1.16.2.4 2019/10/28 18:27:47 martin Exp $	*/
 
 /*-
  * Copyright (C) 2016 NONAKA Kimihiro 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.16.2.3 2018/04/19 15:37:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.16.2.4 2019/10/28 18:27:47 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-8] src/sys/dev/ic

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

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

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

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.16.2.3 -r1.16.2.4 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-8] src/sys/dev/ic

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

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

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

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.30.2.5 -r1.30.2.6 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.30.2.5 src/sys/dev/ic/nvme.c:1.30.2.6
--- src/sys/dev/ic/nvme.c:1.30.2.5	Wed Sep 25 15:49:16 2019
+++ src/sys/dev/ic/nvme.c	Thu Sep 26 18:23:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.30.2.5 2019/09/25 15:49:16 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.30.2.6 2019/09/26 18:23:13 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.30.2.5 2019/09/25 15:49:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.6 2019/09/26 18:23:13 martin Exp $");
 
 #include 
 #include 
@@ -397,6 +397,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-8] src/sys/dev/ic

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

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

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

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.30.2.5 -r1.30.2.6 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-8] src/sys/dev/ic

2019-09-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 25 15:49:17 UTC 2019

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

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

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.30.2.4 -r1.30.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.30.2.4 src/sys/dev/ic/nvme.c:1.30.2.5
--- src/sys/dev/ic/nvme.c:1.30.2.4	Thu Apr 19 15:37:56 2018
+++ src/sys/dev/ic/nvme.c	Wed Sep 25 15:49:16 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.30.2.4 2018/04/19 15:37:56 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.30.2.5 2019/09/25 15:49: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.30.2.4 2018/04/19 15:37:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.5 2019/09/25 15:49:16 martin Exp $");
 
 #include 
 #include 
@@ -1202,8 +1202,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-8] src/sys/dev/ic

2019-09-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 25 15:49:17 UTC 2019

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

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

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.30.2.4 -r1.30.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-8] src/sys/dev/ic

2019-06-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun 30 19:00:10 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-8]: mvsata.c

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

sys/dev/ic/mvsata.c: revision 1.47
sys/dev/ic/mvsata.c: revision 1.48

Fix "mvsata:0:0:1: buffer load failed: error=27" failure.  PR/54205
Ok'ed by jdolecek@.
Should be pulled up to netbsd-8.

Add a missing newline in an error message.  Noticed in PR/54205


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.35.10.1 src/sys/dev/ic/mvsata.c

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



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

2019-06-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun 30 19:00:10 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-8]: mvsata.c

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

sys/dev/ic/mvsata.c: revision 1.47
sys/dev/ic/mvsata.c: revision 1.48

Fix "mvsata:0:0:1: buffer load failed: error=27" failure.  PR/54205
Ok'ed by jdolecek@.
Should be pulled up to netbsd-8.

Add a missing newline in an error message.  Noticed in PR/54205


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.35.10.1 src/sys/dev/ic/mvsata.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/mvsata.c
diff -u src/sys/dev/ic/mvsata.c:1.35 src/sys/dev/ic/mvsata.c:1.35.10.1
--- src/sys/dev/ic/mvsata.c:1.35	Mon May  2 19:18:29 2016
+++ src/sys/dev/ic/mvsata.c	Sun Jun 30 19:00:10 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mvsata.c,v 1.35 2016/05/02 19:18:29 christos Exp $	*/
+/*	$NetBSD: mvsata.c,v 1.35.10.1 2019/06/30 19:00:10 martin Exp $	*/
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.35 2016/05/02 19:18:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.35.10.1 2019/06/30 19:00:10 martin Exp $");
 
 #include "opt_mvsata.h"
 
@@ -103,7 +103,8 @@ int	mvsata_debug = 2;
 	   sending a cmd */
 #define ATAPI_MODE_DELAY	1000	/* 1s, timeout for SET_FEATURE cmds */
 
-#define MVSATA_EPRD_MAX_SIZE	(sizeof(struct eprd) * (MAXPHYS / PAGE_SIZE))
+#define MVSATA_MAX_SEGS		(MAXPHYS / PAGE_SIZE + 1)
+#define MVSATA_EPRD_MAX_SIZE	(sizeof(struct eprd) * MVSATA_MAX_SEGS)
 
 
 static void mvsata_probe_drive(struct ata_channel *);
@@ -2918,7 +2919,7 @@ mvsata_port_init(struct mvsata_hc *mvhc,
 	}
 	for (i = 0; i < MVSATA_EDMAQ_LEN; i++) {
 		rv = bus_dmamap_create(mvport->port_dmat, MAXPHYS,
-		MAXPHYS / PAGE_SIZE, MAXPHYS, 0, BUS_DMA_NOWAIT,
+		MVSATA_MAX_SEGS, MAXPHYS, 0, BUS_DMA_NOWAIT,
 		>port_reqtbl[i].data_dmamap);
 		if (rv != 0) {
 			aprint_error("%s:%d:%d:"
@@ -3125,7 +3126,7 @@ mvsata_dma_bufload(struct mvsata_port *m
 	rv = bus_dmamap_load(mvport->port_dmat, data_dmamap, databuf, datalen,
 	NULL, BUS_DMA_NOWAIT | lop);
 	if (rv) {
-		aprint_error("%s:%d:%d: buffer load failed: error=%d",
+		aprint_error("%s:%d:%d: buffer load failed: error=%d\n",
 		device_xname(MVSATA_DEV2(mvport)), mvport->port_hc->hc,
 		mvport->port, rv);
 		return rv;