Message ID | 20190517140617.31187-1-janusz.krzysztofik@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [RFC] drm/i915: Tolerate file owned GEM contexts on hot unbind | expand |
Quoting Janusz Krzysztofik (2019-05-17 15:06:17) > From: Janusz Krzysztofik <janusz.krzysztofik@intel.com> > > During i915_driver_unload(), GEM contexts are verified restrictively > inside i915_gem_fini() if they don't consume shared resources which > should be cleaned up before the driver is released. If those checks > don't result in kernel panic, one more check is performed at the end of > i915_gem_fini() which issues a WARN_ON() if GEM contexts still exist. Just fix the underlying bug of this code being called too early. The assumptions we made for unload are clearly invalid when applied to unbind, and we need to split the phases. -Chris
On Friday, May 17, 2019 4:32:35 PM CEST Chris Wilson wrote: > Quoting Janusz Krzysztofik (2019-05-17 15:06:17) > > From: Janusz Krzysztofik <janusz.krzysztofik@intel.com> > > > > During i915_driver_unload(), GEM contexts are verified restrictively > > inside i915_gem_fini() if they don't consume shared resources which > > should be cleaned up before the driver is released. If those checks > > don't result in kernel panic, one more check is performed at the end of > > i915_gem_fini() which issues a WARN_ON() if GEM contexts still exist. > > Just fix the underlying bug of this code being called too early. The > assumptions we made for unload are clearly invalid when applied to > unbind, and we need to split the phases. > -Chris Thanks Chris, I think I get it finally. Janusz
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 54f27cabae2a..c00b6dbaf4f5 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4670,7 +4670,17 @@ void i915_gem_fini(struct drm_i915_private *dev_priv) i915_gem_drain_freed_objects(dev_priv); - WARN_ON(!list_empty(&dev_priv->contexts.list)); + if (drm_dev_is_unplugged(&dev_priv->drm)) { + struct i915_gem_context *ctx, *cn; + + list_for_each_entry_safe(ctx, cn, &dev_priv->contexts.list, + link) { + WARN_ON(IS_ERR_OR_NULL(ctx->file_priv)); + break; + } + } else { + WARN_ON(!list_empty(&dev_priv->contexts.list)); + } } void i915_gem_init_mmio(struct drm_i915_private *i915)