diff options
author | Jiang Liu <jiang.liu@linux.intel.com> | 2014-11-15 09:24:05 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2014-11-23 07:01:47 -0500 |
commit | aeeb59657c35da64068336c20068da237f41ab76 (patch) | |
tree | c3571d9d742586e40a89893410ef1ce9caddd00e /kernel/irq | |
parent | d9109698be6e7439e6082aa00d79d4556114739b (diff) |
genirq: Provide default callbacks for msi_domain_ops
Extend struct msi_domain_info and provide default callbacks for
msi_domain_ops.
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Yijing Wang <wangyijing@huawei.com>
Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Alexander Gordeev <agordeev@redhat.com>
Link: http://lkml.kernel.org/r/1416061447-9472-8-git-send-email-jiang.liu@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/irq')
-rw-r--r-- | kernel/irq/msi.c | 111 |
1 files changed, 103 insertions, 8 deletions
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 23111aaa06b2..d0fe84d881f6 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * This file contains common code to support Message Signalled Interrupt for | 9 | * This file contains common code to support Message Signalled Interrupt for |
10 | * PCI compatible and non PCI compatible devices. | 10 | * PCI compatible and non PCI compatible devices. |
11 | */ | 11 | */ |
12 | #include <linux/types.h> | ||
13 | #include <linux/device.h> | ||
12 | #include <linux/irq.h> | 14 | #include <linux/irq.h> |
13 | #include <linux/irqdomain.h> | 15 | #include <linux/irqdomain.h> |
14 | #include <linux/msi.h> | 16 | #include <linux/msi.h> |
@@ -110,23 +112,112 @@ static struct irq_domain_ops msi_domain_ops = { | |||
110 | .deactivate = msi_domain_deactivate, | 112 | .deactivate = msi_domain_deactivate, |
111 | }; | 113 | }; |
112 | 114 | ||
115 | #ifdef GENERIC_MSI_DOMAIN_OPS | ||
116 | static irq_hw_number_t msi_domain_ops_get_hwirq(struct msi_domain_info *info, | ||
117 | msi_alloc_info_t *arg) | ||
118 | { | ||
119 | return arg->hwirq; | ||
120 | } | ||
121 | |||
122 | static int msi_domain_ops_prepare(struct irq_domain *domain, struct device *dev, | ||
123 | int nvec, msi_alloc_info_t *arg) | ||
124 | { | ||
125 | memset(arg, 0, sizeof(*arg)); | ||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static void msi_domain_ops_set_desc(msi_alloc_info_t *arg, | ||
130 | struct msi_desc *desc) | ||
131 | { | ||
132 | arg->desc = desc; | ||
133 | } | ||
134 | #else | ||
135 | #define msi_domain_ops_get_hwirq NULL | ||
136 | #define msi_domain_ops_prepare NULL | ||
137 | #define msi_domain_ops_set_desc NULL | ||
138 | #endif /* !GENERIC_MSI_DOMAIN_OPS */ | ||
139 | |||
140 | static int msi_domain_ops_init(struct irq_domain *domain, | ||
141 | struct msi_domain_info *info, | ||
142 | unsigned int virq, irq_hw_number_t hwirq, | ||
143 | msi_alloc_info_t *arg) | ||
144 | { | ||
145 | irq_domain_set_hwirq_and_chip(domain, virq, hwirq, info->chip, | ||
146 | info->chip_data); | ||
147 | if (info->handler && info->handler_name) { | ||
148 | __irq_set_handler(virq, info->handler, 0, info->handler_name); | ||
149 | if (info->handler_data) | ||
150 | irq_set_handler_data(virq, info->handler_data); | ||
151 | } | ||
152 | return 0; | ||
153 | } | ||
154 | |||
155 | static int msi_domain_ops_check(struct irq_domain *domain, | ||
156 | struct msi_domain_info *info, | ||
157 | struct device *dev) | ||
158 | { | ||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | static struct msi_domain_ops msi_domain_ops_default = { | ||
163 | .get_hwirq = msi_domain_ops_get_hwirq, | ||
164 | .msi_init = msi_domain_ops_init, | ||
165 | .msi_check = msi_domain_ops_check, | ||
166 | .msi_prepare = msi_domain_ops_prepare, | ||
167 | .set_desc = msi_domain_ops_set_desc, | ||
168 | }; | ||
169 | |||
170 | static void msi_domain_update_dom_ops(struct msi_domain_info *info) | ||
171 | { | ||
172 | struct msi_domain_ops *ops = info->ops; | ||
173 | |||
174 | if (ops == NULL) { | ||
175 | info->ops = &msi_domain_ops_default; | ||
176 | return; | ||
177 | } | ||
178 | |||
179 | if (ops->get_hwirq == NULL) | ||
180 | ops->get_hwirq = msi_domain_ops_default.get_hwirq; | ||
181 | if (ops->msi_init == NULL) | ||
182 | ops->msi_init = msi_domain_ops_default.msi_init; | ||
183 | if (ops->msi_check == NULL) | ||
184 | ops->msi_check = msi_domain_ops_default.msi_check; | ||
185 | if (ops->msi_prepare == NULL) | ||
186 | ops->msi_prepare = msi_domain_ops_default.msi_prepare; | ||
187 | if (ops->set_desc == NULL) | ||
188 | ops->set_desc = msi_domain_ops_default.set_desc; | ||
189 | } | ||
190 | |||
191 | static void msi_domain_update_chip_ops(struct msi_domain_info *info) | ||
192 | { | ||
193 | struct irq_chip *chip = info->chip; | ||
194 | |||
195 | BUG_ON(!chip); | ||
196 | if (!chip->irq_mask) | ||
197 | chip->irq_mask = pci_msi_mask_irq; | ||
198 | if (!chip->irq_unmask) | ||
199 | chip->irq_unmask = pci_msi_unmask_irq; | ||
200 | if (!chip->irq_set_affinity) | ||
201 | chip->irq_set_affinity = msi_domain_set_affinity; | ||
202 | } | ||
203 | |||
113 | /** | 204 | /** |
114 | * msi_create_irq_domain - Create a MSI interrupt domain | 205 | * msi_create_irq_domain - Create a MSI interrupt domain |
115 | * @of_node: Optional device-tree node of the interrupt controller | 206 | * @of_node: Optional device-tree node of the interrupt controller |
116 | * @info: MSI domain info | 207 | * @info: MSI domain info |
117 | * @parent: Parent irq domain | 208 | * @parent: Parent irq domain |
118 | */ | 209 | */ |
119 | struct irq_domain *msi_create_irq_domain(struct device_node *of_node, | 210 | struct irq_domain *msi_create_irq_domain(struct device_node *node, |
120 | struct msi_domain_info *info, | 211 | struct msi_domain_info *info, |
121 | struct irq_domain *parent) | 212 | struct irq_domain *parent) |
122 | { | 213 | { |
123 | struct irq_domain *domain; | 214 | if (info->flags & MSI_FLAG_USE_DEF_DOM_OPS) |
215 | msi_domain_update_dom_ops(info); | ||
216 | if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) | ||
217 | msi_domain_update_chip_ops(info); | ||
124 | 218 | ||
125 | domain = irq_domain_add_tree(of_node, &msi_domain_ops, info); | 219 | return irq_domain_add_hierarchy(parent, 0, 0, node, &msi_domain_ops, |
126 | if (domain) | 220 | info); |
127 | domain->parent = parent; | ||
128 | |||
129 | return domain; | ||
130 | } | 221 | } |
131 | 222 | ||
132 | /** | 223 | /** |
@@ -155,8 +246,12 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, | |||
155 | 246 | ||
156 | for_each_msi_entry(desc, dev) { | 247 | for_each_msi_entry(desc, dev) { |
157 | ops->set_desc(&arg, desc); | 248 | ops->set_desc(&arg, desc); |
249 | if (info->flags & MSI_FLAG_IDENTITY_MAP) | ||
250 | virq = (int)ops->get_hwirq(info, &arg); | ||
251 | else | ||
252 | virq = -1; | ||
158 | 253 | ||
159 | virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used, | 254 | virq = __irq_domain_alloc_irqs(domain, virq, desc->nvec_used, |
160 | dev_to_node(dev), &arg, false); | 255 | dev_to_node(dev), &arg, false); |
161 | if (virq < 0) { | 256 | if (virq < 0) { |
162 | ret = -ENOSPC; | 257 | ret = -ENOSPC; |