@@ -2379,7 +2379,9 @@ static void hv_pci_onchannelcallback(void *context)
2379
2379
* failing if the host doesn't support the necessary protocol
2380
2380
* level.
2381
2381
*/
2382
- static int hv_pci_protocol_negotiation (struct hv_device * hdev )
2382
+ static int hv_pci_protocol_negotiation (struct hv_device * hdev ,
2383
+ enum pci_protocol_version_t version [],
2384
+ int num_version )
2383
2385
{
2384
2386
struct pci_version_request * version_req ;
2385
2387
struct hv_pci_compl comp_pkt ;
@@ -2403,8 +2405,8 @@ static int hv_pci_protocol_negotiation(struct hv_device *hdev)
2403
2405
version_req = (struct pci_version_request * )& pkt -> message ;
2404
2406
version_req -> message_type .type = PCI_QUERY_PROTOCOL_VERSION ;
2405
2407
2406
- for (i = 0 ; i < ARRAY_SIZE ( pci_protocol_versions ) ; i ++ ) {
2407
- version_req -> protocol_version = pci_protocol_versions [i ];
2408
+ for (i = 0 ; i < num_version ; i ++ ) {
2409
+ version_req -> protocol_version = version [i ];
2408
2410
ret = vmbus_sendpacket (hdev -> channel , version_req ,
2409
2411
sizeof (struct pci_version_request ),
2410
2412
(unsigned long )pkt , VM_PKT_DATA_INBAND ,
@@ -2420,7 +2422,7 @@ static int hv_pci_protocol_negotiation(struct hv_device *hdev)
2420
2422
}
2421
2423
2422
2424
if (comp_pkt .completion_status >= 0 ) {
2423
- pci_protocol_version = pci_protocol_versions [i ];
2425
+ pci_protocol_version = version [i ];
2424
2426
dev_info (& hdev -> device ,
2425
2427
"PCI VMBus probing: Using version %#x\n" ,
2426
2428
pci_protocol_version );
@@ -2930,7 +2932,8 @@ static int hv_pci_probe(struct hv_device *hdev,
2930
2932
2931
2933
hv_set_drvdata (hdev , hbus );
2932
2934
2933
- ret = hv_pci_protocol_negotiation (hdev );
2935
+ ret = hv_pci_protocol_negotiation (hdev , pci_protocol_versions ,
2936
+ ARRAY_SIZE (pci_protocol_versions ));
2934
2937
if (ret )
2935
2938
goto close ;
2936
2939
@@ -3011,7 +3014,7 @@ static int hv_pci_probe(struct hv_device *hdev,
3011
3014
return ret ;
3012
3015
}
3013
3016
3014
- static void hv_pci_bus_exit (struct hv_device * hdev )
3017
+ static int hv_pci_bus_exit (struct hv_device * hdev , bool hibernating )
3015
3018
{
3016
3019
struct hv_pcibus_device * hbus = hv_get_drvdata (hdev );
3017
3020
struct {
@@ -3027,16 +3030,20 @@ static void hv_pci_bus_exit(struct hv_device *hdev)
3027
3030
* access the per-channel ringbuffer any longer.
3028
3031
*/
3029
3032
if (hdev -> channel -> rescind )
3030
- return ;
3033
+ return 0 ;
3031
3034
3032
- /* Delete any children which might still exist. */
3033
- memset (& relations , 0 , sizeof (relations ));
3034
- hv_pci_devices_present (hbus , & relations );
3035
+ if (!hibernating ) {
3036
+ /* Delete any children which might still exist. */
3037
+ memset (& relations , 0 , sizeof (relations ));
3038
+ hv_pci_devices_present (hbus , & relations );
3039
+ }
3035
3040
3036
3041
ret = hv_send_resources_released (hdev );
3037
- if (ret )
3042
+ if (ret ) {
3038
3043
dev_err (& hdev -> device ,
3039
3044
"Couldn't send resources released packet(s)\n" );
3045
+ return ret ;
3046
+ }
3040
3047
3041
3048
memset (& pkt .teardown_packet , 0 , sizeof (pkt .teardown_packet ));
3042
3049
init_completion (& comp_pkt .host_event );
@@ -3049,8 +3056,13 @@ static void hv_pci_bus_exit(struct hv_device *hdev)
3049
3056
(unsigned long )& pkt .teardown_packet ,
3050
3057
VM_PKT_DATA_INBAND ,
3051
3058
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED );
3052
- if (!ret )
3053
- wait_for_completion_timeout (& comp_pkt .host_event , 10 * HZ );
3059
+ if (ret )
3060
+ return ret ;
3061
+
3062
+ if (wait_for_completion_timeout (& comp_pkt .host_event , 10 * HZ ) == 0 )
3063
+ return - ETIMEDOUT ;
3064
+
3065
+ return 0 ;
3054
3066
}
3055
3067
3056
3068
/**
@@ -3062,6 +3074,7 @@ static void hv_pci_bus_exit(struct hv_device *hdev)
3062
3074
static int hv_pci_remove (struct hv_device * hdev )
3063
3075
{
3064
3076
struct hv_pcibus_device * hbus ;
3077
+ int ret ;
3065
3078
3066
3079
hbus = hv_get_drvdata (hdev );
3067
3080
if (hbus -> state == hv_pcibus_installed ) {
@@ -3074,7 +3087,7 @@ static int hv_pci_remove(struct hv_device *hdev)
3074
3087
hbus -> state = hv_pcibus_removed ;
3075
3088
}
3076
3089
3077
- hv_pci_bus_exit (hdev );
3090
+ ret = hv_pci_bus_exit (hdev , false );
3078
3091
3079
3092
vmbus_close (hdev -> channel );
3080
3093
@@ -3091,7 +3104,7 @@ static int hv_pci_remove(struct hv_device *hdev)
3091
3104
hv_put_dom_num (hbus -> sysdata .domain );
3092
3105
3093
3106
free_page ((unsigned long )hbus );
3094
- return 0 ;
3107
+ return ret ;
3095
3108
}
3096
3109
3097
3110
static const struct hv_vmbus_device_id hv_pci_id_table [] = {
0 commit comments