diff options
| author | Michael Ellerman <mpe@ellerman.id.au> | 2014-10-10 04:04:25 -0400 |
|---|---|---|
| committer | Michael Ellerman <mpe@ellerman.id.au> | 2014-10-14 22:09:33 -0400 |
| commit | 4a77f2bdbdef289a02bd02fac483a9350e039705 (patch) | |
| tree | 1bba1d405b333bd5b8a2d826ed3e4e8792943ddf /arch/powerpc/sysdev | |
| parent | 695911fb1f0e00aebe6c5636b9c08bf0fd51a2fd (diff) | |
powerpc/msi: Use WARN_ON() in msi bitmap selftests
As demonstrated in the previous commit, the failure message from the msi
bitmap selftests is a bit subtle, it's easy to miss a failure in a busy
boot log.
So drop our check() macro and use WARN_ON() instead. This necessitates
inverting all the conditions as well.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/sysdev')
| -rw-r--r-- | arch/powerpc/sysdev/msi_bitmap.c | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/arch/powerpc/sysdev/msi_bitmap.c b/arch/powerpc/sysdev/msi_bitmap.c index 8155d93dee1d..73b64c73505b 100644 --- a/arch/powerpc/sysdev/msi_bitmap.c +++ b/arch/powerpc/sysdev/msi_bitmap.c | |||
| @@ -145,69 +145,64 @@ void msi_bitmap_free(struct msi_bitmap *bmp) | |||
| 145 | 145 | ||
| 146 | #ifdef CONFIG_MSI_BITMAP_SELFTEST | 146 | #ifdef CONFIG_MSI_BITMAP_SELFTEST |
| 147 | 147 | ||
| 148 | #define check(x) \ | ||
| 149 | if (!(x)) printk("msi_bitmap: test failed at line %d\n", __LINE__); | ||
| 150 | |||
| 151 | static void __init test_basics(void) | 148 | static void __init test_basics(void) |
| 152 | { | 149 | { |
| 153 | struct msi_bitmap bmp; | 150 | struct msi_bitmap bmp; |
| 154 | int rc, i, size = 512; | 151 | int rc, i, size = 512; |
| 155 | 152 | ||
| 156 | /* Can't allocate a bitmap of 0 irqs */ | 153 | /* Can't allocate a bitmap of 0 irqs */ |
| 157 | check(msi_bitmap_alloc(&bmp, 0, NULL) != 0); | 154 | WARN_ON(msi_bitmap_alloc(&bmp, 0, NULL) == 0); |
| 158 | 155 | ||
| 159 | /* of_node may be NULL */ | 156 | /* of_node may be NULL */ |
| 160 | check(0 == msi_bitmap_alloc(&bmp, size, NULL)); | 157 | WARN_ON(msi_bitmap_alloc(&bmp, size, NULL)); |
| 161 | 158 | ||
| 162 | /* Should all be free by default */ | 159 | /* Should all be free by default */ |
| 163 | check(0 == bitmap_find_free_region(bmp.bitmap, size, | 160 | WARN_ON(bitmap_find_free_region(bmp.bitmap, size, get_count_order(size))); |
| 164 | get_count_order(size))); | ||
| 165 | bitmap_release_region(bmp.bitmap, 0, get_count_order(size)); | 161 | bitmap_release_region(bmp.bitmap, 0, get_count_order(size)); |
| 166 | 162 | ||
| 167 | /* With no node, there's no msi-available-ranges, so expect > 0 */ | 163 | /* With no node, there's no msi-available-ranges, so expect > 0 */ |
| 168 | check(msi_bitmap_reserve_dt_hwirqs(&bmp) > 0); | 164 | WARN_ON(msi_bitmap_reserve_dt_hwirqs(&bmp) <= 0); |
| 169 | 165 | ||
| 170 | /* Should all still be free */ | 166 | /* Should all still be free */ |
| 171 | check(0 == bitmap_find_free_region(bmp.bitmap, size, | 167 | WARN_ON(bitmap_find_free_region(bmp.bitmap, size, get_count_order(size))); |
| 172 | get_count_order(size))); | ||
| 173 | bitmap_release_region(bmp.bitmap, 0, get_count_order(size)); | 168 | bitmap_release_region(bmp.bitmap, 0, get_count_order(size)); |
| 174 | 169 | ||
| 175 | /* Check we can fill it up and then no more */ | 170 | /* Check we can fill it up and then no more */ |
| 176 | for (i = 0; i < size; i++) | 171 | for (i = 0; i < size; i++) |
| 177 | check(msi_bitmap_alloc_hwirqs(&bmp, 1) >= 0); | 172 | WARN_ON(msi_bitmap_alloc_hwirqs(&bmp, 1) < 0); |
| 178 | 173 | ||
| 179 | check(msi_bitmap_alloc_hwirqs(&bmp, 1) < 0); | 174 | WARN_ON(msi_bitmap_alloc_hwirqs(&bmp, 1) >= 0); |
| 180 | 175 | ||
| 181 | /* Should all be allocated */ | 176 | /* Should all be allocated */ |
| 182 | check(bitmap_find_free_region(bmp.bitmap, size, 0) < 0); | 177 | WARN_ON(bitmap_find_free_region(bmp.bitmap, size, 0) >= 0); |
| 183 | 178 | ||
| 184 | /* And if we free one we can then allocate another */ | 179 | /* And if we free one we can then allocate another */ |
| 185 | msi_bitmap_free_hwirqs(&bmp, size / 2, 1); | 180 | msi_bitmap_free_hwirqs(&bmp, size / 2, 1); |
| 186 | check(msi_bitmap_alloc_hwirqs(&bmp, 1) == size / 2); | 181 | WARN_ON(msi_bitmap_alloc_hwirqs(&bmp, 1) != size / 2); |
| 187 | 182 | ||
| 188 | /* Free most of them for the alignment tests */ | 183 | /* Free most of them for the alignment tests */ |
| 189 | msi_bitmap_free_hwirqs(&bmp, 3, size - 3); | 184 | msi_bitmap_free_hwirqs(&bmp, 3, size - 3); |
| 190 | 185 | ||
| 191 | /* Check we get a naturally aligned offset */ | 186 | /* Check we get a naturally aligned offset */ |
| 192 | rc = msi_bitmap_alloc_hwirqs(&bmp, 2); | 187 | rc = msi_bitmap_alloc_hwirqs(&bmp, 2); |
| 193 | check(rc >= 0 && rc % 2 == 0); | 188 | WARN_ON(rc < 0 && rc % 2 != 0); |
| 194 | rc = msi_bitmap_alloc_hwirqs(&bmp, 4); | 189 | rc = msi_bitmap_alloc_hwirqs(&bmp, 4); |
| 195 | check(rc >= 0 && rc % 4 == 0); | 190 | WARN_ON(rc < 0 && rc % 4 != 0); |
| 196 | rc = msi_bitmap_alloc_hwirqs(&bmp, 8); | 191 | rc = msi_bitmap_alloc_hwirqs(&bmp, 8); |
| 197 | check(rc >= 0 && rc % 8 == 0); | 192 | WARN_ON(rc < 0 && rc % 8 != 0); |
| 198 | rc = msi_bitmap_alloc_hwirqs(&bmp, 9); | 193 | rc = msi_bitmap_alloc_hwirqs(&bmp, 9); |
| 199 | check(rc >= 0 && rc % 16 == 0); | 194 | WARN_ON(rc < 0 && rc % 16 != 0); |
| 200 | rc = msi_bitmap_alloc_hwirqs(&bmp, 3); | 195 | rc = msi_bitmap_alloc_hwirqs(&bmp, 3); |
| 201 | check(rc >= 0 && rc % 4 == 0); | 196 | WARN_ON(rc < 0 && rc % 4 != 0); |
| 202 | rc = msi_bitmap_alloc_hwirqs(&bmp, 7); | 197 | rc = msi_bitmap_alloc_hwirqs(&bmp, 7); |
| 203 | check(rc >= 0 && rc % 8 == 0); | 198 | WARN_ON(rc < 0 && rc % 8 != 0); |
| 204 | rc = msi_bitmap_alloc_hwirqs(&bmp, 121); | 199 | rc = msi_bitmap_alloc_hwirqs(&bmp, 121); |
| 205 | check(rc >= 0 && rc % 128 == 0); | 200 | WARN_ON(rc < 0 && rc % 128 != 0); |
| 206 | 201 | ||
| 207 | msi_bitmap_free(&bmp); | 202 | msi_bitmap_free(&bmp); |
| 208 | 203 | ||
| 209 | /* Clients may check bitmap == NULL for "not-allocated" */ | 204 | /* Clients may WARN_ON bitmap == NULL for "not-allocated" */ |
| 210 | check(bmp.bitmap == NULL); | 205 | WARN_ON(bmp.bitmap != NULL); |
| 211 | 206 | ||
| 212 | kfree(bmp.bitmap); | 207 | kfree(bmp.bitmap); |
| 213 | } | 208 | } |
| @@ -229,14 +224,13 @@ static void __init test_of_node(void) | |||
| 229 | of_node_init(&of_node); | 224 | of_node_init(&of_node); |
| 230 | of_node.full_name = node_name; | 225 | of_node.full_name = node_name; |
| 231 | 226 | ||
| 232 | check(0 == msi_bitmap_alloc(&bmp, size, &of_node)); | 227 | WARN_ON(msi_bitmap_alloc(&bmp, size, &of_node)); |
| 233 | 228 | ||
| 234 | /* No msi-available-ranges, so expect > 0 */ | 229 | /* No msi-available-ranges, so expect > 0 */ |
| 235 | check(msi_bitmap_reserve_dt_hwirqs(&bmp) > 0); | 230 | WARN_ON(msi_bitmap_reserve_dt_hwirqs(&bmp) <= 0); |
| 236 | 231 | ||
| 237 | /* Should all still be free */ | 232 | /* Should all still be free */ |
| 238 | check(0 == bitmap_find_free_region(bmp.bitmap, size, | 233 | WARN_ON(bitmap_find_free_region(bmp.bitmap, size, get_count_order(size))); |
| 239 | get_count_order(size))); | ||
| 240 | bitmap_release_region(bmp.bitmap, 0, get_count_order(size)); | 234 | bitmap_release_region(bmp.bitmap, 0, get_count_order(size)); |
| 241 | 235 | ||
| 242 | /* Now create a fake msi-available-ranges property */ | 236 | /* Now create a fake msi-available-ranges property */ |
| @@ -250,11 +244,11 @@ static void __init test_of_node(void) | |||
| 250 | of_node.properties = ∝ | 244 | of_node.properties = ∝ |
| 251 | 245 | ||
| 252 | /* msi-available-ranges, so expect == 0 */ | 246 | /* msi-available-ranges, so expect == 0 */ |
| 253 | check(msi_bitmap_reserve_dt_hwirqs(&bmp) == 0); | 247 | WARN_ON(msi_bitmap_reserve_dt_hwirqs(&bmp)); |
| 254 | 248 | ||
| 255 | /* Check we got the expected result */ | 249 | /* Check we got the expected result */ |
| 256 | check(0 == bitmap_parselist(expected_str, expected, size)); | 250 | WARN_ON(bitmap_parselist(expected_str, expected, size)); |
| 257 | check(bitmap_equal(expected, bmp.bitmap, size)); | 251 | WARN_ON(!bitmap_equal(expected, bmp.bitmap, size)); |
| 258 | 252 | ||
| 259 | msi_bitmap_free(&bmp); | 253 | msi_bitmap_free(&bmp); |
| 260 | kfree(bmp.bitmap); | 254 | kfree(bmp.bitmap); |
