qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Wierd hack to sound/pci/intel8x0.c
@ 2011-11-06 14:51 Avi Kivity
  2011-11-06 16:15 ` Denis V. Lunev
  0 siblings, 1 reply; 12+ messages in thread
From: Avi Kivity @ 2011-11-06 14:51 UTC (permalink / raw)
  To: Konstantin Ozerkov
  Cc: alsa-devel, KVM list, Takashi Iwai, qemu-devel, Denis V. Lunev,
	Linus Torvalds

The recently merged 228cf79376f1 ("ALSA: intel8x0: Improve performance
in virtual environment") is hacky and somewhat wrong.

First, the detection code

+       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
+       }
+
 
is incorrect.  It detects that you're running in a guest, but that
doesn't imply that the device you're accessing is emulated.  It may be a
host device assigned to the guest; presumably the optimization you apply
doesn't work for real devices.

Second, the optimization itself looks fishy:

        spin_lock(&chip->reg_lock);
        do {
                civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV);
                ptr1 = igetword(chip, ichdev->reg_offset +
ichdev->roff_picb);
                position = ichdev->position;
                if (ptr1 == 0) {
                        udelay(10);
                        continue;
                }
-               if (civ == igetbyte(chip, ichdev->reg_offset +
ICH_REG_OFF_CIV) &&
-                   ptr1 == igetword(chip, ichdev->reg_offset +
ichdev->roff_picb))
+               if (civ != igetbyte(chip, ichdev->reg_offset +
ICH_REG_OFF_CIV))
+                       continue;
+               if (chip->inside_vm)
+                       break;
+               if (ptr1 == igetword(chip, ichdev->reg_offset +
ichdev->roff_picb))
                        break;
        } while (timeout--);


Why is the emulated device timing out?  Can't the emulation be fixed to
behave like real hardware?

Last, please copy kvm@vger.kernel.org on such issues.

-- 
error compiling committee.c: too many arguments to function

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

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

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-06 14:51 [Qemu-devel] Wierd hack to sound/pci/intel8x0.c Avi Kivity
2011-11-06 16:15 ` Denis V. Lunev
2011-11-06 16:31   ` Avi Kivity
2011-11-06 16:47     ` Takashi Iwai
2011-11-06 16:56       ` Denis V. Lunev
2011-11-06 16:50     ` Denis V. Lunev
2011-11-06 16:33   ` Takashi Iwai
2011-11-07  9:25     ` Gerd Hoffmann
2011-11-07  9:52       ` Konstantin Ozerkov
2011-11-07 10:35         ` Gerd Hoffmann
2011-11-07 10:45           ` Takashi Iwai
2011-11-07 10:44       ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).