All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection
@ 2011-11-09 15:28 Konstantin Ozerkov
  2011-11-09 15:28 ` [PATCH 1/3] ALSA: intel8x0: move virtual environment detection code into one place Konstantin Ozerkov
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Konstantin Ozerkov @ 2011-11-09 15:28 UTC (permalink / raw)
  To: patch; +Cc: alsa-devel

Improve detection logic as discussed early: add secondary checks by PCI SSID.

Note: patch [3/3] is made for alsa-driver tree.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] ALSA: intel8x0: move virtual environment detection code into one place
  2011-11-09 15:28 [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection Konstantin Ozerkov
@ 2011-11-09 15:28 ` Konstantin Ozerkov
  2011-11-09 15:28 ` [PATCH 2/3] ALSA: intel8x0: improve virtual environment detection Konstantin Ozerkov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Konstantin Ozerkov @ 2011-11-09 15:28 UTC (permalink / raw)
  To: patch; +Cc: Denis V. Lunev, alsa-devel, Konstantin Ozerkov

This is refactoring patch: preparation for add improved detection code.
Now all detection code placed in one place.

Signed-off-by: Konstantin Ozerkov <kozerkov@parallels.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>

diff --git a/pci/intel8x0.c b/pci/intel8x0.c
index 45b2055..d726d94 100644
--- a/pci/intel8x0.c
+++ b/pci/intel8x0.c
@@ -2930,6 +2930,24 @@ static unsigned int sis_codec_bits[3] = {
 	ICH_PCR, ICH_SCR, ICH_SIS_TCR
 };
 
+static int __devinit snd_intel8x0_inside_vm(void)
+{
+	int result = inside_vm;
+
+	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);
+#endif
+	}
+
+	if (result)
+		printk(KERN_INFO "intel8x0: enable KVM optimization\n");
+
+	return result;
+}
+
 static int __devinit snd_intel8x0_create(struct snd_card *card,
 					 struct pci_dev *pci,
 					 unsigned long device_type,
@@ -2997,9 +3015,7 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
 	if (xbox)
 		chip->xbox = 1;
 
-	chip->inside_vm = inside_vm;
-	if (inside_vm)
-		printk(KERN_INFO "intel8x0: enable KVM optimization\n");
+	chip->inside_vm = snd_intel8x0_inside_vm();
 
 	if (pci->vendor == PCI_VENDOR_ID_INTEL &&
 	    pci->device == PCI_DEVICE_ID_INTEL_440MX)
@@ -3243,14 +3259,6 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci,
 			buggy_irq = 0;
 	}
 
-	if (inside_vm < 0) {
-		/* detect KVM and Parallels virtual environments */
-		inside_vm = kvm_para_available();
-#if defined(__i386__) || defined(__x86_64__)
-		inside_vm = inside_vm || boot_cpu_has(X86_FEATURE_HYPERVISOR);
-#endif
-	}
-
 	if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data,
 				       &chip)) < 0) {
 		snd_card_free(card);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] ALSA: intel8x0: improve virtual environment detection
  2011-11-09 15:28 [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection Konstantin Ozerkov
  2011-11-09 15:28 ` [PATCH 1/3] ALSA: intel8x0: move virtual environment detection code into one place Konstantin Ozerkov
@ 2011-11-09 15:28 ` Konstantin Ozerkov
  2011-11-09 15:28 ` [PATCH 3/3] alsa-driver: Fix build intel8x0 Konstantin Ozerkov
  2011-11-09 17:41 ` [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection Takashi Iwai
  3 siblings, 0 replies; 6+ messages in thread
From: Konstantin Ozerkov @ 2011-11-09 15:28 UTC (permalink / raw)
  To: patch; +Cc: Denis V. Lunev, alsa-devel, Konstantin Ozerkov

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.

Signed-off-by: Konstantin Ozerkov <kozerkov@parallels.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>

diff --git a/pci/intel8x0.c b/pci/intel8x0.c
index d726d94..7db2a74 100644
--- a/pci/intel8x0.c
+++ b/pci/intel8x0.c
@@ -2930,20 +2930,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;
 }
@@ -3015,7 +3036,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)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] alsa-driver: Fix build intel8x0
  2011-11-09 15:28 [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection Konstantin Ozerkov
  2011-11-09 15:28 ` [PATCH 1/3] ALSA: intel8x0: move virtual environment detection code into one place Konstantin Ozerkov
  2011-11-09 15:28 ` [PATCH 2/3] ALSA: intel8x0: improve virtual environment detection Konstantin Ozerkov
@ 2011-11-09 15:28 ` Konstantin Ozerkov
  2011-11-09 17:41 ` [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection Takashi Iwai
  3 siblings, 0 replies; 6+ messages in thread
From: Konstantin Ozerkov @ 2011-11-09 15:28 UTC (permalink / raw)
  To: patch; +Cc: Denis V. Lunev, alsa-devel, Konstantin Ozerkov

Fix build alsa-driver with recent changes in intel8x0 (improved
virtualization detection).

"#ifdef X86_FEATURE_HYPERVISOR" check now placed in main code, no
additional patching required.

Signed-off-by: Konstantin Ozerkov <kozerkov@parallels.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>

diff --git a/pci/intel8x0.patch b/pci/intel8x0.patch
index 3b4b16f..6b3ce6c 100644
--- a/pci/intel8x0.patch
+++ b/pci/intel8x0.patch
@@ -43,17 +43,6 @@
  }
  #else
  #define fill_nocache(buf, size, nocache) do { ; } while (0)
-@@ -3247,8 +3258,10 @@
- 		/* detect KVM and Parallels virtual environments */
- 		inside_vm = kvm_para_available();
- #if defined(__i386__) || defined(__x86_64__)
-+#ifdef X86_FEATURE_HYPERVISOR
- 		inside_vm = inside_vm || boot_cpu_has(X86_FEATURE_HYPERVISOR);
- #endif
-+#endif
- 	}
- 
- 	if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data,
 @@ -3320,3 +3333,5 @@
  
  module_init(alsa_card_intel8x0_init)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection
  2011-11-09 15:28 [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection Konstantin Ozerkov
                   ` (2 preceding siblings ...)
  2011-11-09 15:28 ` [PATCH 3/3] alsa-driver: Fix build intel8x0 Konstantin Ozerkov
@ 2011-11-09 17:41 ` Takashi Iwai
  2011-11-10  9:10   ` Konstantin Ozerkov
  3 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2011-11-09 17:41 UTC (permalink / raw)
  To: Konstantin Ozerkov; +Cc: alsa-devel

At Wed, 9 Nov 2011 19:28:53 +0400,
Konstantin Ozerkov wrote:
> 
> Improve detection logic as discussed early: add secondary checks by PCI SSID.
> 
> Note: patch [3/3] is made for alsa-driver tree.

Thanks, applied now.

The patch 3 couldn't be applied cleanly to my tree, so I refreshed
by myself.

Which git trees are you referring to?  At the next time, please create
patches based on sound git tree, which is the base for linux-next:
  git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

Also for the external alsa-driver, please use the git tree below:
  git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/alsa-driver-build.git


Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection
  2011-11-09 17:41 ` [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection Takashi Iwai
@ 2011-11-10  9:10   ` Konstantin Ozerkov
  0 siblings, 0 replies; 6+ messages in thread
From: Konstantin Ozerkov @ 2011-11-10  9:10 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel@alsa-project.org

On 09.11.11 20:41, Takashi Iwai wrote:
> At Wed, 9 Nov 2011 19:28:53 +0400,
> Konstantin Ozerkov wrote:
>> Improve detection logic as discussed early: add secondary checks by PCI SSID.
>>
>> Note: patch [3/3] is made for alsa-driver tree.
> Thanks, applied now.
>
> The patch 3 couldn't be applied cleanly to my tree, so I refreshed
> by myself.
>
> Which git trees are you referring to?  At the next time, please create
> patches based on sound git tree, which is the base for linux-next:
>    git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
>
> Also for the external alsa-driver, please use the git tree below:
>    git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/alsa-driver-build.git
>
>
> Takashi
Thanks for advise.

I follow tutorial from http://www.alsa-project.org/main/index.php/GIT_Server
I use
git://git.alsa-project.org/alsa-driver.git
git://git.alsa-project.org/alsa-kmirror.git

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-11-10  9:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-09 15:28 [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection Konstantin Ozerkov
2011-11-09 15:28 ` [PATCH 1/3] ALSA: intel8x0: move virtual environment detection code into one place Konstantin Ozerkov
2011-11-09 15:28 ` [PATCH 2/3] ALSA: intel8x0: improve virtual environment detection Konstantin Ozerkov
2011-11-09 15:28 ` [PATCH 3/3] alsa-driver: Fix build intel8x0 Konstantin Ozerkov
2011-11-09 17:41 ` [PATCH 0/3] ALSA: intel8x0: Improve virtual environment detection Takashi Iwai
2011-11-10  9:10   ` Konstantin Ozerkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.