Mon Feb 14 20:37:51 2022 UTC ()
i915: Defer final wakeup on active until after retirement.

Not sure what I was thinking when I moved this earlier!


(riastradh)
diff -r1.10 -r1.11 src/sys/external/bsd/drm2/dist/drm/i915/i915_active.c

cvs diff -r1.10 -r1.11 src/sys/external/bsd/drm2/dist/drm/i915/i915_active.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/i915/i915_active.c 2021/12/24 00:14:03 1.10
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_active.c 2022/02/14 20:37:51 1.11
@@ -1,23 +1,23 @@ @@ -1,23 +1,23 @@
1/* $NetBSD: i915_active.c,v 1.10 2021/12/24 00:14:03 riastradh Exp $ */ 1/* $NetBSD: i915_active.c,v 1.11 2022/02/14 20:37:51 riastradh Exp $ */
2 2
3/* 3/*
4 * SPDX-License-Identifier: MIT 4 * SPDX-License-Identifier: MIT
5 * 5 *
6 * Copyright © 2019 Intel Corporation 6 * Copyright © 2019 Intel Corporation
7 */ 7 */
8 8
9#include <sys/cdefs.h> 9#include <sys/cdefs.h>
10__KERNEL_RCSID(0, "$NetBSD: i915_active.c,v 1.10 2021/12/24 00:14:03 riastradh Exp $"); 10__KERNEL_RCSID(0, "$NetBSD: i915_active.c,v 1.11 2022/02/14 20:37:51 riastradh Exp $");
11 11
12#include <linux/debugobjects.h> 12#include <linux/debugobjects.h>
13 13
14#include "gt/intel_context.h" 14#include "gt/intel_context.h"
15#include "gt/intel_engine_pm.h" 15#include "gt/intel_engine_pm.h"
16#include "gt/intel_ring.h" 16#include "gt/intel_ring.h"
17 17
18#include "i915_drv.h" 18#include "i915_drv.h"
19#include "i915_active.h" 19#include "i915_active.h"
20#include "i915_globals.h" 20#include "i915_globals.h"
21 21
22#include <linux/nbsd-namespace.h> 22#include <linux/nbsd-namespace.h>
23 23
@@ -185,35 +185,36 @@ __active_retire(struct i915_active *ref) @@ -185,35 +185,36 @@ __active_retire(struct i915_active *ref)
185 return; 185 return;
186 186
187 GEM_BUG_ON(rcu_access_pointer(ref->excl.fence)); 187 GEM_BUG_ON(rcu_access_pointer(ref->excl.fence));
188 debug_active_deactivate(ref); 188 debug_active_deactivate(ref);
189 189
190 root = ref->tree; 190 root = ref->tree;
191#ifdef __NetBSD__ 191#ifdef __NetBSD__
192 rb_tree_init(&ref->tree.rbr_tree, &active_rb_ops); 192 rb_tree_init(&ref->tree.rbr_tree, &active_rb_ops);
193#else 193#else
194 ref->tree = RB_ROOT; 194 ref->tree = RB_ROOT;
195#endif 195#endif
196 ref->cache = NULL; 196 ref->cache = NULL;
197 197
198 DRM_SPIN_WAKEUP_ALL(&ref->tree_wq, &ref->tree_lock); 
199 
200 spin_unlock_irqrestore(&ref->tree_lock, flags); 198 spin_unlock_irqrestore(&ref->tree_lock, flags);
201 199
202 /* After the final retire, the entire struct may be freed */ 200 /* After the final retire, the entire struct may be freed */
203 if (ref->retire) 201 if (ref->retire)
204 ref->retire(ref); 202 ref->retire(ref);
205 203
206 /* ... except if you wait on it, you must manage your own references! */ 204 /* ... except if you wait on it, you must manage your own references! */
 205 spin_lock(&ref->tree_lock);
 206 DRM_SPIN_WAKEUP_ALL(&ref->tree_wq, &ref->tree_lock);
 207 spin_unlock(&ref->tree_lock);
207 208
208 rbtree_postorder_for_each_entry_safe(it, n, &root, node) { 209 rbtree_postorder_for_each_entry_safe(it, n, &root, node) {
209 GEM_BUG_ON(i915_active_fence_isset(&it->base)); 210 GEM_BUG_ON(i915_active_fence_isset(&it->base));
210 kmem_cache_free(global.slab_cache, it); 211 kmem_cache_free(global.slab_cache, it);
211 } 212 }
212} 213}
213 214
214static void 215static void
215active_work(struct work_struct *wrk) 216active_work(struct work_struct *wrk)
216{ 217{
217 struct i915_active *ref = container_of(wrk, typeof(*ref), work); 218 struct i915_active *ref = container_of(wrk, typeof(*ref), work);
218 219
219 GEM_BUG_ON(!atomic_read(&ref->count)); 220 GEM_BUG_ON(!atomic_read(&ref->count));