Re: CVS commit: src/sys/dev/fdt

2024-06-12 Thread Rin Okuyama

Thank you, too, for clarification!

rin

On 2024/06/13 5:10, Nick Hudson wrote:

Thanks for the fix.

The bug affects enable and disable in the all (-1) indexes case and
references out of bounds data.

Nick

On 12/06/2024 08:36, Rin Okuyama wrote:

Hmm, there was a confusion for my side.

This bug affected cases where

(1) index >= 1 is explicitly specified for
fdtbus_powerdomain_enable_index(),

as well as

(2) all indices are implicitly specified by
fdtbus_powerdomain_enable().

s/enable/disable/ functions were affected also.

Thanks,
rin

On 2024/06/12 15:39, Rin Okuyama wrote:

Module Name:    src
Committed By:    rin
Date:    Wed Jun 12 06:39:28 UTC 2024

Modified Files:
src/sys/dev/fdt: fdt_powerdomain.c

Log Message:
fdt_powerdomain: Fix bug by which pd index >= 1 couldn't be enabled

Length in bytes was mistakenly used as number of uint32_t variables.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/fdt/fdt_powerdomain.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/fdt/fdt_powerdomain.c
diff -u src/sys/dev/fdt/fdt_powerdomain.c:1.1
src/sys/dev/fdt/fdt_powerdomain.c:1.2
--- src/sys/dev/fdt/fdt_powerdomain.c:1.1    Fri Mar  4 08:19:06 2022
+++ src/sys/dev/fdt/fdt_powerdomain.c    Wed Jun 12 06:39:28 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_powerdomain.c,v 1.1 2022/03/04 08:19:06 skrll Exp $ */
+/* $NetBSD: fdt_powerdomain.c,v 1.2 2024/06/12 06:39:28 rin Exp $ */
  /*-
   * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
   */
  #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_powerdomain.c,v 1.1 2022/03/04
08:19:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_powerdomain.c,v 1.2 2024/06/12
06:39:28 rin Exp $");
  #include 
@@ -103,7 +103,7 @@ fdtbus_powerdomain_enable_internal(int p
  if (pds == NULL)
  return EINVAL;
-    for (const uint32_t *pd = pds; pd < pds + len; index--) {
+    for (const uint32_t *pd = pds; pd < pds + len / sizeof(*pd);
index--) {
  uint32_t pd_node =
 fdtbus_get_phandle_from_native(be32toh(pd[0]));
  struct fdtbus_powerdomain_controller *pdc =







Re: CVS commit: src/sys/dev/fdt

2024-06-12 Thread Nick Hudson

Thanks for the fix.

The bug affects enable and disable in the all (-1) indexes case and
references out of bounds data.

Nick

On 12/06/2024 08:36, Rin Okuyama wrote:

Hmm, there was a confusion for my side.

This bug affected cases where

(1) index >= 1 is explicitly specified for
fdtbus_powerdomain_enable_index(),

as well as

(2) all indices are implicitly specified by
fdtbus_powerdomain_enable().

s/enable/disable/ functions were affected also.

Thanks,
rin

On 2024/06/12 15:39, Rin Okuyama wrote:

Module Name:    src
Committed By:    rin
Date:    Wed Jun 12 06:39:28 UTC 2024

Modified Files:
src/sys/dev/fdt: fdt_powerdomain.c

Log Message:
fdt_powerdomain: Fix bug by which pd index >= 1 couldn't be enabled

Length in bytes was mistakenly used as number of uint32_t variables.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/fdt/fdt_powerdomain.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/fdt/fdt_powerdomain.c
diff -u src/sys/dev/fdt/fdt_powerdomain.c:1.1
src/sys/dev/fdt/fdt_powerdomain.c:1.2
--- src/sys/dev/fdt/fdt_powerdomain.c:1.1    Fri Mar  4 08:19:06 2022
+++ src/sys/dev/fdt/fdt_powerdomain.c    Wed Jun 12 06:39:28 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_powerdomain.c,v 1.1 2022/03/04 08:19:06 skrll Exp $ */
+/* $NetBSD: fdt_powerdomain.c,v 1.2 2024/06/12 06:39:28 rin Exp $ */
  /*-
   * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
   */
  #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_powerdomain.c,v 1.1 2022/03/04
08:19:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_powerdomain.c,v 1.2 2024/06/12
06:39:28 rin Exp $");
  #include 
@@ -103,7 +103,7 @@ fdtbus_powerdomain_enable_internal(int p
  if (pds == NULL)
  return EINVAL;
-    for (const uint32_t *pd = pds; pd < pds + len; index--) {
+    for (const uint32_t *pd = pds; pd < pds + len / sizeof(*pd);
index--) {
  uint32_t pd_node =
 fdtbus_get_phandle_from_native(be32toh(pd[0]));
  struct fdtbus_powerdomain_controller *pdc =







CVS commit: src/sys/dev/marvell

2024-06-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed Jun 12 20:03:56 UTC 2024

Modified Files:
src/sys/dev/marvell: gtidmac.c

Log Message:
MVXORE_XEXCDPR and MVXORE_XEXBCR macros expect two params now, thus adjust
params accordingly, needed in order to fix GTIDMAC_DEBUG build option.

Unfortunately, there few more macros in gtidmac_dump_xorereg() like
MVXORE_XETMCR, MVXORE_XETMIVR, MVXORE_XETMCVR, MVXORE_XEIVRH, MVXORE_XEIVRL
which also expect two params, but second one doesn't seem to be a channel,
thus I am leaving it unfixed for now.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/marvell/gtidmac.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/marvell/gtidmac.c
diff -u src/sys/dev/marvell/gtidmac.c:1.20 src/sys/dev/marvell/gtidmac.c:1.21
--- src/sys/dev/marvell/gtidmac.c:1.20	Fri Feb  2 22:33:42 2024
+++ src/sys/dev/marvell/gtidmac.c	Wed Jun 12 20:03:56 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gtidmac.c,v 1.20 2024/02/02 22:33:42 andvar Exp $	*/
+/*	$NetBSD: gtidmac.c,v 1.21 2024/06/12 20:03:56 andvar Exp $	*/
 /*
  * Copyright (c) 2008, 2012, 2016 KIYOHARA Takashi
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gtidmac.c,v 1.20 2024/02/02 22:33:42 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gtidmac.c,v 1.21 2024/06/12 20:03:56 andvar Exp $");
 
 #include 
 #include 
@@ -2010,10 +2010,10 @@ gtidmac_dump_xorereg(struct gtidmac_soft
 		MVXORE_XEXNDPR(sc, chan)));
 		printf("  CurrentDescPtr  : 0x%08x\n",
 		bus_space_read_4(sc->sc_iot, sc->sc_ioh,
-		MVXORE_XEXCDPR(chan)));
+		MVXORE_XEXCDPR(sc, chan)));
 	}
 	printf("  ByteCnt : 0x%08x\n",
-	bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVXORE_XEXBCR(chan)));
+	bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVXORE_XEXBCR(sc, chan)));
 
 	if (opmode == MVXORE_XEXCR_OM_ECC ||
 	opmode == MVXORE_XEXCR_OM_MEMINIT) {



CVS commit: src/sys/dev/marvell

2024-06-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed Jun 12 20:03:56 UTC 2024

Modified Files:
src/sys/dev/marvell: gtidmac.c

Log Message:
MVXORE_XEXCDPR and MVXORE_XEXBCR macros expect two params now, thus adjust
params accordingly, needed in order to fix GTIDMAC_DEBUG build option.

Unfortunately, there few more macros in gtidmac_dump_xorereg() like
MVXORE_XETMCR, MVXORE_XETMIVR, MVXORE_XETMCVR, MVXORE_XEIVRH, MVXORE_XEIVRL
which also expect two params, but second one doesn't seem to be a channel,
thus I am leaving it unfixed for now.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/marvell/gtidmac.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-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, &pa) == 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(&read_discinfo_data, sizeof(read_discinfo_data));
 
 	bcopy(&read_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(&read_trackinfo_data, sizeof(read_trackinfo_data));
 
 	bcopy(&read_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/distrib/sets/lists/base32

2024-06-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jun 12 18:16:48 UTC 2024

Modified Files:
src/distrib/sets/lists/base32: ad.mipsn64eb

Log Message:
base32/ad.mipsn64eb: Nix stray backtick on n32/libarchive.so.5.1 line.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/distrib/sets/lists/base32/ad.mipsn64eb

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



CVS commit: src/distrib/sets/lists/base32

2024-06-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jun 12 18:16:48 UTC 2024

Modified Files:
src/distrib/sets/lists/base32: ad.mipsn64eb

Log Message:
base32/ad.mipsn64eb: Nix stray backtick on n32/libarchive.so.5.1 line.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/distrib/sets/lists/base32/ad.mipsn64eb

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

Modified files:

Index: src/distrib/sets/lists/base32/ad.mipsn64eb
diff -u src/distrib/sets/lists/base32/ad.mipsn64eb:1.8 src/distrib/sets/lists/base32/ad.mipsn64eb:1.9
--- src/distrib/sets/lists/base32/ad.mipsn64eb:1.8	Mon Jun 10 07:57:10 2024
+++ src/distrib/sets/lists/base32/ad.mipsn64eb	Wed Jun 12 18:16:48 2024
@@ -1,4 +1,4 @@
-# $NetBSD: ad.mipsn64eb,v 1.8 2024/06/10 07:57:10 kre Exp $
+# $NetBSD: ad.mipsn64eb,v 1.9 2024/06/12 18:16:48 riastradh Exp $
 ./lib/n32	base-compat-shlib	compat
 ./lib/n32/npf	base-compat-shlib	compat,npf
 ./lib/n32/npf/ext_log.so			base-compat-shlib	compat,npf
@@ -98,7 +98,7 @@
 ./usr/lib/n32/libamu.so.5.0			base-compat-shlib	compat
 ./usr/lib/n32/libarchive.so			base-compat-shlib	compat
 ./usr/lib/n32/libarchive.so.5			base-compat-shlib	compat
-./usr/lib/n32/libarchive.so.5.1		`	base-compat-shlib	compat
+./usr/lib/n32/libarchive.so.5.1			base-compat-shlib	compat
 ./usr/lib/n32/libasan.so			base-compat-shlib	compat,gcc,cxx
 ./usr/lib/n32/libasan.so.5			base-compat-shlib	compat,gcc,cxx
 ./usr/lib/n32/libasan.so.5.0			base-compat-shlib	compat,gcc,cxx



CVS commit: src/sys/dev/pci

2024-06-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jun 12 16:51:54 UTC 2024

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

Log Message:
ld@virtio(4): Fix maximum size parameters.

- SEG_MAX is the maximum number of segments.
- SIZE_MAX is the maximum number of bytes in a single segment.

The maximum transfer size is, therefore, SEG_MAX * SIZE_MAX.

=> Don't add two extra segments in the dmamap vr_payload for the
   header and status -- we already have a separate dmamap vr_cmdsts
   for that.

=> Don't recalculate payload dmamap parameters based on division by
   NBPG, just use the ones specified by the host.

=> Allow SIZE_MAX below MAXPHYS as long as SIZE_MAX*SEG_MAX >=
   MAXPHYS.

Even though ldattach clamps ld->sc_maxxfer to MAXPHYS, make sure to
clamp it in ld_virtio_attach before ld_virtio_alloc_reqs since it
determines the dmamap sizes and bounce buffer allocation and there's
no sense in allocating those larger than ld will use anyway.

PR kern/58338


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/ld_virtio.c

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

Modified files:

Index: src/sys/dev/pci/ld_virtio.c
diff -u src/sys/dev/pci/ld_virtio.c:1.34 src/sys/dev/pci/ld_virtio.c:1.35
--- src/sys/dev/pci/ld_virtio.c:1.34	Sat Mar  9 11:04:22 2024
+++ src/sys/dev/pci/ld_virtio.c	Wed Jun 12 16:51:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_virtio.c,v 1.34 2024/03/09 11:04:22 isaki Exp $	*/
+/*	$NetBSD: ld_virtio.c,v 1.35 2024/06/12 16:51:53 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.34 2024/03/09 11:04:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.35 2024/06/12 16:51:53 riastradh Exp $");
 
 #include 
 #include 
@@ -128,6 +128,9 @@ struct ld_virtio_softc {
 	struct ld_softc		sc_ld;
 	device_t		sc_dev;
 
+	uint32_t		sc_seg_max; /* max number of segs in xfer */
+	uint32_t		sc_size_max; /* max size of single seg */
+
 	struct virtio_softc	*sc_virtio;
 	struct virtqueue	sc_vq;
 
@@ -220,11 +223,10 @@ ld_virtio_alloc_reqs(struct ld_virtio_so
 			goto err_reqs;
 		}
 		r = bus_dmamap_create(virtio_dmat(sc->sc_virtio),
-  ld->sc_maxxfer,
-  (ld->sc_maxxfer / NBPG) +
-  VIRTIO_BLK_CTRL_SEGMENTS,
-  ld->sc_maxxfer,
-  0,
+  /*size*/ld->sc_maxxfer,
+  /*nseg*/sc->sc_seg_max,
+  /*maxsegsz*/sc->sc_size_max,
+  /*boundary*/0,
   BUS_DMA_WAITOK|BUS_DMA_ALLOCNOW,
   &vr->vr_payload);
 		if (r != 0) {
@@ -264,7 +266,7 @@ ld_virtio_attach(device_t parent, device
 	struct ld_softc *ld = &sc->sc_ld;
 	struct virtio_softc *vsc = device_private(parent);
 	uint64_t features;
-	int qsize, maxxfersize, maxnsegs;
+	int qsize;
 
 	if (virtio_child(vsc) != NULL) {
 		aprint_normal(": child already attached for %s; "
@@ -296,46 +298,53 @@ ld_virtio_attach(device_t parent, device
 	} else
 		ld->sc_secsize = VIRTIO_BLK_BSIZE;
 
-	/* At least genfs_io assumes maxxfer == MAXPHYS. */
-	if (features & VIRTIO_BLK_F_SIZE_MAX) {
-		maxxfersize = virtio_read_device_config_4(vsc,
-		VIRTIO_BLK_CONFIG_SIZE_MAX);
-		if (maxxfersize < MAXPHYS) {
-			aprint_error_dev(sc->sc_dev,
-			"Too small SIZE_MAX %dK minimum is %dK\n",
-			maxxfersize / 1024, MAXPHYS / 1024);
-			// goto err;
-			maxxfersize = MAXPHYS;
-		} else if (maxxfersize > MAXPHYS) {
-			aprint_normal_dev(sc->sc_dev,
-			"Clip SIZE_MAX from %dK to %dK\n",
-			maxxfersize / 1024,
-			MAXPHYS / 1024);
-			maxxfersize = MAXPHYS;
-		}
-	} else
-		maxxfersize = MAXPHYS;
-
 	if (features & VIRTIO_BLK_F_SEG_MAX) {
-		maxnsegs = virtio_read_device_config_4(vsc,
+		sc->sc_seg_max = virtio_read_device_config_4(vsc,
 		VIRTIO_BLK_CONFIG_SEG_MAX);
-		if (maxnsegs == 0) {
+		if (sc->sc_seg_max == 0) {
 			aprint_error_dev(sc->sc_dev,
-			"Invalid SEG_MAX %d\n", maxnsegs);
+			"Invalid SEG_MAX %d\n", sc->sc_seg_max);
 			goto err;
 		}
-	} else
-		maxnsegs = maxxfersize / NBPG;
+	} else {
+		sc->sc_seg_max = 1;
+		aprint_verbose_dev(sc->sc_dev,
+		"Unknown SEG_MAX, assuming %"PRIu32"\n", sc->sc_seg_max);
+	}
 
-	maxnsegs += VIRTIO_BLK_CTRL_SEGMENTS;
+	/* At least genfs_io assumes size_max*seg_max >= MAXPHYS. */
+	if (features & VIRTIO_BLK_F_SIZE_MAX) {
+		sc->sc_size_max = virtio_read_device_config_4(vsc,
+		VIRTIO_BLK_CONFIG_SIZE_MAX);
+		if (sc->sc_size_max < MAXPHYS/sc->sc_seg_max) {
+			aprint_error_dev(sc->sc_dev,
+			"Too small SIZE_MAX %d minimum is %d\n",
+			sc->sc_size_max, MAXPHYS/sc->sc_seg_max);
+			// goto err;
+			sc->sc_size_max = MAXPHYS/sc->sc_seg_max;
+		} else if (sc->sc_size_max > MAXPHYS) {
+			aprint_verbose_dev(sc->sc_dev,
+			"Clip SIZE_MAX from %d to %d\n",
+			sc->sc_size_max, MAXPHYS);
+			sc->sc_size_max = MAXPHYS;
+		}
+	} else {
+		sc->sc_size_max = MAXPHYS;
+		aprint_verbose_dev(sc->sc_dev,

CVS commit: src/sys/dev/pci

2024-06-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jun 12 16:51:54 UTC 2024

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

Log Message:
ld@virtio(4): Fix maximum size parameters.

- SEG_MAX is the maximum number of segments.
- SIZE_MAX is the maximum number of bytes in a single segment.

The maximum transfer size is, therefore, SEG_MAX * SIZE_MAX.

=> Don't add two extra segments in the dmamap vr_payload for the
   header and status -- we already have a separate dmamap vr_cmdsts
   for that.

=> Don't recalculate payload dmamap parameters based on division by
   NBPG, just use the ones specified by the host.

=> Allow SIZE_MAX below MAXPHYS as long as SIZE_MAX*SEG_MAX >=
   MAXPHYS.

Even though ldattach clamps ld->sc_maxxfer to MAXPHYS, make sure to
clamp it in ld_virtio_attach before ld_virtio_alloc_reqs since it
determines the dmamap sizes and bounce buffer allocation and there's
no sense in allocating those larger than ld will use anyway.

PR kern/58338


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/ld_virtio.c

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



CVS commit: src/sys/dev/marvell

2024-06-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed Jun 12 09:51:27 UTC 2024

Modified Files:
src/sys/dev/marvell: gtmpsc.c

Log Message:
Make gtmpsc_intr_rx/tx always static __inline to fix DEBUG enabled build.
Currently code depends on STATIC macro which is defined as empty with DEBUG
option, thus build fails since tx method uses static inline gt_sdma_imask().

Also add missing __inline for gtmpsc_intr_rx() definition.

Fix EV64260 kernel config when DEBUG is enabled.
Fix discussed with mrg@ in irc.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/marvell/gtmpsc.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/marvell/gtmpsc.c
diff -u src/sys/dev/marvell/gtmpsc.c:1.48 src/sys/dev/marvell/gtmpsc.c:1.49
--- src/sys/dev/marvell/gtmpsc.c:1.48	Wed Nov  2 20:38:22 2022
+++ src/sys/dev/marvell/gtmpsc.c	Wed Jun 12 09:51:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gtmpsc.c,v 1.48 2022/11/02 20:38:22 andvar Exp $	*/
+/*	$NetBSD: gtmpsc.c,v 1.49 2024/06/12 09:51:27 andvar Exp $	*/
 /*
  * Copyright (c) 2009 KIYOHARA Takashi
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gtmpsc.c,v 1.48 2022/11/02 20:38:22 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gtmpsc.c,v 1.49 2024/06/12 09:51:27 andvar Exp $");
 
 #include "opt_kgdb.h"
 
@@ -118,8 +118,8 @@ STATIC int  gtmpscparam(struct tty *, st
 STATIC void gtmpsc_shutdownhook(void *);
 
 STATIC uint32_t cflag2mpcr(tcflag_t);
-STATIC __inline void gtmpsc_intr_rx(struct gtmpsc_softc *);
-STATIC __inline void gtmpsc_intr_tx(struct gtmpsc_softc *);
+static __inline void gtmpsc_intr_rx(struct gtmpsc_softc *);
+static __inline void gtmpsc_intr_tx(struct gtmpsc_softc *);
 STATIC void gtmpsc_write(struct gtmpsc_softc *);
 STATIC void gtmpsc_txflush(gtmpsc_softc_t *);
 STATIC void gtmpsc_rxdesc_init(struct gtmpsc_softc *);
@@ -879,7 +879,7 @@ cflag2mpcr(tcflag_t cflag)
 	return mpcr;
 }
 
-STATIC void
+static __inline void
 gtmpsc_intr_rx(struct gtmpsc_softc *sc)
 {
 	gtmpsc_pollrx_t *vrxp;
@@ -943,7 +943,7 @@ gtmpsc_intr_rx(struct gtmpsc_softc *sc)
 	}
 }
 
-STATIC __inline void
+static __inline void
 gtmpsc_intr_tx(struct gtmpsc_softc *sc)
 {
 	gtmpsc_polltx_t *vtxp;



CVS commit: src/sys/dev/marvell

2024-06-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed Jun 12 09:51:27 UTC 2024

Modified Files:
src/sys/dev/marvell: gtmpsc.c

Log Message:
Make gtmpsc_intr_rx/tx always static __inline to fix DEBUG enabled build.
Currently code depends on STATIC macro which is defined as empty with DEBUG
option, thus build fails since tx method uses static inline gt_sdma_imask().

Also add missing __inline for gtmpsc_intr_rx() definition.

Fix EV64260 kernel config when DEBUG is enabled.
Fix discussed with mrg@ in irc.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/marvell/gtmpsc.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/dev/fdt

2024-06-12 Thread Rin Okuyama

Hmm, there was a confusion for my side.

This bug affected cases where

(1) index >= 1 is explicitly specified for
fdtbus_powerdomain_enable_index(),

as well as

(2) all indices are implicitly specified by
fdtbus_powerdomain_enable().

s/enable/disable/ functions were affected also.

Thanks,
rin

On 2024/06/12 15:39, Rin Okuyama wrote:

Module Name:src
Committed By:   rin
Date:   Wed Jun 12 06:39:28 UTC 2024

Modified Files:
src/sys/dev/fdt: fdt_powerdomain.c

Log Message:
fdt_powerdomain: Fix bug by which pd index >= 1 couldn't be enabled

Length in bytes was mistakenly used as number of uint32_t variables.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/fdt/fdt_powerdomain.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/fdt/fdt_powerdomain.c
diff -u src/sys/dev/fdt/fdt_powerdomain.c:1.1 
src/sys/dev/fdt/fdt_powerdomain.c:1.2
--- src/sys/dev/fdt/fdt_powerdomain.c:1.1   Fri Mar  4 08:19:06 2022
+++ src/sys/dev/fdt/fdt_powerdomain.c   Wed Jun 12 06:39:28 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_powerdomain.c,v 1.1 2022/03/04 08:19:06 skrll Exp $ */
+/* $NetBSD: fdt_powerdomain.c,v 1.2 2024/06/12 06:39:28 rin Exp $ */
  
  /*-

   * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
   */
  
  #include 

-__KERNEL_RCSID(0, "$NetBSD: fdt_powerdomain.c,v 1.1 2022/03/04 08:19:06 skrll Exp 
$");
+__KERNEL_RCSID(0, "$NetBSD: fdt_powerdomain.c,v 1.2 2024/06/12 06:39:28 rin Exp 
$");
  
  #include 
  
@@ -103,7 +103,7 @@ fdtbus_powerdomain_enable_internal(int p

if (pds == NULL)
return EINVAL;
  
-	for (const uint32_t *pd = pds; pd < pds + len; index--) {

+   for (const uint32_t *pd = pds; pd < pds + len / sizeof(*pd); index--) {
uint32_t pd_node =
   fdtbus_get_phandle_from_native(be32toh(pd[0]));
struct fdtbus_powerdomain_controller *pdc =