PCI: Remove usage of pci_domain_nr when the PCI bus doesn't yet exist
PATCH 1/1 PCI: Remove usage of pci_domain_nr when the PCI bus doesn't yet exist
From: Jake Oshins <[email protected]>
This patch fixes a race condition in this driver. Using the function pci_domain_nr() only works if the PCI bus has already been fully created. This patch just deletes one call site, as it was in debug prints which aren't strictly necessary. Another call site is changed to look for the data in the same structure that is passed in when creating the PCI bus in the first place.
--- drivers/pci/host/pci-hyperv.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/pci/host/pci-hyperv.c +8 -7
@@ -1265,11 +1265,6 @@ static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus,if (!hpdev)return NULL ; -dev_info (&hbus->hdev->device, -"New child device (%p) [%04x:%04x] at %04x:00:00.%02x\n" , - hpdev, desc->v_id, desc->d_id,pci_domain_nr (hbus->pci_bus), - desc->win_slot.bits.func); - hpdev->hbus = hbus;memset (&pkt,0 ,sizeof (pkt));
@@ -1558,9 +1553,15 @@ static void hv_eject_device_work(struct work_struct *work)return ; } +/* +* Ejection can come before or after the PCI bus has been set up, so +* attempt to find it and tear down the bus state, if it exists. This +* must be done without constructs like pci_domain_nr(hbus->pci_bus) +* because hbus->pci_bus may not exist yet. +*/ wslot =wslot_to_devfn (hpdev->desc.win_slot.slot); - pdev =pci_get_domain_bus_and_slot (pci_domain_nr (hpdev->hbus->pci_bus), -0 , wslot); + pdev =pci_get_domain_bus_and_slot (hpdev->hbus->sysdata.domain,0 , + wslot);if (pdev) {pci_stop_and_remove_bus_device (pdev);pci_dev_put (pdev);
Signature · 1 line
1.9.1
Quoted 11 lines · On Wed, Feb 24, 2016 at 06:56:36PM +0000, [email protected] wrote:
From: Jake Oshins <[email protected]>
This patch fixes a race condition in this driver. Using the function
pci_domain_nr()only works if the PCI bus has already been fully created. This patch just deletes one call site, as it was in debug prints which aren't strictly necessary. Another call site is changed to look for the data in the same structure that is passed in when creating the PCI bus in the first place.Signed-off-by Jake Oshins <[email protected]>
I folded this into the original "Add paravirtual PCI front-end for Microsoft Hyper-V VMs" patch and updated the pci/host-hv branch.
Thanks, Jake!
Quoted 45 lines
--- drivers/pci/host/pci-hyperv.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)drivers/pci/host/pci-hyperv.c +8
-7@@ -1265,11 +1265,6 @@ static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus,if (!hpdev)return NULL ; -dev_info (&hbus->hdev->device, -"New child device (%p) [%04x:%04x] at %04x:00:00.%02x\n" , - hpdev, desc->v_id, desc->d_id,pci_domain_nr (hbus->pci_bus), - desc->win_slot.bits.func); - hpdev->hbus = hbus;memset (&pkt,0 ,sizeof (pkt));@@ -1558,9 +1553,15 @@ static void hv_eject_device_work(struct work_struct *work)return ; } +/* +* Ejection can come before or after the PCI bus has been set up, so +* attempt to find it and tear down the bus state, if it exists. This +* must be done without constructs like pci_domain_nr(hbus->pci_bus) +* because hbus->pci_bus may not exist yet. +*/ wslot =wslot_to_devfn (hpdev->desc.win_slot.slot); - pdev =pci_get_domain_bus_and_slot (pci_domain_nr (hpdev->hbus->pci_bus), -0 , wslot); + pdev =pci_get_domain_bus_and_slot (hpdev->hbus->sysdata.domain,0 , + wslot);if (pdev) {pci_stop_and_remove_bus_device (pdev);pci_dev_put (pdev);Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html