Skip to content

Commit 98f5c57

Browse files
committed
Merge branch 'remotes/lorenzo/pci/hv'
- Fix hv timing issue that causes kdump failures (Wei Hu) - Make some hv functions static (Wei Yongjun) * remotes/lorenzo/pci/hv: PCI: hv: Make some functions static PCI: hv: Fix a timing issue which causes kdump to fail occasionally
2 parents 2641802 + a459d9e commit 98f5c57

File tree

1 file changed

+45
-41
lines changed

1 file changed

+45
-41
lines changed

drivers/pci/controller/pci-hyperv.c

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,9 @@ static void hv_pci_read_config_compl(void *context, struct pci_response *resp,
938938
*
939939
* Return: 0 on success, -errno on failure
940940
*/
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)
943944
{
944945
struct hv_pcibus_device *hbus =
945946
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,
10181019
*
10191020
* Return: 0 on success, -errno on failure
10201021
*/
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)
10231024
{
10241025
struct hv_pcibus_device *hbus =
10251026
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,
10871088
*
10881089
* Return: 0 on success, -errno on failure
10891090
*/
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))
10931094
{
10941095
struct hv_pcibus_device *hbus =
10951096
container_of(pdev->bus->sysdata, struct hv_pcibus_device,
@@ -2759,10 +2760,8 @@ static int hv_pci_enter_d0(struct hv_device *hdev)
27592760
struct pci_bus_d0_entry *d0_entry;
27602761
struct hv_pci_compl comp_pkt;
27612762
struct pci_packet *pkt;
2762-
bool retry = true;
27632763
int ret;
27642764

2765-
enter_d0_retry:
27662765
/*
27672766
* Tell the host that the bus is ready to use, and moved into the
27682767
* powered-on state. This includes telling the host which region
@@ -2789,38 +2788,6 @@ static int hv_pci_enter_d0(struct hv_device *hdev)
27892788
if (ret)
27902789
goto exit;
27912790

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-
28242791
if (comp_pkt.completion_status < 0) {
28252792
dev_err(&hdev->device,
28262793
"PCI Pass-through VSP failed D0 Entry with status %x\n",
@@ -3058,6 +3025,7 @@ static int hv_pci_probe(struct hv_device *hdev,
30583025
struct hv_pcibus_device *hbus;
30593026
u16 dom_req, dom;
30603027
char *name;
3028+
bool enter_d0_retry = true;
30613029
int ret;
30623030

30633031
/*
@@ -3178,11 +3146,47 @@ static int hv_pci_probe(struct hv_device *hdev,
31783146
if (ret)
31793147
goto free_fwnode;
31803148

3149+
retry:
31813150
ret = hv_pci_query_relations(hdev);
31823151
if (ret)
31833152
goto free_irq_domain;
31843153

31853154
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+
}
31863190
if (ret)
31873191
goto free_irq_domain;
31883192

0 commit comments

Comments
 (0)