Skip to content

Commit 2a64c96

Browse files
Russell King (Oracle)Paolo Abeni
authored andcommitted
Revert "net: stmmac: Specify hardware capability value when FIFO size isn't specified"
This reverts commit 8865d22, which caused breakage for platforms which are not using xgmac2 or gmac4. Only these two cores have the capability of providing the FIFO sizes from hardware capability fields (which are provided in priv->dma_cap.[tr]x_fifo_size.) All other cores can not, which results in these two fields containing zero. We also have platforms that do not provide a value in priv->plat->[tr]x_fifo_size, resulting in these also being zero. This causes the new tests introduced by the reverted commit to fail, and produce e.g.: stmmaceth f0804000.eth: Can't specify Rx FIFO size An example of such a platform which fails is QEMU's npcm750-evb. This uses dwmac1000 which, as noted above, does not have the capability to provide the FIFO sizes from hardware. Therefore, revert the commit to maintain compatibility with the way the driver used to work. Reported-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/4e98f967-f636-46fb-9eca-d383b9495b86@roeck-us.net Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Tested-by: Steven Price <steven.price@arm.com> Fixes: 8865d22 ("net: stmmac: Specify hardware capability value when FIFO size isn't specified") Link: https://patch.msgid.link/E1tfeyR-003YGJ-Gb@rmk-PC.armlinux.org.uk Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 82b02a7 commit 2a64c96

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

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

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,6 +2424,11 @@ 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+
24272432
/* Split up the shared Tx/Rx FIFO memory on DW QoS Eth and DW XGMAC */
24282433
if (priv->plat->has_gmac4 || priv->plat->has_xgmac) {
24292434
rxfifosz /= rx_channels_count;
@@ -2892,6 +2897,11 @@ static void stmmac_set_dma_operation_mode(struct stmmac_priv *priv, u32 txmode,
28922897
int rxfifosz = priv->plat->rx_fifo_size;
28932898
int txfifosz = priv->plat->tx_fifo_size;
28942899

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+
28952905
/* Adjust for real per queue fifo size */
28962906
rxfifosz /= rx_channels_count;
28972907
txfifosz /= tx_channels_count;
@@ -5868,6 +5878,9 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
58685878
const int mtu = new_mtu;
58695879
int ret;
58705880

5881+
if (txfifosz == 0)
5882+
txfifosz = priv->dma_cap.tx_fifo_size;
5883+
58715884
txfifosz /= priv->plat->tx_queues_to_use;
58725885

58735886
if (stmmac_xdp_is_enabled(priv) && new_mtu > ETH_DATA_LEN) {
@@ -7219,29 +7232,15 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
72197232
priv->plat->tx_queues_to_use = priv->dma_cap.number_tx_queues;
72207233
}
72217234

7222-
if (!priv->plat->rx_fifo_size) {
7223-
if (priv->dma_cap.rx_fifo_size) {
7224-
priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size;
7225-
} else {
7226-
dev_err(priv->device, "Can't specify Rx FIFO size\n");
7227-
return -ENODEV;
7228-
}
7229-
} else if (priv->dma_cap.rx_fifo_size &&
7230-
priv->plat->rx_fifo_size > priv->dma_cap.rx_fifo_size) {
7235+
if (priv->dma_cap.rx_fifo_size &&
7236+
priv->plat->rx_fifo_size > priv->dma_cap.rx_fifo_size) {
72317237
dev_warn(priv->device,
72327238
"Rx FIFO size (%u) exceeds dma capability\n",
72337239
priv->plat->rx_fifo_size);
72347240
priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size;
72357241
}
7236-
if (!priv->plat->tx_fifo_size) {
7237-
if (priv->dma_cap.tx_fifo_size) {
7238-
priv->plat->tx_fifo_size = priv->dma_cap.tx_fifo_size;
7239-
} else {
7240-
dev_err(priv->device, "Can't specify Tx FIFO size\n");
7241-
return -ENODEV;
7242-
}
7243-
} else if (priv->dma_cap.tx_fifo_size &&
7244-
priv->plat->tx_fifo_size > priv->dma_cap.tx_fifo_size) {
7242+
if (priv->dma_cap.tx_fifo_size &&
7243+
priv->plat->tx_fifo_size > priv->dma_cap.tx_fifo_size) {
72457244
dev_warn(priv->device,
72467245
"Tx FIFO size (%u) exceeds dma capability\n",
72477246
priv->plat->tx_fifo_size);

0 commit comments

Comments
 (0)