* [Qemu-devel] [PATCH v6] kvm irqfd: support direct msimessage to irq translation
@ 2013-09-03 8:08 Alexey Kardashevskiy
2013-09-03 8:17 ` Michael S. Tsirkin
2013-09-12 16:32 ` Paolo Bonzini
0 siblings, 2 replies; 6+ messages in thread
From: Alexey Kardashevskiy @ 2013-09-03 8:08 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S . Tsirkin, Alexey Kardashevskiy, Alexander Graf,
qemu-ppc, Paolo Bonzini, Paul Mackerras
On PPC64 systems MSI Messages are translated to system IRQ in a PCI
host bridge. This is already supported for emulated MSI/MSIX but
not for irqfd where the current QEMU allocates IRQ numbers from
irqchip and maps MSIMessages to IRQ in the host kernel.
This adds a new direct mapping flag which tells
the kvm_irqchip_add_msi_route() function that a new VIRQ
should not be allocated, instead the value from MSIMessage::data
should be used. It is up to the platform code to make sure that
this contains a valid IRQ number as sPAPR does in spapr_pci.c.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
The patch does not enable this mapping for any platform in this patch
as it is going be done for spapr only on a separate patch which is not
ready to go as it depends on the in-kernel XICS-KVM patchset which is not
in upstream yet.
---
Changes:
v6:
* simplified to a single global flag and putting an IRQ number
in MSIMessage::data
2013/08/07 v5:
* pci_bus_map_msi now has default behaviour which is to call
kvm_irqchip_add_msi_route
* kvm_irqchip_release_virq fixed not crash when there is no routes
---
include/sysemu/kvm.h | 9 +++++++++
kvm-all.c | 13 +++++++++++++
kvm-stub.c | 1 +
3 files changed, 23 insertions(+)
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 8e76685..0e9ef38 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -46,6 +46,7 @@ extern bool kvm_halt_in_kernel_allowed;
extern bool kvm_irqfds_allowed;
extern bool kvm_msi_via_irqfd_allowed;
extern bool kvm_gsi_routing_allowed;
+extern bool kvm_gsi_direct_mapping;
extern bool kvm_readonly_mem_allowed;
#if defined CONFIG_KVM || !defined NEED_CPU_H
@@ -108,6 +109,13 @@ extern bool kvm_readonly_mem_allowed;
#define kvm_gsi_routing_enabled() (kvm_gsi_routing_allowed)
/**
+ * kvm_gsi_direct_mapping:
+ *
+ * Returns: true if GSI direct mapping is enabled.
+ */
+#define kvm_gsi_direct_mapping() (kvm_gsi_direct_mapping)
+
+/**
* kvm_readonly_mem_enabled:
*
* Returns: true if KVM readonly memory is enabled (ie the kernel
@@ -123,6 +131,7 @@ extern bool kvm_readonly_mem_allowed;
#define kvm_irqfds_enabled() (false)
#define kvm_msi_via_irqfd_enabled() (false)
#define kvm_gsi_routing_allowed() (false)
+#define kvm_gsi_direct_mapping() (false)
#define kvm_readonly_mem_enabled() (false)
#endif
diff --git a/kvm-all.c b/kvm-all.c
index 875e32e..17fb865 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -111,6 +111,7 @@ bool kvm_halt_in_kernel_allowed;
bool kvm_irqfds_allowed;
bool kvm_msi_via_irqfd_allowed;
bool kvm_gsi_routing_allowed;
+bool kvm_gsi_direct_mapping;
bool kvm_allowed;
bool kvm_readonly_mem_allowed;
@@ -1069,6 +1070,10 @@ void kvm_irqchip_release_virq(KVMState *s, int virq)
struct kvm_irq_routing_entry *e;
int i;
+ if (kvm_gsi_direct_mapping()) {
+ return;
+ }
+
for (i = 0; i < s->irq_routes->nr; i++) {
e = &s->irq_routes->entries[i];
if (e->gsi == virq) {
@@ -1190,6 +1195,10 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
struct kvm_irq_routing_entry kroute = {};
int virq;
+ if (kvm_gsi_direct_mapping()) {
+ return msg.data & 0xffff;
+ }
+
if (!kvm_gsi_routing_enabled()) {
return -ENOSYS;
}
@@ -1216,6 +1225,10 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
{
struct kvm_irq_routing_entry kroute = {};
+ if (kvm_gsi_direct_mapping()) {
+ return 0;
+ }
+
if (!kvm_irqchip_in_kernel()) {
return -ENOSYS;
}
diff --git a/kvm-stub.c b/kvm-stub.c
index 548f471..e979f76 100644
--- a/kvm-stub.c
+++ b/kvm-stub.c
@@ -25,6 +25,7 @@ bool kvm_async_interrupts_allowed;
bool kvm_irqfds_allowed;
bool kvm_msi_via_irqfd_allowed;
bool kvm_gsi_routing_allowed;
+bool kvm_gsi_direct_mapping;
bool kvm_allowed;
bool kvm_readonly_mem_allowed;
--
1.8.4.rc4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v6] kvm irqfd: support direct msimessage to irq translation
2013-09-03 8:08 [Qemu-devel] [PATCH v6] kvm irqfd: support direct msimessage to irq translation Alexey Kardashevskiy
@ 2013-09-03 8:17 ` Michael S. Tsirkin
2013-09-03 15:36 ` Alexander Graf
2013-09-05 16:01 ` Paolo Bonzini
2013-09-12 16:32 ` Paolo Bonzini
1 sibling, 2 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2013-09-03 8:17 UTC (permalink / raw)
To: Alexey Kardashevskiy
Cc: qemu-ppc, Paolo Bonzini, Paul Mackerras, qemu-devel,
Alexander Graf
On Tue, Sep 03, 2013 at 06:08:25PM +1000, Alexey Kardashevskiy wrote:
> On PPC64 systems MSI Messages are translated to system IRQ in a PCI
> host bridge. This is already supported for emulated MSI/MSIX but
> not for irqfd where the current QEMU allocates IRQ numbers from
> irqchip and maps MSIMessages to IRQ in the host kernel.
>
> This adds a new direct mapping flag which tells
> the kvm_irqchip_add_msi_route() function that a new VIRQ
> should not be allocated, instead the value from MSIMessage::data
> should be used. It is up to the platform code to make sure that
> this contains a valid IRQ number as sPAPR does in spapr_pci.c.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Fine with me
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> The patch does not enable this mapping for any platform in this patch
> as it is going be done for spapr only on a separate patch which is not
> ready to go as it depends on the in-kernel XICS-KVM patchset which is not
> in upstream yet.
>
> ---
> Changes:
> v6:
> * simplified to a single global flag and putting an IRQ number
> in MSIMessage::data
>
> 2013/08/07 v5:
> * pci_bus_map_msi now has default behaviour which is to call
> kvm_irqchip_add_msi_route
> * kvm_irqchip_release_virq fixed not crash when there is no routes
> ---
> include/sysemu/kvm.h | 9 +++++++++
> kvm-all.c | 13 +++++++++++++
> kvm-stub.c | 1 +
> 3 files changed, 23 insertions(+)
>
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index 8e76685..0e9ef38 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -46,6 +46,7 @@ extern bool kvm_halt_in_kernel_allowed;
> extern bool kvm_irqfds_allowed;
> extern bool kvm_msi_via_irqfd_allowed;
> extern bool kvm_gsi_routing_allowed;
> +extern bool kvm_gsi_direct_mapping;
> extern bool kvm_readonly_mem_allowed;
>
> #if defined CONFIG_KVM || !defined NEED_CPU_H
> @@ -108,6 +109,13 @@ extern bool kvm_readonly_mem_allowed;
> #define kvm_gsi_routing_enabled() (kvm_gsi_routing_allowed)
>
> /**
> + * kvm_gsi_direct_mapping:
> + *
> + * Returns: true if GSI direct mapping is enabled.
> + */
> +#define kvm_gsi_direct_mapping() (kvm_gsi_direct_mapping)
> +
> +/**
> * kvm_readonly_mem_enabled:
> *
> * Returns: true if KVM readonly memory is enabled (ie the kernel
> @@ -123,6 +131,7 @@ extern bool kvm_readonly_mem_allowed;
> #define kvm_irqfds_enabled() (false)
> #define kvm_msi_via_irqfd_enabled() (false)
> #define kvm_gsi_routing_allowed() (false)
> +#define kvm_gsi_direct_mapping() (false)
> #define kvm_readonly_mem_enabled() (false)
> #endif
>
> diff --git a/kvm-all.c b/kvm-all.c
> index 875e32e..17fb865 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -111,6 +111,7 @@ bool kvm_halt_in_kernel_allowed;
> bool kvm_irqfds_allowed;
> bool kvm_msi_via_irqfd_allowed;
> bool kvm_gsi_routing_allowed;
> +bool kvm_gsi_direct_mapping;
> bool kvm_allowed;
> bool kvm_readonly_mem_allowed;
>
> @@ -1069,6 +1070,10 @@ void kvm_irqchip_release_virq(KVMState *s, int virq)
> struct kvm_irq_routing_entry *e;
> int i;
>
> + if (kvm_gsi_direct_mapping()) {
> + return;
> + }
> +
> for (i = 0; i < s->irq_routes->nr; i++) {
> e = &s->irq_routes->entries[i];
> if (e->gsi == virq) {
> @@ -1190,6 +1195,10 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
> struct kvm_irq_routing_entry kroute = {};
> int virq;
>
> + if (kvm_gsi_direct_mapping()) {
> + return msg.data & 0xffff;
> + }
> +
> if (!kvm_gsi_routing_enabled()) {
> return -ENOSYS;
> }
> @@ -1216,6 +1225,10 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
> {
> struct kvm_irq_routing_entry kroute = {};
>
> + if (kvm_gsi_direct_mapping()) {
> + return 0;
> + }
> +
> if (!kvm_irqchip_in_kernel()) {
> return -ENOSYS;
> }
> diff --git a/kvm-stub.c b/kvm-stub.c
> index 548f471..e979f76 100644
> --- a/kvm-stub.c
> +++ b/kvm-stub.c
> @@ -25,6 +25,7 @@ bool kvm_async_interrupts_allowed;
> bool kvm_irqfds_allowed;
> bool kvm_msi_via_irqfd_allowed;
> bool kvm_gsi_routing_allowed;
> +bool kvm_gsi_direct_mapping;
> bool kvm_allowed;
> bool kvm_readonly_mem_allowed;
>
> --
> 1.8.4.rc4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v6] kvm irqfd: support direct msimessage to irq translation
2013-09-03 8:17 ` Michael S. Tsirkin
@ 2013-09-03 15:36 ` Alexander Graf
2013-09-05 16:01 ` Paolo Bonzini
1 sibling, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2013-09-03 15:36 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Alexey Kardashevskiy, qemu-ppc, Paul Mackerras, qemu-devel,
Paolo Bonzini
On 09/03/2013 10:17 AM, Michael S. Tsirkin wrote:
> On Tue, Sep 03, 2013 at 06:08:25PM +1000, Alexey Kardashevskiy wrote:
>> On PPC64 systems MSI Messages are translated to system IRQ in a PCI
>> host bridge. This is already supported for emulated MSI/MSIX but
>> not for irqfd where the current QEMU allocates IRQ numbers from
>> irqchip and maps MSIMessages to IRQ in the host kernel.
>>
>> This adds a new direct mapping flag which tells
>> the kvm_irqchip_add_msi_route() function that a new VIRQ
>> should not be allocated, instead the value from MSIMessage::data
>> should be used. It is up to the platform code to make sure that
>> this contains a valid IRQ number as sPAPR does in spapr_pci.c.
>>
>> Signed-off-by: Alexey Kardashevskiy<aik@ozlabs.ru>
> Fine with me
>
> Acked-by: Michael S. Tsirkin<mst@redhat.com>
Thanks, applied to ppc-next.
Alex
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v6] kvm irqfd: support direct msimessage to irq translation
2013-09-03 8:17 ` Michael S. Tsirkin
2013-09-03 15:36 ` Alexander Graf
@ 2013-09-05 16:01 ` Paolo Bonzini
2013-09-05 16:03 ` Alexander Graf
1 sibling, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2013-09-05 16:01 UTC (permalink / raw)
To: Alexander Graf
Cc: Alexey Kardashevskiy, Paul Mackerras, qemu-ppc, qemu-devel,
Michael S. Tsirkin
Il 03/09/2013 10:17, Michael S. Tsirkin ha scritto:
>> On PPC64 systems MSI Messages are translated to system IRQ in a PCI
>> > host bridge. This is already supported for emulated MSI/MSIX but
>> > not for irqfd where the current QEMU allocates IRQ numbers from
>> > irqchip and maps MSIMessages to IRQ in the host kernel.
>> >
>> > This adds a new direct mapping flag which tells
>> > the kvm_irqchip_add_msi_route() function that a new VIRQ
>> > should not be allocated, instead the value from MSIMessage::data
>> > should be used. It is up to the platform code to make sure that
>> > this contains a valid IRQ number as sPAPR does in spapr_pci.c.
>> >
>> > Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Fine with me
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>
Alex, are you picking this one?
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v6] kvm irqfd: support direct msimessage to irq translation
2013-09-05 16:01 ` Paolo Bonzini
@ 2013-09-05 16:03 ` Alexander Graf
0 siblings, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2013-09-05 16:03 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Alexey Kardashevskiy, Paul Mackerras, qemu-ppc, qemu-devel,
Michael S. Tsirkin
On 05.09.2013, at 18:01, Paolo Bonzini wrote:
> Il 03/09/2013 10:17, Michael S. Tsirkin ha scritto:
>>> On PPC64 systems MSI Messages are translated to system IRQ in a PCI
>>>> host bridge. This is already supported for emulated MSI/MSIX but
>>>> not for irqfd where the current QEMU allocates IRQ numbers from
>>>> irqchip and maps MSIMessages to IRQ in the host kernel.
>>>>
>>>> This adds a new direct mapping flag which tells
>>>> the kvm_irqchip_add_msi_route() function that a new VIRQ
>>>> should not be allocated, instead the value from MSIMessage::data
>>>> should be used. It is up to the platform code to make sure that
>>>> this contains a valid IRQ number as sPAPR does in spapr_pci.c.
>>>>
>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> Fine with me
>>
>> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>>
>
> Alex, are you picking this one?
I wouldn't mind if you pull it in. It mostly touches generic kvm code after all.
Alex
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v6] kvm irqfd: support direct msimessage to irq translation
2013-09-03 8:08 [Qemu-devel] [PATCH v6] kvm irqfd: support direct msimessage to irq translation Alexey Kardashevskiy
2013-09-03 8:17 ` Michael S. Tsirkin
@ 2013-09-12 16:32 ` Paolo Bonzini
1 sibling, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2013-09-12 16:32 UTC (permalink / raw)
To: Alexey Kardashevskiy
Cc: Alexander Graf, qemu-ppc, qemu-devel, Paul Mackerras,
Michael S . Tsirkin
Il 03/09/2013 10:08, Alexey Kardashevskiy ha scritto:
> On PPC64 systems MSI Messages are translated to system IRQ in a PCI
> host bridge. This is already supported for emulated MSI/MSIX but
> not for irqfd where the current QEMU allocates IRQ numbers from
> irqchip and maps MSIMessages to IRQ in the host kernel.
>
> This adds a new direct mapping flag which tells
> the kvm_irqchip_add_msi_route() function that a new VIRQ
> should not be allocated, instead the value from MSIMessage::data
> should be used. It is up to the platform code to make sure that
> this contains a valid IRQ number as sPAPR does in spapr_pci.c.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>
> ---
>
> The patch does not enable this mapping for any platform in this patch
> as it is going be done for spapr only on a separate patch which is not
> ready to go as it depends on the in-kernel XICS-KVM patchset which is not
> in upstream yet.
>
> ---
> Changes:
> v6:
> * simplified to a single global flag and putting an IRQ number
> in MSIMessage::data
>
> 2013/08/07 v5:
> * pci_bus_map_msi now has default behaviour which is to call
> kvm_irqchip_add_msi_route
> * kvm_irqchip_release_virq fixed not crash when there is no routes
> ---
> include/sysemu/kvm.h | 9 +++++++++
> kvm-all.c | 13 +++++++++++++
> kvm-stub.c | 1 +
> 3 files changed, 23 insertions(+)
>
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index 8e76685..0e9ef38 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -46,6 +46,7 @@ extern bool kvm_halt_in_kernel_allowed;
> extern bool kvm_irqfds_allowed;
> extern bool kvm_msi_via_irqfd_allowed;
> extern bool kvm_gsi_routing_allowed;
> +extern bool kvm_gsi_direct_mapping;
> extern bool kvm_readonly_mem_allowed;
>
> #if defined CONFIG_KVM || !defined NEED_CPU_H
> @@ -108,6 +109,13 @@ extern bool kvm_readonly_mem_allowed;
> #define kvm_gsi_routing_enabled() (kvm_gsi_routing_allowed)
>
> /**
> + * kvm_gsi_direct_mapping:
> + *
> + * Returns: true if GSI direct mapping is enabled.
> + */
> +#define kvm_gsi_direct_mapping() (kvm_gsi_direct_mapping)
> +
> +/**
> * kvm_readonly_mem_enabled:
> *
> * Returns: true if KVM readonly memory is enabled (ie the kernel
> @@ -123,6 +131,7 @@ extern bool kvm_readonly_mem_allowed;
> #define kvm_irqfds_enabled() (false)
> #define kvm_msi_via_irqfd_enabled() (false)
> #define kvm_gsi_routing_allowed() (false)
> +#define kvm_gsi_direct_mapping() (false)
> #define kvm_readonly_mem_enabled() (false)
> #endif
>
> diff --git a/kvm-all.c b/kvm-all.c
> index 875e32e..17fb865 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -111,6 +111,7 @@ bool kvm_halt_in_kernel_allowed;
> bool kvm_irqfds_allowed;
> bool kvm_msi_via_irqfd_allowed;
> bool kvm_gsi_routing_allowed;
> +bool kvm_gsi_direct_mapping;
> bool kvm_allowed;
> bool kvm_readonly_mem_allowed;
>
> @@ -1069,6 +1070,10 @@ void kvm_irqchip_release_virq(KVMState *s, int virq)
> struct kvm_irq_routing_entry *e;
> int i;
>
> + if (kvm_gsi_direct_mapping()) {
> + return;
> + }
> +
> for (i = 0; i < s->irq_routes->nr; i++) {
> e = &s->irq_routes->entries[i];
> if (e->gsi == virq) {
> @@ -1190,6 +1195,10 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
> struct kvm_irq_routing_entry kroute = {};
> int virq;
>
> + if (kvm_gsi_direct_mapping()) {
> + return msg.data & 0xffff;
> + }
> +
> if (!kvm_gsi_routing_enabled()) {
> return -ENOSYS;
> }
> @@ -1216,6 +1225,10 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
> {
> struct kvm_irq_routing_entry kroute = {};
>
> + if (kvm_gsi_direct_mapping()) {
> + return 0;
> + }
> +
> if (!kvm_irqchip_in_kernel()) {
> return -ENOSYS;
> }
> diff --git a/kvm-stub.c b/kvm-stub.c
> index 548f471..e979f76 100644
> --- a/kvm-stub.c
> +++ b/kvm-stub.c
> @@ -25,6 +25,7 @@ bool kvm_async_interrupts_allowed;
> bool kvm_irqfds_allowed;
> bool kvm_msi_via_irqfd_allowed;
> bool kvm_gsi_routing_allowed;
> +bool kvm_gsi_direct_mapping;
> bool kvm_allowed;
> bool kvm_readonly_mem_allowed;
>
>
Applied to uq/master, thanks.
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-09-12 16:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-03 8:08 [Qemu-devel] [PATCH v6] kvm irqfd: support direct msimessage to irq translation Alexey Kardashevskiy
2013-09-03 8:17 ` Michael S. Tsirkin
2013-09-03 15:36 ` Alexander Graf
2013-09-05 16:01 ` Paolo Bonzini
2013-09-05 16:03 ` Alexander Graf
2013-09-12 16:32 ` Paolo Bonzini
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).