Skip to contentSkip to conversation

ib_ehca: fix compile failure on ppc64

PATCH In review Kyle McMartin 3 participants 4 messages Feb 27, 2012 – Mar 19, 2012 3 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ib_ehca: fix compile failure on ppc64

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. Adding a temporary variable as below got it building again though (as did replacing the ilog2 with fls(x) - 1.)

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

drivers/infiniband/hw/ehca/ehca_mrmw.c +2 -1
@@ -112,7 +112,8 @@ 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);
+	u32 pgsize = shca->hca_cap_mr_pgsize;
+	return 1UL << ilog2(pgsize);
 }
 
 static struct ehca_mr *ehca_mr_new(void)

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to a message not in the archive
Quoted 6 lines · Kyle McMartin

 static u64 ehca_get_max_hwpage_size(struct ehca_shca *shca) {
-       return 1UL << ilog2(shca->hca_cap_mr_pgsize);
+       u32 pgsize = shca->hca_cap_mr_pgsize;
+       return 1UL << ilog2(pgsize);
 }

How about using rounddown_pow_of_two(shca->hca_cap_mr_pgsize)? Does that build? Because that seems to me to be a cleaner way of expressing this anyway...

Something about that ilog2() implementation seems to trigger gcc bugs, I seem to remember some other bogus compile failure on sparc involving it as well...

- R.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to a message not in the archive
Quoted 8 lines · Roland Dreier
Quoted 6 lines · Kyle McMartin

 static u64 ehca_get_max_hwpage_size(struct ehca_shca *shca) {
-       return 1UL << ilog2(shca->hca_cap_mr_pgsize);
+       u32 pgsize = shca->hca_cap_mr_pgsize;
+       return 1UL << ilog2(pgsize);
 }

Quoted 4 lines

How about using rounddown_pow_of_two(shca->hca_cap_mr_pgsize)? Does that build? Because that seems to me to be a cleaner way of expressing this anyway...

Yeah, that works too, good catch, I should have noticed that sooner.

Quoted 4 lines

Something about that ilog2() implementation seems to trigger gcc bugs, I seem to remember some other bogus compile failure on sparc involving it as well...

I suspect it's the 64 deep trinary operators ;-) (It seems to trip up on the __builtin_constant_p and hit the second ____ilog2_NaN) It's a pretty weird .config dependent bug, I'm very confused by it.

drivers/infiniband/hw/ehca/ehca_mrmw.c +1 -1
@@ -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)

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to a message not in the archive

The patch below looks fine to me.
Sorry for this so late reply.
Thanks!
Nam

Kyle McMartin <[email protected]> wrote on 02/28/2012 04:15:46 PM:

Quoted 23 lines

From:

Kyle McMartin <[email protected]>

To:

Roland Dreier <[email protected]>

Cc:

[email protected], Hoang-Nam Nguyen/Germany/IBM@IBMDE, Christoph Raisch/Germany/IBM@IBMDE

Date:

02/28/2012 04:15 PM

Subject:

Re: [PATCH] ib_ehca: fix compile failure on ppc64

Quoted 1 line · Roland Dreier

On Mon, Feb 27, 2012 at 2:02 PM, Kyle McMartin <[email protected]>

Quoted 30 lines · wrote:
Quoted 11 lines
Quoted 6 lines

 static u64 ehca_get_max_hwpage_size(struct ehca_shca *shca) {
-       return 1UL << ilog2(shca->hca_cap_mr_pgsize);
+       u32 pgsize = shca->hca_cap_mr_pgsize;
+       return 1UL << ilog2(pgsize);
 }

How about using rounddown_pow_of_two(shca->hca_cap_mr_pgsize)? Does that build? Because that seems to me to be a cleaner way of expressing this anyway...

Yeah, that works too, good catch, I should have noticed that sooner.

Quoted 4 lines

Something about that ilog2() implementation seems to trigger gcc bugs, I seem to remember some other bogus compile failure on sparc involving it as well...

I suspect it's the 64 deep trinary operators ;-) (It seems to trip up on the __builtin_constant_p and hit the second ____ilog2_NaN) It's a pretty weird .config dependent bug, I'm very confused by it.

drivers/infiniband/hw/ehca/ehca_mrmw.c static u32 ehca_encode_hwpage_size(u32 pgsize) · line 118

Quoted 8 lines
drivers/infiniband/hw/ehca/ehca_mrmw.c +1 -1
@@ -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)

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html