Commit 102a2786c9df756cffdbcfd11096124e4dc6c311
Committed by
Rusty Russell
1 parent
1f54b0c055
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>
Showing 1 changed file with 4 additions and 23 deletions Side-by-side Diff
drivers/net/virtio_net.c
... | ... | @@ -123,9 +123,6 @@ |
123 | 123 | /* Host can handle any s/g split between our header and packet data */ |
124 | 124 | bool any_header_sg; |
125 | 125 | |
126 | - /* enable config space updates */ | |
127 | - bool config_enable; | |
128 | - | |
129 | 126 | /* Active statistics */ |
130 | 127 | struct virtnet_stats __percpu *stats; |
131 | 128 | |
... | ... | @@ -1408,9 +1405,6 @@ |
1408 | 1405 | u16 v; |
1409 | 1406 | |
1410 | 1407 | mutex_lock(&vi->config_lock); |
1411 | - if (!vi->config_enable) | |
1412 | - goto done; | |
1413 | - | |
1414 | 1408 | if (virtio_cread_feature(vi->vdev, VIRTIO_NET_F_STATUS, |
1415 | 1409 | struct virtio_net_config, status, &v) < 0) |
1416 | 1410 | goto done; |
... | ... | @@ -1758,7 +1752,6 @@ |
1758 | 1752 | } |
1759 | 1753 | |
1760 | 1754 | mutex_init(&vi->config_lock); |
1761 | - vi->config_enable = true; | |
1762 | 1755 | INIT_WORK(&vi->config_work, virtnet_config_changed_work); |
1763 | 1756 | |
1764 | 1757 | /* If we can receive ANY GSO packets, we must allocate large ones. */ |
1765 | 1758 | |
... | ... | @@ -1875,17 +1868,13 @@ |
1875 | 1868 | |
1876 | 1869 | unregister_hotcpu_notifier(&vi->nb); |
1877 | 1870 | |
1878 | - /* Prevent config work handler from accessing the device. */ | |
1879 | - mutex_lock(&vi->config_lock); | |
1880 | - vi->config_enable = false; | |
1881 | - mutex_unlock(&vi->config_lock); | |
1871 | + /* Make sure no work handler is accessing the device. */ | |
1872 | + flush_work(&vi->config_work); | |
1882 | 1873 | |
1883 | 1874 | unregister_netdev(vi->dev); |
1884 | 1875 | |
1885 | 1876 | remove_vq_common(vi); |
1886 | 1877 | |
1887 | - flush_work(&vi->config_work); | |
1888 | - | |
1889 | 1878 | free_percpu(vi->stats); |
1890 | 1879 | free_netdev(vi->dev); |
1891 | 1880 | } |
... | ... | @@ -1898,10 +1887,8 @@ |
1898 | 1887 | |
1899 | 1888 | unregister_hotcpu_notifier(&vi->nb); |
1900 | 1889 | |
1901 | - /* Prevent config work handler from accessing the device */ | |
1902 | - mutex_lock(&vi->config_lock); | |
1903 | - vi->config_enable = false; | |
1904 | - mutex_unlock(&vi->config_lock); | |
1890 | + /* Make sure no work handler is accessing the device */ | |
1891 | + flush_work(&vi->config_work); | |
1905 | 1892 | |
1906 | 1893 | netif_device_detach(vi->dev); |
1907 | 1894 | cancel_delayed_work_sync(&vi->refill); |
... | ... | @@ -1916,8 +1903,6 @@ |
1916 | 1903 | |
1917 | 1904 | remove_vq_common(vi); |
1918 | 1905 | |
1919 | - flush_work(&vi->config_work); | |
1920 | - | |
1921 | 1906 | return 0; |
1922 | 1907 | } |
1923 | 1908 | |
... | ... | @@ -1940,10 +1925,6 @@ |
1940 | 1925 | } |
1941 | 1926 | |
1942 | 1927 | netif_device_attach(vi->dev); |
1943 | - | |
1944 | - mutex_lock(&vi->config_lock); | |
1945 | - vi->config_enable = true; | |
1946 | - mutex_unlock(&vi->config_lock); | |
1947 | 1928 | |
1948 | 1929 | rtnl_lock(); |
1949 | 1930 | virtnet_set_queues(vi, vi->curr_queue_pairs); |