Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2 amdgpu: Stub out irq domain stuff with...



details:   https://anonhg.NetBSD.org/src/rev/7e6de4184c67
branches:  trunk
changeset: 1028879:7e6de4184c67
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 12:23:16 2021 +0000

description:
amdgpu: Stub out irq domain stuff with a finer grain.

diffstat:

 sys/external/bsd/drm2/amdgpu/files.amdgpu               |   4 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_irq.c  |  18 ++++-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ras.c  |  24 ++++++--
 sys/external/bsd/drm2/dist/drm/scheduler/sched_entity.c |  35 +++++++++++-
 sys/external/bsd/drm2/dist/drm/scheduler/sched_fence.c  |  29 ++++++++++-
 sys/external/bsd/drm2/dist/drm/scheduler/sched_main.c   |  45 ++++++++++++----
 sys/external/bsd/drm2/dist/include/drm/gpu_scheduler.h  |  11 +--
 sys/external/bsd/drm2/drm/files.drmkms                  |   8 ++-
 sys/external/bsd/drm2/include/linux/sched.h             |  18 ++++++-
 9 files changed, 152 insertions(+), 40 deletions(-)

diffs (truncated from 599 to 300 lines):

diff -r 871f9eaad481 -r 7e6de4184c67 sys/external/bsd/drm2/amdgpu/files.amdgpu
--- a/sys/external/bsd/drm2/amdgpu/files.amdgpu Sun Dec 19 12:23:07 2021 +0000
+++ b/sys/external/bsd/drm2/amdgpu/files.amdgpu Sun Dec 19 12:23:16 2021 +0000
@@ -1,9 +1,9 @@
-#      $NetBSD: files.amdgpu,v 1.23 2021/12/19 12:22:48 riastradh Exp $
+#      $NetBSD: files.amdgpu,v 1.24 2021/12/19 12:23:16 riastradh Exp $
 
 version        20180827
 
 define amdgpufbbus     { }
-device amdgpu: drmkms, drmkms_pci, drmkms_ttm, amdgpufbbus, firmload
+device amdgpu: drmkms, drmkms_pci, drmkms_ttm, drmsched, amdgpufbbus, firmload
 attach amdgpu at pci
 
 defflag        opt_amdgpu_cik.h AMDGPU_CIK
diff -r 871f9eaad481 -r 7e6de4184c67 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_irq.c
--- a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_irq.c    Sun Dec 19 12:23:07 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_irq.c    Sun Dec 19 12:23:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdgpu_irq.c,v 1.6 2021/12/19 12:02:39 riastradh Exp $ */
+/*     $NetBSD: amdgpu_irq.c,v 1.7 2021/12/19 12:23:16 riastradh Exp $ */
 
 /*
  * Copyright 2008 Advanced Micro Devices, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_irq.c,v 1.6 2021/12/19 12:02:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_irq.c,v 1.7 2021/12/19 12:23:16 riastradh Exp $");
 
 #include <linux/irq.h>
 #include <linux/pci.h>
@@ -610,7 +610,7 @@
        return !!atomic_read(&src->enabled_types[type]);
 }
 
-#ifndef __NetBSD__             /* XXX amdgpu irq */
+#ifndef __NetBSD__             /* XXX amdgpu irq domain */
 
 /* XXX: Generic IRQ handling */
 static void amdgpu_irq_mask(struct irq_data *irqd)
@@ -659,6 +659,8 @@
        .map = amdgpu_irqdomain_map,
 };
 
+#endif /* __NetBSD__ */
+
 /**
  * amdgpu_irq_add_domain - create a linear IRQ domain
  *
@@ -672,12 +674,14 @@
  */
 int amdgpu_irq_add_domain(struct amdgpu_device *adev)
 {
+#ifndef __NetBSD__             /* XXX amdgpu irq domain */
        adev->irq.domain = irq_domain_add_linear(NULL, AMDGPU_MAX_IRQ_SRC_ID,
                                                 &amdgpu_hw_irqdomain_ops, adev);
        if (!adev->irq.domain) {
                DRM_ERROR("GPU irq add domain failed\n");
                return -ENODEV;
        }
+#endif
 
        return 0;
 }
@@ -692,10 +696,12 @@
  */
 void amdgpu_irq_remove_domain(struct amdgpu_device *adev)
 {
+#ifndef __NetBSD__             /* XXX amdgpu irq domain */
        if (adev->irq.domain) {
                irq_domain_remove(adev->irq.domain);
                adev->irq.domain = NULL;
        }
+#endif
 }
 
 /**
@@ -713,9 +719,11 @@
  */
 unsigned amdgpu_irq_create_mapping(struct amdgpu_device *adev, unsigned src_id)
 {
+#ifdef __NetBSD__              /* XXX amdgpu irq domain */
+       return 0;
+#else
        adev->irq.virq[src_id] = irq_create_mapping(adev->irq.domain, src_id);
 
        return adev->irq.virq[src_id];
+#endif
 }
-
-#endif
diff -r 871f9eaad481 -r 7e6de4184c67 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ras.c
--- a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ras.c    Sun Dec 19 12:23:07 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ras.c    Sun Dec 19 12:23:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdgpu_ras.c,v 1.3 2021/12/19 12:21:29 riastradh Exp $ */
+/*     $NetBSD: amdgpu_ras.c,v 1.4 2021/12/19 12:23:16 riastradh Exp $ */
 
 /*
  * Copyright 2018 Advanced Micro Devices, Inc.
@@ -24,7 +24,7 @@
  *
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_ras.c,v 1.3 2021/12/19 12:21:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_ras.c,v 1.4 2021/12/19 12:23:16 riastradh Exp $");
 
 #include <linux/debugfs.h>
 #include <linux/list.h>
@@ -1006,9 +1006,12 @@
        return 0;
 }
 
+#endif /* __NetBSD__ */
+
 int amdgpu_ras_sysfs_create(struct amdgpu_device *adev,
                struct ras_fs_if *head)
 {
+#ifndef __NetBSD__
        struct ras_manager *obj = amdgpu_ras_find_obj(adev, &head->head);
 
        if (!obj || obj->attr_inuse)
@@ -1037,6 +1040,7 @@
        }
 
        obj->attr_inuse = 1;
+#endif
 
        return 0;
 }
@@ -1044,6 +1048,7 @@
 int amdgpu_ras_sysfs_remove(struct amdgpu_device *adev,
                struct ras_common_if *head)
 {
+#ifndef __NetBSD__             /* XXX amdgpu sysfs */
        struct ras_manager *obj = amdgpu_ras_find_obj(adev, head);
 
        if (!obj || !obj->attr_inuse)
@@ -1054,12 +1059,14 @@
                                "ras");
        obj->attr_inuse = 0;
        put_obj(obj);
+#endif /* __NetBSD__ */
 
        return 0;
 }
 
 static int amdgpu_ras_sysfs_remove_all(struct amdgpu_device *adev)
 {
+#ifndef __NetBSD__
        struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
        struct ras_manager *obj, *tmp;
 
@@ -1068,10 +1075,10 @@
        }
 
        amdgpu_ras_sysfs_remove_feature_node(adev);
+#endif
 
        return 0;
 }
-#endif /* __NetBSD__ */
 /* sysfs end */
 
 /**
@@ -1117,9 +1124,12 @@
                                &con->reboot);
 }
 
+#endif /* __NetBSD__ */
+
 void amdgpu_ras_debugfs_create(struct amdgpu_device *adev,
                struct ras_fs_if *head)
 {
+#ifndef __NetBSD__             /* XXX amdgpu debugfs */
        struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
        struct ras_manager *obj = amdgpu_ras_find_obj(adev, &head->head);
 
@@ -1135,11 +1145,13 @@
        obj->ent = debugfs_create_file(obj->fs_data.debugfs_name,
                                       S_IWUGO | S_IRUGO, con->dir, obj,
                                       &amdgpu_ras_debugfs_ops);
+#endif
 }
 
 void amdgpu_ras_debugfs_remove(struct amdgpu_device *adev,
                struct ras_common_if *head)
 {
+#ifndef __NetBSD__             /* XXX amdgpu debugfs */
        struct ras_manager *obj = amdgpu_ras_find_obj(adev, head);
 
        if (!obj || !obj->ent)
@@ -1148,10 +1160,12 @@
        debugfs_remove(obj->ent);
        obj->ent = NULL;
        put_obj(obj);
+#endif /* __NetBSD__ */
 }
 
 static void amdgpu_ras_debugfs_remove_all(struct amdgpu_device *adev)
 {
+#ifndef __NetBSD__
        struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
        struct ras_manager *obj, *tmp;
 
@@ -1161,8 +1175,8 @@
 
        debugfs_remove_recursive(con->dir);
        con->dir = NULL;
+#endif
 }
-#endif /* __NetBSD__ */
 /* debugfs end */
 
 /* ras fs */
@@ -1179,10 +1193,8 @@
 
 static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)
 {
-#ifndef __NetBSD__             /* XXX amdgpu debugfs sysfs */
        amdgpu_ras_debugfs_remove_all(adev);
        amdgpu_ras_sysfs_remove_all(adev);
-#endif
        return 0;
 }
 /* ras fs end */
diff -r 871f9eaad481 -r 7e6de4184c67 sys/external/bsd/drm2/dist/drm/scheduler/sched_entity.c
--- a/sys/external/bsd/drm2/dist/drm/scheduler/sched_entity.c   Sun Dec 19 12:23:07 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/scheduler/sched_entity.c   Sun Dec 19 12:23:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sched_entity.c,v 1.2 2021/12/18 23:45:43 riastradh Exp $       */
+/*     $NetBSD: sched_entity.c,v 1.3 2021/12/19 12:23:16 riastradh Exp $       */
 
 /*
  * Copyright 2015 Advanced Micro Devices, Inc.
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sched_entity.c,v 1.2 2021/12/18 23:45:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sched_entity.c,v 1.3 2021/12/19 12:23:16 riastradh Exp $");
 
 #include <linux/kthread.h>
 #include <linux/slab.h>
@@ -97,7 +97,7 @@
  */
 static bool drm_sched_entity_is_idle(struct drm_sched_entity *entity)
 {
-       rmb(); /* for list_empty to work without lock */
+       assert_spin_locked(&entity->rq->sched->job_list_lock);
 
        if (list_empty(&entity->list) ||
            spsc_queue_count(&entity->job_queue) == 0)
@@ -171,13 +171,24 @@
 long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout)
 {
        struct drm_gpu_scheduler *sched;
+#ifdef __NetBSD__
+       struct proc *last_user;
+#else
        struct task_struct *last_user;
+#endif
        long ret = timeout;
 
        if (!entity->rq)
                return 0;
 
        sched = entity->rq->sched;
+#ifdef __NetBSD__
+       spin_lock(&sched->job_list_lock);
+       DRM_SPIN_WAIT_NOINTR_UNTIL(ret, &sched->job_scheduled,
+           &sched->job_list_lock,
+           drm_sched_entity_is_idle(entity));
+       spin_unlock(&sched->job_list_lock);
+#else
        /**
         * The client will not queue more IBs during this fini, consume existing
         * queued IBs or discard them on SIGKILL
@@ -192,11 +203,19 @@
                wait_event_killable(sched->job_scheduled,
                                    drm_sched_entity_is_idle(entity));
        }
+#endif
 
        /* For killed process disable any more IBs enqueue right now */
+#ifdef __NetBSD__
+       last_user = cmpxchg(&entity->last_user, curproc, NULL);
+       if ((!last_user || last_user == curproc) &&
+           (curproc->p_sflag & PS_WEXIT))
+#else
        last_user = cmpxchg(&entity->last_user, current->group_leader, NULL);
        if ((!last_user || last_user == current->group_leader) &&
-           (current->flags & PF_EXITING) && (current->exit_code == SIGKILL)) {
+           (current->flags & PF_EXITING) && (current->exit_code == SIGKILL))
+#endif
+       {
                spin_lock(&entity->rq_lock);
                entity->stopped = true;



Home | Main Index | Thread Index | Old Index