@@ -100,12 +100,11 @@ static void free_netvsc_device_rcu(struct netvsc_device *nvdev)
100
100
call_rcu (& nvdev -> rcu , free_netvsc_device );
101
101
}
102
102
103
- static void netvsc_destroy_buf (struct hv_device * device )
103
+ static void netvsc_revoke_buf (struct hv_device * device ,
104
+ struct netvsc_device * net_device )
104
105
{
105
106
struct nvsp_message * revoke_packet ;
106
107
struct net_device * ndev = hv_get_drvdata (device );
107
- struct net_device_context * ndc = netdev_priv (ndev );
108
- struct netvsc_device * net_device = rtnl_dereference (ndc -> nvdev );
109
108
int ret ;
110
109
111
110
/*
@@ -148,28 +147,6 @@ static void netvsc_destroy_buf(struct hv_device *device)
148
147
net_device -> recv_section_cnt = 0 ;
149
148
}
150
149
151
- /* Teardown the gpadl on the vsp end */
152
- if (net_device -> recv_buf_gpadl_handle ) {
153
- ret = vmbus_teardown_gpadl (device -> channel ,
154
- net_device -> recv_buf_gpadl_handle );
155
-
156
- /* If we failed here, we might as well return and have a leak
157
- * rather than continue and a bugchk
158
- */
159
- if (ret != 0 ) {
160
- netdev_err (ndev ,
161
- "unable to teardown receive buffer's gpadl\n" );
162
- return ;
163
- }
164
- net_device -> recv_buf_gpadl_handle = 0 ;
165
- }
166
-
167
- if (net_device -> recv_buf ) {
168
- /* Free up the receive buffer */
169
- vfree (net_device -> recv_buf );
170
- net_device -> recv_buf = NULL ;
171
- }
172
-
173
150
/* Deal with the send buffer we may have setup.
174
151
* If we got a send section size, it means we received a
175
152
* NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE msg (ie sent
@@ -210,7 +187,35 @@ static void netvsc_destroy_buf(struct hv_device *device)
210
187
}
211
188
net_device -> send_section_cnt = 0 ;
212
189
}
213
- /* Teardown the gpadl on the vsp end */
190
+ }
191
+
192
+ static void netvsc_teardown_gpadl (struct hv_device * device ,
193
+ struct netvsc_device * net_device )
194
+ {
195
+ struct net_device * ndev = hv_get_drvdata (device );
196
+ int ret ;
197
+
198
+ if (net_device -> recv_buf_gpadl_handle ) {
199
+ ret = vmbus_teardown_gpadl (device -> channel ,
200
+ net_device -> recv_buf_gpadl_handle );
201
+
202
+ /* If we failed here, we might as well return and have a leak
203
+ * rather than continue and a bugchk
204
+ */
205
+ if (ret != 0 ) {
206
+ netdev_err (ndev ,
207
+ "unable to teardown receive buffer's gpadl\n" );
208
+ return ;
209
+ }
210
+ net_device -> recv_buf_gpadl_handle = 0 ;
211
+ }
212
+
213
+ if (net_device -> recv_buf ) {
214
+ /* Free up the receive buffer */
215
+ vfree (net_device -> recv_buf );
216
+ net_device -> recv_buf = NULL ;
217
+ }
218
+
214
219
if (net_device -> send_buf_gpadl_handle ) {
215
220
ret = vmbus_teardown_gpadl (device -> channel ,
216
221
net_device -> send_buf_gpadl_handle );
@@ -420,7 +425,8 @@ static int netvsc_init_buf(struct hv_device *device,
420
425
goto exit ;
421
426
422
427
cleanup :
423
- netvsc_destroy_buf (device );
428
+ netvsc_revoke_buf (device , net_device );
429
+ netvsc_teardown_gpadl (device , net_device );
424
430
425
431
exit :
426
432
return ret ;
@@ -539,11 +545,6 @@ static int netvsc_connect_vsp(struct hv_device *device,
539
545
return ret ;
540
546
}
541
547
542
- static void netvsc_disconnect_vsp (struct hv_device * device )
543
- {
544
- netvsc_destroy_buf (device );
545
- }
546
-
547
548
/*
548
549
* netvsc_device_remove - Callback when the root bus device is removed
549
550
*/
@@ -557,7 +558,7 @@ void netvsc_device_remove(struct hv_device *device)
557
558
558
559
cancel_work_sync (& net_device -> subchan_work );
559
560
560
- netvsc_disconnect_vsp (device );
561
+ netvsc_revoke_buf (device , net_device );
561
562
562
563
RCU_INIT_POINTER (net_device_ctx -> nvdev , NULL );
563
564
@@ -570,6 +571,8 @@ void netvsc_device_remove(struct hv_device *device)
570
571
/* Now, we can close the channel safely */
571
572
vmbus_close (device -> channel );
572
573
574
+ netvsc_teardown_gpadl (device , net_device );
575
+
573
576
/* And dissassociate NAPI context from device */
574
577
for (i = 0 ; i < net_device -> num_chn ; i ++ )
575
578
netif_napi_del (& net_device -> chan_table [i ].napi );
0 commit comments