[Intel-gfx] [PATCH 2/2] RFC: drm/i915: Switch obj->mm.lock lockdep annotations on its head
Chris Wilson
chris at chris-wilson.co.uk
Wed Aug 14 13:06:23 UTC 2019
Quoting Daniel Vetter (2019-08-14 13:49:33)
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> index d474c6ac4100..1ea3c3c96a5a 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
> @@ -157,7 +157,15 @@ struct drm_i915_gem_object {
> unsigned int pin_global;
>
> struct {
> - struct mutex lock; /* protects the pages and their use */
> + /*
> + * Protects the pages and their use.
> + *
> + * IMPORTANT: It is not allowed to allocate memory while holding
> + * this lock, because the shrinker might recurse on it, except
> + * when there are no pages allocated yet and the object isn't
> + * visible on any LRU.
It's not meant to be public free-for-lock, just to guard the transition
between 0<->1. Inside that transition we do page allocations.
Everyone else takes a pin.
> + */
> + struct mutex lock;
> atomic_t pages_pin_count;
>
> struct sg_table *pages;
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> index 18f0ce0135c1..3b7ec6e6ea8b 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> @@ -101,7 +101,7 @@ int __i915_gem_object_get_pages(struct drm_i915_gem_object *obj)
Fwiw, we have use cases (and people asking where are those patches) for
nested allocations.
-Chris
More information about the Intel-gfx
mailing list