All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] simulated interrupts
@ 2017-07-19 12:20 Bartosz Golaszewski
  2017-07-19 12:20 ` [PATCH 1/3] irq/irq_sim: add a simple interrupt simulator framework Bartosz Golaszewski
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2017-07-19 12:20 UTC (permalink / raw)
  To: Linus Walleij, Thomas Gleixner, Marc Zyngier, Jonathan Corbet,
	Bamvor Jian Zhang, Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-kernel, linux-gpio, linux-doc, Bartosz Golaszewski

Some frameworks (e.g. iio, gpiolib) use irq_work to implement simulated
interrupts that can be 'fired' from process context when needed and
requested just like normal interrupts. This is useful for testing and
development purposes.

Currently this code is reimplemented by every user. This series
proposes to add a new set of functions that can be used by drivers
that want to simulate interrupts without having to duplicate any
boilerplate code.

The first patch adds a simple irq simulator framework. The second
extends it with resource management. The third uses the new
functionality in the gpio-mockup testing driver.

NOTE: The next candidate for using this API would be iio-dummy-evgen.

Bartosz Golaszewski (3):
  irq/irq_sim: add a simple interrupt simulator framework
  irq/irq_sim: add a devres variant of irq_sim_init()
  gpio: mockup: use irq_sim

 Documentation/driver-model/devres.txt |   1 +
 drivers/gpio/Kconfig                  |   2 +-
 drivers/gpio/gpio-mockup.c            |  77 ++--------------
 include/linux/irq_sim.h               |  41 +++++++++
 init/Kconfig                          |   4 +
 kernel/Makefile                       |   1 +
 kernel/irq_sim.c                      | 161 ++++++++++++++++++++++++++++++++++
 7 files changed, 216 insertions(+), 71 deletions(-)
 create mode 100644 include/linux/irq_sim.h
 create mode 100644 kernel/irq_sim.c

-- 
2.13.2

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

* [PATCH 1/3] irq/irq_sim: add a simple interrupt simulator framework
  2017-07-19 12:20 [PATCH 0/3] simulated interrupts Bartosz Golaszewski
@ 2017-07-19 12:20 ` Bartosz Golaszewski
  2017-07-22 20:59   ` Jonathan Cameron
  2017-07-24  7:31   ` Lars-Peter Clausen
  2017-07-19 12:20 ` [PATCH 2/3] irq/irq_sim: add a devres variant of irq_sim_init() Bartosz Golaszewski
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2017-07-19 12:20 UTC (permalink / raw)
  To: Linus Walleij, Thomas Gleixner, Marc Zyngier, Jonathan Corbet,
	Bamvor Jian Zhang, Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-kernel, linux-gpio, linux-doc, Bartosz Golaszewski

Implement a simple, irq_work-based framework for simulating
interrupts. Currently the API exposes routines for initializing and
deinitializing the simulator object, enqueueing the interrupts and
retrieving the allocated interrupt numbers based on the offset of the
dummy interrupt in the simulator struct.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 include/linux/irq_sim.h |  37 +++++++++++++++
 init/Kconfig            |   4 ++
 kernel/Makefile         |   1 +
 kernel/irq_sim.c        | 118 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 160 insertions(+)
 create mode 100644 include/linux/irq_sim.h
 create mode 100644 kernel/irq_sim.c

diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h
new file mode 100644
index 000000000000..0c1abf0e3244
--- /dev/null
+++ b/include/linux/irq_sim.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2017 Bartosz Golaszewski <brgl@bgdev.pl>
+ *
+ * Provides a framework for allocating simulated interrupts which can be
+ * requested like normal irqs and enqueued from process context.
+ */
+
+#ifndef _LINUX_IRQ_SIM_H
+#define _LINUX_IRQ_SIM_H
+
+#include <linux/irq_work.h>
+
+struct irq_sim_work_ctx {
+	struct irq_work work;
+	int irq;
+};
+
+struct irq_sim_irq_ctx {
+	int irqnum;
+	bool enabled;
+};
+
+struct irq_sim {
+	struct irq_sim_work_ctx work_ctx;
+	int irq_base;
+	unsigned int irq_count;
+	struct irq_sim_irq_ctx *irqs;
+};
+
+int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs);
+void irq_sim_fini(struct irq_sim *sim);
+
+void irq_sim_fire(struct irq_sim *sim, unsigned int offset);
+
+int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset);
+
+#endif /* _LINUX_IRQ_SIM_H */
diff --git a/init/Kconfig b/init/Kconfig
index 8514b25db21c..220456599c3f 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -23,6 +23,10 @@ config CONSTRUCTORS
 config IRQ_WORK
 	bool
 
+config IRQ_SIM
+	bool
+	select IRQ_WORK
+
 config BUILDTIME_EXTABLE_SORT
 	bool
 
diff --git a/kernel/Makefile b/kernel/Makefile
index 4cb8e8b23c6e..4472567c5835 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -97,6 +97,7 @@ obj-$(CONFIG_TRACE_CLOCK) += trace/
 obj-$(CONFIG_RING_BUFFER) += trace/
 obj-$(CONFIG_TRACEPOINTS) += trace/
 obj-$(CONFIG_IRQ_WORK) += irq_work.o
+obj-$(CONFIG_IRQ_SIM) += irq_sim.o
 obj-$(CONFIG_CPU_PM) += cpu_pm.o
 obj-$(CONFIG_BPF) += bpf/
 
diff --git a/kernel/irq_sim.c b/kernel/irq_sim.c
new file mode 100644
index 000000000000..062110c90d2a
--- /dev/null
+++ b/kernel/irq_sim.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2017 Bartosz Golaszewski <brgl@bgdev.pl>
+ *
+ * Provides a framework for allocating simulated interrupts which can be
+ * requested like normal irqs and enqueued from process context.
+ */
+
+#include <linux/irq_sim.h>
+#include <linux/irq.h>
+
+static void irq_sim_irqmask(struct irq_data *data)
+{
+	struct irq_sim_irq_ctx *irq_ctx = irq_data_get_irq_chip_data(data);
+
+	irq_ctx->enabled = false;
+}
+
+static void irq_sim_irqunmask(struct irq_data *data)
+{
+	struct irq_sim_irq_ctx *irq_ctx = irq_data_get_irq_chip_data(data);
+
+	irq_ctx->enabled = true;
+}
+
+static struct irq_chip irq_sim_irqchip = {
+	.name		= "irq_sim",
+	.irq_mask	= irq_sim_irqmask,
+	.irq_unmask	= irq_sim_irqunmask,
+};
+
+static void irq_sim_handle_irq(struct irq_work *work)
+{
+	struct irq_sim_work_ctx *work_ctx;
+
+	work_ctx = container_of(work, struct irq_sim_work_ctx, work);
+	handle_simple_irq(irq_to_desc(work_ctx->irq));
+}
+
+/**
+ * irq_sim_init - Initialize the interrupt simulator: allocate a range of
+ *                dummy interrupts.
+ *
+ * @sim:        The interrupt simulator object to initialize.
+ * @num_irqs:   Number of interrupts to allocate
+ *
+ * Returns 0 on success and a negative error number on failure.
+ */
+int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs)
+{
+	int i;
+
+	sim->irqs = kmalloc_array(num_irqs, sizeof(*sim->irqs), GFP_KERNEL);
+	if (!sim->irqs)
+		return -ENOMEM;
+
+	sim->irq_base = irq_alloc_descs(-1, 0, num_irqs, 0);
+	if (sim->irq_base < 0) {
+		kfree(sim->irqs);
+		return sim->irq_base;
+	}
+
+	for (i = 0; i < num_irqs; i++) {
+		sim->irqs[i].irqnum = sim->irq_base + i;
+		sim->irqs[i].enabled = false;
+		irq_set_chip(sim->irq_base + i, &irq_sim_irqchip);
+		irq_set_chip_data(sim->irq_base + i, &sim->irqs[i]);
+		irq_set_handler(sim->irq_base + i, &handle_simple_irq);
+		irq_modify_status(sim->irq_base + i,
+				  IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE);
+	}
+
+	init_irq_work(&sim->work_ctx.work, irq_sim_handle_irq);
+	sim->irq_count = num_irqs;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(irq_sim_init);
+
+/**
+ * irq_sim_fini - Deinitialize the interrupt simulator: free the interrupt
+ *                descriptors and allocated memory.
+ *
+ * @sim:        The interrupt simulator to tear down.
+ */
+void irq_sim_fini(struct irq_sim *sim)
+{
+	irq_free_descs(sim->irq_base, sim->irq_count);
+	kfree(sim->irqs);
+}
+EXPORT_SYMBOL_GPL(irq_sim_fini);
+
+/**
+ * irq_sim_fire - Enqueue an interrupt.
+ *
+ * @sim:        The interrupt simulator object.
+ * @offset:     Offset of the simulated interrupt which should be fired.
+ */
+void irq_sim_fire(struct irq_sim *sim, unsigned int offset)
+{
+	if (sim->irqs[offset].enabled) {
+		sim->work_ctx.irq = irq_sim_irqnum(sim, offset);
+		irq_work_queue(&sim->work_ctx.work);
+	}
+}
+EXPORT_SYMBOL_GPL(irq_sim_fire);
+
+/**
+ * irq_sim_irqnum - Get the allocated number of a dummy interrupt.
+ *
+ * @sim:        The interrupt simulator object.
+ * @offset:     Offset of the simulated interrupt for which to retrieve
+ *              the number.
+ */
+int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset)
+{
+	return sim->irqs[offset].irqnum;
+}
+EXPORT_SYMBOL_GPL(irq_sim_irqnum);
-- 
2.13.2

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

* [PATCH 2/3] irq/irq_sim: add a devres variant of irq_sim_init()
  2017-07-19 12:20 [PATCH 0/3] simulated interrupts Bartosz Golaszewski
  2017-07-19 12:20 ` [PATCH 1/3] irq/irq_sim: add a simple interrupt simulator framework Bartosz Golaszewski
@ 2017-07-19 12:20 ` Bartosz Golaszewski
  2017-07-19 12:20 ` [PATCH 3/3] gpio: mockup: use irq_sim Bartosz Golaszewski
  2017-07-19 12:25 ` [PATCH 0/3] simulated interrupts Thomas Gleixner
  3 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2017-07-19 12:20 UTC (permalink / raw)
  To: Linus Walleij, Thomas Gleixner, Marc Zyngier, Jonathan Corbet,
	Bamvor Jian Zhang, Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-kernel, linux-gpio, linux-doc, Bartosz Golaszewski

Add a resource managed version of irq_sim_init(). This can be
conveniently used in device drivers.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 Documentation/driver-model/devres.txt |  1 +
 include/linux/irq_sim.h               |  4 ++++
 kernel/irq_sim.c                      | 43 +++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 30e04f7a690d..69f08c0f23a8 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -312,6 +312,7 @@ IRQ
   devm_irq_alloc_descs_from()
   devm_irq_alloc_generic_chip()
   devm_irq_setup_generic_chip()
+  devm_irq_sim_init()
 
 LED
   devm_led_classdev_register()
diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h
index 0c1abf0e3244..94c4bfc9b7a9 100644
--- a/include/linux/irq_sim.h
+++ b/include/linux/irq_sim.h
@@ -9,6 +9,7 @@
 #define _LINUX_IRQ_SIM_H
 
 #include <linux/irq_work.h>
+#include <linux/device.h>
 
 struct irq_sim_work_ctx {
 	struct irq_work work;
@@ -30,6 +31,9 @@ struct irq_sim {
 int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs);
 void irq_sim_fini(struct irq_sim *sim);
 
+int devm_irq_sim_init(struct device *dev,
+		      struct irq_sim *sim, unsigned int num_irqs);
+
 void irq_sim_fire(struct irq_sim *sim, unsigned int offset);
 
 int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset);
diff --git a/kernel/irq_sim.c b/kernel/irq_sim.c
index 062110c90d2a..deb5a58eede5 100644
--- a/kernel/irq_sim.c
+++ b/kernel/irq_sim.c
@@ -89,6 +89,49 @@ void irq_sim_fini(struct irq_sim *sim)
 }
 EXPORT_SYMBOL_GPL(irq_sim_fini);
 
+struct irq_sim_devres {
+	struct irq_sim *sim;
+};
+
+static void devm_irq_sim_release(struct device *dev, void *res)
+{
+	struct irq_sim_devres *this = res;
+
+	irq_sim_fini(this->sim);
+}
+
+/**
+ * irq_sim_init - Initialize the interrupt simulator for a managed device.
+ *
+ * @dev:        Device to initialize the simulator object for.
+ * @sim:        The interrupt simulator object to initialize.
+ * @num_irqs:   Number of interrupts to allocate
+ *
+ * Returns 0 on success and a negative error number on failure.
+ */
+int devm_irq_sim_init(struct device *dev,
+		      struct irq_sim *sim, unsigned int num_irqs)
+{
+	struct irq_sim_devres *dr;
+	int rv;
+
+	dr = devres_alloc(devm_irq_sim_release, sizeof(*dr), GFP_KERNEL);
+	if (!dr)
+		return -ENOMEM;
+
+	rv = irq_sim_init(sim, num_irqs);
+	if (rv) {
+		devres_free(dr);
+		return rv;
+	}
+
+	dr->sim = sim;
+	devres_add(dev, dr);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(devm_irq_sim_init);
+
 /**
  * irq_sim_fire - Enqueue an interrupt.
  *
-- 
2.13.2

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

* [PATCH 3/3] gpio: mockup: use irq_sim
  2017-07-19 12:20 [PATCH 0/3] simulated interrupts Bartosz Golaszewski
  2017-07-19 12:20 ` [PATCH 1/3] irq/irq_sim: add a simple interrupt simulator framework Bartosz Golaszewski
  2017-07-19 12:20 ` [PATCH 2/3] irq/irq_sim: add a devres variant of irq_sim_init() Bartosz Golaszewski
@ 2017-07-19 12:20 ` Bartosz Golaszewski
  2017-08-02 11:34   ` Linus Walleij
  2017-07-19 12:25 ` [PATCH 0/3] simulated interrupts Thomas Gleixner
  3 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2017-07-19 12:20 UTC (permalink / raw)
  To: Linus Walleij, Thomas Gleixner, Marc Zyngier, Jonathan Corbet,
	Bamvor Jian Zhang, Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-kernel, linux-gpio, linux-doc, Bartosz Golaszewski

Shrink the driver by removing the code dealing with dummy interrupts
and replacing it with calls to the irq_sim API.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 drivers/gpio/Kconfig       |  2 +-
 drivers/gpio/gpio-mockup.c | 77 +++++-----------------------------------------
 2 files changed, 8 insertions(+), 71 deletions(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index f235eae04c16..e2264fb31f87 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -311,7 +311,7 @@ config GPIO_MOCKUP
 	depends on GPIOLIB && SYSFS
 	select GPIO_SYSFS
 	select GPIOLIB_IRQCHIP
-	select IRQ_WORK
+	select IRQ_SIM
 	help
 	  This enables GPIO Testing driver, which provides a way to test GPIO
 	  subsystem through sysfs(or char device) and debugfs. GPIO_SYSFS
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index a6565e128f9e..6db7163e6d98 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -20,7 +20,7 @@
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/irq_work.h>
+#include <linux/irq_sim.h>
 #include <linux/debugfs.h>
 #include <linux/uaccess.h>
 
@@ -47,18 +47,12 @@ enum {
 struct gpio_mockup_line_status {
 	int dir;
 	bool value;
-	bool irq_enabled;
-};
-
-struct gpio_mockup_irq_context {
-	struct irq_work work;
-	int irq;
 };
 
 struct gpio_mockup_chip {
 	struct gpio_chip gc;
 	struct gpio_mockup_line_status *lines;
-	struct gpio_mockup_irq_context irq_ctx;
+	struct irq_sim irqsim;
 	struct dentry *dbg_dir;
 };
 
@@ -144,65 +138,11 @@ static int gpio_mockup_name_lines(struct device *dev,
 	return 0;
 }
 
-static int gpio_mockup_to_irq(struct gpio_chip *chip, unsigned int offset)
-{
-	return chip->irq_base + offset;
-}
-
-static void gpio_mockup_irqmask(struct irq_data *data)
+static int gpio_mockup_to_irq(struct gpio_chip *gc, unsigned int offset)
 {
-	struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
-	chip->lines[data->irq - gc->irq_base].irq_enabled = false;
-}
-
-static void gpio_mockup_irqunmask(struct irq_data *data)
-{
-	struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
-	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
-
-	chip->lines[data->irq - gc->irq_base].irq_enabled = true;
-}
-
-static struct irq_chip gpio_mockup_irqchip = {
-	.name		= GPIO_MOCKUP_NAME,
-	.irq_mask	= gpio_mockup_irqmask,
-	.irq_unmask	= gpio_mockup_irqunmask,
-};
-
-static void gpio_mockup_handle_irq(struct irq_work *work)
-{
-	struct gpio_mockup_irq_context *irq_ctx;
-
-	irq_ctx = container_of(work, struct gpio_mockup_irq_context, work);
-	handle_simple_irq(irq_to_desc(irq_ctx->irq));
-}
-
-static int gpio_mockup_irqchip_setup(struct device *dev,
-				     struct gpio_mockup_chip *chip)
-{
-	struct gpio_chip *gc = &chip->gc;
-	int irq_base, i;
-
-	irq_base = devm_irq_alloc_descs(dev, -1, 0, gc->ngpio, 0);
-	if (irq_base < 0)
-		return irq_base;
-
-	gc->irq_base = irq_base;
-	gc->irqchip = &gpio_mockup_irqchip;
-
-	for (i = 0; i < gc->ngpio; i++) {
-		irq_set_chip(irq_base + i, gc->irqchip);
-		irq_set_chip_data(irq_base + i, gc);
-		irq_set_handler(irq_base + i, &handle_simple_irq);
-		irq_modify_status(irq_base + i,
-				  IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE);
-	}
-
-	init_irq_work(&chip->irq_ctx.work, gpio_mockup_handle_irq);
-
-	return 0;
+	return irq_sim_irqnum(&chip->irqsim, offset);
 }
 
 static ssize_t gpio_mockup_event_write(struct file *file,
@@ -228,11 +168,8 @@ static ssize_t gpio_mockup_event_write(struct file *file,
 	chip = priv->chip;
 	gc = &chip->gc;
 
-	if (chip->lines[priv->offset].irq_enabled) {
-		gpiod_set_value_cansleep(desc, val);
-		priv->chip->irq_ctx.irq = gc->irq_base + priv->offset;
-		irq_work_queue(&priv->chip->irq_ctx.work);
-	}
+	gpiod_set_value_cansleep(desc, val);
+	irq_sim_fire(&chip->irqsim, priv->offset);
 
 	return size;
 }
@@ -319,7 +256,7 @@ static int gpio_mockup_add(struct device *dev,
 			return ret;
 	}
 
-	ret = gpio_mockup_irqchip_setup(dev, chip);
+	ret = devm_irq_sim_init(dev, &chip->irqsim, gc->ngpio);
 	if (ret)
 		return ret;
 
-- 
2.13.2


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

* Re: [PATCH 0/3] simulated interrupts
  2017-07-19 12:20 [PATCH 0/3] simulated interrupts Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2017-07-19 12:20 ` [PATCH 3/3] gpio: mockup: use irq_sim Bartosz Golaszewski
@ 2017-07-19 12:25 ` Thomas Gleixner
  2017-07-19 12:44   ` Bartosz Golaszewski
  3 siblings, 1 reply; 16+ messages in thread
From: Thomas Gleixner @ 2017-07-19 12:25 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Marc Zyngier, Jonathan Corbet, Bamvor Jian Zhang,
	Jonathan Cameron, Lars-Peter Clausen, linux-kernel, linux-gpio,
	linux-doc

On Wed, 19 Jul 2017, Bartosz Golaszewski wrote:

> Some frameworks (e.g. iio, gpiolib) use irq_work to implement simulated
> interrupts that can be 'fired' from process context when needed and
> requested just like normal interrupts. This is useful for testing and
> development purposes.
> 
> Currently this code is reimplemented by every user. This series
> proposes to add a new set of functions that can be used by drivers
> that want to simulate interrupts without having to duplicate any
> boilerplate code.
> 
> The first patch adds a simple irq simulator framework. The second
> extends it with resource management. The third uses the new
> functionality in the gpio-mockup testing driver.
> 
> NOTE: The next candidate for using this API would be iio-dummy-evgen.

I like the general idea - have not looked at the code yet. Just a quick
question: How many copies/variants of this scheme do we have in tree?

Thanks,

	tglx

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

* Re: [PATCH 0/3] simulated interrupts
  2017-07-19 12:25 ` [PATCH 0/3] simulated interrupts Thomas Gleixner
@ 2017-07-19 12:44   ` Bartosz Golaszewski
  2017-07-19 13:58     ` Thomas Gleixner
  0 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2017-07-19 12:44 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Linus Walleij, Marc Zyngier, Jonathan Corbet, Bamvor Jian Zhang,
	Jonathan Cameron, Lars-Peter Clausen, linux-kernel, linux-gpio,
	linux-doc

2017-07-19 14:25 GMT+02:00 Thomas Gleixner <tglx@linutronix.de>:
> On Wed, 19 Jul 2017, Bartosz Golaszewski wrote:
>
>> Some frameworks (e.g. iio, gpiolib) use irq_work to implement simulated
>> interrupts that can be 'fired' from process context when needed and
>> requested just like normal interrupts. This is useful for testing and
>> development purposes.
>>
>> Currently this code is reimplemented by every user. This series
>> proposes to add a new set of functions that can be used by drivers
>> that want to simulate interrupts without having to duplicate any
>> boilerplate code.
>>
>> The first patch adds a simple irq simulator framework. The second
>> extends it with resource management. The third uses the new
>> functionality in the gpio-mockup testing driver.
>>
>> NOTE: The next candidate for using this API would be iio-dummy-evgen.
>
> I like the general idea - have not looked at the code yet. Just a quick
> question: How many copies/variants of this scheme do we have in tree?
>
> Thanks,
>
>         tglx

Currently there are two: iio and gpiolib basically duplicate the same
code in their respective testing drivers. I only used irq_sim in
gpio-mockup in this series as an example and to see if there's any
interest in merging it before spending time on iio-dummy-evgen.

In the future this could be used in any framework that uses interrupts
and wants to test the irq code paths without touching any specific
hardware.

Thanks,
Bartosz

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

* Re: [PATCH 0/3] simulated interrupts
  2017-07-19 12:44   ` Bartosz Golaszewski
@ 2017-07-19 13:58     ` Thomas Gleixner
  2017-07-19 14:19       ` Marc Zyngier
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Gleixner @ 2017-07-19 13:58 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Marc Zyngier, Jonathan Corbet, Bamvor Jian Zhang,
	Jonathan Cameron, Lars-Peter Clausen, linux-kernel, linux-gpio,
	linux-doc

On Wed, 19 Jul 2017, Bartosz Golaszewski wrote:

> 2017-07-19 14:25 GMT+02:00 Thomas Gleixner <tglx@linutronix.de>:
> > On Wed, 19 Jul 2017, Bartosz Golaszewski wrote:
> >
> >> Some frameworks (e.g. iio, gpiolib) use irq_work to implement simulated
> >> interrupts that can be 'fired' from process context when needed and
> >> requested just like normal interrupts. This is useful for testing and
> >> development purposes.
> >>
> >> Currently this code is reimplemented by every user. This series
> >> proposes to add a new set of functions that can be used by drivers
> >> that want to simulate interrupts without having to duplicate any
> >> boilerplate code.
> >>
> >> The first patch adds a simple irq simulator framework. The second
> >> extends it with resource management. The third uses the new
> >> functionality in the gpio-mockup testing driver.
> >>
> >> NOTE: The next candidate for using this API would be iio-dummy-evgen.
> >
> > I like the general idea - have not looked at the code yet. Just a quick
> > question: How many copies/variants of this scheme do we have in tree?
> >
> > Thanks,
> >
> >         tglx
> 
> Currently there are two: iio and gpiolib basically duplicate the same
> code in their respective testing drivers. I only used irq_sim in
> gpio-mockup in this series as an example and to see if there's any
> interest in merging it before spending time on iio-dummy-evgen.

Yes, I think so. Consolidation is always a good thing and simulation is
useful for developing or validating code.

Thanks,

	tglx

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

* Re: [PATCH 0/3] simulated interrupts
  2017-07-19 13:58     ` Thomas Gleixner
@ 2017-07-19 14:19       ` Marc Zyngier
  2017-07-19 14:43         ` Andy Shevchenko
  2017-08-02 11:32         ` Linus Walleij
  0 siblings, 2 replies; 16+ messages in thread
From: Marc Zyngier @ 2017-07-19 14:19 UTC (permalink / raw)
  To: Thomas Gleixner, Bartosz Golaszewski
  Cc: Linus Walleij, Jonathan Corbet, Bamvor Jian Zhang,
	Jonathan Cameron, Lars-Peter Clausen, linux-kernel, linux-gpio,
	linux-doc

On 19/07/17 14:58, Thomas Gleixner wrote:
> On Wed, 19 Jul 2017, Bartosz Golaszewski wrote:
> 
>> 2017-07-19 14:25 GMT+02:00 Thomas Gleixner <tglx@linutronix.de>:
>>> On Wed, 19 Jul 2017, Bartosz Golaszewski wrote:
>>>
>>>> Some frameworks (e.g. iio, gpiolib) use irq_work to implement simulated
>>>> interrupts that can be 'fired' from process context when needed and
>>>> requested just like normal interrupts. This is useful for testing and
>>>> development purposes.
>>>>
>>>> Currently this code is reimplemented by every user. This series
>>>> proposes to add a new set of functions that can be used by drivers
>>>> that want to simulate interrupts without having to duplicate any
>>>> boilerplate code.
>>>>
>>>> The first patch adds a simple irq simulator framework. The second
>>>> extends it with resource management. The third uses the new
>>>> functionality in the gpio-mockup testing driver.
>>>>
>>>> NOTE: The next candidate for using this API would be iio-dummy-evgen.
>>>
>>> I like the general idea - have not looked at the code yet. Just a quick
>>> question: How many copies/variants of this scheme do we have in tree?
>>>
>>> Thanks,
>>>
>>>         tglx
>>
>> Currently there are two: iio and gpiolib basically duplicate the same
>> code in their respective testing drivers. I only used irq_sim in
>> gpio-mockup in this series as an example and to see if there's any
>> interest in merging it before spending time on iio-dummy-evgen.
> 
> Yes, I think so. Consolidation is always a good thing and simulation is
> useful for developing or validating code.

Indeed, that's pretty interesting.

On a slightly tangential subject, there is another aspect that I thought
of implementing for a while, but always ended up just relying on a quick
hack: forcing the injection of an actual interrupt. A number of
interrupt controllers have the ability to make an interrupt pending, for
it to be handled as if a device had actually triggered it.

In my case, it has proved to be incredibly useful when debugging the
interrupt controller itself, and also things that mess with interrupts
in a creative way (like KVM) while relying on a particular interrupt
controller.

What I had in mind was something like:

echo 1 >/proc/irq/9/trigger (or the corresponding
/sys/kernel/debug/irq/irqs/ interface if we want to make sure that this
is really not for production use...).

If there is any interest, I'll try to whip something up.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

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

* Re: [PATCH 0/3] simulated interrupts
  2017-07-19 14:19       ` Marc Zyngier
@ 2017-07-19 14:43         ` Andy Shevchenko
  2017-07-19 14:53           ` Thomas Gleixner
  2017-08-02 11:32         ` Linus Walleij
  1 sibling, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2017-07-19 14:43 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Thomas Gleixner, Bartosz Golaszewski, Linus Walleij,
	Jonathan Corbet, Bamvor Jian Zhang, Jonathan Cameron,
	Lars-Peter Clausen, linux-kernel, linux-gpio,
	Linux Documentation List

On Wed, Jul 19, 2017 at 5:19 PM, Marc Zyngier <marc.zyngier@arm.com> wrote:
> On 19/07/17 14:58, Thomas Gleixner wrote:
>> On Wed, 19 Jul 2017, Bartosz Golaszewski wrote:

> echo 1 >/proc/irq/9/trigger
> (or the corresponding /sys/kernel/debug/irq/irqs/ interface if we want to make sure that this
> is really not for production use...).

or /sys/kernel/irq as a successor of /proc/irq


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 0/3] simulated interrupts
  2017-07-19 14:43         ` Andy Shevchenko
@ 2017-07-19 14:53           ` Thomas Gleixner
  2017-07-19 15:28             ` Andy Shevchenko
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Gleixner @ 2017-07-19 14:53 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Marc Zyngier, Bartosz Golaszewski, Linus Walleij,
	Jonathan Corbet, Bamvor Jian Zhang, Jonathan Cameron,
	Lars-Peter Clausen, linux-kernel, linux-gpio,
	Linux Documentation List

On Wed, 19 Jul 2017, Andy Shevchenko wrote:

> On Wed, Jul 19, 2017 at 5:19 PM, Marc Zyngier <marc.zyngier@arm.com> wrote:
> > On 19/07/17 14:58, Thomas Gleixner wrote:
> >> On Wed, 19 Jul 2017, Bartosz Golaszewski wrote:
> 
> > echo 1 >/proc/irq/9/trigger
> > (or the corresponding /sys/kernel/debug/irq/irqs/ interface if we want to make sure that this
> > is really not for production use...).
> 
> or /sys/kernel/irq as a successor of /proc/irq

/sys/kernel/debug/irq/irqs/ is already there and it's DEBUG and not
something which is in the regular sysfs maze.

Thanks,

	tglx

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

* Re: [PATCH 0/3] simulated interrupts
  2017-07-19 14:53           ` Thomas Gleixner
@ 2017-07-19 15:28             ` Andy Shevchenko
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2017-07-19 15:28 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Marc Zyngier, Bartosz Golaszewski, Linus Walleij,
	Jonathan Corbet, Bamvor Jian Zhang, Jonathan Cameron,
	Lars-Peter Clausen, linux-kernel, linux-gpio,
	Linux Documentation List

On Wed, Jul 19, 2017 at 5:53 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Wed, 19 Jul 2017, Andy Shevchenko wrote:
>> On Wed, Jul 19, 2017 at 5:19 PM, Marc Zyngier <marc.zyngier@arm.com> wrote:

>> > echo 1 >/proc/irq/9/trigger
>> > (or the corresponding /sys/kernel/debug/irq/irqs/ interface if we want to make sure that this
>> > is really not for production use...).
>>
>> or /sys/kernel/irq as a successor of /proc/irq
>
> /sys/kernel/debug/irq/irqs/ is already there and it's DEBUG and not
> something which is in the regular sysfs maze.

Yep. My point was "not to extend /proc/irq interface". From the
description of the series it indeed looks suitable rather for debug.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 1/3] irq/irq_sim: add a simple interrupt simulator framework
  2017-07-19 12:20 ` [PATCH 1/3] irq/irq_sim: add a simple interrupt simulator framework Bartosz Golaszewski
@ 2017-07-22 20:59   ` Jonathan Cameron
  2017-07-24  6:54     ` Bartosz Golaszewski
  2017-07-24  7:31   ` Lars-Peter Clausen
  1 sibling, 1 reply; 16+ messages in thread
From: Jonathan Cameron @ 2017-07-22 20:59 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Thomas Gleixner, Marc Zyngier, Jonathan Corbet,
	Bamvor Jian Zhang, Lars-Peter Clausen, linux-kernel, linux-gpio,
	linux-doc

On Wed, 19 Jul 2017 14:20:12 +0200
Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> Implement a simple, irq_work-based framework for simulating
> interrupts. Currently the API exposes routines for initializing and
> deinitializing the simulator object, enqueueing the interrupts and
> retrieving the allocated interrupt numbers based on the offset of the
> dummy interrupt in the simulator struct.
> 
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Mostly looks good.  A comment and a question inline.

Jonathan
> ---
>  include/linux/irq_sim.h |  37 +++++++++++++++
>  init/Kconfig            |   4 ++
>  kernel/Makefile         |   1 +
>  kernel/irq_sim.c        | 118 ++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 160 insertions(+)
>  create mode 100644 include/linux/irq_sim.h
>  create mode 100644 kernel/irq_sim.c
> 
> diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h
> new file mode 100644
> index 000000000000..0c1abf0e3244
> --- /dev/null
> +++ b/include/linux/irq_sim.h
> @@ -0,0 +1,37 @@
> +/*
> + * Copyright (C) 2017 Bartosz Golaszewski <brgl@bgdev.pl>
> + *
> + * Provides a framework for allocating simulated interrupts which can be
> + * requested like normal irqs and enqueued from process context.
> + */
> +
> +#ifndef _LINUX_IRQ_SIM_H
> +#define _LINUX_IRQ_SIM_H
> +
> +#include <linux/irq_work.h>
> +
> +struct irq_sim_work_ctx {
> +	struct irq_work work;
> +	int irq;
> +};
> +
> +struct irq_sim_irq_ctx {
> +	int irqnum;
> +	bool enabled;
> +};
> +
> +struct irq_sim {
> +	struct irq_sim_work_ctx work_ctx;
> +	int irq_base;
> +	unsigned int irq_count;
> +	struct irq_sim_irq_ctx *irqs;
> +};
> +
> +int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs);
> +void irq_sim_fini(struct irq_sim *sim);
> +
> +void irq_sim_fire(struct irq_sim *sim, unsigned int offset);
> +
> +int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset);
> +
> +#endif /* _LINUX_IRQ_SIM_H */
> diff --git a/init/Kconfig b/init/Kconfig
> index 8514b25db21c..220456599c3f 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -23,6 +23,10 @@ config CONSTRUCTORS
>  config IRQ_WORK
>  	bool
>  
> +config IRQ_SIM
> +	bool
> +	select IRQ_WORK
> +
>  config BUILDTIME_EXTABLE_SORT
>  	bool
>  
> diff --git a/kernel/Makefile b/kernel/Makefile
> index 4cb8e8b23c6e..4472567c5835 100644
> --- a/kernel/Makefile
> +++ b/kernel/Makefile
> @@ -97,6 +97,7 @@ obj-$(CONFIG_TRACE_CLOCK) += trace/
>  obj-$(CONFIG_RING_BUFFER) += trace/
>  obj-$(CONFIG_TRACEPOINTS) += trace/
>  obj-$(CONFIG_IRQ_WORK) += irq_work.o
> +obj-$(CONFIG_IRQ_SIM) += irq_sim.o
>  obj-$(CONFIG_CPU_PM) += cpu_pm.o
>  obj-$(CONFIG_BPF) += bpf/
>  
> diff --git a/kernel/irq_sim.c b/kernel/irq_sim.c
> new file mode 100644
> index 000000000000..062110c90d2a
> --- /dev/null
> +++ b/kernel/irq_sim.c
> @@ -0,0 +1,118 @@
> +/*
> + * Copyright (C) 2017 Bartosz Golaszewski <brgl@bgdev.pl>
> + *
> + * Provides a framework for allocating simulated interrupts which can be
> + * requested like normal irqs and enqueued from process context.
> + */
> +
> +#include <linux/irq_sim.h>
> +#include <linux/irq.h>
> +
> +static void irq_sim_irqmask(struct irq_data *data)
> +{
> +	struct irq_sim_irq_ctx *irq_ctx = irq_data_get_irq_chip_data(data);
> +
> +	irq_ctx->enabled = false;
> +}
> +
> +static void irq_sim_irqunmask(struct irq_data *data)
> +{
> +	struct irq_sim_irq_ctx *irq_ctx = irq_data_get_irq_chip_data(data);
> +
> +	irq_ctx->enabled = true;
> +}
> +
> +static struct irq_chip irq_sim_irqchip = {
> +	.name		= "irq_sim",
> +	.irq_mask	= irq_sim_irqmask,
> +	.irq_unmask	= irq_sim_irqunmask,
> +};
> +
> +static void irq_sim_handle_irq(struct irq_work *work)
> +{
> +	struct irq_sim_work_ctx *work_ctx;
> +
> +	work_ctx = container_of(work, struct irq_sim_work_ctx, work);
> +	handle_simple_irq(irq_to_desc(work_ctx->irq));
> +}
> +
> +/**
> + * irq_sim_init - Initialize the interrupt simulator: allocate a range of
> + *                dummy interrupts.
> + *
> + * @sim:        The interrupt simulator object to initialize.
> + * @num_irqs:   Number of interrupts to allocate
> + *
> + * Returns 0 on success and a negative error number on failure.
> + */
> +int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs)
> +{
> +	int i;
> +
> +	sim->irqs = kmalloc_array(num_irqs, sizeof(*sim->irqs), GFP_KERNEL);
> +	if (!sim->irqs)
> +		return -ENOMEM;
> +
> +	sim->irq_base = irq_alloc_descs(-1, 0, num_irqs, 0);
> +	if (sim->irq_base < 0) {
> +		kfree(sim->irqs);
> +		return sim->irq_base;
> +	}
> +
> +	for (i = 0; i < num_irqs; i++) {
> +		sim->irqs[i].irqnum = sim->irq_base + i;
> +		sim->irqs[i].enabled = false;
> +		irq_set_chip(sim->irq_base + i, &irq_sim_irqchip);
> +		irq_set_chip_data(sim->irq_base + i, &sim->irqs[i]);
Cool. That's nicer than what we have in IIO :)  This function really
doesn't have a clear name though as I initially thought the data
was shared by the chip, where as it is the chip_data associated with
a particular IRQ. Had me briefly confused!

Just goes to show the advantage of a unified bit of code for
similar users - the gpio code was nicer than the IIO one as it
turned out.
> +		irq_set_handler(sim->irq_base + i, &handle_simple_irq);
> +		irq_modify_status(sim->irq_base + i,
> +				  IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE);
> +	}
> +
> +	init_irq_work(&sim->work_ctx.work, irq_sim_handle_irq);
> +	sim->irq_count = num_irqs;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(irq_sim_init);
> +
> +/**
> + * irq_sim_fini - Deinitialize the interrupt simulator: free the interrupt
> + *                descriptors and allocated memory.
> + *
> + * @sim:        The interrupt simulator to tear down.
> + */
> +void irq_sim_fini(struct irq_sim *sim)
> +{
> +	irq_free_descs(sim->irq_base, sim->irq_count);
> +	kfree(sim->irqs);
> +}
> +EXPORT_SYMBOL_GPL(irq_sim_fini);
> +
> +/**
> + * irq_sim_fire - Enqueue an interrupt.
> + *
> + * @sim:        The interrupt simulator object.
> + * @offset:     Offset of the simulated interrupt which should be fired.
> + */
> +void irq_sim_fire(struct irq_sim *sim, unsigned int offset)
> +{
> +	if (sim->irqs[offset].enabled) {
> +		sim->work_ctx.irq = irq_sim_irqnum(sim, offset);
Is this safe against more than one firing at a time?  Or is it
the responsibility of the caller to prevent that?
> +		irq_work_queue(&sim->work_ctx.work);
> +	}
> +}
> +EXPORT_SYMBOL_GPL(irq_sim_fire);
> +
> +/**
> + * irq_sim_irqnum - Get the allocated number of a dummy interrupt.
> + *
> + * @sim:        The interrupt simulator object.
> + * @offset:     Offset of the simulated interrupt for which to retrieve
> + *              the number.
> + */
> +int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset)
> +{
> +	return sim->irqs[offset].irqnum;
> +}
> +EXPORT_SYMBOL_GPL(irq_sim_irqnum);


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

* Re: [PATCH 1/3] irq/irq_sim: add a simple interrupt simulator framework
  2017-07-22 20:59   ` Jonathan Cameron
@ 2017-07-24  6:54     ` Bartosz Golaszewski
  0 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2017-07-24  6:54 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Linus Walleij, Thomas Gleixner, Marc Zyngier, Jonathan Corbet,
	Bamvor Jian Zhang, Lars-Peter Clausen, linux-kernel, linux-gpio,
	linux-doc

2017-07-22 22:59 GMT+02:00 Jonathan Cameron <jic23@kernel.org>:
>> +
>> +/**
>> + * irq_sim_fire - Enqueue an interrupt.
>> + *
>> + * @sim:        The interrupt simulator object.
>> + * @offset:     Offset of the simulated interrupt which should be fired.
>> + */
>> +void irq_sim_fire(struct irq_sim *sim, unsigned int offset)
>> +{
>> +     if (sim->irqs[offset].enabled) {
>> +             sim->work_ctx.irq = irq_sim_irqnum(sim, offset);
> Is this safe against more than one firing at a time?  Or is it
> the responsibility of the caller to prevent that?
>

Yes, I assumed this should be the responsibility of the caller. Let me
know if there's an important reason to implement separate locking
within this framework. My goal was to keep it simple, hence no
generalized UAPI too - callers should use their own interfaces to
expose this to the user space if needed.

Thanks,
Bartosz

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

* Re: [PATCH 1/3] irq/irq_sim: add a simple interrupt simulator framework
  2017-07-19 12:20 ` [PATCH 1/3] irq/irq_sim: add a simple interrupt simulator framework Bartosz Golaszewski
  2017-07-22 20:59   ` Jonathan Cameron
@ 2017-07-24  7:31   ` Lars-Peter Clausen
  1 sibling, 0 replies; 16+ messages in thread
From: Lars-Peter Clausen @ 2017-07-24  7:31 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij, Thomas Gleixner,
	Marc Zyngier, Jonathan Corbet, Bamvor Jian Zhang,
	Jonathan Cameron
  Cc: linux-kernel, linux-gpio, linux-doc

On 07/19/2017 02:20 PM, Bartosz Golaszewski wrote:
[...]
> +void irq_sim_fini(struct irq_sim *sim)
> +{

Not very likely to happen in practice, but for correctness we should
probably put a irq_work_sync() here for each of the IRQs to make sure that
the memory associated with the irq_sim_work_ctx struct is no longer accessed
and that handle_simple_irq() is not called after irq_free_descs().


> +	irq_free_descs(sim->irq_base, sim->irq_count);
> +	kfree(sim->irqs);
> +}
> +EXPORT_SYMBOL_GPL(irq_sim_fini);

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

* Re: [PATCH 0/3] simulated interrupts
  2017-07-19 14:19       ` Marc Zyngier
  2017-07-19 14:43         ` Andy Shevchenko
@ 2017-08-02 11:32         ` Linus Walleij
  1 sibling, 0 replies; 16+ messages in thread
From: Linus Walleij @ 2017-08-02 11:32 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Thomas Gleixner, Bartosz Golaszewski, Jonathan Corbet,
	Bamvor Jian Zhang, Jonathan Cameron, Lars-Peter Clausen,
	linux-kernel, linux-gpio, linux-doc

On Wed, Jul 19, 2017 at 4:19 PM, Marc Zyngier <marc.zyngier@arm.com> wrote:

> On a slightly tangential subject, there is another aspect that I thought
> of implementing for a while, but always ended up just relying on a quick
> hack: forcing the injection of an actual interrupt. A number of
> interrupt controllers have the ability to make an interrupt pending, for
> it to be handled as if a device had actually triggered it.

This would be especially useful for a class of embedded systems that
are woken up from deep sleep by an asynchronous interrupt controller.

Usually GPIO(-ish) lines are armed and the system put to sleep, and
when it comes up, the information of what line woke it up is there in a
special register, but the actual (synchronous) interrupt line is no longer
asserted or edge triggered, so an interrupt need to be inserted.

Yours,
Linus Walleij

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

* Re: [PATCH 3/3] gpio: mockup: use irq_sim
  2017-07-19 12:20 ` [PATCH 3/3] gpio: mockup: use irq_sim Bartosz Golaszewski
@ 2017-08-02 11:34   ` Linus Walleij
  0 siblings, 0 replies; 16+ messages in thread
From: Linus Walleij @ 2017-08-02 11:34 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Thomas Gleixner, Marc Zyngier, Jonathan Corbet,
	Bamvor Jian Zhang, Jonathan Cameron, Lars-Peter Clausen,
	linux-kernel, linux-gpio, linux-doc

On Wed, Jul 19, 2017 at 2:20 PM, Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> Shrink the driver by removing the code dealing with dummy interrupts
> and replacing it with calls to the irq_sim API.
>
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

You can definately merge this along with the simulator into the IRQchip
subsystem.

Yours,
Linus Walleij

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

end of thread, other threads:[~2017-08-02 11:34 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-19 12:20 [PATCH 0/3] simulated interrupts Bartosz Golaszewski
2017-07-19 12:20 ` [PATCH 1/3] irq/irq_sim: add a simple interrupt simulator framework Bartosz Golaszewski
2017-07-22 20:59   ` Jonathan Cameron
2017-07-24  6:54     ` Bartosz Golaszewski
2017-07-24  7:31   ` Lars-Peter Clausen
2017-07-19 12:20 ` [PATCH 2/3] irq/irq_sim: add a devres variant of irq_sim_init() Bartosz Golaszewski
2017-07-19 12:20 ` [PATCH 3/3] gpio: mockup: use irq_sim Bartosz Golaszewski
2017-08-02 11:34   ` Linus Walleij
2017-07-19 12:25 ` [PATCH 0/3] simulated interrupts Thomas Gleixner
2017-07-19 12:44   ` Bartosz Golaszewski
2017-07-19 13:58     ` Thomas Gleixner
2017-07-19 14:19       ` Marc Zyngier
2017-07-19 14:43         ` Andy Shevchenko
2017-07-19 14:53           ` Thomas Gleixner
2017-07-19 15:28             ` Andy Shevchenko
2017-08-02 11:32         ` Linus Walleij

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.