Skip to content

Commit 8b9b9de

Browse files
khayash1mehmetb0
authored andcommitted
net: stmmac: Limit FIFO size by hardware capability
BugLink: https://bugs.launchpad.net/bugs/2103829 [ Upstream commit 044f2fbaa2725696ecbf1f02ba7ab0a8ccb7e1ae ] 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]> Signed-off-by: Noah Wager <[email protected]> Signed-off-by: Mehmet Basaran <[email protected]>
1 parent 9eb3a95 commit 8b9b9de

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
@@ -7289,6 +7289,21 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
72897289
priv->plat->tx_queues_to_use = priv->dma_cap.number_tx_queues;
72907290
}
72917291

7292+
if (priv->dma_cap.rx_fifo_size &&
7293+
priv->plat->rx_fifo_size > priv->dma_cap.rx_fifo_size) {
7294+
dev_warn(priv->device,
7295+
"Rx FIFO size (%u) exceeds dma capability\n",
7296+
priv->plat->rx_fifo_size);
7297+
priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size;
7298+
}
7299+
if (priv->dma_cap.tx_fifo_size &&
7300+
priv->plat->tx_fifo_size > priv->dma_cap.tx_fifo_size) {
7301+
dev_warn(priv->device,
7302+
"Tx FIFO size (%u) exceeds dma capability\n",
7303+
priv->plat->tx_fifo_size);
7304+
priv->plat->tx_fifo_size = priv->dma_cap.tx_fifo_size;
7305+
}
7306+
72927307
priv->hw->vlan_fail_q_en =
72937308
(priv->plat->flags & STMMAC_FLAG_VLAN_FAIL_Q_EN);
72947309
priv->hw->vlan_fail_q = priv->plat->vlan_fail_q;

0 commit comments

Comments
 (0)