Skip to contentSkip to conversation

PCI: pci_unignore_hotplug()

PATCH In review Alex Williamson 3 participants 6 messages Feb 24, 2015 – Mar 6, 2015

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover PCI: pci_unignore_hotplug()

I'd kinda like to use pci_ignore_hotplug() for devices in use by a user via vfio-pci, but the interface seems only partially implemented since we can only set ignore_hotplug and not clear it. This adds the capability to clear the flag and applies it as seems to be appropriate to the existing users. I don't have a system with power control for a radeon or nouveau device, so I'd certainly appreciate testing. It seems though that once the device is in D0, we've passed the critical point where the device could be accidentally unplugged. Thanks,

Alex

---

Alex Williamson (2):
pci: Add reciprocal function for pci_ignore_hotplug() nouveau/radeon: Un-ignore hotplug on resume

 drivers/gpu/drm/nouveau/nouveau_drm.c |    1 +
 drivers/gpu/drm/radeon/radeon_drv.c   |    1 +
 include/linux/pci.h                   |    5 +++++
 3 files changed, 7 insertions(+)

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#1 lore raw

PATCH 1/2 pci: Add reciprocal function for pci_ignore_hotplug()

We have pci_ignore_hotplug(), but there's no way to undo this without manipulating the device itself. It seems like the original intention of the function is to provide the driver with a way to ignore hotplug over a specific time window, ex. the time while the device is powered off. Once the device is powered on again, the flag should be cleared to avoid leaving driver cruft on the device. Add a trivial helper function to enable this.

---
 include/linux/pci.h |    5 +++++
 1 file changed, 5 insertions(+)
include/linux/pci.h +5 -0
index 211e9da..26f9779 100644
@@ -1044,6 +1044,11 @@ static inline void pci_ignore_hotplug(struct pci_dev *dev)
 	dev->ignore_hotplug = 1;
 }
 
+static inline void pci_unignore_hotplug(struct pci_dev *dev)
+{
+	dev->ignore_hotplug = 0;
+}
+
 static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
 				  bool enable)
 {

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

PATCH 2/2 nouveau/radeon: Un-ignore hotplug on resume

In reply to Alex Williamson

Commit b440bde74f04 enabled drivers to be able to set an ignore hotplug flag on the device and used it in the suspend routine for nouveau and radeon to prevent hotplug when the device is powered off. However, there was no undo function provided, so once set, the ignore hotplug flag lives on for the life of the pci_dev. I think the intention was only to ignore hotplug across the power event for the device, so we should be able to clear the flag on resume.

---
 drivers/gpu/drm/nouveau/nouveau_drm.c |    1 +
 drivers/gpu/drm/radeon/radeon_drv.c   |    1 +
 2 files changed, 2 insertions(+)
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -0
index 8763deb..b168c3a 100644
@@ -749,6 +749,7 @@ nouveau_pmops_runtime_resume(struct device *dev)
 		return -EINVAL;
 
 	pci_set_power_state(pdev, PCI_D0);
+	pci_unignore_hotplug(pdev);
 	pci_restore_state(pdev);
 	ret = pci_enable_device(pdev);
 	if (ret)
drivers/gpu/drm/radeon/radeon_drv.c +1 -0
index 5d684be..1c7c79b 100644
@@ -472,6 +472,7 @@ static int radeon_pmops_runtime_resume(struct device *dev)
 	drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 
 	pci_set_power_state(pdev, PCI_D0);
+	pci_unignore_hotplug(pdev);
 	pci_restore_state(pdev);
 	ret = pci_enable_device(pdev);
 	if (ret)

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
In reply to Alex Williamson
Quoted 8 lines · Alex Williamson

I'd kinda like to use pci_ignore_hotplug() for devices in use by a user via vfio-pci, but the interface seems only partially implemented since we can only set ignore_hotplug and not clear it. This adds the capability to clear the flag and applies it as seems to be appropriate to the existing users. I don't have a system with power control for a radeon or nouveau device, so I'd certainly appreciate testing. It seems though that once the device is in D0, we've passed the critical point where the device could be accidentally unplugged. Thanks,

Something re-broke this recently. See:
https://bugzilla.kernel.org/show_bug.cgi?id=61891
https://bugzilla.kernel.org/show_bug.cgi?id=89731

Alex

Quoted 18 lines

Alex

---

Alex Williamson (2):
pci: Add reciprocal function for pci_ignore_hotplug() nouveau/radeon: Un-ignore hotplug on resume

 drivers/gpu/drm/nouveau/nouveau_drm.c |    1 +
 drivers/gpu/drm/radeon/radeon_drv.c   |    1 +
 include/linux/pci.h                   |    5 +++++
 3 files changed, 7 insertions(+)

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer
#4 lore raw
Quoted 11 lines · Alex Deucher
Quoted 8 lines · Alex Williamson

I'd kinda like to use pci_ignore_hotplug() for devices in use by a user via vfio-pci, but the interface seems only partially implemented since we can only set ignore_hotplug and not clear it. This adds the capability to clear the flag and applies it as seems to be appropriate to the existing users. I don't have a system with power control for a radeon or nouveau device, so I'd certainly appreciate testing. It seems though that once the device is in D0, we've passed the critical point where the device could be accidentally unplugged. Thanks,

Quoted 3 lines

Something re-broke this recently. See:
https://bugzilla.kernel.org/show_bug.cgi?id=61891
https://bugzilla.kernel.org/show_bug.cgi?id=89731

I'm not opposed to adding pci_unignore_hotplug() when we have users for it. I don't really want to throw in the nouveau and radeon changes while there are open issues in the same area, though.

I haven't looked at the bugzillas above. Let me know if I should.

Bjorn
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw
Quoted 16 lines · Bjorn Helgaas
Quoted 11 lines · Alex Deucher
Quoted 8 lines · Alex Williamson

I'd kinda like to use pci_ignore_hotplug() for devices in use by a user via vfio-pci, but the interface seems only partially implemented since we can only set ignore_hotplug and not clear it. This adds the capability to clear the flag and applies it as seems to be appropriate to the existing users. I don't have a system with power control for a radeon or nouveau device, so I'd certainly appreciate testing. It seems though that once the device is in D0, we've passed the critical point where the device could be accidentally unplugged. Thanks,

Quoted 3 lines

Something re-broke this recently. See:
https://bugzilla.kernel.org/show_bug.cgi?id=61891
https://bugzilla.kernel.org/show_bug.cgi?id=89731

Quoted 5 lines

I'm not opposed to adding pci_unignore_hotplug() when we have users for it. I don't really want to throw in the nouveau and radeon changes while there are open issues in the same area, though.

I haven't looked at the bugzillas above. Let me know if I should.

Please do. My comments were not targeted at this patch set, but rather at the fact that pci hotplug (acpiphp in this case) is again trying to remove the driver even though it's flagged to ignore hotplug in the hybrid laptop case.

Alex