* FAILED: patch "[PATCH] PCI: hv: Add pci_destroy_slot() in" failed to apply to 4.14-stable tree
@ 2019-05-15 8:35 gregkh
2019-05-15 23:20 ` Dexuan Cui
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2019-05-15 8:35 UTC (permalink / raw)
To: decui, lorenzo.pieralisi, mikelley, stephen; +Cc: stable
The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 340d455699400f2c2c0f9b3f703ade3085cdb501 Mon Sep 17 00:00:00 2001
From: Dexuan Cui <decui@microsoft.com>
Date: Mon, 4 Mar 2019 21:34:49 +0000
Subject: [PATCH] PCI: hv: Add pci_destroy_slot() in
pci_devices_present_work(), if necessary
When we hot-remove a device, usually the host sends us a PCI_EJECT message,
and a PCI_BUS_RELATIONS message with bus_rel->device_count == 0.
When we execute the quick hot-add/hot-remove test, the host may not send
us the PCI_EJECT message if the guest has not fully finished the
initialization by sending the PCI_RESOURCES_ASSIGNED* message to the
host, so it's potentially unsafe to only depend on the
pci_destroy_slot() in hv_eject_device_work() because the code path
create_root_hv_pci_bus()
-> hv_pci_assign_slots()
is not called in this case. Note: in this case, the host still sends the
guest a PCI_BUS_RELATIONS message with bus_rel->device_count == 0.
In the quick hot-add/hot-remove test, we can have such a race before
the code path
pci_devices_present_work()
-> new_pcichild_device()
adds the new device into the hbus->children list, we may have already
received the PCI_EJECT message, and since the tasklet handler
hv_pci_onchannelcallback()
may fail to find the "hpdev" by calling
get_pcichild_wslot(hbus, dev_message->wslot.slot)
hv_pci_eject_device() is not called; Later, by continuing execution
create_root_hv_pci_bus()
-> hv_pci_assign_slots()
creates the slot and the PCI_BUS_RELATIONS message with
bus_rel->device_count == 0 removes the device from hbus->children, and
we end up being unable to remove the slot in
hv_pci_remove()
-> hv_pci_remove_slots()
Remove the slot in pci_devices_present_work() when the device
is removed to address this race.
pci_devices_present_work() and hv_eject_device_work() run in the
singled-threaded hbus->wq, so there is not a double-remove issue for the
slot.
We cannot offload hv_pci_eject_device() from hv_pci_onchannelcallback()
to the workqueue, because we need the hv_pci_onchannelcallback()
synchronously call hv_pci_eject_device() to poll the channel
ringbuffer to work around the "hangs in hv_compose_msi_msg()" issue
fixed in commit de0aa7b2f97d ("PCI: hv: Fix 2 hang issues in
hv_compose_msi_msg()")
Fixes: a15f2c08c708 ("PCI: hv: support reporting serial number as slot information")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
[lorenzo.pieralisi@arm.com: rewritten commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Cc: stable@vger.kernel.org
diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index b489412e3502..82acd6155adf 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -1776,6 +1776,10 @@ static void pci_devices_present_work(struct work_struct *work)
hpdev = list_first_entry(&removed, struct hv_pci_dev,
list_entry);
list_del(&hpdev->list_entry);
+
+ if (hpdev->pci_slot)
+ pci_destroy_slot(hpdev->pci_slot);
+
put_pcichild(hpdev);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: FAILED: patch "[PATCH] PCI: hv: Add pci_destroy_slot() in" failed to apply to 4.14-stable tree
2019-05-15 8:35 FAILED: patch "[PATCH] PCI: hv: Add pci_destroy_slot() in" failed to apply to 4.14-stable tree gregkh
@ 2019-05-15 23:20 ` Dexuan Cui
2019-05-17 0:48 ` Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Dexuan Cui @ 2019-05-15 23:20 UTC (permalink / raw)
To: gregkh, lorenzo.pieralisi, Michael Kelley, stephen; +Cc: stable
[-- Attachment #1: Type: text/plain, Size: 4256 bytes --]
> From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> Sent: Wednesday, May 15, 2019 1:36 AM
> To: Dexuan Cui <decui@microsoft.com>; lorenzo.pieralisi@arm.com; Michael
> Kelley <mikelley@microsoft.com>; stephen@networkplumber.org
> Cc: stable@vger.kernel.org
> Subject: FAILED: patch "[PATCH] PCI: hv: Add pci_destroy_slot() in" failed to
> apply to 4.14-stable tree
>
>
> The patch below does not apply to the 4.14-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
>
> thanks,
>
> greg k-h
>
> ------------------ original commit in Linus's tree ------------------
>
> From 340d455699400f2c2c0f9b3f703ade3085cdb501 Mon Sep 17 00:00:00
> 2001
> From: Dexuan Cui <decui@microsoft.com>
> Date: Mon, 4 Mar 2019 21:34:49 +0000
> Subject: [PATCH] PCI: hv: Add pci_destroy_slot() in
> pci_devices_present_work(), if necessary
>
> When we hot-remove a device, usually the host sends us a PCI_EJECT message,
> and a PCI_BUS_RELATIONS message with bus_rel->device_count == 0.
>
> When we execute the quick hot-add/hot-remove test, the host may not send
> us the PCI_EJECT message if the guest has not fully finished the
> initialization by sending the PCI_RESOURCES_ASSIGNED* message to the
> host, so it's potentially unsafe to only depend on the
> pci_destroy_slot() in hv_eject_device_work() because the code path
>
> create_root_hv_pci_bus()
> -> hv_pci_assign_slots()
>
> is not called in this case. Note: in this case, the host still sends the
> guest a PCI_BUS_RELATIONS message with bus_rel->device_count == 0.
>
> In the quick hot-add/hot-remove test, we can have such a race before
> the code path
>
> pci_devices_present_work()
> -> new_pcichild_device()
>
> adds the new device into the hbus->children list, we may have already
> received the PCI_EJECT message, and since the tasklet handler
>
> hv_pci_onchannelcallback()
>
> may fail to find the "hpdev" by calling
>
> get_pcichild_wslot(hbus, dev_message->wslot.slot)
>
> hv_pci_eject_device() is not called; Later, by continuing execution
>
> create_root_hv_pci_bus()
> -> hv_pci_assign_slots()
>
> creates the slot and the PCI_BUS_RELATIONS message with
> bus_rel->device_count == 0 removes the device from hbus->children, and
> we end up being unable to remove the slot in
>
> hv_pci_remove()
> -> hv_pci_remove_slots()
>
> Remove the slot in pci_devices_present_work() when the device
> is removed to address this race.
>
> pci_devices_present_work() and hv_eject_device_work() run in the
> singled-threaded hbus->wq, so there is not a double-remove issue for the
> slot.
>
> We cannot offload hv_pci_eject_device() from hv_pci_onchannelcallback()
> to the workqueue, because we need the hv_pci_onchannelcallback()
> synchronously call hv_pci_eject_device() to poll the channel
> ringbuffer to work around the "hangs in hv_compose_msi_msg()" issue
> fixed in commit de0aa7b2f97d ("PCI: hv: Fix 2 hang issues in
> hv_compose_msi_msg()")
>
> Fixes: a15f2c08c708 ("PCI: hv: support reporting serial number as slot
> information")
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> [lorenzo.pieralisi@arm.com: rewritten commit log]
> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> Cc: stable@vger.kernel.org
>
> diff --git a/drivers/pci/controller/pci-hyperv.c
> b/drivers/pci/controller/pci-hyperv.c
> index b489412e3502..82acd6155adf 100644
> --- a/drivers/pci/controller/pci-hyperv.c
> +++ b/drivers/pci/controller/pci-hyperv.c
> @@ -1776,6 +1776,10 @@ static void pci_devices_present_work(struct
> work_struct *work)
> hpdev = list_first_entry(&removed, struct hv_pci_dev,
> list_entry);
> list_del(&hpdev->list_entry);
> +
> + if (hpdev->pci_slot)
> + pci_destroy_slot(hpdev->pci_slot);
> +
> put_pcichild(hpdev);
> }
>
Hi,
I backported the patch for linux-4.14.y.
Please use the attached patch, which is [PATCH 3/3]
Thanks,
-- Dexuan
[-- Attachment #2: For_v4.14.119-0003-PCI-hv-Add-pci_destroy_slot-in-pci_devices_present_w.patch --]
[-- Type: application/octet-stream, Size: 1053 bytes --]
From dec391546607e00c3c8d7d72ead9ff7f5966a932 Mon Sep 17 00:00:00 2001
From: Dexuan Cui <decui@microsoft.com>
Date: Wed, 15 May 2019 16:06:22 -0700
Subject: [PATCH for v4.14.119 3/3] PCI: hv: Add pci_destroy_slot() in
pci_devices_present_work(), if necessary
This patch is backported for v4.14.119 from the mainline
340d45569940 ("PCI: hv: Add pci_destroy_slot() in pci_devices_present_work(), if necessary")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
drivers/pci/host/pci-hyperv.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
index a5825bbcded7..f591de23f3d3 100644
--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -1824,6 +1824,10 @@ static void pci_devices_present_work(struct work_struct *work)
hpdev = list_first_entry(&removed, struct hv_pci_dev,
list_entry);
list_del(&hpdev->list_entry);
+
+ if (hpdev->pci_slot)
+ pci_destroy_slot(hpdev->pci_slot);
+
put_pcichild(hpdev, hv_pcidev_ref_initial);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] PCI: hv: Add pci_destroy_slot() in" failed to apply to 4.14-stable tree
2019-05-15 23:20 ` Dexuan Cui
@ 2019-05-17 0:48 ` Sasha Levin
0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2019-05-17 0:48 UTC (permalink / raw)
To: Dexuan Cui; +Cc: gregkh, lorenzo.pieralisi, Michael Kelley, stephen, stable
On Wed, May 15, 2019 at 11:20:45PM +0000, Dexuan Cui wrote:
>> From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
>> Sent: Wednesday, May 15, 2019 1:36 AM
>> To: Dexuan Cui <decui@microsoft.com>; lorenzo.pieralisi@arm.com; Michael
>> Kelley <mikelley@microsoft.com>; stephen@networkplumber.org
>> Cc: stable@vger.kernel.org
>> Subject: FAILED: patch "[PATCH] PCI: hv: Add pci_destroy_slot() in" failed to
>> apply to 4.14-stable tree
>>
>>
>> The patch below does not apply to the 4.14-stable tree.
>> If someone wants it applied there, or to any other stable or longterm
>> tree, then please email the backport, including the original git commit
>> id to <stable@vger.kernel.org>.
>>
>> thanks,
>>
>> greg k-h
>>
>> ------------------ original commit in Linus's tree ------------------
>>
>> From 340d455699400f2c2c0f9b3f703ade3085cdb501 Mon Sep 17 00:00:00
>> 2001
>> From: Dexuan Cui <decui@microsoft.com>
>> Date: Mon, 4 Mar 2019 21:34:49 +0000
>> Subject: [PATCH] PCI: hv: Add pci_destroy_slot() in
>> pci_devices_present_work(), if necessary
>>
>> When we hot-remove a device, usually the host sends us a PCI_EJECT message,
>> and a PCI_BUS_RELATIONS message with bus_rel->device_count == 0.
>>
>> When we execute the quick hot-add/hot-remove test, the host may not send
>> us the PCI_EJECT message if the guest has not fully finished the
>> initialization by sending the PCI_RESOURCES_ASSIGNED* message to the
>> host, so it's potentially unsafe to only depend on the
>> pci_destroy_slot() in hv_eject_device_work() because the code path
>>
>> create_root_hv_pci_bus()
>> -> hv_pci_assign_slots()
>>
>> is not called in this case. Note: in this case, the host still sends the
>> guest a PCI_BUS_RELATIONS message with bus_rel->device_count == 0.
>>
>> In the quick hot-add/hot-remove test, we can have such a race before
>> the code path
>>
>> pci_devices_present_work()
>> -> new_pcichild_device()
>>
>> adds the new device into the hbus->children list, we may have already
>> received the PCI_EJECT message, and since the tasklet handler
>>
>> hv_pci_onchannelcallback()
>>
>> may fail to find the "hpdev" by calling
>>
>> get_pcichild_wslot(hbus, dev_message->wslot.slot)
>>
>> hv_pci_eject_device() is not called; Later, by continuing execution
>>
>> create_root_hv_pci_bus()
>> -> hv_pci_assign_slots()
>>
>> creates the slot and the PCI_BUS_RELATIONS message with
>> bus_rel->device_count == 0 removes the device from hbus->children, and
>> we end up being unable to remove the slot in
>>
>> hv_pci_remove()
>> -> hv_pci_remove_slots()
>>
>> Remove the slot in pci_devices_present_work() when the device
>> is removed to address this race.
>>
>> pci_devices_present_work() and hv_eject_device_work() run in the
>> singled-threaded hbus->wq, so there is not a double-remove issue for the
>> slot.
>>
>> We cannot offload hv_pci_eject_device() from hv_pci_onchannelcallback()
>> to the workqueue, because we need the hv_pci_onchannelcallback()
>> synchronously call hv_pci_eject_device() to poll the channel
>> ringbuffer to work around the "hangs in hv_compose_msi_msg()" issue
>> fixed in commit de0aa7b2f97d ("PCI: hv: Fix 2 hang issues in
>> hv_compose_msi_msg()")
>>
>> Fixes: a15f2c08c708 ("PCI: hv: support reporting serial number as slot
>> information")
>> Signed-off-by: Dexuan Cui <decui@microsoft.com>
>> [lorenzo.pieralisi@arm.com: rewritten commit log]
>> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
>> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
>> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
>> Cc: stable@vger.kernel.org
>>
>> diff --git a/drivers/pci/controller/pci-hyperv.c
>> b/drivers/pci/controller/pci-hyperv.c
>> index b489412e3502..82acd6155adf 100644
>> --- a/drivers/pci/controller/pci-hyperv.c
>> +++ b/drivers/pci/controller/pci-hyperv.c
>> @@ -1776,6 +1776,10 @@ static void pci_devices_present_work(struct
>> work_struct *work)
>> hpdev = list_first_entry(&removed, struct hv_pci_dev,
>> list_entry);
>> list_del(&hpdev->list_entry);
>> +
>> + if (hpdev->pci_slot)
>> + pci_destroy_slot(hpdev->pci_slot);
>> +
>> put_pcichild(hpdev);
>> }
>>
>
>Hi,
>I backported the patch for linux-4.14.y.
>
>Please use the attached patch, which is [PATCH 3/3]
>
>Thanks,
>-- Dexuan
Queued for 4.14, thank you.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-17 0:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-15 8:35 FAILED: patch "[PATCH] PCI: hv: Add pci_destroy_slot() in" failed to apply to 4.14-stable tree gregkh
2019-05-15 23:20 ` Dexuan Cui
2019-05-17 0:48 ` Sasha Levin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.