aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2014-10-10 04:04:24 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2014-10-14 22:09:32 -0400
commit695911fb1f0e00aebe6c5636b9c08bf0fd51a2fd (patch)
treec211272ee81a84b6134e4754cccd8d5529676a6c /arch/powerpc/sysdev
parent179ea48bc7c04dba3526d66d9f358c2f4f3b3776 (diff)
powerpc/msi: Fix the msi bitmap alignment tests
When we added the alignment tests recently we failed to check they were actually passing - oops. They weren't passing, because the bitmap was full. We should also be a bit more careful when checking the return code, a negative error return could by divisible by our alignment value. Fixes: b0345bbc6d09 ("powerpc/msi: Improve IRQ bitmap allocator") Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/sysdev')
-rw-r--r--arch/powerpc/sysdev/msi_bitmap.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/arch/powerpc/sysdev/msi_bitmap.c b/arch/powerpc/sysdev/msi_bitmap.c
index 0c75214b6f92..8155d93dee1d 100644
--- a/arch/powerpc/sysdev/msi_bitmap.c
+++ b/arch/powerpc/sysdev/msi_bitmap.c
@@ -151,7 +151,7 @@ void msi_bitmap_free(struct msi_bitmap *bmp)
151static void __init test_basics(void) 151static void __init test_basics(void)
152{ 152{
153 struct msi_bitmap bmp; 153 struct msi_bitmap bmp;
154 int i, size = 512; 154 int rc, i, size = 512;
155 155
156 /* Can't allocate a bitmap of 0 irqs */ 156 /* Can't allocate a bitmap of 0 irqs */
157 check(msi_bitmap_alloc(&bmp, 0, NULL) != 0); 157 check(msi_bitmap_alloc(&bmp, 0, NULL) != 0);
@@ -185,14 +185,24 @@ static void __init test_basics(void)
185 msi_bitmap_free_hwirqs(&bmp, size / 2, 1); 185 msi_bitmap_free_hwirqs(&bmp, size / 2, 1);
186 check(msi_bitmap_alloc_hwirqs(&bmp, 1) == size / 2); 186 check(msi_bitmap_alloc_hwirqs(&bmp, 1) == size / 2);
187 187
188 /* Free most of them for the alignment tests */
189 msi_bitmap_free_hwirqs(&bmp, 3, size - 3);
190
188 /* Check we get a naturally aligned offset */ 191 /* Check we get a naturally aligned offset */
189 check(msi_bitmap_alloc_hwirqs(&bmp, 2) % 2 == 0); 192 rc = msi_bitmap_alloc_hwirqs(&bmp, 2);
190 check(msi_bitmap_alloc_hwirqs(&bmp, 4) % 4 == 0); 193 check(rc >= 0 && rc % 2 == 0);
191 check(msi_bitmap_alloc_hwirqs(&bmp, 8) % 8 == 0); 194 rc = msi_bitmap_alloc_hwirqs(&bmp, 4);
192 check(msi_bitmap_alloc_hwirqs(&bmp, 9) % 16 == 0); 195 check(rc >= 0 && rc % 4 == 0);
193 check(msi_bitmap_alloc_hwirqs(&bmp, 3) % 4 == 0); 196 rc = msi_bitmap_alloc_hwirqs(&bmp, 8);
194 check(msi_bitmap_alloc_hwirqs(&bmp, 7) % 8 == 0); 197 check(rc >= 0 && rc % 8 == 0);
195 check(msi_bitmap_alloc_hwirqs(&bmp, 121) % 128 == 0); 198 rc = msi_bitmap_alloc_hwirqs(&bmp, 9);
199 check(rc >= 0 && rc % 16 == 0);
200 rc = msi_bitmap_alloc_hwirqs(&bmp, 3);
201 check(rc >= 0 && rc % 4 == 0);
202 rc = msi_bitmap_alloc_hwirqs(&bmp, 7);
203 check(rc >= 0 && rc % 8 == 0);
204 rc = msi_bitmap_alloc_hwirqs(&bmp, 121);
205 check(rc >= 0 && rc % 128 == 0);
196 206
197 msi_bitmap_free(&bmp); 207 msi_bitmap_free(&bmp);
198 208