When modesetting (aka the full pci driver, which has nothing to do with disable_display option, which just gives you the full pci driver without the display driver) is disabled, we load nothing and do nothing.
So move that check first, for a bit of orderliness. With Jason's module init/exit table this now becomes trivial.
Reviewed-by: Jason Ekstrand jason@jlekstrand.net Cc: Jason Ekstrand jason@jlekstrand.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/i915/i915_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index f28206484552..eb520fcb32e4 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -1293,9 +1293,9 @@ static const struct { int (*init)(void); void (*exit)(void); } init_funcs[] = { + { i915_check_nomodeset, NULL }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, - { i915_check_nomodeset, NULL }, { i915_pmu_init, i915_pmu_exit }, { i915_register_pci_driver, i915_unregister_pci_driver }, { i915_perf_sysctl_register, i915_perf_sysctl_unregister },
With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over.
I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_cache to just a slab_cache.
v2: Make slab static (Jason, 0day)
Reviewed-by: Jason Ekstrand jason@jlekstrand.net Cc: Jason Ekstrand jason@jlekstrand.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/i915/i915_active.c | 31 ++++++++++------------------- drivers/gpu/drm/i915/i915_active.h | 3 +++ drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_globals.h | 1 - drivers/gpu/drm/i915/i915_pci.c | 2 ++ 5 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c index 91723123ae9f..3103c1e1fd14 100644 --- a/drivers/gpu/drm/i915/i915_active.c +++ b/drivers/gpu/drm/i915/i915_active.c @@ -13,7 +13,6 @@
#include "i915_drv.h" #include "i915_active.h" -#include "i915_globals.h"
/* * Active refs memory management @@ -22,10 +21,7 @@ * they idle (when we know the active requests are inactive) and allocate the * 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; +static struct kmem_cache *slab_cache;
struct active_node { struct rb_node node; @@ -174,7 +170,7 @@ __active_retire(struct i915_active *ref) /* Finally free the discarded timeline tree */ rbtree_postorder_for_each_entry_safe(it, n, &root, node) { GEM_BUG_ON(i915_active_fence_isset(&it->base)); - kmem_cache_free(global.slab_cache, it); + kmem_cache_free(slab_cache, it); } }
@@ -322,7 +318,7 @@ active_instance(struct i915_active *ref, u64 idx) * XXX: We should preallocate this before i915_active_ref() is ever * called, but we cannot call into fs_reclaim() anyway, so use GFP_ATOMIC. */ - node = kmem_cache_alloc(global.slab_cache, GFP_ATOMIC); + node = kmem_cache_alloc(slab_cache, GFP_ATOMIC); if (!node) goto out;
@@ -788,7 +784,7 @@ void i915_active_fini(struct i915_active *ref) mutex_destroy(&ref->mutex);
if (ref->cache) - kmem_cache_free(global.slab_cache, ref->cache); + kmem_cache_free(slab_cache, ref->cache); }
static inline bool is_idle_barrier(struct active_node *node, u64 idx) @@ -908,7 +904,7 @@ int i915_active_acquire_preallocate_barrier(struct i915_active *ref, node = reuse_idle_barrier(ref, idx); rcu_read_unlock(); if (!node) { - node = kmem_cache_alloc(global.slab_cache, GFP_KERNEL); + node = kmem_cache_alloc(slab_cache, GFP_KERNEL); if (!node) goto unwind;
@@ -956,7 +952,7 @@ int i915_active_acquire_preallocate_barrier(struct i915_active *ref, atomic_dec(&ref->count); intel_engine_pm_put(barrier_to_engine(node));
- kmem_cache_free(global.slab_cache, node); + kmem_cache_free(slab_cache, node); } return -ENOMEM; } @@ -1176,21 +1172,16 @@ struct i915_active *i915_active_create(void) #include "selftests/i915_active.c" #endif
-static void i915_global_active_exit(void) +void i915_active_module_exit(void) { - kmem_cache_destroy(global.slab_cache); + kmem_cache_destroy(slab_cache); }
-static struct i915_global_active global = { { - .exit = i915_global_active_exit, -} }; - -int __init i915_global_active_init(void) +int __init i915_active_module_init(void) { - global.slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN); - if (!global.slab_cache) + slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN); + if (!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 d0feda68b874..5fcdb0e2bc9e 100644 --- a/drivers/gpu/drm/i915/i915_active.h +++ b/drivers/gpu/drm/i915/i915_active.h @@ -247,4 +247,7 @@ static inline int __i915_request_await_exclusive(struct i915_request *rq, return err; }
+void i915_active_module_exit(void); +int i915_active_module_init(void); + #endif /* _I915_ACTIVE_H_ */ diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index 91198f5b0a06..a53135ee831d 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -7,7 +7,6 @@ #include <linux/slab.h> #include <linux/workqueue.h>
-#include "i915_active.h" #include "i915_buddy.h" #include "gem/i915_gem_context.h" #include "gem/i915_gem_object.h" @@ -34,7 +33,6 @@ static void __i915_globals_cleanup(void) }
static __initconst int (* const initfn[])(void) = { - i915_global_active_init, i915_global_buddy_init, i915_global_context_init, i915_global_gem_context_init, diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index 9e6b4fd07528..d80901ba75e3 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -23,7 +23,6 @@ int i915_globals_init(void); void i915_globals_exit(void);
/* constructors */ -int i915_global_active_init(void); int i915_global_context_init(void); int i915_global_gem_context_init(void); int i915_global_objects_init(void); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index eb520fcb32e4..2a1726e9ae7f 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -30,6 +30,7 @@
#include "display/intel_fbdev.h"
+#include "i915_active.h" #include "i915_drv.h" #include "i915_perf.h" #include "i915_globals.h" @@ -1294,6 +1295,7 @@ static const struct { void (*exit)(void); } init_funcs[] = { { i915_check_nomodeset, NULL }, + { i915_active_module_init, i915_active_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit },
With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over.
I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_blocks to just a slab_blocks.
v2: Make slab static (Jason, 0day)
Reviewed-by: Jason Ekstrand jason@jlekstrand.net Cc: Jason Ekstrand jason@jlekstrand.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/i915/i915_buddy.c | 25 ++++++++----------------- drivers/gpu/drm/i915/i915_buddy.h | 3 ++- drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_pci.c | 2 ++ 4 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_buddy.c b/drivers/gpu/drm/i915/i915_buddy.c index caabcaea3be7..7b274c51cac0 100644 --- a/drivers/gpu/drm/i915/i915_buddy.c +++ b/drivers/gpu/drm/i915/i915_buddy.c @@ -8,13 +8,9 @@ #include "i915_buddy.h"
#include "i915_gem.h" -#include "i915_globals.h" #include "i915_utils.h"
-static struct i915_global_buddy { - struct i915_global base; - struct kmem_cache *slab_blocks; -} global; +static struct kmem_cache *slab_blocks;
static struct i915_buddy_block *i915_block_alloc(struct i915_buddy_mm *mm, struct i915_buddy_block *parent, @@ -25,7 +21,7 @@ static struct i915_buddy_block *i915_block_alloc(struct i915_buddy_mm *mm,
GEM_BUG_ON(order > I915_BUDDY_MAX_ORDER);
- block = kmem_cache_zalloc(global.slab_blocks, GFP_KERNEL); + block = kmem_cache_zalloc(slab_blocks, GFP_KERNEL); if (!block) return NULL;
@@ -40,7 +36,7 @@ static struct i915_buddy_block *i915_block_alloc(struct i915_buddy_mm *mm, static void i915_block_free(struct i915_buddy_mm *mm, struct i915_buddy_block *block) { - kmem_cache_free(global.slab_blocks, block); + kmem_cache_free(slab_blocks, block); }
static void mark_allocated(struct i915_buddy_block *block) @@ -410,21 +406,16 @@ int i915_buddy_alloc_range(struct i915_buddy_mm *mm, #include "selftests/i915_buddy.c" #endif
-static void i915_global_buddy_exit(void) +void i915_buddy_module_exit(void) { - kmem_cache_destroy(global.slab_blocks); + kmem_cache_destroy(slab_blocks); }
-static struct i915_global_buddy global = { { - .exit = i915_global_buddy_exit, -} }; - -int __init i915_global_buddy_init(void) +int __init i915_buddy_module_init(void) { - global.slab_blocks = KMEM_CACHE(i915_buddy_block, 0); - if (!global.slab_blocks) + slab_blocks = KMEM_CACHE(i915_buddy_block, 0); + if (!slab_blocks) return -ENOMEM;
- i915_global_register(&global.base); return 0; } diff --git a/drivers/gpu/drm/i915/i915_buddy.h b/drivers/gpu/drm/i915/i915_buddy.h index d8f26706de52..3940d632f208 100644 --- a/drivers/gpu/drm/i915/i915_buddy.h +++ b/drivers/gpu/drm/i915/i915_buddy.h @@ -129,6 +129,7 @@ void i915_buddy_free(struct i915_buddy_mm *mm, struct i915_buddy_block *block);
void i915_buddy_free_list(struct i915_buddy_mm *mm, struct list_head *objects);
-int i915_global_buddy_init(void); +void i915_buddy_module_exit(void); +int i915_buddy_module_init(void);
#endif diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index a53135ee831d..3de7cf22ec76 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -7,7 +7,6 @@ #include <linux/slab.h> #include <linux/workqueue.h>
-#include "i915_buddy.h" #include "gem/i915_gem_context.h" #include "gem/i915_gem_object.h" #include "i915_globals.h" @@ -33,7 +32,6 @@ static void __i915_globals_cleanup(void) }
static __initconst int (* const initfn[])(void) = { - i915_global_buddy_init, i915_global_context_init, i915_global_gem_context_init, i915_global_objects_init, diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 2a1726e9ae7f..22d9e769ec74 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -31,6 +31,7 @@ #include "display/intel_fbdev.h"
#include "i915_active.h" +#include "i915_buddy.h" #include "i915_drv.h" #include "i915_perf.h" #include "i915_globals.h" @@ -1296,6 +1297,7 @@ static const struct { } init_funcs[] = { { i915_check_nomodeset, NULL }, { i915_active_module_init, i915_active_module_exit }, + { i915_buddy_module_init, i915_buddy_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit },
With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over.
I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_ce to just a slab_ce.
v2: Make slab static (Jason, 0day)
Reviewed-by: Jason Ekstrand jason@jlekstrand.net Cc: Jason Ekstrand jason@jlekstrand.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/i915/gt/intel_context.c | 25 ++++++++----------------- drivers/gpu/drm/i915/gt/intel_context.h | 3 +++ drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_globals.h | 1 - drivers/gpu/drm/i915/i915_pci.c | 2 ++ 5 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c index baa05fddd690..0ba49d74f94d 100644 --- a/drivers/gpu/drm/i915/gt/intel_context.c +++ b/drivers/gpu/drm/i915/gt/intel_context.c @@ -7,7 +7,6 @@ #include "gem/i915_gem_pm.h"
#include "i915_drv.h" -#include "i915_globals.h" #include "i915_trace.h"
#include "intel_context.h" @@ -15,14 +14,11 @@ #include "intel_engine_pm.h" #include "intel_ring.h"
-static struct i915_global_context { - struct i915_global base; - struct kmem_cache *slab_ce; -} global; +static struct kmem_cache *slab_ce;
static struct intel_context *intel_context_alloc(void) { - return kmem_cache_zalloc(global.slab_ce, GFP_KERNEL); + return kmem_cache_zalloc(slab_ce, GFP_KERNEL); }
static void rcu_context_free(struct rcu_head *rcu) @@ -30,7 +26,7 @@ static void rcu_context_free(struct rcu_head *rcu) struct intel_context *ce = container_of(rcu, typeof(*ce), rcu);
trace_intel_context_free(ce); - kmem_cache_free(global.slab_ce, ce); + kmem_cache_free(slab_ce, ce); }
void intel_context_free(struct intel_context *ce) @@ -410,22 +406,17 @@ void intel_context_fini(struct intel_context *ce) i915_active_fini(&ce->active); }
-static void i915_global_context_exit(void) +void i915_context_module_exit(void) { - kmem_cache_destroy(global.slab_ce); + kmem_cache_destroy(slab_ce); }
-static struct i915_global_context global = { { - .exit = i915_global_context_exit, -} }; - -int __init i915_global_context_init(void) +int __init i915_context_module_init(void) { - global.slab_ce = KMEM_CACHE(intel_context, SLAB_HWCACHE_ALIGN); - if (!global.slab_ce) + slab_ce = KMEM_CACHE(intel_context, SLAB_HWCACHE_ALIGN); + if (!slab_ce) return -ENOMEM;
- i915_global_register(&global.base); return 0; }
diff --git a/drivers/gpu/drm/i915/gt/intel_context.h b/drivers/gpu/drm/i915/gt/intel_context.h index 974ef85320c2..a0ca82e3c40d 100644 --- a/drivers/gpu/drm/i915/gt/intel_context.h +++ b/drivers/gpu/drm/i915/gt/intel_context.h @@ -30,6 +30,9 @@ void intel_context_init(struct intel_context *ce, struct intel_engine_cs *engine); void intel_context_fini(struct intel_context *ce);
+void i915_context_module_exit(void); +int i915_context_module_init(void); + struct intel_context * intel_context_create(struct intel_engine_cs *engine);
diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index 3de7cf22ec76..d36eb7dc40aa 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -7,7 +7,6 @@ #include <linux/slab.h> #include <linux/workqueue.h>
-#include "gem/i915_gem_context.h" #include "gem/i915_gem_object.h" #include "i915_globals.h" #include "i915_request.h" @@ -32,7 +31,6 @@ static void __i915_globals_cleanup(void) }
static __initconst int (* const initfn[])(void) = { - i915_global_context_init, i915_global_gem_context_init, i915_global_objects_init, i915_global_request_init, diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index d80901ba75e3..60daa738a188 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -23,7 +23,6 @@ int i915_globals_init(void); void i915_globals_exit(void);
/* constructors */ -int i915_global_context_init(void); int i915_global_gem_context_init(void); int i915_global_objects_init(void); int i915_global_request_init(void); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 22d9e769ec74..8a9b0daef029 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -33,6 +33,7 @@ #include "i915_active.h" #include "i915_buddy.h" #include "i915_drv.h" +#include "gem/i915_gem_context.h" #include "i915_perf.h" #include "i915_globals.h" #include "i915_selftest.h" @@ -1298,6 +1299,7 @@ static const struct { { i915_check_nomodeset, NULL }, { i915_active_module_init, i915_active_module_exit }, { i915_buddy_module_init, i915_buddy_module_exit }, + { i915_context_module_init, i915_context_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit },
With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over.
I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_luts to just a slab_luts.
v2: Make slab static (Jason, 0day)
Reviewed-by: Jason Ekstrand jason@jlekstrand.net Cc: Jason Ekstrand jason@jlekstrand.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/i915/gem/i915_gem_context.c | 25 +++++++-------------- drivers/gpu/drm/i915/gem/i915_gem_context.h | 3 +++ drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_globals.h | 1 - drivers/gpu/drm/i915/i915_pci.c | 2 ++ 5 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c index 89ca401bf9ae..087e1ede6c43 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c @@ -79,25 +79,21 @@ #include "gt/intel_ring.h"
#include "i915_gem_context.h" -#include "i915_globals.h" #include "i915_trace.h" #include "i915_user_extensions.h"
#define ALL_L3_SLICES(dev) (1 << NUM_L3_SLICES(dev)) - 1
-static struct i915_global_gem_context { - struct i915_global base; - struct kmem_cache *slab_luts; -} global; +static struct kmem_cache *slab_luts;
struct i915_lut_handle *i915_lut_handle_alloc(void) { - return kmem_cache_alloc(global.slab_luts, GFP_KERNEL); + return kmem_cache_alloc(slab_luts, GFP_KERNEL); }
void i915_lut_handle_free(struct i915_lut_handle *lut) { - return kmem_cache_free(global.slab_luts, lut); + return kmem_cache_free(slab_luts, lut); }
static void lut_close(struct i915_gem_context *ctx) @@ -2282,21 +2278,16 @@ i915_gem_engines_iter_next(struct i915_gem_engines_iter *it) #include "selftests/i915_gem_context.c" #endif
-static void i915_global_gem_context_exit(void) +void i915_gem_context_module_exit(void) { - kmem_cache_destroy(global.slab_luts); + kmem_cache_destroy(slab_luts); }
-static struct i915_global_gem_context global = { { - .exit = i915_global_gem_context_exit, -} }; - -int __init i915_global_gem_context_init(void) +int __init i915_gem_context_module_init(void) { - global.slab_luts = KMEM_CACHE(i915_lut_handle, 0); - if (!global.slab_luts) + slab_luts = KMEM_CACHE(i915_lut_handle, 0); + if (!slab_luts) return -ENOMEM;
- i915_global_register(&global.base); return 0; } diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.h b/drivers/gpu/drm/i915/gem/i915_gem_context.h index 20411db84914..18060536b0c2 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.h @@ -224,6 +224,9 @@ i915_gem_engines_iter_next(struct i915_gem_engines_iter *it); for (i915_gem_engines_iter_init(&(it), (engines)); \ ((ce) = i915_gem_engines_iter_next(&(it)));)
+void i915_gem_context_module_exit(void); +int i915_gem_context_module_init(void); + struct i915_lut_handle *i915_lut_handle_alloc(void); void i915_lut_handle_free(struct i915_lut_handle *lut);
diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index d36eb7dc40aa..dbb3d81eeea7 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -7,7 +7,6 @@ #include <linux/slab.h> #include <linux/workqueue.h>
-#include "gem/i915_gem_object.h" #include "i915_globals.h" #include "i915_request.h" #include "i915_scheduler.h" @@ -31,7 +30,6 @@ static void __i915_globals_cleanup(void) }
static __initconst int (* const initfn[])(void) = { - i915_global_gem_context_init, i915_global_objects_init, i915_global_request_init, i915_global_scheduler_init, diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index 60daa738a188..f16752dbbdbf 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -23,7 +23,6 @@ int i915_globals_init(void); void i915_globals_exit(void);
/* constructors */ -int i915_global_gem_context_init(void); int i915_global_objects_init(void); int i915_global_request_init(void); int i915_global_scheduler_init(void); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 8a9b0daef029..410a85a1cbab 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -34,6 +34,7 @@ #include "i915_buddy.h" #include "i915_drv.h" #include "gem/i915_gem_context.h" +#include "gem/i915_gem_object.h" #include "i915_perf.h" #include "i915_globals.h" #include "i915_selftest.h" @@ -1300,6 +1301,7 @@ static const struct { { i915_active_module_init, i915_active_module_exit }, { i915_buddy_module_init, i915_buddy_module_exit }, { i915_context_module_init, i915_context_module_exit }, + { i915_gem_context_module_init, i915_gem_context_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit },
With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over.
I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_objects to just a slab_objects.
v2: Make slab static (Jason, 0day)
Reviewed-by: Jason Ekstrand jason@jlekstrand.net Cc: Jason Ekstrand jason@jlekstrand.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/i915/gem/i915_gem_object.c | 26 +++++++--------------- drivers/gpu/drm/i915/gem/i915_gem_object.h | 3 +++ drivers/gpu/drm/i915/i915_globals.c | 1 - drivers/gpu/drm/i915/i915_globals.h | 1 - drivers/gpu/drm/i915/i915_pci.c | 1 + 5 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i915/gem/i915_gem_object.c index 9d3497e1235a..6fb9afb65034 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c @@ -30,14 +30,10 @@ #include "i915_gem_context.h" #include "i915_gem_mman.h" #include "i915_gem_object.h" -#include "i915_globals.h" #include "i915_memcpy.h" #include "i915_trace.h"
-static struct i915_global_object { - struct i915_global base; - struct kmem_cache *slab_objects; -} global; +static struct kmem_cache *slab_objects;
static const struct drm_gem_object_funcs i915_gem_object_funcs;
@@ -45,7 +41,7 @@ struct drm_i915_gem_object *i915_gem_object_alloc(void) { struct drm_i915_gem_object *obj;
- obj = kmem_cache_zalloc(global.slab_objects, GFP_KERNEL); + obj = kmem_cache_zalloc(slab_objects, GFP_KERNEL); if (!obj) return NULL; obj->base.funcs = &i915_gem_object_funcs; @@ -55,7 +51,7 @@ struct drm_i915_gem_object *i915_gem_object_alloc(void)
void i915_gem_object_free(struct drm_i915_gem_object *obj) { - return kmem_cache_free(global.slab_objects, obj); + return kmem_cache_free(slab_objects, obj); }
void i915_gem_object_init(struct drm_i915_gem_object *obj, @@ -658,23 +654,17 @@ void i915_gem_init__objects(struct drm_i915_private *i915) INIT_WORK(&i915->mm.free_work, __i915_gem_free_work); }
-static void i915_global_objects_exit(void) +void i915_objects_module_exit(void) { - kmem_cache_destroy(global.slab_objects); + kmem_cache_destroy(slab_objects); }
-static struct i915_global_object global = { { - .exit = i915_global_objects_exit, -} }; - -int __init i915_global_objects_init(void) +int __init i915_objects_module_init(void) { - global.slab_objects = - KMEM_CACHE(drm_i915_gem_object, SLAB_HWCACHE_ALIGN); - if (!global.slab_objects) + slab_objects = KMEM_CACHE(drm_i915_gem_object, SLAB_HWCACHE_ALIGN); + if (!slab_objects) return -ENOMEM;
- i915_global_register(&global.base); return 0; }
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h index 0896ac532f5e..48112b9d76df 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h @@ -48,6 +48,9 @@ static inline bool i915_gem_object_size_2big(u64 size)
void i915_gem_init__objects(struct drm_i915_private *i915);
+void i915_objects_module_exit(void); +int i915_objects_module_init(void); + struct drm_i915_gem_object *i915_gem_object_alloc(void); void i915_gem_object_free(struct drm_i915_gem_object *obj);
diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index dbb3d81eeea7..40a592fbc3e0 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -30,7 +30,6 @@ static void __i915_globals_cleanup(void) }
static __initconst int (* const initfn[])(void) = { - i915_global_objects_init, i915_global_request_init, i915_global_scheduler_init, i915_global_vma_init, diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index f16752dbbdbf..9734740708f4 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -23,7 +23,6 @@ int i915_globals_init(void); void i915_globals_exit(void);
/* constructors */ -int i915_global_objects_init(void); int i915_global_request_init(void); int i915_global_scheduler_init(void); int i915_global_vma_init(void); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 410a85a1cbab..7a13570c04a5 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -1302,6 +1302,7 @@ static const struct { { i915_buddy_module_init, i915_buddy_module_exit }, { i915_context_module_init, i915_context_module_exit }, { i915_gem_context_module_init, i915_gem_context_module_exit }, + { i915_objects_module_init, i915_objects_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit },
With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over.
I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_requests|execute_cbs to just a slab_requests|execute_cbs.
v2: Make slab static (Jason, 0day)
Reviewed-by: Jason Ekstrand jason@jlekstrand.net Cc: Jason Ekstrand jason@jlekstrand.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_pci.c | 2 ++ drivers/gpu/drm/i915/i915_request.c | 47 ++++++++++++----------------- drivers/gpu/drm/i915/i915_request.h | 3 ++ 4 files changed, 24 insertions(+), 30 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index 40a592fbc3e0..8fffa8d93bc5 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -8,7 +8,6 @@ #include <linux/workqueue.h>
#include "i915_globals.h" -#include "i915_request.h" #include "i915_scheduler.h" #include "i915_vma.h"
@@ -30,7 +29,6 @@ static void __i915_globals_cleanup(void) }
static __initconst int (* const initfn[])(void) = { - i915_global_request_init, i915_global_scheduler_init, i915_global_vma_init, }; diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 7a13570c04a5..3f1716a3d74f 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -35,6 +35,7 @@ #include "i915_drv.h" #include "gem/i915_gem_context.h" #include "gem/i915_gem_object.h" +#include "i915_request.h" #include "i915_perf.h" #include "i915_globals.h" #include "i915_selftest.h" @@ -1303,6 +1304,7 @@ static const struct { { i915_context_module_init, i915_context_module_exit }, { i915_gem_context_module_init, i915_gem_context_module_exit }, { i915_objects_module_init, i915_objects_module_exit }, + { i915_request_module_init, i915_request_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index 6594cb2f8ebd..3dd759be3c28 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -42,7 +42,6 @@
#include "i915_active.h" #include "i915_drv.h" -#include "i915_globals.h" #include "i915_trace.h" #include "intel_pm.h"
@@ -52,11 +51,8 @@ struct execute_cb { struct i915_request *signal; };
-static struct i915_global_request { - struct i915_global base; - struct kmem_cache *slab_requests; - struct kmem_cache *slab_execute_cbs; -} global; +static struct kmem_cache *slab_requests; +static struct kmem_cache *slab_execute_cbs;
static const char *i915_fence_get_driver_name(struct dma_fence *fence) { @@ -107,7 +103,7 @@ static signed long i915_fence_wait(struct dma_fence *fence,
struct kmem_cache *i915_request_slab_cache(void) { - return global.slab_requests; + return slab_requests; }
static void i915_fence_release(struct dma_fence *fence) @@ -159,7 +155,7 @@ static void i915_fence_release(struct dma_fence *fence) !cmpxchg(&rq->engine->request_pool, NULL, rq)) return;
- kmem_cache_free(global.slab_requests, rq); + kmem_cache_free(slab_requests, rq); }
const struct dma_fence_ops i915_fence_ops = { @@ -176,7 +172,7 @@ static void irq_execute_cb(struct irq_work *wrk) struct execute_cb *cb = container_of(wrk, typeof(*cb), work);
i915_sw_fence_complete(cb->fence); - kmem_cache_free(global.slab_execute_cbs, cb); + kmem_cache_free(slab_execute_cbs, cb); }
static __always_inline void @@ -514,7 +510,7 @@ __await_execution(struct i915_request *rq, if (i915_request_is_active(signal)) return 0;
- cb = kmem_cache_alloc(global.slab_execute_cbs, gfp); + cb = kmem_cache_alloc(slab_execute_cbs, gfp); if (!cb) return -ENOMEM;
@@ -868,7 +864,7 @@ request_alloc_slow(struct intel_timeline *tl, rq = list_first_entry(&tl->requests, typeof(*rq), link); i915_request_retire(rq);
- rq = kmem_cache_alloc(global.slab_requests, + rq = kmem_cache_alloc(slab_requests, gfp | __GFP_RETRY_MAYFAIL | __GFP_NOWARN); if (rq) return rq; @@ -881,7 +877,7 @@ request_alloc_slow(struct intel_timeline *tl, retire_requests(tl);
out: - return kmem_cache_alloc(global.slab_requests, gfp); + return kmem_cache_alloc(slab_requests, gfp); }
static void __i915_request_ctor(void *arg) @@ -942,7 +938,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp) * * Do not use kmem_cache_zalloc() here! */ - rq = kmem_cache_alloc(global.slab_requests, + rq = kmem_cache_alloc(slab_requests, gfp | __GFP_RETRY_MAYFAIL | __GFP_NOWARN); if (unlikely(!rq)) { rq = request_alloc_slow(tl, &ce->engine->request_pool, gfp); @@ -1029,7 +1025,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp) GEM_BUG_ON(!list_empty(&rq->sched.waiters_list));
err_free: - kmem_cache_free(global.slab_requests, rq); + kmem_cache_free(slab_requests, rq); err_unreserve: intel_context_unpin(ce); return ERR_PTR(ret); @@ -2084,19 +2080,15 @@ void i915_request_show(struct drm_printer *m, #include "selftests/i915_request.c" #endif
-static void i915_global_request_exit(void) +void i915_request_module_exit(void) { - kmem_cache_destroy(global.slab_execute_cbs); - kmem_cache_destroy(global.slab_requests); + kmem_cache_destroy(slab_execute_cbs); + kmem_cache_destroy(slab_requests); }
-static struct i915_global_request global = { { - .exit = i915_global_request_exit, -} }; - -int __init i915_global_request_init(void) +int __init i915_request_module_init(void) { - global.slab_requests = + slab_requests = kmem_cache_create("i915_request", sizeof(struct i915_request), __alignof__(struct i915_request), @@ -2104,20 +2096,19 @@ int __init i915_global_request_init(void) SLAB_RECLAIM_ACCOUNT | SLAB_TYPESAFE_BY_RCU, __i915_request_ctor); - if (!global.slab_requests) + if (!slab_requests) return -ENOMEM;
- global.slab_execute_cbs = KMEM_CACHE(execute_cb, + slab_execute_cbs = KMEM_CACHE(execute_cb, SLAB_HWCACHE_ALIGN | SLAB_RECLAIM_ACCOUNT | SLAB_TYPESAFE_BY_RCU); - if (!global.slab_execute_cbs) + if (!slab_execute_cbs) goto err_requests;
- i915_global_register(&global.base); return 0;
err_requests: - kmem_cache_destroy(global.slab_requests); + kmem_cache_destroy(slab_requests); return -ENOMEM; } diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h index 717e5b292046..a79480f07f04 100644 --- a/drivers/gpu/drm/i915/i915_request.h +++ b/drivers/gpu/drm/i915/i915_request.h @@ -647,4 +647,7 @@ bool i915_request_active_engine(struct i915_request *rq, struct intel_engine_cs **active);
+void i915_request_module_exit(void); +int i915_request_module_init(void); + #endif /* I915_REQUEST_H */
With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over.
I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_dependencies|priorities to just a slab_dependencies|priorities.
v2: Make slab static (Jason, 0day)
Reviewed-by: Jason Ekstrand jason@jlekstrand.net Cc: Jason Ekstrand jason@jlekstrand.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_globals.h | 2 -- drivers/gpu/drm/i915/i915_pci.c | 2 ++ drivers/gpu/drm/i915/i915_scheduler.c | 39 +++++++++++---------------- drivers/gpu/drm/i915/i915_scheduler.h | 3 +++ 5 files changed, 20 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index 8fffa8d93bc5..8923589057ab 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -8,7 +8,6 @@ #include <linux/workqueue.h>
#include "i915_globals.h" -#include "i915_scheduler.h" #include "i915_vma.h"
static LIST_HEAD(globals); @@ -29,7 +28,6 @@ static void __i915_globals_cleanup(void) }
static __initconst int (* const initfn[])(void) = { - i915_global_scheduler_init, i915_global_vma_init, };
diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index 9734740708f4..7a57bce1da05 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -23,8 +23,6 @@ int i915_globals_init(void); void i915_globals_exit(void);
/* constructors */ -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_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 3f1716a3d74f..500897d0d4b5 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -39,6 +39,7 @@ #include "i915_perf.h" #include "i915_globals.h" #include "i915_selftest.h" +#include "i915_scheduler.h"
#define PLATFORM(x) .platform = (x) #define GEN(x) \ @@ -1305,6 +1306,7 @@ static const struct { { i915_gem_context_module_init, i915_gem_context_module_exit }, { i915_objects_module_init, i915_objects_module_exit }, { i915_request_module_init, i915_request_module_exit }, + { i915_scheduler_module_init, i915_scheduler_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, diff --git a/drivers/gpu/drm/i915/i915_scheduler.c b/drivers/gpu/drm/i915/i915_scheduler.c index 561c649e59f7..c7ea5a1f3b94 100644 --- a/drivers/gpu/drm/i915/i915_scheduler.c +++ b/drivers/gpu/drm/i915/i915_scheduler.c @@ -7,15 +7,11 @@ #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; +static struct kmem_cache *slab_dependencies; +static struct kmem_cache *slab_priorities;
static DEFINE_SPINLOCK(schedule_lock);
@@ -93,7 +89,7 @@ i915_sched_lookup_priolist(struct i915_sched_engine *sched_engine, int prio) if (prio == I915_PRIORITY_NORMAL) { p = &sched_engine->default_priolist; } else { - p = kmem_cache_alloc(global.slab_priorities, GFP_ATOMIC); + p = kmem_cache_alloc(slab_priorities, GFP_ATOMIC); /* Convert an allocation failure to a priority bump */ if (unlikely(!p)) { prio = I915_PRIORITY_NORMAL; /* recurses just once */ @@ -122,7 +118,7 @@ i915_sched_lookup_priolist(struct i915_sched_engine *sched_engine, int prio)
void __i915_priolist_free(struct i915_priolist *p) { - kmem_cache_free(global.slab_priorities, p); + kmem_cache_free(slab_priorities, p); }
struct sched_cache { @@ -313,13 +309,13 @@ void i915_sched_node_reinit(struct i915_sched_node *node) static struct i915_dependency * i915_dependency_alloc(void) { - return kmem_cache_alloc(global.slab_dependencies, GFP_KERNEL); + return kmem_cache_alloc(slab_dependencies, GFP_KERNEL); }
static void i915_dependency_free(struct i915_dependency *dep) { - kmem_cache_free(global.slab_dependencies, dep); + kmem_cache_free(slab_dependencies, dep); }
bool __i915_sched_node_add_dependency(struct i915_sched_node *node, @@ -475,32 +471,27 @@ i915_sched_engine_create(unsigned int subclass) return sched_engine; }
-static void i915_global_scheduler_exit(void) +void i915_scheduler_module_exit(void) { - kmem_cache_destroy(global.slab_dependencies); - kmem_cache_destroy(global.slab_priorities); + kmem_cache_destroy(slab_dependencies); + kmem_cache_destroy(slab_priorities); }
-static struct i915_global_scheduler global = { { - .exit = i915_global_scheduler_exit, -} }; - -int __init i915_global_scheduler_init(void) +int __init i915_scheduler_module_init(void) { - global.slab_dependencies = KMEM_CACHE(i915_dependency, + slab_dependencies = KMEM_CACHE(i915_dependency, SLAB_HWCACHE_ALIGN | SLAB_TYPESAFE_BY_RCU); - if (!global.slab_dependencies) + if (!slab_dependencies) return -ENOMEM;
- global.slab_priorities = KMEM_CACHE(i915_priolist, 0); - if (!global.slab_priorities) + slab_priorities = KMEM_CACHE(i915_priolist, 0); + if (!slab_priorities) goto err_priorities;
- i915_global_register(&global.base); return 0;
err_priorities: - kmem_cache_destroy(global.slab_priorities); + kmem_cache_destroy(slab_priorities); return -ENOMEM; } diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h index 650ab8e0db9f..0a4f61fd0be0 100644 --- a/drivers/gpu/drm/i915/i915_scheduler.h +++ b/drivers/gpu/drm/i915/i915_scheduler.h @@ -98,4 +98,7 @@ void i915_request_show_with_schedule(struct drm_printer *m, const char *prefix, int indent);
+void i915_scheduler_module_exit(void); +int i915_scheduler_module_init(void); + #endif /* _I915_SCHEDULER_H_ */
With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over.
I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_vmas to just a slab_vmas.
We have to keep i915_drv.h include in i915_globals otherwise there's nothing anymore that pulls in GEM_BUG_ON.
v2: Make slab static (Jason, 0day)
Reviewed-by: Jason Ekstrand jason@jlekstrand.net Cc: Jason Ekstrand jason@jlekstrand.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/i915/i915_globals.c | 3 +-- drivers/gpu/drm/i915/i915_globals.h | 3 --- drivers/gpu/drm/i915/i915_pci.c | 2 ++ drivers/gpu/drm/i915/i915_vma.c | 25 ++++++++----------------- drivers/gpu/drm/i915/i915_vma.h | 3 +++ 5 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index 8923589057ab..04979789e7be 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -8,7 +8,7 @@ #include <linux/workqueue.h>
#include "i915_globals.h" -#include "i915_vma.h" +#include "i915_drv.h"
static LIST_HEAD(globals);
@@ -28,7 +28,6 @@ static void __i915_globals_cleanup(void) }
static __initconst int (* const initfn[])(void) = { - i915_global_vma_init, };
int __init i915_globals_init(void) diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index 7a57bce1da05..57d2998bba45 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -22,7 +22,4 @@ void i915_global_register(struct i915_global *global); int i915_globals_init(void); void i915_globals_exit(void);
-/* constructors */ -int i915_global_vma_init(void); - #endif /* _I915_GLOBALS_H_ */ diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 500897d0d4b5..14785d88dafb 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -40,6 +40,7 @@ #include "i915_globals.h" #include "i915_selftest.h" #include "i915_scheduler.h" +#include "i915_vma.h"
#define PLATFORM(x) .platform = (x) #define GEN(x) \ @@ -1307,6 +1308,7 @@ static const struct { { i915_objects_module_init, i915_objects_module_exit }, { i915_request_module_init, i915_request_module_exit }, { i915_scheduler_module_init, i915_scheduler_module_exit }, + { i915_vma_module_init, i915_vma_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c index 09a7c47926f7..4b7fc4647e46 100644 --- a/drivers/gpu/drm/i915/i915_vma.c +++ b/drivers/gpu/drm/i915/i915_vma.c @@ -34,24 +34,20 @@ #include "gt/intel_gt_requests.h"
#include "i915_drv.h" -#include "i915_globals.h" #include "i915_sw_fence_work.h" #include "i915_trace.h" #include "i915_vma.h"
-static struct i915_global_vma { - struct i915_global base; - struct kmem_cache *slab_vmas; -} global; +static struct kmem_cache *slab_vmas;
struct i915_vma *i915_vma_alloc(void) { - return kmem_cache_zalloc(global.slab_vmas, GFP_KERNEL); + return kmem_cache_zalloc(slab_vmas, GFP_KERNEL); }
void i915_vma_free(struct i915_vma *vma) { - return kmem_cache_free(global.slab_vmas, vma); + return kmem_cache_free(slab_vmas, vma); }
#if IS_ENABLED(CONFIG_DRM_I915_ERRLOG_GEM) && IS_ENABLED(CONFIG_DRM_DEBUG_MM) @@ -1414,21 +1410,16 @@ void i915_vma_make_purgeable(struct i915_vma *vma) #include "selftests/i915_vma.c" #endif
-static void i915_global_vma_exit(void) +void i915_vma_module_exit(void) { - kmem_cache_destroy(global.slab_vmas); + kmem_cache_destroy(slab_vmas); }
-static struct i915_global_vma global = { { - .exit = i915_global_vma_exit, -} }; - -int __init i915_global_vma_init(void) +int __init i915_vma_module_init(void) { - global.slab_vmas = KMEM_CACHE(i915_vma, SLAB_HWCACHE_ALIGN); - if (!global.slab_vmas) + slab_vmas = KMEM_CACHE(i915_vma, SLAB_HWCACHE_ALIGN); + if (!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 eca452a9851f..ed69f66c7ab0 100644 --- a/drivers/gpu/drm/i915/i915_vma.h +++ b/drivers/gpu/drm/i915/i915_vma.h @@ -426,4 +426,7 @@ static inline int i915_vma_sync(struct i915_vma *vma) return i915_active_wait(&vma->active); }
+void i915_vma_module_exit(void); +int i915_vma_module_init(void); + #endif
No longer used.
Cc: Jason Ekstrand jason@jlekstrand.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/i915/Makefile | 1 - drivers/gpu/drm/i915/gt/intel_gt_pm.c | 1 - drivers/gpu/drm/i915/i915_globals.c | 53 --------------------------- drivers/gpu/drm/i915/i915_globals.h | 25 ------------- drivers/gpu/drm/i915/i915_pci.c | 2 - 5 files changed, 82 deletions(-) delete mode 100644 drivers/gpu/drm/i915/i915_globals.c delete mode 100644 drivers/gpu/drm/i915/i915_globals.h
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 10b3bb6207ba..9022dc638ed6 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -166,7 +166,6 @@ i915-y += \ i915_gem_gtt.o \ i915_gem_ww.o \ i915_gem.o \ - i915_globals.o \ i915_query.o \ i915_request.o \ i915_scheduler.o \ diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_pm.c index d86825437516..943c1d416ec0 100644 --- a/drivers/gpu/drm/i915/gt/intel_gt_pm.c +++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.c @@ -6,7 +6,6 @@ #include <linux/suspend.h>
#include "i915_drv.h" -#include "i915_globals.h" #include "i915_params.h" #include "intel_context.h" #include "intel_engine_pm.h" diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c deleted file mode 100644 index 04979789e7be..000000000000 --- a/drivers/gpu/drm/i915/i915_globals.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * Copyright © 2019 Intel Corporation - */ - -#include <linux/slab.h> -#include <linux/workqueue.h> - -#include "i915_globals.h" -#include "i915_drv.h" - -static LIST_HEAD(globals); - -void __init i915_global_register(struct i915_global *global) -{ - 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(); -} - -static __initconst int (* const initfn[])(void) = { -}; - -int __init i915_globals_init(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(initfn); i++) { - int err; - - err = initfn[i](); - if (err) { - __i915_globals_cleanup(); - return err; - } - } - - return 0; -} - -void i915_globals_exit(void) -{ - __i915_globals_cleanup(); -} diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h deleted file mode 100644 index 57d2998bba45..000000000000 --- a/drivers/gpu/drm/i915/i915_globals.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * Copyright © 2019 Intel Corporation - */ - -#ifndef _I915_GLOBALS_H_ -#define _I915_GLOBALS_H_ - -#include <linux/types.h> - -typedef void (*i915_global_func_t)(void); - -struct i915_global { - struct list_head link; - - i915_global_func_t exit; -}; - -void i915_global_register(struct i915_global *global); - -int i915_globals_init(void); -void i915_globals_exit(void); - -#endif /* _I915_GLOBALS_H_ */ diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 14785d88dafb..b4f5e88aaae6 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -37,7 +37,6 @@ #include "gem/i915_gem_object.h" #include "i915_request.h" #include "i915_perf.h" -#include "i915_globals.h" #include "i915_selftest.h" #include "i915_scheduler.h" #include "i915_vma.h" @@ -1309,7 +1308,6 @@ static const struct { { i915_request_module_init, i915_request_module_exit }, { i915_scheduler_module_init, i915_scheduler_module_exit }, { i915_vma_module_init, i915_vma_module_exit }, - { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, { i915_register_pci_driver, i915_unregister_pci_driver },
The module init code is somewhat misplaced in i915_pci.c, since it needs to pull in init/exit functions from every part of the driver and pollutes the include list a lot.
Extract an i915_module.c file which pulls all the bits together, and allows us to massively trim the include list of i915_pci.c.
The downside is that have to drop the error path check Jason added to catch when we set up the pci driver too early. I think that risk is acceptable for this pretty nice include.
Cc: Jason Ekstrand jason@jlekstrand.net Cc: Tvrtko Ursulin tvrtko.ursulin@linux.intel.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_module.c | 113 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_pci.c | 117 +---------------------------- drivers/gpu/drm/i915/i915_pci.h | 8 ++ 4 files changed, 125 insertions(+), 114 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_module.c create mode 100644 drivers/gpu/drm/i915/i915_pci.h
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 9022dc638ed6..4ebd9f417ddb 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -38,6 +38,7 @@ i915-y += i915_drv.o \ i915_irq.o \ i915_getparam.o \ i915_mitigations.o \ + i915_module.o \ i915_params.o \ i915_pci.o \ i915_scatterlist.o \ diff --git a/drivers/gpu/drm/i915/i915_module.c b/drivers/gpu/drm/i915/i915_module.c new file mode 100644 index 000000000000..c578ea8f56a0 --- /dev/null +++ b/drivers/gpu/drm/i915/i915_module.c @@ -0,0 +1,113 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2021 Intel Corporation + */ + +#include <linux/console.h> + +#include "gem/i915_gem_context.h" +#include "gem/i915_gem_object.h" +#include "i915_active.h" +#include "i915_buddy.h" +#include "i915_params.h" +#include "i915_pci.h" +#include "i915_perf.h" +#include "i915_request.h" +#include "i915_scheduler.h" +#include "i915_selftest.h" +#include "i915_vma.h" + +static int i915_check_nomodeset(void) +{ + bool use_kms = true; + + /* + * Enable KMS by default, unless explicitly overriden by + * either the i915.modeset prarameter or by the + * vga_text_mode_force boot option. + */ + + if (i915_modparams.modeset == 0) + use_kms = false; + + if (vgacon_text_force() && i915_modparams.modeset == -1) + use_kms = false; + + if (!use_kms) { + /* Silently fail loading to not upset userspace. */ + DRM_DEBUG_DRIVER("KMS disabled.\n"); + return 1; + } + + return 0; +} + +static const struct { + int (*init)(void); + void (*exit)(void); +} init_funcs[] = { + { i915_check_nomodeset, NULL }, + { i915_active_module_init, i915_active_module_exit }, + { i915_buddy_module_init, i915_buddy_module_exit }, + { i915_context_module_init, i915_context_module_exit }, + { i915_gem_context_module_init, i915_gem_context_module_exit }, + { i915_objects_module_init, i915_objects_module_exit }, + { i915_request_module_init, i915_request_module_exit }, + { i915_scheduler_module_init, i915_scheduler_module_exit }, + { i915_vma_module_init, i915_vma_module_exit }, + { i915_mock_selftests, NULL }, + { i915_pmu_init, i915_pmu_exit }, + { i915_register_pci_driver, i915_unregister_pci_driver }, + { i915_perf_sysctl_register, i915_perf_sysctl_unregister }, +}; +static int init_progress; + +static int __init i915_init(void) +{ + int err, i; + + for (i = 0; i < ARRAY_SIZE(init_funcs); i++) { + err = init_funcs[i].init(); + if (err < 0) { + while (i--) { + if (init_funcs[i].exit) + init_funcs[i].exit(); + } + return err; + } else if (err > 0) { + /* + * Early-exit success is reserved for things which + * don't have an exit() function because we have no + * idea how far they got or how to partially tear + * them down. + */ + WARN_ON(init_funcs[i].exit); + break; + } + } + + init_progress = i; + + return 0; +} + +static void __exit i915_exit(void) +{ + int i; + + for (i = init_progress - 1; i >= 0; i--) { + GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs)); + if (init_funcs[i].exit) + init_funcs[i].exit(); + } +} + +module_init(i915_init); +module_exit(i915_exit); + +MODULE_AUTHOR("Tungsten Graphics, Inc."); +MODULE_AUTHOR("Intel Corporation"); + +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index b4f5e88aaae6..08651ca03478 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -22,24 +22,13 @@ * */
-#include <linux/console.h> #include <linux/vga_switcheroo.h>
#include <drm/drm_drv.h> #include <drm/i915_pciids.h>
-#include "display/intel_fbdev.h" - -#include "i915_active.h" -#include "i915_buddy.h" #include "i915_drv.h" -#include "gem/i915_gem_context.h" -#include "gem/i915_gem_object.h" -#include "i915_request.h" -#include "i915_perf.h" -#include "i915_selftest.h" -#include "i915_scheduler.h" -#include "i915_vma.h" +#include "i915_pci.h"
#define PLATFORM(x) .platform = (x) #define GEN(x) \ @@ -1251,31 +1240,6 @@ static void i915_pci_shutdown(struct pci_dev *pdev) i915_driver_shutdown(i915); }
-static int i915_check_nomodeset(void) -{ - bool use_kms = true; - - /* - * Enable KMS by default, unless explicitly overriden by - * either the i915.modeset prarameter or by the - * vga_text_mode_force boot option. - */ - - if (i915_modparams.modeset == 0) - use_kms = false; - - if (vgacon_text_force() && i915_modparams.modeset == -1) - use_kms = false; - - if (!use_kms) { - /* Silently fail loading to not upset userspace. */ - DRM_DEBUG_DRIVER("KMS disabled.\n"); - return 1; - } - - return 0; -} - static struct pci_driver i915_pci_driver = { .name = DRIVER_NAME, .id_table = pciidlist, @@ -1285,87 +1249,12 @@ static struct pci_driver i915_pci_driver = { .driver.pm = &i915_pm_ops, };
-static int i915_register_pci_driver(void) +int i915_register_pci_driver(void) { return pci_register_driver(&i915_pci_driver); }
-static void i915_unregister_pci_driver(void) +void i915_unregister_pci_driver(void) { pci_unregister_driver(&i915_pci_driver); } - -static const struct { - int (*init)(void); - void (*exit)(void); -} init_funcs[] = { - { i915_check_nomodeset, NULL }, - { i915_active_module_init, i915_active_module_exit }, - { i915_buddy_module_init, i915_buddy_module_exit }, - { i915_context_module_init, i915_context_module_exit }, - { i915_gem_context_module_init, i915_gem_context_module_exit }, - { i915_objects_module_init, i915_objects_module_exit }, - { i915_request_module_init, i915_request_module_exit }, - { i915_scheduler_module_init, i915_scheduler_module_exit }, - { i915_vma_module_init, i915_vma_module_exit }, - { i915_mock_selftests, NULL }, - { i915_pmu_init, i915_pmu_exit }, - { i915_register_pci_driver, i915_unregister_pci_driver }, - { i915_perf_sysctl_register, i915_perf_sysctl_unregister }, -}; -static int init_progress; - -static int __init i915_init(void) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(init_funcs); i++) { - err = init_funcs[i].init(); - if (err < 0) { - while (i--) { - if (init_funcs[i].exit) - init_funcs[i].exit(); - } - return err; - } else if (err > 0) { - /* - * Early-exit success is reserved for things which - * don't have an exit() function because we have no - * idea how far they got or how to partially tear - * them down. - */ - WARN_ON(init_funcs[i].exit); - - /* - * We don't want to advertise devices with an only - * partially initialized driver. - */ - WARN_ON(i915_pci_driver.driver.owner); - break; - } - } - - init_progress = i; - - return 0; -} - -static void __exit i915_exit(void) -{ - int i; - - for (i = init_progress - 1; i >= 0; i--) { - GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs)); - if (init_funcs[i].exit) - init_funcs[i].exit(); - } -} - -module_init(i915_init); -module_exit(i915_exit); - -MODULE_AUTHOR("Tungsten Graphics, Inc."); -MODULE_AUTHOR("Intel Corporation"); - -MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.h b/drivers/gpu/drm/i915/i915_pci.h new file mode 100644 index 000000000000..b386f319f52e --- /dev/null +++ b/drivers/gpu/drm/i915/i915_pci.h @@ -0,0 +1,8 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2021 Intel Corporation + */ + +int i915_register_pci_driver(void); +void i915_unregister_pci_driver(void);
On 27/07/2021 13:10, Daniel Vetter wrote:
The module init code is somewhat misplaced in i915_pci.c, since it needs to pull in init/exit functions from every part of the driver and pollutes the include list a lot.
Extract an i915_module.c file which pulls all the bits together, and allows us to massively trim the include list of i915_pci.c.
The downside is that have to drop the error path check Jason added to catch when we set up the pci driver too early. I think that risk is acceptable for this pretty nice include.
i915_module.c is an improvement and the rest for me is not extremely objectionable by the end of this incarnation, but I also do not see it as an improvement really.
There was a bug to fix relating to mock tests, but that is where the exercise should have stopped for now. After that it IMHO spiraled out of control, not least the unjustifiably expedited removal of cache shrinking. On balance for me it is too churny and boils down to two extremely capable people spending time on kind of really unimportant side fiddles. And I do not intend to prescribe you what to do, just expressing my bewilderment. FWIW... I can only say my opinion as it, not that it matters a lot.
Regards,
Tvrtko
Cc: Jason Ekstrand jason@jlekstrand.net Cc: Tvrtko Ursulin tvrtko.ursulin@linux.intel.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_module.c | 113 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_pci.c | 117 +---------------------------- drivers/gpu/drm/i915/i915_pci.h | 8 ++ 4 files changed, 125 insertions(+), 114 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_module.c create mode 100644 drivers/gpu/drm/i915/i915_pci.h
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 9022dc638ed6..4ebd9f417ddb 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -38,6 +38,7 @@ i915-y += i915_drv.o \ i915_irq.o \ i915_getparam.o \ i915_mitigations.o \
i915_params.o \ i915_pci.o \ i915_scatterlist.o \i915_module.o \
diff --git a/drivers/gpu/drm/i915/i915_module.c b/drivers/gpu/drm/i915/i915_module.c new file mode 100644 index 000000000000..c578ea8f56a0 --- /dev/null +++ b/drivers/gpu/drm/i915/i915_module.c @@ -0,0 +1,113 @@ +/*
- SPDX-License-Identifier: MIT
- Copyright © 2021 Intel Corporation
- */
+#include <linux/console.h>
+#include "gem/i915_gem_context.h" +#include "gem/i915_gem_object.h" +#include "i915_active.h" +#include "i915_buddy.h" +#include "i915_params.h" +#include "i915_pci.h" +#include "i915_perf.h" +#include "i915_request.h" +#include "i915_scheduler.h" +#include "i915_selftest.h" +#include "i915_vma.h"
+static int i915_check_nomodeset(void) +{
- bool use_kms = true;
- /*
* Enable KMS by default, unless explicitly overriden by
* either the i915.modeset prarameter or by the
* vga_text_mode_force boot option.
*/
- if (i915_modparams.modeset == 0)
use_kms = false;
- if (vgacon_text_force() && i915_modparams.modeset == -1)
use_kms = false;
- if (!use_kms) {
/* Silently fail loading to not upset userspace. */
DRM_DEBUG_DRIVER("KMS disabled.\n");
return 1;
- }
- return 0;
+}
+static const struct {
- int (*init)(void);
- void (*exit)(void);
+} init_funcs[] = {
- { i915_check_nomodeset, NULL },
- { i915_active_module_init, i915_active_module_exit },
- { i915_buddy_module_init, i915_buddy_module_exit },
- { i915_context_module_init, i915_context_module_exit },
- { i915_gem_context_module_init, i915_gem_context_module_exit },
- { i915_objects_module_init, i915_objects_module_exit },
- { i915_request_module_init, i915_request_module_exit },
- { i915_scheduler_module_init, i915_scheduler_module_exit },
- { i915_vma_module_init, i915_vma_module_exit },
- { i915_mock_selftests, NULL },
- { i915_pmu_init, i915_pmu_exit },
- { i915_register_pci_driver, i915_unregister_pci_driver },
- { i915_perf_sysctl_register, i915_perf_sysctl_unregister },
+}; +static int init_progress;
+static int __init i915_init(void) +{
- int err, i;
- for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
err = init_funcs[i].init();
if (err < 0) {
while (i--) {
if (init_funcs[i].exit)
init_funcs[i].exit();
}
return err;
} else if (err > 0) {
/*
* Early-exit success is reserved for things which
* don't have an exit() function because we have no
* idea how far they got or how to partially tear
* them down.
*/
WARN_ON(init_funcs[i].exit);
break;
}
- }
- init_progress = i;
- return 0;
+}
+static void __exit i915_exit(void) +{
- int i;
- for (i = init_progress - 1; i >= 0; i--) {
GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
if (init_funcs[i].exit)
init_funcs[i].exit();
- }
+}
+module_init(i915_init); +module_exit(i915_exit);
+MODULE_AUTHOR("Tungsten Graphics, Inc."); +MODULE_AUTHOR("Intel Corporation");
+MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index b4f5e88aaae6..08651ca03478 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -22,24 +22,13 @@
*/
-#include <linux/console.h> #include <linux/vga_switcheroo.h>
#include <drm/drm_drv.h> #include <drm/i915_pciids.h>
-#include "display/intel_fbdev.h"
-#include "i915_active.h" -#include "i915_buddy.h" #include "i915_drv.h" -#include "gem/i915_gem_context.h" -#include "gem/i915_gem_object.h" -#include "i915_request.h" -#include "i915_perf.h" -#include "i915_selftest.h" -#include "i915_scheduler.h" -#include "i915_vma.h" +#include "i915_pci.h"
#define PLATFORM(x) .platform = (x) #define GEN(x) \ @@ -1251,31 +1240,6 @@ static void i915_pci_shutdown(struct pci_dev *pdev) i915_driver_shutdown(i915); }
-static int i915_check_nomodeset(void) -{
- bool use_kms = true;
- /*
* Enable KMS by default, unless explicitly overriden by
* either the i915.modeset prarameter or by the
* vga_text_mode_force boot option.
*/
- if (i915_modparams.modeset == 0)
use_kms = false;
- if (vgacon_text_force() && i915_modparams.modeset == -1)
use_kms = false;
- if (!use_kms) {
/* Silently fail loading to not upset userspace. */
DRM_DEBUG_DRIVER("KMS disabled.\n");
return 1;
- }
- return 0;
-}
- static struct pci_driver i915_pci_driver = { .name = DRIVER_NAME, .id_table = pciidlist,
@@ -1285,87 +1249,12 @@ static struct pci_driver i915_pci_driver = { .driver.pm = &i915_pm_ops, };
-static int i915_register_pci_driver(void) +int i915_register_pci_driver(void) { return pci_register_driver(&i915_pci_driver); }
-static void i915_unregister_pci_driver(void) +void i915_unregister_pci_driver(void) { pci_unregister_driver(&i915_pci_driver); }
-static const struct {
- int (*init)(void);
- void (*exit)(void);
-} init_funcs[] = {
- { i915_check_nomodeset, NULL },
- { i915_active_module_init, i915_active_module_exit },
- { i915_buddy_module_init, i915_buddy_module_exit },
- { i915_context_module_init, i915_context_module_exit },
- { i915_gem_context_module_init, i915_gem_context_module_exit },
- { i915_objects_module_init, i915_objects_module_exit },
- { i915_request_module_init, i915_request_module_exit },
- { i915_scheduler_module_init, i915_scheduler_module_exit },
- { i915_vma_module_init, i915_vma_module_exit },
- { i915_mock_selftests, NULL },
- { i915_pmu_init, i915_pmu_exit },
- { i915_register_pci_driver, i915_unregister_pci_driver },
- { i915_perf_sysctl_register, i915_perf_sysctl_unregister },
-}; -static int init_progress;
-static int __init i915_init(void) -{
- int err, i;
- for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
err = init_funcs[i].init();
if (err < 0) {
while (i--) {
if (init_funcs[i].exit)
init_funcs[i].exit();
}
return err;
} else if (err > 0) {
/*
* Early-exit success is reserved for things which
* don't have an exit() function because we have no
* idea how far they got or how to partially tear
* them down.
*/
WARN_ON(init_funcs[i].exit);
/*
* We don't want to advertise devices with an only
* partially initialized driver.
*/
WARN_ON(i915_pci_driver.driver.owner);
break;
}
- }
- init_progress = i;
- return 0;
-}
-static void __exit i915_exit(void) -{
- int i;
- for (i = init_progress - 1; i >= 0; i--) {
GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
if (init_funcs[i].exit)
init_funcs[i].exit();
- }
-}
-module_init(i915_init); -module_exit(i915_exit);
-MODULE_AUTHOR("Tungsten Graphics, Inc."); -MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.h b/drivers/gpu/drm/i915/i915_pci.h new file mode 100644 index 000000000000..b386f319f52e --- /dev/null +++ b/drivers/gpu/drm/i915/i915_pci.h @@ -0,0 +1,8 @@ +/*
- SPDX-License-Identifier: MIT
- Copyright © 2021 Intel Corporation
- */
+int i915_register_pci_driver(void); +void i915_unregister_pci_driver(void);
On Tue, Jul 27, 2021 at 9:44 AM Tvrtko Ursulin tvrtko.ursulin@linux.intel.com wrote:
On 27/07/2021 13:10, Daniel Vetter wrote:
The module init code is somewhat misplaced in i915_pci.c, since it needs to pull in init/exit functions from every part of the driver and pollutes the include list a lot.
Extract an i915_module.c file which pulls all the bits together, and allows us to massively trim the include list of i915_pci.c.
The downside is that have to drop the error path check Jason added to catch when we set up the pci driver too early. I think that risk is acceptable for this pretty nice include.
i915_module.c is an improvement and the rest for me is not extremely objectionable by the end of this incarnation, but I also do not see it as an improvement really.
It's not a big improvement to be sure, but I think there are a few ways this is nicer:
1. One less level of indirection to sort through. 2. The init/exit table is generally simpler than the i915_global interface. 3. It's easy to forget i915_global_register but forgetting to put an _exit function in the module init table is a lot more obvious.
None of those are deal-breakers but they're kind-of nice. Anyway, this one is also
Reviewed-by: Jason Ekstrand jason@jlekstrand.net
--Jason
There was a bug to fix relating to mock tests, but that is where the exercise should have stopped for now. After that it IMHO spiraled out of control, not least the unjustifiably expedited removal of cache shrinking. On balance for me it is too churny and boils down to two extremely capable people spending time on kind of really unimportant side fiddles. And I do not intend to prescribe you what to do, just expressing my bewilderment. FWIW... I can only say my opinion as it, not that it matters a lot.
Regards,
Tvrtko
Cc: Jason Ekstrand jason@jlekstrand.net Cc: Tvrtko Ursulin tvrtko.ursulin@linux.intel.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_module.c | 113 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_pci.c | 117 +---------------------------- drivers/gpu/drm/i915/i915_pci.h | 8 ++ 4 files changed, 125 insertions(+), 114 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_module.c create mode 100644 drivers/gpu/drm/i915/i915_pci.h
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 9022dc638ed6..4ebd9f417ddb 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -38,6 +38,7 @@ i915-y += i915_drv.o \ i915_irq.o \ i915_getparam.o \ i915_mitigations.o \
i915_module.o \ i915_params.o \ i915_pci.o \ i915_scatterlist.o \
diff --git a/drivers/gpu/drm/i915/i915_module.c b/drivers/gpu/drm/i915/i915_module.c new file mode 100644 index 000000000000..c578ea8f56a0 --- /dev/null +++ b/drivers/gpu/drm/i915/i915_module.c @@ -0,0 +1,113 @@ +/*
- SPDX-License-Identifier: MIT
- Copyright © 2021 Intel Corporation
- */
+#include <linux/console.h>
+#include "gem/i915_gem_context.h" +#include "gem/i915_gem_object.h" +#include "i915_active.h" +#include "i915_buddy.h" +#include "i915_params.h" +#include "i915_pci.h" +#include "i915_perf.h" +#include "i915_request.h" +#include "i915_scheduler.h" +#include "i915_selftest.h" +#include "i915_vma.h"
+static int i915_check_nomodeset(void) +{
bool use_kms = true;
/*
* Enable KMS by default, unless explicitly overriden by
* either the i915.modeset prarameter or by the
* vga_text_mode_force boot option.
*/
if (i915_modparams.modeset == 0)
use_kms = false;
if (vgacon_text_force() && i915_modparams.modeset == -1)
use_kms = false;
if (!use_kms) {
/* Silently fail loading to not upset userspace. */
DRM_DEBUG_DRIVER("KMS disabled.\n");
return 1;
}
return 0;
+}
+static const struct {
- int (*init)(void);
- void (*exit)(void);
+} init_funcs[] = {
{ i915_check_nomodeset, NULL },
{ i915_active_module_init, i915_active_module_exit },
{ i915_buddy_module_init, i915_buddy_module_exit },
{ i915_context_module_init, i915_context_module_exit },
{ i915_gem_context_module_init, i915_gem_context_module_exit },
{ i915_objects_module_init, i915_objects_module_exit },
{ i915_request_module_init, i915_request_module_exit },
{ i915_scheduler_module_init, i915_scheduler_module_exit },
{ i915_vma_module_init, i915_vma_module_exit },
{ i915_mock_selftests, NULL },
{ i915_pmu_init, i915_pmu_exit },
{ i915_register_pci_driver, i915_unregister_pci_driver },
{ i915_perf_sysctl_register, i915_perf_sysctl_unregister },
+}; +static int init_progress;
+static int __init i915_init(void) +{
int err, i;
for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
err = init_funcs[i].init();
if (err < 0) {
while (i--) {
if (init_funcs[i].exit)
init_funcs[i].exit();
}
return err;
} else if (err > 0) {
/*
* Early-exit success is reserved for things which
* don't have an exit() function because we have no
* idea how far they got or how to partially tear
* them down.
*/
WARN_ON(init_funcs[i].exit);
break;
}
}
init_progress = i;
return 0;
+}
+static void __exit i915_exit(void) +{
int i;
for (i = init_progress - 1; i >= 0; i--) {
GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
if (init_funcs[i].exit)
init_funcs[i].exit();
}
+}
+module_init(i915_init); +module_exit(i915_exit);
+MODULE_AUTHOR("Tungsten Graphics, Inc."); +MODULE_AUTHOR("Intel Corporation");
+MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index b4f5e88aaae6..08651ca03478 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -22,24 +22,13 @@
*/
-#include <linux/console.h> #include <linux/vga_switcheroo.h>
#include <drm/drm_drv.h> #include <drm/i915_pciids.h>
-#include "display/intel_fbdev.h"
-#include "i915_active.h" -#include "i915_buddy.h" #include "i915_drv.h" -#include "gem/i915_gem_context.h" -#include "gem/i915_gem_object.h" -#include "i915_request.h" -#include "i915_perf.h" -#include "i915_selftest.h" -#include "i915_scheduler.h" -#include "i915_vma.h" +#include "i915_pci.h"
#define PLATFORM(x) .platform = (x) #define GEN(x) \ @@ -1251,31 +1240,6 @@ static void i915_pci_shutdown(struct pci_dev *pdev) i915_driver_shutdown(i915); }
-static int i915_check_nomodeset(void) -{
bool use_kms = true;
/*
* Enable KMS by default, unless explicitly overriden by
* either the i915.modeset prarameter or by the
* vga_text_mode_force boot option.
*/
if (i915_modparams.modeset == 0)
use_kms = false;
if (vgacon_text_force() && i915_modparams.modeset == -1)
use_kms = false;
if (!use_kms) {
/* Silently fail loading to not upset userspace. */
DRM_DEBUG_DRIVER("KMS disabled.\n");
return 1;
}
return 0;
-}
- static struct pci_driver i915_pci_driver = { .name = DRIVER_NAME, .id_table = pciidlist,
@@ -1285,87 +1249,12 @@ static struct pci_driver i915_pci_driver = { .driver.pm = &i915_pm_ops, };
-static int i915_register_pci_driver(void) +int i915_register_pci_driver(void) { return pci_register_driver(&i915_pci_driver); }
-static void i915_unregister_pci_driver(void) +void i915_unregister_pci_driver(void) { pci_unregister_driver(&i915_pci_driver); }
-static const struct {
- int (*init)(void);
- void (*exit)(void);
-} init_funcs[] = {
{ i915_check_nomodeset, NULL },
{ i915_active_module_init, i915_active_module_exit },
{ i915_buddy_module_init, i915_buddy_module_exit },
{ i915_context_module_init, i915_context_module_exit },
{ i915_gem_context_module_init, i915_gem_context_module_exit },
{ i915_objects_module_init, i915_objects_module_exit },
{ i915_request_module_init, i915_request_module_exit },
{ i915_scheduler_module_init, i915_scheduler_module_exit },
{ i915_vma_module_init, i915_vma_module_exit },
{ i915_mock_selftests, NULL },
{ i915_pmu_init, i915_pmu_exit },
{ i915_register_pci_driver, i915_unregister_pci_driver },
{ i915_perf_sysctl_register, i915_perf_sysctl_unregister },
-}; -static int init_progress;
-static int __init i915_init(void) -{
int err, i;
for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
err = init_funcs[i].init();
if (err < 0) {
while (i--) {
if (init_funcs[i].exit)
init_funcs[i].exit();
}
return err;
} else if (err > 0) {
/*
* Early-exit success is reserved for things which
* don't have an exit() function because we have no
* idea how far they got or how to partially tear
* them down.
*/
WARN_ON(init_funcs[i].exit);
/*
* We don't want to advertise devices with an only
* partially initialized driver.
*/
WARN_ON(i915_pci_driver.driver.owner);
break;
}
}
init_progress = i;
return 0;
-}
-static void __exit i915_exit(void) -{
int i;
for (i = init_progress - 1; i >= 0; i--) {
GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
if (init_funcs[i].exit)
init_funcs[i].exit();
}
-}
-module_init(i915_init); -module_exit(i915_exit);
-MODULE_AUTHOR("Tungsten Graphics, Inc."); -MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.h b/drivers/gpu/drm/i915/i915_pci.h new file mode 100644 index 000000000000..b386f319f52e --- /dev/null +++ b/drivers/gpu/drm/i915/i915_pci.h @@ -0,0 +1,8 @@ +/*
- SPDX-License-Identifier: MIT
- Copyright © 2021 Intel Corporation
- */
+int i915_register_pci_driver(void); +void i915_unregister_pci_driver(void);
On Tue, Jul 27, 2021 at 02:10:37PM +0200, Daniel Vetter wrote:
The module init code is somewhat misplaced in i915_pci.c, since it needs to pull in init/exit functions from every part of the driver and pollutes the include list a lot.
Extract an i915_module.c file which pulls all the bits together, and allows us to massively trim the include list of i915_pci.c.
The downside is that have to drop the error path check Jason added to catch when we set up the pci driver too early. I think that risk is acceptable for this pretty nice include.
Cc: Jason Ekstrand jason@jlekstrand.net Cc: Tvrtko Ursulin tvrtko.ursulin@linux.intel.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com Reviewed-by: Jason Ekstrand jason@jlekstrand.net
With gcc and CONFIG_GCC_PLUGIN_RANDSTRUCT=y, this patch results in:
drivers/gpu/drm/i915/i915_module.c:50:11: error: positional initialization of field in 'struct' declared with 'designated_init' attribute
This is seen for each of the initializers.
Guenter
drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_module.c | 113 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_pci.c | 117 +---------------------------- drivers/gpu/drm/i915/i915_pci.h | 8 ++ 4 files changed, 125 insertions(+), 114 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_module.c create mode 100644 drivers/gpu/drm/i915/i915_pci.h
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 9022dc638ed6..4ebd9f417ddb 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -38,6 +38,7 @@ i915-y += i915_drv.o \ i915_irq.o \ i915_getparam.o \ i915_mitigations.o \
i915_params.o \ i915_pci.o \ i915_scatterlist.o \i915_module.o \
diff --git a/drivers/gpu/drm/i915/i915_module.c b/drivers/gpu/drm/i915/i915_module.c new file mode 100644 index 000000000000..c578ea8f56a0 --- /dev/null +++ b/drivers/gpu/drm/i915/i915_module.c @@ -0,0 +1,113 @@ +/*
- SPDX-License-Identifier: MIT
- Copyright © 2021 Intel Corporation
- */
+#include <linux/console.h>
+#include "gem/i915_gem_context.h" +#include "gem/i915_gem_object.h" +#include "i915_active.h" +#include "i915_buddy.h" +#include "i915_params.h" +#include "i915_pci.h" +#include "i915_perf.h" +#include "i915_request.h" +#include "i915_scheduler.h" +#include "i915_selftest.h" +#include "i915_vma.h"
+static int i915_check_nomodeset(void) +{
- bool use_kms = true;
- /*
* Enable KMS by default, unless explicitly overriden by
* either the i915.modeset prarameter or by the
* vga_text_mode_force boot option.
*/
- if (i915_modparams.modeset == 0)
use_kms = false;
- if (vgacon_text_force() && i915_modparams.modeset == -1)
use_kms = false;
- if (!use_kms) {
/* Silently fail loading to not upset userspace. */
DRM_DEBUG_DRIVER("KMS disabled.\n");
return 1;
- }
- return 0;
+}
+static const struct {
- int (*init)(void);
- void (*exit)(void);
+} init_funcs[] = {
- { i915_check_nomodeset, NULL },
- { i915_active_module_init, i915_active_module_exit },
- { i915_buddy_module_init, i915_buddy_module_exit },
- { i915_context_module_init, i915_context_module_exit },
- { i915_gem_context_module_init, i915_gem_context_module_exit },
- { i915_objects_module_init, i915_objects_module_exit },
- { i915_request_module_init, i915_request_module_exit },
- { i915_scheduler_module_init, i915_scheduler_module_exit },
- { i915_vma_module_init, i915_vma_module_exit },
- { i915_mock_selftests, NULL },
- { i915_pmu_init, i915_pmu_exit },
- { i915_register_pci_driver, i915_unregister_pci_driver },
- { i915_perf_sysctl_register, i915_perf_sysctl_unregister },
+}; +static int init_progress;
+static int __init i915_init(void) +{
- int err, i;
- for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
err = init_funcs[i].init();
if (err < 0) {
while (i--) {
if (init_funcs[i].exit)
init_funcs[i].exit();
}
return err;
} else if (err > 0) {
/*
* Early-exit success is reserved for things which
* don't have an exit() function because we have no
* idea how far they got or how to partially tear
* them down.
*/
WARN_ON(init_funcs[i].exit);
break;
}
- }
- init_progress = i;
- return 0;
+}
+static void __exit i915_exit(void) +{
- int i;
- for (i = init_progress - 1; i >= 0; i--) {
GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
if (init_funcs[i].exit)
init_funcs[i].exit();
- }
+}
+module_init(i915_init); +module_exit(i915_exit);
+MODULE_AUTHOR("Tungsten Graphics, Inc."); +MODULE_AUTHOR("Intel Corporation");
+MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index b4f5e88aaae6..08651ca03478 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -22,24 +22,13 @@
*/
-#include <linux/console.h> #include <linux/vga_switcheroo.h>
#include <drm/drm_drv.h> #include <drm/i915_pciids.h>
-#include "display/intel_fbdev.h"
-#include "i915_active.h" -#include "i915_buddy.h" #include "i915_drv.h" -#include "gem/i915_gem_context.h" -#include "gem/i915_gem_object.h" -#include "i915_request.h" -#include "i915_perf.h" -#include "i915_selftest.h" -#include "i915_scheduler.h" -#include "i915_vma.h" +#include "i915_pci.h"
#define PLATFORM(x) .platform = (x) #define GEN(x) \ @@ -1251,31 +1240,6 @@ static void i915_pci_shutdown(struct pci_dev *pdev) i915_driver_shutdown(i915); }
-static int i915_check_nomodeset(void) -{
- bool use_kms = true;
- /*
* Enable KMS by default, unless explicitly overriden by
* either the i915.modeset prarameter or by the
* vga_text_mode_force boot option.
*/
- if (i915_modparams.modeset == 0)
use_kms = false;
- if (vgacon_text_force() && i915_modparams.modeset == -1)
use_kms = false;
- if (!use_kms) {
/* Silently fail loading to not upset userspace. */
DRM_DEBUG_DRIVER("KMS disabled.\n");
return 1;
- }
- return 0;
-}
static struct pci_driver i915_pci_driver = { .name = DRIVER_NAME, .id_table = pciidlist, @@ -1285,87 +1249,12 @@ static struct pci_driver i915_pci_driver = { .driver.pm = &i915_pm_ops, };
-static int i915_register_pci_driver(void) +int i915_register_pci_driver(void) { return pci_register_driver(&i915_pci_driver); }
-static void i915_unregister_pci_driver(void) +void i915_unregister_pci_driver(void) { pci_unregister_driver(&i915_pci_driver); }
-static const struct {
- int (*init)(void);
- void (*exit)(void);
-} init_funcs[] = {
- { i915_check_nomodeset, NULL },
- { i915_active_module_init, i915_active_module_exit },
- { i915_buddy_module_init, i915_buddy_module_exit },
- { i915_context_module_init, i915_context_module_exit },
- { i915_gem_context_module_init, i915_gem_context_module_exit },
- { i915_objects_module_init, i915_objects_module_exit },
- { i915_request_module_init, i915_request_module_exit },
- { i915_scheduler_module_init, i915_scheduler_module_exit },
- { i915_vma_module_init, i915_vma_module_exit },
- { i915_mock_selftests, NULL },
- { i915_pmu_init, i915_pmu_exit },
- { i915_register_pci_driver, i915_unregister_pci_driver },
- { i915_perf_sysctl_register, i915_perf_sysctl_unregister },
-}; -static int init_progress;
-static int __init i915_init(void) -{
- int err, i;
- for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
err = init_funcs[i].init();
if (err < 0) {
while (i--) {
if (init_funcs[i].exit)
init_funcs[i].exit();
}
return err;
} else if (err > 0) {
/*
* Early-exit success is reserved for things which
* don't have an exit() function because we have no
* idea how far they got or how to partially tear
* them down.
*/
WARN_ON(init_funcs[i].exit);
/*
* We don't want to advertise devices with an only
* partially initialized driver.
*/
WARN_ON(i915_pci_driver.driver.owner);
break;
}
- }
- init_progress = i;
- return 0;
-}
-static void __exit i915_exit(void) -{
- int i;
- for (i = init_progress - 1; i >= 0; i--) {
GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
if (init_funcs[i].exit)
init_funcs[i].exit();
- }
-}
-module_init(i915_init); -module_exit(i915_exit);
-MODULE_AUTHOR("Tungsten Graphics, Inc."); -MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.h b/drivers/gpu/drm/i915/i915_pci.h new file mode 100644 index 000000000000..b386f319f52e --- /dev/null +++ b/drivers/gpu/drm/i915/i915_pci.h @@ -0,0 +1,8 @@ +/*
- SPDX-License-Identifier: MIT
- Copyright © 2021 Intel Corporation
- */
+int i915_register_pci_driver(void); +void i915_unregister_pci_driver(void);
On Mon, 23 Aug 2021, Guenter Roeck linux@roeck-us.net wrote:
On Tue, Jul 27, 2021 at 02:10:37PM +0200, Daniel Vetter wrote:
The module init code is somewhat misplaced in i915_pci.c, since it needs to pull in init/exit functions from every part of the driver and pollutes the include list a lot.
Extract an i915_module.c file which pulls all the bits together, and allows us to massively trim the include list of i915_pci.c.
The downside is that have to drop the error path check Jason added to catch when we set up the pci driver too early. I think that risk is acceptable for this pretty nice include.
Cc: Jason Ekstrand jason@jlekstrand.net Cc: Tvrtko Ursulin tvrtko.ursulin@linux.intel.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com Reviewed-by: Jason Ekstrand jason@jlekstrand.net
With gcc and CONFIG_GCC_PLUGIN_RANDSTRUCT=y, this patch results in:
drivers/gpu/drm/i915/i915_module.c:50:11: error: positional initialization of field in 'struct' declared with 'designated_init' attribute
This is seen for each of the initializers.
https://patchwork.freedesktop.org/patch/msgid/20210817233357.2379455-1-keesc...
BR, Jani.
Guenter
drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_module.c | 113 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_pci.c | 117 +---------------------------- drivers/gpu/drm/i915/i915_pci.h | 8 ++ 4 files changed, 125 insertions(+), 114 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_module.c create mode 100644 drivers/gpu/drm/i915/i915_pci.h
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 9022dc638ed6..4ebd9f417ddb 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -38,6 +38,7 @@ i915-y += i915_drv.o \ i915_irq.o \ i915_getparam.o \ i915_mitigations.o \
i915_params.o \ i915_pci.o \ i915_scatterlist.o \i915_module.o \
diff --git a/drivers/gpu/drm/i915/i915_module.c b/drivers/gpu/drm/i915/i915_module.c new file mode 100644 index 000000000000..c578ea8f56a0 --- /dev/null +++ b/drivers/gpu/drm/i915/i915_module.c @@ -0,0 +1,113 @@ +/*
- SPDX-License-Identifier: MIT
- Copyright © 2021 Intel Corporation
- */
+#include <linux/console.h>
+#include "gem/i915_gem_context.h" +#include "gem/i915_gem_object.h" +#include "i915_active.h" +#include "i915_buddy.h" +#include "i915_params.h" +#include "i915_pci.h" +#include "i915_perf.h" +#include "i915_request.h" +#include "i915_scheduler.h" +#include "i915_selftest.h" +#include "i915_vma.h"
+static int i915_check_nomodeset(void) +{
- bool use_kms = true;
- /*
* Enable KMS by default, unless explicitly overriden by
* either the i915.modeset prarameter or by the
* vga_text_mode_force boot option.
*/
- if (i915_modparams.modeset == 0)
use_kms = false;
- if (vgacon_text_force() && i915_modparams.modeset == -1)
use_kms = false;
- if (!use_kms) {
/* Silently fail loading to not upset userspace. */
DRM_DEBUG_DRIVER("KMS disabled.\n");
return 1;
- }
- return 0;
+}
+static const struct {
- int (*init)(void);
- void (*exit)(void);
+} init_funcs[] = {
- { i915_check_nomodeset, NULL },
- { i915_active_module_init, i915_active_module_exit },
- { i915_buddy_module_init, i915_buddy_module_exit },
- { i915_context_module_init, i915_context_module_exit },
- { i915_gem_context_module_init, i915_gem_context_module_exit },
- { i915_objects_module_init, i915_objects_module_exit },
- { i915_request_module_init, i915_request_module_exit },
- { i915_scheduler_module_init, i915_scheduler_module_exit },
- { i915_vma_module_init, i915_vma_module_exit },
- { i915_mock_selftests, NULL },
- { i915_pmu_init, i915_pmu_exit },
- { i915_register_pci_driver, i915_unregister_pci_driver },
- { i915_perf_sysctl_register, i915_perf_sysctl_unregister },
+}; +static int init_progress;
+static int __init i915_init(void) +{
- int err, i;
- for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
err = init_funcs[i].init();
if (err < 0) {
while (i--) {
if (init_funcs[i].exit)
init_funcs[i].exit();
}
return err;
} else if (err > 0) {
/*
* Early-exit success is reserved for things which
* don't have an exit() function because we have no
* idea how far they got or how to partially tear
* them down.
*/
WARN_ON(init_funcs[i].exit);
break;
}
- }
- init_progress = i;
- return 0;
+}
+static void __exit i915_exit(void) +{
- int i;
- for (i = init_progress - 1; i >= 0; i--) {
GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
if (init_funcs[i].exit)
init_funcs[i].exit();
- }
+}
+module_init(i915_init); +module_exit(i915_exit);
+MODULE_AUTHOR("Tungsten Graphics, Inc."); +MODULE_AUTHOR("Intel Corporation");
+MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index b4f5e88aaae6..08651ca03478 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -22,24 +22,13 @@
*/
-#include <linux/console.h> #include <linux/vga_switcheroo.h>
#include <drm/drm_drv.h> #include <drm/i915_pciids.h>
-#include "display/intel_fbdev.h"
-#include "i915_active.h" -#include "i915_buddy.h" #include "i915_drv.h" -#include "gem/i915_gem_context.h" -#include "gem/i915_gem_object.h" -#include "i915_request.h" -#include "i915_perf.h" -#include "i915_selftest.h" -#include "i915_scheduler.h" -#include "i915_vma.h" +#include "i915_pci.h"
#define PLATFORM(x) .platform = (x) #define GEN(x) \ @@ -1251,31 +1240,6 @@ static void i915_pci_shutdown(struct pci_dev *pdev) i915_driver_shutdown(i915); }
-static int i915_check_nomodeset(void) -{
- bool use_kms = true;
- /*
* Enable KMS by default, unless explicitly overriden by
* either the i915.modeset prarameter or by the
* vga_text_mode_force boot option.
*/
- if (i915_modparams.modeset == 0)
use_kms = false;
- if (vgacon_text_force() && i915_modparams.modeset == -1)
use_kms = false;
- if (!use_kms) {
/* Silently fail loading to not upset userspace. */
DRM_DEBUG_DRIVER("KMS disabled.\n");
return 1;
- }
- return 0;
-}
static struct pci_driver i915_pci_driver = { .name = DRIVER_NAME, .id_table = pciidlist, @@ -1285,87 +1249,12 @@ static struct pci_driver i915_pci_driver = { .driver.pm = &i915_pm_ops, };
-static int i915_register_pci_driver(void) +int i915_register_pci_driver(void) { return pci_register_driver(&i915_pci_driver); }
-static void i915_unregister_pci_driver(void) +void i915_unregister_pci_driver(void) { pci_unregister_driver(&i915_pci_driver); }
-static const struct {
- int (*init)(void);
- void (*exit)(void);
-} init_funcs[] = {
- { i915_check_nomodeset, NULL },
- { i915_active_module_init, i915_active_module_exit },
- { i915_buddy_module_init, i915_buddy_module_exit },
- { i915_context_module_init, i915_context_module_exit },
- { i915_gem_context_module_init, i915_gem_context_module_exit },
- { i915_objects_module_init, i915_objects_module_exit },
- { i915_request_module_init, i915_request_module_exit },
- { i915_scheduler_module_init, i915_scheduler_module_exit },
- { i915_vma_module_init, i915_vma_module_exit },
- { i915_mock_selftests, NULL },
- { i915_pmu_init, i915_pmu_exit },
- { i915_register_pci_driver, i915_unregister_pci_driver },
- { i915_perf_sysctl_register, i915_perf_sysctl_unregister },
-}; -static int init_progress;
-static int __init i915_init(void) -{
- int err, i;
- for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
err = init_funcs[i].init();
if (err < 0) {
while (i--) {
if (init_funcs[i].exit)
init_funcs[i].exit();
}
return err;
} else if (err > 0) {
/*
* Early-exit success is reserved for things which
* don't have an exit() function because we have no
* idea how far they got or how to partially tear
* them down.
*/
WARN_ON(init_funcs[i].exit);
/*
* We don't want to advertise devices with an only
* partially initialized driver.
*/
WARN_ON(i915_pci_driver.driver.owner);
break;
}
- }
- init_progress = i;
- return 0;
-}
-static void __exit i915_exit(void) -{
- int i;
- for (i = init_progress - 1; i >= 0; i--) {
GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
if (init_funcs[i].exit)
init_funcs[i].exit();
- }
-}
-module_init(i915_init); -module_exit(i915_exit);
-MODULE_AUTHOR("Tungsten Graphics, Inc."); -MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.h b/drivers/gpu/drm/i915/i915_pci.h new file mode 100644 index 000000000000..b386f319f52e --- /dev/null +++ b/drivers/gpu/drm/i915/i915_pci.h @@ -0,0 +1,8 @@ +/*
- SPDX-License-Identifier: MIT
- Copyright © 2021 Intel Corporation
- */
+int i915_register_pci_driver(void); +void i915_unregister_pci_driver(void);
On Tue, 27 Jul 2021, Daniel Vetter daniel.vetter@ffwll.ch wrote:
+static void __exit i915_exit(void) +{
- int i;
- for (i = init_progress - 1; i >= 0; i--) {
GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
Not introduced by you, but it's kind of silly we're using GEM_BUG_ON() in generic driver code.
BR, Jani.
if (init_funcs[i].exit)
init_funcs[i].exit();
- }
+}
dri-devel@lists.freedesktop.org