virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Zhu Lingshan <lingshan.zhu@intel.com>
Cc: wanpengli@tencent.com, kvm@vger.kernel.org,
	netdev@vger.kernel.org, sean.j.christopherson@intel.com,
	virtualization@lists.linux-foundation.org, pbonzini@redhat.com,
	"./0000-cover-letter.patch"@redhat.com
Subject: Re: [PATCH 2/7] kvm/vfio: detect assigned device via irqbypass manager
Date: Sun, 12 Jul 2020 17:06:27 -0400	[thread overview]
Message-ID: <20200712170518-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1594565366-3195-2-git-send-email-lingshan.zhu@intel.com>

On Sun, Jul 12, 2020 at 10:49:21PM +0800, Zhu Lingshan wrote:
> We used to detect assigned device via VFIO manipulated device
> conters. This is less flexible consider VFIO is not the only
> interface for assigned device. vDPA devices has dedicated
> backed hardware as well. So this patch tries to detect
> the assigned device via irqbypass manager.
> 
> We will increase/decrease the assigned device counter in kvm/x86.
> Both vDPA and VFIO would go through this code path.
> 
> This code path only affect x86 for now.
> 
> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>


I think it's best to leave VFIO alone. Add appropriate APIs for VDPA,
worry about converting existing users later.

> ---
>  arch/x86/kvm/x86.c | 10 ++++++++--
>  virt/kvm/vfio.c    |  2 --
>  2 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 00c88c2..20c07d3 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -10624,11 +10624,17 @@ int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons,
>  {
>  	struct kvm_kernel_irqfd *irqfd =
>  		container_of(cons, struct kvm_kernel_irqfd, consumer);
> +	int ret;
>  
>  	irqfd->producer = prod;
> +	kvm_arch_start_assignment(irqfd->kvm);
> +	ret = kvm_x86_ops.update_pi_irte(irqfd->kvm,
> +					 prod->irq, irqfd->gsi, 1);
> +
> +	if (ret)
> +		kvm_arch_end_assignment(irqfd->kvm);
>  
> -	return kvm_x86_ops.update_pi_irte(irqfd->kvm,
> -					   prod->irq, irqfd->gsi, 1);
> +	return ret;
>  }
>  
>  void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
> diff --git a/virt/kvm/vfio.c b/virt/kvm/vfio.c
> index 8fcbc50..111da52 100644
> --- a/virt/kvm/vfio.c
> +++ b/virt/kvm/vfio.c
> @@ -226,7 +226,6 @@ static int kvm_vfio_set_group(struct kvm_device *dev, long attr, u64 arg)
>  		list_add_tail(&kvg->node, &kv->group_list);
>  		kvg->vfio_group = vfio_group;
>  
> -		kvm_arch_start_assignment(dev->kvm);
>  
>  		mutex_unlock(&kv->lock);
>  
> @@ -254,7 +253,6 @@ static int kvm_vfio_set_group(struct kvm_device *dev, long attr, u64 arg)
>  				continue;
>  
>  			list_del(&kvg->node);
> -			kvm_arch_end_assignment(dev->kvm);
>  #ifdef CONFIG_SPAPR_TCE_IOMMU
>  			kvm_spapr_tce_release_vfio_group(dev->kvm,
>  							 kvg->vfio_group);
> -- 
> 1.8.3.1

  parent reply	other threads:[~2020-07-12 21:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1594565366-3195-1-git-send-email-lingshan.zhu@intel.com>
     [not found] ` <1594565366-3195-2-git-send-email-lingshan.zhu@intel.com>
2020-07-12 15:29   ` [PATCH 2/7] kvm/vfio: detect assigned device via irqbypass manager Alex Williamson
2020-07-13  7:57     ` Jason Wang
2020-07-12 21:06   ` Michael S. Tsirkin [this message]
2020-07-13  8:13     ` Jason Wang
2020-07-13 10:52       ` Michael S. Tsirkin
     [not found]         ` <aca899f7-ec2e-2b55-df78-44eacb923c00@intel.com>
2020-07-14  9:03           ` Michael S. Tsirkin
     [not found] ` <1594565366-3195-3-git-send-email-lingshan.zhu@intel.com>
2020-07-13  8:22   ` [PATCH 3/7] vhost_vdpa: implement IRQ offloading functions in vhost_vdpa Jason Wang
     [not found]     ` <e06f9706-441f-0d7a-c8c0-cd43a26c5296@intel.com>
2020-07-15  8:51       ` Jason Wang
     [not found]         ` <8f52ee3a-7a08-db14-9194-8085432481a4@intel.com>
2020-07-15  9:06           ` Jason Wang
     [not found]             ` <61c1753a-43dc-e448-6ece-13a19058e621@intel.com>
2020-07-15  9:42               ` Jason Wang
2020-07-15 11:09                 ` Zhu, Lingshan
     [not found] ` <1594565366-3195-4-git-send-email-lingshan.zhu@intel.com>
2020-07-13  8:27   ` [PATCH 4/7] vDPA: implement IRQ offloading helpers in vDPA core Jason Wang
     [not found] ` <1594565366-3195-5-git-send-email-lingshan.zhu@intel.com>
2020-07-13  8:28   ` [PATCH 5/7] virtio_vdpa: init IRQ offloading function pointers to NULL Jason Wang
     [not found]     ` <ba1ea94c-b0ae-8bd8-8425-64b096512d3d@intel.com>
2020-07-15  8:43       ` Jason Wang
     [not found] ` <1594565366-3195-6-git-send-email-lingshan.zhu@intel.com>
2020-07-13  8:33   ` [PATCH 6/7] ifcvf: replace irq_request/free with helpers in vDPA core Jason Wang
     [not found]     ` <f6fc09e2-7a45-aaa5-2b4a-f1f963c5ce2c@intel.com>
2020-07-15  8:40       ` Jason Wang
2020-07-15 10:01         ` Michael S. Tsirkin
2020-07-15 10:04           ` Jason Wang
2020-07-15 11:10             ` Zhu, Lingshan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200712170518-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc="./0000-cover-letter.patch"@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lingshan.zhu@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wanpengli@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).