intel: Fix up math errors when allocating very large BOs.
authorEric Anholt <eric@anholt.net>
Mon, 6 Jul 2009 18:55:28 +0000 (11:55 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 6 Jul 2009 20:11:03 +0000 (13:11 -0700)
commit78fa590a1d297f2e2fea98bd3f0cbf4cdb1e3a08
tree69b75677d8c3910a6aa8ed3e921b9cba1cd6a174
parentcea2d29ee49f23d560f0088a1a3dd01932a1eaf4
intel: Fix up math errors when allocating very large BOs.

The logbase2 would overflow and wrap the size around to 0, making the code
allocate a 4kb object instead.  By simplifying the code to just walk the
14-entry bucket array comparing sizes instead of indexing on
ffs(1 << logbase2(size)), we avoid silly math errors and have code of
approximately the same speed.

Many thanks to Simon Farnsworth for debugging and providing a working patch.
Bug #27365.
libdrm/intel/intel_bufmgr_gem.c