aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@linaro.org>2013-06-08 07:57:40 -0400
committerGrant Likely <grant.likely@linaro.org>2013-06-10 06:52:09 -0400
commitfa40f377577752b83252b9d2b3165d4acee0eb7c (patch)
tree81314980dfd943e07cadd7415a6c092cf91e4b19
parent1aa0dd94ca07df818cf14588c9031ab1d7fd84d3 (diff)
irqdomain: Clean up aftermath of irq_domain refactoring
After refactoring the irqdomain code, there are a number of API functions that are merely empty wrappers around core code. Drop those wrappers out of the C file and replace them with static inlines in the header. Signed-off-by: Grant Likely <grant.likely@linaro.org>
-rw-r--r--arch/powerpc/platforms/cell/beat_interrupt.c2
-rw-r--r--arch/powerpc/platforms/powermac/smp.c2
-rw-r--r--include/linux/irqdomain.h31
-rw-r--r--kernel/irq/irqdomain.c127
4 files changed, 62 insertions, 100 deletions
diff --git a/arch/powerpc/platforms/cell/beat_interrupt.c b/arch/powerpc/platforms/cell/beat_interrupt.c
index 8c6dc42ecf65..9e5dfbcc00af 100644
--- a/arch/powerpc/platforms/cell/beat_interrupt.c
+++ b/arch/powerpc/platforms/cell/beat_interrupt.c
@@ -239,7 +239,7 @@ void __init beatic_init_IRQ(void)
239 ppc_md.get_irq = beatic_get_irq; 239 ppc_md.get_irq = beatic_get_irq;
240 240
241 /* Allocate an irq host */ 241 /* Allocate an irq host */
242 beatic_host = irq_domain_add_nomap(NULL, 0, &beatic_pic_host_ops, NULL); 242 beatic_host = irq_domain_add_nomap(NULL, ~0, &beatic_pic_host_ops, NULL);
243 BUG_ON(beatic_host == NULL); 243 BUG_ON(beatic_host == NULL);
244 irq_set_default_host(beatic_host); 244 irq_set_default_host(beatic_host);
245} 245}
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index bdb738a69e41..f921067d924d 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -192,7 +192,7 @@ static int psurge_secondary_ipi_init(void)
192{ 192{
193 int rc = -ENOMEM; 193 int rc = -ENOMEM;
194 194
195 psurge_host = irq_domain_add_nomap(NULL, 0, &psurge_host_ops, NULL); 195 psurge_host = irq_domain_add_nomap(NULL, ~0, &psurge_host_ops, NULL);
196 196
197 if (psurge_host) 197 if (psurge_host)
198 psurge_secondary_virq = irq_create_direct_mapping(psurge_host); 198 psurge_secondary_virq = irq_create_direct_mapping(psurge_host);
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 51ef84a3c990..fd4b26f8f44c 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -110,6 +110,10 @@ struct irq_domain {
110}; 110};
111 111
112#ifdef CONFIG_IRQ_DOMAIN 112#ifdef CONFIG_IRQ_DOMAIN
113struct irq_domain *__irq_domain_add(struct device_node *of_node,
114 int size, int direct_max,
115 const struct irq_domain_ops *ops,
116 void *host_data);
113struct irq_domain *irq_domain_add_simple(struct device_node *of_node, 117struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
114 unsigned int size, 118 unsigned int size,
115 unsigned int first_irq, 119 unsigned int first_irq,
@@ -121,17 +125,30 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
121 irq_hw_number_t first_hwirq, 125 irq_hw_number_t first_hwirq,
122 const struct irq_domain_ops *ops, 126 const struct irq_domain_ops *ops,
123 void *host_data); 127 void *host_data);
124struct irq_domain *irq_domain_add_linear(struct device_node *of_node, 128extern struct irq_domain *irq_find_host(struct device_node *node);
129extern void irq_set_default_host(struct irq_domain *host);
130
131/**
132 * irq_domain_add_linear() - Allocate and register a linear revmap irq_domain.
133 * @of_node: pointer to interrupt controller's device tree node.
134 * @size: Number of interrupts in the domain.
135 * @ops: map/unmap domain callbacks
136 * @host_data: Controller private data pointer
137 */
138static inline struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
125 unsigned int size, 139 unsigned int size,
126 const struct irq_domain_ops *ops, 140 const struct irq_domain_ops *ops,
127 void *host_data); 141 void *host_data)
128struct irq_domain *irq_domain_add_nomap(struct device_node *of_node, 142{
143 return __irq_domain_add(of_node, size, 0, ops, host_data);
144}
145static inline struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
129 unsigned int max_irq, 146 unsigned int max_irq,
130 const struct irq_domain_ops *ops, 147 const struct irq_domain_ops *ops,
131 void *host_data); 148 void *host_data)
132extern struct irq_domain *irq_find_host(struct device_node *node); 149{
133extern void irq_set_default_host(struct irq_domain *host); 150 return __irq_domain_add(of_node, 0, max_irq, ops, host_data);
134 151}
135static inline struct irq_domain *irq_domain_add_legacy_isa( 152static inline struct irq_domain *irq_domain_add_legacy_isa(
136 struct device_node *of_node, 153 struct device_node *of_node,
137 const struct irq_domain_ops *ops, 154 const struct irq_domain_ops *ops,
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index c38be78fceb4..e0db59e2eef6 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -23,8 +23,11 @@ static DEFINE_MUTEX(revmap_trees_mutex);
23static struct irq_domain *irq_default_domain; 23static struct irq_domain *irq_default_domain;
24 24
25/** 25/**
26 * irq_domain_alloc() - Allocate a new irq_domain data structure 26 * __irq_domain_add() - Allocate a new irq_domain data structure
27 * @of_node: optional device-tree node of the interrupt controller 27 * @of_node: optional device-tree node of the interrupt controller
28 * @size: Size of linear map; 0 for radix mapping only
29 * @direct_max: Maximum value of direct maps; Use ~0 for no limit; 0 for no
30 * direct mapping
28 * @ops: map/unmap domain callbacks 31 * @ops: map/unmap domain callbacks
29 * @host_data: Controller private data pointer 32 * @host_data: Controller private data pointer
30 * 33 *
@@ -32,10 +35,10 @@ static struct irq_domain *irq_default_domain;
32 * register allocated irq_domain with irq_domain_register(). Returns pointer 35 * register allocated irq_domain with irq_domain_register(). Returns pointer
33 * to IRQ domain, or NULL on failure. 36 * to IRQ domain, or NULL on failure.
34 */ 37 */
35static struct irq_domain *irq_domain_alloc(struct device_node *of_node, 38struct irq_domain *__irq_domain_add(struct device_node *of_node,
36 int size, 39 int size, int direct_max,
37 const struct irq_domain_ops *ops, 40 const struct irq_domain_ops *ops,
38 void *host_data) 41 void *host_data)
39{ 42{
40 struct irq_domain *domain; 43 struct irq_domain *domain;
41 44
@@ -50,23 +53,16 @@ static struct irq_domain *irq_domain_alloc(struct device_node *of_node,
50 domain->host_data = host_data; 53 domain->host_data = host_data;
51 domain->of_node = of_node_get(of_node); 54 domain->of_node = of_node_get(of_node);
52 domain->revmap_size = size; 55 domain->revmap_size = size;
56 domain->revmap_direct_max_irq = direct_max;
53 57
54 return domain;
55}
56
57static void irq_domain_free(struct irq_domain *domain)
58{
59 of_node_put(domain->of_node);
60 kfree(domain);
61}
62
63static void irq_domain_add(struct irq_domain *domain)
64{
65 mutex_lock(&irq_domain_mutex); 58 mutex_lock(&irq_domain_mutex);
66 list_add(&domain->link, &irq_domain_list); 59 list_add(&domain->link, &irq_domain_list);
67 mutex_unlock(&irq_domain_mutex); 60 mutex_unlock(&irq_domain_mutex);
61
68 pr_debug("Added domain %s\n", domain->name); 62 pr_debug("Added domain %s\n", domain->name);
63 return domain;
69} 64}
65EXPORT_SYMBOL_GPL(__irq_domain_add);
70 66
71/** 67/**
72 * irq_domain_remove() - Remove an irq domain. 68 * irq_domain_remove() - Remove an irq domain.
@@ -99,30 +95,28 @@ void irq_domain_remove(struct irq_domain *domain)
99 95
100 pr_debug("Removed domain %s\n", domain->name); 96 pr_debug("Removed domain %s\n", domain->name);
101 97
102 irq_domain_free(domain); 98 of_node_put(domain->of_node);
99 kfree(domain);
103} 100}
104EXPORT_SYMBOL_GPL(irq_domain_remove); 101EXPORT_SYMBOL_GPL(irq_domain_remove);
105 102
106/** 103/**
107 * irq_domain_add_simple() - Allocate and register a simple irq_domain. 104 * irq_domain_add_simple() - Register an irq_domain and optionally map a range of irqs
108 * @of_node: pointer to interrupt controller's device tree node. 105 * @of_node: pointer to interrupt controller's device tree node.
109 * @size: total number of irqs in mapping 106 * @size: total number of irqs in mapping
110 * @first_irq: first number of irq block assigned to the domain, 107 * @first_irq: first number of irq block assigned to the domain,
111 * pass zero to assign irqs on-the-fly. This will result in a 108 * pass zero to assign irqs on-the-fly. If first_irq is non-zero, then
112 * linear IRQ domain so it is important to use irq_create_mapping() 109 * pre-map all of the irqs in the domain to virqs starting at first_irq.
113 * for each used IRQ, especially when SPARSE_IRQ is enabled.
114 * @ops: map/unmap domain callbacks 110 * @ops: map/unmap domain callbacks
115 * @host_data: Controller private data pointer 111 * @host_data: Controller private data pointer
116 * 112 *
117 * Allocates a legacy irq_domain if irq_base is positive or a linear 113 * Allocates an irq_domain, and optionally if first_irq is positive then also
118 * domain otherwise. For the legacy domain, IRQ descriptors will also 114 * allocate irq_descs and map all of the hwirqs to virqs starting at first_irq.
119 * be allocated.
120 * 115 *
121 * This is intended to implement the expected behaviour for most 116 * This is intended to implement the expected behaviour for most
122 * interrupt controllers which is that a linear mapping should 117 * interrupt controllers. If device tree is used, then first_irq will be 0 and
123 * normally be used unless the system requires a legacy mapping in 118 * irqs get mapped dynamically on the fly. However, if the controller requires
124 * order to support supplying interrupt numbers during non-DT 119 * static virq assignments (non-DT boot) then it will set that up correctly.
125 * registration of devices.
126 */ 120 */
127struct irq_domain *irq_domain_add_simple(struct device_node *of_node, 121struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
128 unsigned int size, 122 unsigned int size,
@@ -130,33 +124,25 @@ struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
130 const struct irq_domain_ops *ops, 124 const struct irq_domain_ops *ops,
131 void *host_data) 125 void *host_data)
132{ 126{
133 if (first_irq > 0) { 127 struct irq_domain *domain;
134 int irq_base; 128
129 domain = __irq_domain_add(of_node, size, 0, ops, host_data);
130 if (!domain)
131 return NULL;
135 132
133 if (first_irq > 0) {
136 if (IS_ENABLED(CONFIG_SPARSE_IRQ)) { 134 if (IS_ENABLED(CONFIG_SPARSE_IRQ)) {
137 /* 135 /* attempt to allocated irq_descs */
138 * Set the descriptor allocator to search for a 136 int rc = irq_alloc_descs(first_irq, first_irq, size,
139 * 1-to-1 mapping, such as irq_alloc_desc_at(). 137 of_node_to_nid(of_node));
140 * Use of_node_to_nid() which is defined to 138 if (rc < 0)
141 * numa_node_id() on platforms that have no custom
142 * implementation.
143 */
144 irq_base = irq_alloc_descs(first_irq, first_irq, size,
145 of_node_to_nid(of_node));
146 if (irq_base < 0) {
147 pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n", 139 pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
148 first_irq); 140 first_irq);
149 irq_base = first_irq; 141 }
150 } 142 WARN_ON(irq_domain_associate_many(domain, first_irq, 0, size));
151 } else
152 irq_base = first_irq;
153
154 return irq_domain_add_legacy(of_node, size, irq_base, 0,
155 ops, host_data);
156 } 143 }
157 144
158 /* A linear domain is the default */ 145 return domain;
159 return irq_domain_add_linear(of_node, size, ops, host_data);
160} 146}
161EXPORT_SYMBOL_GPL(irq_domain_add_simple); 147EXPORT_SYMBOL_GPL(irq_domain_add_simple);
162 148
@@ -184,11 +170,7 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
184{ 170{
185 struct irq_domain *domain; 171 struct irq_domain *domain;
186 172
187 pr_debug("Setting up legacy domain virq[%i:%i] ==> hwirq[%i:%i]\n", 173 domain = __irq_domain_add(of_node, first_hwirq + size, 0, ops, host_data);
188 first_irq, first_irq + size - 1,
189 (int)first_hwirq, (int)first_hwirq + size -1);
190
191 domain = irq_domain_add_linear(of_node, first_hwirq + size, ops, host_data);
192 if (!domain) 174 if (!domain)
193 return NULL; 175 return NULL;
194 176
@@ -199,43 +181,6 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
199EXPORT_SYMBOL_GPL(irq_domain_add_legacy); 181EXPORT_SYMBOL_GPL(irq_domain_add_legacy);
200 182
201/** 183/**
202 * irq_domain_add_linear() - Allocate and register a linear revmap irq_domain.
203 * @of_node: pointer to interrupt controller's device tree node.
204 * @size: Number of interrupts in the domain.
205 * @ops: map/unmap domain callbacks
206 * @host_data: Controller private data pointer
207 */
208struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
209 unsigned int size,
210 const struct irq_domain_ops *ops,
211 void *host_data)
212{
213 struct irq_domain *domain;
214
215 domain = irq_domain_alloc(of_node, size, ops, host_data);
216 if (!domain)
217 return NULL;
218
219 irq_domain_add(domain);
220 return domain;
221}
222EXPORT_SYMBOL_GPL(irq_domain_add_linear);
223
224struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
225 unsigned int max_irq,
226 const struct irq_domain_ops *ops,
227 void *host_data)
228{
229 struct irq_domain *domain = irq_domain_alloc(of_node, 0, ops, host_data);
230 if (domain) {
231 domain->revmap_direct_max_irq = max_irq ? max_irq : ~0;
232 irq_domain_add(domain);
233 }
234 return domain;
235}
236EXPORT_SYMBOL_GPL(irq_domain_add_nomap);
237
238/**
239 * irq_find_host() - Locates a domain for a given device node 184 * irq_find_host() - Locates a domain for a given device node
240 * @node: device-tree node of the interrupt controller 185 * @node: device-tree node of the interrupt controller
241 */ 186 */