aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/virtio_net.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-10-14 19:52:29 -0400
committerRusty Russell <rusty@rustcorp.com.au>2014-10-14 19:54:58 -0400
commit102a2786c9df756cffdbcfd11096124e4dc6c311 (patch)
tree83d549017a6a2b18114d77050cbed1b447445855 /drivers/net/virtio_net.c
parent1f54b0c055b9322f4e7acb49c492edc5accd15ae (diff)
virtio_net: drop config_enable
Now that virtio core ensures config changes don't arrive during probing, drop config_enable flag in virtio net. On removal, flush is now sufficient to guarantee that no change work is queued. This help simplify the driver, and will allow setting DRIVER_OK earlier without losing config change notifications. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/net/virtio_net.c')
-rw-r--r--drivers/net/virtio_net.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 59caa06f34a6..743fb04a4df9 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -123,9 +123,6 @@ struct virtnet_info {
123 /* Host can handle any s/g split between our header and packet data */ 123 /* Host can handle any s/g split between our header and packet data */
124 bool any_header_sg; 124 bool any_header_sg;
125 125
126 /* enable config space updates */
127 bool config_enable;
128
129 /* Active statistics */ 126 /* Active statistics */
130 struct virtnet_stats __percpu *stats; 127 struct virtnet_stats __percpu *stats;
131 128
@@ -1408,9 +1405,6 @@ static void virtnet_config_changed_work(struct work_struct *work)
1408 u16 v; 1405 u16 v;
1409 1406
1410 mutex_lock(&vi->config_lock); 1407 mutex_lock(&vi->config_lock);
1411 if (!vi->config_enable)
1412 goto done;
1413
1414 if (virtio_cread_feature(vi->vdev, VIRTIO_NET_F_STATUS, 1408 if (virtio_cread_feature(vi->vdev, VIRTIO_NET_F_STATUS,
1415 struct virtio_net_config, status, &v) < 0) 1409 struct virtio_net_config, status, &v) < 0)
1416 goto done; 1410 goto done;
@@ -1758,7 +1752,6 @@ static int virtnet_probe(struct virtio_device *vdev)
1758 } 1752 }
1759 1753
1760 mutex_init(&vi->config_lock); 1754 mutex_init(&vi->config_lock);
1761 vi->config_enable = true;
1762 INIT_WORK(&vi->config_work, virtnet_config_changed_work); 1755 INIT_WORK(&vi->config_work, virtnet_config_changed_work);
1763 1756
1764 /* If we can receive ANY GSO packets, we must allocate large ones. */ 1757 /* If we can receive ANY GSO packets, we must allocate large ones. */
@@ -1875,17 +1868,13 @@ static void virtnet_remove(struct virtio_device *vdev)
1875 1868
1876 unregister_hotcpu_notifier(&vi->nb); 1869 unregister_hotcpu_notifier(&vi->nb);
1877 1870
1878 /* Prevent config work handler from accessing the device. */ 1871 /* Make sure no work handler is accessing the device. */
1879 mutex_lock(&vi->config_lock); 1872 flush_work(&vi->config_work);
1880 vi->config_enable = false;
1881 mutex_unlock(&vi->config_lock);
1882 1873
1883 unregister_netdev(vi->dev); 1874 unregister_netdev(vi->dev);
1884 1875
1885 remove_vq_common(vi); 1876 remove_vq_common(vi);
1886 1877
1887 flush_work(&vi->config_work);
1888
1889 free_percpu(vi->stats); 1878 free_percpu(vi->stats);
1890 free_netdev(vi->dev); 1879 free_netdev(vi->dev);
1891} 1880}
@@ -1898,10 +1887,8 @@ static int virtnet_freeze(struct virtio_device *vdev)
1898 1887
1899 unregister_hotcpu_notifier(&vi->nb); 1888 unregister_hotcpu_notifier(&vi->nb);
1900 1889
1901 /* Prevent config work handler from accessing the device */ 1890 /* Make sure no work handler is accessing the device */
1902 mutex_lock(&vi->config_lock); 1891 flush_work(&vi->config_work);
1903 vi->config_enable = false;
1904 mutex_unlock(&vi->config_lock);
1905 1892
1906 netif_device_detach(vi->dev); 1893 netif_device_detach(vi->dev);
1907 cancel_delayed_work_sync(&vi->refill); 1894 cancel_delayed_work_sync(&vi->refill);
@@ -1916,8 +1903,6 @@ static int virtnet_freeze(struct virtio_device *vdev)
1916 1903
1917 remove_vq_common(vi); 1904 remove_vq_common(vi);
1918 1905
1919 flush_work(&vi->config_work);
1920
1921 return 0; 1906 return 0;
1922} 1907}
1923 1908
@@ -1941,10 +1926,6 @@ static int virtnet_restore(struct virtio_device *vdev)
1941 1926
1942 netif_device_attach(vi->dev); 1927 netif_device_attach(vi->dev);
1943 1928
1944 mutex_lock(&vi->config_lock);
1945 vi->config_enable = true;
1946 mutex_unlock(&vi->config_lock);
1947
1948 rtnl_lock(); 1929 rtnl_lock();
1949 virtnet_set_queues(vi, vi->curr_queue_pairs); 1930 virtnet_set_queues(vi, vi->curr_queue_pairs);
1950 rtnl_unlock(); 1931 rtnl_unlock();