These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / net / core / netpoll.c
index c126a87..94acfc8 100644 (file)
@@ -140,36 +140,42 @@ static void queue_process(struct work_struct *work)
  * case. Further, we test the poll_owner to avoid recursion on UP
  * systems where the lock doesn't exist.
  */
-static int poll_one_napi(struct napi_struct *napi, int budget)
+static void poll_one_napi(struct napi_struct *napi)
 {
-       int work;
+       int work = 0;
 
        /* net_rx_action's ->poll() invocations and our's are
         * synchronized by this test which is only made while
         * holding the napi->poll_lock.
         */
        if (!test_bit(NAPI_STATE_SCHED, &napi->state))
-               return budget;
+               return;
 
-       set_bit(NAPI_STATE_NPSVC, &napi->state);
+       /* If we set this bit but see that it has already been set,
+        * that indicates that napi has been disabled and we need
+        * to abort this operation
+        */
+       if (test_and_set_bit(NAPI_STATE_NPSVC, &napi->state))
+               return;
 
-       work = napi->poll(napi, budget);
-       WARN_ONCE(work > budget, "%pF exceeded budget in poll\n", napi->poll);
+       /* We explicilty pass the polling call a budget of 0 to
+        * indicate that we are clearing the Tx path only.
+        */
+       work = napi->poll(napi, 0);
+       WARN_ONCE(work, "%pF exceeded budget in poll\n", napi->poll);
        trace_napi_poll(napi);
 
        clear_bit(NAPI_STATE_NPSVC, &napi->state);
-
-       return budget - work;
 }
 
-static void poll_napi(struct net_device *dev, int budget)
+static void poll_napi(struct net_device *dev)
 {
        struct napi_struct *napi;
 
        list_for_each_entry(napi, &dev->napi_list, dev_list) {
                if (napi->poll_owner != smp_processor_id() &&
                    spin_trylock(&napi->poll_lock)) {
-                       budget = poll_one_napi(napi, budget);
+                       poll_one_napi(napi);
                        spin_unlock(&napi->poll_lock);
                }
        }
@@ -179,7 +185,6 @@ static void netpoll_poll_dev(struct net_device *dev)
 {
        const struct net_device_ops *ops;
        struct netpoll_info *ni = rcu_dereference_bh(dev->npinfo);
-       int budget = 0;
 
        /* Don't do any rx activity if the dev_lock mutex is held
         * the dev_open/close paths use this to block netpoll activity
@@ -202,7 +207,7 @@ static void netpoll_poll_dev(struct net_device *dev)
        /* Process pending work on NIC */
        ops->ndo_poll_controller(dev);
 
-       poll_napi(dev, budget);
+       poll_napi(dev);
 
        up(&ni->dev_lock);
 
@@ -380,6 +385,8 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
        static atomic_t ip_ident;
        struct ipv6hdr *ip6h;
 
+       WARN_ON_ONCE(!irqs_disabled());
+
        udp_len = len + sizeof(*udph);
        if (np->ipv6)
                ip_len = udp_len + sizeof(*ip6h);