drm/i915: Use i915_global_register()
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> Link: https://patchwork.freedesktop.org/patch/msgid/20190305213830.18094-1-chris@chris-wilson.co.uk Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
This commit is contained in:
@@ -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
|
||||
|
||||
static void i915_global_active_shrink(void)
|
||||
{
|
||||
kmem_cache_shrink(global.slab_cache);
|
||||
}
|
||||
|
||||
static void i915_global_active_exit(void)
|
||||
{
|
||||
kmem_cache_destroy(global.slab_cache);
|
||||
}
|
||||
|
||||
static struct i915_global_active global = { {
|
||||
.shrink = i915_global_active_shrink,
|
||||
.exit = i915_global_active_exit,
|
||||
} };
|
||||
|
||||
int __init i915_global_active_init(void)
|
||||
{
|
||||
global.slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN);
|
||||
if (!global.slab_cache)
|
||||
return -ENOMEM;
|
||||
|
||||
i915_global_register(&global.base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void i915_global_active_shrink(void)
|
||||
{
|
||||
kmem_cache_shrink(global.slab_cache);
|
||||
}
|
||||
|
||||
void i915_global_active_exit(void)
|
||||
{
|
||||
kmem_cache_destroy(global.slab_cache);
|
||||
}
|
||||
|
Reference in New Issue
Block a user