Skip to content

Commit ab1b2ab

Browse files
committed
Revert "PCI: hv: Fix a timing issue which causes kdump to fail occasionally"
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2182619 commit a847234 Author: Dexuan Cui <decui@microsoft.com> Date: Wed Jun 14 21:44:50 2023 -0700 Revert "PCI: hv: Fix a timing issue which causes kdump to fail occasionally" This reverts commit d6af2ed. The statement "the hv_pci_bus_exit() call releases structures of all its child devices" in commit d6af2ed is not true: in the path hv_pci_probe() -> hv_pci_enter_d0() -> hv_pci_bus_exit(hdev, true): the parameter "keep_devs" is true, so hv_pci_bus_exit() does *not* release the child "struct hv_pci_dev *hpdev" that is created earlier in pci_devices_present_work() -> new_pcichild_device(). The commit d6af2ed was originally made in July 2020 for RHEL 7.7, where the old version of hv_pci_bus_exit() was used; when the commit was rebased and merged into the upstream, people didn't notice that it's not really necessary. The commit itself doesn't cause any issue, but it makes hv_pci_probe() more complicated. Revert it to facilitate some upcoming changes to hv_pci_probe(). Signed-off-by: Dexuan Cui <decui@microsoft.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Acked-by: Wei Hu <weh@microsoft.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20230615044451.5580-5-decui@microsoft.com Signed-off-by: Wei Liu <wei.liu@kernel.org> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
1 parent 5776f14 commit ab1b2ab

File tree

1 file changed

+34
-37
lines changed

1 file changed

+34
-37
lines changed

drivers/pci/controller/pci-hyperv.c

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3225,8 +3225,10 @@ static int hv_pci_enter_d0(struct hv_device *hdev)
32253225
struct pci_bus_d0_entry *d0_entry;
32263226
struct hv_pci_compl comp_pkt;
32273227
struct pci_packet *pkt;
3228+
bool retry = true;
32283229
int ret;
32293230

3231+
enter_d0_retry:
32303232
/*
32313233
* Tell the host that the bus is ready to use, and moved into the
32323234
* powered-on state. This includes telling the host which region
@@ -3253,6 +3255,38 @@ static int hv_pci_enter_d0(struct hv_device *hdev)
32533255
if (ret)
32543256
goto exit;
32553257

3258+
/*
3259+
* In certain case (Kdump) the pci device of interest was
3260+
* not cleanly shut down and resource is still held on host
3261+
* side, the host could return invalid device status.
3262+
* We need to explicitly request host to release the resource
3263+
* and try to enter D0 again.
3264+
*/
3265+
if (comp_pkt.completion_status < 0 && retry) {
3266+
retry = false;
3267+
3268+
dev_err(&hdev->device, "Retrying D0 Entry\n");
3269+
3270+
/*
3271+
* Hv_pci_bus_exit() calls hv_send_resource_released()
3272+
* to free up resources of its child devices.
3273+
* In the kdump kernel we need to set the
3274+
* wslot_res_allocated to 255 so it scans all child
3275+
* devices to release resources allocated in the
3276+
* normal kernel before panic happened.
3277+
*/
3278+
hbus->wslot_res_allocated = 255;
3279+
3280+
ret = hv_pci_bus_exit(hdev, true);
3281+
3282+
if (ret == 0) {
3283+
kfree(pkt);
3284+
goto enter_d0_retry;
3285+
}
3286+
dev_err(&hdev->device,
3287+
"Retrying D0 failed with ret %d\n", ret);
3288+
}
3289+
32563290
if (comp_pkt.completion_status < 0) {
32573291
dev_err(&hdev->device,
32583292
"PCI Pass-through VSP failed D0 Entry with status %x\n",
@@ -3498,7 +3532,6 @@ static int hv_pci_probe(struct hv_device *hdev,
34983532
struct hv_pcibus_device *hbus;
34993533
u16 dom_req, dom;
35003534
char *name;
3501-
bool enter_d0_retry = true;
35023535
int ret;
35033536

35043537
/*
@@ -3638,47 +3671,11 @@ static int hv_pci_probe(struct hv_device *hdev,
36383671
if (ret)
36393672
goto free_fwnode;
36403673

3641-
retry:
36423674
ret = hv_pci_query_relations(hdev);
36433675
if (ret)
36443676
goto free_irq_domain;
36453677

36463678
ret = hv_pci_enter_d0(hdev);
3647-
/*
3648-
* In certain case (Kdump) the pci device of interest was
3649-
* not cleanly shut down and resource is still held on host
3650-
* side, the host could return invalid device status.
3651-
* We need to explicitly request host to release the resource
3652-
* and try to enter D0 again.
3653-
* Since the hv_pci_bus_exit() call releases structures
3654-
* of all its child devices, we need to start the retry from
3655-
* hv_pci_query_relations() call, requesting host to send
3656-
* the synchronous child device relations message before this
3657-
* information is needed in hv_send_resources_allocated()
3658-
* call later.
3659-
*/
3660-
if (ret == -EPROTO && enter_d0_retry) {
3661-
enter_d0_retry = false;
3662-
3663-
dev_err(&hdev->device, "Retrying D0 Entry\n");
3664-
3665-
/*
3666-
* Hv_pci_bus_exit() calls hv_send_resources_released()
3667-
* to free up resources of its child devices.
3668-
* In the kdump kernel we need to set the
3669-
* wslot_res_allocated to 255 so it scans all child
3670-
* devices to release resources allocated in the
3671-
* normal kernel before panic happened.
3672-
*/
3673-
hbus->wslot_res_allocated = 255;
3674-
ret = hv_pci_bus_exit(hdev, true);
3675-
3676-
if (ret == 0)
3677-
goto retry;
3678-
3679-
dev_err(&hdev->device,
3680-
"Retrying D0 failed with ret %d\n", ret);
3681-
}
36823679
if (ret)
36833680
goto free_irq_domain;
36843681

0 commit comments

Comments
 (0)