From: Frank.Li at freescale.com <hidden> Date: 2014-09-15 17:12:54
From: Frank Li <redacted>
check tx and rx queue seperately.
fix typo, "Invalidate" and "fail".
change pr_err to pr_warn.
Signed-off-by: Frank Li <redacted>
---
drivers/net/ethernet/freescale/fec_main.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
@@ -2890,22 +2890,22 @@ fec_enet_get_queue_num(struct platform_device *pdev, int *num_tx, int *num_rx)/* parse the num of tx and rx queues */err=of_property_read_u32(np,"fsl,num-tx-queues",num_tx);-err|=of_property_read_u32(np,"fsl,num-rx-queues",num_rx);-if(err){+if(err)*num_tx=1;++err=of_property_read_u32(np,"fsl,num-rx-queues",num_rx);+if(err)*num_rx=1;-return;-}if(*num_tx<1||*num_tx>FEC_ENET_MAX_TX_QS){-dev_err(&pdev->dev,"Invalidate num_tx(=%d), fail back to 1\n",+dev_warn(&pdev->dev,"Invalid num_tx(=%d), fall back to 1\n",*num_tx);*num_tx=1;return;}if(*num_rx<1||*num_rx>FEC_ENET_MAX_RX_QS){-dev_err(&pdev->dev,"Invalidate num_rx(=%d), fail back to 1\n",+dev_warn(&pdev->dev,"Invalid num_rx(=%d), fall back to 1\n",*num_rx);*num_rx=1;return;
@@ -1095,6 +1096,10 @@ fec_restart(struct net_device *ndev)/* Enable interrupts we wish to service */writel(FEC_DEFAULT_IMASK,fep->hwp+FEC_IMASK);++/* Init the interrupt coalescing */+fec_enet_itr_coal_init(ndev);+}staticvoid
@@ -2234,12 +2239,118 @@ static int fec_enet_nway_reset(struct net_device *dev)returngenphy_restart_aneg(phydev);}+/*+*ITRclocksourceisenetsystemclock(clk_ahb).+*TCTTunitiscycle_ns*64cycle+*So,theICTTvalue=Xus/(cycle_ns*64)+*/+staticintfec_enet_us_to_itr_clock(structnet_device*ndev,intus)+{+structfec_enet_private*fep=netdev_priv(ndev);++returnus*(clk_get_rate(fep->clk_ahb)/64000)/1000;+}++/* Set threshold for interrupt coalescing */+staticvoidfec_enet_itr_coal_set(structnet_device*ndev)+{+structfec_enet_private*fep=netdev_priv(ndev);+conststructplatform_device_id*id_entry=+platform_get_device_id(fep->pdev);+intrx_itr,tx_itr;++if(!(id_entry->driver_data&FEC_QUIRK_HAS_AVB))+return;++/* Must be greater than zero to avoid unpredictable behavior */+if(!fep->rx_time_itr||!fep->rx_pkts_itr||+!fep->tx_time_itr||!fep->tx_pkts_itr)+return;+/*+*SelectenetsystemclockasInterruptCoalescing+*timerClockSource+*/+rx_itr=FEC_ITR_CLK_SEL;+tx_itr=FEC_ITR_CLK_SEL;++/* set ICFT and ICTT */+rx_itr|=FEC_ITR_ICFT(fep->rx_pkts_itr);+rx_itr|=FEC_ITR_ICTT(fec_enet_us_to_itr_clock(ndev,fep->rx_time_itr));+tx_itr|=FEC_ITR_ICFT(fep->tx_pkts_itr);+tx_itr|=FEC_ITR_ICTT(fec_enet_us_to_itr_clock(ndev,fep->tx_time_itr));++rx_itr|=FEC_ITR_EN;+tx_itr|=FEC_ITR_EN;++writel(tx_itr,fep->hwp+FEC_TXIC0);+writel(rx_itr,fep->hwp+FEC_RXIC0);+writel(tx_itr,fep->hwp+FEC_TXIC1);+writel(rx_itr,fep->hwp+FEC_RXIC1);+writel(tx_itr,fep->hwp+FEC_TXIC2);+writel(rx_itr,fep->hwp+FEC_RXIC2);+}++staticintfec_enet_get_coalesce(structnet_device*ndev,+structethtool_coalesce*ec)+{+structfec_enet_private*fep=netdev_priv(ndev);+conststructplatform_device_id*id_entry=+platform_get_device_id(fep->pdev);++if(!(id_entry->driver_data&FEC_QUIRK_HAS_AVB))+return-EOPNOTSUPP;++ec->rx_coalesce_usecs=fep->rx_time_itr;+ec->rx_max_coalesced_frames=fep->rx_pkts_itr;++ec->tx_coalesce_usecs=fep->tx_time_itr;+ec->tx_max_coalesced_frames=fep->tx_pkts_itr;++return0;+}++staticintfec_enet_set_coalesce(structnet_device*ndev,+structethtool_coalesce*ec)+{+structfec_enet_private*fep=netdev_priv(ndev);+conststructplatform_device_id*id_entry=+platform_get_device_id(fep->pdev);++if(!(id_entry->driver_data&FEC_QUIRK_HAS_AVB))+return-EOPNOTSUPP;++fep->rx_time_itr=ec->rx_coalesce_usecs;+fep->rx_pkts_itr=ec->rx_max_coalesced_frames;++fep->tx_time_itr=ec->tx_coalesce_usecs;+fep->tx_pkts_itr=ec->tx_max_coalesced_frames;++fec_enet_itr_coal_set(ndev);++return0;+}++staticvoidfec_enet_itr_coal_init(structnet_device*ndev)+{+structethtool_coalesceec;++ec.rx_coalesce_usecs=FEC_ITR_ICTT_DEFAULT;+ec.rx_max_coalesced_frames=FEC_ITR_ICFT_DEFAULT;++ec.tx_coalesce_usecs=FEC_ITR_ICTT_DEFAULT;+ec.tx_max_coalesced_frames=FEC_ITR_ICFT_DEFAULT;++fec_enet_set_coalesce(ndev,&ec);+}+staticconststructethtool_opsfec_enet_ethtool_ops={.get_settings=fec_enet_get_settings,.set_settings=fec_enet_set_settings,.get_drvinfo=fec_enet_get_drvinfo,.nway_reset=fec_enet_nway_reset,.get_link=ethtool_op_get_link,+.get_coalesce=fec_enet_get_coalesce,+.set_coalesce=fec_enet_set_coalesce,#ifndef CONFIG_M5272.get_pauseparam=fec_enet_get_pauseparam,.set_pauseparam=fec_enet_set_pauseparam,
From: Frank.Li at freescale.com <hidden> Date: 2014-09-15 17:12:57
From: Fugang Duan <redacted>
When enable three queues on imx6sx enet, and then do tx performance
test with iperf tool, after some time running, tx hang.
Found that:
If uDMA is running, software set TDAR may cause tx hang.
If uDMA is in idle, software set TDAR don't cause tx hang.
There is a TDAR race condition for mutliQ when the software sets TDAR
and the UDMA clears TDAR simultaneously or in a small window (2-4 cycles).
This will cause the udma_tx and udma_tx_arbiter state machines to hang.
The issue exist at i.MX6SX enet IP.
So, the Workaround is checking TDAR status four time, if TDAR cleared by
hardware and then write TDAR, otherwise don't set TDAR.
The patch is only one Workaround for the issue TKT210582.
Signed-off-by: Fugang Duan <redacted>
Signed-off-by: Frank Li <redacted>
---
drivers/net/ethernet/freescale/fec_main.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
- dev_err(&pdev->dev, "Invalidate num_tx(=%d), fail back to 1\n",
+ dev_warn(&pdev->dev, "Invalid num_tx(=%d), fall back to 1\n",
*num_tx);
Any time you change the function name of a multi-line function call, you must
be mindful to adjust the indention of the subsequent argument lines, if
necessary.
if (*num_rx < 1 || *num_rx > FEC_ENET_MAX_RX_QS) {
- dev_err(&pdev->dev, "Invalidate num_rx(=%d), fail back to 1\n",
+ dev_warn(&pdev->dev, "Invalid num_rx(=%d), fall back to 1\n",
*num_rx);
Please use explicit "unsigned int" just like the lines right above the ones
you are adding.
+ /* Must be greater than zero to avoid unpredictable behavior */
+ if (!fep->rx_time_itr || !fep->rx_pkts_itr ||
+ !fep->tx_time_itr || !fep->tx_pkts_itr)
This is not indented properly.
On the second and subsequent lines of a multi-line conditional, things
must start exactly at the first column after the openning parenthesis
of the first line.
@@ -111,6 +111,13 @@ static void fec_enet_itr_coal_init(struct net_device *ndev); * independent rings */ #define FEC_QUIRK_HAS_AVB (1 << 8)+/*+ * There is a TDAR race condition for mutliQ when the software sets TDAR+ * and the UDMA clears TDAR simultaneously or in a small window (2-4 cycles).+ * This will cause the udma_tx and udma_tx_arbiter state machines to hang.+ * The issue exist at i.MX6SX enet IP.+ */+#define FEC_QUIRK_TKT210582 (1 << 9)
Networking comments should be of the form:
/* Like
* this.
*/
On Tue, Sep 16, 2014 at 01:12:57AM +0800, Frank.Li@freescale.com wrote:
quoted hunk
From: Fugang Duan <redacted>
When enable three queues on imx6sx enet, and then do tx performance
test with iperf tool, after some time running, tx hang.
Found that:
If uDMA is running, software set TDAR may cause tx hang.
If uDMA is in idle, software set TDAR don't cause tx hang.
There is a TDAR race condition for mutliQ when the software sets TDAR
and the UDMA clears TDAR simultaneously or in a small window (2-4 cycles).
This will cause the udma_tx and udma_tx_arbiter state machines to hang.
The issue exist at i.MX6SX enet IP.
So, the Workaround is checking TDAR status four time, if TDAR cleared by
hardware and then write TDAR, otherwise don't set TDAR.
The patch is only one Workaround for the issue TKT210582.
Signed-off-by: Fugang Duan <redacted>
Signed-off-by: Frank Li <redacted>
---
drivers/net/ethernet/freescale/fec_main.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
I think TKTxxx number is used by Freescale design team to track issues
internally, and there should be a corresponding errata number like
ERRxxx which should be accessible by external people in errata document?
Shawn
From: fugang.duan at freescale.com <hidden> Date: 2014-09-16 03:09:09
From: Shawn Guo <redacted> Sent: Tuesday, September 16, 2014 8:52 AM
To: Li Frank-B20596
Cc: Duan Fugang-B38611; davem@davemloft.net; netdev@vger.kernel.org;
lznuaa@gmail.com; linux-arm-kernel@lists.infradead.org
Subject: Re: [Patch net-next 4/4] net: fec: Workaround for imx6sx enet tx
hang when enable three queues
On Tue, Sep 16, 2014 at 01:12:57AM +0800, Frank.Li@freescale.com wrote:
quoted
From: Fugang Duan <redacted>
When enable three queues on imx6sx enet, and then do tx performance
test with iperf tool, after some time running, tx hang.
Found that:
If uDMA is running, software set TDAR may cause tx hang.
If uDMA is in idle, software set TDAR don't cause tx hang.
There is a TDAR race condition for mutliQ when the software sets TDAR
and the UDMA clears TDAR simultaneously or in a small window (2-4
cycles).
quoted
This will cause the udma_tx and udma_tx_arbiter state machines to hang.
The issue exist at i.MX6SX enet IP.
So, the Workaround is checking TDAR status four time, if TDAR cleared
by hardware and then write TDAR, otherwise don't set TDAR.
The patch is only one Workaround for the issue TKT210582.
Signed-off-by: Fugang Duan <redacted>
Signed-off-by: Frank Li <redacted>
---
drivers/net/ethernet/freescale/fec_main.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
* independent rings
*/
#define FEC_QUIRK_HAS_AVB (1 << 8)
+/*
+ * There is a TDAR race condition for mutliQ when the software sets
+TDAR
+ * and the UDMA clears TDAR simultaneously or in a small window (2-4
cycles).
quoted
+ * This will cause the udma_tx and udma_tx_arbiter state machines to
hang.
quoted
+ * The issue exist at i.MX6SX enet IP.
+ */
+#define FEC_QUIRK_TKT210582 (1 << 9)
I think TKTxxx number is used by Freescale design team to track issues
internally, and there should be a corresponding errata number like ERRxxx
which should be accessible by external people in errata document?
Shawn
The issue ticket is: TDAR race condition for mutliQ - Errata: ERR007885