From b4ffd6bfee53bb04e8e3578dce61959a079db43f Mon Sep 17 00:00:00 2001 From: David Wu Date: Thu, 7 Apr 2022 10:41:56 +0800 Subject: [PATCH] ethernet: stmmac: Add dma size option property Sometimes, no need to use more DMA buffer, add a configurable option from DTB. Signed-off-by: David Wu Change-Id: I81883c1a3531b8805d554a34e07dc50735829ecc --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +++++-- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 ++ include/linux/stmmac.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index b79ab5fc66a8..f69786d2d1f9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2835,9 +2835,12 @@ static int stmmac_open(struct net_device *dev) priv->rx_copybreak = STMMAC_RX_COPYBREAK; if (!priv->dma_tx_size) - priv->dma_tx_size = DMA_DEFAULT_TX_SIZE; + priv->dma_tx_size = priv->plat->dma_size ? priv->plat->dma_size : + DMA_DEFAULT_TX_SIZE; + if (!priv->dma_rx_size) - priv->dma_rx_size = DMA_DEFAULT_RX_SIZE; + priv->dma_rx_size = priv->plat->dma_size ? priv->plat->dma_size : + DMA_DEFAULT_RX_SIZE; /* Earlier check for TBS */ for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++) { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index ab6fa4169c19..40e68f9ed444 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -462,6 +462,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) of_property_read_u32(np, "rx-fifo-depth", &plat->rx_fifo_size); + of_property_read_u32(np, "dma-size", &plat->dma_size); + plat->force_sf_dma_mode = of_property_read_bool(np, "snps,force_sf_dma_mode"); diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 1f4a7c840f02..787f4f1ff88b 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -172,6 +172,7 @@ struct plat_stmmacenet_data { int unicast_filter_entries; int tx_fifo_size; int rx_fifo_size; + int dma_size; u32 addr64; u32 rx_queues_to_use; u32 tx_queues_to_use;