@@ -938,8 +938,9 @@ static void hv_pci_read_config_compl(void *context, struct pci_response *resp,
938
938
*
939
939
* Return: 0 on success, -errno on failure
940
940
*/
941
- int hv_read_config_block (struct pci_dev * pdev , void * buf , unsigned int len ,
942
- unsigned int block_id , unsigned int * bytes_returned )
941
+ static int hv_read_config_block (struct pci_dev * pdev , void * buf ,
942
+ unsigned int len , unsigned int block_id ,
943
+ unsigned int * bytes_returned )
943
944
{
944
945
struct hv_pcibus_device * hbus =
945
946
container_of (pdev -> bus -> sysdata , struct hv_pcibus_device ,
@@ -1018,8 +1019,8 @@ static void hv_pci_write_config_compl(void *context, struct pci_response *resp,
1018
1019
*
1019
1020
* Return: 0 on success, -errno on failure
1020
1021
*/
1021
- int hv_write_config_block (struct pci_dev * pdev , void * buf , unsigned int len ,
1022
- unsigned int block_id )
1022
+ static int hv_write_config_block (struct pci_dev * pdev , void * buf ,
1023
+ unsigned int len , unsigned int block_id )
1023
1024
{
1024
1025
struct hv_pcibus_device * hbus =
1025
1026
container_of (pdev -> bus -> sysdata , struct hv_pcibus_device ,
@@ -1087,9 +1088,9 @@ int hv_write_config_block(struct pci_dev *pdev, void *buf, unsigned int len,
1087
1088
*
1088
1089
* Return: 0 on success, -errno on failure
1089
1090
*/
1090
- int hv_register_block_invalidate (struct pci_dev * pdev , void * context ,
1091
- void (* block_invalidate )(void * context ,
1092
- u64 block_mask ))
1091
+ static int hv_register_block_invalidate (struct pci_dev * pdev , void * context ,
1092
+ void (* block_invalidate )(void * context ,
1093
+ u64 block_mask ))
1093
1094
{
1094
1095
struct hv_pcibus_device * hbus =
1095
1096
container_of (pdev -> bus -> sysdata , struct hv_pcibus_device ,
@@ -2759,10 +2760,8 @@ static int hv_pci_enter_d0(struct hv_device *hdev)
2759
2760
struct pci_bus_d0_entry * d0_entry ;
2760
2761
struct hv_pci_compl comp_pkt ;
2761
2762
struct pci_packet * pkt ;
2762
- bool retry = true;
2763
2763
int ret ;
2764
2764
2765
- enter_d0_retry :
2766
2765
/*
2767
2766
* Tell the host that the bus is ready to use, and moved into the
2768
2767
* powered-on state. This includes telling the host which region
@@ -2789,38 +2788,6 @@ static int hv_pci_enter_d0(struct hv_device *hdev)
2789
2788
if (ret )
2790
2789
goto exit ;
2791
2790
2792
- /*
2793
- * In certain case (Kdump) the pci device of interest was
2794
- * not cleanly shut down and resource is still held on host
2795
- * side, the host could return invalid device status.
2796
- * We need to explicitly request host to release the resource
2797
- * and try to enter D0 again.
2798
- */
2799
- if (comp_pkt .completion_status < 0 && retry ) {
2800
- retry = false;
2801
-
2802
- dev_err (& hdev -> device , "Retrying D0 Entry\n" );
2803
-
2804
- /*
2805
- * Hv_pci_bus_exit() calls hv_send_resource_released()
2806
- * to free up resources of its child devices.
2807
- * In the kdump kernel we need to set the
2808
- * wslot_res_allocated to 255 so it scans all child
2809
- * devices to release resources allocated in the
2810
- * normal kernel before panic happened.
2811
- */
2812
- hbus -> wslot_res_allocated = 255 ;
2813
-
2814
- ret = hv_pci_bus_exit (hdev , true);
2815
-
2816
- if (ret == 0 ) {
2817
- kfree (pkt );
2818
- goto enter_d0_retry ;
2819
- }
2820
- dev_err (& hdev -> device ,
2821
- "Retrying D0 failed with ret %d\n" , ret );
2822
- }
2823
-
2824
2791
if (comp_pkt .completion_status < 0 ) {
2825
2792
dev_err (& hdev -> device ,
2826
2793
"PCI Pass-through VSP failed D0 Entry with status %x\n" ,
@@ -3058,6 +3025,7 @@ static int hv_pci_probe(struct hv_device *hdev,
3058
3025
struct hv_pcibus_device * hbus ;
3059
3026
u16 dom_req , dom ;
3060
3027
char * name ;
3028
+ bool enter_d0_retry = true;
3061
3029
int ret ;
3062
3030
3063
3031
/*
@@ -3178,11 +3146,47 @@ static int hv_pci_probe(struct hv_device *hdev,
3178
3146
if (ret )
3179
3147
goto free_fwnode ;
3180
3148
3149
+ retry :
3181
3150
ret = hv_pci_query_relations (hdev );
3182
3151
if (ret )
3183
3152
goto free_irq_domain ;
3184
3153
3185
3154
ret = hv_pci_enter_d0 (hdev );
3155
+ /*
3156
+ * In certain case (Kdump) the pci device of interest was
3157
+ * not cleanly shut down and resource is still held on host
3158
+ * side, the host could return invalid device status.
3159
+ * We need to explicitly request host to release the resource
3160
+ * and try to enter D0 again.
3161
+ * Since the hv_pci_bus_exit() call releases structures
3162
+ * of all its child devices, we need to start the retry from
3163
+ * hv_pci_query_relations() call, requesting host to send
3164
+ * the synchronous child device relations message before this
3165
+ * information is needed in hv_send_resources_allocated()
3166
+ * call later.
3167
+ */
3168
+ if (ret == - EPROTO && enter_d0_retry ) {
3169
+ enter_d0_retry = false;
3170
+
3171
+ dev_err (& hdev -> device , "Retrying D0 Entry\n" );
3172
+
3173
+ /*
3174
+ * Hv_pci_bus_exit() calls hv_send_resources_released()
3175
+ * to free up resources of its child devices.
3176
+ * In the kdump kernel we need to set the
3177
+ * wslot_res_allocated to 255 so it scans all child
3178
+ * devices to release resources allocated in the
3179
+ * normal kernel before panic happened.
3180
+ */
3181
+ hbus -> wslot_res_allocated = 255 ;
3182
+ ret = hv_pci_bus_exit (hdev , true);
3183
+
3184
+ if (ret == 0 )
3185
+ goto retry ;
3186
+
3187
+ dev_err (& hdev -> device ,
3188
+ "Retrying D0 failed with ret %d\n" , ret );
3189
+ }
3186
3190
if (ret )
3187
3191
goto free_irq_domain ;
3188
3192
0 commit comments