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

net: stmmac: Fix page pool size

The size of individual pages in the page pool in given by an order. The
order is the binary logarithm of the number of pages that make up one of
the pages in the pool. However, the driver currently passes the number
of pages rather than the order, so it ends up wasting quite a bit of
memory.

Fix this by taking the binary logarithm and passing that in the order
field.

Fixes: 2af6106ae949 ("net: stmmac: Introducing support for Page Pool")
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Thierry Reding and committed by
David S. Miller
4f28bd95 ba56d8ce

+3 -1
+3 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 1557 1557 for (queue = 0; queue < rx_count; queue++) { 1558 1558 struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; 1559 1559 struct page_pool_params pp_params = { 0 }; 1560 + unsigned int num_pages; 1560 1561 1561 1562 rx_q->queue_index = queue; 1562 1563 rx_q->priv_data = priv; 1563 1564 1564 1565 pp_params.flags = PP_FLAG_DMA_MAP; 1565 1566 pp_params.pool_size = DMA_RX_SIZE; 1566 - pp_params.order = DIV_ROUND_UP(priv->dma_buf_sz, PAGE_SIZE); 1567 + num_pages = DIV_ROUND_UP(priv->dma_buf_sz, PAGE_SIZE); 1568 + pp_params.order = ilog2(num_pages); 1567 1569 pp_params.nid = dev_to_node(priv->device); 1568 1570 pp_params.dev = priv->device; 1569 1571 pp_params.dma_dir = DMA_FROM_DEVICE;