Skip to content

Commit 8865d22

Browse files
khayash1Paolo Abeni
authored andcommitted
net: stmmac: Specify hardware capability value when FIFO size isn't specified
When Tx/Rx FIFO size is not specified in advance, the driver checks if the value is zero and sets the hardware capability value in functions where that value is used. Consolidate the check and settings into function stmmac_hw_init() and remove redundant other statements. If FIFO size is zero and the hardware capability also doesn't have upper limit values, return with an error message. Signed-off-by: Kunihiko Hayashi <[email protected]> Reviewed-by: Yanteng Si <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 044f2fb commit 8865d22

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,11 +2424,6 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
24242424
u32 chan = 0;
24252425
u8 qmode = 0;
24262426

2427-
if (rxfifosz == 0)
2428-
rxfifosz = priv->dma_cap.rx_fifo_size;
2429-
if (txfifosz == 0)
2430-
txfifosz = priv->dma_cap.tx_fifo_size;
2431-
24322427
/* Split up the shared Tx/Rx FIFO memory on DW QoS Eth and DW XGMAC */
24332428
if (priv->plat->has_gmac4 || priv->plat->has_xgmac) {
24342429
rxfifosz /= rx_channels_count;
@@ -2897,11 +2892,6 @@ static void stmmac_set_dma_operation_mode(struct stmmac_priv *priv, u32 txmode,
28972892
int rxfifosz = priv->plat->rx_fifo_size;
28982893
int txfifosz = priv->plat->tx_fifo_size;
28992894

2900-
if (rxfifosz == 0)
2901-
rxfifosz = priv->dma_cap.rx_fifo_size;
2902-
if (txfifosz == 0)
2903-
txfifosz = priv->dma_cap.tx_fifo_size;
2904-
29052895
/* Adjust for real per queue fifo size */
29062896
rxfifosz /= rx_channels_count;
29072897
txfifosz /= tx_channels_count;
@@ -5878,9 +5868,6 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
58785868
const int mtu = new_mtu;
58795869
int ret;
58805870

5881-
if (txfifosz == 0)
5882-
txfifosz = priv->dma_cap.tx_fifo_size;
5883-
58845871
txfifosz /= priv->plat->tx_queues_to_use;
58855872

58865873
if (stmmac_xdp_is_enabled(priv) && new_mtu > ETH_DATA_LEN) {
@@ -7236,15 +7223,29 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
72367223
priv->plat->tx_queues_to_use = priv->dma_cap.number_tx_queues;
72377224
}
72387225

7239-
if (priv->dma_cap.rx_fifo_size &&
7240-
priv->plat->rx_fifo_size > priv->dma_cap.rx_fifo_size) {
7226+
if (!priv->plat->rx_fifo_size) {
7227+
if (priv->dma_cap.rx_fifo_size) {
7228+
priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size;
7229+
} else {
7230+
dev_err(priv->device, "Can't specify Rx FIFO size\n");
7231+
return -ENODEV;
7232+
}
7233+
} else if (priv->dma_cap.rx_fifo_size &&
7234+
priv->plat->rx_fifo_size > priv->dma_cap.rx_fifo_size) {
72417235
dev_warn(priv->device,
72427236
"Rx FIFO size (%u) exceeds dma capability\n",
72437237
priv->plat->rx_fifo_size);
72447238
priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size;
72457239
}
7246-
if (priv->dma_cap.tx_fifo_size &&
7247-
priv->plat->tx_fifo_size > priv->dma_cap.tx_fifo_size) {
7240+
if (!priv->plat->tx_fifo_size) {
7241+
if (priv->dma_cap.tx_fifo_size) {
7242+
priv->plat->tx_fifo_size = priv->dma_cap.tx_fifo_size;
7243+
} else {
7244+
dev_err(priv->device, "Can't specify Tx FIFO size\n");
7245+
return -ENODEV;
7246+
}
7247+
} else if (priv->dma_cap.tx_fifo_size &&
7248+
priv->plat->tx_fifo_size > priv->dma_cap.tx_fifo_size) {
72487249
dev_warn(priv->device,
72497250
"Tx FIFO size (%u) exceeds dma capability\n",
72507251
priv->plat->tx_fifo_size);

0 commit comments

Comments
 (0)