linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] be2net: fix adapter->big_page_size miscaculation
@ 2019-07-12 19:23 Qian Cai
  2019-07-12 22:46 ` David Miller
  2019-07-19 10:32 ` kbuild test robot
  0 siblings, 2 replies; 16+ messages in thread
From: Qian Cai @ 2019-07-12 19:23 UTC (permalink / raw)
  To: davem
  Cc: sathya.perla, ajit.khaparde, sriharsha.basavapatna,
	somnath.kotur, arnd, dhowells, hpa, netdev, linux-arch,
	linux-kernel, Qian Cai

The commit d66acc39c7ce ("bitops: Optimise get_order()") introduced a
problem for the be2net driver as "rx_frag_size" could be a module
parameter that can be changed while loading the module. That commit
checks __builtin_constant_p() first in get_order() which cause
"adapter->big_page_size" to be assigned a value based on the
the default "rx_frag_size" value at the compilation time. It also
generate a compilation warning,

In file included from ./arch/powerpc/include/asm/page_64.h:107,
                 from ./arch/powerpc/include/asm/page.h:242,
                 from ./arch/powerpc/include/asm/mmu.h:132,
                 from ./arch/powerpc/include/asm/lppaca.h:47,
                 from ./arch/powerpc/include/asm/paca.h:17,
                 from ./arch/powerpc/include/asm/current.h:13,
                 from ./include/linux/thread_info.h:21,
                 from ./arch/powerpc/include/asm/processor.h:39,
                 from ./include/linux/prefetch.h:15,
                 from drivers/net/ethernet/emulex/benet/be_main.c:14:
drivers/net/ethernet/emulex/benet/be_main.c: In function
'be_rx_cqs_create':
./include/asm-generic/getorder.h:54:9: warning: comparison is always
true due to limited range of data type [-Wtype-limits]
   (((n) < (1UL << PAGE_SHIFT)) ? 0 :  \
         ^
drivers/net/ethernet/emulex/benet/be_main.c:3138:33: note: in expansion
of macro 'get_order'
  adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE;
                                 ^~~~~~~~~

Fix it by using __get_order() instead which will calculate in runtime.

Fixes: d66acc39c7ce ("bitops: Optimise get_order()")
Signed-off-by: Qian Cai <cai@lca.pw>
---
 drivers/net/ethernet/emulex/benet/be_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 82015c8a5ed7..db13e714df7c 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -3135,7 +3135,7 @@ static int be_rx_cqs_create(struct be_adapter *adapter)
 	if (adapter->num_rx_qs == 0)
 		adapter->num_rx_qs = 1;
 
-	adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE;
+	adapter->big_page_size = (1 << __get_order(rx_frag_size)) * PAGE_SIZE;
 	for_all_rx_queues(adapter, rxo, i) {
 		rxo->adapter = adapter;
 		cq = &rxo->cq;
-- 
1.8.3.1


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

end of thread, other threads:[~2019-07-23  3:08 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-12 19:23 [PATCH] be2net: fix adapter->big_page_size miscaculation Qian Cai
2019-07-12 22:46 ` David Miller
2019-07-13  0:27   ` Qian Cai
2019-07-13  0:50     ` David Miller
2019-07-18 21:01       ` Qian Cai
2019-07-18 21:10         ` Nick Desaulniers
2019-07-18 21:21           ` Bill Wendling
2019-07-18 23:26             ` Qian Cai
2019-07-18 23:29               ` David Miller
2019-07-19 21:47                 ` Qian Cai
2019-07-22 21:13                   ` Qian Cai
2019-07-22 22:58                     ` James Y Knight
2019-07-23  3:08                       ` Qian Cai
     [not found]           ` <CAGG=3QWkgm+YhC=TWEWwt585Lbm8ZPG-uFre-kBRv+roPzZFbA@mail.gmail.com>
2019-07-18 21:22             ` Nick Desaulniers
2019-07-18 21:28               ` Bill Wendling
2019-07-19 10:32 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).