diff options
author | Konstantin Ozerkov <kozerkov@parallels.com> | 2011-11-09 19:28:55 +0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-11-09 18:34:28 +0100 |
commit | 7fb4f392bd27e5b0e2444430d241370837bcc8fa (patch) | |
tree | a7488f66f50f8469919e78865a25a781b06547d0 /sound/pci/intel8x0.c | |
parent | 65c397d6b58d5e401bee7c24608d3a33a220a63a (diff) | |
download | linux-7fb4f392bd27e5b0e2444430d241370837bcc8fa.tar.gz linux-7fb4f392bd27e5b0e2444430d241370837bcc8fa.tar.bz2 linux-7fb4f392bd27e5b0e2444430d241370837bcc8fa.zip |
ALSA: intel8x0: improve virtual environment detection
Detection code improved by PCI SSID usage. VM optimization
now enabled only for known devcices (skip host devices forwarded
to VM by VT-d or same kind of technology).
For debug/troubleshooting purposes optimization can be
forced (on/off) by module parameter: "inside_vm" (boolean).
Known devices (PCI SSID):
1af4:1100: Reserved for KVM devices. Note this is not yet
implemented for KVM's ICH/AC'97 emulation.
1ab8:xxxx: Parallels ICH/AC'97 emulated sound.
[ fixed a minor coding-style issue by tiwai]
Signed-off-by: Konstantin Ozerkov <kozerkov@parallels.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/intel8x0.c')
-rw-r--r-- | sound/pci/intel8x0.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 2d4bb4c9a030..11718b49b2e2 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2937,20 +2937,41 @@ static unsigned int sis_codec_bits[3] = { ICH_PCR, ICH_SCR, ICH_SIS_TCR }; -static int __devinit snd_intel8x0_inside_vm(void) +static int __devinit snd_intel8x0_inside_vm(struct pci_dev *pci) { - int result = inside_vm; + int result = inside_vm; + char *msg = NULL; - if (result < 0) { - /* detect KVM and Parallels virtual environments */ - result = kvm_para_available(); -#if defined(__i386__) || defined(__x86_64__) - result = result || boot_cpu_has(X86_FEATURE_HYPERVISOR); + /* check module parameter first (override detection) */ + if (result >= 0) { + msg = result ? "enable (forced) VM" : "disable (forced) VM"; + goto fini; + } + + /* detect KVM and Parallels virtual environments */ + result = kvm_para_available(); +#ifdef X86_FEATURE_HYPERVISOR + result = result || boot_cpu_has(X86_FEATURE_HYPERVISOR); #endif + if (!result) + goto fini; + + /* check for known (emulated) devices */ + if (pci->subsystem_vendor == 0x1af4 && + pci->subsystem_device == 0x1100) { + /* KVM emulated sound, PCI SSID: 1af4:1100 */ + msg = "enable KVM"; + } else if (pci->subsystem_vendor == 0x1ab8) { + /* Parallels VM emulated sound, PCI SSID: 1ab8:xxxx */ + msg = "enable Parallels VM"; + } else { + msg = "disable (unknown or VT-d) VM"; + result = 0; } - if (result) - printk(KERN_INFO "intel8x0: enable KVM optimization\n"); +fini: + if (msg != NULL) + printk(KERN_INFO "intel8x0: %s optimization\n", msg); return result; } @@ -3022,7 +3043,7 @@ static int __devinit snd_intel8x0_create(struct snd_card *card, if (xbox) chip->xbox = 1; - chip->inside_vm = snd_intel8x0_inside_vm(); + chip->inside_vm = snd_intel8x0_inside_vm(pci); if (pci->vendor == PCI_VENDOR_ID_INTEL && pci->device == PCI_DEVICE_ID_INTEL_440MX) |