CVS commit: src/sys/kern

2023-11-26 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Nov 27 02:50:27 UTC 2023

Modified Files:
src/sys/kern: uipc_mbuf.c

Log Message:
mbuf: avoid assertion failure when splitting mbuf cluster

>From OpenBSD:

commit 7b4d35e0a60ba1dd4daf4b1c2932020a22463a89
Author: bluhm 
Date:   Fri Oct 20 16:25:15 2023 +

Avoid assertion failure when splitting mbuf cluster.

m_split() calls m_align() to initialize the data pointer of newly
allocated mbuf.  If the new mbuf will be converted to a cluster,
this is not necessary.  If additionally the new mbuf is larger than
MLEN, this can lead to a panic.
Only call m_align() when a valid m_data is needed.  This is the
case if we do not refecence the existing cluster, but memcpy() the
data into the new mbuf.

Reported-by: syzbot+0e6817f5877926f0e...@syzkaller.appspotmail.com
OK claudio@ deraadt@

The issue is harmless if DIAGNOSTIC is not enabled.

XXX pullup-10
XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/sys/kern/uipc_mbuf.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/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.251 src/sys/kern/uipc_mbuf.c:1.252
--- src/sys/kern/uipc_mbuf.c:1.251	Wed Apr 12 06:48:08 2023
+++ src/sys/kern/uipc_mbuf.c	Mon Nov 27 02:50:27 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.251 2023/04/12 06:48:08 riastradh Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.252 2023/11/27 02:50:27 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001, 2018 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.251 2023/04/12 06:48:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.252 2023/11/27 02:50:27 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -1343,10 +1343,7 @@ m_split_internal(struct mbuf *m0, int le
 		len_save = m0->m_pkthdr.len;
 		m0->m_pkthdr.len = len0;
 
-		if (m->m_flags & M_EXT)
-			goto extpacket;
-
-		if (remain > MHLEN) {
+		if ((m->m_flags & M_EXT) == 0 && remain > MHLEN) {
 			/* m can't be the lead packet */
 			m_align(n, 0);
 			n->m_len = 0;
@@ -1357,8 +1354,6 @@ m_split_internal(struct mbuf *m0, int le
 return NULL;
 			}
 			return n;
-		} else {
-			m_align(n, remain);
 		}
 	} else if (remain == 0) {
 		n = m->m_next;
@@ -1369,14 +1364,13 @@ m_split_internal(struct mbuf *m0, int le
 		if (n == NULL)
 			return NULL;
 		MCLAIM(n, m->m_owner);
-		m_align(n, remain);
 	}
 
-extpacket:
 	if (m->m_flags & M_EXT) {
 		n->m_data = m->m_data + len;
 		MCLADDREFERENCE(m, n);
 	} else {
+		m_align(n, remain);
 		memcpy(mtod(n, void *), mtod(m, char *) + len, remain);
 	}
 



CVS commit: src/sys/kern

2023-11-26 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Nov 27 02:50:27 UTC 2023

Modified Files:
src/sys/kern: uipc_mbuf.c

Log Message:
mbuf: avoid assertion failure when splitting mbuf cluster

>From OpenBSD:

commit 7b4d35e0a60ba1dd4daf4b1c2932020a22463a89
Author: bluhm 
Date:   Fri Oct 20 16:25:15 2023 +

Avoid assertion failure when splitting mbuf cluster.

m_split() calls m_align() to initialize the data pointer of newly
allocated mbuf.  If the new mbuf will be converted to a cluster,
this is not necessary.  If additionally the new mbuf is larger than
MLEN, this can lead to a panic.
Only call m_align() when a valid m_data is needed.  This is the
case if we do not refecence the existing cluster, but memcpy() the
data into the new mbuf.

Reported-by: syzbot+0e6817f5877926f0e...@syzkaller.appspotmail.com
OK claudio@ deraadt@

The issue is harmless if DIAGNOSTIC is not enabled.

XXX pullup-10
XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/sys/kern/uipc_mbuf.c

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



Re: CVS commit: src/share/man/man7

2023-11-26 Thread Valery Ushakov
On Sat, Nov 25, 2023 at 11:36:34 -0800, Alistair Crooks wrote:

> I find it better to have
> 
> MAN+= bar.7
> MAN+= foo.7
> 
> Since a grep for 'MAN.*foo' will produce meaningful results

Also good for diffs in the future, e.g.

 MAN += f.3
-MAN += g.3
 MAN += h.3

vs.

 f.3 \
-g.3 \
 h.3 \


Diff -p *might* do the helpful thing, but it gets confused sometimes.

-uwe


Re: CVS commit: src/share/man/man7

2023-11-26 Thread Alistair Crooks
On Fri, Nov 24, 2023 at 18:09 Taylor R Campbell <
campbell+netbsd-source-change...@mumble.net> wrote:

> > Date: Sat, 25 Nov 2023 02:05:25 +
> > From: Taylor R Campbell 
> >
> > > Date: Sat, 25 Nov 2023 00:23:33 - (UTC)
> > > From: chris...@astron.com (Christos Zoulas)
> > >
> > > Yes, this is indeed a lot better. I prefer though:
> > >
> > > MAN+= \
> > > bar.7 \
> > > foo.7
> > >
> > > It is faster to parse, involves less typing, whitespace is cleaner.
> >
> > This one doesn't have the same pattern for every line, so it makes
> > merging and sorting harder -- do M-x sort-lines on the content lines,
> > and you'll come up with:
> >
> > MAN+= \
> > foo.7
> > bar.7 \
>
> err, obviously I meant this example the other way; if it had been
> written as:
>
> MAN+= \
> foo.7 \
> bar.7
>
> as the natural order of metasyntactic variables (foo, bar), then doing
> M-x sort-lines on the content lines would yield:
>
> MAN+= \
> bar.7
> foo.7 \


I find it better to have

MAN+= bar.7
MAN+= foo.7

Since a grep for 'MAN.*foo' will produce meaningful results

Sorting, and initial entry are once-only operations, searching happens
everywhere all the time.

>
>
>


CVS commit: [netbsd-10] src/doc

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:55:27 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Tickets 460-471, 473, 474


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.159 -r1.1.2.160 src/doc/CHANGES-10.0

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

Modified files:

Index: src/doc/CHANGES-10.0
diff -u src/doc/CHANGES-10.0:1.1.2.159 src/doc/CHANGES-10.0:1.1.2.160
--- src/doc/CHANGES-10.0:1.1.2.159	Wed Nov  8 10:37:54 2023
+++ src/doc/CHANGES-10.0	Sun Nov 26 12:55:26 2023
@@ -1,5 +1,5 @@
 
-# $NetBSD: CHANGES-10.0,v 1.1.2.159 2023/11/08 10:37:54 martin Exp $
+# $NetBSD: CHANGES-10.0,v 1.1.2.160 2023/11/26 12:55:26 bouyer Exp $
 
 A complete list of changes from the initial NetBSD 10.0 branch on 2022-12-16
 until the 10.0 release:
@@ -14086,3 +14086,104 @@ sys/sys/param.h	(manually edited)
 doc/3RDPARTY	(manually edited)
 
 	Adjust libfido2 entry for ticket #345.
+
+sys/dev/pci/if_ena.c1.35-1.40
+sys/dev/pci/if_enavar.h1.9
+sys/external/bsd/ena-com/ena_com.c		1.2-1.4
+sys/external/bsd/ena-com/ena_com.h		1.2
+sys/external/bsd/ena-com/ena_plat.h		1.10
+
+	ena(4): MP-enable always, add RSS support, and reliability fixes.
+	[jdolecek, ticket #460]
+
+etc/MAKEDEV.tmpl1.234
+share/man/man4/gpioirq.4			1.4 via patch
+sys/conf/majors	1.103
+sys/dev/gpio/gpio.c1.73
+sys/dev/gpio/gpioirq.c1.2
+sys/dev/gpio/gpiovar.h1.19
+
+	gpioirq(4): allow multiple pins per gpioirq instance, add the ability
+	to use a /dev/gpioirqN device to get pin interrupts into userland.
+	[brad, ticket #461]
+
+sys/arch/newsmips/dev/dmac_0448.h		1.7
+sys/arch/newsmips/dev/scsi_1185.c		1.25
+
+	Use DELAY(9), not empty for() loop that could be optimized out.
+	[tsutsui, ticket #462]
+
+share/man/man4/gpiosim.4			1.7
+sys/dev/gpio/gpiosim.c1.25
+
+	Simple simulated interrupts for the simulated GPIO device gpiosim(4)
+	[brad, ticket #463]
+
+sys/dev/gpio/gpioirq.c1.3
+
+	Support async I/O against gpioirq(4): O_NONBLOCK reads, and
+	poll(2)/select(2)
+	[brad, ticket #464]
+
+xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c 1.5, 1.6
+
+	Revert r1.4.
+	The changes are minimal and they cause redraw problems (as reported by
+	Maxim Devaev on port-sparc).
+	[jdc, ticket #465]
+
+xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c 1.22
+xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.h 1.5
+xsrc/external/mit/xf86-input-keyboard/dist/src/kbd.c	1.9
+xsrc/external/mit/xf86-input-keyboard/dist/src/ws_KbdMap.c 1.1
+src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile 1.23
+
+	xf86-input-keyboard: add suppport to get keymap via
+	WSKBDIO_GETMAP ioctl(2).
+	[tsutsui, ticket #466]
+
+common/lib/libprop/prop_string.c		1.18
+
+	Fix PR lib/57699: Memory leak in libprop
+	[thorpej, ticket #467]
+
+sys/kern/sys_eventfd.c1.10
+
+	eventfd(2): Fix kernel crash on close after read or write is
+	interrupted by signal, PR kern/57703.
+	[riastradh, ticket #468]
+
+external/gpl3/binutils.old/dist/gas/config/tc-mips.c 1.8
+external/gpl3/binutils/dist/gas/config/tc-mips.c 1.25
+
+	binutils, binutils.old: fix gas that doesn't handle MIPS1 FPR load
+	hazard correctly.  Fixes PR/57680.
+	[tsutsui, ticket #469]
+
+sys/dev/pci/pciide_common.c			1.70
+
+	pciide_dma_dmamap_setup(): If we end up with a DMA segment with an odd
+	length or odd starting address, unload the map and return EINVAL, which
+	should  cause the upper layers in the ATA code to re-try the I/O using
+	PIO.  Fixes PR port-alpha/56434
+	[thorpej, ticket #470]
+
+usr.sbin/sysinst/label.c			1.50
+usr.sbin/sysinst/util.c1.74
+
+	Force alignment of disk buffers to at least 8 byte.
+	Fixes PR 56434.
+	[martin, ticket #471]
+
+crypto/external/bsd/libsaslc/lib/Makefile	1.11
+
+	move line to avoid deprecated declaration errors outside of the
+	kerberos block.
+	[kre, ticket #473]
+
+usr.sbin/sysinst/partman.c			1.57
+
+	PR 57698: avoid installer crashes in restricted (miniroot)
+	environments.
+	[martin, ticket #474]
+



CVS commit: [netbsd-10] src/doc

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:55:27 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Tickets 460-471, 473, 474


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.159 -r1.1.2.160 src/doc/CHANGES-10.0

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



CVS commit: [netbsd-10] src/usr.sbin/sysinst

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:53:08 UTC 2023

Modified Files:
src/usr.sbin/sysinst [netbsd-10]: partman.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #474):
usr.sbin/sysinst/partman.c: revision 1.57
PR 57698: avoid a few potential sysinst crashes in environments where
not all binaries are available - e.g. w/o cgdconfig(8) the "cgds" pointer
would be NULL (as there can't be any) and we crashed when naively
dereferencing it.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.56.2.1 src/usr.sbin/sysinst/partman.c

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

Modified files:

Index: src/usr.sbin/sysinst/partman.c
diff -u src/usr.sbin/sysinst/partman.c:1.56 src/usr.sbin/sysinst/partman.c:1.56.2.1
--- src/usr.sbin/sysinst/partman.c:1.56	Sun Jul 10 10:52:41 2022
+++ src/usr.sbin/sysinst/partman.c	Sun Nov 26 12:53:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: partman.c,v 1.56 2022/07/10 10:52:41 martin Exp $ */
+/*	$NetBSD: partman.c,v 1.56.2.1 2023/11/26 12:53:07 bouyer Exp $ */
 
 /*
  * Copyright 2012 Eugene Lozovoy
@@ -817,6 +817,8 @@ pm_raid_commit(void)
 	FILE *f;
 	char f_name[STRSIZE], devname[STRSIZE];
 
+	if (!have_raid)
+		return 0;
 	for (i = 0; i < MAX_RAID; i++) {
 		if (! pm_raid_check([i]))
 			continue;
@@ -1163,6 +1165,8 @@ pm_vnd_commit(void)
 	part_id id, part_suit = NO_PART;
 	struct disk_part_info info;
 
+	if (!have_vnd)
+		return 0;
 	for (i = 0; i < MAX_VND; i++) {
 		error = 0;
 		if (! pm_vnd_check([i]))
@@ -1454,6 +1458,8 @@ pm_cgd_commit(void)
 	char devname[STRSIZE];
 	int i, error = 0;
 
+	if (!have_cgd)
+		return 0;
 	for (i = 0; i < MAX_CGD; i++) {
 		if (! pm_cgd_check([i]))
 			continue;
@@ -1979,6 +1985,8 @@ pm_lvm_commit(void)
 	uint used_size = 0;
 	char params[STRSIZE*3], devs[STRSIZE*3], arg[STRSIZE];
 
+	if (!have_lvm)
+		return 0;
 	for (i = 0; i < MAX_LVM_VG; i++) {
 		/* Stage 0: checks */
 		if (! pm_lvm_check([i]))
@@ -2118,7 +2126,7 @@ pm_getrefdev(struct pm_devs *pm_cur)
 	char descr[MENUSTRSIZE], dev[MENUSTRSIZE] = "";
 
 	pm_cur->refdev = NULL;
-	if (! strncmp(pm_cur->diskdev, "cgd", 3)) {
+	if (have_cgd && strncmp(pm_cur->diskdev, "cgd", 3) == 0) {
 		dev_num = pm_cur->diskdev[3] - '0';
 		for (i = 0; i < MAX_CGD; i++)
 			if (cgds[i].blocked && cgds[i].node == dev_num) {
@@ -2130,7 +2138,7 @@ pm_getrefdev(struct pm_devs *pm_cur)
 sizeof(pm_cur->diskdev_descr));
 break;
 			}
- 	} else if (! strncmp(pm_cur->diskdev, "vnd", 3)) {
+ 	} else if (have_vnd && strncmp(pm_cur->diskdev, "vnd", 3) == 0) {
  		dev_num = pm_cur->diskdev[3] - '0';
  		for (i = 0; i < MAX_VND; i++)
 			if (vnds[i].blocked && vnds[i].node == dev_num) {
@@ -2145,7 +2153,7 @@ pm_getrefdev(struct pm_devs *pm_cur)
 sizeof(pm_cur->diskdev_descr));
 break;
 			}
-	} else if (! strncmp(pm_cur->diskdev, "raid", 4)) {
+	} else if (have_raid && strncmp(pm_cur->diskdev, "raid", 4) == 0) {
 		dev_num = pm_cur->diskdev[4] - '0';
  		for (i = 0; i < MAX_RAID; i++)
 			if (raids[i].blocked && raids[i].node == dev_num) {
@@ -2237,7 +2245,7 @@ pm_partusage(struct pm_devs *pm_cur, int
 	if (id >= pm_cur->parts->num_part)
 		return 0;
 
-	for (i = 0; i < MAX_CGD; i++)
+	for (i = 0; have_cgd && i < MAX_CGD; i++)
 		if (cgds[i].enabled &&
 			cgds[i].pm == pm_cur &&
 			cgds[i].pm_part == id) {
@@ -2247,7 +2255,7 @@ pm_partusage(struct pm_devs *pm_cur, int
 			}
 			return 1;
 		}
-	for (i = 0; i < MAX_RAID; i++)
+	for (i = 0; have_raid && i < MAX_RAID; i++)
 		for (ii = 0; ii < MAX_IN_RAID; ii++)
 			if (raids[i].enabled &&
 raids[i].comp[ii].parts == pm_cur->parts &&
@@ -2256,7 +2264,7 @@ pm_partusage(struct pm_devs *pm_cur, int
 		raids[i].comp[ii].parts = NULL;
 	return 1;
 			}
-	for (i = 0; i < MAX_LVM_VG; i++)
+	for (i = 0; have_lvm && i < MAX_LVM_VG; i++)
 		for (ii = 0; ii < MAX_LVM_PV; ii++)
 			if (lvms[i].enabled &&
 lvms[i].pv[ii].pm == pm_cur &&



CVS commit: [netbsd-10] src/usr.sbin/sysinst

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:53:08 UTC 2023

Modified Files:
src/usr.sbin/sysinst [netbsd-10]: partman.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #474):
usr.sbin/sysinst/partman.c: revision 1.57
PR 57698: avoid a few potential sysinst crashes in environments where
not all binaries are available - e.g. w/o cgdconfig(8) the "cgds" pointer
would be NULL (as there can't be any) and we crashed when naively
dereferencing it.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.56.2.1 src/usr.sbin/sysinst/partman.c

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



CVS commit: [netbsd-10] src/crypto/external/bsd/libsaslc/lib

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:51:24 UTC 2023

Modified Files:
src/crypto/external/bsd/libsaslc/lib [netbsd-10]: Makefile

Log Message:
Pull up following revision(s) (requested by kre in ticket #473):
crypto/external/bsd/libsaslc/lib/Makefile: revision 1.11
move line to avoid deprecated declaration errors outside of the kerberos b=
lock.


To generate a diff of this commit:
cvs rdiff -u -r1.9.14.1 -r1.9.14.2 \
src/crypto/external/bsd/libsaslc/lib/Makefile

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

Modified files:

Index: src/crypto/external/bsd/libsaslc/lib/Makefile
diff -u src/crypto/external/bsd/libsaslc/lib/Makefile:1.9.14.1 src/crypto/external/bsd/libsaslc/lib/Makefile:1.9.14.2
--- src/crypto/external/bsd/libsaslc/lib/Makefile:1.9.14.1	Fri Aug 11 13:40:10 2023
+++ src/crypto/external/bsd/libsaslc/lib/Makefile	Sun Nov 26 12:51:24 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.9.14.1 2023/08/11 13:40:10 martin Exp $
+# $NetBSD: Makefile,v 1.9.14.2 2023/11/26 12:51:24 bouyer Exp $
 
 .include 
 
@@ -59,7 +59,8 @@ LIBDPLIBS+= ssl ${NETBSDSRCDIR}/crypto/e
 .if (${MKKERBEROS} != "no")
 LIBDPLIBS+= gssapi ${NETBSDSRCDIR}/crypto/external/bsd/heimdal/lib/libgssapi
 
-COPTS.crypto.c+=-Wno-error=deprecated-declarations
 .endif
 
+COPTS.crypto.c+=-Wno-error=deprecated-declarations
+
 .include 



CVS commit: [netbsd-10] src/crypto/external/bsd/libsaslc/lib

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:51:24 UTC 2023

Modified Files:
src/crypto/external/bsd/libsaslc/lib [netbsd-10]: Makefile

Log Message:
Pull up following revision(s) (requested by kre in ticket #473):
crypto/external/bsd/libsaslc/lib/Makefile: revision 1.11
move line to avoid deprecated declaration errors outside of the kerberos b=
lock.


To generate a diff of this commit:
cvs rdiff -u -r1.9.14.1 -r1.9.14.2 \
src/crypto/external/bsd/libsaslc/lib/Makefile

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



CVS commit: [netbsd-10] src/usr.sbin/sysinst

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:40:50 UTC 2023

Modified Files:
src/usr.sbin/sysinst [netbsd-10]: label.c util.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #471):
usr.sbin/sysinst/label.c: revision 1.50
usr.sbin/sysinst/util.c: revision 1.74
Force alignment of disk buffers to at least 8 byte.
Fixes PR 56434.


To generate a diff of this commit:
cvs rdiff -u -r1.46.2.1 -r1.46.2.2 src/usr.sbin/sysinst/label.c
cvs rdiff -u -r1.71.2.1 -r1.71.2.2 src/usr.sbin/sysinst/util.c

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



CVS commit: [netbsd-10] src/usr.sbin/sysinst

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:40:50 UTC 2023

Modified Files:
src/usr.sbin/sysinst [netbsd-10]: label.c util.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #471):
usr.sbin/sysinst/label.c: revision 1.50
usr.sbin/sysinst/util.c: revision 1.74
Force alignment of disk buffers to at least 8 byte.
Fixes PR 56434.


To generate a diff of this commit:
cvs rdiff -u -r1.46.2.1 -r1.46.2.2 src/usr.sbin/sysinst/label.c
cvs rdiff -u -r1.71.2.1 -r1.71.2.2 src/usr.sbin/sysinst/util.c

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

Modified files:

Index: src/usr.sbin/sysinst/label.c
diff -u src/usr.sbin/sysinst/label.c:1.46.2.1 src/usr.sbin/sysinst/label.c:1.46.2.2
--- src/usr.sbin/sysinst/label.c:1.46.2.1	Thu Nov  2 14:08:17 2023
+++ src/usr.sbin/sysinst/label.c	Sun Nov 26 12:40:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: label.c,v 1.46.2.1 2023/11/02 14:08:17 sborrill Exp $	*/
+/*	$NetBSD: label.c,v 1.46.2.2 2023/11/26 12:40:50 bouyer Exp $	*/
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -36,7 +36,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: label.c,v 1.46.2.1 2023/11/02 14:08:17 sborrill Exp $");
+__RCSID("$NetBSD: label.c,v 1.46.2.2 2023/11/26 12:40:50 bouyer Exp $");
 #endif
 
 #include 
@@ -1965,7 +1965,7 @@ const char *
 get_last_mounted(int fd, daddr_t partstart, uint *fs_type, uint *fs_sub_type,
 uint flags)
 {
-	static char sblk[SBLOCKSIZE];		/* is this enough? */
+	static char sblk[SBLOCKSIZE] __aligned(8);	/* is this enough? */
 	struct fs *SB = (struct fs *)sblk;
 	static const off_t sblocks[] = SBLOCKSEARCH;
 	const off_t *sbp;

Index: src/usr.sbin/sysinst/util.c
diff -u src/usr.sbin/sysinst/util.c:1.71.2.1 src/usr.sbin/sysinst/util.c:1.71.2.2
--- src/usr.sbin/sysinst/util.c:1.71.2.1	Sat Sep  9 14:50:15 2023
+++ src/usr.sbin/sysinst/util.c	Sun Nov 26 12:40:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.71.2.1 2023/09/09 14:50:15 martin Exp $	*/
+/*	$NetBSD: util.c,v 1.71.2.2 2023/11/26 12:40:50 bouyer Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -398,7 +398,7 @@ static int
 get_iso9660_volname(int dev, int sess, char *volname, size_t volnamelen)
 {
 	int blkno, error, last;
-	char buf[ISO_BLKSIZE];
+	static char buf[ISO_BLKSIZE] __aligned(8);
 	struct iso_volume_descriptor *vd = NULL;
 	struct iso_primary_descriptor *pd = NULL;
 



CVS commit: [netbsd-10] src/sys/dev/pci

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:38:56 UTC 2023

Modified Files:
src/sys/dev/pci [netbsd-10]: pciide_common.c

Log Message:
Pull up following revision(s) (requested by thorpej in ticket #470):
sys/dev/pci/pciide_common.c: revision 1.70
pciide_dma_dmamap_setup(): If we end up with a DMA segment with an odd
length or odd starting address, unload the map and return EINVAL.  Some
controllers get really upset if a DMA segment has an odd address or length.
This can happen if a physio user performs a virtually-contiguous I/O that
starts at an odd address and spans a page boundary where the resulting
physical pages are discontiguous.  The EINVAL return will cause the upper
layers in the ATA code to re-try the I/O using PIO, which should (will
in all of my tests) succeed.
PR port-alpha/56434


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.67.20.1 src/sys/dev/pci/pciide_common.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/pciide_common.c
diff -u src/sys/dev/pci/pciide_common.c:1.67 src/sys/dev/pci/pciide_common.c:1.67.20.1
--- src/sys/dev/pci/pciide_common.c:1.67	Mon Aug 24 05:37:41 2020
+++ src/sys/dev/pci/pciide_common.c	Sun Nov 26 12:38:56 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pciide_common.c,v 1.67 2020/08/24 05:37:41 msaitoh Exp $	*/
+/*	$NetBSD: pciide_common.c,v 1.67.20.1 2023/11/26 12:38:56 bouyer Exp $	*/
 
 
 /*
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pciide_common.c,v 1.67 2020/08/24 05:37:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pciide_common.c,v 1.67.20.1 2023/11/26 12:38:56 bouyer Exp $");
 
 #include 
 
@@ -721,25 +721,51 @@ pciide_dma_dmamap_setup(struct pciide_so
 	BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
 
 	for (seg = 0; seg < dma_maps->dmamap_xfer->dm_nsegs; seg++) {
+		bus_addr_t phys = dma_maps->dmamap_xfer->dm_segs[seg].ds_addr;
+		bus_size_t len = dma_maps->dmamap_xfer->dm_segs[seg].ds_len;
+
 #ifdef DIAGNOSTIC
 		/* A segment must not cross a 64k boundary */
 		{
-		u_long phys = dma_maps->dmamap_xfer->dm_segs[seg].ds_addr;
-		u_long len = dma_maps->dmamap_xfer->dm_segs[seg].ds_len;
 		if ((phys & ~IDEDMA_BYTE_COUNT_MASK) !=
 		((phys + len - 1) & ~IDEDMA_BYTE_COUNT_MASK)) {
-			printf("pciide_dma: segment %d physical addr 0x%lx"
-			" len 0x%lx not properly aligned\n",
-			seg, phys, len);
+			printf("pciide_dma: seg %d addr 0x%" PRIx64
+			" len 0x%" PRIx64 " not properly aligned\n",
+			seg, (uint64_t)phys, (uint64_t)len);
 			panic("pciide_dma: buf align");
 		}
 		}
 #endif
-		dma_maps->dma_table[seg].base_addr =
-		htole32(dma_maps->dmamap_xfer->dm_segs[seg].ds_addr);
+		/*
+		 * Some controllers get really upset if the length
+		 * of any DMA segment is odd.  This isn't something
+		 * that's going to happen in normal steady-state
+		 * operation (reading VM pages, etc.), but physio users
+		 * don't have as many guard rails.
+		 *
+		 * Consider an 8K read request that starts at an odd
+		 * offset within a page.  At first blush, all of the
+		 * checks pass because it's a sector-rounded size, but
+		 * unless the buffer spans 2 physically contiguous pages,
+		 * it's going to result in 2 odd-length DMA segments.
+		 *
+		 * Odd start addresses are also frowned upon, so we
+		 * catch those here, too.
+		 *
+		 * Returning EINVAL here will cause the upper layers to
+		 * fall back onto PIO.
+		 */
+		if ((phys & 1) != 0 || (len & 1) != 0) {
+			aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev,
+			"Invalid DMA segment: "
+			"seg %d addr 0x%" PRIx64 " len 0x%" PRIx64 "\n",
+			seg, (uint64_t)phys, (uint64_t)len);
+			bus_dmamap_unload(sc->sc_dmat, dma_maps->dmamap_xfer);
+			return EINVAL;
+		}
+		dma_maps->dma_table[seg].base_addr = htole32(phys);
 		dma_maps->dma_table[seg].byte_count =
-		htole32(dma_maps->dmamap_xfer->dm_segs[seg].ds_len &
-		IDEDMA_BYTE_COUNT_MASK);
+		htole32(len & IDEDMA_BYTE_COUNT_MASK);
 		ATADEBUG_PRINT(("\t seg %d len %d addr 0x%x\n",
 		   seg, le32toh(dma_maps->dma_table[seg].byte_count),
 		   le32toh(dma_maps->dma_table[seg].base_addr)), DEBUG_DMA);



CVS commit: [netbsd-10] src/sys/dev/pci

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:38:56 UTC 2023

Modified Files:
src/sys/dev/pci [netbsd-10]: pciide_common.c

Log Message:
Pull up following revision(s) (requested by thorpej in ticket #470):
sys/dev/pci/pciide_common.c: revision 1.70
pciide_dma_dmamap_setup(): If we end up with a DMA segment with an odd
length or odd starting address, unload the map and return EINVAL.  Some
controllers get really upset if a DMA segment has an odd address or length.
This can happen if a physio user performs a virtually-contiguous I/O that
starts at an odd address and spans a page boundary where the resulting
physical pages are discontiguous.  The EINVAL return will cause the upper
layers in the ATA code to re-try the I/O using PIO, which should (will
in all of my tests) succeed.
PR port-alpha/56434


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.67.20.1 src/sys/dev/pci/pciide_common.c

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



CVS commit: [netbsd-10] src/external/gpl3

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:35:26 UTC 2023

Modified Files:
src/external/gpl3/binutils.old/dist/gas/config [netbsd-10]: tc-mips.c
src/external/gpl3/binutils/dist/gas/config [netbsd-10]: tc-mips.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #469):
external/gpl3/binutils/dist/gas/config/tc-mips.c: revision 1.25
external/gpl3/binutils.old/dist/gas/config/tc-mips.c: revision 1.8
binutils: fix gas that doesn't handle MIPS1 FPR load hazard correctly.
Fixes PR/57680.
Should be pulled up to netbsd-10, netbsd-9, and netbsd-8.
binutils.old: apply the same fix for mips gas from binutils.
binutils: fix gas that doesn't handle MIPS1 FPR load hazard correctly.
Fixes PR/57680.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.6.1 \
src/external/gpl3/binutils.old/dist/gas/config/tc-mips.c
cvs rdiff -u -r1.22 -r1.22.6.1 \
src/external/gpl3/binutils/dist/gas/config/tc-mips.c

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

Modified files:

Index: src/external/gpl3/binutils.old/dist/gas/config/tc-mips.c
diff -u src/external/gpl3/binutils.old/dist/gas/config/tc-mips.c:1.6 src/external/gpl3/binutils.old/dist/gas/config/tc-mips.c:1.6.6.1
--- src/external/gpl3/binutils.old/dist/gas/config/tc-mips.c:1.6	Fri Apr  3 17:51:09 2020
+++ src/external/gpl3/binutils.old/dist/gas/config/tc-mips.c	Sun Nov 26 12:35:26 2023
@@ -6440,8 +6440,8 @@ insns_between (const struct mips_cl_insn
   /* Itbl support may require additional care here. FIXME!
 	 Need to modify this to include knowledge about
 	 user specified delays!  */
-  else if ((!cop_interlocks && (pinfo1 & INSN_COPROC_MOVE))
-	   || (!cop_mem_interlocks && (pinfo1 & INSN_COPROC_MEMORY_DELAY)))
+  if ((!cop_interlocks && (pinfo1 & INSN_COPROC_MOVE))
+	 || (!cop_mem_interlocks && (pinfo1 & INSN_COPROC_MEMORY_DELAY)))
 	{
 	  /* Handle cases where INSN1 writes to a known general coprocessor
 	 register.  There must be a one instruction delay before INSN2

Index: src/external/gpl3/binutils/dist/gas/config/tc-mips.c
diff -u src/external/gpl3/binutils/dist/gas/config/tc-mips.c:1.22 src/external/gpl3/binutils/dist/gas/config/tc-mips.c:1.22.6.1
--- src/external/gpl3/binutils/dist/gas/config/tc-mips.c:1.22	Fri Apr  3 23:48:47 2020
+++ src/external/gpl3/binutils/dist/gas/config/tc-mips.c	Sun Nov 26 12:35:26 2023
@@ -6529,8 +6529,8 @@ insns_between (const struct mips_cl_insn
   /* Itbl support may require additional care here. FIXME!
 	 Need to modify this to include knowledge about
 	 user specified delays!  */
-  else if ((!cop_interlocks && (pinfo1 & INSN_COPROC_MOVE))
-	   || (!cop_mem_interlocks && (pinfo1 & INSN_COPROC_MEMORY_DELAY)))
+  if ((!cop_interlocks && (pinfo1 & INSN_COPROC_MOVE))
+	 || (!cop_mem_interlocks && (pinfo1 & INSN_COPROC_MEMORY_DELAY)))
 	{
 	  /* Handle cases where INSN1 writes to a known general coprocessor
 	 register.  There must be a one instruction delay before INSN2



CVS commit: [netbsd-10] src/external/gpl3

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:35:26 UTC 2023

Modified Files:
src/external/gpl3/binutils.old/dist/gas/config [netbsd-10]: tc-mips.c
src/external/gpl3/binutils/dist/gas/config [netbsd-10]: tc-mips.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #469):
external/gpl3/binutils/dist/gas/config/tc-mips.c: revision 1.25
external/gpl3/binutils.old/dist/gas/config/tc-mips.c: revision 1.8
binutils: fix gas that doesn't handle MIPS1 FPR load hazard correctly.
Fixes PR/57680.
Should be pulled up to netbsd-10, netbsd-9, and netbsd-8.
binutils.old: apply the same fix for mips gas from binutils.
binutils: fix gas that doesn't handle MIPS1 FPR load hazard correctly.
Fixes PR/57680.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.6.1 \
src/external/gpl3/binutils.old/dist/gas/config/tc-mips.c
cvs rdiff -u -r1.22 -r1.22.6.1 \
src/external/gpl3/binutils/dist/gas/config/tc-mips.c

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



CVS commit: [netbsd-10] src/sys/kern

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:33:19 UTC 2023

Modified Files:
src/sys/kern [netbsd-10]: sys_eventfd.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #468):
sys/kern/sys_eventfd.c: revision 1.10
eventfd(2): Omit needless micro-optimization causing PR kern/57703.
Unfortunately, owing to PR kern/57705 and PR misc/57706, it isn't
convenient to flip the xfail switch on a test for this bug.  So we'll
do that separately.  (But I did verify that a rumpified version of
the test postd to PR kern/57703 failed without this change, and
passed with this change.)
PR kern/57703
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/kern/sys_eventfd.c

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



CVS commit: [netbsd-10] src/sys/kern

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:33:19 UTC 2023

Modified Files:
src/sys/kern [netbsd-10]: sys_eventfd.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #468):
sys/kern/sys_eventfd.c: revision 1.10
eventfd(2): Omit needless micro-optimization causing PR kern/57703.
Unfortunately, owing to PR kern/57705 and PR misc/57706, it isn't
convenient to flip the xfail switch on a test for this bug.  So we'll
do that separately.  (But I did verify that a rumpified version of
the test postd to PR kern/57703 failed without this change, and
passed with this change.)
PR kern/57703
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/kern/sys_eventfd.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/kern/sys_eventfd.c
diff -u src/sys/kern/sys_eventfd.c:1.9 src/sys/kern/sys_eventfd.c:1.9.4.1
--- src/sys/kern/sys_eventfd.c:1.9	Thu Feb 17 16:28:29 2022
+++ src/sys/kern/sys_eventfd.c	Sun Nov 26 12:33:19 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_eventfd.c,v 1.9 2022/02/17 16:28:29 thorpej Exp $	*/
+/*	$NetBSD: sys_eventfd.c,v 1.9.4.1 2023/11/26 12:33:19 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_eventfd.c,v 1.9 2022/02/17 16:28:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_eventfd.c,v 1.9.4.1 2023/11/26 12:33:19 bouyer Exp $");
 
 /*
  * eventfd
@@ -69,8 +69,6 @@ struct eventfd {
 	eventfd_t	efd_val;
 	int64_t		efd_nwaiters;
 	bool		efd_restarting;
-	bool		efd_has_read_waiters;
-	bool		efd_has_write_waiters;
 	bool		efd_is_semaphore;
 
 	/*
@@ -117,8 +115,6 @@ eventfd_destroy(struct eventfd * const e
 {
 
 	KASSERT(efd->efd_nwaiters == 0);
-	KASSERT(efd->efd_has_read_waiters == false);
-	KASSERT(efd->efd_has_write_waiters == false);
 
 	cv_destroy(>efd_read_wait);
 	cv_destroy(>efd_write_wait);
@@ -155,10 +151,8 @@ eventfd_wait(struct eventfd * const efd,
 	}
 
 	if (is_write) {
-		efd->efd_has_write_waiters = true;
 		waitcv = >efd_write_wait;
 	} else {
-		efd->efd_has_read_waiters = true;
 		waitcv = >efd_read_wait;
 	}
 
@@ -194,17 +188,11 @@ eventfd_wake(struct eventfd * const efd,
 	int pollev;
 
 	if (is_write) {
-		if (efd->efd_has_read_waiters) {
-			waitcv = >efd_read_wait;
-			efd->efd_has_read_waiters = false;
-		}
+		waitcv = >efd_read_wait;
 		sel = >efd_read_sel;
 		pollev = POLLIN | POLLRDNORM;
 	} else {
-		if (efd->efd_has_write_waiters) {
-			waitcv = >efd_write_wait;
-			efd->efd_has_write_waiters = false;
-		}
+		waitcv = >efd_write_wait;
 		sel = >efd_write_sel;
 		pollev = POLLOUT | POLLWRNORM;
 	}
@@ -537,14 +525,8 @@ eventfd_fop_restart(file_t * const fp)
 
 	if (efd->efd_nwaiters != 0) {
 		efd->efd_restarting = true;
-		if (efd->efd_has_read_waiters) {
-			cv_broadcast(>efd_read_wait);
-			efd->efd_has_read_waiters = false;
-		}
-		if (efd->efd_has_write_waiters) {
-			cv_broadcast(>efd_write_wait);
-			efd->efd_has_write_waiters = false;
-		}
+		cv_broadcast(>efd_read_wait);
+		cv_broadcast(>efd_write_wait);
 	}
 
 	mutex_exit(>efd_lock);



CVS commit: [netbsd-10] src/common/lib/libprop

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:29:49 UTC 2023

Modified Files:
src/common/lib/libprop [netbsd-10]: prop_string.c

Log Message:
Pull up following revision(s) (requested by thorpej in ticket #467):
common/lib/libprop/prop_string.c: revision 1.18
In _prop_string_instantiate(), when we de-dup a non-MUTABLE string, make
sure we free the provided string buffer if NOCOPY is not set.  Fixes
a memory leak reported by M. Boerschig.
While we're at it, also change _prop_string_instantiate() to free the
provided string buffer in the not-NOCOPY case when string object allocation
fails (this was previously handled by _prop_string_instantiate()'s
callers).
PR lib/57699


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.17.2.1 src/common/lib/libprop/prop_string.c

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

Modified files:

Index: src/common/lib/libprop/prop_string.c
diff -u src/common/lib/libprop/prop_string.c:1.17 src/common/lib/libprop/prop_string.c:1.17.2.1
--- src/common/lib/libprop/prop_string.c:1.17	Wed Aug  3 21:13:46 2022
+++ src/common/lib/libprop/prop_string.c	Sun Nov 26 12:29:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: prop_string.c,v 1.17 2022/08/03 21:13:46 riastradh Exp $	*/
+/*	$NetBSD: prop_string.c,v 1.17.2.1 2023/11/26 12:29:49 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2020 The NetBSD Foundation, Inc.
@@ -247,12 +247,18 @@ _prop_string_instantiate(int const flags
  */
 prop_object_retain(ops);
 _PROP_MUTEX_UNLOCK(_prop_string_tree_mutex);
+if ((flags & PS_F_NOCOPY) == 0) {
+	_PROP_FREE(ps->ps_mutable,
+	M_PROP_STRING);
+}
 _PROP_POOL_PUT(_prop_string_pool, ps);
 ps = ops;
 			} else {
 _PROP_MUTEX_UNLOCK(_prop_string_tree_mutex);
 			}
 		}
+	} else if ((flags & PS_F_NOCOPY) == 0) {
+		_PROP_FREE(__UNCONST(str), M_PROP_STRING);
 	}
 
 	return (ps);
@@ -311,7 +317,6 @@ prop_string_create_cstring_nocopy(const 
 prop_string_t __printflike(1, 2)
 prop_string_create_format(const char *fmt, ...)
 {
-	prop_string_t ps;
 	char *str = NULL;
 	int len;
 	size_t nlen;
@@ -335,11 +340,7 @@ prop_string_create_format(const char *fm
 	vsnprintf(str, nlen, fmt, ap);
 	va_end(ap);
 
-	ps = _prop_string_instantiate(0, str, (size_t)len);
-	if (ps == NULL)
-		_PROP_FREE(str, M_PROP_STRING);
-
-	return (ps);
+	return _prop_string_instantiate(0, str, (size_t)len);
 }
 
 /*
@@ -374,7 +375,6 @@ prop_string_create_nocopy(const char *st
 prop_string_t
 prop_string_copy(prop_string_t ops)
 {
-	prop_string_t ps;
 	char *cp;
 
 	if (! prop_object_is_string(ops))
@@ -391,11 +391,7 @@ prop_string_copy(prop_string_t ops)
 
 	strcpy(cp, prop_string_contents(ops));
 
-	ps = _prop_string_instantiate(PS_F_MUTABLE, cp, ops->ps_size);
-	if (ps == NULL)
-		_PROP_FREE(cp, M_PROP_STRING);
-
-	return (ps);
+	return _prop_string_instantiate(PS_F_MUTABLE, cp, ops->ps_size);
 }
 
 _PROP_DEPRECATED(prop_string_copy_mutable,
@@ -404,7 +400,6 @@ _PROP_DEPRECATED(prop_string_copy_mutabl
 prop_string_t
 prop_string_copy_mutable(prop_string_t ops)
 {
-	prop_string_t ps;
 	char *cp;
 
 	if (! prop_object_is_string(ops))
@@ -416,11 +411,7 @@ prop_string_copy_mutable(prop_string_t o
 
 	strcpy(cp, prop_string_contents(ops));
 
-	ps = _prop_string_instantiate(PS_F_MUTABLE, cp, ops->ps_size);
-	if (ps == NULL)
-		_PROP_FREE(cp, M_PROP_STRING);
-
-	return (ps);
+	return _prop_string_instantiate(PS_F_MUTABLE, cp, ops->ps_size);
 }
 
 /*
@@ -655,7 +646,6 @@ bool
 _prop_string_internalize(prop_stack_t stack, prop_object_t *obj,
 struct _prop_object_internalize_context *ctx)
 {
-	prop_string_t string;
 	char *str;
 	size_t len, alen;
 
@@ -691,10 +681,6 @@ _prop_string_internalize(prop_stack_t st
 		return (true);
 	}
 
-	string = _prop_string_instantiate(0, str, len);
-	if (string == NULL)
-		_PROP_FREE(str, M_PROP_STRING);
-
-	*obj = string;
+	*obj = _prop_string_instantiate(0, str, len);
 	return (true);
 }



CVS commit: [netbsd-10] src/common/lib/libprop

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:29:49 UTC 2023

Modified Files:
src/common/lib/libprop [netbsd-10]: prop_string.c

Log Message:
Pull up following revision(s) (requested by thorpej in ticket #467):
common/lib/libprop/prop_string.c: revision 1.18
In _prop_string_instantiate(), when we de-dup a non-MUTABLE string, make
sure we free the provided string buffer if NOCOPY is not set.  Fixes
a memory leak reported by M. Boerschig.
While we're at it, also change _prop_string_instantiate() to free the
provided string buffer in the not-NOCOPY case when string object allocation
fails (this was previously handled by _prop_string_instantiate()'s
callers).
PR lib/57699


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.17.2.1 src/common/lib/libprop/prop_string.c

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



CVS commit: [netbsd-10]

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:26:23 UTC 2023

Modified Files:
src/external/mit/xorg/server/drivers/xf86-input-keyboard [netbsd-10]:
Makefile
xsrc/external/mit/xf86-input-keyboard/dist/src [netbsd-10]: bsd_kbd.c
bsd_kbd.h kbd.c
Added Files:
xsrc/external/mit/xf86-input-keyboard/dist/src [netbsd-10]: ws_KbdMap.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #466):
xsrc/external/mit/xf86-input-keyboard/dist/src/ws_KbdMap.c: revision 1.1
xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.h: revision 1.5
xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c: revision 1.22
xsrc/external/mit/xf86-input-keyboard/dist/src/kbd.c: revision 1.9
src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile: 
revision 1.23
xf86-input-keyboard: add suppport to get keymap via WSKBDIO_GETMAP ioctl(2).
No particular comment on tech-x11@:
 https://mail-index.netbsd.org/tech-x11/2023/10/31/msg002415.html
 https://mail-index.netbsd.org/tech-x11/2023/11/04/msg002416.html
Tested on NWS-3260 and NWS-3470 with Xorg 1.10 server in netbsd-9.
Worth to pullup to netbsd-10 and netbsd-9.
xf86-input-keyboard: add build glue to enable USE_WSKBD_GETMAP.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.22.2.1 \
src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile
cvs rdiff -u -r1.21 -r1.21.6.1 \
xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c
cvs rdiff -u -r1.4 -r1.4.14.1 \
xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.h
cvs rdiff -u -r1.8 -r1.8.2.1 \
xsrc/external/mit/xf86-input-keyboard/dist/src/kbd.c
cvs rdiff -u -r0 -r1.1.2.2 \
xsrc/external/mit/xf86-input-keyboard/dist/src/ws_KbdMap.c

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

Modified files:

Index: src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile
diff -u src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile:1.22 src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile:1.22.2.1
--- src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile:1.22	Wed Dec 15 15:27:30 2021
+++ src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile	Sun Nov 26 12:26:23 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.22 2021/12/15 15:27:30 christos Exp $
+#	$NetBSD: Makefile,v 1.22.2.1 2023/11/26 12:26:23 bouyer Exp $
 
 DRIVER=		xf86-input-keyboard
 DRIVER_NAME=	kbd_drv
@@ -16,7 +16,9 @@ CPPFLAGS+=	-DPCVT_SUPPORT
 .if ${MACHINE_ARCH} == "powerpc" || \
 ${MACHINE} == "amiga" || \
 ${MACHINE} == "evbarm" || \
+${MACHINE} == "ews4800mips" || \
 ${MACHINE} == "mac68k" || \
+${MACHINE} == "newsmips" || \
 ${MACHINE} == "pmax" || \
 ${MACHINE} == "sgimips" || \
 ${MACHINE} == "shark" || \
@@ -30,6 +32,14 @@ CPPFLAGS+=	-DWSCONS_SUPPORT
 CPPFLAGS+=	-DXKB
 CPPFLAGS.kbd.c=	-D__XKBDEFRULES__=${__XKBDEFRULES__}
 
+.if \
+${MACHINE} == "ews4800mips"	|| \
+${MACHINE} == "newsmips"	|| \
+0
+CPPFLAGS+=	-DUSE_WSKBD_GETMAP
+SRCS+=		ws_KbdMap.c
+.endif
+
 X11EXTRAMANDEFS+=	-e 's,__xkb_path__,${X11LIBDIR}/xkb,g'
 
 COPTS.kbd.c=		-Wno-error	# XXX deprecated

Index: xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c
diff -u xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c:1.21 xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c:1.21.6.1
--- xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c:1.21	Thu Nov 12 12:03:58 2015
+++ xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c	Sun Nov 26 12:26:22 2023
@@ -445,12 +445,14 @@ OpenKeyboard(InputInfoPtr pInfo)
case WSKBD_TYPE_PC_AT:
printWsType("AT", pInfo->name);
break;
+#ifndef USE_WSKBD_GETMAP
case 0:
/* If wsKbdType==0, no keyboard attached to the mux. Assume USB. */
xf86Msg(X_WARNING, "%s: No keyboard attached, assuming USB\n",
   pInfo->name);
pKbd->wsKbdType = WSKBD_TYPE_USB;
/* FALLTHROUGH */
+#endif
case WSKBD_TYPE_USB:
printWsType("USB", pInfo->name);
break;
@@ -484,6 +486,9 @@ OpenKeyboard(InputInfoPtr pInfo)
printWsType("Sun5", pInfo->name);
break;
 #endif
+#ifdef USE_WSKBD_GETMAP
+   case 0:
+#endif
default:
xf86Msg(X_WARNING, "%s: Unsupported wskbd type \"%d\"\n",
   pInfo->name, pKbd->wsKbdType);
@@ -506,7 +511,11 @@ xf86OSKbdPreInit(InputInfoPtr pInfo)
 pKbd->Bell		= SoundBell;
 pKbd->SetLeds	= SetKbdLeds;
 pKbd->GetLeds	= GetKbdLeds;
+#ifdef USE_WSKBD_GETMAP
+pKbd->KbdGetMapping	= KbdGetMappingFromWsksym;
+#else
 pKbd->KbdGetMapping	= KbdGetMapping;
+#endif
 
 pKbd->RemapScanCode = NULL;
 

Index: 

CVS commit: [netbsd-10]

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:26:23 UTC 2023

Modified Files:
src/external/mit/xorg/server/drivers/xf86-input-keyboard [netbsd-10]:
Makefile
xsrc/external/mit/xf86-input-keyboard/dist/src [netbsd-10]: bsd_kbd.c
bsd_kbd.h kbd.c
Added Files:
xsrc/external/mit/xf86-input-keyboard/dist/src [netbsd-10]: ws_KbdMap.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #466):
xsrc/external/mit/xf86-input-keyboard/dist/src/ws_KbdMap.c: revision 1.1
xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.h: revision 1.5
xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c: revision 1.22
xsrc/external/mit/xf86-input-keyboard/dist/src/kbd.c: revision 1.9
src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile: 
revision 1.23
xf86-input-keyboard: add suppport to get keymap via WSKBDIO_GETMAP ioctl(2).
No particular comment on tech-x11@:
 https://mail-index.netbsd.org/tech-x11/2023/10/31/msg002415.html
 https://mail-index.netbsd.org/tech-x11/2023/11/04/msg002416.html
Tested on NWS-3260 and NWS-3470 with Xorg 1.10 server in netbsd-9.
Worth to pullup to netbsd-10 and netbsd-9.
xf86-input-keyboard: add build glue to enable USE_WSKBD_GETMAP.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.22.2.1 \
src/external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile
cvs rdiff -u -r1.21 -r1.21.6.1 \
xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c
cvs rdiff -u -r1.4 -r1.4.14.1 \
xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.h
cvs rdiff -u -r1.8 -r1.8.2.1 \
xsrc/external/mit/xf86-input-keyboard/dist/src/kbd.c
cvs rdiff -u -r0 -r1.1.2.2 \
xsrc/external/mit/xf86-input-keyboard/dist/src/ws_KbdMap.c

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



CVS commit: [netbsd-10] xsrc/external/mit/xf86-video-pnozz/dist/src

2023-11-26 Thread Manuel Bouyer
Module Name:xsrc
Committed By:   bouyer
Date:   Sun Nov 26 12:19:22 UTC 2023

Modified Files:
xsrc/external/mit/xf86-video-pnozz/dist/src [netbsd-10]: pnozz_exa.c

Log Message:
Pull up following revision(s) (requested by jdc in ticket #465):
external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c: revision 1.5
external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c: revision 1.6
Revert r1.4.
The changes are minimal and they cause redraw problems (as reported by
Maxim Devaev on port-sparc).
Add NetBSD keyword.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.2.1 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c

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

Modified files:

Index: xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c
diff -u xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.4 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.4.2.1
--- xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.4	Wed Jun  9 07:25:57 2021
+++ xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c	Sun Nov 26 12:19:22 2023
@@ -1,6 +1,7 @@
 /*
  * SBus Weitek P9100 EXA support
- *
+ */
+/*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -28,6 +29,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+/* $NetBSD: pnozz_exa.c,v 1.4.2.1 2023/11/26 12:19:22 bouyer Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -78,9 +80,11 @@ static CARD32 PnozzDrawROP[] = {
 #define waitReady(pPnozz) while((pnozz_read_4(pPnozz, ENGINE_STATUS) & \
 (ENGINE_BUSY | BLITTER_BUSY)) !=0 )
 
-/* From pnozz_accel.c */
+void PnozzInitEngine(PnozzPtr);
 void pnozz_write_colour(PnozzPtr pPnozz, int reg, CARD32 colour);
 
+extern CARD32 MaxClip, junk;
+
 static void
 PnozzWaitMarker(ScreenPtr pScreen, int Marker)
 {
@@ -107,10 +111,8 @@ PnozzPrepareCopy
 waitReady(pPnozz);
 pnozz_write_4(pPnozz, RASTER_OP, (PnozzCopyROP[alu] & 0xff));
 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
-pPnozz->srcoff = exaGetPixmapOffset(pSrcPixmap);
+pPnozz->srcoff = exaGetPixmapOffset(pSrcPixmap) / pPnozz->width;
 
-if (exaGetPixmapPitch(pSrcPixmap) != exaGetPixmapPitch(pDstPixmap))
-	return FALSE;
 return TRUE;
 }
 
@@ -129,25 +131,24 @@ PnozzCopy
 ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
 CARD32 src, dst, srcw, dstw;
-int soff = pPnozz->srcoff / exaGetPixmapPitch(pDstPixmap);
-int doff = exaGetPixmapOffset(pDstPixmap) / exaGetPixmapPitch(pDstPixmap);
+int doff = exaGetPixmapOffset(pDstPixmap) / pPnozz->width;
 
 src = (((xSrc << pPnozz->depthshift) & 0x1fff) << 16) |
-	((ySrc + soff) & 0x1fff);
+	((ySrc + pPnozz->srcoff) & 0x1fff);
 dst = (((xDst << pPnozz->depthshift) & 0x1fff) << 16) |
 	((yDst + doff) & 0x1fff);
-srcw = xSrc + w) << pPnozz->depthshift) - 1) << 16) |
-	((ySrc + soff + h) & 0x1fff);
+srcw = xSrc + w) << pPnozz->depthshift) - 1) << 16) | 
+((ySrc + pPnozz->srcoff + h - 1) & 0x1fff);
 dstw = xDst + w) << pPnozz->depthshift) - 1) << 16) |
-	((yDst + doff + h) & 0x1fff);
+((yDst + doff + h - 1) & 0x1fff);
 
 waitReady(pPnozz);
+
 pnozz_write_4(pPnozz, ABS_XY0, src);
 pnozz_write_4(pPnozz, ABS_XY1, srcw);
 pnozz_write_4(pPnozz, ABS_XY2, dst);
 pnozz_write_4(pPnozz, ABS_XY3, dstw);
-pnozz_read_4(pPnozz, COMMAND_BLIT);
-
+junk = pnozz_read_4(pPnozz, COMMAND_BLIT);
 exaMarkSync(pDstPixmap->drawable.pScreen);
 }
 
@@ -172,8 +173,7 @@ PnozzPrepareSolid(
 
 waitReady(pPnozz);
 pnozz_write_colour(pPnozz, FOREGROUND_COLOR, fg);
-pnozz_write_colour(pPnozz, BACKGROUND_COLOR, fg);
-pnozz_write_4(pPnozz, RASTER_OP, ROP_PAT);
+pnozz_write_4(pPnozz, RASTER_OP, PnozzDrawROP[alu] & 0xff);
 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
 pnozz_write_4(pPnozz, COORD_INDEX, 0);
 
@@ -190,18 +190,15 @@ PnozzSolid(
 {
 ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
-int doff = exaGetPixmapOffset(pPixmap);
+int w = x2 - x - 1;
+int h = y2 - y - 1;
 
 waitReady(pPnozz);
-pnozz_write_4(pPnozz, ABS_XY0, (((x + doff) & 0x1fff) << 16) |
-	(y & 0x1fff));
-pnozz_write_4(pPnozz, ABS_XY1, (((x + doff) & 0x1fff) << 16) |
-	(y2 & 0x1fff));
-pnozz_write_4(pPnozz, ABS_XY2, (((x2 + doff) & 0x1fff) << 16) |
-	(y2 & 0x1fff));
-pnozz_write_4(pPnozz, ABS_XY3, (((x2 + doff) & 0x1fff) << 16) |
-	(y & 0x1fff));
-pnozz_read_4(pPnozz, COMMAND_QUAD);
+pnozz_write_4(pPnozz, RECT_RTW_XY, ((x & 0x1fff) << 16) | 
+(y & 0x1fff));
+pnozz_write_4(pPnozz, RECT_RTP_XY, (((w & 0x1fff) << 16) | 
+(h & 0x1fff)));
+junk = pnozz_read_4(pPnozz, COMMAND_QUAD);
 

CVS commit: [netbsd-10] xsrc/external/mit/xf86-video-pnozz/dist/src

2023-11-26 Thread Manuel Bouyer
Module Name:xsrc
Committed By:   bouyer
Date:   Sun Nov 26 12:19:22 UTC 2023

Modified Files:
xsrc/external/mit/xf86-video-pnozz/dist/src [netbsd-10]: pnozz_exa.c

Log Message:
Pull up following revision(s) (requested by jdc in ticket #465):
external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c: revision 1.5
external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c: revision 1.6
Revert r1.4.
The changes are minimal and they cause redraw problems (as reported by
Maxim Devaev on port-sparc).
Add NetBSD keyword.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.2.1 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c

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



CVS commit: [netbsd-10] src/sys/dev/gpio

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:16:31 UTC 2023

Modified Files:
src/sys/dev/gpio [netbsd-10]: gpioirq.c

Log Message:
Pull up following revision(s) (requested by brad in ticket #464):
sys/dev/gpio/gpioirq.c: revision 1.3
For /dev/ reads against gpioirq(4) implement the following:
o O_NONBLOCK on reads
o Add a d_poll function and associated sel[init|notify|record|destroy]
  calls to the driver so that select(2) and poll(2) work as expected.
With these in place async use cases work against /dev/gpioirqN


To generate a diff of this commit:
cvs rdiff -u -r1.1.36.1 -r1.1.36.2 src/sys/dev/gpio/gpioirq.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/gpio/gpioirq.c
diff -u src/sys/dev/gpio/gpioirq.c:1.1.36.1 src/sys/dev/gpio/gpioirq.c:1.1.36.2
--- src/sys/dev/gpio/gpioirq.c:1.1.36.1	Sun Nov 26 11:45:16 2023
+++ src/sys/dev/gpio/gpioirq.c	Sun Nov 26 12:16:31 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: gpioirq.c,v 1.1.36.1 2023/11/26 11:45:16 bouyer Exp $ */
+/* $NetBSD: gpioirq.c,v 1.1.36.2 2023/11/26 12:16:31 bouyer Exp $ */
 
 /*
  * Copyright (c) 2016, 2023 Brad Spencer 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gpioirq.c,v 1.1.36.1 2023/11/26 11:45:16 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpioirq.c,v 1.1.36.2 2023/11/26 12:16:31 bouyer Exp $");
 
 /*
  * GPIO driver that uses interrupts and can send that fact to userland.
@@ -34,6 +34,9 @@ __KERNEL_RCSID(0, "$NetBSD: gpioirq.c,v 
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 
@@ -67,6 +70,7 @@ struct gpioirq_softc {
 	kcondvar_t		sc_cond_dying;
 	pool_cache_tsc_readpool;
 	char*sc_readpoolname;
+	struct  selinfo 	sc_rsel;
 	SIMPLEQ_HEAD(,gpioirq_read_q)  sc_read_queue;
 };
 
@@ -97,6 +101,7 @@ extern struct cfdriver gpioirq_cd;
 static dev_type_open(gpioirq_open);
 static dev_type_read(gpioirq_read);
 static dev_type_close(gpioirq_close);
+static dev_type_poll(gpioirq_poll);
 const struct cdevsw gpioirq_cdevsw = {
 	.d_open = gpioirq_open,
 	.d_close = gpioirq_close,
@@ -105,7 +110,7 @@ const struct cdevsw gpioirq_cdevsw = {
 	.d_ioctl = noioctl,
 	.d_stop = nostop,
 	.d_tty = notty,
-	.d_poll = nopoll,
+	.d_poll = gpioirq_poll,
 	.d_mmap = nommap,
 	.d_kqfilter = nokqfilter,
 	.d_discard = nodiscard,
@@ -189,6 +194,7 @@ gpioirq_attach(device_t parent, device_t
 	sc->sc_readpool = pool_cache_init(sizeof(struct gpioirq_read_q),0,0,0,sc->sc_readpoolname,NULL,IPL_VM,NULL,NULL,NULL);
 	pool_cache_sethiwat(sc->sc_readpool,100);
 	SIMPLEQ_INIT(>sc_read_queue);
+	selinit(>sc_rsel);
 
 	for(int apin = 0; apin < sc->sc_npins; apin++) {
 		if (!gpio_intr_str(sc->sc_gpio, >sc_map, apin, irqmode,
@@ -263,6 +269,7 @@ gpioirq_intr(void *arg)
 			q->parentunit = is->i_parentunit;
 			q->theval = val;
 			SIMPLEQ_INSERT_TAIL(>sc_read_queue,q,read_q);
+			selnotify(>sc_rsel, POLLIN|POLLRDNORM, NOTE_SUBMIT);
 			cv_signal(>sc_condreadready);
 		} else {
 			aprint_error("Could not allocate memory for read pool\n");
@@ -304,6 +311,10 @@ gpioirq_read(dev_t dev, struct uio *uio,
 	if (!sc)
 		return (ENXIO);
 
+	if (sc->sc_dying) {
+		return EIO;
+	}
+
 	while (uio->uio_resid > 0) {
 		any = 0;
 		error = 0;
@@ -316,7 +327,11 @@ gpioirq_read(dev_t dev, struct uio *uio,
 any = 1;
 break;
 			} else {
-error = cv_wait_sig(>sc_condreadready,>sc_read_mutex);
+if (flags & IO_NDELAY) {
+	error = EWOULDBLOCK;
+} else {
+	error = cv_wait_sig(>sc_condreadready,>sc_read_mutex);
+}
 if (sc->sc_dying)
 	error = EIO;
 if (error == 0)
@@ -358,6 +373,10 @@ gpioirq_close(dev_t dev, int flags, int 
 
 	sc = device_lookup_private(_cd, minor(dev));
 
+	if (sc->sc_dying) {
+		return(0);
+	}
+
 	mutex_enter(>sc_lock);
 	while ((q = SIMPLEQ_FIRST(>sc_read_queue)) != NULL) {
 		SIMPLEQ_REMOVE_HEAD(>sc_read_queue, read_q);
@@ -369,6 +388,31 @@ gpioirq_close(dev_t dev, int flags, int 
 	return(0);
 }
 
+static int
+gpioirq_poll(dev_t dev, int events, struct lwp *l)
+{
+struct gpioirq_softc *sc;
+int revents = 0;
+
+sc = device_lookup_private(_cd, minor(dev));
+
+	mutex_enter(>sc_read_mutex);
+	if (sc->sc_dying) {
+mutex_exit(>sc_read_mutex);
+return POLLHUP;
+}
+
+	if ((events & (POLLIN | POLLRDNORM)) != 0) {
+if (!SIMPLEQ_EMPTY(>sc_read_queue))
+revents |= events & (POLLIN | POLLRDNORM);
+else
+selrecord(l, >sc_rsel);
+}
+
+	mutex_exit(>sc_read_mutex);
+return revents;
+}
+
 int
 gpioirq_detach(device_t self, int flags)
 {
@@ -413,6 +457,7 @@ gpioirq_detach(device_t self, int flags)
 
 	mutex_destroy(>sc_read_mutex);
 	mutex_destroy(>sc_lock);
+	seldestroy(>sc_rsel);
 
 	return (0);
 }



CVS commit: [netbsd-10] src/sys/dev/gpio

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:16:31 UTC 2023

Modified Files:
src/sys/dev/gpio [netbsd-10]: gpioirq.c

Log Message:
Pull up following revision(s) (requested by brad in ticket #464):
sys/dev/gpio/gpioirq.c: revision 1.3
For /dev/ reads against gpioirq(4) implement the following:
o O_NONBLOCK on reads
o Add a d_poll function and associated sel[init|notify|record|destroy]
  calls to the driver so that select(2) and poll(2) work as expected.
With these in place async use cases work against /dev/gpioirqN


To generate a diff of this commit:
cvs rdiff -u -r1.1.36.1 -r1.1.36.2 src/sys/dev/gpio/gpioirq.c

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



CVS commit: [netbsd-10] src

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:13:19 UTC 2023

Modified Files:
src/share/man/man4 [netbsd-10]: gpiosim.4
src/sys/dev/gpio [netbsd-10]: gpiosim.c

Log Message:
Pull up following revision(s) (requested by brad in ticket #463):
share/man/man4/gpiosim.4: revision 1.7
sys/dev/gpio/gpiosim.c: revision 1.25
Simple simulated interrupts for the simulated GPIO device gpiosim(4)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.16.1 src/share/man/man4/gpiosim.4
cvs rdiff -u -r1.23 -r1.23.6.1 src/sys/dev/gpio/gpiosim.c

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

Modified files:

Index: src/share/man/man4/gpiosim.4
diff -u src/share/man/man4/gpiosim.4:1.6 src/share/man/man4/gpiosim.4:1.6.16.1
--- src/share/man/man4/gpiosim.4:1.6	Mon Jul  3 21:30:58 2017
+++ src/share/man/man4/gpiosim.4	Sun Nov 26 12:13:19 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpiosim.4,v 1.6 2017/07/03 21:30:58 wiz Exp $
+.\" $NetBSD: gpiosim.4,v 1.6.16.1 2023/11/26 12:13:19 bouyer Exp $
 .\"
 .\" Copyright (c) 2009, 2013 Marc Balmer 
 .\" All rights reserved.
@@ -15,7 +15,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd May 20, 2013
+.Dd November 8, 2013
 .Dt GPIOSIM 4
 .Os
 .Sh NAME
@@ -37,12 +37,21 @@ For this purpose, access the "hw.gpiosim
 variable, where "" denotes the number of the
 .Nm
 instance.
+.Pp
+Both edge and level interrupts are simulated.  The "hw.gpiosim.ms"
+.Xr sysctl 8
+variable will change the amount of time between
+.Xr callout 9
+ticks for simulated level interrupts.
 .Sh SEE ALSO
 .Xr gpio 4 ,
+.Xr gpioirq 4 ,
 .Xr sysctl 8
 .Sh AUTHORS
 .An -nosplit
 The
 .Nm
 driver was written by
-.An Marc Balmer Aq Mt m...@msys.ch .
+.An Marc Balmer Aq Mt m...@msys.ch
+Simulated interrupts added by
+.An Brad Spencer Aq Mt b...@anduin.eldar.org .

Index: src/sys/dev/gpio/gpiosim.c
diff -u src/sys/dev/gpio/gpiosim.c:1.23 src/sys/dev/gpio/gpiosim.c:1.23.6.1
--- src/sys/dev/gpio/gpiosim.c:1.23	Sat Aug  7 16:19:10 2021
+++ src/sys/dev/gpio/gpiosim.c	Sun Nov 26 12:13:19 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: gpiosim.c,v 1.23 2021/08/07 16:19:10 thorpej Exp $ */
+/* $NetBSD: gpiosim.c,v 1.23.6.1 2023/11/26 12:13:19 bouyer Exp $ */
 /*  $OpenBSD: gpiosim.c,v 1.1 2008/11/23 18:46:49 mbalmer Exp $	*/
 
 /*
@@ -29,34 +29,65 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "gpiosim.h"
 #include "ioconf.h"
 
 #define	GPIOSIM_NPINS	64
 
+struct gpiosim_irq {
+	int (*sc_gpio_irqfunc)(void *);
+	void *sc_gpio_irqarg;
+	int sc_gpio_irqmode;
+	bool sc_gpio_irqtriggered;
+};
+
 struct gpiosim_softc {
 	device_t		sc_dev;
 	device_t		sc_gdev;	/* gpio that attaches here */
 	uint64_t		sc_state;
 	struct gpio_chipset_tag	sc_gpio_gc;
 	gpio_pin_t		sc_gpio_pins[GPIOSIM_NPINS];
+struct gpiosim_irq  sc_gpio_irqs[GPIOSIM_NPINS];
 
 	struct sysctllog	*sc_log;
+struct workqueue*sc_wq;
+callout_t   sc_co;
+boolsc_co_init;
+	bool			sc_co_running;
+int sc_ms;
+kmutex_t 		sc_intr_mutex;
 };
 
 static int	gpiosim_match(device_t, cfdata_t, void *);
 static void	gpiosim_attach(device_t, device_t, void *);
 static int	gpiosim_detach(device_t, int);
 static int	gpiosim_sysctl(SYSCTLFN_PROTO);
+static int	gpiosim_ms_sysctl(SYSCTLFN_PROTO);
 
 static int	gpiosim_pin_read(void *, int);
 static void	gpiosim_pin_write(void *, int, int);
 static void	gpiosim_pin_ctl(void *, int, int);
 
+static void *   gpiosim_intr_establish(void *, int, int, int,
+int (*)(void *), void *);
+static void gpiosim_intr_disestablish(void *, void *);
+static bool gpiosim_gpio_intrstr(void *, int, int, char *, size_t);
+
+voidgpiosim_wq(struct work *,void *);
+voidgpiosim_co(void *);
+
 CFATTACH_DECL_NEW(gpiosim, sizeof(struct gpiosim_softc), gpiosim_match,
 gpiosim_attach, gpiosim_detach, NULL);
 
+int gpiosim_work;
+
+#ifndef GPIOSIM_MS
+#define GPIOSIM_MS 1000
+#endif
+
 static int
 gpiosim_match(device_t parent, cfdata_t match, void *aux)
 {
@@ -90,6 +121,7 @@ gpiosim_attach(device_t parent, device_t
 	struct gpiobus_attach_args gba;
 	const struct sysctlnode *node;
 	int i;
+	int error = 0;
 
 	sc->sc_dev = self;
 
@@ -103,16 +135,36 @@ gpiosim_attach(device_t parent, device_t
 		GPIO_PIN_PULLUP | GPIO_PIN_PULLDOWN |
 		GPIO_PIN_INVIN | GPIO_PIN_INVOUT;
 
+		/* Set up what interrupt types are allowed */
+		sc->sc_gpio_pins[i].pin_intrcaps =
+		GPIO_INTR_POS_EDGE |
+		GPIO_INTR_NEG_EDGE |
+		GPIO_INTR_DOUBLE_EDGE |
+		GPIO_INTR_HIGH_LEVEL |
+		GPIO_INTR_LOW_LEVEL |
+		GPIO_INTR_MPSAFE;
+		sc->sc_gpio_irqs[i].sc_gpio_irqfunc = NULL;
+		sc->sc_gpio_irqs[i].sc_gpio_irqarg = NULL;
+		sc->sc_gpio_irqs[i].sc_gpio_irqmode = 0;
+		

CVS commit: [netbsd-10] src

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 12:13:19 UTC 2023

Modified Files:
src/share/man/man4 [netbsd-10]: gpiosim.4
src/sys/dev/gpio [netbsd-10]: gpiosim.c

Log Message:
Pull up following revision(s) (requested by brad in ticket #463):
share/man/man4/gpiosim.4: revision 1.7
sys/dev/gpio/gpiosim.c: revision 1.25
Simple simulated interrupts for the simulated GPIO device gpiosim(4)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.16.1 src/share/man/man4/gpiosim.4
cvs rdiff -u -r1.23 -r1.23.6.1 src/sys/dev/gpio/gpiosim.c

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



CVS commit: [netbsd-10] src/sys/arch/newsmips/dev

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 11:54:31 UTC 2023

Modified Files:
src/sys/arch/newsmips/dev [netbsd-10]: dmac_0448.h scsi_1185.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #462):
sys/arch/newsmips/dev/dmac_0448.h: revision 1.7
sys/arch/newsmips/dev/scsi_1185.c: revision 1.25
Use DELAY(9), not empty for() loop that could be optimized out.
No visible regression on NWS-3260 and NWS-3470.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.122.1 src/sys/arch/newsmips/dev/dmac_0448.h
cvs rdiff -u -r1.23 -r1.23.46.1 src/sys/arch/newsmips/dev/scsi_1185.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/newsmips/dev/dmac_0448.h
diff -u src/sys/arch/newsmips/dev/dmac_0448.h:1.6 src/sys/arch/newsmips/dev/dmac_0448.h:1.6.122.1
--- src/sys/arch/newsmips/dev/dmac_0448.h:1.6	Wed Apr  9 15:40:30 2008
+++ src/sys/arch/newsmips/dev/dmac_0448.h	Sun Nov 26 11:54:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dmac_0448.h,v 1.6 2008/04/09 15:40:30 tsutsui Exp $	*/
+/*	$NetBSD: dmac_0448.h,v 1.6.122.1 2023/11/26 11:54:31 bouyer Exp $	*/
 /*
  * Copyright (c) 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -120,7 +120,7 @@ struct	dm_stat {
 	unsigned int dm_width;
 };
 
-#define	DMAC_WAIT	nops(10)
+#define	DMAC_WAIT	DELAY(1)
 
 #define PINTEN		0xbfc80001
 # define	DMA_INTEN	0x10

Index: src/sys/arch/newsmips/dev/scsi_1185.c
diff -u src/sys/arch/newsmips/dev/scsi_1185.c:1.23 src/sys/arch/newsmips/dev/scsi_1185.c:1.23.46.1
--- src/sys/arch/newsmips/dev/scsi_1185.c:1.23	Thu Jul 21 19:49:58 2016
+++ src/sys/arch/newsmips/dev/scsi_1185.c	Sun Nov 26 11:54:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsi_1185.c,v 1.23 2016/07/21 19:49:58 christos Exp $	*/
+/*	$NetBSD: scsi_1185.c,v 1.23.46.1 2023/11/26 11:54:31 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: scsi_1185.c,v 1.23 2016/07/21 19:49:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsi_1185.c,v 1.23.46.1 2023/11/26 11:54:31 bouyer Exp $");
 
 #define	__INTR_PRIVATE
 #include 
@@ -116,10 +116,9 @@ __KERNEL_RCSID(0, "$NetBSD: scsi_1185.c,
 #define	splscsi splsc
 
 #if defined(__mips__) && defined(CPU_SINGLE)
-#define nops(x)		{ int __i; for (__i = 0; __i < (x); __i++) ; }
-#define	DMAC_WAIT0	;
+#define	DMAC_WAIT0	__nothing
 #else
-#define	DMAC_WAIT0	DMAC_WAIT
+#define	DMAC_WAIT0	DMAC_WAIT	/* see MODIFY HISTORY comment above */
 #endif
 
 #ifdef DMAC_MAP_INIT



CVS commit: [netbsd-10] src/sys/arch/newsmips/dev

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 11:54:31 UTC 2023

Modified Files:
src/sys/arch/newsmips/dev [netbsd-10]: dmac_0448.h scsi_1185.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #462):
sys/arch/newsmips/dev/dmac_0448.h: revision 1.7
sys/arch/newsmips/dev/scsi_1185.c: revision 1.25
Use DELAY(9), not empty for() loop that could be optimized out.
No visible regression on NWS-3260 and NWS-3470.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.122.1 src/sys/arch/newsmips/dev/dmac_0448.h
cvs rdiff -u -r1.23 -r1.23.46.1 src/sys/arch/newsmips/dev/scsi_1185.c

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



CVS commit: [netbsd-10] src

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 11:45:16 UTC 2023

Modified Files:
src/etc [netbsd-10]: MAKEDEV.tmpl
src/share/man/man4 [netbsd-10]: gpioirq.4
src/sys/conf [netbsd-10]: majors
src/sys/dev/gpio [netbsd-10]: gpio.c gpioirq.c gpiovar.h

Log Message:
Pull up following revision(s) (requested by brad in ticket #461):
sys/dev/gpio/gpiovar.h: revision 1.19
share/man/man4/gpioirq.4: revision 1.4 via patch
sys/dev/gpio/gpio.c: revision 1.73
etc/MAKEDEV.tmpl: revision 1.234
sys/conf/majors: revision 1.103
sys/dev/gpio/gpioirq.c: revision 1.2
gpioirq(4) version 2
This update makes this driver more than just an example and allows for:
o More than one pin to be attached to a gpioirq instance.  That is,
  the mask parameter can be greater than 0x01 now.
o A /dev/gpioirqN device that allows GPIO pin interrupts to be
  transported into userland.  This is a device that can be opened for
  reading with a simple fixed output indicating the device unit, pin
  number and current pin state.
This update was used as part of a physical intrusion detection system
where multiple switches (i.e. window magnetic reed switches and etc.)
are tied to a bunch of GPIO inputs with userland software that reacts
to the pins changing state.


To generate a diff of this commit:
cvs rdiff -u -r1.232.2.1 -r1.232.2.2 src/etc/MAKEDEV.tmpl
cvs rdiff -u -r1.2 -r1.2.14.1 src/share/man/man4/gpioirq.4
cvs rdiff -u -r1.102 -r1.102.4.1 src/sys/conf/majors
cvs rdiff -u -r1.72 -r1.72.2.1 src/sys/dev/gpio/gpio.c
cvs rdiff -u -r1.1 -r1.1.36.1 src/sys/dev/gpio/gpioirq.c
cvs rdiff -u -r1.18 -r1.18.34.1 src/sys/dev/gpio/gpiovar.h

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



CVS commit: [netbsd-10] src

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 11:45:16 UTC 2023

Modified Files:
src/etc [netbsd-10]: MAKEDEV.tmpl
src/share/man/man4 [netbsd-10]: gpioirq.4
src/sys/conf [netbsd-10]: majors
src/sys/dev/gpio [netbsd-10]: gpio.c gpioirq.c gpiovar.h

Log Message:
Pull up following revision(s) (requested by brad in ticket #461):
sys/dev/gpio/gpiovar.h: revision 1.19
share/man/man4/gpioirq.4: revision 1.4 via patch
sys/dev/gpio/gpio.c: revision 1.73
etc/MAKEDEV.tmpl: revision 1.234
sys/conf/majors: revision 1.103
sys/dev/gpio/gpioirq.c: revision 1.2
gpioirq(4) version 2
This update makes this driver more than just an example and allows for:
o More than one pin to be attached to a gpioirq instance.  That is,
  the mask parameter can be greater than 0x01 now.
o A /dev/gpioirqN device that allows GPIO pin interrupts to be
  transported into userland.  This is a device that can be opened for
  reading with a simple fixed output indicating the device unit, pin
  number and current pin state.
This update was used as part of a physical intrusion detection system
where multiple switches (i.e. window magnetic reed switches and etc.)
are tied to a bunch of GPIO inputs with userland software that reacts
to the pins changing state.


To generate a diff of this commit:
cvs rdiff -u -r1.232.2.1 -r1.232.2.2 src/etc/MAKEDEV.tmpl
cvs rdiff -u -r1.2 -r1.2.14.1 src/share/man/man4/gpioirq.4
cvs rdiff -u -r1.102 -r1.102.4.1 src/sys/conf/majors
cvs rdiff -u -r1.72 -r1.72.2.1 src/sys/dev/gpio/gpio.c
cvs rdiff -u -r1.1 -r1.1.36.1 src/sys/dev/gpio/gpioirq.c
cvs rdiff -u -r1.18 -r1.18.34.1 src/sys/dev/gpio/gpiovar.h

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

Modified files:

Index: src/etc/MAKEDEV.tmpl
diff -u src/etc/MAKEDEV.tmpl:1.232.2.1 src/etc/MAKEDEV.tmpl:1.232.2.2
--- src/etc/MAKEDEV.tmpl:1.232.2.1	Fri Jan 13 19:08:30 2023
+++ src/etc/MAKEDEV.tmpl	Sun Nov 26 11:45:16 2023
@@ -1,5 +1,5 @@
 #!/bin/sh -
-#	$NetBSD: MAKEDEV.tmpl,v 1.232.2.1 2023/01/13 19:08:30 martin Exp $
+#	$NetBSD: MAKEDEV.tmpl,v 1.232.2.2 2023/11/26 11:45:16 bouyer Exp $
 #
 # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -232,6 +232,7 @@
 #	dtv*	Digital TV interface
 #	fb*	PMAX generic framebuffer pseudo-device
 #	fd	file descriptors
+#	gpioirq* Interrupts on GPIO pins
 #	gpiopps* 1PPS signals on GPIO pins
 #	grf*	graphics frame buffer device
 #	hdaudio* High Definition audio control device
@@ -830,7 +831,7 @@ all)
 	makedev srt0 srt1 srt2 srt3
 	makedev tap tap0 tap1 tap2 tap3
 	makedev gpio gpio0 gpio1 gpio2 gpio3 gpio4 gpio5 gpio6 gpio7
-	makedev gpiopps0
+	makedev gpioirq0 gpiopps0
 	makedev pad pad0 pad1 pad2 pad3
 	makedev bthub
 	makedev putter
@@ -873,6 +874,10 @@ gpio)
 	lndev gpio0 gpio
 	;;
 
+gpioirq)
+	makedev gpioirq0
+	;;
+
 gpiopps)
 	makedev gpiopps0
 	lndev gpiopps0 gpiopps
@@ -1547,6 +1552,11 @@ gpio[0-9]*)
 	mkdev gpio$unit c %gpio_chr% $unit 664 $g_gpio
 	;;
 
+gpioirq[0-9]*)
+	unit=${i#gpioirq}
+	mkdev gpioirq$unit c %gpioirq_chr% $unit 444 $g_gpio
+	;;
+
 gpiopps[0-9]*)
 	unit=${i#gpiopps}
 	mkdev gpiopps$unit c %gpiopps_chr% $unit 664 $g_gpio

Index: src/share/man/man4/gpioirq.4
diff -u src/share/man/man4/gpioirq.4:1.2 src/share/man/man4/gpioirq.4:1.2.14.1
--- src/share/man/man4/gpioirq.4:1.2	Sun May 20 12:08:46 2018
+++ src/share/man/man4/gpioirq.4	Sun Nov 26 11:45:16 2023
@@ -1,6 +1,6 @@
-.\" $NetBSD: gpioirq.4,v 1.2 2018/05/20 12:08:46 wiz Exp $
+.\" $NetBSD: gpioirq.4,v 1.2.14.1 2023/11/26 11:45:16 bouyer Exp $
 .\"
-.\" Copyright (c) 2016 Brad Spencer 
+.\" Copyright (c) 2016, 2023 Brad Spencer 
 .\"
 .\" Permission to use, copy, modify, and distribute this software for any
 .\" purpose with or without fee is hereby granted, provided that the above
@@ -14,25 +14,26 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd May 11, 2018
+.Dd November 5, 2023
 .Dt GPIOIRQ 4
 .Os
 .Sh NAME
 .Nm gpioirq
-.Nd Install an interrupt handler on a GPIO pin
+.Nd Install an interrupt handler on GPIO pins
 .Sh SYNOPSIS
 .Cd "gpioirq* at gpio? offset 0 mask 0x1 flag 0x00"
 .Sh DESCRIPTION
 The
 .Nm
-driver attaches an interrupt handler to a single GPIO pin.
+driver attaches an interrupt handler to a one or more GPIO pins.
 .Pp
-The pin number is specified in the kernel configuration file with the
+The base pin number is specified in the kernel configuration file with the
 .Ar offset
 locator.
 The
 .Ar mask
-locator should always be 0x1.
+locator can be 0x01 or greater to indicate that more pins should have an
+interrupt handler attached to them.
 .Pp
 The
 .Ar flag
@@ -49,7 +50,7 @@ edge of the pin.
 .It Dv 0x04
 Interrupt on both edges of the pin.
 .It Dv 0x08
-Assert the intrerrupt as long as the pin is high.
+Assert the interrupt as long 

CVS commit: [netbsd-10] src/sys

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 11:37:03 UTC 2023

Modified Files:
src/sys/dev/pci [netbsd-10]: if_ena.c if_enavar.h
src/sys/external/bsd/ena-com [netbsd-10]: ena_com.c ena_com.h
ena_plat.h

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #460):
sys/dev/pci/if_ena.c: revision 1.35
sys/dev/pci/if_ena.c: revision 1.36
sys/dev/pci/if_ena.c: revision 1.37
sys/dev/pci/if_ena.c: revision 1.38
sys/dev/pci/if_ena.c: revision 1.39
sys/external/bsd/ena-com/ena_plat.h: revision 1.10
sys/dev/pci/if_enavar.h: revision 1.9
sys/external/bsd/ena-com/ena_com.c: revision 1.2
sys/external/bsd/ena-com/ena_com.c: revision 1.3
sys/external/bsd/ena-com/ena_com.c: revision 1.4
sys/dev/pci/if_ena.c: revision 1.40
sys/external/bsd/ena-com/ena_com.h: revision 1.2
ena(4): replace malloc(9) to kmem(9)
Code contributed by KUSABA Takeshi 
ena(4): prevent AENQ handler from use-after-free
Code contributed by KUSABA Takeshi 
ena(4): destroy all wait_event
Code contributed by KUSABA Takeshi 
ena(4): support RSS and delete FreeBSD-specified code
Code contributed by KUSABA Takeshi 
ena(4) is MP-ready, always use MPSAFE
Code contributed by KUSABA Takeshi 
ena(4): establish interrupt after setting up resources
Code contributed by KUSABA Takeshi 
ena(4): stop management first when detaching
Code contributed by KUSABA Takeshi 


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.4.1 src/sys/dev/pci/if_ena.c
cvs rdiff -u -r1.8 -r1.8.10.1 src/sys/dev/pci/if_enavar.h
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.34.1 src/sys/external/bsd/ena-com/ena_com.c \
src/sys/external/bsd/ena-com/ena_com.h
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/external/bsd/ena-com/ena_plat.h

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

Modified files:

Index: src/sys/dev/pci/if_ena.c
diff -u src/sys/dev/pci/if_ena.c:1.33 src/sys/dev/pci/if_ena.c:1.33.4.1
--- src/sys/dev/pci/if_ena.c:1.33	Mon May 23 13:53:37 2022
+++ src/sys/dev/pci/if_ena.c	Sun Nov 26 11:37:02 2023
@@ -36,15 +36,15 @@
 #if 0
 __FBSDID("$FreeBSD: head/sys/dev/ena/ena.c 333456 2018-05-10 09:37:54Z mw $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.33 2022/05/23 13:53:37 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.33.4.1 2023/11/26 11:37:02 bouyer Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -61,14 +61,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1
 
 #include 
 
-#ifdef NET_MPSAFE
-#define	WQ_FLAGS	WQ_MPSAFE
-#define	CALLOUT_FLAGS	CALLOUT_MPSAFE
-#else
-#define	WQ_FLAGS	0
-#define	CALLOUT_FLAGS	0
-#endif
-
 /*
  *  Function prototypes
  */
@@ -106,6 +98,7 @@ static void	ena_free_all_io_rings_resour
 static int	ena_get_dev_offloads(struct ena_com_dev_get_features_ctx *);
 static int	ena_setup_ifnet(device_t, struct ena_adapter *,
 		struct ena_com_dev_get_features_ctx *);
+static void	ena_rss_init_default(device_t);
 
 static inline void	ena_alloc_counters_rx(struct ena_adapter *,
 			struct ena_stats_rx *, int);
@@ -217,8 +210,6 @@ static void	ena_rx_hash_mbuf(struct ena_
 struct mbuf *);
 static uint64_t	ena_get_counter(struct ifnet *, ift_counter);
 static void	ena_qflush(struct ifnet *);
-static int	ena_rss_init_default(struct ena_adapter *);
-static void	ena_rss_init_default_deferred(void *);
 #endif
 
 static const char ena_version[] =
@@ -693,15 +684,12 @@ ena_setup_tx_resources(struct ena_adapte
 	struct ena_que *que = >que[qid];
 	struct ena_ring *tx_ring = que->tx_ring;
 	int size, i, err;
-#ifdef	RSS
-	cpuset_t cpu_mask;
-#endif
 
 	size = sizeof(struct ena_tx_buffer) * tx_ring->ring_size;
-	tx_ring->tx_buffer_info = malloc(size, M_DEVBUF, M_WAITOK | M_ZERO);
+	tx_ring->tx_buffer_info = kmem_zalloc(size, KM_SLEEP);
 
 	size = sizeof(uint16_t) * tx_ring->ring_size;
-	tx_ring->free_tx_ids = malloc(size, M_DEVBUF, M_WAITOK | M_ZERO);
+	tx_ring->free_tx_ids = kmem_zalloc(size, KM_SLEEP);
 
 	/* Req id stack for TX OOO completions */
 	for (i = 0; i < tx_ring->ring_size; i++)
@@ -732,27 +720,13 @@ ena_setup_tx_resources(struct ena_adapte
 
 	/* Allocate workqueues */
 	int rc = workqueue_create(_ring->enqueue_tq, "ena_tx_enq",
-	ena_deferred_mq_start, tx_ring, 0, IPL_NET, WQ_PERCPU | WQ_FLAGS);
+	ena_deferred_mq_start, tx_ring, 0, IPL_NET, WQ_PERCPU | WQ_MPSAFE);
 	if (unlikely(rc != 0)) {
 		ena_trace(ENA_ALERT,
 		"Unable to create workqueue for enqueue task\n");
 		i = tx_ring->ring_size;
 		goto err_buf_info_unmap;
 	}
-
-#if 0
-	/* RSS set cpu for thread */
-#ifdef RSS
-	CPU_SETOF(que->cpu, _mask);
-	taskqueue_start_threads_cpuset(_ring->enqueue_tq, 1, IPL_NET,
-	_mask, "%s tx_ring enq (bucket %d)",
-	

CVS commit: [netbsd-10] src/sys

2023-11-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 26 11:37:03 UTC 2023

Modified Files:
src/sys/dev/pci [netbsd-10]: if_ena.c if_enavar.h
src/sys/external/bsd/ena-com [netbsd-10]: ena_com.c ena_com.h
ena_plat.h

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #460):
sys/dev/pci/if_ena.c: revision 1.35
sys/dev/pci/if_ena.c: revision 1.36
sys/dev/pci/if_ena.c: revision 1.37
sys/dev/pci/if_ena.c: revision 1.38
sys/dev/pci/if_ena.c: revision 1.39
sys/external/bsd/ena-com/ena_plat.h: revision 1.10
sys/dev/pci/if_enavar.h: revision 1.9
sys/external/bsd/ena-com/ena_com.c: revision 1.2
sys/external/bsd/ena-com/ena_com.c: revision 1.3
sys/external/bsd/ena-com/ena_com.c: revision 1.4
sys/dev/pci/if_ena.c: revision 1.40
sys/external/bsd/ena-com/ena_com.h: revision 1.2
ena(4): replace malloc(9) to kmem(9)
Code contributed by KUSABA Takeshi 
ena(4): prevent AENQ handler from use-after-free
Code contributed by KUSABA Takeshi 
ena(4): destroy all wait_event
Code contributed by KUSABA Takeshi 
ena(4): support RSS and delete FreeBSD-specified code
Code contributed by KUSABA Takeshi 
ena(4) is MP-ready, always use MPSAFE
Code contributed by KUSABA Takeshi 
ena(4): establish interrupt after setting up resources
Code contributed by KUSABA Takeshi 
ena(4): stop management first when detaching
Code contributed by KUSABA Takeshi 


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.4.1 src/sys/dev/pci/if_ena.c
cvs rdiff -u -r1.8 -r1.8.10.1 src/sys/dev/pci/if_enavar.h
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.34.1 src/sys/external/bsd/ena-com/ena_com.c \
src/sys/external/bsd/ena-com/ena_com.h
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/external/bsd/ena-com/ena_plat.h

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