diff mbox

KVM: Fix assigned device with no irq

Message ID 1236076755-14328-1-git-send-email-sheng@linux.intel.com (mailing list archive)
State Superseded
Headers show

Commit Message

Sheng Yang March 3, 2009, 10:39 a.m. UTC
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).

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

Comments

Avi Kivity May 7, 2009, 12:24 p.m. UTC | #1
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).
>
>   

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


> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 4d2be16..ce80f3a 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -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 */
>
Marcelo Tosatti May 7, 2009, 12:28 p.m. UTC | #2
On Thu, May 07, 2009 at 03:24:15PM +0300, Avi Kivity wrote:
> 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).
>>
>>   
>
> Just noticed I missed this patch.  Is it still needed or is it obsolete?

I think its obsolete. 


>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> index 4d2be16..ce80f3a 100644
>> --- a/virt/kvm/kvm_main.c
>> +++ b/virt/kvm/kvm_main.c
>> @@ -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 */
>>   
>
>
> -- 
> error compiling committee.c: too many arguments to function
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sheng Yang May 7, 2009, 12:32 p.m. UTC | #3
On Thursday 07 May 2009 20:28:12 Marcelo Tosatti wrote:
> On Thu, May 07, 2009 at 03:24:15PM +0300, Avi Kivity wrote:
> > 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).
> >
> > 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.
diff mbox

Patch

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 4d2be16..ce80f3a 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -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 */