@@ -503,6 +503,7 @@ struct virtio_net_common_hdr {
503503static struct virtio_net_common_hdr xsk_hdr ;
504504
505505static void virtnet_sq_free_unused_buf (struct virtqueue * vq , void * buf );
506+ static void virtnet_sq_free_unused_buf_done (struct virtqueue * vq );
506507static int virtnet_xdp_handler (struct bpf_prog * xdp_prog , struct xdp_buff * xdp ,
507508 struct net_device * dev ,
508509 unsigned int * xdp_xmit ,
@@ -3054,7 +3055,6 @@ static int virtnet_enable_queue_pair(struct virtnet_info *vi, int qp_index)
30543055 if (err < 0 )
30553056 goto err_xdp_reg_mem_model ;
30563057
3057- netdev_tx_reset_queue (netdev_get_tx_queue (vi -> dev , qp_index ));
30583058 virtnet_napi_enable (vi -> rq [qp_index ].vq , & vi -> rq [qp_index ].napi );
30593059 virtnet_napi_tx_enable (vi , vi -> sq [qp_index ].vq , & vi -> sq [qp_index ].napi );
30603060
@@ -3332,7 +3332,7 @@ static int virtnet_rx_resize(struct virtnet_info *vi,
33323332
33333333 virtnet_rx_pause (vi , rq );
33343334
3335- err = virtqueue_resize (rq -> vq , ring_num , virtnet_rq_unmap_free_buf );
3335+ err = virtqueue_resize (rq -> vq , ring_num , virtnet_rq_unmap_free_buf , NULL );
33363336 if (err )
33373337 netdev_err (vi -> dev , "resize rx fail: rx queue index: %d err: %d\n" , qindex , err );
33383338
@@ -3395,7 +3395,8 @@ static int virtnet_tx_resize(struct virtnet_info *vi, struct send_queue *sq,
33953395
33963396 virtnet_tx_pause (vi , sq );
33973397
3398- err = virtqueue_resize (sq -> vq , ring_num , virtnet_sq_free_unused_buf );
3398+ err = virtqueue_resize (sq -> vq , ring_num , virtnet_sq_free_unused_buf ,
3399+ virtnet_sq_free_unused_buf_done );
33993400 if (err )
34003401 netdev_err (vi -> dev , "resize tx fail: tx queue index: %d err: %d\n" , qindex , err );
34013402
@@ -5710,7 +5711,7 @@ static int virtnet_rq_bind_xsk_pool(struct virtnet_info *vi, struct receive_queu
57105711
57115712 virtnet_rx_pause (vi , rq );
57125713
5713- err = virtqueue_reset (rq -> vq , virtnet_rq_unmap_free_buf );
5714+ err = virtqueue_reset (rq -> vq , virtnet_rq_unmap_free_buf , NULL );
57145715 if (err ) {
57155716 netdev_err (vi -> dev , "reset rx fail: rx queue index: %d err: %d\n" , qindex , err );
57165717
@@ -5739,7 +5740,8 @@ static int virtnet_sq_bind_xsk_pool(struct virtnet_info *vi,
57395740
57405741 virtnet_tx_pause (vi , sq );
57415742
5742- err = virtqueue_reset (sq -> vq , virtnet_sq_free_unused_buf );
5743+ err = virtqueue_reset (sq -> vq , virtnet_sq_free_unused_buf ,
5744+ virtnet_sq_free_unused_buf_done );
57435745 if (err ) {
57445746 netdev_err (vi -> dev , "reset tx fail: tx queue index: %d err: %d\n" , qindex , err );
57455747 pool = NULL ;
@@ -6214,7 +6216,7 @@ static void virtnet_sq_free_unused_buf(struct virtqueue *vq, void *buf)
62146216{
62156217 struct virtnet_info * vi = vq -> vdev -> priv ;
62166218 struct send_queue * sq ;
6217- int i = vq2rxq (vq );
6219+ int i = vq2txq (vq );
62186220
62196221 sq = & vi -> sq [i ];
62206222
@@ -6234,6 +6236,14 @@ static void virtnet_sq_free_unused_buf(struct virtqueue *vq, void *buf)
62346236 }
62356237}
62366238
6239+ static void virtnet_sq_free_unused_buf_done (struct virtqueue * vq )
6240+ {
6241+ struct virtnet_info * vi = vq -> vdev -> priv ;
6242+ int i = vq2txq (vq );
6243+
6244+ netdev_tx_reset_queue (netdev_get_tx_queue (vi -> dev , i ));
6245+ }
6246+
62376247static void free_unused_bufs (struct virtnet_info * vi )
62386248{
62396249 void * buf ;
@@ -6966,11 +6976,20 @@ static int virtnet_probe(struct virtio_device *vdev)
69666976
69676977static void remove_vq_common (struct virtnet_info * vi )
69686978{
6979+ int i ;
6980+
69696981 virtio_reset_device (vi -> vdev );
69706982
69716983 /* Free unused buffers in both send and recv, if any. */
69726984 free_unused_bufs (vi );
69736985
6986+ /*
6987+ * Rule of thumb is netdev_tx_reset_queue() should follow any
6988+ * skb freeing not followed by netdev_tx_completed_queue()
6989+ */
6990+ for (i = 0 ; i < vi -> max_queue_pairs ; i ++ )
6991+ netdev_tx_reset_queue (netdev_get_tx_queue (vi -> dev , i ));
6992+
69746993 free_receive_bufs (vi );
69756994
69766995 free_receive_page_frags (vi );
0 commit comments