aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/radeon_state.c
diff options
context:
space:
mode:
author=?utf-8?q?Michel_D=C3=A4nzer?= <michel@tungstengraphics.com>2006-12-15 02:54:35 -0500
committerDave Airlie <airlied@linux.ie>2006-12-15 02:54:35 -0500
commit1d6bb8e51dba3db1c15575901022fe72d363e5a4 (patch)
treed7a3a26d427050ab3d7ca76d9df5083afc3df888 /drivers/char/drm/radeon_state.c
parent3188a24c256bae0ed93d81d82db1f1bb6060d727 (diff)
drm: Unify radeon offset checking.
Replace r300_check_offset() with generic radeon_check_offset(), which doesn't reject valid offsets when the framebuffer area is at the very end of the card's 32 bit address space. Make radeon_check_and_fixup_offset() use radeon_check_offset() as well. This fixes https://bugs.freedesktop.org/show_bug.cgi?id=7697 .
Diffstat (limited to 'drivers/char/drm/radeon_state.c')
-rw-r--r--drivers/char/drm/radeon_state.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c
index 6e04fdd732ac..938eccb78cc0 100644
--- a/drivers/char/drm/radeon_state.c
+++ b/drivers/char/drm/radeon_state.c
@@ -43,10 +43,7 @@ static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t *
43 u32 *offset) 43 u32 *offset)
44{ 44{
45 u64 off = *offset; 45 u64 off = *offset;
46 u32 fb_start = dev_priv->fb_location; 46 u32 fb_end = dev_priv->fb_location + dev_priv->fb_size - 1;
47 u32 fb_end = fb_start + dev_priv->fb_size - 1;
48 u32 gart_start = dev_priv->gart_vm_start;
49 u32 gart_end = gart_start + dev_priv->gart_size - 1;
50 struct drm_radeon_driver_file_fields *radeon_priv; 47 struct drm_radeon_driver_file_fields *radeon_priv;
51 48
52 /* Hrm ... the story of the offset ... So this function converts 49 /* Hrm ... the story of the offset ... So this function converts
@@ -66,8 +63,7 @@ static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t *
66 /* First, the best case, the offset already lands in either the 63 /* First, the best case, the offset already lands in either the
67 * framebuffer or the GART mapped space 64 * framebuffer or the GART mapped space
68 */ 65 */
69 if ((off >= fb_start && off <= fb_end) || 66 if (radeon_check_offset(dev_priv, off))
70 (off >= gart_start && off <= gart_end))
71 return 0; 67 return 0;
72 68
73 /* Ok, that didn't happen... now check if we have a zero based 69 /* Ok, that didn't happen... now check if we have a zero based
@@ -81,11 +77,10 @@ static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t *
81 77
82 /* Finally, assume we aimed at a GART offset if beyond the fb */ 78 /* Finally, assume we aimed at a GART offset if beyond the fb */
83 if (off > fb_end) 79 if (off > fb_end)
84 off = off - fb_end - 1 + gart_start; 80 off = off - fb_end - 1 + dev_priv->gart_vm_start;
85 81
86 /* Now recheck and fail if out of bounds */ 82 /* Now recheck and fail if out of bounds */
87 if ((off >= fb_start && off <= fb_end) || 83 if (radeon_check_offset(dev_priv, off)) {
88 (off >= gart_start && off <= gart_end)) {
89 DRM_DEBUG("offset fixed up to 0x%x\n", (unsigned int)off); 84 DRM_DEBUG("offset fixed up to 0x%x\n", (unsigned int)off);
90 *offset = off; 85 *offset = off;
91 return 0; 86 return 0;