PCI,pciehp: Don't set slot off when found device already exists.
PATCH 1/1 PCI,pciehp: Don't set slot off when found device already exists.
If we found device already exists during hot add device, we should leave it, not to set slot off.
--- drivers/pci/hotplug/pciehp_ctrl.c | 3 ++- drivers/pci/hotplug/pciehp_pci.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/pci/hotplug/pciehp_ctrl.c +2 -1
@@ -224,7 +224,8 @@ static int board_added(struct slot *p_slot)if (retval) {ctrl_err (ctrl,"Cannot add device at %04x:%02x:00\n" ,pci_domain_nr (parent), parent->number); - goto err_exit; +if (retval != -EEXIST ) + goto err_exit; }if (PWR_LED (ctrl))
drivers/pci/hotplug/pciehp_pci.c +1 -1
@@ -48,7 +48,7 @@ int pciehp_configure_device(struct slot *p_slot)"at %04x:%02x:00, cannot hot-add\n" ,pci_name (dev), pci_domain_nr(parent), parent->number);pci_dev_put (dev); -return -EINVAL ; +return -EEXIST ; } num =pci_scan_slot (parent,PCI_DEVFN (0 ,0 ));
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerQuoted 2 lines · Yijing Wang
If we found device already exists during hot add device, we should leave it, not to set slot off.
Does this fix a defect? What's the scenario where this fixes a problem in the current code? I think this change makes sense, but I'd like to have a better description of the problem that we're fixing.
I see the following path that looks like it might be a problem with the current code if slot power is off when we resume after a suspend:
pciehp_resume
pciehp_enable_slot
board_added
pciehp_configure_device
Is this the scenario you're addressing?
Quoted 41 lines
Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/hotplug/pciehp_ctrl.c | 3 ++- drivers/pci/hotplug/pciehp_pci.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)drivers/pci/hotplug/pciehp_ctrl.c +2
-1@@ -224,7 +224,8 @@ static int board_added(struct slot *p_slot)if (retval) {ctrl_err (ctrl,"Cannot add device at %04x:%02x:00\n" ,pci_domain_nr (parent), parent->number); - goto err_exit; +if (retval != -EEXIST ) + goto err_exit; }if (PWR_LED (ctrl))drivers/pci/hotplug/pciehp_pci.c +1
-1@@ -48,7 +48,7 @@ int pciehp_configure_device(struct slot *p_slot)"at %04x:%02x:00, cannot hot-add\n" ,pci_name (dev), pci_domain_nr(parent), parent->number);pci_dev_put (dev); -return -EINVAL ; +return -EEXIST ; } num =pci_scan_slot (parent,PCI_DEVFN (0 ,0 ));Signature · 7 lines
1.7.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
Quoted 11 lines · Bjorn Helgaas
Quoted 2 lines · Yijing Wang
If we found device already exists during hot add device, we should leave it, not to set slot off.
Does this fix a defect? What's the scenario where this fixes a problem in the current code? I think this change makes sense, but I'd like to have a better description of the problem that we're fixing.
I see the following path that looks like it might be a problem with the current code if slot power is off when we resume after a suspend:
Quoted 6 lines
pciehp_resume
pciehp_enable_slot
board_added
pciehp_configure_deviceIs this the scenario you're addressing?
Yes, it is.
I found this case by reviewing the code. But I have no platform supports pciehp resume. So I can not test it in real.
Thanks!
Yijing.
Quoted 44 lines
Quoted 42 lines
Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/hotplug/pciehp_ctrl.c | 3 ++- drivers/pci/hotplug/pciehp_pci.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)drivers/pci/hotplug/pciehp_ctrl.c +2
-1@@ -224,7 +224,8 @@ static int board_added(struct slot *p_slot)if (retval) {ctrl_err (ctrl,"Cannot add device at %04x:%02x:00\n" ,pci_domain_nr (parent), parent->number); - goto err_exit; +if (retval != -EEXIST ) + goto err_exit; }if (PWR_LED (ctrl))drivers/pci/hotplug/pciehp_pci.c +1
-1@@ -48,7 +48,7 @@ int pciehp_configure_device(struct slot *p_slot)"at %04x:%02x:00, cannot hot-add\n" ,pci_name (dev), pci_domain_nr(parent), parent->number);pci_dev_put (dev); -return -EINVAL ; +return -EEXIST ; } num =pci_scan_slot (parent,PCI_DEVFN (0 ,0 ));Signature · 7 lines
1.7.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
Signature · 2 lines
Thanks! Yijing
Quoted 4 lines · Yijing Wang
If we found device already exists during hot add device, we should leave it, not to set slot off.
Signed-off-by Yijing Wang <[email protected]>
Applied to pci/pciehp for v3.15, thanks!
Bjorn
Quoted 40 lines
--- drivers/pci/hotplug/pciehp_ctrl.c | 3 ++- drivers/pci/hotplug/pciehp_pci.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)drivers/pci/hotplug/pciehp_ctrl.c +2
-1@@ -224,7 +224,8 @@ static int board_added(struct slot *p_slot)if (retval) {ctrl_err (ctrl,"Cannot add device at %04x:%02x:00\n" ,pci_domain_nr (parent), parent->number); - goto err_exit; +if (retval != -EEXIST ) + goto err_exit; }if (PWR_LED (ctrl))drivers/pci/hotplug/pciehp_pci.c +1
-1@@ -48,7 +48,7 @@ int pciehp_configure_device(struct slot *p_slot)"at %04x:%02x:00, cannot hot-add\n" ,pci_name (dev), pci_domain_nr(parent), parent->number);pci_dev_put (dev); -return -EINVAL ; +return -EEXIST ; } num =pci_scan_slot (parent,PCI_DEVFN (0 ,0 ));Signature · 7 lines
1.7.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