diff options
| author | Maarten Maathuis <madman2003@gmail.com> | 2009-12-27 06:22:07 -0500 |
|---|---|---|
| committer | Ben Skeggs <bskeggs@redhat.com> | 2010-02-09 17:19:34 -0500 |
| commit | eb1dba0ebaa5b7642b323fac148f9947522a48a8 (patch) | |
| tree | 5aaf08820f7b37235f04d79e7aadef9a80326930 | |
| parent | 5025b43120b629bdf11087a3c652dc9cbe172191 (diff) | |
drm/nv50: align size of buffer object to the right boundaries.
- In the current situation the padding that is added is dangerous to write
to, userspace could potentially overwrite parts of another bo.
- Depth and stencil buffers are supposed to be large enough in general so
the waste of memory should be acceptable.
- Alternatives are hiding the padding from users or splitting vram into 2
zones.
Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
| -rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bo.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index db0ed4c13f98..028719fddf76 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c | |||
| @@ -65,8 +65,10 @@ nouveau_bo_fixup_align(struct drm_device *dev, | |||
| 65 | 65 | ||
| 66 | /* | 66 | /* |
| 67 | * Some of the tile_flags have a periodic structure of N*4096 bytes, | 67 | * Some of the tile_flags have a periodic structure of N*4096 bytes, |
| 68 | * align to to that as well as the page size. Overallocate memory to | 68 | * align to to that as well as the page size. Align the size to the |
| 69 | * avoid corruption of other buffer objects. | 69 | * appropriate boundaries. This does imply that sizes are rounded up |
| 70 | * 3-7 pages, so be aware of this and do not waste memory by allocating | ||
| 71 | * many small buffers. | ||
| 70 | */ | 72 | */ |
| 71 | if (dev_priv->card_type == NV_50) { | 73 | if (dev_priv->card_type == NV_50) { |
| 72 | uint32_t block_size = nouveau_mem_fb_amount(dev) >> 15; | 74 | uint32_t block_size = nouveau_mem_fb_amount(dev) >> 15; |
| @@ -77,22 +79,20 @@ nouveau_bo_fixup_align(struct drm_device *dev, | |||
| 77 | case 0x2800: | 79 | case 0x2800: |
| 78 | case 0x4800: | 80 | case 0x4800: |
| 79 | case 0x7a00: | 81 | case 0x7a00: |
| 80 | *size = roundup(*size, block_size); | ||
| 81 | if (is_power_of_2(block_size)) { | 82 | if (is_power_of_2(block_size)) { |
| 82 | *size += 3 * block_size; | ||
| 83 | for (i = 1; i < 10; i++) { | 83 | for (i = 1; i < 10; i++) { |
| 84 | *align = 12 * i * block_size; | 84 | *align = 12 * i * block_size; |
| 85 | if (!(*align % 65536)) | 85 | if (!(*align % 65536)) |
| 86 | break; | 86 | break; |
| 87 | } | 87 | } |
| 88 | } else { | 88 | } else { |
| 89 | *size += 6 * block_size; | ||
| 90 | for (i = 1; i < 10; i++) { | 89 | for (i = 1; i < 10; i++) { |
| 91 | *align = 8 * i * block_size; | 90 | *align = 8 * i * block_size; |
| 92 | if (!(*align % 65536)) | 91 | if (!(*align % 65536)) |
| 93 | break; | 92 | break; |
| 94 | } | 93 | } |
| 95 | } | 94 | } |
| 95 | *size = roundup(*size, *align); | ||
| 96 | break; | 96 | break; |
| 97 | default: | 97 | default: |
| 98 | break; | 98 | break; |
