History

Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull irq updates from Thomas Gleixner: "The irq department provides: - Support for MSI to wire bridges and a first user of it - More ACPI support for ARM/GIC - A new TS-4800 interrupt controller driver - RCU based free of interrupt descriptors to support the upcoming Intel VMD technology without introducing a locking nightmare - The usual pile of fixes and updates to drivers and core code" * 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (41 commits) irqchip/omap-intc: Add support for spurious irq handling irqchip/zevio: Use irq_data_get_chip_type() helper irqchip/omap-intc: Remove duplicate setup for IRQ chip type handler irqchip/ts4800: Add TS-4800 interrupt controller irqchip/ts4800: Add documentation for TS-4800 interrupt controller irq/platform-MSI: Increase the maximum MSIs the MSI framework can support irqchip/gicv2m: Miscellaneous fixes for v2m resources and SPI ranges irqchip/bcm2836: Make code more readable irqchip/bcm2836: Tolerate IRQs while no flag is set in ISR irqchip/bcm2836: Add SMP support for the 2836 irqchip/bcm2836: Fix initialization of the LOCAL_IRQ_CNT timers irqchip/gic-v2m: acpi: Introducing GICv2m ACPI support irqchip/gic-v2m: Refactor to prepare for ACPI support irqdomain: Introduce is_fwnode_irqchip helper acpi: pci: Setup MSI domain for ACPI based pci devices genirq/msi: Export functions to allow MSI domains in modules irqchip/mbigen: Implement the mbigen irq chip operation functions irqchip/mbigen: Create irq domain for each mbigen device irqchip/mgigen: Add platform device driver for mbigen device dt-bindings: Documents the mbigen bindings ...

Linus Torvalds committed 10 years ago

Commit 3d116a62 parents b4cee21 d3b421c32 files · +1350 −209Browse files

Unified · Split

32 files
  1. Documentation/devicetree/bindings/interrupt-controller/allwinner,sunxi-nmi.txt +1 −1
  2. Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt +1 −0
  3. Documentation/devicetree/bindings/interrupt-controller/hisilicon,mbigen-v2.txt +74 −0
  4. Documentation/devicetree/bindings/interrupt-controller/technologic,ts4800.txt +16 −0
  5. drivers/base/platform-msi.c +201 −55
  6. drivers/irqchip/Kconfig +19 −0
  7. drivers/irqchip/Makefile +3 −0
  8. drivers/irqchip/irq-bcm2836.c +51 −4
  9. drivers/irqchip/irq-gic-realview.c +43 −0
  10. drivers/irqchip/irq-gic-v2m.c +142 −23
  11. drivers/irqchip/irq-gic.c +31 −33
  12. drivers/irqchip/irq-mbigen.c +297 −0
  13. drivers/irqchip/irq-omap-intc.c +26 −2
  14. drivers/irqchip/irq-renesas-intc-irqpin.c +51 −45
  15. drivers/irqchip/irq-sunxi-nmi.c +13 −0
  16. drivers/irqchip/irq-ts4800.c +163 −0
  17. drivers/irqchip/irq-zevio.c +1 −2
  18. drivers/pci/msi.c +4 −0
  19. drivers/pci/pci-acpi.c +42 −0
  20. drivers/pci/probe.c +2 −0
  21. include/linux/interrupt.h +1 −0
  22. include/linux/irqchip/arm-gic.h +12 −1
  23. include/linux/irqdesc.h +6 −0
  24. include/linux/irqdomain.h +13 −0
  25. include/linux/msi.h +18 −0
  26. include/linux/pci.h +10 −0
  27. include/linux/platform_data/irq-renesas-intc-irqpin.h +0 −29
  28. kernel/irq/chip.c +5 −4
  29. kernel/irq/irqdesc.c +16 −3
  30. kernel/irq/irqdomain.c +8 −4
  31. kernel/irq/manage.c +25 −0
  32. kernel/irq/msi.c +55 −3
Documentation/devicetree/bindings/interrupt-controller/allwinner,sunxi-nmi.txtrenamed from Documentation/devicetree/bindings/interrupt-controller/allwinner,sun67i-sc-nmi.txt+1−1
@@ -4,7 +4,7 @@ Allwinner Sunxi NMI Controller · 3 unmodified lines
44 Required properties:
55
66 - compatible : should be "allwinner,sun7i-a20-sc-nmi" or
7− "allwinner,sun6i-a31-sc-nmi"
7+ "allwinner,sun6i-a31-sc-nmi" or "allwinner,sun9i-a80-nmi"
88 - reg : Specifies base physical address and size of the registers.
99 - interrupt-controller : Identifies the node as an interrupt controller
1010 - #interrupt-cells : Specifies the number of cells needed to encode an
Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt+1−0
@@ -18,6 +18,7 @@ Main node required properties: · 17 unmodified lines
1818 "arm,cortex-a9-gic"
1919 "arm,gic-400"
2020 "arm,pl390"
21+ "arm,tc11mp-gic"
2122 "brcm,brahma-b15-gic"
2223 "qcom,msm-8660-qgic"
2324 "qcom,msm-qgic2"
Documentation/devicetree/bindings/interrupt-controller/hisilicon,mbigen-v2.txt+74−0
@@ -0,0 +1,74 @@
1+Hisilicon mbigen device tree bindings.
2+=======================================
3+
4+Mbigen means: message based interrupt generator.
5+
6+MBI is kind of msi interrupt only used on Non-PCI devices.
7+
8+To reduce the wired interrupt number connected to GIC,
9+Hisilicon designed mbigen to collect and generate interrupt.
10+
11+
12+Non-pci devices can connect to mbigen and generate the
13+interrupt by writing ITS register.
14+
15+The mbigen chip and devices connect to mbigen have the following properties:
16+
17+Mbigen main node required properties:
18+-------------------------------------------
19+- compatible: Should be "hisilicon,mbigen-v2"
20+
21+- reg: Specifies the base physical address and size of the Mbigen
22+ registers.
23+
24+- interrupt controller: Identifies the node as an interrupt controller
25+
26+- msi-parent: Specifies the MSI controller this mbigen use.
27+ For more detail information,please refer to the generic msi-parent binding in
28+ Documentation/devicetree/bindings/interrupt-controller/msi.txt.
29+
30+- num-pins: the total number of pins implemented in this Mbigen
31+ instance.
32+
33+- #interrupt-cells : Specifies the number of cells needed to encode an
34+ interrupt source. The value must be 2.
35+
36+ The 1st cell is hardware pin number of the interrupt.This number is local to
37+ each mbigen chip and in the range from 0 to the maximum interrupts number
38+ of the mbigen.
39+
40+ The 2nd cell is the interrupt trigger type.
41+ The value of this cell should be:
42+ 1: rising edge triggered
43+ or
44+ 4: high level triggered
45+
46+Examples:
47+
48+ mbigen_device_gmac:intc {
49+ compatible = "hisilicon,mbigen-v2";
50+ reg = <0x0 0xc0080000 0x0 0x10000>;
51+ interrupt-controller;
52+ msi-parent = <&its_dsa 0x40b1c>;
53+ num-pins = <9>;
54+ #interrupt-cells = <2>;
55+ };
56+
57+Devices connect to mbigen required properties:
58+----------------------------------------------------
59+-interrupt-parent: Specifies the mbigen device node which device connected.
60+
61+-interrupts:Specifies the interrupt source.
62+ For the specific information of each cell in this property,please refer to
63+ the "interrupt-cells" description mentioned above.
64+
65+Examples:
66+ gmac0: ethernet@c2080000 {
67+ #address-cells = <1>;
68+ #size-cells = <0>;
69+ reg = <0 0xc2080000 0 0x20000>,
70+ <0 0xc0000000 0 0x1000>;
71+ interrupt-parent = <&mbigen_device_gmac>;
72+ interrupts = <656 1>,
73+ <657 1>;
74+ };
Documentation/devicetree/bindings/interrupt-controller/technologic,ts4800.txt+16−0
@@ -0,0 +1,16 @@
1+TS-4800 FPGA interrupt controller
2+
3+TS-4800 FPGA has an internal interrupt controller. When one of the
4+interrupts is triggered, the SoC is notified, usually using a GPIO as
5+parent interrupt source.
6+
7+Required properties:
8+- compatible: should be "technologic,ts4800-irqc"
9+- interrupt-controller: identifies the node as an interrupt controller
10+- reg: physical base address of the controller and length of memory mapped
11+ region
12+- #interrupt-cells: specifies the number of cells needed to encode an interrupt
13+ source, should be 1.
14+- interrupt-parent: phandle to the parent interrupt controller this one is
15+ cascaded from
16+- interrupts: specifies the interrupt line in the interrupt-parent controller
drivers/base/platform-msi.c+201−55
@@ -24,13 +24,17 @@ · 23 unmodified lines
2424 #include <linux/msi.h>
2525 #include <linux/slab.h>
2626
27−#define DEV_ID_SHIFT 24
27+#define DEV_ID_SHIFT 21
28+#define MAX_DEV_MSIS (1 << (32 - DEV_ID_SHIFT))
2829
2930 /*
3031 * Internal data structure containing a (made up, but unique) devid
3132 * and the callback to write the MSI message.
3233 */
3334 struct platform_msi_priv_data {
35+ struct device *dev;
36+ void *host_data;
37+ msi_alloc_info_t arg;
3438 irq_write_msi_msg_t write_msg;
3539 int devid;
3640 };
@@ -110,39 +114,49 @@ static void platform_msi_update_chip_ops(struct msi_domain_info *info) · 73 unmodified lines
110114 chip->irq_write_msi_msg = platform_msi_write_msg;
111115 }
112116
113−static void platform_msi_free_descs(struct device *dev)
117+static void platform_msi_free_descs(struct device *dev, int base, int nvec)
114118 {
115119 struct msi_desc *desc, *tmp;
116120
117121 list_for_each_entry_safe(desc, tmp, dev_to_msi_list(dev), list) {
118− list_del(&desc->list);
119− free_msi_entry(desc);
122+ if (desc->platform.msi_index >= base &&
123+ desc->platform.msi_index < (base + nvec)) {
124+ list_del(&desc->list);
125+ free_msi_entry(desc);
126+ }
120127 }
121128 }
122129
123−static int platform_msi_alloc_descs(struct device *dev, int nvec,
124− struct platform_msi_priv_data *data)
130+static int platform_msi_alloc_descs_with_irq(struct device *dev, int virq,
131+ int nvec,
132+ struct platform_msi_priv_data *data)
125133
126134 {
127− int i;
135+ struct msi_desc *desc;
136+ int i, base = 0;
128137
129− for (i = 0; i < nvec; i++) {
130− struct msi_desc *desc;
138+ if (!list_empty(dev_to_msi_list(dev))) {
139+ desc = list_last_entry(dev_to_msi_list(dev),
140+ struct msi_desc, list);
141+ base = desc->platform.msi_index + 1;
142+ }
131143
144+ for (i = 0; i < nvec; i++) {
132145 desc = alloc_msi_entry(dev);
133146 if (!desc)
134147 break;
135148
136149 desc->platform.msi_priv_data = data;
137− desc->platform.msi_index = i;
150+ desc->platform.msi_index = base + i;
138151 desc->nvec_used = 1;
152+ desc->irq = virq ? virq + i : 0;
139153
140154 list_add_tail(&desc->list, dev_to_msi_list(dev));
141155 }
142156
143157 if (i != nvec) {
144158 /* Clean up the mess */
145− platform_msi_free_descs(dev);
159+ platform_msi_free_descs(dev, base, nvec);
146160
147161 return -ENOMEM;
148162 }
@@ -150,6 +164,13 @@ static int platform_msi_alloc_descs(struct device *dev, int nvec, · 1 unmodified line
150164 return 0;
151165 }
152166
167+static int platform_msi_alloc_descs(struct device *dev, int nvec,
168+ struct platform_msi_priv_data *data)
169+
170+{
171+ return platform_msi_alloc_descs_with_irq(dev, 0, nvec, data);
172+}
173+
153174 /**
154175 * platform_msi_create_irq_domain - Create a platform MSI interrupt domain
155176 * @fwnode: Optional fwnode of the interrupt controller
@@ -180,56 +201,75 @@ struct irq_domain *platform_msi_create_irq_domain(struct fwnode_handle *fwnode, · 24 unmodified lines
180201 return domain;
181202 }
182203
183−/**
184− * platform_msi_domain_alloc_irqs - Allocate MSI interrupts for @dev
185− * @dev: The device for which to allocate interrupts
186− * @nvec: The number of interrupts to allocate
187− * @write_msi_msg: Callback to write an interrupt message for @dev
188− *
189− * Returns:
190− * Zero for success, or an error code in case of failure
191− */
192−int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
193− irq_write_msi_msg_t write_msi_msg)
204+static struct platform_msi_priv_data *
205+platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec,
206+ irq_write_msi_msg_t write_msi_msg)
194207 {
195− struct platform_msi_priv_data *priv_data;
196− int err;
197−
208+ struct platform_msi_priv_data *datap;
198209 /*
199210 * Limit the number of interrupts to 256 per device. Should we
200211 * need to bump this up, DEV_ID_SHIFT should be adjusted
201212 * accordingly (which would impact the max number of MSI
202213 * capable devices).
203214 */
204− if (!dev->msi_domain || !write_msi_msg || !nvec ||
205− nvec > (1 << (32 - DEV_ID_SHIFT)))
206− return -EINVAL;
215+ if (!dev->msi_domain || !write_msi_msg || !nvec || nvec > MAX_DEV_MSIS)
216+ return ERR_PTR(-EINVAL);
207217
208218 if (dev->msi_domain->bus_token != DOMAIN_BUS_PLATFORM_MSI) {
209219 dev_err(dev, "Incompatible msi_domain, giving up\n");
210− return -EINVAL;
220+ return ERR_PTR(-EINVAL);
211221 }
212222
213223 /* Already had a helping of MSI? Greed... */
214224 if (!list_empty(dev_to_msi_list(dev)))
215− return -EBUSY;
225+ return ERR_PTR(-EBUSY);
226+
227+ datap = kzalloc(sizeof(*datap), GFP_KERNEL);
228+ if (!datap)
229+ return ERR_PTR(-ENOMEM);
230+
231+ datap->devid = ida_simple_get(&platform_msi_devid_ida,
232+ 0, 1 << DEV_ID_SHIFT, GFP_KERNEL);
233+ if (datap->devid < 0) {
234+ int err = datap->devid;
235+ kfree(datap);
236+ return ERR_PTR(err);
237+ }
216238
217− priv_data = kzalloc(sizeof(*priv_data), GFP_KERNEL);
218− if (!priv_data)
219− return -ENOMEM;
239+ datap->write_msg = write_msi_msg;
240+ datap->dev = dev;
220241
221− priv_data->devid = ida_simple_get(&platform_msi_devid_ida,
222− 0, 1 << DEV_ID_SHIFT, GFP_KERNEL);
223− if (priv_data->devid < 0) {
224− err = priv_data->devid;
225− goto out_free_data;
226− }
242+ return datap;
243+}
244+
245+static void platform_msi_free_priv_data(struct platform_msi_priv_data *data)
246+{
247+ ida_simple_remove(&platform_msi_devid_ida, data->devid);
248+ kfree(data);
249+}
250+
251+/**
252+ * platform_msi_domain_alloc_irqs - Allocate MSI interrupts for @dev
253+ * @dev: The device for which to allocate interrupts
254+ * @nvec: The number of interrupts to allocate
255+ * @write_msi_msg: Callback to write an interrupt message for @dev
256+ *
257+ * Returns:
258+ * Zero for success, or an error code in case of failure
259+ */
260+int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
261+ irq_write_msi_msg_t write_msi_msg)
262+{
263+ struct platform_msi_priv_data *priv_data;
264+ int err;
227265
228− priv_data->write_msg = write_msi_msg;
266+ priv_data = platform_msi_alloc_priv_data(dev, nvec, write_msi_msg);
267+ if (IS_ERR(priv_data))
268+ return PTR_ERR(priv_data);
229269
230270 err = platform_msi_alloc_descs(dev, nvec, priv_data);
231271 if (err)
232− goto out_free_id;
272+ goto out_free_priv_data;
233273
234274 err = msi_domain_alloc_irqs(dev->msi_domain, dev, nvec);
235275 if (err)
@@ -238,11 +278,9 @@ int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec, · 2 unmodified lines
238278 return 0;
239279
240280 out_free_desc:
241− platform_msi_free_descs(dev);
242−out_free_id:
243− ida_simple_remove(&platform_msi_devid_ida, priv_data->devid);
244−out_free_data:
245− kfree(priv_data);
281+ platform_msi_free_descs(dev, 0, nvec);
282+out_free_priv_data:
283+ platform_msi_free_priv_data(priv_data);
246284
247285 return err;
248286 }
@@ -253,18 +291,126 @@ out_free_data: · 4 unmodified lines
253291 */
254292 void platform_msi_domain_free_irqs(struct device *dev)
255293 {
256− struct msi_desc *desc;
294+ if (!list_empty(dev_to_msi_list(dev))) {
295+ struct msi_desc *desc;
296+
297+ desc = first_msi_entry(dev);
298+ platform_msi_free_priv_data(desc->platform.msi_priv_data);
299+ }
300+
301+ msi_domain_free_irqs(dev->msi_domain, dev);
302+ platform_msi_free_descs(dev, 0, MAX_DEV_MSIS);
303+}
304+
305+/**
306+ * platform_msi_get_host_data - Query the private data associated with
307+ * a platform-msi domain
308+ * @domain: The platform-msi domain
309+ *
310+ * Returns the private data provided when calling
311+ * platform_msi_create_device_domain.
312+ */
313+void *platform_msi_get_host_data(struct irq_domain *domain)
314+{
315+ struct platform_msi_priv_data *data = domain->host_data;
316+ return data->host_data;
317+}
318+
319+/**
320+ * platform_msi_create_device_domain - Create a platform-msi domain
321+ *
322+ * @dev: The device generating the MSIs
323+ * @nvec: The number of MSIs that need to be allocated
324+ * @write_msi_msg: Callback to write an interrupt message for @dev
325+ * @ops: The hierarchy domain operations to use
326+ * @host_data: Private data associated to this domain
327+ *
328+ * Returns an irqdomain for @nvec interrupts
329+ */
330+struct irq_domain *
331+platform_msi_create_device_domain(struct device *dev,
332+ unsigned int nvec,
333+ irq_write_msi_msg_t write_msi_msg,
334+ const struct irq_domain_ops *ops,
335+ void *host_data)
336+{
337+ struct platform_msi_priv_data *data;
338+ struct irq_domain *domain;
339+ int err;
340+
341+ data = platform_msi_alloc_priv_data(dev, nvec, write_msi_msg);
342+ if (IS_ERR(data))
343+ return NULL;
344+
345+ data->host_data = host_data;
346+ domain = irq_domain_create_hierarchy(dev->msi_domain, 0, nvec,
347+ of_node_to_fwnode(dev->of_node),
348+ ops, data);
349+ if (!domain)
350+ goto free_priv;
257351
258− desc = first_msi_entry(dev);
259− if (desc) {
260− struct platform_msi_priv_data *data;
352+ err = msi_domain_prepare_irqs(domain->parent, dev, nvec, &data->arg);
353+ if (err)
354+ goto free_domain;
355+
356+ return domain;
261357
262− data = desc->platform.msi_priv_data;
358+free_domain:
359+ irq_domain_remove(domain);
360+free_priv:
361+ platform_msi_free_priv_data(data);
362+ return NULL;
363+}
364+
365+/**
366+ * platform_msi_domain_free - Free interrupts associated with a platform-msi
367+ * domain
368+ *
369+ * @domain: The platform-msi domain
370+ * @virq: The base irq from which to perform the free operation
371+ * @nvec: How many interrupts to free from @virq
372+ */
373+void platform_msi_domain_free(struct irq_domain *domain, unsigned int virq,
374+ unsigned int nvec)
375+{
376+ struct platform_msi_priv_data *data = domain->host_data;
377+ struct msi_desc *desc;
378+ for_each_msi_entry(desc, data->dev) {
379+ if (WARN_ON(!desc->irq || desc->nvec_used != 1))
380+ return;
381+ if (!(desc->irq >= virq && desc->irq < (virq + nvec)))
382+ continue;
263383
264− ida_simple_remove(&platform_msi_devid_ida, data->devid);
265− kfree(data);
384+ irq_domain_free_irqs_common(domain, desc->irq, 1);
266385 }
386+}
267387
268− msi_domain_free_irqs(dev->msi_domain, dev);
269− platform_msi_free_descs(dev);
388+/**
389+ * platform_msi_domain_alloc - Allocate interrupts associated with
390+ * a platform-msi domain
391+ *
392+ * @domain: The platform-msi domain
393+ * @virq: The base irq from which to perform the allocate operation
394+ * @nvec: How many interrupts to free from @virq
395+ *
396+ * Return 0 on success, or an error code on failure. Must be called
397+ * with irq_domain_mutex held (which can only be done as part of a
398+ * top-level interrupt allocation).
399+ */
400+int platform_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
401+ unsigned int nr_irqs)
402+{
403+ struct platform_msi_priv_data *data = domain->host_data;
404+ int err;
405+
406+ err = platform_msi_alloc_descs_with_irq(data->dev, virq, nr_irqs, data);
407+ if (err)
408+ return err;
409+
410+ err = msi_domain_populate_irqs(domain->parent, data->dev,
411+ virq, nr_irqs, &data->arg);
412+ if (err)
413+ platform_msi_domain_free(domain, virq, nr_irqs);
414+
415+ return err;
270416 }
drivers/irqchip/Kconfig+19−0
@@ -8,6 +8,11 @@ config ARM_GIC · 7 unmodified lines
88 select IRQ_DOMAIN_HIERARCHY
99 select MULTI_IRQ_HANDLER
1010
11+config ARM_GIC_MAX_NR
12+ int
13+ default 2 if ARCH_REALVIEW
14+ default 1
15+
1116 config ARM_GIC_V2M
1217 bool
1318 depends on ARM_GIC
@@ -27,6 +32,14 @@ config ARM_GIC_V3_ITS · 13 unmodified lines
2732 bool
2833 select PCI_MSI_IRQ_DOMAIN
2934
35+config HISILICON_IRQ_MBIGEN
36+ bool "Support mbigen interrupt controller"
37+ default n
38+ depends on ARM_GIC_V3 && ARM_GIC_V3_ITS && GENERIC_MSI_IRQ_DOMAIN
39+ help
40+ Enable the mbigen interrupt controller used on
41+ Hisilicon platform.
42+
3043 config ARM_NVIC
3144 bool
3245 select IRQ_DOMAIN
@@ -138,6 +151,12 @@ config TB10X_IRQC · 105 unmodified lines
138151 select IRQ_DOMAIN
139152 select GENERIC_IRQ_CHIP
140153
154+config TS4800_IRQ
155+ tristate "TS-4800 IRQ controller"
156+ select IRQ_DOMAIN
157+ help
158+ Support for the TS-4800 FPGA IRQ controller
159+
141160 config VERSATILE_FPGA_IRQ
142161 bool
143162 select IRQ_DOMAIN
drivers/irqchip/Makefile+3−0
@@ -21,9 +21,11 @@ obj-$(CONFIG_ARCH_SUNXI) += irq-sun4i.o · 20 unmodified lines
2121 obj-$(CONFIG_ARCH_SUNXI) += irq-sunxi-nmi.o
2222 obj-$(CONFIG_ARCH_SPEAR3XX) += spear-shirq.o
2323 obj-$(CONFIG_ARM_GIC) += irq-gic.o irq-gic-common.o
24+obj-$(CONFIG_REALVIEW_DT) += irq-gic-realview.o
2425 obj-$(CONFIG_ARM_GIC_V2M) += irq-gic-v2m.o
2526 obj-$(CONFIG_ARM_GIC_V3) += irq-gic-v3.o irq-gic-common.o
2627 obj-$(CONFIG_ARM_GIC_V3_ITS) += irq-gic-v3-its.o irq-gic-v3-its-pci-msi.o irq-gic-v3-its-platform-msi.o
28+obj-$(CONFIG_HISILICON_IRQ_MBIGEN) += irq-mbigen.o
2729 obj-$(CONFIG_ARM_NVIC) += irq-nvic.o
2830 obj-$(CONFIG_ARM_VIC) += irq-vic.o
2931 obj-$(CONFIG_ATMEL_AIC_IRQ) += irq-atmel-aic-common.o irq-atmel-aic.o
@@ -39,6 +41,7 @@ obj-$(CONFIG_ARCH_NSPIRE) += irq-zevio.o · 9 unmodified lines
3941 obj-$(CONFIG_ARCH_VT8500) += irq-vt8500.o
4042 obj-$(CONFIG_ST_IRQCHIP) += irq-st.o
4143 obj-$(CONFIG_TB10X_IRQC) += irq-tb10x.o
44+obj-$(CONFIG_TS4800_IRQ) += irq-ts4800.o
4245 obj-$(CONFIG_XTENSA) += irq-xtensa-pic.o
4346 obj-$(CONFIG_XTENSA_MX) += irq-xtensa-mx.o
4447 obj-$(CONFIG_IRQ_CROSSBAR) += irq-crossbar.o
drivers/irqchip/irq-bcm2836.c+51−4
@@ -21,6 +21,9 @@ · 20 unmodified lines
2121 #include <linux/irqdomain.h>
2222 #include <asm/exception.h>
2323
24+#define LOCAL_CONTROL 0x000
25+#define LOCAL_PRESCALER 0x008
26+
2427 /*
2528 * The low 2 bits identify the CPU that the GPU IRQ goes to, and the
2629 * next 2 bits identify the CPU that the GPU FIQ goes to.
@@ -50,14 +53,16 @@ · 23 unmodified lines
5053 /* Same status bits as above, but for FIQ. */
5154 #define LOCAL_FIQ_PENDING0 0x070
5255 /*
53− * Mailbox0 write-to-set bits. There are 16 mailboxes, 4 per CPU, and
56+ * Mailbox write-to-set bits. There are 16 mailboxes, 4 per CPU, and
5457 * these bits are organized by mailbox number and then CPU number. We
5558 * use mailbox 0 for IPIs. The mailbox's interrupt is raised while
5659 * any bit is set.
5760 */
5861 #define LOCAL_MAILBOX0_SET0 0x080
59−/* Mailbox0 write-to-clear bits. */
62+#define LOCAL_MAILBOX3_SET0 0x08c
63+/* Mailbox write-to-clear bits. */
6064 #define LOCAL_MAILBOX0_CLR0 0x0c0
65+#define LOCAL_MAILBOX3_CLR0 0x0cc
6166
6267 #define LOCAL_IRQ_CNTPSIRQ 0
6368 #define LOCAL_IRQ_CNTPNSIRQ 1
@@ -162,7 +167,7 @@ __exception_irq_entry bcm2836_arm_irqchip_handle_irq(struct pt_regs *regs) · 98 unmodified lines
162167 u32 stat;
163168
164169 stat = readl_relaxed(intc.base + LOCAL_IRQ_PENDING0 + 4 * cpu);
165− if (stat & 0x10) {
170+ if (stat & BIT(LOCAL_IRQ_MAILBOX0)) {
166171 #ifdef CONFIG_SMP
167172 void __iomem *mailbox0 = (intc.base +
168173 LOCAL_MAILBOX0_CLR0 + 16 * cpu);
@@ -172,7 +177,7 @@ __exception_irq_entry bcm2836_arm_irqchip_handle_irq(struct pt_regs *regs) · 3 unmodified lines
172177 writel(1 << ipi, mailbox0);
173178 handle_IPI(ipi, regs);
174179 #endif
175− } else {
180+ } else if (stat) {
176181 u32 hwirq = ffs(stat) - 1;
177182
178183 handle_IRQ(irq_linear_revmap(intc.domain, hwirq), regs);
@@ -217,6 +222,24 @@ static struct notifier_block bcm2836_arm_irqchip_cpu_notifier = { · 38 unmodified lines
217222 .notifier_call = bcm2836_arm_irqchip_cpu_notify,
218223 .priority = 100,
219224 };
225+
226+int __init bcm2836_smp_boot_secondary(unsigned int cpu,
227+ struct task_struct *idle)
228+{
229+ unsigned long secondary_startup_phys =
230+ (unsigned long)virt_to_phys((void *)secondary_startup);
231+
232+ dsb();
233+ writel(secondary_startup_phys,
234+ intc.base + LOCAL_MAILBOX3_SET0 + 16 * cpu);
235+
236+ return 0;
237+}
238+
239+static const struct smp_operations bcm2836_smp_ops __initconst = {
240+ .smp_boot_secondary = bcm2836_smp_boot_secondary,
241+};
242+
220243 #endif
221244
222245 static const struct irq_domain_ops bcm2836_arm_irqchip_intc_ops = {
@@ -234,9 +257,31 @@ bcm2836_arm_irqchip_smp_init(void) · 11 unmodified lines
234257 register_cpu_notifier(&bcm2836_arm_irqchip_cpu_notifier);
235258
236259 set_smp_cross_call(bcm2836_arm_irqchip_send_ipi);
260+ smp_set_ops(&bcm2836_smp_ops);
237261 #endif
238262 }
239263
264+/*
265+ * The LOCAL_IRQ_CNT* timer firings are based off of the external
266+ * oscillator with some scaling. The firmware sets up CNTFRQ to
267+ * report 19.2Mhz, but doesn't set up the scaling registers.
268+ */
269+static void bcm2835_init_local_timer_frequency(void)
270+{
271+ /*
272+ * Set the timer to source from the 19.2Mhz crystal clock (bit
273+ * 8 unset), and only increment by 1 instead of 2 (bit 9
274+ * unset).
275+ */
276+ writel(0, intc.base + LOCAL_CONTROL);
277+
278+ /*
279+ * Set the timer prescaler to 1:1 (timer freq = input freq *
280+ * 2**31 / prescaler)
281+ */
282+ writel(0x80000000, intc.base + LOCAL_PRESCALER);
283+}
284+
240285 static int __init bcm2836_arm_irqchip_l1_intc_of_init(struct device_node *node,
241286 struct device_node *parent)
242287 {
@@ -246,6 +291,8 @@ static int __init bcm2836_arm_irqchip_l1_intc_of_init(struct device_node *node, · 3 unmodified lines
246291 node->full_name);
247292 }
248293
294+ bcm2835_init_local_timer_frequency();
295+
249296 intc.domain = irq_domain_add_linear(node, LAST_IRQ + 1,
250297 &bcm2836_arm_irqchip_intc_ops,
251298 NULL);
drivers/irqchip/irq-gic-realview.c+43−0
@@ -0,0 +1,43 @@
1+/*
2+ * Special GIC quirks for the ARM RealView
3+ * Copyright (C) 2015 Linus Walleij
4+ */
5+#include <linux/of.h>
6+#include <linux/regmap.h>
7+#include <linux/mfd/syscon.h>
8+#include <linux/bitops.h>
9+#include <linux/irqchip.h>
10+#include <linux/irqchip/arm-gic.h>
11+
12+#define REALVIEW_SYS_LOCK_OFFSET 0x20
13+#define REALVIEW_PB11MP_SYS_PLD_CTRL1 0x74
14+#define VERSATILE_LOCK_VAL 0xA05F
15+#define PLD_INTMODE_MASK BIT(22)|BIT(23)|BIT(24)
16+#define PLD_INTMODE_LEGACY 0x0
17+#define PLD_INTMODE_NEW_DCC BIT(22)
18+#define PLD_INTMODE_NEW_NO_DCC BIT(23)
19+#define PLD_INTMODE_FIQ_ENABLE BIT(24)
20+
21+static int __init
22+realview_gic_of_init(struct device_node *node, struct device_node *parent)
23+{
24+ static struct regmap *map;
25+
26+ /* The PB11MPCore GIC needs to be configured in the syscon */
27+ map = syscon_regmap_lookup_by_compatible("arm,realview-pb11mp-syscon");
28+ if (!IS_ERR(map)) {
29+ /* new irq mode with no DCC */
30+ regmap_write(map, REALVIEW_SYS_LOCK_OFFSET,
31+ VERSATILE_LOCK_VAL);
32+ regmap_update_bits(map, REALVIEW_PB11MP_SYS_PLD_CTRL1,
33+ PLD_INTMODE_NEW_NO_DCC,
34+ PLD_INTMODE_MASK);
35+ regmap_write(map, REALVIEW_SYS_LOCK_OFFSET, 0x0000);
36+ pr_info("TC11MP GIC: set up interrupt controller to NEW mode, no DCC\n");
37+ } else {
38+ pr_err("TC11MP GIC setup: could not find syscon\n");
39+ return -ENXIO;
40+ }
41+ return gic_of_init(node, parent);
42+}
43+IRQCHIP_DECLARE(armtc11mp_gic, "arm,tc11mp-gic", realview_gic_of_init);
drivers/irqchip/irq-gic-v2m.c+142−23
@@ -15,9 +15,11 @@ · 14 unmodified lines
1515
1616 #define pr_fmt(fmt) "GICv2m: " fmt
1717
18+#include <linux/acpi.h>
1819 #include <linux/irq.h>
1920 #include <linux/irqdomain.h>
2021 #include <linux/kernel.h>
22+#include <linux/msi.h>
2123 #include <linux/of_address.h>
2224 #include <linux/of_pci.h>
2325 #include <linux/slab.h>
@@ -55,7 +57,7 @@ static DEFINE_SPINLOCK(v2m_lock); · 31 unmodified lines
5557
5658 struct v2m_data {
5759 struct list_head entry;
58− struct device_node *node;
60+ struct fwnode_handle *fwnode;
5961 struct resource res; /* GICv2m resource */
6062 void __iomem *base; /* GICv2m virt address */
6163 u32 spi_start; /* The SPI number that MSIs start */
@@ -138,6 +140,11 @@ static int gicv2m_irq_gic_domain_alloc(struct irq_domain *domain, · 76 unmodified lines
138140 fwspec.param[0] = 0;
139141 fwspec.param[1] = hwirq - 32;
140142 fwspec.param[2] = IRQ_TYPE_EDGE_RISING;
143+ } else if (is_fwnode_irqchip(domain->parent->fwnode)) {
144+ fwspec.fwnode = domain->parent->fwnode;
145+ fwspec.param_count = 2;
146+ fwspec.param[0] = hwirq;
147+ fwspec.param[1] = IRQ_TYPE_EDGE_RISING;
141148 } else {
142149 return -EINVAL;
143150 }
@@ -254,7 +261,9 @@ static void gicv2m_teardown(void) · 110 unmodified lines
254261 list_del(&v2m->entry);
255262 kfree(v2m->bm);
256263 iounmap(v2m->base);
257− of_node_put(v2m->node);
264+ of_node_put(to_of_node(v2m->fwnode));
265+ if (is_fwnode_irqchip(v2m->fwnode))
266+ irq_domain_free_fwnode(v2m->fwnode);
258267 kfree(v2m);
259268 }
260269 }
@@ -268,7 +277,7 @@ static int gicv2m_allocate_domains(struct irq_domain *parent) · 7 unmodified lines
268277 if (!v2m)
269278 return 0;
270279
271− inner_domain = irq_domain_create_tree(of_node_to_fwnode(v2m->node),
280+ inner_domain = irq_domain_create_tree(v2m->fwnode,
272281 &gicv2m_domain_ops, v2m);
273282 if (!inner_domain) {
274283 pr_err("Failed to create GICv2m domain\n");
@@ -277,10 +286,10 @@ static int gicv2m_allocate_domains(struct irq_domain *parent) · 2 unmodified lines
277286
278287 inner_domain->bus_token = DOMAIN_BUS_NEXUS;
279288 inner_domain->parent = parent;
280− pci_domain = pci_msi_create_irq_domain(of_node_to_fwnode(v2m->node),
289+ pci_domain = pci_msi_create_irq_domain(v2m->fwnode,
281290 &gicv2m_msi_domain_info,
282291 inner_domain);
283− plat_domain = platform_msi_create_irq_domain(of_node_to_fwnode(v2m->node),
292+ plat_domain = platform_msi_create_irq_domain(v2m->fwnode,
284293 &gicv2m_pmsi_domain_info,
285294 inner_domain);
286295 if (!pci_domain || !plat_domain) {
@@ -296,8 +305,9 @@ static int gicv2m_allocate_domains(struct irq_domain *parent) · 9 unmodified lines
296305 return 0;
297306 }
298307
299−static int __init gicv2m_init_one(struct device_node *node,
300− struct irq_domain *parent)
308+static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
309+ u32 spi_start, u32 nr_spis,
310+ struct resource *res)
301311 {
302312 int ret;
303313 struct v2m_data *v2m;
@@ -309,13 +319,9 @@ static int __init gicv2m_init_one(struct device_node *node, · 5 unmodified lines
309319 }
310320
311321 INIT_LIST_HEAD(&v2m->entry);
312− v2m->node = node;
322+ v2m->fwnode = fwnode;
313323
314− ret = of_address_to_resource(node, 0, &v2m->res);
315− if (ret) {
316− pr_err("Failed to allocate v2m resource.\n");
317− goto err_free_v2m;
318− }
324+ memcpy(&v2m->res, res, sizeof(struct resource));
319325
320326 v2m->base = ioremap(v2m->res.start, resource_size(&v2m->res));
321327 if (!v2m->base) {
@@ -324,10 +330,9 @@ static int __init gicv2m_init_one(struct device_node *node, · 2 unmodified lines
324330 goto err_free_v2m;
325331 }
326332
327− if (!of_property_read_u32(node, "arm,msi-base-spi", &v2m->spi_start) &&
328− !of_property_read_u32(node, "arm,msi-num-spis", &v2m->nr_spis)) {
329− pr_info("Overriding V2M MSI_TYPER (base:%u, num:%u)\n",
330− v2m->spi_start, v2m->nr_spis);
333+ if (spi_start && nr_spis) {
334+ v2m->spi_start = spi_start;
335+ v2m->nr_spis = nr_spis;
331336 } else {
332337 u32 typer = readl_relaxed(v2m->base + V2M_MSI_TYPER);
333338
@@ -359,10 +364,9 @@ static int __init gicv2m_init_one(struct device_node *node, · 25 unmodified lines
359364 }
360365
361366 list_add_tail(&v2m->entry, &v2m_nodes);
362− pr_info("Node %s: range[%#lx:%#lx], SPI[%d:%d]\n", node->name,
363− (unsigned long)v2m->res.start, (unsigned long)v2m->res.end,
364− v2m->spi_start, (v2m->spi_start + v2m->nr_spis));
365367
368+ pr_info("range%pR, SPI[%d:%d]\n", res,
369+ v2m->spi_start, (v2m->spi_start + v2m->nr_spis - 1));
366370 return 0;
367371
368372 err_iounmap:
@@ -377,19 +381,36 @@ static struct of_device_id gicv2m_device_id[] = { · 8 unmodified lines
377381 {},
378382 };
379383
380−int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent)
384+static int __init gicv2m_of_init(struct fwnode_handle *parent_handle,
385+ struct irq_domain *parent)
381386 {
382387 int ret = 0;
388+ struct device_node *node = to_of_node(parent_handle);
383389 struct device_node *child;
384390
385391 for (child = of_find_matching_node(node, gicv2m_device_id); child;
386392 child = of_find_matching_node(child, gicv2m_device_id)) {
393+ u32 spi_start = 0, nr_spis = 0;
394+ struct resource res;
395+
387396 if (!of_find_property(child, "msi-controller", NULL))
388397 continue;
389398
390− ret = gicv2m_init_one(child, parent);
399+ ret = of_address_to_resource(child, 0, &res);
400+ if (ret) {
401+ pr_err("Failed to allocate v2m resource.\n");
402+ break;
403+ }
404+
405+ if (!of_property_read_u32(child, "arm,msi-base-spi",
406+ &spi_start) &&
407+ !of_property_read_u32(child, "arm,msi-num-spis", &nr_spis))
408+ pr_info("DT overriding V2M MSI_TYPER (base:%u, num:%u)\n",
409+ spi_start, nr_spis);
410+
411+ ret = gicv2m_init_one(&child->fwnode, spi_start, nr_spis, &res);
391412 if (ret) {
392− of_node_put(node);
413+ of_node_put(child);
393414 break;
394415 }
395416 }
@@ -400,3 +421,101 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent) · 4 unmodified lines
400421 gicv2m_teardown();
401422 return ret;
402423 }
424+
425+#ifdef CONFIG_ACPI
426+static int acpi_num_msi;
427+
428+static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev)
429+{
430+ struct v2m_data *data;
431+
432+ if (WARN_ON(acpi_num_msi <= 0))
433+ return NULL;
434+
435+ /* We only return the fwnode of the first MSI frame. */
436+ data = list_first_entry_or_null(&v2m_nodes, struct v2m_data, entry);
437+ if (!data)
438+ return NULL;
439+
440+ return data->fwnode;
441+}
442+
443+static int __init
444+acpi_parse_madt_msi(struct acpi_subtable_header *header,
445+ const unsigned long end)
446+{
447+ int ret;
448+ struct resource res;
449+ u32 spi_start = 0, nr_spis = 0;
450+ struct acpi_madt_generic_msi_frame *m;
451+ struct fwnode_handle *fwnode;
452+
453+ m = (struct acpi_madt_generic_msi_frame *)header;
454+ if (BAD_MADT_ENTRY(m, end))
455+ return -EINVAL;
456+
457+ res.start = m->base_address;
458+ res.end = m->base_address + SZ_4K - 1;
459+ res.flags = IORESOURCE_MEM;
460+
461+ if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
462+ spi_start = m->spi_base;
463+ nr_spis = m->spi_count;
464+
465+ pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
466+ spi_start, nr_spis);
467+ }
468+
469+ fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
470+ if (!fwnode) {
471+ pr_err("Unable to allocate GICv2m domain token\n");
472+ return -EINVAL;
473+ }
474+
475+ ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
476+ if (ret)
477+ irq_domain_free_fwnode(fwnode);
478+
479+ return ret;
480+}
481+
482+static int __init gicv2m_acpi_init(struct irq_domain *parent)
483+{
484+ int ret;
485+
486+ if (acpi_num_msi > 0)
487+ return 0;
488+
489+ acpi_num_msi = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_MSI_FRAME,
490+ acpi_parse_madt_msi, 0);
491+
492+ if (acpi_num_msi <= 0)
493+ goto err_out;
494+
495+ ret = gicv2m_allocate_domains(parent);
496+ if (ret)
497+ goto err_out;
498+
499+ pci_msi_register_fwnode_provider(&gicv2m_get_fwnode);
500+
501+ return 0;
502+
503+err_out:
504+ gicv2m_teardown();
505+ return -EINVAL;
506+}
507+#else /* CONFIG_ACPI */
508+static int __init gicv2m_acpi_init(struct irq_domain *parent)
509+{
510+ return -EINVAL;
511+}
512+#endif /* CONFIG_ACPI */
513+
514+int __init gicv2m_init(struct fwnode_handle *parent_handle,
515+ struct irq_domain *parent)
516+{
517+ if (is_of_node(parent_handle))
518+ return gicv2m_of_init(parent_handle, parent);
519+
520+ return gicv2m_acpi_init(parent);
521+}
drivers/irqchip/irq-gic.c+31−33
@@ -69,6 +69,7 @@ union gic_base { · 68 unmodified lines
6969 };
7070
7171 struct gic_chip_data {
72+ struct irq_chip chip;
7273 union gic_base dist_base;
7374 union gic_base cpu_base;
7475 #ifdef CONFIG_CPU_PM
@@ -99,11 +100,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly; · 24 unmodified lines
99100
100101 static struct static_key supports_deactivate = STATIC_KEY_INIT_TRUE;
101102
102−#ifndef MAX_GIC_NR
103−#define MAX_GIC_NR 1
104−#endif
105−
106−static struct gic_chip_data gic_data[MAX_GIC_NR] __read_mostly;
103+static struct gic_chip_data gic_data[CONFIG_ARM_GIC_MAX_NR] __read_mostly;
107104
108105 #ifdef CONFIG_GIC_NON_BANKED
109106 static void __iomem *gic_get_percpu_base(union gic_base *base)
@@ -336,7 +333,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) · 226 unmodified lines
336333 irqstat = readl_relaxed(cpu_base + GIC_CPU_INTACK);
337334 irqnr = irqstat & GICC_IAR_INT_ID_MASK;
338335
339− if (likely(irqnr > 15 && irqnr < 1021)) {
336+ if (likely(irqnr > 15 && irqnr < 1020)) {
340337 if (static_key_true(&supports_deactivate))
341338 writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI);
342339 handle_domain_irq(gic->domain, irqnr, regs);
@@ -383,7 +380,6 @@ static void gic_handle_cascade_irq(struct irq_desc *desc) · 40 unmodified lines
383380 }
384381
385382 static struct irq_chip gic_chip = {
386− .name = "GIC",
387383 .irq_mask = gic_mask_irq,
388384 .irq_unmask = gic_unmask_irq,
389385 .irq_eoi = gic_eoi_irq,
@@ -417,8 +413,7 @@ static struct irq_chip gic_eoimode1_chip = { · 27 unmodified lines
417413
418414 void __init gic_cascade_irq(unsigned int gic_nr, unsigned int irq)
419415 {
420− if (gic_nr >= MAX_GIC_NR)
421− BUG();
416+ BUG_ON(gic_nr >= CONFIG_ARM_GIC_MAX_NR);
422417 irq_set_chained_handler_and_data(irq, gic_handle_cascade_irq,
423418 &gic_data[gic_nr]);
424419 }
@@ -524,7 +519,7 @@ int gic_cpu_if_down(unsigned int gic_nr) · 99 unmodified lines
524519 void __iomem *cpu_base;
525520 u32 val = 0;
526521
527− if (gic_nr >= MAX_GIC_NR)
522+ if (gic_nr >= CONFIG_ARM_GIC_MAX_NR)
528523 return -EINVAL;
529524
530525 cpu_base = gic_data_cpu_base(&gic_data[gic_nr]);
@@ -548,8 +543,7 @@ static void gic_dist_save(unsigned int gic_nr) · 17 unmodified lines
548543 void __iomem *dist_base;
549544 int i;
550545
551− if (gic_nr >= MAX_GIC_NR)
552− BUG();
546+ BUG_ON(gic_nr >= CONFIG_ARM_GIC_MAX_NR);
553547
554548 gic_irqs = gic_data[gic_nr].gic_irqs;
555549 dist_base = gic_data_dist_base(&gic_data[gic_nr]);
@@ -587,8 +581,7 @@ static void gic_dist_restore(unsigned int gic_nr) · 31 unmodified lines
587581 unsigned int i;
588582 void __iomem *dist_base;
589583
590− if (gic_nr >= MAX_GIC_NR)
591− BUG();
584+ BUG_ON(gic_nr >= CONFIG_ARM_GIC_MAX_NR);
592585
593586 gic_irqs = gic_data[gic_nr].gic_irqs;
594587 dist_base = gic_data_dist_base(&gic_data[gic_nr]);
@@ -634,8 +627,7 @@ static void gic_cpu_save(unsigned int gic_nr) · 39 unmodified lines
634627 void __iomem *dist_base;
635628 void __iomem *cpu_base;
636629
637− if (gic_nr >= MAX_GIC_NR)
638− BUG();
630+ BUG_ON(gic_nr >= CONFIG_ARM_GIC_MAX_NR);
639631
640632 dist_base = gic_data_dist_base(&gic_data[gic_nr]);
641633 cpu_base = gic_data_cpu_base(&gic_data[gic_nr]);
@@ -664,8 +656,7 @@ static void gic_cpu_restore(unsigned int gic_nr) · 22 unmodified lines
664656 void __iomem *dist_base;
665657 void __iomem *cpu_base;
666658
667− if (gic_nr >= MAX_GIC_NR)
668− BUG();
659+ BUG_ON(gic_nr >= CONFIG_ARM_GIC_MAX_NR);
669660
670661 dist_base = gic_data_dist_base(&gic_data[gic_nr]);
671662 cpu_base = gic_data_cpu_base(&gic_data[gic_nr]);
@@ -703,7 +694,7 @@ static int gic_notifier(struct notifier_block *self, unsigned long cmd, void *v) · 31 unmodified lines
703694 {
704695 int i;
705696
706− for (i = 0; i < MAX_GIC_NR; i++) {
697+ for (i = 0; i < CONFIG_ARM_GIC_MAX_NR; i++) {
707698 #ifdef CONFIG_GIC_NON_BANKED
708699 /* Skip over unused GICs */
709700 if (!gic_data[i].get_base)
@@ -835,8 +826,7 @@ void gic_migrate_target(unsigned int new_cpu_id) · 125 unmodified lines
835826 int i, ror_val, cpu = smp_processor_id();
836827 u32 val, cur_target_mask, active_mask;
837828
838− if (gic_nr >= MAX_GIC_NR)
839− BUG();
829+ BUG_ON(gic_nr >= CONFIG_ARM_GIC_MAX_NR);
840830
841831 dist_base = gic_data_dist_base(&gic_data[gic_nr]);
842832 if (!dist_base)
@@ -925,20 +915,15 @@ void __init gic_init_physaddr(struct device_node *node) · 82 unmodified lines
925915 static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq,
926916 irq_hw_number_t hw)
927917 {
928− struct irq_chip *chip = &gic_chip;
929−
930− if (static_key_true(&supports_deactivate)) {
931− if (d->host_data == (void *)&gic_data[0])
932− chip = &gic_eoimode1_chip;
933− }
918+ struct gic_chip_data *gic = d->host_data;
934919
935920 if (hw < 32) {
936921 irq_set_percpu_devid(irq);
937− irq_domain_set_info(d, irq, hw, chip, d->host_data,
922+ irq_domain_set_info(d, irq, hw, &gic->chip, d->host_data,
938923 handle_percpu_devid_irq, NULL, NULL);
939924 irq_set_status_flags(irq, IRQ_NOAUTOEN);
940925 } else {
941− irq_domain_set_info(d, irq, hw, chip, d->host_data,
926+ irq_domain_set_info(d, irq, hw, &gic->chip, d->host_data,
942927 handle_fasteoi_irq, NULL, NULL);
943928 irq_set_probe(irq);
944929 }
@@ -972,7 +957,7 @@ static int gic_irq_domain_translate(struct irq_domain *d, · 27 unmodified lines
972957 return 0;
973958 }
974959
975− if (fwspec->fwnode->type == FWNODE_IRQCHIP) {
960+ if (is_fwnode_irqchip(fwspec->fwnode)) {
976961 if(fwspec->param_count != 2)
977962 return -EINVAL;
978963
@@ -1040,11 +1025,20 @@ static void __init __gic_init_bases(unsigned int gic_nr, int irq_start, · 61 unmodified lines
10401025 struct gic_chip_data *gic;
10411026 int gic_irqs, irq_base, i;
10421027
1043− BUG_ON(gic_nr >= MAX_GIC_NR);
1028+ BUG_ON(gic_nr >= CONFIG_ARM_GIC_MAX_NR);
10441029
10451030 gic_check_cpu_features();
10461031
10471032 gic = &gic_data[gic_nr];
1033+
1034+ /* Initialize irq_chip */
1035+ if (static_key_true(&supports_deactivate) && gic_nr == 0) {
1036+ gic->chip = gic_eoimode1_chip;
1037+ } else {
1038+ gic->chip = gic_chip;
1039+ gic->chip.name = kasprintf(GFP_KERNEL, "GIC-%d", gic_nr);
1040+ }
1041+
10481042 #ifdef CONFIG_GIC_NON_BANKED
10491043 if (percpu_offset) { /* Frankein-GIC without banked registers... */
10501044 unsigned int cpu;
@@ -1196,7 +1190,7 @@ static bool gic_check_eoimode(struct device_node *node, void __iomem **base) · 145 unmodified lines
11961190 return true;
11971191 }
11981192
1199−static int __init
1193+int __init
12001194 gic_of_init(struct device_node *node, struct device_node *parent)
12011195 {
12021196 void __iomem *cpu_base;
@@ -1234,7 +1228,7 @@ gic_of_init(struct device_node *node, struct device_node *parent) · 31 unmodified lines
12341228 }
12351229
12361230 if (IS_ENABLED(CONFIG_ARM_GIC_V2M))
1237− gicv2m_of_init(node, gic_data[gic_cnt].domain);
1231+ gicv2m_init(&node->fwnode, gic_data[gic_cnt].domain);
12381232
12391233 gic_cnt++;
12401234 return 0;
@@ -1359,6 +1353,10 @@ static int __init gic_v2_acpi_init(struct acpi_subtable_header *header, · 118 unmodified lines
13591353 __gic_init_bases(0, -1, dist_base, cpu_base, 0, domain_handle);
13601354
13611355 acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, domain_handle);
1356+
1357+ if (IS_ENABLED(CONFIG_ARM_GIC_V2M))
1358+ gicv2m_init(NULL, gic_data[0].domain);
1359+
13621360 return 0;
13631361 }
13641362 IRQCHIP_ACPI_DECLARE(gic_v2, ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR,
drivers/irqchip/irq-mbigen.c+297−0
@@ -0,0 +1,297 @@
1+/*
2+ * Copyright (C) 2015 Hisilicon Limited, All Rights Reserved.
3+ * Author: Jun Ma <majun258@huawei.com>
4+ * Author: Yun Wu <wuyun.wu@huawei.com>
5+ *
6+ * This program is free software; you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License version 2 as
8+ * published by the Free Software Foundation.
9+ *
10+ * This program is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ * GNU General Public License for more details.
14+ *
15+ * You should have received a copy of the GNU General Public License
16+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17+ */
18+
19+#include <linux/interrupt.h>
20+#include <linux/irqchip.h>
21+#include <linux/module.h>
22+#include <linux/msi.h>
23+#include <linux/of_address.h>
24+#include <linux/of_irq.h>
25+#include <linux/of_platform.h>
26+#include <linux/platform_device.h>
27+#include <linux/slab.h>
28+
29+/* Interrupt numbers per mbigen node supported */
30+#define IRQS_PER_MBIGEN_NODE 128
31+
32+/* 64 irqs (Pin0-pin63) are reserved for each mbigen chip */
33+#define RESERVED_IRQ_PER_MBIGEN_CHIP 64
34+
35+/* The maximum IRQ pin number of mbigen chip(start from 0) */
36+#define MAXIMUM_IRQ_PIN_NUM 1407
37+
38+/**
39+ * In mbigen vector register
40+ * bit[21:12]: event id value
41+ * bit[11:0]: device id
42+ */
43+#define IRQ_EVENT_ID_SHIFT 12
44+#define IRQ_EVENT_ID_MASK 0x3ff
45+
46+/* register range of each mbigen node */
47+#define MBIGEN_NODE_OFFSET 0x1000
48+
49+/* offset of vector register in mbigen node */
50+#define REG_MBIGEN_VEC_OFFSET 0x200
51+
52+/**
53+ * offset of clear register in mbigen node
54+ * This register is used to clear the status
55+ * of interrupt
56+ */
57+#define REG_MBIGEN_CLEAR_OFFSET 0xa000
58+
59+/**
60+ * offset of interrupt type register
61+ * This register is used to configure interrupt
62+ * trigger type
63+ */
64+#define REG_MBIGEN_TYPE_OFFSET 0x0
65+
66+/**
67+ * struct mbigen_device - holds the information of mbigen device.
68+ *
69+ * @pdev: pointer to the platform device structure of mbigen chip.
70+ * @base: mapped address of this mbigen chip.
71+ */
72+struct mbigen_device {
73+ struct platform_device *pdev;
74+ void __iomem *base;
75+};
76+
77+static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq)
78+{
79+ unsigned int nid, pin;
80+
81+ hwirq -= RESERVED_IRQ_PER_MBIGEN_CHIP;
82+ nid = hwirq / IRQS_PER_MBIGEN_NODE + 1;
83+ pin = hwirq % IRQS_PER_MBIGEN_NODE;
84+
85+ return pin * 4 + nid * MBIGEN_NODE_OFFSET
86+ + REG_MBIGEN_VEC_OFFSET;
87+}
88+
89+static inline void get_mbigen_type_reg(irq_hw_number_t hwirq,
90+ u32 *mask, u32 *addr)
91+{
92+ unsigned int nid, irq_ofst, ofst;
93+
94+ hwirq -= RESERVED_IRQ_PER_MBIGEN_CHIP;
95+ nid = hwirq / IRQS_PER_MBIGEN_NODE + 1;
96+ irq_ofst = hwirq % IRQS_PER_MBIGEN_NODE;
97+
98+ *mask = 1 << (irq_ofst % 32);
99+ ofst = irq_ofst / 32 * 4;
100+
101+ *addr = ofst + nid * MBIGEN_NODE_OFFSET
102+ + REG_MBIGEN_TYPE_OFFSET;
103+}
104+
105+static inline void get_mbigen_clear_reg(irq_hw_number_t hwirq,
106+ u32 *mask, u32 *addr)
107+{
108+ unsigned int ofst;
109+
110+ hwirq -= RESERVED_IRQ_PER_MBIGEN_CHIP;
111+ ofst = hwirq / 32 * 4;
112+
113+ *mask = 1 << (hwirq % 32);
114+ *addr = ofst + REG_MBIGEN_CLEAR_OFFSET;
115+}
116+
117+static void mbigen_eoi_irq(struct irq_data *data)
118+{
119+ void __iomem *base = data->chip_data;
120+ u32 mask, addr;
121+
122+ get_mbigen_clear_reg(data->hwirq, &mask, &addr);
123+
124+ writel_relaxed(mask, base + addr);
125+
126+ irq_chip_eoi_parent(data);
127+}
128+
129+static int mbigen_set_type(struct irq_data *data, unsigned int type)
130+{
131+ void __iomem *base = data->chip_data;
132+ u32 mask, addr, val;
133+
134+ if (type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_EDGE_RISING)
135+ return -EINVAL;
136+
137+ get_mbigen_type_reg(data->hwirq, &mask, &addr);
138+
139+ val = readl_relaxed(base + addr);
140+
141+ if (type == IRQ_TYPE_LEVEL_HIGH)
142+ val |= mask;
143+ else
144+ val &= ~mask;
145+
146+ writel_relaxed(val, base + addr);
147+
148+ return 0;
149+}
150+
151+static struct irq_chip mbigen_irq_chip = {
152+ .name = "mbigen-v2",
153+ .irq_mask = irq_chip_mask_parent,
154+ .irq_unmask = irq_chip_unmask_parent,
155+ .irq_eoi = mbigen_eoi_irq,
156+ .irq_set_type = mbigen_set_type,
157+ .irq_set_affinity = irq_chip_set_affinity_parent,
158+};
159+
160+static void mbigen_write_msg(struct msi_desc *desc, struct msi_msg *msg)
161+{
162+ struct irq_data *d = irq_get_irq_data(desc->irq);
163+ void __iomem *base = d->chip_data;
164+ u32 val;
165+
166+ base += get_mbigen_vec_reg(d->hwirq);
167+ val = readl_relaxed(base);
168+
169+ val &= ~(IRQ_EVENT_ID_MASK << IRQ_EVENT_ID_SHIFT);
170+ val |= (msg->data << IRQ_EVENT_ID_SHIFT);
171+
172+ /* The address of doorbell is encoded in mbigen register by default
173+ * So,we don't need to program the doorbell address at here
174+ */
175+ writel_relaxed(val, base);
176+}
177+
178+static int mbigen_domain_translate(struct irq_domain *d,
179+ struct irq_fwspec *fwspec,
180+ unsigned long *hwirq,
181+ unsigned int *type)
182+{
183+ if (is_of_node(fwspec->fwnode)) {
184+ if (fwspec->param_count != 2)
185+ return -EINVAL;
186+
187+ if ((fwspec->param[0] > MAXIMUM_IRQ_PIN_NUM) ||
188+ (fwspec->param[0] < RESERVED_IRQ_PER_MBIGEN_CHIP))
189+ return -EINVAL;
190+ else
191+ *hwirq = fwspec->param[0];
192+
193+ /* If there is no valid irq type, just use the default type */
194+ if ((fwspec->param[1] == IRQ_TYPE_EDGE_RISING) ||
195+ (fwspec->param[1] == IRQ_TYPE_LEVEL_HIGH))
196+ *type = fwspec->param[1];
197+ else
198+ return -EINVAL;
199+
200+ return 0;
201+ }
202+ return -EINVAL;
203+}
204+
205+static int mbigen_irq_domain_alloc(struct irq_domain *domain,
206+ unsigned int virq,
207+ unsigned int nr_irqs,
208+ void *args)
209+{
210+ struct irq_fwspec *fwspec = args;
211+ irq_hw_number_t hwirq;
212+ unsigned int type;
213+ struct mbigen_device *mgn_chip;
214+ int i, err;
215+
216+ err = mbigen_domain_translate(domain, fwspec, &hwirq, &type);
217+ if (err)
218+ return err;
219+
220+ err = platform_msi_domain_alloc(domain, virq, nr_irqs);
221+ if (err)
222+ return err;
223+
224+ mgn_chip = platform_msi_get_host_data(domain);
225+
226+ for (i = 0; i < nr_irqs; i++)
227+ irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i,
228+ &mbigen_irq_chip, mgn_chip->base);
229+
230+ return 0;
231+}
232+
233+static struct irq_domain_ops mbigen_domain_ops = {
234+ .translate = mbigen_domain_translate,
235+ .alloc = mbigen_irq_domain_alloc,
236+ .free = irq_domain_free_irqs_common,
237+};
238+
239+static int mbigen_device_probe(struct platform_device *pdev)
240+{
241+ struct mbigen_device *mgn_chip;
242+ struct resource *res;
243+ struct irq_domain *domain;
244+ u32 num_pins;
245+
246+ mgn_chip = devm_kzalloc(&pdev->dev, sizeof(*mgn_chip), GFP_KERNEL);
247+ if (!mgn_chip)
248+ return -ENOMEM;
249+
250+ mgn_chip->pdev = pdev;
251+
252+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
253+ mgn_chip->base = devm_ioremap_resource(&pdev->dev, res);
254+ if (IS_ERR(mgn_chip->base))
255+ return PTR_ERR(mgn_chip->base);
256+
257+ if (of_property_read_u32(pdev->dev.of_node, "num-pins", &num_pins) < 0) {
258+ dev_err(&pdev->dev, "No num-pins property\n");
259+ return -EINVAL;
260+ }
261+
262+ domain = platform_msi_create_device_domain(&pdev->dev, num_pins,
263+ mbigen_write_msg,
264+ &mbigen_domain_ops,
265+ mgn_chip);
266+
267+ if (!domain)
268+ return -ENOMEM;
269+
270+ platform_set_drvdata(pdev, mgn_chip);
271+
272+ dev_info(&pdev->dev, "Allocated %d MSIs\n", num_pins);
273+
274+ return 0;
275+}
276+
277+static const struct of_device_id mbigen_of_match[] = {
278+ { .compatible = "hisilicon,mbigen-v2" },
279+ { /* END */ }
280+};
281+MODULE_DEVICE_TABLE(of, mbigen_of_match);
282+
283+static struct platform_driver mbigen_platform_driver = {
284+ .driver = {
285+ .name = "Hisilicon MBIGEN-V2",
286+ .owner = THIS_MODULE,
287+ .of_match_table = mbigen_of_match,
288+ },
289+ .probe = mbigen_device_probe,
290+};
291+
292+module_platform_driver(mbigen_platform_driver);
293+
294+MODULE_AUTHOR("Jun Ma <majun258@huawei.com>");
295+MODULE_AUTHOR("Yun Wu <wuyun.wu@huawei.com>");
296+MODULE_LICENSE("GPL");
297+MODULE_DESCRIPTION("Hisilicon MBI Generator driver");
drivers/irqchip/irq-omap-intc.c+26−2
@@ -47,6 +47,7 @@ · 46 unmodified lines
4747 #define INTC_ILR0 0x0100
4848
4949 #define ACTIVEIRQ_MASK 0x7f /* omap2/3 active interrupt bits */
50+#define SPURIOUSIRQ_MASK (0x1ffffff << 7)
5051 #define INTCPS_NR_ILR_REGS 128
5152 #define INTCPS_NR_MIR_REGS 4
5253
@@ -207,7 +208,6 @@ static int __init omap_alloc_gc_of(struct irq_domain *d, void __iomem *base) · 154 unmodified lines
207208 ct = gc->chip_types;
208209
209210 ct->type = IRQ_TYPE_LEVEL_MASK;
210− ct->handler = handle_level_irq;
211211
212212 ct->chip.irq_ack = omap_mask_ack_irq;
213213 ct->chip.irq_mask = irq_gc_mask_disable_reg;
@@ -330,11 +330,35 @@ static int __init omap_init_irq(u32 base, struct device_node *node) · 116 unmodified lines
330330 static asmlinkage void __exception_irq_entry
331331 omap_intc_handle_irq(struct pt_regs *regs)
332332 {
333+ extern unsigned long irq_err_count;
333334 u32 irqnr;
334335
335336 irqnr = intc_readl(INTC_SIR);
337+
338+ /*
339+ * A spurious IRQ can result if interrupt that triggered the
340+ * sorting is no longer active during the sorting (10 INTC
341+ * functional clock cycles after interrupt assertion). Or a
342+ * change in interrupt mask affected the result during sorting
343+ * time. There is no special handling required except ignoring
344+ * the SIR register value just read and retrying.
345+ * See section 6.2.5 of AM335x TRM Literature Number: SPRUH73K
346+ *
347+ * Many a times, a spurious interrupt situation has been fixed
348+ * by adding a flush for the posted write acking the IRQ in
349+ * the device driver. Typically, this is going be the device
350+ * driver whose interrupt was handled just before the spurious
351+ * IRQ occurred. Pay attention to those device drivers if you
352+ * run into hitting the spurious IRQ condition below.
353+ */
354+ if (unlikely((irqnr & SPURIOUSIRQ_MASK) == SPURIOUSIRQ_MASK)) {
355+ pr_err_once("%s: spurious irq!\n", __func__);
356+ irq_err_count++;
357+ omap_ack_irq(NULL);
358+ return;
359+ }
360+
336361 irqnr &= ACTIVEIRQ_MASK;
337− WARN_ONCE(!irqnr, "Spurious IRQ ?\n");
338362 handle_domain_irq(domain, irqnr, regs);
339363 }
340364
drivers/irqchip/irq-renesas-intc-irqpin.c+51−45
@@ -31,7 +31,6 @@ · 30 unmodified lines
3131 #include <linux/slab.h>
3232 #include <linux/module.h>
3333 #include <linux/of_device.h>
34−#include <linux/platform_data/irq-renesas-intc-irqpin.h>
3534 #include <linux/pm_runtime.h>
3635
3736 #define INTC_IRQPIN_MAX 8 /* maximum 8 interrupts per driver instance */
@@ -75,18 +74,20 @@ struct intc_irqpin_irq { · 37 unmodified lines
7574 struct intc_irqpin_priv {
7675 struct intc_irqpin_iomem iomem[INTC_IRQPIN_REG_NR];
7776 struct intc_irqpin_irq irq[INTC_IRQPIN_MAX];
78− struct renesas_intc_irqpin_config config;
79− unsigned int number_of_irqs;
77+ unsigned int sense_bitfield_width;
8078 struct platform_device *pdev;
8179 struct irq_chip irq_chip;
8280 struct irq_domain *irq_domain;
8381 struct clk *clk;
84− bool shared_irqs;
82+ unsigned shared_irqs:1;
83+ unsigned needs_clk:1;
8584 u8 shared_irq_mask;
8685 };
8786
88−struct intc_irqpin_irlm_config {
87+struct intc_irqpin_config {
8988 unsigned int irlm_bit;
89+ unsigned needs_irlm:1;
90+ unsigned needs_clk:1;
9091 };
9192
9293 static unsigned long intc_irqpin_read32(void __iomem *iomem)
@@ -171,7 +172,7 @@ static void intc_irqpin_mask_unmask_prio(struct intc_irqpin_priv *p, · 78 unmodified lines
171172 static int intc_irqpin_set_sense(struct intc_irqpin_priv *p, int irq, int value)
172173 {
173174 /* The SENSE register is assumed to be 32-bit. */
174− int bitfield_width = p->config.sense_bitfield_width;
175+ int bitfield_width = p->sense_bitfield_width;
175176 int shift = 32 - (irq + 1) * bitfield_width;
176177
177178 dev_dbg(&p->pdev->dev, "sense irq = %d, mode = %d\n", irq, value);
@@ -361,8 +362,15 @@ static const struct irq_domain_ops intc_irqpin_irq_domain_ops = { · 183 unmodified lines
361362 .xlate = irq_domain_xlate_twocell,
362363 };
363364
364−static const struct intc_irqpin_irlm_config intc_irqpin_irlm_r8a777x = {
365+static const struct intc_irqpin_config intc_irqpin_irlm_r8a777x = {
365366 .irlm_bit = 23, /* ICR0.IRLM0 */
367+ .needs_irlm = 1,
368+ .needs_clk = 0,
369+};
370+
371+static const struct intc_irqpin_config intc_irqpin_rmobile = {
372+ .needs_irlm = 0,
373+ .needs_clk = 1,
366374 };
367375
368376 static const struct of_device_id intc_irqpin_dt_ids[] = {
@@ -371,14 +379,18 @@ static const struct of_device_id intc_irqpin_dt_ids[] = { · 2 unmodified lines
371379 .data = &intc_irqpin_irlm_r8a777x },
372380 { .compatible = "renesas,intc-irqpin-r8a7779",
373381 .data = &intc_irqpin_irlm_r8a777x },
382+ { .compatible = "renesas,intc-irqpin-r8a7740",
383+ .data = &intc_irqpin_rmobile },
384+ { .compatible = "renesas,intc-irqpin-sh73a0",
385+ .data = &intc_irqpin_rmobile },
374386 {},
375387 };
376388 MODULE_DEVICE_TABLE(of, intc_irqpin_dt_ids);
377389
378390 static int intc_irqpin_probe(struct platform_device *pdev)
379391 {
392+ const struct intc_irqpin_config *config = NULL;
380393 struct device *dev = &pdev->dev;
381− struct renesas_intc_irqpin_config *pdata = dev->platform_data;
382394 const struct of_device_id *of_id;
383395 struct intc_irqpin_priv *p;
384396 struct intc_irqpin_iomem *i;
@@ -388,6 +400,8 @@ static int intc_irqpin_probe(struct platform_device *pdev) · 3 unmodified lines
388400 void (*enable_fn)(struct irq_data *d);
389401 void (*disable_fn)(struct irq_data *d);
390402 const char *name = dev_name(dev);
403+ bool control_parent;
404+ unsigned int nirqs;
391405 int ref_irq;
392406 int ret;
393407 int k;
@@ -399,23 +413,28 @@ static int intc_irqpin_probe(struct platform_device *pdev) · 5 unmodified lines
399413 }
400414
401415 /* deal with driver instance configuration */
402− if (pdata) {
403− memcpy(&p->config, pdata, sizeof(*pdata));
404− } else {
405− of_property_read_u32(dev->of_node, "sense-bitfield-width",
406− &p->config.sense_bitfield_width);
407− p->config.control_parent = of_property_read_bool(dev->of_node,
408− "control-parent");
409− }
410− if (!p->config.sense_bitfield_width)
411− p->config.sense_bitfield_width = 4; /* default to 4 bits */
416+ of_property_read_u32(dev->of_node, "sense-bitfield-width",
417+ &p->sense_bitfield_width);
418+ control_parent = of_property_read_bool(dev->of_node, "control-parent");
419+ if (!p->sense_bitfield_width)
420+ p->sense_bitfield_width = 4; /* default to 4 bits */
412421
413422 p->pdev = pdev;
414423 platform_set_drvdata(pdev, p);
415424
425+ of_id = of_match_device(intc_irqpin_dt_ids, dev);
426+ if (of_id && of_id->data) {
427+ config = of_id->data;
428+ p->needs_clk = config->needs_clk;
429+ }
430+
416431 p->clk = devm_clk_get(dev, NULL);
417432 if (IS_ERR(p->clk)) {
418− dev_warn(dev, "unable to get clock\n");
433+ if (p->needs_clk) {
434+ dev_err(dev, "unable to get clock\n");
435+ ret = PTR_ERR(p->clk);
436+ goto err0;
437+ }
419438 p->clk = NULL;
420439 }
421440
@@ -443,8 +462,8 @@ static int intc_irqpin_probe(struct platform_device *pdev) · 21 unmodified lines
443462 p->irq[k].requested_irq = irq->start;
444463 }
445464
446− p->number_of_irqs = k;
447− if (p->number_of_irqs < 1) {
465+ nirqs = k;
466+ if (nirqs < 1) {
448467 dev_err(dev, "not enough IRQ resources\n");
449468 ret = -EINVAL;
450469 goto err0;
@@ -485,20 +504,16 @@ static int intc_irqpin_probe(struct platform_device *pdev) · 34 unmodified lines
485504 }
486505
487506 /* configure "individual IRQ mode" where needed */
488− of_id = of_match_device(intc_irqpin_dt_ids, dev);
489− if (of_id && of_id->data) {
490− const struct intc_irqpin_irlm_config *irlm_config = of_id->data;
491−
507+ if (config && config->needs_irlm) {
492508 if (io[INTC_IRQPIN_REG_IRLM])
493509 intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_IRLM,
494− irlm_config->irlm_bit,
495− 1, 1);
510+ config->irlm_bit, 1, 1);
496511 else
497512 dev_warn(dev, "unable to select IRLM mode\n");
498513 }
499514
500515 /* mask all interrupts using priority */
501− for (k = 0; k < p->number_of_irqs; k++)
516+ for (k = 0; k < nirqs; k++)
502517 intc_irqpin_mask_unmask_prio(p, k, 1);
503518
504519 /* clear all pending interrupts */
@@ -506,16 +521,16 @@ static int intc_irqpin_probe(struct platform_device *pdev) · 1 unmodified line
506521
507522 /* scan for shared interrupt lines */
508523 ref_irq = p->irq[0].requested_irq;
509− p->shared_irqs = true;
510− for (k = 1; k < p->number_of_irqs; k++) {
524+ p->shared_irqs = 1;
525+ for (k = 1; k < nirqs; k++) {
511526 if (ref_irq != p->irq[k].requested_irq) {
512− p->shared_irqs = false;
527+ p->shared_irqs = 0;
513528 break;
514529 }
515530 }
516531
517532 /* use more severe masking method if requested */
518− if (p->config.control_parent) {
533+ if (control_parent) {
519534 enable_fn = intc_irqpin_irq_enable_force;
520535 disable_fn = intc_irqpin_irq_disable_force;
521536 } else if (!p->shared_irqs) {
@@ -534,9 +549,7 @@ static int intc_irqpin_probe(struct platform_device *pdev) · 12 unmodified lines
534549 irq_chip->irq_set_wake = intc_irqpin_irq_set_wake;
535550 irq_chip->flags = IRQCHIP_MASK_ON_SUSPEND;
536551
537− p->irq_domain = irq_domain_add_simple(dev->of_node,
538− p->number_of_irqs,
539− p->config.irq_base,
552+ p->irq_domain = irq_domain_add_simple(dev->of_node, nirqs, 0,
540553 &intc_irqpin_irq_domain_ops, p);
541554 if (!p->irq_domain) {
542555 ret = -ENXIO;
@@ -555,7 +568,7 @@ static int intc_irqpin_probe(struct platform_device *pdev) · 12 unmodified lines
555568 }
556569 } else {
557570 /* request interrupts one by one */
558− for (k = 0; k < p->number_of_irqs; k++) {
571+ for (k = 0; k < nirqs; k++) {
559572 if (devm_request_irq(dev, p->irq[k].requested_irq,
560573 intc_irqpin_irq_handler, 0, name,
561574 &p->irq[k])) {
@@ -567,17 +580,10 @@ static int intc_irqpin_probe(struct platform_device *pdev) · 5 unmodified lines
567580 }
568581
569582 /* unmask all interrupts on prio level */
570− for (k = 0; k < p->number_of_irqs; k++)
583+ for (k = 0; k < nirqs; k++)
571584 intc_irqpin_mask_unmask_prio(p, k, 0);
572585
573− dev_info(dev, "driving %d irqs\n", p->number_of_irqs);
574−
575− /* warn in case of mismatch if irq base is specified */
576− if (p->config.irq_base) {
577− if (p->config.irq_base != p->irq[0].domain_irq)
578− dev_warn(dev, "irq base mismatch (%d/%d)\n",
579− p->config.irq_base, p->irq[0].domain_irq);
580− }
586+ dev_info(dev, "driving %d irqs\n", nirqs);
581587
582588 return 0;
583589
drivers/irqchip/irq-sunxi-nmi.c+13−0
@@ -50,6 +50,12 @@ static struct sunxi_sc_nmi_reg_offs sun6i_reg_offs = { · 49 unmodified lines
5050 .enable = 0x34,
5151 };
5252
53+static struct sunxi_sc_nmi_reg_offs sun9i_reg_offs = {
54+ .ctrl = 0x00,
55+ .pend = 0x08,
56+ .enable = 0x04,
57+};
58+
5359 static inline void sunxi_sc_nmi_write(struct irq_chip_generic *gc, u32 off,
5460 u32 val)
5561 {
@@ -207,3 +213,10 @@ static int __init sun7i_sc_nmi_irq_init(struct device_node *node, · 151 unmodified lines
207213 return sunxi_sc_nmi_irq_init(node, &sun7i_reg_offs);
208214 }
209215 IRQCHIP_DECLARE(sun7i_sc_nmi, "allwinner,sun7i-a20-sc-nmi", sun7i_sc_nmi_irq_init);
216+
217+static int __init sun9i_nmi_irq_init(struct device_node *node,
218+ struct device_node *parent)
219+{
220+ return sunxi_sc_nmi_irq_init(node, &sun9i_reg_offs);
221+}
222+IRQCHIP_DECLARE(sun9i_nmi, "allwinner,sun9i-a80-nmi", sun9i_nmi_irq_init);
drivers/irqchip/irq-ts4800.c+163−0
@@ -0,0 +1,163 @@
1+/*
2+ * Multiplexed-IRQs driver for TS-4800's FPGA
3+ *
4+ * Copyright (c) 2015 - Savoir-faire Linux
5+ *
6+ * This file is licensed under the terms of the GNU General Public
7+ * License version 2. This program is licensed "as is" without any
8+ * warranty of any kind, whether express or implied.
9+ */
10+
11+#include <linux/interrupt.h>
12+#include <linux/io.h>
13+#include <linux/irq.h>
14+#include <linux/irqchip.h>
15+#include <linux/irqchip/chained_irq.h>
16+#include <linux/irqdomain.h>
17+#include <linux/module.h>
18+#include <linux/of.h>
19+#include <linux/of_address.h>
20+#include <linux/of_irq.h>
21+#include <linux/platform_device.h>
22+
23+#define IRQ_MASK 0x4
24+#define IRQ_STATUS 0x8
25+
26+struct ts4800_irq_data {
27+ void __iomem *base;
28+ struct irq_domain *domain;
29+ struct irq_chip irq_chip;
30+};
31+
32+static void ts4800_irq_mask(struct irq_data *d)
33+{
34+ struct ts4800_irq_data *data = irq_data_get_irq_chip_data(d);
35+ u16 reg = readw(data->base + IRQ_MASK);
36+ u16 mask = 1 << d->hwirq;
37+
38+ writew(reg | mask, data->base + IRQ_MASK);
39+}
40+
41+static void ts4800_irq_unmask(struct irq_data *d)
42+{
43+ struct ts4800_irq_data *data = irq_data_get_irq_chip_data(d);
44+ u16 reg = readw(data->base + IRQ_MASK);
45+ u16 mask = 1 << d->hwirq;
46+
47+ writew(reg & ~mask, data->base + IRQ_MASK);
48+}
49+
50+static int ts4800_irqdomain_map(struct irq_domain *d, unsigned int irq,
51+ irq_hw_number_t hwirq)
52+{
53+ struct ts4800_irq_data *data = d->host_data;
54+
55+ irq_set_chip_and_handler(irq, &data->irq_chip, handle_simple_irq);
56+ irq_set_chip_data(irq, data);
57+ irq_set_noprobe(irq);
58+
59+ return 0;
60+}
61+
62+struct irq_domain_ops ts4800_ic_ops = {
63+ .map = ts4800_irqdomain_map,
64+ .xlate = irq_domain_xlate_onecell,
65+};
66+
67+static void ts4800_ic_chained_handle_irq(struct irq_desc *desc)
68+{
69+ struct ts4800_irq_data *data = irq_desc_get_handler_data(desc);
70+ struct irq_chip *chip = irq_desc_get_chip(desc);
71+ u16 status = readw(data->base + IRQ_STATUS);
72+
73+ chained_irq_enter(chip, desc);
74+
75+ if (unlikely(status == 0)) {
76+ handle_bad_irq(desc);
77+ goto out;
78+ }
79+
80+ do {
81+ unsigned int bit = __ffs(status);
82+ int irq = irq_find_mapping(data->domain, bit);
83+
84+ status &= ~(1 << bit);
85+ generic_handle_irq(irq);
86+ } while (status);
87+
88+out:
89+ chained_irq_exit(chip, desc);
90+}
91+
92+static int ts4800_ic_probe(struct platform_device *pdev)
93+{
94+ struct device_node *node = pdev->dev.of_node;
95+ struct ts4800_irq_data *data;
96+ struct irq_chip *irq_chip;
97+ struct resource *res;
98+ int parent_irq;
99+
100+ data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
101+ if (!data)
102+ return -ENOMEM;
103+
104+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
105+ data->base = devm_ioremap_resource(&pdev->dev, res);
106+ if (IS_ERR(data->base))
107+ return PTR_ERR(data->base);
108+
109+ writew(0xFFFF, data->base + IRQ_MASK);
110+
111+ parent_irq = irq_of_parse_and_map(node, 0);
112+ if (!parent_irq) {
113+ dev_err(&pdev->dev, "failed to get parent IRQ\n");
114+ return -EINVAL;
115+ }
116+
117+ irq_chip = &data->irq_chip;
118+ irq_chip->name = dev_name(&pdev->dev);
119+ irq_chip->irq_mask = ts4800_irq_mask;
120+ irq_chip->irq_unmask = ts4800_irq_unmask;
121+
122+ data->domain = irq_domain_add_linear(node, 8, &ts4800_ic_ops, data);
123+ if (!data->domain) {
124+ dev_err(&pdev->dev, "cannot add IRQ domain\n");
125+ return -ENOMEM;
126+ }
127+
128+ irq_set_chained_handler_and_data(parent_irq,
129+ ts4800_ic_chained_handle_irq, data);
130+
131+ platform_set_drvdata(pdev, data);
132+
133+ return 0;
134+}
135+
136+static int ts4800_ic_remove(struct platform_device *pdev)
137+{
138+ struct ts4800_irq_data *data = platform_get_drvdata(pdev);
139+
140+ irq_domain_remove(data->domain);
141+
142+ return 0;
143+}
144+
145+static const struct of_device_id ts4800_ic_of_match[] = {
146+ { .compatible = "technologic,ts4800-irqc", },
147+ {},
148+};
149+MODULE_DEVICE_TABLE(of, ts4800_ic_of_match);
150+
151+static struct platform_driver ts4800_ic_driver = {
152+ .probe = ts4800_ic_probe,
153+ .remove = ts4800_ic_remove,
154+ .driver = {
155+ .name = "ts4800-irqc",
156+ .of_match_table = ts4800_ic_of_match,
157+ },
158+};
159+module_platform_driver(ts4800_ic_driver);
160+
161+MODULE_AUTHOR("Damien Riegel <damien.riegel@savoirfairelinux.com>");
162+MODULE_LICENSE("GPL v2");
163+MODULE_ALIAS("platform:ts4800_irqc");
drivers/irqchip/irq-zevio.c+1−2
@@ -43,8 +43,7 @@ static void __iomem *zevio_irq_io; · 42 unmodified lines
4343 static void zevio_irq_ack(struct irq_data *irqd)
4444 {
4545 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(irqd);
46− struct irq_chip_regs *regs =
47− &container_of(irqd->chip, struct irq_chip_type, chip)->regs;
46+ struct irq_chip_regs *regs = &irq_data_get_chip_type(irqd)->regs;
4847
4948 readl(gc->reg_base + regs->ack);
5049 }
drivers/pci/msi.c+4−0
@@ -257,6 +257,7 @@ void pci_msi_mask_irq(struct irq_data *data) · 256 unmodified lines
257257 {
258258 msi_set_mask_bit(data, 1);
259259 }
260+EXPORT_SYMBOL_GPL(pci_msi_mask_irq);
260261
261262 /**
262263 * pci_msi_unmask_irq - Generic irq chip callback to unmask PCI/MSI interrupts
@@ -266,6 +267,7 @@ void pci_msi_unmask_irq(struct irq_data *data) · 3 unmodified lines
266267 {
267268 msi_set_mask_bit(data, 0);
268269 }
270+EXPORT_SYMBOL_GPL(pci_msi_unmask_irq);
269271
270272 void default_restore_msi_irqs(struct pci_dev *dev)
271273 {
@@ -1126,6 +1128,7 @@ struct pci_dev *msi_desc_to_pci_dev(struct msi_desc *desc) · 854 unmodified lines
11261128 {
11271129 return to_pci_dev(desc->dev);
11281130 }
1131+EXPORT_SYMBOL(msi_desc_to_pci_dev);
11291132
11301133 void *msi_desc_to_pci_sysdata(struct msi_desc *desc)
11311134 {
@@ -1285,6 +1288,7 @@ struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode, · 153 unmodified lines
12851288 domain->bus_token = DOMAIN_BUS_PCI_MSI;
12861289 return domain;
12871290 }
1291+EXPORT_SYMBOL_GPL(pci_msi_create_irq_domain);
12881292
12891293 /**
12901294 * pci_msi_domain_alloc_irqs - Allocate interrupts for @dev in @domain
drivers/pci/pci-acpi.c+42−0
@@ -9,7 +9,9 @@ · 8 unmodified lines
99
1010 #include <linux/delay.h>
1111 #include <linux/init.h>
12+#include <linux/irqdomain.h>
1213 #include <linux/pci.h>
14+#include <linux/msi.h>
1315 #include <linux/pci_hotplug.h>
1416 #include <linux/module.h>
1517 #include <linux/pci-aspm.h>
@@ -689,6 +691,46 @@ static struct acpi_bus_type acpi_pci_bus = { · 673 unmodified lines
689691 .cleanup = pci_acpi_cleanup,
690692 };
691693
694+
695+static struct fwnode_handle *(*pci_msi_get_fwnode_cb)(struct device *dev);
696+
697+/**
698+ * pci_msi_register_fwnode_provider - Register callback to retrieve fwnode
699+ * @fn: Callback matching a device to a fwnode that identifies a PCI
700+ * MSI domain.
701+ *
702+ * This should be called by irqchip driver, which is the parent of
703+ * the MSI domain to provide callback interface to query fwnode.
704+ */
705+void
706+pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *))
707+{
708+ pci_msi_get_fwnode_cb = fn;
709+}
710+
711+/**
712+ * pci_host_bridge_acpi_msi_domain - Retrieve MSI domain of a PCI host bridge
713+ * @bus: The PCI host bridge bus.
714+ *
715+ * This function uses the callback function registered by
716+ * pci_msi_register_fwnode_provider() to retrieve the irq_domain with
717+ * type DOMAIN_BUS_PCI_MSI of the specified host bridge bus.
718+ * This returns NULL on error or when the domain is not found.
719+ */
720+struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
721+{
722+ struct fwnode_handle *fwnode;
723+
724+ if (!pci_msi_get_fwnode_cb)
725+ return NULL;
726+
727+ fwnode = pci_msi_get_fwnode_cb(&bus->dev);
728+ if (!fwnode)
729+ return NULL;
730+
731+ return irq_find_matching_fwnode(fwnode, DOMAIN_BUS_PCI_MSI);
732+}
733+
692734 static int __init acpi_pci_init(void)
693735 {
694736 int ret;
drivers/pci/probe.c+2−0
@@ -672,6 +672,8 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus) · 671 unmodified lines
672672 * should be called from here.
673673 */
674674 d = pci_host_bridge_of_msi_domain(bus);
675+ if (!d)
676+ d = pci_host_bridge_acpi_msi_domain(bus);
675677
676678 return d;
677679 }
include/linux/interrupt.h+1−0
@@ -195,6 +195,7 @@ extern void disable_irq(unsigned int irq); · 194 unmodified lines
195195 extern void disable_percpu_irq(unsigned int irq);
196196 extern void enable_irq(unsigned int irq);
197197 extern void enable_percpu_irq(unsigned int irq, unsigned int type);
198+extern bool irq_percpu_is_enabled(unsigned int irq);
198199 extern void irq_wake_thread(unsigned int irq, void *dev_id);
199200
200201 /* The following three functions are for the core kernel use only. */
include/linux/irqchip/arm-gic.h+12−1
@@ -103,10 +103,21 @@ struct device_node; · 102 unmodified lines
103103 void gic_cascade_irq(unsigned int gic_nr, unsigned int irq);
104104 int gic_cpu_if_down(unsigned int gic_nr);
105105
106+/*
107+ * Subdrivers that need some preparatory work can initialize their
108+ * chips and call this to register their GICs.
109+ */
110+int gic_of_init(struct device_node *node, struct device_node *parent);
111+
112+/*
113+ * Legacy platforms not converted to DT yet must use this to init
114+ * their GIC
115+ */
106116 void gic_init(unsigned int nr, int start,
107117 void __iomem *dist , void __iomem *cpu);
108118
109−int gicv2m_of_init(struct device_node *node, struct irq_domain *parent);
119+int gicv2m_init(struct fwnode_handle *parent_handle,
120+ struct irq_domain *parent);
110121
111122 void gic_send_sgi(unsigned int cpu_id, unsigned int irq);
112123 int gic_get_cpu_id(unsigned int cpu);
include/linux/irqdesc.h+6−0
@@ -1,6 +1,8 @@
11 #ifndef _LINUX_IRQDESC_H
22 #define _LINUX_IRQDESC_H
33
4+#include <linux/rcupdate.h>
5+
46 /*
57 * Core internal functions to deal with irq descriptors
68 */
@@ -40,6 +42,7 @@ struct pt_regs; · 33 unmodified lines
4042 * IRQF_NO_SUSPEND set
4143 * @force_resume_depth: number of irqactions on a irq descriptor with
4244 * IRQF_FORCE_RESUME set
45+ * @rcu: rcu head for delayed free
4346 * @dir: /proc/irq/ procfs entry
4447 * @name: flow handler name for /proc/interrupts output
4548 */
@@ -81,6 +84,9 @@ struct irq_desc { · 35 unmodified lines
8184 #endif
8285 #ifdef CONFIG_PROC_FS
8386 struct proc_dir_entry *dir;
87+#endif
88+#ifdef CONFIG_SPARSE_IRQ
89+ struct rcu_head rcu;
8490 #endif
8591 int parent_irq;
8692 struct module *owner;
include/linux/irqdomain.h+13−0
@@ -211,6 +211,11 @@ static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node) · 210 unmodified lines
211211 return node ? &node->fwnode : NULL;
212212 }
213213
214+static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
215+{
216+ return fwnode && fwnode->type == FWNODE_IRQCHIP;
217+}
218+
214219 static inline struct irq_domain *irq_find_matching_host(struct device_node *node,
215220 enum irq_domain_bus_token bus_token)
216221 {
@@ -367,6 +372,9 @@ static inline int irq_domain_alloc_irqs(struct irq_domain *domain, · 150 unmodified lines
367372 return __irq_domain_alloc_irqs(domain, -1, nr_irqs, node, arg, false);
368373 }
369374
375+extern int irq_domain_alloc_irqs_recursive(struct irq_domain *domain,
376+ unsigned int irq_base,
377+ unsigned int nr_irqs, void *arg);
370378 extern int irq_domain_set_hwirq_and_chip(struct irq_domain *domain,
371379 unsigned int virq,
372380 irq_hw_number_t hwirq,
@@ -410,6 +418,11 @@ static inline bool irq_domain_is_hierarchy(struct irq_domain *domain) · 37 unmodified lines
410418 static inline void irq_dispose_mapping(unsigned int virq) { }
411419 static inline void irq_domain_activate_irq(struct irq_data *data) { }
412420 static inline void irq_domain_deactivate_irq(struct irq_data *data) { }
421+static inline struct irq_domain *irq_find_matching_fwnode(
422+ struct fwnode_handle *fwnode, enum irq_domain_bus_token bus_token)
423+{
424+ return NULL;
425+}
413426 #endif /* !CONFIG_IRQ_DOMAIN */
414427
415428 #endif /* _LINUX_IRQDOMAIN_H */
include/linux/msi.h+18−0
@@ -174,6 +174,7 @@ struct msi_controller { · 173 unmodified lines
174174 #include <asm/msi.h>
175175
176176 struct irq_domain;
177+struct irq_domain_ops;
177178 struct irq_chip;
178179 struct device_node;
179180 struct fwnode_handle;
@@ -279,6 +280,23 @@ struct irq_domain *platform_msi_create_irq_domain(struct fwnode_handle *fwnode, · 99 unmodified lines
279280 int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec,
280281 irq_write_msi_msg_t write_msi_msg);
281282 void platform_msi_domain_free_irqs(struct device *dev);
283+
284+/* When an MSI domain is used as an intermediate domain */
285+int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
286+ int nvec, msi_alloc_info_t *args);
287+int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev,
288+ int virq, int nvec, msi_alloc_info_t *args);
289+struct irq_domain *
290+platform_msi_create_device_domain(struct device *dev,
291+ unsigned int nvec,
292+ irq_write_msi_msg_t write_msi_msg,
293+ const struct irq_domain_ops *ops,
294+ void *host_data);
295+int platform_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
296+ unsigned int nr_irqs);
297+void platform_msi_domain_free(struct irq_domain *domain, unsigned int virq,
298+ unsigned int nvec);
299+void *platform_msi_get_host_data(struct irq_domain *domain);
282300 #endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */
283301
284302 #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
include/linux/pci.h+10−0
@@ -1946,6 +1946,16 @@ static inline struct irq_domain * · 1945 unmodified lines
19461946 pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; }
19471947 #endif /* CONFIG_OF */
19481948
1949+#ifdef CONFIG_ACPI
1950+struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus);
1951+
1952+void
1953+pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *));
1954+#else
1955+static inline struct irq_domain *
1956+pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
1957+#endif
1958+
19491959 #ifdef CONFIG_EEH
19501960 static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
19511961 {
include/linux/platform_data/irq-renesas-intc-irqpin.h+0−29
@@ -1,29 +0,0 @@
1−/*
2− * Renesas INTC External IRQ Pin Driver
3− *
4− * Copyright (C) 2013 Magnus Damm
5− *
6− * This program is free software; you can redistribute it and/or modify
7− * it under the terms of the GNU General Public License as published by
8− * the Free Software Foundation; either version 2 of the License
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU General Public License for more details.
14− *
15− * You should have received a copy of the GNU General Public License
16− * along with this program; if not, write to the Free Software
17− * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18− */
19−
20−#ifndef __IRQ_RENESAS_INTC_IRQPIN_H__
21−#define __IRQ_RENESAS_INTC_IRQPIN_H__
22−
23−struct renesas_intc_irqpin_config {
24− unsigned int sense_bitfield_width;
25− unsigned int irq_base;
26− bool control_parent;
27−};
28−
29−#endif /* __IRQ_RENESAS_INTC_IRQPIN_H__ */
kernel/irq/chip.c+5−4
@@ -338,7 +338,6 @@ void handle_nested_irq(unsigned int irq) · 337 unmodified lines
338338 raw_spin_lock_irq(&desc->lock);
339339
340340 desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
341− kstat_incr_irqs_this_cpu(desc);
342341
343342 action = desc->action;
344343 if (unlikely(!action || irqd_irq_disabled(&desc->irq_data))) {
@@ -346,6 +345,7 @@ void handle_nested_irq(unsigned int irq) · 1 unmodified line
346345 goto out_unlock;
347346 }
348347
348+ kstat_incr_irqs_this_cpu(desc);
349349 irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS);
350350 raw_spin_unlock_irq(&desc->lock);
351351
@@ -412,13 +412,13 @@ void handle_simple_irq(struct irq_desc *desc) · 60 unmodified lines
412412 goto out_unlock;
413413
414414 desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
415− kstat_incr_irqs_this_cpu(desc);
416415
417416 if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) {
418417 desc->istate |= IRQS_PENDING;
419418 goto out_unlock;
420419 }
421420
421+ kstat_incr_irqs_this_cpu(desc);
422422 handle_irq_event(desc);
423423
424424 out_unlock:
@@ -462,7 +462,6 @@ void handle_level_irq(struct irq_desc *desc) · 37 unmodified lines
462462 goto out_unlock;
463463
464464 desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
465− kstat_incr_irqs_this_cpu(desc);
466465
467466 /*
468467 * If its disabled or no action available
@@ -473,6 +472,7 @@ void handle_level_irq(struct irq_desc *desc) · 4 unmodified lines
473472 goto out_unlock;
474473 }
475474
475+ kstat_incr_irqs_this_cpu(desc);
476476 handle_irq_event(desc);
477477
478478 cond_unmask_irq(desc);
@@ -532,7 +532,6 @@ void handle_fasteoi_irq(struct irq_desc *desc) · 53 unmodified lines
532532 goto out;
533533
534534 desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
535− kstat_incr_irqs_this_cpu(desc);
536535
537536 /*
538537 * If its disabled or no action available
@@ -544,6 +543,7 @@ void handle_fasteoi_irq(struct irq_desc *desc) · 5 unmodified lines
544543 goto out;
545544 }
546545
546+ kstat_incr_irqs_this_cpu(desc);
547547 if (desc->istate & IRQS_ONESHOT)
548548 mask_irq(desc);
549549
@@ -950,6 +950,7 @@ void irq_chip_ack_parent(struct irq_data *data) · 400 unmodified lines
950950 data = data->parent_data;
951951 data->chip->irq_ack(data);
952952 }
953+EXPORT_SYMBOL_GPL(irq_chip_ack_parent);
953954
954955 /**
955956 * irq_chip_mask_parent - Mask the parent interrupt
kernel/irq/irqdesc.c+16−3
@@ -159,6 +159,7 @@ static struct irq_desc *alloc_desc(int irq, int node, struct module *owner) · 158 unmodified lines
159159
160160 raw_spin_lock_init(&desc->lock);
161161 lockdep_set_class(&desc->lock, &irq_desc_lock_class);
162+ init_rcu_head(&desc->rcu);
162163
163164 desc_set_defaults(irq, desc, node, owner);
164165
@@ -171,6 +172,15 @@ err_desc: · 6 unmodified lines
171172 return NULL;
172173 }
173174
175+static void delayed_free_desc(struct rcu_head *rhp)
176+{
177+ struct irq_desc *desc = container_of(rhp, struct irq_desc, rcu);
178+
179+ free_masks(desc);
180+ free_percpu(desc->kstat_irqs);
181+ kfree(desc);
182+}
183+
174184 static void free_desc(unsigned int irq)
175185 {
176186 struct irq_desc *desc = irq_to_desc(irq);
@@ -187,9 +197,12 @@ static void free_desc(unsigned int irq) · 10 unmodified lines
187197 delete_irq_desc(irq);
188198 mutex_unlock(&sparse_irq_lock);
189199
190− free_masks(desc);
191− free_percpu(desc->kstat_irqs);
192− kfree(desc);
200+ /*
201+ * We free the descriptor, masks and stat fields via RCU. That
202+ * allows demultiplex interrupts to do rcu based management of
203+ * the child interrupts.
204+ */
205+ call_rcu(&desc->rcu, delayed_free_desc);
193206 }
194207
195208 static int alloc_descs(unsigned int start, unsigned int cnt, int node,
kernel/irq/irqdomain.c+8−4
@@ -60,6 +60,7 @@ struct fwnode_handle *irq_domain_alloc_fwnode(void *data) · 59 unmodified lines
6060 fwid->fwnode.type = FWNODE_IRQCHIP;
6161 return &fwid->fwnode;
6262 }
63+EXPORT_SYMBOL_GPL(irq_domain_alloc_fwnode);
6364
6465 /**
6566 * irq_domain_free_fwnode - Free a non-OF-backed fwnode_handle
@@ -70,13 +71,14 @@ void irq_domain_free_fwnode(struct fwnode_handle *fwnode) · 4 unmodified lines
7071 {
7172 struct irqchip_fwid *fwid;
7273
73− if (WARN_ON(fwnode->type != FWNODE_IRQCHIP))
74+ if (WARN_ON(!is_fwnode_irqchip(fwnode)))
7475 return;
7576
7677 fwid = container_of(fwnode, struct irqchip_fwid, fwnode);
7778 kfree(fwid->name);
7879 kfree(fwid);
7980 }
81+EXPORT_SYMBOL_GPL(irq_domain_free_fwnode);
8082
8183 /**
8284 * __irq_domain_add() - Allocate a new irq_domain data structure
@@ -1013,6 +1015,7 @@ struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain, · 930 unmodified lines
10131015
10141016 return NULL;
10151017 }
1018+EXPORT_SYMBOL_GPL(irq_domain_get_irq_data);
10161019
10171020 /**
10181021 * irq_domain_set_hwirq_and_chip - Set hwirq and irqchip of @virq at @domain
@@ -1125,9 +1128,9 @@ static void irq_domain_free_irqs_recursive(struct irq_domain *domain, · 106 unmodified lines
11251128 }
11261129 }
11271130
1128−static int irq_domain_alloc_irqs_recursive(struct irq_domain *domain,
1129− unsigned int irq_base,
1130− unsigned int nr_irqs, void *arg)
1131+int irq_domain_alloc_irqs_recursive(struct irq_domain *domain,
1132+ unsigned int irq_base,
1133+ unsigned int nr_irqs, void *arg)
11311134 {
11321135 int ret = 0;
11331136 struct irq_domain *parent = domain->parent;
@@ -1343,6 +1346,7 @@ struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain, · 209 unmodified lines
13431346
13441347 return (irq_data && irq_data->domain == domain) ? irq_data : NULL;
13451348 }
1349+EXPORT_SYMBOL_GPL(irq_domain_get_irq_data);
13461350
13471351 /**
13481352 * irq_domain_set_info - Set the complete data for a @virq in @domain
kernel/irq/manage.c+25−0
@@ -1743,6 +1743,31 @@ out: · 1742 unmodified lines
17431743 }
17441744 EXPORT_SYMBOL_GPL(enable_percpu_irq);
17451745
1746+/**
1747+ * irq_percpu_is_enabled - Check whether the per cpu irq is enabled
1748+ * @irq: Linux irq number to check for
1749+ *
1750+ * Must be called from a non migratable context. Returns the enable
1751+ * state of a per cpu interrupt on the current cpu.
1752+ */
1753+bool irq_percpu_is_enabled(unsigned int irq)
1754+{
1755+ unsigned int cpu = smp_processor_id();
1756+ struct irq_desc *desc;
1757+ unsigned long flags;
1758+ bool is_enabled;
1759+
1760+ desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU);
1761+ if (!desc)
1762+ return false;
1763+
1764+ is_enabled = cpumask_test_cpu(cpu, desc->percpu_enabled);
1765+ irq_put_desc_unlock(desc, flags);
1766+
1767+ return is_enabled;
1768+}
1769+EXPORT_SYMBOL_GPL(irq_percpu_is_enabled);
1770+
17461771 void disable_percpu_irq(unsigned int irq)
17471772 {
17481773 unsigned int cpu = smp_processor_id();
kernel/irq/msi.c+55−3
@@ -252,6 +252,60 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode, · 251 unmodified lines
252252 &msi_domain_ops, info);
253253 }
254254
255+int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
256+ int nvec, msi_alloc_info_t *arg)
257+{
258+ struct msi_domain_info *info = domain->host_data;
259+ struct msi_domain_ops *ops = info->ops;
260+ int ret;
261+
262+ ret = ops->msi_check(domain, info, dev);
263+ if (ret == 0)
264+ ret = ops->msi_prepare(domain, dev, nvec, arg);
265+
266+ return ret;
267+}
268+
269+int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev,
270+ int virq, int nvec, msi_alloc_info_t *arg)
271+{
272+ struct msi_domain_info *info = domain->host_data;
273+ struct msi_domain_ops *ops = info->ops;
274+ struct msi_desc *desc;
275+ int ret = 0;
276+
277+ for_each_msi_entry(desc, dev) {
278+ /* Don't even try the multi-MSI brain damage. */
279+ if (WARN_ON(!desc->irq || desc->nvec_used != 1)) {
280+ ret = -EINVAL;
281+ break;
282+ }
283+
284+ if (!(desc->irq >= virq && desc->irq < (virq + nvec)))
285+ continue;
286+
287+ ops->set_desc(arg, desc);
288+ /* Assumes the domain mutex is held! */
289+ ret = irq_domain_alloc_irqs_recursive(domain, virq, 1, arg);
290+ if (ret)
291+ break;
292+
293+ irq_set_msi_desc_off(virq, 0, desc);
294+ }
295+
296+ if (ret) {
297+ /* Mop up the damage */
298+ for_each_msi_entry(desc, dev) {
299+ if (!(desc->irq >= virq && desc->irq < (virq + nvec)))
300+ continue;
301+
302+ irq_domain_free_irqs_common(domain, desc->irq, 1);
303+ }
304+ }
305+
306+ return ret;
307+}
308+
255309 /**
256310 * msi_domain_alloc_irqs - Allocate interrupts from a MSI interrupt domain
257311 * @domain: The domain to allocate from
@@ -270,9 +324,7 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, · 12 unmodified lines
270324 struct msi_desc *desc;
271325 int i, ret, virq = -1;
272326
273− ret = ops->msi_check(domain, info, dev);
274− if (ret == 0)
275− ret = ops->msi_prepare(domain, dev, nvec, &arg);
327+ ret = msi_domain_prepare_irqs(domain, dev, nvec, &arg);
276328 if (ret)
277329 return ret;
278330

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t