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

2024-06-20 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Jun 20 18:41:45 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: change some debug printf() to DPRINTF()


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc64/dev/vdsk.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/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.17 src/sys/arch/sparc64/dev/vdsk.c:1.18
--- src/sys/arch/sparc64/dev/vdsk.c:1.17	Thu Jun 20 17:49:46 2024
+++ src/sys/arch/sparc64/dev/vdsk.c	Thu Jun 20 18:41:45 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.17 2024/06/20 17:49:46 palle Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.18 2024/06/20 18:41:45 palle Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -1098,27 +1098,27 @@ vdsk_scsi_cmd(struct vdsk_softc *sc, str
 			return;
 			
 		case SCSI_MODE_SENSE_6:
-			printf("SCSI_MODE_SENSE_6 (not implemented)\n");
+			DPRINTF(("SCSI_MODE_SENSE_6 (not implemented)\n"));
 			vdsk_scsi_done(xs, XS_DRIVER_STUFFUP);
 			return;
 
 		case SCSI_MODE_SELECT_6:
-			printf("MODE_SELECT_6 (not implemented)\n");
+DPRINTF(("MODE_SELECT_6 (not implemented)\n"));
 			vdsk_scsi_done(xs, XS_DRIVER_STUFFUP);
 			return;
 
 		case SCSI_MAINTENANCE_IN:
-			printf("MAINTENANCE_IN\n");
+			DPRINTF(("MAINTENANCE_IN\n"));
 			vdsk_scsi_done(xs, XS_NOERROR);
 			return;
 
 		case SCSI_MODE_SENSE_10:
-			printf("SCSI_MODE_SENSE_10 (not implemented)\n");
+			DPRINTF(("SCSI_MODE_SENSE_10 (not implemented)\n"));
 			vdsk_scsi_done(xs, XS_DRIVER_STUFFUP);
 			return;
 			
 		case READ_TOC:
-			printf("READ_TOC (not implemented)\n");
+			DPRINTF(("READ_TOC (not implemented)\n"));
 			vdsk_scsi_done(xs, XS_DRIVER_STUFFUP);
 			return;
 



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

2024-06-20 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Jun 20 18:41:45 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: change some debug printf() to DPRINTF()


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc64/dev/vdsk.c

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



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

2024-06-20 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Jun 20 17:49:46 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: add some DPRINTF() to vdsk


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc64/dev/vdsk.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/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.16 src/sys/arch/sparc64/dev/vdsk.c:1.17
--- src/sys/arch/sparc64/dev/vdsk.c:1.16	Wed Jun 19 20:04:20 2024
+++ src/sys/arch/sparc64/dev/vdsk.c	Thu Jun 20 17:49:46 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.16 2024/06/19 20:04:20 palle Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.17 2024/06/20 17:49:46 palle Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -631,7 +631,9 @@ vdsk_rx_vio_attr_info(struct vdsk_softc 
 			}
 
 			sc->sc_vdisk_block_size = ai->vdisk_block_size;
+			DPRINTF(("vdisk_block_size %u\n", sc->sc_vdisk_block_size));
 			sc->sc_vdisk_size = ai->vdisk_size;
+			DPRINTF(("vdisk_size %lu\n", sc->sc_vdisk_size));
 			if (sc->sc_major > 1 || sc->sc_minor >= 1)
 sc->sc_vd_mtype = ai->vd_mtype;
 			else
@@ -846,6 +848,8 @@ vdsk_send_attr_info(struct vdsk_softc *s
 	ai.xfer_mode = VIO_DRING_MODE;
 	ai.vdisk_block_size = DEV_BSIZE;
 	ai.max_xfer_sz = MAXPHYS / DEV_BSIZE;
+	DPRINTF(("vdisk_block_size %u\n", ai.vdisk_block_size));
+	DPRINTF(("max_xfer_sz %lu\n", ai.max_xfer_sz));
 	vdsk_sendmsg(sc, , sizeof(ai));
 
 	sc->sc_vio_state |= VIO_SND_ATTR_INFO;
@@ -1023,42 +1027,98 @@ vdsk_scsi_cmd(struct vdsk_softc *sc, str
 	switch (xs->cmd->opcode) {
 
 		case SCSI_READ_6_COMMAND:
+			DPRINTF(("SCSI_READ_6_COMMAND\n"));
+			break;
+			
 		case READ_10:
+			DPRINTF(("SCSI_READ_10\n"));
+			break;
+			
 		case READ_12:
+			DPRINTF(("SCSI_READ_12\n"));
+			break;
+			
 		case READ_16:
+			DPRINTF(("SCSI_READ_16\n"));
+			break;
+			
 		case SCSI_WRITE_6_COMMAND:
+			DPRINTF(("SCSI_WRITE_6\n"));
+			break;
+			
 		case WRITE_10:
+			DPRINTF(("SCSI_WRITE_10\n"));
+			break;
+			
 		case WRITE_12:
+			DPRINTF(("SCSI_WRITE_12\n"));
+			break;
+			
 		case WRITE_16:
+			DPRINTF(("SCSI_WRITE_16\n"));
+			break;
+			
 		case SCSI_SYNCHRONIZE_CACHE_10:
+			DPRINTF(("SCSI_SYNCHRONIZE_CACHE_10WRITE_16\n"));
 			break;
 
 		case INQUIRY:
+			DPRINTF(("INQUIRY\n"));
 			vdsk_scsi_inq(sc, xs);
 			return;
 
 		case READ_CAPACITY_10:
+			DPRINTF(("READ_CAPACITY_10\n"));
 			vdsk_scsi_capacity(sc, xs);
 			return;
 
 		case READ_CAPACITY_16:
+			DPRINTF(("READ_CAPACITY_16\n"));
 			vdsk_scsi_capacity16(sc, xs);
 			return;
 
 		case SCSI_REPORT_LUNS:
+			DPRINTF(("REPORT_LUNS\n"));
 			vdsk_scsi_report_luns(sc, xs);
 			return;
 
 		case SCSI_TEST_UNIT_READY:
+			DPRINTF(("TEST_UNIT_READY\n"));
+			vdsk_scsi_done(xs, XS_NOERROR);
+			return;
+			
 		case START_STOP:
+			DPRINTF(("START_STOP\n"));
+			vdsk_scsi_done(xs, XS_NOERROR);
+			return;
+			
 		case SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL:
+			DPRINTF(("PREVENT_ALLOW_MEDIUM_REMOVAL\n"));
+			vdsk_scsi_done(xs, XS_NOERROR);
+			return;
+			
 		case SCSI_MODE_SENSE_6:
+			printf("SCSI_MODE_SENSE_6 (not implemented)\n");
+			vdsk_scsi_done(xs, XS_DRIVER_STUFFUP);
+			return;
+
+		case SCSI_MODE_SELECT_6:
+			printf("MODE_SELECT_6 (not implemented)\n");
+			vdsk_scsi_done(xs, XS_DRIVER_STUFFUP);
+			return;
+
 		case SCSI_MAINTENANCE_IN:
+			printf("MAINTENANCE_IN\n");
 			vdsk_scsi_done(xs, XS_NOERROR);
 			return;
 
 		case SCSI_MODE_SENSE_10:
+			printf("SCSI_MODE_SENSE_10 (not implemented)\n");
+			vdsk_scsi_done(xs, XS_DRIVER_STUFFUP);
+			return;
+			
 		case READ_TOC:
+			printf("READ_TOC (not implemented)\n");
 			vdsk_scsi_done(xs, XS_DRIVER_STUFFUP);
 			return;
 
@@ -1113,6 +1173,7 @@ vdsk_submit_cmd(struct vdsk_softc *sc, s
 		case READ_10:
 		case READ_12:
 		case READ_16:
+			DPRINTF(("VD_OP_BREAD\n"));
 			operation = VD_OP_BREAD;
 			break;
 
@@ -1120,10 +1181,12 @@ vdsk_submit_cmd(struct vdsk_softc *sc, s
 		case WRITE_10:
 		case WRITE_12:
 		case WRITE_16:
+			DPRINTF(("VD_OP_BWRITE\n"));
 			operation = VD_OP_BWRITE;
 			break;
 
 		case SCSI_SYNCHRONIZE_CACHE_10:
+			DPRINTF(("VD_OP_FLUSH\n"));
 			operation = VD_OP_FLUSH;
 			break;
 
@@ -1157,7 +1220,7 @@ vdsk_submit_cmd(struct vdsk_softc *sc, s
 	len = xs->datalen;
 	va = (vaddr_t)xs->data;
 	while (len > 0) {
-	  DPRINTF(("len = %u\n", len));
+		DPRINTF(("len = %u\n", len));
 		KASSERT(ncookies < MAXPHYS / PAGE_SIZE);
 		pa = 0;
 		pmap_extract(pmap_kernel(), va, );



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

2024-06-20 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Jun 20 17:49:46 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: add some DPRINTF() to vdsk


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc64/dev/vdsk.c

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



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

2024-06-19 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Wed Jun 19 20:04:20 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: revert two new functions introduced in rev. 1.13 - not necessary yet


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sparc64/dev/vdsk.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/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.15 src/sys/arch/sparc64/dev/vdsk.c:1.16
--- src/sys/arch/sparc64/dev/vdsk.c:1.15	Wed Jun 19 20:00:10 2024
+++ src/sys/arch/sparc64/dev/vdsk.c	Wed Jun 19 20:04:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.15 2024/06/19 20:00:10 palle Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.16 2024/06/19 20:04:20 palle Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -219,8 +219,6 @@ void	vdsk_scsi_inquiry(struct vdsk_softc
 void	vdsk_scsi_capacity(struct vdsk_softc *sc, struct scsipi_xfer *);
 void	vdsk_scsi_capacity16(struct vdsk_softc *sc, struct scsipi_xfer *);
 void	vdsk_scsi_report_luns(struct vdsk_softc *sc, struct scsipi_xfer *);
-void	vdsk_scsi_read_discinfo(struct vdsk_softc *sc, struct scsipi_xfer *);
-void	vdsk_scsi_read_trackinfo(struct vdsk_softc *sc, struct scsipi_xfer *);
 void	vdsk_scsi_done(struct scsipi_xfer *, int);
 
 int
@@ -1051,14 +1049,6 @@ vdsk_scsi_cmd(struct vdsk_softc *sc, str
 			vdsk_scsi_report_luns(sc, xs);
 			return;
 
-		case READ_DISCINFO:
-			vdsk_scsi_read_discinfo(sc, xs);
-			return;
-
-		case READ_TRACKINFO:
-			vdsk_scsi_read_trackinfo(sc, xs);
-			return;
-
 		case SCSI_TEST_UNIT_READY:
 		case START_STOP:
 		case SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL:
@@ -1350,32 +1340,6 @@ vdsk_scsi_report_luns(struct vdsk_softc 
 }
 
 void
-vdsk_scsi_read_discinfo(struct vdsk_softc *sc, struct scsipi_xfer *xs)
-{
-	DPRINTF(("%s()\n", __FUNCTION__));
-
-	struct scsipi_read_discinfo_data read_discinfo_data;
-	bzero(_discinfo_data, sizeof(read_discinfo_data));
-
-	bcopy(_discinfo_data, xs->data, MIN(sizeof(read_discinfo_data), xs->datalen));
-
-	vdsk_scsi_done(xs, XS_NOERROR);
-}
-
-void
-vdsk_scsi_read_trackinfo(struct vdsk_softc *sc, struct scsipi_xfer *xs)
-{
-	DPRINTF(("%s()\n", __FUNCTION__));
-
-	struct scsipi_read_trackinfo_data read_trackinfo_data;
-	bzero(_trackinfo_data, sizeof(read_trackinfo_data));
-
-	bcopy(_trackinfo_data, xs->data, MIN(sizeof(read_trackinfo_data), xs->datalen));
-
-	vdsk_scsi_done(xs, XS_NOERROR);
-}
-
-void
 vdsk_scsi_done(struct scsipi_xfer *xs, int error)
 {
 	xs->error = error;



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

2024-06-19 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Wed Jun 19 20:04:20 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: revert two new functions introduced in rev. 1.13 - not necessary yet


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sparc64/dev/vdsk.c

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



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

2024-06-19 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Wed Jun 19 20:00:10 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: fix incorrect string length (product name Virtual CDROM)


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/dev/vdsk.c

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



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

2024-06-19 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Wed Jun 19 20:00:10 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: fix incorrect string length (product name Virtual CDROM)


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/dev/vdsk.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/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.14 src/sys/arch/sparc64/dev/vdsk.c:1.15
--- src/sys/arch/sparc64/dev/vdsk.c:1.14	Wed Jun 12 19:12:44 2024
+++ src/sys/arch/sparc64/dev/vdsk.c	Wed Jun 19 20:00:10 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.14 2024/06/12 19:12:44 riastradh Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.15 2024/06/19 20:00:10 palle Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -1277,7 +1277,7 @@ vdsk_scsi_inquiry(struct vdsk_softc *sc,
 		case VD_MEDIA_TYPE_DVD:
 			inq.device = T_CDROM;
 			inq.dev_qual2 = SID_REMOVABLE;
-			bcopy("Virtual CDROM", inq.product, sizeof(inq.product));
+			bcopy("Virtual CDROM   ", inq.product, sizeof(inq.product));
 			break;
 		case VD_MEDIA_TYPE_FIXED:
 			inq.device = T_DIRECT;



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

2024-06-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jun 12 19:12:44 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
arch/sparc64/dev/dsk.c: Nix trailing whitespace.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/dev/vdsk.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/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.13 src/sys/arch/sparc64/dev/vdsk.c:1.14
--- src/sys/arch/sparc64/dev/vdsk.c:1.13	Mon Jun 10 19:54:24 2024
+++ src/sys/arch/sparc64/dev/vdsk.c	Wed Jun 12 19:12:44 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.13 2024/06/10 19:54:24 palle Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.14 2024/06/12 19:12:44 riastradh Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -139,7 +139,7 @@ struct vdsk_softc {
 
 	struct scsipi_adapter sc_adapter;
 	struct scsipi_channel sc_channel;
-  
+
 	bus_space_tag_t	sc_bustag;
 	bus_dma_tag_t	sc_dmatag;
 
@@ -248,7 +248,7 @@ vdsk_attach(device_t parent, device_t se
 	sc->sc_bustag = ca->ca_bustag;
 	sc->sc_dmatag = ca->ca_dmatag;
 
-	printf(": ivec 0x%llx, 0x%llx", 
+	printf(": ivec 0x%llx, 0x%llx",
 	   (long long unsigned int)ca->ca_tx_ino,
 	   (long long unsigned int)ca->ca_rx_ino);
 
@@ -331,7 +331,7 @@ vdsk_attach(device_t parent, device_t se
 	if (pmap_extract(pmap_kernel(), va, ) == FALSE)
 		panic("pmap_extract failed %lx\n", va);
 #if OPENBSD_BUSDMA
-	err = hv_ldc_tx_qconf(lc->lc_id, 
+	err = hv_ldc_tx_qconf(lc->lc_id,
 	lc->lc_txq->lq_map->dm_segs[0].ds_addr, lc->lc_txq->lq_nentries);
 #else
 err = hv_ldc_tx_qconf(lc->lc_id, pa, lc->lc_txq->lq_nentries);
@@ -423,10 +423,10 @@ vdsk_scsipi_request(struct scsipi_channe
 	switch (req) {
 		case ADAPTER_REQ_RUN_XFER:
 			vdsk_scsi_cmd(sc, xs);
-			break;  
+			break;
 		case ADAPTER_REQ_GROW_RESOURCES:
-		case ADAPTER_REQ_SET_XFER_MODE: 
-			/* Ignored */  
+		case ADAPTER_REQ_SET_XFER_MODE:
+			/* Ignored */
 			break;
 		default:
 			panic("req unhandled: %x", req);
@@ -1050,7 +1050,7 @@ vdsk_scsi_cmd(struct vdsk_softc *sc, str
 		case SCSI_REPORT_LUNS:
 			vdsk_scsi_report_luns(sc, xs);
 			return;
-			
+
 		case READ_DISCINFO:
 			vdsk_scsi_read_discinfo(sc, xs);
 			return;
@@ -1058,7 +1058,7 @@ vdsk_scsi_cmd(struct vdsk_softc *sc, str
 		case READ_TRACKINFO:
 			vdsk_scsi_read_trackinfo(sc, xs);
 			return;
-			
+
 		case SCSI_TEST_UNIT_READY:
 		case START_STOP:
 		case SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL:
@@ -1073,7 +1073,7 @@ vdsk_scsi_cmd(struct vdsk_softc *sc, str
 			return;
 
 		default:
-			panic("%s unhandled cmd 0x%02x\n", 
+			panic("%s unhandled cmd 0x%02x\n",
 			  __func__, xs->cmd->opcode);
 	}
 
@@ -1138,7 +1138,7 @@ vdsk_submit_cmd(struct vdsk_softc *sc, s
 			break;
 
 		default:
-			panic("%s  unhandled cmd opcode 0x%x", 
+			panic("%s  unhandled cmd opcode 0x%x",
 			  __func__, xs->cmd->opcode);
 	}
 
@@ -1246,8 +1246,8 @@ vdsk_complete_cmd(struct vdsk_softc *sc,
 	xs->resid = xs->datalen -
 		sc->sc_vd->vd_desc[desc].size;
 
-	/* 
-	 * scsi_done() called by vdsk_scsi_done() requires 
+	/*
+	 * scsi_done() called by vdsk_scsi_done() requires
 	 * the kernel to be locked
 	 */
 	KERNEL_LOCK(1, curlwp);
@@ -1358,7 +1358,7 @@ vdsk_scsi_read_discinfo(struct vdsk_soft
 	bzero(_discinfo_data, sizeof(read_discinfo_data));
 
 	bcopy(_discinfo_data, xs->data, MIN(sizeof(read_discinfo_data), xs->datalen));
-	
+
 	vdsk_scsi_done(xs, XS_NOERROR);
 }
 
@@ -1371,7 +1371,7 @@ vdsk_scsi_read_trackinfo(struct vdsk_sof
 	bzero(_trackinfo_data, sizeof(read_trackinfo_data));
 
 	bcopy(_trackinfo_data, xs->data, MIN(sizeof(read_trackinfo_data), xs->datalen));
-	
+
 	vdsk_scsi_done(xs, XS_NOERROR);
 }
 



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

2024-06-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jun 12 19:12:44 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
arch/sparc64/dev/dsk.c: Nix trailing whitespace.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/dev/vdsk.c

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



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

2024-06-10 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Jun 10 19:54:24 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: add incomplete implementation of the CD-specific READ_DISCINFO and 
READ_TRACKINFO - probably needs some more work though...


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc64/dev/vdsk.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/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.12 src/sys/arch/sparc64/dev/vdsk.c:1.13
--- src/sys/arch/sparc64/dev/vdsk.c:1.12	Sun Jun  9 19:13:54 2024
+++ src/sys/arch/sparc64/dev/vdsk.c	Mon Jun 10 19:54:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.12 2024/06/09 19:13:54 palle Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.13 2024/06/10 19:54:24 palle Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -219,6 +219,8 @@ void	vdsk_scsi_inquiry(struct vdsk_softc
 void	vdsk_scsi_capacity(struct vdsk_softc *sc, struct scsipi_xfer *);
 void	vdsk_scsi_capacity16(struct vdsk_softc *sc, struct scsipi_xfer *);
 void	vdsk_scsi_report_luns(struct vdsk_softc *sc, struct scsipi_xfer *);
+void	vdsk_scsi_read_discinfo(struct vdsk_softc *sc, struct scsipi_xfer *);
+void	vdsk_scsi_read_trackinfo(struct vdsk_softc *sc, struct scsipi_xfer *);
 void	vdsk_scsi_done(struct scsipi_xfer *, int);
 
 int
@@ -1049,6 +1051,14 @@ vdsk_scsi_cmd(struct vdsk_softc *sc, str
 			vdsk_scsi_report_luns(sc, xs);
 			return;
 			
+		case READ_DISCINFO:
+			vdsk_scsi_read_discinfo(sc, xs);
+			return;
+
+		case READ_TRACKINFO:
+			vdsk_scsi_read_trackinfo(sc, xs);
+			return;
+			
 		case SCSI_TEST_UNIT_READY:
 		case START_STOP:
 		case SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL:
@@ -1340,6 +1350,32 @@ vdsk_scsi_report_luns(struct vdsk_softc 
 }
 
 void
+vdsk_scsi_read_discinfo(struct vdsk_softc *sc, struct scsipi_xfer *xs)
+{
+	DPRINTF(("%s()\n", __FUNCTION__));
+
+	struct scsipi_read_discinfo_data read_discinfo_data;
+	bzero(_discinfo_data, sizeof(read_discinfo_data));
+
+	bcopy(_discinfo_data, xs->data, MIN(sizeof(read_discinfo_data), xs->datalen));
+	
+	vdsk_scsi_done(xs, XS_NOERROR);
+}
+
+void
+vdsk_scsi_read_trackinfo(struct vdsk_softc *sc, struct scsipi_xfer *xs)
+{
+	DPRINTF(("%s()\n", __FUNCTION__));
+
+	struct scsipi_read_trackinfo_data read_trackinfo_data;
+	bzero(_trackinfo_data, sizeof(read_trackinfo_data));
+
+	bcopy(_trackinfo_data, xs->data, MIN(sizeof(read_trackinfo_data), xs->datalen));
+	
+	vdsk_scsi_done(xs, XS_NOERROR);
+}
+
+void
 vdsk_scsi_done(struct scsipi_xfer *xs, int error)
 {
 	xs->error = error;



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

2024-06-10 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Jun 10 19:54:24 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: add incomplete implementation of the CD-specific READ_DISCINFO and 
READ_TRACKINFO - probably needs some more work though...


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc64/dev/vdsk.c

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



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

2024-06-09 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Jun  9 19:13:54 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: fix vdsk so an iso image exported by the ldom virtual disk service is 
correctly detected as a cd device + some whitespace fixes


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/dev/vdsk.c

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



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

2024-06-09 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Jun  9 19:13:54 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: fix vdsk so an iso image exported by the ldom virtual disk service is 
correctly detected as a cd device + some whitespace fixes


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/dev/vdsk.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/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.11 src/sys/arch/sparc64/dev/vdsk.c:1.12
--- src/sys/arch/sparc64/dev/vdsk.c:1.11	Tue Dec 12 21:34:34 2023
+++ src/sys/arch/sparc64/dev/vdsk.c	Sun Jun  9 19:13:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.11 2023/12/12 21:34:34 andvar Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.12 2024/06/09 19:13:54 palle Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -788,7 +788,6 @@ vdsk_rx_vio_dring_data(struct vdsk_softc
 void
 vdsk_ldc_reset(struct ldc_conn *lc)
 {
-
 	struct vdsk_softc *sc = lc->lc_sc;
 
 	sc->sc_vio_state = 0;
@@ -797,7 +796,6 @@ vdsk_ldc_reset(struct ldc_conn *lc)
 void
 vdsk_ldc_start(struct ldc_conn *lc)
 {
-
 	struct vdsk_softc *sc = lc->lc_sc;
 
 	vdsk_send_ver_info(sc, VDSK_MAJOR, VDSK_MINOR);
@@ -806,7 +804,6 @@ vdsk_ldc_start(struct ldc_conn *lc)
 void
 vdsk_sendmsg(struct vdsk_softc *sc, void *msg, size_t len)
 {
-
 	struct ldc_conn *lc = >sc_lc;
 	int err;
 
@@ -818,7 +815,6 @@ vdsk_sendmsg(struct vdsk_softc *sc, void
 void
 vdsk_send_ver_info(struct vdsk_softc *sc, uint16_t major, uint16_t minor)
 {
-
 	struct vio_ver_info vi;
 
 	/* Allocate new session ID. */
@@ -1255,14 +1251,12 @@ vdsk_complete_cmd(struct vdsk_softc *sc,
 void
 vdsk_scsi_inq(struct vdsk_softc *sc, struct scsipi_xfer *xs)
 {
-
 	vdsk_scsi_inquiry(sc, xs);
 }
 
 void
 vdsk_scsi_inquiry(struct vdsk_softc *sc, struct scsipi_xfer *xs)
 {
-
 	struct scsipi_inquiry_data inq;
 	char buf[5];
 
@@ -1272,20 +1266,21 @@ vdsk_scsi_inquiry(struct vdsk_softc *sc,
 		case VD_MEDIA_TYPE_CD:
 		case VD_MEDIA_TYPE_DVD:
 			inq.device = T_CDROM;
+			inq.dev_qual2 = SID_REMOVABLE;
+			bcopy("Virtual CDROM", inq.product, sizeof(inq.product));
 			break;
-
 		case VD_MEDIA_TYPE_FIXED:
-		default:
 			inq.device = T_DIRECT;
+			bcopy("Virtual Disk", inq.product, sizeof(inq.product));
 			break;
+		default:
+			panic("Unhandled media type %d\n", sc->sc_vd_mtype);
 	}
-
 	inq.version = 0x05; /* SPC-3 */
 	inq.response_format = 2;
 	inq.additional_length = 32;
 	inq.flags3 |= SID_CmdQue;
 	bcopy("SUN ", inq.vendor, sizeof(inq.vendor));
-	bcopy("Virtual Disk", inq.product, sizeof(inq.product));
 	snprintf(buf, sizeof(buf), "%u.%u ", sc->sc_major, sc->sc_minor);
 	bcopy(buf, inq.revision, sizeof(inq.revision));
 
@@ -1297,7 +1292,6 @@ vdsk_scsi_inquiry(struct vdsk_softc *sc,
 void
 vdsk_scsi_capacity(struct vdsk_softc *sc, struct scsipi_xfer *xs)
 {
-
 	struct scsipi_read_capacity_10_data rcd;
 	uint64_t capacity;
 
@@ -1321,7 +1315,6 @@ vdsk_scsi_capacity(struct vdsk_softc *sc
 void
 vdsk_scsi_capacity16(struct vdsk_softc *sc, struct scsipi_xfer *xs)
 {
-
 	struct scsipi_read_capacity_16_data rcd;
 	uint64_t capacity;
 
@@ -1349,7 +1342,6 @@ vdsk_scsi_report_luns(struct vdsk_softc 
 void
 vdsk_scsi_done(struct scsipi_xfer *xs, int error)
 {
-
 	xs->error = error;
 
 	scsipi_done(xs);



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

2023-12-13 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed Dec 13 22:53:04 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
Make NBPFILTER build by adopting NetBSD's bpf_mtap() interface and definitions.
Condition is also not needed, since this check is performed inside function.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc64/dev/vnet.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/sparc64/dev/vnet.c
diff -u src/sys/arch/sparc64/dev/vnet.c:1.7 src/sys/arch/sparc64/dev/vnet.c:1.8
--- src/sys/arch/sparc64/dev/vnet.c:1.7	Sun Sep 18 13:31:08 2022
+++ src/sys/arch/sparc64/dev/vnet.c	Wed Dec 13 22:53:04 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnet.c,v 1.7 2022/09/18 13:31:08 thorpej Exp $	*/
+/*	$NetBSD: vnet.c,v 1.8 2023/12/13 22:53:04 andvar Exp $	*/
 /*	$OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $	*/
 /*
  * Copyright (c) 2009, 2015 Mark Kettenis
@@ -1206,12 +1206,9 @@ vnet_start(struct ifnet *ifp)
 		 * If BPF is listening on this interface, let it see the
 		 * packet before we commit it to the wire.
 		 */
-		if (ifp->if_bpf)
-		{
-			DPRINTF(("%s: before bpf\n", __func__));
-			bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT);
-			DPRINTF(("%s: after bpf\n", __func__));
-		}
+		DPRINTF(("%s: before bpf\n", __func__));
+		bpf_mtap(ifp, m, BPF_D_OUT);
+		DPRINTF(("%s: after bpf\n", __func__));
 #endif
 
 		pmap_extract(pmap_kernel(), (vaddr_t)buf, );
@@ -1286,8 +1283,7 @@ vnet_start_desc(struct ifnet *ifp)
 		 * If BPF is listening on this interface, let it see the
 		 * packet before we commit it to the wire.
 		 */
-		if (ifp->if_bpf)
-			bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT);
+		bpf_mtap(ifp, m, BPF_D_OUT);
 #endif
 
 		pmap_extract(pmap_kernel(), (vaddr_t)buf, );



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

2023-12-13 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed Dec 13 22:53:04 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
Make NBPFILTER build by adopting NetBSD's bpf_mtap() interface and definitions.
Condition is also not needed, since this check is performed inside function.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc64/dev/vnet.c

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



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

2023-12-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec 12 21:34:34 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
extract capacity variable to make VDSK_DEBUG enabled code build.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/dev/vdsk.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/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.10 src/sys/arch/sparc64/dev/vdsk.c:1.11
--- src/sys/arch/sparc64/dev/vdsk.c:1.10	Mon May 16 17:13:28 2022
+++ src/sys/arch/sparc64/dev/vdsk.c	Tue Dec 12 21:34:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.10 2022/05/16 17:13:28 palle Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.11 2023/12/12 21:34:34 andvar Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -1323,10 +1323,13 @@ vdsk_scsi_capacity16(struct vdsk_softc *
 {
 
 	struct scsipi_read_capacity_16_data rcd;
+	uint64_t capacity;
 
 	bzero(, sizeof(rcd));
 
-	_lto8b(sc->sc_vdisk_size - 1, rcd.addr);
+	capacity = sc->sc_vdisk_size - 1;
+
+	_lto8b(capacity, rcd.addr);
 	_lto4b(sc->sc_vdisk_block_size, rcd.length);
 
 	DPRINTF(("%s() capacity %lu  block size %u\n",



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

2023-12-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec 12 21:34:34 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
extract capacity variable to make VDSK_DEBUG enabled code build.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/dev/vdsk.c

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



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

2023-12-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Dec  8 17:19:11 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: iommu.c

Log Message:
Change one vmem_free() in an error path that should be vmem_xfree().


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/sparc64/dev/iommu.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/sparc64/dev/iommu.c
diff -u src/sys/arch/sparc64/dev/iommu.c:1.117 src/sys/arch/sparc64/dev/iommu.c:1.118
--- src/sys/arch/sparc64/dev/iommu.c:1.117	Fri Dec  1 06:47:59 2023
+++ src/sys/arch/sparc64/dev/iommu.c	Fri Dec  8 17:19:11 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommu.c,v 1.117 2023/12/01 06:47:59 thorpej Exp $	*/
+/*	$NetBSD: iommu.c,v 1.118 2023/12/08 17:19:11 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.117 2023/12/01 06:47:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.118 2023/12/08 17:19:11 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -1073,7 +1073,7 @@ iommu_dvmamap_load_raw(bus_dma_tag_t t, 
 	return (0);
 
 fail:
-	vmem_free(is->is_dvmamap, map->_dm_dvmastart, sgsize);
+	vmem_xfree(is->is_dvmamap, map->_dm_dvmastart, sgsize);
 	map->_dm_dvmastart = 0;
 	map->_dm_dvmasize = 0;
 	return (EFBIG);



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

2023-12-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Dec  8 17:19:11 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: iommu.c

Log Message:
Change one vmem_free() in an error path that should be vmem_xfree().


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/sparc64/dev/iommu.c

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



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

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 21:02:53 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: sbus.c

Log Message:
Use vmem_xalloc_addr() to reserve the first Sbus DVMA page.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/sparc64/dev/sbus.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/sparc64/dev/sbus.c
diff -u src/sys/arch/sparc64/dev/sbus.c:1.105 src/sys/arch/sparc64/dev/sbus.c:1.106
--- src/sys/arch/sparc64/dev/sbus.c:1.105	Fri Dec  1 06:47:59 2023
+++ src/sys/arch/sparc64/dev/sbus.c	Sat Dec  2 21:02:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sbus.c,v 1.105 2023/12/01 06:47:59 thorpej Exp $ */
+/*	$NetBSD: sbus.c,v 1.106 2023/12/02 21:02:53 thorpej Exp $ */
 
 /*
  * Copyright (c) 1999-2002 Eduardo Horvath
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.105 2023/12/01 06:47:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.106 2023/12/02 21:02:53 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -268,19 +268,9 @@ sbus_attach(device_t parent, device_t se
 	 * NULL DMA pointer will be translated by the first page of the IOTSB.
 	 * To avoid bugs we'll alloc and ignore the first entry in the IOTSB.
 	 */
-	{
-		vmem_addr_t dummy;
-
-		if (vmem_xalloc(sc->sc_is.is_dvmamap, PAGE_SIZE,
-0,		/* alignment */
-0,		/* phase */
-0,		/* nocross */
-sc->sc_is.is_dvmabase,
-sc->sc_is.is_dvmabase + PAGE_SIZE - 1,
-VM_BESTFIT | VM_NOSLEEP,
-) != 0) {
-			panic("sbus iommu: can't toss first dvma page");
-		}
+	if (vmem_xalloc_addr(sc->sc_is.is_dvmamap, sc->sc_is.is_dvmabase,
+			PAGE_SIZE, VM_NOSLEEP) != 0) {
+		panic("sbus iommu: can't toss first dvma page");
 	}
 
 	/*



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

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec  2 21:02:53 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: sbus.c

Log Message:
Use vmem_xalloc_addr() to reserve the first Sbus DVMA page.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/sparc64/dev/sbus.c

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



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

2023-11-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Dec  1 06:47:59 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: iommu.c iommuvar.h sbus.c

Log Message:
Use vmem(9) rather than extent(9) to manage DVMA mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/sparc64/dev/iommu.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sparc64/dev/iommuvar.h
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/sparc64/dev/sbus.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/sparc64/dev/iommu.c
diff -u src/sys/arch/sparc64/dev/iommu.c:1.116 src/sys/arch/sparc64/dev/iommu.c:1.117
--- src/sys/arch/sparc64/dev/iommu.c:1.116	Mon Apr 26 07:18:01 2021
+++ src/sys/arch/sparc64/dev/iommu.c	Fri Dec  1 06:47:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommu.c,v 1.116 2021/04/26 07:18:01 mrg Exp $	*/
+/*	$NetBSD: iommu.c,v 1.117 2023/12/01 06:47:59 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.116 2021/04/26 07:18:01 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.117 2023/12/01 06:47:59 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -212,13 +212,17 @@ iommu_init(char *name, struct iommu_stat
 	aprint_debug("IOTSB: %llx to %llx\n",
 		(unsigned long long)is->is_ptsb,
 		(unsigned long long)(is->is_ptsb + size - 1));
-	is->is_dvmamap = extent_create(name,
-	is->is_dvmabase, is->is_dvmaend,
-	0, 0, EX_NOWAIT);
-	if (!is->is_dvmamap)
-		panic("iommu_init: extent_create() failed");
-	  
-	mutex_init(>is_lock, MUTEX_DEFAULT, IPL_HIGH);
+	is->is_dvmamap = vmem_create(name,
+ is->is_dvmabase,
+ (is->is_dvmaend + 1) - is->is_dvmabase,
+ PAGE_SIZE,		/* quantum */
+ NULL,		/* importfn */
+ NULL,		/* releasefn */
+ NULL,		/* source */
+ 0,			/* qcache_max */
+ VM_SLEEP,
+ IPL_VM);
+	KASSERT(is->is_dvmamap != NULL);
 
 	/*
 	 * Set the TSB size.  The relevant bits were moved to the TSB
@@ -554,7 +558,8 @@ iommu_dvmamap_load(bus_dma_tag_t t, bus_
 	int err, needsflush;
 	bus_size_t sgsize;
 	paddr_t curaddr;
-	u_long dvmaddr, sgstart, sgend, bmask;
+	u_long sgstart, sgend, bmask;
+	vmem_addr_t dvmaddr;
 	bus_size_t align, boundary, len;
 	vaddr_t vaddr = (vaddr_t)buf;
 	int seg;
@@ -596,12 +601,15 @@ iommu_dvmamap_load(bus_dma_tag_t t, bus_
 	 * If our segment size is larger than the boundary we need to
 	 * split the transfer up int little pieces ourselves.
 	 */
-	KASSERT(is->is_dvmamap);
-	mutex_enter(>is_lock);
-	err = extent_alloc(is->is_dvmamap, sgsize, align,
-	(sgsize > boundary) ? 0 : boundary,
-	EX_NOWAIT|EX_BOUNDZERO, );
-	mutex_exit(>is_lock);
+	KASSERT(is->is_dvmamap != NULL);
+	err = vmem_xalloc(is->is_dvmamap, sgsize,
+			  align,		/* alignment */
+			  0,			/* phase */
+			  (sgsize > boundary) ? 0 : boundary,
+			  VMEM_ADDR_MIN,	/* minaddr */
+			  VMEM_ADDR_MAX,	/* maxaddr */
+			  VM_NOSLEEP | VM_BESTFIT,
+			  );
 
 #ifdef DEBUG
 	if (err || (dvmaddr == (u_long)-1)) {
@@ -649,15 +657,9 @@ iommu_dvmamap_load(bus_dma_tag_t t, bus_
 			/* Too many segments.  Fail the operation. */
 			DPRINTF(IDB_INFO, ("iommu_dvmamap_load: "
 			"too many segments %d\n", seg));
-			mutex_enter(>is_lock);
-			err = extent_free(is->is_dvmamap,
-			dvmaddr, sgsize, EX_NOWAIT);
+			vmem_xfree(is->is_dvmamap, dvmaddr, sgsize);
 			map->_dm_dvmastart = 0;
 			map->_dm_dvmasize = 0;
-			mutex_exit(>is_lock);
-			if (err != 0)
-printf("warning: %s: %" PRId64
-" of DVMA space lost\n", __func__, sgsize);
 			return (EFBIG);
 		}
 		sgstart += len;
@@ -741,8 +743,6 @@ iommu_dvmamap_unload(bus_dma_tag_t t, bu
 {
 	struct strbuf_ctl *sb = (struct strbuf_ctl *)map->_dm_cookie;
 	struct iommu_state *is = sb->sb_is;
-	int error;
-	bus_size_t sgsize = map->_dm_dvmasize;
 
 	/* Flush the iommu */
 	if (!map->_dm_dvmastart)
@@ -763,15 +763,9 @@ iommu_dvmamap_unload(bus_dma_tag_t t, bu
 		bus_dmamap_unload(t->_parent, map);
 	}
 
-	mutex_enter(>is_lock);
-	error = extent_free(is->is_dvmamap, map->_dm_dvmastart,
-		map->_dm_dvmasize, EX_NOWAIT);
+	vmem_xfree(is->is_dvmamap, map->_dm_dvmastart, map->_dm_dvmasize);
 	map->_dm_dvmastart = 0;
 	map->_dm_dvmasize = 0;
-	mutex_exit(>is_lock);
-	if (error != 0)
-		printf("warning: %s: %" PRId64 " of DVMA space lost\n",
-		__func__, sgsize);
 
 	/* Clear the map */
 }
@@ -833,17 +827,21 @@ iommu_dvmamap_load_raw(bus_dma_tag_t t, 
 	}
 	sgsize = round_page(sgsize);
 
-	mutex_enter(>is_lock);
 	/*
 	 * If our segment size is larger than the boundary we need to
 	 * split the transfer up into little pieces ourselves.
 	 */
-	err = extent_alloc(is->is_dvmamap, sgsize, align,
-		(sgsize > boundary) ? 0 : boundary,
-		((flags & BUS_DMA_NOWAIT) == 0 ? EX_WAITOK : EX_NOWAIT) |
-		EX_BOUNDZERO, );
-	mutex_exit(>is_lock);
+	const vm_flag_t vmflags = VM_BESTFIT |
+	((flags & 

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

2023-11-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Dec  1 06:47:59 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: iommu.c iommuvar.h sbus.c

Log Message:
Use vmem(9) rather than extent(9) to manage DVMA mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/sparc64/dev/iommu.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sparc64/dev/iommuvar.h
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/sparc64/dev/sbus.c

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



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

2022-10-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Oct 26 23:59:56 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: zs.c

Log Message:
sparc64/zs(4): Convert to ttylock/ttyunlock.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/sparc64/dev/zs.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/sparc64/dev/zs.c
diff -u src/sys/arch/sparc64/dev/zs.c:1.79 src/sys/arch/sparc64/dev/zs.c:1.80
--- src/sys/arch/sparc64/dev/zs.c:1.79	Wed Oct 26 23:38:08 2022
+++ src/sys/arch/sparc64/dev/zs.c	Wed Oct 26 23:59:56 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: zs.c,v 1.79 2022/10/26 23:38:08 riastradh Exp $	*/
+/*	$NetBSD: zs.c,v 1.80 2022/10/26 23:59:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.79 2022/10/26 23:38:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.80 2022/10/26 23:59:56 riastradh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -541,8 +541,8 @@ zssoft(void *arg)
 	struct zsc_softc *zsc = arg;
 
 #if 0 /* not yet */
-	/* Make sure we call the tty layer with tty_lock held. */
-	mutex_spin_enter(_lock);
+	/* Make sure we call the tty layer with ttylock held. */
+	ttylock(tp);
 #endif
 	(void)zsc_intr_soft(zsc);
 #ifdef TTY_DEBUG
@@ -558,7 +558,7 @@ zssoft(void *arg)
 	}
 #endif
 #if 0 /* not yet */
-	mutex_spin_exit(_lock);
+	ttyunlock(tp);
 #endif
 }
 



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

2022-10-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Oct 26 23:59:56 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: zs.c

Log Message:
sparc64/zs(4): Convert to ttylock/ttyunlock.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/sparc64/dev/zs.c

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



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

2022-10-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Oct 26 23:59:36 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: sab.c

Log Message:
sparc64/sab(4): Convert to ttylock/ttyunlock.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/sparc64/dev/sab.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/sparc64/dev/sab.c
diff -u src/sys/arch/sparc64/dev/sab.c:1.57 src/sys/arch/sparc64/dev/sab.c:1.58
--- src/sys/arch/sparc64/dev/sab.c:1.57	Sat Aug  7 16:19:05 2021
+++ src/sys/arch/sparc64/dev/sab.c	Wed Oct 26 23:59:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sab.c,v 1.57 2021/08/07 16:19:05 thorpej Exp $	*/
+/*	$NetBSD: sab.c,v 1.58 2022/10/26 23:59:36 riastradh Exp $	*/
 /*	$OpenBSD: sab.c,v 1.7 2002/04/08 17:49:42 jason Exp $	*/
 
 /*
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sab.c,v 1.57 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sab.c,v 1.58 2022/10/26 23:59:36 riastradh Exp $");
 
 #include "opt_kgdb.h"
 #include 
@@ -693,7 +693,7 @@ sabopen(dev_t dev, int flags, int mode, 
 	if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp))
 		return (EBUSY);
 
-	mutex_spin_enter(_lock);
+	ttylock(tp);
 	if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
 		ttychars(tp);
 		tp->t_iflag = TTYDEF_IFLAG;
@@ -744,24 +744,24 @@ sabopen(dev_t dev, int flags, int mode, 
 
 			error = ttysleep(tp, >t_rawcv, true, 0);
 			if (error != 0) {
-mutex_spin_exit(_lock);
+ttyunlock(tp);
 return (error);
 			}
 		}
 	}
 
-	mutex_spin_exit(_lock);
+	ttyunlock(tp);
 
 	s = (*tp->t_linesw->l_open)(dev, tp);
 	if (s != 0) {
-		mutex_spin_enter(_lock);
+		ttylock(tp);
 		if (tp->t_state & TS_ISOPEN) {
-			mutex_spin_exit(_lock);
+			ttyunlock(tp);
 			return (s);
 		}
 		if (tp->t_cflag & HUPCL) {
 			sabtty_mdmctrl(sc, 0, DMSET);
-			cv_wait(, _lock);
+			ttysleep(tp, NULL, /*catch_p*/false, hz);
 		}
 
 		if ((sc->sc_flags & (SABTTYF_CONS_IN | SABTTYF_CONS_OUT)) == 0) {
@@ -769,7 +769,7 @@ sabopen(dev_t dev, int flags, int mode, 
 			sabtty_flush(sc);
 			sabtty_reset(sc);
 		}
-		mutex_spin_exit(_lock);
+		ttyunlock(tp);
 	}
 	return (s);
 }



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

2022-10-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Oct 26 23:59:36 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: sab.c

Log Message:
sparc64/sab(4): Convert to ttylock/ttyunlock.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/sparc64/dev/sab.c

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



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

2022-10-01 Thread Charlotte Koch
Module Name:src
Committed By:   charlotte
Date:   Sat Oct  1 07:59:25 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: pci_machdep.c

Log Message:
Don't try to make a tag based on node 0


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/sparc64/dev/pci_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/sparc64/dev/pci_machdep.c
diff -u src/sys/arch/sparc64/dev/pci_machdep.c:1.78 src/sys/arch/sparc64/dev/pci_machdep.c:1.79
--- src/sys/arch/sparc64/dev/pci_machdep.c:1.78	Mon Sep  3 16:29:27 2018
+++ src/sys/arch/sparc64/dev/pci_machdep.c	Sat Oct  1 07:59:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.78 2018/09/03 16:29:27 riastradh Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.79 2022/10/01 07:59:25 charlotte Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.78 2018/09/03 16:29:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.79 2022/10/01 07:59:25 charlotte Exp $");
 
 #include 
 #include 
@@ -116,7 +116,7 @@ pci_make_tag(pci_chipset_tag_t pc, int b
 	struct ofw_pci_register reg;
 	pcitag_t tag;
 	int (*valid)(void *);
-	int node, len;
+	int node, new_node, len;
 #ifdef DEBUG
 	char name[80];
 	memset(name, 0, sizeof(name));
@@ -193,8 +193,11 @@ pci_make_tag(pci_chipset_tag_t pc, int b
 break;
 			if (len != 2 || b < busrange[0] || b > busrange[1])
 break;
-			/* Go down 1 level */
-			node = prom_firstchild(node);
+			/* Go down 1 level, as long as we're able */
+			new_node = prom_firstchild(node);
+			if (new_node == 0)
+break;
+			node = new_node;
 			DPRINTF(SPDB_PROBE, ("going down to node %x %s\n", node,
 			prom_getpropstringA(node, "name", name,
 sizeof(name;



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

2022-10-01 Thread Charlotte Koch
Module Name:src
Committed By:   charlotte
Date:   Sat Oct  1 07:59:25 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: pci_machdep.c

Log Message:
Don't try to make a tag based on node 0


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/sparc64/dev/pci_machdep.c

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



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 13:31:08 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/vnet.c

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



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 13:31:08 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/vnet.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/sparc64/dev/vnet.c
diff -u src/sys/arch/sparc64/dev/vnet.c:1.6 src/sys/arch/sparc64/dev/vnet.c:1.7
--- src/sys/arch/sparc64/dev/vnet.c:1.6	Fri Feb 11 23:49:28 2022
+++ src/sys/arch/sparc64/dev/vnet.c	Sun Sep 18 13:31:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnet.c,v 1.6 2022/02/11 23:49:28 riastradh Exp $	*/
+/*	$NetBSD: vnet.c,v 1.7 2022/09/18 13:31:08 thorpej Exp $	*/
 /*	$OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $	*/
 /*
  * Copyright (c) 2009, 2015 Mark Kettenis
@@ -695,7 +695,6 @@ vnet_rx_vio_rdx(struct vnet_softc *sc, s
 		vnet_setmulti(sc, 1);
 
 		KERNEL_LOCK(1, curlwp);
-		ifp->if_flags &= ~IFF_OACTIVE;
 		vnet_start(ifp);
 		KERNEL_UNLOCK_ONE(curlwp);
 	}
@@ -951,8 +950,6 @@ vnet_rx_vio_dring_data(struct vnet_softc
 			vnet_send_dring_data(sc, cons);
 
 		KERNEL_LOCK(1, curlwp);
-		if (count < (sc->sc_vd->vd_nentries - 1))
-			ifp->if_flags &= ~IFF_OACTIVE;
 		if (count == 0)
 			ifp->if_timer = 0;
 
@@ -1138,11 +1135,6 @@ vnet_start(struct ifnet *ifp)
 		DPRINTF(("%s: not in RUNNING state\n", __func__));
 		return;
 	}
-	if (ifp->if_flags & IFF_OACTIVE)
-	{
-		DPRINTF(("%s: already active\n", __func__));
-		return;
-	}
 
 	if (IFQ_IS_EMPTY(>if_snd))
 	{
@@ -1175,7 +1167,6 @@ vnet_start(struct ifnet *ifp)
 	tx_tail += sizeof(struct ldc_pkt);
 	tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(struct ldc_pkt)) - 1);
 	if (tx_tail == tx_head) {
-		ifp->if_flags |= IFF_OACTIVE;
 		{
 			DPRINTF(("%s: tail equals head\n", __func__));
 			return;
@@ -1194,14 +1185,12 @@ vnet_start(struct ifnet *ifp)
 		if (count >= (sc->sc_vd->vd_nentries - 1) ||
 		map->lm_count >= map->lm_nentries) {
 			DPRINTF(("%s: count issue\n", __func__));
-			ifp->if_flags |= IFF_OACTIVE;
 			break;
 		}
 
 		buf = pool_get(>sc_pool, PR_NOWAIT|PR_ZERO);
 		if (buf == NULL) {
 			DPRINTF(("%s: buff is NULL\n", __func__));
-			ifp->if_flags |= IFF_OACTIVE;
 			break;
 		}
 		IFQ_DEQUEUE(>if_snd, m);
@@ -1275,13 +1264,11 @@ vnet_start_desc(struct ifnet *ifp)
 		count = sc->sc_tx_prod - sc->sc_tx_cons;
 		if (count >= (sc->sc_vd->vd_nentries - 1) ||
 		map->lm_count >= map->lm_nentries) {
-			ifp->if_flags |= IFF_OACTIVE;
 			return;
 		}
 
 		buf = pool_get(>sc_pool, PR_NOWAIT|PR_ZERO);
 		if (buf == NULL) {
-			ifp->if_flags |= IFF_OACTIVE;
 			return;
 		}
 
@@ -1548,7 +1535,6 @@ vnet_stop(struct ifnet *ifp, int disable
 	struct ldc_conn *lc = >sc_lc;
 
 	ifp->if_flags &= ~IFF_RUNNING;
-	ifp->if_flags &= ~IFF_OACTIVE;
 	ifp->if_timer = 0;
 
 	cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino, INTR_DISABLED);



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

2022-05-16 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon May 16 17:13:28 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v/vdsk: add handling of SCSI_REPORT_LUNS


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc64/dev/vdsk.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/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.9 src/sys/arch/sparc64/dev/vdsk.c:1.10
--- src/sys/arch/sparc64/dev/vdsk.c:1.9	Sat Dec  4 13:23:03 2021
+++ src/sys/arch/sparc64/dev/vdsk.c	Mon May 16 17:13:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.9 2021/12/04 13:23:03 andvar Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.10 2022/05/16 17:13:28 palle Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -218,6 +218,7 @@ void	vdsk_scsi_inq(struct vdsk_softc *sc
 void	vdsk_scsi_inquiry(struct vdsk_softc *sc, struct scsipi_xfer *);
 void	vdsk_scsi_capacity(struct vdsk_softc *sc, struct scsipi_xfer *);
 void	vdsk_scsi_capacity16(struct vdsk_softc *sc, struct scsipi_xfer *);
+void	vdsk_scsi_report_luns(struct vdsk_softc *sc, struct scsipi_xfer *);
 void	vdsk_scsi_done(struct scsipi_xfer *, int);
 
 int
@@ -1048,6 +1049,10 @@ vdsk_scsi_cmd(struct vdsk_softc *sc, str
 			vdsk_scsi_capacity16(sc, xs);
 			return;
 
+		case SCSI_REPORT_LUNS:
+			vdsk_scsi_report_luns(sc, xs);
+			return;
+			
 		case SCSI_TEST_UNIT_READY:
 		case START_STOP:
 		case SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL:
@@ -1333,6 +1338,12 @@ vdsk_scsi_capacity16(struct vdsk_softc *
 }
 
 void
+vdsk_scsi_report_luns(struct vdsk_softc *sc, struct scsipi_xfer *xs)
+{
+	vdsk_scsi_done(xs, XS_NOERROR);
+}
+
+void
 vdsk_scsi_done(struct scsipi_xfer *xs, int error)
 {
 



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

2022-05-16 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon May 16 17:13:28 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v/vdsk: add handling of SCSI_REPORT_LUNS


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc64/dev/vdsk.c

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



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

2022-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Feb 11 23:49:28 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
sparc64/vnet(4): device_t/softc split


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/dev/vnet.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/sparc64/dev/vnet.c
diff -u src/sys/arch/sparc64/dev/vnet.c:1.5 src/sys/arch/sparc64/dev/vnet.c:1.6
--- src/sys/arch/sparc64/dev/vnet.c:1.5	Mon Mar 15 18:44:04 2021
+++ src/sys/arch/sparc64/dev/vnet.c	Fri Feb 11 23:49:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnet.c,v 1.5 2021/03/15 18:44:04 palle Exp $	*/
+/*	$NetBSD: vnet.c,v 1.6 2022/02/11 23:49:28 riastradh Exp $	*/
 /*	$OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $	*/
 /*
  * Copyright (c) 2009, 2015 Mark Kettenis
@@ -128,7 +128,7 @@ struct vnet_soft_desc {
 };
 
 struct vnet_softc {
-	struct device	sc_dv;
+	device_t	sc_dv;
 	bus_space_tag_t	sc_bustag;
 	bus_dma_tag_t	sc_dmatag;
 
@@ -247,6 +247,7 @@ vnet_attach(struct device *parent, struc
 	struct ldc_conn *lc;
 	struct ifnet *ifp;
 
+	sc->sc_dv = self;
 	sc->sc_bustag = ca->ca_bustag;
 	sc->sc_dmatag = ca->ca_dmatag;
 	sc->sc_tx_ino = ca->ca_tx_ino;
@@ -304,8 +305,10 @@ vnet_attach(struct device *parent, struc
 	/*
 	 * Each interface gets its own pool.
 	 */
-	pool_init(>sc_pool, 2048, 0, 0, 0, sc->sc_dv.dv_xname, NULL, IPL_NET);
- 
+	pool_init(>sc_pool, /*size*/2048, /*align*/0, /*align_offset*/0,
+	/*flags*/0, /*wchan*/device_xname(sc->sc_dv), /*palloc*/NULL,
+	IPL_NET);
+
 	ifp = >sc_ethercom.ec_if;
 	ifp->if_softc = sc;
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@@ -1392,7 +1395,7 @@ vnet_watchdog(struct ifnet *ifp)
 
 	struct vnet_softc *sc = ifp->if_softc;
 
-	printf("%s: watchdog timeout\n", sc->sc_dv.dv_xname);
+	printf("%s: watchdog timeout\n", device_xname(sc->sc_dv));
 }
 
 int



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

2022-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Feb 11 23:49:28 UTC 2022

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
sparc64/vnet(4): device_t/softc split


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/dev/vnet.c

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



Re: CVS commit: src/sys/arch/sparc64/dev

2020-10-24 Thread Julian Coleman
Hi Tobias,

> If you're interested there is an older version[1] of envctrl in the
> Attic that might be relevant to use for reference. It supported fan
> speed controls on E450. IIRC I got some of the magic constants from
> OpenSolaris. Sadly I don't own an E450 any more.
> 
> [1] 
> cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/arch/sparc64/dev/Attic/envctrl.c?rev=1.11=text/plain_with_tag=MAIN

Thank you - that's useful information!

Related to the magic offsets, I noticed that the value read from the sensor
was always lower than the value written.  However, it doesn't appear to be
a constant difference (I see about 15 for most values, but only 5 for the
minimum).  I think that it's OK to keep the higher value - it'll mean that
we run the fans slightly faster.  The CPU temperature on my E250 doesn't
reach the minimum threshold where the fan speed actually increases, so I
don't think that this will have any impact.

The GPIO values there helps to see what values I should be checking for too.

It would be good to merge this with the current code, but I only have an
E250 to test on, so I'll need to find a volunteer.

Regards,

Julian


Re: CVS commit: src/sys/arch/sparc64/dev

2020-10-24 Thread Tobias Nygren
On Sat, 24 Oct 2020 15:16:39 +
Julian Coleman  wrote:

> Module Name:  src
> Committed By: jdc
> Date: Sat Oct 24 15:16:39 UTC 2020
> 
> Modified Files:
>   src/sys/arch/sparc64/dev: pcf8591_envctrl.c
> 
> Log Message:
> Add support for automatically changing the CPU fan speed on the E250 in a
> similar way to the SB1000/SB2000.
> The fan control information was determined by experiment, as it's only
> partially available in OFW.
> Hardcode the missing information for E250 fan control into the driver
> (it should be possible to support the E450 in future too).

If you're interested there is an older version[1] of envctrl in the
Attic that might be relevant to use for reference. It supported fan
speed controls on E450. IIRC I got some of the magic constants from
OpenSolaris. Sadly I don't own an E450 any more.

[1] 
cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/arch/sparc64/dev/Attic/envctrl.c?rev=1.11=text/plain_with_tag=MAIN


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

2019-11-19 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue Nov 19 20:07:30 UTC 2019

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: added support for handling of opcode SCSI_MAINTENANCE_IN when using ldom 
based virtual disk


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/dev/vdsk.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/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.4 src/sys/arch/sparc64/dev/vdsk.c:1.5
--- src/sys/arch/sparc64/dev/vdsk.c:1.4	Tue Oct  1 18:00:07 2019
+++ src/sys/arch/sparc64/dev/vdsk.c	Tue Nov 19 20:07:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.4 2019/10/01 18:00:07 chs Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.5 2019/11/19 20:07:30 palle Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -1049,6 +1049,7 @@ vdsk_scsi_cmd(struct vdsk_softc *sc, str
 		case START_STOP:
 		case SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL:
 		case SCSI_MODE_SENSE_6:
+		case SCSI_MAINTENANCE_IN:
 			vdsk_scsi_done(xs, XS_NOERROR);
 			return;
 



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

2019-11-19 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue Nov 19 20:07:30 UTC 2019

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: added support for handling of opcode SCSI_MAINTENANCE_IN when using ldom 
based virtual disk


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/dev/vdsk.c

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



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

2010-03-10 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Mar 11 03:30:16 UTC 2010

Modified Files:
src/sys/arch/sparc64/dev: schizo.c

Log Message:
- pay attention to the no-streaming-cache flag.
- minor re-structure so this looks a little more like psycho.c.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/dev/schizo.c

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



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

2010-03-10 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Mar 11 03:30:16 UTC 2010

Modified Files:
src/sys/arch/sparc64/dev: schizo.c

Log Message:
- pay attention to the no-streaming-cache flag.
- minor re-structure so this looks a little more like psycho.c.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/dev/schizo.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/sparc64/dev/schizo.c
diff -u src/sys/arch/sparc64/dev/schizo.c:1.14 src/sys/arch/sparc64/dev/schizo.c:1.15
--- src/sys/arch/sparc64/dev/schizo.c:1.14	Sat Feb 13 11:55:48 2010
+++ src/sys/arch/sparc64/dev/schizo.c	Thu Mar 11 03:30:16 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: schizo.c,v 1.14 2010/02/13 11:55:48 nakayama Exp $	*/
+/*	$NetBSD: schizo.c,v 1.15 2010/03/11 03:30:16 mrg Exp $	*/
 /*	$OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $	*/
 
 /*
@@ -136,6 +136,7 @@
 	struct schizo_softc *sc = (struct schizo_softc *)self;
 	struct mainbus_attach_args *ma = aux;
 	struct schizo_pbm *pbm;
+	struct iommu_state *is;
 	struct pcibus_attach_args pba;
 	uint64_t reg, eccctrl;
 	int *busranges = NULL, nranges;
@@ -209,6 +210,26 @@
 		panic(schizo: unable to create PBM handle);
 	}
 
+	is = pbm-sp_is;
+	pbm-sp_sb.sb_is = is;
+	if (prom_getproplen(sc-sc_node, no-streaming-cache)  0) {
+		vaddr_t va = (vaddr_t)pbm-sp_flush[0x40];
+
+		/*
+		 * Initialize the strbuf_ctl.
+		 *
+		 * The flush sync buffer must be 64-byte aligned.
+		 */
+		is-is_sb[0] = pbm-sp_sb;
+		is-is_sb[0]-sb_flush = (void *)(va  ~0x3f);
+
+		bus_space_subregion(pbm-sp_regt, pbm-sp_regh,
+			offsetof(struct schizo_pbm_regs, strbuf),
+			sizeof(struct iommu_strbuf), is-is_sb[0]-sb_sb);
+	} else {
+		aprint_debug(%s: no streaming buffers\n, sc-sc_dv.dv_xname);
+	}
+
 	printf(%s: , sc-sc_dv.dv_xname);
 	schizo_init_iommu(sc, pbm);
 
@@ -378,37 +399,14 @@
 	struct iommu_state *is = pbm-sp_is;
 	int *vdma = NULL, nitem, tsbsize = 7;
 	u_int32_t iobase = -1;
-	vaddr_t va;
 	char *name;
 
-	if (prom_getproplen(sc-sc_node, no-streaming-cache)  0) {
-	}
-
-	va = (vaddr_t)pbm-sp_flush[0x40];
-
 	/* punch in our copies */
 	is-is_bustag = pbm-sp_regt;
-	if (bus_space_subregion(is-is_bustag, pbm-sp_regh,
-	offsetof(struct schizo_pbm_regs, iommu),
-	sizeof(struct schizo_iommureg), is-is_iommu)) {
-		printf(schizo: unable to create streaming buffer handle\n);
-		is-is_sb[0]-sb_flush = NULL;
-	} 
-
-	/* initialize our strbuf_ctl */
-	is-is_sb[0] = pbm-sp_sb;
-	pbm-sp_sb.sb_is = is;
-	is-is_sb[0]-sb_flush = (void *)(va  ~0x3f);
-
-	if (bus_space_subregion(is-is_bustag, pbm-sp_regh,
-	offsetof(struct schizo_pbm_regs, strbuf),
-	sizeof(struct iommu_strbuf), is-is_sb[0]-sb_sb)) {
-	} 
-
-	name = (char *)malloc(32, M_DEVBUF, M_NOWAIT);
-	if (name == NULL)
-		panic(couldn't malloc iommu name);
-	snprintf(name, 32, %s dvma, sc-sc_dv.dv_xname);
+	bus_space_subregion(is-is_bustag, pbm-sp_regh,
+		offsetof(struct schizo_pbm_regs, iommu),
+		sizeof(struct schizo_iommureg),
+		is-is_iommu);
 
 	/*
 	 * Separate the men from the boys.  If the `virtual-dma'
@@ -434,6 +432,12 @@
 		using iobase=0x%x, tsbsize=%d\n, iobase, tsbsize));
 	}
 
+	/* give us a nice name.. */
+	name = (char *)malloc(32, M_DEVBUF, M_NOWAIT);
+	if (name == NULL)
+		panic(couldn't malloc iommu name);
+	snprintf(name, 32, %s dvma, sc-sc_dv.dv_xname);
+
 	iommu_init(name, is, tsbsize, iobase);
 }
 



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

2010-03-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  1 22:53:09 UTC 2010

Modified Files:
src/sys/arch/sparc64/dev: tda.c

Log Message:
Fix printf formats (for 32bit compiles)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/dev/tda.c

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



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

2010-03-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  1 22:53:09 UTC 2010

Modified Files:
src/sys/arch/sparc64/dev: tda.c

Log Message:
Fix printf formats (for 32bit compiles)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/dev/tda.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/sparc64/dev/tda.c
diff -u src/sys/arch/sparc64/dev/tda.c:1.1 src/sys/arch/sparc64/dev/tda.c:1.2
--- src/sys/arch/sparc64/dev/tda.c:1.1	Sun Feb 28 11:49:44 2010
+++ src/sys/arch/sparc64/dev/tda.c	Mon Mar  1 22:53:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: tda.c,v 1.1 2010/02/28 11:49:44 martin Exp $	*/
+/*	$NetBSD: tda.c,v 1.2 2010/03/01 22:53:09 martin Exp $	*/
 /*	$OpenBSD: tda.c,v 1.4 2008/02/27 17:25:00 robert Exp $ */
 
 /*
@@ -200,7 +200,8 @@
 		return;
 	}
 
-	aprint_debug_dev(sc-sc_dev, current temperature: cpu %lu system %lu\n,
+	aprint_debug_dev(sc-sc_dev, current temperature: cpu % PRIu64
+		 system % PRIu64 \n,
 		ctemp, stemp);
 
 	if (ctemp  CPU_TEMP_MIN)



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

2010-02-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Feb 28 15:30:22 UTC 2010

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
dmesg cosmetics


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/dev/pcf8591_envctrl.c

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



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

2010-02-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Feb 28 15:30:22 UTC 2010

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
dmesg cosmetics


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.2 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.3
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.2	Sun Feb 28 12:40:46 2010
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sun Feb 28 15:30:22 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.2 2010/02/28 12:40:46 pgoyette Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.3 2010/02/28 15:30:22 martin Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -193,7 +193,7 @@
 	}
 
 	aprint_naive(: Temp Sensors\n);
-	aprint_normal(%s Temp Sensors\n, ia-ia_name);
+	aprint_normal(: %s Temp Sensors\n, ia-ia_name);
 }
 
 static void



re: CVS commit: src/sys/arch/sparc64/dev

2010-02-13 Thread matthew green

   Module Name: src
   Committed By:nakayama
   Date:Sat Feb 13 11:55:48 UTC 2010
   
   Modified Files:
src/sys/arch/sparc64/dev: schizo.c schizoreg.h
   
   Log Message:
   Make 32-bit kernels compilable.

thanks! i guess i never tried that. :)


.mrg.


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

2010-01-18 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jan 18 09:58:20 UTC 2010

Modified Files:
src/sys/arch/sparc64/dev: sab.c

Log Message:
Re-do the previous check for the RSC console:
Do the check in sabtty_console_flags() and set a flag if we are an RSC port.
If we are an RSC port, note that the baud rate is 115200, but don't write a
new value to the baud rate generator register, as this stops the console
working.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/sparc64/dev/sab.c

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



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

2010-01-07 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Jan  7 09:33:44 UTC 2010

Modified Files:
src/sys/arch/sparc64/dev: pci_machdep.c

Log Message:
Cope with up to four interrupts properties for a node.
Just use the first one for now.  This should be improved.
OK: m...@.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/sparc64/dev/pci_machdep.c

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



Re: CVS commit: src/sys/arch/sparc64/dev

2009-12-07 Thread Takeshi Nakayama
 matthew green m...@eterna.com.au wrote

 
Module Name:   src
Committed By:  nakayama
Date:  Mon Dec  7 11:14:27 UTC 2009

Modified Files:
   src/sys/arch/sparc64/dev: iommu.c

Log Message:
Avoid use of iommu_dvmamap_unload in error path.  It is too
expensive since it contains data cache flushing.

Some driver (tlp(4) with DM9201 on Netra X1) can only handle one
DMA segment, so it was called frequently.
 
 +   /* How can this fail?  And if it does what can we do? */
 +   err = extent_free(is-is_dvmamap, map-_dm_dvmastart, sgsize,
 +   EX_NOWAIT);
 
 
 this can fail almost any time.  it happens when there is no free
 memory and to free a chunk would require to split a current extent
 range into two.

Ah, OK.  I added the warning printf as well as what we do in
iommu_dvmamap_unload.

-- Takeshi Nakayama