Quantcast

[SRU][Xenial][PATCH 0/3] UBUNTU: SAUCE: Fixes for LP:1665097

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[SRU][Xenial][PATCH 0/3] UBUNTU: SAUCE: Fixes for LP:1665097

Joseph Salisbury-3
BugLink: http://bugs.launchpad.net/bugs/1665097

== SRU Justification ==
These three patches were submitted upstream but missed getting
pulled into Bjorn's tree. They are needed to fix an issue discovered
working on SR-IOV on Azure.

The patches are not in mainline or linux-next yet, so they are marked as SAUCE.

== Fixes ==
Author: Dexuan Cui <[hidden email]>
Date: Fri, 10 Feb 2017 15:18:46 -0600

    PCI: hv: Fix wslot_to_devfn() to fix warnings on device removal

Author: Long Li <[hidden email]>
Date:   Wed Sep 14 19:03:30 2016 +0000

    pci-hyperv: properly handle pci bus remove

Author: Long Li <[hidden email]>
Date:   Wed Sep 14 19:04:38 2016 +0000

    pci-hyperv: lock pci bus on device eject



Dexuan Cui (1):
  PCI: hv: Fix wslot_to_devfn() to fix warnings on device removal

Long Li (2):
  pci-hyperv: properly handle pci bus remove
  pci-hyperv: lock pci bus on device eject

 drivers/pci/host/pci-hyperv.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

--
2.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[SRU][Xenial][PATCH 1/3] UBUNTU: SAUCE: PCI: hv: Fix wslot_to_devfn() to fix warnings on device removal

Joseph Salisbury-3
From: Dexuan Cui <[hidden email]>

BugLink: http://bugs.launchpad.net/bugs/1665097

The devfn of 00:02.0 is 0x10.  devfn_to_wslot(0x10) == 0x2, and
wslot_to_devfn(0x2) should be 0x10, while it's 0x2 in the current code.

Due to this, hv_eject_device_work() -> pci_get_domain_bus_and_slot()
returns NULL and pci_stop_and_remove_bus_device() is not called.

Later when the real device driver's .remove() is invoked by
hv_pci_remove() -> pci_stop_root_bus(), some warnings can be noticed
because the VM has lost the access to the underlying device at that
time.

Signed-off-by: Jake Oshins <[hidden email]>
Signed-off-by: Dexuan Cui <[hidden email]>
Signed-off-by: Bjorn Helgaas <[hidden email]>
Acked-by: Haiyang Zhang <[hidden email]>
CC: [hidden email]
CC: K. Y. Srinivasan <[hidden email]>
CC: Stephen Hemminger <[hidden email]>
Signed-off-by: Joseph Salisbury <[hidden email]>
---
 drivers/pci/host/pci-hyperv.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
index 6955ffdb..b0ee99c6 100644
--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -130,7 +130,8 @@ union pci_version {
  */
 union win_slot_encoding {
  struct {
- u32 func:8;
+ u32 dev:5;
+ u32 func:3;
  u32 reserved:24;
  } bits;
  u32 slot;
@@ -482,7 +483,8 @@ static u32 devfn_to_wslot(int devfn)
  union win_slot_encoding wslot;
 
  wslot.slot = 0;
- wslot.bits.func = PCI_SLOT(devfn) | (PCI_FUNC(devfn) << 5);
+ wslot.bits.dev = PCI_SLOT(devfn);
+ wslot.bits.func = PCI_FUNC(devfn);
 
  return wslot.slot;
 }
@@ -500,7 +502,7 @@ static int wslot_to_devfn(u32 wslot)
  union win_slot_encoding slot_no;
 
  slot_no.slot = wslot;
- return PCI_DEVFN(0, slot_no.bits.func);
+ return PCI_DEVFN(slot_no.bits.dev, slot_no.bits.func);
 }
 
 /*
--
2.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[SRU][Xenial][PATCH 2/3] UBUNTU: SAUCE: pci-hyperv: properly handle pci bus remove

Joseph Salisbury-3
In reply to this post by Joseph Salisbury-3
From: Long Li <[hidden email]>

BugLink: http://bugs.launchpad.net/bugs/1665097

hv_pci_devices_present is called in hv_pci_remove when we remove a PCI
device from host (e.g. by disabling SRIOV on a device). In hv_pci_remove,
the bus is already removed before the call, so we don't need to rescan the
bus in the workqueue scheduled from hv_pci_devices_present. By introducing
status hv_pcibus_removed, we can avoid this situation.

Signed-off-by: Long Li <[hidden email]>
Reported-by: Xiaofeng Wang <[hidden email]>
Signed-off-by: Joseph Salisbury <[hidden email]>
---
 drivers/pci/host/pci-hyperv.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
index b0ee99c6..d4a7994 100644
--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -349,6 +349,7 @@ enum hv_pcibus_state {
  hv_pcibus_init = 0,
  hv_pcibus_probed,
  hv_pcibus_installed,
+ hv_pcibus_removed,
  hv_pcibus_maximum
 };
 
@@ -1484,13 +1485,24 @@ static void pci_devices_present_work(struct work_struct *work)
  put_pcichild(hpdev, hv_pcidev_ref_initial);
  }
 
- /* Tell the core to rescan bus because there may have been changes. */
- if (hbus->state == hv_pcibus_installed) {
+ switch (hbus->state) {
+ case hv_pcibus_installed:
+ /*
+ * Tell the core to rescan bus
+ * because there may have been changes.
+ */
  pci_lock_rescan_remove();
  pci_scan_child_bus(hbus->pci_bus);
  pci_unlock_rescan_remove();
- } else {
+ break;
+
+ case hv_pcibus_init:
+ case hv_pcibus_probed:
  survey_child_resources(hbus);
+ break;
+
+ default:
+ break;
  }
 
  up(&hbus->enum_sem);
@@ -2166,6 +2178,7 @@ static int hv_pci_probe(struct hv_device *hdev,
  hbus = kzalloc(sizeof(*hbus), GFP_KERNEL);
  if (!hbus)
  return -ENOMEM;
+ hbus->state = hv_pcibus_init;
 
  /*
  * The PCI bus "domain" is what is called "segment" in ACPI and
@@ -2308,6 +2321,7 @@ static int hv_pci_remove(struct hv_device *hdev)
  pci_stop_root_bus(hbus->pci_bus);
  pci_remove_root_bus(hbus->pci_bus);
  pci_unlock_rescan_remove();
+ hbus->state = hv_pcibus_removed;
  }
 
  ret = hv_send_resources_released(hdev);
--
2.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[SRU][Xenial][PATCH 3/3] UBUNTU: SAUCE: pci-hyperv: lock pci bus on device eject

Joseph Salisbury-3
In reply to this post by Joseph Salisbury-3
From: Long Li <[hidden email]>

BugLink: http://bugs.launchpad.net/bugs/1665097

A PCI_EJECT message can arrive at the same time we are calling
pci_scan_child_bus in the workqueue for the previous PCI_BUS_RELATIONS
message or in create_root_hv_pci_bus(), in this case we could potentailly
modify the bus from multiple places. Properly lock the bus access.

Thanks Dexuan Cui <[hidden email]> for pointing out the race
condition in create_root_hv_pci_bus().

Signed-off-by: Long Li <[hidden email]>
Reported-by: Xiaofeng Wang <[hidden email]>
Signed-off-by: Joseph Salisbury <[hidden email]>
---
 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 d4a7994..669d54d 100644
--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -1200,9 +1200,11 @@ static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus)
  hbus->pci_bus->msi = &hbus->msi_chip;
  hbus->pci_bus->msi->dev = &hbus->hdev->device;
 
+ pci_lock_rescan_remove();
  pci_scan_child_bus(hbus->pci_bus);
  pci_bus_assign_resources(hbus->pci_bus);
  pci_bus_add_devices(hbus->pci_bus);
+ pci_unlock_rescan_remove();
  hbus->state = hv_pcibus_installed;
  return 0;
 }
@@ -1593,8 +1595,10 @@ static void hv_eject_device_work(struct work_struct *work)
  pdev = pci_get_domain_bus_and_slot(hpdev->hbus->sysdata.domain, 0,
    wslot);
  if (pdev) {
+ pci_lock_rescan_remove();
  pci_stop_and_remove_bus_device(pdev);
  pci_dev_put(pdev);
+ pci_unlock_rescan_remove();
  }
 
  memset(&ctxt, 0, sizeof(ctxt));
--
2.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ACK: [SRU][Xenial][PATCH 0/3] UBUNTU: SAUCE: Fixes for LP:1665097

Tim Gardner-2
In reply to this post by Joseph Salisbury-3
Vendor request, isolated to one driver
--
Tim Gardner [hidden email]

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ACK: [SRU][Xenial][PATCH 0/3] UBUNTU: SAUCE: Fixes for LP:1665097

brad.figg
In reply to this post by Joseph Salisbury-3
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ACK: [SRU][Xenial][PATCH 0/3] UBUNTU: SAUCE: Fixes for LP:1665097

brad.figg
In reply to this post by Joseph Salisbury-3
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

APPLIED: [SRU][Xenial][PATCH 0/3] UBUNTU: SAUCE: Fixes for LP:1665097

Thadeu Lima de Souza Cascardo-3
In reply to this post by Joseph Salisbury-3
Applied to xenial master-next branch.

Thanks.
Cascardo.

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Loading...