* [PATCH 3/3] PCI: hv: delete the device earlier from hbus->children for hot-remove
@ 2016-11-10 7:19 Dexuan Cui
2016-11-12 0:44 ` Jake Oshins
2016-11-14 23:08 ` KY Srinivasan
0 siblings, 2 replies; 3+ messages in thread
From: Dexuan Cui @ 2016-11-10 7:19 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci, devel
Cc: gregkh, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
Jake Oshins, Hadden Hoppert, Vitaly Kuznetsov, jasowang, apw,
olaf, linux-kernel
After we send a PCI_EJECTION_COMPLETE message to the host, the host will
immediately send us a PCI_BUS_RELATIONS message with
relations->device_count == 0, so pci_devices_present_work(), running on
another thread, can find the being-ejected device, mark
the hpdev->reported_missing to true, and run list_move_tail()/list_del()
for the device -- this races hv_eject_device_work() -> list_del().
The patch moves the list_del() in hv_eject_device_work() to an earlier
place, i.e. before we send PCI_EJECTION_COMPLETE, so later the
pci_devices_present_work() can't see the device.
Signed-off-by: Dexuan Cui <decui@microsoft.com>
CC: Jake Oshins <jakeo@microsoft.com>
Cc: KY Srinivasan <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>
---
drivers/pci/host/pci-hyperv.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
index 7590ad0..fe5179d 100644
--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -1582,6 +1582,10 @@ static void hv_eject_device_work(struct work_struct *work)
pci_dev_put(pdev);
}
+ spin_lock_irqsave(&hpdev->hbus->device_list_lock, flags);
+ list_del(&hpdev->list_entry);
+ spin_unlock_irqrestore(&hpdev->hbus->device_list_lock, flags);
+
memset(&ctxt, 0, sizeof(ctxt));
ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message;
ejct_pkt->message_type.type = PCI_EJECTION_COMPLETE;
@@ -1590,10 +1594,6 @@ static void hv_eject_device_work(struct work_struct *work)
sizeof(*ejct_pkt), (unsigned long)&ctxt.pkt,
VM_PKT_DATA_INBAND, 0);
- spin_lock_irqsave(&hpdev->hbus->device_list_lock, flags);
- list_del(&hpdev->list_entry);
- spin_unlock_irqrestore(&hpdev->hbus->device_list_lock, flags);
-
put_pcichild(hpdev, hv_pcidev_ref_childlist);
put_pcichild(hpdev, hv_pcidev_ref_pnp);
put_hvpcibus(hpdev->hbus);
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH 3/3] PCI: hv: delete the device earlier from hbus->children for hot-remove
2016-11-10 7:19 [PATCH 3/3] PCI: hv: delete the device earlier from hbus->children for hot-remove Dexuan Cui
@ 2016-11-12 0:44 ` Jake Oshins
2016-11-14 23:08 ` KY Srinivasan
1 sibling, 0 replies; 3+ messages in thread
From: Jake Oshins @ 2016-11-12 0:44 UTC (permalink / raw)
To: Dexuan Cui, Bjorn Helgaas, linux-pci, devel
Cc: gregkh, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
Hadden Hoppert, Vitaly Kuznetsov, jasowang, apw, olaf,
linux-kernel
> -----Original Message-----
> From: Dexuan Cui
> Sent: Wednesday, November 9, 2016 11:20 PM
> To: Bjorn Helgaas <bhelgaas@google.com>; linux-pci@vger.kernel.org;
> devel@linuxdriverproject.org
> Cc: gregkh@linuxfoundation.org; KY Srinivasan <kys@microsoft.com>;
> Haiyang Zhang <haiyangz@microsoft.com>; Stephen Hemminger
> <sthemmin@microsoft.com>; Jake Oshins <jakeo@microsoft.com>; Hadden
> Hoppert <haddenh@microsoft.com>; Vitaly Kuznetsov
> <vkuznets@redhat.com>; jasowang@redhat.com; apw@canonical.com;
> olaf@aepfle.de; linux-kernel@vger.kernel.org
> Subject: [PATCH 3/3] PCI: hv: delete the device earlier from hbus->children
> for hot-remove
>
> After we send a PCI_EJECTION_COMPLETE message to the host, the host will
> immediately send us a PCI_BUS_RELATIONS message with
> relations->device_count == 0, so pci_devices_present_work(), running on
> another thread, can find the being-ejected device, mark
> the hpdev->reported_missing to true, and run list_move_tail()/list_del()
> for the device -- this races hv_eject_device_work() -> list_del().
>
> The patch moves the list_del() in hv_eject_device_work() to an earlier
> place, i.e. before we send PCI_EJECTION_COMPLETE, so later the
> pci_devices_present_work() can't see the device.
>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> CC: Jake Oshins <jakeo@microsoft.com>
> Cc: KY Srinivasan <kys@microsoft.com>
> CC: Haiyang Zhang <haiyangz@microsoft.com>
> CC: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
> drivers/pci/host/pci-hyperv.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
> index 7590ad0..fe5179d 100644
> --- a/drivers/pci/host/pci-hyperv.c
> +++ b/drivers/pci/host/pci-hyperv.c
> @@ -1582,6 +1582,10 @@ static void hv_eject_device_work(struct
> work_struct *work)
> pci_dev_put(pdev);
> }
>
> + spin_lock_irqsave(&hpdev->hbus->device_list_lock, flags);
> + list_del(&hpdev->list_entry);
> + spin_unlock_irqrestore(&hpdev->hbus->device_list_lock, flags);
> +
> memset(&ctxt, 0, sizeof(ctxt));
> ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message;
> ejct_pkt->message_type.type = PCI_EJECTION_COMPLETE;
> @@ -1590,10 +1594,6 @@ static void hv_eject_device_work(struct
> work_struct *work)
> sizeof(*ejct_pkt), (unsigned long)&ctxt.pkt,
> VM_PKT_DATA_INBAND, 0);
>
> - spin_lock_irqsave(&hpdev->hbus->device_list_lock, flags);
> - list_del(&hpdev->list_entry);
> - spin_unlock_irqrestore(&hpdev->hbus->device_list_lock, flags);
> -
> put_pcichild(hpdev, hv_pcidev_ref_childlist);
> put_pcichild(hpdev, hv_pcidev_ref_pnp);
> put_hvpcibus(hpdev->hbus);
> --
> 2.7.4
This looks good, too.
-- Jake Oshins
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH 3/3] PCI: hv: delete the device earlier from hbus->children for hot-remove
2016-11-10 7:19 [PATCH 3/3] PCI: hv: delete the device earlier from hbus->children for hot-remove Dexuan Cui
2016-11-12 0:44 ` Jake Oshins
@ 2016-11-14 23:08 ` KY Srinivasan
1 sibling, 0 replies; 3+ messages in thread
From: KY Srinivasan @ 2016-11-14 23:08 UTC (permalink / raw)
To: Dexuan Cui, Bjorn Helgaas, linux-pci, devel
Cc: gregkh, Haiyang Zhang, Stephen Hemminger, Jake Oshins,
Hadden Hoppert, Vitaly Kuznetsov, jasowang, apw, olaf,
linux-kernel
> -----Original Message-----
> From: Dexuan Cui
> Sent: Wednesday, November 9, 2016 11:20 PM
> To: Bjorn Helgaas <bhelgaas@google.com>; linux-pci@vger.kernel.org;
> devel@linuxdriverproject.org
> Cc: gregkh@linuxfoundation.org; KY Srinivasan <kys@microsoft.com>;
> Haiyang Zhang <haiyangz@microsoft.com>; Stephen Hemminger
> <sthemmin@microsoft.com>; Jake Oshins <jakeo@microsoft.com>; Hadden
> Hoppert <haddenh@microsoft.com>; Vitaly Kuznetsov
> <vkuznets@redhat.com>; jasowang@redhat.com; apw@canonical.com;
> olaf@aepfle.de; linux-kernel@vger.kernel.org
> Subject: [PATCH 3/3] PCI: hv: delete the device earlier from hbus->children
> for hot-remove
>
> After we send a PCI_EJECTION_COMPLETE message to the host, the host will
> immediately send us a PCI_BUS_RELATIONS message with
> relations->device_count == 0, so pci_devices_present_work(), running on
> another thread, can find the being-ejected device, mark
> the hpdev->reported_missing to true, and run list_move_tail()/list_del()
> for the device -- this races hv_eject_device_work() -> list_del().
>
> The patch moves the list_del() in hv_eject_device_work() to an earlier
> place, i.e. before we send PCI_EJECTION_COMPLETE, so later the
> pci_devices_present_work() can't see the device.
>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> CC: Jake Oshins <jakeo@microsoft.com>
> Cc: KY Srinivasan <kys@microsoft.com>
> CC: Haiyang Zhang <haiyangz@microsoft.com>
> CC: Vitaly Kuznetsov <vkuznets@redhat.com>
Thanks Dexuan.
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
> drivers/pci/host/pci-hyperv.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
> index 7590ad0..fe5179d 100644
> --- a/drivers/pci/host/pci-hyperv.c
> +++ b/drivers/pci/host/pci-hyperv.c
> @@ -1582,6 +1582,10 @@ static void hv_eject_device_work(struct
> work_struct *work)
> pci_dev_put(pdev);
> }
>
> + spin_lock_irqsave(&hpdev->hbus->device_list_lock, flags);
> + list_del(&hpdev->list_entry);
> + spin_unlock_irqrestore(&hpdev->hbus->device_list_lock, flags);
> +
> memset(&ctxt, 0, sizeof(ctxt));
> ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message;
> ejct_pkt->message_type.type = PCI_EJECTION_COMPLETE;
> @@ -1590,10 +1594,6 @@ static void hv_eject_device_work(struct
> work_struct *work)
> sizeof(*ejct_pkt), (unsigned long)&ctxt.pkt,
> VM_PKT_DATA_INBAND, 0);
>
> - spin_lock_irqsave(&hpdev->hbus->device_list_lock, flags);
> - list_del(&hpdev->list_entry);
> - spin_unlock_irqrestore(&hpdev->hbus->device_list_lock, flags);
> -
> put_pcichild(hpdev, hv_pcidev_ref_childlist);
> put_pcichild(hpdev, hv_pcidev_ref_pnp);
> put_hvpcibus(hpdev->hbus);
> --
> 2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-14 23:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-10 7:19 [PATCH 3/3] PCI: hv: delete the device earlier from hbus->children for hot-remove Dexuan Cui
2016-11-12 0:44 ` Jake Oshins
2016-11-14 23:08 ` KY Srinivasan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).