Created attachment 30782 [details] [review] drm/radeon/kms: fix calculation of free dwords in ring There are two scenarios of read/write pointers relation: 1) read lower than write /----------------------------\ | A B C D E F G | | 1 2 3 4 5 6 7 8 9 10 11 12 | \----------------------------/ R W used = w - r free = size - used free = size - (w - r) free = size - w + r free = r + size - w 2) write lower than read /----------------------------\ | E F G A B C D | | 1 2 3 4 5 6 7 8 9 10 11 12 | \----------------------------/ W R free = r - w I made there ascii pictures to make it clear, as noone believed me today on IRC we have some bug there ;) Problem is we calculate free dwords for first situation only (always). We have to detect second situation and use other calculation then.
You can see real hitting this issue in bug #24535 (check rings dumps logs).
The current code works as is since the ring size is always a power of two as per the comment in the code: A B C D E F G 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 R W (3 + 16 - 9) & 15 = 10 E F G A B C D 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 W R (12 + 16 - 2) & 15 = 10
(In reply to comment #2) > The current code works as is since the ring size is always a power of two as > per the comment in the code: It seems so... I've never played with so hackish (like for me) bit operations. Thanks for explaining.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.