Skip to contentSkip to conversation

radeon: avoid possible divide by 0 in surface manager

PATCH In review Alex Deucher 3 participants 4 messages Dec 10, 2013 – Dec 24, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 radeon: avoid possible divide by 0 in surface manager

Some users report hitting a divide by 0 with the tile split in certain apps. Tile_split shouldn't ever be 0 unless the surface structure was not properly initialized. I think there may be some cases where mesa uses an improperly initialized surface struct, but I haven't had time to track it down.

Bug:
https://bugs.freedesktop.org/show_bug.cgi?id=72425

---
 radeon/radeon_surface.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
radeon/radeon_surface.c +3 -3
index dcbbfdc..15127d4 100644
@@ -655,7 +655,7 @@ static int eg_surface_init_2d(struct radeon_surface_manager *surf_man,
     tileb = tilew * tileh * bpe * surf->nsamples;
     /* slices per tile */
     slice_pt = 1;
-    if (tileb > tile_split) {
+    if (tileb > tile_split && tile_split) {
         slice_pt = tileb / tile_split;
     }
     tileb = tileb / slice_pt;
@@ -1621,7 +1621,7 @@ static int si_surface_init_2d(struct radeon_surface_manager *surf_man,
     tileb = tilew * tileh * bpe * surf->nsamples;
     /* slices per tile */
     slice_pt = 1;
-    if (tileb > tile_split) {
+    if (tileb > tile_split && tile_split) {
         slice_pt = tileb / tile_split;
     }
     tileb = tileb / slice_pt;
@@ -2223,7 +2223,7 @@ static int cik_surface_init_2d(struct radeon_surface_manager *surf_man,
 
     /* slices per tile */
     slice_pt = 1;
-    if (tileb > tile_split) {
+    if (tileb > tile_split && tile_split) {
         slice_pt = tileb / tile_split;
         tileb = tileb / slice_pt;
     }
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw

Marek

Quoted 48 lines · Alex Deucher

Some users report hitting a divide by 0 with the tile split in certain apps. Tile_split shouldn't ever be 0 unless the surface structure was not properly initialized. I think there may be some cases where mesa uses an improperly initialized surface struct, but I haven't had time to track it down.

Bug:
https://bugs.freedesktop.org/show_bug.cgi?id=72425

---
 radeon/radeon_surface.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
radeon/radeon_surface.c +3 -4
index dcbbfdc..15127d4 100644
@@ -655,7 +655,7 @@ static int eg_surface_init_2d(struct radeon_surface_manager *surf_man,
     tileb = tilew * tileh * bpe * surf->nsamples;
     /* slices per tile */
     slice_pt = 1;
-    if (tileb > tile_split) {
+    if (tileb > tile_split && tile_split) {
         slice_pt = tileb / tile_split;
     }
     tileb = tileb / slice_pt;
@@ -1621,7 +1621,7 @@ static int si_surface_init_2d(struct radeon_surface_manager *surf_man,
     tileb = tilew * tileh * bpe * surf->nsamples;
     /* slices per tile */
     slice_pt = 1;
-    if (tileb > tile_split) {
+    if (tileb > tile_split && tile_split) {
         slice_pt = tileb / tile_split;
     }
     tileb = tileb / slice_pt;
@@ -2223,7 +2223,7 @@ static int cik_surface_init_2d(struct radeon_surface_manager *surf_man,
 
     /* slices per tile */
     slice_pt = 1;
-    if (tileb > tile_split) {
+    if (tileb > tile_split && tile_split) {
         slice_pt = tileb / tile_split;
         tileb = tileb / slice_pt;
     }
--

1.8.3.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
In reply to Alex Deucher
Quoted 5 lines · Alex Deucher

Some users report hitting a divide by 0 with the tile split in certain apps. Tile_split shouldn't ever be 0 unless the surface structure was not properly initialized. I think there may be some cases where mesa uses an improperly initialized surface struct, but I haven't had time to track it down.

It would be good to know where the bogus tile split is coming from though — who knows what else might be wrong in that case?

Signature · 7 lines
Earthling Michel Dänzer            |                  http://www.amd.com
Libre software enthusiast          |                Mesa and X developer

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 9 lines · Michel Dänzer
Quoted 5 lines · Alex Deucher

Some users report hitting a divide by 0 with the tile split in certain apps. Tile_split shouldn't ever be 0 unless the surface structure was not properly initialized. I think there may be some cases where mesa uses an improperly initialized surface struct, but I haven't had time to track it down.

It would be good to know where the bogus tile split is coming from though — who knows what else might be wrong in that case?

Agreed. The reporter updated the bug with the full backtrace, I just haven't had a chance to look at it yet.
https://bugs.freedesktop.org/show_bug.cgi?id=72425

Alex

Quoted 6 lines

--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer