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: b0345bbc6d
("powerpc/msi: Improve IRQ bitmap allocator")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
parent
179ea48bc7
commit
695911fb1f
|
@ -151,7 +151,7 @@ void msi_bitmap_free(struct msi_bitmap *bmp)
|
|||
static void __init test_basics(void)
|
||||
{
|
||||
struct msi_bitmap bmp;
|
||||
int i, size = 512;
|
||||
int rc, i, size = 512;
|
||||
|
||||
/* Can't allocate a bitmap of 0 irqs */
|
||||
check(msi_bitmap_alloc(&bmp, 0, NULL) != 0);
|
||||
|
@ -185,14 +185,24 @@ static void __init test_basics(void)
|
|||
msi_bitmap_free_hwirqs(&bmp, size / 2, 1);
|
||||
check(msi_bitmap_alloc_hwirqs(&bmp, 1) == size / 2);
|
||||
|
||||
/* Free most of them for the alignment tests */
|
||||
msi_bitmap_free_hwirqs(&bmp, 3, size - 3);
|
||||
|
||||
/* Check we get a naturally aligned offset */
|
||||
check(msi_bitmap_alloc_hwirqs(&bmp, 2) % 2 == 0);
|
||||
check(msi_bitmap_alloc_hwirqs(&bmp, 4) % 4 == 0);
|
||||
check(msi_bitmap_alloc_hwirqs(&bmp, 8) % 8 == 0);
|
||||
check(msi_bitmap_alloc_hwirqs(&bmp, 9) % 16 == 0);
|
||||
check(msi_bitmap_alloc_hwirqs(&bmp, 3) % 4 == 0);
|
||||
check(msi_bitmap_alloc_hwirqs(&bmp, 7) % 8 == 0);
|
||||
check(msi_bitmap_alloc_hwirqs(&bmp, 121) % 128 == 0);
|
||||
rc = msi_bitmap_alloc_hwirqs(&bmp, 2);
|
||||
check(rc >= 0 && rc % 2 == 0);
|
||||
rc = msi_bitmap_alloc_hwirqs(&bmp, 4);
|
||||
check(rc >= 0 && rc % 4 == 0);
|
||||
rc = msi_bitmap_alloc_hwirqs(&bmp, 8);
|
||||
check(rc >= 0 && rc % 8 == 0);
|
||||
rc = msi_bitmap_alloc_hwirqs(&bmp, 9);
|
||||
check(rc >= 0 && rc % 16 == 0);
|
||||
rc = msi_bitmap_alloc_hwirqs(&bmp, 3);
|
||||
check(rc >= 0 && rc % 4 == 0);
|
||||
rc = msi_bitmap_alloc_hwirqs(&bmp, 7);
|
||||
check(rc >= 0 && rc % 8 == 0);
|
||||
rc = msi_bitmap_alloc_hwirqs(&bmp, 121);
|
||||
check(rc >= 0 && rc % 128 == 0);
|
||||
|
||||
msi_bitmap_free(&bmp);
|
||||
|
||||
|
|
Loading…
Reference in New Issue