Skip to content

Commit 2bd1bea

Browse files
committed
Merge tag 'irq-cleanups-2025-05-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull irq cleanups from Thomas Gleixner: "A set of cleanups for the generic interrupt subsystem: - Consolidate on one set of functions for the interrupt domain code to get rid of pointlessly duplicated code with only marginal different semantics. - Update the documentation accordingly and consolidate the coding style of the irqdomain header" * tag 'irq-cleanups-2025-05-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (46 commits) irqdomain: Consolidate coding style irqdomain: Fix kernel-doc and add it to Documentation Documentation: irqdomain: Update it Documentation: irq-domain.rst: Simple improvements Documentation: irq/concepts: Minor improvements Documentation: irq/concepts: Add commas and reflow irqdomain: Improve kernel-docs of functions irqdomain: Make struct irq_domain_info variables const irqdomain: Use irq_domain_instantiate()'s return value as initializers irqdomain: Drop irq_linear_revmap() pinctrl: keembay: Switch to irq_find_mapping() irqchip/armada-370-xp: Switch to irq_find_mapping() gpu: ipu-v3: Switch to irq_find_mapping() gpio: idt3243x: Switch to irq_find_mapping() sh: Switch to irq_find_mapping() powerpc: Switch to irq_find_mapping() irqdomain: Drop irq_domain_add_*() functions powerpc: Switch irq_domain_add_nomap() to use fwnode thermal: Switch to irq_domain_create_linear() soc: Switch to irq_domain_create_*() ...
2 parents c0f182c + 38c1e73 commit 2bd1bea

File tree

250 files changed

+902
-997
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

250 files changed

+902
-997
lines changed

Documentation/core-api/genericirq.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,6 @@ which are used in the generic IRQ layer.
410410
.. kernel-doc:: include/linux/interrupt.h
411411
:internal:
412412

413-
.. kernel-doc:: include/linux/irqdomain.h
414-
415413
Public Functions Provided
416414
=========================
417415

Documentation/core-api/irq/concepts.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22
What is an IRQ?
33
===============
44

5-
An IRQ is an interrupt request from a device.
6-
Currently they can come in over a pin, or over a packet.
7-
Several devices may be connected to the same pin thus
8-
sharing an IRQ.
5+
An IRQ is an interrupt request from a device. Currently, they can come
6+
in over a pin, or over a packet. Several devices may be connected to
7+
the same pin thus sharing an IRQ. Such as on legacy PCI bus: All devices
8+
typically share 4 lanes/pins. Note that each device can request an
9+
interrupt on each of the lanes.
910

1011
An IRQ number is a kernel identifier used to talk about a hardware
11-
interrupt source. Typically this is an index into the global irq_desc
12-
array, but except for what linux/interrupt.h implements the details
13-
are architecture specific.
12+
interrupt source. Typically, this is an index into the global irq_desc
13+
array or sparse_irqs tree. But except for what linux/interrupt.h
14+
implements, the details are architecture specific.
1415

1516
An IRQ number is an enumeration of the possible interrupt sources on a
16-
machine. Typically what is enumerated is the number of input pins on
17-
all of the interrupt controller in the system. In the case of ISA
18-
what is enumerated are the 16 input pins on the two i8259 interrupt
19-
controllers.
17+
machine. Typically, what is enumerated is the number of input pins on
18+
all of the interrupt controllers in the system. In the case of ISA,
19+
what is enumerated are the 8 input pins on each of the two i8259
20+
interrupt controllers.
2021

2122
Architectures can assign additional meaning to the IRQ numbers, and
22-
are encouraged to in the case where there is any manual configuration
23-
of the hardware involved. The ISA IRQs are a classic example of
23+
are encouraged to in the case where there is any manual configuration
24+
of the hardware involved. The ISA IRQs are a classic example of
2425
assigning this kind of additional meaning.
Lines changed: 113 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,77 @@
11
===============================================
2-
The irq_domain interrupt number mapping library
2+
The irq_domain Interrupt Number Mapping Library
33
===============================================
44

55
The current design of the Linux kernel uses a single large number
6-
space where each separate IRQ source is assigned a different number.
7-
This is simple when there is only one interrupt controller, but in
8-
systems with multiple interrupt controllers the kernel must ensure
6+
space where each separate IRQ source is assigned a unique number.
7+
This is simple when there is only one interrupt controller. But in
8+
systems with multiple interrupt controllers, the kernel must ensure
99
that each one gets assigned non-overlapping allocations of Linux
1010
IRQ numbers.
1111

1212
The number of interrupt controllers registered as unique irqchips
13-
show a rising tendency: for example subdrivers of different kinds
13+
shows a rising tendency. For example, subdrivers of different kinds
1414
such as GPIO controllers avoid reimplementing identical callback
1515
mechanisms as the IRQ core system by modelling their interrupt
16-
handlers as irqchips, i.e. in effect cascading interrupt controllers.
16+
handlers as irqchips. I.e. in effect cascading interrupt controllers.
1717

18-
Here the interrupt number loose all kind of correspondence to
19-
hardware interrupt numbers: whereas in the past, IRQ numbers could
20-
be chosen so they matched the hardware IRQ line into the root
21-
interrupt controller (i.e. the component actually fireing the
22-
interrupt line to the CPU) nowadays this number is just a number.
18+
So in the past, IRQ numbers could be chosen so that they match the
19+
hardware IRQ line into the root interrupt controller (i.e. the
20+
component actually firing the interrupt line to the CPU). Nowadays,
21+
this number is just a number and the number loose all kind of
22+
correspondence to hardware interrupt numbers.
2323

24-
For this reason we need a mechanism to separate controller-local
25-
interrupt numbers, called hardware irq's, from Linux IRQ numbers.
24+
For this reason, we need a mechanism to separate controller-local
25+
interrupt numbers, called hardware IRQs, from Linux IRQ numbers.
2626

2727
The irq_alloc_desc*() and irq_free_desc*() APIs provide allocation of
28-
irq numbers, but they don't provide any support for reverse mapping of
28+
IRQ numbers, but they don't provide any support for reverse mapping of
2929
the controller-local IRQ (hwirq) number into the Linux IRQ number
3030
space.
3131

32-
The irq_domain library adds mapping between hwirq and IRQ numbers on
33-
top of the irq_alloc_desc*() API. An irq_domain to manage mapping is
34-
preferred over interrupt controller drivers open coding their own
32+
The irq_domain library adds a mapping between hwirq and IRQ numbers on
33+
top of the irq_alloc_desc*() API. An irq_domain to manage the mapping
34+
is preferred over interrupt controller drivers open coding their own
3535
reverse mapping scheme.
3636

37-
irq_domain also implements translation from an abstract irq_fwspec
38-
structure to hwirq numbers (Device Tree and ACPI GSI so far), and can
39-
be easily extended to support other IRQ topology data sources.
37+
irq_domain also implements a translation from an abstract struct
38+
irq_fwspec to hwirq numbers (Device Tree, non-DT firmware node, ACPI
39+
GSI, and software node so far), and can be easily extended to support
40+
other IRQ topology data sources. The implementation is performed
41+
without any extra platform support code.
4042

41-
irq_domain usage
43+
irq_domain Usage
4244
================
43-
44-
An interrupt controller driver creates and registers an irq_domain by
45-
calling one of the irq_domain_add_*() or irq_domain_create_*() functions
46-
(each mapping method has a different allocator function, more on that later).
47-
The function will return a pointer to the irq_domain on success. The caller
48-
must provide the allocator function with an irq_domain_ops structure.
45+
struct irq_domain could be defined as an irq domain controller. That
46+
is, it handles the mapping between hardware and virtual interrupt
47+
numbers for a given interrupt domain. The domain structure is
48+
generally created by the PIC code for a given PIC instance (though a
49+
domain can cover more than one PIC if they have a flat number model).
50+
It is the domain callbacks that are responsible for setting the
51+
irq_chip on a given irq_desc after it has been mapped.
52+
53+
The host code and data structures use a fwnode_handle pointer to
54+
identify the domain. In some cases, and in order to preserve source
55+
code compatibility, this fwnode pointer is "upgraded" to a DT
56+
device_node. For those firmware infrastructures that do not provide a
57+
unique identifier for an interrupt controller, the irq_domain code
58+
offers a fwnode allocator.
59+
60+
An interrupt controller driver creates and registers a struct irq_domain
61+
by calling one of the irq_domain_create_*() functions (each mapping
62+
method has a different allocator function, more on that later). The
63+
function will return a pointer to the struct irq_domain on success. The
64+
caller must provide the allocator function with a struct irq_domain_ops
65+
pointer.
4966

5067
In most cases, the irq_domain will begin empty without any mappings
5168
between hwirq and IRQ numbers. Mappings are added to the irq_domain
5269
by calling irq_create_mapping() which accepts the irq_domain and a
53-
hwirq number as arguments. If a mapping for the hwirq doesn't already
54-
exist then it will allocate a new Linux irq_desc, associate it with
55-
the hwirq, and call the .map() callback so the driver can perform any
56-
required hardware setup.
70+
hwirq number as arguments. If a mapping for the hwirq doesn't already
71+
exist, irq_create_mapping() allocates a new Linux irq_desc, associates
72+
it with the hwirq, and calls the :c:member:`irq_domain_ops.map()`
73+
callback. In there, the driver can perform any required hardware
74+
setup.
5775

5876
Once a mapping has been established, it can be retrieved or used via a
5977
variety of methods:
@@ -63,8 +81,6 @@ variety of methods:
6381
mapping.
6482
- irq_find_mapping() returns a Linux IRQ number for a given domain and
6583
hwirq number, and 0 if there was no mapping
66-
- irq_linear_revmap() is now identical to irq_find_mapping(), and is
67-
deprecated
6884
- generic_handle_domain_irq() handles an interrupt described by a
6985
domain and a hwirq number
7086

@@ -77,9 +93,10 @@ be allocated.
7793

7894
If the driver has the Linux IRQ number or the irq_data pointer, and
7995
needs to know the associated hwirq number (such as in the irq_chip
80-
callbacks) then it can be directly obtained from irq_data->hwirq.
96+
callbacks) then it can be directly obtained from
97+
:c:member:`irq_data.hwirq`.
8198

82-
Types of irq_domain mappings
99+
Types of irq_domain Mappings
83100
============================
84101

85102
There are several mechanisms available for reverse mapping from hwirq
@@ -92,7 +109,6 @@ Linear
92109

93110
::
94111

95-
irq_domain_add_linear()
96112
irq_domain_create_linear()
97113

98114
The linear reverse map maintains a fixed size table indexed by the
@@ -105,19 +121,13 @@ map are fixed time lookup for IRQ numbers, and irq_descs are only
105121
allocated for in-use IRQs. The disadvantage is that the table must be
106122
as large as the largest possible hwirq number.
107123

108-
irq_domain_add_linear() and irq_domain_create_linear() are functionally
109-
equivalent, except for the first argument is different - the former
110-
accepts an Open Firmware specific 'struct device_node', while the latter
111-
accepts a more general abstraction 'struct fwnode_handle'.
112-
113-
The majority of drivers should use the linear map.
124+
The majority of drivers should use the Linear map.
114125

115126
Tree
116127
----
117128

118129
::
119130

120-
irq_domain_add_tree()
121131
irq_domain_create_tree()
122132

123133
The irq_domain maintains a radix tree map from hwirq numbers to Linux
@@ -129,19 +139,14 @@ since it doesn't need to allocate a table as large as the largest
129139
hwirq number. The disadvantage is that hwirq to IRQ number lookup is
130140
dependent on how many entries are in the table.
131141

132-
irq_domain_add_tree() and irq_domain_create_tree() are functionally
133-
equivalent, except for the first argument is different - the former
134-
accepts an Open Firmware specific 'struct device_node', while the latter
135-
accepts a more general abstraction 'struct fwnode_handle'.
136-
137142
Very few drivers should need this mapping.
138143

139144
No Map
140145
------
141146

142147
::
143148

144-
irq_domain_add_nomap()
149+
irq_domain_create_nomap()
145150

146151
The No Map mapping is to be used when the hwirq number is
147152
programmable in the hardware. In this case it is best to program the
@@ -159,8 +164,6 @@ Legacy
159164

160165
::
161166

162-
irq_domain_add_simple()
163-
irq_domain_add_legacy()
164167
irq_domain_create_simple()
165168
irq_domain_create_legacy()
166169

@@ -189,13 +192,13 @@ supported. For example, ISA controllers would use the legacy map for
189192
mapping Linux IRQs 0-15 so that existing ISA drivers get the correct IRQ
190193
numbers.
191194

192-
Most users of legacy mappings should use irq_domain_add_simple() or
193-
irq_domain_create_simple() which will use a legacy domain only if an IRQ range
194-
is supplied by the system and will otherwise use a linear domain mapping.
195-
The semantics of this call are such that if an IRQ range is specified then
196-
descriptors will be allocated on-the-fly for it, and if no range is
197-
specified it will fall through to irq_domain_add_linear() or
198-
irq_domain_create_linear() which means *no* irq descriptors will be allocated.
195+
Most users of legacy mappings should use irq_domain_create_simple()
196+
which will use a legacy domain only if an IRQ range is supplied by the
197+
system and will otherwise use a linear domain mapping. The semantics of
198+
this call are such that if an IRQ range is specified then descriptors
199+
will be allocated on-the-fly for it, and if no range is specified it
200+
will fall through to irq_domain_create_linear() which means *no* irq
201+
descriptors will be allocated.
199202

200203
A typical use case for simple domains is where an irqchip provider
201204
is supporting both dynamic and static IRQ assignments.
@@ -206,13 +209,7 @@ that the driver using the simple domain call irq_create_mapping()
206209
before any irq_find_mapping() since the latter will actually work
207210
for the static IRQ assignment case.
208211

209-
irq_domain_add_simple() and irq_domain_create_simple() as well as
210-
irq_domain_add_legacy() and irq_domain_create_legacy() are functionally
211-
equivalent, except for the first argument is different - the former
212-
accepts an Open Firmware specific 'struct device_node', while the latter
213-
accepts a more general abstraction 'struct fwnode_handle'.
214-
215-
Hierarchy IRQ domain
212+
Hierarchy IRQ Domain
216213
--------------------
217214

218215
On some architectures, there may be multiple interrupt controllers
@@ -253,20 +250,40 @@ There are four major interfaces to use hierarchy irq_domain:
253250
4) irq_domain_deactivate_irq(): deactivate interrupt controller hardware
254251
to stop delivering the interrupt.
255252

256-
Following changes are needed to support hierarchy irq_domain:
253+
The following is needed to support hierarchy irq_domain:
257254

258-
1) a new field 'parent' is added to struct irq_domain; it's used to
255+
1) The :c:member:`parent` field in struct irq_domain is used to
259256
maintain irq_domain hierarchy information.
260-
2) a new field 'parent_data' is added to struct irq_data; it's used to
261-
build hierarchy irq_data to match hierarchy irq_domains. The irq_data
262-
is used to store irq_domain pointer and hardware irq number.
263-
3) new callbacks are added to struct irq_domain_ops to support hierarchy
264-
irq_domain operations.
265-
266-
With support of hierarchy irq_domain and hierarchy irq_data ready, an
267-
irq_domain structure is built for each interrupt controller, and an
257+
2) The :c:member:`parent_data` field in struct irq_data is used to
258+
build hierarchy irq_data to match hierarchy irq_domains. The
259+
irq_data is used to store irq_domain pointer and hardware irq
260+
number.
261+
3) The :c:member:`alloc()`, :c:member:`free()`, and other callbacks in
262+
struct irq_domain_ops to support hierarchy irq_domain operations.
263+
264+
With the support of hierarchy irq_domain and hierarchy irq_data ready,
265+
an irq_domain structure is built for each interrupt controller, and an
268266
irq_data structure is allocated for each irq_domain associated with an
269-
IRQ. Now we could go one step further to support stacked(hierarchy)
267+
IRQ.
268+
269+
For an interrupt controller driver to support hierarchy irq_domain, it
270+
needs to:
271+
272+
1) Implement irq_domain_ops.alloc() and irq_domain_ops.free()
273+
2) Optionally, implement irq_domain_ops.activate() and
274+
irq_domain_ops.deactivate().
275+
3) Optionally, implement an irq_chip to manage the interrupt controller
276+
hardware.
277+
4) There is no need to implement irq_domain_ops.map() and
278+
irq_domain_ops.unmap(). They are unused with hierarchy irq_domain.
279+
280+
Note the hierarchy irq_domain is in no way x86-specific, and is
281+
heavily used to support other architectures, such as ARM, ARM64 etc.
282+
283+
Stacked irq_chip
284+
~~~~~~~~~~~~~~~~
285+
286+
Now, we could go one step further to support stacked (hierarchy)
270287
irq_chip. That is, an irq_chip is associated with each irq_data along
271288
the hierarchy. A child irq_chip may implement a required action by
272289
itself or by cooperating with its parent irq_chip.
@@ -276,22 +293,28 @@ with the hardware managed by itself and may ask for services from its
276293
parent irq_chip when needed. So we could achieve a much cleaner
277294
software architecture.
278295

279-
For an interrupt controller driver to support hierarchy irq_domain, it
280-
needs to:
281-
282-
1) Implement irq_domain_ops.alloc and irq_domain_ops.free
283-
2) Optionally implement irq_domain_ops.activate and
284-
irq_domain_ops.deactivate.
285-
3) Optionally implement an irq_chip to manage the interrupt controller
286-
hardware.
287-
4) No need to implement irq_domain_ops.map and irq_domain_ops.unmap,
288-
they are unused with hierarchy irq_domain.
289-
290-
Hierarchy irq_domain is in no way x86 specific, and is heavily used to
291-
support other architectures, such as ARM, ARM64 etc.
292-
293296
Debugging
294297
=========
295298

296299
Most of the internals of the IRQ subsystem are exposed in debugfs by
297300
turning CONFIG_GENERIC_IRQ_DEBUGFS on.
301+
302+
Structures and Public Functions Provided
303+
========================================
304+
305+
This chapter contains the autogenerated documentation of the structures
306+
and exported kernel API functions which are used for IRQ domains.
307+
308+
.. kernel-doc:: include/linux/irqdomain.h
309+
310+
.. kernel-doc:: kernel/irq/irqdomain.c
311+
:export:
312+
313+
Internal Functions Provided
314+
===========================
315+
316+
This chapter contains the autogenerated documentation of the internal
317+
functions.
318+
319+
.. kernel-doc:: kernel/irq/irqdomain.c
320+
:internal:

0 commit comments

Comments
 (0)