In response to a request, I have created a patch against kernel version 2.6.29-davinci1, using git-format-patch. This is similar code to that patch that I submitted earlier, except this time for 2.6.29, rather than 2.6.27.

However, I still have some issues with this fix; it deserves a better look.

1. Other Ethernet drivers do not bother to mess around with the NAPI list if they need to continue polling. Davinci EMAC driver could probably copy this (eg e100 driver)

2. There is one case in the nested if-statements that does nothing. This implies that the statement above it true, since the Davinci EMAC driver sometimes 'does nothing'.

3. In emac_rx_bdproc() and emac_tx_bdproc(), when the pending flag is set, it also checks whether it has consumed the entire budget. The code could probably do with some rationalisation between emac_?x_bdproc() functions, and emac_poll().

I have implemented a different patch that resolves 1. and 2. above. However, I am not an expert on the Davinci EMAC hardware, or of Linux device drivers in general, and do not feel qualified to review emac_rx_bdproc() and emac_poll().

So I will submit my preferred patch, and leave the review of emac_rx_bdproc() and emac_poll() to those better qualified.

Stephen Irons



Stephen Irons wrote:
Do not re-enable interrupts if receive processing has used its entire budget.

As described in net/core/dev.c, function net_rx_action, drivers must not modify the NAPI state if they consume their entire weight. Davinci EMAC driver was re-enabling interrupts in the rare case that it has used its budget, and there
was now no more work to do.

Tested on DM644x EVM.
---
drivers/net/davinci_emac.c |   15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 89ff48b..b3017ef 100755
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -2157,7 +2157,8 @@ static int emac_poll(struct napi_struct *napi, int budget) struct emac_priv *priv = container_of(napi, struct emac_priv, napi);
       struct net_device *ndev = priv->ndev;
       u32 status = 0;
-       u32 num_pkts = 0;
+       u32 num_txpkts = 0;
+       u32 num_rxpkts = 0;
       u32 txpending = 0;
       u32 rxpending = 0;

@@ -2173,7 +2174,7 @@ static int emac_poll(struct napi_struct *napi, int budget)
               mask = EMAC_DM646X_MAC_IN_VECTOR_TX_INT_VEC;

       if (status & mask) {
-               num_pkts = emac_tx_bdproc(priv, EMAC_DEF_TX_CH,

+               num_txpkts = emac_tx_bdproc(priv, EMAC_DEF_TX_CH,
                                         EMAC_DEF_TX_MAX_SERVICE,
                                         &txpending);
       } /* TX processing */
@@ -2184,7 +2185,7 @@ static int emac_poll(struct napi_struct *napi, int budget)
               mask = EMAC_DM646X_MAC_IN_VECTOR_RX_INT_VEC;

       if (status & mask) {
-               num_pkts = emac_rx_bdproc(priv, EMAC_DEF_RX_CH,
+               num_rxpkts = emac_rx_bdproc(priv, EMAC_DEF_RX_CH,
                                         budget, &rxpending);
       } /* RX processing */

@@ -2194,8 +2195,10 @@ static int emac_poll(struct napi_struct *napi, int budget)
                       __netif_rx_schedule(&priv->napi);
               }
       } else {
-               netif_rx_complete(napi);
-               emac_int_enable(priv);
+               if (num_rxpkts != budget) {
+                       netif_rx_complete(napi);
+                       emac_int_enable(priv);
+               }
       }

       if (unlikely(status & EMAC_DM644X_MAC_IN_VECTOR_HOST_INT)) {
@@ -2226,7 +2229,7 @@ static int emac_poll(struct napi_struct *napi, int budget)
               }
       } /* Host error processing */

-       return num_pkts;
+       return num_rxpkts;
}


--
1.5.6.3




=======================================================================
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
=======================================================================


_______________________________________________
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to