All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ib_ehca: fix compile failure on ppc64
@ 2012-02-27 22:02 Kyle McMartin
       [not found] ` <20120227220255.GE29211-nxOev/eQj6CGu0OVIAPS5KfLeoKvNuZc@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Kyle McMartin @ 2012-02-27 22:02 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: hnguyen-tA70FqPdS9bQT0dZR+AlfA, raisch-tA70FqPdS9bQT0dZR+AlfA

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.

Signed-off-by: Kyle McMartin <kmcmarti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ib_ehca: fix compile failure on ppc64
       [not found] ` <20120227220255.GE29211-nxOev/eQj6CGu0OVIAPS5KfLeoKvNuZc@public.gmane.org>
@ 2012-02-28  5:18   ` Roland Dreier
       [not found]     ` <CAL1RGDXjF-Y-UABiondu6y9k9HRoxgE9oVAbp-BJ4x+iuRjiWg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Dreier @ 2012-02-28  5:18 UTC (permalink / raw)
  To: Kyle McMartin
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	hnguyen-tA70FqPdS9bQT0dZR+AlfA, raisch-tA70FqPdS9bQT0dZR+AlfA

On Mon, Feb 27, 2012 at 2:02 PM, Kyle McMartin <kmcmartin-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
>  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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ib_ehca: fix compile failure on ppc64
       [not found]     ` <CAL1RGDXjF-Y-UABiondu6y9k9HRoxgE9oVAbp-BJ4x+iuRjiWg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2012-02-28 15:15       ` Kyle McMartin
       [not found]         ` <20120228151545.GF29211-nxOev/eQj6CGu0OVIAPS5KfLeoKvNuZc@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Kyle McMartin @ 2012-02-28 15:15 UTC (permalink / raw)
  To: Roland Dreier
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	hnguyen-tA70FqPdS9bQT0dZR+AlfA, raisch-tA70FqPdS9bQT0dZR+AlfA

On Mon, Feb 27, 2012 at 09:18:35PM -0800, Roland Dreier wrote:
> On Mon, Feb 27, 2012 at 2:02 PM, Kyle McMartin <kmcmartin-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> >  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.

> 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.

Suggested-by: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
Signed-off-by: Kyle McMartin <kmcmarti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ib_ehca: fix compile failure on ppc64
       [not found]         ` <20120228151545.GF29211-nxOev/eQj6CGu0OVIAPS5KfLeoKvNuZc@public.gmane.org>
@ 2012-03-19 10:05           ` Hoang-Nam Nguyen
  0 siblings, 0 replies; 4+ messages in thread
From: Hoang-Nam Nguyen @ 2012-03-19 10:05 UTC (permalink / raw)
  To: Kyle McMartin, Roland Dreier
  Cc: Christoph Raisch, linux-rdma-u79uwXL29TY76Z2rM5mHXA

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

Kyle McMartin <kmcmartin-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote on 02/28/2012 04:15:46 PM:

> From:
>
> Kyle McMartin <kmcmartin-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>
> To:
>
> Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
>
> Cc:
>
> linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, 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
>
> On Mon, Feb 27, 2012 at 09:18:35PM -0800, Roland Dreier wrote:
> > On Mon, Feb 27, 2012 at 2:02 PM, Kyle McMartin <kmcmartin-H+wXaHxf7aJhl2p70BpVqQ@public.gmane.orgm>
wrote:
> > >  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.
>
> > 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.
>
> Suggested-by: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
> Signed-off-by: Kyle McMartin <kmcmarti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>
> --- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
> +++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
> @@ -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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-03-19 10:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-27 22:02 [PATCH] ib_ehca: fix compile failure on ppc64 Kyle McMartin
     [not found] ` <20120227220255.GE29211-nxOev/eQj6CGu0OVIAPS5KfLeoKvNuZc@public.gmane.org>
2012-02-28  5:18   ` Roland Dreier
     [not found]     ` <CAL1RGDXjF-Y-UABiondu6y9k9HRoxgE9oVAbp-BJ4x+iuRjiWg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-28 15:15       ` Kyle McMartin
     [not found]         ` <20120228151545.GF29211-nxOev/eQj6CGu0OVIAPS5KfLeoKvNuZc@public.gmane.org>
2012-03-19 10:05           ` Hoang-Nam Nguyen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.