diff options
author | Jerome Glisse <jglisse@redhat.com> | 2010-12-03 16:38:19 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-12-07 18:33:41 -0500 |
commit | 93225b0d7bc030f4a93165347a65893685822d70 (patch) | |
tree | 86e3dda44c3b327f91e2fcc2355f35639a4aab53 /drivers/gpu | |
parent | 541cc966915b6756e54c20eebe60ae957afdb537 (diff) |
drm/radeon/kms: forbid big bo allocation (fdo 31708) v3
Forbid allocating buffer bigger than visible VRAM or GTT, also
properly set lpfn field.
v2 - use max macro
- silence warning
v3 - don't explicitly set range limit
- use min macro
Cc: stable <stable@kernel.org>
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_object.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 1d067743fee0..a598d0049aa5 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c | |||
@@ -69,7 +69,7 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) | |||
69 | u32 c = 0; | 69 | u32 c = 0; |
70 | 70 | ||
71 | rbo->placement.fpfn = 0; | 71 | rbo->placement.fpfn = 0; |
72 | rbo->placement.lpfn = rbo->rdev->mc.active_vram_size >> PAGE_SHIFT; | 72 | rbo->placement.lpfn = 0; |
73 | rbo->placement.placement = rbo->placements; | 73 | rbo->placement.placement = rbo->placements; |
74 | rbo->placement.busy_placement = rbo->placements; | 74 | rbo->placement.busy_placement = rbo->placements; |
75 | if (domain & RADEON_GEM_DOMAIN_VRAM) | 75 | if (domain & RADEON_GEM_DOMAIN_VRAM) |
@@ -91,7 +91,8 @@ int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj, | |||
91 | { | 91 | { |
92 | struct radeon_bo *bo; | 92 | struct radeon_bo *bo; |
93 | enum ttm_bo_type type; | 93 | enum ttm_bo_type type; |
94 | int page_align = roundup(byte_align, PAGE_SIZE) >> PAGE_SHIFT; | 94 | unsigned long page_align = roundup(byte_align, PAGE_SIZE) >> PAGE_SHIFT; |
95 | unsigned long max_size = 0; | ||
95 | int r; | 96 | int r; |
96 | 97 | ||
97 | if (unlikely(rdev->mman.bdev.dev_mapping == NULL)) { | 98 | if (unlikely(rdev->mman.bdev.dev_mapping == NULL)) { |
@@ -104,6 +105,14 @@ int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj, | |||
104 | } | 105 | } |
105 | *bo_ptr = NULL; | 106 | *bo_ptr = NULL; |
106 | 107 | ||
108 | /* maximun bo size is the minimun btw visible vram and gtt size */ | ||
109 | max_size = min(rdev->mc.visible_vram_size, rdev->mc.gtt_size); | ||
110 | if ((page_align << PAGE_SHIFT) >= max_size) { | ||
111 | printk(KERN_WARNING "%s:%d alloc size %ldM bigger than %ldMb limit\n", | ||
112 | __func__, __LINE__, page_align >> (20 - PAGE_SHIFT), max_size >> 20); | ||
113 | return -ENOMEM; | ||
114 | } | ||
115 | |||
107 | retry: | 116 | retry: |
108 | bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL); | 117 | bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL); |
109 | if (bo == NULL) | 118 | if (bo == NULL) |