kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/02][v2] Support for disable MSI
@ 2009-01-06  8:25 Sheng Yang
  2009-01-06  8:25 ` [PATCH 1/2] KVM: Fix INTx for device assignment Sheng Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sheng Yang @ 2009-01-06  8:25 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

Change from v2:
Discard first two patches, instead fix bugs in update_intx(). Finally, I
purpose to use kvm_free_assigned_irq(), but before that, I think I have to
split kvm->lock due to cancel_work_sync() implicit need kvm->lock. So leave it
a little later.

--
 include/linux/kvm.h |    1 +
 virt/kvm/kvm_main.c |   22 ++++++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

--
regards
Yang, Sheng

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

* [PATCH 1/2] KVM: Fix INTx for device assignment
  2009-01-06  8:25 [PATCH 00/02][v2] Support for disable MSI Sheng Yang
@ 2009-01-06  8:25 ` Sheng Yang
  2009-01-06  8:25 ` [PATCH 2/2] KVM: Add support to disable MSI for assigned device Sheng Yang
  2009-01-06  9:22 ` [PATCH 00/02][v2] Support for disable MSI Avi Kivity
  2 siblings, 0 replies; 4+ messages in thread
From: Sheng Yang @ 2009-01-06  8:25 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, Sheng Yang

Missing buckets and wrong parameter for free_irq()

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
 virt/kvm/kvm_main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 7a102d7..213bb91 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -296,8 +296,8 @@ static int assigned_device_update_intx(struct kvm *kvm,
 
 	if (irqchip_in_kernel(kvm)) {
 		if (!msi2intx &&
-		    adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI) {
-			free_irq(adev->host_irq, (void *)kvm);
+		    (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)) {
+			free_irq(adev->host_irq, (void *)adev);
 			pci_disable_msi(adev->dev);
 		}
 
-- 
1.5.4.5


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

* [PATCH 2/2] KVM: Add support to disable MSI for assigned device
  2009-01-06  8:25 [PATCH 00/02][v2] Support for disable MSI Sheng Yang
  2009-01-06  8:25 ` [PATCH 1/2] KVM: Fix INTx for device assignment Sheng Yang
@ 2009-01-06  8:25 ` Sheng Yang
  2009-01-06  9:22 ` [PATCH 00/02][v2] Support for disable MSI Avi Kivity
  2 siblings, 0 replies; 4+ messages in thread
From: Sheng Yang @ 2009-01-06  8:25 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, Sheng Yang

MSI is always enabled by default for msi2intx=1. But if msi2intx=0, we
have to disable MSI if guest require to do so.

The patch also discard unnecessary msi2intx judgment if guest want to update
MSI state.

Notice KVM_DEV_IRQ_ASSIGN_MSI_ACTION is a mask which should cover all MSI
related operations, though we only got one for now.

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

diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 4ec359e..71c150f 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -550,6 +550,7 @@ struct kvm_assigned_irq {
 
 #define KVM_DEV_ASSIGN_ENABLE_IOMMU	(1 << 0)
 
+#define KVM_DEV_IRQ_ASSIGN_MSI_ACTION	KVM_DEV_IRQ_ASSIGN_ENABLE_MSI
 #define KVM_DEV_IRQ_ASSIGN_ENABLE_MSI	(1 << 0)
 
 #endif
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 213bb91..dcbfc68 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -343,6 +343,14 @@ static int assigned_device_update_msi(struct kvm *kvm,
 		adev->irq_requested_type &= ~KVM_ASSIGNED_DEV_GUEST_MSI;
 		adev->guest_irq = airq->guest_irq;
 		adev->ack_notifier.gsi = airq->guest_irq;
+	} else {
+		/*
+		 * Guest require to disable device MSI, we disable MSI and
+		 * re-enable INTx by default again. Notice it's only for
+		 * non-msi2intx.
+		 */
+		assigned_device_update_intx(kvm, adev, airq);
+		return 0;
 	}
 
 	if (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)
@@ -379,6 +387,7 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm,
 {
 	int r = 0;
 	struct kvm_assigned_dev_kernel *match;
+	u32 current_flags = 0, changed_flags;
 
 	mutex_lock(&kvm->lock);
 
@@ -416,8 +425,13 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm,
 		}
 	}
 
-	if ((!msi2intx &&
-	     (assigned_irq->flags & KVM_DEV_IRQ_ASSIGN_ENABLE_MSI)) ||
+	if ((match->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI) &&
+		 (match->irq_requested_type & KVM_ASSIGNED_DEV_GUEST_MSI))
+		current_flags |= KVM_DEV_IRQ_ASSIGN_ENABLE_MSI;
+
+	changed_flags = assigned_irq->flags ^ current_flags;
+
+	if ((changed_flags & KVM_DEV_IRQ_ASSIGN_MSI_ACTION) ||
 	    (msi2intx && match->dev->msi_enabled)) {
 #ifdef CONFIG_X86
 		r = assigned_device_update_msi(kvm, match, assigned_irq);
-- 
1.5.4.5


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

* Re: [PATCH 00/02][v2] Support for disable MSI
  2009-01-06  8:25 [PATCH 00/02][v2] Support for disable MSI Sheng Yang
  2009-01-06  8:25 ` [PATCH 1/2] KVM: Fix INTx for device assignment Sheng Yang
  2009-01-06  8:25 ` [PATCH 2/2] KVM: Add support to disable MSI for assigned device Sheng Yang
@ 2009-01-06  9:22 ` Avi Kivity
  2 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2009-01-06  9:22 UTC (permalink / raw)
  To: Sheng Yang; +Cc: kvm

Sheng Yang wrote:
> Change from v2:
> Discard first two patches, instead fix bugs in update_intx(). Finally, I
> purpose to use kvm_free_assigned_irq(), but before that, I think I have to
> split kvm->lock due to cancel_work_sync() implicit need kvm->lock. So leave it
> a little later.
>
>   

Applied, thanks.

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


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

end of thread, other threads:[~2009-01-06  9:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-06  8:25 [PATCH 00/02][v2] Support for disable MSI Sheng Yang
2009-01-06  8:25 ` [PATCH 1/2] KVM: Fix INTx for device assignment Sheng Yang
2009-01-06  8:25 ` [PATCH 2/2] KVM: Add support to disable MSI for assigned device Sheng Yang
2009-01-06  9:22 ` [PATCH 00/02][v2] Support for disable MSI Avi Kivity

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