All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-06 12:11 ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: eric.auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches

This series introduces and extends the IRQ bypass manager written
by Alex and transforms irqfd into an IRQ bypass manager consumer.
The producer part, in my case the VFIO platform driver will be introduced
separately. That code should be usable by both ARM IRQ forwarding
and Intel Posted Interrupts.

The IRQ bypass manager enables to setup a negotiated link between an
IRQ producer and an IRQ consumer (typically the VFIO driver and KVM irqfd).

The series currently includes Alex's code which was sent my email.
Its structure obvioulsy will adapt to Alex's will.

Also the irq bypass manager gets compiled/linked on arm/arm64 along
with KVM and VFIO platform driver.

can be found at:
https://git.linaro.org/people/eric.auger/linux.git/shortlog/refs/heads/v4.2-rc1-bypass-fwd-v2

Best Regards

Eric

History:
v1 -> v2:
- isolate the bypass manager and irqfd consumer in this series
- take into account Paolo's comments and use container_of strategy and
  remove additional fields introduced in v1.
- create kvm_irqfd.h
- add unregistration in irqfd_shutdown

v1: originally part of [RFC 00/17] ARM IRQ forward control based on IRQ
    bypass manager (https://lkml.org/lkml/2015/7/2/268)


Eric Auger (6):
  KVM: arm/arm64: select IRQ_BYPASS_MANAGER
  VFIO: platform: select IRQ_BYPASS_MANAGER
  irq: bypass: Extend skeleton for ARM forwarding control
  KVM: create kvm_irqfd.h
  KVM: introduce kvm_arch functions for IRQ bypass
  KVM: eventfd: add irq bypass consumer management

 arch/arm/kvm/Kconfig          |   1 +
 arch/arm64/kvm/Kconfig        |   1 +
 drivers/vfio/platform/Kconfig |   1 +
 include/linux/irqbypass.h     |  19 ++++++--
 include/linux/kvm_host.h      |  37 ++++++++++++++
 include/linux/kvm_irqfd.h     |  70 +++++++++++++++++++++++++++
 kernel/irq/bypass.c           |  44 +++++++++++++++--
 virt/kvm/Kconfig              |   3 ++
 virt/kvm/eventfd.c            | 109 +++++++++++++-----------------------------
 9 files changed, 203 insertions(+), 82 deletions(-)
 create mode 100644 include/linux/kvm_irqfd.h

-- 
1.9.1


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-06 12:11 ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: linux-arm-kernel

This series introduces and extends the IRQ bypass manager written
by Alex and transforms irqfd into an IRQ bypass manager consumer.
The producer part, in my case the VFIO platform driver will be introduced
separately. That code should be usable by both ARM IRQ forwarding
and Intel Posted Interrupts.

The IRQ bypass manager enables to setup a negotiated link between an
IRQ producer and an IRQ consumer (typically the VFIO driver and KVM irqfd).

The series currently includes Alex's code which was sent my email.
Its structure obvioulsy will adapt to Alex's will.

Also the irq bypass manager gets compiled/linked on arm/arm64 along
with KVM and VFIO platform driver.

can be found at:
https://git.linaro.org/people/eric.auger/linux.git/shortlog/refs/heads/v4.2-rc1-bypass-fwd-v2

Best Regards

Eric

History:
v1 -> v2:
- isolate the bypass manager and irqfd consumer in this series
- take into account Paolo's comments and use container_of strategy and
  remove additional fields introduced in v1.
- create kvm_irqfd.h
- add unregistration in irqfd_shutdown

v1: originally part of [RFC 00/17] ARM IRQ forward control based on IRQ
    bypass manager (https://lkml.org/lkml/2015/7/2/268)


Eric Auger (6):
  KVM: arm/arm64: select IRQ_BYPASS_MANAGER
  VFIO: platform: select IRQ_BYPASS_MANAGER
  irq: bypass: Extend skeleton for ARM forwarding control
  KVM: create kvm_irqfd.h
  KVM: introduce kvm_arch functions for IRQ bypass
  KVM: eventfd: add irq bypass consumer management

 arch/arm/kvm/Kconfig          |   1 +
 arch/arm64/kvm/Kconfig        |   1 +
 drivers/vfio/platform/Kconfig |   1 +
 include/linux/irqbypass.h     |  19 ++++++--
 include/linux/kvm_host.h      |  37 ++++++++++++++
 include/linux/kvm_irqfd.h     |  70 +++++++++++++++++++++++++++
 kernel/irq/bypass.c           |  44 +++++++++++++++--
 virt/kvm/Kconfig              |   3 ++
 virt/kvm/eventfd.c            | 109 +++++++++++++-----------------------------
 9 files changed, 203 insertions(+), 82 deletions(-)
 create mode 100644 include/linux/kvm_irqfd.h

-- 
1.9.1

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 1/6] KVM: arm/arm64: select IRQ_BYPASS_MANAGER
  2015-07-06 12:11 ` Eric Auger
@ 2015-07-06 12:11   ` Eric Auger
  -1 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: eric.auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches

Select IRQ_BYPASS_MANAGER when CONFIG_KVM is set

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---
v1 -> v2:
- also set IRQ_BYPASS_MANAGER for arm64
---
 arch/arm/kvm/Kconfig   | 1 +
 arch/arm64/kvm/Kconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
index bfb915d..7d38d25 100644
--- a/arch/arm/kvm/Kconfig
+++ b/arch/arm/kvm/Kconfig
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select IRQ_BYPASS_MANAGER
 	depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
 	---help---
 	  Support hosting virtualized guest machines.
diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index bfffe8f..d1922b4 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select HAVE_KVM_IRQFD
 	---help---
 	  Support hosting virtualized guest machines.
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 1/6] KVM: arm/arm64: select IRQ_BYPASS_MANAGER
@ 2015-07-06 12:11   ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: linux-arm-kernel

Select IRQ_BYPASS_MANAGER when CONFIG_KVM is set

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---
v1 -> v2:
- also set IRQ_BYPASS_MANAGER for arm64
---
 arch/arm/kvm/Kconfig   | 1 +
 arch/arm64/kvm/Kconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
index bfb915d..7d38d25 100644
--- a/arch/arm/kvm/Kconfig
+++ b/arch/arm/kvm/Kconfig
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select IRQ_BYPASS_MANAGER
 	depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
 	---help---
 	  Support hosting virtualized guest machines.
diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index bfffe8f..d1922b4 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -31,6 +31,7 @@ config KVM
 	select KVM_VFIO
 	select HAVE_KVM_EVENTFD
 	select HAVE_KVM_IRQFD
+	select HAVE_KVM_IRQFD
 	---help---
 	  Support hosting virtualized guest machines.
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 2/6] VFIO: platform: select IRQ_BYPASS_MANAGER
  2015-07-06 12:11 ` Eric Auger
@ 2015-07-06 12:11   ` Eric Auger
  -1 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: eric.auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches

Select IRQ_BYPASS_MANAGER when CONFIG_VFIO_PLATFORM is set

Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
 drivers/vfio/platform/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vfio/platform/Kconfig b/drivers/vfio/platform/Kconfig
index bb30128..c2f3dce 100644
--- a/drivers/vfio/platform/Kconfig
+++ b/drivers/vfio/platform/Kconfig
@@ -2,6 +2,7 @@ config VFIO_PLATFORM
 	tristate "VFIO support for platform devices"
 	depends on VFIO && EVENTFD && (ARM || ARM64)
 	select VFIO_VIRQFD
+	select IRQ_BYPASS_MANAGER
 	help
 	  Support for platform devices with VFIO. This is required to make
 	  use of platform devices present on the system using the VFIO
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 2/6] VFIO: platform: select IRQ_BYPASS_MANAGER
@ 2015-07-06 12:11   ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: linux-arm-kernel

Select IRQ_BYPASS_MANAGER when CONFIG_VFIO_PLATFORM is set

Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
 drivers/vfio/platform/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vfio/platform/Kconfig b/drivers/vfio/platform/Kconfig
index bb30128..c2f3dce 100644
--- a/drivers/vfio/platform/Kconfig
+++ b/drivers/vfio/platform/Kconfig
@@ -2,6 +2,7 @@ config VFIO_PLATFORM
 	tristate "VFIO support for platform devices"
 	depends on VFIO && EVENTFD && (ARM || ARM64)
 	select VFIO_VIRQFD
+	select IRQ_BYPASS_MANAGER
 	help
 	  Support for platform devices with VFIO. This is required to make
 	  use of platform devices present on the system using the VFIO
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-06 12:11 ` Eric Auger
@ 2015-07-06 12:11   ` Eric Auger
  -1 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: eric.auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches

- [add,del]_[consumer,producer] updated to takes both the consumer and
  producer handles. This is requested to combine info from both,
  typically to link the source irq owned by the producer with the gsi
  owned by the consumer (forwarded IRQ setup).
- new methods are added:
  x stop/resume: Those are needed for forwarding since the state change
    requires to entermingle actions at consumer, producer.
  x consumer update for posted interrupts
- On handshake, we now call connect, disconnect which features the more
  complex sequence.
- add irq on producer side

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---

v1 -> v2:
- remove vfio_device, kvm, gsi, opaque fields included in v1 except common
- all those in can be retrieved with container_of in callbacks
---
 include/linux/irqbypass.h | 19 ++++++++++++++++---
 kernel/irq/bypass.c       | 44 ++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
index 718508e..8f62235 100644
--- a/include/linux/irqbypass.h
+++ b/include/linux/irqbypass.h
@@ -3,17 +3,30 @@
 
 #include <linux/list.h>
 
+struct irq_bypass_consumer;
+
 struct irq_bypass_producer {
 	struct list_head node;
 	void *token;
-	/* TBD */
+	int irq; /* linux irq */
+	void (*stop)(struct irq_bypass_producer *);
+	void (*resume)(struct irq_bypass_producer *);
+	void (*add_consumer)(struct irq_bypass_producer *,
+			     struct irq_bypass_consumer *);
+	void (*del_consumer)(struct irq_bypass_producer *,
+			     struct irq_bypass_consumer *);
 };
 
 struct irq_bypass_consumer {
 	struct list_head node;
 	void *token;
-	void (*add_producer)(struct irq_bypass_producer *);
-	void (*del_producer)(struct irq_bypass_producer *);
+	void (*stop)(struct irq_bypass_consumer *);
+	void (*resume)(struct irq_bypass_consumer *);
+	void (*add_producer)(struct irq_bypass_consumer *,
+			     struct irq_bypass_producer *);
+	void (*del_producer)(struct irq_bypass_consumer *,
+			     struct irq_bypass_producer *);
+	void (*update)(struct irq_bypass_consumer *);
 };
 
 int irq_bypass_register_producer(struct irq_bypass_producer *);
diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
index 5d0f92b..efadbe5 100644
--- a/kernel/irq/bypass.c
+++ b/kernel/irq/bypass.c
@@ -19,6 +19,42 @@ static LIST_HEAD(producers);
 static LIST_HEAD(consumers);
 static DEFINE_MUTEX(lock);
 
+/* lock must be hold when calling connect */
+static void connect(struct irq_bypass_producer *prod,
+		    struct irq_bypass_consumer *cons)
+{
+	if (prod->stop)
+		prod->stop(prod);
+	if (cons->stop)
+		cons->stop(cons);
+	if (prod->add_consumer)
+		prod->add_consumer(prod, cons);
+	if (cons->add_producer)
+		cons->add_producer(cons, prod);
+	if (cons->resume)
+		cons->resume(cons);
+	if (prod->resume)
+		prod->resume(prod);
+}
+
+/* lock must be hold when calling disconnect */
+static void disconnect(struct irq_bypass_producer *prod,
+		       struct irq_bypass_consumer *cons)
+{
+	if (prod->stop)
+		prod->stop(prod);
+	if (cons->stop)
+		cons->stop(cons);
+	if (cons->del_producer)
+		cons->del_producer(cons, prod);
+	if (prod->del_consumer)
+		prod->del_consumer(prod, cons);
+	if (cons->resume)
+		cons->resume(cons);
+	if (prod->resume)
+		prod->resume(prod);
+}
+
 int irq_bypass_register_producer(struct irq_bypass_producer *producer)
 {
 	struct irq_bypass_producer *tmp;
@@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct irq_bypass_producer *producer)
 
 	list_for_each_entry(consumer, &consumers, node) {
 		if (consumer->token == producer->token) {
-			consumer->add_producer(producer);
+			connect(producer, consumer);
 			break;
 		}
 	}
@@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct irq_bypass_producer *producer)
 
 	list_for_each_entry(consumer, &consumers, node) {
 		if (consumer->token == producer->token) {
-			consumer->del_producer(producer);
+			disconnect(producer, consumer);
 			break;
 		}
 	}
@@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer)
 
 	list_for_each_entry(producer, &producers, node) {
 		if (producer->token == consumer->token) {
-			consumer->add_producer(producer);
+			connect(producer, consumer);
 			break;
 		}
 	}
@@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct irq_bypass_consumer *consumer)
 
 	list_for_each_entry(producer, &producers, node) {
 		if (producer->token == consumer->token) {
-			consumer->del_producer(producer);
+			disconnect(producer, consumer);
 			break;
 		}
 	}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-06 12:11   ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: linux-arm-kernel

- [add,del]_[consumer,producer] updated to takes both the consumer and
  producer handles. This is requested to combine info from both,
  typically to link the source irq owned by the producer with the gsi
  owned by the consumer (forwarded IRQ setup).
- new methods are added:
  x stop/resume: Those are needed for forwarding since the state change
    requires to entermingle actions at consumer, producer.
  x consumer update for posted interrupts
- On handshake, we now call connect, disconnect which features the more
  complex sequence.
- add irq on producer side

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---

v1 -> v2:
- remove vfio_device, kvm, gsi, opaque fields included in v1 except common
- all those in can be retrieved with container_of in callbacks
---
 include/linux/irqbypass.h | 19 ++++++++++++++++---
 kernel/irq/bypass.c       | 44 ++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
index 718508e..8f62235 100644
--- a/include/linux/irqbypass.h
+++ b/include/linux/irqbypass.h
@@ -3,17 +3,30 @@
 
 #include <linux/list.h>
 
+struct irq_bypass_consumer;
+
 struct irq_bypass_producer {
 	struct list_head node;
 	void *token;
-	/* TBD */
+	int irq; /* linux irq */
+	void (*stop)(struct irq_bypass_producer *);
+	void (*resume)(struct irq_bypass_producer *);
+	void (*add_consumer)(struct irq_bypass_producer *,
+			     struct irq_bypass_consumer *);
+	void (*del_consumer)(struct irq_bypass_producer *,
+			     struct irq_bypass_consumer *);
 };
 
 struct irq_bypass_consumer {
 	struct list_head node;
 	void *token;
-	void (*add_producer)(struct irq_bypass_producer *);
-	void (*del_producer)(struct irq_bypass_producer *);
+	void (*stop)(struct irq_bypass_consumer *);
+	void (*resume)(struct irq_bypass_consumer *);
+	void (*add_producer)(struct irq_bypass_consumer *,
+			     struct irq_bypass_producer *);
+	void (*del_producer)(struct irq_bypass_consumer *,
+			     struct irq_bypass_producer *);
+	void (*update)(struct irq_bypass_consumer *);
 };
 
 int irq_bypass_register_producer(struct irq_bypass_producer *);
diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
index 5d0f92b..efadbe5 100644
--- a/kernel/irq/bypass.c
+++ b/kernel/irq/bypass.c
@@ -19,6 +19,42 @@ static LIST_HEAD(producers);
 static LIST_HEAD(consumers);
 static DEFINE_MUTEX(lock);
 
+/* lock must be hold when calling connect */
+static void connect(struct irq_bypass_producer *prod,
+		    struct irq_bypass_consumer *cons)
+{
+	if (prod->stop)
+		prod->stop(prod);
+	if (cons->stop)
+		cons->stop(cons);
+	if (prod->add_consumer)
+		prod->add_consumer(prod, cons);
+	if (cons->add_producer)
+		cons->add_producer(cons, prod);
+	if (cons->resume)
+		cons->resume(cons);
+	if (prod->resume)
+		prod->resume(prod);
+}
+
+/* lock must be hold when calling disconnect */
+static void disconnect(struct irq_bypass_producer *prod,
+		       struct irq_bypass_consumer *cons)
+{
+	if (prod->stop)
+		prod->stop(prod);
+	if (cons->stop)
+		cons->stop(cons);
+	if (cons->del_producer)
+		cons->del_producer(cons, prod);
+	if (prod->del_consumer)
+		prod->del_consumer(prod, cons);
+	if (cons->resume)
+		cons->resume(cons);
+	if (prod->resume)
+		prod->resume(prod);
+}
+
 int irq_bypass_register_producer(struct irq_bypass_producer *producer)
 {
 	struct irq_bypass_producer *tmp;
@@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct irq_bypass_producer *producer)
 
 	list_for_each_entry(consumer, &consumers, node) {
 		if (consumer->token == producer->token) {
-			consumer->add_producer(producer);
+			connect(producer, consumer);
 			break;
 		}
 	}
@@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct irq_bypass_producer *producer)
 
 	list_for_each_entry(consumer, &consumers, node) {
 		if (consumer->token == producer->token) {
-			consumer->del_producer(producer);
+			disconnect(producer, consumer);
 			break;
 		}
 	}
@@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer)
 
 	list_for_each_entry(producer, &producers, node) {
 		if (producer->token == consumer->token) {
-			consumer->add_producer(producer);
+			connect(producer, consumer);
 			break;
 		}
 	}
@@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct irq_bypass_consumer *consumer)
 
 	list_for_each_entry(producer, &producers, node) {
 		if (producer->token == consumer->token) {
-			consumer->del_producer(producer);
+			disconnect(producer, consumer);
 			break;
 		}
 	}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 4/6] KVM: create kvm_irqfd.h
  2015-07-06 12:11 ` Eric Auger
@ 2015-07-06 12:11   ` Eric Auger
  -1 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: eric.auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches

Move _irqfd_resampler and _irqfd struct declarations in a new
public header: kvm_irqfd.h. They are respectively renamed into
kvm_kernel_irqfd_resampler and kvm_kernel_irqfd. Those datatypes
will be used by architecture specific code, in the context of
IRQ bypass manager integration.

Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
 include/linux/kvm_irqfd.h | 69 ++++++++++++++++++++++++++++++++++
 virt/kvm/eventfd.c        | 95 ++++++++++++-----------------------------------
 2 files changed, 92 insertions(+), 72 deletions(-)
 create mode 100644 include/linux/kvm_irqfd.h

diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
new file mode 100644
index 0000000..f926b39
--- /dev/null
+++ b/include/linux/kvm_irqfd.h
@@ -0,0 +1,69 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * irqfd: Allows an fd to be used to inject an interrupt to the guest
+ * Credit goes to Avi Kivity for the original idea.
+ */
+
+#ifndef __LINUX_KVM_IRQFD_H
+#define __LINUX_KVM_IRQFD_H
+
+#include <linux/kvm_host.h>
+#include <linux/poll.h>
+
+/*
+ * Resampling irqfds are a special variety of irqfds used to emulate
+ * level triggered interrupts.  The interrupt is asserted on eventfd
+ * trigger.  On acknowledgment through the irq ack notifier, the
+ * interrupt is de-asserted and userspace is notified through the
+ * resamplefd.  All resamplers on the same gsi are de-asserted
+ * together, so we don't need to track the state of each individual
+ * user.  We can also therefore share the same irq source ID.
+ */
+struct kvm_kernel_irqfd_resampler {
+	struct kvm *kvm;
+	/*
+	 * List of resampling struct _irqfd objects sharing this gsi.
+	 * RCU list modified under kvm->irqfds.resampler_lock
+	 */
+	struct list_head list;
+	struct kvm_irq_ack_notifier notifier;
+	/*
+	 * Entry in list of kvm->irqfd.resampler_list.  Use for sharing
+	 * resamplers among irqfds on the same gsi.
+	 * Accessed and modified under kvm->irqfds.resampler_lock
+	 */
+	struct list_head link;
+};
+
+struct kvm_kernel_irqfd {
+	/* Used for MSI fast-path */
+	struct kvm *kvm;
+	wait_queue_t wait;
+	/* Update side is protected by irqfds.lock */
+	struct kvm_kernel_irq_routing_entry irq_entry;
+	seqcount_t irq_entry_sc;
+	/* Used for level IRQ fast-path */
+	int gsi;
+	struct work_struct inject;
+	/* The resampler used by this irqfd (resampler-only) */
+	struct kvm_kernel_irqfd_resampler *resampler;
+	/* Eventfd notified on resample (resampler-only) */
+	struct eventfd_ctx *resamplefd;
+	/* Entry in list of irqfds for a resampler (resampler-only) */
+	struct list_head resampler_link;
+	/* Used for setup/shutdown */
+	struct eventfd_ctx *eventfd;
+	struct list_head list;
+	poll_table pt;
+	struct work_struct shutdown;
+};
+
+#endif /* __LINUX_KVM_IRQFD_H */
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index f3da161..b79dc61 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -23,6 +23,7 @@
 
 #include <linux/kvm_host.h>
 #include <linux/kvm.h>
+#include <linux/kvm_irqfd.h>
 #include <linux/workqueue.h>
 #include <linux/syscalls.h>
 #include <linux/wait.h>
@@ -39,68 +40,14 @@
 #include <kvm/iodev.h>
 
 #ifdef CONFIG_HAVE_KVM_IRQFD
-/*
- * --------------------------------------------------------------------
- * irqfd: Allows an fd to be used to inject an interrupt to the guest
- *
- * Credit goes to Avi Kivity for the original idea.
- * --------------------------------------------------------------------
- */
-
-/*
- * Resampling irqfds are a special variety of irqfds used to emulate
- * level triggered interrupts.  The interrupt is asserted on eventfd
- * trigger.  On acknowledgement through the irq ack notifier, the
- * interrupt is de-asserted and userspace is notified through the
- * resamplefd.  All resamplers on the same gsi are de-asserted
- * together, so we don't need to track the state of each individual
- * user.  We can also therefore share the same irq source ID.
- */
-struct _irqfd_resampler {
-	struct kvm *kvm;
-	/*
-	 * List of resampling struct _irqfd objects sharing this gsi.
-	 * RCU list modified under kvm->irqfds.resampler_lock
-	 */
-	struct list_head list;
-	struct kvm_irq_ack_notifier notifier;
-	/*
-	 * Entry in list of kvm->irqfd.resampler_list.  Use for sharing
-	 * resamplers among irqfds on the same gsi.
-	 * Accessed and modified under kvm->irqfds.resampler_lock
-	 */
-	struct list_head link;
-};
-
-struct _irqfd {
-	/* Used for MSI fast-path */
-	struct kvm *kvm;
-	wait_queue_t wait;
-	/* Update side is protected by irqfds.lock */
-	struct kvm_kernel_irq_routing_entry irq_entry;
-	seqcount_t irq_entry_sc;
-	/* Used for level IRQ fast-path */
-	int gsi;
-	struct work_struct inject;
-	/* The resampler used by this irqfd (resampler-only) */
-	struct _irqfd_resampler *resampler;
-	/* Eventfd notified on resample (resampler-only) */
-	struct eventfd_ctx *resamplefd;
-	/* Entry in list of irqfds for a resampler (resampler-only) */
-	struct list_head resampler_link;
-	/* Used for setup/shutdown */
-	struct eventfd_ctx *eventfd;
-	struct list_head list;
-	poll_table pt;
-	struct work_struct shutdown;
-};
 
 static struct workqueue_struct *irqfd_cleanup_wq;
 
 static void
 irqfd_inject(struct work_struct *work)
 {
-	struct _irqfd *irqfd = container_of(work, struct _irqfd, inject);
+	struct kvm_kernel_irqfd *irqfd =
+		container_of(work, struct kvm_kernel_irqfd, inject);
 	struct kvm *kvm = irqfd->kvm;
 
 	if (!irqfd->resampler) {
@@ -121,12 +68,13 @@ irqfd_inject(struct work_struct *work)
 static void
 irqfd_resampler_ack(struct kvm_irq_ack_notifier *kian)
 {
-	struct _irqfd_resampler *resampler;
+	struct kvm_kernel_irqfd_resampler *resampler;
 	struct kvm *kvm;
-	struct _irqfd *irqfd;
+	struct kvm_kernel_irqfd *irqfd;
 	int idx;
 
-	resampler = container_of(kian, struct _irqfd_resampler, notifier);
+	resampler = container_of(kian,
+			struct kvm_kernel_irqfd_resampler, notifier);
 	kvm = resampler->kvm;
 
 	kvm_set_irq(kvm, KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID,
@@ -141,9 +89,9 @@ irqfd_resampler_ack(struct kvm_irq_ack_notifier *kian)
 }
 
 static void
-irqfd_resampler_shutdown(struct _irqfd *irqfd)
+irqfd_resampler_shutdown(struct kvm_kernel_irqfd *irqfd)
 {
-	struct _irqfd_resampler *resampler = irqfd->resampler;
+	struct kvm_kernel_irqfd_resampler *resampler = irqfd->resampler;
 	struct kvm *kvm = resampler->kvm;
 
 	mutex_lock(&kvm->irqfds.resampler_lock);
@@ -168,7 +116,8 @@ irqfd_resampler_shutdown(struct _irqfd *irqfd)
 static void
 irqfd_shutdown(struct work_struct *work)
 {
-	struct _irqfd *irqfd = container_of(work, struct _irqfd, shutdown);
+	struct kvm_kernel_irqfd *irqfd =
+		container_of(work, struct kvm_kernel_irqfd, shutdown);
 	u64 cnt;
 
 	/*
@@ -198,7 +147,7 @@ irqfd_shutdown(struct work_struct *work)
 
 /* assumes kvm->irqfds.lock is held */
 static bool
-irqfd_is_active(struct _irqfd *irqfd)
+irqfd_is_active(struct kvm_kernel_irqfd *irqfd)
 {
 	return list_empty(&irqfd->list) ? false : true;
 }
@@ -209,7 +158,7 @@ irqfd_is_active(struct _irqfd *irqfd)
  * assumes kvm->irqfds.lock is held
  */
 static void
-irqfd_deactivate(struct _irqfd *irqfd)
+irqfd_deactivate(struct kvm_kernel_irqfd *irqfd)
 {
 	BUG_ON(!irqfd_is_active(irqfd));
 
@@ -224,7 +173,8 @@ irqfd_deactivate(struct _irqfd *irqfd)
 static int
 irqfd_wakeup(wait_queue_t *wait, unsigned mode, int sync, void *key)
 {
-	struct _irqfd *irqfd = container_of(wait, struct _irqfd, wait);
+	struct kvm_kernel_irqfd *irqfd =
+		container_of(wait, struct kvm_kernel_irqfd, wait);
 	unsigned long flags = (unsigned long)key;
 	struct kvm_kernel_irq_routing_entry irq;
 	struct kvm *kvm = irqfd->kvm;
@@ -274,12 +224,13 @@ static void
 irqfd_ptable_queue_proc(struct file *file, wait_queue_head_t *wqh,
 			poll_table *pt)
 {
-	struct _irqfd *irqfd = container_of(pt, struct _irqfd, pt);
+	struct kvm_kernel_irqfd *irqfd =
+		container_of(pt, struct kvm_kernel_irqfd, pt);
 	add_wait_queue(wqh, &irqfd->wait);
 }
 
 /* Must be called under irqfds.lock */
-static void irqfd_update(struct kvm *kvm, struct _irqfd *irqfd)
+static void irqfd_update(struct kvm *kvm, struct kvm_kernel_irqfd *irqfd)
 {
 	struct kvm_kernel_irq_routing_entry *e;
 	struct kvm_kernel_irq_routing_entry entries[KVM_NR_IRQCHIPS];
@@ -304,7 +255,7 @@ static void irqfd_update(struct kvm *kvm, struct _irqfd *irqfd)
 static int
 kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
 {
-	struct _irqfd *irqfd, *tmp;
+	struct kvm_kernel_irqfd *irqfd, *tmp;
 	struct fd f;
 	struct eventfd_ctx *eventfd = NULL, *resamplefd = NULL;
 	int ret;
@@ -340,7 +291,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
 	irqfd->eventfd = eventfd;
 
 	if (args->flags & KVM_IRQFD_FLAG_RESAMPLE) {
-		struct _irqfd_resampler *resampler;
+		struct kvm_kernel_irqfd_resampler *resampler;
 
 		resamplefd = eventfd_ctx_fdget(args->resamplefd);
 		if (IS_ERR(resamplefd)) {
@@ -527,7 +478,7 @@ kvm_eventfd_init(struct kvm *kvm)
 static int
 kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args)
 {
-	struct _irqfd *irqfd, *tmp;
+	struct kvm_kernel_irqfd *irqfd, *tmp;
 	struct eventfd_ctx *eventfd;
 
 	/* irq_bypass_unregister_consumer() */
@@ -585,7 +536,7 @@ kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args)
 void
 kvm_irqfd_release(struct kvm *kvm)
 {
-	struct _irqfd *irqfd, *tmp;
+	struct kvm_kernel_irqfd *irqfd, *tmp;
 
 	spin_lock_irq(&kvm->irqfds.lock);
 
@@ -608,7 +559,7 @@ kvm_irqfd_release(struct kvm *kvm)
  */
 void kvm_irq_routing_update(struct kvm *kvm)
 {
-	struct _irqfd *irqfd;
+	struct kvm_kernel_irqfd *irqfd;
 
 	spin_lock_irq(&kvm->irqfds.lock);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 4/6] KVM: create kvm_irqfd.h
@ 2015-07-06 12:11   ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: linux-arm-kernel

Move _irqfd_resampler and _irqfd struct declarations in a new
public header: kvm_irqfd.h. They are respectively renamed into
kvm_kernel_irqfd_resampler and kvm_kernel_irqfd. Those datatypes
will be used by architecture specific code, in the context of
IRQ bypass manager integration.

Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
 include/linux/kvm_irqfd.h | 69 ++++++++++++++++++++++++++++++++++
 virt/kvm/eventfd.c        | 95 ++++++++++++-----------------------------------
 2 files changed, 92 insertions(+), 72 deletions(-)
 create mode 100644 include/linux/kvm_irqfd.h

diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
new file mode 100644
index 0000000..f926b39
--- /dev/null
+++ b/include/linux/kvm_irqfd.h
@@ -0,0 +1,69 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * irqfd: Allows an fd to be used to inject an interrupt to the guest
+ * Credit goes to Avi Kivity for the original idea.
+ */
+
+#ifndef __LINUX_KVM_IRQFD_H
+#define __LINUX_KVM_IRQFD_H
+
+#include <linux/kvm_host.h>
+#include <linux/poll.h>
+
+/*
+ * Resampling irqfds are a special variety of irqfds used to emulate
+ * level triggered interrupts.  The interrupt is asserted on eventfd
+ * trigger.  On acknowledgment through the irq ack notifier, the
+ * interrupt is de-asserted and userspace is notified through the
+ * resamplefd.  All resamplers on the same gsi are de-asserted
+ * together, so we don't need to track the state of each individual
+ * user.  We can also therefore share the same irq source ID.
+ */
+struct kvm_kernel_irqfd_resampler {
+	struct kvm *kvm;
+	/*
+	 * List of resampling struct _irqfd objects sharing this gsi.
+	 * RCU list modified under kvm->irqfds.resampler_lock
+	 */
+	struct list_head list;
+	struct kvm_irq_ack_notifier notifier;
+	/*
+	 * Entry in list of kvm->irqfd.resampler_list.  Use for sharing
+	 * resamplers among irqfds on the same gsi.
+	 * Accessed and modified under kvm->irqfds.resampler_lock
+	 */
+	struct list_head link;
+};
+
+struct kvm_kernel_irqfd {
+	/* Used for MSI fast-path */
+	struct kvm *kvm;
+	wait_queue_t wait;
+	/* Update side is protected by irqfds.lock */
+	struct kvm_kernel_irq_routing_entry irq_entry;
+	seqcount_t irq_entry_sc;
+	/* Used for level IRQ fast-path */
+	int gsi;
+	struct work_struct inject;
+	/* The resampler used by this irqfd (resampler-only) */
+	struct kvm_kernel_irqfd_resampler *resampler;
+	/* Eventfd notified on resample (resampler-only) */
+	struct eventfd_ctx *resamplefd;
+	/* Entry in list of irqfds for a resampler (resampler-only) */
+	struct list_head resampler_link;
+	/* Used for setup/shutdown */
+	struct eventfd_ctx *eventfd;
+	struct list_head list;
+	poll_table pt;
+	struct work_struct shutdown;
+};
+
+#endif /* __LINUX_KVM_IRQFD_H */
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index f3da161..b79dc61 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -23,6 +23,7 @@
 
 #include <linux/kvm_host.h>
 #include <linux/kvm.h>
+#include <linux/kvm_irqfd.h>
 #include <linux/workqueue.h>
 #include <linux/syscalls.h>
 #include <linux/wait.h>
@@ -39,68 +40,14 @@
 #include <kvm/iodev.h>
 
 #ifdef CONFIG_HAVE_KVM_IRQFD
-/*
- * --------------------------------------------------------------------
- * irqfd: Allows an fd to be used to inject an interrupt to the guest
- *
- * Credit goes to Avi Kivity for the original idea.
- * --------------------------------------------------------------------
- */
-
-/*
- * Resampling irqfds are a special variety of irqfds used to emulate
- * level triggered interrupts.  The interrupt is asserted on eventfd
- * trigger.  On acknowledgement through the irq ack notifier, the
- * interrupt is de-asserted and userspace is notified through the
- * resamplefd.  All resamplers on the same gsi are de-asserted
- * together, so we don't need to track the state of each individual
- * user.  We can also therefore share the same irq source ID.
- */
-struct _irqfd_resampler {
-	struct kvm *kvm;
-	/*
-	 * List of resampling struct _irqfd objects sharing this gsi.
-	 * RCU list modified under kvm->irqfds.resampler_lock
-	 */
-	struct list_head list;
-	struct kvm_irq_ack_notifier notifier;
-	/*
-	 * Entry in list of kvm->irqfd.resampler_list.  Use for sharing
-	 * resamplers among irqfds on the same gsi.
-	 * Accessed and modified under kvm->irqfds.resampler_lock
-	 */
-	struct list_head link;
-};
-
-struct _irqfd {
-	/* Used for MSI fast-path */
-	struct kvm *kvm;
-	wait_queue_t wait;
-	/* Update side is protected by irqfds.lock */
-	struct kvm_kernel_irq_routing_entry irq_entry;
-	seqcount_t irq_entry_sc;
-	/* Used for level IRQ fast-path */
-	int gsi;
-	struct work_struct inject;
-	/* The resampler used by this irqfd (resampler-only) */
-	struct _irqfd_resampler *resampler;
-	/* Eventfd notified on resample (resampler-only) */
-	struct eventfd_ctx *resamplefd;
-	/* Entry in list of irqfds for a resampler (resampler-only) */
-	struct list_head resampler_link;
-	/* Used for setup/shutdown */
-	struct eventfd_ctx *eventfd;
-	struct list_head list;
-	poll_table pt;
-	struct work_struct shutdown;
-};
 
 static struct workqueue_struct *irqfd_cleanup_wq;
 
 static void
 irqfd_inject(struct work_struct *work)
 {
-	struct _irqfd *irqfd = container_of(work, struct _irqfd, inject);
+	struct kvm_kernel_irqfd *irqfd =
+		container_of(work, struct kvm_kernel_irqfd, inject);
 	struct kvm *kvm = irqfd->kvm;
 
 	if (!irqfd->resampler) {
@@ -121,12 +68,13 @@ irqfd_inject(struct work_struct *work)
 static void
 irqfd_resampler_ack(struct kvm_irq_ack_notifier *kian)
 {
-	struct _irqfd_resampler *resampler;
+	struct kvm_kernel_irqfd_resampler *resampler;
 	struct kvm *kvm;
-	struct _irqfd *irqfd;
+	struct kvm_kernel_irqfd *irqfd;
 	int idx;
 
-	resampler = container_of(kian, struct _irqfd_resampler, notifier);
+	resampler = container_of(kian,
+			struct kvm_kernel_irqfd_resampler, notifier);
 	kvm = resampler->kvm;
 
 	kvm_set_irq(kvm, KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID,
@@ -141,9 +89,9 @@ irqfd_resampler_ack(struct kvm_irq_ack_notifier *kian)
 }
 
 static void
-irqfd_resampler_shutdown(struct _irqfd *irqfd)
+irqfd_resampler_shutdown(struct kvm_kernel_irqfd *irqfd)
 {
-	struct _irqfd_resampler *resampler = irqfd->resampler;
+	struct kvm_kernel_irqfd_resampler *resampler = irqfd->resampler;
 	struct kvm *kvm = resampler->kvm;
 
 	mutex_lock(&kvm->irqfds.resampler_lock);
@@ -168,7 +116,8 @@ irqfd_resampler_shutdown(struct _irqfd *irqfd)
 static void
 irqfd_shutdown(struct work_struct *work)
 {
-	struct _irqfd *irqfd = container_of(work, struct _irqfd, shutdown);
+	struct kvm_kernel_irqfd *irqfd =
+		container_of(work, struct kvm_kernel_irqfd, shutdown);
 	u64 cnt;
 
 	/*
@@ -198,7 +147,7 @@ irqfd_shutdown(struct work_struct *work)
 
 /* assumes kvm->irqfds.lock is held */
 static bool
-irqfd_is_active(struct _irqfd *irqfd)
+irqfd_is_active(struct kvm_kernel_irqfd *irqfd)
 {
 	return list_empty(&irqfd->list) ? false : true;
 }
@@ -209,7 +158,7 @@ irqfd_is_active(struct _irqfd *irqfd)
  * assumes kvm->irqfds.lock is held
  */
 static void
-irqfd_deactivate(struct _irqfd *irqfd)
+irqfd_deactivate(struct kvm_kernel_irqfd *irqfd)
 {
 	BUG_ON(!irqfd_is_active(irqfd));
 
@@ -224,7 +173,8 @@ irqfd_deactivate(struct _irqfd *irqfd)
 static int
 irqfd_wakeup(wait_queue_t *wait, unsigned mode, int sync, void *key)
 {
-	struct _irqfd *irqfd = container_of(wait, struct _irqfd, wait);
+	struct kvm_kernel_irqfd *irqfd =
+		container_of(wait, struct kvm_kernel_irqfd, wait);
 	unsigned long flags = (unsigned long)key;
 	struct kvm_kernel_irq_routing_entry irq;
 	struct kvm *kvm = irqfd->kvm;
@@ -274,12 +224,13 @@ static void
 irqfd_ptable_queue_proc(struct file *file, wait_queue_head_t *wqh,
 			poll_table *pt)
 {
-	struct _irqfd *irqfd = container_of(pt, struct _irqfd, pt);
+	struct kvm_kernel_irqfd *irqfd =
+		container_of(pt, struct kvm_kernel_irqfd, pt);
 	add_wait_queue(wqh, &irqfd->wait);
 }
 
 /* Must be called under irqfds.lock */
-static void irqfd_update(struct kvm *kvm, struct _irqfd *irqfd)
+static void irqfd_update(struct kvm *kvm, struct kvm_kernel_irqfd *irqfd)
 {
 	struct kvm_kernel_irq_routing_entry *e;
 	struct kvm_kernel_irq_routing_entry entries[KVM_NR_IRQCHIPS];
@@ -304,7 +255,7 @@ static void irqfd_update(struct kvm *kvm, struct _irqfd *irqfd)
 static int
 kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
 {
-	struct _irqfd *irqfd, *tmp;
+	struct kvm_kernel_irqfd *irqfd, *tmp;
 	struct fd f;
 	struct eventfd_ctx *eventfd = NULL, *resamplefd = NULL;
 	int ret;
@@ -340,7 +291,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
 	irqfd->eventfd = eventfd;
 
 	if (args->flags & KVM_IRQFD_FLAG_RESAMPLE) {
-		struct _irqfd_resampler *resampler;
+		struct kvm_kernel_irqfd_resampler *resampler;
 
 		resamplefd = eventfd_ctx_fdget(args->resamplefd);
 		if (IS_ERR(resamplefd)) {
@@ -527,7 +478,7 @@ kvm_eventfd_init(struct kvm *kvm)
 static int
 kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args)
 {
-	struct _irqfd *irqfd, *tmp;
+	struct kvm_kernel_irqfd *irqfd, *tmp;
 	struct eventfd_ctx *eventfd;
 
 	/* irq_bypass_unregister_consumer() */
@@ -585,7 +536,7 @@ kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args)
 void
 kvm_irqfd_release(struct kvm *kvm)
 {
-	struct _irqfd *irqfd, *tmp;
+	struct kvm_kernel_irqfd *irqfd, *tmp;
 
 	spin_lock_irq(&kvm->irqfds.lock);
 
@@ -608,7 +559,7 @@ kvm_irqfd_release(struct kvm *kvm)
  */
 void kvm_irq_routing_update(struct kvm *kvm)
 {
-	struct _irqfd *irqfd;
+	struct kvm_kernel_irqfd *irqfd;
 
 	spin_lock_irq(&kvm->irqfds.lock);
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 5/6] KVM: introduce kvm_arch functions for IRQ bypass
  2015-07-06 12:11 ` Eric Auger
@ 2015-07-06 12:11   ` Eric Auger
  -1 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: eric.auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches

This patch introduces
- kvm_arch_irq_bypass_add_producer
- kvm_arch_irq_bypass_del_producer
- kvm_arch_irq_bypass_stop
- kvm_arch_irq_bypass_resume
- kvm_arch_irq_bypass_update

They make possible to specialize the KVM IRQ bypass consumer in
case CONFIG_KVM_HAVE_IRQ_BYPASS is set.

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---

v1 -> v2:
- use CONFIG_KVM_HAVE_IRQ_BYPASS instead CONFIG_IRQ_BYPASS_MANAGER
- rename all functions according to Paolo's proposal
- add kvm_arch_irq_bypass_update according to Feng's need
---
 include/linux/kvm_host.h | 37 +++++++++++++++++++++++++++++++++++++
 virt/kvm/Kconfig         |  3 +++
 2 files changed, 40 insertions(+)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 9564fd7..91a5734 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -24,6 +24,7 @@
 #include <linux/err.h>
 #include <linux/irqflags.h>
 #include <linux/context_tracking.h>
+#include <linux/irqbypass.h>
 #include <asm/signal.h>
 
 #include <linux/kvm.h>
@@ -1133,5 +1134,41 @@ static inline void kvm_vcpu_set_dy_eligible(struct kvm_vcpu *vcpu, bool val)
 {
 }
 #endif /* CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT */
+
+#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
+
+void kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *,
+			   struct irq_bypass_producer *);
+void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *,
+			   struct irq_bypass_producer *);
+void kvm_arch_irq_bypass_stop(struct irq_bypass_consumer *);
+void kvm_arch_irq_bypass_resume(struct irq_bypass_consumer *);
+void kvm_arch_irq_bypass_update(struct irq_bypass_consumer *);
+
+#else
+
+static inline void kvm_arch_irq_bypass_add_producer(
+			struct irq_bypass_consumer *cons,
+			struct irq_bypass_producer *prod)
+{
+}
+static inline void kvm_arch_irq_bypass_del_producer(
+			struct irq_bypass_consumer *cons,
+			struct irq_bypass_producer *prod)
+{
+}
+static inline void kvm_arch_irq_bypass_stop(
+			struct irq_bypass_consumer *cons)
+{
+}
+static inline void kvm_arch_irq_bypass_resume(
+			struct irq_bypass_consumer *cons)
+{
+}
+static inline void kvm_arch_irq_bypass_update(
+			struct irq_bypass_consumer *cons)
+{
+}
+#endif /* CONFIG_HAVE_KVM_IRQ_BYPASS */
 #endif
 
diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig
index e2c876d..9f8014d 100644
--- a/virt/kvm/Kconfig
+++ b/virt/kvm/Kconfig
@@ -47,3 +47,6 @@ config KVM_GENERIC_DIRTYLOG_READ_PROTECT
 config KVM_COMPAT
        def_bool y
        depends on COMPAT && !S390
+
+config HAVE_KVM_IRQ_BYPASS
+       bool
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 5/6] KVM: introduce kvm_arch functions for IRQ bypass
@ 2015-07-06 12:11   ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: linux-arm-kernel

This patch introduces
- kvm_arch_irq_bypass_add_producer
- kvm_arch_irq_bypass_del_producer
- kvm_arch_irq_bypass_stop
- kvm_arch_irq_bypass_resume
- kvm_arch_irq_bypass_update

They make possible to specialize the KVM IRQ bypass consumer in
case CONFIG_KVM_HAVE_IRQ_BYPASS is set.

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---

v1 -> v2:
- use CONFIG_KVM_HAVE_IRQ_BYPASS instead CONFIG_IRQ_BYPASS_MANAGER
- rename all functions according to Paolo's proposal
- add kvm_arch_irq_bypass_update according to Feng's need
---
 include/linux/kvm_host.h | 37 +++++++++++++++++++++++++++++++++++++
 virt/kvm/Kconfig         |  3 +++
 2 files changed, 40 insertions(+)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 9564fd7..91a5734 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -24,6 +24,7 @@
 #include <linux/err.h>
 #include <linux/irqflags.h>
 #include <linux/context_tracking.h>
+#include <linux/irqbypass.h>
 #include <asm/signal.h>
 
 #include <linux/kvm.h>
@@ -1133,5 +1134,41 @@ static inline void kvm_vcpu_set_dy_eligible(struct kvm_vcpu *vcpu, bool val)
 {
 }
 #endif /* CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT */
+
+#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
+
+void kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *,
+			   struct irq_bypass_producer *);
+void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *,
+			   struct irq_bypass_producer *);
+void kvm_arch_irq_bypass_stop(struct irq_bypass_consumer *);
+void kvm_arch_irq_bypass_resume(struct irq_bypass_consumer *);
+void kvm_arch_irq_bypass_update(struct irq_bypass_consumer *);
+
+#else
+
+static inline void kvm_arch_irq_bypass_add_producer(
+			struct irq_bypass_consumer *cons,
+			struct irq_bypass_producer *prod)
+{
+}
+static inline void kvm_arch_irq_bypass_del_producer(
+			struct irq_bypass_consumer *cons,
+			struct irq_bypass_producer *prod)
+{
+}
+static inline void kvm_arch_irq_bypass_stop(
+			struct irq_bypass_consumer *cons)
+{
+}
+static inline void kvm_arch_irq_bypass_resume(
+			struct irq_bypass_consumer *cons)
+{
+}
+static inline void kvm_arch_irq_bypass_update(
+			struct irq_bypass_consumer *cons)
+{
+}
+#endif /* CONFIG_HAVE_KVM_IRQ_BYPASS */
 #endif
 
diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig
index e2c876d..9f8014d 100644
--- a/virt/kvm/Kconfig
+++ b/virt/kvm/Kconfig
@@ -47,3 +47,6 @@ config KVM_GENERIC_DIRTYLOG_READ_PROTECT
 config KVM_COMPAT
        def_bool y
        depends on COMPAT && !S390
+
+config HAVE_KVM_IRQ_BYPASS
+       bool
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
  2015-07-06 12:11 ` Eric Auger
@ 2015-07-06 12:11   ` Eric Auger
  -1 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: eric.auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches

This patch adds the registration/unregistration of an
irq_bypass_consumer on irqfd assignment/deassignment.

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---

v1 -> v2:
- populate of kvm and gsi removed
- unregister the consumer on irqfd_shutdown
---
 include/linux/kvm_irqfd.h |  1 +
 virt/kvm/eventfd.c        | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
index f926b39..3c0bd07 100644
--- a/include/linux/kvm_irqfd.h
+++ b/include/linux/kvm_irqfd.h
@@ -64,6 +64,7 @@ struct kvm_kernel_irqfd {
 	struct list_head list;
 	poll_table pt;
 	struct work_struct shutdown;
+	struct irq_bypass_consumer consumer;
 };
 
 #endif /* __LINUX_KVM_IRQFD_H */
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index b79dc61..9452754 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -35,6 +35,7 @@
 #include <linux/srcu.h>
 #include <linux/slab.h>
 #include <linux/seqlock.h>
+#include <linux/irqbypass.h>
 #include <trace/events/kvm.h>
 
 #include <kvm/iodev.h>
@@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
 	/*
 	 * It is now safe to release the object's resources
 	 */
+	irq_bypass_unregister_consumer(&irqfd->consumer);
 	eventfd_ctx_put(irqfd->eventfd);
 	kfree(irqfd);
 }
@@ -380,7 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
 	 */
 	fdput(f);
 
-	/* irq_bypass_register_consumer(); */
+	irqfd->consumer.token = (void *)irqfd->eventfd;
+	irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
+	irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
+	irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
+	irqfd->consumer.resume = kvm_arch_irq_bypass_resume;
+	irqfd->consumer.update = kvm_arch_irq_bypass_update;
+	ret = irq_bypass_register_consumer(&irqfd->consumer);
+	WARN_ON(ret);
 
 	return 0;
 
@@ -481,8 +490,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args)
 	struct kvm_kernel_irqfd *irqfd, *tmp;
 	struct eventfd_ctx *eventfd;
 
-	/* irq_bypass_unregister_consumer() */
-
 	eventfd = eventfd_ctx_fdget(args->fd);
 	if (IS_ERR(eventfd))
 		return PTR_ERR(eventfd);
@@ -501,6 +508,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args)
 			irqfd->irq_entry.type = 0;
 			write_seqcount_end(&irqfd->irq_entry_sc);
 			irqfd_deactivate(irqfd);
+			irq_bypass_unregister_consumer(&irqfd->consumer);
 		}
 	}
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
@ 2015-07-06 12:11   ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 12:11 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds the registration/unregistration of an
irq_bypass_consumer on irqfd assignment/deassignment.

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---

v1 -> v2:
- populate of kvm and gsi removed
- unregister the consumer on irqfd_shutdown
---
 include/linux/kvm_irqfd.h |  1 +
 virt/kvm/eventfd.c        | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
index f926b39..3c0bd07 100644
--- a/include/linux/kvm_irqfd.h
+++ b/include/linux/kvm_irqfd.h
@@ -64,6 +64,7 @@ struct kvm_kernel_irqfd {
 	struct list_head list;
 	poll_table pt;
 	struct work_struct shutdown;
+	struct irq_bypass_consumer consumer;
 };
 
 #endif /* __LINUX_KVM_IRQFD_H */
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index b79dc61..9452754 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -35,6 +35,7 @@
 #include <linux/srcu.h>
 #include <linux/slab.h>
 #include <linux/seqlock.h>
+#include <linux/irqbypass.h>
 #include <trace/events/kvm.h>
 
 #include <kvm/iodev.h>
@@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
 	/*
 	 * It is now safe to release the object's resources
 	 */
+	irq_bypass_unregister_consumer(&irqfd->consumer);
 	eventfd_ctx_put(irqfd->eventfd);
 	kfree(irqfd);
 }
@@ -380,7 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
 	 */
 	fdput(f);
 
-	/* irq_bypass_register_consumer(); */
+	irqfd->consumer.token = (void *)irqfd->eventfd;
+	irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
+	irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
+	irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
+	irqfd->consumer.resume = kvm_arch_irq_bypass_resume;
+	irqfd->consumer.update = kvm_arch_irq_bypass_update;
+	ret = irq_bypass_register_consumer(&irqfd->consumer);
+	WARN_ON(ret);
 
 	return 0;
 
@@ -481,8 +490,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args)
 	struct kvm_kernel_irqfd *irqfd, *tmp;
 	struct eventfd_ctx *eventfd;
 
-	/* irq_bypass_unregister_consumer() */
-
 	eventfd = eventfd_ctx_fdget(args->fd);
 	if (IS_ERR(eventfd))
 		return PTR_ERR(eventfd);
@@ -501,6 +508,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args)
 			irqfd->irq_entry.type = 0;
 			write_seqcount_end(&irqfd->irq_entry_sc);
 			irqfd_deactivate(irqfd);
+			irq_bypass_unregister_consumer(&irqfd->consumer);
 		}
 	}
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* Re: [RFC v2 1/6] KVM: arm/arm64: select IRQ_BYPASS_MANAGER
  2015-07-06 12:11   ` Eric Auger
@ 2015-07-06 12:24     ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-06 12:24 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches



On 06/07/2015 14:11, Eric Auger wrote:
> Select IRQ_BYPASS_MANAGER when CONFIG_KVM is set
> 
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> 
> ---
> v1 -> v2:
> - also set IRQ_BYPASS_MANAGER for arm64
> ---
>  arch/arm/kvm/Kconfig   | 1 +
>  arch/arm64/kvm/Kconfig | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
> index bfb915d..7d38d25 100644
> --- a/arch/arm/kvm/Kconfig
> +++ b/arch/arm/kvm/Kconfig
> @@ -31,6 +31,7 @@ config KVM
>  	select KVM_VFIO
>  	select HAVE_KVM_EVENTFD
>  	select HAVE_KVM_IRQFD
> +	select IRQ_BYPASS_MANAGER
>  	depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
>  	---help---
>  	  Support hosting virtualized guest machines.
> diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
> index bfffe8f..d1922b4 100644
> --- a/arch/arm64/kvm/Kconfig
> +++ b/arch/arm64/kvm/Kconfig
> @@ -31,6 +31,7 @@ config KVM
>  	select KVM_VFIO
>  	select HAVE_KVM_EVENTFD
>  	select HAVE_KVM_IRQFD
> +	select HAVE_KVM_IRQFD

Obvious pasto. :)

Paolo

>  	---help---
>  	  Support hosting virtualized guest machines.
>  
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 1/6] KVM: arm/arm64: select IRQ_BYPASS_MANAGER
@ 2015-07-06 12:24     ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-06 12:24 UTC (permalink / raw)
  To: linux-arm-kernel



On 06/07/2015 14:11, Eric Auger wrote:
> Select IRQ_BYPASS_MANAGER when CONFIG_KVM is set
> 
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> 
> ---
> v1 -> v2:
> - also set IRQ_BYPASS_MANAGER for arm64
> ---
>  arch/arm/kvm/Kconfig   | 1 +
>  arch/arm64/kvm/Kconfig | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
> index bfb915d..7d38d25 100644
> --- a/arch/arm/kvm/Kconfig
> +++ b/arch/arm/kvm/Kconfig
> @@ -31,6 +31,7 @@ config KVM
>  	select KVM_VFIO
>  	select HAVE_KVM_EVENTFD
>  	select HAVE_KVM_IRQFD
> +	select IRQ_BYPASS_MANAGER
>  	depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
>  	---help---
>  	  Support hosting virtualized guest machines.
> diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
> index bfffe8f..d1922b4 100644
> --- a/arch/arm64/kvm/Kconfig
> +++ b/arch/arm64/kvm/Kconfig
> @@ -31,6 +31,7 @@ config KVM
>  	select KVM_VFIO
>  	select HAVE_KVM_EVENTFD
>  	select HAVE_KVM_IRQFD
> +	select HAVE_KVM_IRQFD

Obvious pasto. :)

Paolo

>  	---help---
>  	  Support hosting virtualized guest machines.
>  
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-06 12:11   ` Eric Auger
@ 2015-07-06 12:27     ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-06 12:27 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches



On 06/07/2015 14:11, Eric Auger wrote:
> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
> index 5d0f92b..efadbe5 100644
> --- a/kernel/irq/bypass.c
> +++ b/kernel/irq/bypass.c
> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>  static LIST_HEAD(consumers);
>  static DEFINE_MUTEX(lock);
>  
> +/* lock must be hold when calling connect */

If a lock must be held while callbacks are called, you have to document
that producers and consumers must _not_ call back into the IRQ bypass
manager.  (If they have to, you have to document explicitly "This
function can be called from producer and consumer callbacks" whenever
relevant).

> +static void connect(struct irq_bypass_producer *prod,
> +		    struct irq_bypass_consumer *cons)
> +{
> +	if (prod->stop)
> +		prod->stop(prod);
> +	if (cons->stop)
> +		cons->stop(cons);
> +	if (prod->add_consumer)
> +		prod->add_consumer(prod, cons);
> +	if (cons->add_producer)
> +		cons->add_producer(cons, prod);
> +	if (cons->resume)
> +		cons->resume(cons);
> +	if (prod->resume)
> +		prod->resume(prod);
> +}
> +
> +/* lock must be hold when calling disconnect */
> +static void disconnect(struct irq_bypass_producer *prod,
> +		       struct irq_bypass_consumer *cons)
> +{
> +	if (prod->stop)
> +		prod->stop(prod);
> +	if (cons->stop)
> +		cons->stop(cons);
> +	if (cons->del_producer)
> +		cons->del_producer(cons, prod);
> +	if (prod->del_consumer)
> +		prod->del_consumer(prod, cons);
> +	if (cons->resume)
> +		cons->resume(cons);
> +	if (prod->resume)
> +		prod->resume(prod);
> +}
> +

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-06 12:27     ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-06 12:27 UTC (permalink / raw)
  To: linux-arm-kernel



On 06/07/2015 14:11, Eric Auger wrote:
> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
> index 5d0f92b..efadbe5 100644
> --- a/kernel/irq/bypass.c
> +++ b/kernel/irq/bypass.c
> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>  static LIST_HEAD(consumers);
>  static DEFINE_MUTEX(lock);
>  
> +/* lock must be hold when calling connect */

If a lock must be held while callbacks are called, you have to document
that producers and consumers must _not_ call back into the IRQ bypass
manager.  (If they have to, you have to document explicitly "This
function can be called from producer and consumer callbacks" whenever
relevant).

> +static void connect(struct irq_bypass_producer *prod,
> +		    struct irq_bypass_consumer *cons)
> +{
> +	if (prod->stop)
> +		prod->stop(prod);
> +	if (cons->stop)
> +		cons->stop(cons);
> +	if (prod->add_consumer)
> +		prod->add_consumer(prod, cons);
> +	if (cons->add_producer)
> +		cons->add_producer(cons, prod);
> +	if (cons->resume)
> +		cons->resume(cons);
> +	if (prod->resume)
> +		prod->resume(prod);
> +}
> +
> +/* lock must be hold when calling disconnect */
> +static void disconnect(struct irq_bypass_producer *prod,
> +		       struct irq_bypass_consumer *cons)
> +{
> +	if (prod->stop)
> +		prod->stop(prod);
> +	if (cons->stop)
> +		cons->stop(cons);
> +	if (cons->del_producer)
> +		cons->del_producer(cons, prod);
> +	if (prod->del_consumer)
> +		prod->del_consumer(prod, cons);
> +	if (cons->resume)
> +		cons->resume(cons);
> +	if (prod->resume)
> +		prod->resume(prod);
> +}
> +

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-06 12:27     ` Paolo Bonzini
@ 2015-07-06 15:35       ` Eric Auger
  -1 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 15:35 UTC (permalink / raw)
  To: Paolo Bonzini, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches

Hi Paolo,
On 07/06/2015 02:27 PM, Paolo Bonzini wrote:
> 
> 
> On 06/07/2015 14:11, Eric Auger wrote:
>> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
>> index 5d0f92b..efadbe5 100644
>> --- a/kernel/irq/bypass.c
>> +++ b/kernel/irq/bypass.c
>> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>>  static LIST_HEAD(consumers);
>>  static DEFINE_MUTEX(lock);
>>  
>> +/* lock must be hold when calling connect */
> 
> If a lock must be held while callbacks are called, you have to document
> that producers and consumers must _not_ call back into the IRQ bypass
> manager.  (If they have to, you have to document explicitly "This
> function can be called from producer and consumer callbacks" whenever
> relevant).
OK Thanks

Eric
> 
>> +static void connect(struct irq_bypass_producer *prod,
>> +		    struct irq_bypass_consumer *cons)
>> +{
>> +	if (prod->stop)
>> +		prod->stop(prod);
>> +	if (cons->stop)
>> +		cons->stop(cons);
>> +	if (prod->add_consumer)
>> +		prod->add_consumer(prod, cons);
>> +	if (cons->add_producer)
>> +		cons->add_producer(cons, prod);
>> +	if (cons->resume)
>> +		cons->resume(cons);
>> +	if (prod->resume)
>> +		prod->resume(prod);
>> +}
>> +
>> +/* lock must be hold when calling disconnect */
>> +static void disconnect(struct irq_bypass_producer *prod,
>> +		       struct irq_bypass_consumer *cons)
>> +{
>> +	if (prod->stop)
>> +		prod->stop(prod);
>> +	if (cons->stop)
>> +		cons->stop(cons);
>> +	if (cons->del_producer)
>> +		cons->del_producer(cons, prod);
>> +	if (prod->del_consumer)
>> +		prod->del_consumer(prod, cons);
>> +	if (cons->resume)
>> +		cons->resume(cons);
>> +	if (prod->resume)
>> +		prod->resume(prod);
>> +}
>> +


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-06 15:35       ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Paolo,
On 07/06/2015 02:27 PM, Paolo Bonzini wrote:
> 
> 
> On 06/07/2015 14:11, Eric Auger wrote:
>> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
>> index 5d0f92b..efadbe5 100644
>> --- a/kernel/irq/bypass.c
>> +++ b/kernel/irq/bypass.c
>> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>>  static LIST_HEAD(consumers);
>>  static DEFINE_MUTEX(lock);
>>  
>> +/* lock must be hold when calling connect */
> 
> If a lock must be held while callbacks are called, you have to document
> that producers and consumers must _not_ call back into the IRQ bypass
> manager.  (If they have to, you have to document explicitly "This
> function can be called from producer and consumer callbacks" whenever
> relevant).
OK Thanks

Eric
> 
>> +static void connect(struct irq_bypass_producer *prod,
>> +		    struct irq_bypass_consumer *cons)
>> +{
>> +	if (prod->stop)
>> +		prod->stop(prod);
>> +	if (cons->stop)
>> +		cons->stop(cons);
>> +	if (prod->add_consumer)
>> +		prod->add_consumer(prod, cons);
>> +	if (cons->add_producer)
>> +		cons->add_producer(cons, prod);
>> +	if (cons->resume)
>> +		cons->resume(cons);
>> +	if (prod->resume)
>> +		prod->resume(prod);
>> +}
>> +
>> +/* lock must be hold when calling disconnect */
>> +static void disconnect(struct irq_bypass_producer *prod,
>> +		       struct irq_bypass_consumer *cons)
>> +{
>> +	if (prod->stop)
>> +		prod->stop(prod);
>> +	if (cons->stop)
>> +		cons->stop(cons);
>> +	if (cons->del_producer)
>> +		cons->del_producer(cons, prod);
>> +	if (prod->del_consumer)
>> +		prod->del_consumer(prod, cons);
>> +	if (cons->resume)
>> +		cons->resume(cons);
>> +	if (prod->resume)
>> +		prod->resume(prod);
>> +}
>> +

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-06 15:35       ` Eric Auger
@ 2015-07-06 15:57         ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-06 15:57 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches



On 06/07/2015 17:35, Eric Auger wrote:
>>> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
>>> >> index 5d0f92b..efadbe5 100644
>>> >> --- a/kernel/irq/bypass.c
>>> >> +++ b/kernel/irq/bypass.c
>>> >> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>>> >>  static LIST_HEAD(consumers);
>>> >>  static DEFINE_MUTEX(lock);
>>> >>  
>>> >> +/* lock must be hold when calling connect */
>> > 
>> > If a lock must be held while callbacks are called, you have to document
>> > that producers and consumers must _not_ call back into the IRQ bypass
>> > manager.  (If they have to, you have to document explicitly "This
>> > function can be called from producer and consumer callbacks" whenever
>> > relevant).
> OK Thanks

Also, please document on functions that take the irq bypass mutex that
they can sleep.  In fact irq_bypass_{,un}register_{producer,consumer}
need kerneldoc comments.

The good thing is that this helps a bit forming a lock hierarchy across
the subsystems, for example irq bypass mutex outside vfio_platform_irq
spinlock, because you cannot have a spinlock inside the mutex.  I think
that all of your six callbacks are fine.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-06 15:57         ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-06 15:57 UTC (permalink / raw)
  To: linux-arm-kernel



On 06/07/2015 17:35, Eric Auger wrote:
>>> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
>>> >> index 5d0f92b..efadbe5 100644
>>> >> --- a/kernel/irq/bypass.c
>>> >> +++ b/kernel/irq/bypass.c
>>> >> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>>> >>  static LIST_HEAD(consumers);
>>> >>  static DEFINE_MUTEX(lock);
>>> >>  
>>> >> +/* lock must be hold when calling connect */
>> > 
>> > If a lock must be held while callbacks are called, you have to document
>> > that producers and consumers must _not_ call back into the IRQ bypass
>> > manager.  (If they have to, you have to document explicitly "This
>> > function can be called from producer and consumer callbacks" whenever
>> > relevant).
> OK Thanks

Also, please document on functions that take the irq bypass mutex that
they can sleep.  In fact irq_bypass_{,un}register_{producer,consumer}
need kerneldoc comments.

The good thing is that this helps a bit forming a lock hierarchy across
the subsystems, for example irq bypass mutex outside vfio_platform_irq
spinlock, because you cannot have a spinlock inside the mutex.  I think
that all of your six callbacks are fine.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-06 15:57         ` Paolo Bonzini
@ 2015-07-06 17:09           ` Eric Auger
  -1 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 17:09 UTC (permalink / raw)
  To: Paolo Bonzini, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches

On 07/06/2015 05:57 PM, Paolo Bonzini wrote:
> 
> 
> On 06/07/2015 17:35, Eric Auger wrote:
>>>> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
>>>>>> index 5d0f92b..efadbe5 100644
>>>>>> --- a/kernel/irq/bypass.c
>>>>>> +++ b/kernel/irq/bypass.c
>>>>>> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>>>>>>  static LIST_HEAD(consumers);
>>>>>>  static DEFINE_MUTEX(lock);
>>>>>>  
>>>>>> +/* lock must be hold when calling connect */
>>>>
>>>> If a lock must be held while callbacks are called, you have to document
>>>> that producers and consumers must _not_ call back into the IRQ bypass
>>>> manager.  (If they have to, you have to document explicitly "This
>>>> function can be called from producer and consumer callbacks" whenever
>>>> relevant).
>> OK Thanks
> 
> Also, please document on functions that take the irq bypass mutex that
> they can sleep.  In fact irq_bypass_{,un}register_{producer,consumer}
> need kerneldoc comments.
> 
> The good thing is that this helps a bit forming a lock hierarchy across
> the subsystems, for example irq bypass mutex outside vfio_platform_irq
> spinlock, because you cannot have a spinlock inside the mutex.  I think
> that all of your six callbacks are fine.

arghh, no that's wrong then. I have plenty of them in the KVM/arm vgic
part :-(

Eric
> 
> Paolo
> 


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-06 17:09           ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-06 17:09 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/06/2015 05:57 PM, Paolo Bonzini wrote:
> 
> 
> On 06/07/2015 17:35, Eric Auger wrote:
>>>> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
>>>>>> index 5d0f92b..efadbe5 100644
>>>>>> --- a/kernel/irq/bypass.c
>>>>>> +++ b/kernel/irq/bypass.c
>>>>>> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>>>>>>  static LIST_HEAD(consumers);
>>>>>>  static DEFINE_MUTEX(lock);
>>>>>>  
>>>>>> +/* lock must be hold when calling connect */
>>>>
>>>> If a lock must be held while callbacks are called, you have to document
>>>> that producers and consumers must _not_ call back into the IRQ bypass
>>>> manager.  (If they have to, you have to document explicitly "This
>>>> function can be called from producer and consumer callbacks" whenever
>>>> relevant).
>> OK Thanks
> 
> Also, please document on functions that take the irq bypass mutex that
> they can sleep.  In fact irq_bypass_{,un}register_{producer,consumer}
> need kerneldoc comments.
> 
> The good thing is that this helps a bit forming a lock hierarchy across
> the subsystems, for example irq bypass mutex outside vfio_platform_irq
> spinlock, because you cannot have a spinlock inside the mutex.  I think
> that all of your six callbacks are fine.

arghh, no that's wrong then. I have plenty of them in the KVM/arm vgic
part :-(

Eric
> 
> Paolo
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-06 17:09           ` Eric Auger
@ 2015-07-06 17:41             ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-06 17:41 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches



On 06/07/2015 19:09, Eric Auger wrote:
>> > The good thing is that this helps a bit forming a lock hierarchy across
>> > the subsystems, for example irq bypass mutex outside vfio_platform_irq
>> > spinlock, because you cannot have a spinlock inside the mutex.  I think
>> > that all of your six callbacks are fine.
> arghh, no that's wrong then. I have plenty of them in the KVM/arm vgic
> part :-(

I checked and it's right...

/me rereads

AAAARGH.  You cannot have a mutex inside a spinlock.  What you're doing
is fine.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-06 17:41             ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-06 17:41 UTC (permalink / raw)
  To: linux-arm-kernel



On 06/07/2015 19:09, Eric Auger wrote:
>> > The good thing is that this helps a bit forming a lock hierarchy across
>> > the subsystems, for example irq bypass mutex outside vfio_platform_irq
>> > spinlock, because you cannot have a spinlock inside the mutex.  I think
>> > that all of your six callbacks are fine.
> arghh, no that's wrong then. I have plenty of them in the KVM/arm vgic
> part :-(

I checked and it's right...

/me rereads

AAAARGH.  You cannot have a mutex inside a spinlock.  What you're doing
is fine.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-06 17:41             ` Paolo Bonzini
@ 2015-07-07  7:10               ` Eric Auger
  -1 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-07  7:10 UTC (permalink / raw)
  To: Paolo Bonzini, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches

On 07/06/2015 07:41 PM, Paolo Bonzini wrote:
> 
> 
> On 06/07/2015 19:09, Eric Auger wrote:
>>>> The good thing is that this helps a bit forming a lock hierarchy across
>>>> the subsystems, for example irq bypass mutex outside vfio_platform_irq
>>>> spinlock, because you cannot have a spinlock inside the mutex.  I think
>>>> that all of your six callbacks are fine.
>> arghh, no that's wrong then. I have plenty of them in the KVM/arm vgic
>> part :-(
> 
> I checked and it's right...
> 
> /me rereads
> 
> AAAARGH.  You cannot have a mutex inside a spinlock.  What you're doing
> is fine.
Sweated up (+ heat wave in France). Was about to read again the
"concurrency and race conditions" chapter of the linux driver bible.
Might be worth anyway ;-)

Many thanks for the review

Eric
> 
> Paolo
> 


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07  7:10               ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-07  7:10 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/06/2015 07:41 PM, Paolo Bonzini wrote:
> 
> 
> On 06/07/2015 19:09, Eric Auger wrote:
>>>> The good thing is that this helps a bit forming a lock hierarchy across
>>>> the subsystems, for example irq bypass mutex outside vfio_platform_irq
>>>> spinlock, because you cannot have a spinlock inside the mutex.  I think
>>>> that all of your six callbacks are fine.
>> arghh, no that's wrong then. I have plenty of them in the KVM/arm vgic
>> part :-(
> 
> I checked and it's right...
> 
> /me rereads
> 
> AAAARGH.  You cannot have a mutex inside a spinlock.  What you're doing
> is fine.
Sweated up (+ heat wave in France). Was about to read again the
"concurrency and race conditions" chapter of the linux driver bible.
Might be worth anyway ;-)

Many thanks for the review

Eric
> 
> Paolo
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
  2015-07-06 12:11   ` Eric Auger
  (?)
@ 2015-07-07  8:47     ` Wu, Feng
  -1 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07  8:47 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Eric Auger [mailto:eric.auger@linaro.org]
> Sent: Monday, July 06, 2015 8:12 PM
> To: eric.auger@st.com; eric.auger@linaro.org;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
> b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
> 
> This patch adds the registration/unregistration of an
> irq_bypass_consumer on irqfd assignment/deassignment.
> 
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> 
> ---
> 
> v1 -> v2:
> - populate of kvm and gsi removed
> - unregister the consumer on irqfd_shutdown
> ---
>  include/linux/kvm_irqfd.h |  1 +
>  virt/kvm/eventfd.c        | 14 +++++++++++---
>  2 files changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
> index f926b39..3c0bd07 100644
> --- a/include/linux/kvm_irqfd.h
> +++ b/include/linux/kvm_irqfd.h
> @@ -64,6 +64,7 @@ struct kvm_kernel_irqfd {
>  	struct list_head list;
>  	poll_table pt;
>  	struct work_struct shutdown;
> +	struct irq_bypass_consumer consumer;
>  };
> 
>  #endif /* __LINUX_KVM_IRQFD_H */
> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> index b79dc61..9452754 100644
> --- a/virt/kvm/eventfd.c
> +++ b/virt/kvm/eventfd.c
> @@ -35,6 +35,7 @@
>  #include <linux/srcu.h>
>  #include <linux/slab.h>
>  #include <linux/seqlock.h>
> +#include <linux/irqbypass.h>
>  #include <trace/events/kvm.h>
> 
>  #include <kvm/iodev.h>
> @@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
>  	/*
>  	 * It is now safe to release the object's resources
>  	 */
> +	irq_bypass_unregister_consumer(&irqfd->consumer);
>  	eventfd_ctx_put(irqfd->eventfd);
>  	kfree(irqfd);
>  }
> @@ -380,7 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd
> *args)
>  	 */
>  	fdput(f);
> 
> -	/* irq_bypass_register_consumer(); */
> +	irqfd->consumer.token = (void *)irqfd->eventfd;
> +	irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
> +	irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
> +	irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
> +	irqfd->consumer.resume = kvm_arch_irq_bypass_resume;
> +	irqfd->consumer.update = kvm_arch_irq_bypass_update;
> +	ret = irq_bypass_register_consumer(&irqfd->consumer);
> +	WARN_ON(ret);
> 
>  	return 0;
> 
> @@ -481,8 +490,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
> *args)
>  	struct kvm_kernel_irqfd *irqfd, *tmp;
>  	struct eventfd_ctx *eventfd;
> 
> -	/* irq_bypass_unregister_consumer() */
> -
>  	eventfd = eventfd_ctx_fdget(args->fd);
>  	if (IS_ERR(eventfd))
>  		return PTR_ERR(eventfd);
> @@ -501,6 +508,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
> *args)
>  			irqfd->irq_entry.type = 0;
>  			write_seqcount_end(&irqfd->irq_entry_sc);
>  			irqfd_deactivate(irqfd);
> +			irq_bypass_unregister_consumer(&irqfd->consumer);

consumer is unregistered in irqfd_shutdown(), why need we do it here?

Thanks,
Feng

>  		}
>  	}
> 
> --
> 1.9.1


^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
@ 2015-07-07  8:47     ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07  8:47 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Eric Auger [mailto:eric.auger@linaro.org]
> Sent: Monday, July 06, 2015 8:12 PM
> To: eric.auger@st.com; eric.auger@linaro.org;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
> b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
> 
> This patch adds the registration/unregistration of an
> irq_bypass_consumer on irqfd assignment/deassignment.
> 
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> 
> ---
> 
> v1 -> v2:
> - populate of kvm and gsi removed
> - unregister the consumer on irqfd_shutdown
> ---
>  include/linux/kvm_irqfd.h |  1 +
>  virt/kvm/eventfd.c        | 14 +++++++++++---
>  2 files changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
> index f926b39..3c0bd07 100644
> --- a/include/linux/kvm_irqfd.h
> +++ b/include/linux/kvm_irqfd.h
> @@ -64,6 +64,7 @@ struct kvm_kernel_irqfd {
>  	struct list_head list;
>  	poll_table pt;
>  	struct work_struct shutdown;
> +	struct irq_bypass_consumer consumer;
>  };
> 
>  #endif /* __LINUX_KVM_IRQFD_H */
> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> index b79dc61..9452754 100644
> --- a/virt/kvm/eventfd.c
> +++ b/virt/kvm/eventfd.c
> @@ -35,6 +35,7 @@
>  #include <linux/srcu.h>
>  #include <linux/slab.h>
>  #include <linux/seqlock.h>
> +#include <linux/irqbypass.h>
>  #include <trace/events/kvm.h>
> 
>  #include <kvm/iodev.h>
> @@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
>  	/*
>  	 * It is now safe to release the object's resources
>  	 */
> +	irq_bypass_unregister_consumer(&irqfd->consumer);
>  	eventfd_ctx_put(irqfd->eventfd);
>  	kfree(irqfd);
>  }
> @@ -380,7 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd
> *args)
>  	 */
>  	fdput(f);
> 
> -	/* irq_bypass_register_consumer(); */
> +	irqfd->consumer.token = (void *)irqfd->eventfd;
> +	irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
> +	irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
> +	irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
> +	irqfd->consumer.resume = kvm_arch_irq_bypass_resume;
> +	irqfd->consumer.update = kvm_arch_irq_bypass_update;
> +	ret = irq_bypass_register_consumer(&irqfd->consumer);
> +	WARN_ON(ret);
> 
>  	return 0;
> 
> @@ -481,8 +490,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
> *args)
>  	struct kvm_kernel_irqfd *irqfd, *tmp;
>  	struct eventfd_ctx *eventfd;
> 
> -	/* irq_bypass_unregister_consumer() */
> -
>  	eventfd = eventfd_ctx_fdget(args->fd);
>  	if (IS_ERR(eventfd))
>  		return PTR_ERR(eventfd);
> @@ -501,6 +508,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
> *args)
>  			irqfd->irq_entry.type = 0;
>  			write_seqcount_end(&irqfd->irq_entry_sc);
>  			irqfd_deactivate(irqfd);
> +			irq_bypass_unregister_consumer(&irqfd->consumer);

consumer is unregistered in irqfd_shutdown(), why need we do it here?

Thanks,
Feng

>  		}
>  	}
> 
> --
> 1.9.1


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
@ 2015-07-07  8:47     ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07  8:47 UTC (permalink / raw)
  To: linux-arm-kernel



> -----Original Message-----
> From: Eric Auger [mailto:eric.auger at linaro.org]
> Sent: Monday, July 06, 2015 8:12 PM
> To: eric.auger at st.com; eric.auger at linaro.org;
> linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
> kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
> alex.williamson at redhat.com; pbonzini at redhat.com; avi.kivity at gmail.com;
> mtosatti at redhat.com; Wu, Feng; joro at 8bytes.org;
> b.reynal at virtualopensystems.com
> Cc: linux-kernel at vger.kernel.org; patches at linaro.org
> Subject: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
> 
> This patch adds the registration/unregistration of an
> irq_bypass_consumer on irqfd assignment/deassignment.
> 
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> 
> ---
> 
> v1 -> v2:
> - populate of kvm and gsi removed
> - unregister the consumer on irqfd_shutdown
> ---
>  include/linux/kvm_irqfd.h |  1 +
>  virt/kvm/eventfd.c        | 14 +++++++++++---
>  2 files changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
> index f926b39..3c0bd07 100644
> --- a/include/linux/kvm_irqfd.h
> +++ b/include/linux/kvm_irqfd.h
> @@ -64,6 +64,7 @@ struct kvm_kernel_irqfd {
>  	struct list_head list;
>  	poll_table pt;
>  	struct work_struct shutdown;
> +	struct irq_bypass_consumer consumer;
>  };
> 
>  #endif /* __LINUX_KVM_IRQFD_H */
> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> index b79dc61..9452754 100644
> --- a/virt/kvm/eventfd.c
> +++ b/virt/kvm/eventfd.c
> @@ -35,6 +35,7 @@
>  #include <linux/srcu.h>
>  #include <linux/slab.h>
>  #include <linux/seqlock.h>
> +#include <linux/irqbypass.h>
>  #include <trace/events/kvm.h>
> 
>  #include <kvm/iodev.h>
> @@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
>  	/*
>  	 * It is now safe to release the object's resources
>  	 */
> +	irq_bypass_unregister_consumer(&irqfd->consumer);
>  	eventfd_ctx_put(irqfd->eventfd);
>  	kfree(irqfd);
>  }
> @@ -380,7 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd
> *args)
>  	 */
>  	fdput(f);
> 
> -	/* irq_bypass_register_consumer(); */
> +	irqfd->consumer.token = (void *)irqfd->eventfd;
> +	irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
> +	irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
> +	irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
> +	irqfd->consumer.resume = kvm_arch_irq_bypass_resume;
> +	irqfd->consumer.update = kvm_arch_irq_bypass_update;
> +	ret = irq_bypass_register_consumer(&irqfd->consumer);
> +	WARN_ON(ret);
> 
>  	return 0;
> 
> @@ -481,8 +490,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
> *args)
>  	struct kvm_kernel_irqfd *irqfd, *tmp;
>  	struct eventfd_ctx *eventfd;
> 
> -	/* irq_bypass_unregister_consumer() */
> -
>  	eventfd = eventfd_ctx_fdget(args->fd);
>  	if (IS_ERR(eventfd))
>  		return PTR_ERR(eventfd);
> @@ -501,6 +508,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
> *args)
>  			irqfd->irq_entry.type = 0;
>  			write_seqcount_end(&irqfd->irq_entry_sc);
>  			irqfd_deactivate(irqfd);
> +			irq_bypass_unregister_consumer(&irqfd->consumer);

consumer is unregistered in irqfd_shutdown(), why need we do it here?

Thanks,
Feng

>  		}
>  	}
> 
> --
> 1.9.1

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-07  7:10               ` Eric Auger
@ 2015-07-07  8:58                 ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07  8:58 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, feng.wu, joro, b.reynal
  Cc: linux-kernel, patches



On 07/07/2015 09:10, Eric Auger wrote:
> On 07/06/2015 07:41 PM, Paolo Bonzini wrote:
>>
>>
>> On 06/07/2015 19:09, Eric Auger wrote:
>>>>> The good thing is that this helps a bit forming a lock hierarchy across
>>>>> the subsystems, for example irq bypass mutex outside vfio_platform_irq
>>>>> spinlock, because you cannot have a spinlock inside the mutex.  I think
>>>>> that all of your six callbacks are fine.
>>> arghh, no that's wrong then. I have plenty of them in the KVM/arm vgic
>>> part :-(
>>
>> I checked and it's right...
>>
>> /me rereads
>>
>> AAAARGH.  You cannot have a mutex inside a spinlock.  What you're doing
>> is fine.
>
> Sweated up (+ heat wave in France).

Same here, I also can blame the heat wave for the mistakes. :)

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07  8:58                 ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07  8:58 UTC (permalink / raw)
  To: linux-arm-kernel



On 07/07/2015 09:10, Eric Auger wrote:
> On 07/06/2015 07:41 PM, Paolo Bonzini wrote:
>>
>>
>> On 06/07/2015 19:09, Eric Auger wrote:
>>>>> The good thing is that this helps a bit forming a lock hierarchy across
>>>>> the subsystems, for example irq bypass mutex outside vfio_platform_irq
>>>>> spinlock, because you cannot have a spinlock inside the mutex.  I think
>>>>> that all of your six callbacks are fine.
>>> arghh, no that's wrong then. I have plenty of them in the KVM/arm vgic
>>> part :-(
>>
>> I checked and it's right...
>>
>> /me rereads
>>
>> AAAARGH.  You cannot have a mutex inside a spinlock.  What you're doing
>> is fine.
>
> Sweated up (+ heat wave in France).

Same here, I also can blame the heat wave for the mistakes. :)

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
  2015-07-07  8:47     ` Wu, Feng
  (?)
@ 2015-07-07  9:05       ` Eric Auger
  -1 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-07  9:05 UTC (permalink / raw)
  To: Wu, Feng, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, joro, b.reynal
  Cc: linux-kernel, patches

Hi Feng,
On 07/07/2015 10:47 AM, Wu, Feng wrote:
> 
> 
>> -----Original Message-----
>> From: Eric Auger [mailto:eric.auger@linaro.org]
>> Sent: Monday, July 06, 2015 8:12 PM
>> To: eric.auger@st.com; eric.auger@linaro.org;
>> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
>> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
>> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
>> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
>> b.reynal@virtualopensystems.com
>> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
>> Subject: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
>>
>> This patch adds the registration/unregistration of an
>> irq_bypass_consumer on irqfd assignment/deassignment.
>>
>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>>
>> ---
>>
>> v1 -> v2:
>> - populate of kvm and gsi removed
>> - unregister the consumer on irqfd_shutdown
>> ---
>>  include/linux/kvm_irqfd.h |  1 +
>>  virt/kvm/eventfd.c        | 14 +++++++++++---
>>  2 files changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
>> index f926b39..3c0bd07 100644
>> --- a/include/linux/kvm_irqfd.h
>> +++ b/include/linux/kvm_irqfd.h
>> @@ -64,6 +64,7 @@ struct kvm_kernel_irqfd {
>>  	struct list_head list;
>>  	poll_table pt;
>>  	struct work_struct shutdown;
>> +	struct irq_bypass_consumer consumer;
>>  };
>>
>>  #endif /* __LINUX_KVM_IRQFD_H */
>> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
>> index b79dc61..9452754 100644
>> --- a/virt/kvm/eventfd.c
>> +++ b/virt/kvm/eventfd.c
>> @@ -35,6 +35,7 @@
>>  #include <linux/srcu.h>
>>  #include <linux/slab.h>
>>  #include <linux/seqlock.h>
>> +#include <linux/irqbypass.h>
>>  #include <trace/events/kvm.h>
>>
>>  #include <kvm/iodev.h>
>> @@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
>>  	/*
>>  	 * It is now safe to release the object's resources
>>  	 */
>> +	irq_bypass_unregister_consumer(&irqfd->consumer);
>>  	eventfd_ctx_put(irqfd->eventfd);
>>  	kfree(irqfd);
>>  }
>> @@ -380,7 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd
>> *args)
>>  	 */
>>  	fdput(f);
>>
>> -	/* irq_bypass_register_consumer(); */
>> +	irqfd->consumer.token = (void *)irqfd->eventfd;
>> +	irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
>> +	irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
>> +	irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
>> +	irqfd->consumer.resume = kvm_arch_irq_bypass_resume;
>> +	irqfd->consumer.update = kvm_arch_irq_bypass_update;
>> +	ret = irq_bypass_register_consumer(&irqfd->consumer);
>> +	WARN_ON(ret);
>>
>>  	return 0;
>>
>> @@ -481,8 +490,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
>> *args)
>>  	struct kvm_kernel_irqfd *irqfd, *tmp;
>>  	struct eventfd_ctx *eventfd;
>>
>> -	/* irq_bypass_unregister_consumer() */
>> -
>>  	eventfd = eventfd_ctx_fdget(args->fd);
>>  	if (IS_ERR(eventfd))
>>  		return PTR_ERR(eventfd);
>> @@ -501,6 +508,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
>> *args)
>>  			irqfd->irq_entry.type = 0;
>>  			write_seqcount_end(&irqfd->irq_entry_sc);
>>  			irqfd_deactivate(irqfd);
>> +			irq_bypass_unregister_consumer(&irqfd->consumer);
> 
> consumer is unregistered in irqfd_shutdown(), why need we do it here?
Yes you're right, this is not needed anymore. Did things too hastily :-(

Otherwise does that isolated series fit your needs for posted interrupts
and match your expectations with regards to split/reusability?

Eric

> 
> Thanks,
> Feng
> 
>>  		}
>>  	}
>>
>> --
>> 1.9.1
> 


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
@ 2015-07-07  9:05       ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-07  9:05 UTC (permalink / raw)
  To: Wu, Feng, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, joro, b.reynal
  Cc: linux-kernel, patches

Hi Feng,
On 07/07/2015 10:47 AM, Wu, Feng wrote:
> 
> 
>> -----Original Message-----
>> From: Eric Auger [mailto:eric.auger@linaro.org]
>> Sent: Monday, July 06, 2015 8:12 PM
>> To: eric.auger@st.com; eric.auger@linaro.org;
>> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
>> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
>> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
>> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
>> b.reynal@virtualopensystems.com
>> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
>> Subject: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
>>
>> This patch adds the registration/unregistration of an
>> irq_bypass_consumer on irqfd assignment/deassignment.
>>
>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>>
>> ---
>>
>> v1 -> v2:
>> - populate of kvm and gsi removed
>> - unregister the consumer on irqfd_shutdown
>> ---
>>  include/linux/kvm_irqfd.h |  1 +
>>  virt/kvm/eventfd.c        | 14 +++++++++++---
>>  2 files changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
>> index f926b39..3c0bd07 100644
>> --- a/include/linux/kvm_irqfd.h
>> +++ b/include/linux/kvm_irqfd.h
>> @@ -64,6 +64,7 @@ struct kvm_kernel_irqfd {
>>  	struct list_head list;
>>  	poll_table pt;
>>  	struct work_struct shutdown;
>> +	struct irq_bypass_consumer consumer;
>>  };
>>
>>  #endif /* __LINUX_KVM_IRQFD_H */
>> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
>> index b79dc61..9452754 100644
>> --- a/virt/kvm/eventfd.c
>> +++ b/virt/kvm/eventfd.c
>> @@ -35,6 +35,7 @@
>>  #include <linux/srcu.h>
>>  #include <linux/slab.h>
>>  #include <linux/seqlock.h>
>> +#include <linux/irqbypass.h>
>>  #include <trace/events/kvm.h>
>>
>>  #include <kvm/iodev.h>
>> @@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
>>  	/*
>>  	 * It is now safe to release the object's resources
>>  	 */
>> +	irq_bypass_unregister_consumer(&irqfd->consumer);
>>  	eventfd_ctx_put(irqfd->eventfd);
>>  	kfree(irqfd);
>>  }
>> @@ -380,7 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd
>> *args)
>>  	 */
>>  	fdput(f);
>>
>> -	/* irq_bypass_register_consumer(); */
>> +	irqfd->consumer.token = (void *)irqfd->eventfd;
>> +	irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
>> +	irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
>> +	irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
>> +	irqfd->consumer.resume = kvm_arch_irq_bypass_resume;
>> +	irqfd->consumer.update = kvm_arch_irq_bypass_update;
>> +	ret = irq_bypass_register_consumer(&irqfd->consumer);
>> +	WARN_ON(ret);
>>
>>  	return 0;
>>
>> @@ -481,8 +490,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
>> *args)
>>  	struct kvm_kernel_irqfd *irqfd, *tmp;
>>  	struct eventfd_ctx *eventfd;
>>
>> -	/* irq_bypass_unregister_consumer() */
>> -
>>  	eventfd = eventfd_ctx_fdget(args->fd);
>>  	if (IS_ERR(eventfd))
>>  		return PTR_ERR(eventfd);
>> @@ -501,6 +508,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
>> *args)
>>  			irqfd->irq_entry.type = 0;
>>  			write_seqcount_end(&irqfd->irq_entry_sc);
>>  			irqfd_deactivate(irqfd);
>> +			irq_bypass_unregister_consumer(&irqfd->consumer);
> 
> consumer is unregistered in irqfd_shutdown(), why need we do it here?
Yes you're right, this is not needed anymore. Did things too hastily :-(

Otherwise does that isolated series fit your needs for posted interrupts
and match your expectations with regards to split/reusability?

Eric

> 
> Thanks,
> Feng
> 
>>  		}
>>  	}
>>
>> --
>> 1.9.1
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
@ 2015-07-07  9:05       ` Eric Auger
  0 siblings, 0 replies; 84+ messages in thread
From: Eric Auger @ 2015-07-07  9:05 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Feng,
On 07/07/2015 10:47 AM, Wu, Feng wrote:
> 
> 
>> -----Original Message-----
>> From: Eric Auger [mailto:eric.auger at linaro.org]
>> Sent: Monday, July 06, 2015 8:12 PM
>> To: eric.auger at st.com; eric.auger at linaro.org;
>> linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
>> kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
>> alex.williamson at redhat.com; pbonzini at redhat.com; avi.kivity at gmail.com;
>> mtosatti at redhat.com; Wu, Feng; joro at 8bytes.org;
>> b.reynal at virtualopensystems.com
>> Cc: linux-kernel at vger.kernel.org; patches at linaro.org
>> Subject: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
>>
>> This patch adds the registration/unregistration of an
>> irq_bypass_consumer on irqfd assignment/deassignment.
>>
>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>>
>> ---
>>
>> v1 -> v2:
>> - populate of kvm and gsi removed
>> - unregister the consumer on irqfd_shutdown
>> ---
>>  include/linux/kvm_irqfd.h |  1 +
>>  virt/kvm/eventfd.c        | 14 +++++++++++---
>>  2 files changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
>> index f926b39..3c0bd07 100644
>> --- a/include/linux/kvm_irqfd.h
>> +++ b/include/linux/kvm_irqfd.h
>> @@ -64,6 +64,7 @@ struct kvm_kernel_irqfd {
>>  	struct list_head list;
>>  	poll_table pt;
>>  	struct work_struct shutdown;
>> +	struct irq_bypass_consumer consumer;
>>  };
>>
>>  #endif /* __LINUX_KVM_IRQFD_H */
>> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
>> index b79dc61..9452754 100644
>> --- a/virt/kvm/eventfd.c
>> +++ b/virt/kvm/eventfd.c
>> @@ -35,6 +35,7 @@
>>  #include <linux/srcu.h>
>>  #include <linux/slab.h>
>>  #include <linux/seqlock.h>
>> +#include <linux/irqbypass.h>
>>  #include <trace/events/kvm.h>
>>
>>  #include <kvm/iodev.h>
>> @@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
>>  	/*
>>  	 * It is now safe to release the object's resources
>>  	 */
>> +	irq_bypass_unregister_consumer(&irqfd->consumer);
>>  	eventfd_ctx_put(irqfd->eventfd);
>>  	kfree(irqfd);
>>  }
>> @@ -380,7 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd
>> *args)
>>  	 */
>>  	fdput(f);
>>
>> -	/* irq_bypass_register_consumer(); */
>> +	irqfd->consumer.token = (void *)irqfd->eventfd;
>> +	irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
>> +	irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
>> +	irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
>> +	irqfd->consumer.resume = kvm_arch_irq_bypass_resume;
>> +	irqfd->consumer.update = kvm_arch_irq_bypass_update;
>> +	ret = irq_bypass_register_consumer(&irqfd->consumer);
>> +	WARN_ON(ret);
>>
>>  	return 0;
>>
>> @@ -481,8 +490,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
>> *args)
>>  	struct kvm_kernel_irqfd *irqfd, *tmp;
>>  	struct eventfd_ctx *eventfd;
>>
>> -	/* irq_bypass_unregister_consumer() */
>> -
>>  	eventfd = eventfd_ctx_fdget(args->fd);
>>  	if (IS_ERR(eventfd))
>>  		return PTR_ERR(eventfd);
>> @@ -501,6 +508,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd
>> *args)
>>  			irqfd->irq_entry.type = 0;
>>  			write_seqcount_end(&irqfd->irq_entry_sc);
>>  			irqfd_deactivate(irqfd);
>> +			irq_bypass_unregister_consumer(&irqfd->consumer);
> 
> consumer is unregistered in irqfd_shutdown(), why need we do it here?
Yes you're right, this is not needed anymore. Did things too hastily :-(

Otherwise does that isolated series fit your needs for posted interrupts
and match your expectations with regards to split/reusability?

Eric

> 
> Thanks,
> Feng
> 
>>  		}
>>  	}
>>
>> --
>> 1.9.1
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
  2015-07-07  9:05       ` Eric Auger
  (?)
@ 2015-07-07  9:13         ` Wu, Feng
  -1 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07  9:13 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Eric Auger [mailto:eric.auger@linaro.org]
> Sent: Tuesday, July 07, 2015 5:06 PM
> To: Wu, Feng; eric.auger@st.com; linux-arm-kernel@lists.infradead.org;
> kvmarm@lists.cs.columbia.edu; kvm@vger.kernel.org;
> christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> mtosatti@redhat.com; joro@8bytes.org; b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: Re: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
> 
> Hi Feng,
> On 07/07/2015 10:47 AM, Wu, Feng wrote:
> >
> >
> >> -----Original Message-----
> >> From: Eric Auger [mailto:eric.auger@linaro.org]
> >> Sent: Monday, July 06, 2015 8:12 PM
> >> To: eric.auger@st.com; eric.auger@linaro.org;
> >> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> >> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> >> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> >> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
> >> b.reynal@virtualopensystems.com
> >> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> >> Subject: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
> >>
> >> This patch adds the registration/unregistration of an
> >> irq_bypass_consumer on irqfd assignment/deassignment.
> >>
> >> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> >>
> >> ---
> >>
> >> v1 -> v2:
> >> - populate of kvm and gsi removed
> >> - unregister the consumer on irqfd_shutdown
> >> ---
> >>  include/linux/kvm_irqfd.h |  1 +
> >>  virt/kvm/eventfd.c        | 14 +++++++++++---
> >>  2 files changed, 12 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
> >> index f926b39..3c0bd07 100644
> >> --- a/include/linux/kvm_irqfd.h
> >> +++ b/include/linux/kvm_irqfd.h
> >> @@ -64,6 +64,7 @@ struct kvm_kernel_irqfd {
> >>  	struct list_head list;
> >>  	poll_table pt;
> >>  	struct work_struct shutdown;
> >> +	struct irq_bypass_consumer consumer;
> >>  };
> >>
> >>  #endif /* __LINUX_KVM_IRQFD_H */
> >> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> >> index b79dc61..9452754 100644
> >> --- a/virt/kvm/eventfd.c
> >> +++ b/virt/kvm/eventfd.c
> >> @@ -35,6 +35,7 @@
> >>  #include <linux/srcu.h>
> >>  #include <linux/slab.h>
> >>  #include <linux/seqlock.h>
> >> +#include <linux/irqbypass.h>
> >>  #include <trace/events/kvm.h>
> >>
> >>  #include <kvm/iodev.h>
> >> @@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
> >>  	/*
> >>  	 * It is now safe to release the object's resources
> >>  	 */
> >> +	irq_bypass_unregister_consumer(&irqfd->consumer);
> >>  	eventfd_ctx_put(irqfd->eventfd);
> >>  	kfree(irqfd);
> >>  }
> >> @@ -380,7 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct
> kvm_irqfd
> >> *args)
> >>  	 */
> >>  	fdput(f);
> >>
> >> -	/* irq_bypass_register_consumer(); */
> >> +	irqfd->consumer.token = (void *)irqfd->eventfd;
> >> +	irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
> >> +	irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
> >> +	irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
> >> +	irqfd->consumer.resume = kvm_arch_irq_bypass_resume;
> >> +	irqfd->consumer.update = kvm_arch_irq_bypass_update;
> >> +	ret = irq_bypass_register_consumer(&irqfd->consumer);
> >> +	WARN_ON(ret);
> >>
> >>  	return 0;
> >>
> >> @@ -481,8 +490,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct
> kvm_irqfd
> >> *args)
> >>  	struct kvm_kernel_irqfd *irqfd, *tmp;
> >>  	struct eventfd_ctx *eventfd;
> >>
> >> -	/* irq_bypass_unregister_consumer() */
> >> -
> >>  	eventfd = eventfd_ctx_fdget(args->fd);
> >>  	if (IS_ERR(eventfd))
> >>  		return PTR_ERR(eventfd);
> >> @@ -501,6 +508,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct
> kvm_irqfd
> >> *args)
> >>  			irqfd->irq_entry.type = 0;
> >>  			write_seqcount_end(&irqfd->irq_entry_sc);
> >>  			irqfd_deactivate(irqfd);
> >> +			irq_bypass_unregister_consumer(&irqfd->consumer);
> >
> > consumer is unregistered in irqfd_shutdown(), why need we do it here?
> Yes you're right, this is not needed anymore. Did things too hastily :-(
> 
> Otherwise does that isolated series fit your needs for posted interrupts
> and match your expectations with regards to split/reusability?

Basically, they are fine. I am trying to rebase my patch on top of it. If I
encounter any issues, I will discuss it here ASAP.

Thanks,
Feng

> 
> Eric
> 
> >
> > Thanks,
> > Feng
> >
> >>  		}
> >>  	}
> >>
> >> --
> >> 1.9.1
> >


^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
@ 2015-07-07  9:13         ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07  9:13 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Eric Auger [mailto:eric.auger@linaro.org]
> Sent: Tuesday, July 07, 2015 5:06 PM
> To: Wu, Feng; eric.auger@st.com; linux-arm-kernel@lists.infradead.org;
> kvmarm@lists.cs.columbia.edu; kvm@vger.kernel.org;
> christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> mtosatti@redhat.com; joro@8bytes.org; b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: Re: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
> 
> Hi Feng,
> On 07/07/2015 10:47 AM, Wu, Feng wrote:
> >
> >
> >> -----Original Message-----
> >> From: Eric Auger [mailto:eric.auger@linaro.org]
> >> Sent: Monday, July 06, 2015 8:12 PM
> >> To: eric.auger@st.com; eric.auger@linaro.org;
> >> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> >> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> >> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> >> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
> >> b.reynal@virtualopensystems.com
> >> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> >> Subject: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
> >>
> >> This patch adds the registration/unregistration of an
> >> irq_bypass_consumer on irqfd assignment/deassignment.
> >>
> >> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> >>
> >> ---
> >>
> >> v1 -> v2:
> >> - populate of kvm and gsi removed
> >> - unregister the consumer on irqfd_shutdown
> >> ---
> >>  include/linux/kvm_irqfd.h |  1 +
> >>  virt/kvm/eventfd.c        | 14 +++++++++++---
> >>  2 files changed, 12 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
> >> index f926b39..3c0bd07 100644
> >> --- a/include/linux/kvm_irqfd.h
> >> +++ b/include/linux/kvm_irqfd.h
> >> @@ -64,6 +64,7 @@ struct kvm_kernel_irqfd {
> >>  	struct list_head list;
> >>  	poll_table pt;
> >>  	struct work_struct shutdown;
> >> +	struct irq_bypass_consumer consumer;
> >>  };
> >>
> >>  #endif /* __LINUX_KVM_IRQFD_H */
> >> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> >> index b79dc61..9452754 100644
> >> --- a/virt/kvm/eventfd.c
> >> +++ b/virt/kvm/eventfd.c
> >> @@ -35,6 +35,7 @@
> >>  #include <linux/srcu.h>
> >>  #include <linux/slab.h>
> >>  #include <linux/seqlock.h>
> >> +#include <linux/irqbypass.h>
> >>  #include <trace/events/kvm.h>
> >>
> >>  #include <kvm/iodev.h>
> >> @@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
> >>  	/*
> >>  	 * It is now safe to release the object's resources
> >>  	 */
> >> +	irq_bypass_unregister_consumer(&irqfd->consumer);
> >>  	eventfd_ctx_put(irqfd->eventfd);
> >>  	kfree(irqfd);
> >>  }
> >> @@ -380,7 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct
> kvm_irqfd
> >> *args)
> >>  	 */
> >>  	fdput(f);
> >>
> >> -	/* irq_bypass_register_consumer(); */
> >> +	irqfd->consumer.token = (void *)irqfd->eventfd;
> >> +	irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
> >> +	irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
> >> +	irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
> >> +	irqfd->consumer.resume = kvm_arch_irq_bypass_resume;
> >> +	irqfd->consumer.update = kvm_arch_irq_bypass_update;
> >> +	ret = irq_bypass_register_consumer(&irqfd->consumer);
> >> +	WARN_ON(ret);
> >>
> >>  	return 0;
> >>
> >> @@ -481,8 +490,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct
> kvm_irqfd
> >> *args)
> >>  	struct kvm_kernel_irqfd *irqfd, *tmp;
> >>  	struct eventfd_ctx *eventfd;
> >>
> >> -	/* irq_bypass_unregister_consumer() */
> >> -
> >>  	eventfd = eventfd_ctx_fdget(args->fd);
> >>  	if (IS_ERR(eventfd))
> >>  		return PTR_ERR(eventfd);
> >> @@ -501,6 +508,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct
> kvm_irqfd
> >> *args)
> >>  			irqfd->irq_entry.type = 0;
> >>  			write_seqcount_end(&irqfd->irq_entry_sc);
> >>  			irqfd_deactivate(irqfd);
> >> +			irq_bypass_unregister_consumer(&irqfd->consumer);
> >
> > consumer is unregistered in irqfd_shutdown(), why need we do it here?
> Yes you're right, this is not needed anymore. Did things too hastily :-(
> 
> Otherwise does that isolated series fit your needs for posted interrupts
> and match your expectations with regards to split/reusability?

Basically, they are fine. I am trying to rebase my patch on top of it. If I
encounter any issues, I will discuss it here ASAP.

Thanks,
Feng

> 
> Eric
> 
> >
> > Thanks,
> > Feng
> >
> >>  		}
> >>  	}
> >>
> >> --
> >> 1.9.1
> >


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
@ 2015-07-07  9:13         ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07  9:13 UTC (permalink / raw)
  To: linux-arm-kernel



> -----Original Message-----
> From: Eric Auger [mailto:eric.auger at linaro.org]
> Sent: Tuesday, July 07, 2015 5:06 PM
> To: Wu, Feng; eric.auger at st.com; linux-arm-kernel at lists.infradead.org;
> kvmarm at lists.cs.columbia.edu; kvm at vger.kernel.org;
> christoffer.dall at linaro.org; marc.zyngier at arm.com;
> alex.williamson at redhat.com; pbonzini at redhat.com; avi.kivity at gmail.com;
> mtosatti at redhat.com; joro at 8bytes.org; b.reynal at virtualopensystems.com
> Cc: linux-kernel at vger.kernel.org; patches at linaro.org
> Subject: Re: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
> 
> Hi Feng,
> On 07/07/2015 10:47 AM, Wu, Feng wrote:
> >
> >
> >> -----Original Message-----
> >> From: Eric Auger [mailto:eric.auger at linaro.org]
> >> Sent: Monday, July 06, 2015 8:12 PM
> >> To: eric.auger at st.com; eric.auger at linaro.org;
> >> linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
> >> kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
> >> alex.williamson at redhat.com; pbonzini at redhat.com; avi.kivity at gmail.com;
> >> mtosatti at redhat.com; Wu, Feng; joro at 8bytes.org;
> >> b.reynal at virtualopensystems.com
> >> Cc: linux-kernel at vger.kernel.org; patches at linaro.org
> >> Subject: [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management
> >>
> >> This patch adds the registration/unregistration of an
> >> irq_bypass_consumer on irqfd assignment/deassignment.
> >>
> >> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> >>
> >> ---
> >>
> >> v1 -> v2:
> >> - populate of kvm and gsi removed
> >> - unregister the consumer on irqfd_shutdown
> >> ---
> >>  include/linux/kvm_irqfd.h |  1 +
> >>  virt/kvm/eventfd.c        | 14 +++++++++++---
> >>  2 files changed, 12 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
> >> index f926b39..3c0bd07 100644
> >> --- a/include/linux/kvm_irqfd.h
> >> +++ b/include/linux/kvm_irqfd.h
> >> @@ -64,6 +64,7 @@ struct kvm_kernel_irqfd {
> >>  	struct list_head list;
> >>  	poll_table pt;
> >>  	struct work_struct shutdown;
> >> +	struct irq_bypass_consumer consumer;
> >>  };
> >>
> >>  #endif /* __LINUX_KVM_IRQFD_H */
> >> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> >> index b79dc61..9452754 100644
> >> --- a/virt/kvm/eventfd.c
> >> +++ b/virt/kvm/eventfd.c
> >> @@ -35,6 +35,7 @@
> >>  #include <linux/srcu.h>
> >>  #include <linux/slab.h>
> >>  #include <linux/seqlock.h>
> >> +#include <linux/irqbypass.h>
> >>  #include <trace/events/kvm.h>
> >>
> >>  #include <kvm/iodev.h>
> >> @@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
> >>  	/*
> >>  	 * It is now safe to release the object's resources
> >>  	 */
> >> +	irq_bypass_unregister_consumer(&irqfd->consumer);
> >>  	eventfd_ctx_put(irqfd->eventfd);
> >>  	kfree(irqfd);
> >>  }
> >> @@ -380,7 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct
> kvm_irqfd
> >> *args)
> >>  	 */
> >>  	fdput(f);
> >>
> >> -	/* irq_bypass_register_consumer(); */
> >> +	irqfd->consumer.token = (void *)irqfd->eventfd;
> >> +	irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
> >> +	irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
> >> +	irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
> >> +	irqfd->consumer.resume = kvm_arch_irq_bypass_resume;
> >> +	irqfd->consumer.update = kvm_arch_irq_bypass_update;
> >> +	ret = irq_bypass_register_consumer(&irqfd->consumer);
> >> +	WARN_ON(ret);
> >>
> >>  	return 0;
> >>
> >> @@ -481,8 +490,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct
> kvm_irqfd
> >> *args)
> >>  	struct kvm_kernel_irqfd *irqfd, *tmp;
> >>  	struct eventfd_ctx *eventfd;
> >>
> >> -	/* irq_bypass_unregister_consumer() */
> >> -
> >>  	eventfd = eventfd_ctx_fdget(args->fd);
> >>  	if (IS_ERR(eventfd))
> >>  		return PTR_ERR(eventfd);
> >> @@ -501,6 +508,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct
> kvm_irqfd
> >> *args)
> >>  			irqfd->irq_entry.type = 0;
> >>  			write_seqcount_end(&irqfd->irq_entry_sc);
> >>  			irqfd_deactivate(irqfd);
> >> +			irq_bypass_unregister_consumer(&irqfd->consumer);
> >
> > consumer is unregistered in irqfd_shutdown(), why need we do it here?
> Yes you're right, this is not needed anymore. Did things too hastily :-(
> 
> Otherwise does that isolated series fit your needs for posted interrupts
> and match your expectations with regards to split/reusability?

Basically, they are fine. I am trying to rebase my patch on top of it. If I
encounter any issues, I will discuss it here ASAP.

Thanks,
Feng

> 
> Eric
> 
> >
> > Thanks,
> > Feng
> >
> >>  		}
> >>  	}
> >>
> >> --
> >> 1.9.1
> >

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-06 12:11   ` Eric Auger
  (?)
@ 2015-07-07 10:58     ` Wu, Feng
  -1 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 10:58 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Eric Auger [mailto:eric.auger@linaro.org]
> Sent: Monday, July 06, 2015 8:11 PM
> To: eric.auger@st.com; eric.auger@linaro.org;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
> b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
> 
> - [add,del]_[consumer,producer] updated to takes both the consumer and
>   producer handles. This is requested to combine info from both,
>   typically to link the source irq owned by the producer with the gsi
>   owned by the consumer (forwarded IRQ setup).
> - new methods are added:
>   x stop/resume: Those are needed for forwarding since the state change
>     requires to entermingle actions at consumer, producer.
>   x consumer update for posted interrupts
> - On handshake, we now call connect, disconnect which features the more
>   complex sequence.
> - add irq on producer side
> 
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> 
> ---
> 
> v1 -> v2:
> - remove vfio_device, kvm, gsi, opaque fields included in v1 except common
> - all those in can be retrieved with container_of in callbacks
> ---
>  include/linux/irqbypass.h | 19 ++++++++++++++++---
>  kernel/irq/bypass.c       | 44
> ++++++++++++++++++++++++++++++++++++++++----
>  2 files changed, 56 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
> index 718508e..8f62235 100644
> --- a/include/linux/irqbypass.h
> +++ b/include/linux/irqbypass.h
> @@ -3,17 +3,30 @@
> 
>  #include <linux/list.h>
> 
> +struct irq_bypass_consumer;
> +
>  struct irq_bypass_producer {
>  	struct list_head node;
>  	void *token;
> -	/* TBD */
> +	int irq; /* linux irq */
> +	void (*stop)(struct irq_bypass_producer *);
> +	void (*resume)(struct irq_bypass_producer *);
> +	void (*add_consumer)(struct irq_bypass_producer *,
> +			     struct irq_bypass_consumer *);
> +	void (*del_consumer)(struct irq_bypass_producer *,
> +			     struct irq_bypass_consumer *);
>  };
> 
>  struct irq_bypass_consumer {
>  	struct list_head node;
>  	void *token;

Can we add a pointer to ' struct irq_bypass_producer ', and
assign it when connecting, de-assign it when disconnecting.
since in some case, I need to update IRTE from the consumer
side, where I cannot get the related producer info (I need irq info)
without iterating it again.

Thanks,
Feng

> -	void (*add_producer)(struct irq_bypass_producer *);
> -	void (*del_producer)(struct irq_bypass_producer *);
> +	void (*stop)(struct irq_bypass_consumer *);
> +	void (*resume)(struct irq_bypass_consumer *);
> +	void (*add_producer)(struct irq_bypass_consumer *,
> +			     struct irq_bypass_producer *);
> +	void (*del_producer)(struct irq_bypass_consumer *,
> +			     struct irq_bypass_producer *);
> +	void (*update)(struct irq_bypass_consumer *);
>  };
> 
>  int irq_bypass_register_producer(struct irq_bypass_producer *);
> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
> index 5d0f92b..efadbe5 100644
> --- a/kernel/irq/bypass.c
> +++ b/kernel/irq/bypass.c
> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>  static LIST_HEAD(consumers);
>  static DEFINE_MUTEX(lock);
> 
> +/* lock must be hold when calling connect */
> +static void connect(struct irq_bypass_producer *prod,
> +		    struct irq_bypass_consumer *cons)
> +{
> +	if (prod->stop)
> +		prod->stop(prod);
> +	if (cons->stop)
> +		cons->stop(cons);
> +	if (prod->add_consumer)
> +		prod->add_consumer(prod, cons);
> +	if (cons->add_producer)
> +		cons->add_producer(cons, prod);
> +	if (cons->resume)
> +		cons->resume(cons);
> +	if (prod->resume)
> +		prod->resume(prod);
> +}
> +
> +/* lock must be hold when calling disconnect */
> +static void disconnect(struct irq_bypass_producer *prod,
> +		       struct irq_bypass_consumer *cons)
> +{
> +	if (prod->stop)
> +		prod->stop(prod);
> +	if (cons->stop)
> +		cons->stop(cons);
> +	if (cons->del_producer)
> +		cons->del_producer(cons, prod);
> +	if (prod->del_consumer)
> +		prod->del_consumer(prod, cons);
> +	if (cons->resume)
> +		cons->resume(cons);
> +	if (prod->resume)
> +		prod->resume(prod);
> +}
> +
>  int irq_bypass_register_producer(struct irq_bypass_producer *producer)
>  {
>  	struct irq_bypass_producer *tmp;
> @@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct
> irq_bypass_producer *producer)
> 
>  	list_for_each_entry(consumer, &consumers, node) {
>  		if (consumer->token == producer->token) {
> -			consumer->add_producer(producer);
> +			connect(producer, consumer);
>  			break;
>  		}
>  	}
> @@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct
> irq_bypass_producer *producer)
> 
>  	list_for_each_entry(consumer, &consumers, node) {
>  		if (consumer->token == producer->token) {
> -			consumer->del_producer(producer);
> +			disconnect(producer, consumer);
>  			break;
>  		}
>  	}
> @@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct
> irq_bypass_consumer *consumer)
> 
>  	list_for_each_entry(producer, &producers, node) {
>  		if (producer->token == consumer->token) {
> -			consumer->add_producer(producer);
> +			connect(producer, consumer);
>  			break;
>  		}
>  	}
> @@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct
> irq_bypass_consumer *consumer)
> 
>  	list_for_each_entry(producer, &producers, node) {
>  		if (producer->token == consumer->token) {
> -			consumer->del_producer(producer);
> +			disconnect(producer, consumer);
>  			break;
>  		}
>  	}
> --
> 1.9.1


^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 10:58     ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 10:58 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Eric Auger [mailto:eric.auger@linaro.org]
> Sent: Monday, July 06, 2015 8:11 PM
> To: eric.auger@st.com; eric.auger@linaro.org;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
> b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
> 
> - [add,del]_[consumer,producer] updated to takes both the consumer and
>   producer handles. This is requested to combine info from both,
>   typically to link the source irq owned by the producer with the gsi
>   owned by the consumer (forwarded IRQ setup).
> - new methods are added:
>   x stop/resume: Those are needed for forwarding since the state change
>     requires to entermingle actions at consumer, producer.
>   x consumer update for posted interrupts
> - On handshake, we now call connect, disconnect which features the more
>   complex sequence.
> - add irq on producer side
> 
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> 
> ---
> 
> v1 -> v2:
> - remove vfio_device, kvm, gsi, opaque fields included in v1 except common
> - all those in can be retrieved with container_of in callbacks
> ---
>  include/linux/irqbypass.h | 19 ++++++++++++++++---
>  kernel/irq/bypass.c       | 44
> ++++++++++++++++++++++++++++++++++++++++----
>  2 files changed, 56 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
> index 718508e..8f62235 100644
> --- a/include/linux/irqbypass.h
> +++ b/include/linux/irqbypass.h
> @@ -3,17 +3,30 @@
> 
>  #include <linux/list.h>
> 
> +struct irq_bypass_consumer;
> +
>  struct irq_bypass_producer {
>  	struct list_head node;
>  	void *token;
> -	/* TBD */
> +	int irq; /* linux irq */
> +	void (*stop)(struct irq_bypass_producer *);
> +	void (*resume)(struct irq_bypass_producer *);
> +	void (*add_consumer)(struct irq_bypass_producer *,
> +			     struct irq_bypass_consumer *);
> +	void (*del_consumer)(struct irq_bypass_producer *,
> +			     struct irq_bypass_consumer *);
>  };
> 
>  struct irq_bypass_consumer {
>  	struct list_head node;
>  	void *token;

Can we add a pointer to ' struct irq_bypass_producer ', and
assign it when connecting, de-assign it when disconnecting.
since in some case, I need to update IRTE from the consumer
side, where I cannot get the related producer info (I need irq info)
without iterating it again.

Thanks,
Feng

> -	void (*add_producer)(struct irq_bypass_producer *);
> -	void (*del_producer)(struct irq_bypass_producer *);
> +	void (*stop)(struct irq_bypass_consumer *);
> +	void (*resume)(struct irq_bypass_consumer *);
> +	void (*add_producer)(struct irq_bypass_consumer *,
> +			     struct irq_bypass_producer *);
> +	void (*del_producer)(struct irq_bypass_consumer *,
> +			     struct irq_bypass_producer *);
> +	void (*update)(struct irq_bypass_consumer *);
>  };
> 
>  int irq_bypass_register_producer(struct irq_bypass_producer *);
> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
> index 5d0f92b..efadbe5 100644
> --- a/kernel/irq/bypass.c
> +++ b/kernel/irq/bypass.c
> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>  static LIST_HEAD(consumers);
>  static DEFINE_MUTEX(lock);
> 
> +/* lock must be hold when calling connect */
> +static void connect(struct irq_bypass_producer *prod,
> +		    struct irq_bypass_consumer *cons)
> +{
> +	if (prod->stop)
> +		prod->stop(prod);
> +	if (cons->stop)
> +		cons->stop(cons);
> +	if (prod->add_consumer)
> +		prod->add_consumer(prod, cons);
> +	if (cons->add_producer)
> +		cons->add_producer(cons, prod);
> +	if (cons->resume)
> +		cons->resume(cons);
> +	if (prod->resume)
> +		prod->resume(prod);
> +}
> +
> +/* lock must be hold when calling disconnect */
> +static void disconnect(struct irq_bypass_producer *prod,
> +		       struct irq_bypass_consumer *cons)
> +{
> +	if (prod->stop)
> +		prod->stop(prod);
> +	if (cons->stop)
> +		cons->stop(cons);
> +	if (cons->del_producer)
> +		cons->del_producer(cons, prod);
> +	if (prod->del_consumer)
> +		prod->del_consumer(prod, cons);
> +	if (cons->resume)
> +		cons->resume(cons);
> +	if (prod->resume)
> +		prod->resume(prod);
> +}
> +
>  int irq_bypass_register_producer(struct irq_bypass_producer *producer)
>  {
>  	struct irq_bypass_producer *tmp;
> @@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct
> irq_bypass_producer *producer)
> 
>  	list_for_each_entry(consumer, &consumers, node) {
>  		if (consumer->token == producer->token) {
> -			consumer->add_producer(producer);
> +			connect(producer, consumer);
>  			break;
>  		}
>  	}
> @@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct
> irq_bypass_producer *producer)
> 
>  	list_for_each_entry(consumer, &consumers, node) {
>  		if (consumer->token == producer->token) {
> -			consumer->del_producer(producer);
> +			disconnect(producer, consumer);
>  			break;
>  		}
>  	}
> @@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct
> irq_bypass_consumer *consumer)
> 
>  	list_for_each_entry(producer, &producers, node) {
>  		if (producer->token == consumer->token) {
> -			consumer->add_producer(producer);
> +			connect(producer, consumer);
>  			break;
>  		}
>  	}
> @@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct
> irq_bypass_consumer *consumer)
> 
>  	list_for_each_entry(producer, &producers, node) {
>  		if (producer->token == consumer->token) {
> -			consumer->del_producer(producer);
> +			disconnect(producer, consumer);
>  			break;
>  		}
>  	}
> --
> 1.9.1

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 10:58     ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 10:58 UTC (permalink / raw)
  To: linux-arm-kernel



> -----Original Message-----
> From: Eric Auger [mailto:eric.auger at linaro.org]
> Sent: Monday, July 06, 2015 8:11 PM
> To: eric.auger at st.com; eric.auger at linaro.org;
> linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
> kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
> alex.williamson at redhat.com; pbonzini at redhat.com; avi.kivity at gmail.com;
> mtosatti at redhat.com; Wu, Feng; joro at 8bytes.org;
> b.reynal at virtualopensystems.com
> Cc: linux-kernel at vger.kernel.org; patches at linaro.org
> Subject: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
> 
> - [add,del]_[consumer,producer] updated to takes both the consumer and
>   producer handles. This is requested to combine info from both,
>   typically to link the source irq owned by the producer with the gsi
>   owned by the consumer (forwarded IRQ setup).
> - new methods are added:
>   x stop/resume: Those are needed for forwarding since the state change
>     requires to entermingle actions at consumer, producer.
>   x consumer update for posted interrupts
> - On handshake, we now call connect, disconnect which features the more
>   complex sequence.
> - add irq on producer side
> 
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> 
> ---
> 
> v1 -> v2:
> - remove vfio_device, kvm, gsi, opaque fields included in v1 except common
> - all those in can be retrieved with container_of in callbacks
> ---
>  include/linux/irqbypass.h | 19 ++++++++++++++++---
>  kernel/irq/bypass.c       | 44
> ++++++++++++++++++++++++++++++++++++++++----
>  2 files changed, 56 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
> index 718508e..8f62235 100644
> --- a/include/linux/irqbypass.h
> +++ b/include/linux/irqbypass.h
> @@ -3,17 +3,30 @@
> 
>  #include <linux/list.h>
> 
> +struct irq_bypass_consumer;
> +
>  struct irq_bypass_producer {
>  	struct list_head node;
>  	void *token;
> -	/* TBD */
> +	int irq; /* linux irq */
> +	void (*stop)(struct irq_bypass_producer *);
> +	void (*resume)(struct irq_bypass_producer *);
> +	void (*add_consumer)(struct irq_bypass_producer *,
> +			     struct irq_bypass_consumer *);
> +	void (*del_consumer)(struct irq_bypass_producer *,
> +			     struct irq_bypass_consumer *);
>  };
> 
>  struct irq_bypass_consumer {
>  	struct list_head node;
>  	void *token;

Can we add a pointer to ' struct irq_bypass_producer ', and
assign it when connecting, de-assign it when disconnecting.
since in some case, I need to update IRTE from the consumer
side, where I cannot get the related producer info (I need irq info)
without iterating it again.

Thanks,
Feng

> -	void (*add_producer)(struct irq_bypass_producer *);
> -	void (*del_producer)(struct irq_bypass_producer *);
> +	void (*stop)(struct irq_bypass_consumer *);
> +	void (*resume)(struct irq_bypass_consumer *);
> +	void (*add_producer)(struct irq_bypass_consumer *,
> +			     struct irq_bypass_producer *);
> +	void (*del_producer)(struct irq_bypass_consumer *,
> +			     struct irq_bypass_producer *);
> +	void (*update)(struct irq_bypass_consumer *);
>  };
> 
>  int irq_bypass_register_producer(struct irq_bypass_producer *);
> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
> index 5d0f92b..efadbe5 100644
> --- a/kernel/irq/bypass.c
> +++ b/kernel/irq/bypass.c
> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>  static LIST_HEAD(consumers);
>  static DEFINE_MUTEX(lock);
> 
> +/* lock must be hold when calling connect */
> +static void connect(struct irq_bypass_producer *prod,
> +		    struct irq_bypass_consumer *cons)
> +{
> +	if (prod->stop)
> +		prod->stop(prod);
> +	if (cons->stop)
> +		cons->stop(cons);
> +	if (prod->add_consumer)
> +		prod->add_consumer(prod, cons);
> +	if (cons->add_producer)
> +		cons->add_producer(cons, prod);
> +	if (cons->resume)
> +		cons->resume(cons);
> +	if (prod->resume)
> +		prod->resume(prod);
> +}
> +
> +/* lock must be hold when calling disconnect */
> +static void disconnect(struct irq_bypass_producer *prod,
> +		       struct irq_bypass_consumer *cons)
> +{
> +	if (prod->stop)
> +		prod->stop(prod);
> +	if (cons->stop)
> +		cons->stop(cons);
> +	if (cons->del_producer)
> +		cons->del_producer(cons, prod);
> +	if (prod->del_consumer)
> +		prod->del_consumer(prod, cons);
> +	if (cons->resume)
> +		cons->resume(cons);
> +	if (prod->resume)
> +		prod->resume(prod);
> +}
> +
>  int irq_bypass_register_producer(struct irq_bypass_producer *producer)
>  {
>  	struct irq_bypass_producer *tmp;
> @@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct
> irq_bypass_producer *producer)
> 
>  	list_for_each_entry(consumer, &consumers, node) {
>  		if (consumer->token == producer->token) {
> -			consumer->add_producer(producer);
> +			connect(producer, consumer);
>  			break;
>  		}
>  	}
> @@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct
> irq_bypass_producer *producer)
> 
>  	list_for_each_entry(consumer, &consumers, node) {
>  		if (consumer->token == producer->token) {
> -			consumer->del_producer(producer);
> +			disconnect(producer, consumer);
>  			break;
>  		}
>  	}
> @@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct
> irq_bypass_consumer *consumer)
> 
>  	list_for_each_entry(producer, &producers, node) {
>  		if (producer->token == consumer->token) {
> -			consumer->add_producer(producer);
> +			connect(producer, consumer);
>  			break;
>  		}
>  	}
> @@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct
> irq_bypass_consumer *consumer)
> 
>  	list_for_each_entry(producer, &producers, node) {
>  		if (producer->token == consumer->token) {
> -			consumer->del_producer(producer);
> +			disconnect(producer, consumer);
>  			break;
>  		}
>  	}
> --
> 1.9.1

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-07 10:58     ` Wu, Feng
  (?)
@ 2015-07-07 11:00       ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 11:00 UTC (permalink / raw)
  To: Wu, Feng, Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches



On 07/07/2015 12:58, Wu, Feng wrote:
> 
> 
>> -----Original Message-----
>> From: Eric Auger [mailto:eric.auger@linaro.org]
>> Sent: Monday, July 06, 2015 8:11 PM
>> To: eric.auger@st.com; eric.auger@linaro.org;
>> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
>> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
>> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
>> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
>> b.reynal@virtualopensystems.com
>> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
>> Subject: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
>>
>> - [add,del]_[consumer,producer] updated to takes both the consumer and
>>   producer handles. This is requested to combine info from both,
>>   typically to link the source irq owned by the producer with the gsi
>>   owned by the consumer (forwarded IRQ setup).
>> - new methods are added:
>>   x stop/resume: Those are needed for forwarding since the state change
>>     requires to entermingle actions at consumer, producer.
>>   x consumer update for posted interrupts
>> - On handshake, we now call connect, disconnect which features the more
>>   complex sequence.
>> - add irq on producer side
>>
>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>>
>> ---
>>
>> v1 -> v2:
>> - remove vfio_device, kvm, gsi, opaque fields included in v1 except common
>> - all those in can be retrieved with container_of in callbacks
>> ---
>>  include/linux/irqbypass.h | 19 ++++++++++++++++---
>>  kernel/irq/bypass.c       | 44
>> ++++++++++++++++++++++++++++++++++++++++----
>>  2 files changed, 56 insertions(+), 7 deletions(-)
>>
>> diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
>> index 718508e..8f62235 100644
>> --- a/include/linux/irqbypass.h
>> +++ b/include/linux/irqbypass.h
>> @@ -3,17 +3,30 @@
>>
>>  #include <linux/list.h>
>>
>> +struct irq_bypass_consumer;
>> +
>>  struct irq_bypass_producer {
>>  	struct list_head node;
>>  	void *token;
>> -	/* TBD */
>> +	int irq; /* linux irq */
>> +	void (*stop)(struct irq_bypass_producer *);
>> +	void (*resume)(struct irq_bypass_producer *);
>> +	void (*add_consumer)(struct irq_bypass_producer *,
>> +			     struct irq_bypass_consumer *);
>> +	void (*del_consumer)(struct irq_bypass_producer *,
>> +			     struct irq_bypass_consumer *);
>>  };
>>
>>  struct irq_bypass_consumer {
>>  	struct list_head node;
>>  	void *token;
> 
> Can we add a pointer to ' struct irq_bypass_producer ', and
> assign it when connecting, de-assign it when disconnecting.
> since in some case, I need to update IRTE from the consumer
> side, where I cannot get the related producer info (I need irq info)
> without iterating it again.

You can use container_of to add it to your own struct, e.g.

	struct irq_bypass_consumer cons;
	struct irq_bypass_producer *prod;

Paolo

> Thanks,
> Feng
> 
>> -	void (*add_producer)(struct irq_bypass_producer *);
>> -	void (*del_producer)(struct irq_bypass_producer *);
>> +	void (*stop)(struct irq_bypass_consumer *);
>> +	void (*resume)(struct irq_bypass_consumer *);
>> +	void (*add_producer)(struct irq_bypass_consumer *,
>> +			     struct irq_bypass_producer *);
>> +	void (*del_producer)(struct irq_bypass_consumer *,
>> +			     struct irq_bypass_producer *);
>> +	void (*update)(struct irq_bypass_consumer *);
>>  };
>>
>>  int irq_bypass_register_producer(struct irq_bypass_producer *);
>> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
>> index 5d0f92b..efadbe5 100644
>> --- a/kernel/irq/bypass.c
>> +++ b/kernel/irq/bypass.c
>> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>>  static LIST_HEAD(consumers);
>>  static DEFINE_MUTEX(lock);
>>
>> +/* lock must be hold when calling connect */
>> +static void connect(struct irq_bypass_producer *prod,
>> +		    struct irq_bypass_consumer *cons)
>> +{
>> +	if (prod->stop)
>> +		prod->stop(prod);
>> +	if (cons->stop)
>> +		cons->stop(cons);
>> +	if (prod->add_consumer)
>> +		prod->add_consumer(prod, cons);
>> +	if (cons->add_producer)
>> +		cons->add_producer(cons, prod);
>> +	if (cons->resume)
>> +		cons->resume(cons);
>> +	if (prod->resume)
>> +		prod->resume(prod);
>> +}
>> +
>> +/* lock must be hold when calling disconnect */
>> +static void disconnect(struct irq_bypass_producer *prod,
>> +		       struct irq_bypass_consumer *cons)
>> +{
>> +	if (prod->stop)
>> +		prod->stop(prod);
>> +	if (cons->stop)
>> +		cons->stop(cons);
>> +	if (cons->del_producer)
>> +		cons->del_producer(cons, prod);
>> +	if (prod->del_consumer)
>> +		prod->del_consumer(prod, cons);
>> +	if (cons->resume)
>> +		cons->resume(cons);
>> +	if (prod->resume)
>> +		prod->resume(prod);
>> +}
>> +
>>  int irq_bypass_register_producer(struct irq_bypass_producer *producer)
>>  {
>>  	struct irq_bypass_producer *tmp;
>> @@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct
>> irq_bypass_producer *producer)
>>
>>  	list_for_each_entry(consumer, &consumers, node) {
>>  		if (consumer->token == producer->token) {
>> -			consumer->add_producer(producer);
>> +			connect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> @@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct
>> irq_bypass_producer *producer)
>>
>>  	list_for_each_entry(consumer, &consumers, node) {
>>  		if (consumer->token == producer->token) {
>> -			consumer->del_producer(producer);
>> +			disconnect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> @@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct
>> irq_bypass_consumer *consumer)
>>
>>  	list_for_each_entry(producer, &producers, node) {
>>  		if (producer->token == consumer->token) {
>> -			consumer->add_producer(producer);
>> +			connect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> @@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct
>> irq_bypass_consumer *consumer)
>>
>>  	list_for_each_entry(producer, &producers, node) {
>>  		if (producer->token == consumer->token) {
>> -			consumer->del_producer(producer);
>> +			disconnect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> --
>> 1.9.1
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:00       ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 11:00 UTC (permalink / raw)
  To: Wu, Feng, Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches



On 07/07/2015 12:58, Wu, Feng wrote:
> 
> 
>> -----Original Message-----
>> From: Eric Auger [mailto:eric.auger@linaro.org]
>> Sent: Monday, July 06, 2015 8:11 PM
>> To: eric.auger@st.com; eric.auger@linaro.org;
>> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
>> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
>> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
>> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
>> b.reynal@virtualopensystems.com
>> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
>> Subject: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
>>
>> - [add,del]_[consumer,producer] updated to takes both the consumer and
>>   producer handles. This is requested to combine info from both,
>>   typically to link the source irq owned by the producer with the gsi
>>   owned by the consumer (forwarded IRQ setup).
>> - new methods are added:
>>   x stop/resume: Those are needed for forwarding since the state change
>>     requires to entermingle actions at consumer, producer.
>>   x consumer update for posted interrupts
>> - On handshake, we now call connect, disconnect which features the more
>>   complex sequence.
>> - add irq on producer side
>>
>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>>
>> ---
>>
>> v1 -> v2:
>> - remove vfio_device, kvm, gsi, opaque fields included in v1 except common
>> - all those in can be retrieved with container_of in callbacks
>> ---
>>  include/linux/irqbypass.h | 19 ++++++++++++++++---
>>  kernel/irq/bypass.c       | 44
>> ++++++++++++++++++++++++++++++++++++++++----
>>  2 files changed, 56 insertions(+), 7 deletions(-)
>>
>> diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
>> index 718508e..8f62235 100644
>> --- a/include/linux/irqbypass.h
>> +++ b/include/linux/irqbypass.h
>> @@ -3,17 +3,30 @@
>>
>>  #include <linux/list.h>
>>
>> +struct irq_bypass_consumer;
>> +
>>  struct irq_bypass_producer {
>>  	struct list_head node;
>>  	void *token;
>> -	/* TBD */
>> +	int irq; /* linux irq */
>> +	void (*stop)(struct irq_bypass_producer *);
>> +	void (*resume)(struct irq_bypass_producer *);
>> +	void (*add_consumer)(struct irq_bypass_producer *,
>> +			     struct irq_bypass_consumer *);
>> +	void (*del_consumer)(struct irq_bypass_producer *,
>> +			     struct irq_bypass_consumer *);
>>  };
>>
>>  struct irq_bypass_consumer {
>>  	struct list_head node;
>>  	void *token;
> 
> Can we add a pointer to ' struct irq_bypass_producer ', and
> assign it when connecting, de-assign it when disconnecting.
> since in some case, I need to update IRTE from the consumer
> side, where I cannot get the related producer info (I need irq info)
> without iterating it again.

You can use container_of to add it to your own struct, e.g.

	struct irq_bypass_consumer cons;
	struct irq_bypass_producer *prod;

Paolo

> Thanks,
> Feng
> 
>> -	void (*add_producer)(struct irq_bypass_producer *);
>> -	void (*del_producer)(struct irq_bypass_producer *);
>> +	void (*stop)(struct irq_bypass_consumer *);
>> +	void (*resume)(struct irq_bypass_consumer *);
>> +	void (*add_producer)(struct irq_bypass_consumer *,
>> +			     struct irq_bypass_producer *);
>> +	void (*del_producer)(struct irq_bypass_consumer *,
>> +			     struct irq_bypass_producer *);
>> +	void (*update)(struct irq_bypass_consumer *);
>>  };
>>
>>  int irq_bypass_register_producer(struct irq_bypass_producer *);
>> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
>> index 5d0f92b..efadbe5 100644
>> --- a/kernel/irq/bypass.c
>> +++ b/kernel/irq/bypass.c
>> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>>  static LIST_HEAD(consumers);
>>  static DEFINE_MUTEX(lock);
>>
>> +/* lock must be hold when calling connect */
>> +static void connect(struct irq_bypass_producer *prod,
>> +		    struct irq_bypass_consumer *cons)
>> +{
>> +	if (prod->stop)
>> +		prod->stop(prod);
>> +	if (cons->stop)
>> +		cons->stop(cons);
>> +	if (prod->add_consumer)
>> +		prod->add_consumer(prod, cons);
>> +	if (cons->add_producer)
>> +		cons->add_producer(cons, prod);
>> +	if (cons->resume)
>> +		cons->resume(cons);
>> +	if (prod->resume)
>> +		prod->resume(prod);
>> +}
>> +
>> +/* lock must be hold when calling disconnect */
>> +static void disconnect(struct irq_bypass_producer *prod,
>> +		       struct irq_bypass_consumer *cons)
>> +{
>> +	if (prod->stop)
>> +		prod->stop(prod);
>> +	if (cons->stop)
>> +		cons->stop(cons);
>> +	if (cons->del_producer)
>> +		cons->del_producer(cons, prod);
>> +	if (prod->del_consumer)
>> +		prod->del_consumer(prod, cons);
>> +	if (cons->resume)
>> +		cons->resume(cons);
>> +	if (prod->resume)
>> +		prod->resume(prod);
>> +}
>> +
>>  int irq_bypass_register_producer(struct irq_bypass_producer *producer)
>>  {
>>  	struct irq_bypass_producer *tmp;
>> @@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct
>> irq_bypass_producer *producer)
>>
>>  	list_for_each_entry(consumer, &consumers, node) {
>>  		if (consumer->token == producer->token) {
>> -			consumer->add_producer(producer);
>> +			connect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> @@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct
>> irq_bypass_producer *producer)
>>
>>  	list_for_each_entry(consumer, &consumers, node) {
>>  		if (consumer->token == producer->token) {
>> -			consumer->del_producer(producer);
>> +			disconnect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> @@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct
>> irq_bypass_consumer *consumer)
>>
>>  	list_for_each_entry(producer, &producers, node) {
>>  		if (producer->token == consumer->token) {
>> -			consumer->add_producer(producer);
>> +			connect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> @@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct
>> irq_bypass_consumer *consumer)
>>
>>  	list_for_each_entry(producer, &producers, node) {
>>  		if (producer->token == consumer->token) {
>> -			consumer->del_producer(producer);
>> +			disconnect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> --
>> 1.9.1
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:00       ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 11:00 UTC (permalink / raw)
  To: linux-arm-kernel



On 07/07/2015 12:58, Wu, Feng wrote:
> 
> 
>> -----Original Message-----
>> From: Eric Auger [mailto:eric.auger at linaro.org]
>> Sent: Monday, July 06, 2015 8:11 PM
>> To: eric.auger at st.com; eric.auger at linaro.org;
>> linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
>> kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
>> alex.williamson at redhat.com; pbonzini at redhat.com; avi.kivity at gmail.com;
>> mtosatti at redhat.com; Wu, Feng; joro at 8bytes.org;
>> b.reynal at virtualopensystems.com
>> Cc: linux-kernel at vger.kernel.org; patches at linaro.org
>> Subject: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
>>
>> - [add,del]_[consumer,producer] updated to takes both the consumer and
>>   producer handles. This is requested to combine info from both,
>>   typically to link the source irq owned by the producer with the gsi
>>   owned by the consumer (forwarded IRQ setup).
>> - new methods are added:
>>   x stop/resume: Those are needed for forwarding since the state change
>>     requires to entermingle actions at consumer, producer.
>>   x consumer update for posted interrupts
>> - On handshake, we now call connect, disconnect which features the more
>>   complex sequence.
>> - add irq on producer side
>>
>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>>
>> ---
>>
>> v1 -> v2:
>> - remove vfio_device, kvm, gsi, opaque fields included in v1 except common
>> - all those in can be retrieved with container_of in callbacks
>> ---
>>  include/linux/irqbypass.h | 19 ++++++++++++++++---
>>  kernel/irq/bypass.c       | 44
>> ++++++++++++++++++++++++++++++++++++++++----
>>  2 files changed, 56 insertions(+), 7 deletions(-)
>>
>> diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
>> index 718508e..8f62235 100644
>> --- a/include/linux/irqbypass.h
>> +++ b/include/linux/irqbypass.h
>> @@ -3,17 +3,30 @@
>>
>>  #include <linux/list.h>
>>
>> +struct irq_bypass_consumer;
>> +
>>  struct irq_bypass_producer {
>>  	struct list_head node;
>>  	void *token;
>> -	/* TBD */
>> +	int irq; /* linux irq */
>> +	void (*stop)(struct irq_bypass_producer *);
>> +	void (*resume)(struct irq_bypass_producer *);
>> +	void (*add_consumer)(struct irq_bypass_producer *,
>> +			     struct irq_bypass_consumer *);
>> +	void (*del_consumer)(struct irq_bypass_producer *,
>> +			     struct irq_bypass_consumer *);
>>  };
>>
>>  struct irq_bypass_consumer {
>>  	struct list_head node;
>>  	void *token;
> 
> Can we add a pointer to ' struct irq_bypass_producer ', and
> assign it when connecting, de-assign it when disconnecting.
> since in some case, I need to update IRTE from the consumer
> side, where I cannot get the related producer info (I need irq info)
> without iterating it again.

You can use container_of to add it to your own struct, e.g.

	struct irq_bypass_consumer cons;
	struct irq_bypass_producer *prod;

Paolo

> Thanks,
> Feng
> 
>> -	void (*add_producer)(struct irq_bypass_producer *);
>> -	void (*del_producer)(struct irq_bypass_producer *);
>> +	void (*stop)(struct irq_bypass_consumer *);
>> +	void (*resume)(struct irq_bypass_consumer *);
>> +	void (*add_producer)(struct irq_bypass_consumer *,
>> +			     struct irq_bypass_producer *);
>> +	void (*del_producer)(struct irq_bypass_consumer *,
>> +			     struct irq_bypass_producer *);
>> +	void (*update)(struct irq_bypass_consumer *);
>>  };
>>
>>  int irq_bypass_register_producer(struct irq_bypass_producer *);
>> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
>> index 5d0f92b..efadbe5 100644
>> --- a/kernel/irq/bypass.c
>> +++ b/kernel/irq/bypass.c
>> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
>>  static LIST_HEAD(consumers);
>>  static DEFINE_MUTEX(lock);
>>
>> +/* lock must be hold when calling connect */
>> +static void connect(struct irq_bypass_producer *prod,
>> +		    struct irq_bypass_consumer *cons)
>> +{
>> +	if (prod->stop)
>> +		prod->stop(prod);
>> +	if (cons->stop)
>> +		cons->stop(cons);
>> +	if (prod->add_consumer)
>> +		prod->add_consumer(prod, cons);
>> +	if (cons->add_producer)
>> +		cons->add_producer(cons, prod);
>> +	if (cons->resume)
>> +		cons->resume(cons);
>> +	if (prod->resume)
>> +		prod->resume(prod);
>> +}
>> +
>> +/* lock must be hold when calling disconnect */
>> +static void disconnect(struct irq_bypass_producer *prod,
>> +		       struct irq_bypass_consumer *cons)
>> +{
>> +	if (prod->stop)
>> +		prod->stop(prod);
>> +	if (cons->stop)
>> +		cons->stop(cons);
>> +	if (cons->del_producer)
>> +		cons->del_producer(cons, prod);
>> +	if (prod->del_consumer)
>> +		prod->del_consumer(prod, cons);
>> +	if (cons->resume)
>> +		cons->resume(cons);
>> +	if (prod->resume)
>> +		prod->resume(prod);
>> +}
>> +
>>  int irq_bypass_register_producer(struct irq_bypass_producer *producer)
>>  {
>>  	struct irq_bypass_producer *tmp;
>> @@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct
>> irq_bypass_producer *producer)
>>
>>  	list_for_each_entry(consumer, &consumers, node) {
>>  		if (consumer->token == producer->token) {
>> -			consumer->add_producer(producer);
>> +			connect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> @@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct
>> irq_bypass_producer *producer)
>>
>>  	list_for_each_entry(consumer, &consumers, node) {
>>  		if (consumer->token == producer->token) {
>> -			consumer->del_producer(producer);
>> +			disconnect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> @@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct
>> irq_bypass_consumer *consumer)
>>
>>  	list_for_each_entry(producer, &producers, node) {
>>  		if (producer->token == consumer->token) {
>> -			consumer->add_producer(producer);
>> +			connect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> @@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct
>> irq_bypass_consumer *consumer)
>>
>>  	list_for_each_entry(producer, &producers, node) {
>>  		if (producer->token == consumer->token) {
>> -			consumer->del_producer(producer);
>> +			disconnect(producer, consumer);
>>  			break;
>>  		}
>>  	}
>> --
>> 1.9.1
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-07 11:00       ` Paolo Bonzini
  (?)
@ 2015-07-07 11:13         ` Wu, Feng
  -1 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:13 UTC (permalink / raw)
  To: Paolo Bonzini, Eric Auger, eric.auger, linux-arm-kernel, kvmarm,
	kvm, christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Tuesday, July 07, 2015 7:01 PM
> To: Wu, Feng; Eric Auger; eric.auger@st.com;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; avi.kivity@gmail.com; mtosatti@redhat.com;
> joro@8bytes.org; b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> On 07/07/2015 12:58, Wu, Feng wrote:
> >
> >
> >> -----Original Message-----
> >> From: Eric Auger [mailto:eric.auger@linaro.org]
> >> Sent: Monday, July 06, 2015 8:11 PM
> >> To: eric.auger@st.com; eric.auger@linaro.org;
> >> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> >> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> >> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> >> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
> >> b.reynal@virtualopensystems.com
> >> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> >> Subject: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> >>
> >> - [add,del]_[consumer,producer] updated to takes both the consumer and
> >>   producer handles. This is requested to combine info from both,
> >>   typically to link the source irq owned by the producer with the gsi
> >>   owned by the consumer (forwarded IRQ setup).
> >> - new methods are added:
> >>   x stop/resume: Those are needed for forwarding since the state change
> >>     requires to entermingle actions at consumer, producer.
> >>   x consumer update for posted interrupts
> >> - On handshake, we now call connect, disconnect which features the more
> >>   complex sequence.
> >> - add irq on producer side
> >>
> >> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> >>
> >> ---
> >>
> >> v1 -> v2:
> >> - remove vfio_device, kvm, gsi, opaque fields included in v1 except common
> >> - all those in can be retrieved with container_of in callbacks
> >> ---
> >>  include/linux/irqbypass.h | 19 ++++++++++++++++---
> >>  kernel/irq/bypass.c       | 44
> >> ++++++++++++++++++++++++++++++++++++++++----
> >>  2 files changed, 56 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
> >> index 718508e..8f62235 100644
> >> --- a/include/linux/irqbypass.h
> >> +++ b/include/linux/irqbypass.h
> >> @@ -3,17 +3,30 @@
> >>
> >>  #include <linux/list.h>
> >>
> >> +struct irq_bypass_consumer;
> >> +
> >>  struct irq_bypass_producer {
> >>  	struct list_head node;
> >>  	void *token;
> >> -	/* TBD */
> >> +	int irq; /* linux irq */
> >> +	void (*stop)(struct irq_bypass_producer *);
> >> +	void (*resume)(struct irq_bypass_producer *);
> >> +	void (*add_consumer)(struct irq_bypass_producer *,
> >> +			     struct irq_bypass_consumer *);
> >> +	void (*del_consumer)(struct irq_bypass_producer *,
> >> +			     struct irq_bypass_consumer *);
> >>  };
> >>
> >>  struct irq_bypass_consumer {
> >>  	struct list_head node;
> >>  	void *token;
> >
> > Can we add a pointer to ' struct irq_bypass_producer ', and
> > assign it when connecting, de-assign it when disconnecting.
> > since in some case, I need to update IRTE from the consumer
> > side, where I cannot get the related producer info (I need irq info)
> > without iterating it again.
> 
> You can use container_of to add it to your own struct, e.g.
> 
> 	struct irq_bypass_consumer cons;
> 	struct irq_bypass_producer *prod;

Do you mean this:

struct kvm_kernel_irqfd {
	
	......

	struct irq_bypass_consumer cons;
	struct irq_bypass_producer *prod;
};

Thanks,
Feng

> 
> Paolo
> 
> > Thanks,
> > Feng
> >
> >> -	void (*add_producer)(struct irq_bypass_producer *);
> >> -	void (*del_producer)(struct irq_bypass_producer *);
> >> +	void (*stop)(struct irq_bypass_consumer *);
> >> +	void (*resume)(struct irq_bypass_consumer *);
> >> +	void (*add_producer)(struct irq_bypass_consumer *,
> >> +			     struct irq_bypass_producer *);
> >> +	void (*del_producer)(struct irq_bypass_consumer *,
> >> +			     struct irq_bypass_producer *);
> >> +	void (*update)(struct irq_bypass_consumer *);
> >>  };
> >>
> >>  int irq_bypass_register_producer(struct irq_bypass_producer *);
> >> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
> >> index 5d0f92b..efadbe5 100644
> >> --- a/kernel/irq/bypass.c
> >> +++ b/kernel/irq/bypass.c
> >> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
> >>  static LIST_HEAD(consumers);
> >>  static DEFINE_MUTEX(lock);
> >>
> >> +/* lock must be hold when calling connect */
> >> +static void connect(struct irq_bypass_producer *prod,
> >> +		    struct irq_bypass_consumer *cons)
> >> +{
> >> +	if (prod->stop)
> >> +		prod->stop(prod);
> >> +	if (cons->stop)
> >> +		cons->stop(cons);
> >> +	if (prod->add_consumer)
> >> +		prod->add_consumer(prod, cons);
> >> +	if (cons->add_producer)
> >> +		cons->add_producer(cons, prod);
> >> +	if (cons->resume)
> >> +		cons->resume(cons);
> >> +	if (prod->resume)
> >> +		prod->resume(prod);
> >> +}
> >> +
> >> +/* lock must be hold when calling disconnect */
> >> +static void disconnect(struct irq_bypass_producer *prod,
> >> +		       struct irq_bypass_consumer *cons)
> >> +{
> >> +	if (prod->stop)
> >> +		prod->stop(prod);
> >> +	if (cons->stop)
> >> +		cons->stop(cons);
> >> +	if (cons->del_producer)
> >> +		cons->del_producer(cons, prod);
> >> +	if (prod->del_consumer)
> >> +		prod->del_consumer(prod, cons);
> >> +	if (cons->resume)
> >> +		cons->resume(cons);
> >> +	if (prod->resume)
> >> +		prod->resume(prod);
> >> +}
> >> +
> >>  int irq_bypass_register_producer(struct irq_bypass_producer *producer)
> >>  {
> >>  	struct irq_bypass_producer *tmp;
> >> @@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct
> >> irq_bypass_producer *producer)
> >>
> >>  	list_for_each_entry(consumer, &consumers, node) {
> >>  		if (consumer->token == producer->token) {
> >> -			consumer->add_producer(producer);
> >> +			connect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> @@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct
> >> irq_bypass_producer *producer)
> >>
> >>  	list_for_each_entry(consumer, &consumers, node) {
> >>  		if (consumer->token == producer->token) {
> >> -			consumer->del_producer(producer);
> >> +			disconnect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> @@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct
> >> irq_bypass_consumer *consumer)
> >>
> >>  	list_for_each_entry(producer, &producers, node) {
> >>  		if (producer->token == consumer->token) {
> >> -			consumer->add_producer(producer);
> >> +			connect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> @@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct
> >> irq_bypass_consumer *consumer)
> >>
> >>  	list_for_each_entry(producer, &producers, node) {
> >>  		if (producer->token == consumer->token) {
> >> -			consumer->del_producer(producer);
> >> +			disconnect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> --
> >> 1.9.1
> >

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:13         ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:13 UTC (permalink / raw)
  To: Paolo Bonzini, Eric Auger, eric.auger, linux-arm-kernel, kvmarm,
	kvm, christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: Wu, Feng, linux-kernel, patches



> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Tuesday, July 07, 2015 7:01 PM
> To: Wu, Feng; Eric Auger; eric.auger@st.com;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; avi.kivity@gmail.com; mtosatti@redhat.com;
> joro@8bytes.org; b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> On 07/07/2015 12:58, Wu, Feng wrote:
> >
> >
> >> -----Original Message-----
> >> From: Eric Auger [mailto:eric.auger@linaro.org]
> >> Sent: Monday, July 06, 2015 8:11 PM
> >> To: eric.auger@st.com; eric.auger@linaro.org;
> >> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> >> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> >> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> >> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
> >> b.reynal@virtualopensystems.com
> >> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> >> Subject: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> >>
> >> - [add,del]_[consumer,producer] updated to takes both the consumer and
> >>   producer handles. This is requested to combine info from both,
> >>   typically to link the source irq owned by the producer with the gsi
> >>   owned by the consumer (forwarded IRQ setup).
> >> - new methods are added:
> >>   x stop/resume: Those are needed for forwarding since the state change
> >>     requires to entermingle actions at consumer, producer.
> >>   x consumer update for posted interrupts
> >> - On handshake, we now call connect, disconnect which features the more
> >>   complex sequence.
> >> - add irq on producer side
> >>
> >> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> >>
> >> ---
> >>
> >> v1 -> v2:
> >> - remove vfio_device, kvm, gsi, opaque fields included in v1 except common
> >> - all those in can be retrieved with container_of in callbacks
> >> ---
> >>  include/linux/irqbypass.h | 19 ++++++++++++++++---
> >>  kernel/irq/bypass.c       | 44
> >> ++++++++++++++++++++++++++++++++++++++++----
> >>  2 files changed, 56 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
> >> index 718508e..8f62235 100644
> >> --- a/include/linux/irqbypass.h
> >> +++ b/include/linux/irqbypass.h
> >> @@ -3,17 +3,30 @@
> >>
> >>  #include <linux/list.h>
> >>
> >> +struct irq_bypass_consumer;
> >> +
> >>  struct irq_bypass_producer {
> >>  	struct list_head node;
> >>  	void *token;
> >> -	/* TBD */
> >> +	int irq; /* linux irq */
> >> +	void (*stop)(struct irq_bypass_producer *);
> >> +	void (*resume)(struct irq_bypass_producer *);
> >> +	void (*add_consumer)(struct irq_bypass_producer *,
> >> +			     struct irq_bypass_consumer *);
> >> +	void (*del_consumer)(struct irq_bypass_producer *,
> >> +			     struct irq_bypass_consumer *);
> >>  };
> >>
> >>  struct irq_bypass_consumer {
> >>  	struct list_head node;
> >>  	void *token;
> >
> > Can we add a pointer to ' struct irq_bypass_producer ', and
> > assign it when connecting, de-assign it when disconnecting.
> > since in some case, I need to update IRTE from the consumer
> > side, where I cannot get the related producer info (I need irq info)
> > without iterating it again.
> 
> You can use container_of to add it to your own struct, e.g.
> 
> 	struct irq_bypass_consumer cons;
> 	struct irq_bypass_producer *prod;

Do you mean this:

struct kvm_kernel_irqfd {
	
	......

	struct irq_bypass_consumer cons;
	struct irq_bypass_producer *prod;
};

Thanks,
Feng

> 
> Paolo
> 
> > Thanks,
> > Feng
> >
> >> -	void (*add_producer)(struct irq_bypass_producer *);
> >> -	void (*del_producer)(struct irq_bypass_producer *);
> >> +	void (*stop)(struct irq_bypass_consumer *);
> >> +	void (*resume)(struct irq_bypass_consumer *);
> >> +	void (*add_producer)(struct irq_bypass_consumer *,
> >> +			     struct irq_bypass_producer *);
> >> +	void (*del_producer)(struct irq_bypass_consumer *,
> >> +			     struct irq_bypass_producer *);
> >> +	void (*update)(struct irq_bypass_consumer *);
> >>  };
> >>
> >>  int irq_bypass_register_producer(struct irq_bypass_producer *);
> >> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
> >> index 5d0f92b..efadbe5 100644
> >> --- a/kernel/irq/bypass.c
> >> +++ b/kernel/irq/bypass.c
> >> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
> >>  static LIST_HEAD(consumers);
> >>  static DEFINE_MUTEX(lock);
> >>
> >> +/* lock must be hold when calling connect */
> >> +static void connect(struct irq_bypass_producer *prod,
> >> +		    struct irq_bypass_consumer *cons)
> >> +{
> >> +	if (prod->stop)
> >> +		prod->stop(prod);
> >> +	if (cons->stop)
> >> +		cons->stop(cons);
> >> +	if (prod->add_consumer)
> >> +		prod->add_consumer(prod, cons);
> >> +	if (cons->add_producer)
> >> +		cons->add_producer(cons, prod);
> >> +	if (cons->resume)
> >> +		cons->resume(cons);
> >> +	if (prod->resume)
> >> +		prod->resume(prod);
> >> +}
> >> +
> >> +/* lock must be hold when calling disconnect */
> >> +static void disconnect(struct irq_bypass_producer *prod,
> >> +		       struct irq_bypass_consumer *cons)
> >> +{
> >> +	if (prod->stop)
> >> +		prod->stop(prod);
> >> +	if (cons->stop)
> >> +		cons->stop(cons);
> >> +	if (cons->del_producer)
> >> +		cons->del_producer(cons, prod);
> >> +	if (prod->del_consumer)
> >> +		prod->del_consumer(prod, cons);
> >> +	if (cons->resume)
> >> +		cons->resume(cons);
> >> +	if (prod->resume)
> >> +		prod->resume(prod);
> >> +}
> >> +
> >>  int irq_bypass_register_producer(struct irq_bypass_producer *producer)
> >>  {
> >>  	struct irq_bypass_producer *tmp;
> >> @@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct
> >> irq_bypass_producer *producer)
> >>
> >>  	list_for_each_entry(consumer, &consumers, node) {
> >>  		if (consumer->token == producer->token) {
> >> -			consumer->add_producer(producer);
> >> +			connect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> @@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct
> >> irq_bypass_producer *producer)
> >>
> >>  	list_for_each_entry(consumer, &consumers, node) {
> >>  		if (consumer->token == producer->token) {
> >> -			consumer->del_producer(producer);
> >> +			disconnect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> @@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct
> >> irq_bypass_consumer *consumer)
> >>
> >>  	list_for_each_entry(producer, &producers, node) {
> >>  		if (producer->token == consumer->token) {
> >> -			consumer->add_producer(producer);
> >> +			connect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> @@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct
> >> irq_bypass_consumer *consumer)
> >>
> >>  	list_for_each_entry(producer, &producers, node) {
> >>  		if (producer->token == consumer->token) {
> >> -			consumer->del_producer(producer);
> >> +			disconnect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> --
> >> 1.9.1
> >

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:13         ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:13 UTC (permalink / raw)
  To: linux-arm-kernel



> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini at redhat.com]
> Sent: Tuesday, July 07, 2015 7:01 PM
> To: Wu, Feng; Eric Auger; eric.auger at st.com;
> linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
> kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
> alex.williamson at redhat.com; avi.kivity at gmail.com; mtosatti at redhat.com;
> joro at 8bytes.org; b.reynal at virtualopensystems.com
> Cc: linux-kernel at vger.kernel.org; patches at linaro.org
> Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> On 07/07/2015 12:58, Wu, Feng wrote:
> >
> >
> >> -----Original Message-----
> >> From: Eric Auger [mailto:eric.auger at linaro.org]
> >> Sent: Monday, July 06, 2015 8:11 PM
> >> To: eric.auger at st.com; eric.auger at linaro.org;
> >> linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
> >> kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
> >> alex.williamson at redhat.com; pbonzini at redhat.com; avi.kivity at gmail.com;
> >> mtosatti at redhat.com; Wu, Feng; joro at 8bytes.org;
> >> b.reynal at virtualopensystems.com
> >> Cc: linux-kernel at vger.kernel.org; patches at linaro.org
> >> Subject: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> >>
> >> - [add,del]_[consumer,producer] updated to takes both the consumer and
> >>   producer handles. This is requested to combine info from both,
> >>   typically to link the source irq owned by the producer with the gsi
> >>   owned by the consumer (forwarded IRQ setup).
> >> - new methods are added:
> >>   x stop/resume: Those are needed for forwarding since the state change
> >>     requires to entermingle actions at consumer, producer.
> >>   x consumer update for posted interrupts
> >> - On handshake, we now call connect, disconnect which features the more
> >>   complex sequence.
> >> - add irq on producer side
> >>
> >> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> >>
> >> ---
> >>
> >> v1 -> v2:
> >> - remove vfio_device, kvm, gsi, opaque fields included in v1 except common
> >> - all those in can be retrieved with container_of in callbacks
> >> ---
> >>  include/linux/irqbypass.h | 19 ++++++++++++++++---
> >>  kernel/irq/bypass.c       | 44
> >> ++++++++++++++++++++++++++++++++++++++++----
> >>  2 files changed, 56 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
> >> index 718508e..8f62235 100644
> >> --- a/include/linux/irqbypass.h
> >> +++ b/include/linux/irqbypass.h
> >> @@ -3,17 +3,30 @@
> >>
> >>  #include <linux/list.h>
> >>
> >> +struct irq_bypass_consumer;
> >> +
> >>  struct irq_bypass_producer {
> >>  	struct list_head node;
> >>  	void *token;
> >> -	/* TBD */
> >> +	int irq; /* linux irq */
> >> +	void (*stop)(struct irq_bypass_producer *);
> >> +	void (*resume)(struct irq_bypass_producer *);
> >> +	void (*add_consumer)(struct irq_bypass_producer *,
> >> +			     struct irq_bypass_consumer *);
> >> +	void (*del_consumer)(struct irq_bypass_producer *,
> >> +			     struct irq_bypass_consumer *);
> >>  };
> >>
> >>  struct irq_bypass_consumer {
> >>  	struct list_head node;
> >>  	void *token;
> >
> > Can we add a pointer to ' struct irq_bypass_producer ', and
> > assign it when connecting, de-assign it when disconnecting.
> > since in some case, I need to update IRTE from the consumer
> > side, where I cannot get the related producer info (I need irq info)
> > without iterating it again.
> 
> You can use container_of to add it to your own struct, e.g.
> 
> 	struct irq_bypass_consumer cons;
> 	struct irq_bypass_producer *prod;

Do you mean this:

struct kvm_kernel_irqfd {
	
	......

	struct irq_bypass_consumer cons;
	struct irq_bypass_producer *prod;
};

Thanks,
Feng

> 
> Paolo
> 
> > Thanks,
> > Feng
> >
> >> -	void (*add_producer)(struct irq_bypass_producer *);
> >> -	void (*del_producer)(struct irq_bypass_producer *);
> >> +	void (*stop)(struct irq_bypass_consumer *);
> >> +	void (*resume)(struct irq_bypass_consumer *);
> >> +	void (*add_producer)(struct irq_bypass_consumer *,
> >> +			     struct irq_bypass_producer *);
> >> +	void (*del_producer)(struct irq_bypass_consumer *,
> >> +			     struct irq_bypass_producer *);
> >> +	void (*update)(struct irq_bypass_consumer *);
> >>  };
> >>
> >>  int irq_bypass_register_producer(struct irq_bypass_producer *);
> >> diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
> >> index 5d0f92b..efadbe5 100644
> >> --- a/kernel/irq/bypass.c
> >> +++ b/kernel/irq/bypass.c
> >> @@ -19,6 +19,42 @@ static LIST_HEAD(producers);
> >>  static LIST_HEAD(consumers);
> >>  static DEFINE_MUTEX(lock);
> >>
> >> +/* lock must be hold when calling connect */
> >> +static void connect(struct irq_bypass_producer *prod,
> >> +		    struct irq_bypass_consumer *cons)
> >> +{
> >> +	if (prod->stop)
> >> +		prod->stop(prod);
> >> +	if (cons->stop)
> >> +		cons->stop(cons);
> >> +	if (prod->add_consumer)
> >> +		prod->add_consumer(prod, cons);
> >> +	if (cons->add_producer)
> >> +		cons->add_producer(cons, prod);
> >> +	if (cons->resume)
> >> +		cons->resume(cons);
> >> +	if (prod->resume)
> >> +		prod->resume(prod);
> >> +}
> >> +
> >> +/* lock must be hold when calling disconnect */
> >> +static void disconnect(struct irq_bypass_producer *prod,
> >> +		       struct irq_bypass_consumer *cons)
> >> +{
> >> +	if (prod->stop)
> >> +		prod->stop(prod);
> >> +	if (cons->stop)
> >> +		cons->stop(cons);
> >> +	if (cons->del_producer)
> >> +		cons->del_producer(cons, prod);
> >> +	if (prod->del_consumer)
> >> +		prod->del_consumer(prod, cons);
> >> +	if (cons->resume)
> >> +		cons->resume(cons);
> >> +	if (prod->resume)
> >> +		prod->resume(prod);
> >> +}
> >> +
> >>  int irq_bypass_register_producer(struct irq_bypass_producer *producer)
> >>  {
> >>  	struct irq_bypass_producer *tmp;
> >> @@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct
> >> irq_bypass_producer *producer)
> >>
> >>  	list_for_each_entry(consumer, &consumers, node) {
> >>  		if (consumer->token == producer->token) {
> >> -			consumer->add_producer(producer);
> >> +			connect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> @@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct
> >> irq_bypass_producer *producer)
> >>
> >>  	list_for_each_entry(consumer, &consumers, node) {
> >>  		if (consumer->token == producer->token) {
> >> -			consumer->del_producer(producer);
> >> +			disconnect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> @@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct
> >> irq_bypass_consumer *consumer)
> >>
> >>  	list_for_each_entry(producer, &producers, node) {
> >>  		if (producer->token == consumer->token) {
> >> -			consumer->add_producer(producer);
> >> +			connect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> @@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct
> >> irq_bypass_consumer *consumer)
> >>
> >>  	list_for_each_entry(producer, &producers, node) {
> >>  		if (producer->token == consumer->token) {
> >> -			consumer->del_producer(producer);
> >> +			disconnect(producer, consumer);
> >>  			break;
> >>  		}
> >>  	}
> >> --
> >> 1.9.1
> >

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-07 11:13         ` Wu, Feng
  (?)
@ 2015-07-07 11:13           ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 11:13 UTC (permalink / raw)
  To: Wu, Feng, Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches



On 07/07/2015 13:13, Wu, Feng wrote:
>> > You can use container_of to add it to your own struct, e.g.
>> > 
>> > 	struct irq_bypass_consumer cons;
>> > 	struct irq_bypass_producer *prod;
> Do you mean this:
> 
> struct kvm_kernel_irqfd {
> 	
> 	......
> 
> 	struct irq_bypass_consumer cons;
> 	struct irq_bypass_producer *prod;
> };

Yes.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:13           ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 11:13 UTC (permalink / raw)
  To: Wu, Feng, Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches



On 07/07/2015 13:13, Wu, Feng wrote:
>> > You can use container_of to add it to your own struct, e.g.
>> > 
>> > 	struct irq_bypass_consumer cons;
>> > 	struct irq_bypass_producer *prod;
> Do you mean this:
> 
> struct kvm_kernel_irqfd {
> 	
> 	......
> 
> 	struct irq_bypass_consumer cons;
> 	struct irq_bypass_producer *prod;
> };

Yes.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:13           ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 11:13 UTC (permalink / raw)
  To: linux-arm-kernel



On 07/07/2015 13:13, Wu, Feng wrote:
>> > You can use container_of to add it to your own struct, e.g.
>> > 
>> > 	struct irq_bypass_consumer cons;
>> > 	struct irq_bypass_producer *prod;
> Do you mean this:
> 
> struct kvm_kernel_irqfd {
> 	
> 	......
> 
> 	struct irq_bypass_consumer cons;
> 	struct irq_bypass_producer *prod;
> };

Yes.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-07 11:13           ` Paolo Bonzini
  (?)
@ 2015-07-07 11:18             ` Wu, Feng
  -1 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:18 UTC (permalink / raw)
  To: Paolo Bonzini, Eric Auger, eric.auger, linux-arm-kernel, kvmarm,
	kvm, christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Tuesday, July 07, 2015 7:14 PM
> To: Wu, Feng; Eric Auger; eric.auger@st.com;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; avi.kivity@gmail.com; mtosatti@redhat.com;
> joro@8bytes.org; b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> On 07/07/2015 13:13, Wu, Feng wrote:
> >> > You can use container_of to add it to your own struct, e.g.
> >> >
> >> > 	struct irq_bypass_consumer cons;
> >> > 	struct irq_bypass_producer *prod;
> > Do you mean this:
> >
> > struct kvm_kernel_irqfd {
> >
> > 	......
> >
> > 	struct irq_bypass_consumer cons;
> > 	struct irq_bypass_producer *prod;
> > };
> 
> Yes.

Then I still need assign prod and de-assign prod in irq_bypass_register_consumer/irq_bypass_unregister_consumer,
Right? Would you please share why this is better. My original though is as below:

diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
index 8f62235..11930c1 100644
--- a/include/linux/irqbypass.h
+++ b/include/linux/irqbypass.h
@@ -20,6 +20,7 @@ struct irq_bypass_producer {
 struct irq_bypass_consumer {
        struct list_head node;
        void *token;
+       struct irq_bypass_producer *producer;
        void (*stop)(struct irq_bypass_consumer *);
        void (*resume)(struct irq_bypass_consumer *);
        void (*add_producer)(struct irq_bypass_consumer *,
diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
index efadbe5..be2da25 100644
--- a/kernel/irq/bypass.c
+++ b/kernel/irq/bypass.c
@@ -122,6 +122,7 @@ int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer)

        list_for_each_entry(producer, &producers, node) {
                if (producer->token == consumer->token) {
+                       consumer->producer = producer;
                        connect(producer, consumer);
                        break;
                }
@@ -140,6 +141,7 @@ void irq_bypass_unregister_consumer(struct irq_bypass_consumer *consumer)

        list_for_each_entry(producer, &producers, node) {
                if (producer->token == consumer->token) {
+                       consumer->producer = NULL;
                        disconnect(producer, consumer);
                        break;
                }

Thanks,
Feng

> 
> Paolo

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:18             ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:18 UTC (permalink / raw)
  To: Paolo Bonzini, Eric Auger, eric.auger, linux-arm-kernel, kvmarm,
	kvm, christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Tuesday, July 07, 2015 7:14 PM
> To: Wu, Feng; Eric Auger; eric.auger@st.com;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; avi.kivity@gmail.com; mtosatti@redhat.com;
> joro@8bytes.org; b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> On 07/07/2015 13:13, Wu, Feng wrote:
> >> > You can use container_of to add it to your own struct, e.g.
> >> >
> >> > 	struct irq_bypass_consumer cons;
> >> > 	struct irq_bypass_producer *prod;
> > Do you mean this:
> >
> > struct kvm_kernel_irqfd {
> >
> > 	......
> >
> > 	struct irq_bypass_consumer cons;
> > 	struct irq_bypass_producer *prod;
> > };
> 
> Yes.

Then I still need assign prod and de-assign prod in irq_bypass_register_consumer/irq_bypass_unregister_consumer,
Right? Would you please share why this is better. My original though is as below:

diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
index 8f62235..11930c1 100644
--- a/include/linux/irqbypass.h
+++ b/include/linux/irqbypass.h
@@ -20,6 +20,7 @@ struct irq_bypass_producer {
 struct irq_bypass_consumer {
        struct list_head node;
        void *token;
+       struct irq_bypass_producer *producer;
        void (*stop)(struct irq_bypass_consumer *);
        void (*resume)(struct irq_bypass_consumer *);
        void (*add_producer)(struct irq_bypass_consumer *,
diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
index efadbe5..be2da25 100644
--- a/kernel/irq/bypass.c
+++ b/kernel/irq/bypass.c
@@ -122,6 +122,7 @@ int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer)

        list_for_each_entry(producer, &producers, node) {
                if (producer->token == consumer->token) {
+                       consumer->producer = producer;
                        connect(producer, consumer);
                        break;
                }
@@ -140,6 +141,7 @@ void irq_bypass_unregister_consumer(struct irq_bypass_consumer *consumer)

        list_for_each_entry(producer, &producers, node) {
                if (producer->token == consumer->token) {
+                       consumer->producer = NULL;
                        disconnect(producer, consumer);
                        break;
                }

Thanks,
Feng

> 
> Paolo

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:18             ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:18 UTC (permalink / raw)
  To: linux-arm-kernel



> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini at redhat.com]
> Sent: Tuesday, July 07, 2015 7:14 PM
> To: Wu, Feng; Eric Auger; eric.auger at st.com;
> linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
> kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
> alex.williamson at redhat.com; avi.kivity at gmail.com; mtosatti at redhat.com;
> joro at 8bytes.org; b.reynal at virtualopensystems.com
> Cc: linux-kernel at vger.kernel.org; patches at linaro.org
> Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> On 07/07/2015 13:13, Wu, Feng wrote:
> >> > You can use container_of to add it to your own struct, e.g.
> >> >
> >> > 	struct irq_bypass_consumer cons;
> >> > 	struct irq_bypass_producer *prod;
> > Do you mean this:
> >
> > struct kvm_kernel_irqfd {
> >
> > 	......
> >
> > 	struct irq_bypass_consumer cons;
> > 	struct irq_bypass_producer *prod;
> > };
> 
> Yes.

Then I still need assign prod and de-assign prod in irq_bypass_register_consumer/irq_bypass_unregister_consumer,
Right? Would you please share why this is better. My original though is as below:

diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
index 8f62235..11930c1 100644
--- a/include/linux/irqbypass.h
+++ b/include/linux/irqbypass.h
@@ -20,6 +20,7 @@ struct irq_bypass_producer {
 struct irq_bypass_consumer {
        struct list_head node;
        void *token;
+       struct irq_bypass_producer *producer;
        void (*stop)(struct irq_bypass_consumer *);
        void (*resume)(struct irq_bypass_consumer *);
        void (*add_producer)(struct irq_bypass_consumer *,
diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c
index efadbe5..be2da25 100644
--- a/kernel/irq/bypass.c
+++ b/kernel/irq/bypass.c
@@ -122,6 +122,7 @@ int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer)

        list_for_each_entry(producer, &producers, node) {
                if (producer->token == consumer->token) {
+                       consumer->producer = producer;
                        connect(producer, consumer);
                        break;
                }
@@ -140,6 +141,7 @@ void irq_bypass_unregister_consumer(struct irq_bypass_consumer *consumer)

        list_for_each_entry(producer, &producers, node) {
                if (producer->token == consumer->token) {
+                       consumer->producer = NULL;
                        disconnect(producer, consumer);
                        break;
                }

Thanks,
Feng

> 
> Paolo

^ permalink raw reply related	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-07 11:18             ` Wu, Feng
  (?)
@ 2015-07-07 11:21               ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 11:21 UTC (permalink / raw)
  To: Wu, Feng, Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches



On 07/07/2015 13:18, Wu, Feng wrote:
> Then I still need assign prod and de-assign prod in
> irq_bypass_register_consumer/irq_bypass_unregister_consumer, Right?
> Would you please share why this is better.

The need to store the consumer->producer link seems to be unique to
posted interrupts.  It is difficult to say without seeing the PI code,
but I prefer to keep the bypass manager as small as possible.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:21               ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 11:21 UTC (permalink / raw)
  To: Wu, Feng, Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches



On 07/07/2015 13:18, Wu, Feng wrote:
> Then I still need assign prod and de-assign prod in
> irq_bypass_register_consumer/irq_bypass_unregister_consumer, Right?
> Would you please share why this is better.

The need to store the consumer->producer link seems to be unique to
posted interrupts.  It is difficult to say without seeing the PI code,
but I prefer to keep the bypass manager as small as possible.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:21               ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 11:21 UTC (permalink / raw)
  To: linux-arm-kernel



On 07/07/2015 13:18, Wu, Feng wrote:
> Then I still need assign prod and de-assign prod in
> irq_bypass_register_consumer/irq_bypass_unregister_consumer, Right?
> Would you please share why this is better.

The need to store the consumer->producer link seems to be unique to
posted interrupts.  It is difficult to say without seeing the PI code,
but I prefer to keep the bypass manager as small as possible.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-07 11:21               ` Paolo Bonzini
  (?)
@ 2015-07-07 11:24                 ` Wu, Feng
  -1 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:24 UTC (permalink / raw)
  To: Paolo Bonzini, Eric Auger, eric.auger, linux-arm-kernel, kvmarm,
	kvm, christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Tuesday, July 07, 2015 7:22 PM
> To: Wu, Feng; Eric Auger; eric.auger@st.com;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; avi.kivity@gmail.com; mtosatti@redhat.com;
> joro@8bytes.org; b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> On 07/07/2015 13:18, Wu, Feng wrote:
> > Then I still need assign prod and de-assign prod in
> > irq_bypass_register_consumer/irq_bypass_unregister_consumer, Right?
> > Would you please share why this is better.
> 
> The need to store the consumer->producer link seems to be unique to
> posted interrupts.  It is difficult to say without seeing the PI code,
> but I prefer to keep the bypass manager as small as possible.

Fine. I will follow your suggestion!

Thanks,
Feng

> 
> Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:24                 ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:24 UTC (permalink / raw)
  To: Paolo Bonzini, Eric Auger, eric.auger, linux-arm-kernel, kvmarm,
	kvm, christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Tuesday, July 07, 2015 7:22 PM
> To: Wu, Feng; Eric Auger; eric.auger@st.com;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; avi.kivity@gmail.com; mtosatti@redhat.com;
> joro@8bytes.org; b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> On 07/07/2015 13:18, Wu, Feng wrote:
> > Then I still need assign prod and de-assign prod in
> > irq_bypass_register_consumer/irq_bypass_unregister_consumer, Right?
> > Would you please share why this is better.
> 
> The need to store the consumer->producer link seems to be unique to
> posted interrupts.  It is difficult to say without seeing the PI code,
> but I prefer to keep the bypass manager as small as possible.

Fine. I will follow your suggestion!

Thanks,
Feng

> 
> Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:24                 ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:24 UTC (permalink / raw)
  To: linux-arm-kernel



> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini at redhat.com]
> Sent: Tuesday, July 07, 2015 7:22 PM
> To: Wu, Feng; Eric Auger; eric.auger at st.com;
> linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
> kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
> alex.williamson at redhat.com; avi.kivity at gmail.com; mtosatti at redhat.com;
> joro at 8bytes.org; b.reynal at virtualopensystems.com
> Cc: linux-kernel at vger.kernel.org; patches at linaro.org
> Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> On 07/07/2015 13:18, Wu, Feng wrote:
> > Then I still need assign prod and de-assign prod in
> > irq_bypass_register_consumer/irq_bypass_unregister_consumer, Right?
> > Would you please share why this is better.
> 
> The need to store the consumer->producer link seems to be unique to
> posted interrupts.  It is difficult to say without seeing the PI code,
> but I prefer to keep the bypass manager as small as possible.

Fine. I will follow your suggestion!

Thanks,
Feng

> 
> Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-07 11:24                 ` Wu, Feng
  (?)
@ 2015-07-07 11:33                   ` Wu, Feng
  -1 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:33 UTC (permalink / raw)
  To: Paolo Bonzini, Eric Auger, eric.auger, linux-arm-kernel, kvmarm,
	kvm, christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Wu, Feng
> Sent: Tuesday, July 07, 2015 7:24 PM
> To: Paolo Bonzini; Eric Auger; eric.auger@st.com;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; avi.kivity@gmail.com; mtosatti@redhat.com;
> joro@8bytes.org; b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org; Wu, Feng
> Subject: RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> > -----Original Message-----
> > From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> > Sent: Tuesday, July 07, 2015 7:22 PM
> > To: Wu, Feng; Eric Auger; eric.auger@st.com;
> > linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> > kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> > alex.williamson@redhat.com; avi.kivity@gmail.com; mtosatti@redhat.com;
> > joro@8bytes.org; b.reynal@virtualopensystems.com
> > Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> > Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> > control
> >
> >
> >
> > On 07/07/2015 13:18, Wu, Feng wrote:
> > > Then I still need assign prod and de-assign prod in
> > > irq_bypass_register_consumer/irq_bypass_unregister_consumer, Right?
> > > Would you please share why this is better.
> >
> > The need to store the consumer->producer link seems to be unique to
> > posted interrupts.  It is difficult to say without seeing the PI code,
> > but I prefer to keep the bypass manager as small as possible.
> 
> Fine. I will follow your suggestion!

If using the following changes, how can we assign 'prod', we need to use
container_of to get struct kvm_kernel_irqfd and then refer to 'prod', but
we cannot do this in irq_bypass_register_consumer(), right? It is a
common API. But we can only get the associated producer info inside
bypass manager, right?

Thanks,
Feng

struct kvm_kernel_irqfd {

 	......

 	struct irq_bypass_consumer cons;
 	struct irq_bypass_producer *prod;
};


> 
> Thanks,
> Feng
> 
> >
> > Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:33                   ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:33 UTC (permalink / raw)
  To: Paolo Bonzini, Eric Auger, eric.auger, linux-arm-kernel, kvmarm,
	kvm, christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: Wu, Feng
> Sent: Tuesday, July 07, 2015 7:24 PM
> To: Paolo Bonzini; Eric Auger; eric.auger@st.com;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; avi.kivity@gmail.com; mtosatti@redhat.com;
> joro@8bytes.org; b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org; Wu, Feng
> Subject: RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> > -----Original Message-----
> > From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> > Sent: Tuesday, July 07, 2015 7:22 PM
> > To: Wu, Feng; Eric Auger; eric.auger@st.com;
> > linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> > kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> > alex.williamson@redhat.com; avi.kivity@gmail.com; mtosatti@redhat.com;
> > joro@8bytes.org; b.reynal@virtualopensystems.com
> > Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> > Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> > control
> >
> >
> >
> > On 07/07/2015 13:18, Wu, Feng wrote:
> > > Then I still need assign prod and de-assign prod in
> > > irq_bypass_register_consumer/irq_bypass_unregister_consumer, Right?
> > > Would you please share why this is better.
> >
> > The need to store the consumer->producer link seems to be unique to
> > posted interrupts.  It is difficult to say without seeing the PI code,
> > but I prefer to keep the bypass manager as small as possible.
> 
> Fine. I will follow your suggestion!

If using the following changes, how can we assign 'prod', we need to use
container_of to get struct kvm_kernel_irqfd and then refer to 'prod', but
we cannot do this in irq_bypass_register_consumer(), right? It is a
common API. But we can only get the associated producer info inside
bypass manager, right?

Thanks,
Feng

struct kvm_kernel_irqfd {

 	......

 	struct irq_bypass_consumer cons;
 	struct irq_bypass_producer *prod;
};


> 
> Thanks,
> Feng
> 
> >
> > Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 11:33                   ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-07 11:33 UTC (permalink / raw)
  To: linux-arm-kernel



> -----Original Message-----
> From: Wu, Feng
> Sent: Tuesday, July 07, 2015 7:24 PM
> To: Paolo Bonzini; Eric Auger; eric.auger at st.com;
> linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
> kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
> alex.williamson at redhat.com; avi.kivity at gmail.com; mtosatti at redhat.com;
> joro at 8bytes.org; b.reynal at virtualopensystems.com
> Cc: linux-kernel at vger.kernel.org; patches at linaro.org; Wu, Feng
> Subject: RE: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> control
> 
> 
> 
> > -----Original Message-----
> > From: Paolo Bonzini [mailto:pbonzini at redhat.com]
> > Sent: Tuesday, July 07, 2015 7:22 PM
> > To: Wu, Feng; Eric Auger; eric.auger at st.com;
> > linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
> > kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
> > alex.williamson at redhat.com; avi.kivity at gmail.com; mtosatti at redhat.com;
> > joro at 8bytes.org; b.reynal at virtualopensystems.com
> > Cc: linux-kernel at vger.kernel.org; patches at linaro.org
> > Subject: Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding
> > control
> >
> >
> >
> > On 07/07/2015 13:18, Wu, Feng wrote:
> > > Then I still need assign prod and de-assign prod in
> > > irq_bypass_register_consumer/irq_bypass_unregister_consumer, Right?
> > > Would you please share why this is better.
> >
> > The need to store the consumer->producer link seems to be unique to
> > posted interrupts.  It is difficult to say without seeing the PI code,
> > but I prefer to keep the bypass manager as small as possible.
> 
> Fine. I will follow your suggestion!

If using the following changes, how can we assign 'prod', we need to use
container_of to get struct kvm_kernel_irqfd and then refer to 'prod', but
we cannot do this in irq_bypass_register_consumer(), right? It is a
common API. But we can only get the associated producer info inside
bypass manager, right?

Thanks,
Feng

struct kvm_kernel_irqfd {

 	......

 	struct irq_bypass_consumer cons;
 	struct irq_bypass_producer *prod;
};


> 
> Thanks,
> Feng
> 
> >
> > Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
  2015-07-07 11:33                   ` Wu, Feng
  (?)
@ 2015-07-07 13:22                     ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 13:22 UTC (permalink / raw)
  To: Wu, Feng, Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches



On 07/07/2015 13:33, Wu, Feng wrote:
>>> > > The need to store the consumer->producer link seems to be unique to
>>> > > posted interrupts.  It is difficult to say without seeing the PI code,
>>> > > but I prefer to keep the bypass manager as small as possible.
>> > 
>> > Fine. I will follow your suggestion!
> If using the following changes, how can we assign 'prod', we need to use
> container_of to get struct kvm_kernel_irqfd and then refer to 'prod', but
> we cannot do this in irq_bypass_register_consumer(), right? It is a
> common API. But we can only get the associated producer info inside
> bypass manager, right?

KVM's add_producer and del_producer callbacks do have a pointer to the
producer.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 13:22                     ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 13:22 UTC (permalink / raw)
  To: Wu, Feng, Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, avi.kivity,
	mtosatti, joro, b.reynal
  Cc: linux-kernel, patches



On 07/07/2015 13:33, Wu, Feng wrote:
>>> > > The need to store the consumer->producer link seems to be unique to
>>> > > posted interrupts.  It is difficult to say without seeing the PI code,
>>> > > but I prefer to keep the bypass manager as small as possible.
>> > 
>> > Fine. I will follow your suggestion!
> If using the following changes, how can we assign 'prod', we need to use
> container_of to get struct kvm_kernel_irqfd and then refer to 'prod', but
> we cannot do this in irq_bypass_register_consumer(), right? It is a
> common API. But we can only get the associated producer info inside
> bypass manager, right?

KVM's add_producer and del_producer callbacks do have a pointer to the
producer.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control
@ 2015-07-07 13:22                     ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-07 13:22 UTC (permalink / raw)
  To: linux-arm-kernel



On 07/07/2015 13:33, Wu, Feng wrote:
>>> > > The need to store the consumer->producer link seems to be unique to
>>> > > posted interrupts.  It is difficult to say without seeing the PI code,
>>> > > but I prefer to keep the bypass manager as small as possible.
>> > 
>> > Fine. I will follow your suggestion!
> If using the following changes, how can we assign 'prod', we need to use
> container_of to get struct kvm_kernel_irqfd and then refer to 'prod', but
> we cannot do this in irq_bypass_register_consumer(), right? It is a
> common API. But we can only get the associated producer info inside
> bypass manager, right?

KVM's add_producer and del_producer callbacks do have a pointer to the
producer.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
  2015-07-06 12:11 ` Eric Auger
  (?)
@ 2015-07-07 17:17   ` Alex Williamson
  -1 siblings, 0 replies; 84+ messages in thread
From: Alex Williamson @ 2015-07-07 17:17 UTC (permalink / raw)
  To: Eric Auger
  Cc: eric.auger, linux-arm-kernel, kvmarm, kvm, christoffer.dall,
	marc.zyngier, pbonzini, avi.kivity, mtosatti, feng.wu, joro,
	b.reynal, linux-kernel, patches

On Mon, 2015-07-06 at 14:11 +0200, Eric Auger wrote:
> This series introduces and extends the IRQ bypass manager written
> by Alex and transforms irqfd into an IRQ bypass manager consumer.
> The producer part, in my case the VFIO platform driver will be introduced
> separately. That code should be usable by both ARM IRQ forwarding
> and Intel Posted Interrupts.
> 
> The IRQ bypass manager enables to setup a negotiated link between an
> IRQ producer and an IRQ consumer (typically the VFIO driver and KVM irqfd).
> 
> The series currently includes Alex's code which was sent my email.
> Its structure obvioulsy will adapt to Alex's will.
> 
> Also the irq bypass manager gets compiled/linked on arm/arm64 along
> with KVM and VFIO platform driver.
> 
> can be found at:
> https://git.linaro.org/people/eric.auger/linux.git/shortlog/refs/heads/v4.2-rc1-bypass-fwd-v2


Thanks for taking this from a skeleton to a functional implementation,
Eric!  I'm happy with the way this is progressing.  Once we're confident
Feng can use your extensions, I'd be happy to merge those back into the
irq bypass manager and propose it upstream.

Hosting the bypass manager in kernel/irq seemed appropriate, but really
it could be anywhere.  Does anyone have a different preference or
specifically want it under their scope?  We had originally thought of
this as an IOMMU service, but I think we've generalized it beyond that.
I expect we should also add the necessary hooks to turn it into a
loadable module to keep the tinification folks happy, I'll incorporate
the current working changes and post a version with that.  Thanks,

Alex

> History:
> v1 -> v2:
> - isolate the bypass manager and irqfd consumer in this series
> - take into account Paolo's comments and use container_of strategy and
>   remove additional fields introduced in v1.
> - create kvm_irqfd.h
> - add unregistration in irqfd_shutdown
> 
> v1: originally part of [RFC 00/17] ARM IRQ forward control based on IRQ
>     bypass manager (https://lkml.org/lkml/2015/7/2/268)
> 
> 
> Eric Auger (6):
>   KVM: arm/arm64: select IRQ_BYPASS_MANAGER
>   VFIO: platform: select IRQ_BYPASS_MANAGER
>   irq: bypass: Extend skeleton for ARM forwarding control
>   KVM: create kvm_irqfd.h
>   KVM: introduce kvm_arch functions for IRQ bypass
>   KVM: eventfd: add irq bypass consumer management
> 
>  arch/arm/kvm/Kconfig          |   1 +
>  arch/arm64/kvm/Kconfig        |   1 +
>  drivers/vfio/platform/Kconfig |   1 +
>  include/linux/irqbypass.h     |  19 ++++++--
>  include/linux/kvm_host.h      |  37 ++++++++++++++
>  include/linux/kvm_irqfd.h     |  70 +++++++++++++++++++++++++++
>  kernel/irq/bypass.c           |  44 +++++++++++++++--
>  virt/kvm/Kconfig              |   3 ++
>  virt/kvm/eventfd.c            | 109 +++++++++++++-----------------------------
>  9 files changed, 203 insertions(+), 82 deletions(-)
>  create mode 100644 include/linux/kvm_irqfd.h
> 




^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-07 17:17   ` Alex Williamson
  0 siblings, 0 replies; 84+ messages in thread
From: Alex Williamson @ 2015-07-07 17:17 UTC (permalink / raw)
  To: Eric Auger
  Cc: eric.auger, kvm, patches, marc.zyngier, joro, mtosatti,
	linux-kernel, linux-arm-kernel, pbonzini, feng.wu, kvmarm,
	avi.kivity

On Mon, 2015-07-06 at 14:11 +0200, Eric Auger wrote:
> This series introduces and extends the IRQ bypass manager written
> by Alex and transforms irqfd into an IRQ bypass manager consumer.
> The producer part, in my case the VFIO platform driver will be introduced
> separately. That code should be usable by both ARM IRQ forwarding
> and Intel Posted Interrupts.
> 
> The IRQ bypass manager enables to setup a negotiated link between an
> IRQ producer and an IRQ consumer (typically the VFIO driver and KVM irqfd).
> 
> The series currently includes Alex's code which was sent my email.
> Its structure obvioulsy will adapt to Alex's will.
> 
> Also the irq bypass manager gets compiled/linked on arm/arm64 along
> with KVM and VFIO platform driver.
> 
> can be found at:
> https://git.linaro.org/people/eric.auger/linux.git/shortlog/refs/heads/v4.2-rc1-bypass-fwd-v2


Thanks for taking this from a skeleton to a functional implementation,
Eric!  I'm happy with the way this is progressing.  Once we're confident
Feng can use your extensions, I'd be happy to merge those back into the
irq bypass manager and propose it upstream.

Hosting the bypass manager in kernel/irq seemed appropriate, but really
it could be anywhere.  Does anyone have a different preference or
specifically want it under their scope?  We had originally thought of
this as an IOMMU service, but I think we've generalized it beyond that.
I expect we should also add the necessary hooks to turn it into a
loadable module to keep the tinification folks happy, I'll incorporate
the current working changes and post a version with that.  Thanks,

Alex

> History:
> v1 -> v2:
> - isolate the bypass manager and irqfd consumer in this series
> - take into account Paolo's comments and use container_of strategy and
>   remove additional fields introduced in v1.
> - create kvm_irqfd.h
> - add unregistration in irqfd_shutdown
> 
> v1: originally part of [RFC 00/17] ARM IRQ forward control based on IRQ
>     bypass manager (https://lkml.org/lkml/2015/7/2/268)
> 
> 
> Eric Auger (6):
>   KVM: arm/arm64: select IRQ_BYPASS_MANAGER
>   VFIO: platform: select IRQ_BYPASS_MANAGER
>   irq: bypass: Extend skeleton for ARM forwarding control
>   KVM: create kvm_irqfd.h
>   KVM: introduce kvm_arch functions for IRQ bypass
>   KVM: eventfd: add irq bypass consumer management
> 
>  arch/arm/kvm/Kconfig          |   1 +
>  arch/arm64/kvm/Kconfig        |   1 +
>  drivers/vfio/platform/Kconfig |   1 +
>  include/linux/irqbypass.h     |  19 ++++++--
>  include/linux/kvm_host.h      |  37 ++++++++++++++
>  include/linux/kvm_irqfd.h     |  70 +++++++++++++++++++++++++++
>  kernel/irq/bypass.c           |  44 +++++++++++++++--
>  virt/kvm/Kconfig              |   3 ++
>  virt/kvm/eventfd.c            | 109 +++++++++++++-----------------------------
>  9 files changed, 203 insertions(+), 82 deletions(-)
>  create mode 100644 include/linux/kvm_irqfd.h
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-07 17:17   ` Alex Williamson
  0 siblings, 0 replies; 84+ messages in thread
From: Alex Williamson @ 2015-07-07 17:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2015-07-06 at 14:11 +0200, Eric Auger wrote:
> This series introduces and extends the IRQ bypass manager written
> by Alex and transforms irqfd into an IRQ bypass manager consumer.
> The producer part, in my case the VFIO platform driver will be introduced
> separately. That code should be usable by both ARM IRQ forwarding
> and Intel Posted Interrupts.
> 
> The IRQ bypass manager enables to setup a negotiated link between an
> IRQ producer and an IRQ consumer (typically the VFIO driver and KVM irqfd).
> 
> The series currently includes Alex's code which was sent my email.
> Its structure obvioulsy will adapt to Alex's will.
> 
> Also the irq bypass manager gets compiled/linked on arm/arm64 along
> with KVM and VFIO platform driver.
> 
> can be found at:
> https://git.linaro.org/people/eric.auger/linux.git/shortlog/refs/heads/v4.2-rc1-bypass-fwd-v2


Thanks for taking this from a skeleton to a functional implementation,
Eric!  I'm happy with the way this is progressing.  Once we're confident
Feng can use your extensions, I'd be happy to merge those back into the
irq bypass manager and propose it upstream.

Hosting the bypass manager in kernel/irq seemed appropriate, but really
it could be anywhere.  Does anyone have a different preference or
specifically want it under their scope?  We had originally thought of
this as an IOMMU service, but I think we've generalized it beyond that.
I expect we should also add the necessary hooks to turn it into a
loadable module to keep the tinification folks happy, I'll incorporate
the current working changes and post a version with that.  Thanks,

Alex

> History:
> v1 -> v2:
> - isolate the bypass manager and irqfd consumer in this series
> - take into account Paolo's comments and use container_of strategy and
>   remove additional fields introduced in v1.
> - create kvm_irqfd.h
> - add unregistration in irqfd_shutdown
> 
> v1: originally part of [RFC 00/17] ARM IRQ forward control based on IRQ
>     bypass manager (https://lkml.org/lkml/2015/7/2/268)
> 
> 
> Eric Auger (6):
>   KVM: arm/arm64: select IRQ_BYPASS_MANAGER
>   VFIO: platform: select IRQ_BYPASS_MANAGER
>   irq: bypass: Extend skeleton for ARM forwarding control
>   KVM: create kvm_irqfd.h
>   KVM: introduce kvm_arch functions for IRQ bypass
>   KVM: eventfd: add irq bypass consumer management
> 
>  arch/arm/kvm/Kconfig          |   1 +
>  arch/arm64/kvm/Kconfig        |   1 +
>  drivers/vfio/platform/Kconfig |   1 +
>  include/linux/irqbypass.h     |  19 ++++++--
>  include/linux/kvm_host.h      |  37 ++++++++++++++
>  include/linux/kvm_irqfd.h     |  70 +++++++++++++++++++++++++++
>  kernel/irq/bypass.c           |  44 +++++++++++++++--
>  virt/kvm/Kconfig              |   3 ++
>  virt/kvm/eventfd.c            | 109 +++++++++++++-----------------------------
>  9 files changed, 203 insertions(+), 82 deletions(-)
>  create mode 100644 include/linux/kvm_irqfd.h
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
  2015-07-07 17:17   ` Alex Williamson
@ 2015-07-09 12:28     ` Joerg Roedel
  -1 siblings, 0 replies; 84+ messages in thread
From: Joerg Roedel @ 2015-07-09 12:28 UTC (permalink / raw)
  To: Alex Williamson
  Cc: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, pbonzini, avi.kivity, mtosatti,
	feng.wu, b.reynal, linux-kernel, patches

On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
> Hosting the bypass manager in kernel/irq seemed appropriate, but really
> it could be anywhere.  Does anyone have a different preference or
> specifically want it under their scope?  We had originally thought of
> this as an IOMMU service, but I think we've generalized it beyond that.
> I expect we should also add the necessary hooks to turn it into a
> loadable module to keep the tinification folks happy, I'll incorporate
> the current working changes and post a version with that.

Yeah, this is only an IOMMU service on x86, afaik. So drivers/iommu is
probably the wrong place to host it.

Will there be any other producers than VFIO or any other consumers than
KVM? If not, it should live in one of these spaces. KVM is probably the
best choice, as any hardware feature that uses this targets
virtualization, so there will hardly ever be another consumer than KVM.


	Joerg


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-09 12:28     ` Joerg Roedel
  0 siblings, 0 replies; 84+ messages in thread
From: Joerg Roedel @ 2015-07-09 12:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
> Hosting the bypass manager in kernel/irq seemed appropriate, but really
> it could be anywhere.  Does anyone have a different preference or
> specifically want it under their scope?  We had originally thought of
> this as an IOMMU service, but I think we've generalized it beyond that.
> I expect we should also add the necessary hooks to turn it into a
> loadable module to keep the tinification folks happy, I'll incorporate
> the current working changes and post a version with that.

Yeah, this is only an IOMMU service on x86, afaik. So drivers/iommu is
probably the wrong place to host it.

Will there be any other producers than VFIO or any other consumers than
KVM? If not, it should live in one of these spaces. KVM is probably the
best choice, as any hardware feature that uses this targets
virtualization, so there will hardly ever be another consumer than KVM.


	Joerg

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
  2015-07-09 12:28     ` Joerg Roedel
@ 2015-07-09 14:13       ` Alex Williamson
  -1 siblings, 0 replies; 84+ messages in thread
From: Alex Williamson @ 2015-07-09 14:13 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, pbonzini, avi.kivity, mtosatti,
	feng.wu, b.reynal, linux-kernel, patches

On Thu, 2015-07-09 at 14:28 +0200, Joerg Roedel wrote:
> On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
> > Hosting the bypass manager in kernel/irq seemed appropriate, but really
> > it could be anywhere.  Does anyone have a different preference or
> > specifically want it under their scope?  We had originally thought of
> > this as an IOMMU service, but I think we've generalized it beyond that.
> > I expect we should also add the necessary hooks to turn it into a
> > loadable module to keep the tinification folks happy, I'll incorporate
> > the current working changes and post a version with that.
> 
> Yeah, this is only an IOMMU service on x86, afaik. So drivers/iommu is
> probably the wrong place to host it.
> 
> Will there be any other producers than VFIO or any other consumers than
> KVM? If not, it should live in one of these spaces. KVM is probably the
> best choice, as any hardware feature that uses this targets
> virtualization, so there will hardly ever be another consumer than KVM.

If we think that it's *only* a kvm-vfio interaction then we could add it
to virt/kvm/vfio.c.  vfio could use symbol_get to avoid a module
dependency and effectively disable the code path when not used with kvm.
The reverse model of hosting it in vfio and using symbol_get from
kvm-vfio would also work.  Do we really want to declare it to be
kvm-vfio specific though?  Another option would be to simply host it
under virt/lib with module dependencies for both vfio and kvm.  Thanks,

Alex


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-09 14:13       ` Alex Williamson
  0 siblings, 0 replies; 84+ messages in thread
From: Alex Williamson @ 2015-07-09 14:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 2015-07-09 at 14:28 +0200, Joerg Roedel wrote:
> On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
> > Hosting the bypass manager in kernel/irq seemed appropriate, but really
> > it could be anywhere.  Does anyone have a different preference or
> > specifically want it under their scope?  We had originally thought of
> > this as an IOMMU service, but I think we've generalized it beyond that.
> > I expect we should also add the necessary hooks to turn it into a
> > loadable module to keep the tinification folks happy, I'll incorporate
> > the current working changes and post a version with that.
> 
> Yeah, this is only an IOMMU service on x86, afaik. So drivers/iommu is
> probably the wrong place to host it.
> 
> Will there be any other producers than VFIO or any other consumers than
> KVM? If not, it should live in one of these spaces. KVM is probably the
> best choice, as any hardware feature that uses this targets
> virtualization, so there will hardly ever be another consumer than KVM.

If we think that it's *only* a kvm-vfio interaction then we could add it
to virt/kvm/vfio.c.  vfio could use symbol_get to avoid a module
dependency and effectively disable the code path when not used with kvm.
The reverse model of hosting it in vfio and using symbol_get from
kvm-vfio would also work.  Do we really want to declare it to be
kvm-vfio specific though?  Another option would be to simply host it
under virt/lib with module dependencies for both vfio and kvm.  Thanks,

Alex

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
  2015-07-09 14:13       ` Alex Williamson
@ 2015-07-09 14:38         ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-09 14:38 UTC (permalink / raw)
  To: Alex Williamson, Joerg Roedel
  Cc: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, avi.kivity, mtosatti, feng.wu,
	b.reynal, linux-kernel, patches



On 09/07/2015 16:13, Alex Williamson wrote:
> On Thu, 2015-07-09 at 14:28 +0200, Joerg Roedel wrote:
>> On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
>>> Hosting the bypass manager in kernel/irq seemed appropriate, but really
>>> it could be anywhere.  Does anyone have a different preference or
>>> specifically want it under their scope?  We had originally thought of
>>> this as an IOMMU service, but I think we've generalized it beyond that.
>>> I expect we should also add the necessary hooks to turn it into a
>>> loadable module to keep the tinification folks happy, I'll incorporate
>>> the current working changes and post a version with that.
>>
>> Yeah, this is only an IOMMU service on x86, afaik. So drivers/iommu is
>> probably the wrong place to host it.
>>
>> Will there be any other producers than VFIO or any other consumers than
>> KVM? If not, it should live in one of these spaces. KVM is probably the
>> best choice, as any hardware feature that uses this targets
>> virtualization, so there will hardly ever be another consumer than KVM.
> 
> If we think that it's *only* a kvm-vfio interaction then we could add it
> to virt/kvm/vfio.c.  vfio could use symbol_get to avoid a module
> dependency and effectively disable the code path when not used with kvm.
> The reverse model of hosting it in vfio and using symbol_get from
> kvm-vfio would also work.  Do we really want to declare it to be
> kvm-vfio specific though?  Another option would be to simply host it
> under virt/lib with module dependencies for both vfio and kvm.

I wonder if in the future we may have some kind of driver-mediated
passthrough, e.g. for network drivers.  They might use the bypass
mechanism too.  So I think drivers/vfio is too restrictive.

virt/ right now only hosts KVM, but it could for example host lguest
too.  virt/lib/ is okay with me.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-09 14:38         ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2015-07-09 14:38 UTC (permalink / raw)
  To: linux-arm-kernel



On 09/07/2015 16:13, Alex Williamson wrote:
> On Thu, 2015-07-09 at 14:28 +0200, Joerg Roedel wrote:
>> On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
>>> Hosting the bypass manager in kernel/irq seemed appropriate, but really
>>> it could be anywhere.  Does anyone have a different preference or
>>> specifically want it under their scope?  We had originally thought of
>>> this as an IOMMU service, but I think we've generalized it beyond that.
>>> I expect we should also add the necessary hooks to turn it into a
>>> loadable module to keep the tinification folks happy, I'll incorporate
>>> the current working changes and post a version with that.
>>
>> Yeah, this is only an IOMMU service on x86, afaik. So drivers/iommu is
>> probably the wrong place to host it.
>>
>> Will there be any other producers than VFIO or any other consumers than
>> KVM? If not, it should live in one of these spaces. KVM is probably the
>> best choice, as any hardware feature that uses this targets
>> virtualization, so there will hardly ever be another consumer than KVM.
> 
> If we think that it's *only* a kvm-vfio interaction then we could add it
> to virt/kvm/vfio.c.  vfio could use symbol_get to avoid a module
> dependency and effectively disable the code path when not used with kvm.
> The reverse model of hosting it in vfio and using symbol_get from
> kvm-vfio would also work.  Do we really want to declare it to be
> kvm-vfio specific though?  Another option would be to simply host it
> under virt/lib with module dependencies for both vfio and kvm.

I wonder if in the future we may have some kind of driver-mediated
passthrough, e.g. for network drivers.  They might use the bypass
mechanism too.  So I think drivers/vfio is too restrictive.

virt/ right now only hosts KVM, but it could for example host lguest
too.  virt/lib/ is okay with me.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
  2015-07-09 14:38         ` Paolo Bonzini
  (?)
@ 2015-07-09 15:34           ` Joerg Roedel
  -1 siblings, 0 replies; 84+ messages in thread
From: Joerg Roedel @ 2015-07-09 15:34 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Alex Williamson, Eric Auger, eric.auger, linux-arm-kernel,
	kvmarm, kvm, christoffer.dall, marc.zyngier, avi.kivity,
	mtosatti, feng.wu, b.reynal, linux-kernel, patches

On Thu, Jul 09, 2015 at 04:38:41PM +0200, Paolo Bonzini wrote:
> >> On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
> > If we think that it's *only* a kvm-vfio interaction then we could add it
> > to virt/kvm/vfio.c.  vfio could use symbol_get to avoid a module
> > dependency and effectively disable the code path when not used with kvm.
> > The reverse model of hosting it in vfio and using symbol_get from
> > kvm-vfio would also work.  Do we really want to declare it to be
> > kvm-vfio specific though?  Another option would be to simply host it
> > under virt/lib with module dependencies for both vfio and kvm.
> 
> I wonder if in the future we may have some kind of driver-mediated
> passthrough, e.g. for network drivers.  They might use the bypass
> mechanism too.  So I think drivers/vfio is too restrictive.
> 
> virt/ right now only hosts KVM, but it could for example host lguest
> too.  virt/lib/ is okay with me.

Yeah, virt/lib is probably the best choice.


	Joerg


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-09 15:34           ` Joerg Roedel
  0 siblings, 0 replies; 84+ messages in thread
From: Joerg Roedel @ 2015-07-09 15:34 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: eric.auger, kvm, marc.zyngier, mtosatti, linux-kernel,
	Alex Williamson, patches, feng.wu, kvmarm, linux-arm-kernel,
	avi.kivity

On Thu, Jul 09, 2015 at 04:38:41PM +0200, Paolo Bonzini wrote:
> >> On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
> > If we think that it's *only* a kvm-vfio interaction then we could add it
> > to virt/kvm/vfio.c.  vfio could use symbol_get to avoid a module
> > dependency and effectively disable the code path when not used with kvm.
> > The reverse model of hosting it in vfio and using symbol_get from
> > kvm-vfio would also work.  Do we really want to declare it to be
> > kvm-vfio specific though?  Another option would be to simply host it
> > under virt/lib with module dependencies for both vfio and kvm.
> 
> I wonder if in the future we may have some kind of driver-mediated
> passthrough, e.g. for network drivers.  They might use the bypass
> mechanism too.  So I think drivers/vfio is too restrictive.
> 
> virt/ right now only hosts KVM, but it could for example host lguest
> too.  virt/lib/ is okay with me.

Yeah, virt/lib is probably the best choice.


	Joerg

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-09 15:34           ` Joerg Roedel
  0 siblings, 0 replies; 84+ messages in thread
From: Joerg Roedel @ 2015-07-09 15:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jul 09, 2015 at 04:38:41PM +0200, Paolo Bonzini wrote:
> >> On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
> > If we think that it's *only* a kvm-vfio interaction then we could add it
> > to virt/kvm/vfio.c.  vfio could use symbol_get to avoid a module
> > dependency and effectively disable the code path when not used with kvm.
> > The reverse model of hosting it in vfio and using symbol_get from
> > kvm-vfio would also work.  Do we really want to declare it to be
> > kvm-vfio specific though?  Another option would be to simply host it
> > under virt/lib with module dependencies for both vfio and kvm.
> 
> I wonder if in the future we may have some kind of driver-mediated
> passthrough, e.g. for network drivers.  They might use the bypass
> mechanism too.  So I think drivers/vfio is too restrictive.
> 
> virt/ right now only hosts KVM, but it could for example host lguest
> too.  virt/lib/ is okay with me.

Yeah, virt/lib is probably the best choice.


	Joerg

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
  2015-07-09 15:34           ` Joerg Roedel
  (?)
@ 2015-07-09 16:06             ` Alex Williamson
  -1 siblings, 0 replies; 84+ messages in thread
From: Alex Williamson @ 2015-07-09 16:06 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: Paolo Bonzini, Eric Auger, eric.auger, linux-arm-kernel, kvmarm,
	kvm, christoffer.dall, marc.zyngier, avi.kivity, mtosatti,
	feng.wu, b.reynal, linux-kernel, patches

On Thu, 2015-07-09 at 17:34 +0200, Joerg Roedel wrote:
> On Thu, Jul 09, 2015 at 04:38:41PM +0200, Paolo Bonzini wrote:
> > >> On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
> > > If we think that it's *only* a kvm-vfio interaction then we could add it
> > > to virt/kvm/vfio.c.  vfio could use symbol_get to avoid a module
> > > dependency and effectively disable the code path when not used with kvm.
> > > The reverse model of hosting it in vfio and using symbol_get from
> > > kvm-vfio would also work.  Do we really want to declare it to be
> > > kvm-vfio specific though?  Another option would be to simply host it
> > > under virt/lib with module dependencies for both vfio and kvm.
> > 
> > I wonder if in the future we may have some kind of driver-mediated
> > passthrough, e.g. for network drivers.  They might use the bypass
> > mechanism too.  So I think drivers/vfio is too restrictive.
> > 
> > virt/ right now only hosts KVM, but it could for example host lguest
> > too.  virt/lib/ is okay with me.
> 
> Yeah, virt/lib is probably the best choice.

I will make it so.  Thanks,

Alex


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-09 16:06             ` Alex Williamson
  0 siblings, 0 replies; 84+ messages in thread
From: Alex Williamson @ 2015-07-09 16:06 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: eric.auger, kvm, marc.zyngier, mtosatti, linux-kernel, patches,
	Paolo Bonzini, feng.wu, kvmarm, linux-arm-kernel, avi.kivity

On Thu, 2015-07-09 at 17:34 +0200, Joerg Roedel wrote:
> On Thu, Jul 09, 2015 at 04:38:41PM +0200, Paolo Bonzini wrote:
> > >> On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
> > > If we think that it's *only* a kvm-vfio interaction then we could add it
> > > to virt/kvm/vfio.c.  vfio could use symbol_get to avoid a module
> > > dependency and effectively disable the code path when not used with kvm.
> > > The reverse model of hosting it in vfio and using symbol_get from
> > > kvm-vfio would also work.  Do we really want to declare it to be
> > > kvm-vfio specific though?  Another option would be to simply host it
> > > under virt/lib with module dependencies for both vfio and kvm.
> > 
> > I wonder if in the future we may have some kind of driver-mediated
> > passthrough, e.g. for network drivers.  They might use the bypass
> > mechanism too.  So I think drivers/vfio is too restrictive.
> > 
> > virt/ right now only hosts KVM, but it could for example host lguest
> > too.  virt/lib/ is okay with me.
> 
> Yeah, virt/lib is probably the best choice.

I will make it so.  Thanks,

Alex

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-09 16:06             ` Alex Williamson
  0 siblings, 0 replies; 84+ messages in thread
From: Alex Williamson @ 2015-07-09 16:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 2015-07-09 at 17:34 +0200, Joerg Roedel wrote:
> On Thu, Jul 09, 2015 at 04:38:41PM +0200, Paolo Bonzini wrote:
> > >> On Tue, Jul 07, 2015 at 11:17:48AM -0600, Alex Williamson wrote:
> > > If we think that it's *only* a kvm-vfio interaction then we could add it
> > > to virt/kvm/vfio.c.  vfio could use symbol_get to avoid a module
> > > dependency and effectively disable the code path when not used with kvm.
> > > The reverse model of hosting it in vfio and using symbol_get from
> > > kvm-vfio would also work.  Do we really want to declare it to be
> > > kvm-vfio specific though?  Another option would be to simply host it
> > > under virt/lib with module dependencies for both vfio and kvm.
> > 
> > I wonder if in the future we may have some kind of driver-mediated
> > passthrough, e.g. for network drivers.  They might use the bypass
> > mechanism too.  So I think drivers/vfio is too restrictive.
> > 
> > virt/ right now only hosts KVM, but it could for example host lguest
> > too.  virt/lib/ is okay with me.
> 
> Yeah, virt/lib is probably the best choice.

I will make it so.  Thanks,

Alex

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
  2015-07-06 12:11 ` Eric Auger
  (?)
@ 2015-07-24  1:27   ` Wu, Feng
  -1 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-24  1:27 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org
> [mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Eric Auger
> Sent: Monday, July 06, 2015 8:11 PM
> To: eric.auger@st.com; eric.auger@linaro.org;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
> b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
> 
> This series introduces and extends the IRQ bypass manager written
> by Alex and transforms irqfd into an IRQ bypass manager consumer.
> The producer part, in my case the VFIO platform driver will be introduced
> separately. That code should be usable by both ARM IRQ forwarding
> and Intel Posted Interrupts.
> 
> The IRQ bypass manager enables to setup a negotiated link between an
> IRQ producer and an IRQ consumer (typically the VFIO driver and KVM irqfd).
> 
> The series currently includes Alex's code which was sent my email.
> Its structure obvioulsy will adapt to Alex's will.
> 
> Also the irq bypass manager gets compiled/linked on arm/arm64 along
> with KVM and VFIO platform driver.
> 
> can be found at:
> https://git.linaro.org/people/eric.auger/linux.git/shortlog/refs/heads/v4.2-rc1-
> bypass-fwd-v2
> 
> Best Regards
> 
> Eric
> 
> History:
> v1 -> v2:
> - isolate the bypass manager and irqfd consumer in this series
> - take into account Paolo's comments and use container_of strategy and
>   remove additional fields introduced in v1.
> - create kvm_irqfd.h
> - add unregistration in irqfd_shutdown

Hi Eric,

[4/6], [5/6], and [6/6] of this series are common to forwarded irq and posted
interrupts, did you have a chance to get a new version of them based on
Alex's latest irqbypass manager patch:

https://lkml.org/lkml/2015/7/16/810

Thanks a lot!

Thanks,
Feng

> 
> v1: originally part of [RFC 00/17] ARM IRQ forward control based on IRQ
>     bypass manager (https://lkml.org/lkml/2015/7/2/268)
> 
> 
> Eric Auger (6):
>   KVM: arm/arm64: select IRQ_BYPASS_MANAGER
>   VFIO: platform: select IRQ_BYPASS_MANAGER
>   irq: bypass: Extend skeleton for ARM forwarding control
>   KVM: create kvm_irqfd.h
>   KVM: introduce kvm_arch functions for IRQ bypass
>   KVM: eventfd: add irq bypass consumer management
> 
>  arch/arm/kvm/Kconfig          |   1 +
>  arch/arm64/kvm/Kconfig        |   1 +
>  drivers/vfio/platform/Kconfig |   1 +
>  include/linux/irqbypass.h     |  19 ++++++--
>  include/linux/kvm_host.h      |  37 ++++++++++++++
>  include/linux/kvm_irqfd.h     |  70 +++++++++++++++++++++++++++
>  kernel/irq/bypass.c           |  44 +++++++++++++++--
>  virt/kvm/Kconfig              |   3 ++
>  virt/kvm/eventfd.c            | 109 +++++++++++++-----------------------------
>  9 files changed, 203 insertions(+), 82 deletions(-)
>  create mode 100644 include/linux/kvm_irqfd.h
> 
> --
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 84+ messages in thread

* RE: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-24  1:27   ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-24  1:27 UTC (permalink / raw)
  To: Eric Auger, eric.auger, linux-arm-kernel, kvmarm, kvm,
	christoffer.dall, marc.zyngier, alex.williamson, pbonzini,
	avi.kivity, mtosatti, joro, b.reynal
  Cc: linux-kernel, patches, Wu, Feng



> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org
> [mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Eric Auger
> Sent: Monday, July 06, 2015 8:11 PM
> To: eric.auger@st.com; eric.auger@linaro.org;
> linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu;
> kvm@vger.kernel.org; christoffer.dall@linaro.org; marc.zyngier@arm.com;
> alex.williamson@redhat.com; pbonzini@redhat.com; avi.kivity@gmail.com;
> mtosatti@redhat.com; Wu, Feng; joro@8bytes.org;
> b.reynal@virtualopensystems.com
> Cc: linux-kernel@vger.kernel.org; patches@linaro.org
> Subject: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
> 
> This series introduces and extends the IRQ bypass manager written
> by Alex and transforms irqfd into an IRQ bypass manager consumer.
> The producer part, in my case the VFIO platform driver will be introduced
> separately. That code should be usable by both ARM IRQ forwarding
> and Intel Posted Interrupts.
> 
> The IRQ bypass manager enables to setup a negotiated link between an
> IRQ producer and an IRQ consumer (typically the VFIO driver and KVM irqfd).
> 
> The series currently includes Alex's code which was sent my email.
> Its structure obvioulsy will adapt to Alex's will.
> 
> Also the irq bypass manager gets compiled/linked on arm/arm64 along
> with KVM and VFIO platform driver.
> 
> can be found at:
> https://git.linaro.org/people/eric.auger/linux.git/shortlog/refs/heads/v4.2-rc1-
> bypass-fwd-v2
> 
> Best Regards
> 
> Eric
> 
> History:
> v1 -> v2:
> - isolate the bypass manager and irqfd consumer in this series
> - take into account Paolo's comments and use container_of strategy and
>   remove additional fields introduced in v1.
> - create kvm_irqfd.h
> - add unregistration in irqfd_shutdown

Hi Eric,

[4/6], [5/6], and [6/6] of this series are common to forwarded irq and posted
interrupts, did you have a chance to get a new version of them based on
Alex's latest irqbypass manager patch:

https://lkml.org/lkml/2015/7/16/810

Thanks a lot!

Thanks,
Feng

> 
> v1: originally part of [RFC 00/17] ARM IRQ forward control based on IRQ
>     bypass manager (https://lkml.org/lkml/2015/7/2/268)
> 
> 
> Eric Auger (6):
>   KVM: arm/arm64: select IRQ_BYPASS_MANAGER
>   VFIO: platform: select IRQ_BYPASS_MANAGER
>   irq: bypass: Extend skeleton for ARM forwarding control
>   KVM: create kvm_irqfd.h
>   KVM: introduce kvm_arch functions for IRQ bypass
>   KVM: eventfd: add irq bypass consumer management
> 
>  arch/arm/kvm/Kconfig          |   1 +
>  arch/arm64/kvm/Kconfig        |   1 +
>  drivers/vfio/platform/Kconfig |   1 +
>  include/linux/irqbypass.h     |  19 ++++++--
>  include/linux/kvm_host.h      |  37 ++++++++++++++
>  include/linux/kvm_irqfd.h     |  70 +++++++++++++++++++++++++++
>  kernel/irq/bypass.c           |  44 +++++++++++++++--
>  virt/kvm/Kconfig              |   3 ++
>  virt/kvm/eventfd.c            | 109 +++++++++++++-----------------------------
>  9 files changed, 203 insertions(+), 82 deletions(-)
>  create mode 100644 include/linux/kvm_irqfd.h
> 
> --
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [RFC v2 0/6] IRQ bypass manager and irqfd consumer
@ 2015-07-24  1:27   ` Wu, Feng
  0 siblings, 0 replies; 84+ messages in thread
From: Wu, Feng @ 2015-07-24  1:27 UTC (permalink / raw)
  To: linux-arm-kernel



> -----Original Message-----
> From: linux-kernel-owner at vger.kernel.org
> [mailto:linux-kernel-owner at vger.kernel.org] On Behalf Of Eric Auger
> Sent: Monday, July 06, 2015 8:11 PM
> To: eric.auger at st.com; eric.auger at linaro.org;
> linux-arm-kernel at lists.infradead.org; kvmarm at lists.cs.columbia.edu;
> kvm at vger.kernel.org; christoffer.dall at linaro.org; marc.zyngier at arm.com;
> alex.williamson at redhat.com; pbonzini at redhat.com; avi.kivity at gmail.com;
> mtosatti at redhat.com; Wu, Feng; joro at 8bytes.org;
> b.reynal at virtualopensystems.com
> Cc: linux-kernel at vger.kernel.org; patches at linaro.org
> Subject: [RFC v2 0/6] IRQ bypass manager and irqfd consumer
> 
> This series introduces and extends the IRQ bypass manager written
> by Alex and transforms irqfd into an IRQ bypass manager consumer.
> The producer part, in my case the VFIO platform driver will be introduced
> separately. That code should be usable by both ARM IRQ forwarding
> and Intel Posted Interrupts.
> 
> The IRQ bypass manager enables to setup a negotiated link between an
> IRQ producer and an IRQ consumer (typically the VFIO driver and KVM irqfd).
> 
> The series currently includes Alex's code which was sent my email.
> Its structure obvioulsy will adapt to Alex's will.
> 
> Also the irq bypass manager gets compiled/linked on arm/arm64 along
> with KVM and VFIO platform driver.
> 
> can be found at:
> https://git.linaro.org/people/eric.auger/linux.git/shortlog/refs/heads/v4.2-rc1-
> bypass-fwd-v2
> 
> Best Regards
> 
> Eric
> 
> History:
> v1 -> v2:
> - isolate the bypass manager and irqfd consumer in this series
> - take into account Paolo's comments and use container_of strategy and
>   remove additional fields introduced in v1.
> - create kvm_irqfd.h
> - add unregistration in irqfd_shutdown

Hi Eric,

[4/6], [5/6], and [6/6] of this series are common to forwarded irq and posted
interrupts, did you have a chance to get a new version of them based on
Alex's latest irqbypass manager patch:

https://lkml.org/lkml/2015/7/16/810

Thanks a lot!

Thanks,
Feng

> 
> v1: originally part of [RFC 00/17] ARM IRQ forward control based on IRQ
>     bypass manager (https://lkml.org/lkml/2015/7/2/268)
> 
> 
> Eric Auger (6):
>   KVM: arm/arm64: select IRQ_BYPASS_MANAGER
>   VFIO: platform: select IRQ_BYPASS_MANAGER
>   irq: bypass: Extend skeleton for ARM forwarding control
>   KVM: create kvm_irqfd.h
>   KVM: introduce kvm_arch functions for IRQ bypass
>   KVM: eventfd: add irq bypass consumer management
> 
>  arch/arm/kvm/Kconfig          |   1 +
>  arch/arm64/kvm/Kconfig        |   1 +
>  drivers/vfio/platform/Kconfig |   1 +
>  include/linux/irqbypass.h     |  19 ++++++--
>  include/linux/kvm_host.h      |  37 ++++++++++++++
>  include/linux/kvm_irqfd.h     |  70 +++++++++++++++++++++++++++
>  kernel/irq/bypass.c           |  44 +++++++++++++++--
>  virt/kvm/Kconfig              |   3 ++
>  virt/kvm/eventfd.c            | 109 +++++++++++++-----------------------------
>  9 files changed, 203 insertions(+), 82 deletions(-)
>  create mode 100644 include/linux/kvm_irqfd.h
> 
> --
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 84+ messages in thread

end of thread, other threads:[~2015-07-24  1:27 UTC | newest]

Thread overview: 84+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-06 12:11 [RFC v2 0/6] IRQ bypass manager and irqfd consumer Eric Auger
2015-07-06 12:11 ` Eric Auger
2015-07-06 12:11 ` [RFC v2 1/6] KVM: arm/arm64: select IRQ_BYPASS_MANAGER Eric Auger
2015-07-06 12:11   ` Eric Auger
2015-07-06 12:24   ` Paolo Bonzini
2015-07-06 12:24     ` Paolo Bonzini
2015-07-06 12:11 ` [RFC v2 2/6] VFIO: platform: " Eric Auger
2015-07-06 12:11   ` Eric Auger
2015-07-06 12:11 ` [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control Eric Auger
2015-07-06 12:11   ` Eric Auger
2015-07-06 12:27   ` Paolo Bonzini
2015-07-06 12:27     ` Paolo Bonzini
2015-07-06 15:35     ` Eric Auger
2015-07-06 15:35       ` Eric Auger
2015-07-06 15:57       ` Paolo Bonzini
2015-07-06 15:57         ` Paolo Bonzini
2015-07-06 17:09         ` Eric Auger
2015-07-06 17:09           ` Eric Auger
2015-07-06 17:41           ` Paolo Bonzini
2015-07-06 17:41             ` Paolo Bonzini
2015-07-07  7:10             ` Eric Auger
2015-07-07  7:10               ` Eric Auger
2015-07-07  8:58               ` Paolo Bonzini
2015-07-07  8:58                 ` Paolo Bonzini
2015-07-07 10:58   ` Wu, Feng
2015-07-07 10:58     ` Wu, Feng
2015-07-07 10:58     ` Wu, Feng
2015-07-07 11:00     ` Paolo Bonzini
2015-07-07 11:00       ` Paolo Bonzini
2015-07-07 11:00       ` Paolo Bonzini
2015-07-07 11:13       ` Wu, Feng
2015-07-07 11:13         ` Wu, Feng
2015-07-07 11:13         ` Wu, Feng
2015-07-07 11:13         ` Paolo Bonzini
2015-07-07 11:13           ` Paolo Bonzini
2015-07-07 11:13           ` Paolo Bonzini
2015-07-07 11:18           ` Wu, Feng
2015-07-07 11:18             ` Wu, Feng
2015-07-07 11:18             ` Wu, Feng
2015-07-07 11:21             ` Paolo Bonzini
2015-07-07 11:21               ` Paolo Bonzini
2015-07-07 11:21               ` Paolo Bonzini
2015-07-07 11:24               ` Wu, Feng
2015-07-07 11:24                 ` Wu, Feng
2015-07-07 11:24                 ` Wu, Feng
2015-07-07 11:33                 ` Wu, Feng
2015-07-07 11:33                   ` Wu, Feng
2015-07-07 11:33                   ` Wu, Feng
2015-07-07 13:22                   ` Paolo Bonzini
2015-07-07 13:22                     ` Paolo Bonzini
2015-07-07 13:22                     ` Paolo Bonzini
2015-07-06 12:11 ` [RFC v2 4/6] KVM: create kvm_irqfd.h Eric Auger
2015-07-06 12:11   ` Eric Auger
2015-07-06 12:11 ` [RFC v2 5/6] KVM: introduce kvm_arch functions for IRQ bypass Eric Auger
2015-07-06 12:11   ` Eric Auger
2015-07-06 12:11 ` [RFC v2 6/6] KVM: eventfd: add irq bypass consumer management Eric Auger
2015-07-06 12:11   ` Eric Auger
2015-07-07  8:47   ` Wu, Feng
2015-07-07  8:47     ` Wu, Feng
2015-07-07  8:47     ` Wu, Feng
2015-07-07  9:05     ` Eric Auger
2015-07-07  9:05       ` Eric Auger
2015-07-07  9:05       ` Eric Auger
2015-07-07  9:13       ` Wu, Feng
2015-07-07  9:13         ` Wu, Feng
2015-07-07  9:13         ` Wu, Feng
2015-07-07 17:17 ` [RFC v2 0/6] IRQ bypass manager and irqfd consumer Alex Williamson
2015-07-07 17:17   ` Alex Williamson
2015-07-07 17:17   ` Alex Williamson
2015-07-09 12:28   ` Joerg Roedel
2015-07-09 12:28     ` Joerg Roedel
2015-07-09 14:13     ` Alex Williamson
2015-07-09 14:13       ` Alex Williamson
2015-07-09 14:38       ` Paolo Bonzini
2015-07-09 14:38         ` Paolo Bonzini
2015-07-09 15:34         ` Joerg Roedel
2015-07-09 15:34           ` Joerg Roedel
2015-07-09 15:34           ` Joerg Roedel
2015-07-09 16:06           ` Alex Williamson
2015-07-09 16:06             ` Alex Williamson
2015-07-09 16:06             ` Alex Williamson
2015-07-24  1:27 ` Wu, Feng
2015-07-24  1:27   ` Wu, Feng
2015-07-24  1:27   ` Wu, Feng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.