Skip to content

Commit 740a3e7

Browse files
author
Paolo Abeni
committed
Merge branch 'limit-devicetree-parameters-to-hardware-capability'
Kunihiko Hayashi says: ==================== Limit devicetree parameters to hardware capability This series includes patches that checks the devicetree properties, the number of MTL queues and FIFO size values, and if these specified values exceed the value contained in hardware capabilities, limit to the values from the capabilities. Do nothing if the capabilities don't have any specified values. And this sets hardware capability values if FIFO sizes are not specified and removes redundant lines. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 4f5a52a + 8865d22 commit 740a3e7

File tree

1 file changed

+44
-13
lines changed

1 file changed

+44
-13
lines changed

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

Lines changed: 44 additions & 13 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) {
@@ -7221,6 +7208,50 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
72217208
if (priv->dma_cap.tsoen)
72227209
dev_info(priv->device, "TSO supported\n");
72237210

7211+
if (priv->dma_cap.number_rx_queues &&
7212+
priv->plat->rx_queues_to_use > priv->dma_cap.number_rx_queues) {
7213+
dev_warn(priv->device,
7214+
"Number of Rx queues (%u) exceeds dma capability\n",
7215+
priv->plat->rx_queues_to_use);
7216+
priv->plat->rx_queues_to_use = priv->dma_cap.number_rx_queues;
7217+
}
7218+
if (priv->dma_cap.number_tx_queues &&
7219+
priv->plat->tx_queues_to_use > priv->dma_cap.number_tx_queues) {
7220+
dev_warn(priv->device,
7221+
"Number of Tx queues (%u) exceeds dma capability\n",
7222+
priv->plat->tx_queues_to_use);
7223+
priv->plat->tx_queues_to_use = priv->dma_cap.number_tx_queues;
7224+
}
7225+
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) {
7235+
dev_warn(priv->device,
7236+
"Rx FIFO size (%u) exceeds dma capability\n",
7237+
priv->plat->rx_fifo_size);
7238+
priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size;
7239+
}
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) {
7249+
dev_warn(priv->device,
7250+
"Tx FIFO size (%u) exceeds dma capability\n",
7251+
priv->plat->tx_fifo_size);
7252+
priv->plat->tx_fifo_size = priv->dma_cap.tx_fifo_size;
7253+
}
7254+
72247255
priv->hw->vlan_fail_q_en =
72257256
(priv->plat->flags & STMMAC_FLAG_VLAN_FAIL_Q_EN);
72267257
priv->hw->vlan_fail_q = priv->plat->vlan_fail_q;

0 commit comments

Comments
 (0)