IB/ehca: Fix ilog2() compile failure
authorKyle McMartin <kmcmartin@redhat.com>
Mon, 27 Feb 2012 22:02:56 +0000 (17:02 -0500)
committerRoland Dreier <roland@purestorage.com>
Mon, 5 Mar 2012 18:12:35 +0000 (10:12 -0800)
I'm getting compile failures building this driver, which I narrowed
down to the ilog2 call in ehca_get_max_hwpage_size...

    ERROR: ".____ilog2_NaN" [drivers/infiniband/hw/ehca/ib_ehca.ko]
    undefined!
    make[1]: *** [__modpost] Error 1
    make: *** [modules] Error 2

The use of shca->hca_cap_mr_pgsize is confusing the compiler, and
resulting in the __builtin_constant_p in ilog2 going insane.

I tried making it take the u32 pgsize as an argument and the expansion
of shca->_pgsize in the caller, but that failed as well.

With this patch in place, the driver compiles on my GCC 4.6.2 here.

Suggested-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Kyle McMartin <kmcmarti@redhat.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/ehca/ehca_mrmw.c

index 43cae84005f0a5bb7d80b440eb0e34e1e6a2500e..b781b2cb062409a2f97a4a045c2c67b7e6641a71 100644 (file)
@@ -112,7 +112,7 @@ static u32 ehca_encode_hwpage_size(u32 pgsize)
 
 static u64 ehca_get_max_hwpage_size(struct ehca_shca *shca)
 {
-       return 1UL << ilog2(shca->hca_cap_mr_pgsize);
+       return rounddown_pow_of_two(shca->hca_cap_mr_pgsize);
 }
 
 static struct ehca_mr *ehca_mr_new(void)
This page took 0.026454 seconds and 5 git commands to generate.