Skip to content

Commit aa87db3

Browse files
khayash1gregkh
authored andcommitted
net: stmmac: Limit FIFO size by hardware capability
[ Upstream commit 044f2fb ] Tx/Rx FIFO size is specified by the parameter "{tx,rx}-fifo-depth" from stmmac_platform layer. However, these values are constrained by upper limits determined by the capabilities of each hardware feature. There is a risk that the upper bits will be truncated due to the calculation, so it's appropriate to limit them to the upper limit values and display a warning message. This only works if the hardware capability has the upper limit values. Fixes: e7877f5 ("stmmac: Read tx-fifo-depth and rx-fifo-depth from the devicetree") Signed-off-by: Kunihiko Hayashi <[email protected]> Reviewed-by: Yanteng Si <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 13c61cf commit aa87db3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7190,6 +7190,21 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
71907190
priv->plat->tx_queues_to_use = priv->dma_cap.number_tx_queues;
71917191
}
71927192

7193+
if (priv->dma_cap.rx_fifo_size &&
7194+
priv->plat->rx_fifo_size > priv->dma_cap.rx_fifo_size) {
7195+
dev_warn(priv->device,
7196+
"Rx FIFO size (%u) exceeds dma capability\n",
7197+
priv->plat->rx_fifo_size);
7198+
priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size;
7199+
}
7200+
if (priv->dma_cap.tx_fifo_size &&
7201+
priv->plat->tx_fifo_size > priv->dma_cap.tx_fifo_size) {
7202+
dev_warn(priv->device,
7203+
"Tx FIFO size (%u) exceeds dma capability\n",
7204+
priv->plat->tx_fifo_size);
7205+
priv->plat->tx_fifo_size = priv->dma_cap.tx_fifo_size;
7206+
}
7207+
71937208
priv->hw->vlan_fail_q_en =
71947209
(priv->plat->flags & STMMAC_FLAG_VLAN_FAIL_Q_EN);
71957210
priv->hw->vlan_fail_q = priv->plat->vlan_fail_q;

0 commit comments

Comments
 (0)