Re: [PATCH v5 kvmtool 03/13] irq: add irqfd helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 15, 2018 at 03:04:54PM +0000, Jean-Philippe Brucker wrote:
> Add helpers to add and remove IRQFD routing for both irqchips and MSIs.
> We have to make a special case of IRQ lines on ARM where the
> initialisation order goes like this:
> 
>  (1) Devices reserve their IRQ lines
>  (2) VGIC is setup with VGIC_CTRL_INIT (in a late_init call)
>  (3) MSIs are reserved lazily, when the guest needs them
> 
> Since we cannot setup IRQFD before (2), store the IRQFD routing for IRQ
> lines temporarily until we're ready to submit them.
> 
> Reviewed-by: Punit Agrawal <punit.agrawal@xxxxxxx>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@xxxxxxx>
> ---
>  arm/gic.c                    | 74 +++++++++++++++++++++++++++++++++++++++++++-
>  arm/include/arm-common/gic.h |  6 ++++
>  hw/pci-shmem.c               |  8 +----
>  include/kvm/irq.h            | 17 ++++++++++
>  irq.c                        | 31 +++++++++++++++++++
>  virtio/net.c                 |  9 ++----
>  virtio/scsi.c                | 10 ++----
>  7 files changed, 133 insertions(+), 22 deletions(-)
> 
> diff --git a/arm/gic.c b/arm/gic.c
> index aca0b93975d7..46cfa245e590 100644
> --- a/arm/gic.c
> +++ b/arm/gic.c
> @@ -17,6 +17,14 @@ static u64 gic_redists_base;
>  static u64 gic_redists_size;
>  static u64 gic_msi_base;
>  static u64 gic_msi_size = 0;
> +static bool vgic_is_init = false;
> +
> +struct kvm_irqfd_line {
> +	struct kvm_irqfd	irqfd;
> +	struct list_head	list;
> +};
> +
> +static LIST_HEAD(irqfd_lines);
>  
>  int irqchip_parser(const struct option *opt, const char *arg, int unset)
>  {
> @@ -38,6 +46,25 @@ int irqchip_parser(const struct option *opt, const char *arg, int unset)
>  	return 0;
>  }
>  
> +static int irq__setup_irqfd_lines(struct kvm *kvm)
> +{
> +	int ret;
> +	struct kvm_irqfd_line *line, *tmp;
> +
> +	list_for_each_entry_safe(line, tmp, &irqfd_lines, list) {
> +		ret = ioctl(kvm->vm_fd, KVM_IRQFD, &line->irqfd);
> +		if (ret < 0) {
> +			pr_err("Failed to register IRQFD");
> +			return ret;
> +		}

I think it would be cleaner to call irq__common_add_irqfd here, and have
that take care of constructing the kvm_irqfd. Still, this is gic-specific
backend code so we can always rework that later.

Will



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux