Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/mthca: create_eq with size not a power of 2

Fix mthca_create_eq for when the EQ size is not a power of 2.

Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by

Michael S. Tsirkin and committed by
Roland Dreier
46620056 38d1e793

+2 -2
+2 -2
drivers/infiniband/hw/mthca/mthca_eq.c
··· 484 484 u8 intr, 485 485 struct mthca_eq *eq) 486 486 { 487 - int npages = (nent * MTHCA_EQ_ENTRY_SIZE + PAGE_SIZE - 1) / 488 - PAGE_SIZE; 487 + int npages; 489 488 u64 *dma_list = NULL; 490 489 dma_addr_t t; 491 490 struct mthca_mailbox *mailbox; ··· 495 496 496 497 eq->dev = dev; 497 498 eq->nent = roundup_pow_of_two(max(nent, 2)); 499 + npages = ALIGN(eq->nent * MTHCA_EQ_ENTRY_SIZE, PAGE_SIZE) / PAGE_SIZE; 498 500 499 501 eq->page_list = kmalloc(npages * sizeof *eq->page_list, 500 502 GFP_KERNEL);