netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2 0/5] net: stmmac: Misc Fixes
@ 2019-01-09  9:05 Jose Abreu
  2019-01-09  9:05 ` [PATCH net v2 1/5] net: stmmac: Fix PCI module removal leak Jose Abreu
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Jose Abreu @ 2019-01-09  9:05 UTC (permalink / raw)
  To: netdev
  Cc: Jose Abreu, Joao Pinto, David S . Miller, Giuseppe Cavallaro,
	Alexandre Torgue

Some small fixes for stmmac targeting -net. Detailed info in commit log.

Cc: Joao Pinto <jpinto@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>

Jose Abreu (5):
  net: stmmac: Fix PCI module removal leak
  net: stmmac: dwxgmac2: Only clear interrupts that are active
  net: stmmac: Check if CBS is supported before configuring
  net: stmmac: Fix the logic of checking if RX Watchdog must be enabled
  net: stmmac: Prevent RX starvation in stmmac_napi_poll()

 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c |  6 +--
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 51 +++++++++++-----------
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c   | 10 +++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c    |  2 +
 4 files changed, 41 insertions(+), 28 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net v2 1/5] net: stmmac: Fix PCI module removal leak
  2019-01-09  9:05 [PATCH net v2 0/5] net: stmmac: Misc Fixes Jose Abreu
@ 2019-01-09  9:05 ` Jose Abreu
  2019-01-09  9:05 ` [PATCH net v2 2/5] net: stmmac: dwxgmac2: Only clear interrupts that are active Jose Abreu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jose Abreu @ 2019-01-09  9:05 UTC (permalink / raw)
  To: netdev
  Cc: Jose Abreu, Joao Pinto, David S . Miller, Giuseppe Cavallaro,
	Alexandre Torgue

Since commit b7d0f08e9129, the enable / disable of PCI device is not
managed which will result in IO regions not being automatically unmapped.
As regions continue mapped it is currently not possible to remove and
then probe again the PCI module of stmmac.

Fix this by manually unmapping regions on remove callback.

Changes from v1:
- Fix build error

Cc: Joao Pinto <jpinto@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Fixes: b7d0f08e9129 ("net: stmmac: Fix WoL for PCI-based setups")
Signed-off-by: Jose Abreu <joabreu@synopsys.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index c54a50dbd5ac..d819e8eaba12 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -299,7 +299,17 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
  */
 static void stmmac_pci_remove(struct pci_dev *pdev)
 {
+	int i;
+
 	stmmac_dvr_remove(&pdev->dev);
+
+	for (i = 0; i <= PCI_STD_RESOURCE_END; i++) {
+		if (pci_resource_len(pdev, i) == 0)
+			continue;
+		pcim_iounmap_regions(pdev, BIT(i));
+		break;
+	}
+
 	pci_disable_device(pdev);
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net v2 2/5] net: stmmac: dwxgmac2: Only clear interrupts that are active
  2019-01-09  9:05 [PATCH net v2 0/5] net: stmmac: Misc Fixes Jose Abreu
  2019-01-09  9:05 ` [PATCH net v2 1/5] net: stmmac: Fix PCI module removal leak Jose Abreu
@ 2019-01-09  9:05 ` Jose Abreu
  2019-01-09  9:05 ` [PATCH net v2 3/5] net: stmmac: Check if CBS is supported before configuring Jose Abreu
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jose Abreu @ 2019-01-09  9:05 UTC (permalink / raw)
  To: netdev
  Cc: Jose Abreu, Joao Pinto, David S . Miller, Giuseppe Cavallaro,
	Alexandre Torgue

In DMA interrupt handler we were clearing all interrupts status, even
the ones that were not active. Fix this and only clear the active
interrupts.

Cc: Joao Pinto <jpinto@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: Jose Abreu <joabreu@synopsys.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
index 6c5092e7771c..c5e25580a43f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
@@ -263,6 +263,7 @@ static int dwxgmac2_dma_interrupt(void __iomem *ioaddr,
 				  struct stmmac_extra_stats *x, u32 chan)
 {
 	u32 intr_status = readl(ioaddr + XGMAC_DMA_CH_STATUS(chan));
+	u32 intr_en = readl(ioaddr + XGMAC_DMA_CH_INT_EN(chan));
 	int ret = 0;
 
 	/* ABNORMAL interrupts */
@@ -282,8 +283,7 @@ static int dwxgmac2_dma_interrupt(void __iomem *ioaddr,
 		x->normal_irq_n++;
 
 		if (likely(intr_status & XGMAC_RI)) {
-			u32 value = readl(ioaddr + XGMAC_DMA_CH_INT_EN(chan));
-			if (likely(value & XGMAC_RIE)) {
+			if (likely(intr_en & XGMAC_RIE)) {
 				x->rx_normal_irq_n++;
 				ret |= handle_rx;
 			}
@@ -295,7 +295,7 @@ static int dwxgmac2_dma_interrupt(void __iomem *ioaddr,
 	}
 
 	/* Clear interrupts */
-	writel(~0x0, ioaddr + XGMAC_DMA_CH_STATUS(chan));
+	writel(intr_en & intr_status, ioaddr + XGMAC_DMA_CH_STATUS(chan));
 
 	return ret;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net v2 3/5] net: stmmac: Check if CBS is supported before configuring
  2019-01-09  9:05 [PATCH net v2 0/5] net: stmmac: Misc Fixes Jose Abreu
  2019-01-09  9:05 ` [PATCH net v2 1/5] net: stmmac: Fix PCI module removal leak Jose Abreu
  2019-01-09  9:05 ` [PATCH net v2 2/5] net: stmmac: dwxgmac2: Only clear interrupts that are active Jose Abreu
@ 2019-01-09  9:05 ` Jose Abreu
  2019-01-09  9:05 ` [PATCH net v2 4/5] net: stmmac: Fix the logic of checking if RX Watchdog must be enabled Jose Abreu
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jose Abreu @ 2019-01-09  9:05 UTC (permalink / raw)
  To: netdev
  Cc: Jose Abreu, Joao Pinto, David S . Miller, Giuseppe Cavallaro,
	Alexandre Torgue

Check if CBS is currently supported before trying to configure it in HW.

Cc: Joao Pinto <jpinto@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: Jose Abreu <joabreu@synopsys.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
index 531294f4978b..58ea18af9813 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
@@ -301,6 +301,8 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
 	/* Queue 0 is not AVB capable */
 	if (queue <= 0 || queue >= tx_queues_count)
 		return -EINVAL;
+	if (!priv->dma_cap.av)
+		return -EOPNOTSUPP;
 	if (priv->speed != SPEED_100 && priv->speed != SPEED_1000)
 		return -EOPNOTSUPP;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net v2 4/5] net: stmmac: Fix the logic of checking if RX Watchdog must be enabled
  2019-01-09  9:05 [PATCH net v2 0/5] net: stmmac: Misc Fixes Jose Abreu
                   ` (2 preceding siblings ...)
  2019-01-09  9:05 ` [PATCH net v2 3/5] net: stmmac: Check if CBS is supported before configuring Jose Abreu
@ 2019-01-09  9:05 ` Jose Abreu
  2019-01-09  9:06 ` [PATCH net v2 5/5] net: stmmac: Prevent RX starvation in stmmac_napi_poll() Jose Abreu
  2019-01-11 23:35 ` [PATCH net v2 0/5] net: stmmac: Misc Fixes David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Jose Abreu @ 2019-01-09  9:05 UTC (permalink / raw)
  To: netdev
  Cc: Jose Abreu, Joao Pinto, David S . Miller, Giuseppe Cavallaro,
	Alexandre Torgue

RX Watchdog can be disabled by platform definitions but currently we are
initializing the descriptors before checking if Watchdog must be
disabled or not.

Fix this by checking earlier if user wants Watchdog disabled or not.

Cc: Joao Pinto <jpinto@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: Jose Abreu <joabreu@synopsys.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 24 +++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 0e0a0789c2ed..83ceb1a12e77 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4168,6 +4168,18 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
 			return ret;
 	}
 
+	/* Rx Watchdog is available in the COREs newer than the 3.40.
+	 * In some case, for example on bugged HW this feature
+	 * has to be disable and this can be done by passing the
+	 * riwt_off field from the platform.
+	 */
+	if (((priv->synopsys_id >= DWMAC_CORE_3_50) ||
+	    (priv->plat->has_xgmac)) && (!priv->plat->riwt_off)) {
+		priv->use_riwt = 1;
+		dev_info(priv->device,
+			 "Enable RX Mitigation via HW Watchdog Timer\n");
+	}
+
 	return 0;
 }
 
@@ -4300,18 +4312,6 @@ int stmmac_dvr_probe(struct device *device,
 	if (flow_ctrl)
 		priv->flow_ctrl = FLOW_AUTO;	/* RX/TX pause on */
 
-	/* Rx Watchdog is available in the COREs newer than the 3.40.
-	 * In some case, for example on bugged HW this feature
-	 * has to be disable and this can be done by passing the
-	 * riwt_off field from the platform.
-	 */
-	if (((priv->synopsys_id >= DWMAC_CORE_3_50) ||
-	    (priv->plat->has_xgmac)) && (!priv->plat->riwt_off)) {
-		priv->use_riwt = 1;
-		dev_info(priv->device,
-			 "Enable RX Mitigation via HW Watchdog Timer\n");
-	}
-
 	/* Setup channels NAPI */
 	maxq = max(priv->plat->rx_queues_to_use, priv->plat->tx_queues_to_use);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net v2 5/5] net: stmmac: Prevent RX starvation in stmmac_napi_poll()
  2019-01-09  9:05 [PATCH net v2 0/5] net: stmmac: Misc Fixes Jose Abreu
                   ` (3 preceding siblings ...)
  2019-01-09  9:05 ` [PATCH net v2 4/5] net: stmmac: Fix the logic of checking if RX Watchdog must be enabled Jose Abreu
@ 2019-01-09  9:06 ` Jose Abreu
  2019-01-11 23:35 ` [PATCH net v2 0/5] net: stmmac: Misc Fixes David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Jose Abreu @ 2019-01-09  9:06 UTC (permalink / raw)
  To: netdev
  Cc: Jose Abreu, Joao Pinto, David S . Miller, Giuseppe Cavallaro,
	Alexandre Torgue

Currently, TX is given a budget which is consumed by stmmac_tx_clean()
and stmmac_rx() is given the remaining non-consumed budget.

This is wrong and in case we are sending a large number of packets this
can starve RX because remaining budget will be low.

Let's give always the same budget for RX and TX clean.

While at it, check if we missed any interrupts while we were in NAPI
callback by looking at DMA interrupt status.

Cc: Joao Pinto <jpinto@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: Jose Abreu <joabreu@synopsys.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 27 ++++++++++++-----------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 83ceb1a12e77..3f23e14891df 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3525,27 +3525,28 @@ static int stmmac_napi_poll(struct napi_struct *napi, int budget)
 	struct stmmac_channel *ch =
 		container_of(napi, struct stmmac_channel, napi);
 	struct stmmac_priv *priv = ch->priv_data;
-	int work_done = 0, work_rem = budget;
+	int work_done, rx_done = 0, tx_done = 0;
 	u32 chan = ch->index;
 
 	priv->xstats.napi_poll++;
 
-	if (ch->has_tx) {
-		int done = stmmac_tx_clean(priv, work_rem, chan);
+	if (ch->has_tx)
+		tx_done = stmmac_tx_clean(priv, budget, chan);
+	if (ch->has_rx)
+		rx_done = stmmac_rx(priv, budget, chan);
 
-		work_done += done;
-		work_rem -= done;
-	}
-
-	if (ch->has_rx) {
-		int done = stmmac_rx(priv, work_rem, chan);
+	work_done = max(rx_done, tx_done);
+	work_done = min(work_done, budget);
 
-		work_done += done;
-		work_rem -= done;
-	}
+	if (work_done < budget && napi_complete_done(napi, work_done)) {
+		int stat;
 
-	if (work_done < budget && napi_complete_done(napi, work_done))
 		stmmac_enable_dma_irq(priv, priv->ioaddr, chan);
+		stat = stmmac_dma_interrupt_status(priv, priv->ioaddr,
+						   &priv->xstats, chan);
+		if (stat && napi_reschedule(napi))
+			stmmac_disable_dma_irq(priv, priv->ioaddr, chan);
+	}
 
 	return work_done;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net v2 0/5] net: stmmac: Misc Fixes
  2019-01-09  9:05 [PATCH net v2 0/5] net: stmmac: Misc Fixes Jose Abreu
                   ` (4 preceding siblings ...)
  2019-01-09  9:06 ` [PATCH net v2 5/5] net: stmmac: Prevent RX starvation in stmmac_napi_poll() Jose Abreu
@ 2019-01-11 23:35 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2019-01-11 23:35 UTC (permalink / raw)
  To: jose.abreu; +Cc: netdev, joao.pinto, peppe.cavallaro, alexandre.torgue

From: Jose Abreu <jose.abreu@synopsys.com>
Date: Wed,  9 Jan 2019 10:05:55 +0100

> Some small fixes for stmmac targeting -net. Detailed info in commit
> log.

Series applied, thanks Jose.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-01-11 23:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-09  9:05 [PATCH net v2 0/5] net: stmmac: Misc Fixes Jose Abreu
2019-01-09  9:05 ` [PATCH net v2 1/5] net: stmmac: Fix PCI module removal leak Jose Abreu
2019-01-09  9:05 ` [PATCH net v2 2/5] net: stmmac: dwxgmac2: Only clear interrupts that are active Jose Abreu
2019-01-09  9:05 ` [PATCH net v2 3/5] net: stmmac: Check if CBS is supported before configuring Jose Abreu
2019-01-09  9:05 ` [PATCH net v2 4/5] net: stmmac: Fix the logic of checking if RX Watchdog must be enabled Jose Abreu
2019-01-09  9:06 ` [PATCH net v2 5/5] net: stmmac: Prevent RX starvation in stmmac_napi_poll() Jose Abreu
2019-01-11 23:35 ` [PATCH net v2 0/5] net: stmmac: Misc Fixes David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).