kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] KVM: IRQ ACK notifier should be used with in-kernel irqchip
@ 2008-10-20  8:07 Sheng Yang
  2008-10-22 10:26 ` Avi Kivity
  2008-11-28 10:25 ` Mark McLoughlin
  0 siblings, 2 replies; 22+ messages in thread
From: Sheng Yang @ 2008-10-20  8:07 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, Sheng Yang

Also remove unnecessary parameter of unregister irq ack notifier.

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
 include/linux/kvm_host.h |    3 +--
 virt/kvm/irq_comm.c      |    8 ++++++--
 virt/kvm/kvm_main.c      |    2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index bb92be2..3a0fb77 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -316,8 +316,7 @@ void kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level);
 void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi);
 void kvm_register_irq_ack_notifier(struct kvm *kvm,
 				   struct kvm_irq_ack_notifier *kian);
-void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
-				     struct kvm_irq_ack_notifier *kian);
+void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian);
 int kvm_request_irq_source_id(struct kvm *kvm);
 void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id);
 
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 55ad76e..9fbbdea 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -58,12 +58,16 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi)
 void kvm_register_irq_ack_notifier(struct kvm *kvm,
 				   struct kvm_irq_ack_notifier *kian)
 {
+	/* Must be called with in-kernel IRQ chip, otherwise it's nonsense */
+	ASSERT(irqchip_in_kernel(kvm));
+	ASSERT(kian);
 	hlist_add_head(&kian->link, &kvm->arch.irq_ack_notifier_list);
 }
 
-void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
-				     struct kvm_irq_ack_notifier *kian)
+void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian)
 {
+	if (!kian)
+		return;
 	hlist_del(&kian->link);
 }
 
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a87f45e..4f43abe 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -143,7 +143,7 @@ static void kvm_free_assigned_device(struct kvm *kvm,
 	if (irqchip_in_kernel(kvm) && assigned_dev->irq_requested)
 		free_irq(assigned_dev->host_irq, (void *)assigned_dev);
 
-	kvm_unregister_irq_ack_notifier(kvm, &assigned_dev->ack_notifier);
+	kvm_unregister_irq_ack_notifier(&assigned_dev->ack_notifier);
 	kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id);
 
 	if (cancel_work_sync(&assigned_dev->interrupt_work))
-- 
1.5.4.5


^ permalink raw reply related	[flat|nested] 22+ messages in thread
* [PATCH 1/1] KVM: IRQ ACK notifier should be used with in-kernel irqchip
@ 2008-10-09  8:16 Sheng Yang
  2008-10-09  8:34 ` Avi Kivity
  0 siblings, 1 reply; 22+ messages in thread
From: Sheng Yang @ 2008-10-09  8:16 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, Amit Shah, Sheng Yang

Also remove unnecessary parameter of unregister irq ack notifier.

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
 include/linux/kvm_host.h |    3 +--
 virt/kvm/irq_comm.c      |    8 ++++++--
 virt/kvm/kvm_main.c      |    2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 3833c48..41955ed 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -313,8 +313,7 @@ void kvm_set_irq(struct kvm *kvm, int irq, int level);
 void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi);
 void kvm_register_irq_ack_notifier(struct kvm *kvm,
 				   struct kvm_irq_ack_notifier *kian);
-void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
-				     struct kvm_irq_ack_notifier *kian);
+void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian);
 
 #ifdef CONFIG_DMAR
 int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn,
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index d0169f5..54b251d 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -50,11 +50,15 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi)
 void kvm_register_irq_ack_notifier(struct kvm *kvm,
 				   struct kvm_irq_ack_notifier *kian)
 {
+	/* Must be called with in-kernel IRQ chip, otherwise it's nonsense */
+	ASSERT(irqchip_in_kernel(kvm));
+	ASSERT(kian);
 	hlist_add_head(&kian->link, &kvm->arch.irq_ack_notifier_list);
 }
 
-void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
-				     struct kvm_irq_ack_notifier *kian)
+void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian)
 {
+	if (!kian)
+		return;
 	hlist_del(&kian->link);
 }
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index cf0ab8e..d2ae1c9 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -145,7 +145,7 @@ static void kvm_free_assigned_device(struct kvm *kvm,
 	if (irqchip_in_kernel(kvm) && assigned_dev->irq_requested)
 		free_irq(assigned_dev->host_irq, (void *)assigned_dev);
 
-	kvm_unregister_irq_ack_notifier(kvm, &assigned_dev->ack_notifier);
+	kvm_unregister_irq_ack_notifier(&assigned_dev->ack_notifier);
 
 	if (cancel_work_sync(&assigned_dev->interrupt_work))
 		/* We had pending work. That means we will have to take
-- 
1.5.4.5


^ permalink raw reply related	[flat|nested] 22+ messages in thread
* Re: [PATCH] KVM: Unregister IRQ ACK notifier with in-kernel irqchip
@ 2008-10-08  9:04 Sheng Yang
  2008-10-08  9:28 ` [PATCH 1/1] KVM: IRQ ACK notifier should be used " Sheng Yang
  0 siblings, 1 reply; 22+ messages in thread
From: Sheng Yang @ 2008-10-08  9:04 UTC (permalink / raw)
  To: kvm; +Cc: Amit Shah, Avi Kivity

On Wednesday 08 October 2008 16:54:18 Sheng Yang wrote:
> On Wednesday 08 October 2008 15:08:52 Amit Shah wrote:
> > * On Wednesday 08 Oct 2008 12:09:20 Sheng Yang wrote:
> > > Signed-off-by: Sheng Yang <sheng@linux.intel.com>
> > > ---
> > >  arch/x86/kvm/x86.c |    4 +++-
> > >  1 files changed, 3 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > > index 675fcc1..c5763d7 100644
> > > --- a/arch/x86/kvm/x86.c
> > > +++ b/arch/x86/kvm/x86.c
> > > @@ -176,7 +176,9 @@ static void kvm_free_assigned_device(struct kvm
> > > *kvm, if (irqchip_in_kernel(kvm) && assigned_dev->irq_requested)
> > >  		free_irq(assigned_dev->host_irq, (void *)assigned_dev);
> > >
> > > -	kvm_unregister_irq_ack_notifier(kvm, &assigned_dev->ack_notifier);
> > > +	if (irqchip_in_kernel(kvm))
> > > +		kvm_unregister_irq_ack_notifier(kvm,
> > > +				&assigned_dev->ack_notifier);
> >
> > The unregister API should perform the check whether the said notifier
> > exists so this shouldn't be necessary.
>
> Yeah, that's more reasonable. But now I just see,
> kvm_register_irq_ack_notifier() go with irqchip_in_kernel() and unregister
> didn't. :)
>
Um... After consider a little more, I think keep it unwrapped by 
irqchip_in_kernel() may be a little more reasonable. The reason is we just 
register kvm_register_irq_ack_notifier() when we have in kernel irqchip. If 
we don't have in kernel irqchip, we shouldn't call them and try to perform 
this action. Call the function without in-kernel irqchip is wrong, ensure the 
exist of in-kernel irqchip is the caller's responsibility. What we can do is 
add a BUG_ON() or ASSERT() to the function, rather let the function tell if 
itself need in-kernel irqchip. 

I will update the patch to say we need in kernel irqchip when call the 
function explicitly. 

Thanks!
--
regards
Yang, Sheng

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

end of thread, other threads:[~2008-12-02 12:41 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-20  8:07 [PATCH 1/1] KVM: IRQ ACK notifier should be used with in-kernel irqchip Sheng Yang
2008-10-22 10:26 ` Avi Kivity
2008-11-28 10:25 ` Mark McLoughlin
2008-11-28 10:26   ` [PATCH 1/4] KVM: remove the IRQ ACK notifier assertions Mark McLoughlin
2008-11-28 10:26     ` [PATCH 2/4] KVM: make kvm_unregister_irq_ack_notifier() safe Mark McLoughlin
2008-11-28 10:26       ` [PATCH 3/4] KVM: gracefully handle zero in kvm_free_irq_source_id() Mark McLoughlin
2008-11-28 10:26         ` [PATCH 4/4] KVM: split out kvm_free_assigned_irq() Mark McLoughlin
2008-11-30 10:28         ` [PATCH 3/4] KVM: gracefully handle zero in kvm_free_irq_source_id() Avi Kivity
2008-12-01 13:56           ` Mark McLoughlin
2008-12-01 13:57             ` [PATCH 1/5] KVM: remove the IRQ ACK notifier assertions Mark McLoughlin
2008-12-01 13:57               ` [PATCH 2/5] KVM: make kvm_unregister_irq_ack_notifier() safe Mark McLoughlin
2008-12-01 13:57                 ` [PATCH 3/5] KVM: don't fee an unallocated irq source id Mark McLoughlin
2008-12-01 13:57                   ` [PATCH 4/5] KVM: add KVM_USERSPACE_IRQ_SOURCE_ID assertions Mark McLoughlin
2008-12-01 13:57                     ` [PATCH 5/5] KVM: split out kvm_free_assigned_irq() Mark McLoughlin
2008-12-02 12:41                     ` [PATCH 4/5] KVM: add KVM_USERSPACE_IRQ_SOURCE_ID assertions Avi Kivity
2008-12-02 12:39               ` [PATCH 1/5] KVM: remove the IRQ ACK notifier assertions Avi Kivity
2008-12-01  2:31   ` [PATCH 1/1] KVM: IRQ ACK notifier should be used with in-kernel irqchip Sheng Yang
  -- strict thread matches above, loose matches on Subject: below --
2008-10-09  8:16 Sheng Yang
2008-10-09  8:34 ` Avi Kivity
2008-10-09  8:43   ` Sheng Yang
2008-10-19  9:16     ` Avi Kivity
2008-10-08  9:04 [PATCH] KVM: Unregister IRQ ACK notifier " Sheng Yang
2008-10-08  9:28 ` [PATCH 1/1] KVM: IRQ ACK notifier should be used " Sheng Yang

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).