The default RX queues contain 512 descriptors per port. The shared software free queue is sized at twice their combined capacity, requiring 4 MiB of page fragments even on Gemini systems with only 32 or 64 MiB of RAM. Choose smaller default RX queues on memory-constrained systems. Use 256 descriptors per port and a 2 MiB free queue with at most 64 MiB of RAM, and 128 descriptors per port with a 1 MiB free queue with at most 32 MiB. Keep the existing defaults on systems with more memory. This preserves the existing relationship between RX descriptor capacity and the free queue. Users can still override the defaults with ethtool. Assisted-by: LLM Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 6d5f7dacf12a..a14209ec2fe6 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -472,6 +474,17 @@ static int gmac_pick_rx_max_len(unsigned int max_l3_len) return -1; } +static unsigned int gmac_pick_rxq_order(void) +{ + if (totalram_pages() <= (SZ_32M >> PAGE_SHIFT)) + return DEFAULT_GMAC_RXQ_ORDER - 2; + + if (totalram_pages() <= (SZ_64M >> PAGE_SHIFT)) + return DEFAULT_GMAC_RXQ_ORDER - 1; + + return DEFAULT_GMAC_RXQ_ORDER; +} + static int gmac_init(struct net_device *netdev) { struct gemini_ethernet_port *port = netdev_priv(netdev); @@ -540,7 +553,7 @@ static int gmac_init(struct net_device *netdev) writel(sw_weigh.bits32, port->dma_base + GMAC_TX_WEIGHTING_CTRL_1_REG); - port->rxq_order = DEFAULT_GMAC_RXQ_ORDER; + port->rxq_order = gmac_pick_rxq_order(); port->txq_order = DEFAULT_GMAC_TXQ_ORDER; port->rx_coalesce_nsecs = DEFAULT_RX_COALESCE_NSECS; -- 2.55.0