From: Marc Zyngier <marc.zyngier@arm.com>
To: "Bartosz Golaszewski" <brgl@bgdev.pl>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [PATCH v2 3/9] irq/irq_sim: provide irq_sim_fire_type()
Date: Tue, 12 Feb 2019 09:10:15 +0000 [thread overview]
Message-ID: <656763ec-41b9-cdee-22bd-1f32d74473a0@arm.com> (raw)
In-Reply-To: <20190129084411.30495-4-brgl@bgdev.pl>
On 29/01/2019 08:44, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Provide a more specialized variant of irq_sim_fire() that allows to
> specify the type of the fired interrupt. The type is stored in the
> dummy irq context struct via the set_type callback.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
> include/linux/irq_sim.h | 9 ++++++++-
> kernel/irq/irq_sim.c | 26 ++++++++++++++++++++++----
> 2 files changed, 30 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h
> index b96c2f752320..647a6c8ffb31 100644
> --- a/include/linux/irq_sim.h
> +++ b/include/linux/irq_sim.h
> @@ -23,6 +23,7 @@ struct irq_sim_work_ctx {
>
> struct irq_sim_irq_ctx {
> bool enabled;
> + unsigned int type;
> };
>
> struct irq_sim {
> @@ -37,7 +38,13 @@ int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs);
> int devm_irq_sim_init(struct device *dev, 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);
> +void irq_sim_fire_type(struct irq_sim *sim,
> + unsigned int offset, unsigned int type);
> int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset);
>
> +static inline void irq_sim_fire(struct irq_sim *sim, unsigned int offset)
> +{
> + irq_sim_fire_type(sim, offset, IRQ_TYPE_DEFAULT);
> +}
> +
> #endif /* _LINUX_IRQ_SIM_H */
> diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c
> index 2bcdbab1bc5a..e3160b5e59b8 100644
> --- a/kernel/irq/irq_sim.c
> +++ b/kernel/irq/irq_sim.c
> @@ -25,6 +25,15 @@ static void irq_sim_irqunmask(struct irq_data *data)
> irq_ctx->enabled = true;
> }
>
> +static int irq_sim_set_type(struct irq_data *data, unsigned int type)
> +{
> + struct irq_sim_irq_ctx *irq_ctx = irq_data_get_irq_chip_data(data);
> +
> + irq_ctx->type = type;
> +
> + return 0;
> +}
> +
> static void irq_sim_handle_irq(struct irq_work *work)
> {
> struct irq_sim_work_ctx *work_ctx;
> @@ -107,6 +116,7 @@ int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs)
> sim->chip.name = "irq_sim";
> sim->chip.irq_mask = irq_sim_irqmask;
> sim->chip.irq_unmask = irq_sim_irqunmask;
> + sim->chip.irq_set_type = irq_sim_set_type;
>
> sim->work_ctx.pending = bitmap_zalloc(num_irqs, GFP_KERNEL);
> if (!sim->work_ctx.pending) {
> @@ -192,21 +202,29 @@ irq_sim_get_ctx(struct irq_sim *sim, unsigned int offset)
> }
>
> /**
> - * irq_sim_fire - Enqueue an interrupt.
> + * irq_sim_fire_type - Enqueue an interrupt.
> *
> * @sim: The interrupt simulator object.
> * @offset: Offset of the simulated interrupt which should be fired.
> + * @type: Type of the fired interrupt. Must be one of the following:
> + * IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING,
> + * IRQ_TYPE_EDGE_BOTH, IRQ_TYPE_LEVEL_HIGH,
> + * IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_DEFAULT
> */
> -void irq_sim_fire(struct irq_sim *sim, unsigned int offset)
> +void irq_sim_fire_type(struct irq_sim *sim,
> + unsigned int offset, unsigned int type)
> {
> struct irq_sim_irq_ctx *ctx = irq_sim_get_ctx(sim, offset);
>
> - if (ctx->enabled) {
> + /* Only care about relevant flags. */
> + type &= IRQ_TYPE_SENSE_MASK;
> +
> + if (ctx->enabled && (ctx->type & type)) {
I wonder how realistic this is, given that you do not track the release
of a level. In short, mo matter what the type is, you treat everything
as edge.
What is the point of this?
> set_bit(offset, sim->work_ctx.pending);
> irq_work_queue(&sim->work_ctx.work);
> }
> }
> -EXPORT_SYMBOL_GPL(irq_sim_fire);
> +EXPORT_SYMBOL_GPL(irq_sim_fire_type);
>
> /**
> * irq_sim_irqnum - Get the allocated number of a dummy interrupt.
>
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2019-02-12 9:10 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-29 8:44 [PATCH v2 0/9] gpio: mockup: improve the user-space testing interface Bartosz Golaszewski
2019-01-29 8:44 ` [PATCH v2 1/9] irq/irq_sim: don't share the irq_chip structure between simulators Bartosz Golaszewski
2019-02-11 22:28 ` Marc Zyngier
2019-02-12 8:29 ` Bartosz Golaszewski
2019-01-29 8:44 ` [PATCH v2 2/9] irq/irq_sim: use irq domain Bartosz Golaszewski
2019-02-11 22:26 ` Marc Zyngier
2019-02-12 8:30 ` Bartosz Golaszewski
2019-02-12 8:53 ` Marc Zyngier
2019-02-12 8:56 ` Bartosz Golaszewski
2019-01-29 8:44 ` [PATCH v2 3/9] irq/irq_sim: provide irq_sim_fire_type() Bartosz Golaszewski
2019-01-29 9:07 ` Uwe Kleine-König
2019-01-29 11:01 ` Bartosz Golaszewski
2019-01-29 12:55 ` Uwe Kleine-König
2019-02-01 11:02 ` Bartosz Golaszewski
2019-02-12 9:10 ` Marc Zyngier [this message]
2019-02-12 9:19 ` Bartosz Golaszewski
2019-02-12 10:06 ` Uwe Kleine-König
2019-02-12 10:15 ` Bartosz Golaszewski
2019-02-12 10:27 ` Marc Zyngier
2019-02-12 10:37 ` Bartosz Golaszewski
2019-02-12 10:52 ` Marc Zyngier
2019-02-12 11:05 ` Uwe Kleine-König
2019-02-12 11:09 ` Bartosz Golaszewski
2019-02-12 11:35 ` Marc Zyngier
2019-01-29 8:44 ` [PATCH v2 4/9] gpio: mockup: add locking Bartosz Golaszewski
2019-01-29 8:44 ` [PATCH v2 5/9] gpio: mockup: implement get_multiple() Bartosz Golaszewski
2019-01-29 8:44 ` [PATCH v2 6/9] gpio: mockup: don't create the debugfs link named after the label Bartosz Golaszewski
2019-01-29 8:44 ` [PATCH v2 7/9] gpio: mockup: change the type of 'offset' to unsigned int Bartosz Golaszewski
2019-01-29 8:44 ` [PATCH v2 8/9] gpio: mockup: change the signature of unlocked get/set helpers Bartosz Golaszewski
2019-01-29 8:44 ` [PATCH v2 9/9] gpio: mockup: rework debugfs interface Bartosz Golaszewski
2019-02-06 10:23 ` [PATCH v2 0/9] gpio: mockup: improve the user-space testing interface Bartosz Golaszewski
2019-02-11 22:33 ` Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=656763ec-41b9-cdee-22bd-1f32d74473a0@arm.com \
--to=marc.zyngier@arm.com \
--cc=bgolaszewski@baylibre.com \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome