Commit 740a3e71 authored by Paolo Abeni's avatar Paolo Abeni
Browse files

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/20250127013820.2941044-1-hayashi.kunihiko@socionext.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 4f5a52ad 8865d226
Loading
Loading
Loading
Loading
+44 −13
Original line number Diff line number Diff line
@@ -2424,11 +2424,6 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
	u32 chan = 0;
	u8 qmode = 0;

	if (rxfifosz == 0)
		rxfifosz = priv->dma_cap.rx_fifo_size;
	if (txfifosz == 0)
		txfifosz = priv->dma_cap.tx_fifo_size;

	/* Split up the shared Tx/Rx FIFO memory on DW QoS Eth and DW XGMAC */
	if (priv->plat->has_gmac4 || priv->plat->has_xgmac) {
		rxfifosz /= rx_channels_count;
@@ -2897,11 +2892,6 @@ static void stmmac_set_dma_operation_mode(struct stmmac_priv *priv, u32 txmode,
	int rxfifosz = priv->plat->rx_fifo_size;
	int txfifosz = priv->plat->tx_fifo_size;

	if (rxfifosz == 0)
		rxfifosz = priv->dma_cap.rx_fifo_size;
	if (txfifosz == 0)
		txfifosz = priv->dma_cap.tx_fifo_size;

	/* Adjust for real per queue fifo size */
	rxfifosz /= rx_channels_count;
	txfifosz /= tx_channels_count;
@@ -5878,9 +5868,6 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
	const int mtu = new_mtu;
	int ret;

	if (txfifosz == 0)
		txfifosz = priv->dma_cap.tx_fifo_size;

	txfifosz /= priv->plat->tx_queues_to_use;

	if (stmmac_xdp_is_enabled(priv) && new_mtu > ETH_DATA_LEN) {
@@ -7221,6 +7208,50 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
	if (priv->dma_cap.tsoen)
		dev_info(priv->device, "TSO supported\n");

	if (priv->dma_cap.number_rx_queues &&
	    priv->plat->rx_queues_to_use > priv->dma_cap.number_rx_queues) {
		dev_warn(priv->device,
			 "Number of Rx queues (%u) exceeds dma capability\n",
			 priv->plat->rx_queues_to_use);
		priv->plat->rx_queues_to_use = priv->dma_cap.number_rx_queues;
	}
	if (priv->dma_cap.number_tx_queues &&
	    priv->plat->tx_queues_to_use > priv->dma_cap.number_tx_queues) {
		dev_warn(priv->device,
			 "Number of Tx queues (%u) exceeds dma capability\n",
			 priv->plat->tx_queues_to_use);
		priv->plat->tx_queues_to_use = priv->dma_cap.number_tx_queues;
	}

	if (!priv->plat->rx_fifo_size) {
		if (priv->dma_cap.rx_fifo_size) {
			priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size;
		} else {
			dev_err(priv->device, "Can't specify Rx FIFO size\n");
			return -ENODEV;
		}
	} else if (priv->dma_cap.rx_fifo_size &&
		   priv->plat->rx_fifo_size > priv->dma_cap.rx_fifo_size) {
		dev_warn(priv->device,
			 "Rx FIFO size (%u) exceeds dma capability\n",
			 priv->plat->rx_fifo_size);
		priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size;
	}
	if (!priv->plat->tx_fifo_size) {
		if (priv->dma_cap.tx_fifo_size) {
			priv->plat->tx_fifo_size = priv->dma_cap.tx_fifo_size;
		} else {
			dev_err(priv->device, "Can't specify Tx FIFO size\n");
			return -ENODEV;
		}
	} else if (priv->dma_cap.tx_fifo_size &&
		   priv->plat->tx_fifo_size > priv->dma_cap.tx_fifo_size) {
		dev_warn(priv->device,
			 "Tx FIFO size (%u) exceeds dma capability\n",
			 priv->plat->tx_fifo_size);
		priv->plat->tx_fifo_size = priv->dma_cap.tx_fifo_size;
	}

	priv->hw->vlan_fail_q_en =
		(priv->plat->flags & STMMAC_FLAG_VLAN_FAIL_Q_EN);
	priv->hw->vlan_fail_q = priv->plat->vlan_fail_q;