Module Name: src
Committed By: riastradh
Date: Mon Aug 27 14:02:32 UTC 2018
Modified Files:
src/sys/external/bsd/drm2/pci: files.drmkms_pci
Added Files:
src/sys/external/bsd/drm2/amdgpu: amdgpu2netbsd amdgpu_module.c
amdgpu_pci.c amdgpu_task.h amdgpufb.c files.amdgpu
src/sys/external/bsd/drm2/include: amdgpu_trace.h amdgpufb.h
gpu_sched_trace.h
Log Message:
Add some amdgpu goo.
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/drm2/amdgpu/amdgpu2netbsd \
src/sys/external/bsd/drm2/amdgpu/amdgpu_module.c \
src/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c \
src/sys/external/bsd/drm2/amdgpu/amdgpu_task.h \
src/sys/external/bsd/drm2/amdgpu/amdgpufb.c \
src/sys/external/bsd/drm2/amdgpu/files.amdgpu
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/drm2/include/amdgpu_trace.h \
src/sys/external/bsd/drm2/include/amdgpufb.h \
src/sys/external/bsd/drm2/include/gpu_sched_trace.h
cvs rdiff -u -r1.9 -r1.10 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/pci/files.drmkms_pci
diff -u src/sys/external/bsd/drm2/pci/files.drmkms_pci:1.9 src/sys/external/bsd/drm2/pci/files.drmkms_pci:1.10
--- src/sys/external/bsd/drm2/pci/files.drmkms_pci:1.9 Mon Aug 27 13:55:24 2018
+++ src/sys/external/bsd/drm2/pci/files.drmkms_pci Mon Aug 27 14:02:32 2018
@@ -1,4 +1,4 @@
-# $NetBSD: files.drmkms_pci,v 1.9 2018/08/27 13:55:24 riastradh Exp $
+# $NetBSD: files.drmkms_pci,v 1.10 2018/08/27 14:02:32 riastradh Exp $
# Attribute for kernel components supporting PCI-based real graphics
# drivers, a.k.a. `KMS' (kernel mode-setting), as opposed to the legacy
@@ -14,6 +14,7 @@ file external/bsd/drm2/pci/drm_pci_modul
define drmfb_pci: drmfb, drmkms_pci
file external/bsd/drm2/pci/drmfb_pci.c drmfb_pci
+include "external/bsd/drm2/amdgpu/files.amdgpu"
include "external/bsd/drm2/i915drm/files.i915drmkms"
include "external/bsd/drm2/radeon/files.radeon"
include "external/bsd/drm2/nouveau/files.nouveau"
Added files:
Index: src/sys/external/bsd/drm2/amdgpu/amdgpu2netbsd
diff -u /dev/null src/sys/external/bsd/drm2/amdgpu/amdgpu2netbsd:1.1
--- /dev/null Mon Aug 27 14:02:32 2018
+++ src/sys/external/bsd/drm2/amdgpu/amdgpu2netbsd Mon Aug 27 14:02:32 2018
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# $NetBSD: amdgpu2netbsd,v 1.1 2018/08/27 14:02:32 riastradh Exp $
+#
+# $ /path/to/amdgpu2netbsd > /path/to/files.amdgpu.new
+#
+# Run from the top-level amd/amdgpu source directory.
+
+set -Ceu
+
+# Location of the amdgpu sources relative to $NETBSDSRCDIR.
+amdgpu_top=external/bsd/drm2/dist/drm/amd/amdgpu
+
+# config(5) flag for the amdgpu driver.
+amdgpu_flag=amdgpu
+
+env CONFIG_ACPI=y \
+env src=. \
+make -f Makefile -V '$(amdgpu-y)' \
+| tr ' ' '\n' \
+| grep -v '^$' \
+| sed -e 's,\.o$,.c,' \
+| sort -u \
+| while read f; do
+ printf 'file\t%s\t%s\n' "$amdgpu_top/$f" "$amdgpu_flag"
+done
Index: src/sys/external/bsd/drm2/amdgpu/amdgpu_module.c
diff -u /dev/null src/sys/external/bsd/drm2/amdgpu/amdgpu_module.c:1.1
--- /dev/null Mon Aug 27 14:02:32 2018
+++ src/sys/external/bsd/drm2/amdgpu/amdgpu_module.c Mon Aug 27 14:02:32 2018
@@ -0,0 +1,161 @@
+/* $NetBSD: amdgpu_module.c,v 1.1 2018/08/27 14:02:32 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_module.c,v 1.1 2018/08/27 14:02:32 riastradh Exp $");
+
+#include <sys/types.h>
+#include <sys/module.h>
+#ifndef _MODULE
+#include <sys/once.h>
+#endif
+#include <sys/systm.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_sysctl.h>
+
+#include "amdgpu_amdkfd.h"
+#include "amdgpu_drv.h"
+
+MODULE(MODULE_CLASS_DRIVER, amdgpu, "amdgpu,drmkms_pci"); /* XXX drmkms_i2c, drmkms_ttm */
+
+#ifdef _MODULE
+#include "ioconf.c"
+#endif
+
+/* XXX Kludge to get these from amdgpu_drv.c. */
+extern struct drm_driver *const amdgpu_drm_driver;
+extern int amdgpu_max_kms_ioctl;
+
+struct drm_sysctl_def amdgpu_def = DRM_SYSCTL_INIT();
+
+static int
+amdgpu_init(void)
+{
+ extern int drm_guarantee_initialized(void);
+ int error;
+
+ error = drm_guarantee_initialized();
+ if (error)
+ return error;
+
+ amdgpu_drm_driver->num_ioctls = amdgpu_max_kms_ioctl;
+ amdgpu_drm_driver->driver_features |= DRIVER_MODESET;
+
+#if notyet /* XXX amdgpu acpi */
+ amdgpu_register_atpx_handler();
+#endif
+
+ amdgpu_amdkfd_init();
+
+ error = drm_pci_init(amdgpu_drm_driver, NULL);
+ if (error) {
+ aprint_error("amdgpu: failed to init pci: %d\n",
+ error);
+ return error;
+ }
+ drm_sysctl_init(&amdgpu_def);
+
+ return 0;
+}
+
+int amdgpu_guarantee_initialized(void); /* XXX */
+int
+amdgpu_guarantee_initialized(void)
+{
+#ifdef _MODULE
+ return 0;
+#else
+ static ONCE_DECL(amdgpu_init_once);
+
+ return RUN_ONCE(&amdgpu_init_once, &amdgpu_init);
+#endif
+}
+
+static void
+amdgpu_fini(void)
+{
+
+ drm_sysctl_fini(&amdgpu_def);
+ drm_pci_exit(amdgpu_drm_driver, NULL);
+ amdgpu_amdkfd_fini();
+#if notyet /* XXX amdgpu acpi */
+ amdgpu_unregister_atpx_handler();
+#endif
+}
+
+static int
+amdgpu_modcmd(modcmd_t cmd, void *arg __unused)
+{
+ int error;
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ /* XXX Kludge it up... Must happen before attachment. */
+#ifdef _MODULE
+ error = amdgpu_init();
+#else
+ error = amdgpu_guarantee_initialized();
+#endif
+ if (error) {
+ aprint_error("amdgpu: failed to initialize: %d\n",
+ error);
+ return error;
+ }
+#ifdef _MODULE
+ error = config_init_component(cfdriver_ioconf_amdgpu,
+ cfattach_ioconf_amdgpu, cfdata_ioconf_amdgpu);
+ if (error) {
+ aprint_error("amdgpu: failed to init component"
+ ": %d\n", error);
+ amdgpu_fini();
+ return error;
+ }
+#endif
+ return 0;
+
+ case MODULE_CMD_FINI:
+#ifdef _MODULE
+ error = config_fini_component(cfdriver_ioconf_amdgpu,
+ cfattach_ioconf_amdgpu, cfdata_ioconf_amdgpu);
+ if (error) {
+ aprint_error("amdgpu: failed to fini component"
+ ": %d\n", error);
+ return error;
+ }
+#endif
+ amdgpu_fini();
+ return 0;
+
+ default:
+ return ENOTTY;
+ }
+}
Index: src/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c
diff -u /dev/null src/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c:1.1
--- /dev/null Mon Aug 27 14:02:32 2018
+++ src/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c Mon Aug 27 14:02:32 2018
@@ -0,0 +1,290 @@
+/* $NetBSD: amdgpu_pci.c,v 1.1 2018/08/27 14:02:32 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_pci.c,v 1.1 2018/08/27 14:02:32 riastradh Exp $");
+
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/systm.h>
+#include <sys/workqueue.h>
+
+#include <drm/drmP.h>
+
+#include <amdgpu.h>
+#include "amdgpu_drv.h"
+#include "amdgpu_task.h"
+
+SIMPLEQ_HEAD(amdgpu_task_head, amdgpu_task);
+
+struct amdgpu_softc {
+ device_t sc_dev;
+ struct pci_attach_args sc_pa;
+ enum {
+ AMDGPU_TASK_ATTACH,
+ AMDGPU_TASK_WORKQUEUE,
+ } sc_task_state;
+ union {
+ struct workqueue *workqueue;
+ struct amdgpu_task_head attach;
+ } sc_task_u;
+ struct drm_device *sc_drm_dev;
+ struct pci_dev sc_pci_dev;
+};
+
+static bool amdgpu_pci_lookup(const struct pci_attach_args *,
+ unsigned long *);
+
+static int amdgpu_match(device_t, cfdata_t, void *);
+static void amdgpu_attach(device_t, device_t, void *);
+static void amdgpu_attach_real(device_t);
+static int amdgpu_detach(device_t, int);
+static bool amdgpu_do_suspend(device_t, const pmf_qual_t *);
+static bool amdgpu_do_resume(device_t, const pmf_qual_t *);
+
+static void amdgpu_task_work(struct work *, void *);
+
+CFATTACH_DECL_NEW(amdgpu, sizeof(struct amdgpu_softc),
+ amdgpu_match, amdgpu_attach, amdgpu_detach, NULL);
+
+/* XXX Kludge to get these from amdgpu_drv.c. */
+extern struct drm_driver *const amdgpu_drm_driver;
+extern const struct pci_device_id *const amdgpu_device_ids;
+extern const size_t amdgpu_n_device_ids;
+
+static bool
+amdgpu_pci_lookup(const struct pci_attach_args *pa, unsigned long *flags)
+{
+ size_t i;
+
+ for (i = 0; i < amdgpu_n_device_ids; i++) {
+ if ((PCI_VENDOR(pa->pa_id) == amdgpu_device_ids[i].vendor) &&
+ (PCI_PRODUCT(pa->pa_id) == amdgpu_device_ids[i].device))
+ break;
+ }
+
+ /* Did we find it? */
+ if (i == amdgpu_n_device_ids)
+ return false;
+
+ if (flags)
+ *flags = amdgpu_device_ids[i].driver_data;
+ return true;
+}
+
+static int
+amdgpu_match(device_t parent, cfdata_t match, void *aux)
+{
+ extern int amdgpu_guarantee_initialized(void);
+ const struct pci_attach_args *const pa = aux;
+ int error;
+
+ error = amdgpu_guarantee_initialized();
+ if (error) {
+ aprint_error("amdgpu: failed to initialize: %d\n", error);
+ return 0;
+ }
+
+ if (!amdgpu_pci_lookup(pa, NULL))
+ return 0;
+
+ return 6; /* XXX Beat genfb_pci... */
+}
+
+static void
+amdgpu_attach(device_t parent, device_t self, void *aux)
+{
+ struct amdgpu_softc *const sc = device_private(self);
+ const struct pci_attach_args *const pa = aux;
+
+ pci_aprint_devinfo(pa, NULL);
+
+ if (!pmf_device_register(self, &amdgpu_do_suspend, &amdgpu_do_resume))
+ aprint_error_dev(self, "unable to establish power handler\n");
+
+ /*
+ * Trivial initialization first; the rest will come after we
+ * have mounted the root file system and can load firmware
+ * images.
+ */
+ sc->sc_dev = NULL;
+ sc->sc_pa = *pa;
+
+ config_mountroot(self, &amdgpu_attach_real);
+}
+
+static void
+amdgpu_attach_real(device_t self)
+{
+ struct amdgpu_softc *const sc = device_private(self);
+ const struct pci_attach_args *const pa = &sc->sc_pa;
+ bool ok __diagused;
+ unsigned long flags = 0; /* XXXGCC */
+ int error;
+
+ ok = amdgpu_pci_lookup(pa, &flags);
+ KASSERT(ok);
+
+ sc->sc_task_state = AMDGPU_TASK_ATTACH;
+ SIMPLEQ_INIT(&sc->sc_task_u.attach);
+
+ /* XXX errno Linux->NetBSD */
+ error = -drm_pci_attach(self, pa, &sc->sc_pci_dev, amdgpu_drm_driver,
+ flags, &sc->sc_drm_dev);
+ if (error) {
+ aprint_error_dev(self, "unable to attach drm: %d\n", error);
+ goto out;
+ }
+
+ while (!SIMPLEQ_EMPTY(&sc->sc_task_u.attach)) {
+ struct amdgpu_task *const task =
+ SIMPLEQ_FIRST(&sc->sc_task_u.attach);
+
+ SIMPLEQ_REMOVE_HEAD(&sc->sc_task_u.attach, rt_u.queue);
+ (*task->rt_fn)(task);
+ }
+
+ sc->sc_task_state = AMDGPU_TASK_WORKQUEUE;
+ error = workqueue_create(&sc->sc_task_u.workqueue, "amdgpufb",
+ &amdgpu_task_work, NULL, PRI_NONE, IPL_NONE, WQ_MPSAFE);
+ if (error) {
+ aprint_error_dev(self, "unable to create workqueue: %d\n",
+ error);
+ sc->sc_task_u.workqueue = NULL;
+ goto out;
+ }
+
+out: sc->sc_dev = self;
+}
+
+static int
+amdgpu_detach(device_t self, int flags)
+{
+ struct amdgpu_softc *const sc = device_private(self);
+ int error;
+
+ if (sc->sc_dev == NULL)
+ /* Not done attaching. */
+ return EBUSY;
+
+ /* XXX Check for in-use before tearing it all down... */
+ error = config_detach_children(self, flags);
+ if (error)
+ return error;
+
+ if (sc->sc_task_state == AMDGPU_TASK_ATTACH)
+ goto out;
+ if (sc->sc_task_u.workqueue != NULL) {
+ workqueue_destroy(sc->sc_task_u.workqueue);
+ sc->sc_task_u.workqueue = NULL;
+ }
+
+ if (sc->sc_drm_dev == NULL)
+ goto out;
+ /* XXX errno Linux->NetBSD */
+ error = -drm_pci_detach(sc->sc_drm_dev, flags);
+ if (error)
+ /* XXX Kinda too late to fail now... */
+ return error;
+ sc->sc_drm_dev = NULL;
+
+out: pmf_device_deregister(self);
+
+ return 0;
+}
+
+static bool
+amdgpu_do_suspend(device_t self, const pmf_qual_t *qual)
+{
+ struct amdgpu_softc *const sc = device_private(self);
+ struct drm_device *const dev = sc->sc_drm_dev;
+ int ret;
+ bool is_console = true; /* XXX */
+
+ if (dev == NULL)
+ return true;
+
+ ret = amdgpu_suspend_kms(dev, true, is_console);
+ if (ret)
+ return false;
+
+ return true;
+}
+
+static bool
+amdgpu_do_resume(device_t self, const pmf_qual_t *qual)
+{
+ struct amdgpu_softc *const sc = device_private(self);
+ struct drm_device *const dev = sc->sc_drm_dev;
+ int ret;
+ bool is_console = true; /* XXX */
+
+ if (dev == NULL)
+ return true;
+
+ ret = amdgpu_resume_kms(dev, true, is_console);
+ if (ret)
+ return false;
+
+ return true;
+}
+
+static void
+amdgpu_task_work(struct work *work, void *cookie __unused)
+{
+ struct amdgpu_task *const task = container_of(work, struct amdgpu_task,
+ rt_u.work);
+
+ (*task->rt_fn)(task);
+}
+
+int
+amdgpu_task_schedule(device_t self, struct amdgpu_task *task)
+{
+ struct amdgpu_softc *const sc = device_private(self);
+
+ switch (sc->sc_task_state) {
+ case AMDGPU_TASK_ATTACH:
+ SIMPLEQ_INSERT_TAIL(&sc->sc_task_u.attach, task, rt_u.queue);
+ return 0;
+ case AMDGPU_TASK_WORKQUEUE:
+ if (sc->sc_task_u.workqueue == NULL) {
+ aprint_error_dev(self, "unable to schedule task\n");
+ return EIO;
+ }
+ workqueue_enqueue(sc->sc_task_u.workqueue, &task->rt_u.work,
+ NULL);
+ return 0;
+ default:
+ panic("amdgpu in invalid task state: %d\n",
+ (int)sc->sc_task_state);
+ }
+}
Index: src/sys/external/bsd/drm2/amdgpu/amdgpu_task.h
diff -u /dev/null src/sys/external/bsd/drm2/amdgpu/amdgpu_task.h:1.1
--- /dev/null Mon Aug 27 14:02:32 2018
+++ src/sys/external/bsd/drm2/amdgpu/amdgpu_task.h Mon Aug 27 14:02:32 2018
@@ -0,0 +1,55 @@
+/* $NetBSD: amdgpu_task.h,v 1.1 2018/08/27 14:02:32 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _AMDGPU_AMDGPU_TASK_H_
+#define _AMDGPU_AMDGPU_TASK_H_
+
+#include <sys/queue.h>
+#include <sys/workqueue.h>
+
+struct amdgpu_task {
+ union {
+ SIMPLEQ_ENTRY(amdgpu_task) queue;
+ struct work work;
+ } rt_u;
+ void (*rt_fn)(struct amdgpu_task *);
+};
+
+static inline void
+amdgpu_task_init(struct amdgpu_task *task, void (*fn)(struct amdgpu_task *))
+{
+
+ task->rt_fn = fn;
+}
+
+int amdgpu_task_schedule(device_t, struct amdgpu_task *);
+
+#endif /* _AMDGPU_AMDGPU_TASK_H_ */
Index: src/sys/external/bsd/drm2/amdgpu/amdgpufb.c
diff -u /dev/null src/sys/external/bsd/drm2/amdgpu/amdgpufb.c:1.1
--- /dev/null Mon Aug 27 14:02:32 2018
+++ src/sys/external/bsd/drm2/amdgpu/amdgpufb.c Mon Aug 27 14:02:32 2018
@@ -0,0 +1,198 @@
+/* $NetBSD: amdgpufb.c,v 1.1 2018/08/27 14:02:32 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: amdgpufb.c,v 1.1 2018/08/27 14:02:32 riastradh Exp $");
+
+#include <sys/types.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/errno.h>
+
+#include <drm/drmP.h>
+#include <drm/drmfb.h>
+#include <drm/drmfb_pci.h>
+
+#include "amdgpu.h"
+#include "amdgpu_task.h"
+#include "amdgpufb.h"
+
+static int amdgpufb_match(device_t, cfdata_t, void *);
+static void amdgpufb_attach(device_t, device_t, void *);
+static int amdgpufb_detach(device_t, int);
+
+static void amdgpufb_attach_task(struct amdgpu_task *);
+
+static bool amdgpufb_shutdown(device_t, int);
+static paddr_t amdgpufb_drmfb_mmapfb(struct drmfb_softc *, off_t, int);
+
+struct amdgpufb_softc {
+ struct drmfb_softc sc_drmfb; /* XXX Must be first. */
+ device_t sc_dev;
+ struct amdgpufb_attach_args sc_afa;
+ struct amdgpu_task sc_attach_task;
+ bool sc_scheduled:1;
+ bool sc_attached:1;
+};
+
+static const struct drmfb_params amdgpufb_drmfb_params = {
+ .dp_mmapfb = amdgpufb_drmfb_mmapfb,
+ .dp_mmap = drmfb_pci_mmap,
+ .dp_ioctl = drmfb_pci_ioctl,
+ .dp_is_vga_console = drmfb_pci_is_vga_console,
+};
+
+CFATTACH_DECL_NEW(amdgpufb, sizeof(struct amdgpufb_softc),
+ amdgpufb_match, amdgpufb_attach, amdgpufb_detach, NULL);
+
+static int
+amdgpufb_match(device_t parent, cfdata_t match, void *aux)
+{
+
+ return 1;
+}
+
+static void
+amdgpufb_attach(device_t parent, device_t self, void *aux)
+{
+ struct amdgpufb_softc *const sc = device_private(self);
+ const struct amdgpufb_attach_args *const afa = aux;
+ int error;
+
+ sc->sc_dev = self;
+ sc->sc_afa = *afa;
+ sc->sc_scheduled = false;
+ sc->sc_attached = false;
+
+ aprint_naive("\n");
+ aprint_normal("\n");
+
+ amdgpu_task_init(&sc->sc_attach_task, &amdgpufb_attach_task);
+ error = amdgpu_task_schedule(parent, &sc->sc_attach_task);
+ if (error) {
+ aprint_error_dev(self, "failed to schedule mode set: %d\n",
+ error);
+ goto fail0;
+ }
+ sc->sc_scheduled = true;
+
+ /* Success! */
+ return;
+
+fail0: return;
+}
+
+static int
+amdgpufb_detach(device_t self, int flags)
+{
+ struct amdgpufb_softc *const sc = device_private(self);
+ int error;
+
+ if (sc->sc_scheduled)
+ return EBUSY;
+
+ if (sc->sc_attached) {
+ pmf_device_deregister(self);
+ error = drmfb_detach(&sc->sc_drmfb, flags);
+ if (error) {
+ /* XXX Ugh. */
+ (void)pmf_device_register1(self, NULL, NULL,
+ &amdgpufb_shutdown);
+ return error;
+ }
+ sc->sc_attached = false;
+ }
+
+ return 0;
+}
+
+static void
+amdgpufb_attach_task(struct amdgpu_task *task)
+{
+ struct amdgpufb_softc *const sc = container_of(task,
+ struct amdgpufb_softc, sc_attach_task);
+ const struct amdgpufb_attach_args *const afa = &sc->sc_afa;
+ const struct drmfb_attach_args da = {
+ .da_dev = sc->sc_dev,
+ .da_fb_helper = afa->afa_fb_helper,
+ .da_fb_sizes = &afa->afa_fb_sizes,
+ .da_fb_vaddr = __UNVOLATILE(afa->afa_fb_ptr),
+ .da_fb_linebytes = afa->afa_fb_linebytes,
+ .da_params = &amdgpufb_drmfb_params,
+ };
+ int error;
+
+ error = drmfb_attach(&sc->sc_drmfb, &da);
+ if (error) {
+ aprint_error_dev(sc->sc_dev, "failed to attach drmfb: %d\n",
+ error);
+ return;
+ }
+
+ if (!pmf_device_register1(sc->sc_dev, NULL, NULL, &amdgpufb_shutdown))
+ aprint_error_dev(sc->sc_dev,
+ "failed to register shutdown handler\n");
+
+ sc->sc_attached = true;
+}
+
+static bool
+amdgpufb_shutdown(device_t self, int flags)
+{
+ struct amdgpufb_softc *const sc = device_private(self);
+
+ return drmfb_shutdown(&sc->sc_drmfb, flags);
+}
+
+static paddr_t
+amdgpufb_drmfb_mmapfb(struct drmfb_softc *drmfb, off_t offset, int prot)
+{
+ struct amdgpufb_softc *const sc = container_of(drmfb,
+ struct amdgpufb_softc, sc_drmfb);
+ struct drm_fb_helper *const helper = sc->sc_afa.afa_fb_helper;
+ struct drm_framebuffer *const fb = helper->fb;
+ struct amdgpu_framebuffer *const rfb = container_of(fb,
+ struct amdgpu_framebuffer, base);
+ struct drm_gem_object *const gobj = rfb->obj;
+ struct amdgpu_bo *const rbo = gem_to_amdgpu_bo(gobj);
+ const unsigned num_pages __diagused = rbo->tbo.num_pages;
+ int flags = 0;
+
+ KASSERT(0 <= offset);
+ KASSERT(offset < ((uintmax_t)num_pages << PAGE_SHIFT));
+ KASSERT(rbo->tbo.mem.bus.is_iomem);
+
+ if (ISSET(rbo->tbo.mem.placement, TTM_PL_FLAG_WC))
+ flags |= BUS_SPACE_MAP_PREFETCHABLE;
+
+ return bus_space_mmap(rbo->tbo.bdev->memt, rbo->tbo.mem.bus.base,
+ rbo->tbo.mem.bus.offset + offset, prot, flags);
+}
Index: src/sys/external/bsd/drm2/amdgpu/files.amdgpu
diff -u /dev/null src/sys/external/bsd/drm2/amdgpu/files.amdgpu:1.1
--- /dev/null Mon Aug 27 14:02:32 2018
+++ src/sys/external/bsd/drm2/amdgpu/files.amdgpu Mon Aug 27 14:02:32 2018
@@ -0,0 +1,98 @@
+# $NetBSD: files.amdgpu,v 1.1 2018/08/27 14:02:32 riastradh Exp $
+
+define amdgpufbbus { }
+device amdgpu: drmkms, drmkms_pci, drmkms_ttm, amdgpufbbus, firmload
+attach amdgpu at pci
+
+device amdgpufb: amdgpufbbus, drmfb, drmfb_pci, wsemuldisplaydev
+attach amdgpufb at amdgpufbbus
+
+# Match order in dist/drm/amd/amdgpu/Makefile.
+makeoptions amdgpu CPPFLAGS+="-I$S/external/bsd/drm2/dist/drm/amd/include/asic_reg"
+makeoptions amdgpu CPPFLAGS+="-I$S/external/bsd/drm2/dist/drm/amd/include"
+makeoptions amdgpu CPPFLAGS+="-I$S/external/bsd/drm2/dist/drm/amd/amdgpu"
+makeoptions amdgpu CPPFLAGS+="-I$S/external/bsd/drm2/dist/drm/amd/scheduler"
+
+makeoptions amdgpu "CWARNFLAGS.amdgpu_drv.c"+="-Wno-missing-field-initializers"
+makeoptions amdgpu "CWARNFLAGS.dce_v10_0.c"+="-Wno-shadow"
+makeoptions amdgpu "CWARNFLAGS.dce_v11_0.c"+="-Wno-shadow"
+makeoptions amdgpu "CWARNFLAGS.vi.c"+="-Wno-missing-field-initializers"
+
+# Local additions.
+file external/bsd/drm2/amdgpu/amdgpu_module.c amdgpu
+file external/bsd/drm2/amdgpu/amdgpu_pci.c amdgpu
+file external/bsd/drm2/amdgpu/amdgpufb.c amdgpufb
+
+# Generated from amdgpu2netbsd.
+file external/bsd/drm2/dist/drm/amd/amdgpu/../scheduler/gpu_scheduler.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/../scheduler/sched_fence.c amdgpu
+#file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_afmt.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_amdkfd.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_atombios.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_benchmark.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_bios.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_bo_list.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cgs.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_connectors.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cs.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ctx.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_display.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_dpm.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_drv.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_encoders.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gem.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gfx.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_i2c.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ib.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ih.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_irq.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_kms.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_object.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_pll.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_pm.c amdgpu
+#file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_prime.c amdgpu # XXX amdgpu prime
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ring.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_sa.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_sched.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_semaphore.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_sync.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_test.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_trace_points.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ttm.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ucode.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_uvd.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vce.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vm.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/atom.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/atombios_crtc.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/atombios_dp.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/atombios_encoders.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/atombios_i2c.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/cz_dpm.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/cz_ih.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/cz_smc.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/dce_v10_0.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/dce_v11_0.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/fiji_dpm.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/fiji_smc.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/gfx_v8_0.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/gmc_v7_0.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/gmc_v8_0.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/iceland_dpm.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/iceland_ih.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/iceland_smc.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/sdma_v2_4.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/sdma_v3_0.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/tonga_dpm.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/tonga_ih.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/tonga_smc.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/uvd_v5_0.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/uvd_v6_0.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/vce_v3_0.c amdgpu
+file external/bsd/drm2/dist/drm/amd/amdgpu/vi.c amdgpu
Index: src/sys/external/bsd/drm2/include/amdgpu_trace.h
diff -u /dev/null src/sys/external/bsd/drm2/include/amdgpu_trace.h:1.1
--- /dev/null Mon Aug 27 14:02:32 2018
+++ src/sys/external/bsd/drm2/include/amdgpu_trace.h Mon Aug 27 14:02:32 2018
@@ -0,0 +1,114 @@
+/* $NetBSD: amdgpu_trace.h,v 1.1 2018/08/27 14:02:32 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _AMDGPU_TRACE_H_
+#define _AMDGPU_TRACE_H_
+
+static inline void
+trace_amdgpu_bo_list_set(struct amdgpu_bo_list *list, struct amdgpu_bo *obj)
+{
+}
+
+static inline void
+trace_amdgpu_cs(struct amdgpu_cs_parser *parser, int i)
+{
+}
+
+static inline void
+trace_amdgpu_cs_ioctl(struct amdgpu_job *job)
+{
+}
+
+static inline void
+trace_amdgpu_semaphore_signale(u32 ring, struct amdgpu_semaphore *semaphore)
+{
+}
+
+static inline void
+trace_amdgpu_semaphore_wait(u32 ring, struct amdgpu_semaphore *semaphore)
+{
+}
+
+static inline void
+trace_amdgpu_sched_run_job(struct amdgpu_job *job)
+{
+}
+
+static inline void
+trace_amdgpu_bo_create(struct amdgpu_bo *bo)
+{
+}
+
+static inline void
+trace_amdgpu_vm_grab_id(unsigned vmid, u32 ring)
+{
+}
+
+static inline void
+trace_amdgpu_vm_flush(uint64_t pd_addr, u32 ring, unsigned vmid)
+{
+}
+
+static inline void
+trace_amdgpu_vm_set_page(uint64_t pe, uint64_t addr, unsigned count,
+ uint32_t incr, uint32_t flags)
+{
+}
+
+static inline void
+trace_amdgpu_vm_bo_update(struct amdgpu_bo_va_mapping *mapping)
+{
+}
+
+static inline void
+trace_amdgpu_vm_bo_mapping(struct amdgpu_bo_va_mapping *mapping)
+{
+}
+
+static inline bool
+trace_amdgpu_vm_bo_mapping_enabled(void)
+{
+ return false;
+}
+
+static inline void
+trace_amdgpu_vm_bo_map(struct amdgpu_bo_va *bo_va,
+ struct amdgpu_bo_va_mapping *mapping)
+{
+}
+
+static inline void
+trace_amdgpu_vm_bo_unmap(struct amdgpu_bo_va *bo_va,
+ struct amdgpu_bo_va_mapping *mapping)
+{
+}
+
+#endif /* _AMDGPU_TRACE_H_ */
Index: src/sys/external/bsd/drm2/include/amdgpufb.h
diff -u /dev/null src/sys/external/bsd/drm2/include/amdgpufb.h:1.1
--- /dev/null Mon Aug 27 14:02:32 2018
+++ src/sys/external/bsd/drm2/include/amdgpufb.h Mon Aug 27 14:02:32 2018
@@ -0,0 +1,48 @@
+/* $NetBSD: amdgpufb.h,v 1.1 2018/08/27 14:02:32 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _AMDGPU_AMDGPUFB_H_
+#define _AMDGPU_AMDGPUFB_H_
+
+#include <sys/bus.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_fb_helper.h>
+
+struct amdgpufb_attach_args {
+ struct drm_device *afa_drm_dev;
+ struct drm_fb_helper *afa_fb_helper;
+ struct drm_fb_helper_surface_size afa_fb_sizes;
+ volatile void *afa_fb_ptr;
+ uint32_t afa_fb_linebytes;
+};
+
+#endif /* _AMDGPU_AMDGPUFB_H_ */
Index: src/sys/external/bsd/drm2/include/gpu_sched_trace.h
diff -u /dev/null src/sys/external/bsd/drm2/include/gpu_sched_trace.h:1.1
--- /dev/null Mon Aug 27 14:02:32 2018
+++ src/sys/external/bsd/drm2/include/gpu_sched_trace.h Mon Aug 27 14:02:32 2018
@@ -0,0 +1,45 @@
+/* $NetBSD: gpu_sched_trace.h,v 1.1 2018/08/27 14:02:32 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _AMDGPU_GPU_SCHED_TRACE_H_
+#define _AMDGPU_GPU_SCHED_TRACE_H_
+
+static inline void
+trace_amd_sched_job(struct amd_sched_job *sched_job)
+{
+}
+
+static inline void
+trace_amd_sched_process_job(struct amd_sched_fence *s_fence)
+{
+}
+
+#endif /* _AMDGPU_GPU_SCHED_TRACE_H_ */