diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-10-10 08:46:37 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-10-16 16:06:39 -0400 |
commit | aa5f8021811aede2e40aa715c55fbd87d945a443 (patch) | |
tree | a491c020dab146964f8ec6da84a47367b4dff7c1 | |
parent | 80075d492f8773209e26d11d6bb13ba624ef95a4 (diff) |
drm/i915: Use unsigned long for obj->user_pin_count
At least on linux sizeof(long) == sizeof(void*) and the thinking
is that you can grab about as many references as there's memory.
Doesn't really matter, just a bit of OCD since the fixed size data
type in a pure in-kernel datastructure look off.
v2: Ville asked for an overflow check since no one prevents userspace
from incrementing the pin count forever.
v3: s/INT/LONG/, noticed by Chris.
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 759de9f123fd..e4ff8e91d939 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -1604,7 +1604,7 @@ struct drm_i915_gem_object { | |||
1604 | unsigned long *bit_17; | 1604 | unsigned long *bit_17; |
1605 | 1605 | ||
1606 | /** User space pin count and filp owning the pin */ | 1606 | /** User space pin count and filp owning the pin */ |
1607 | uint32_t user_pin_count; | 1607 | unsigned long user_pin_count; |
1608 | struct drm_file *pin_filp; | 1608 | struct drm_file *pin_filp; |
1609 | 1609 | ||
1610 | /** for phy allocated objects */ | 1610 | /** for phy allocated objects */ |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index f10ae6498bce..34df59b660f8 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -3931,6 +3931,11 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data, | |||
3931 | goto out; | 3931 | goto out; |
3932 | } | 3932 | } |
3933 | 3933 | ||
3934 | if (obj->user_pin_count == ULONG_MAX) { | ||
3935 | ret = -EBUSY; | ||
3936 | goto out; | ||
3937 | } | ||
3938 | |||
3934 | if (obj->user_pin_count == 0) { | 3939 | if (obj->user_pin_count == 0) { |
3935 | ret = i915_gem_obj_ggtt_pin(obj, args->alignment, true, false); | 3940 | ret = i915_gem_obj_ggtt_pin(obj, args->alignment, true, false); |
3936 | if (ret) | 3941 | if (ret) |