Commit 102a2786 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by Rusty Russell

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: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 1f54b0c0
...@@ -123,9 +123,6 @@ struct virtnet_info { ...@@ -123,9 +123,6 @@ struct virtnet_info {
/* Host can handle any s/g split between our header and packet data */ /* Host can handle any s/g split between our header and packet data */
bool any_header_sg; bool any_header_sg;
/* enable config space updates */
bool config_enable;
/* Active statistics */ /* Active statistics */
struct virtnet_stats __percpu *stats; struct virtnet_stats __percpu *stats;
...@@ -1408,9 +1405,6 @@ static void virtnet_config_changed_work(struct work_struct *work) ...@@ -1408,9 +1405,6 @@ static void virtnet_config_changed_work(struct work_struct *work)
u16 v; u16 v;
mutex_lock(&vi->config_lock); mutex_lock(&vi->config_lock);
if (!vi->config_enable)
goto done;
if (virtio_cread_feature(vi->vdev, VIRTIO_NET_F_STATUS, if (virtio_cread_feature(vi->vdev, VIRTIO_NET_F_STATUS,
struct virtio_net_config, status, &v) < 0) struct virtio_net_config, status, &v) < 0)
goto done; goto done;
...@@ -1758,7 +1752,6 @@ static int virtnet_probe(struct virtio_device *vdev) ...@@ -1758,7 +1752,6 @@ static int virtnet_probe(struct virtio_device *vdev)
} }
mutex_init(&vi->config_lock); mutex_init(&vi->config_lock);
vi->config_enable = true;
INIT_WORK(&vi->config_work, virtnet_config_changed_work); INIT_WORK(&vi->config_work, virtnet_config_changed_work);
/* If we can receive ANY GSO packets, we must allocate large ones. */ /* 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,17 +1868,13 @@ static void virtnet_remove(struct virtio_device *vdev)
unregister_hotcpu_notifier(&vi->nb); unregister_hotcpu_notifier(&vi->nb);
/* Prevent config work handler from accessing the device. */ /* Make sure no work handler is accessing the device. */
mutex_lock(&vi->config_lock); flush_work(&vi->config_work);
vi->config_enable = false;
mutex_unlock(&vi->config_lock);
unregister_netdev(vi->dev); unregister_netdev(vi->dev);
remove_vq_common(vi); remove_vq_common(vi);
flush_work(&vi->config_work);
free_percpu(vi->stats); free_percpu(vi->stats);
free_netdev(vi->dev); free_netdev(vi->dev);
} }
...@@ -1898,10 +1887,8 @@ static int virtnet_freeze(struct virtio_device *vdev) ...@@ -1898,10 +1887,8 @@ static int virtnet_freeze(struct virtio_device *vdev)
unregister_hotcpu_notifier(&vi->nb); unregister_hotcpu_notifier(&vi->nb);
/* Prevent config work handler from accessing the device */ /* Make sure no work handler is accessing the device */
mutex_lock(&vi->config_lock); flush_work(&vi->config_work);
vi->config_enable = false;
mutex_unlock(&vi->config_lock);
netif_device_detach(vi->dev); netif_device_detach(vi->dev);
cancel_delayed_work_sync(&vi->refill); cancel_delayed_work_sync(&vi->refill);
...@@ -1916,8 +1903,6 @@ static int virtnet_freeze(struct virtio_device *vdev) ...@@ -1916,8 +1903,6 @@ static int virtnet_freeze(struct virtio_device *vdev)
remove_vq_common(vi); remove_vq_common(vi);
flush_work(&vi->config_work);
return 0; return 0;
} }
...@@ -1941,10 +1926,6 @@ static int virtnet_restore(struct virtio_device *vdev) ...@@ -1941,10 +1926,6 @@ static int virtnet_restore(struct virtio_device *vdev)
netif_device_attach(vi->dev); netif_device_attach(vi->dev);
mutex_lock(&vi->config_lock);
vi->config_enable = true;
mutex_unlock(&vi->config_lock);
rtnl_lock(); rtnl_lock();
virtnet_set_queues(vi, vi->curr_queue_pairs); virtnet_set_queues(vi, vi->curr_queue_pairs);
rtnl_unlock(); rtnl_unlock();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment