[PATCH 1/2] powerpc/msi: Fix the msi bitmap alignment tests
Michael Ellerman
mpe at ellerman.id.au
Fri Oct 10 19:04:24 AEDT 2014
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 at ellerman.id.au>
---
arch/powerpc/sysdev/msi_bitmap.c | 26 ++++++++++++++++++--------
1 file 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)
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);
--
1.9.1
More information about the Linuxppc-dev
mailing list