@@ -90,6 +90,11 @@ static void free_netvsc_device(struct rcu_head *head)
90
90
= container_of (head , struct netvsc_device , rcu );
91
91
int i ;
92
92
93
+ kfree (nvdev -> extension );
94
+ vfree (nvdev -> recv_buf );
95
+ vfree (nvdev -> send_buf );
96
+ kfree (nvdev -> send_section_map );
97
+
93
98
for (i = 0 ; i < VRSS_CHANNEL_MAX ; i ++ )
94
99
vfree (nvdev -> chan_table [i ].mrc .slots );
95
100
@@ -211,12 +216,6 @@ static void netvsc_teardown_gpadl(struct hv_device *device,
211
216
net_device -> recv_buf_gpadl_handle = 0 ;
212
217
}
213
218
214
- if (net_device -> recv_buf ) {
215
- /* Free up the receive buffer */
216
- vfree (net_device -> recv_buf );
217
- net_device -> recv_buf = NULL ;
218
- }
219
-
220
219
if (net_device -> send_buf_gpadl_handle ) {
221
220
ret = vmbus_teardown_gpadl (device -> channel ,
222
221
net_device -> send_buf_gpadl_handle );
@@ -231,12 +230,6 @@ static void netvsc_teardown_gpadl(struct hv_device *device,
231
230
}
232
231
net_device -> send_buf_gpadl_handle = 0 ;
233
232
}
234
- if (net_device -> send_buf ) {
235
- /* Free up the send buffer */
236
- vfree (net_device -> send_buf );
237
- net_device -> send_buf = NULL ;
238
- }
239
- kfree (net_device -> send_section_map );
240
233
}
241
234
242
235
int netvsc_alloc_recv_comp_ring (struct netvsc_device * net_device , u32 q_idx )
@@ -562,26 +555,29 @@ void netvsc_device_remove(struct hv_device *device)
562
555
= rtnl_dereference (net_device_ctx -> nvdev );
563
556
int i ;
564
557
565
- cancel_work_sync (& net_device -> subchan_work );
566
-
567
558
netvsc_revoke_buf (device , net_device );
568
559
569
560
RCU_INIT_POINTER (net_device_ctx -> nvdev , NULL );
570
561
562
+ /* And disassociate NAPI context from device */
563
+ for (i = 0 ; i < net_device -> num_chn ; i ++ )
564
+ netif_napi_del (& net_device -> chan_table [i ].napi );
565
+
571
566
/*
572
567
* At this point, no one should be accessing net_device
573
568
* except in here
574
569
*/
575
570
netdev_dbg (ndev , "net device safe to remove\n" );
576
571
572
+ /* older versions require that buffer be revoked before close */
573
+ if (net_device -> nvsp_version < NVSP_PROTOCOL_VERSION_4 )
574
+ netvsc_teardown_gpadl (device , net_device );
575
+
577
576
/* Now, we can close the channel safely */
578
577
vmbus_close (device -> channel );
579
578
580
- netvsc_teardown_gpadl (device , net_device );
581
-
582
- /* And dissassociate NAPI context from device */
583
- for (i = 0 ; i < net_device -> num_chn ; i ++ )
584
- netif_napi_del (& net_device -> chan_table [i ].napi );
579
+ if (net_device -> nvsp_version >= NVSP_PROTOCOL_VERSION_4 )
580
+ netvsc_teardown_gpadl (device , net_device );
585
581
586
582
/* Release all resources */
587
583
free_netvsc_device_rcu (net_device );
@@ -645,14 +641,18 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device,
645
641
queue_sends =
646
642
atomic_dec_return (& net_device -> chan_table [q_idx ].queue_sends );
647
643
648
- if (net_device -> destroy && queue_sends == 0 )
649
- wake_up (& net_device -> wait_drain );
644
+ if (unlikely (net_device -> destroy )) {
645
+ if (queue_sends == 0 )
646
+ wake_up (& net_device -> wait_drain );
647
+ } else {
648
+ struct netdev_queue * txq = netdev_get_tx_queue (ndev , q_idx );
650
649
651
- if (netif_tx_queue_stopped (netdev_get_tx_queue (ndev , q_idx )) &&
652
- (hv_ringbuf_avail_percent (& channel -> outbound ) > RING_AVAIL_PERCENT_HIWATER ||
653
- queue_sends < 1 )) {
654
- netif_tx_wake_queue (netdev_get_tx_queue (ndev , q_idx ));
655
- ndev_ctx -> eth_stats .wake_queue ++ ;
650
+ if (netif_tx_queue_stopped (txq ) &&
651
+ (hv_ringbuf_avail_percent (& channel -> outbound ) > RING_AVAIL_PERCENT_HIWATER ||
652
+ queue_sends < 1 )) {
653
+ netif_tx_wake_queue (txq );
654
+ ndev_ctx -> eth_stats .wake_queue ++ ;
655
+ }
656
656
}
657
657
}
658
658
0 commit comments