CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:39:13 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_bo.c

Log Message:
vmwgfx(4): Partially adapt rbtree.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_bo.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/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_bo.c
diff -u src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_bo.c:1.2 src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_bo.c:1.3
--- src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_bo.c:1.2	Sat Dec 18 23:45:45 2021
+++ src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_bo.c	Tue Oct 25 23:39:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmwgfx_bo.c,v 1.2 2021/12/18 23:45:45 riastradh Exp $	*/
+/*	$NetBSD: vmwgfx_bo.c,v 1.3 2022/10/25 23:39:13 riastradh Exp $	*/
 
 // SPDX-License-Identifier: GPL-2.0 OR MIT
 /**
@@ -29,7 +29,7 @@
  **/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmwgfx_bo.c,v 1.2 2021/12/18 23:45:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmwgfx_bo.c,v 1.3 2022/10/25 23:39:13 riastradh Exp $");
 
 #include 
 
@@ -490,6 +490,9 @@ static void vmw_user_bo_destroy(struct t
 	ttm_prime_object_kfree(vmw_user_bo, prime);
 }
 
+#ifdef __NetBSD__
+extern rb_tree_ops_t vmwgfx_res_rb_ops;
+#endif
 
 /**
  * vmw_bo_init - Initialize a vmw buffer object
@@ -521,7 +524,11 @@ int vmw_bo_init(struct vmw_private *dev_
 	memset(vmw_bo, 0, sizeof(*vmw_bo));
 	BUILD_BUG_ON(TTM_MAX_BO_PRIORITY <= 3);
 	vmw_bo->base.priority = 3;
+#ifdef __NetBSD__
+	rb_tree_init(_bo->res_tree.rbr_tree, _res_rb_ops);
+#else
 	vmw_bo->res_tree = RB_ROOT;
+#endif
 
 	ret = ttm_bo_init(bdev, _bo->base, size,
 			  ttm_bo_type_device, placement,



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:39:13 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_bo.c

Log Message:
vmwgfx(4): Partially adapt rbtree.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_bo.c

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



CVS commit: src/sys/external/bsd

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:39:01 UTC 2022

Added Files:
src/sys/external/bsd/common/include/asm: vmware.h
Removed Files:
src/sys/external/bsd/drm2/include/asm: vmware.h

Log Message:
linux asm/vmware.h: Fill this in with hypercall asm.

Not sure if it's necessary to support vmcall or vmmcall -- if so,
need to deal with binary patching inline asm, ugh.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/common/include/asm/vmware.h
cvs rdiff -u -r1.1 -r0 src/sys/external/bsd/drm2/include/asm/vmware.h

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

Added files:

Index: src/sys/external/bsd/common/include/asm/vmware.h
diff -u /dev/null src/sys/external/bsd/common/include/asm/vmware.h:1.1
--- /dev/null	Tue Oct 25 23:39:01 2022
+++ src/sys/external/bsd/common/include/asm/vmware.h	Tue Oct 25 23:39:01 2022
@@ -0,0 +1,57 @@
+/*	$NetBSD: vmware.h,v 1.1 2022/10/25 23:39:01 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _ASM_VMWARE_H_
+#define _ASM_VMWARE_H_
+
+#include 
+
+#if defined __i386__ || defined __x86_64__
+
+#define	VMWARE_HYPERVISOR_PORT		0x5658
+#define	VMWARE_HYPERVISOR_PORT_HB	0x5659
+
+#define	VMWARE_HYPERVISOR_HB		__BIT(0)
+#define	VMWARE_HYPERVISOR_OUT		__BIT(1)
+
+/* XXX support vmcall/vmmcall */
+#define	VMWARE_HYPERCALL		  \
+	"movw $"__STRING(VMWARE_HYPERVISOR_PORT)",%%dx;"		  \
+	"inl (%%dx),%%eax;"
+
+#define	VMWARE_HYPERCALL_HB_OUT		  \
+	"movw $"__STRING(VMWARE_HYPERVISOR_PORT_HB)",%%dx;"		  \
+	"rep outsb;"
+
+#define	VMWARE_HYPERCALL_HB_IN		  \
+	"movw $"__STRING(VMWARE_HYPERVISOR_PORT_HB)",%%dx;"		  \
+	"rep insb;"
+
+#endif
+
+#endif  /* _ASM_BARRIER_H_ */



CVS commit: src/sys/external/bsd

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:39:01 UTC 2022

Added Files:
src/sys/external/bsd/common/include/asm: vmware.h
Removed Files:
src/sys/external/bsd/drm2/include/asm: vmware.h

Log Message:
linux asm/vmware.h: Fill this in with hypercall asm.

Not sure if it's necessary to support vmcall or vmmcall -- if so,
need to deal with binary patching inline asm, ugh.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/common/include/asm/vmware.h
cvs rdiff -u -r1.1 -r0 src/sys/external/bsd/drm2/include/asm/vmware.h

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



CVS commit: src/sys/external/bsd

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:38:34 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/asm: uaccess.h
Added Files:
src/sys/external/bsd/common/include/linux: mem_encrypt.h
Removed Files:
src/sys/external/bsd/drm2/include/linux: mem_encrypt.h

Log Message:
linux asm/uaccess.h: strncpy_from_user

(which does not actually have strncpy semantics, naturally, from what
I can gather)


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
src/sys/external/bsd/common/include/linux/mem_encrypt.h
cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/drm2/include/asm/uaccess.h
cvs rdiff -u -r1.1 -r0 src/sys/external/bsd/drm2/include/linux/mem_encrypt.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/external/bsd/drm2/include/asm/uaccess.h
diff -u src/sys/external/bsd/drm2/include/asm/uaccess.h:1.10 src/sys/external/bsd/drm2/include/asm/uaccess.h:1.11
--- src/sys/external/bsd/drm2/include/asm/uaccess.h:1.10	Sun Dec 19 11:33:30 2021
+++ src/sys/external/bsd/drm2/include/asm/uaccess.h	Tue Oct 25 23:38:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaccess.h,v 1.10 2021/12/19 11:33:30 riastradh Exp $	*/
+/*	$NetBSD: uaccess.h,v 1.11 2022/10/25 23:38:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -57,6 +57,22 @@ copy_from_user(void *kernel_addr, const 
 	return -copyin(user_addr, kernel_addr, len);
 }
 
+static inline long
+strncpy_from_user(char *kernel_addr, const void *user_addr, long len)
+{
+	size_t done;
+	int error;
+
+	if (len <= 0)
+		return 0;
+	error = copyinstr(user_addr, kernel_addr, len, );
+	if (error)
+		return error;
+	KASSERT(done <= (size_t)len);
+	KASSERT(done >= 1);
+	return done - 1;
+}
+
 static inline int
 copy_to_user(void *user_addr, const void *kernel_addr, size_t len)
 {

Added files:

Index: src/sys/external/bsd/common/include/linux/mem_encrypt.h
diff -u /dev/null src/sys/external/bsd/common/include/linux/mem_encrypt.h:1.1
--- /dev/null	Tue Oct 25 23:38:34 2022
+++ src/sys/external/bsd/common/include/linux/mem_encrypt.h	Tue Oct 25 23:38:33 2022
@@ -0,0 +1,34 @@
+/*	$NetBSD: mem_encrypt.h,v 1.1 2022/10/25 23:38:33 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef	_LINUX_MEM_ENCRYPT_H_
+#define	_LINUX_MEM_ENCRYPT_H_
+
+#define	mem_encrypt_active()	0
+
+#endif	/* _LINUX_MEM_ENCRYPT_H_ */



CVS commit: src/sys/external/bsd

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:38:34 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/asm: uaccess.h
Added Files:
src/sys/external/bsd/common/include/linux: mem_encrypt.h
Removed Files:
src/sys/external/bsd/drm2/include/linux: mem_encrypt.h

Log Message:
linux asm/uaccess.h: strncpy_from_user

(which does not actually have strncpy semantics, naturally, from what
I can gather)


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
src/sys/external/bsd/common/include/linux/mem_encrypt.h
cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/drm2/include/asm/uaccess.h
cvs rdiff -u -r1.1 -r0 src/sys/external/bsd/drm2/include/linux/mem_encrypt.h

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



CVS commit: src/sys/external/bsd

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:38:02 UTC 2022

Added Files:
src/sys/external/bsd/common/include/linux: frame.h
Removed Files:
src/sys/external/bsd/drm2/include/linux: frame.h

Log Message:
linux/frame.h: STACK_FRAME_NON_STANDARD


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/common/include/linux/frame.h
cvs rdiff -u -r1.1 -r0 src/sys/external/bsd/drm2/include/linux/frame.h

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

Added files:

Index: src/sys/external/bsd/common/include/linux/frame.h
diff -u /dev/null src/sys/external/bsd/common/include/linux/frame.h:1.1
--- /dev/null	Tue Oct 25 23:38:02 2022
+++ src/sys/external/bsd/common/include/linux/frame.h	Tue Oct 25 23:38:02 2022
@@ -0,0 +1,34 @@
+/*	$NetBSD: frame.h,v 1.1 2022/10/25 23:38:02 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef	_LINUX_FRAME_H_
+#define	_LINUX_FRAME_H_
+
+#define	STACK_FRAME_NON_STANDARD(func)	/* nothing */
+
+#endif	/* _LINUX_FRAME_H_ */



CVS commit: src/sys/external/bsd

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:38:02 UTC 2022

Added Files:
src/sys/external/bsd/common/include/linux: frame.h
Removed Files:
src/sys/external/bsd/drm2/include/linux: frame.h

Log Message:
linux/frame.h: STACK_FRAME_NON_STANDARD


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/common/include/linux/frame.h
cvs rdiff -u -r1.1 -r0 src/sys/external/bsd/drm2/include/linux/frame.h

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



CVS commit: src/sys/external/bsd/common/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:37:36 UTC 2022

Modified Files:
src/sys/external/bsd/common/include/linux: kernel.h

Log Message:
linux/kernel.h: S16_MIN, S32_MIN, S64_MIN


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/external/bsd/common/include/linux/kernel.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/external/bsd/common/include/linux/kernel.h
diff -u src/sys/external/bsd/common/include/linux/kernel.h:1.45 src/sys/external/bsd/common/include/linux/kernel.h:1.46
--- src/sys/external/bsd/common/include/linux/kernel.h:1.45	Sun Dec 19 12:02:13 2021
+++ src/sys/external/bsd/common/include/linux/kernel.h	Tue Oct 25 23:37:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernel.h,v 1.45 2021/12/19 12:02:13 riastradh Exp $	*/
+/*	$NetBSD: kernel.h,v 1.46 2022/10/25 23:37:36 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -53,8 +53,11 @@
 #define U64_MAX UINT64_MAX
 
 #define	S16_MAX	INT16_MAX
+#define	S16_MIN	INT16_MIN
 #define	S32_MAX	INT32_MAX
+#define	S32_MIN	INT32_MIN
 #define	S64_MAX	INT64_MAX
+#define	S64_MIN	INT64_MIN
 
 #define	oops_in_progress	(panicstr != NULL)
 



CVS commit: src/sys/external/bsd/common/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:37:36 UTC 2022

Modified Files:
src/sys/external/bsd/common/include/linux: kernel.h

Log Message:
linux/kernel.h: S16_MIN, S32_MIN, S64_MIN


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/external/bsd/common/include/linux/kernel.h

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



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:37:24 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: suspend.h

Log Message:
linux/suspend.h: Stubs for (un)register_pm_notifier.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/include/linux/suspend.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/external/bsd/drm2/include/linux/suspend.h
diff -u src/sys/external/bsd/drm2/include/linux/suspend.h:1.3 src/sys/external/bsd/drm2/include/linux/suspend.h:1.4
--- src/sys/external/bsd/drm2/include/linux/suspend.h:1.3	Sun Dec 19 12:00:24 2021
+++ src/sys/external/bsd/drm2/include/linux/suspend.h	Tue Oct 25 23:37:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: suspend.h,v 1.3 2021/12/19 12:00:24 riastradh Exp $	*/
+/*	$NetBSD: suspend.h,v 1.4 2022/10/25 23:37:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,4 +36,7 @@
 
 #define	ksys_sync_helper()	__nothing
 
+#define	register_pm_notifier(n)		__nothing
+#define	unregister_pm_notifier(n)	__nothing
+
 #endif  /* _LINUX_SUSPEND_H_ */



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:37:24 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: suspend.h

Log Message:
linux/suspend.h: Stubs for (un)register_pm_notifier.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/include/linux/suspend.h

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



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:37:07 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: pci.h

Log Message:
linux/pci.h: Stubs for pci_request/release_region(s).


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/external/bsd/drm2/include/linux/pci.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/external/bsd/drm2/include/linux/pci.h
diff -u src/sys/external/bsd/drm2/include/linux/pci.h:1.55 src/sys/external/bsd/drm2/include/linux/pci.h:1.56
--- src/sys/external/bsd/drm2/include/linux/pci.h:1.55	Mon Oct 17 03:05:32 2022
+++ src/sys/external/bsd/drm2/include/linux/pci.h	Tue Oct 25 23:37:06 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci.h,v 1.55 2022/10/17 03:05:32 mrg Exp $	*/
+/*	$NetBSD: pci.h,v 1.56 2022/10/25 23:37:06 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -266,6 +266,10 @@ enum pcie_link_width {
 #define	pci_read_config_byte		linux_pci_read_config_byte
 #define	pci_read_config_dword		linux_pci_read_config_dword
 #define	pci_read_config_word		linux_pci_read_config_word
+#define	pci_release_region		linux_pci_release_region
+#define	pci_release_regions		linux_pci_release_regions
+#define	pci_request_region		linux_pci_request_region
+#define	pci_request_regions		linux_pci_request_regions
 #define	pci_resource_end		linux_pci_resource_end
 #define	pci_resource_flags		linux_pci_resource_flags
 #define	pci_resource_len		linux_pci_resource_len
@@ -362,6 +366,11 @@ void		pci_unmap_rom(struct pci_dev *, vo
 int		pci_enable_rom(struct pci_dev *);
 void		pci_disable_rom(struct pci_dev *);
 
+int		pci_request_regions(struct pci_dev *, const char *);
+void		pci_release_regions(struct pci_dev *);
+int		pci_request_region(struct pci_dev *, int, const char *);
+void		pci_release_region(struct pci_dev *, int);
+
 bus_addr_t	pci_resource_start(struct pci_dev *, unsigned);
 bus_size_t	pci_resource_len(struct pci_dev *, unsigned);
 bus_addr_t	pci_resource_end(struct pci_dev *, unsigned);



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:37:07 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: pci.h

Log Message:
linux/pci.h: Stubs for pci_request/release_region(s).


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/external/bsd/drm2/include/linux/pci.h

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



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:36:32 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: idr.h

Log Message:
linux/idr.h: Update ida_* API.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/include/linux/idr.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/external/bsd/drm2/include/linux/idr.h
diff -u src/sys/external/bsd/drm2/include/linux/idr.h:1.9 src/sys/external/bsd/drm2/include/linux/idr.h:1.10
--- src/sys/external/bsd/drm2/include/linux/idr.h:1.9	Sun Dec 19 01:15:21 2021
+++ src/sys/external/bsd/drm2/include/linux/idr.h	Tue Oct 25 23:36:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: idr.h,v 1.9 2021/12/19 01:15:21 riastradh Exp $	*/
+/*	$NetBSD: idr.h,v 1.10 2022/10/25 23:36:32 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@ ida_destroy(struct ida *ida)
 }
 
 static inline void
-ida_remove(struct ida *ida, int id)
+ida_free(struct ida *ida, int id)
 {
 
 	idr_remove(>ida_idr, id);
@@ -118,12 +118,19 @@ ida_simple_get(struct ida *ida, unsigned
 	return id;
 }
 
+static inline int
+ida_alloc_max(struct ida *ida, unsigned max, gfp_t gfp)
+{
+
+	return ida_simple_get(ida, 0, max + 1, gfp);
+}
+
 static inline void
 ida_simple_remove(struct ida *ida, unsigned int id)
 {
 
 	KASSERT((int)id >= 0);
-	ida_remove(ida, id);
+	ida_free(ida, id);
 }
 
 #endif  /* _LINUX_IDR_H_ */



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:36:32 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: idr.h

Log Message:
linux/idr.h: Update ida_* API.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/include/linux/idr.h

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:36:21 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_drv.h vmwgfx_irq.c

Log Message:
vmwgfx(4): Hand-cruft threaded irq with a workqueue(9).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_irq.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:36:21 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_drv.h vmwgfx_irq.c

Log Message:
vmwgfx(4): Hand-cruft threaded irq with a workqueue(9).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_irq.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/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h
diff -u src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h:1.8 src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h:1.9
--- src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h:1.8	Tue Oct 25 23:35:43 2022
+++ src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h	Tue Oct 25 23:36:21 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmwgfx_drv.h,v 1.8 2022/10/25 23:35:43 riastradh Exp $	*/
+/*	$NetBSD: vmwgfx_drv.h,v 1.9 2022/10/25 23:36:21 riastradh Exp $	*/
 
 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
 /**
@@ -30,6 +30,10 @@
 #ifndef _VMWGFX_DRV_H_
 #define _VMWGFX_DRV_H_
 
+#ifdef __NetBSD__
+#include 
+#endif
+
 #include 
 #include 
 #include 
@@ -629,6 +633,11 @@ struct vmw_private {
 
 	struct vmw_cmdbuf_man *cman;
 	DECLARE_BITMAP(irqthread_pending, VMW_IRQTHREAD_MAX);
+#ifdef __NetBSD__
+	struct workqueue *irqthread_wq;
+	struct work irqthread_work;
+	volatile unsigned irqthread_scheduled;
+#endif
 
 	/* Validation memory reservation */
 	struct vmw_validation_mem vvm;

Index: src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_irq.c
diff -u src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_irq.c:1.5 src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_irq.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_irq.c:1.5	Tue Oct 25 23:35:43 2022
+++ src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_irq.c	Tue Oct 25 23:36:21 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmwgfx_irq.c,v 1.5 2022/10/25 23:35:43 riastradh Exp $	*/
+/*	$NetBSD: vmwgfx_irq.c,v 1.6 2022/10/25 23:36:21 riastradh Exp $	*/
 
 // SPDX-License-Identifier: GPL-2.0 OR MIT
 /**
@@ -28,7 +28,7 @@
  **/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmwgfx_irq.c,v 1.5 2022/10/25 23:35:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmwgfx_irq.c,v 1.6 2022/10/25 23:36:21 riastradh Exp $");
 
 #include 
 
@@ -49,12 +49,21 @@ __KERNEL_RCSID(0, "$NetBSD: vmwgfx_irq.c
  * vmw_irq_handler has returned with IRQ_WAKE_THREAD.
  *
  */
+#ifdef __NetBSD__
+static void
+vmw_thread_fn(struct work *work, void *arg)
+#else
 static irqreturn_t vmw_thread_fn(int irq, void *arg)
+#endif
 {
 	struct drm_device *dev = (struct drm_device *)arg;
 	struct vmw_private *dev_priv = vmw_priv(dev);
 	irqreturn_t ret = IRQ_NONE;
 
+#ifdef __NetBSD__
+	atomic_store_relaxed(_priv->irqthread_scheduled, false);
+#endif
+
 	if (test_and_clear_bit(VMW_IRQTHREAD_FENCE,
 			   dev_priv->irqthread_pending)) {
 		spin_lock(_priv->fence_lock);
@@ -71,7 +80,9 @@ static irqreturn_t vmw_thread_fn(int irq
 		ret = IRQ_HANDLED;
 	}
 
+#ifndef __NetBSD__
 	return ret;
+#endif
 }
 
 /**
@@ -129,6 +140,16 @@ static irqreturn_t vmw_irq_handler(int i
 			  dev_priv->irqthread_pending))
 		ret = IRQ_WAKE_THREAD;
 
+#ifdef __NetBSD__
+	if (ret == IRQ_WAKE_THREAD) {
+		if (atomic_swap_uint(_priv->irqthread_scheduled, 1) == 0) {
+			workqueue_enqueue(dev_priv->irqthread_wq,
+			_priv->irqthread_work, NULL);
+		}
+		ret = IRQ_HANDLED;
+	}
+#endif
+
 	return ret;
 }
 
@@ -450,7 +471,13 @@ void vmw_irq_uninstall(struct drm_device
 #endif
 
 	dev->irq_enabled = false;
+#ifdef __NetBSD__
+	int ret = drm_irq_uninstall(dev);
+	KASSERT(ret == 0);
+	workqueue_destroy(dev_priv->irqthread_wq);
+#else
 	free_irq(dev->irq, dev);
+#endif
 }
 
 /**
@@ -469,8 +496,21 @@ int vmw_irq_install(struct drm_device *d
 
 	vmw_irq_preinstall(dev);
 
+#ifdef __NetBSD__
+	/* XXX errno NetBSD->Linux */
+	ret = -workqueue_create(_priv(dev)->irqthread_wq, "vmwgfirq",
+	vmw_thread_fn, dev, PRI_NONE, IPL_DRM, WQ_MPSAFE);
+	if (ret < 0)
+		return ret;
+	ret = drm_irq_install(dev);
+	if (ret < 0) {
+		workqueue_destroy(vmw_priv(dev)->irqthread_wq);
+		vmw_priv(dev)->irqthread_wq = NULL;
+	}
+#else
 	ret = request_threaded_irq(irq, vmw_irq_handler, vmw_thread_fn,
    IRQF_SHARED, VMWGFX_DRIVER_NAME, dev);
+#endif
 	if (ret < 0)
 		return ret;
 



CVS commit: src/sys/external/bsd/drm2/include/drm

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:36:09 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_irq_netbsd.h

Log Message:
drm: New IRQ_WAKE_THREAD constant.

Not really wired up to anything but helps reduce diffs -- driver is
responsible for making decisions based on it, corresponding to
Linux's built-in `threaded irq'.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/include/drm/drm_irq_netbsd.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/external/bsd/drm2/include/drm/drm_irq_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_irq_netbsd.h:1.6 src/sys/external/bsd/drm2/include/drm/drm_irq_netbsd.h:1.7
--- src/sys/external/bsd/drm2/include/drm/drm_irq_netbsd.h:1.6	Sun Dec 19 12:10:58 2021
+++ src/sys/external/bsd/drm2/include/drm/drm_irq_netbsd.h	Tue Oct 25 23:36:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_irq_netbsd.h,v 1.6 2021/12/19 12:10:58 riastradh Exp $	*/
+/*	$NetBSD: drm_irq_netbsd.h,v 1.7 2022/10/25 23:36:09 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,6 +37,7 @@ typedef int irqreturn_t;
 enum irqreturn {
 	IRQ_NONE = 0x0,
 	IRQ_HANDLED = 0x1,
+	IRQ_WAKE_THREAD = 0x2,	/* XXX requires manual workqueue setup */
 };
 
 #define	DRM_IRQ_ARGS	void *arg



CVS commit: src/sys/external/bsd/drm2/include/drm

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:36:09 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_irq_netbsd.h

Log Message:
drm: New IRQ_WAKE_THREAD constant.

Not really wired up to anything but helps reduce diffs -- driver is
responsible for making decisions based on it, corresponding to
Linux's built-in `threaded irq'.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/include/drm/drm_irq_netbsd.h

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:35:57 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_execbuf.c

Log Message:
vmwgfx(4): Port fd creation.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.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/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c
diff -u src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c:1.4 src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c:1.4	Tue Oct 25 23:34:05 2022
+++ src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c	Tue Oct 25 23:35:57 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmwgfx_execbuf.c,v 1.4 2022/10/25 23:34:05 riastradh Exp $	*/
+/*	$NetBSD: vmwgfx_execbuf.c,v 1.5 2022/10/25 23:35:57 riastradh Exp $	*/
 
 // SPDX-License-Identifier: GPL-2.0 OR MIT
 /**
@@ -27,10 +27,14 @@
  *
  **/
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmwgfx_execbuf.c,v 1.4 2022/10/25 23:34:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmwgfx_execbuf.c,v 1.5 2022/10/25 23:35:57 riastradh Exp $");
 
 #include 
 
+#ifdef __NetBSD__
+#include 
+#endif
+
 #include "vmwgfx_drv.h"
 #include "vmwgfx_reg.h"
 #include 
@@ -3466,6 +3470,10 @@ vmw_execbuf_copy_fence_user(struct vmw_p
 	 * handle.
 	 */
 	if (unlikely(ret != 0) && (fence_rep.error == 0)) {
+#ifdef __NetBSD__
+		if (fd_getfile(fence_rep.fd))
+			(void)fd_close(fence_rep.fd);
+#else
 		if (sync_file)
 			fput(sync_file->file);
 
@@ -3473,6 +3481,7 @@ vmw_execbuf_copy_fence_user(struct vmw_p
 			put_unused_fd(fence_rep.fd);
 			fence_rep.fd = -1;
 		}
+#endif
 
 		ttm_ref_object_base_unref(vmw_fp->tfile, fence_handle,
 	  TTM_REF_USAGE);
@@ -3655,18 +3664,29 @@ int vmw_execbuf_process(struct drm_file 
 	struct vmw_cmdbuf_header *header;
 	uint32_t handle = 0;
 	int ret;
+#ifdef __NetBSD__
+	int out_fence_fd = -1;
+	struct file *out_fence_fp = NULL;
+#else
 	int32_t out_fence_fd = -1;
+#endif
 	struct sync_file *sync_file = NULL;
 	DECLARE_VAL_CONTEXT(val_ctx, _context->res_ht, 1);
 
 	vmw_validation_set_val_mem(_ctx, _priv->vvm);
 
 	if (flags & DRM_VMW_EXECBUF_FLAG_EXPORT_FENCE_FD) {
+#ifdef __NetBSD__
+		ret = -fd_allocfile(_fence_fp, _fence_fd);
+		if (ret)
+			return ret;
+#else
 		out_fence_fd = get_unused_fd_flags(O_CLOEXEC);
 		if (out_fence_fd < 0) {
 			VMW_DEBUG_USER("Failed to get a fence fd.\n");
 			return out_fence_fd;
 		}
+#endif
 	}
 
 	if (throttle_us) {
@@ -3813,17 +3833,30 @@ int vmw_execbuf_process(struct drm_file 
 	 */
 	if (flags & DRM_VMW_EXECBUF_FLAG_EXPORT_FENCE_FD) {
 
+#ifdef __NetBSD__
+		sync_file = sync_file_create(>base, out_fence_fp);
+#else
 		sync_file = sync_file_create(>base);
+#endif
 		if (!sync_file) {
 			VMW_DEBUG_USER("Sync file create failed for fence\n");
+#ifdef __NetBSD__
+			fd_abort(curproc, out_fence_fp, out_fence_fd);
+			out_fence_fp = NULL;
+#else
 			put_unused_fd(out_fence_fd);
+#endif
 			out_fence_fd = -1;
 
 			(void) vmw_fence_obj_wait(fence, false, false,
 		  VMW_FENCE_WAIT_TIMEOUT);
 		} else {
 			/* Link the fence with the FD created earlier */
+#ifdef __NetBSD__
+			fd_affix(curproc, out_fence_fp, out_fence_fd);
+#else
 			fd_install(out_fence_fd, sync_file->file);
+#endif
 		}
 	}
 
@@ -3877,7 +3910,11 @@ out_free_header:
 		vmw_cmdbuf_header_free(header);
 out_free_fence_fd:
 	if (out_fence_fd >= 0)
+#ifdef __NetBSD__
+		fd_abort(curproc, out_fence_fp, out_fence_fd);
+#else
 		put_unused_fd(out_fence_fd);
+#endif
 
 	return ret;
 }



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:35:57 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_execbuf.c

Log Message:
vmwgfx(4): Port fd creation.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:35:43 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_drv.c vmwgfx_drv.h
vmwgfx_ioctl.c vmwgfx_irq.c vmwgfx_marker.c vmwgfx_overlay.c
vmwgfx_reg.h

Log Message:
vmwgfx(4): Misc porting too.

- inl/outl -> bus_space_read/write
- struct device for DMA stuff -> bus_dma_tag_t
- spin_lock_destroy (and don't hold spin lock across kfree)
- driver load/unload, fops, 
- drm_irq_install/uninstall


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_ioctl.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_marker.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_overlay.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_reg.h
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_irq.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/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c
diff -u src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c:1.6 src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c:1.7
--- src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c:1.6	Tue Oct 25 23:34:05 2022
+++ src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c	Tue Oct 25 23:35:43 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmwgfx_drv.c,v 1.6 2022/10/25 23:34:05 riastradh Exp $	*/
+/*	$NetBSD: vmwgfx_drv.c,v 1.7 2022/10/25 23:35:43 riastradh Exp $	*/
 
 // SPDX-License-Identifier: GPL-2.0 OR MIT
 /**
@@ -28,7 +28,7 @@
  **/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmwgfx_drv.c,v 1.6 2022/10/25 23:34:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmwgfx_drv.c,v 1.7 2022/10/25 23:35:43 riastradh Exp $");
 
 #include 
 #include 
@@ -46,6 +46,8 @@ __KERNEL_RCSID(0, "$NetBSD: vmwgfx_drv.c
 #include "vmwgfx_binding.h"
 #include "vmwgfx_drv.h"
 
+#include 
+
 #define VMWGFX_DRIVER_DESC "Linux drm driver for VMware graphics devices"
 #define VMWGFX_CHIP_SVGAII 0
 #define VMW_FB_RESERVATION 0
@@ -269,7 +271,9 @@ static int vmw_force_coherent;
 static int vmw_restrict_dma_mask;
 static int vmw_assume_16bpp;
 
+#ifndef __NetBSD__
 static int vmw_probe(struct pci_dev *, const struct pci_device_id *);
+#endif
 static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
 			  void *ptr);
 
@@ -608,11 +612,19 @@ static int vmw_dma_masks(struct vmw_priv
 	struct drm_device *dev = dev_priv->dev;
 	int ret = 0;
 
+#ifdef __NetBSD__
+	ret = drm_limit_dma_space(dev, 0, __BITS(63,0));
+#else
 	ret = dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64));
+#endif
 	if (dev_priv->map_mode != vmw_dma_phys &&
 	(sizeof(unsigned long) == 4 || vmw_restrict_dma_mask)) {
 		DRM_INFO("Restricting DMA addresses to 44 bits.\n");
+#ifdef __NetBSD__
+		return drm_limit_dma_space(dev, 0, __BITS(43,0));
+#else
 		return dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(44));
+#endif
 	}
 
 	return ret;
@@ -762,8 +774,10 @@ static int vmw_driver_load(struct drm_de
 	if (unlikely(ret != 0))
 		goto out_err0;
 
+#ifndef __NetBSD__		/* XXX set bus_dma maxsegsz? */
 	dma_set_max_seg_size(dev->dev, min_t(unsigned int, U32_MAX & PAGE_MASK,
 	 SCATTERLIST_MAX_SEGMENT));
+#endif
 
 	if (dev_priv->capabilities & SVGA_CAP_GMR2) {
 		DRM_INFO("Max GMR ids is %u\n",
@@ -780,8 +794,20 @@ static int vmw_driver_load(struct drm_de
 	DRM_INFO("MMIO at 0x%08x size is %u kiB\n",
 		 dev_priv->mmio_start, dev_priv->mmio_size / 1024);
 
+#ifdef __NetBSD__
+	dev_priv->mmio_bst = dev->bst;
+	if (bus_space_map(dev_priv->mmio_bst, dev_priv->mmio_start,
+		dev_priv->mmio_size, BUS_SPACE_MAP_LINEAR,
+		_priv->mmio_bsh) == 0) {
+		dev_priv->mmio_virt = bus_space_vaddr(dev_priv->mmio_bst,
+		dev_priv->mmio_bsh);
+	} else {
+		dev_priv->mmio_virt = NULL;
+	}
+#else
 	dev_priv->mmio_virt = memremap(dev_priv->mmio_start,
    dev_priv->mmio_size, MEMREMAP_WB);
+#endif
 
 	if (unlikely(dev_priv->mmio_virt == NULL)) {
 		ret = -ENOMEM;
@@ -789,6 +815,18 @@ static int vmw_driver_load(struct drm_de
 		goto out_err0;
 	}
 
+#ifdef __NetBSD__
+	dev_priv->iot = dev->pdev->pd_pa.pa_iot;
+
+	/* XXX errno NetBSD->Linux */
+	ret = -bus_space_map(dev_priv->iot, dev_priv->io_start, VMWGFX_IOSIZE,
+	0, _priv->ioh);
+	if (ret) {
+		DRM_ERROR("Failed mapping IO ports.\n");
+		goto out_err3;
+	}
+#endif
+
 	/* Need mmio memory to check for fifo pitchlock cap. */
 	if (!(dev_priv->capabilities & SVGA_CAP_DISPLAY_TOPOLOGY) &&
 	!(dev_priv->capabilities & SVGA_CAP_PITCHLOCK) &&
@@ -826,7 +864,11 @@ static int vmw_driver_load(struct 

CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:35:43 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_drv.c vmwgfx_drv.h
vmwgfx_ioctl.c vmwgfx_irq.c vmwgfx_marker.c vmwgfx_overlay.c
vmwgfx_reg.h

Log Message:
vmwgfx(4): Misc porting too.

- inl/outl -> bus_space_read/write
- struct device for DMA stuff -> bus_dma_tag_t
- spin_lock_destroy (and don't hold spin lock across kfree)
- driver load/unload, fops, 
- drm_irq_install/uninstall


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_ioctl.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_marker.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_overlay.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_reg.h
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_irq.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:35:29 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_cmdbuf.c

Log Message:
vmwgfx(4): Use bus_dma tag, not struct device, for dma_pool shims.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.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/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c
diff -u src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c:1.6 src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c:1.7
--- src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c:1.6	Tue Oct 25 23:33:44 2022
+++ src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c	Tue Oct 25 23:35:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmwgfx_cmdbuf.c,v 1.6 2022/10/25 23:33:44 riastradh Exp $	*/
+/*	$NetBSD: vmwgfx_cmdbuf.c,v 1.7 2022/10/25 23:35:29 riastradh Exp $	*/
 
 // SPDX-License-Identifier: GPL-2.0 OR MIT
 /**
@@ -28,7 +28,7 @@
  **/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmwgfx_cmdbuf.c,v 1.6 2022/10/25 23:33:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmwgfx_cmdbuf.c,v 1.7 2022/10/25 23:35:29 riastradh Exp $");
 
 #include 
 #include 
@@ -1373,7 +1373,11 @@ struct vmw_cmdbuf_man *vmw_cmdbuf_man_cr
 	man->num_contexts = (dev_priv->capabilities & SVGA_CAP_HP_CMD_QUEUE) ?
 		2 : 1;
 	man->headers = dma_pool_create("vmwgfx cmdbuf",
+#ifdef __NetBSD__
+   dev_priv->dev->dmat,
+#else
    _priv->dev->pdev->dev,
+#endif
    sizeof(SVGACBHeader),
    64, PAGE_SIZE);
 	if (!man->headers) {
@@ -1382,7 +1386,11 @@ struct vmw_cmdbuf_man *vmw_cmdbuf_man_cr
 	}
 
 	man->dheaders = dma_pool_create("vmwgfx inline cmdbuf",
+#ifdef __NetBSD__
+	dev_priv->dev->dmat,
+#else
 	_priv->dev->pdev->dev,
+#endif
 	sizeof(struct vmw_cmdbuf_dheader),
 	64, PAGE_SIZE);
 	if (!man->dheaders) {



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:35:29 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_cmdbuf.c

Log Message:
vmwgfx(4): Use bus_dma tag, not struct device, for dma_pool shims.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:34:06 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_drv.c vmwgfx_drv.h
vmwgfx_execbuf.c vmwgfx_fence.c vmwgfx_fifo.c vmwgfx_irq.c

Log Message:
vmwgfx(4): Convert fence_queue and fifo_queue to drm_waitqueue_t.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_fence.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_fifo.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_irq.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/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c
diff -u src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c:1.5 src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c:1.5	Thu Feb 17 01:21:02 2022
+++ src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c	Tue Oct 25 23:34:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmwgfx_drv.c,v 1.5 2022/02/17 01:21:02 riastradh Exp $	*/
+/*	$NetBSD: vmwgfx_drv.c,v 1.6 2022/10/25 23:34:05 riastradh Exp $	*/
 
 // SPDX-License-Identifier: GPL-2.0 OR MIT
 /**
@@ -28,7 +28,7 @@
  **/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmwgfx_drv.c,v 1.5 2022/02/17 01:21:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmwgfx_drv.c,v 1.6 2022/10/25 23:34:05 riastradh Exp $");
 
 #include 
 #include 
@@ -655,8 +655,10 @@ static int vmw_driver_load(struct drm_de
 		INIT_LIST_HEAD(_priv->res_lru[i]);
 	}
 
-	init_waitqueue_head(_priv->fence_queue);
-	init_waitqueue_head(_priv->fifo_queue);
+	DRM_INIT_WAITQUEUE(_priv->fence_queue, "vmwgfence");
+	spin_lock_init(_priv->fence_lock);
+	DRM_INIT_WAITQUEUE(_priv->fifo_queue, "vmwgfifo");
+	spin_lock_init(_priv->fifo_lock);
 	dev_priv->fence_queue_waiters = 0;
 	dev_priv->fifo_queue_waiters = 0;
 
@@ -963,6 +965,11 @@ out_no_device:
 out_err4:
 	memunmap(dev_priv->mmio_virt);
 out_err0:
+	spin_lock_destroy(_priv->fifo_lock);
+	DRM_DESTROY_WAITQUEUE(_priv->fifo_queue);
+	spin_lock_destroy(_priv->fence_lock);
+	DRM_DESTROY_WAITQUEUE(_priv->fence_queue);
+
 	for (i = vmw_res_context; i < vmw_res_max; ++i)
 		idr_destroy(_priv->res_idr[i]);
 
@@ -1015,6 +1022,11 @@ static void vmw_driver_unload(struct drm
 	if (dev_priv->ctx.staged_bindings)
 		vmw_binding_state_free(dev_priv->ctx.staged_bindings);
 
+	spin_lock_destroy(_priv->fifo_lock);
+	DRM_DESTROY_WAITQUEUE(_priv->fifo_queue);
+	spin_lock_destroy(_priv->fence_lock);
+	DRM_DESTROY_WAITQUEUE(_priv->fence_queue);
+
 	for (i = vmw_res_context; i < vmw_res_max; ++i)
 		idr_destroy(_priv->res_idr[i]);
 

Index: src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h
diff -u src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h:1.6 src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h:1.7
--- src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h:1.6	Thu Feb 17 01:21:02 2022
+++ src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h	Tue Oct 25 23:34:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmwgfx_drv.h,v 1.6 2022/02/17 01:21:02 riastradh Exp $	*/
+/*	$NetBSD: vmwgfx_drv.h,v 1.7 2022/10/25 23:34:05 riastradh Exp $	*/
 
 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
 /**
@@ -538,7 +538,9 @@ struct vmw_private {
 
 	atomic_t marker_seq;
 	drm_waitqueue_t fence_queue;
+	spinlock_t fence_lock;
 	drm_waitqueue_t fifo_queue;
+	spinlock_t fifo_lock;
 	spinlock_t waiter_lock;
 	int fence_queue_waiters; /* Protected by waiter_lock */
 	int goal_queue_waiters; /* Protected by waiter_lock */

Index: src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c
diff -u src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c:1.3 src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c:1.4
--- src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c:1.3	Sat Dec 18 23:45:45 2021
+++ src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c	Tue Oct 25 23:34:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmwgfx_execbuf.c,v 1.3 2021/12/18 23:45:45 riastradh Exp $	*/
+/*	$NetBSD: vmwgfx_execbuf.c,v 1.4 2022/10/25 23:34:05 riastradh Exp $	*/
 
 // SPDX-License-Identifier: GPL-2.0 OR MIT
 /**
@@ -27,7 +27,7 @@
  *
  **/
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmwgfx_execbuf.c,v 1.3 2021/12/18 23:45:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmwgfx_execbuf.c,v 1.4 

CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:34:06 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_drv.c vmwgfx_drv.h
vmwgfx_execbuf.c vmwgfx_fence.c vmwgfx_fifo.c vmwgfx_irq.c

Log Message:
vmwgfx(4): Convert fence_queue and fifo_queue to drm_waitqueue_t.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_fence.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_fifo.c \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_irq.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:33:44 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_cmdbuf.c

Log Message:
vmwgfx(4): Convert cmdbuf to drm_waitqueue_t.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.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/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c
diff -u src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c:1.5 src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c:1.5	Tue Oct 25 23:32:04 2022
+++ src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c	Tue Oct 25 23:33:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmwgfx_cmdbuf.c,v 1.5 2022/10/25 23:32:04 riastradh Exp $	*/
+/*	$NetBSD: vmwgfx_cmdbuf.c,v 1.6 2022/10/25 23:33:44 riastradh Exp $	*/
 
 // SPDX-License-Identifier: GPL-2.0 OR MIT
 /**
@@ -28,7 +28,7 @@
  **/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmwgfx_cmdbuf.c,v 1.5 2022/10/25 23:32:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmwgfx_cmdbuf.c,v 1.6 2022/10/25 23:33:44 riastradh Exp $");
 
 #include 
 #include 
@@ -132,8 +132,8 @@ struct vmw_cmdbuf_man {
 	spinlock_t lock;
 	struct dma_pool *headers;
 	struct dma_pool *dheaders;
-	wait_queue_head_t alloc_queue;
-	wait_queue_head_t idle_queue;
+	drm_waitqueue_t alloc_queue;
+	drm_waitqueue_t idle_queue;
 	bool irq_on;
 	bool using_mob;
 	bool has_pool;
@@ -276,7 +276,7 @@ static void __vmw_cmdbuf_header_free(str
 	}
 
 	drm_mm_remove_node(>node);
-	wake_up_all(>alloc_queue);
+	DRM_SPIN_WAKEUP_ALL(>alloc_queue, >lock); /* XXX */
 	if (header->cb_header)
 		dma_pool_free(man->headers, header->cb_header,
 			  header->handle);
@@ -391,6 +391,8 @@ static void vmw_cmdbuf_ctx_process(struc
 {
 	struct vmw_cmdbuf_header *entry, *next;
 
+	assert_spin_locked(>lock);
+
 	vmw_cmdbuf_ctx_submit(man, ctx);
 
 	list_for_each_entry_safe(entry, next, >hw_submitted, list) {
@@ -400,7 +402,7 @@ static void vmw_cmdbuf_ctx_process(struc
 			break;
 
 		list_del(>list);
-		wake_up_all(>idle_queue);
+		DRM_SPIN_WAKEUP_ONE(>idle_queue, >lock);
 		ctx->num_hw_submitted--;
 		switch (status) {
 		case SVGA_CB_STATUS_COMPLETED:
@@ -448,6 +450,8 @@ static void vmw_cmdbuf_man_process(struc
 	struct vmw_cmdbuf_context *ctx;
 	int i;
 
+	assert_spin_locked(>lock);
+
 retry:
 	notempty = 0;
 	for_each_cmdbuf_ctx(man, i, ctx)
@@ -622,7 +626,9 @@ static void vmw_cmdbuf_work_func(struct 
 	/* Send a new fence in case one was removed */
 	if (send_fence) {
 		vmw_fifo_send_fence(man->dev_priv, );
-		wake_up_all(>idle_queue);
+		spin_lock(>lock);
+		DRM_SPIN_WAKEUP_ALL(>idle_queue, >lock);
+		spin_unlock(>lock);
 	}
 
 	mutex_unlock(>error_mutex);
@@ -642,20 +648,19 @@ static bool vmw_cmdbuf_man_idle(struct v
 	bool idle = false;
 	int i;
 
-	spin_lock(>lock);
+	assert_spin_locked(>lock);
+
 	vmw_cmdbuf_man_process(man);
 	for_each_cmdbuf_ctx(man, i, ctx) {
 		if (!list_empty(>submitted) ||
 		!list_empty(>hw_submitted) ||
 		(check_preempted && !list_empty(>preempted)))
-			goto out_unlock;
+			goto out;
 	}
 
 	idle = list_empty(>error);
 
-out_unlock:
-	spin_unlock(>lock);
-
+out:
 	return idle;
 }
 
@@ -732,18 +737,17 @@ int vmw_cmdbuf_idle(struct vmw_cmdbuf_ma
 	int ret;
 
 	ret = vmw_cmdbuf_cur_flush(man, interruptible);
+	spin_lock(>lock);
 	vmw_generic_waiter_add(man->dev_priv,
 			   SVGA_IRQFLAG_COMMAND_BUFFER,
 			   >dev_priv->cmdbuf_waiters);
-
 	if (interruptible) {
-		ret = wait_event_interruptible_timeout
-			(man->idle_queue, vmw_cmdbuf_man_idle(man, true),
-			 timeout);
+		DRM_SPIN_TIMED_WAIT_UNTIL(ret, >idle_queue, >lock,
+		timeout, vmw_cmdbuf_man_idle(man, true));
 	} else {
-		ret = wait_event_timeout
-			(man->idle_queue, vmw_cmdbuf_man_idle(man, true),
-			 timeout);
+		DRM_SPIN_TIMED_WAIT_NOINTR_UNTIL(ret, >idle_queue,
+		>lock,
+		timeout, vmw_cmdbuf_man_idle(man, true));
 	}
 	vmw_generic_waiter_remove(man->dev_priv,
   SVGA_IRQFLAG_COMMAND_BUFFER,
@@ -754,6 +758,7 @@ int vmw_cmdbuf_idle(struct vmw_cmdbuf_ma
 		else
 			ret = 0;
 	}
+	spin_unlock(>lock);
 	if (ret > 0)
 		ret = 0;
 
@@ -825,6 +830,7 @@ static int vmw_cmdbuf_alloc_space(struct
 	} else {
 		mutex_lock(>space_mutex);
 	}
+	spin_lock(>lock);
 
 	/* Try to allocate space without waiting. */
 	if (vmw_cmdbuf_try_alloc(man, ))
@@ -837,23 +843,29 @@ static int vmw_cmdbuf_alloc_space(struct
 	if (interruptible) {
 		int ret;
 
-		ret = wait_event_interruptible
-			(man->alloc_queue, vmw_cmdbuf_try_alloc(man, ));
+		DRM_SPIN_WAIT_UNTIL(ret, >alloc_queue, >lock,
+		vmw_cmdbuf_try_alloc(man, ));
 		if (ret) {
 			

CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:33:44 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_cmdbuf.c

Log Message:
vmwgfx(4): Convert cmdbuf to drm_waitqueue_t.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c

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



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:33:29 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: spinlock.h

Log Message:
linux/spinlock.h: spin_lock_bh, spin_unlock_bh

Nothing special needed here; NetBSD mutex(9) at IPL_* giving spin
locks already blocks `BH' (i.e., softints -- although I'm not sure
softints are relevant to the one use of this in vmwgfx).


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/include/linux/spinlock.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/external/bsd/drm2/include/linux/spinlock.h
diff -u src/sys/external/bsd/drm2/include/linux/spinlock.h:1.14 src/sys/external/bsd/drm2/include/linux/spinlock.h:1.15
--- src/sys/external/bsd/drm2/include/linux/spinlock.h:1.14	Sun Dec 19 11:52:08 2021
+++ src/sys/external/bsd/drm2/include/linux/spinlock.h	Tue Oct 25 23:33:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: spinlock.h,v 1.14 2021/12/19 11:52:08 riastradh Exp $	*/
+/*	$NetBSD: spinlock.h,v 1.15 2022/10/25 23:33:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -65,6 +65,18 @@ spin_unlock(spinlock_t *spinlock)
 }
 
 static inline void
+spin_lock_bh(spinlock_t *spinlock)
+{
+	spin_lock(spinlock);
+}
+
+static inline void
+spin_unlock_bh(spinlock_t *spinlock)
+{
+	spin_unlock(spinlock);
+}
+
+static inline void
 spin_lock_irq(spinlock_t *spinlock)
 {
 	spin_lock(spinlock);



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:33:29 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: spinlock.h

Log Message:
linux/spinlock.h: spin_lock_bh, spin_unlock_bh

Nothing special needed here; NetBSD mutex(9) at IPL_* giving spin
locks already blocks `BH' (i.e., softints -- although I'm not sure
softints are relevant to the one use of this in vmwgfx).


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/include/linux/spinlock.h

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



CVS commit: src/sys/external/bsd/drm2/include/asm

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:33:18 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/asm: io.h

Log Message:
linux asm/io.h: Side-load linux/vmalloc.h like Linux does.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/include/asm/io.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/external/bsd/drm2/include/asm/io.h
diff -u src/sys/external/bsd/drm2/include/asm/io.h:1.9 src/sys/external/bsd/drm2/include/asm/io.h:1.10
--- src/sys/external/bsd/drm2/include/asm/io.h:1.9	Mon Feb 14 00:28:33 2022
+++ src/sys/external/bsd/drm2/include/asm/io.h	Tue Oct 25 23:33:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.h,v 1.9 2022/02/14 00:28:33 riastradh Exp $	*/
+/*	$NetBSD: io.h,v 1.10 2022/10/25 23:33:18 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,6 +36,7 @@
 #include 
 
 #include 
+#include 
 
 #define	memcpy_fromio(d,s,n)	memcpy((d),__UNVOLATILE(s),(n))
 #define	memcpy_toio(d,s,n)	memcpy(__UNVOLATILE(d),(s),(n))



CVS commit: src/sys/external/bsd/drm2/include/asm

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:33:18 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/asm: io.h

Log Message:
linux asm/io.h: Side-load linux/vmalloc.h like Linux does.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/include/asm/io.h

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



CVS commit: src/sys/external/bsd

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:32:37 UTC 2022

Added Files:
src/sys/external/bsd/common/include/linux: dmapool.h
Removed Files:
src/sys/external/bsd/drm2/include/linux: dmapool.h

Log Message:
linux/dmapool.h: Start filling out stubs.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/common/include/linux/dmapool.h
cvs rdiff -u -r1.1 -r0 src/sys/external/bsd/drm2/include/linux/dmapool.h

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



CVS commit: src/sys/external/bsd

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:32:37 UTC 2022

Added Files:
src/sys/external/bsd/common/include/linux: dmapool.h
Removed Files:
src/sys/external/bsd/drm2/include/linux: dmapool.h

Log Message:
linux/dmapool.h: Start filling out stubs.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/common/include/linux/dmapool.h
cvs rdiff -u -r1.1 -r0 src/sys/external/bsd/drm2/include/linux/dmapool.h

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

Added files:

Index: src/sys/external/bsd/common/include/linux/dmapool.h
diff -u /dev/null src/sys/external/bsd/common/include/linux/dmapool.h:1.1
--- /dev/null	Tue Oct 25 23:32:37 2022
+++ src/sys/external/bsd/common/include/linux/dmapool.h	Tue Oct 25 23:32:37 2022
@@ -0,0 +1,54 @@
+/*	$NetBSD: dmapool.h,v 1.1 2022/10/25 23:32:37 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef	_LINUX_DMAPOOL_H_
+#define	_LINUX_DMAPOOL_H_
+
+#include 
+
+#include 
+
+#include 
+#include 
+
+/* namespace */
+#define	dma_pool_create		linux_dma_pool_create
+#define	dma_pool_destroy	linux_dma_pool_destroy
+#define	dma_pool_free		linux_dma_pool_free
+#define	dma_pool_zalloc		linux_dma_pool_zalloc
+
+struct dma_pool;
+
+struct dma_pool *dma_pool_create(const char *, bus_dma_tag_t, size_t, size_t,
+size_t);
+void dma_pool_destroy(struct dma_pool *);
+
+void *dma_pool_zalloc(struct dma_pool *, gfp_t, dma_addr_t *);
+void dma_pool_free(struct dma_pool *, void *, dma_addr_t);
+
+#endif	/* _LINUX_DMAPOOL_H_ */



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:32:04 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_cmdbuf.c

Log Message:
vmwgfx(4): dma_alloc/free_coherent -> bus_dma_*


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.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/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c
diff -u src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c:1.4 src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c:1.4	Thu Feb 17 01:21:02 2022
+++ src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c	Tue Oct 25 23:32:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmwgfx_cmdbuf.c,v 1.4 2022/02/17 01:21:02 riastradh Exp $	*/
+/*	$NetBSD: vmwgfx_cmdbuf.c,v 1.5 2022/10/25 23:32:04 riastradh Exp $	*/
 
 // SPDX-License-Identifier: GPL-2.0 OR MIT
 /**
@@ -28,7 +28,7 @@
  **/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmwgfx_cmdbuf.c,v 1.4 2022/02/17 01:21:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmwgfx_cmdbuf.c,v 1.5 2022/10/25 23:32:04 riastradh Exp $");
 
 #include 
 #include 
@@ -137,6 +137,10 @@ struct vmw_cmdbuf_man {
 	bool irq_on;
 	bool using_mob;
 	bool has_pool;
+#ifdef __NetBSD__
+	bus_dmamap_t dmamap;
+	bus_dma_segment_t dmaseg;
+#endif
 	dma_addr_t handle;
 	size_t size;
 	u32 num_contexts;
@@ -1237,8 +1241,46 @@ int vmw_cmdbuf_set_pool_size(struct vmw_
 
 	/* First, try to allocate a huge chunk of DMA memory */
 	size = PAGE_ALIGN(size);
+#ifdef __NetBSD__
+	int error, nseg, alloced = 0,  mapped = 0, loaded = 0;
+
+	do {
+		error = bus_dmamap_create(dev_priv->dev->dmat, size, 1, size,
+		0, BUS_DMA_ALLOCNOW|BUS_DMA_WAITOK, >dmamap);
+		if (error)
+			break;
+		error = bus_dmamem_alloc(dev_priv->dev->dmat, size, 1, 0,
+		>dmaseg, 1, , BUS_DMA_WAITOK);
+		if (error)
+			break;
+		KASSERT(nseg == 1);
+		alloced = 1;
+		error = bus_dmamem_map(dev_priv->dev->dmat, >dmaseg, 1,
+		size, (void *)>map, BUS_DMA_COHERENT|BUS_DMA_WAITOK);
+		if (error)
+			break;
+		mapped = 1;
+		error = bus_dmamap_load(dev_priv->dev->dmat, man->dmamap,
+		man->map, size, NULL, BUS_DMA_WAITOK);
+		if (error)
+			break;
+		loaded = 1;
+	} while (0);
+	if (error) {
+		if (loaded)
+			bus_dmamap_unload(dev_priv->dev->dmat, man->dmamap);
+		if (mapped)
+			bus_dmamem_unmap(dev_priv->dev->dmat, man->map, size);
+		if (alloced)
+			bus_dmamem_free(dev_priv->dev->dmat, >dmaseg, 1);
+		if (man->dmamap)
+			bus_dmamap_destroy(dev_priv->dev->dmat, man->dmamap);
+		man->map = NULL;
+	}
+#else
 	man->map = dma_alloc_coherent(_priv->dev->pdev->dev, size,
   >handle, GFP_KERNEL);
+#endif
 	if (man->map) {
 		man->using_mob = false;
 	} else {
@@ -1393,8 +1435,16 @@ void vmw_cmdbuf_remove_pool(struct vmw_c
 		ttm_bo_put(man->cmd_space);
 		man->cmd_space = NULL;
 	} else {
+#ifdef __NetBSD__
+		const bus_dma_tag_t dmat = man->dev_priv->dev->dmat;
+		bus_dmamap_unload(dmat, man->dmamap);
+		bus_dmamem_unmap(dmat, man->map, man->size);
+		bus_dmamem_free(dmat, >dmaseg, 1);
+		bus_dmamap_destroy(dmat, man->dmamap);
+#else
 		dma_free_coherent(>dev_priv->dev->pdev->dev,
   man->size, man->map, man->handle);
+#endif
 	}
 }
 



CVS commit: src/sys/external/bsd/drm2/dist/drm/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:32:04 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/vmwgfx: vmwgfx_cmdbuf.c

Log Message:
vmwgfx(4): dma_alloc/free_coherent -> bus_dma_*


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c

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



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:31:49 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: module.h

Log Message:
linux/module.h: MODULE_VERSION


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/drm2/include/linux/module.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/external/bsd/drm2/include/linux/module.h
diff -u src/sys/external/bsd/drm2/include/linux/module.h:1.12 src/sys/external/bsd/drm2/include/linux/module.h:1.13
--- src/sys/external/bsd/drm2/include/linux/module.h:1.12	Sun Dec 19 10:47:38 2021
+++ src/sys/external/bsd/drm2/include/linux/module.h	Tue Oct 25 23:31:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: module.h,v 1.12 2021/12/19 10:47:38 riastradh Exp $	*/
+/*	$NetBSD: module.h,v 1.13 2022/10/25 23:31:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -50,6 +50,7 @@
 #define	MODULE_DEVICE_TABLE(DESCRIPTION, IDLIST)
 #define	MODULE_FIRMWARE(FIRMWARE)
 #define	MODULE_LICENSE(LICENSE)
+#define	MODULE_VERSION(VERSION)
 
 #define	THIS_MODULE	0
 #define	KBUILD_MODNAME	__file__



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:31:49 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: module.h

Log Message:
linux/module.h: MODULE_VERSION


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/drm2/include/linux/module.h

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



CVS commit: src/sys/external/bsd/drm2/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:31:38 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/vmwgfx: files.vmwgfx

Log Message:
vmwgfx: Set some warning and config flags.  Nix vmwgfx_fb.c for now.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/vmwgfx/files.vmwgfx

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

Modified files:

Index: src/sys/external/bsd/drm2/vmwgfx/files.vmwgfx
diff -u src/sys/external/bsd/drm2/vmwgfx/files.vmwgfx:1.2 src/sys/external/bsd/drm2/vmwgfx/files.vmwgfx:1.3
--- src/sys/external/bsd/drm2/vmwgfx/files.vmwgfx:1.2	Tue Jul 19 23:19:07 2022
+++ src/sys/external/bsd/drm2/vmwgfx/files.vmwgfx	Tue Oct 25 23:31:38 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.vmwgfx,v 1.2 2022/07/19 23:19:07 riastradh Exp $
+#	$NetBSD: files.vmwgfx,v 1.3 2022/10/25 23:31:38 riastradh Exp $
 
 version	20180827
 
@@ -22,7 +22,14 @@ makeoptions	vmwgfx	"CPPFLAGS.vmwgfx"+="-
 # Then their header files.
 makeoptions	vmwgfx	"CPPFLAGS.vmwgfx"+="-I$S/external/bsd/drm2/dist/drm/vmwgfx"
 
+makeoptions	vmwgfx	"CPPFLAGS.vmwgfx"+="-DCONFIG_DRM_TTM_DMA_PAGE_POOL=0"
+makeoptions	vmwgfx	"CPPFLAGS.vmwgfx"+="-DCONFIG_DRM_VMWGFX_FBCON=1"
+
+makeoptions	vmwgfx	"CWARNFLAGS.vmwgfx"+="-Wno-cast-qual"
 makeoptions	vmwgfx	"CWARNFLAGS.vmwgfx"+="-Wno-missing-field-initializers"
+makeoptions	vmwgfx	"CWARNFLAGS.vmwgfx"+="-Wno-pointer-arith"
+makeoptions	vmwgfx	"CWARNFLAGS.vmwgfx"+="-Wno-unused-but-set-variable"
+makeoptions	vmwgfx	"CWARNFLAGS.vmwgfx"+="-Wno-unused-function"
 
 file	external/bsd/drm2/vmwgfx/vmwgfx_module.c		vmwgfx
 file	external/bsd/drm2/vmwgfx/vmwgfx_pci.c			vmwgfx
@@ -40,7 +47,7 @@ file	external/bsd/drm2/dist/drm/vmwgfx/v
 file	external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cotable.c	vmwgfx
 file	external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c	vmwgfx
 file	external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_execbuf.c	vmwgfx
-file	external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_fb.c	vmwgfx
+#file	external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_fb.c	vmwgfx
 file	external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_fence.c	vmwgfx
 file	external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_fifo.c	vmwgfx
 file	external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_gmr.c	vmwgfx



CVS commit: src/sys/external/bsd/drm2/vmwgfx

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:31:38 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/vmwgfx: files.vmwgfx

Log Message:
vmwgfx: Set some warning and config flags.  Nix vmwgfx_fb.c for now.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/vmwgfx/files.vmwgfx

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



CVS commit: src/sys/external/bsd/common/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:31:27 UTC 2022

Modified Files:
src/sys/external/bsd/common/include/linux: export.h

Log Message:
linux/export.h: Side-load linux/stringify.h.

Expected by some users.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/external/bsd/common/include/linux/export.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/external/bsd/common/include/linux/export.h
diff -u src/sys/external/bsd/common/include/linux/export.h:1.1 src/sys/external/bsd/common/include/linux/export.h:1.2
--- src/sys/external/bsd/common/include/linux/export.h:1.1	Sun Dec 19 09:42:27 2021
+++ src/sys/external/bsd/common/include/linux/export.h	Tue Oct 25 23:31:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: export.h,v 1.1 2021/12/19 09:42:27 riastradh Exp $	*/
+/*	$NetBSD: export.h,v 1.2 2022/10/25 23:31:27 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,6 +32,8 @@
 #ifndef _LINUX_EXPORT_H_
 #define _LINUX_EXPORT_H_
 
+#include 
+
 #define	EXPORT_SYMBOL(name)
 
 /* XXX Provisional -- this shouldn't happen in sources we use.  */



CVS commit: src/sys/external/bsd/common/include/linux

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:31:27 UTC 2022

Modified Files:
src/sys/external/bsd/common/include/linux: export.h

Log Message:
linux/export.h: Side-load linux/stringify.h.

Expected by some users.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/external/bsd/common/include/linux/export.h

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



CVS commit: src/sys/kern

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:22:36 UTC 2022

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

Log Message:
extattr(9): KNF

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/kern/vfs_xattr.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/vfs_xattr.c
diff -u src/sys/kern/vfs_xattr.c:1.37 src/sys/kern/vfs_xattr.c:1.38
--- src/sys/kern/vfs_xattr.c:1.37	Tue Oct 25 23:22:17 2022
+++ src/sys/kern/vfs_xattr.c	Tue Oct 25 23:22:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_xattr.c,v 1.37 2022/10/25 23:22:17 riastradh Exp $	*/
+/*	$NetBSD: vfs_xattr.c,v 1.38 2022/10/25 23:22:36 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.37 2022/10/25 23:22:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.38 2022/10/25 23:22:36 riastradh Exp $");
 
 #include 
 #include 
@@ -113,7 +113,7 @@ extattr_check_cred(struct vnode *vp, int
 {
 
 	if (cred == NOCRED)
-		return (0);
+		return 0;
 
 	return kauth_authorize_vnode(cred, kauth_extattr_action(access), vp,
 	NULL, genfs_can_extattr(vp, cred, access, attrspace));
@@ -131,7 +131,7 @@ vfs_stdextattrctl(struct mount *mp, int 
 
 	if (vp != NULL)
 		VOP_UNLOCK(vp);
-	return (EOPNOTSUPP);
+	return EOPNOTSUPP;
 }
 
 /*
@@ -161,28 +161,27 @@ sys_extattrctl(struct lwp *l, const stru
 		error = copyinstr(SCARG(uap, attrname), attrname,
 		sizeof(attrname), NULL);
 		if (error)
-			return (error);
+			return error;
 	}
 
-	error = namei_simple_user(SCARG(uap, path),
-NSM_FOLLOW_NOEMULROOT, _vp);
-	if (error) {
-		return (error);
-	}
+	error = namei_simple_user(SCARG(uap, path), NSM_FOLLOW_NOEMULROOT,
+	_vp);
+	if (error)
+		return error;
 
 	file_vp = NULL;
 	if (SCARG(uap, filename) != NULL) {
 		error = pathbuf_copyin(SCARG(uap, filename), _pb);
 		if (error) {
 			vrele(path_vp);
-			return (error);
+			return error;
 		}
 		NDINIT(_nd, LOOKUP, FOLLOW | LOCKLEAF, file_pb);
 		error = namei(_nd);
 		if (error) {
 			pathbuf_destroy(file_pb);
 			vrele(path_vp);
-			return (error);
+			return error;
 		}
 		file_vp = file_nd.ni_vp;
 		pathbuf_destroy(file_pb);
@@ -196,7 +195,7 @@ sys_extattrctl(struct lwp *l, const stru
 		vrele(file_vp);
 	vrele(path_vp);
 
-	return (error);
+	return error;
 }
 
 /*
@@ -228,7 +227,7 @@ extattr_set_vp(struct vnode *vp, int att
 		size_t attrlen;
 
 		error = VOP_GETEXTATTR(vp, attrnamespace, attrname, NULL,
-   , l->l_cred);
+		, l->l_cred);
 
 		switch (error) {
 		case ENODATA:
@@ -271,7 +270,7 @@ extattr_set_vp(struct vnode *vp, int att
 
  done:
 	VOP_UNLOCK(vp);
-	return (error);
+	return error;
 }
 
 /*
@@ -333,7 +332,7 @@ extattr_get_vp(struct vnode *vp, int att
 
  done:
 	VOP_UNLOCK(vp);
-	return (error);
+	return error;
 }
 
 /*
@@ -357,7 +356,7 @@ extattr_delete_vp(struct vnode *vp, int 
 		l->l_cred);
 
 	VOP_UNLOCK(vp);
-	return (error);
+	return error;
 }
 
 /*
@@ -399,8 +398,8 @@ extattr_list_vp(struct vnode *vp, int at
 	} else
 		sizep = 
 
-	error = VOP_LISTEXTATTR(vp, attrnamespace, auiop, sizep, 
-flag, l->l_cred);
+	error = VOP_LISTEXTATTR(vp, attrnamespace, auiop, sizep, flag,
+	l->l_cred);
 
 	if (auiop != NULL) {
 		cnt -= auio.uio_resid;
@@ -412,7 +411,7 @@ extattr_list_vp(struct vnode *vp, int at
 
  done:
 	VOP_UNLOCK(vp);
-	return (error);
+	return error;
 }
 
 /*
@@ -420,7 +419,8 @@ extattr_list_vp(struct vnode *vp, int at
  */
 
 int
-sys_extattr_set_fd(struct lwp *l, const struct sys_extattr_set_fd_args *uap, register_t *retval)
+sys_extattr_set_fd(struct lwp *l, const struct sys_extattr_set_fd_args *uap,
+register_t *retval)
 {
 	/* {
 		syscallarg(int) fd;
@@ -437,22 +437,24 @@ sys_extattr_set_fd(struct lwp *l, const 
 	error = copyinstr(SCARG(uap, attrname), attrname, sizeof(attrname),
 	NULL);
 	if (error)
-		return (error);
+		return error;
 
 	error = fd_getvnode(SCARG(uap, fd), );
 	if (error)
-		return (error);
+		return error;
 	vp = fp->f_vnode;
 
 	error = extattr_set_vp(vp, SCARG(uap, attrnamespace), attrname,
 	SCARG(uap, data), SCARG(uap, nbytes), l, retval, 0);
 
 	fd_putfile(SCARG(uap, fd));
-	return (error);
+	return error;
 }
 
 int
-sys_extattr_set_file(struct lwp *l, const struct sys_extattr_set_file_args *uap, register_t *retval)
+sys_extattr_set_file(struct lwp *l,
+const struct sys_extattr_set_file_args *uap,
+register_t *retval)
 {
 	/* {
 		syscallarg(const char *) path;
@@ -468,22 +470,24 @@ sys_extattr_set_file(struct lwp *l, cons
 	error = copyinstr(SCARG(uap, attrname), attrname, 

CVS commit: src/sys/kern

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:22:36 UTC 2022

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

Log Message:
extattr(9): KNF

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/kern/vfs_xattr.c

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



CVS commit: src/sys/kern

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:22:17 UTC 2022

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

Log Message:
extattr(9): Fix uninitialized uio_iovcnt.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/kern/vfs_xattr.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/vfs_xattr.c
diff -u src/sys/kern/vfs_xattr.c:1.36 src/sys/kern/vfs_xattr.c:1.37
--- src/sys/kern/vfs_xattr.c:1.36	Sun Jun 27 09:13:08 2021
+++ src/sys/kern/vfs_xattr.c	Tue Oct 25 23:22:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_xattr.c,v 1.36 2021/06/27 09:13:08 christos Exp $	*/
+/*	$NetBSD: vfs_xattr.c,v 1.37 2022/10/25 23:22:17 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.36 2021/06/27 09:13:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.37 2022/10/25 23:22:17 riastradh Exp $");
 
 #include 
 #include 
@@ -303,6 +303,7 @@ extattr_get_vp(struct vnode *vp, int att
 		aiov.iov_base = data;
 		aiov.iov_len = nbytes;
 		auio.uio_iov = 
+		auio.uio_iovcnt = 1;
 		auio.uio_offset = 0;
 		if (nbytes > INT_MAX) {
 			error = EINVAL;
@@ -383,6 +384,7 @@ extattr_list_vp(struct vnode *vp, int at
 		aiov.iov_base = data;
 		aiov.iov_len = nbytes;
 		auio.uio_iov = 
+		auio.uio_iovcnt = 1;
 		auio.uio_offset = 0;
 		if (nbytes > INT_MAX) {
 			error = EINVAL;



CVS commit: src/sys/kern

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:22:17 UTC 2022

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

Log Message:
extattr(9): Fix uninitialized uio_iovcnt.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/kern/vfs_xattr.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

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:21:33 UTC 2022

Modified Files:
src/sys/dev: cons.c

Log Message:
console(4), constty(4): Rip off the kernel lock, take three.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/cons.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/cons.c
diff -u src/sys/dev/cons.c:1.91 src/sys/dev/cons.c:1.92
--- src/sys/dev/cons.c:1.91	Tue Oct 25 23:21:13 2022
+++ src/sys/dev/cons.c	Tue Oct 25 23:21:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cons.c,v 1.91 2022/10/25 23:21:13 riastradh Exp $	*/
+/*	$NetBSD: cons.c,v 1.92 2022/10/25 23:21:33 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.91 2022/10/25 23:21:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.92 2022/10/25 23:21:33 riastradh Exp $");
 
 #include 
 #include 
@@ -84,7 +84,7 @@ const struct cdevsw cons_cdevsw = {
 	.d_mmap = nommap,
 	.d_kqfilter = cnkqfilter,
 	.d_discard = nodiscard,
-	.d_flag = D_TTY
+	.d_flag = D_TTY|D_MPSAFE,
 };
 
 static struct kmutex cn_lock;



CVS commit: src/sys/dev

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:21:33 UTC 2022

Modified Files:
src/sys/dev: cons.c

Log Message:
console(4), constty(4): Rip off the kernel lock, take three.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/cons.c

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



CVS commit: src/sys

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:21:13 UTC 2022

Modified Files:
src/sys/dev: cons.c
src/sys/kern: subr_prf.c tty.c
src/sys/sys: tty.h

Log Message:
constty(4): Make MP-safe, take three.

Access to the global constty variable is coordinated as follows:

1. Setting constty to nonnull, with atomic_store_release, is allowed
   only under the new adaptive constty_lock in thread context.  This
   serializes TIOCCONS operations and ensures unlocked readers can
   safely use a constty pointer read with atomic_load_consume.

2. Changing constty from nonnull to null, with atomic_cas_ptr, is
   allowed in any context -- printf(9) uses this to disable a broken
   constty.

3. Reading constty under constty_lock is allowed with
   atomic_load_relaxed, because while constty_lock is held, it can
   only be made null by some other thread/CPU, never made nonnull.

4. Reading constty outside constty_lock is allowed with
   atomic_load_consume in a pserialize read section -- constty is
   only ever made nonnull with atomic_store_release, in (1).
   ttyclose will wait for all these pserialize read sections to
   complete before flushing the tty.

5. To continue to use a struct tty pointer in (4) after the
   pserialize read section has completed, caller must use tty_acquire
   during the pserialize read section and then tty_release when done.
   ttyclose will wait for all these references to drain before
   returning.

These access rules allow us to serialize TIOCCONS, and safely destroy
ttys, without putting any locks on the access paths like printf(9)
that use constty.  Once we set D_MPSAFE, operations on /dev/console
will contend only with other users of the same tty as constty, which
will be an improvement over contending with all other kernel lock
users in the system.

Changes second time around:
- Fix initialization of ok in cons.c cn_redirect.
- Fix reversed sense of conditional in subr_prf.c putone.

Changes third time around:
- Initialize ttyref_cv so we don't panic when trying to use it,
  leading to infinite loop when panic tries to take tty_lock to print
  the panic message while we already hold tty_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/dev/cons.c
cvs rdiff -u -r1.193 -r1.194 src/sys/kern/subr_prf.c
cvs rdiff -u -r1.305 -r1.306 src/sys/kern/tty.c
cvs rdiff -u -r1.101 -r1.102 src/sys/sys/tty.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/cons.c
diff -u src/sys/dev/cons.c:1.90 src/sys/dev/cons.c:1.91
--- src/sys/dev/cons.c:1.90	Fri Oct  7 18:59:37 2022
+++ src/sys/dev/cons.c	Tue Oct 25 23:21:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cons.c,v 1.90 2022/10/07 18:59:37 riastradh Exp $	*/
+/*	$NetBSD: cons.c,v 1.91 2022/10/25 23:21:13 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.90 2022/10/07 18:59:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.91 2022/10/25 23:21:13 riastradh Exp $");
 
 #include 
 #include 
@@ -54,6 +54,8 @@ __KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.9
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -67,7 +69,8 @@ dev_type_ioctl(cnioctl);
 dev_type_poll(cnpoll);
 dev_type_kqfilter(cnkqfilter);
 
-static bool cn_redirect(dev_t *, int, int *);
+static bool cn_redirect(dev_t *, int, int *, struct tty **);
+static void cn_release(struct tty *);
 
 const struct cdevsw cons_cdevsw = {
 	.d_open = cnopen,
@@ -86,7 +89,7 @@ const struct cdevsw cons_cdevsw = {
 
 static struct kmutex cn_lock;
 
-struct	tty *constty = NULL;	/* virtual console output device */
+struct	tty *volatile constty;	/* virtual console output device */
 struct	consdev *cn_tab;	/* physical console device info */
 struct	vnode *cn_devvp[2];	/* vnode for underlying device. */
 
@@ -199,6 +202,7 @@ out:	mutex_exit(_lock);
 int
 cnread(dev_t dev, struct uio *uio, int flag)
 {
+	struct tty *ctp = NULL;
 	int error;
 
 	/*
@@ -208,25 +212,31 @@ cnread(dev_t dev, struct uio *uio, int f
 	 * input (except a shell in single-user mode, but then,
 	 * one wouldn't TIOCCONS then).
 	 */
-	if (!cn_redirect(, 1, ))
+	if (!cn_redirect(, 1, , ))
 		return error;
-	return cdev_read(dev, uio, flag);
+	error = cdev_read(dev, uio, flag);
+	cn_release(ctp);
+	return error;
 }
 
 int
 cnwrite(dev_t dev, struct uio *uio, int flag)
 {
+	struct tty *ctp = NULL;
 	int error;
 
 	/* Redirect output, if that's appropriate. */
-	if (!cn_redirect(, 0, ))
+	if (!cn_redirect(, 0, , ))
 		return error;
-	return cdev_write(dev, uio, flag);
+	error = cdev_write(dev, uio, flag);
+	cn_release(ctp);
+	return error;
 }
 
 int
 cnioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
 {
+	struct tty *ctp = NULL;
 	int error;
 
 	error = 0;
@@ -235,29 +245,41 @@ cnioctl(dev_t dev, u_long cmd, void *dat
 	 * Superuser can always use 

CVS commit: src/sys

2022-10-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Oct 25 23:21:13 UTC 2022

Modified Files:
src/sys/dev: cons.c
src/sys/kern: subr_prf.c tty.c
src/sys/sys: tty.h

Log Message:
constty(4): Make MP-safe, take three.

Access to the global constty variable is coordinated as follows:

1. Setting constty to nonnull, with atomic_store_release, is allowed
   only under the new adaptive constty_lock in thread context.  This
   serializes TIOCCONS operations and ensures unlocked readers can
   safely use a constty pointer read with atomic_load_consume.

2. Changing constty from nonnull to null, with atomic_cas_ptr, is
   allowed in any context -- printf(9) uses this to disable a broken
   constty.

3. Reading constty under constty_lock is allowed with
   atomic_load_relaxed, because while constty_lock is held, it can
   only be made null by some other thread/CPU, never made nonnull.

4. Reading constty outside constty_lock is allowed with
   atomic_load_consume in a pserialize read section -- constty is
   only ever made nonnull with atomic_store_release, in (1).
   ttyclose will wait for all these pserialize read sections to
   complete before flushing the tty.

5. To continue to use a struct tty pointer in (4) after the
   pserialize read section has completed, caller must use tty_acquire
   during the pserialize read section and then tty_release when done.
   ttyclose will wait for all these references to drain before
   returning.

These access rules allow us to serialize TIOCCONS, and safely destroy
ttys, without putting any locks on the access paths like printf(9)
that use constty.  Once we set D_MPSAFE, operations on /dev/console
will contend only with other users of the same tty as constty, which
will be an improvement over contending with all other kernel lock
users in the system.

Changes second time around:
- Fix initialization of ok in cons.c cn_redirect.
- Fix reversed sense of conditional in subr_prf.c putone.

Changes third time around:
- Initialize ttyref_cv so we don't panic when trying to use it,
  leading to infinite loop when panic tries to take tty_lock to print
  the panic message while we already hold tty_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/dev/cons.c
cvs rdiff -u -r1.193 -r1.194 src/sys/kern/subr_prf.c
cvs rdiff -u -r1.305 -r1.306 src/sys/kern/tty.c
cvs rdiff -u -r1.101 -r1.102 src/sys/sys/tty.h

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



CVS commit: src/sys/arch/arm/xilinx

2022-10-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 25 22:59:10 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq_platform.c

Log Message:
Remove unnecessary code in zynq_platform_device_register


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/xilinx/zynq_platform.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/arm/xilinx/zynq_platform.c
diff -u src/sys/arch/arm/xilinx/zynq_platform.c:1.5 src/sys/arch/arm/xilinx/zynq_platform.c:1.6
--- src/sys/arch/arm/xilinx/zynq_platform.c:1.5	Sat Apr 24 23:36:29 2021
+++ src/sys/arch/arm/xilinx/zynq_platform.c	Tue Oct 25 22:59:10 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: zynq_platform.c,v 1.5 2021/04/24 23:36:29 thorpej Exp $	*/
+/*	$NetBSD: zynq_platform.c,v 1.6 2022/10/25 22:59:10 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "arml2cc.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zynq_platform.c,v 1.5 2021/04/24 23:36:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zynq_platform.c,v 1.6 2022/10/25 22:59:10 jmcneill Exp $");
 
 #include 
 #include 
@@ -127,12 +127,6 @@ zynq_platform_early_putchar(char c)
 static void
 zynq_platform_device_register(device_t dev, void *aux)
 {
-	prop_dictionary_t dict = device_properties(dev);
-
-	if (device_is_a(dev, "arma9tmr")) {
-		prop_dictionary_set_uint32(dict, "frequency",
-			ZYNQ_REF_FREQ / 4);
-	}
 }
 
 static u_int



CVS commit: src/sys/arch/arm/xilinx

2022-10-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 25 22:59:10 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq_platform.c

Log Message:
Remove unnecessary code in zynq_platform_device_register


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/xilinx/zynq_platform.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/arm/xilinx

2022-10-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 25 22:52:48 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq7000_usb.c

Log Message:
Fixup mixed up log messages.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/xilinx/zynq7000_usb.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/arm/xilinx/zynq7000_usb.c
diff -u src/sys/arch/arm/xilinx/zynq7000_usb.c:1.2 src/sys/arch/arm/xilinx/zynq7000_usb.c:1.3
--- src/sys/arch/arm/xilinx/zynq7000_usb.c:1.2	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/xilinx/zynq7000_usb.c	Tue Oct 25 22:52:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: zynq7000_usb.c,v 1.2 2021/01/27 03:10:20 thorpej Exp $	*/
+/*	$NetBSD: zynq7000_usb.c,v 1.3 2022/10/25 22:52:48 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zynq7000_usb.c,v 1.2 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zynq7000_usb.c,v 1.3 2022/10/25 22:52:48 jmcneill Exp $");
 
 #include "opt_soc.h"
 
@@ -93,13 +93,13 @@ zynqusb_attach(device_t parent, device_t
 	}
 
 	if (fdtbus_intr_establish(phandle, 0, IPL_USB, IST_LEVEL, ehci_intr,
-		hsc) == NULL) {
-		aprint_error_dev(self, "failed to establish interrupt on %s\n",
+  hsc) == NULL) {
+		aprint_error("failed to establish interrupt on %s\n",
 		intrstr);
 		return;
 	}
-	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
 	zynqusb_attach_common(parent, self, faa->faa_bst, faa->faa_dmat,
 	addr, size, 0, ZYNQUSBC_IF_ULPI, ZYNQUSB_HOST);
+	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 }



CVS commit: src/sys/arch/arm/xilinx

2022-10-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 25 22:52:48 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq7000_usb.c

Log Message:
Fixup mixed up log messages.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/xilinx/zynq7000_usb.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/arm/xilinx

2022-10-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 25 22:49:39 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq7000_uart.c zynq_cemac.c

Log Message:
Fixup some mixed up log messages.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/xilinx/zynq7000_uart.c \
src/sys/arch/arm/xilinx/zynq_cemac.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/arm/xilinx/zynq7000_uart.c
diff -u src/sys/arch/arm/xilinx/zynq7000_uart.c:1.2 src/sys/arch/arm/xilinx/zynq7000_uart.c:1.3
--- src/sys/arch/arm/xilinx/zynq7000_uart.c:1.2	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/xilinx/zynq7000_uart.c	Tue Oct 25 22:49:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: zynq7000_uart.c,v 1.2 2021/01/27 03:10:20 thorpej Exp $	*/
+/*	$NetBSD: zynq7000_uart.c,v 1.3 2022/10/25 22:49:39 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zynq7000_uart.c,v 1.2 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zynq7000_uart.c,v 1.3 2022/10/25 22:49:39 jmcneill Exp $");
 
 #include "opt_soc.h"
 #include "opt_console.h"
@@ -75,13 +75,13 @@ zynquart_attach(device_t parent, device_
 	}
 
 	if (fdtbus_intr_establish(phandle, 0, IPL_SERIAL, IST_LEVEL,
-		zynquartintr, device_private(self)) == NULL) {
-		aprint_error_dev(self, "failed to establish interrupt on %s\n", intrstr);
+  zynquartintr, device_private(self)) == NULL) {
+		aprint_error(": failed to establish interrupt on %s\n", intrstr);
 		return;
 	}
-	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
 	zynquart_attach_common(parent, self, faa->faa_bst, addr, size, 0);
+	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 }
 
 /*
Index: src/sys/arch/arm/xilinx/zynq_cemac.c
diff -u src/sys/arch/arm/xilinx/zynq_cemac.c:1.2 src/sys/arch/arm/xilinx/zynq_cemac.c:1.3
--- src/sys/arch/arm/xilinx/zynq_cemac.c:1.2	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/xilinx/zynq_cemac.c	Tue Oct 25 22:49:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: zynq_cemac.c,v 1.2 2021/01/27 03:10:20 thorpej Exp $	*/
+/*	$NetBSD: zynq_cemac.c,v 1.3 2022/10/25 22:49:39 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zynq_cemac.c,v 1.2 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zynq_cemac.c,v 1.3 2022/10/25 22:49:39 jmcneill Exp $");
 
 #include "opt_soc.h"
 
@@ -85,12 +85,12 @@ cemac_attach(device_t parent, device_t s
 	}
 
 	if (fdtbus_intr_establish(phandle, 0, IPL_NET, 0, cemac_intr,
-		device_private(self)) == NULL) {
-		aprint_error_dev(self, "failed to establish interrupt on %s\n", intrstr);
+  device_private(self)) == NULL) {
+		aprint_error(": failed to establish interrupt on %s\n", intrstr);
 		return;
 	}
-	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
 	cemac_attach_common(self, faa->faa_bst, ioh, faa->faa_dmat, CEMAC_FLAG_GEM);
+	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 }
 



CVS commit: src/sys/arch/arm/xilinx

2022-10-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 25 22:49:39 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: zynq7000_uart.c zynq_cemac.c

Log Message:
Fixup some mixed up log messages.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/xilinx/zynq7000_uart.c \
src/sys/arch/arm/xilinx/zynq_cemac.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

2022-10-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 25 22:27:49 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: files.zynq
src/sys/arch/evbarm/conf: GENERIC
Added Files:
src/sys/arch/arm/xilinx: zynq7000_clkc.c

Log Message:
Add basic Zynq-7000 PS clock subsystem driver.

PR# kern/57068


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/xilinx/files.zynq
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/xilinx/zynq7000_clkc.c
cvs rdiff -u -r1.108 -r1.109 src/sys/arch/evbarm/conf/GENERIC

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/arm/xilinx/files.zynq
diff -u src/sys/arch/arm/xilinx/files.zynq:1.1 src/sys/arch/arm/xilinx/files.zynq:1.2
--- src/sys/arch/arm/xilinx/files.zynq:1.1	Tue Jun 11 13:01:48 2019
+++ src/sys/arch/arm/xilinx/files.zynq	Tue Oct 25 22:27:49 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.zynq,v 1.1 2019/06/11 13:01:48 skrll Exp $
+#	$NetBSD: files.zynq,v 1.2 2022/10/25 22:27:49 jmcneill Exp $
 #
 # Configuration info for Xilinx Zynq-7000 SoC
 #
@@ -15,6 +15,11 @@ defflag	opt_soc.hSOC_ZYNQ7000: SOC_Z
 #attach	zynqslcr at fdt
 #file	arch/arm/xilinx/zynq_slcr.c		zynqslcr needs-flag
 
+# PS clock subsystem
+device	zynqclk
+attach	zynqclk at fdt with zynq7000_clkc
+file	arch/arm/xilinx/zynq7000_clkc.c		zynq7000_clkc
+
 # UART
 device	zynquart
 attach	zynquart at fdt

Index: src/sys/arch/evbarm/conf/GENERIC
diff -u src/sys/arch/evbarm/conf/GENERIC:1.108 src/sys/arch/evbarm/conf/GENERIC:1.109
--- src/sys/arch/evbarm/conf/GENERIC:1.108	Tue Jun 28 05:19:03 2022
+++ src/sys/arch/evbarm/conf/GENERIC	Tue Oct 25 22:27:49 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC,v 1.108 2022/06/28 05:19:03 skrll Exp $
+#	$NetBSD: GENERIC,v 1.109 2022/10/25 22:27:49 jmcneill Exp $
 #
 #	GENERIC ARM (aarch32) kernel
 #
@@ -162,6 +162,7 @@ tegra210car* 	at fdt? pass 3		# NVIDIA T
 tidivclk* 	at fdt? pass 1		# TI divider clock
 tidpllclk* 	at fdt? pass 2		# TI DPLL clock
 timuxclk* 	at fdt? pass 1		# TI mux clock
+zynqclk*	at fdt? pass 1		# Xilinx Zynq PS clocks
 
 fclock* 	at fdt? pass 1
 ffclock* 	at fdt? pass 1

Added files:

Index: src/sys/arch/arm/xilinx/zynq7000_clkc.c
diff -u /dev/null src/sys/arch/arm/xilinx/zynq7000_clkc.c:1.1
--- /dev/null	Tue Oct 25 22:27:49 2022
+++ src/sys/arch/arm/xilinx/zynq7000_clkc.c	Tue Oct 25 22:27:49 2022
@@ -0,0 +1,367 @@
+/* $NetBSD: zynq7000_clkc.c,v 1.1 2022/10/25 22:27:49 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2022 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+__KERNEL_RCSID(0, "$NetBSD: zynq7000_clkc.c,v 1.1 2022/10/25 22:27:49 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#define	ARM_PLL_CTRL	0x000
+#define	DDR_PLL_CTRL	0x004
+#define	IO_PLL_CTRL	0x008
+#define	 PLL_FDIV		__BITS(18,12)
+#define	ARM_CLK_CTRL	0x020
+#define	 ARM_CLK_CTRL_DIVISOR		__BITS(13,8)
+#define	 ARM_CLK_CTRL_CPU_1XCLKACT	__BIT(27)
+#define	 ARM_CLK_CTRL_CPU_2XCLKACT	__BIT(26)
+#define	 ARM_CLK_CTRL_CPU_3OR2XCLKACT	__BIT(25)
+#define	 ARM_CLK_CTRL_CPU_6OR4XCLKACT	__BIT(24)
+#define	APER_CLK_CTRL	0x02c
+#define	 UART1_CPU_1XCLKACT	__BIT(21)
+#define	 UART0_CPU_1XCLKACT	__BIT(20)
+#define	UART_CLK_CTRL	0x054
+#define	 UART_CLK_CTRL_DIVISOR	__BITS(13,8)
+#define	 UART_CLK_CTRL_SRCSEL	__BITS(5,4)
+#define	 UART_CLK_CTRL_CLKACT1	__BIT(1)
+#define	 UART_CLK_CTRL_CLKACT0	__BIT(0)
+#define	CLK_621_TRUE	0x0C4
+#define	 CLK_621_TRUE_EN	__BIT(0)
+
+enum xynq7000_clkid {
+	clkid_armpll,
+	clkid_ddrpll,
+	clkid_iopll,
+	clkid_cpu_6or4x,
+	clkid_cpu_3or2x,

CVS commit: src/sys/arch

2022-10-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 25 22:27:49 UTC 2022

Modified Files:
src/sys/arch/arm/xilinx: files.zynq
src/sys/arch/evbarm/conf: GENERIC
Added Files:
src/sys/arch/arm/xilinx: zynq7000_clkc.c

Log Message:
Add basic Zynq-7000 PS clock subsystem driver.

PR# kern/57068


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/xilinx/files.zynq
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/xilinx/zynq7000_clkc.c
cvs rdiff -u -r1.108 -r1.109 src/sys/arch/evbarm/conf/GENERIC

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



CVS commit: src/games/fortune/datfiles

2022-10-25 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 25 19:33:00 UTC 2022

Modified Files:
src/games/fortune/datfiles: netbsd-tips

Log Message:
-h doesn't sort numerically, pointed out by various


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/games/fortune/datfiles/netbsd-tips

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

Modified files:

Index: src/games/fortune/datfiles/netbsd-tips
diff -u src/games/fortune/datfiles/netbsd-tips:1.15 src/games/fortune/datfiles/netbsd-tips:1.16
--- src/games/fortune/datfiles/netbsd-tips:1.15	Tue Oct 25 15:44:02 2022
+++ src/games/fortune/datfiles/netbsd-tips	Tue Oct 25 19:33:00 2022
@@ -1,6 +1,6 @@
 List 20 largest files (larger than 5 MB) sorted by megabytes:
 
- find . -type f -size +1 -exec du -h {} + | sort -nr | head -20
+ find . -type f -size +1 -exec du -m {} + | sort -nr | head -20
 %
 You can keep specific rc.conf configurations in individual files
 under /etc/rc.conf.d/ where each file is named after the $name of



CVS commit: src/games/fortune/datfiles

2022-10-25 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 25 19:33:00 UTC 2022

Modified Files:
src/games/fortune/datfiles: netbsd-tips

Log Message:
-h doesn't sort numerically, pointed out by various


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/games/fortune/datfiles/netbsd-tips

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



CVS commit: [netbsd-9] src/doc

2022-10-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 25 17:54:59 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.4

Log Message:
Ticket #1547


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.26 -r1.1.2.27 src/doc/CHANGES-9.4

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-9.4
diff -u src/doc/CHANGES-9.4:1.1.2.26 src/doc/CHANGES-9.4:1.1.2.27
--- src/doc/CHANGES-9.4:1.1.2.26	Thu Oct 20 13:20:35 2022
+++ src/doc/CHANGES-9.4	Tue Oct 25 17:54:59 2022
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.4,v 1.1.2.26 2022/10/20 13:20:35 martin Exp $
+# $NetBSD: CHANGES-9.4,v 1.1.2.27 2022/10/25 17:54:59 martin Exp $
 
 A complete list of changes from the NetBSD 9.3 release to the NetBSD 9.4
 release:
@@ -416,3 +416,9 @@ doc/3RDPARTY	(apply patch)
 
 	Update timezone data to 2022e.
 	[kre, ticket #1546]
+
+usr.bin/progress/progress.c			1.24,1.25
+
+	PR 56303: progress(1): fix error handling.
+	[riastradh, ticket #1547]
+



CVS commit: [netbsd-9] src/doc

2022-10-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 25 17:54:59 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.4

Log Message:
Ticket #1547


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.26 -r1.1.2.27 src/doc/CHANGES-9.4

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



CVS commit: [netbsd-9] src/usr.bin/progress

2022-10-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 25 17:52:46 UTC 2022

Modified Files:
src/usr.bin/progress [netbsd-9]: progress.c

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

usr.bin/progress/progress.c: revision 1.24
usr.bin/progress/progress.c: revision 1.25

Test errno when the return value from wait() indicates an error, not
when it indicates success.  PR install/56303.

Add missing check for error returns from read().  Found by inspection
while reviewing the changes suggested by RVP in PR install/56303, but
not believed to be the cause of the failure reported in that PR.


To generate a diff of this commit:
cvs rdiff -u -r1.21.18.1 -r1.21.18.2 src/usr.bin/progress/progress.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.bin/progress/progress.c
diff -u src/usr.bin/progress/progress.c:1.21.18.1 src/usr.bin/progress/progress.c:1.21.18.2
--- src/usr.bin/progress/progress.c:1.21.18.1	Fri Jan 29 18:27:05 2021
+++ src/usr.bin/progress/progress.c	Tue Oct 25 17:52:46 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: progress.c,v 1.21.18.1 2021/01/29 18:27:05 martin Exp $ */
+/*	$NetBSD: progress.c,v 1.21.18.2 2022/10/25 17:52:46 martin Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: progress.c,v 1.21.18.1 2021/01/29 18:27:05 martin Exp $");
+__RCSID("$NetBSD: progress.c,v 1.21.18.2 2022/10/25 17:52:46 martin Exp $");
 #endif/* not lint */
 
 #include 
@@ -232,7 +232,11 @@ main(int argc, char *argv[])
 		do {
 			nr = read(fd, fb_buf, buffersize);
 		} while (nr < 0 && errno == EINTR);
-		if (nr <= 0)
+		if (nr < 0) {
+			progressmeter(1);
+			err(1, "reading input");
+		}
+		if (nr == 0)
 			break;
 		for (off = 0; nr; nr -= nw, off += nw, bytes += nw)
 			if ((nw = write(outpipe[1], fb_buf + off,
@@ -260,7 +264,7 @@ main(int argc, char *argv[])
 		 */
 		ws = WIFSIGNALED(ws) ? WTERMSIG(ws) : WEXITSTATUS(ws);
 
-		if (deadpid != -1 && errno == EINTR)
+		if (deadpid == -1 && errno == EINTR)
 			continue;
 		if (deadpid == pid) {
 			pid = 0;



CVS commit: [netbsd-9] src/usr.bin/progress

2022-10-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 25 17:52:46 UTC 2022

Modified Files:
src/usr.bin/progress [netbsd-9]: progress.c

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

usr.bin/progress/progress.c: revision 1.24
usr.bin/progress/progress.c: revision 1.25

Test errno when the return value from wait() indicates an error, not
when it indicates success.  PR install/56303.

Add missing check for error returns from read().  Found by inspection
while reviewing the changes suggested by RVP in PR install/56303, but
not believed to be the cause of the failure reported in that PR.


To generate a diff of this commit:
cvs rdiff -u -r1.21.18.1 -r1.21.18.2 src/usr.bin/progress/progress.c

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



re: CVS commit: src/usr.bin/ldd

2022-10-25 Thread Ryo ONODERA
Hi,

matthew green  writes:

>> With this change, ldd /lib/libc.so.12.220 fails under NetBSD/amd64 9.99.101.
>>
>>
>> /lib/libc.so.12.220:
>> ldd: /lib/libc.so.12.220: invalid ELF class 2, expected 1
>>
>> It seems that elf32_ldd() fails.
>>
>> Builds of some pkgsrc packages that use gobject introspection and meson fails
>> because they uses ldd command during build.
>
> this should be fixed now.  sorry for the failure..

I am sorry. I have missed your email.
Thanks for your quick fix!!!

> .mrg.

-- 
Ryo ONODERA // r...@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3


CVS commit: src/games/fortune/datfiles

2022-10-25 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 25 15:44:02 UTC 2022

Modified Files:
src/games/fortune/datfiles: netbsd-tips

Log Message:
various tips/simplifications from UnitedBSD


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/games/fortune/datfiles/netbsd-tips

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

Modified files:

Index: src/games/fortune/datfiles/netbsd-tips
diff -u src/games/fortune/datfiles/netbsd-tips:1.14 src/games/fortune/datfiles/netbsd-tips:1.15
--- src/games/fortune/datfiles/netbsd-tips:1.14	Fri Nov 26 17:38:07 2021
+++ src/games/fortune/datfiles/netbsd-tips	Tue Oct 25 15:44:02 2022
@@ -1,6 +1,6 @@
 List 20 largest files (larger than 5 MB) sorted by megabytes:
 
- find / -type f -size +1 -print0 | xargs -0 du -m | sort -nr | head -20
+ find . -type f -size +1 -exec du -h {} + | sort -nr | head -20
 %
 You can keep specific rc.conf configurations in individual files
 under /etc/rc.conf.d/ where each file is named after the $name of
@@ -211,3 +211,23 @@ To list connected disk devices:
 screenblank(1) can disable the framebuffer if the keyboard and mouse are
 idle for a period of time, and re-enables the framebuffer when keyboard
 or mouse activity resumes.
+%
+If you want to convert a Microsoft Windows text file to have Unix line
+endings, it's possible to achieve by simply stripping all of the carriage
+return characters from the file:
+
+	tr -d '\r' < IN > OUT
+
+However, you might want to do this more carefully (i.e. only remove
+carriage returns that constitute a line ending).  See "dos2unix" in pkgsrc.
+%
+Some useful X11 commands:
+
+	xset s off		# disable screen blanking
+	xset -dpms		# disable screen power saving
+	xset b 0		# mute bell (beep)
+	xset m 55/20 4		# mouse acceleration 
+%
+Automatically run a make(1) job on each active CPU:
+
+	alias make="make -j $(sysctl -n hw.ncpuonline)"



CVS commit: src/games/fortune/datfiles

2022-10-25 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 25 15:44:02 UTC 2022

Modified Files:
src/games/fortune/datfiles: netbsd-tips

Log Message:
various tips/simplifications from UnitedBSD


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/games/fortune/datfiles/netbsd-tips

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



CVS commit: xsrc/local/programs/bdfload

2022-10-25 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Tue Oct 25 13:36:35 UTC 2022

Modified Files:
xsrc/local/programs/bdfload: bdfload.c

Log Message:
put back quotation mark removal in FAMILI_NAME statement which got broken
in a previous commit


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 xsrc/local/programs/bdfload/bdfload.c

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



CVS commit: xsrc/local/programs/bdfload

2022-10-25 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Tue Oct 25 13:36:35 UTC 2022

Modified Files:
xsrc/local/programs/bdfload: bdfload.c

Log Message:
put back quotation mark removal in FAMILI_NAME statement which got broken
in a previous commit


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 xsrc/local/programs/bdfload/bdfload.c

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

Modified files:

Index: xsrc/local/programs/bdfload/bdfload.c
diff -u xsrc/local/programs/bdfload/bdfload.c:1.18 xsrc/local/programs/bdfload/bdfload.c:1.19
--- xsrc/local/programs/bdfload/bdfload.c:1.18	Tue Oct 25 13:31:58 2022
+++ xsrc/local/programs/bdfload/bdfload.c	Tue Oct 25 13:36:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdfload.c,v 1.18 2022/10/25 13:31:58 macallan Exp $	*/
+/*	$NetBSD: bdfload.c,v 1.19 2022/10/25 13:36:35 macallan Exp $	*/
 
 /*
  * Copyright (c) 2018 Michael Lorenz
@@ -267,8 +267,12 @@ interpret(FILE *foo)
 		}
 		arg[i] = 0;
 		if (strcmp(line, "FAMILY_NAME") == 0) {
+			char *q;
 			/* cut off quotation marks */
 			strlcpy(name, arg + 1, 64);
+			/* remove trailing " */
+			if ((q = strnstr(name, "\"", 64)) != NULL)
+*q = 0;
 			if (verbose) printf("name: %s\n", name);
 		} else if (strcmp(line, "COMMENT") == 0) {
 			commentptr += snprintf([commentptr],



CVS commit: xsrc/local/programs/bdfload

2022-10-25 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Tue Oct 25 13:31:58 UTC 2022

Modified Files:
xsrc/local/programs/bdfload: bdfload.c

Log Message:
keep track of character names and dump them into the header file if known


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 xsrc/local/programs/bdfload/bdfload.c

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



CVS commit: xsrc/local/programs/bdfload

2022-10-25 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Tue Oct 25 13:31:58 UTC 2022

Modified Files:
xsrc/local/programs/bdfload: bdfload.c

Log Message:
keep track of character names and dump them into the header file if known


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 xsrc/local/programs/bdfload/bdfload.c

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

Modified files:

Index: xsrc/local/programs/bdfload/bdfload.c
diff -u xsrc/local/programs/bdfload/bdfload.c:1.17 xsrc/local/programs/bdfload/bdfload.c:1.18
--- xsrc/local/programs/bdfload/bdfload.c:1.17	Tue Oct 25 12:55:04 2022
+++ xsrc/local/programs/bdfload/bdfload.c	Tue Oct 25 13:31:58 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdfload.c,v 1.17 2022/10/25 12:55:04 macallan Exp $	*/
+/*	$NetBSD: bdfload.c,v 1.18 2022/10/25 13:31:58 macallan Exp $	*/
 
 /*
  * Copyright (c) 2018 Michael Lorenz
@@ -106,6 +106,7 @@ int force = 0;
 char commentbuf[2048] = "";
 int commentptr = 0;
 char fontname[64] = "";
+char *names[256];
 
 void
 dump_line(char *gptr, int stride)
@@ -200,7 +201,10 @@ write_header(const char *filename, struc
 	fprintf(output, "};\n\n");
 	fprintf(output, "static u_char %s_data[] = {\n", name);
 	for (i = f->firstchar; i < f->firstchar + f->numchars; i++) {
-		fprintf(output, "\t/* %d */\n", i);
+		if (names[i] != NULL) {
+			fprintf(output, "\t/* %d %s */\n", i, names[i]);
+		} else			
+			fprintf(output, "\t/* %d */\n", i);
 		idx = i * f->stride * f->fontheight;
 		for (y = 0; y < f->fontheight; y++) {
 			for (x = 0; x < f->stride; x++) {
@@ -233,7 +237,8 @@ void
 interpret(FILE *foo)
 {
 	char line[128], *arg, name[64] = "foo", *buffer, *cbitmap;
-	int buflen = -1;
+	char charname[65], *charnamebuf;
+	int buflen = -1, charnamebufptr = 0, j;
 	int in_char = 0, current = -1, stride = 0, charsize = 0;
 	int width, height, x, y, num;
 	int first = 255, last = 0;
@@ -242,6 +247,11 @@ interpret(FILE *foo)
 	struct wsdisplay_font f;
 	int status;
 
+	charnamebuf = malloc(64 * 256);
+	if (charnamebuf == 0) err(EXIT_FAILURE, "failed to allocate memory\n");
+	memset(charnamebuf, 0, 64 * 256);
+	for (j = 0; j < 256; j++) names[j] = NULL;
+
 	while (fgets(line, sizeof(line), foo) != NULL) {
 		size_t i = 0, len;
 		/* separate keyword from parameters */
@@ -305,12 +315,24 @@ interpret(FILE *foo)
 			if (charsize <= 1) err(EXIT_FAILURE,
 			"syntax error - no valid FONTBOUNDINGBOX\n");
 			memset(cbitmap, 0, charsize);
+			strlcpy(charname, arg, 64);
 		} else if (strcmp(line, "ENDCHAR") == 0) {
 			in_char = 0;
 			/* only commit the glyph if it's in range */
 			if ((current >= 0) && (current < 256)) {
 memcpy([charsize * current],
 cbitmap, charsize);
+if ((strlen(charname) > 0) &&
+(charnamebufptr < 255 * 64)) {
+	char *cur;
+	int len;
+	/* copy name into buffer, keep a
+	 * pointer to it for later */
+	cur = [charnamebufptr];	
+	len = strlcpy(cur, charname, 64);
+	charnamebufptr += len + 1;
+	names[current] = cur;
+}
 			}
 			current = -1;
 		} else if (strcmp(line, "ENCODING") == 0) {



CVS commit: xsrc/local/programs/bdfload

2022-10-25 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Tue Oct 25 12:55:04 UTC 2022

Modified Files:
xsrc/local/programs/bdfload: bdfload.c

Log Message:
do not rely on every STARTCHAR/ENDCHAR sequence starting with ENCODING - the
standard doesn't specify in which order each glyph's properties are listed


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 xsrc/local/programs/bdfload/bdfload.c

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

Modified files:

Index: xsrc/local/programs/bdfload/bdfload.c
diff -u xsrc/local/programs/bdfload/bdfload.c:1.16 xsrc/local/programs/bdfload/bdfload.c:1.17
--- xsrc/local/programs/bdfload/bdfload.c:1.16	Tue Sep 27 18:29:08 2022
+++ xsrc/local/programs/bdfload/bdfload.c	Tue Oct 25 12:55:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdfload.c,v 1.16 2022/09/27 18:29:08 christos Exp $	*/
+/*	$NetBSD: bdfload.c,v 1.17 2022/10/25 12:55:04 macallan Exp $	*/
 
 /*
  * Copyright (c) 2018 Michael Lorenz
@@ -232,7 +232,7 @@ write_header(const char *filename, struc
 void
 interpret(FILE *foo)
 {
-	char line[128], *arg, name[64] = "foo", *buffer;
+	char line[128], *arg, name[64] = "foo", *buffer, *cbitmap;
 	int buflen = -1;
 	int in_char = 0, current = -1, stride = 0, charsize = 0;
 	int width, height, x, y, num;
@@ -288,21 +288,30 @@ interpret(FILE *foo)
 "no fonts wider than 16 work for now\n");
 			}
 			charsize = height * stride;
-			buflen = 256 * charsize;
+			buflen = 257 * charsize;
 			buffer = calloc(1, buflen);
 			if (buffer == NULL) {
 err(EXIT_FAILURE, 
 "failed to allocate %dKB for glyphs\n",
 buflen);
 			}
+			cbitmap = buffer + 256 * charsize;
 		} else if (strcmp(line, "CHARS") == 0) {
 			if (sscanf(arg, "%d", ) == 1)
 if (verbose) 
 printf("number of characters: %d\n", num);
 		} else if (strcmp(line, "STARTCHAR") == 0) {
 			in_char = 1;
+			if (charsize <= 1) err(EXIT_FAILURE,
+			"syntax error - no valid FONTBOUNDINGBOX\n");
+			memset(cbitmap, 0, charsize);
 		} else if (strcmp(line, "ENDCHAR") == 0) {
 			in_char = 0;
+			/* only commit the glyph if it's in range */
+			if ((current >= 0) && (current < 256)) {
+memcpy([charsize * current],
+cbitmap, charsize);
+			}
 			current = -1;
 		} else if (strcmp(line, "ENCODING") == 0) {
 			if (sscanf(arg, "%d", ) == 1) {
@@ -329,7 +338,7 @@ interpret(FILE *foo)
 		} else if (strcmp(line, "BITMAP") == 0) {
 			int i, j, k, l;
 			char num[32];
-			char *gptr = [charsize * current];
+			char *gptr = cbitmap;
 			char *bptr = gptr + top;
 			uint16_t *bptr16 = (uint16_t *)gptr;
 			bptr16 += top;
@@ -351,7 +360,7 @@ interpret(FILE *foo)
 }
 			}
 			if (dump) {
-gptr = [charsize * current];
+gptr = cbitmap;
 for (i = 0; i < height; i++) {
 	dump_line(gptr, stride);
 	gptr += stride;



CVS commit: xsrc/local/programs/bdfload

2022-10-25 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Tue Oct 25 12:55:04 UTC 2022

Modified Files:
xsrc/local/programs/bdfload: bdfload.c

Log Message:
do not rely on every STARTCHAR/ENDCHAR sequence starting with ENCODING - the
standard doesn't specify in which order each glyph's properties are listed


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 xsrc/local/programs/bdfload/bdfload.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/net

2022-10-25 Thread Masanobu SAITOH


On 2022/10/25 14:55, Masanobu SAITOH wrote:
> 
> 
> On 2022/10/25 14:51, matthew green wrote:
>> "SAITOH Masanobu" writes:
>>> Module Name:src
>>> Committed By:   msaitoh
>>> Date:   Mon Oct 24 07:45:44 UTC 2022
>>>
>>> Modified Files:
>>> src/sys/net: if_dl.h
>>>
>>> Log Message:
>>> Increase sdl_data so that more then IFNAMSIZ bytes are available.
>>>
>>>  - Increase the size of dl_data[] from 12 to 24.
>>>  - Same as OpenBSD.
>>
>> isn't this a binary compat issue?  eg, 'struct sockaddr_dl' changes,
>> and that, and things based upon it, are in user interfaces.  i had
>> a look and i believe it's a problem, but maybe i missed something.
>>
>> thanks.
>>
>>
>> .mrg.
> 
> struct dl_addr is at the end of struct sockaddr_dl.
> dl_data is at the end of struct dl_addr.
> So I think it's has no problem for old binaries.

I've roughly tested with old arp, ndp, ifconfig, ifmcstat and all /usr/tests
on a new kernel and I didn't saw any problem.

I think getifaddrs(3) has no problem. The routing message has no problem
because struct rtm_msglen has rtm_msglen and we can get the next message
using with it. I can't see any kernel data structure which has
struct sockaddr_dl foobadr[xxx] array.

One problem might be exist. An old userland program allocate buffer
with sizeof(struct sockaddr_dl), the size is smaller than the newer.
The old program might copy with memcpy(old_sized_buf, newdata, dla->sdl_len).

Should I backout the change until the COMPAT code is written?

-- 
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


CVS commit: src/lib/libc/time

2022-10-25 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Oct 25 08:07:08 UTC 2022

Modified Files:
src/lib/libc/time: strftime.3

Log Message:
Fix a merge or conversion problem (probably) - a .SH BUGS
(meaningless macro in mdoc) followed by the first line of the
real BUGS section somehow ended up inserted after the first
word of the STANDARDS section.   Delete the noise.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libc/time/strftime.3

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

Modified files:

Index: src/lib/libc/time/strftime.3
diff -u src/lib/libc/time/strftime.3:1.36 src/lib/libc/time/strftime.3:1.37
--- src/lib/libc/time/strftime.3:1.36	Fri Oct  9 18:38:48 2020
+++ src/lib/libc/time/strftime.3	Tue Oct 25 08:07:07 2022
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" from: @(#)strftime.3	5.12 (Berkeley) 6/29/91
-.\"	$NetBSD: strftime.3,v 1.36 2020/10/09 18:38:48 christos Exp $
+.\"	$NetBSD: strftime.3,v 1.37 2022/10/25 08:07:07 kre Exp $
 .\"
 .Dd October 9, 2020
 .Dt STRFTIME 3
@@ -264,8 +264,6 @@ in a
 .Xr tm 3
 .Sh STANDARDS
 The
-.SH BUGS
-There is no conversion specification for the phase of the moon.
 .Fn strftime
 function
 conforms to



CVS commit: src/lib/libc/time

2022-10-25 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Oct 25 08:07:08 UTC 2022

Modified Files:
src/lib/libc/time: strftime.3

Log Message:
Fix a merge or conversion problem (probably) - a .SH BUGS
(meaningless macro in mdoc) followed by the first line of the
real BUGS section somehow ended up inserted after the first
word of the STANDARDS section.   Delete the noise.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libc/time/strftime.3

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



CVS commit: src/lib/libcurses

2022-10-25 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Oct 25 06:20:01 UTC 2022

Modified Files:
src/lib/libcurses: attributes.c

Log Message:
Fix for lib/57050
Perform a sanity check on the window parameter being passed and return
ERR if it is null.  This prevents buggy code crashing.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/attributes.c

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

Modified files:

Index: src/lib/libcurses/attributes.c
diff -u src/lib/libcurses/attributes.c:1.34 src/lib/libcurses/attributes.c:1.35
--- src/lib/libcurses/attributes.c:1.34	Tue Apr 12 07:03:04 2022
+++ src/lib/libcurses/attributes.c	Tue Oct 25 06:20:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: attributes.c,v 1.34 2022/04/12 07:03:04 blymn Exp $	*/
+/*	$NetBSD: attributes.c,v 1.35 2022/10/25 06:20:01 blymn Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: attributes.c,v 1.34 2022/04/12 07:03:04 blymn Exp $");
+__RCSID("$NetBSD: attributes.c,v 1.35 2022/10/25 06:20:01 blymn Exp $");
 #endif/* not lint */
 
 #include "curses.h"
@@ -143,6 +143,9 @@ attrset(int attr)
 int
 wattr_get(WINDOW *win, attr_t *attr, short *pair, void *opts)
 {
+	if (__predict_false(win == NULL))
+		return ERR;
+
 	__CTRACE(__CTRACE_ATTR, "wattr_get: win %p\n", win);
 	if (attr != NULL) {
 		*attr = win->wattr;
@@ -231,6 +234,9 @@ wcolor_set(WINDOW *win, short pair, void
 chtype
 getattrs(WINDOW *win)
 {
+	if (__predict_false(win == NULL))
+		return ERR;
+
 	__CTRACE(__CTRACE_ATTR, "getattrs: win %p\n", win);
 	return((chtype) win->wattr);
 }
@@ -361,7 +367,12 @@ term_attrs(void)
 static int
 __wattr_on(WINDOW *win, attr_t attr)
 {
-	const TERMINAL *t = win->screen->term;
+	const TERMINAL *t;
+
+	if (__predict_false(win == NULL))
+		return ERR;
+
+	t = win->screen->term;
 
 	__CTRACE(__CTRACE_ATTR, "wattr_on: win %p, attr %08x\n", win, attr);
 	/* If can enter modes, set the relevant attribute bits. */
@@ -408,7 +419,12 @@ __wattr_on(WINDOW *win, attr_t attr)
 static int
 __wattr_off(WINDOW *win, attr_t attr)
 {
-	const TERMINAL *t = win->screen->term;
+	const TERMINAL *t;
+
+	if (__predict_false(win == NULL))
+		return ERR;
+
+	t = win->screen->term;
 
 	__CTRACE(__CTRACE_ATTR, "wattr_off: win %p, attr %08x\n", win, attr);
 	/* If can do exit modes, unset the relevant attribute bits. */
@@ -455,7 +471,12 @@ __wattr_off(WINDOW *win, attr_t attr)
 static void
 __wcolor_set(WINDOW *win, attr_t attr)
 {
-	const TERMINAL *t = win->screen->term;
+	const TERMINAL *t;
+
+	if (__predict_false(win == NULL))
+		return;
+
+	t = win->screen->term;
 
 	/* If another color pair is set, turn that off first. */
 	win->wattr &= ~__COLOR;



CVS commit: src/lib/libcurses

2022-10-25 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Oct 25 06:20:01 UTC 2022

Modified Files:
src/lib/libcurses: attributes.c

Log Message:
Fix for lib/57050
Perform a sanity check on the window parameter being passed and return
ERR if it is null.  This prevents buggy code crashing.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/attributes.c

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