* [PATCH] drm/i915: Use i915_global_register()
@ 2019-03-05 21:06 Chris Wilson
2019-03-05 21:38 ` Chris Wilson
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Chris Wilson @ 2019-03-05 21:06 UTC (permalink / raw)
To: intel-gfx
Rather than manually add every new global into each hook, use
i915_global_register() function and keep a list of registered globals to
invoke instead.
However, I haven't found a way for random drivers to add an .init table
to avoid having to manually add ourselves to i915_globals_init() each
time.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_active.c | 28 +++++++-----
drivers/gpu/drm/i915/i915_active.h | 2 -
drivers/gpu/drm/i915/i915_gem_context.c | 28 +++++++-----
drivers/gpu/drm/i915/i915_gem_context.h | 2 -
drivers/gpu/drm/i915/i915_gem_object.c | 28 +++++++-----
drivers/gpu/drm/i915/i915_gem_object.h | 2 -
drivers/gpu/drm/i915/i915_globals.c | 59 +++++++++++++------------
drivers/gpu/drm/i915/i915_globals.h | 11 +++++
drivers/gpu/drm/i915/i915_request.c | 36 +++++++++------
drivers/gpu/drm/i915/i915_request.h | 2 -
drivers/gpu/drm/i915/i915_scheduler.c | 32 +++++++++-----
drivers/gpu/drm/i915/i915_scheduler.h | 2 -
drivers/gpu/drm/i915/i915_vma.c | 28 +++++++-----
drivers/gpu/drm/i915/i915_vma.h | 2 -
14 files changed, 156 insertions(+), 106 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
index d9f6471ac16c..863ae12707ba 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -6,6 +6,7 @@
#include "i915_drv.h"
#include "i915_active.h"
+#include "i915_globals.h"
#define BKL(ref) (&(ref)->i915->drm.struct_mutex)
@@ -17,6 +18,7 @@
* nodes from a local slab cache to hopefully reduce the fragmentation.
*/
static struct i915_global_active {
+ struct i915_global base;
struct kmem_cache *slab_cache;
} global;
@@ -285,21 +287,27 @@ void i915_active_retire_noop(struct i915_active_request *active,
#include "selftests/i915_active.c"
#endif
-int __init i915_global_active_init(void)
+static void i915_global_active_shrink(void)
{
- global.slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN);
- if (!global.slab_cache)
- return -ENOMEM;
-
- return 0;
+ kmem_cache_shrink(global.slab_cache);
}
-void i915_global_active_shrink(void)
+static void i915_global_active_exit(void)
{
- kmem_cache_shrink(global.slab_cache);
+ kmem_cache_destroy(global.slab_cache);
}
-void i915_global_active_exit(void)
+static struct i915_global_active global = { {
+ .shrink = i915_global_active_shrink,
+ .exit = i915_global_active_exit,
+} };
+
+int __init i915_global_active_init(void)
{
- kmem_cache_destroy(global.slab_cache);
+ global.slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN);
+ if (!global.slab_cache)
+ return -ENOMEM;
+
+ i915_global_register(&global.base);
+ return 0;
}
diff --git a/drivers/gpu/drm/i915/i915_active.h b/drivers/gpu/drm/i915/i915_active.h
index 5fbd9102384b..575c01846875 100644
--- a/drivers/gpu/drm/i915/i915_active.h
+++ b/drivers/gpu/drm/i915/i915_active.h
@@ -420,7 +420,5 @@ static inline void i915_active_fini(struct i915_active *ref) { }
#endif
int i915_global_active_init(void);
-void i915_global_active_shrink(void);
-void i915_global_active_exit(void);
#endif /* _I915_ACTIVE_H_ */
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 1e3211e909f1..b9f321947982 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -88,6 +88,7 @@
#include <linux/log2.h>
#include <drm/i915_drm.h>
#include "i915_drv.h"
+#include "i915_globals.h"
#include "i915_trace.h"
#include "intel_lrc_reg.h"
#include "intel_workarounds.h"
@@ -95,6 +96,7 @@
#define ALL_L3_SLICES(dev) (1 << NUM_L3_SLICES(dev)) - 1
static struct i915_global_context {
+ struct i915_global base;
struct kmem_cache *slab_luts;
} global;
@@ -1423,21 +1425,27 @@ int __i915_gem_context_pin_hw_id(struct i915_gem_context *ctx)
#include "selftests/i915_gem_context.c"
#endif
-int __init i915_global_context_init(void)
+static void i915_global_context_shrink(void)
{
- global.slab_luts = KMEM_CACHE(i915_lut_handle, 0);
- if (!global.slab_luts)
- return -ENOMEM;
-
- return 0;
+ kmem_cache_shrink(global.slab_luts);
}
-void i915_global_context_shrink(void)
+static void i915_global_context_exit(void)
{
- kmem_cache_shrink(global.slab_luts);
+ kmem_cache_destroy(global.slab_luts);
}
-void i915_global_context_exit(void)
+static struct i915_global_context global = { {
+ .shrink = i915_global_context_shrink,
+ .exit = i915_global_context_exit,
+} };
+
+int __init i915_global_context_init(void)
{
- kmem_cache_destroy(global.slab_luts);
+ global.slab_luts = KMEM_CACHE(i915_lut_handle, 0);
+ if (!global.slab_luts)
+ return -ENOMEM;
+
+ i915_global_register(&global.base);
+ return 0;
}
diff --git a/drivers/gpu/drm/i915/i915_gem_context.h b/drivers/gpu/drm/i915/i915_gem_context.h
index be63666ffaac..b59107248b54 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.h
+++ b/drivers/gpu/drm/i915/i915_gem_context.h
@@ -412,7 +412,5 @@ struct i915_lut_handle *i915_lut_handle_alloc(void);
void i915_lut_handle_free(struct i915_lut_handle *lut);
int i915_global_context_init(void);
-void i915_global_context_shrink(void);
-void i915_global_context_exit(void);
#endif /* !__I915_GEM_CONTEXT_H__ */
diff --git a/drivers/gpu/drm/i915/i915_gem_object.c b/drivers/gpu/drm/i915/i915_gem_object.c
index 4aeb8c3b87e4..ac6a5ab84586 100644
--- a/drivers/gpu/drm/i915/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/i915_gem_object.c
@@ -24,8 +24,10 @@
#include "i915_drv.h"
#include "i915_gem_object.h"
+#include "i915_globals.h"
static struct i915_global_object {
+ struct i915_global base;
struct kmem_cache *slab_objects;
} global;
@@ -61,6 +63,21 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE);
}
+static void i915_global_objects_shrink(void)
+{
+ kmem_cache_shrink(global.slab_objects);
+}
+
+static void i915_global_objects_exit(void)
+{
+ kmem_cache_destroy(global.slab_objects);
+}
+
+static struct i915_global_object global = { {
+ .shrink = i915_global_objects_shrink,
+ .exit = i915_global_objects_exit,
+} };
+
int __init i915_global_objects_init(void)
{
global.slab_objects =
@@ -68,15 +85,6 @@ int __init i915_global_objects_init(void)
if (!global.slab_objects)
return -ENOMEM;
+ i915_global_register(&global.base);
return 0;
}
-
-void i915_global_objects_shrink(void)
-{
- kmem_cache_shrink(global.slab_objects);
-}
-
-void i915_global_objects_exit(void)
-{
- kmem_cache_destroy(global.slab_objects);
-}
diff --git a/drivers/gpu/drm/i915/i915_gem_object.h b/drivers/gpu/drm/i915/i915_gem_object.h
index 0eaa2b3aeb62..75d49fe12d18 100644
--- a/drivers/gpu/drm/i915/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/i915_gem_object.h
@@ -503,7 +503,5 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj);
int i915_global_objects_init(void);
-void i915_global_objects_shrink(void);
-void i915_global_objects_exit(void);
#endif
diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c
index cfd0bc462f58..383b43d86e71 100644
--- a/drivers/gpu/drm/i915/i915_globals.c
+++ b/drivers/gpu/drm/i915/i915_globals.c
@@ -15,62 +15,70 @@
#include "i915_scheduler.h"
#include "i915_vma.h"
+static LIST_HEAD(globals);
+
+void __init i915_global_register(struct i915_global *global)
+{
+ GEM_BUG_ON(!global->shrink);
+ GEM_BUG_ON(!global->exit);
+
+ list_add_tail(&global->link, &globals);
+}
+
+static void __i915_globals_cleanup(void)
+{
+ struct i915_global *global, *next;
+
+ list_for_each_entry_safe_reverse(global, next, &globals, link)
+ global->exit();
+}
+
int __init i915_globals_init(void)
{
int err;
err = i915_global_active_init();
if (err)
- return err;
+ goto err;
err = i915_global_context_init();
if (err)
- goto err_active;
+ goto err;
err = i915_global_objects_init();
if (err)
- goto err_context;
+ goto err;
err = i915_global_request_init();
if (err)
- goto err_objects;
+ goto err;
err = i915_global_scheduler_init();
if (err)
- goto err_request;
+ goto err;
err = i915_global_vma_init();
if (err)
- goto err_scheduler;
+ goto err;
return 0;
-err_scheduler:
- i915_global_scheduler_exit();
-err_request:
- i915_global_request_exit();
-err_objects:
- i915_global_objects_exit();
-err_context:
- i915_global_context_exit();
-err_active:
- i915_global_active_exit();
+err:
+ __i915_globals_cleanup();
return err;
}
static void i915_globals_shrink(void)
{
+ struct i915_global *global;
+
/*
* kmem_cache_shrink() discards empty slabs and reorders partially
* filled slabs to prioritise allocating from the mostly full slabs,
* with the aim of reducing fragmentation.
*/
- i915_global_active_shrink();
- i915_global_context_shrink();
- i915_global_objects_shrink();
- i915_global_request_shrink();
- i915_global_scheduler_shrink();
- i915_global_vma_shrink();
+ list_for_each_entry(global, &globals, link)
+ global->shrink();
}
static atomic_t active;
@@ -128,12 +136,7 @@ void __exit i915_globals_exit(void)
rcu_barrier();
flush_scheduled_work();
- i915_global_vma_exit();
- i915_global_scheduler_exit();
- i915_global_request_exit();
- i915_global_objects_exit();
- i915_global_context_exit();
- i915_global_active_exit();
+ __i915_globals_cleanup();
/* And ensure that our DESTROY_BY_RCU slabs are truly destroyed */
rcu_barrier();
diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h
index e468f0413a73..b924ec8d1156 100644
--- a/drivers/gpu/drm/i915/i915_globals.h
+++ b/drivers/gpu/drm/i915/i915_globals.h
@@ -7,6 +7,17 @@
#ifndef _I915_GLOBALS_H_
#define _I915_GLOBALS_H_
+typedef void (*i915_global_func_t)(void);
+
+struct i915_global {
+ struct list_head link;
+
+ i915_global_func_t shrink;
+ i915_global_func_t exit;
+};
+
+void i915_global_register(struct i915_global *global);
+
int i915_globals_init(void);
void i915_globals_park(void);
void i915_globals_unpark(void);
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index bcf3c1a155e2..f8a63495114c 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -31,6 +31,7 @@
#include "i915_drv.h"
#include "i915_active.h"
+#include "i915_globals.h"
#include "i915_reset.h"
struct execute_cb {
@@ -40,6 +41,7 @@ struct execute_cb {
};
static struct i915_global_request {
+ struct i915_global base;
struct kmem_cache *slab_requests;
struct kmem_cache *slab_dependencies;
struct kmem_cache *slab_execute_cbs;
@@ -1338,6 +1340,25 @@ void i915_retire_requests(struct drm_i915_private *i915)
#include "selftests/i915_request.c"
#endif
+static void i915_global_request_shrink(void)
+{
+ kmem_cache_shrink(global.slab_dependencies);
+ kmem_cache_shrink(global.slab_execute_cbs);
+ kmem_cache_shrink(global.slab_requests);
+}
+
+static void i915_global_request_exit(void)
+{
+ kmem_cache_destroy(global.slab_dependencies);
+ kmem_cache_destroy(global.slab_execute_cbs);
+ kmem_cache_destroy(global.slab_requests);
+}
+
+static struct i915_global_request global = { {
+ .shrink = i915_global_request_shrink,
+ .exit = i915_global_request_exit,
+} };
+
int __init i915_global_request_init(void)
{
global.slab_requests = KMEM_CACHE(i915_request,
@@ -1360,6 +1381,7 @@ int __init i915_global_request_init(void)
if (!global.slab_dependencies)
goto err_execute_cbs;
+ i915_global_register(&global.base);
return 0;
err_execute_cbs:
@@ -1368,17 +1390,3 @@ int __init i915_global_request_init(void)
kmem_cache_destroy(global.slab_requests);
return -ENOMEM;
}
-
-void i915_global_request_shrink(void)
-{
- kmem_cache_shrink(global.slab_dependencies);
- kmem_cache_shrink(global.slab_execute_cbs);
- kmem_cache_shrink(global.slab_requests);
-}
-
-void i915_global_request_exit(void)
-{
- kmem_cache_destroy(global.slab_dependencies);
- kmem_cache_destroy(global.slab_execute_cbs);
- kmem_cache_destroy(global.slab_requests);
-}
diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h
index 4dd1dea1d1af..15a46b6cd5ec 100644
--- a/drivers/gpu/drm/i915/i915_request.h
+++ b/drivers/gpu/drm/i915/i915_request.h
@@ -407,7 +407,5 @@ static inline void i915_request_mark_complete(struct i915_request *rq)
void i915_retire_requests(struct drm_i915_private *i915);
int i915_global_request_init(void);
-void i915_global_request_shrink(void);
-void i915_global_request_exit(void);
#endif /* I915_REQUEST_H */
diff --git a/drivers/gpu/drm/i915/i915_scheduler.c b/drivers/gpu/drm/i915/i915_scheduler.c
index 3f0a4d56bd37..e0f609d01564 100644
--- a/drivers/gpu/drm/i915/i915_scheduler.c
+++ b/drivers/gpu/drm/i915/i915_scheduler.c
@@ -7,10 +7,12 @@
#include <linux/mutex.h>
#include "i915_drv.h"
+#include "i915_globals.h"
#include "i915_request.h"
#include "i915_scheduler.h"
static struct i915_global_scheduler {
+ struct i915_global base;
struct kmem_cache *slab_dependencies;
struct kmem_cache *slab_priorities;
} global;
@@ -437,6 +439,23 @@ void __i915_priolist_free(struct i915_priolist *p)
kmem_cache_free(global.slab_priorities, p);
}
+static void i915_global_scheduler_shrink(void)
+{
+ kmem_cache_shrink(global.slab_dependencies);
+ kmem_cache_shrink(global.slab_priorities);
+}
+
+static void i915_global_scheduler_exit(void)
+{
+ kmem_cache_destroy(global.slab_dependencies);
+ kmem_cache_destroy(global.slab_priorities);
+}
+
+static struct i915_global_scheduler global = { {
+ .shrink = i915_global_scheduler_shrink,
+ .exit = i915_global_scheduler_exit,
+} };
+
int __init i915_global_scheduler_init(void)
{
global.slab_dependencies = KMEM_CACHE(i915_dependency,
@@ -449,21 +468,10 @@ int __init i915_global_scheduler_init(void)
if (!global.slab_priorities)
goto err_priorities;
+ i915_global_register(&global.base);
return 0;
err_priorities:
kmem_cache_destroy(global.slab_priorities);
return -ENOMEM;
}
-
-void i915_global_scheduler_shrink(void)
-{
- kmem_cache_shrink(global.slab_dependencies);
- kmem_cache_shrink(global.slab_priorities);
-}
-
-void i915_global_scheduler_exit(void)
-{
- kmem_cache_destroy(global.slab_dependencies);
- kmem_cache_destroy(global.slab_priorities);
-}
diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h
index 6ce450cf63fa..544709019d48 100644
--- a/drivers/gpu/drm/i915/i915_scheduler.h
+++ b/drivers/gpu/drm/i915/i915_scheduler.h
@@ -135,7 +135,5 @@ static inline void i915_priolist_free(struct i915_priolist *p)
}
int i915_global_scheduler_init(void);
-void i915_global_scheduler_shrink(void);
-void i915_global_scheduler_exit(void);
#endif /* _I915_SCHEDULER_H_ */
diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index 757a33998bbf..36726392e737 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -25,12 +25,14 @@
#include "i915_vma.h"
#include "i915_drv.h"
+#include "i915_globals.h"
#include "intel_ringbuffer.h"
#include "intel_frontbuffer.h"
#include <drm/drm_gem.h>
static struct i915_global_vma {
+ struct i915_global base;
struct kmem_cache *slab_vmas;
} global;
@@ -1054,21 +1056,27 @@ int i915_vma_unbind(struct i915_vma *vma)
#include "selftests/i915_vma.c"
#endif
-int __init i915_global_vma_init(void)
+static void i915_global_vma_shrink(void)
{
- global.slab_vmas = KMEM_CACHE(i915_vma, SLAB_HWCACHE_ALIGN);
- if (!global.slab_vmas)
- return -ENOMEM;
-
- return 0;
+ kmem_cache_shrink(global.slab_vmas);
}
-void i915_global_vma_shrink(void)
+static void i915_global_vma_exit(void)
{
- kmem_cache_shrink(global.slab_vmas);
+ kmem_cache_destroy(global.slab_vmas);
}
-void i915_global_vma_exit(void)
+static struct i915_global_vma global = { {
+ .shrink = i915_global_vma_shrink,
+ .exit = i915_global_vma_exit,
+} };
+
+int __init i915_global_vma_init(void)
{
- kmem_cache_destroy(global.slab_vmas);
+ global.slab_vmas = KMEM_CACHE(i915_vma, SLAB_HWCACHE_ALIGN);
+ if (!global.slab_vmas)
+ return -ENOMEM;
+
+ i915_global_register(&global.base);
+ return 0;
}
diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
index 37f93358aa3c..3c3de52cc0d7 100644
--- a/drivers/gpu/drm/i915/i915_vma.h
+++ b/drivers/gpu/drm/i915/i915_vma.h
@@ -444,7 +444,5 @@ struct i915_vma *i915_vma_alloc(void);
void i915_vma_free(struct i915_vma *vma);
int i915_global_vma_init(void);
-void i915_global_vma_shrink(void);
-void i915_global_vma_exit(void);
#endif
--
2.20.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] drm/i915: Use i915_global_register()
2019-03-05 21:06 [PATCH] drm/i915: Use i915_global_register() Chris Wilson
@ 2019-03-05 21:38 ` Chris Wilson
2019-03-05 22:02 ` ✓ Fi.CI.BAT: success for " Patchwork
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Chris Wilson @ 2019-03-05 21:38 UTC (permalink / raw)
To: intel-gfx
Rather than manually add every new global into each hook, use
i915_global_register() function and keep a list of registered globals to
invoke instead.
However, I haven't found a way for random drivers to add an .init table
to avoid having to manually add ourselves to i915_globals_init() each
time.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_active.c | 28 ++++++---
drivers/gpu/drm/i915/i915_active.h | 4 --
drivers/gpu/drm/i915/i915_gem_context.c | 28 ++++++---
drivers/gpu/drm/i915/i915_gem_context.h | 4 --
drivers/gpu/drm/i915/i915_gem_object.c | 28 ++++++---
drivers/gpu/drm/i915/i915_gem_object.h | 4 --
drivers/gpu/drm/i915/i915_globals.c | 82 ++++++++++++-------------
drivers/gpu/drm/i915/i915_globals.h | 19 ++++++
drivers/gpu/drm/i915/i915_request.c | 36 ++++++-----
drivers/gpu/drm/i915/i915_request.h | 4 --
drivers/gpu/drm/i915/i915_scheduler.c | 32 ++++++----
drivers/gpu/drm/i915/i915_scheduler.h | 4 --
drivers/gpu/drm/i915/i915_vma.c | 28 ++++++---
drivers/gpu/drm/i915/i915_vma.h | 4 --
14 files changed, 171 insertions(+), 134 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
index d9f6471ac16c..863ae12707ba 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -6,6 +6,7 @@
#include "i915_drv.h"
#include "i915_active.h"
+#include "i915_globals.h"
#define BKL(ref) (&(ref)->i915->drm.struct_mutex)
@@ -17,6 +18,7 @@
* nodes from a local slab cache to hopefully reduce the fragmentation.
*/
static struct i915_global_active {
+ struct i915_global base;
struct kmem_cache *slab_cache;
} global;
@@ -285,21 +287,27 @@ void i915_active_retire_noop(struct i915_active_request *active,
#include "selftests/i915_active.c"
#endif
-int __init i915_global_active_init(void)
+static void i915_global_active_shrink(void)
{
- global.slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN);
- if (!global.slab_cache)
- return -ENOMEM;
-
- return 0;
+ kmem_cache_shrink(global.slab_cache);
}
-void i915_global_active_shrink(void)
+static void i915_global_active_exit(void)
{
- kmem_cache_shrink(global.slab_cache);
+ kmem_cache_destroy(global.slab_cache);
}
-void i915_global_active_exit(void)
+static struct i915_global_active global = { {
+ .shrink = i915_global_active_shrink,
+ .exit = i915_global_active_exit,
+} };
+
+int __init i915_global_active_init(void)
{
- kmem_cache_destroy(global.slab_cache);
+ global.slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN);
+ if (!global.slab_cache)
+ return -ENOMEM;
+
+ i915_global_register(&global.base);
+ return 0;
}
diff --git a/drivers/gpu/drm/i915/i915_active.h b/drivers/gpu/drm/i915/i915_active.h
index 5fbd9102384b..8142a334b37b 100644
--- a/drivers/gpu/drm/i915/i915_active.h
+++ b/drivers/gpu/drm/i915/i915_active.h
@@ -419,8 +419,4 @@ void i915_active_fini(struct i915_active *ref);
static inline void i915_active_fini(struct i915_active *ref) { }
#endif
-int i915_global_active_init(void);
-void i915_global_active_shrink(void);
-void i915_global_active_exit(void);
-
#endif /* _I915_ACTIVE_H_ */
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 1e3211e909f1..b9f321947982 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -88,6 +88,7 @@
#include <linux/log2.h>
#include <drm/i915_drm.h>
#include "i915_drv.h"
+#include "i915_globals.h"
#include "i915_trace.h"
#include "intel_lrc_reg.h"
#include "intel_workarounds.h"
@@ -95,6 +96,7 @@
#define ALL_L3_SLICES(dev) (1 << NUM_L3_SLICES(dev)) - 1
static struct i915_global_context {
+ struct i915_global base;
struct kmem_cache *slab_luts;
} global;
@@ -1423,21 +1425,27 @@ int __i915_gem_context_pin_hw_id(struct i915_gem_context *ctx)
#include "selftests/i915_gem_context.c"
#endif
-int __init i915_global_context_init(void)
+static void i915_global_context_shrink(void)
{
- global.slab_luts = KMEM_CACHE(i915_lut_handle, 0);
- if (!global.slab_luts)
- return -ENOMEM;
-
- return 0;
+ kmem_cache_shrink(global.slab_luts);
}
-void i915_global_context_shrink(void)
+static void i915_global_context_exit(void)
{
- kmem_cache_shrink(global.slab_luts);
+ kmem_cache_destroy(global.slab_luts);
}
-void i915_global_context_exit(void)
+static struct i915_global_context global = { {
+ .shrink = i915_global_context_shrink,
+ .exit = i915_global_context_exit,
+} };
+
+int __init i915_global_context_init(void)
{
- kmem_cache_destroy(global.slab_luts);
+ global.slab_luts = KMEM_CACHE(i915_lut_handle, 0);
+ if (!global.slab_luts)
+ return -ENOMEM;
+
+ i915_global_register(&global.base);
+ return 0;
}
diff --git a/drivers/gpu/drm/i915/i915_gem_context.h b/drivers/gpu/drm/i915/i915_gem_context.h
index be63666ffaac..2f9ef333acaa 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.h
+++ b/drivers/gpu/drm/i915/i915_gem_context.h
@@ -411,8 +411,4 @@ void intel_context_init(struct intel_context *ce,
struct i915_lut_handle *i915_lut_handle_alloc(void);
void i915_lut_handle_free(struct i915_lut_handle *lut);
-int i915_global_context_init(void);
-void i915_global_context_shrink(void);
-void i915_global_context_exit(void);
-
#endif /* !__I915_GEM_CONTEXT_H__ */
diff --git a/drivers/gpu/drm/i915/i915_gem_object.c b/drivers/gpu/drm/i915/i915_gem_object.c
index 4aeb8c3b87e4..ac6a5ab84586 100644
--- a/drivers/gpu/drm/i915/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/i915_gem_object.c
@@ -24,8 +24,10 @@
#include "i915_drv.h"
#include "i915_gem_object.h"
+#include "i915_globals.h"
static struct i915_global_object {
+ struct i915_global base;
struct kmem_cache *slab_objects;
} global;
@@ -61,6 +63,21 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE);
}
+static void i915_global_objects_shrink(void)
+{
+ kmem_cache_shrink(global.slab_objects);
+}
+
+static void i915_global_objects_exit(void)
+{
+ kmem_cache_destroy(global.slab_objects);
+}
+
+static struct i915_global_object global = { {
+ .shrink = i915_global_objects_shrink,
+ .exit = i915_global_objects_exit,
+} };
+
int __init i915_global_objects_init(void)
{
global.slab_objects =
@@ -68,15 +85,6 @@ int __init i915_global_objects_init(void)
if (!global.slab_objects)
return -ENOMEM;
+ i915_global_register(&global.base);
return 0;
}
-
-void i915_global_objects_shrink(void)
-{
- kmem_cache_shrink(global.slab_objects);
-}
-
-void i915_global_objects_exit(void)
-{
- kmem_cache_destroy(global.slab_objects);
-}
diff --git a/drivers/gpu/drm/i915/i915_gem_object.h b/drivers/gpu/drm/i915/i915_gem_object.h
index 0eaa2b3aeb62..1a24dc97e4fd 100644
--- a/drivers/gpu/drm/i915/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/i915_gem_object.h
@@ -502,8 +502,4 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
unsigned int cache_level);
void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj);
-int i915_global_objects_init(void);
-void i915_global_objects_shrink(void);
-void i915_global_objects_exit(void);
-
#endif
diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c
index cfd0bc462f58..1cf4e8bc8ec6 100644
--- a/drivers/gpu/drm/i915/i915_globals.c
+++ b/drivers/gpu/drm/i915/i915_globals.c
@@ -15,62 +15,61 @@
#include "i915_scheduler.h"
#include "i915_vma.h"
-int __init i915_globals_init(void)
+static LIST_HEAD(globals);
+
+void __init i915_global_register(struct i915_global *global)
{
- int err;
+ GEM_BUG_ON(!global->shrink);
+ GEM_BUG_ON(!global->exit);
- err = i915_global_active_init();
- if (err)
- return err;
+ list_add_tail(&global->link, &globals);
+}
- err = i915_global_context_init();
- if (err)
- goto err_active;
+static void __i915_globals_cleanup(void)
+{
+ struct i915_global *global, *next;
- err = i915_global_objects_init();
- if (err)
- goto err_context;
+ list_for_each_entry_safe_reverse(global, next, &globals, link)
+ global->exit();
+}
- err = i915_global_request_init();
- if (err)
- goto err_objects;
+static __initconst int (* const initfn[])(void) = {
+ i915_global_active_init,
+ i915_global_context_init,
+ i915_global_objects_init,
+ i915_global_request_init,
+ i915_global_scheduler_init,
+ i915_global_vma_init,
+};
- err = i915_global_scheduler_init();
- if (err)
- goto err_request;
+int __init i915_globals_init(void)
+{
+ int i;
- err = i915_global_vma_init();
- if (err)
- goto err_scheduler;
+ for (i = 0; i < ARRAY_SIZE(initfn); i++) {
+ int err;
- return 0;
+ err = initfn[i]();
+ if (err) {
+ __i915_globals_cleanup();
+ return err;
+ }
+ }
-err_scheduler:
- i915_global_scheduler_exit();
-err_request:
- i915_global_request_exit();
-err_objects:
- i915_global_objects_exit();
-err_context:
- i915_global_context_exit();
-err_active:
- i915_global_active_exit();
- return err;
+ return 0;
}
static void i915_globals_shrink(void)
{
+ struct i915_global *global;
+
/*
* kmem_cache_shrink() discards empty slabs and reorders partially
* filled slabs to prioritise allocating from the mostly full slabs,
* with the aim of reducing fragmentation.
*/
- i915_global_active_shrink();
- i915_global_context_shrink();
- i915_global_objects_shrink();
- i915_global_request_shrink();
- i915_global_scheduler_shrink();
- i915_global_vma_shrink();
+ list_for_each_entry(global, &globals, link)
+ global->shrink();
}
static atomic_t active;
@@ -128,12 +127,7 @@ void __exit i915_globals_exit(void)
rcu_barrier();
flush_scheduled_work();
- i915_global_vma_exit();
- i915_global_scheduler_exit();
- i915_global_request_exit();
- i915_global_objects_exit();
- i915_global_context_exit();
- i915_global_active_exit();
+ __i915_globals_cleanup();
/* And ensure that our DESTROY_BY_RCU slabs are truly destroyed */
rcu_barrier();
diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h
index e468f0413a73..a45529022a42 100644
--- a/drivers/gpu/drm/i915/i915_globals.h
+++ b/drivers/gpu/drm/i915/i915_globals.h
@@ -7,9 +7,28 @@
#ifndef _I915_GLOBALS_H_
#define _I915_GLOBALS_H_
+typedef void (*i915_global_func_t)(void);
+
+struct i915_global {
+ struct list_head link;
+
+ i915_global_func_t shrink;
+ i915_global_func_t exit;
+};
+
+void i915_global_register(struct i915_global *global);
+
int i915_globals_init(void);
void i915_globals_park(void);
void i915_globals_unpark(void);
void i915_globals_exit(void);
+/* constructors */
+int i915_global_active_init(void);
+int i915_global_context_init(void);
+int i915_global_objects_init(void);
+int i915_global_request_init(void);
+int i915_global_scheduler_init(void);
+int i915_global_vma_init(void);
+
#endif /* _I915_GLOBALS_H_ */
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index bcf3c1a155e2..f8a63495114c 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -31,6 +31,7 @@
#include "i915_drv.h"
#include "i915_active.h"
+#include "i915_globals.h"
#include "i915_reset.h"
struct execute_cb {
@@ -40,6 +41,7 @@ struct execute_cb {
};
static struct i915_global_request {
+ struct i915_global base;
struct kmem_cache *slab_requests;
struct kmem_cache *slab_dependencies;
struct kmem_cache *slab_execute_cbs;
@@ -1338,6 +1340,25 @@ void i915_retire_requests(struct drm_i915_private *i915)
#include "selftests/i915_request.c"
#endif
+static void i915_global_request_shrink(void)
+{
+ kmem_cache_shrink(global.slab_dependencies);
+ kmem_cache_shrink(global.slab_execute_cbs);
+ kmem_cache_shrink(global.slab_requests);
+}
+
+static void i915_global_request_exit(void)
+{
+ kmem_cache_destroy(global.slab_dependencies);
+ kmem_cache_destroy(global.slab_execute_cbs);
+ kmem_cache_destroy(global.slab_requests);
+}
+
+static struct i915_global_request global = { {
+ .shrink = i915_global_request_shrink,
+ .exit = i915_global_request_exit,
+} };
+
int __init i915_global_request_init(void)
{
global.slab_requests = KMEM_CACHE(i915_request,
@@ -1360,6 +1381,7 @@ int __init i915_global_request_init(void)
if (!global.slab_dependencies)
goto err_execute_cbs;
+ i915_global_register(&global.base);
return 0;
err_execute_cbs:
@@ -1368,17 +1390,3 @@ int __init i915_global_request_init(void)
kmem_cache_destroy(global.slab_requests);
return -ENOMEM;
}
-
-void i915_global_request_shrink(void)
-{
- kmem_cache_shrink(global.slab_dependencies);
- kmem_cache_shrink(global.slab_execute_cbs);
- kmem_cache_shrink(global.slab_requests);
-}
-
-void i915_global_request_exit(void)
-{
- kmem_cache_destroy(global.slab_dependencies);
- kmem_cache_destroy(global.slab_execute_cbs);
- kmem_cache_destroy(global.slab_requests);
-}
diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h
index 4dd1dea1d1af..8c8fa5010644 100644
--- a/drivers/gpu/drm/i915/i915_request.h
+++ b/drivers/gpu/drm/i915/i915_request.h
@@ -406,8 +406,4 @@ static inline void i915_request_mark_complete(struct i915_request *rq)
void i915_retire_requests(struct drm_i915_private *i915);
-int i915_global_request_init(void);
-void i915_global_request_shrink(void);
-void i915_global_request_exit(void);
-
#endif /* I915_REQUEST_H */
diff --git a/drivers/gpu/drm/i915/i915_scheduler.c b/drivers/gpu/drm/i915/i915_scheduler.c
index 3f0a4d56bd37..e0f609d01564 100644
--- a/drivers/gpu/drm/i915/i915_scheduler.c
+++ b/drivers/gpu/drm/i915/i915_scheduler.c
@@ -7,10 +7,12 @@
#include <linux/mutex.h>
#include "i915_drv.h"
+#include "i915_globals.h"
#include "i915_request.h"
#include "i915_scheduler.h"
static struct i915_global_scheduler {
+ struct i915_global base;
struct kmem_cache *slab_dependencies;
struct kmem_cache *slab_priorities;
} global;
@@ -437,6 +439,23 @@ void __i915_priolist_free(struct i915_priolist *p)
kmem_cache_free(global.slab_priorities, p);
}
+static void i915_global_scheduler_shrink(void)
+{
+ kmem_cache_shrink(global.slab_dependencies);
+ kmem_cache_shrink(global.slab_priorities);
+}
+
+static void i915_global_scheduler_exit(void)
+{
+ kmem_cache_destroy(global.slab_dependencies);
+ kmem_cache_destroy(global.slab_priorities);
+}
+
+static struct i915_global_scheduler global = { {
+ .shrink = i915_global_scheduler_shrink,
+ .exit = i915_global_scheduler_exit,
+} };
+
int __init i915_global_scheduler_init(void)
{
global.slab_dependencies = KMEM_CACHE(i915_dependency,
@@ -449,21 +468,10 @@ int __init i915_global_scheduler_init(void)
if (!global.slab_priorities)
goto err_priorities;
+ i915_global_register(&global.base);
return 0;
err_priorities:
kmem_cache_destroy(global.slab_priorities);
return -ENOMEM;
}
-
-void i915_global_scheduler_shrink(void)
-{
- kmem_cache_shrink(global.slab_dependencies);
- kmem_cache_shrink(global.slab_priorities);
-}
-
-void i915_global_scheduler_exit(void)
-{
- kmem_cache_destroy(global.slab_dependencies);
- kmem_cache_destroy(global.slab_priorities);
-}
diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h
index 6ce450cf63fa..9a1d257f3d6e 100644
--- a/drivers/gpu/drm/i915/i915_scheduler.h
+++ b/drivers/gpu/drm/i915/i915_scheduler.h
@@ -134,8 +134,4 @@ static inline void i915_priolist_free(struct i915_priolist *p)
__i915_priolist_free(p);
}
-int i915_global_scheduler_init(void);
-void i915_global_scheduler_shrink(void);
-void i915_global_scheduler_exit(void);
-
#endif /* _I915_SCHEDULER_H_ */
diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index 757a33998bbf..36726392e737 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -25,12 +25,14 @@
#include "i915_vma.h"
#include "i915_drv.h"
+#include "i915_globals.h"
#include "intel_ringbuffer.h"
#include "intel_frontbuffer.h"
#include <drm/drm_gem.h>
static struct i915_global_vma {
+ struct i915_global base;
struct kmem_cache *slab_vmas;
} global;
@@ -1054,21 +1056,27 @@ int i915_vma_unbind(struct i915_vma *vma)
#include "selftests/i915_vma.c"
#endif
-int __init i915_global_vma_init(void)
+static void i915_global_vma_shrink(void)
{
- global.slab_vmas = KMEM_CACHE(i915_vma, SLAB_HWCACHE_ALIGN);
- if (!global.slab_vmas)
- return -ENOMEM;
-
- return 0;
+ kmem_cache_shrink(global.slab_vmas);
}
-void i915_global_vma_shrink(void)
+static void i915_global_vma_exit(void)
{
- kmem_cache_shrink(global.slab_vmas);
+ kmem_cache_destroy(global.slab_vmas);
}
-void i915_global_vma_exit(void)
+static struct i915_global_vma global = { {
+ .shrink = i915_global_vma_shrink,
+ .exit = i915_global_vma_exit,
+} };
+
+int __init i915_global_vma_init(void)
{
- kmem_cache_destroy(global.slab_vmas);
+ global.slab_vmas = KMEM_CACHE(i915_vma, SLAB_HWCACHE_ALIGN);
+ if (!global.slab_vmas)
+ return -ENOMEM;
+
+ i915_global_register(&global.base);
+ return 0;
}
diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
index 37f93358aa3c..6eab70953a57 100644
--- a/drivers/gpu/drm/i915/i915_vma.h
+++ b/drivers/gpu/drm/i915/i915_vma.h
@@ -443,8 +443,4 @@ void i915_vma_parked(struct drm_i915_private *i915);
struct i915_vma *i915_vma_alloc(void);
void i915_vma_free(struct i915_vma *vma);
-int i915_global_vma_init(void);
-void i915_global_vma_shrink(void);
-void i915_global_vma_exit(void);
-
#endif
--
2.20.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 6+ messages in thread
* ✓ Fi.CI.BAT: success for drm/i915: Use i915_global_register()
2019-03-05 21:06 [PATCH] drm/i915: Use i915_global_register() Chris Wilson
2019-03-05 21:38 ` Chris Wilson
@ 2019-03-05 22:02 ` Patchwork
2019-03-05 22:36 ` ✓ Fi.CI.BAT: success for drm/i915: Use i915_global_register() (rev2) Patchwork
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2019-03-05 22:02 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: drm/i915: Use i915_global_register()
URL : https://patchwork.freedesktop.org/series/57605/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5708 -> Patchwork_12379
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/57605/revisions/1/mbox/
Known issues
------------
Here are the changes found in Patchwork_12379 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_module_load@reload-with-fault-injection:
- fi-kbl-7567u: PASS -> DMESG-WARN [fdo#105602] / [fdo#108529] +1
* igt@i915_pm_rpm@module-reload:
- fi-kbl-7567u: PASS -> DMESG-WARN [fdo#108529]
* igt@i915_selftest@live_execlists:
- fi-apl-guc: PASS -> INCOMPLETE [fdo#103927] / [fdo#109720]
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-kbl-7567u: PASS -> DMESG-FAIL [fdo#105079]
* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-b-frame-sequence:
- fi-byt-clapper: PASS -> FAIL [fdo#103191] / [fdo#107362]
* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-c:
- fi-kbl-7567u: PASS -> SKIP [fdo#109271] +33
* igt@kms_pipe_crc_basic@read-crc-pipe-b:
- fi-byt-clapper: PASS -> FAIL [fdo#107362]
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
- fi-blb-e6850: NOTRUN -> INCOMPLETE [fdo#107718]
* igt@runner@aborted:
- fi-apl-guc: NOTRUN -> FAIL [fdo#108622] / [fdo#109720]
#### Possible fixes ####
* igt@i915_pm_rpm@module-reload:
- fi-kbl-7560u: CRASH -> PASS
* igt@kms_busy@basic-flip-a:
- fi-gdg-551: FAIL [fdo#103182] -> PASS
* igt@kms_frontbuffer_tracking@basic:
- fi-icl-u3: FAIL [fdo#103167] -> PASS
* igt@kms_pipe_crc_basic@read-crc-pipe-a-frame-sequence:
- fi-byt-clapper: FAIL [fdo#103191] / [fdo#107362] -> PASS
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
- fi-blb-e6850: INCOMPLETE [fdo#107718] -> PASS
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105079]: https://bugs.freedesktop.org/show_bug.cgi?id=105079
[fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108529]: https://bugs.freedesktop.org/show_bug.cgi?id=108529
[fdo#108622]: https://bugs.freedesktop.org/show_bug.cgi?id=108622
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109720]: https://bugs.freedesktop.org/show_bug.cgi?id=109720
Participating hosts (47 -> 41)
------------------------------
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-bdw-samus
Build changes
-------------
* Linux: CI_DRM_5708 -> Patchwork_12379
CI_DRM_5708: afd34c5dec857362de91fb3044f09d90e83ad6a5 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4871: 8feb147562ba1b364615ddacd44c3846f0250d37 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12379: 9f0d6f6166e052777db105d5958df10b243f2764 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
9f0d6f6166e0 drm/i915: Use i915_global_register()
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12379/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* ✓ Fi.CI.BAT: success for drm/i915: Use i915_global_register() (rev2)
2019-03-05 21:06 [PATCH] drm/i915: Use i915_global_register() Chris Wilson
2019-03-05 21:38 ` Chris Wilson
2019-03-05 22:02 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2019-03-05 22:36 ` Patchwork
2019-03-06 3:36 ` ✓ Fi.CI.IGT: " Patchwork
2019-03-06 9:21 ` [PATCH] drm/i915: Use i915_global_register() Tvrtko Ursulin
4 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2019-03-05 22:36 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: drm/i915: Use i915_global_register() (rev2)
URL : https://patchwork.freedesktop.org/series/57605/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5708 -> Patchwork_12380
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/57605/revisions/2/mbox/
Known issues
------------
Here are the changes found in Patchwork_12380 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_suspend@basic-s3:
- fi-blb-e6850: PASS -> INCOMPLETE [fdo#107718]
* igt@i915_module_load@reload-with-fault-injection:
- fi-kbl-7567u: PASS -> DMESG-WARN [fdo#105602] / [fdo#108529] +1
* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-bsw-kefka: PASS -> SKIP [fdo#109271]
* igt@i915_pm_rpm@basic-rte:
- fi-bsw-kefka: PASS -> FAIL [fdo#108800]
* igt@i915_pm_rpm@module-reload:
- fi-kbl-7567u: PASS -> DMESG-WARN [fdo#108529]
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-kbl-7567u: PASS -> DMESG-FAIL [fdo#105079]
* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a:
- fi-byt-clapper: PASS -> FAIL [fdo#107362]
* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-c:
- fi-kbl-7567u: PASS -> SKIP [fdo#109271] +33
* igt@prime_vgem@basic-fence-flip:
- fi-ilk-650: PASS -> FAIL [fdo#104008]
#### Possible fixes ####
* igt@gem_mmap@basic-small-bo:
- {fi-icl-y}: DMESG-WARN -> PASS
* igt@kms_busy@basic-flip-a:
- fi-gdg-551: FAIL [fdo#103182] -> PASS
* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a-frame-sequence:
- fi-byt-clapper: FAIL [fdo#103191] / [fdo#107362] -> PASS +1
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#104008]: https://bugs.freedesktop.org/show_bug.cgi?id=104008
[fdo#105079]: https://bugs.freedesktop.org/show_bug.cgi?id=105079
[fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108529]: https://bugs.freedesktop.org/show_bug.cgi?id=108529
[fdo#108654]: https://bugs.freedesktop.org/show_bug.cgi?id=108654
[fdo#108800]: https://bugs.freedesktop.org/show_bug.cgi?id=108800
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
Participating hosts (47 -> 41)
------------------------------
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-bdw-samus fi-snb-2600
Build changes
-------------
* Linux: CI_DRM_5708 -> Patchwork_12380
CI_DRM_5708: afd34c5dec857362de91fb3044f09d90e83ad6a5 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4871: 8feb147562ba1b364615ddacd44c3846f0250d37 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12380: 660fc43c5f670066093edad2df5d1266c6a804e5 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
660fc43c5f67 drm/i915: Use i915_global_register()
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12380/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* ✓ Fi.CI.IGT: success for drm/i915: Use i915_global_register() (rev2)
2019-03-05 21:06 [PATCH] drm/i915: Use i915_global_register() Chris Wilson
` (2 preceding siblings ...)
2019-03-05 22:36 ` ✓ Fi.CI.BAT: success for drm/i915: Use i915_global_register() (rev2) Patchwork
@ 2019-03-06 3:36 ` Patchwork
2019-03-06 9:21 ` [PATCH] drm/i915: Use i915_global_register() Tvrtko Ursulin
4 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2019-03-06 3:36 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: drm/i915: Use i915_global_register() (rev2)
URL : https://patchwork.freedesktop.org/series/57605/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5708_full -> Patchwork_12380_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Known issues
------------
Here are the changes found in Patchwork_12380_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_pwrite@big-cpu-fbr:
- shard-apl: PASS -> INCOMPLETE [fdo#103927]
* igt@i915_pm_rpm@fences-dpms:
- shard-skl: PASS -> INCOMPLETE [fdo#107807]
* igt@kms_atomic_transition@3x-modeset-transitions:
- shard-snb: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +6
* igt@kms_busy@extended-modeset-hang-oldfb-with-reset-render-d:
- shard-kbl: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]
* igt@kms_busy@extended-pageflip-hang-newfb-render-f:
- shard-skl: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +5
* igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-a:
- shard-snb: NOTRUN -> DMESG-WARN [fdo#107956]
* igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-c:
- shard-skl: NOTRUN -> DMESG-WARN [fdo#107956]
* igt@kms_cursor_crc@cursor-128x128-onscreen:
- shard-apl: PASS -> FAIL [fdo#103232]
* igt@kms_cursor_crc@cursor-256x85-onscreen:
- shard-skl: NOTRUN -> FAIL [fdo#103232]
* igt@kms_fbcon_fbt@psr:
- shard-skl: NOTRUN -> FAIL [fdo#103833]
* igt@kms_fence_pin_leak:
- shard-snb: PASS -> SKIP [fdo#109271]
* igt@kms_flip_tiling@flip-changes-tiling-y:
- shard-skl: PASS -> FAIL [fdo#107931] / [fdo#108303]
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-blt:
- shard-apl: PASS -> FAIL [fdo#103167]
* igt@kms_frontbuffer_tracking@fbc-1p-rte:
- shard-apl: PASS -> FAIL [fdo#103167] / [fdo#105682]
* igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-cur-indfb-draw-render:
- shard-snb: NOTRUN -> SKIP [fdo#109271] +38
* igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-pri-indfb-draw-blt:
- shard-skl: NOTRUN -> SKIP [fdo#109271] +46
* igt@kms_frontbuffer_tracking@fbcpsr-1p-pri-indfb-multidraw:
- shard-skl: PASS -> FAIL [fdo#105682]
* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-shrfb-plflip-blt:
- shard-kbl: NOTRUN -> SKIP [fdo#109271] +15
* igt@kms_frontbuffer_tracking@psr-1p-offscren-pri-shrfb-draw-blt:
- shard-skl: PASS -> FAIL [fdo#103167]
* igt@kms_panel_fitting@legacy:
- shard-skl: NOTRUN -> FAIL [fdo#105456]
* igt@kms_plane@pixel-format-pipe-b-planes-source-clamping:
- shard-skl: NOTRUN -> DMESG-WARN [fdo#106885]
* igt@kms_plane@pixel-format-pipe-c-planes-source-clamping:
- shard-glk: PASS -> FAIL [fdo#108948]
* igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes:
- shard-skl: PASS -> INCOMPLETE [fdo#104108]
* igt@kms_plane@plane-position-covered-pipe-a-planes:
- shard-apl: PASS -> FAIL [fdo#103166] +1
* igt@kms_plane@plane-position-covered-pipe-c-planes:
- shard-glk: PASS -> FAIL [fdo#103166] +1
* igt@kms_plane_alpha_blend@pipe-b-alpha-7efc:
- shard-skl: NOTRUN -> FAIL [fdo#107815] / [fdo#108145]
* igt@kms_plane_alpha_blend@pipe-b-coverage-7efc:
- shard-skl: PASS -> FAIL [fdo#107815]
* igt@kms_rotation_crc@primary-rotation-270:
- shard-skl: PASS -> FAIL [fdo#103925] / [fdo#107815]
#### Possible fixes ####
* igt@i915_pm_rpm@gem-execbuf-stress-extra-wait:
- shard-skl: INCOMPLETE [fdo#107803] / [fdo#107807] -> PASS
* igt@kms_cursor_crc@cursor-alpha-opaque:
- shard-apl: FAIL [fdo#109350] -> PASS
* igt@kms_cursor_crc@cursor-size-change:
- shard-apl: FAIL [fdo#103232] -> PASS
* igt@kms_flip@flip-vs-expired-vblank:
- shard-skl: FAIL [fdo#105363] -> PASS
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-pwrite:
- shard-apl: FAIL [fdo#103167] -> PASS
* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-cpu:
- shard-glk: FAIL [fdo#103167] -> PASS
* igt@kms_frontbuffer_tracking@fbcpsr-rgb101010-draw-mmap-wc:
- shard-skl: FAIL [fdo#103167] / [fdo#105682] -> PASS
* igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
- shard-skl: FAIL [fdo#107815] -> PASS
* igt@kms_rotation_crc@multiplane-rotation:
- shard-kbl: INCOMPLETE [fdo#103665] -> PASS
* igt@kms_universal_plane@universal-plane-pipe-c-functional:
- shard-apl: FAIL [fdo#103166] -> PASS +1
#### Warnings ####
* igt@kms_plane@pixel-format-pipe-b-planes:
- shard-skl: DMESG-FAIL [fdo#103166] / [fdo#106885] -> FAIL [fdo#103166]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#103833]: https://bugs.freedesktop.org/show_bug.cgi?id=103833
[fdo#103925]: https://bugs.freedesktop.org/show_bug.cgi?id=103925
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#104108]: https://bugs.freedesktop.org/show_bug.cgi?id=104108
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#105456]: https://bugs.freedesktop.org/show_bug.cgi?id=105456
[fdo#105682]: https://bugs.freedesktop.org/show_bug.cgi?id=105682
[fdo#106885]: https://bugs.freedesktop.org/show_bug.cgi?id=106885
[fdo#107803]: https://bugs.freedesktop.org/show_bug.cgi?id=107803
[fdo#107807]: https://bugs.freedesktop.org/show_bug.cgi?id=107807
[fdo#107815]: https://bugs.freedesktop.org/show_bug.cgi?id=107815
[fdo#107931]: https://bugs.freedesktop.org/show_bug.cgi?id=107931
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108303]: https://bugs.freedesktop.org/show_bug.cgi?id=108303
[fdo#108948]: https://bugs.freedesktop.org/show_bug.cgi?id=108948
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109350]: https://bugs.freedesktop.org/show_bug.cgi?id=109350
Participating hosts (6 -> 6)
------------------------------
No changes in participating hosts
Build changes
-------------
* Linux: CI_DRM_5708 -> Patchwork_12380
CI_DRM_5708: afd34c5dec857362de91fb3044f09d90e83ad6a5 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4871: 8feb147562ba1b364615ddacd44c3846f0250d37 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12380: 660fc43c5f670066093edad2df5d1266c6a804e5 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12380/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/i915: Use i915_global_register()
2019-03-05 21:06 [PATCH] drm/i915: Use i915_global_register() Chris Wilson
` (3 preceding siblings ...)
2019-03-06 3:36 ` ✓ Fi.CI.IGT: " Patchwork
@ 2019-03-06 9:21 ` Tvrtko Ursulin
4 siblings, 0 replies; 6+ messages in thread
From: Tvrtko Ursulin @ 2019-03-06 9:21 UTC (permalink / raw)
To: Chris Wilson, intel-gfx
On 05/03/2019 21:06, Chris Wilson wrote:
> Rather than manually add every new global into each hook, use
> i915_global_register() function and keep a list of registered globals to
> invoke instead.
>
> However, I haven't found a way for random drivers to add an .init table
> to avoid having to manually add ourselves to i915_globals_init() each
> time.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_active.c | 28 +++++++-----
> drivers/gpu/drm/i915/i915_active.h | 2 -
> drivers/gpu/drm/i915/i915_gem_context.c | 28 +++++++-----
> drivers/gpu/drm/i915/i915_gem_context.h | 2 -
> drivers/gpu/drm/i915/i915_gem_object.c | 28 +++++++-----
> drivers/gpu/drm/i915/i915_gem_object.h | 2 -
> drivers/gpu/drm/i915/i915_globals.c | 59 +++++++++++++------------
> drivers/gpu/drm/i915/i915_globals.h | 11 +++++
> drivers/gpu/drm/i915/i915_request.c | 36 +++++++++------
> drivers/gpu/drm/i915/i915_request.h | 2 -
> drivers/gpu/drm/i915/i915_scheduler.c | 32 +++++++++-----
> drivers/gpu/drm/i915/i915_scheduler.h | 2 -
> drivers/gpu/drm/i915/i915_vma.c | 28 +++++++-----
> drivers/gpu/drm/i915/i915_vma.h | 2 -
> 14 files changed, 156 insertions(+), 106 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
> index d9f6471ac16c..863ae12707ba 100644
> --- a/drivers/gpu/drm/i915/i915_active.c
> +++ b/drivers/gpu/drm/i915/i915_active.c
> @@ -6,6 +6,7 @@
>
> #include "i915_drv.h"
> #include "i915_active.h"
> +#include "i915_globals.h"
>
> #define BKL(ref) (&(ref)->i915->drm.struct_mutex)
>
> @@ -17,6 +18,7 @@
> * nodes from a local slab cache to hopefully reduce the fragmentation.
> */
> static struct i915_global_active {
> + struct i915_global base;
> struct kmem_cache *slab_cache;
> } global;
>
> @@ -285,21 +287,27 @@ void i915_active_retire_noop(struct i915_active_request *active,
> #include "selftests/i915_active.c"
> #endif
>
> -int __init i915_global_active_init(void)
> +static void i915_global_active_shrink(void)
> {
> - global.slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN);
> - if (!global.slab_cache)
> - return -ENOMEM;
> -
> - return 0;
> + kmem_cache_shrink(global.slab_cache);
> }
>
> -void i915_global_active_shrink(void)
> +static void i915_global_active_exit(void)
> {
> - kmem_cache_shrink(global.slab_cache);
> + kmem_cache_destroy(global.slab_cache);
> }
>
> -void i915_global_active_exit(void)
> +static struct i915_global_active global = { {
> + .shrink = i915_global_active_shrink,
> + .exit = i915_global_active_exit,
> +} };
> +
> +int __init i915_global_active_init(void)
> {
> - kmem_cache_destroy(global.slab_cache);
> + global.slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN);
> + if (!global.slab_cache)
> + return -ENOMEM;
> +
> + i915_global_register(&global.base);
> + return 0;
> }
> diff --git a/drivers/gpu/drm/i915/i915_active.h b/drivers/gpu/drm/i915/i915_active.h
> index 5fbd9102384b..575c01846875 100644
> --- a/drivers/gpu/drm/i915/i915_active.h
> +++ b/drivers/gpu/drm/i915/i915_active.h
> @@ -420,7 +420,5 @@ static inline void i915_active_fini(struct i915_active *ref) { }
> #endif
>
> int i915_global_active_init(void);
> -void i915_global_active_shrink(void);
> -void i915_global_active_exit(void);
>
> #endif /* _I915_ACTIVE_H_ */
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 1e3211e909f1..b9f321947982 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -88,6 +88,7 @@
> #include <linux/log2.h>
> #include <drm/i915_drm.h>
> #include "i915_drv.h"
> +#include "i915_globals.h"
> #include "i915_trace.h"
> #include "intel_lrc_reg.h"
> #include "intel_workarounds.h"
> @@ -95,6 +96,7 @@
> #define ALL_L3_SLICES(dev) (1 << NUM_L3_SLICES(dev)) - 1
>
> static struct i915_global_context {
> + struct i915_global base;
> struct kmem_cache *slab_luts;
> } global;
>
> @@ -1423,21 +1425,27 @@ int __i915_gem_context_pin_hw_id(struct i915_gem_context *ctx)
> #include "selftests/i915_gem_context.c"
> #endif
>
> -int __init i915_global_context_init(void)
> +static void i915_global_context_shrink(void)
> {
> - global.slab_luts = KMEM_CACHE(i915_lut_handle, 0);
> - if (!global.slab_luts)
> - return -ENOMEM;
> -
> - return 0;
> + kmem_cache_shrink(global.slab_luts);
> }
>
> -void i915_global_context_shrink(void)
> +static void i915_global_context_exit(void)
> {
> - kmem_cache_shrink(global.slab_luts);
> + kmem_cache_destroy(global.slab_luts);
> }
>
> -void i915_global_context_exit(void)
> +static struct i915_global_context global = { {
> + .shrink = i915_global_context_shrink,
> + .exit = i915_global_context_exit,
> +} };
> +
> +int __init i915_global_context_init(void)
> {
> - kmem_cache_destroy(global.slab_luts);
> + global.slab_luts = KMEM_CACHE(i915_lut_handle, 0);
> + if (!global.slab_luts)
> + return -ENOMEM;
> +
> + i915_global_register(&global.base);
> + return 0;
> }
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.h b/drivers/gpu/drm/i915/i915_gem_context.h
> index be63666ffaac..b59107248b54 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.h
> +++ b/drivers/gpu/drm/i915/i915_gem_context.h
> @@ -412,7 +412,5 @@ struct i915_lut_handle *i915_lut_handle_alloc(void);
> void i915_lut_handle_free(struct i915_lut_handle *lut);
>
> int i915_global_context_init(void);
> -void i915_global_context_shrink(void);
> -void i915_global_context_exit(void);
>
> #endif /* !__I915_GEM_CONTEXT_H__ */
> diff --git a/drivers/gpu/drm/i915/i915_gem_object.c b/drivers/gpu/drm/i915/i915_gem_object.c
> index 4aeb8c3b87e4..ac6a5ab84586 100644
> --- a/drivers/gpu/drm/i915/i915_gem_object.c
> +++ b/drivers/gpu/drm/i915/i915_gem_object.c
> @@ -24,8 +24,10 @@
>
> #include "i915_drv.h"
> #include "i915_gem_object.h"
> +#include "i915_globals.h"
>
> static struct i915_global_object {
> + struct i915_global base;
> struct kmem_cache *slab_objects;
> } global;
>
> @@ -61,6 +63,21 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
> !(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE);
> }
>
> +static void i915_global_objects_shrink(void)
> +{
> + kmem_cache_shrink(global.slab_objects);
> +}
> +
> +static void i915_global_objects_exit(void)
> +{
> + kmem_cache_destroy(global.slab_objects);
> +}
> +
> +static struct i915_global_object global = { {
> + .shrink = i915_global_objects_shrink,
> + .exit = i915_global_objects_exit,
> +} };
> +
> int __init i915_global_objects_init(void)
> {
> global.slab_objects =
> @@ -68,15 +85,6 @@ int __init i915_global_objects_init(void)
> if (!global.slab_objects)
> return -ENOMEM;
>
> + i915_global_register(&global.base);
> return 0;
> }
> -
> -void i915_global_objects_shrink(void)
> -{
> - kmem_cache_shrink(global.slab_objects);
> -}
> -
> -void i915_global_objects_exit(void)
> -{
> - kmem_cache_destroy(global.slab_objects);
> -}
> diff --git a/drivers/gpu/drm/i915/i915_gem_object.h b/drivers/gpu/drm/i915/i915_gem_object.h
> index 0eaa2b3aeb62..75d49fe12d18 100644
> --- a/drivers/gpu/drm/i915/i915_gem_object.h
> +++ b/drivers/gpu/drm/i915/i915_gem_object.h
> @@ -503,7 +503,5 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
> void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj);
>
> int i915_global_objects_init(void);
> -void i915_global_objects_shrink(void);
> -void i915_global_objects_exit(void);
>
> #endif
> diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c
> index cfd0bc462f58..383b43d86e71 100644
> --- a/drivers/gpu/drm/i915/i915_globals.c
> +++ b/drivers/gpu/drm/i915/i915_globals.c
> @@ -15,62 +15,70 @@
> #include "i915_scheduler.h"
> #include "i915_vma.h"
>
> +static LIST_HEAD(globals);
> +
> +void __init i915_global_register(struct i915_global *global)
> +{
> + GEM_BUG_ON(!global->shrink);
> + GEM_BUG_ON(!global->exit);
> +
> + list_add_tail(&global->link, &globals);
> +}
> +
> +static void __i915_globals_cleanup(void)
> +{
> + struct i915_global *global, *next;
> +
> + list_for_each_entry_safe_reverse(global, next, &globals, link)
> + global->exit();
> +}
> +
> int __init i915_globals_init(void)
> {
> int err;
>
> err = i915_global_active_init();
> if (err)
> - return err;
> + goto err;
>
> err = i915_global_context_init();
> if (err)
> - goto err_active;
> + goto err;
>
> err = i915_global_objects_init();
> if (err)
> - goto err_context;
> + goto err;
>
> err = i915_global_request_init();
> if (err)
> - goto err_objects;
> + goto err;
>
> err = i915_global_scheduler_init();
> if (err)
> - goto err_request;
> + goto err;
>
> err = i915_global_vma_init();
> if (err)
> - goto err_scheduler;
> + goto err;
>
> return 0;
>
> -err_scheduler:
> - i915_global_scheduler_exit();
> -err_request:
> - i915_global_request_exit();
> -err_objects:
> - i915_global_objects_exit();
> -err_context:
> - i915_global_context_exit();
> -err_active:
> - i915_global_active_exit();
> +err:
> + __i915_globals_cleanup();
> return err;
> }
>
> static void i915_globals_shrink(void)
> {
> + struct i915_global *global;
> +
> /*
> * kmem_cache_shrink() discards empty slabs and reorders partially
> * filled slabs to prioritise allocating from the mostly full slabs,
> * with the aim of reducing fragmentation.
> */
> - i915_global_active_shrink();
> - i915_global_context_shrink();
> - i915_global_objects_shrink();
> - i915_global_request_shrink();
> - i915_global_scheduler_shrink();
> - i915_global_vma_shrink();
> + list_for_each_entry(global, &globals, link)
> + global->shrink();
> }
>
> static atomic_t active;
> @@ -128,12 +136,7 @@ void __exit i915_globals_exit(void)
> rcu_barrier();
> flush_scheduled_work();
>
> - i915_global_vma_exit();
> - i915_global_scheduler_exit();
> - i915_global_request_exit();
> - i915_global_objects_exit();
> - i915_global_context_exit();
> - i915_global_active_exit();
> + __i915_globals_cleanup();
>
> /* And ensure that our DESTROY_BY_RCU slabs are truly destroyed */
> rcu_barrier();
> diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h
> index e468f0413a73..b924ec8d1156 100644
> --- a/drivers/gpu/drm/i915/i915_globals.h
> +++ b/drivers/gpu/drm/i915/i915_globals.h
> @@ -7,6 +7,17 @@
> #ifndef _I915_GLOBALS_H_
> #define _I915_GLOBALS_H_
>
> +typedef void (*i915_global_func_t)(void);
> +
> +struct i915_global {
> + struct list_head link;
> +
> + i915_global_func_t shrink;
> + i915_global_func_t exit;
> +};
> +
> +void i915_global_register(struct i915_global *global);
> +
> int i915_globals_init(void);
> void i915_globals_park(void);
> void i915_globals_unpark(void);
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index bcf3c1a155e2..f8a63495114c 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -31,6 +31,7 @@
>
> #include "i915_drv.h"
> #include "i915_active.h"
> +#include "i915_globals.h"
> #include "i915_reset.h"
>
> struct execute_cb {
> @@ -40,6 +41,7 @@ struct execute_cb {
> };
>
> static struct i915_global_request {
> + struct i915_global base;
> struct kmem_cache *slab_requests;
> struct kmem_cache *slab_dependencies;
> struct kmem_cache *slab_execute_cbs;
> @@ -1338,6 +1340,25 @@ void i915_retire_requests(struct drm_i915_private *i915)
> #include "selftests/i915_request.c"
> #endif
>
> +static void i915_global_request_shrink(void)
> +{
> + kmem_cache_shrink(global.slab_dependencies);
> + kmem_cache_shrink(global.slab_execute_cbs);
> + kmem_cache_shrink(global.slab_requests);
> +}
> +
> +static void i915_global_request_exit(void)
> +{
> + kmem_cache_destroy(global.slab_dependencies);
> + kmem_cache_destroy(global.slab_execute_cbs);
> + kmem_cache_destroy(global.slab_requests);
> +}
> +
> +static struct i915_global_request global = { {
> + .shrink = i915_global_request_shrink,
> + .exit = i915_global_request_exit,
> +} };
> +
> int __init i915_global_request_init(void)
> {
> global.slab_requests = KMEM_CACHE(i915_request,
> @@ -1360,6 +1381,7 @@ int __init i915_global_request_init(void)
> if (!global.slab_dependencies)
> goto err_execute_cbs;
>
> + i915_global_register(&global.base);
> return 0;
>
> err_execute_cbs:
> @@ -1368,17 +1390,3 @@ int __init i915_global_request_init(void)
> kmem_cache_destroy(global.slab_requests);
> return -ENOMEM;
> }
> -
> -void i915_global_request_shrink(void)
> -{
> - kmem_cache_shrink(global.slab_dependencies);
> - kmem_cache_shrink(global.slab_execute_cbs);
> - kmem_cache_shrink(global.slab_requests);
> -}
> -
> -void i915_global_request_exit(void)
> -{
> - kmem_cache_destroy(global.slab_dependencies);
> - kmem_cache_destroy(global.slab_execute_cbs);
> - kmem_cache_destroy(global.slab_requests);
> -}
> diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h
> index 4dd1dea1d1af..15a46b6cd5ec 100644
> --- a/drivers/gpu/drm/i915/i915_request.h
> +++ b/drivers/gpu/drm/i915/i915_request.h
> @@ -407,7 +407,5 @@ static inline void i915_request_mark_complete(struct i915_request *rq)
> void i915_retire_requests(struct drm_i915_private *i915);
>
> int i915_global_request_init(void);
> -void i915_global_request_shrink(void);
> -void i915_global_request_exit(void);
>
> #endif /* I915_REQUEST_H */
> diff --git a/drivers/gpu/drm/i915/i915_scheduler.c b/drivers/gpu/drm/i915/i915_scheduler.c
> index 3f0a4d56bd37..e0f609d01564 100644
> --- a/drivers/gpu/drm/i915/i915_scheduler.c
> +++ b/drivers/gpu/drm/i915/i915_scheduler.c
> @@ -7,10 +7,12 @@
> #include <linux/mutex.h>
>
> #include "i915_drv.h"
> +#include "i915_globals.h"
> #include "i915_request.h"
> #include "i915_scheduler.h"
>
> static struct i915_global_scheduler {
> + struct i915_global base;
> struct kmem_cache *slab_dependencies;
> struct kmem_cache *slab_priorities;
> } global;
> @@ -437,6 +439,23 @@ void __i915_priolist_free(struct i915_priolist *p)
> kmem_cache_free(global.slab_priorities, p);
> }
>
> +static void i915_global_scheduler_shrink(void)
> +{
> + kmem_cache_shrink(global.slab_dependencies);
> + kmem_cache_shrink(global.slab_priorities);
> +}
> +
> +static void i915_global_scheduler_exit(void)
> +{
> + kmem_cache_destroy(global.slab_dependencies);
> + kmem_cache_destroy(global.slab_priorities);
> +}
> +
> +static struct i915_global_scheduler global = { {
> + .shrink = i915_global_scheduler_shrink,
> + .exit = i915_global_scheduler_exit,
> +} };
> +
> int __init i915_global_scheduler_init(void)
> {
> global.slab_dependencies = KMEM_CACHE(i915_dependency,
> @@ -449,21 +468,10 @@ int __init i915_global_scheduler_init(void)
> if (!global.slab_priorities)
> goto err_priorities;
>
> + i915_global_register(&global.base);
> return 0;
>
> err_priorities:
> kmem_cache_destroy(global.slab_priorities);
> return -ENOMEM;
> }
> -
> -void i915_global_scheduler_shrink(void)
> -{
> - kmem_cache_shrink(global.slab_dependencies);
> - kmem_cache_shrink(global.slab_priorities);
> -}
> -
> -void i915_global_scheduler_exit(void)
> -{
> - kmem_cache_destroy(global.slab_dependencies);
> - kmem_cache_destroy(global.slab_priorities);
> -}
> diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h
> index 6ce450cf63fa..544709019d48 100644
> --- a/drivers/gpu/drm/i915/i915_scheduler.h
> +++ b/drivers/gpu/drm/i915/i915_scheduler.h
> @@ -135,7 +135,5 @@ static inline void i915_priolist_free(struct i915_priolist *p)
> }
>
> int i915_global_scheduler_init(void);
> -void i915_global_scheduler_shrink(void);
> -void i915_global_scheduler_exit(void);
>
> #endif /* _I915_SCHEDULER_H_ */
> diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
> index 757a33998bbf..36726392e737 100644
> --- a/drivers/gpu/drm/i915/i915_vma.c
> +++ b/drivers/gpu/drm/i915/i915_vma.c
> @@ -25,12 +25,14 @@
> #include "i915_vma.h"
>
> #include "i915_drv.h"
> +#include "i915_globals.h"
> #include "intel_ringbuffer.h"
> #include "intel_frontbuffer.h"
>
> #include <drm/drm_gem.h>
>
> static struct i915_global_vma {
> + struct i915_global base;
> struct kmem_cache *slab_vmas;
> } global;
>
> @@ -1054,21 +1056,27 @@ int i915_vma_unbind(struct i915_vma *vma)
> #include "selftests/i915_vma.c"
> #endif
>
> -int __init i915_global_vma_init(void)
> +static void i915_global_vma_shrink(void)
> {
> - global.slab_vmas = KMEM_CACHE(i915_vma, SLAB_HWCACHE_ALIGN);
> - if (!global.slab_vmas)
> - return -ENOMEM;
> -
> - return 0;
> + kmem_cache_shrink(global.slab_vmas);
> }
>
> -void i915_global_vma_shrink(void)
> +static void i915_global_vma_exit(void)
> {
> - kmem_cache_shrink(global.slab_vmas);
> + kmem_cache_destroy(global.slab_vmas);
> }
>
> -void i915_global_vma_exit(void)
> +static struct i915_global_vma global = { {
> + .shrink = i915_global_vma_shrink,
> + .exit = i915_global_vma_exit,
> +} };
> +
> +int __init i915_global_vma_init(void)
> {
> - kmem_cache_destroy(global.slab_vmas);
> + global.slab_vmas = KMEM_CACHE(i915_vma, SLAB_HWCACHE_ALIGN);
> + if (!global.slab_vmas)
> + return -ENOMEM;
> +
> + i915_global_register(&global.base);
> + return 0;
> }
> diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
> index 37f93358aa3c..3c3de52cc0d7 100644
> --- a/drivers/gpu/drm/i915/i915_vma.h
> +++ b/drivers/gpu/drm/i915/i915_vma.h
> @@ -444,7 +444,5 @@ struct i915_vma *i915_vma_alloc(void);
> void i915_vma_free(struct i915_vma *vma);
>
> int i915_global_vma_init(void);
> -void i915_global_vma_shrink(void);
> -void i915_global_vma_exit(void);
>
> #endif
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-03-06 9:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-05 21:06 [PATCH] drm/i915: Use i915_global_register() Chris Wilson
2019-03-05 21:38 ` Chris Wilson
2019-03-05 22:02 ` ✓ Fi.CI.BAT: success for " Patchwork
2019-03-05 22:36 ` ✓ Fi.CI.BAT: success for drm/i915: Use i915_global_register() (rev2) Patchwork
2019-03-06 3:36 ` ✓ Fi.CI.IGT: " Patchwork
2019-03-06 9:21 ` [PATCH] drm/i915: Use i915_global_register() Tvrtko Ursulin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.