From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Wierd hack to sound/pci/intel8x0.c Date: Sun, 06 Nov 2011 16:51:06 +0200 Message-ID: <4EB69EDA.5000901@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: Sender: kvm-owner@vger.kernel.org To: Konstantin Ozerkov Cc: "Denis V. Lunev" , Takashi Iwai , Linus Torvalds , alsa-devel@alsa-project.org, KVM list , qemu-devel List-Id: alsa-devel@alsa-project.org 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RN447-0003bZ-J2 for qemu-devel@nongnu.org; Sun, 06 Nov 2011 09:51:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RN446-0002OJ-6h for qemu-devel@nongnu.org; Sun, 06 Nov 2011 09:51:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32706) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RN445-0002O3-Ry for qemu-devel@nongnu.org; Sun, 06 Nov 2011 09:51:18 -0500 Message-ID: <4EB69EDA.5000901@redhat.com> Date: Sun, 06 Nov 2011 16:51:06 +0200 From: Avi Kivity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Wierd hack to sound/pci/intel8x0.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Konstantin Ozerkov Cc: alsa-devel@alsa-project.org, 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