From: Jiang Liu <jiang.liu@linux.intel.com>
To: Feng Wu <feng.wu@intel.com>,
tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [v4 1/3] genirq: Introduce irq_set_vcpu_affinity() to target an interrupt to a VCPU
Date: Wed, 13 May 2015 16:09:45 +0800 [thread overview]
Message-ID: <555306C9.6040405@linux.intel.com> (raw)
In-Reply-To: <1430377608-10490-2-git-send-email-feng.wu@intel.com>
On 2015/4/30 15:06, Feng Wu wrote:
> With Posted-Interrupts support in Intel CPU and IOMMU, an external
> interrupt from assigned-devices could be directly delivered to a
> virtual CPU in a virtual machine. Instead of hacking KVM and Intel
> IOMMU drivers, we propose a platform independent interface to target
> an interrupt to a specific virtual CPU in a virtual machine, or set
> virtual CPU affinity for an interrupt.
>
> By adopting this new interface and the hierarchy irqdomain, we could
> easily support posted-interrupts on Intel platforms, and also provide
> flexible enough interfaces for other platforms to support similar
> features.
>
> Here is the usage scenario for this interface:
> Guest update MSI/MSI-X interrupt configuration
> -->QEMU and KVM handle this
> -->KVM call this interface (passing posted interrupts descriptor
> and guest vector)
> -->irq core will transfer the control to IOMMU
> -->IOMMU will do the real work of updating IRTE (IRTE has new
> format for VT-d Posted-Interrupts)
Hi Thomas,
Any comments or suggestions about this abstraction interface?
Thanks!
Gerry
>
> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
> Signed-off-by: Feng Wu <feng.wu@intel.com>
> ---
> include/linux/irq.h | 4 ++++
> kernel/irq/chip.c | 14 ++++++++++++++
> kernel/irq/manage.c | 20 ++++++++++++++++++++
> 3 files changed, 38 insertions(+)
>
> diff --git a/include/linux/irq.h b/include/linux/irq.h
> index 62c6901..684c35d 100644
> --- a/include/linux/irq.h
> +++ b/include/linux/irq.h
> @@ -327,6 +327,7 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
> * @irq_write_msi_msg: optional to write message content for MSI
> * @irq_get_irqchip_state: return the internal state of an interrupt
> * @irq_set_irqchip_state: set the internal state of a interrupt
> + * @irq_set_vcpu_affinity: optional to target a virtual CPU in a virtual
> * @flags: chip specific flags
> */
> struct irq_chip {
> @@ -369,6 +370,8 @@ struct irq_chip {
> int (*irq_get_irqchip_state)(struct irq_data *data, enum irqchip_irq_state which, bool *state);
> int (*irq_set_irqchip_state)(struct irq_data *data, enum irqchip_irq_state which, bool state);
>
> + int (*irq_set_vcpu_affinity)(struct irq_data *data, void *vcpu_info);
> +
> unsigned long flags;
> };
>
> @@ -422,6 +425,7 @@ extern void irq_cpu_online(void);
> extern void irq_cpu_offline(void);
> extern int irq_set_affinity_locked(struct irq_data *data,
> const struct cpumask *cpumask, bool force);
> +extern int irq_set_vcpu_affinity(unsigned int irq, void *vcpu_info);
>
> #if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_PENDING_IRQ)
> void irq_move_irq(struct irq_data *data);
> diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
> index eb9a4ea..55016b2 100644
> --- a/kernel/irq/chip.c
> +++ b/kernel/irq/chip.c
> @@ -950,6 +950,20 @@ int irq_chip_retrigger_hierarchy(struct irq_data *data)
> }
>
> /**
> + * irq_chip_set_vcpu_affinity_parent - Set vcpu affinity on the parent interrupt
> + * @data: Pointer to interrupt specific data
> + * @dest: The vcpu affinity information
> + */
> +int irq_chip_set_vcpu_affinity_parent(struct irq_data *data, void *vcpu_info)
> +{
> + data = data->parent_data;
> + if (data->chip->irq_set_vcpu_affinity)
> + return data->chip->irq_set_vcpu_affinity(data, vcpu_info);
> +
> + return -ENOSYS;
> +}
> +
> +/**
> * irq_chip_set_wake_parent - Set/reset wake-up on the parent interrupt
> * @data: Pointer to interrupt specific data
> * @on: Whether to set or reset the wake-up capability of this irq
> diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
> index e68932b..5e09bc2 100644
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -256,6 +256,26 @@ int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
> }
> EXPORT_SYMBOL_GPL(irq_set_affinity_hint);
>
> +int irq_set_vcpu_affinity(unsigned int irq, void *vcpu_info)
> +{
> + struct irq_desc *desc = irq_to_desc(irq);
> + struct irq_chip *chip;
> + unsigned long flags;
> + int ret = -ENOSYS;
> +
> + if (!desc)
> + return -EINVAL;
> +
> + raw_spin_lock_irqsave(&desc->lock, flags);
> + chip = desc->irq_data.chip;
> + if (chip && chip->irq_set_vcpu_affinity)
> + ret = chip->irq_set_vcpu_affinity(irq_desc_get_irq_data(desc),
> + vcpu_info);
> + raw_spin_unlock_irqrestore(&desc->lock, flags);
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(irq_set_vcpu_affinity);
> +
> static void irq_affinity_notify(struct work_struct *work)
> {
> struct irq_affinity_notify *notify =
>
next prev parent reply other threads:[~2015-05-13 8:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-30 7:06 [v4 0/3] prerequisite changes for VT-d posted-interrupts Feng Wu
2015-04-30 7:06 ` [v4 1/3] genirq: Introduce irq_set_vcpu_affinity() to target an interrupt to a VCPU Feng Wu
2015-05-13 8:09 ` Jiang Liu [this message]
2015-05-13 21:03 ` Thomas Gleixner
2015-05-14 1:04 ` Wu, Feng
2015-05-15 13:18 ` Thomas Gleixner
2015-05-18 2:42 ` Wu, Feng
2015-04-30 7:06 ` [v4 2/3] x86, irq: Implement irq_set_vcpu_affinity for pci_msi_ir_controller Feng Wu
2015-05-15 13:19 ` Thomas Gleixner
2015-04-30 7:06 ` [v4 3/3] x86, irq: Define a global vector for VT-d Posted-Interrupts Feng Wu
2015-05-15 13:27 ` Thomas Gleixner
2015-05-18 2:44 ` Wu, Feng
2015-05-07 2:05 ` [v4 0/3] prerequisite changes for VT-d posted-interrupts Wu, Feng
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=555306C9.6040405@linux.intel.com \
--to=jiang.liu@linux.intel.com \
--cc=feng.wu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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