From: Amit Shah Subject: Re: [PATCH 4/8] KVM: PCIPT: fix interrupt handling Date: Thu, 24 Jul 2008 19:01:51 +0530 Message-ID: <200807241901.52049.amit.shah@qumranet.com> References: <1216214225-18030-1-git-send-email-benami@il.ibm.com> <200807231907.50900.amit.shah@qumranet.com> <1216898937.7822.18.camel@cluwyn.haifa.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Muli Ben-Yehuda , weidong.han@intel.com, anthony@codemonkey.ws To: Ben-Ami Yassour Return-path: Received: from mis011-1.exch011.intermedia.net ([64.78.21.221]:43512 "EHLO mis011-1.exch011.intermedia.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1756240AbYGXNce (ORCPT ); Thu, 24 Jul 2008 09:32:34 -0400 In-Reply-To: <1216898937.7822.18.camel@cluwyn.haifa.ibm.com> Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: * On Thursday 24 Jul 2008 16:58:57 Ben-Ami Yassour wrote: > On Wed, 2008-07-23 at 19:07 +0530, Amit Shah wrote: > > * On Wednesday 16 Jul 2008 18:47:01 Ben-Ami Yassour wrote: > > > This patch fixes a few problems with the interrupt handling for > > > passthrough devices. > > > > > > 1. Pass the interrupt handler the pointer to the device, so we do not > > > need to lock the pcipt lock in the interrupt handler. > > > > > > 2. Remove the pt_irq_handled bitmap - it is no longer needed. > > > > > > 3. Split kvm_pci_pt_work_fn into two functions, one for interrupt > > > injection and another for the ack - is much simpler code this way. > > > > > > 4. Change the passthrough initialization order - add the device > > > structure to the list, before registering the interrupt handler. > > > > > > 5. On passthrough destruction path, free the interrupt handler before > > > cleaning queued work. > > > > > > Signed-off-by: Ben-Ami Yassour > > > --- > > > > > > if (irqchip_in_kernel(kvm)) { > > > + match->pt_dev.guest.irq = pci_pt_dev->guest.irq; > > > + match->pt_dev.host.irq = dev->irq; > > > + if (kvm->arch.vioapic) > > > + kvm->arch.vioapic->ack_notifier = kvm_pci_pt_ack_irq; > > > + if (kvm->arch.vpic) > > > + kvm->arch.vpic->ack_notifier = kvm_pci_pt_ack_irq; > > > + > > > > We shouldn't register this notifier unless we get the irq below to avoid > > unneeded function calls and checks. > > Note: This code was changed in the last version of the code but the > comment is still relevant. > > Do you mean that we need to postpone registering the notification? I mean we can register these function pointers after the request_irq succeeds. > In the case of an assigned device this is means the we postpone it for a > few seconds, and implementing it like above it cleaner. So I don't see > the real value in postponing it. Sorry, don't get what you mean here.