diff options
author | Konstantin Ozerkov <kozerkov@parallels.com> | 2011-11-09 10:28:55 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-11-09 12:34:28 -0500 |
commit | 7fb4f392bd27e5b0e2444430d241370837bcc8fa (patch) | |
tree | a7488f66f50f8469919e78865a25a781b06547d0 /sound | |
parent | 65c397d6b58d5e401bee7c24608d3a33a220a63a (diff) |
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')
-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] = { | |||
2937 | ICH_PCR, ICH_SCR, ICH_SIS_TCR | 2937 | ICH_PCR, ICH_SCR, ICH_SIS_TCR |
2938 | }; | 2938 | }; |
2939 | 2939 | ||
2940 | static int __devinit snd_intel8x0_inside_vm(void) | 2940 | static int __devinit snd_intel8x0_inside_vm(struct pci_dev *pci) |
2941 | { | 2941 | { |
2942 | int result = inside_vm; | 2942 | int result = inside_vm; |
2943 | char *msg = NULL; | ||
2943 | 2944 | ||
2944 | if (result < 0) { | 2945 | /* check module parameter first (override detection) */ |
2945 | /* detect KVM and Parallels virtual environments */ | 2946 | if (result >= 0) { |
2946 | result = kvm_para_available(); | 2947 | msg = result ? "enable (forced) VM" : "disable (forced) VM"; |
2947 | #if defined(__i386__) || defined(__x86_64__) | 2948 | goto fini; |
2948 | result = result || boot_cpu_has(X86_FEATURE_HYPERVISOR); | 2949 | } |
2950 | |||
2951 | /* detect KVM and Parallels virtual environments */ | ||
2952 | result = kvm_para_available(); | ||
2953 | #ifdef X86_FEATURE_HYPERVISOR | ||
2954 | result = result || boot_cpu_has(X86_FEATURE_HYPERVISOR); | ||
2949 | #endif | 2955 | #endif |
2956 | if (!result) | ||
2957 | goto fini; | ||
2958 | |||
2959 | /* check for known (emulated) devices */ | ||
2960 | if (pci->subsystem_vendor == 0x1af4 && | ||
2961 | pci->subsystem_device == 0x1100) { | ||
2962 | /* KVM emulated sound, PCI SSID: 1af4:1100 */ | ||
2963 | msg = "enable KVM"; | ||
2964 | } else if (pci->subsystem_vendor == 0x1ab8) { | ||
2965 | /* Parallels VM emulated sound, PCI SSID: 1ab8:xxxx */ | ||
2966 | msg = "enable Parallels VM"; | ||
2967 | } else { | ||
2968 | msg = "disable (unknown or VT-d) VM"; | ||
2969 | result = 0; | ||
2950 | } | 2970 | } |
2951 | 2971 | ||
2952 | if (result) | 2972 | fini: |
2953 | printk(KERN_INFO "intel8x0: enable KVM optimization\n"); | 2973 | if (msg != NULL) |
2974 | printk(KERN_INFO "intel8x0: %s optimization\n", msg); | ||
2954 | 2975 | ||
2955 | return result; | 2976 | return result; |
2956 | } | 2977 | } |
@@ -3022,7 +3043,7 @@ static int __devinit snd_intel8x0_create(struct snd_card *card, | |||
3022 | if (xbox) | 3043 | if (xbox) |
3023 | chip->xbox = 1; | 3044 | chip->xbox = 1; |
3024 | 3045 | ||
3025 | chip->inside_vm = snd_intel8x0_inside_vm(); | 3046 | chip->inside_vm = snd_intel8x0_inside_vm(pci); |
3026 | 3047 | ||
3027 | if (pci->vendor == PCI_VENDOR_ID_INTEL && | 3048 | if (pci->vendor == PCI_VENDOR_ID_INTEL && |
3028 | pci->device == PCI_DEVICE_ID_INTEL_440MX) | 3049 | pci->device == PCI_DEVICE_ID_INTEL_440MX) |