diff options
author | Maarten Maathuis <madman2003@gmail.com> | 2009-12-25 12:51:17 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2010-01-10 18:06:36 -0500 |
commit | 1c7059e4f36e76c72cefbb6c9bd2bcf45c12e777 (patch) | |
tree | 3bf415ce10c2f5760cb73f2a6a69480f6a71eee1 /drivers/gpu/drm/nouveau/nouveau_bo.c | |
parent | 111b459af191891f49682f21e11f348703cd8bdd (diff) |
drm/nouveau: better alignment of bo sizes and use roundup instead of ALIGN
- Aligning to block size should ensure that the extra size is enough.
- Using roundup, because not all sizes are powers of two.
Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_bo.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bo.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 5fd462f49407..a0c9e00e7062 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c | |||
@@ -73,6 +73,7 @@ nouveau_bo_fixup_align(struct drm_device *dev, | |||
73 | case 0x4800: | 73 | case 0x4800: |
74 | case 0x7a00: | 74 | case 0x7a00: |
75 | if (dev_priv->chipset >= 0xA0) { | 75 | if (dev_priv->chipset >= 0xA0) { |
76 | *size = roundup(*size, 28672); | ||
76 | /* This is based on high end cards with 448 bits | 77 | /* This is based on high end cards with 448 bits |
77 | * memory bus, could be different elsewhere.*/ | 78 | * memory bus, could be different elsewhere.*/ |
78 | *size += 6 * 28672; | 79 | *size += 6 * 28672; |
@@ -80,9 +81,11 @@ nouveau_bo_fixup_align(struct drm_device *dev, | |||
80 | * but we must also align to page size. */ | 81 | * but we must also align to page size. */ |
81 | *align = 2 * 8 * 28672; | 82 | *align = 2 * 8 * 28672; |
82 | } else if (dev_priv->chipset >= 0x90) { | 83 | } else if (dev_priv->chipset >= 0x90) { |
84 | *size = roundup(*size, 16384); | ||
83 | *size += 3 * 16384; | 85 | *size += 3 * 16384; |
84 | *align = 12 * 16384; | 86 | *align = 12 * 16384; |
85 | } else { | 87 | } else { |
88 | *size = roundup(*size, 8192); | ||
86 | *size += 3 * 8192; | 89 | *size += 3 * 8192; |
87 | /* 12 * 8192 is the actual alignment requirement | 90 | /* 12 * 8192 is the actual alignment requirement |
88 | * but we must also align to page size. */ | 91 | * but we must also align to page size. */ |
@@ -114,10 +117,11 @@ nouveau_bo_fixup_align(struct drm_device *dev, | |||
114 | } | 117 | } |
115 | } | 118 | } |
116 | 119 | ||
117 | *size = ALIGN(*size, PAGE_SIZE); | 120 | /* ALIGN works only on powers of two. */ |
121 | *size = roundup(*size, PAGE_SIZE); | ||
118 | 122 | ||
119 | if (dev_priv->card_type == NV_50) { | 123 | if (dev_priv->card_type == NV_50) { |
120 | *size = ALIGN(*size, 65536); | 124 | *size = roundup(*size, 65536); |
121 | *align = max(65536, *align); | 125 | *align = max(65536, *align); |
122 | } | 126 | } |
123 | } | 127 | } |