Starting with commit ec3e00b4ee27 ("drm/i915: stop registering if drm_dev_register() fails"), we may return from i915_driver_register() immediately, skipping remaining registration steps. However, the _unregister() counterpart called at device remove knows nothing about that skip and executes reverts of all those steps. As a consequence, a number of kernel warnings that taint the kernel are triggered. Introduce a flag that indicates device registration status and raise it on device registration success. As a minimum (first patch), when that flag is found not set while unregistering the driver, jump over those reverts of registration steps omitted after device registration failure that are not ready for being called unconditionally (and trigger the kernel warnings). With the second patch, also jump over reverts of other driver registration steps that were not called due to device registration failure. Some unregister function calls, found implementing additional steps beyond the register reverts, are still executed. To simplify i915_driver_unregister() code, the third patch makes sure reverts of driver registration steps executed before potentially unsuccessful device registration are symmetrically called after the device unplug. Finally, the last patch further simplifies the i915_driver_unregister() code by moving two required steps down, right after device unplug. The first patch may be squashed with one or more of its follow-ups if so decided. Janusz Krzysztofik (4): drm/i915: Skip harmful unregister steps if not registered drm/i915: Omit unnecessary driver unregister steps drm/i915: Fix asymmetry in PMU register/unregister step order drm/i915: Group not skipped unregister steps drivers/gpu/drm/i915/gt/intel_gt.c | 6 ++++++ drivers/gpu/drm/i915/i915_driver.c | 18 ++++++++++++------ drivers/gpu/drm/i915/i915_drv.h | 2 ++ 3 files changed, 20 insertions(+), 6 deletions(-) -- 2.48.1