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

From: Ken Stailey
Date: Wed Feb 09 2011 - 06:04:16 EST


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

--- drivers/net/virtio_net.c.orig    2011-02-08 14:34:51.444099190 -0500
+++ drivers/net/virtio_net.c    2011-02-08 14:18:00.484400134 -0500
@@ -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;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/