Skip to content

Commit

Permalink
drm/i915/gem: Move stolen node into GEM object union
Browse files Browse the repository at this point in the history
The obj->stolen is currently used to identify an object allocated from
stolen memory. This dates back to when there were just 1.5 types of
objects, an object backed by shmemfs and an object backed by shmemfs
with a contiguous physical address. Now that we have several different
types of objects, we no longer want to treat stolen objects as a special
case.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210119214336.1463-3-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed Jan 20, 2021
1 parent 30d2bfd commit 41a9c75
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions drivers/gpu/drm/i915/display/intel_fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
* If the object is stolen however, it will be full of whatever
* garbage was left in there.
*/
if (vma->obj->stolen && !prealloc)
if (!i915_gem_object_is_shmem(vma->obj) && !prealloc)
memset_io(info->screen_base, 0, info->screen_size);

/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
Expand Down Expand Up @@ -595,7 +595,7 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous
* full of whatever garbage was left in there.
*/
if (state == FBINFO_STATE_RUNNING &&
intel_fb_obj(&ifbdev->fb->base)->stolen)
!i915_gem_object_is_shmem(intel_fb_obj(&ifbdev->fb->base)))
memset_io(info->screen_base, 0, info->screen_size);

drm_fb_helper_set_suspend(&ifbdev->helper, state);
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,4 +531,6 @@ i915_gem_object_invalidate_frontbuffer(struct drm_i915_gem_object *obj,
__i915_gem_object_invalidate_frontbuffer(obj, origin);
}

bool i915_gem_object_is_shmem(const struct drm_i915_gem_object *obj);

#endif
4 changes: 2 additions & 2 deletions drivers/gpu/drm/i915/gem/i915_gem_object_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ struct drm_i915_gem_object {
*/
struct list_head obj_link;

/** Stolen memory for this object, instead of being backed by shmem. */
struct drm_mm_node *stolen;
union {
struct rcu_head rcu;
struct llist_node freed;
Expand Down Expand Up @@ -303,6 +301,8 @@ struct drm_i915_gem_object {
struct work_struct *work;
} userptr;

struct drm_mm_node *stolen;

unsigned long scratch;
u64 encode;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/gem/i915_gem_phys.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, int align)
if (obj->ops == &i915_gem_phys_ops)
return 0;

if (obj->ops != &i915_gem_shmem_ops)
if (!i915_gem_object_is_shmem(obj))
return -EINVAL;

err = i915_gem_object_unbind(obj, I915_GEM_OBJECT_UNBIND_ACTIVE);
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,8 @@ struct intel_memory_region *i915_gem_shmem_setup(struct drm_i915_private *i915)
PAGE_SIZE, 0,
&shmem_region_ops);
}

bool i915_gem_object_is_shmem(const struct drm_i915_gem_object *obj)
{
return obj->ops == &i915_gem_shmem_ops;
}
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_stolen.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,3 +781,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *i915,
kfree(stolen);
return obj;
}

bool i915_gem_object_is_stolen(const struct drm_i915_gem_object *obj)
{
return obj->ops == &i915_gem_object_stolen_ops;
}
2 changes: 2 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_stolen.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv
resource_size_t stolen_offset,
resource_size_t size);

bool i915_gem_object_is_stolen(const struct drm_i915_gem_object *obj);

#define I915_GEM_STOLEN_BIAS SZ_128K

#endif /* __I915_GEM_STOLEN_H__ */
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/gt/intel_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int intel_ring_pin(struct intel_ring *ring, struct i915_gem_ww_ctx *ww)
/* Ring wraparound at offset 0 sometimes hangs. No idea why. */
flags = PIN_OFFSET_BIAS | i915_ggtt_pin_bias(vma);

if (vma->obj->stolen)
if (i915_gem_object_is_stolen(vma->obj))
flags |= PIN_MAPPABLE;
else
flags |= PIN_HIGH;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/gt/shmem_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
struct file *file;
void *ptr;

if (obj->ops == &i915_gem_shmem_ops) {
if (i915_gem_object_is_shmem(obj)) {
file = obj->base.filp;
atomic_long_inc(&file->f_count);
return file;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/i915_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ i915_debugfs_describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
spin_unlock(&obj->vma.lock);

seq_printf(m, " (pinned x %d)", pin_count);
if (obj->stolen)
if (i915_gem_object_is_stolen(obj))
seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
if (i915_gem_object_is_framebuffer(obj))
seq_printf(m, " (fb)");
Expand Down

0 comments on commit 41a9c75

Please sign in to comment.