* [PATCH net 0/2 v2] net: bcmgenet: TX reclaim and DMA fixes
@ 2014-09-22 18:54 Florian Fainelli
2014-09-22 18:54 ` [PATCH net 1/2 v2] net: bcmgenet: fix TX reclaim accounting for fragments Florian Fainelli
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Florian Fainelli @ 2014-09-22 18:54 UTC (permalink / raw)
To: netdev; +Cc: davem, Florian Fainelli
Hi David,
This patch set contains one fix for an accounting problem while reclaiming
transmitted buffers having fragments, and the second fix is to make sure
that the DMA shutdown is properly controlled.
Florian Fainelli (2):
net: bcmgenet: fix TX reclaim accounting for fragments
net: bcmgenet: call bcmgenet_dma_teardown in bcmgenet_fini_dma
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 110 +++++++++++++------------
1 file changed, 56 insertions(+), 54 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 1/2 v2] net: bcmgenet: fix TX reclaim accounting for fragments
2014-09-22 18:54 [PATCH net 0/2 v2] net: bcmgenet: TX reclaim and DMA fixes Florian Fainelli
@ 2014-09-22 18:54 ` Florian Fainelli
2014-09-22 18:54 ` [PATCH net 2/2 v2] net: bcmgenet: call bcmgenet_dma_teardown in bcmgenet_fini_dma Florian Fainelli
2014-09-22 22:39 ` [PATCH net 0/2 v2] net: bcmgenet: TX reclaim and DMA fixes David Miller
2 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2014-09-22 18:54 UTC (permalink / raw)
To: netdev; +Cc: davem, Florian Fainelli
The GENET driver supports SKB fragments, and succeeds in transmitting
them properly, but when reclaiming these transmitted fragments, we will
only update the count of free buffer descriptors by 1, even for SKBs
with fragments. This leads to the networking stack thinking it has more
room than the hardware has when pushing new SKBs, and backing off
consequently because we return NETDEV_TX_BUSY.
Fix this by accounting for the SKB nr_frags plus one (itself) and update
ring->free_bds accordingly with that value for each iteration loop in
__bcmgenet_tx_reclaim().
Fixes: 1c1008c793fa ("net: bcmgenet: add main driver file")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index cdef86a03862..11a96437862d 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -875,6 +875,7 @@ static void __bcmgenet_tx_reclaim(struct net_device *dev,
int last_tx_cn, last_c_index, num_tx_bds;
struct enet_cb *tx_cb_ptr;
struct netdev_queue *txq;
+ unsigned int bds_compl;
unsigned int c_index;
/* Compute how many buffers are transmitted since last xmit call */
@@ -899,7 +900,9 @@ static void __bcmgenet_tx_reclaim(struct net_device *dev,
/* Reclaim transmitted buffers */
while (last_tx_cn-- > 0) {
tx_cb_ptr = ring->cbs + last_c_index;
+ bds_compl = 0;
if (tx_cb_ptr->skb) {
+ bds_compl = skb_shinfo(tx_cb_ptr->skb)->nr_frags + 1;
dev->stats.tx_bytes += tx_cb_ptr->skb->len;
dma_unmap_single(&dev->dev,
dma_unmap_addr(tx_cb_ptr, dma_addr),
@@ -916,7 +919,7 @@ static void __bcmgenet_tx_reclaim(struct net_device *dev,
dma_unmap_addr_set(tx_cb_ptr, dma_addr, 0);
}
dev->stats.tx_packets++;
- ring->free_bds += 1;
+ ring->free_bds += bds_compl;
last_c_index++;
last_c_index &= (num_tx_bds - 1);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 2/2 v2] net: bcmgenet: call bcmgenet_dma_teardown in bcmgenet_fini_dma
2014-09-22 18:54 [PATCH net 0/2 v2] net: bcmgenet: TX reclaim and DMA fixes Florian Fainelli
2014-09-22 18:54 ` [PATCH net 1/2 v2] net: bcmgenet: fix TX reclaim accounting for fragments Florian Fainelli
@ 2014-09-22 18:54 ` Florian Fainelli
2014-09-22 22:39 ` [PATCH net 0/2 v2] net: bcmgenet: TX reclaim and DMA fixes David Miller
2 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2014-09-22 18:54 UTC (permalink / raw)
To: netdev; +Cc: davem, Florian Fainelli
We should not be manipulaging the DMA_CTRL registers directly by writing
0 to them to disable DMA. This is an operation that needs to be timed to
make sure the DMA engines have been properly stopped since their state
machine stops on a packet boundary, not immediately.
Make sure that tha bcmgenet_fini_dma() calls bcmgenet_dma_teardown() to
ensure a proper DMA engine state. As a result, we need to reorder the
function bodies to resolve the use dependency.
Fixes: 1c1008c793fa ("net: bcmgenet: add main driver file")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v2:
- properly re-order bcmgenet_dma_teardown to resolve the use dependency
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 105 ++++++++++++-------------
1 file changed, 52 insertions(+), 53 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 11a96437862d..5cc9cae21ed5 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1744,13 +1744,63 @@ static void bcmgenet_init_multiq(struct net_device *dev)
bcmgenet_tdma_writel(priv, reg, DMA_CTRL);
}
+static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv)
+{
+ int ret = 0;
+ int timeout = 0;
+ u32 reg;
+
+ /* Disable TDMA to stop add more frames in TX DMA */
+ reg = bcmgenet_tdma_readl(priv, DMA_CTRL);
+ reg &= ~DMA_EN;
+ bcmgenet_tdma_writel(priv, reg, DMA_CTRL);
+
+ /* Check TDMA status register to confirm TDMA is disabled */
+ while (timeout++ < DMA_TIMEOUT_VAL) {
+ reg = bcmgenet_tdma_readl(priv, DMA_STATUS);
+ if (reg & DMA_DISABLED)
+ break;
+
+ udelay(1);
+ }
+
+ if (timeout == DMA_TIMEOUT_VAL) {
+ netdev_warn(priv->dev, "Timed out while disabling TX DMA\n");
+ ret = -ETIMEDOUT;
+ }
+
+ /* Wait 10ms for packet drain in both tx and rx dma */
+ usleep_range(10000, 20000);
+
+ /* Disable RDMA */
+ reg = bcmgenet_rdma_readl(priv, DMA_CTRL);
+ reg &= ~DMA_EN;
+ bcmgenet_rdma_writel(priv, reg, DMA_CTRL);
+
+ timeout = 0;
+ /* Check RDMA status register to confirm RDMA is disabled */
+ while (timeout++ < DMA_TIMEOUT_VAL) {
+ reg = bcmgenet_rdma_readl(priv, DMA_STATUS);
+ if (reg & DMA_DISABLED)
+ break;
+
+ udelay(1);
+ }
+
+ if (timeout == DMA_TIMEOUT_VAL) {
+ netdev_warn(priv->dev, "Timed out while disabling RX DMA\n");
+ ret = -ETIMEDOUT;
+ }
+
+ return ret;
+}
+
static void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
{
int i;
/* disable DMA */
- bcmgenet_rdma_writel(priv, 0, DMA_CTRL);
- bcmgenet_tdma_writel(priv, 0, DMA_CTRL);
+ bcmgenet_dma_teardown(priv);
for (i = 0; i < priv->num_tx_bds; i++) {
if (priv->tx_cbs[i].skb != NULL) {
@@ -2109,57 +2159,6 @@ err_clk_disable:
return ret;
}
-static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv)
-{
- int ret = 0;
- int timeout = 0;
- u32 reg;
-
- /* Disable TDMA to stop add more frames in TX DMA */
- reg = bcmgenet_tdma_readl(priv, DMA_CTRL);
- reg &= ~DMA_EN;
- bcmgenet_tdma_writel(priv, reg, DMA_CTRL);
-
- /* Check TDMA status register to confirm TDMA is disabled */
- while (timeout++ < DMA_TIMEOUT_VAL) {
- reg = bcmgenet_tdma_readl(priv, DMA_STATUS);
- if (reg & DMA_DISABLED)
- break;
-
- udelay(1);
- }
-
- if (timeout == DMA_TIMEOUT_VAL) {
- netdev_warn(priv->dev, "Timed out while disabling TX DMA\n");
- ret = -ETIMEDOUT;
- }
-
- /* Wait 10ms for packet drain in both tx and rx dma */
- usleep_range(10000, 20000);
-
- /* Disable RDMA */
- reg = bcmgenet_rdma_readl(priv, DMA_CTRL);
- reg &= ~DMA_EN;
- bcmgenet_rdma_writel(priv, reg, DMA_CTRL);
-
- timeout = 0;
- /* Check RDMA status register to confirm RDMA is disabled */
- while (timeout++ < DMA_TIMEOUT_VAL) {
- reg = bcmgenet_rdma_readl(priv, DMA_STATUS);
- if (reg & DMA_DISABLED)
- break;
-
- udelay(1);
- }
-
- if (timeout == DMA_TIMEOUT_VAL) {
- netdev_warn(priv->dev, "Timed out while disabling RX DMA\n");
- ret = -ETIMEDOUT;
- }
-
- return ret;
-}
-
static void bcmgenet_netif_stop(struct net_device *dev)
{
struct bcmgenet_priv *priv = netdev_priv(dev);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/2 v2] net: bcmgenet: TX reclaim and DMA fixes
2014-09-22 18:54 [PATCH net 0/2 v2] net: bcmgenet: TX reclaim and DMA fixes Florian Fainelli
2014-09-22 18:54 ` [PATCH net 1/2 v2] net: bcmgenet: fix TX reclaim accounting for fragments Florian Fainelli
2014-09-22 18:54 ` [PATCH net 2/2 v2] net: bcmgenet: call bcmgenet_dma_teardown in bcmgenet_fini_dma Florian Fainelli
@ 2014-09-22 22:39 ` David Miller
2014-09-22 22:43 ` Florian Fainelli
2 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2014-09-22 22:39 UTC (permalink / raw)
To: f.fainelli; +Cc: netdev
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon, 22 Sep 2014 11:54:41 -0700
> This patch set contains one fix for an accounting problem while reclaiming
> transmitted buffers having fragments, and the second fix is to make sure
> that the DMA shutdown is properly controlled.
Series applied, but I can't see how you could have possibly
functionally tested the original patch series if it didn't
even compile :-/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/2 v2] net: bcmgenet: TX reclaim and DMA fixes
2014-09-22 22:39 ` [PATCH net 0/2 v2] net: bcmgenet: TX reclaim and DMA fixes David Miller
@ 2014-09-22 22:43 ` Florian Fainelli
0 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2014-09-22 22:43 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On 09/22/2014 03:39 PM, David Miller wrote:
> From: Florian Fainelli <f.fainelli@gmail.com>
> Date: Mon, 22 Sep 2014 11:54:41 -0700
>
>> This patch set contains one fix for an accounting problem while reclaiming
>> transmitted buffers having fragments, and the second fix is to make sure
>> that the DMA shutdown is properly controlled.
>
> Series applied, but I can't see how you could have possibly
> functionally tested the original patch series if it didn't
> even compile :-/
I cherry picked the second patch from my downstream tree which had a
different function re-arrangement, and I must admit I thought I also had
compiled the second patch, while I did not...
--
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-22 22:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-22 18:54 [PATCH net 0/2 v2] net: bcmgenet: TX reclaim and DMA fixes Florian Fainelli
2014-09-22 18:54 ` [PATCH net 1/2 v2] net: bcmgenet: fix TX reclaim accounting for fragments Florian Fainelli
2014-09-22 18:54 ` [PATCH net 2/2 v2] net: bcmgenet: call bcmgenet_dma_teardown in bcmgenet_fini_dma Florian Fainelli
2014-09-22 22:39 ` [PATCH net 0/2 v2] net: bcmgenet: TX reclaim and DMA fixes David Miller
2014-09-22 22:43 ` Florian Fainelli
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).