Skip to contentSkip to conversation

KVM: Fix assigned device with no irq

PATCH In review Sheng Yang 3 participants 6 messages Mar 3, 2009 – May 7, 2009 KVM

lore
Share & tools
lore

Sheng Yang

author
#0 lore raw

PATCH 1/1 KVM: Fix assigned device with no irq

Some device like VF of SRIOV only support MSI-X.

With this patch, SRIOV can be enabled with KVM assigned device(all kernel space patches are ready).

---
 virt/kvm/kvm_main.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
virt/kvm/kvm_main.c +6 -3
index 4d2be16..5dc6423 100644
@@ -308,6 +308,10 @@ static int assigned_device_update_intx(struct kvm *kvm,
 	if (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_INTX)
 		return 0;
 
+	/* IRQ 0 means uninitialized */
+	if (adev->host_irq == 0)
+		return 0;
+
 	if (irqchip_in_kernel(kvm)) {
 		if (!msi2intx &&
 		    (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)) {
@@ -529,9 +533,8 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm,
 			r = 0;
 		} else {
 			printk(KERN_WARNING
-			       "kvm: failed to enable MSI device!\n");
-			r = -ENOTTY;
-			goto out_release;
+			       "kvm: device didn't support INTx or MSI!\n");
+			r = 0;
 		}
 	} else {
 		/* Non-sharing INTx mode */
Signature · 1 line
1.5.4.5
author
#1 lore raw
Quoted 5 lines · On Tuesday 03 March 2009 15:49:19 Sheng Yang wrote:

Some device like VF of SRIOV only support MSI-X.

With this patch, SRIOV can be enabled with KVM assigned device(all kernel space patches are ready).

Withdraw this as well.

Signature · 2 lines
regards
Yang, Sheng
Quoted 32 lines
---
 virt/kvm/kvm_main.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
virt/kvm/kvm_main.c +6 -3
index 4d2be16..5dc6423 100644
@@ -308,6 +308,10 @@ static int assigned_device_update_intx(struct kvm
 *kvm, if (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_INTX)
 		return 0;
 
+	/* IRQ 0 means uninitialized */
+	if (adev->host_irq == 0)
+		return 0;
+
 	if (irqchip_in_kernel(kvm)) {
 		if (!msi2intx &&
 		    (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)) {
@@ -529,9 +533,8 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm,
 			r = 0;
 		} else {
 			printk(KERN_WARNING
-			       "kvm: failed to enable MSI device!\n");
-			r = -ENOTTY;
-			goto out_release;
+			       "kvm: device didn't support INTx or MSI!\n");
+			r = 0;
 		}
 	} else {
 		/* Non-sharing INTx mode */
author
#2 lore raw

PATCH 1/1 KVM: Fix assigned device with no irq

Some device like VF of SRIOV only support MSI-X.

With this patch, SRIOV can be enabled with KVM assigned device(all kernel space patches are ready).

---
 virt/kvm/kvm_main.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
virt/kvm/kvm_main.c +10 -4
index 4d2be16..ce80f3a 100644
@@ -217,8 +217,11 @@ static void kvm_free_assigned_irq(struct kvm *kvm,
 		kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id);
 	assigned_dev->irq_source_id = -1;
 
-	if (!assigned_dev->irq_requested_type)
+	if (!assigned_dev->irq_requested_type) {
+		if (assigned_dev->dev->msi_enabled)
+			pci_disable_msi(assigned_dev->dev);
 		return;
+	}
 
 	/*
 	 * In kvm_free_device_irq, cancel_work_sync return true if:
@@ -308,6 +311,10 @@ static int assigned_device_update_intx(struct kvm *kvm,
 	if (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_INTX)
 		return 0;
 
+	/* IRQ 0 means uninitialized here */
+	if (airq->host_irq == 0)
+		return 0;
+
 	if (irqchip_in_kernel(kvm)) {
 		if (!msi2intx &&
 		    (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)) {
@@ -529,9 +536,8 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm,
 			r = 0;
 		} else {
 			printk(KERN_WARNING
-			       "kvm: failed to enable MSI device!\n");
-			r = -ENOTTY;
-			goto out_release;
+			       "kvm: device didn't support INTx or MSI!\n");
+			r = 0;
 		}
 	} else {
 		/* Non-sharing INTx mode */
Signature · 1 line
1.5.4.5
#3 lore raw
Quoted 6 lines · Sheng Yang

Some device like VF of SRIOV only support MSI-X.

With this patch, SRIOV can be enabled with KVM assigned device(all kernel space patches are ready).

Just noticed I missed this patch. Is it still needed or is it obsolete?

Quoted 41 lines
virt/kvm/kvm_main.c +10 -4
index 4d2be16..ce80f3a 100644
@@ -217,8 +217,11 @@ static void kvm_free_assigned_irq(struct kvm *kvm,
 		kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id);
 	assigned_dev->irq_source_id = -1;
 
-	if (!assigned_dev->irq_requested_type)
+	if (!assigned_dev->irq_requested_type) {
+		if (assigned_dev->dev->msi_enabled)
+			pci_disable_msi(assigned_dev->dev);
 		return;
+	}
 
 	/*
 	 * In kvm_free_device_irq, cancel_work_sync return true if:
@@ -308,6 +311,10 @@ static int assigned_device_update_intx(struct kvm *kvm,
 	if (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_INTX)
 		return 0;
 
+	/* IRQ 0 means uninitialized here */
+	if (airq->host_irq == 0)
+		return 0;
+
 	if (irqchip_in_kernel(kvm)) {
 		if (!msi2intx &&
 		    (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)) {
@@ -529,9 +536,8 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm,
 			r = 0;
 		} else {
 			printk(KERN_WARNING
-			       "kvm: failed to enable MSI device!\n");
-			r = -ENOTTY;
-			goto out_release;
+			       "kvm: device didn't support INTx or MSI!\n");
+			r = 0;
 		}
 	} else {
 		/* Non-sharing INTx mode */
Signature · 1 line
error compiling committee.c: too many arguments to function
#4 lore raw
Quoted 9 lines · Avi Kivity
Quoted 6 lines · Sheng Yang

Some device like VF of SRIOV only support MSI-X.

With this patch, SRIOV can be enabled with KVM assigned device(all kernel space patches are ready).

Just noticed I missed this patch. Is it still needed or is it obsolete?

I think its obsolete.

Quoted 42 lines
Quoted 38 lines
virt/kvm/kvm_main.c +9 -3
index 4d2be16..ce80f3a 100644
@@ -217,8 +217,11 @@ static void kvm_free_assigned_irq(struct kvm *kvm,
 		kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id);
 	assigned_dev->irq_source_id = -1;
 -	if (!assigned_dev->irq_requested_type)
+	if (!assigned_dev->irq_requested_type) {
+		if (assigned_dev->dev->msi_enabled)
+			pci_disable_msi(assigned_dev->dev);
 		return;
+	}
  	/*
 	 * In kvm_free_device_irq, cancel_work_sync return true if:
@@ -308,6 +311,10 @@ static int assigned_device_update_intx(struct kvm *kvm,
 	if (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_INTX)
 		return 0;
 +	/* IRQ 0 means uninitialized here */
+	if (airq->host_irq == 0)
+		return 0;
+
 	if (irqchip_in_kernel(kvm)) {
 		if (!msi2intx &&
 		    (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)) {
@@ -529,9 +536,8 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm,
 			r = 0;
 		} else {
 			printk(KERN_WARNING
-			       "kvm: failed to enable MSI device!\n");
-			r = -ENOTTY;
-			goto out_release;
+			       "kvm: device didn't support INTx or MSI!\n");
+			r = 0;
 		}
 	} else {
 		/* Non-sharing INTx mode */
Signature · 1 line
error compiling committee.c: too many arguments to function
author
#5 lore raw
Quoted 10 lines · On Thursday 07 May 2009 20:28:12 Marcelo Tosatti wrote:
Quoted 7 lines · Avi Kivity
Quoted 4 lines · Sheng Yang

Some device like VF of SRIOV only support MSI-X.

With this patch, SRIOV can be enabled with KVM assigned device(all kernel space patches are ready).

Just noticed I missed this patch. Is it still needed or is it obsolete?

I think its obsolete.

Yeah, it have been fixed from another direct in userspace: Interrupt pin =0 means it haven't been initialized.

Signature · 2 lines
regards
Yang, Sheng
Quoted 41 lines
Quoted 41 lines
Quoted 28 lines
virt/kvm/kvm_main.c +7 -0
index 4d2be16..ce80f3a 100644
@@ -217,8 +217,11 @@ static void kvm_free_assigned_irq(struct kvm *kvm,
 		kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id);
 	assigned_dev->irq_source_id = -1;
 -	if (!assigned_dev->irq_requested_type)
+	if (!assigned_dev->irq_requested_type) {
+		if (assigned_dev->dev->msi_enabled)
+			pci_disable_msi(assigned_dev->dev);
 		return;
+	}
  	/*
 	 * In kvm_free_device_irq, cancel_work_sync return true if:
@@ -308,6 +311,10 @@ static int assigned_device_update_intx(struct kvm
 *kvm, if (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_INTX)
 		return 0;
 +	/* IRQ 0 means uninitialized here */
+	if (airq->host_irq == 0)
+		return 0;
+
 	if (irqchip_in_kernel(kvm)) {
 		if (!msi2intx &&
 		    (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)) {
@@ -529,9 +536,8 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm,
 			r = 0;

virt/kvm/kvm_main.c static int kvm_vm_ioctl_assign_irq(struct kvm *kvm, · line 543

Quoted 10 lines
virt/kvm/kvm_main.c +2 -3
 		} else {
 			printk(KERN_WARNING
-			       "kvm: failed to enable MSI device!\n");
-			r = -ENOTTY;
-			goto out_release;
+			       "kvm: device didn't support INTx or MSI!\n");
+			r = 0;
 		}
 	} else {
 		/* Non-sharing INTx mode */

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