linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jason Cooper <jason@lakedaemon.net>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-iio@vger.kernel.org,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v4 2/2] irq/irq_sim: simplify the API
Date: Tue, 12 May 2020 16:37:14 +0100	[thread overview]
Message-ID: <6568919d6cc3ee8f602a58354e3aff44@kernel.org> (raw)
In-Reply-To: <20200430143019.1704-3-brgl@bgdev.pl>

Bartosz,

On 2020-04-30 15:30, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> The interrupt simulator API exposes a lot of custom data structures and
> functions and doesn't reuse the interfaces already exposed by the irq
> subsystem. This patch tries to address it.
> 
> We hide all the simulator-related data structures from users and 
> instead
> rely on the well-known irq domain. When creating the interrupt 
> simulator
> the user receives a pointer to a newly created irq_domain and can use 
> it
> to create mappings for simulated interrupts.
> 
> It is also possible to pass a handle to fwnode when creating the 
> simulator
> domain and retrieve it using irq_find_matching_fwnode().
> 
> The irq_sim_fire() function now only takes the virtual interrupt number
> as argument - there's no need anymore to pass it any data structure 
> linked
> to the simulator.
> 
> We modify the two modules that use the simulator at the same time as
> adding these changes in order to reduce the intermediate bloat that 
> would
> result when trying to migrate the drivers in separate patches.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> #for IIO
> ---
>  drivers/gpio/gpio-mockup.c          |  47 ++++--
>  drivers/iio/dummy/iio_dummy_evgen.c |  32 ++--
>  include/linux/irq_sim.h             |  34 ++---
>  kernel/irq/Kconfig                  |   1 +
>  kernel/irq/irq_sim.c                | 225 +++++++++++++++++-----------
>  5 files changed, 202 insertions(+), 137 deletions(-)

[...]

>  /**
>   * irq_sim_fire - Enqueue an interrupt.
>   *
> - * @sim:        The interrupt simulator object.
> - * @offset:     Offset of the simulated interrupt which should be 
> fired.
> + * @virq:       Virtual interrupt number to fire. It must be 
> associated with
> + *              an existing interrupt simulator.
>   */
> -void irq_sim_fire(struct irq_sim *sim, unsigned int offset)
> +void irq_sim_fire(int virq)
>  {
> -	if (sim->irqs[offset].enabled) {
> -		set_bit(offset, sim->work_ctx.pending);
> -		irq_work_queue(&sim->work_ctx.work);
> +	struct irq_sim_irq_ctx *irq_ctx;
> +	struct irq_data *irqd;
> +
> +	irqd = irq_get_irq_data(virq);
> +	if (!irqd) {
> +		pr_warn_ratelimited("%s: invalid irq number\n", __func__);
> +		return;
>  	}
> -}
> -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;
> +	irq_ctx = irq_data_get_irq_chip_data(irqd);
> +
> +	if (irq_ctx->enabled) {
> +		set_bit(irqd_to_hwirq(irqd), irq_ctx->work_ctx->pending);
> +		irq_work_queue(&irq_ctx->work_ctx->work);
> +	}
>  }
> -EXPORT_SYMBOL_GPL(irq_sim_irqnum);
> +EXPORT_SYMBOL_GPL(irq_sim_fire);

Rather than using an ad-hoc API to queue an interrupt, why don't you
actually implement the interface that already exists for this at
the irqchip level (irq_set_irqchip_state, which allows the pending
state to be set)?

Thanks,

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

  parent reply	other threads:[~2020-05-12 15:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-30 14:30 [PATCH v4 0/2] irq/irq_sim: try to improve the API Bartosz Golaszewski
2020-04-30 14:30 ` [PATCH v4 1/2] irq: make irq_domain_reset_irq_data() available even for non-V2 users Bartosz Golaszewski
2020-05-12 12:15   ` Linus Walleij
2020-04-30 14:30 ` [PATCH v4 2/2] irq/irq_sim: simplify the API Bartosz Golaszewski
2020-05-12 12:16   ` Linus Walleij
2020-05-12 15:37   ` Marc Zyngier [this message]
2020-05-12 17:12     ` Bartosz Golaszewski
2020-05-12 11:39 ` [PATCH v4 0/2] irq/irq_sim: try to improve " Bartosz Golaszewski

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=6568919d6cc3ee8f602a58354e3aff44@kernel.org \
    --to=maz@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=brgl@bgdev.pl \
    --cc=jason@lakedaemon.net \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).