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

2024-04-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 21 03:02:51 UTC 2024

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

Log Message:
drm: Allow DRM_IOCTL_GET_UNIQUE on render nodes.

On NetBSD, libdrm uses this to discover what kind of bus the device
is on, without which it refuses to expose the render node at all,
rendering it useless.  With this change, libdrm is able to use render
nodes on NetBSD.

Since this is just reading out information about the bus type and
bus/dev/func numbers, I don't think it's problematic to expose to
render nodes.

This requires tweaking the access path to the master.

PR kern/58180


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/external/bsd/drm2/dist/drm/drm_ioctl.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/drm_ioctl.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_ioctl.c:1.24 src/sys/external/bsd/drm2/dist/drm/drm_ioctl.c:1.25
--- src/sys/external/bsd/drm2/dist/drm/drm_ioctl.c:1.24	Sat Oct 15 15:19:28 2022
+++ src/sys/external/bsd/drm2/dist/drm/drm_ioctl.c	Sun Apr 21 03:02:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_ioctl.c,v 1.24 2022/10/15 15:19:28 riastradh Exp $	*/
+/*	$NetBSD: drm_ioctl.c,v 1.25 2024/04/21 03:02:51 riastradh Exp $	*/
 
 /*
  * Created: Fri Jan  8 09:01:26 1999 by fa...@valinux.com
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_ioctl.c,v 1.24 2022/10/15 15:19:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_ioctl.c,v 1.25 2024/04/21 03:02:51 riastradh Exp $");
 
 #include 
 #include 
@@ -129,19 +129,35 @@ int drm_getunique(struct drm_device *dev
 		  struct drm_file *file_priv)
 {
 	struct drm_unique *u = data;
-	struct drm_master *master = file_priv->master;
+	struct drm_master *master;
+	int ret;
 
-	mutex_lock(>dev->master_mutex);
-	if (u->unique_len >= master->unique_len) {
-		if (copy_to_user(u->unique, master->unique, master->unique_len)) {
-			mutex_unlock(>dev->master_mutex);
-			return -EFAULT;
-		}
+	mutex_lock(>master_mutex);
+	master = dev->master;
+	if (master == NULL) {
+		ret = -ENXIO;
+		goto out;
+	}
+
+	/*
+	 * Copy out only if the user allocated enough space.  Either
+	 * way, on success, report the actual size -- so the user can
+	 * allocate enough space if they didn't before, or so they know
+	 * exactly how much we copied out.
+	 */
+	if (u->unique_len < master->unique_len) {
+		ret = 0;
+	} else {
+		ret = copy_to_user(u->unique, master->unique,
+		master->unique_len);
+		if (ret)
+			goto out;
 	}
 	u->unique_len = master->unique_len;
-	mutex_unlock(>dev->master_mutex);
 
-	return 0;
+out:	mutex_unlock(>master_mutex);
+
+	return ret;
 }
 
 static void
@@ -597,7 +613,7 @@ EXPORT_SYMBOL(drm_ioctl_permit);
 /* Ioctl table */
 static const struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, DRM_RENDER_ALLOW),
-	DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
+	DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0),
 	DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY),
 



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

2024-04-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 21 03:02:51 UTC 2024

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

Log Message:
drm: Allow DRM_IOCTL_GET_UNIQUE on render nodes.

On NetBSD, libdrm uses this to discover what kind of bus the device
is on, without which it refuses to expose the render node at all,
rendering it useless.  With this change, libdrm is able to use render
nodes on NetBSD.

Since this is just reading out information about the bus type and
bus/dev/func numbers, I don't think it's problematic to expose to
render nodes.

This requires tweaking the access path to the master.

PR kern/58180


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/external/bsd/drm2/dist/drm/drm_ioctl.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/drm

2024-04-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 21 03:02:39 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/drm: drm_cdevsw.c

Log Message:
drm(4): Fix st_rdev in stat.

dminor->index already has the 64*type adjustment, as allocated in
drm_minor_alloc.

PR kern/58180


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/external/bsd/drm2/drm/drm_cdevsw.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/drm/drm_cdevsw.c
diff -u src/sys/external/bsd/drm2/drm/drm_cdevsw.c:1.30 src/sys/external/bsd/drm2/drm/drm_cdevsw.c:1.31
--- src/sys/external/bsd/drm2/drm/drm_cdevsw.c:1.30	Wed Jul  6 01:12:45 2022
+++ src/sys/external/bsd/drm2/drm/drm_cdevsw.c	Sun Apr 21 03:02:39 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_cdevsw.c,v 1.30 2022/07/06 01:12:45 riastradh Exp $	*/
+/*	$NetBSD: drm_cdevsw.c,v 1.31 2024/04/21 03:02:39 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_cdevsw.c,v 1.30 2022/07/06 01:12:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_cdevsw.c,v 1.31 2024/04/21 03:02:39 riastradh Exp $");
 
 #include 
 #include 
@@ -496,7 +496,7 @@ drm_stat(struct file *fp, struct stat *s
 	struct drm_file *const file = fp->f_data;
 	struct drm_minor *const dminor = file->minor;
 	const dev_t devno = makedev(cdevsw_lookup_major(_cdevsw),
-	64*dminor->type + dminor->index);
+	dminor->index);
 
 	(void)memset(st, 0, sizeof(*st));
 



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

2024-04-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 21 03:02:39 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/drm: drm_cdevsw.c

Log Message:
drm(4): Fix st_rdev in stat.

dminor->index already has the 64*type adjustment, as allocated in
drm_minor_alloc.

PR kern/58180


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/external/bsd/drm2/drm/drm_cdevsw.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/radeon

2024-04-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 18 23:33:15 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_acpi.c

Log Message:
radeon_acpi.c: ifdef out unused function on NetBSD.

Should fix syzkaller build.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.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/radeon/radeon_acpi.c
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c:1.5 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c:1.5	Tue Apr 16 14:34:02 2024
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c	Thu Apr 18 23:33:15 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeon_acpi.c,v 1.5 2024/04/16 14:34:02 riastradh Exp $	*/
+/*	$NetBSD: radeon_acpi.c,v 1.6 2024/04/18 23:33:15 riastradh Exp $	*/
 
 /*
  * Copyright 2012 Advanced Micro Devices, Inc.
@@ -24,7 +24,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeon_acpi.c,v 1.5 2024/04/16 14:34:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_acpi.c,v 1.6 2024/04/18 23:33:15 riastradh Exp $");
 
 #include 
 #include 
@@ -50,11 +50,13 @@ ACPI_MODULE_NAME("radeon_acpi")
 #include 
 #endif
 
+#ifndef __NetBSD__		/* XXX radeon acpi */
 #if defined(CONFIG_VGA_SWITCHEROO)
 bool radeon_atpx_dgpu_req_power_for_displays(void);
 #else
 static inline bool radeon_atpx_dgpu_req_power_for_displays(void) { return false; }
 #endif
+#endif
 
 #define ACPI_AC_CLASS   "ac_adapter"
 



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

2024-04-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 18 23:33:15 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_acpi.c

Log Message:
radeon_acpi.c: ifdef out unused function on NetBSD.

Should fix syzkaller build.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.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/nouveau

2024-04-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr 16 14:26:53 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/nouveau: nouveau2netbsd

Log Message:
nouveau: Rework nouveau2netbsd hack to get ACPI stuff.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/external/bsd/drm2/nouveau/nouveau2netbsd

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/nouveau/nouveau2netbsd
diff -u src/sys/external/bsd/drm2/nouveau/nouveau2netbsd:1.5 src/sys/external/bsd/drm2/nouveau/nouveau2netbsd:1.6
--- src/sys/external/bsd/drm2/nouveau/nouveau2netbsd:1.5	Mon Aug 27 00:46:21 2018
+++ src/sys/external/bsd/drm2/nouveau/nouveau2netbsd	Tue Apr 16 14:26:53 2024
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-#	$NetBSD: nouveau2netbsd,v 1.5 2018/08/27 00:46:21 riastradh Exp $
+#	$NetBSD: nouveau2netbsd,v 1.6 2024/04/16 14:26:53 riastradh Exp $
 #
 # $ /path/to/nouveau2netbsd > /path/to/files.nouveau.new
 #
@@ -32,9 +32,13 @@ filemap="$(mktemp -t ${0##*/})"
 
 cat Kbuild\
 | sed -e 's,^include \(.*\)$,.include "\1",'\
-| sed -e 's,^ifdef \(.*\)$,.if !empty(\1:M[yY][eE][sS]),'		\
+| sed -e 's,^ifdef \(.*\)$,.if !empty(\1:M[yY]),'			\
 | sed -e 's,^endif$,.endif,'		\
-| make -f /dev/stdin -V '$(nouveau-y)' src=.\
+| env	\
+	env CONFIG_ACPI=y		\
+	env CONFIG_X86=y		\
+	env src=.			\
+	make -f /dev/stdin -V '$(nouveau-y)'\
 | tr ' ' '\n'\
 | sed -e 's,^$,,'			\
 | sort -u\



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

2024-04-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr 16 14:26:53 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/nouveau: nouveau2netbsd

Log Message:
nouveau: Rework nouveau2netbsd hack to get ACPI stuff.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/external/bsd/drm2/nouveau/nouveau2netbsd

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/sljit/dist/sljit_src

2024-04-02 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr  2 22:29:57 UTC 2024

Modified Files:
src/sys/external/bsd/sljit/dist/sljit_src: sljitNativeARM_64.c

Log Message:
sljit: Pacify -Wsign-compare.

If these sizes are negative, we're probably in trouble anyway, so
assert nonnegative here.

Needed to resolve PR 58103.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.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/sljit/dist/sljit_src

2024-04-02 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr  2 22:29:57 UTC 2024

Modified Files:
src/sys/external/bsd/sljit/dist/sljit_src: sljitNativeARM_64.c

Log Message:
sljit: Pacify -Wsign-compare.

If these sizes are negative, we're probably in trouble anyway, so
assert nonnegative here.

Needed to resolve PR 58103.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.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/sljit/dist/sljit_src/sljitNativeARM_64.c
diff -u src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c:1.4 src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c:1.5
--- src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c:1.4	Sun Jan 20 23:14:16 2019
+++ src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c	Tue Apr  2 22:29:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljitNativeARM_64.c,v 1.4 2019/01/20 23:14:16 alnsn Exp $	*/
+/*	$NetBSD: sljitNativeARM_64.c,v 1.5 2024/04/02 22:29:57 riastradh Exp $	*/
 
 /*
  *Stack-less Just-In-Time compiler
@@ -1079,7 +1079,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 	local_size = (local_size + 15) & ~0xf;
 	compiler->local_size = local_size;
 
-	if (local_size <= (63 * sizeof(sljit_sw))) {
+	SLJIT_ASSERT(local_size >= 0);
+	if ((size_t)local_size <= (63 * sizeof(sljit_sw))) {
 		FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR)
 			| RN(TMP_SP) | ((-(local_size >> 3) & 0x7f) << 15)));
 		FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10)));
@@ -1129,7 +1130,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 
 	SLJIT_ASSERT(prev == -1);
 
-	if (compiler->local_size > (63 * sizeof(sljit_sw))) {
+	SLJIT_ASSERT(compiler->local_size >= 0);
+	if ((size_t)compiler->local_size > (63 * sizeof(sljit_sw))) {
 		/* The local_size is already adjusted by the saved registers. */
 		if (local_size > 0xfff) {
 			FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22)));
@@ -1179,7 +1181,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 	local_size = compiler->local_size;
 
 	saved_regs_size = GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 0);
-	if (local_size <= (63 * sizeof(sljit_sw)))
+	SLJIT_ASSERT(local_size >= 0);
+	if ((size_t)local_size <= (63 * sizeof(sljit_sw)))
 		offs = (local_size - saved_regs_size) << (15 - 3);
 	else {
 		FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
@@ -1232,7 +1235,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 
 	SLJIT_ASSERT(prev == -1);
 
-	if (compiler->local_size <= (63 * sizeof(sljit_sw))) {
+	SLJIT_ASSERT(compiler->local_size >= 0);
+	if ((size_t)compiler->local_size <= (63 * sizeof(sljit_sw))) {
 		FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
 			| RN(TMP_SP) | (((local_size >> 3) & 0x7f) << 15)));
 	} else if (saved_regs_size > 0) {



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

2024-03-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Mar  9 09:55:52 UTC 2024

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

Log Message:
drm(4): make pr_debug equivalent to aprint_debug

significantly reduces the default spam from amdgpu(4).


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/common/include/linux/printk.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/printk.h
diff -u src/sys/external/bsd/common/include/linux/printk.h:1.13 src/sys/external/bsd/common/include/linux/printk.h:1.14
--- src/sys/external/bsd/common/include/linux/printk.h:1.13	Fri Jul 29 23:50:44 2022
+++ src/sys/external/bsd/common/include/linux/printk.h	Sat Mar  9 09:55:52 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: printk.h,v 1.13 2022/07/29 23:50:44 riastradh Exp $	*/
+/*	$NetBSD: printk.h,v 1.14 2024/03/09 09:55:52 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
 #define	pr_warn		printf	/* XXX */
 #define	pr_warn_once	printf	/* XXX */
 #define	pr_notice	printf	/* XXX */
-#define	pr_debug	printf	/* XXX */
+#define	pr_debug	aprint_debug
 #define	KERN_EMERG	"emerg: "
 #define	KERN_ALERT	"alert: "
 #define	KERN_CRIT	"crit: "



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

2024-03-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Mar  9 09:55:52 UTC 2024

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

Log Message:
drm(4): make pr_debug equivalent to aprint_debug

significantly reduces the default spam from amdgpu(4).


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/common/include/linux/printk.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/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:24:38 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_stolen.c

Log Message:
i915_gem_stolen: Fill sg_pgs, with size/PAGE_SIZE entries.

Use sg_alloc_table_from_bus_dmamem to do this.

i915_gem_mman.c vm_fault_cpu and i915_gem_object_release_mmap_offset
both rely on sg_pgs to be a page array, so providing a table with
only one entry doesn't work (except by accident, if the object is
page-sized anyway).  And they rely on the sg_pgs entries to be
initialized, which we weren't doing before, and which
sg_alloc_table_from_bus_dmamem does for us.

Related to PR kern/57833.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.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/i915/gem/i915_gem_stolen.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c:1.6 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c:1.7
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c:1.6	Fri Jan 19 22:24:27 2024
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c	Fri Jan 19 22:24:38 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_stolen.c,v 1.6 2024/01/19 22:24:27 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_stolen.c,v 1.7 2024/01/19 22:24:38 riastradh Exp $	*/
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_stolen.c,v 1.6 2024/01/19 22:24:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_stolen.c,v 1.7 2024/01/19 22:24:38 riastradh Exp $");
 
 #include 
 #include 
@@ -506,14 +506,13 @@ i915_pages_create_for_stolen(struct drm_
 {
 	struct drm_i915_private *i915 = to_i915(dev);
 	struct sg_table *st;
+	struct scatterlist *sg;
 #ifdef __NetBSD__
 	bus_dma_tag_t dmat = i915->drm.dmat;
 	bus_dma_segment_t *seg = NULL;
 	int nseg = 0, i;
 	bool loaded = false;
 	int ret;
-#else
-	struct scatterlist *sg;
 #endif
 
 	GEM_BUG_ON(range_overflows(offset, size, resource_size(>dsm)));
@@ -527,11 +526,6 @@ i915_pages_create_for_stolen(struct drm_
 	if (st == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	if (sg_alloc_table(st, 1, GFP_KERNEL)) {
-		kfree(st);
-		return ERR_PTR(-ENOMEM);
-	}
-
 #ifdef __NetBSD__
 	KASSERT((size % PAGE_SIZE) == 0);
 	nseg = size / PAGE_SIZE;
@@ -548,6 +542,17 @@ i915_pages_create_for_stolen(struct drm_
 		seg[i].ds_len = PAGE_SIZE;
 	}
 
+	sg = NULL;
+
+	ret = sg_alloc_table_from_bus_dmamem(st, dmat, seg, nseg, GFP_KERNEL);
+	if (ret) {
+		DRM_ERROR("failed to alloc sg table for stolen object: %d\n",
+		ret);
+		ret = -ENOMEM;
+		goto out;
+	}
+	sg = st->sgl;
+
 	/* XXX errno NetBSD->Linux */
 	ret = -bus_dmamap_create(dmat, size, nseg, PAGE_SIZE, 0,
 	BUS_DMA_WAITOK, >sgl->sg_dmamap);
@@ -573,11 +578,19 @@ out:	kmem_free(seg, nseg * sizeof(seg[0]
 	if (ret) {
 		if (loaded)
 			bus_dmamap_unload(dmat, st->sgl->sg_dmamap);
-		sg_free_table(st);
+		if (sg && sg->sg_dmamap)
+			bus_dmamap_destroy(dmat, sg->sg_dmamap);
+		if (sg)
+			sg_free_table(st);
 		kfree(st);
 		return ERR_PTR(ret);
 	}
 #else
+	if (sg_alloc_table(st, 1, GFP_KERNEL)) {
+		kfree(st);
+		return ERR_PTR(-ENOMEM);
+	}
+
 	sg = st->sgl;
 	sg->offset = 0;
 	sg->length = size;



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:24:38 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_stolen.c

Log Message:
i915_gem_stolen: Fill sg_pgs, with size/PAGE_SIZE entries.

Use sg_alloc_table_from_bus_dmamem to do this.

i915_gem_mman.c vm_fault_cpu and i915_gem_object_release_mmap_offset
both rely on sg_pgs to be a page array, so providing a table with
only one entry doesn't work (except by accident, if the object is
page-sized anyway).  And they rely on the sg_pgs entries to be
initialized, which we weren't doing before, and which
sg_alloc_table_from_bus_dmamem does for us.

Related to PR kern/57833.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.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/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:24:27 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_stolen.c

Log Message:
i915_gem_stolen: Fix memory leak.

Found while trying to address the PR 57833 class of problems.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.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/i915/gem/i915_gem_stolen.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c:1.5 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c:1.5	Sun Dec 19 12:10:42 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.c	Fri Jan 19 22:24:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_stolen.c,v 1.5 2021/12/19 12:10:42 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_stolen.c,v 1.6 2024/01/19 22:24:27 riastradh Exp $	*/
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_stolen.c,v 1.5 2021/12/19 12:10:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_stolen.c,v 1.6 2024/01/19 22:24:27 riastradh Exp $");
 
 #include 
 #include 
@@ -569,7 +569,8 @@ i915_pages_create_for_stolen(struct drm_
 	}
 	loaded = true;
 
-out:	if (ret) {
+out:	kmem_free(seg, nseg * sizeof(seg[0]));
+	if (ret) {
 		if (loaded)
 			bus_dmamap_unload(dmat, st->sgl->sg_dmamap);
 		sg_free_table(st);



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:24:27 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_stolen.c

Log Message:
i915_gem_stolen: Fix memory leak.

Found while trying to address the PR 57833 class of problems.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_stolen.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/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:23:19 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_region.c

Log Message:
i915_gem_region: Fill sg_pgs, with size/PAGE_SIZE entries.

Use sg_alloc_table_from_bus_dmamem to do this.

i915_gem_mman.c vm_fault_cpu and i915_gem_object_release_mmap_offset
both rely on sg_pgs to be a page array, so using something else like
size >> ilog2(mem->mm.chunk_size) entries doesn't work.  And they
rely on the sg_pgs entries to be initialized, which we weren't doing
before, and which sg_alloc_table_from_bus_dmamem does for us.

Related to PR kern/57833.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.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/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:23:19 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_region.c

Log Message:
i915_gem_region: Fill sg_pgs, with size/PAGE_SIZE entries.

Use sg_alloc_table_from_bus_dmamem to do this.

i915_gem_mman.c vm_fault_cpu and i915_gem_object_release_mmap_offset
both rely on sg_pgs to be a page array, so using something else like
size >> ilog2(mem->mm.chunk_size) entries doesn't work.  And they
rely on the sg_pgs entries to be initialized, which we weren't doing
before, and which sg_alloc_table_from_bus_dmamem does for us.

Related to PR kern/57833.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.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/i915/gem/i915_gem_region.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c:1.5 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c:1.5	Fri Jan 19 22:22:27 2024
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c	Fri Jan 19 22:23:19 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_region.c,v 1.5 2024/01/19 22:22:27 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_region.c,v 1.6 2024/01/19 22:23:19 riastradh Exp $	*/
 
 // SPDX-License-Identifier: MIT
 /*
@@ -6,7 +6,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_region.c,v 1.5 2024/01/19 22:22:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_region.c,v 1.6 2024/01/19 22:23:19 riastradh Exp $");
 
 #include "intel_memory_region.h"
 #include "i915_gem_region.h"
@@ -45,10 +45,12 @@ i915_gem_object_get_pages_buddy(struct d
 	if (!st)
 		return -ENOMEM;
 
+#ifndef __NetBSD__
 	if (sg_alloc_table(st, size >> ilog2(mem->mm.chunk_size), GFP_KERNEL)) {
 		kfree(st);
 		return -ENOMEM;
 	}
+#endif
 
 	flags = I915_ALLOC_MIN_PAGE_SIZE;
 	if (obj->flags & I915_BO_ALLOC_CONTIGUOUS)
@@ -60,7 +62,6 @@ i915_gem_object_get_pages_buddy(struct d
 
 	GEM_BUG_ON(list_empty(blocks));
 
-	sg = st->sgl;
 #ifdef __NetBSD__
 	__USE(prev_end);
 	bus_dma_tag_t dmat = obj->base.dev->dmat;
@@ -68,6 +69,8 @@ i915_gem_object_get_pages_buddy(struct d
 	int i = 0, nsegs = 0;
 	bool loaded = false;
 
+	sg = NULL;
+
 	list_for_each_entry(block, blocks, link) {
 		if (nsegs >= INT_MAX ||
 		nsegs >= SIZE_MAX/sizeof(segs[0]))
@@ -84,7 +87,15 @@ i915_gem_object_get_pages_buddy(struct d
 
 		segs[i].ds_addr = mem->region.start + offset;
 		segs[i].ds_len = block_size;
+		i++;
 	}
+	KASSERT(i == nsegs);
+
+	ret = sg_alloc_table_from_bus_dmamem(st, dmat, segs, nsegs,
+	GFP_KERNEL);
+	if (ret)
+		goto err;
+	sg = st->sgl;
 
 	/* XXX errno NetBSD->Linux */
 	ret = -bus_dmamap_create(dmat, size, nsegs, size, 0, BUS_DMA_WAITOK,
@@ -107,6 +118,7 @@ i915_gem_object_get_pages_buddy(struct d
 
 	sg_page_sizes = i915_sg_page_sizes(sg);
 #else
+	sg = st->sgl;
 	st->nents = 0;
 	sg_page_sizes = 0;
 	prev_end = (resource_size_t)-1;
@@ -154,6 +166,8 @@ i915_gem_object_get_pages_buddy(struct d
 err:
 	if (loaded)
 		bus_dmamap_unload(dmat, st->sgl->sg_dmamap);
+	if (sg && sg->sg_dmamap)
+		bus_dmamap_destroy(dmat, sg->sg_dmamap);
 	if (segs)
 		kmem_free(segs, nsegs * sizeof(segs[0]));
 	__intel_memory_region_put_pages_buddy(mem, blocks);



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:23:04 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_phys.c

Log Message:
i915_gem_phys: Fill sg_pgs.

This is needed by i915 gem fault, which maps user virtual addresses
to those pages, and by i915 gem object destruction, which does
pmap_page_protect on the pages to remove any of those user virtual
mappings.

This needs pmap_kenter_pa rather than pmap_enter(pmap_kernel(), ...)
in order to preserve the _kernel's_ mapping of the pages after
pmap_page_protect.

But bus_dmamem_map currently uses pmap_enter(pmap_kernel(), ...)
instead which creates a mapping that is removed by pmap_page_protect.

So we use a variant of bus_dmamem_map that uses pmap_kenter_pa
instead.  Perhaps bus_dmamem_map should do this itself, but this
change is less risky to pull up than a change to bus_dmamem_map
itself.

PR kern/57833: kernel panic on xorg exit

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.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/i915/gem/i915_gem_phys.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c:1.8 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c:1.9
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c:1.8	Sun Dec 19 12:45:43 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c	Fri Jan 19 22:23:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_phys.c,v 1.8 2021/12/19 12:45:43 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_phys.c,v 1.9 2024/01/19 22:23:04 riastradh Exp $	*/
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,91 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_phys.c,v 1.8 2021/12/19 12:45:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_phys.c,v 1.9 2024/01/19 22:23:04 riastradh Exp $");
+
+#ifdef __NetBSD__
+/*
+ * Make sure this block comes before any linux includes, so we don't
+ * get mixed up by the PAGE_MASK complementation.
+ */
+
+#include 
+
+#include 
+#include 
+
+#include  /* kvtopte, pmap_pte_clearbits */
+
+/*
+ * Version of bus_dmamem_map that uses pmap_kenter_pa, not pmap_enter,
+ * so that it isn't affected by pmap_page_protect on the physical
+ * address.  Adapted from sys/arch/x86/x86/bus_dma.c.
+ */
+static int
+bus_dmamem_kmap(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
+size_t size, void **kvap, int flags)
+{
+	vaddr_t va;
+	bus_addr_t addr;
+	int curseg;
+	const uvm_flag_t kmflags =
+	(flags & BUS_DMA_NOWAIT) != 0 ? UVM_KMF_NOWAIT : 0;
+	u_int pmapflags = PMAP_WIRED | VM_PROT_READ | VM_PROT_WRITE;
+
+	size = round_page(size);
+	if (flags & BUS_DMA_NOCACHE)
+		pmapflags |= PMAP_NOCACHE;
+
+	va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY | kmflags);
+
+	if (va == 0)
+		return ENOMEM;
+
+	*kvap = (void *)va;
+
+	for (curseg = 0; curseg < nsegs; curseg++) {
+		for (addr = segs[curseg].ds_addr;
+		addr < (segs[curseg].ds_addr + segs[curseg].ds_len);
+		addr += PAGE_SIZE, va += PAGE_SIZE, size -= PAGE_SIZE) {
+			if (size == 0)
+panic("bus_dmamem_kmap: size botch");
+			pmap_kenter_pa(va, addr,
+			VM_PROT_READ | VM_PROT_WRITE,
+			pmapflags);
+		}
+	}
+	pmap_update(pmap_kernel());
+
+	return 0;
+}
+
+static void
+bus_dmamem_kunmap(bus_dma_tag_t t, void *kva, size_t size)
+{
+	pt_entry_t *pte, opte;
+	vaddr_t va, sva, eva;
+
+	KASSERTMSG(((uintptr_t)kva & PGOFSET) == 0, "kva=%p", kva);
+
+	size = round_page(size);
+	sva = (vaddr_t)kva;
+	eva = sva + size;
+
+	/*
+	 * mark pages cacheable again.
+	 */
+	for (va = sva; va < eva; va += PAGE_SIZE) {
+		pte = kvtopte(va);
+		opte = *pte;
+		if ((opte & PTE_PCD) != 0)
+			pmap_pte_clearbits(pte, PTE_PCD);
+	}
+	pmap_kremove((vaddr_t)kva, size);
+	pmap_update(pmap_kernel());
+	uvm_km_free(kernel_map, (vaddr_t)kva, size, UVM_KMF_VAONLY);
+}
+
+#endif
 
 #include 
 #include 
@@ -65,7 +149,7 @@ static int i915_gem_object_get_pages_phy
 	if (ret)
 		return -ENOMEM;
 	KASSERT(rsegs == 1);
-	ret = -bus_dmamem_map(dmat, >mm.u.phys.seg, 1,
+	ret = -bus_dmamem_kmap(dmat, >mm.u.phys.seg, 1,
 	roundup_pow_of_two(obj->base.size), ,
 	BUS_DMA_WAITOK|BUS_DMA_COHERENT);
 	if (ret)
@@ -83,7 +167,12 @@ static int i915_gem_object_get_pages_phy
 	if (!st)
 		goto err_pci;
 
+#ifdef __NetBSD__
+	if (sg_alloc_table_from_bus_dmamem(st, dmat, >mm.u.phys.seg, 1,
+		GFP_KERNEL))
+#else
 	if (sg_alloc_table(st, 1, GFP_KERNEL))
+#endif
 		goto err_st;
 
 	sg = st->sgl;
@@ -151,7 +240,7 @@ err_st:
 err_pci:
 #ifdef __NetBSD__
 	if (vaddr) {
-		bus_dmamem_unmap(dmat, vaddr,
+		bus_dmamem_kunmap(dmat, vaddr,
 		roundup_pow_of_two(obj->base.size));
 	}
 	obj->mm.u.phys.kva = NULL;
@@ -225,7 +314,7 @@ i915_gem_object_put_pages_phys(struct dr
 	kfree(pages);
 
 #ifdef __NetBSD__
-	bus_dmamem_unmap(dmat, 

CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:23:04 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_phys.c

Log Message:
i915_gem_phys: Fill sg_pgs.

This is needed by i915 gem fault, which maps user virtual addresses
to those pages, and by i915 gem object destruction, which does
pmap_page_protect on the pages to remove any of those user virtual
mappings.

This needs pmap_kenter_pa rather than pmap_enter(pmap_kernel(), ...)
in order to preserve the _kernel's_ mapping of the pages after
pmap_page_protect.

But bus_dmamem_map currently uses pmap_enter(pmap_kernel(), ...)
instead which creates a mapping that is removed by pmap_page_protect.

So we use a variant of bus_dmamem_map that uses pmap_kenter_pa
instead.  Perhaps bus_dmamem_map should do this itself, but this
change is less risky to pull up than a change to bus_dmamem_map
itself.

PR kern/57833: kernel panic on xorg exit

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.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/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:22:54 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_pages.c

Log Message:
i915_gem: Assert page array size.

Let's detect the bug of sg_npgs failing to match
obj->base.size/PAGE_SIZE earlier.

Related to PR kern/57833.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.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/i915/gem/i915_gem_pages.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c:1.6 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c:1.7
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c:1.6	Sun Dec 19 12:00:57 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c	Fri Jan 19 22:22:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_pages.c,v 1.6 2021/12/19 12:00:57 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_pages.c,v 1.7 2024/01/19 22:22:54 riastradh Exp $	*/
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_pages.c,v 1.6 2021/12/19 12:00:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_pages.c,v 1.7 2024/01/19 22:22:54 riastradh Exp $");
 
 #include "i915_drv.h"
 #include "i915_gem_object.h"
@@ -42,6 +42,18 @@ void __i915_gem_object_set_pages(struct 
 	}
 
 #ifndef __NetBSD__
+	/*
+	 * Paranoia: In NetBSD, a scatterlist is just an array of
+	 * pages, not an array of segments that might be larger than
+	 * pages, so the number of entries must exactly match the size
+	 * of the object (which should also be page-aligned).
+	 *
+	 * Both vm_fault_cpu and i915_gem_object_release_mmap_offset in
+	 * i915_gem_mman.c rely on this page array as such.
+	 */
+	KASSERTMSG(pages->sgl->sg_npgs == obj->base.size >> PAGE_SHIFT,
+	"npgs=%zu size=%zu", pages->sgl->sg_npgs, obj->base.size);
+
 	obj->mm.get_page.sg_pos = pages->sgl;
 	obj->mm.get_page.sg_idx = 0;
 #endif



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:22:54 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_pages.c

Log Message:
i915_gem: Assert page array size.

Let's detect the bug of sg_npgs failing to match
obj->base.size/PAGE_SIZE earlier.

Related to PR kern/57833.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.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/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:22:40 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_mman.c

Log Message:
i915_gem: Avoid walking off end of sg_pgs.

sg_npgs currently fails to match obj->base.size/PAGE_SIZE only due to
bugs in the construction of sg_pgs in various i915 gem object types,
which we should also fix, but let's avoid compounding it here.

Related to PR kern/57833.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.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/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:22:40 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_mman.c

Log Message:
i915_gem: Avoid walking off end of sg_pgs.

sg_npgs currently fails to match obj->base.size/PAGE_SIZE only due to
bugs in the construction of sg_pgs in various i915 gem object types,
which we should also fix, but let's avoid compounding it here.

Related to PR kern/57833.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.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/i915/gem/i915_gem_mman.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c:1.21 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c:1.22
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c:1.21	Sun Dec 19 12:26:55 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c	Fri Jan 19 22:22:40 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_mman.c,v 1.21 2021/12/19 12:26:55 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_mman.c,v 1.22 2024/01/19 22:22:40 riastradh Exp $	*/
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_mman.c,v 1.21 2021/12/19 12:26:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_mman.c,v 1.22 2024/01/19 22:22:40 riastradh Exp $");
 
 #include 
 #include 
@@ -675,7 +675,7 @@ void i915_gem_object_release_mmap_offset
 
 	if (!i915_gem_object_has_pages(obj))
 		return;
-	for (i = 0; i < obj->base.size >> PAGE_SHIFT; i++) {
+	for (i = 0; i < obj->mm.pages->sgl->sg_npgs; i++) {
 		page = obj->mm.pages->sgl->sg_pgs[i];
 		vm_page = >p_vmp;
 		pmap_page_protect(vm_page, VM_PROT_NONE);



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:22:27 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_region.c

Log Message:
i915_gem_region: Reduce diff from upstream a little.

No functional change intended.

Prompted by upcoming nearby changes related to PR kern/57833.

XXX pullup-10 (to make subsequent pullups easier)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.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/i915/gem/i915_gem_region.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c:1.4 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c:1.4	Sun Dec 19 12:10:42 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.c	Fri Jan 19 22:22:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_region.c,v 1.4 2021/12/19 12:10:42 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_region.c,v 1.5 2024/01/19 22:22:27 riastradh Exp $	*/
 
 // SPDX-License-Identifier: MIT
 /*
@@ -6,7 +6,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_region.c,v 1.4 2021/12/19 12:10:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_region.c,v 1.5 2024/01/19 22:22:27 riastradh Exp $");
 
 #include "intel_memory_region.h"
 #include "i915_gem_region.h"
@@ -63,7 +63,6 @@ i915_gem_object_get_pages_buddy(struct d
 	sg = st->sgl;
 #ifdef __NetBSD__
 	__USE(prev_end);
-	__USE(sg_page_sizes);
 	bus_dma_tag_t dmat = obj->base.dev->dmat;
 	bus_dma_segment_t *segs = NULL;
 	int i = 0, nsegs = 0;
@@ -106,7 +105,7 @@ i915_gem_object_get_pages_buddy(struct d
 	kmem_free(segs, nsegs * sizeof(segs[0]));
 	segs = NULL;
 
-	__i915_gem_object_set_pages(obj, st, i915_sg_page_sizes(sg));
+	sg_page_sizes = i915_sg_page_sizes(sg);
 #else
 	st->nents = 0;
 	sg_page_sizes = 0;
@@ -145,9 +144,9 @@ i915_gem_object_get_pages_buddy(struct d
 	sg_page_sizes |= sg->length;
 	sg_mark_end(sg);
 	i915_sg_trim(st);
+#endif
 
 	__i915_gem_object_set_pages(obj, st, sg_page_sizes);
-#endif
 
 	return 0;
 



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2024-01-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 19 22:22:27 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_region.c

Log Message:
i915_gem_region: Reduce diff from upstream a little.

No functional change intended.

Prompted by upcoming nearby changes related to PR kern/57833.

XXX pullup-10 (to make subsequent pullups easier)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_region.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/i915

2024-01-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan 14 22:15:15 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915: i915_pci.c

Log Message:
i915: Backport change to downgrade gen7/vlv to aliasing-ppggtt.

PR kern/57268

XXX pullup-10

commit 4fbe112a569526e46fa2accb5763c069f78cb431
Author: Chris Wilson 
Date:   Mon Feb 24 10:11:20 2020 +

drm/i915/gtt: Downgrade gen7 (ivb, byt, hsw) back to aliasing-ppgtt

Full-ppgtt on gen7 is proving to be highly unstable and not robust.

Closes: https://gitlab.freedesktop.org/drm/intel/issues/694
Fixes: 3cd6e8860ecd ("drm/i915/gen7: Re-enable full-ppgtt for ivb & hsw")
Signed-off-by: Chris Wilson 
Cc: Joonas Lahtinen 
Cc: Rodrigo Vivi 
Cc: Jani Nikula 
Cc: Dave Airlie 
Acked-by: Rodrigo Vivi 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20200224101120.4024481-1-ch...@chris-wilson.co.uk


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/dist/drm/i915/i915_pci.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/i915/i915_pci.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_pci.c:1.4 src/sys/external/bsd/drm2/dist/drm/i915/i915_pci.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_pci.c:1.4	Sun Dec 19 01:44:49 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_pci.c	Sun Jan 14 22:15:15 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_pci.c,v 1.4 2021/12/19 01:44:49 riastradh Exp $	*/
+/*	$NetBSD: i915_pci.c,v 1.5 2024/01/14 22:15:15 riastradh Exp $	*/
 
 /*
  * Copyright © 2016 Intel Corporation
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_pci.c,v 1.4 2021/12/19 01:44:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_pci.c,v 1.5 2024/01/14 22:15:15 riastradh Exp $");
 
 #include 
 #include 
@@ -442,7 +442,7 @@ static const struct intel_device_info sn
 	.has_rc6 = 1, \
 	.has_rc6p = 1, \
 	.has_rps = true, \
-	.ppgtt_type = INTEL_PPGTT_FULL, \
+	.ppgtt_type = INTEL_PPGTT_ALIASING, \
 	.ppgtt_size = 31, \
 	IVB_PIPE_OFFSETS, \
 	IVB_CURSOR_OFFSETS, \
@@ -499,7 +499,7 @@ static const struct intel_device_info vl
 	.has_rps = true,
 	.display.has_gmch = 1,
 	.display.has_hotplug = 1,
-	.ppgtt_type = INTEL_PPGTT_FULL,
+	.ppgtt_type = INTEL_PPGTT_ALIASING,
 	.ppgtt_size = 31,
 	.has_snoop = true,
 	.has_coherent_ggtt = false,



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

2024-01-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan 14 22:15:15 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915: i915_pci.c

Log Message:
i915: Backport change to downgrade gen7/vlv to aliasing-ppggtt.

PR kern/57268

XXX pullup-10

commit 4fbe112a569526e46fa2accb5763c069f78cb431
Author: Chris Wilson 
Date:   Mon Feb 24 10:11:20 2020 +

drm/i915/gtt: Downgrade gen7 (ivb, byt, hsw) back to aliasing-ppgtt

Full-ppgtt on gen7 is proving to be highly unstable and not robust.

Closes: https://gitlab.freedesktop.org/drm/intel/issues/694
Fixes: 3cd6e8860ecd ("drm/i915/gen7: Re-enable full-ppgtt for ivb & hsw")
Signed-off-by: Chris Wilson 
Cc: Joonas Lahtinen 
Cc: Rodrigo Vivi 
Cc: Jani Nikula 
Cc: Dave Airlie 
Acked-by: Rodrigo Vivi 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20200224101120.4024481-1-ch...@chris-wilson.co.uk


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/dist/drm/i915/i915_pci.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

2023-12-29 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Fri Dec 29 22:58:24 UTC 2023

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

Log Message:
drm: put_cpu() should enable preemption, not disable it again


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/include/linux/smp.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

2023-12-29 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Fri Dec 29 22:58:24 UTC 2023

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

Log Message:
drm: put_cpu() should enable preemption, not disable it again


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/include/linux/smp.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/smp.h
diff -u src/sys/external/bsd/drm2/include/linux/smp.h:1.4 src/sys/external/bsd/drm2/include/linux/smp.h:1.5
--- src/sys/external/bsd/drm2/include/linux/smp.h:1.4	Sun Dec 19 11:49:12 2021
+++ src/sys/external/bsd/drm2/include/linux/smp.h	Fri Dec 29 22:58:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: smp.h,v 1.4 2021/12/19 11:49:12 riastradh Exp $	*/
+/*	$NetBSD: smp.h,v 1.5 2023/12/29 22:58:23 chs Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@ static inline void
 put_cpu(void)
 {
 
-	kpreempt_disable();
+	kpreempt_enable();
 }
 
 static inline void



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

2023-11-06 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Nov  6 14:33:51 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_bios.c

Log Message:
radeon: fix and enable ACPI methods for getting ROM BIOS

The hacky way of getting the BIOS mapped only works on x86. ACPI
should be preferred if available. Makes BIOS reading though VFCT
work on aarch64 with EDK2. (But only if EDK2 has POSTed the GPU.)

XXX amdgpu should get the same treatment.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.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/radeon/radeon_bios.c
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.12 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.13
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.12	Sat May 28 01:07:47 2022
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c	Mon Nov  6 14:33:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeon_bios.c,v 1.12 2022/05/28 01:07:47 manu Exp $	*/
+/*	$NetBSD: radeon_bios.c,v 1.13 2023/11/06 14:33:51 tnn Exp $	*/
 
 /*
  * Copyright 2008 Advanced Micro Devices, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeon_bios.c,v 1.12 2022/05/28 01:07:47 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_bios.c,v 1.13 2023/11/06 14:33:51 tnn Exp $");
 
 #include 
 #include 
@@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: radeon_bios.
 #include "radeon_reg.h"
 
 #if defined(__NetBSD__) && NACPICA > 0
+#define CONFIG_ACPI
 #include 
 #define	_COMPONENT	ACPI_DISPLAY_COMPONENT
 ACPI_MODULE_NAME("radeon_acpi")
@@ -252,10 +253,15 @@ static bool radeon_atrm_get_bios(struct 
 	if (rdev->flags & RADEON_IS_IGP)
 		return false;
 
-	while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
 #ifdef __NetBSD__
+	pdev = rdev->pdev;
+	while (pdev != NULL) {
 		dhandle = (pdev->pd_ad ? pdev->pd_ad->ad_handle : NULL);
+		pdev = NULL;
+		if (rdev->pdev->class != PCI_CLASS_DISPLAY_VGA)
+			continue;
 #else
+	while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
 		dhandle = ACPI_HANDLE(>dev);
 #endif
 		if (!dhandle)
@@ -269,11 +275,16 @@ static bool radeon_atrm_get_bios(struct 
 	}
 
 	if (!found) {
-		while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
 #ifdef __NetBSD__
+		pdev = rdev->pdev;
+		while (pdev != NULL) {
 			dhandle = (pdev->pd_ad ? pdev->pd_ad->ad_handle
 			: NULL);
+			pdev = NULL;
+			if (rdev->pdev->class != PCI_CLASS_DISPLAY_OTHER)
+continue;
 #else
+		while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
 			dhandle = ACPI_HANDLE(>dev);
 #endif
 			if (!dhandle)



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

2023-11-06 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Nov  6 14:33:51 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_bios.c

Log Message:
radeon: fix and enable ACPI methods for getting ROM BIOS

The hacky way of getting the BIOS mapped only works on x86. ACPI
should be preferred if available. Makes BIOS reading though VFCT
work on aarch64 with EDK2. (But only if EDK2 has POSTed the GPU.)

XXX amdgpu should get the same treatment.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.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/ena-com

2023-11-05 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Nov  5 18:24:31 UTC 2023

Modified Files:
src/sys/external/bsd/ena-com: ena_com.c

Log Message:
ena(4): destroy all wait_event

Code contributed by KUSABA Takeshi 


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/ena-com/ena_com.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/ena-com/ena_com.c
diff -u src/sys/external/bsd/ena-com/ena_com.c:1.3 src/sys/external/bsd/ena-com/ena_com.c:1.4
--- src/sys/external/bsd/ena-com/ena_com.c:1.3	Sun Nov  5 18:21:54 2023
+++ src/sys/external/bsd/ena-com/ena_com.c	Sun Nov  5 18:24:31 2023
@@ -1584,13 +1584,20 @@ void ena_com_admin_destroy(struct ena_co
 	struct ena_com_admin_sq *sq = _queue->sq;
 	struct ena_com_aenq *aenq = _dev->aenq;
 	u16 size;
-
-	ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event);
+	int i;
 
 	ENA_SPINLOCK_DESTROY(admin_queue->q_lock);
 
 	if (admin_queue->comp_ctx) {
-		size_t s = admin_queue->q_depth * sizeof(struct ena_comp_ctx);
+		size_t s;
+
+		for (i = 0; i < admin_queue->q_depth; i++) {
+			struct ena_comp_ctx *comp_ctx = get_comp_ctxt(admin_queue, i, false);
+			if (comp_ctx != NULL)
+ENA_WAIT_EVENT_DESTROY(comp_ctx->wait_event);
+		}
+
+		s = admin_queue->q_depth * sizeof(struct ena_comp_ctx);
 		ENA_MEM_FREE(ena_dev->dmadev, admin_queue->comp_ctx, s);
 	}
 	admin_queue->comp_ctx = NULL;



CVS commit: src/sys/external/bsd/ena-com

2023-11-05 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Nov  5 18:24:31 UTC 2023

Modified Files:
src/sys/external/bsd/ena-com: ena_com.c

Log Message:
ena(4): destroy all wait_event

Code contributed by KUSABA Takeshi 


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/ena-com/ena_com.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

2023-09-30 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Sep 30 10:46:46 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_cik.c
amdgpu_device.c amdgpu_si.c amdgpu_vi.c
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci:
nouveau_nvkm_subdev_pci_pcie.c
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_ci_dpm.c radeon_cik.c
radeon_evergreen.c radeon_r600.c radeon_rv770.c radeon_si.c
radeon_si_dpm.c
src/sys/external/bsd/drm2/include/linux: pci.h
src/sys/external/bsd/drm2/linux: linux_pci.c

Log Message:
drm: enable almost all PCIe functionality

linux_pci.c revisions 1.24 and 1.25 implemented most of the remaining
missing PCIe backends, but only enabled them for some amdgpu portions.

this enables all code marked with "XXX amdgpu pcie", "XXX radeon pcie",
and "XXX pcie speed".  for most of it, simply removing #ifndefs __NetBSD__
to enable compliation was required, once the new "bus->max_bus_speed"
member was added to struct pci_bus.  add an "always fails" backend for
pci_enable_atomic_ops_to_root() which seems to only be necessary
for virtual GPU functionality (and could be implemented if needed.)

tested on radeon 5450, 7750, R7 240 [radeon], and RX 550 [amdgpu], and
nvidia 750 and 1030 [nouveau].

this still does not quite work on nvidia cards.  there are two problems
that remain:

- the call to set the link speed is skipped because the speed is set
  to the default value of "-1".  nvkm_pcie_set_link() will actually
  determine the right value for this and for some cards, calling this
  function if the current speed is -1 helps set the link speed.  it
  may be that on linux other paths we don't have enabled properly
  would set this (there's one via debugfs, and a jetson specific one,
  though perhaps setting either AC or DC speed values as boot options
  (after hooking up these for netbsd) would currently work.

- worse, cards newer than kepler - geforce 900, 1000, and newer, are
  all lacking the backing support to set pcie link speed.  the GT 1030
  card i have been testing with remains at pcie 1.0.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c
cvs rdiff -u -r1.19 -r1.20 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_si.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vi.c
cvs rdiff -u -r1.4 -r1.5 \

src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_ci_dpm.c \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_r600.c
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_cik.c
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_evergreen.c \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_si.c
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_rv770.c
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_si_dpm.c
cvs rdiff -u -r1.56 -r1.57 src/sys/external/bsd/drm2/include/linux/pci.h
cvs rdiff -u -r1.26 -r1.27 src/sys/external/bsd/drm2/linux/linux_pci.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

2023-09-30 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Sep 30 10:46:46 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_cik.c
amdgpu_device.c amdgpu_si.c amdgpu_vi.c
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci:
nouveau_nvkm_subdev_pci_pcie.c
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_ci_dpm.c radeon_cik.c
radeon_evergreen.c radeon_r600.c radeon_rv770.c radeon_si.c
radeon_si_dpm.c
src/sys/external/bsd/drm2/include/linux: pci.h
src/sys/external/bsd/drm2/linux: linux_pci.c

Log Message:
drm: enable almost all PCIe functionality

linux_pci.c revisions 1.24 and 1.25 implemented most of the remaining
missing PCIe backends, but only enabled them for some amdgpu portions.

this enables all code marked with "XXX amdgpu pcie", "XXX radeon pcie",
and "XXX pcie speed".  for most of it, simply removing #ifndefs __NetBSD__
to enable compliation was required, once the new "bus->max_bus_speed"
member was added to struct pci_bus.  add an "always fails" backend for
pci_enable_atomic_ops_to_root() which seems to only be necessary
for virtual GPU functionality (and could be implemented if needed.)

tested on radeon 5450, 7750, R7 240 [radeon], and RX 550 [amdgpu], and
nvidia 750 and 1030 [nouveau].

this still does not quite work on nvidia cards.  there are two problems
that remain:

- the call to set the link speed is skipped because the speed is set
  to the default value of "-1".  nvkm_pcie_set_link() will actually
  determine the right value for this and for some cards, calling this
  function if the current speed is -1 helps set the link speed.  it
  may be that on linux other paths we don't have enabled properly
  would set this (there's one via debugfs, and a jetson specific one,
  though perhaps setting either AC or DC speed values as boot options
  (after hooking up these for netbsd) would currently work.

- worse, cards newer than kepler - geforce 900, 1000, and newer, are
  all lacking the backing support to set pcie link speed.  the GT 1030
  card i have been testing with remains at pcie 1.0.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c
cvs rdiff -u -r1.19 -r1.20 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_si.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vi.c
cvs rdiff -u -r1.4 -r1.5 \

src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_ci_dpm.c \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_r600.c
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_cik.c
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_evergreen.c \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_si.c
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_rv770.c
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_si_dpm.c
cvs rdiff -u -r1.56 -r1.57 src/sys/external/bsd/drm2/include/linux/pci.h
cvs rdiff -u -r1.26 -r1.27 src/sys/external/bsd/drm2/linux/linux_pci.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/amd/amdgpu/amdgpu_cik.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c:1.6 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c:1.7
--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c:1.6	Mon Oct 17 03:05:32 2022
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c	Sat Sep 30 10:46:45 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_cik.c,v 1.6 2022/10/17 03:05:32 mrg Exp $	*/
+/*	$NetBSD: amdgpu_cik.c,v 1.7 2023/09/30 10:46:45 mrg Exp $	*/
 
 /*
  * Copyright 2012 Advanced Micro Devices, Inc.
@@ -24,7 +24,7 @@
  * Authors: Alex Deucher
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_cik.c,v 1.6 2022/10/17 03:05:32 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_cik.c,v 1.7 2023/09/30 10:46:45 mrg Exp $");
 
 #include 
 #include 
@@ -1733,9 +1733,6 @@ static void cik_program_aspm(struct amdg
 WREG32_PCIE(ixPCIE_LC_LINK_WIDTH_CNTL, data);
 
 			if (!disable_clkreq) {
-#ifdef __NetBSD__		/* XXX amdgpu pcie */
-clk_req_support = false;
-#else
 struct pci_dev *root = adev->pdev->bus->self;
 u32 lnkcap;
 
@@ -1743,7 +1740,6 @@ static void cik_program_aspm(struct amdg
 pcie_capability_read_dword(root, PCI_EXP_LNKCAP, );
 if (lnkcap & PCI_EXP_LNKCAP_CLKPM)
 	clk_req_support = true;
-#endif
 			} else {
 clk_req_support = false;
 			}

Index: src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c
diff -u 

CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci

2023-09-30 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Sep 30 10:38:31 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci:
nouveau_nvkm_subdev_pci_pcie.c

Log Message:
avoid an unlikely array bounds issue picked up by GCC 12.

nvkm_pcie_speed() can return -1, which is then used as an array index,
so make this default return PCIe 1.0 speeds.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \

src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.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/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c:1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c:1.4
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c:1.3	Sun Dec 19 10:51:58 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c	Sat Sep 30 10:38:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_nvkm_subdev_pci_pcie.c,v 1.3 2021/12/19 10:51:58 riastradh Exp $	*/
+/*	$NetBSD: nouveau_nvkm_subdev_pci_pcie.c,v 1.4 2023/09/30 10:38:31 mrg Exp $	*/
 
 /*
  * Copyright 2015 Karol Herbst 
@@ -24,7 +24,7 @@
  * Authors: Karol Herbst 
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_pci_pcie.c,v 1.3 2021/12/19 10:51:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_pci_pcie.c,v 1.4 2023/09/30 10:38:31 mrg Exp $");
 
 #include "priv.h"
 
@@ -48,7 +48,7 @@ nvkm_pcie_speed(enum pci_bus_speed speed
 		/* XXX 0x16 is 8_0, assume 0x17 will be 16_0 for now */
 		if (speed == 0x17)
 			return NVKM_PCIE_SPEED_8_0;
-		return -1;
+		return NVKM_PCIE_SPEED_2_5;
 	}
 }
 



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci

2023-09-30 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Sep 30 10:38:31 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci:
nouveau_nvkm_subdev_pci_pcie.c

Log Message:
avoid an unlikely array bounds issue picked up by GCC 12.

nvkm_pcie_speed() can return -1, which is then used as an array index,
so make this default return PCIe 1.0 speeds.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \

src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.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/acpica/dist/debugger

2023-09-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep  5 22:15:46 UTC 2023

Modified Files:
src/sys/external/bsd/acpica/dist/debugger: dbcmds.c

Log Message:
we don't have/need limits.h


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/external/bsd/acpica/dist/debugger/dbcmds.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/acpica/dist/debugger/dbcmds.c
diff -u src/sys/external/bsd/acpica/dist/debugger/dbcmds.c:1.17 src/sys/external/bsd/acpica/dist/debugger/dbcmds.c:1.18
--- src/sys/external/bsd/acpica/dist/debugger/dbcmds.c:1.17	Fri Sep  1 14:37:29 2023
+++ src/sys/external/bsd/acpica/dist/debugger/dbcmds.c	Tue Sep  5 18:15:46 2023
@@ -48,7 +48,9 @@
 #include "acnamesp.h"
 #include "acresrc.h"
 #include "actables.h"
+#ifndef _KERNEL
 #include "limits.h"
+#endif
 
 #define _COMPONENT  ACPI_CA_DEBUGGER
 ACPI_MODULE_NAME("dbcmds")



CVS commit: src/sys/external/bsd/acpica/dist/debugger

2023-09-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep  5 22:15:46 UTC 2023

Modified Files:
src/sys/external/bsd/acpica/dist/debugger: dbcmds.c

Log Message:
we don't have/need limits.h


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/external/bsd/acpica/dist/debugger/dbcmds.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

2023-09-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep  5 20:15:10 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/drm: drm_module.c
src/sys/external/bsd/drm2/pci: files.drmkms_pci

Log Message:
drm: Fix conditionals around drmkms_pci and agp.

Kernel should build now with all pci drm drivers stripped out but
DRM_LEGACY still enabled.  (Might not be very useful, but it'll
build.  Maybe we should also have DRM_LEGACY_PCI so those drivers can
be modloaded later.)


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/external/bsd/drm2/drm/drm_module.c
cvs rdiff -u -r1.17 -r1.18 src/sys/external/bsd/drm2/pci/files.drmkms_pci

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

2023-09-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep  5 20:15:10 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/drm: drm_module.c
src/sys/external/bsd/drm2/pci: files.drmkms_pci

Log Message:
drm: Fix conditionals around drmkms_pci and agp.

Kernel should build now with all pci drm drivers stripped out but
DRM_LEGACY still enabled.  (Might not be very useful, but it'll
build.  Maybe we should also have DRM_LEGACY_PCI so those drivers can
be modloaded later.)


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/external/bsd/drm2/drm/drm_module.c
cvs rdiff -u -r1.17 -r1.18 src/sys/external/bsd/drm2/pci/files.drmkms_pci

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/drm/drm_module.c
diff -u src/sys/external/bsd/drm2/drm/drm_module.c:1.31 src/sys/external/bsd/drm2/drm/drm_module.c:1.32
--- src/sys/external/bsd/drm2/drm/drm_module.c:1.31	Tue Jul 19 22:24:47 2022
+++ src/sys/external/bsd/drm2/drm/drm_module.c	Tue Sep  5 20:15:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_module.c,v 1.31 2022/07/19 22:24:47 riastradh Exp $	*/
+/*	$NetBSD: drm_module.c,v 1.32 2023/09/05 20:15:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_module.c,v 1.31 2022/07/19 22:24:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_module.c,v 1.32 2023/09/05 20:15:10 riastradh Exp $");
 
 #include 
 #include 
@@ -89,6 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: drm_module.c
  */
 #if defined(__powerpc__) || defined(__i386__) || defined(__x86_64__)
 #include "agp.h"
+#include "drmkms_pci.h"
 #endif
 
 /*
@@ -114,7 +115,7 @@ drm_init(void)
 	drm_core_init_complete = true;
 
 	drm_agp_hooks_init();
-#if NAGP > 0
+#if NDRMKMS_PCI > 0 && NAGP > 0
 	extern int drmkms_agp_guarantee_initialized(void);
 	error = drmkms_agp_guarantee_initialized();
 	if (error) {

Index: src/sys/external/bsd/drm2/pci/files.drmkms_pci
diff -u src/sys/external/bsd/drm2/pci/files.drmkms_pci:1.17 src/sys/external/bsd/drm2/pci/files.drmkms_pci:1.18
--- src/sys/external/bsd/drm2/pci/files.drmkms_pci:1.17	Tue Jul 19 23:19:07 2022
+++ src/sys/external/bsd/drm2/pci/files.drmkms_pci	Tue Sep  5 20:15:10 2023
@@ -1,11 +1,11 @@
-#	$NetBSD: files.drmkms_pci,v 1.17 2022/07/19 23:19:07 riastradh Exp $
+#	$NetBSD: files.drmkms_pci,v 1.18 2023/09/05 20:15:10 riastradh Exp $
 
 define	drmkms_pci: drmkms
 
 makeoptions	drmkms_pci	"CPPFLAGS.drmkms_pci"+="${CPPFLAGS.drmkms}"
 
 #file	external/bsd/drm2/dist/drm/ati_pcigart.c	drmkms_pci
-file	external/bsd/drm2/dist/drm/drm_agpsupport.c	drmkms_pci & agp
+file	external/bsd/drm2/dist/drm/drm_agpsupport.c	drmkms_pci & agp	needs-flag
 file	external/bsd/drm2/pci/drm_pci.c			drmkms_pci
 file	external/bsd/drm2/pci/drm_pci_module.c		drmkms_pci
 



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

2023-09-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Sep  5 06:08:02 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/i915drm: files.i915drmkms

Log Message:
match warnings with the module build, fixes i386 with GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/external/bsd/drm2/i915drm/files.i915drmkms

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/i915drm

2023-09-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Sep  5 06:08:02 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/i915drm: files.i915drmkms

Log Message:
match warnings with the module build, fixes i386 with GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/external/bsd/drm2/i915drm/files.i915drmkms

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/i915drm/files.i915drmkms
diff -u src/sys/external/bsd/drm2/i915drm/files.i915drmkms:1.90 src/sys/external/bsd/drm2/i915drm/files.i915drmkms:1.91
--- src/sys/external/bsd/drm2/i915drm/files.i915drmkms:1.90	Sat Jun  3 21:31:46 2023
+++ src/sys/external/bsd/drm2/i915drm/files.i915drmkms	Tue Sep  5 06:08:02 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: files.i915drmkms,v 1.90 2023/06/03 21:31:46 lukem Exp $
+#	$NetBSD: files.i915drmkms,v 1.91 2023/09/05 06:08:02 mrg Exp $
 
 version	20180827
 
@@ -44,17 +44,19 @@ makeoptions	i915drmkms	"CWARNFLAGS.i915d
 makeoptions	i915drmkms	"CWARNFLAGS.i915drmkms"+="-Wno-pointer-arith"
 makeoptions	i915drmkms	"CWARNFLAGS.i915drmkms"+="-Wno-shadow"
 
+makeoptions 	i915drmkms 	"CWARNFLAGS.i915_irq.c"+="${CC_WNO_MAYBE_UNINITIALIZED}"
 makeoptions 	i915drmkms 	"CWARNFLAGS.i915_pci.c"+="${${ACTIVE_CC} == gcc:? -Wno-override-init :}"
 makeoptions 	i915drmkms 	"CWARNFLAGS.i915_pci.c"+="${${ACTIVE_CC} == clang:? -Wno-initializer-overrides :}"
 makeoptions	i915drmkms	"CWARNFLAGS.i915_sw_fence.c"+="${${ACTIVE_CC} == clang :? -Wno-unused-function :}"
 
-makeoptions 	i915drmkms 	"CWARNFLAGS.intel_sprite.c"+="${CC_WNO_MAYBE_UNINITIALIZED}"
-
-makeoptions 	i915drmkms 	"CWARNFLAGS.intel_ddi.c"+="${CC_WNO_MAYBE_UNINITIALIZED} ${CC_WNO_IMPLICIT_FALLTHROUGH}"
-makeoptions 	i915drmkms 	"CWARNFLAGS.intel_display.c"+="${CC_WNO_IMPLICIT_FALLTHROUGH}"
 makeoptions	i915drmkms	"CWARNFLAGS.intel_guc_submission.c"+="${${ACTIVE_CC} == clang :? -Wno-unused-function :}"
 makeoptions	i915drmkms	"CWARNFLAGS.intel_hdmi.c"+="${${ACTIVE_CC} == clang :? -Wno-unused-function :}"
+makeoptions 	i915drmkms 	"CWARNFLAGS.intel_ddi.c"+="${CC_WNO_MAYBE_UNINITIALIZED} ${CC_WNO_IMPLICIT_FALLTHROUGH}"
+makeoptions 	i915drmkms 	"CWARNFLAGS.intel_display.c"+="${CC_WNO_IMPLICIT_FALLTHROUGH}"
+makeoptions 	i915drmkms 	"CWARNFLAGS.intel_dp.c"+="${CC_WNO_STRINGOP_OVERREAD}"
+makeoptions 	i915drmkms 	"CWARNFLAGS.intel_pm.c"+="${CC_WNO_STRINGOP_OVERREAD} ${CC_WNO_STRINGOP_OVERFLOW}"
 makeoptions 	i915drmkms 	"CWARNFLAGS.intel_sdvo.c"+="${CC_WNO_IMPLICIT_FALLTHROUGH}"
+makeoptions 	i915drmkms 	"CWARNFLAGS.intel_sprite.c"+="${CC_WNO_MAYBE_UNINITIALIZED}"
 
 makeoptions	intelfb		"CPPFLAGS.intelfb"+="${CPPFLAGS.i915drmkms}"
 makeoptions	intelfb		"CWARNFLAGS.intelfb"+="${CWARNFLAGS.i915drmkms}"



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

2023-09-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Sep  4 21:31:58 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/linux: linux_pci.c

Log Message:
convert a KASSERT() into an if () panic() sequence to appease GCC 12.

OK riastradh@.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/external/bsd/drm2/linux/linux_pci.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/linux

2023-09-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Sep  4 21:31:58 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/linux: linux_pci.c

Log Message:
convert a KASSERT() into an if () panic() sequence to appease GCC 12.

OK riastradh@.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/external/bsd/drm2/linux/linux_pci.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/linux/linux_pci.c
diff -u src/sys/external/bsd/drm2/linux/linux_pci.c:1.25 src/sys/external/bsd/drm2/linux/linux_pci.c:1.26
--- src/sys/external/bsd/drm2/linux/linux_pci.c:1.25	Mon Oct 17 03:05:32 2022
+++ src/sys/external/bsd/drm2/linux/linux_pci.c	Mon Sep  4 21:31:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_pci.c,v 1.25 2022/10/17 03:05:32 mrg Exp $	*/
+/*	$NetBSD: linux_pci.c,v 1.26 2023/09/04 21:31:58 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.25 2022/10/17 03:05:32 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.26 2023/09/04 21:31:58 mrg Exp $");
 
 #if NACPICA > 0
 #include 
@@ -790,7 +790,8 @@ bus_addr_t
 pci_resource_start(struct pci_dev *pdev, unsigned i)
 {
 
-	KASSERT(i < PCI_NUM_RESOURCES);
+	if (i >= PCI_NUM_RESOURCES)
+		panic("resource %d >= max %d", i, PCI_NUM_RESOURCES);
 	return pdev->pd_resources[i].addr;
 }
 
@@ -798,7 +799,8 @@ bus_size_t
 pci_resource_len(struct pci_dev *pdev, unsigned i)
 {
 
-	KASSERT(i < PCI_NUM_RESOURCES);
+	if (i >= PCI_NUM_RESOURCES)
+		panic("resource %d >= max %d", i, PCI_NUM_RESOURCES);
 	return pdev->pd_resources[i].size;
 }
 
@@ -813,7 +815,8 @@ int
 pci_resource_flags(struct pci_dev *pdev, unsigned i)
 {
 
-	KASSERT(i < PCI_NUM_RESOURCES);
+	if (i >= PCI_NUM_RESOURCES)
+		panic("resource %d >= max %d", i, PCI_NUM_RESOURCES);
 	return pdev->pd_resources[i].flags;
 }
 



CVS commit: src/sys/external/bsd/acpica/dist

2023-09-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep  1 18:37:33 UTC 2023

Modified Files:
src/sys/external/bsd/acpica/dist/common: dmtables.c dmtbdump.c
dmtbinfo.c
src/sys/external/bsd/acpica/dist/compiler: aslanalyze.c aslcompile.c
aslcompiler.h aslcompiler.l aslerror.c aslfileio.c aslfiles.c
aslload.c asllookup.c aslmain.c aslopcodes.c aslopt.c asloptions.c
aslpredef.c aslprepkg.c aslsupport.l asltree.c aslutils.c
aslwalks.c aslxref.c dtcompile.c dtcompilerparser.y dtfield.c
dtparser.y dtsubtable.c dttable.c dtutils.c prparser.y prutils.c
src/sys/external/bsd/acpica/dist/debugger: dbcmds.c dbdisply.c dbexec.c
dbinput.c dbmethod.c dbnames.c dbtest.c dbutils.c
src/sys/external/bsd/acpica/dist/disassembler: dmbuffer.c dmcstyle.c
dmresrc.c dmresrcl.c dmresrcl2.c dmwalk.c
src/sys/external/bsd/acpica/dist/dispatcher: dscontrol.c dsopcode.c
dspkginit.c dsutils.c dswexec.c
src/sys/external/bsd/acpica/dist/events: evregion.c evrgnini.c
evxface.c
src/sys/external/bsd/acpica/dist/executer: exconfig.c exdebug.c
exdump.c exsystem.c
src/sys/external/bsd/acpica/dist/hardware: hwesleep.c hwregs.c
hwsleep.c hwxfsleep.c
src/sys/external/bsd/acpica/dist/include: acapps.h acdebug.h acdisasm.h
acexcep.h acglobal.h achware.h acinterp.h aclocal.h acmacros.h
acnamesp.h acoutput.h acpiosxf.h acpixf.h acresrc.h actables.h
actbl1.h actypes.h acutils.h amlresrc.h
src/sys/external/bsd/acpica/dist/include/platform: acgcc.h acnetbsd.h
src/sys/external/bsd/acpica/dist/namespace: nsaccess.c nsdump.c
nseval.c nsinit.c nsrepair2.c nsxfeval.c nsxfname.c
src/sys/external/bsd/acpica/dist/os_specific/service_layers:
oslinuxtbl.c
src/sys/external/bsd/acpica/dist/parser: psopcode.c psopinfo.c
src/sys/external/bsd/acpica/dist/resources: rsdump.c rsdumpinfo.c
rsutils.c rsxface.c
src/sys/external/bsd/acpica/dist/tables: tbdata.c tbfadt.c tbinstal.c
tbutils.c tbxface.c tbxfload.c tbxfroot.c
src/sys/external/bsd/acpica/dist/tools/acpidump: apfiles.c
src/sys/external/bsd/acpica/dist/tools/acpixtract: acpixtract.c
src/sys/external/bsd/acpica/dist/utilities: utcache.c utdebug.c
utdecode.c utdelete.c uteval.c utglobal.c utmisc.c utmutex.c
utnonansi.c utobject.c utosi.c utprint.c uttrack.c utuuid.c
utxferror.c

Log Message:
merge conflicts between 20230628 and 20221020


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/acpica/dist/common/dmtables.c
cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/acpica/dist/common/dmtbdump.c
cvs rdiff -u -r1.21 -r1.22 src/sys/external/bsd/acpica/dist/common/dmtbinfo.c
cvs rdiff -u -r1.16 -r1.17 \
src/sys/external/bsd/acpica/dist/compiler/aslanalyze.c \
src/sys/external/bsd/acpica/dist/compiler/asloptions.c \
src/sys/external/bsd/acpica/dist/compiler/aslpredef.c \
src/sys/external/bsd/acpica/dist/compiler/aslprepkg.c \
src/sys/external/bsd/acpica/dist/compiler/aslwalks.c
cvs rdiff -u -r1.22 -r1.23 \
src/sys/external/bsd/acpica/dist/compiler/aslcompile.c \
src/sys/external/bsd/acpica/dist/compiler/aslload.c \
src/sys/external/bsd/acpica/dist/compiler/aslxref.c
cvs rdiff -u -r1.20 -r1.21 \
src/sys/external/bsd/acpica/dist/compiler/aslcompiler.h \
src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l \
src/sys/external/bsd/acpica/dist/compiler/dtfield.c
cvs rdiff -u -r1.19 -r1.20 \
src/sys/external/bsd/acpica/dist/compiler/aslerror.c \
src/sys/external/bsd/acpica/dist/compiler/aslfiles.c \
src/sys/external/bsd/acpica/dist/compiler/dtcompile.c
cvs rdiff -u -r1.13 -r1.14 \
src/sys/external/bsd/acpica/dist/compiler/aslfileio.c
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/acpica/dist/compiler/asllookup.c \
src/sys/external/bsd/acpica/dist/compiler/aslopcodes.c \
src/sys/external/bsd/acpica/dist/compiler/prutils.c
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/acpica/dist/compiler/aslmain.c
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/acpica/dist/compiler/aslopt.c
cvs rdiff -u -r1.17 -r1.18 \
src/sys/external/bsd/acpica/dist/compiler/aslsupport.l \
src/sys/external/bsd/acpica/dist/compiler/asltree.c \
src/sys/external/bsd/acpica/dist/compiler/dtparser.y \
src/sys/external/bsd/acpica/dist/compiler/dttable.c \
src/sys/external/bsd/acpica/dist/compiler/prparser.y
cvs rdiff -u -r1.32 -r1.33 \
src/sys/external/bsd/acpica/dist/compiler/aslutils.c
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/acpica/dist/compiler/dtcompilerparser.y
cvs rdiff -u -r1.14 -r1.15 \
src/sys/external/bsd/acpica/dist/compiler/dtsubtable.c
cvs rdiff -u -r1.21 -r1.22 \

CVS commit: src/sys/external/bsd/acpica/dist

2023-09-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep  1 18:37:33 UTC 2023

Modified Files:
src/sys/external/bsd/acpica/dist/common: dmtables.c dmtbdump.c
dmtbinfo.c
src/sys/external/bsd/acpica/dist/compiler: aslanalyze.c aslcompile.c
aslcompiler.h aslcompiler.l aslerror.c aslfileio.c aslfiles.c
aslload.c asllookup.c aslmain.c aslopcodes.c aslopt.c asloptions.c
aslpredef.c aslprepkg.c aslsupport.l asltree.c aslutils.c
aslwalks.c aslxref.c dtcompile.c dtcompilerparser.y dtfield.c
dtparser.y dtsubtable.c dttable.c dtutils.c prparser.y prutils.c
src/sys/external/bsd/acpica/dist/debugger: dbcmds.c dbdisply.c dbexec.c
dbinput.c dbmethod.c dbnames.c dbtest.c dbutils.c
src/sys/external/bsd/acpica/dist/disassembler: dmbuffer.c dmcstyle.c
dmresrc.c dmresrcl.c dmresrcl2.c dmwalk.c
src/sys/external/bsd/acpica/dist/dispatcher: dscontrol.c dsopcode.c
dspkginit.c dsutils.c dswexec.c
src/sys/external/bsd/acpica/dist/events: evregion.c evrgnini.c
evxface.c
src/sys/external/bsd/acpica/dist/executer: exconfig.c exdebug.c
exdump.c exsystem.c
src/sys/external/bsd/acpica/dist/hardware: hwesleep.c hwregs.c
hwsleep.c hwxfsleep.c
src/sys/external/bsd/acpica/dist/include: acapps.h acdebug.h acdisasm.h
acexcep.h acglobal.h achware.h acinterp.h aclocal.h acmacros.h
acnamesp.h acoutput.h acpiosxf.h acpixf.h acresrc.h actables.h
actbl1.h actypes.h acutils.h amlresrc.h
src/sys/external/bsd/acpica/dist/include/platform: acgcc.h acnetbsd.h
src/sys/external/bsd/acpica/dist/namespace: nsaccess.c nsdump.c
nseval.c nsinit.c nsrepair2.c nsxfeval.c nsxfname.c
src/sys/external/bsd/acpica/dist/os_specific/service_layers:
oslinuxtbl.c
src/sys/external/bsd/acpica/dist/parser: psopcode.c psopinfo.c
src/sys/external/bsd/acpica/dist/resources: rsdump.c rsdumpinfo.c
rsutils.c rsxface.c
src/sys/external/bsd/acpica/dist/tables: tbdata.c tbfadt.c tbinstal.c
tbutils.c tbxface.c tbxfload.c tbxfroot.c
src/sys/external/bsd/acpica/dist/tools/acpidump: apfiles.c
src/sys/external/bsd/acpica/dist/tools/acpixtract: acpixtract.c
src/sys/external/bsd/acpica/dist/utilities: utcache.c utdebug.c
utdecode.c utdelete.c uteval.c utglobal.c utmisc.c utmutex.c
utnonansi.c utobject.c utosi.c utprint.c uttrack.c utuuid.c
utxferror.c

Log Message:
merge conflicts between 20230628 and 20221020


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/acpica/dist/common/dmtables.c
cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/acpica/dist/common/dmtbdump.c
cvs rdiff -u -r1.21 -r1.22 src/sys/external/bsd/acpica/dist/common/dmtbinfo.c
cvs rdiff -u -r1.16 -r1.17 \
src/sys/external/bsd/acpica/dist/compiler/aslanalyze.c \
src/sys/external/bsd/acpica/dist/compiler/asloptions.c \
src/sys/external/bsd/acpica/dist/compiler/aslpredef.c \
src/sys/external/bsd/acpica/dist/compiler/aslprepkg.c \
src/sys/external/bsd/acpica/dist/compiler/aslwalks.c
cvs rdiff -u -r1.22 -r1.23 \
src/sys/external/bsd/acpica/dist/compiler/aslcompile.c \
src/sys/external/bsd/acpica/dist/compiler/aslload.c \
src/sys/external/bsd/acpica/dist/compiler/aslxref.c
cvs rdiff -u -r1.20 -r1.21 \
src/sys/external/bsd/acpica/dist/compiler/aslcompiler.h \
src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l \
src/sys/external/bsd/acpica/dist/compiler/dtfield.c
cvs rdiff -u -r1.19 -r1.20 \
src/sys/external/bsd/acpica/dist/compiler/aslerror.c \
src/sys/external/bsd/acpica/dist/compiler/aslfiles.c \
src/sys/external/bsd/acpica/dist/compiler/dtcompile.c
cvs rdiff -u -r1.13 -r1.14 \
src/sys/external/bsd/acpica/dist/compiler/aslfileio.c
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/acpica/dist/compiler/asllookup.c \
src/sys/external/bsd/acpica/dist/compiler/aslopcodes.c \
src/sys/external/bsd/acpica/dist/compiler/prutils.c
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/acpica/dist/compiler/aslmain.c
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/acpica/dist/compiler/aslopt.c
cvs rdiff -u -r1.17 -r1.18 \
src/sys/external/bsd/acpica/dist/compiler/aslsupport.l \
src/sys/external/bsd/acpica/dist/compiler/asltree.c \
src/sys/external/bsd/acpica/dist/compiler/dtparser.y \
src/sys/external/bsd/acpica/dist/compiler/dttable.c \
src/sys/external/bsd/acpica/dist/compiler/prparser.y
cvs rdiff -u -r1.32 -r1.33 \
src/sys/external/bsd/acpica/dist/compiler/aslutils.c
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/acpica/dist/compiler/dtcompilerparser.y
cvs rdiff -u -r1.14 -r1.15 \
src/sys/external/bsd/acpica/dist/compiler/dtsubtable.c
cvs rdiff -u -r1.21 -r1.22 \

CVS commit: src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core

2023-08-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Aug 15 05:01:58 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core:
amdgpu_dc_stream.c

Log Message:
avoid a GCC 12 warning.

there's a 1-element long array and a loop conditional that tries to see
if indexes for it are not identical.  as these indexes will always both
be 0, the only valid index, the condition is always false.  GCC 12
triggers a strange warning on this code that can never run (see below),
so simply assert the array size is 1 and comment the rest.

amdgpu_dc_stream.c:470:55: error: array subscript [0, 0] is outside array 
bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
  470 | stream->writeback_info[j] = 
stream->writeback_info[i];


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.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/amd/display/dc/core

2023-08-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Aug 15 05:01:58 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core:
amdgpu_dc_stream.c

Log Message:
avoid a GCC 12 warning.

there's a 1-element long array and a loop conditional that tries to see
if indexes for it are not identical.  as these indexes will always both
be 0, the only valid index, the condition is always false.  GCC 12
triggers a strange warning on this code that can never run (see below),
so simply assert the array size is 1 and comment the rest.

amdgpu_dc_stream.c:470:55: error: array subscript [0, 0] is outside array 
bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
  470 | stream->writeback_info[j] = 
stream->writeback_info[i];


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.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/amd/display/dc/core/amdgpu_dc_stream.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c:1.2 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c:1.3
--- src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c:1.2	Sat Dec 18 23:45:02 2021
+++ src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c	Tue Aug 15 05:01:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_dc_stream.c,v 1.2 2021/12/18 23:45:02 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_dc_stream.c,v 1.3 2023/08/15 05:01:57 mrg Exp $	*/
 
 /*
  * Copyright 2012-15 Advanced Micro Devices, Inc.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_dc_stream.c,v 1.2 2021/12/18 23:45:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_dc_stream.c,v 1.3 2023/08/15 05:01:57 mrg Exp $");
 
 #include 
 #include 
@@ -465,9 +465,18 @@ bool dc_stream_remove_writeback(struct d
 	/* remove writeback info for disabled writeback pipes from stream */
 	for (i = 0, j = 0; i < stream->num_wb_info; i++) {
 		if (stream->writeback_info[i].wb_enabled) {
+#ifdef __NetBSD__
+			/*
+			 * XXXGCC12
+			 * The array is only 1 entry long, so i and j must
+			 * always be 0 here, so the below test fails.
+			 */
+			CTASSERT(ARRAY_SIZE(stream->writeback_info) == 1);
+#else
 			if (i != j)
 /* trim the array */
 stream->writeback_info[j] = stream->writeback_info[i];
+#endif
 			j++;
 		}
 	}



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

2023-08-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Aug 15 04:57:36 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/drm: drm_gem_cma_helper.c

Log Message:
avoid uninitialised variable usage in drm_gem_cma_create_internal().

in the case nothing has returned 'error', 'nsegs' and the dma info
are (potentially) uninitialised, so consider this an error.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.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/drm/drm_gem_cma_helper.c
diff -u src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c:1.14 src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c:1.15
--- src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c:1.14	Sat Jul  2 00:26:07 2022
+++ src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c	Tue Aug 15 04:57:36 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_gem_cma_helper.c,v 1.14 2022/07/02 00:26:07 riastradh Exp $ */
+/* $NetBSD: drm_gem_cma_helper.c,v 1.15 2023/08/15 04:57:36 mrg Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_gem_cma_helper.c,v 1.14 2022/07/02 00:26:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_gem_cma_helper.c,v 1.15 2023/08/15 04:57:36 mrg Exp $");
 
 #include 
 
@@ -44,7 +44,7 @@ drm_gem_cma_create_internal(struct drm_d
 struct sg_table *sgt)
 {
 	struct drm_gem_cma_object *obj;
-	int error, nsegs;
+	int error = EINVAL, nsegs;
 
 	obj = kmem_zalloc(sizeof(*obj), KM_SLEEP);
 	obj->dmat = ddev->dmat;



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

2023-08-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Aug 15 04:57:36 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/drm: drm_gem_cma_helper.c

Log Message:
avoid uninitialised variable usage in drm_gem_cma_create_internal().

in the case nothing has returned 'error', 'nsegs' and the dma info
are (potentially) uninitialised, so consider this an error.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/drm/drm_gem_cma_helper.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/i915

2023-08-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Aug  8 06:59:41 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915: i915_gem.h

Log Message:
nix the NetBSD specific GEM_BUG_ON().

avoids GCC 12 warnings, and matches upstream closer.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.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/dist/drm/i915/i915_gem.h
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.h:1.7 src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.h:1.8
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.h:1.7	Mon Dec 20 19:54:07 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.h	Tue Aug  8 06:59:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem.h,v 1.7 2021/12/20 19:54:07 riastradh Exp $	*/
+/*	$NetBSD: i915_gem.h,v 1.8 2023/08/08 06:59:40 mrg Exp $	*/
 
 /*
  * Copyright © 2016 Intel Corporation
@@ -41,13 +41,6 @@ struct drm_i915_private;
 
 #define GEM_SHOW_DEBUG() drm_debug_enabled(DRM_UT_DRIVER)
 
-#ifdef __NetBSD__
-#ifdef DIAGNOSTIC
-#define	GEM_BUG_ON(condition)	KASSERT(!(condition))
-#else
-#define	GEM_BUG_ON(condition)	BUILD_BUG_ON_INVALID(condition)
-#endif
-#else
 #define GEM_BUG_ON(condition) do { if (unlikely((condition))) {	\
 		GEM_TRACE_ERR("%s:%d GEM_BUG_ON(%s)\n", \
 			  __func__, __LINE__, __stringify(condition)); \
@@ -55,7 +48,6 @@ struct drm_i915_private;
 		BUG(); \
 		} \
 	} while(0)
-#endif
 #define GEM_WARN_ON(expr) WARN_ON(expr)
 
 #define GEM_DEBUG_DECL(var) var



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

2023-08-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Aug  8 06:59:41 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915: i915_gem.h

Log Message:
nix the NetBSD specific GEM_BUG_ON().

avoids GCC 12 warnings, and matches upstream closer.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.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

2023-08-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Aug  8 06:58:20 UTC 2023

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

Log Message:
comment a function that has a clear overbounds read but it isn't used.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/external/bsd/drm2/dist/drm/drm_dp_helper.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/drm_dp_helper.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_dp_helper.c:1.16 src/sys/external/bsd/drm2/dist/drm/drm_dp_helper.c:1.17
--- src/sys/external/bsd/drm2/dist/drm/drm_dp_helper.c:1.16	Sun Dec 19 12:41:54 2021
+++ src/sys/external/bsd/drm2/dist/drm/drm_dp_helper.c	Tue Aug  8 06:58:20 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_dp_helper.c,v 1.16 2021/12/19 12:41:54 riastradh Exp $	*/
+/*	$NetBSD: drm_dp_helper.c,v 1.17 2023/08/08 06:58:20 mrg Exp $	*/
 
 /*
  * Copyright © 2009 Keith Packard
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_dp_helper.c,v 1.16 2021/12/19 12:41:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_dp_helper.c,v 1.17 2023/08/08 06:58:20 mrg Exp $");
 
 #include 
 #include 
@@ -128,6 +128,13 @@ u8 drm_dp_get_adjust_request_pre_emphasi
 }
 EXPORT_SYMBOL(drm_dp_get_adjust_request_pre_emphasis);
 
+#ifndef __NetBSD__
+/*
+ * XXXGCC12
+ * this unused function is bad.  DP_LINK_STATUS_SIZE is 6, and
+ * DP_ADJUST_REQUEST_POST_CURSOR2 triggers an offset of 10 into link_status[].
+ * fortunately, it is not used.
+ */
 u8 drm_dp_get_adjust_request_post_cursor(const u8 link_status[DP_LINK_STATUS_SIZE],
 	 unsigned int lane)
 {
@@ -137,6 +144,7 @@ u8 drm_dp_get_adjust_request_post_cursor
 	return (value >> (lane << 1)) & 0x3;
 }
 EXPORT_SYMBOL(drm_dp_get_adjust_request_post_cursor);
+#endif
 
 void drm_dp_link_train_clock_recovery_delay(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
 {



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

2023-08-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Aug  8 06:58:20 UTC 2023

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

Log Message:
comment a function that has a clear overbounds read but it isn't used.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/external/bsd/drm2/dist/drm/drm_dp_helper.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/radeon

2023-08-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug  7 16:35:06 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/radeon: radeon_pci.c

Log Message:
radeon: Suspend ioctls while device is suspended.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/external/bsd/drm2/radeon/radeon_pci.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/radeon

2023-08-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug  7 16:35:06 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/radeon: radeon_pci.c

Log Message:
radeon: Suspend ioctls while device is suspended.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/external/bsd/drm2/radeon/radeon_pci.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/radeon/radeon_pci.c
diff -u src/sys/external/bsd/drm2/radeon/radeon_pci.c:1.23 src/sys/external/bsd/drm2/radeon/radeon_pci.c:1.24
--- src/sys/external/bsd/drm2/radeon/radeon_pci.c:1.23	Tue Mar  7 20:23:00 2023
+++ src/sys/external/bsd/drm2/radeon/radeon_pci.c	Mon Aug  7 16:35:06 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeon_pci.c,v 1.23 2023/03/07 20:23:00 mrg Exp $	*/
+/*	$NetBSD: radeon_pci.c,v 1.24 2023/08/07 16:35:06 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeon_pci.c,v 1.23 2023/03/07 20:23:00 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_pci.c,v 1.24 2023/08/07 16:35:06 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "genfb.h"
@@ -72,6 +72,7 @@ __KERNEL_RCSID(0, "$NetBSD: radeon_pci.c
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #if NGENFB > 0
@@ -366,6 +367,8 @@ radeon_do_suspend(device_t self, const p
 	int ret;
 	bool is_console = true; /* XXX */
 
+	drm_suspend_ioctl(dev);
+
 	ret = radeon_suspend_kms(dev, true, is_console, false);
 	if (ret)
 		return false;
@@ -383,9 +386,10 @@ radeon_do_resume(device_t self, const pm
 
 	ret = radeon_resume_kms(dev, true, is_console);
 	if (ret)
-		return false;
+		goto out;
 
-	return true;
+out:	drm_resume_ioctl(dev);
+	return ret == 0;
 }
 
 static void



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

2023-08-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug  7 16:34:57 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/nouveau: nouveau_pci.c

Log Message:
nouveau: Suspend ioctls while device is suspended.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/external/bsd/drm2/nouveau/nouveau_pci.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/nouveau/nouveau_pci.c
diff -u src/sys/external/bsd/drm2/nouveau/nouveau_pci.c:1.37 src/sys/external/bsd/drm2/nouveau/nouveau_pci.c:1.38
--- src/sys/external/bsd/drm2/nouveau/nouveau_pci.c:1.37	Wed Mar  1 08:42:34 2023
+++ src/sys/external/bsd/drm2/nouveau/nouveau_pci.c	Mon Aug  7 16:34:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_pci.c,v 1.37 2023/03/01 08:42:34 riastradh Exp $	*/
+/*	$NetBSD: nouveau_pci.c,v 1.38 2023/08/07 16:34:57 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_pci.c,v 1.37 2023/03/01 08:42:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_pci.c,v 1.38 2023/08/07 16:34:57 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "genfb.h"
@@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_pci.
 #include 
 #endif
 
+#include 
 #include 
 
 #include 
@@ -316,16 +317,31 @@ static bool
 nouveau_pci_suspend(device_t self, const pmf_qual_t *qual __unused)
 {
 	struct nouveau_pci_softc *const sc = device_private(self);
+	struct drm_device *const dev = sc->sc_drm_dev;
+	int ret;
+
+	drm_suspend_ioctl(dev);
+
+	ret = nouveau_pmops_suspend(dev);
+	if (ret)
+		return false;
 
-	return nouveau_pmops_suspend(sc->sc_drm_dev) == 0;
+	return true;
 }
 
 static bool
 nouveau_pci_resume(device_t self, const pmf_qual_t *qual)
 {
 	struct nouveau_pci_softc *const sc = device_private(self);
+	struct drm_device *const dev = sc->sc_drm_dev;
+	int ret;
+
+	ret = nouveau_pmops_resume(sc->sc_drm_dev);
+	if (ret)
+		goto out;
 
-	return nouveau_pmops_resume(sc->sc_drm_dev) == 0;
+out:	drm_resume_ioctl(dev);
+	return ret == 0;
 }
 
 static void



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

2023-08-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug  7 16:34:57 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/nouveau: nouveau_pci.c

Log Message:
nouveau: Suspend ioctls while device is suspended.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/external/bsd/drm2/nouveau/nouveau_pci.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/amdgpu

2023-08-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug  7 16:34:47 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/amdgpu: amdgpu_pci.c

Log Message:
amdgpu: Suspend ioctls while device is suspended.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/drm2/amdgpu/amdgpu_pci.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/amdgpu/amdgpu_pci.c
diff -u src/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c:1.11 src/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c:1.12
--- src/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c:1.11	Mon Jul 18 23:34:02 2022
+++ src/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c	Mon Aug  7 16:34:47 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_pci.c,v 1.11 2022/07/18 23:34:02 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_pci.c,v 1.12 2023/08/07 16:34:47 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_pci.c,v 1.11 2022/07/18 23:34:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_pci.c,v 1.12 2023/08/07 16:34:47 riastradh Exp $");
 
 #include 
 #include 
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdgpu_pci.c
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -260,6 +261,8 @@ amdgpu_do_suspend(device_t self, const p
 	struct drm_device *const dev = sc->sc_drm_dev;
 	int ret;
 
+	drm_suspend_ioctl(dev);
+
 	ret = amdgpu_device_suspend(dev, /*fbcon*/true);
 	if (ret)
 		return false;
@@ -276,9 +279,10 @@ amdgpu_do_resume(device_t self, const pm
 
 	ret = amdgpu_device_resume(dev, /*fbcon*/true);
 	if (ret)
-		return false;
+		goto out;
 
-	return true;
+out:	drm_resume_ioctl(dev);
+	return ret == 0;
 }
 
 static void



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

2023-08-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug  7 16:34:47 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/amdgpu: amdgpu_pci.c

Log Message:
amdgpu: Suspend ioctls while device is suspended.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/drm2/amdgpu/amdgpu_pci.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/compiler_rt/dist/lib/sanitizer_common

2023-08-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug  2 10:31:46 UTC 2023

Modified Files:
src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common:
sanitizer_interceptors_ioctl_netbsd.inc
sanitizer_platform_limits_netbsd.cc
sanitizer_platform_limits_netbsd.h

Log Message:
Use the new struct and ioctl names for the compat functions (thanks Ryo)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
cvs rdiff -u -r1.8 -r1.9 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cc
cvs rdiff -u -r1.6 -r1.7 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_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/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
diff -u src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.5 src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.6
--- src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.5	Mon Dec 26 17:22:22 2022
+++ src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc	Wed Aug  2 06:31:46 2023
@@ -452,7 +452,7 @@ static void ioctl_table_fill() {
   _(USB_SETDEBUG, READ, sizeof(int));
   _(USB_DISCOVER, NONE, 0);
   _(USB_DEVICEINFO, READWRITE, struct_usb_device_info_sz);
-  _(USB_DEVICEINFO_OLD, READWRITE, struct_usb_device_info_old_sz);
+  _(USB_DEVICEINFO_30, READWRITE, struct_usb_device_info30_sz);
   _(USB_DEVICESTATS, WRITE, struct_usb_device_stats_sz);
   _(USB_GET_REPORT_DESC, WRITE, struct_usb_ctl_report_desc_sz);
   _(USB_SET_IMMED, READ, sizeof(int));
@@ -472,7 +472,7 @@ static void ioctl_table_fill() {
   _(USB_GET_STRING_DESC, READWRITE, struct_usb_string_desc_sz);
   _(USB_DO_REQUEST, READWRITE, struct_usb_ctl_request_sz);
   _(USB_GET_DEVICEINFO, WRITE, struct_usb_device_info_sz);
-  _(USB_GET_DEVICEINFO_OLD, WRITE, struct_usb_device_info_old_sz);
+  _(USB_GET_DEVICEINFO_30, WRITE, struct_usb_device_info30_sz);
   _(USB_SET_SHORT_XFER, READ, sizeof(int));
   _(USB_SET_TIMEOUT, READ, sizeof(int));
   _(USB_SET_BULK_RA, READ, sizeof(int));
@@ -675,7 +675,7 @@ static void ioctl_table_fill() {
   _(BIOCGETIF, WRITE, struct_ifreq_sz);
   _(BIOCSETIF, READ, struct_ifreq_sz);
   _(BIOCGSTATS, WRITE, struct_bpf_stat_sz);
-  _(BIOCGSTATSOLD, WRITE, struct_bpf_stat_old_sz);
+  _(BIOCGSTATS_30, WRITE, struct_bpf_stat30_sz);
   _(BIOCIMMEDIATE, READ, sizeof(unsigned int));
   _(BIOCVERSION, WRITE, struct_bpf_version_sz);
   _(BIOCSTCPF, READ, struct_bpf_program_sz);

Index: src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cc
diff -u src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cc:1.8 src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cc:1.9
--- src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cc:1.8	Mon Dec 26 17:22:22 2022
+++ src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cc	Wed Aug  2 06:31:46 2023
@@ -549,7 +549,7 @@ unsigned struct_blue_interface_sz = size
 unsigned struct_blue_stats_sz = sizeof(blue_stats);
 unsigned struct_bpf_dltlist_sz = sizeof(bpf_dltlist);
 unsigned struct_bpf_program_sz = sizeof(bpf_program);
-unsigned struct_bpf_stat_old_sz = sizeof(bpf_stat_old);
+unsigned struct_bpf_stat30_sz = sizeof(bpf_stat30);
 unsigned struct_bpf_stat_sz = sizeof(bpf_stat);
 unsigned struct_bpf_version_sz = sizeof(bpf_version);
 unsigned struct_btreq_sz = sizeof(btreq);
@@ -856,7 +856,7 @@ unsigned struct_spi_ioctl_transfer_sz = 
 unsigned struct_autofs_daemon_request_sz = sizeof(autofs_daemon_request);
 unsigned struct_autofs_daemon_done_sz = sizeof(autofs_daemon_done);
 unsigned struct_sctp_connectx_addrs_sz = sizeof(sctp_connectx_addrs);
-unsigned struct_usb_device_info_old_sz = sizeof(usb_device_info_old);
+unsigned struct_usb_device_info30_sz = sizeof(usb_device_info30);
 unsigned struct_usb_device_info_sz = sizeof(usb_device_info);
 unsigned struct_usb_device_stats_sz = sizeof(usb_device_stats);
 unsigned struct_usb_endpoint_desc_sz = sizeof(usb_endpoint_desc);
@@ -1419,7 +1419,7 @@ unsigned IOCTL_USB_REQUEST = USB_REQUEST
 unsigned IOCTL_USB_SETDEBUG = USB_SETDEBUG;
 unsigned IOCTL_USB_DISCOVER = USB_DISCOVER;
 unsigned IOCTL_USB_DEVICEINFO = USB_DEVICEINFO;
-unsigned IOCTL_USB_DEVICEINFO_OLD = USB_DEVICEINFO_OLD;
+unsigned IOCTL_USB_DEVICEINFO_30 = USB_DEVICEINFO_30;
 unsigned IOCTL_USB_DEVICESTATS = USB_DEVICESTATS;
 unsigned IOCTL_USB_GET_REPORT_DESC = 

CVS commit: src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common

2023-08-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug  2 10:31:46 UTC 2023

Modified Files:
src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common:
sanitizer_interceptors_ioctl_netbsd.inc
sanitizer_platform_limits_netbsd.cc
sanitizer_platform_limits_netbsd.h

Log Message:
Use the new struct and ioctl names for the compat functions (thanks Ryo)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
cvs rdiff -u -r1.8 -r1.9 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cc
cvs rdiff -u -r1.6 -r1.7 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_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/linux

2023-07-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jul 29 23:50:03 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/linux: linux_ww_mutex.c

Log Message:
drm/linux_ww_mutex: Fix ww acquire context ordering.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/linux/linux_ww_mutex.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/linux/linux_ww_mutex.c
diff -u src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.15 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.16
--- src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.15	Sat Jul 29 22:43:56 2023
+++ src/sys/external/bsd/drm2/linux/linux_ww_mutex.c	Sat Jul 29 23:50:03 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_ww_mutex.c,v 1.15 2023/07/29 22:43:56 riastradh Exp $	*/
+/*	$NetBSD: linux_ww_mutex.c,v 1.16 2023/07/29 23:50:03 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.15 2023/07/29 22:43:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.16 2023/07/29 23:50:03 riastradh Exp $");
 
 #include 
 #include 
@@ -62,7 +62,7 @@ ww_acquire_ctx_compare(void *cookie __un
 	if (ctx_a->wwx_ticket < ctx_b->wwx_ticket)
 		return -1;
 	if (ctx_a->wwx_ticket > ctx_b->wwx_ticket)
-		return -1;
+		return +1;
 	return 0;
 }
 
@@ -76,7 +76,7 @@ ww_acquire_ctx_compare_key(void *cookie 
 	if (ctx->wwx_ticket < ticket)
 		return -1;
 	if (ctx->wwx_ticket > ticket)
-		return -1;
+		return +1;
 	return 0;
 }
 



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

2023-07-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jul 29 23:50:03 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/linux: linux_ww_mutex.c

Log Message:
drm/linux_ww_mutex: Fix ww acquire context ordering.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/linux/linux_ww_mutex.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/linux

2023-07-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jul 29 22:43:56 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/linux: linux_ww_mutex.c

Log Message:
drm/linux_ww_mutex: Fix wait loops.

If cv_wait_sig returns because a signal is delivered, we may
nonetheless have been granted the lock.  It is harmless for us to
ignore this fact in three of the four paths, but in
ww_mutex_state_wait_sig, we may now have ownership of the lock and
MUST NOT return failure because the caller MUST release the lock
before destroying the ww_acquire_ctx.

While here, restructure the other three loops for clarity, so they
match the structure of the fourth and so they have a little less
impenetrable negation.

PR kern/57537

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/linux/linux_ww_mutex.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/linux/linux_ww_mutex.c
diff -u src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.14 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.15
--- src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.14	Fri Mar 18 23:33:41 2022
+++ src/sys/external/bsd/drm2/linux/linux_ww_mutex.c	Sat Jul 29 22:43:56 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_ww_mutex.c,v 1.14 2022/03/18 23:33:41 riastradh Exp $	*/
+/*	$NetBSD: linux_ww_mutex.c,v 1.15 2023/07/29 22:43:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.14 2022/03/18 23:33:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.15 2023/07/29 22:43:56 riastradh Exp $");
 
 #include 
 #include 
@@ -286,8 +286,14 @@ ww_mutex_state_wait(struct ww_mutex *mut
 
 	KASSERT(mutex_owned(>wwm_lock));
 	KASSERT(mutex->wwm_state == state);
-	do cv_wait(>wwm_cv, >wwm_lock);
-	while (mutex->wwm_state == state);
+
+	for (;;) {
+		cv_wait(>wwm_cv, >wwm_lock);
+		if (mutex->wwm_state != state)
+			break;
+	}
+
+	KASSERT(mutex->wwm_state != state);
 }
 
 /*
@@ -310,18 +316,26 @@ ww_mutex_state_wait_sig(struct ww_mutex 
 
 	KASSERT(mutex_owned(>wwm_lock));
 	KASSERT(mutex->wwm_state == state);
-	do {
+
+	for (;;) {
 		/* XXX errno NetBSD->Linux */
 		ret = -cv_wait_sig(>wwm_cv, >wwm_lock);
+		if (mutex->wwm_state != state) {
+			ret = 0;
+			break;
+		}
 		if (ret) {
 			KASSERTMSG((ret == -EINTR || ret == -ERESTART),
 			"ret=%d", ret);
 			ret = -EINTR;
 			break;
 		}
-	} while (mutex->wwm_state == state);
+	}
 
 	KASSERTMSG((ret == 0 || ret == -EINTR), "ret=%d", ret);
+	KASSERTMSG(ret != 0 || mutex->wwm_state != state,
+	"ret=%d mutex=%p mutex->wwm_state=%d state=%d",
+	ret, mutex, mutex->wwm_state, state);
 	return ret;
 }
 
@@ -363,12 +377,18 @@ ww_mutex_lock_wait(struct ww_mutex *mute
 	"ticket number reused: %"PRId64" (%p) %"PRId64" (%p)",
 	ctx->wwx_ticket, ctx, collision->wwx_ticket, collision);
 
-	do cv_wait(>wwm_cv, >wwm_lock);
-	while (!(((mutex->wwm_state == WW_CTX) ||
-		(mutex->wwm_state == WW_WANTOWN)) &&
-		 (mutex->wwm_u.ctx == ctx)));
+	for (;;) {
+		cv_wait(>wwm_cv, >wwm_lock);
+		if ((mutex->wwm_state == WW_CTX ||
+			mutex->wwm_state == WW_WANTOWN) &&
+		mutex->wwm_u.ctx == ctx)
+			break;
+	}
 
 	rb_tree_remove_node(>wwm_waiters, ctx);
+
+	KASSERT(mutex->wwm_state == WW_CTX || mutex->wwm_state == WW_WANTOWN);
+	KASSERT(mutex->wwm_u.ctx == ctx);
 }
 
 /*
@@ -411,21 +431,29 @@ ww_mutex_lock_wait_sig(struct ww_mutex *
 	"ticket number reused: %"PRId64" (%p) %"PRId64" (%p)",
 	ctx->wwx_ticket, ctx, collision->wwx_ticket, collision);
 
-	do {
+	for (;;) {
 		/* XXX errno NetBSD->Linux */
 		ret = -cv_wait_sig(>wwm_cv, >wwm_lock);
+		if ((mutex->wwm_state == WW_CTX ||
+			mutex->wwm_state == WW_WANTOWN) &&
+		mutex->wwm_u.ctx == ctx) {
+			ret = 0;
+			break;
+		}
 		if (ret) {
 			KASSERTMSG((ret == -EINTR || ret == -ERESTART),
 			"ret=%d", ret);
 			ret = -EINTR;
-			goto out;
+			break;
 		}
-	} while (!(((mutex->wwm_state == WW_CTX) ||
-		(mutex->wwm_state == WW_WANTOWN)) &&
-		(mutex->wwm_u.ctx == ctx)));
+	}
+
+	rb_tree_remove_node(>wwm_waiters, ctx);
 
-out:	rb_tree_remove_node(>wwm_waiters, ctx);
 	KASSERTMSG((ret == 0 || ret == -EINTR), "ret=%d", ret);
+	KASSERT(ret != 0 ||
+	mutex->wwm_state == WW_CTX || mutex->wwm_state == WW_WANTOWN);
+	KASSERT(ret != 0 || mutex->wwm_u.ctx == ctx);
 	return ret;
 }
 



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

2023-07-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jul 29 22:43:56 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/linux: linux_ww_mutex.c

Log Message:
drm/linux_ww_mutex: Fix wait loops.

If cv_wait_sig returns because a signal is delivered, we may
nonetheless have been granted the lock.  It is harmless for us to
ignore this fact in three of the four paths, but in
ww_mutex_state_wait_sig, we may now have ownership of the lock and
MUST NOT return failure because the caller MUST release the lock
before destroying the ww_acquire_ctx.

While here, restructure the other three loops for clarity, so they
match the structure of the fourth and so they have a little less
impenetrable negation.

PR kern/57537

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/linux/linux_ww_mutex.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/amd/display/dc

2023-07-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Jul 20 21:48:49 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs:
amdgpu_dcn_calcs.c
src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn20:
amdgpu_dcn20_resource.c

Log Message:
amdgpu: Mark float-dependent variables volatile.

This way they are computed -- using FP instructions -- before
DC_FP_END, after which point FP instructions will trap or behave
unpredictably.

This is a workaround, not a proper solution -- really, the
DC_FP_START/END calls should happen in a separate compilation unit
built without -mhard-float or whatever, but that's a lot more work to
make happen for now.

PR kern/57059

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs/amdgpu_dcn_calcs.c
cvs rdiff -u -r1.4 -r1.5 \

src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn20/amdgpu_dcn20_resource.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/amd/display/dc/calcs/amdgpu_dcn_calcs.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs/amdgpu_dcn_calcs.c:1.3 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs/amdgpu_dcn_calcs.c:1.4
--- src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs/amdgpu_dcn_calcs.c:1.3	Sun Dec 19 11:35:07 2021
+++ src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs/amdgpu_dcn_calcs.c	Thu Jul 20 21:48:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_dcn_calcs.c,v 1.3 2021/12/19 11:35:07 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_dcn_calcs.c,v 1.4 2023/07/20 21:48:49 riastradh Exp $	*/
 
 /*
  * Copyright 2017 Advanced Micro Devices, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_dcn_calcs.c,v 1.3 2021/12/19 11:35:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_dcn_calcs.c,v 1.4 2023/07/20 21:48:49 riastradh Exp $");
 
 #include "dm_services.h"
 #include "dc.h"
@@ -626,7 +626,7 @@ static void calc_wm_sets_and_perf_params
 
 static bool dcn_bw_apply_registry_override(struct dc *dc)
 {
-	bool updated = false;
+	volatile bool updated = false;
 
 	DC_FP_START();
 	if ((int)(dc->dcn_soc->sr_exit_time * 1000) != dc->debug.sr_exit_time_ns
@@ -733,7 +733,7 @@ bool dcn_validate_bandwidth(
 	struct dcn_bw_internal_vars *v = >dcn_bw_vars;
 	int i, input_idx, k;
 	int vesa_sync_start, asic_blank_end, asic_blank_start;
-	bool bw_limit_pass;
+	volatile bool bw_limit_pass;
 	float bw_limit;
 
 	PERFORMANCE_TRACE_START();
@@ -1502,7 +1502,7 @@ void dcn_bw_notify_pplib_of_wm_ranges(st
 {
 	struct pp_smu_funcs_rv *pp = NULL;
 	struct pp_smu_wm_range_sets ranges = {0};
-	int min_fclk_khz, min_dcfclk_khz, socclk_khz;
+	volatile int min_fclk_khz, min_dcfclk_khz, socclk_khz;
 	const int overdrive = 500; /* 5 GHz to cover Overdrive */
 
 	if (dc->res_pool->pp_smu)

Index: src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn20/amdgpu_dcn20_resource.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn20/amdgpu_dcn20_resource.c:1.4 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn20/amdgpu_dcn20_resource.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn20/amdgpu_dcn20_resource.c:1.4	Sun Dec 19 11:59:31 2021
+++ src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn20/amdgpu_dcn20_resource.c	Thu Jul 20 21:48:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_dcn20_resource.c,v 1.4 2021/12/19 11:59:31 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_dcn20_resource.c,v 1.5 2023/07/20 21:48:49 riastradh Exp $	*/
 
 /*
 * Copyright 2016 Advanced Micro Devices, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_dcn20_resource.c,v 1.4 2021/12/19 11:59:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_dcn20_resource.c,v 1.5 2023/07/20 21:48:49 riastradh Exp $");
 
 #include 
 
@@ -2932,7 +2932,7 @@ validate_out:
 bool dcn20_validate_bandwidth(struct dc *dc, struct dc_state *context,
 		bool fast_validate)
 {
-	bool voltage_supported = false;
+	volatile bool voltage_supported = false;
 	bool full_pstate_supported = false;
 	bool dummy_pstate_supported = false;
 	double p_state_latency_us;



CVS commit: src/sys/external/bsd/drm2/dist/drm/amd/display/dc

2023-07-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Jul 20 21:48:49 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs:
amdgpu_dcn_calcs.c
src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn20:
amdgpu_dcn20_resource.c

Log Message:
amdgpu: Mark float-dependent variables volatile.

This way they are computed -- using FP instructions -- before
DC_FP_END, after which point FP instructions will trap or behave
unpredictably.

This is a workaround, not a proper solution -- really, the
DC_FP_START/END calls should happen in a separate compilation unit
built without -mhard-float or whatever, but that's a lot more work to
make happen for now.

PR kern/57059

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs/amdgpu_dcn_calcs.c
cvs rdiff -u -r1.4 -r1.5 \

src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn20/amdgpu_dcn20_resource.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/amd/amdgpu

2023-07-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jul 20 18:02:45 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_fence.c

Log Message:
avoid calling drm_sched_fini() for AMDGPU_RING_TYPE_KIQ rings.

drm_sched_init() is not called for these rings, and we'd panic trying
to mutex_destroy() a mutex that wasn't initialised.

this seems like a general bug, not a bug in netbsd port.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.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/amd/amdgpu/amdgpu_fence.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c:1.10 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c:1.11
--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c:1.10	Sun Dec 19 12:02:39 2021
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c	Thu Jul 20 18:02:45 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_fence.c,v 1.10 2021/12/19 12:02:39 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_fence.c,v 1.11 2023/07/20 18:02:45 mrg Exp $	*/
 
 /*
  * Copyright 2009 Jerome Glisse.
@@ -31,7 +31,7 @@
  *Dave Airlie
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_fence.c,v 1.10 2021/12/19 12:02:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_fence.c,v 1.11 2023/07/20 18:02:45 mrg Exp $");
 
 #include 
 #include 
@@ -541,7 +541,9 @@ void amdgpu_fence_driver_fini(struct amd
 		}
 		amdgpu_irq_put(adev, ring->fence_drv.irq_src,
 			   ring->fence_drv.irq_type);
-		drm_sched_fini(>sched);
+		if (ring->funcs->type != AMDGPU_RING_TYPE_KIQ) {
+			drm_sched_fini(>sched);
+		}
 		del_timer_sync(>fence_drv.fallback_timer);
 		for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j)
 			dma_fence_put(ring->fence_drv.fences[j]);



CVS commit: src/sys/external/bsd/drm2/dist/drm/amd/amdgpu

2023-07-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jul 20 18:02:45 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_fence.c

Log Message:
avoid calling drm_sched_fini() for AMDGPU_RING_TYPE_KIQ rings.

drm_sched_init() is not called for these rings, and we'd panic trying
to mutex_destroy() a mutex that wasn't initialised.

this seems like a general bug, not a bug in netbsd port.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.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

2023-07-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul 11 10:42:36 UTC 2023

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

Log Message:
linux/idr.h: Need  for kmutex_t.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.10 src/sys/external/bsd/drm2/include/linux/idr.h:1.11
--- src/sys/external/bsd/drm2/include/linux/idr.h:1.10	Tue Oct 25 23:36:32 2022
+++ src/sys/external/bsd/drm2/include/linux/idr.h	Tue Jul 11 10:42:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: idr.h,v 1.10 2022/10/25 23:36:32 riastradh Exp $	*/
+/*	$NetBSD: idr.h,v 1.11 2023/07/11 10:42:36 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -33,6 +33,7 @@
 #define _LINUX_IDR_H_
 
 #include 
+#include 
 #include 
 
 #include 



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

2023-07-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul 11 10:42:36 UTC 2023

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

Log Message:
linux/idr.h: Need  for kmutex_t.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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/i915/gt

2023-07-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jul  9 20:24:06 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gt: intel_ggtt.c

Log Message:
i915: Fail gracefully, don't panic, with unsupported ggtt views.

Workaround for part of PR kern/56648.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_ggtt.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/i915/gt/intel_ggtt.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_ggtt.c:1.15 src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_ggtt.c:1.16
--- src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_ggtt.c:1.15	Sun Dec 19 12:35:13 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_ggtt.c	Sun Jul  9 20:24:06 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_ggtt.c,v 1.15 2021/12/19 12:35:13 riastradh Exp $	*/
+/*	$NetBSD: intel_ggtt.c,v 1.16 2023/07/09 20:24:06 riastradh Exp $	*/
 
 // SPDX-License-Identifier: MIT
 /*
@@ -6,7 +6,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intel_ggtt.c,v 1.15 2021/12/19 12:35:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_ggtt.c,v 1.16 2023/07/09 20:24:06 riastradh Exp $");
 
 #include 
 
@@ -1772,17 +1772,23 @@ i915_get_ggtt_vma_pages(struct i915_vma 
 		vma->pages = vma->obj->mm.pages;
 		return 0;
 
-#ifndef __NetBSD__
 	case I915_GGTT_VIEW_ROTATED:
+#ifdef __NetBSD__
+		vma->pages = ERR_PTR(-ENODEV);
+#else
 		vma->pages =
 			intel_rotate_pages(>ggtt_view.rotated, vma->obj);
+#endif
 		break;
 
 	case I915_GGTT_VIEW_REMAPPED:
+#ifdef __NetBSD__
+		vma->pages = ERR_PTR(-ENODEV);
+#else
 		vma->pages =
 			intel_remap_pages(>ggtt_view.remapped, vma->obj);
-		break;
 #endif
+		break;
 
 	case I915_GGTT_VIEW_PARTIAL:
 		vma->pages = intel_partial_pages(>ggtt_view, vma->obj);



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gt

2023-07-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jul  9 20:24:06 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gt: intel_ggtt.c

Log Message:
i915: Fail gracefully, don't panic, with unsupported ggtt views.

Workaround for part of PR kern/56648.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_ggtt.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/ipf/netinet

2023-06-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jun 24 05:16:15 UTC 2023

Modified Files:
src/sys/external/bsd/ipf/netinet: fil.c ip_fil_netbsd.c

Log Message:
Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/external/bsd/ipf/netinet/fil.c
cvs rdiff -u -r1.37 -r1.38 src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.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/ipf/netinet/fil.c
diff -u src/sys/external/bsd/ipf/netinet/fil.c:1.36 src/sys/external/bsd/ipf/netinet/fil.c:1.37
--- src/sys/external/bsd/ipf/netinet/fil.c:1.36	Fri Feb  3 19:01:08 2023
+++ src/sys/external/bsd/ipf/netinet/fil.c	Sat Jun 24 05:16:15 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fil.c,v 1.36 2023/02/03 19:01:08 christos Exp $	*/
+/*	$NetBSD: fil.c,v 1.37 2023/06/24 05:16:15 msaitoh Exp $	*/
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -141,7 +141,7 @@ extern struct timeout ipf_slowtimer_ch;
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.36 2023/02/03 19:01:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.37 2023/06/24 05:16:15 msaitoh Exp $");
 #else
 static const char sccsid[] = "@(#)fil.c	1.36 6/5/96 (C) 1993-2000 Darren Reed";
 static const char rcsid[] = "@(#)Id: fil.c,v 1.1.1.2 2012/07/22 13:45:07 darrenr Exp $";
@@ -5943,7 +5943,7 @@ ipf_movequeue(u_long ticks, ipftqent_t *
 
 /*  */
 /* Function:ipf_updateipid  */
-/* Returns: int - 0 == success, -1 == error (packet should be droppped) */
+/* Returns: int - 0 == success, -1 == error (packet should be dropped)  */
 /* Parameters:  fin(I) - pointer to packet information  */
 /*  */
 /* When we are doing NAT, change the IP of every packet to represent a  */

Index: src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c
diff -u src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.37 src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.38
--- src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.37	Mon Mar 28 12:33:21 2022
+++ src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c	Sat Jun 24 05:16:15 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_fil_netbsd.c,v 1.37 2022/03/28 12:33:21 riastradh Exp $	*/
+/*	$NetBSD: ip_fil_netbsd.c,v 1.38 2023/06/24 05:16:15 msaitoh Exp $	*/
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -8,7 +8,7 @@
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.37 2022/03/28 12:33:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.38 2023/06/24 05:16:15 msaitoh Exp $");
 #else
 static const char sccsid[] = "@(#)ip_fil.c	2.41 6/5/96 (C) 1993-2000 Darren Reed";
 static const char rcsid[] = "@(#)Id: ip_fil_netbsd.c,v 1.1.1.2 2012/07/22 13:45:17 darrenr Exp";
@@ -1680,8 +1680,8 @@ ipf_newisn(fr_info_t *fin)
 
 
 /*  */
-/* Function:ipf_nextipid */
-/* Returns: int - 0 == success, -1 == error (packet should be droppped) */
+/* Function:ipf_nextipid*/
+/* Returns: int - 0 == success, -1 == error (packet should be dropped)  */
 /* Parameters:  fin(I) - pointer to packet information  */
 /*  */
 /* Returns the next IPv4 ID to use for this packet. */



CVS commit: src/sys/external/bsd/ipf/netinet

2023-06-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jun 24 05:16:15 UTC 2023

Modified Files:
src/sys/external/bsd/ipf/netinet: fil.c ip_fil_netbsd.c

Log Message:
Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/external/bsd/ipf/netinet/fil.c
cvs rdiff -u -r1.37 -r1.38 src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.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/amd/amdgpu

2023-05-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 25 12:07:43 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_device.c

Log Message:
amdgpu: Fix mostly harmless merge botch.

Avoids confusing error message that should have been confined to an
error branch.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.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/amd/amdgpu

2023-05-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 25 12:07:43 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_device.c

Log Message:
amdgpu: Fix mostly harmless merge botch.

Avoids confusing error message that should have been confined to an
error branch.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.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/amd/amdgpu/amdgpu_device.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c:1.18 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c:1.19
--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c:1.18	Tue Feb 21 11:39:39 2023
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c	Thu May 25 12:07:43 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_device.c,v 1.18 2023/02/21 11:39:39 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_device.c,v 1.19 2023/05/25 12:07:43 riastradh Exp $	*/
 
 /*
  * Copyright 2008 Advanced Micro Devices, Inc.
@@ -28,7 +28,7 @@
  *  Jerome Glisse
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_device.c,v 1.18 2023/02/21 11:39:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_device.c,v 1.19 2023/05/25 12:07:43 riastradh Exp $");
 
 #include 
 #include 
@@ -3085,7 +3085,6 @@ int amdgpu_device_init(struct amdgpu_dev
 	}
 #ifdef __NetBSD__
 	if (i == DEVICE_COUNT_RESOURCE)
-		DRM_ERROR("Unable to find PCI I/O BAR\n");
 #else
 	if (adev->rio_mem == NULL)
 #endif



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

2023-05-22 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Mon May 22 22:36:53 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/i915drm: intelfb.c

Log Message:
Use the offset in mmap calculations.

It fixes wsfb(4) when used with intelfb(4).

Ok riastradh@

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/external/bsd/drm2/i915drm/intelfb.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/i915drm/intelfb.c
diff -u src/sys/external/bsd/drm2/i915drm/intelfb.c:1.24 src/sys/external/bsd/drm2/i915drm/intelfb.c:1.25
--- src/sys/external/bsd/drm2/i915drm/intelfb.c:1.24	Mon Jul 18 23:34:02 2022
+++ src/sys/external/bsd/drm2/i915drm/intelfb.c	Mon May 22 22:36:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: intelfb.c,v 1.24 2022/07/18 23:34:02 riastradh Exp $	*/
+/*	$NetBSD: intelfb.c,v 1.25 2023/05/22 22:36:53 nat Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intelfb.c,v 1.24 2022/07/18 23:34:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intelfb.c,v 1.25 2023/05/22 22:36:53 nat Exp $");
 
 #include 
 #include 
@@ -181,8 +181,8 @@ intelfb_drmfb_mmapfb(struct drmfb_softc 
 	KASSERT(0 <= offset);
 	KASSERT(offset < vma->node.size);
 
-	return bus_space_mmap(dev->bst, ggtt->gmadr.start, vma->node.start,
-	prot, BUS_SPACE_MAP_PREFETCHABLE);
+	return bus_space_mmap(dev->bst, ggtt->gmadr.start,
+	vma->node.start + offset, prot, BUS_SPACE_MAP_PREFETCHABLE);
 }
 
 static void



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

2023-05-22 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Mon May 22 22:36:53 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/i915drm: intelfb.c

Log Message:
Use the offset in mmap calculations.

It fixes wsfb(4) when used with intelfb(4).

Ok riastradh@

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/external/bsd/drm2/i915drm/intelfb.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/i915/gem

2023-05-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 12 10:13:37 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_busy.c

Log Message:
i915: Avoid dereferencing null fence if resv has changed.

PR kern/57402

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_busy.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/i915/gem

2023-05-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 12 10:13:37 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_busy.c

Log Message:
i915: Avoid dereferencing null fence if resv has changed.

PR kern/57402

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_busy.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/i915/gem/i915_gem_busy.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_busy.c:1.3 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_busy.c:1.4
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_busy.c:1.3	Sun Dec 19 11:20:25 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_busy.c	Fri May 12 10:13:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_busy.c,v 1.3 2021/12/19 11:20:25 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_busy.c,v 1.4 2023/05/12 10:13:37 riastradh Exp $	*/
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_busy.c,v 1.3 2021/12/19 11:20:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_busy.c,v 1.4 2023/05/12 10:13:37 riastradh Exp $");
 
 #include "gt/intel_engine.h"
 
@@ -130,6 +130,8 @@ retry:
 			struct dma_fence *fence =
 rcu_dereference(list->shared[i]);
 
+			if (read_seqcount_retry(>base.resv->seq, seq))
+goto retry;
 			args->busy |= busy_check_reader(fence);
 		}
 	}



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

2023-05-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May  1 09:41:55 UTC 2023

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

Log Message:
drm: KASSERT(A && B) -> KASSERT(A); KASSERT(B)


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/sys/external/bsd/drm2/include/linux/interval_tree.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/interval_tree.h
diff -u src/sys/external/bsd/drm2/include/linux/interval_tree.h:1.13 src/sys/external/bsd/drm2/include/linux/interval_tree.h:1.14
--- src/sys/external/bsd/drm2/include/linux/interval_tree.h:1.13	Sun Feb 27 14:18:25 2022
+++ src/sys/external/bsd/drm2/include/linux/interval_tree.h	Mon May  1 09:41:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: interval_tree.h,v 1.13 2022/02/27 14:18:25 riastradh Exp $	*/
+/*	$NetBSD: interval_tree.h,v 1.14 2023/05/01 09:41:55 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -120,7 +120,8 @@ interval_tree_iter_first(struct rb_root_
 		return NULL;
 	if (last < node->start)
 		return NULL;
-	KASSERT(node->start <= last && node->last >= start);
+	KASSERT(node->start <= last);
+	KASSERT(node->last >= start);
 
 	return node;
 }
@@ -142,7 +143,8 @@ interval_tree_iter_next(struct rb_root_c
 		return NULL;
 	if (last < next->start)
 		return NULL;
-	KASSERT(next->start <= last && next->last >= start);
+	KASSERT(next->start <= last);
+	KASSERT(next->last >= start);
 
 	return next;
 }



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

2023-05-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May  1 09:41:55 UTC 2023

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

Log Message:
drm: KASSERT(A && B) -> KASSERT(A); KASSERT(B)


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/sys/external/bsd/drm2/include/linux/interval_tree.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/dwc2/dist

2023-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr  9 12:31:10 UTC 2023

Modified Files:
src/sys/external/bsd/dwc2/dist: dwc2_hcdddma.c

Log Message:
dwc2: KASSERT(A && B) -> KASSERT(A); KASSERT(B)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/dwc2/dist/dwc2_hcdddma.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/dwc2/dist/dwc2_hcdddma.c
diff -u src/sys/external/bsd/dwc2/dist/dwc2_hcdddma.c:1.10 src/sys/external/bsd/dwc2/dist/dwc2_hcdddma.c:1.11
--- src/sys/external/bsd/dwc2/dist/dwc2_hcdddma.c:1.10	Tue Dec 21 09:51:22 2021
+++ src/sys/external/bsd/dwc2/dist/dwc2_hcdddma.c	Sun Apr  9 12:31:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc2_hcdddma.c,v 1.10 2021/12/21 09:51:22 skrll Exp $	*/
+/*	$NetBSD: dwc2_hcdddma.c,v 1.11 2023/04/09 12:31:10 riastradh Exp $	*/
 
 /*
  * hcd_ddma.c - DesignWare HS OTG Controller descriptor DMA routines
@@ -40,7 +40,7 @@
  * This file contains the Descriptor DMA implementation for Host mode
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwc2_hcdddma.c,v 1.10 2021/12/21 09:51:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2_hcdddma.c,v 1.11 2023/04/09 12:31:10 riastradh Exp $");
 
 #include 
 #include 
@@ -99,7 +99,8 @@ static int dwc2_desc_list_alloc(struct d
 {
 	int err;
 
-	KASSERT(!cpu_intr_p() && !cpu_softintr_p());
+	KASSERT(!cpu_intr_p());
+	KASSERT(!cpu_softintr_p());
 
 	qh->desc_list = NULL;
 	qh->desc_list_sz = sizeof(struct dwc2_hcd_dma_desc) *



CVS commit: src/sys/external/bsd/dwc2/dist

2023-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr  9 12:31:10 UTC 2023

Modified Files:
src/sys/external/bsd/dwc2/dist: dwc2_hcdddma.c

Log Message:
dwc2: KASSERT(A && B) -> KASSERT(A); KASSERT(B)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/dwc2/dist/dwc2_hcdddma.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/radeon

2023-03-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Mar  7 20:23:00 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/radeon: radeon_pci.c

Log Message:
remove "nouveau" from a comment.  noted by jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/external/bsd/drm2/radeon/radeon_pci.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/radeon/radeon_pci.c
diff -u src/sys/external/bsd/drm2/radeon/radeon_pci.c:1.22 src/sys/external/bsd/drm2/radeon/radeon_pci.c:1.23
--- src/sys/external/bsd/drm2/radeon/radeon_pci.c:1.22	Tue Mar  7 09:47:48 2023
+++ src/sys/external/bsd/drm2/radeon/radeon_pci.c	Tue Mar  7 20:23:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeon_pci.c,v 1.22 2023/03/07 09:47:48 mrg Exp $	*/
+/*	$NetBSD: radeon_pci.c,v 1.23 2023/03/07 20:23:00 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeon_pci.c,v 1.22 2023/03/07 09:47:48 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_pci.c,v 1.23 2023/03/07 20:23:00 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "genfb.h"
@@ -285,7 +285,7 @@ radeon_attach_real(device_t self)
 	 * with a firmware-provided framebuffer address, we may have to
 	 * turn it off early, before we are ready to switch the console
 	 * over -- something goes wrong if we're still writing to the
-	 * firmware-provided framebuffer during nouveau initialization.
+	 * firmware-provided framebuffer during initialization.
 	 */
 {
 	bool is_console;



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

2023-03-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Mar  7 20:23:00 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/radeon: radeon_pci.c

Log Message:
remove "nouveau" from a comment.  noted by jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/external/bsd/drm2/radeon/radeon_pci.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/radeon

2023-03-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Mar  7 09:47:48 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/radeon: radeon_pci.c

Log Message:
radeon: Kick out genfb on firmware framebuffer before initializing.

this is the same change as nouveau_pci.c:1.37, and should fix at
least PR#56714 and i thought at least another PR i can't find right
now.  it fixes at least 2 different radeon cards for me on UEFI
booted system.

XXX: pullup-10 also include the original change:
   http://mail-index.netbsd.org/source-changes/2023/03/01/msg143606.html


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/external/bsd/drm2/radeon/radeon_pci.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/radeon/radeon_pci.c
diff -u src/sys/external/bsd/drm2/radeon/radeon_pci.c:1.21 src/sys/external/bsd/drm2/radeon/radeon_pci.c:1.22
--- src/sys/external/bsd/drm2/radeon/radeon_pci.c:1.21	Mon Jul 18 23:34:03 2022
+++ src/sys/external/bsd/drm2/radeon/radeon_pci.c	Tue Mar  7 09:47:48 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeon_pci.c,v 1.21 2022/07/18 23:34:03 riastradh Exp $	*/
+/*	$NetBSD: radeon_pci.c,v 1.22 2023/03/07 09:47:48 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,9 +30,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeon_pci.c,v 1.21 2022/07/18 23:34:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_pci.c,v 1.22 2023/03/07 09:47:48 mrg Exp $");
 
 #ifdef _KERNEL_OPT
+#include "genfb.h"
 #include "vga.h"
 #if defined(__arm__) || defined(__aarch64__)
 #include "opt_fdt.h"
@@ -73,6 +74,11 @@ __KERNEL_RCSID(0, "$NetBSD: radeon_pci.c
 #include 
 #include 
 
+#if NGENFB > 0
+#include 
+#include 
+#endif
+
 #include 
 #include "radeon_drv.h"
 #include "radeon_task.h"
@@ -273,6 +279,24 @@ radeon_attach_real(device_t self)
 	}
 	sc->sc_pci_attached = true;
 
+#if NGENFB > 0
+	/*
+	 * If MD initialization has selected this as the console device
+	 * with a firmware-provided framebuffer address, we may have to
+	 * turn it off early, before we are ready to switch the console
+	 * over -- something goes wrong if we're still writing to the
+	 * firmware-provided framebuffer during nouveau initialization.
+	 */
+{
+	bool is_console;
+	if (prop_dictionary_get_bool(device_properties(self), "is_console",
+		_console) &&
+	is_console &&
+	genfb_is_console())
+		wsdisplay_predetach();
+}
+#endif
+
 	/* XXX errno Linux->NetBSD */
 	error = -drm_dev_register(sc->sc_drm_dev, flags);
 	if (error) {



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

2023-03-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Mar  7 09:47:48 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/radeon: radeon_pci.c

Log Message:
radeon: Kick out genfb on firmware framebuffer before initializing.

this is the same change as nouveau_pci.c:1.37, and should fix at
least PR#56714 and i thought at least another PR i can't find right
now.  it fixes at least 2 different radeon cards for me on UEFI
booted system.

XXX: pullup-10 also include the original change:
   http://mail-index.netbsd.org/source-changes/2023/03/01/msg143606.html


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/external/bsd/drm2/radeon/radeon_pci.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/amd/amdgpu

2023-03-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar  1 08:14:13 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_gart.c

Log Message:
amdgpu: Fix bogus loop invariant assertions in amdgpu_gart_map.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.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/amd/amdgpu/amdgpu_gart.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c:1.10 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c:1.11
--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c:1.10	Sat Jul 30 17:12:39 2022
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c	Wed Mar  1 08:14:13 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_gart.c,v 1.10 2022/07/30 17:12:39 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_gart.c,v 1.11 2023/03/01 08:14:13 riastradh Exp $	*/
 
 /*
  * Copyright 2008 Advanced Micro Devices, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_gart.c,v 1.10 2022/07/30 17:12:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_gart.c,v 1.11 2023/03/01 08:14:13 riastradh Exp $");
 
 #include 
 #include 
@@ -440,8 +440,9 @@ int amdgpu_gart_map(struct amdgpu_device
 	t = gpu_start / AMDGPU_GPU_PAGE_SIZE;
 
 	for (i = 0; npages --> 0;) {
-		KASSERT(i < dmamap->dm_nsegs);
 		for (j = 0; j < AMDGPU_GPU_PAGES_IN_CPU_PAGE; j++) {
+			KASSERT(i < dmamap->dm_nsegs);
+			KASSERT(seg_off < dmamap->dm_segs[i].ds_len);
 			amdgpu_gmc_set_pte_pde(adev, dst, t,
 			dmamap->dm_segs[i].ds_addr + seg_off, flags);
 			seg_off += AMDGPU_GPU_PAGE_SIZE;
@@ -449,7 +450,6 @@ int amdgpu_gart_map(struct amdgpu_device
 i++;
 seg_off = 0;
 			}
-			KASSERT(seg_off < dmamap->dm_segs[i].ds_len);
 		}
 	}
 



CVS commit: src/sys/external/bsd/drm2/dist/drm/amd/amdgpu

2023-03-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar  1 08:14:13 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_gart.c

Log Message:
amdgpu: Fix bogus loop invariant assertions in amdgpu_gart_map.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.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/common/include/asm

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 12:23:36 UTC 2023

Modified Files:
src/sys/external/bsd/common/include/asm: barrier.h

Log Message:
linux asm/barrier.h: Fix !MULTIPROCESSOR build.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/external/bsd/common/include/asm/barrier.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/asm

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 12:23:36 UTC 2023

Modified Files:
src/sys/external/bsd/common/include/asm: barrier.h

Log Message:
linux asm/barrier.h: Fix !MULTIPROCESSOR build.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/external/bsd/common/include/asm/barrier.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/asm/barrier.h
diff -u src/sys/external/bsd/common/include/asm/barrier.h:1.20 src/sys/external/bsd/common/include/asm/barrier.h:1.21
--- src/sys/external/bsd/common/include/asm/barrier.h:1.20	Fri Feb 24 11:02:05 2023
+++ src/sys/external/bsd/common/include/asm/barrier.h	Sat Feb 25 12:23:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: barrier.h,v 1.20 2023/02/24 11:02:05 riastradh Exp $	*/
+/*	$NetBSD: barrier.h,v 1.21 2023/02/25 12:23:36 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -106,8 +106,8 @@
 #  define	smp_mb()			__insn_barrier()
 #  define	smp_wmb()			__insn_barrier()
 #  define	smp_rmb()			__insn_barrier()
-#  define	smp_mb__before_atomic		__nothing
-#  define	smp_mb__after_atomic		__nothing
+#  define	smp_mb__before_atomic()		__nothing
+#  define	smp_mb__after_atomic()		__nothing
 #endif
 
 #endif  /* _ASM_BARRIER_H_ */



CVS commit: src/sys/external/bsd

2023-02-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Feb 24 11:02:06 UTC 2023

Modified Files:
src/sys/external/bsd/common/include/asm: barrier.h
src/sys/external/bsd/common/linux: linux_tasklet.c
src/sys/external/bsd/drm2/include/linux: kref.h

Log Message:
drm: Eliminate __HAVE_ATOMIC_AS_MEMBAR conditionals.

Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/02/23/msg028729.html


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/external/bsd/common/include/asm/barrier.h
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/common/linux/linux_tasklet.c
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/include/linux/kref.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/asm/barrier.h
diff -u src/sys/external/bsd/common/include/asm/barrier.h:1.19 src/sys/external/bsd/common/include/asm/barrier.h:1.20
--- src/sys/external/bsd/common/include/asm/barrier.h:1.19	Tue Jul 19 21:30:40 2022
+++ src/sys/external/bsd/common/include/asm/barrier.h	Fri Feb 24 11:02:05 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: barrier.h,v 1.19 2022/07/19 21:30:40 riastradh Exp $	*/
+/*	$NetBSD: barrier.h,v 1.20 2023/02/24 11:02:05 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -100,18 +100,14 @@
 #  define	smp_mbmembar_sync
 #  define	smp_wmbmembar_producer
 #  define	smp_rmbmembar_consumer
+#  define	smp_mb__before_atomic		membar_release
+#  define	smp_mb__after_atomic		membar_acquire
 #else
 #  define	smp_mb()			__insn_barrier()
 #  define	smp_wmb()			__insn_barrier()
 #  define	smp_rmb()			__insn_barrier()
-#endif
-
-#if defined(MULTIPROCESSOR) && !defined(__HAVE_ATOMIC_AS_MEMBAR)
-#  define	smp_mb__before_atomic()		membar_release()
-#  define	smp_mb__after_atomic()		membar_acquire()
-#else
-#  define	smp_mb__before_atomic()		__insn_barrier()
-#  define	smp_mb__after_atomic()		__insn_barrier()
+#  define	smp_mb__before_atomic		__nothing
+#  define	smp_mb__after_atomic		__nothing
 #endif
 
 #endif  /* _ASM_BARRIER_H_ */

Index: src/sys/external/bsd/common/linux/linux_tasklet.c
diff -u src/sys/external/bsd/common/linux/linux_tasklet.c:1.11 src/sys/external/bsd/common/linux/linux_tasklet.c:1.12
--- src/sys/external/bsd/common/linux/linux_tasklet.c:1.11	Sat Apr  9 23:43:31 2022
+++ src/sys/external/bsd/common/linux/linux_tasklet.c	Fri Feb 24 11:02:05 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_tasklet.c,v 1.11 2022/04/09 23:43:31 riastradh Exp $	*/
+/*	$NetBSD: linux_tasklet.c,v 1.12 2023/02/24 11:02:05 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2018, 2020, 2021 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_tasklet.c,v 1.11 2022/04/09 23:43:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_tasklet.c,v 1.12 2023/02/24 11:02:05 riastradh Exp $");
 
 #include 
 #include 
@@ -395,9 +395,7 @@ tasklet_disable_nosync(struct tasklet_st
 	KASSERT(disablecount != 0);
 
 	/* Pairs with membar_release in __tasklet_enable.  */
-#ifndef __HAVE_ATOMIC_AS_MEMBAR
 	membar_acquire();
-#endif
 }
 
 /*
@@ -515,9 +513,7 @@ tasklet_trylock(struct tasklet_struct *t
 		state | TASKLET_RUNNING) != state);
 
 	/* Pairs with membar_release in tasklet_unlock.  */
-#ifndef __HAVE_ATOMIC_AS_MEMBAR
 	membar_acquire();
-#endif
 
 	return true;
 }
@@ -539,9 +535,7 @@ tasklet_unlock(struct tasklet_struct *ta
 	 * Pairs with membar_acquire in tasklet_trylock and with
 	 * atomic_load_acquire in tasklet_unlock_wait.
 	 */
-#ifndef __HAVE_ATOMIC_AS_MEMBAR
 	membar_release();
-#endif
 	atomic_and_uint(>tl_state, ~TASKLET_RUNNING);
 }
 
@@ -590,9 +584,7 @@ __tasklet_disable_sync_once(struct taskl
 	KASSERT(disablecount != 0);
 
 	/* Pairs with membar_release in __tasklet_enable_sync_once.  */
-#ifndef __HAVE_ATOMIC_AS_MEMBAR
 	membar_acquire();
-#endif
 
 	/*
 	 * If it was zero, wait for it to finish running.  If it was
@@ -614,9 +606,7 @@ __tasklet_enable_sync_once(struct taskle
 	unsigned int disablecount;
 
 	/* Pairs with membar_acquire in __tasklet_disable_sync_once.  */
-#ifndef __HAVE_ATOMIC_AS_MEMBAR
 	membar_release();
-#endif
 
 	/* Decrement the disable count.  */
 	disablecount = atomic_dec_uint_nv(>tl_disablecount);
@@ -683,9 +673,7 @@ __tasklet_enable(struct tasklet_struct *
 	 * Pairs with atomic_load_acquire in tasklet_softintr and with
 	 * membar_acquire in tasklet_disable.
 	 */
-#ifndef __HAVE_ATOMIC_AS_MEMBAR
 	membar_release();
-#endif
 
 	/* Decrement the disable count.  */
 	disablecount = atomic_dec_uint_nv(>tl_disablecount);

Index: src/sys/external/bsd/drm2/include/linux/kref.h
diff -u src/sys/external/bsd/drm2/include/linux/kref.h:1.13 src/sys/external/bsd/drm2/include/linux/kref.h:1.14
--- src/sys/external/bsd/drm2/include/linux/kref.h:1.13	Sat Apr  9 23:43:39 2022
+++ src/sys/external/bsd/drm2/include/linux/kref.h	Fri Feb 24 11:02:06 2023
@@ -1,4 +1,4 @@
-/*	

CVS commit: src/sys/external/bsd

2023-02-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Feb 24 11:02:06 UTC 2023

Modified Files:
src/sys/external/bsd/common/include/asm: barrier.h
src/sys/external/bsd/common/linux: linux_tasklet.c
src/sys/external/bsd/drm2/include/linux: kref.h

Log Message:
drm: Eliminate __HAVE_ATOMIC_AS_MEMBAR conditionals.

Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/02/23/msg028729.html


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/external/bsd/common/include/asm/barrier.h
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/common/linux/linux_tasklet.c
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/include/linux/kref.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/linux

2023-02-21 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Feb 21 11:40:13 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/linux: linux_dma_buf.c

Log Message:
drm: Teach dmabuf to handle lseek.

Needed by libdrm_amdgpu.

Based on patch from Jeff Frasca -- thanks!

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/linux/linux_dma_buf.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/linux/linux_dma_buf.c
diff -u src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.15 src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.16
--- src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.15	Sat Apr  9 23:44:44 2022
+++ src/sys/external/bsd/drm2/linux/linux_dma_buf.c	Tue Feb 21 11:40:13 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_dma_buf.c,v 1.15 2022/04/09 23:44:44 riastradh Exp $	*/
+/*	$NetBSD: linux_dma_buf.c,v 1.16 2023/02/21 11:40:13 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.15 2022/04/09 23:44:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.16 2023/02/21 11:40:13 riastradh Exp $");
 
 #include 
 #include 
@@ -48,6 +48,8 @@ static int	dmabuf_fop_close(struct file 
 static int	dmabuf_fop_kqfilter(struct file *, struct knote *);
 static int	dmabuf_fop_mmap(struct file *, off_t *, size_t, int, int *,
 		int *, struct uvm_object **, int *);
+static int	dmabuf_fop_seek(struct file *fp, off_t delta, int whence,
+		off_t *newoffp, int flags);
 
 static const struct fileops dmabuf_fileops = {
 	.fo_name = "dmabuf",
@@ -61,6 +63,7 @@ static const struct fileops dmabuf_fileo
 	.fo_kqfilter = dmabuf_fop_kqfilter,
 	.fo_restart = fnullop_restart,
 	.fo_mmap = dmabuf_fop_mmap,
+	.fo_seek = dmabuf_fop_seek,
 };
 
 struct dma_buf *
@@ -288,3 +291,54 @@ dmabuf_fop_mmap(struct file *file, off_t
 	return dmabuf->ops->mmap(dmabuf, offp, size, prot, flagsp, advicep,
 	uobjp, maxprotp);
 }
+
+/*
+ * We don't actually do anything with the file offset; this is just how
+ * libdrm_amdgpu expects to find the size of the DMA buf.  (Why it
+ * doesn't use fstat is unclear, but it doesn't really matter.)
+ */
+static int
+dmabuf_fop_seek(struct file *fp, off_t delta, int whence, off_t *newoffp,
+int flags)
+{
+	const off_t OFF_MAX = __type_max(off_t);
+	struct dma_buf *dmabuf = fp->f_data;
+	off_t base, newoff;
+	int error;
+
+	mutex_enter(>f_lock);
+
+	switch (whence) {
+	case SEEK_CUR:
+		base = fp->f_offset;
+		break;
+	case SEEK_END:
+		base = dmabuf->size;
+		break;
+	case SEEK_SET:
+		base = 0;
+		break;
+	default:
+		error = EINVAL;
+		goto out;
+	}
+
+	/* Check for arithmetic overflow and reject negative offsets.  */
+	if (base < 0 || delta > OFF_MAX - base || base + delta < 0) {
+		error = EINVAL;
+		goto out;
+	}
+
+	/* Compute the new offset.  */
+	newoff = base + delta;
+
+	/* Success!  */
+	if (newoffp)
+		*newoffp = newoff;
+	if (flags & FOF_UPDATE_OFFSET)
+		fp->f_offset = newoff;
+	error = 0;
+
+out:	mutex_exit(>f_lock);
+	return error;
+}



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

2023-02-21 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Feb 21 11:40:13 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/linux: linux_dma_buf.c

Log Message:
drm: Teach dmabuf to handle lseek.

Needed by libdrm_amdgpu.

Based on patch from Jeff Frasca -- thanks!

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/linux/linux_dma_buf.c

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



  1   2   3   4   5   6   7   8   9   10   >