kernel: bump 4.9 to 4.9.127
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.9 / 811-irqchip-support-layerscape.patch
1 From 5a5ff01c790d49c0f6fd247f68f2fd9a2128ea91 Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Wed, 17 Jan 2018 15:36:28 +0800
4 Subject: [PATCH 23/30] irqchip: support layerscape
5
6 This is an integrated patch for layerscape gic support.
7
8 Signed-off-by: Eric Auger <eric.auger@redhat.com>
9 Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
10 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
11 ---
12 drivers/irqchip/Makefile | 1 +
13 drivers/irqchip/irq-gic-v3-its.c | 1 +
14 include/linux/irqdomain.h | 36 ++++++++++++++++++++++++++++++++++++
15 kernel/irq/irqdomain.c | 39 +++++++++++++++++++++++++++++++++++++++
16 kernel/irq/msi.c | 4 ++--
17 5 files changed, 79 insertions(+), 2 deletions(-)
18
19 --- a/drivers/irqchip/Makefile
20 +++ b/drivers/irqchip/Makefile
21 @@ -74,3 +74,4 @@ obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scf
22 obj-$(CONFIG_EZNPS_GIC) += irq-eznps.o
23 obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o
24 obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o
25 +obj-$(CONFIG_QUICC_ENGINE) += irq-qeic.o
26 --- a/drivers/irqchip/irq-gic-v3-its.c
27 +++ b/drivers/irqchip/irq-gic-v3-its.c
28 @@ -1658,6 +1658,7 @@ static int its_init_domain(struct fwnode
29
30 inner_domain->parent = its_parent;
31 inner_domain->bus_token = DOMAIN_BUS_NEXUS;
32 + inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_REMAP;
33 info->ops = &its_msi_domain_ops;
34 info->data = its;
35 inner_domain->host_data = info;
36 --- a/include/linux/irqdomain.h
37 +++ b/include/linux/irqdomain.h
38 @@ -183,6 +183,12 @@ enum {
39 /* Irq domain is an IPI domain with single virq */
40 IRQ_DOMAIN_FLAG_IPI_SINGLE = (1 << 3),
41
42 + /* Irq domain implements MSIs */
43 + IRQ_DOMAIN_FLAG_MSI = (1 << 4),
44 +
45 + /* Irq domain implements MSI remapping */
46 + IRQ_DOMAIN_FLAG_MSI_REMAP = (1 << 5),
47 +
48 /*
49 * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved
50 * for implementation specific purposes and ignored by the
51 @@ -216,6 +222,7 @@ struct irq_domain *irq_domain_add_legacy
52 void *host_data);
53 extern struct irq_domain *irq_find_matching_fwspec(struct irq_fwspec *fwspec,
54 enum irq_domain_bus_token bus_token);
55 +extern bool irq_domain_check_msi_remap(void);
56 extern void irq_set_default_host(struct irq_domain *host);
57 extern int irq_domain_alloc_descs(int virq, unsigned int nr_irqs,
58 irq_hw_number_t hwirq, int node,
59 @@ -446,6 +453,19 @@ static inline bool irq_domain_is_ipi_sin
60 {
61 return domain->flags & IRQ_DOMAIN_FLAG_IPI_SINGLE;
62 }
63 +
64 +static inline bool irq_domain_is_msi(struct irq_domain *domain)
65 +{
66 + return domain->flags & IRQ_DOMAIN_FLAG_MSI;
67 +}
68 +
69 +static inline bool irq_domain_is_msi_remap(struct irq_domain *domain)
70 +{
71 + return domain->flags & IRQ_DOMAIN_FLAG_MSI_REMAP;
72 +}
73 +
74 +extern bool irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain);
75 +
76 #else /* CONFIG_IRQ_DOMAIN_HIERARCHY */
77 static inline void irq_domain_activate_irq(struct irq_data *data) { }
78 static inline void irq_domain_deactivate_irq(struct irq_data *data) { }
79 @@ -477,6 +497,22 @@ static inline bool irq_domain_is_ipi_sin
80 {
81 return false;
82 }
83 +
84 +static inline bool irq_domain_is_msi(struct irq_domain *domain)
85 +{
86 + return false;
87 +}
88 +
89 +static inline bool irq_domain_is_msi_remap(struct irq_domain *domain)
90 +{
91 + return false;
92 +}
93 +
94 +static inline bool
95 +irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain)
96 +{
97 + return false;
98 +}
99 #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */
100
101 #else /* CONFIG_IRQ_DOMAIN */
102 --- a/kernel/irq/irqdomain.c
103 +++ b/kernel/irq/irqdomain.c
104 @@ -278,6 +278,31 @@ struct irq_domain *irq_find_matching_fws
105 EXPORT_SYMBOL_GPL(irq_find_matching_fwspec);
106
107 /**
108 + * irq_domain_check_msi_remap - Check whether all MSI irq domains implement
109 + * IRQ remapping
110 + *
111 + * Return: false if any MSI irq domain does not support IRQ remapping,
112 + * true otherwise (including if there is no MSI irq domain)
113 + */
114 +bool irq_domain_check_msi_remap(void)
115 +{
116 + struct irq_domain *h;
117 + bool ret = true;
118 +
119 + mutex_lock(&irq_domain_mutex);
120 + list_for_each_entry(h, &irq_domain_list, link) {
121 + if (irq_domain_is_msi(h) &&
122 + !irq_domain_hierarchical_is_msi_remap(h)) {
123 + ret = false;
124 + break;
125 + }
126 + }
127 + mutex_unlock(&irq_domain_mutex);
128 + return ret;
129 +}
130 +EXPORT_SYMBOL_GPL(irq_domain_check_msi_remap);
131 +
132 +/**
133 * irq_set_default_host() - Set a "default" irq domain
134 * @domain: default domain pointer
135 *
136 @@ -1408,6 +1433,20 @@ static void irq_domain_check_hierarchy(s
137 if (domain->ops->alloc)
138 domain->flags |= IRQ_DOMAIN_FLAG_HIERARCHY;
139 }
140 +
141 +/**
142 + * irq_domain_hierarchical_is_msi_remap - Check if the domain or any
143 + * parent has MSI remapping support
144 + * @domain: domain pointer
145 + */
146 +bool irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain)
147 +{
148 + for (; domain; domain = domain->parent) {
149 + if (irq_domain_is_msi_remap(domain))
150 + return true;
151 + }
152 + return false;
153 +}
154 #else /* CONFIG_IRQ_DOMAIN_HIERARCHY */
155 /**
156 * irq_domain_get_irq_data - Get irq_data associated with @virq and @domain
157 --- a/kernel/irq/msi.c
158 +++ b/kernel/irq/msi.c
159 @@ -272,8 +272,8 @@ struct irq_domain *msi_create_irq_domain
160 if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS)
161 msi_domain_update_chip_ops(info);
162
163 - return irq_domain_create_hierarchy(parent, 0, 0, fwnode,
164 - &msi_domain_ops, info);
165 + return irq_domain_create_hierarchy(parent, IRQ_DOMAIN_FLAG_MSI, 0,
166 + fwnode, &msi_domain_ops, info);
167 }
168
169 int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,