projects
/
cascardo
/
linux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
net/mlx4_en: Cleanups suggested by clang static checker
[cascardo/linux.git]
/
drivers
/
net
/
virtio_net.c
diff --git
a/drivers/net/virtio_net.c
b/drivers/net/virtio_net.c
index
3d0ce44
..
d75256b
100644
(file)
--- a/
drivers/net/virtio_net.c
+++ b/
drivers/net/virtio_net.c
@@
-123,9
+123,6
@@
struct virtnet_info {
/* Host can handle any s/g split between our header and packet data */
bool any_header_sg;
/* Host can handle any s/g split between our header and packet data */
bool any_header_sg;
- /* enable config space updates */
- bool config_enable;
-
/* Active statistics */
struct virtnet_stats __percpu *stats;
/* Active statistics */
struct virtnet_stats __percpu *stats;
@@
-135,9
+132,6
@@
struct virtnet_info {
/* Work struct for config space updates */
struct work_struct config_work;
/* Work struct for config space updates */
struct work_struct config_work;
- /* Lock for config space updates */
- struct mutex config_lock;
-
/* Does the affinity hint is set for virtqueues? */
bool affinity_hint_set;
/* Does the affinity hint is set for virtqueues? */
bool affinity_hint_set;
@@
-920,6
+914,8
@@
static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
int qnum = skb_get_queue_mapping(skb);
struct send_queue *sq = &vi->sq[qnum];
int err;
int qnum = skb_get_queue_mapping(skb);
struct send_queue *sq = &vi->sq[qnum];
int err;
+ struct netdev_queue *txq = netdev_get_tx_queue(dev, qnum);
+ bool kick = !skb->xmit_more;
/* Free up any pending old buffers before queueing new ones. */
free_old_xmit_skbs(sq);
/* Free up any pending old buffers before queueing new ones. */
free_old_xmit_skbs(sq);
@@
-956,7
+952,7
@@
static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
}
}
}
}
- if (
__netif_subqueue_stopped(dev, qnum) || !skb->xmit_more
)
+ if (
kick || netif_xmit_stopped(txq)
)
virtqueue_kick(sq->vq);
return NETDEV_TX_OK;
virtqueue_kick(sq->vq);
return NETDEV_TX_OK;
@@
-1412,13
+1408,9
@@
static void virtnet_config_changed_work(struct work_struct *work)
container_of(work, struct virtnet_info, config_work);
u16 v;
container_of(work, struct virtnet_info, config_work);
u16 v;
- mutex_lock(&vi->config_lock);
- if (!vi->config_enable)
- goto done;
-
if (virtio_cread_feature(vi->vdev, VIRTIO_NET_F_STATUS,
struct virtio_net_config, status, &v) < 0)
if (virtio_cread_feature(vi->vdev, VIRTIO_NET_F_STATUS,
struct virtio_net_config, status, &v) < 0)
-
goto done
;
+
return
;
if (v & VIRTIO_NET_S_ANNOUNCE) {
netdev_notify_peers(vi->dev);
if (v & VIRTIO_NET_S_ANNOUNCE) {
netdev_notify_peers(vi->dev);
@@
-1429,7
+1421,7
@@
static void virtnet_config_changed_work(struct work_struct *work)
v &= VIRTIO_NET_S_LINK_UP;
if (vi->status == v)
v &= VIRTIO_NET_S_LINK_UP;
if (vi->status == v)
-
goto done
;
+
return
;
vi->status = v;
vi->status = v;
@@
-1440,8
+1432,6
@@
static void virtnet_config_changed_work(struct work_struct *work)
netif_carrier_off(vi->dev);
netif_tx_stop_all_queues(vi->dev);
}
netif_carrier_off(vi->dev);
netif_tx_stop_all_queues(vi->dev);
}
-done:
- mutex_unlock(&vi->config_lock);
}
static void virtnet_config_changed(struct virtio_device *vdev)
}
static void virtnet_config_changed(struct virtio_device *vdev)
@@
-1762,8
+1752,6
@@
static int virtnet_probe(struct virtio_device *vdev)
u64_stats_init(&virtnet_stats->rx_syncp);
}
u64_stats_init(&virtnet_stats->rx_syncp);
}
- mutex_init(&vi->config_lock);
- vi->config_enable = true;
INIT_WORK(&vi->config_work, virtnet_config_changed_work);
/* If we can receive ANY GSO packets, we must allocate large ones. */
INIT_WORK(&vi->config_work, virtnet_config_changed_work);
/* If we can receive ANY GSO packets, we must allocate large ones. */
@@
-1811,6
+1799,8
@@
static int virtnet_probe(struct virtio_device *vdev)
goto free_vqs;
}
goto free_vqs;
}
+ virtio_device_ready(vdev);
+
/* Last of all, set up some receive buffers. */
for (i = 0; i < vi->curr_queue_pairs; i++) {
try_fill_recv(&vi->rq[i], GFP_KERNEL);
/* Last of all, set up some receive buffers. */
for (i = 0; i < vi->curr_queue_pairs; i++) {
try_fill_recv(&vi->rq[i], GFP_KERNEL);
@@
-1847,6
+1837,8
@@
static int virtnet_probe(struct virtio_device *vdev)
return 0;
free_recv_bufs:
return 0;
free_recv_bufs:
+ vi->vdev->config->reset(vdev);
+
free_receive_bufs(vi);
unregister_netdev(dev);
free_vqs:
free_receive_bufs(vi);
unregister_netdev(dev);
free_vqs:
@@
-1880,17
+1872,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. */
- mutex_lock(&vi->config_lock);
- vi->config_enable = false;
- mutex_unlock(&vi->config_lock);
+ /* Make sure no work handler is accessing the device. */
+ flush_work(&vi->config_work);
unregister_netdev(vi->dev);
remove_vq_common(vi);
unregister_netdev(vi->dev);
remove_vq_common(vi);
- flush_work(&vi->config_work);
-
free_percpu(vi->stats);
free_netdev(vi->dev);
}
free_percpu(vi->stats);
free_netdev(vi->dev);
}
@@
-1903,10
+1891,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 */
- mutex_lock(&vi->config_lock);
- vi->config_enable = false;
- mutex_unlock(&vi->config_lock);
+ /* Make sure no work handler is accessing the device */
+ flush_work(&vi->config_work);
netif_device_detach(vi->dev);
cancel_delayed_work_sync(&vi->refill);
netif_device_detach(vi->dev);
cancel_delayed_work_sync(&vi->refill);
@@
-1921,8
+1907,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;
}
@@
-1935,6
+1919,8
@@
static int virtnet_restore(struct virtio_device *vdev)
if (err)
return err;
if (err)
return err;
+ virtio_device_ready(vdev);
+
if (netif_running(vi->dev)) {
for (i = 0; i < vi->curr_queue_pairs; i++)
if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
if (netif_running(vi->dev)) {
for (i = 0; i < vi->curr_queue_pairs; i++)
if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
@@
-1946,10
+1932,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();
virtnet_set_queues(vi, vi->curr_queue_pairs);
rtnl_unlock();
rtnl_lock();
virtnet_set_queues(vi, vi->curr_queue_pairs);
rtnl_unlock();