]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net: ethernet: aquantia: Fixed memory allocation if AQ_CFG_RX_FRAME_MAX > 1 page.
authorPavel Belous <pavel.belous@aquantia.com>
Mon, 20 Feb 2017 19:36:49 +0000 (22:36 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 20 Feb 2017 22:11:09 +0000 (17:11 -0500)
We should allocate the number of pages based on the config parameter
AQ_CFG_RX_FRAME_MAX.

Signed-off-by: Pavel Belous <pavel.belous@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/aquantia/atlantic/aq_ring.c

index 22bb75eff27477a155692b9b812a9e01f293638d..51f4e7f5e1320a654d3aa92322fe991c7eb1537c 100644 (file)
@@ -270,6 +270,8 @@ err_exit:
 
 int aq_ring_rx_fill(struct aq_ring_s *self)
 {
+       unsigned int pages_order = fls(AQ_CFG_RX_FRAME_MAX / PAGE_SIZE +
+               (AQ_CFG_RX_FRAME_MAX % PAGE_SIZE ? 1 : 0)) - 1;
        struct aq_ring_buff_s *buff = NULL;
        int err = 0;
        int i = 0;
@@ -282,7 +284,7 @@ int aq_ring_rx_fill(struct aq_ring_s *self)
                buff->len = AQ_CFG_RX_FRAME_MAX;
 
                buff->page = alloc_pages(GFP_ATOMIC | __GFP_COLD |
-                                        __GFP_COMP, 0);
+                                        __GFP_COMP, pages_order);
                if (!buff->page) {
                        err = -ENOMEM;
                        goto err_exit;