diff mbox series

[bionic:linux-azure-4.15,5/5] PCI: hv: Use bytes 4 and 5 from instance ID as the PCI domain numbers

Message ID 20200426204229.119093-6-marcelo.cerri@canonical.com
State New
Headers show
Series [bionic:linux-azure-4.15,1/5] Revert "Revert "PCI: hv: Make sure the bus domain is really unique"" | expand

Commit Message

Marcelo Henrique Cerri April 26, 2020, 8:42 p.m. UTC
From: Haiyang Zhang <haiyangz@microsoft.com>

BugLink: https://bugs.launchpad.net/bugs/1867220

As recommended by Azure host team, the bytes 4, 5 have more uniqueness
(info entropy) than bytes 8, 9 so use them as the PCI domain numbers.

On older hosts, bytes 4, 5 can also be used -- no backward compatibility
issues are introduced and the chance of collision is greatly reduced.

In the rare cases of collision, the driver code detects and finds
another number that is not in use.

Suggested-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Sasha Levin <sashal@kernel.org>
(backported from commit f73f8a504e27959576a2f4d85182202561e426f2)
[marcelo.cerri@canonical.com: basically a clean cherry-pick, but the
 changes from drivers/pci/controller/pci-hyperv.c had to be applied
 to drivers/pci/host/pci-hyperv.c instead]
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
---
 drivers/pci/host/pci-hyperv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
index c414255d2ae6..81da709aa757 100644
--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -2632,7 +2632,7 @@  static int hv_pci_probe(struct hv_device *hdev,
 	 * (2) There will be no overlap between domains (after fixing possible
 	 * collisions) in the same VM.
 	 */
-	dom_req = hdev->dev_instance.b[8] << 8 | hdev->dev_instance.b[9];
+	dom_req = hdev->dev_instance.b[5] << 8 | hdev->dev_instance.b[4];
 	dom = hv_get_dom_num(dom_req);
 
 	if (dom == HVPCI_DOM_INVALID) {