aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_pci.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2021-07-27 14:10:37 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2021-07-28 17:20:05 +0200
commit708b7df3480aff61449e848876876b930ce93c4a (patch)
tree4bbbf0e41906b02deb60afab0f6adea1a063e95a /drivers/gpu/drm/i915/i915_pci.c
parentdrm/i915: Remove i915_globals (diff)
downloadlinux-dev-708b7df3480aff61449e848876876b930ce93c4a.tar.xz
linux-dev-708b7df3480aff61449e848876876b930ce93c4a.zip
drm/i915: Extract i915_module.c
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. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Cc: Jason Ekstrand <jason@jlekstrand.net> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210727121037.2041102-11-daniel.vetter@ffwll.ch
Diffstat (limited to 'drivers/gpu/drm/i915/i915_pci.c')
-rw-r--r--drivers/gpu/drm/i915/i915_pci.c117
1 files changed, 3 insertions, 114 deletions
diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
index fbe7795a2027..b76c2ba8451c 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) \
@@ -1216,31 +1205,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,
@@ -1250,87 +1214,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");