Skip to contentSkip to conversation

virtio-net: add schedule check to napi_enable call, kernel 2.6.38-RC4

PATCH New Ken Stailey 1 participant 1 message Feb 9, 2011 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-net: add schedule check to napi_enable call, kernel 2.6.38-RC4

Several people are experiencing virtio-net driver lock ups while attempting to do real work and this patch which was submitted in the past and ignored fixes that. For details see:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/579276

net/virtio_net.c    2011-02-08 14:18:00.484400134 -0500 renamed from net/virtio_net.c.orig    2011-02-08 14:34:51.444099190 -0500 +16 -11
@@ -446,6 +446,20 @@
     }
 }
 
+static void virtnet_napi_enable(struct virtnet_info *vi)
+{
+    napi_enable(&vi->napi);
+
+    /* If all buffers were filled by other side before we napi_enabled, we
+     * won't get another interrupt, so process any outstanding packets
+     * now.  virtnet_poll wants re-enable the queue, so we disable here.
+     * We synchronize against interrupts via NAPI_STATE_SCHED */
+    if (napi_schedule_prep(&vi->napi)) {
+        virtqueue_disable_cb(vi->rvq);
+        __napi_schedule(&vi->napi);
+    }
+}
+
 static void refill_work(struct work_struct *work)
 {
     struct virtnet_info *vi;
@@ -454,7 +468,7 @@
     vi = container_of(work, struct virtnet_info, refill.work);
     napi_disable(&vi->napi);
     still_empty = !try_fill_recv(vi, GFP_KERNEL);
-    napi_enable(&vi->napi);
+    virtnet_napi_enable(vi);
 
     /* In theory, this can happen: if we don't get any buffers in
      * we will *never* try to fill again. */
@@ -638,16 +652,7 @@
 {
     struct virtnet_info *vi = netdev_priv(dev);
 
-    napi_enable(&vi->napi);
-
-    /* If all buffers were filled by other side before we napi_enabled, we
-     * won't get another interrupt, so process any outstanding packets
-     * now.  virtnet_poll wants re-enable the queue, so we disable here.
-     * We synchronize against interrupts via NAPI_STATE_SCHED */
-    if (napi_schedule_prep(&vi->napi)) {
-        virtqueue_disable_cb(vi->rvq);
-        __napi_schedule(&vi->napi);
-    }
+    virtnet_napi_enable(vi);
     return 0;
 }