Skip to content

Commit ed56a6c

Browse files
khayash1opsiff
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]> (cherry picked from commit dff69e422d26ce291049403175f54b3454385bf6)
1 parent 870ba7c commit ed56a6c

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
@@ -7135,6 +7135,21 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
71357135
priv->plat->tx_queues_to_use = priv->dma_cap.number_tx_queues;
71367136
}
71377137

7138+
if (priv->dma_cap.rx_fifo_size &&
7139+
priv->plat->rx_fifo_size > priv->dma_cap.rx_fifo_size) {
7140+
dev_warn(priv->device,
7141+
"Rx FIFO size (%u) exceeds dma capability\n",
7142+
priv->plat->rx_fifo_size);
7143+
priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size;
7144+
}
7145+
if (priv->dma_cap.tx_fifo_size &&
7146+
priv->plat->tx_fifo_size > priv->dma_cap.tx_fifo_size) {
7147+
dev_warn(priv->device,
7148+
"Tx FIFO size (%u) exceeds dma capability\n",
7149+
priv->plat->tx_fifo_size);
7150+
priv->plat->tx_fifo_size = priv->dma_cap.tx_fifo_size;
7151+
}
7152+
71387153
priv->hw->vlan_fail_q_en =
71397154
(priv->plat->flags & STMMAC_FLAG_VLAN_FAIL_Q_EN);
71407155
priv->hw->vlan_fail_q = priv->plat->vlan_fail_q;

0 commit comments

Comments
 (0)