
On Wed, Feb 25, 2009 at 08:17:08PM +0000, Mark McLoughlin wrote:
Add implementations of dettach, reattach and reset for PCI devices.
Background to this code can be found here:
http://marc.info/?l=kvm&m=123454366317045
Some notes:
* pci-stub was first introduced in 2.6.29; if it's not available, then dettach can only unbind the device from the host driver
* remove_id is queued up for 2.6.30; in it's absence reattach cannot re-bind the device to the original driver
* If the device supports Function Level Reset, we just don't bother doing the reset - KVM will do this before and after a guest runs
* Currently, if a reset would affect another device on the same bus, or another function on the same multi-function device, then we just refuse to do the reset. In future, we could allow the reset as long as it doesn't affect a device in use by the host or assigned to another guest
* The device reset code is similar in concept to some of Xen's code
* This code should use libpciaccess - libpci isn't an option because we can't handle malloc failures with it
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
In absence of any objections, I ACK this patch, because it is internal only code we can easily change later as required.
+/* PM12 3.2.4 Power Management Control/Status (Offset = 4) */ +#define PCI_PM_CTRL 4 /* PM control and status register */ +#define PCI_PM_CTRL_STATE_MASK 0x3 /* Current power state (D0 to D3) */ +#define PCI_PM_CTRL_STATE_D0 0x0 /* D0 state */ +#define PCI_PM_CTRL_STATE_D3hot 0x3 /* D3 state */ +#define PCI_PM_CTRL_NO_SOFT_RESET 0x4 /* No reset for D3hot->D0 */
I've been told off-list, that this last constant should be 0x8 instead of 0x4 Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|