History

genirq/irq_sim: Simplify the API

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 is dropped as well. Instead we implement the irq_get/set_irqchip_state interface. 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.

Bartosz Golaszewski committed 6 years ago

Commit 337cbeb1 parent 5c8f77a5 files · +237 −151Browse files

Showing the changes to include/linux (1 of 5 files). Show all

Unified · Split

include/linux/irq_sim.h+9−24
@@ -1,41 +1,26 @@
1/* SPDX-License-Identifier: GPL-2.0+ */1/* SPDX-License-Identifier: GPL-2.0+ */
2/*2/*
3 * Copyright (C) 2017-2018 Bartosz Golaszewski <brgl@bgdev.pl>3 * Copyright (C) 2017-2018 Bartosz Golaszewski <brgl@bgdev.pl>
4 * Copyright (C) 2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>
4 */5 */
5 6
6#ifndef _LINUX_IRQ_SIM_H7#ifndef _LINUX_IRQ_SIM_H
7#define _LINUX_IRQ_SIM_H8#define _LINUX_IRQ_SIM_H
8 9
9#include <linux/irq_work.h>
10#include <linux/device.h>10#include <linux/device.h>
11#include <linux/fwnode.h>
12#include <linux/irqdomain.h>
11 13
12/*14/*
13 * Provides a framework for allocating simulated interrupts which can be15 * Provides a framework for allocating simulated interrupts which can be
14 * requested like normal irqs and enqueued from process context.16 * requested like normal irqs and enqueued from process context.
15 */17 */
16 18
17struct irq_sim_work_ctx {19struct irq_domain *irq_domain_create_sim(struct fwnode_handle *fwnode,
18 struct irq_work work;20 unsigned int num_irqs);
19 unsigned long *pending;21struct irq_domain *devm_irq_domain_create_sim(struct device *dev,
20};22 struct fwnode_handle *fwnode,
21 23 unsigned int num_irqs);
22struct irq_sim_irq_ctx {24void irq_domain_remove_sim(struct irq_domain *domain);
23 int irqnum;
24 bool enabled;
25};
26
27struct irq_sim {
28 struct irq_sim_work_ctx work_ctx;
29 int irq_base;
30 unsigned int irq_count;
31 struct irq_sim_irq_ctx *irqs;
32};
33
34int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs);
35int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
36 unsigned int num_irqs);
37void irq_sim_fini(struct irq_sim *sim);
38void irq_sim_fire(struct irq_sim *sim, unsigned int offset);
39int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset);
40 25
41#endif /* _LINUX_IRQ_SIM_H */26#endif /* _LINUX_IRQ_SIM_H */