Skip to content

Commit 6d3693d

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 80083bd commit 6d3693d

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
@@ -7118,6 +7118,21 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
71187118
priv->plat->tx_queues_to_use = priv->dma_cap.number_tx_queues;
71197119
}
71207120

7121+
if (priv->dma_cap.rx_fifo_size &&
7122+
priv->plat->rx_fifo_size > priv->dma_cap.rx_fifo_size) {
7123+
dev_warn(priv->device,
7124+
"Rx FIFO size (%u) exceeds dma capability\n",
7125+
priv->plat->rx_fifo_size);
7126+
priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size;
7127+
}
7128+
if (priv->dma_cap.tx_fifo_size &&
7129+
priv->plat->tx_fifo_size > priv->dma_cap.tx_fifo_size) {
7130+
dev_warn(priv->device,
7131+
"Tx FIFO size (%u) exceeds dma capability\n",
7132+
priv->plat->tx_fifo_size);
7133+
priv->plat->tx_fifo_size = priv->dma_cap.tx_fifo_size;
7134+
}
7135+
71217136
priv->hw->vlan_fail_q_en =
71227137
(priv->plat->flags & STMMAC_FLAG_VLAN_FAIL_Q_EN);
71237138
priv->hw->vlan_fail_q = priv->plat->vlan_fail_q;

0 commit comments

Comments
 (0)