Skip to content

Commit fe35ece

Browse files
committed
irqchip/riscv-imsic: Move to common MSI library
Simplify the leaf MSI domain handling in the RISC-V IMSIC driver by using msi_lib_init_dev_msi_info() and msi_lib_irq_domain_select() provided by the common MSI library. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Andrew Jones <[email protected]> Signed-off-by: Anup Patel <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 1c000dc commit fe35ece

File tree

2 files changed

+6
-116
lines changed

2 files changed

+6
-116
lines changed

drivers/irqchip/Kconfig

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -589,13 +589,7 @@ config RISCV_IMSIC
589589
select IRQ_DOMAIN_HIERARCHY
590590
select GENERIC_IRQ_MATRIX_ALLOCATOR
591591
select GENERIC_MSI_IRQ
592-
593-
config RISCV_IMSIC_PCI
594-
bool
595-
depends on RISCV_IMSIC
596-
depends on PCI
597-
depends on PCI_MSI
598-
default RISCV_IMSIC
592+
select IRQ_MSI_LIB
599593

600594
config SIFIVE_PLIC
601595
bool

drivers/irqchip/irq-riscv-imsic-platform.c

Lines changed: 5 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/spinlock.h>
2121
#include <linux/smp.h>
2222

23+
#include "irq-msi-lib.h"
2324
#include "irq-riscv-imsic-state.h"
2425

2526
static bool imsic_cpu_page_phys(unsigned int cpu, unsigned int guest_index,
@@ -174,22 +175,6 @@ static void imsic_irq_domain_free(struct irq_domain *domain, unsigned int virq,
174175
irq_domain_free_irqs_parent(domain, virq, nr_irqs);
175176
}
176177

177-
static int imsic_irq_domain_select(struct irq_domain *domain, struct irq_fwspec *fwspec,
178-
enum irq_domain_bus_token bus_token)
179-
{
180-
const struct msi_parent_ops *ops = domain->msi_parent_ops;
181-
u32 busmask = BIT(bus_token);
182-
183-
if (fwspec->fwnode != domain->fwnode || fwspec->param_count != 0)
184-
return 0;
185-
186-
/* Handle pure domain searches */
187-
if (bus_token == ops->bus_select_token)
188-
return 1;
189-
190-
return !!(ops->bus_select_mask & busmask);
191-
}
192-
193178
#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
194179
static void imsic_irq_debug_show(struct seq_file *m, struct irq_domain *d,
195180
struct irq_data *irqd, int ind)
@@ -206,110 +191,21 @@ static void imsic_irq_debug_show(struct seq_file *m, struct irq_domain *d,
206191
static const struct irq_domain_ops imsic_base_domain_ops = {
207192
.alloc = imsic_irq_domain_alloc,
208193
.free = imsic_irq_domain_free,
209-
.select = imsic_irq_domain_select,
194+
.select = msi_lib_irq_domain_select,
210195
#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
211196
.debug_show = imsic_irq_debug_show,
212197
#endif
213198
};
214199

215-
#ifdef CONFIG_RISCV_IMSIC_PCI
216-
217-
static void imsic_pci_mask_irq(struct irq_data *d)
218-
{
219-
pci_msi_mask_irq(d);
220-
irq_chip_mask_parent(d);
221-
}
222-
223-
static void imsic_pci_unmask_irq(struct irq_data *d)
224-
{
225-
irq_chip_unmask_parent(d);
226-
pci_msi_unmask_irq(d);
227-
}
228-
229-
#define MATCH_PCI_MSI BIT(DOMAIN_BUS_PCI_MSI)
230-
231-
#else
232-
233-
#define MATCH_PCI_MSI 0
234-
235-
#endif
236-
237-
static bool imsic_init_dev_msi_info(struct device *dev,
238-
struct irq_domain *domain,
239-
struct irq_domain *real_parent,
240-
struct msi_domain_info *info)
241-
{
242-
const struct msi_parent_ops *pops = real_parent->msi_parent_ops;
243-
244-
/* MSI parent domain specific settings */
245-
switch (real_parent->bus_token) {
246-
case DOMAIN_BUS_NEXUS:
247-
if (WARN_ON_ONCE(domain != real_parent))
248-
return false;
249-
#ifdef CONFIG_SMP
250-
info->chip->irq_set_affinity = irq_chip_set_affinity_parent;
251-
#endif
252-
break;
253-
default:
254-
WARN_ON_ONCE(1);
255-
return false;
256-
}
257-
258-
/* Is the target supported? */
259-
switch (info->bus_token) {
260-
#ifdef CONFIG_RISCV_IMSIC_PCI
261-
case DOMAIN_BUS_PCI_DEVICE_MSI:
262-
case DOMAIN_BUS_PCI_DEVICE_MSIX:
263-
info->chip->irq_mask = imsic_pci_mask_irq;
264-
info->chip->irq_unmask = imsic_pci_unmask_irq;
265-
break;
266-
#endif
267-
case DOMAIN_BUS_DEVICE_MSI:
268-
/*
269-
* Per-device MSI should never have any MSI feature bits
270-
* set. It's sole purpose is to create a dumb interrupt
271-
* chip which has a device specific irq_write_msi_msg()
272-
* callback.
273-
*/
274-
if (WARN_ON_ONCE(info->flags))
275-
return false;
276-
277-
/* Core managed MSI descriptors */
278-
info->flags |= MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS |
279-
MSI_FLAG_FREE_MSI_DESCS;
280-
break;
281-
case DOMAIN_BUS_WIRED_TO_MSI:
282-
break;
283-
default:
284-
WARN_ON_ONCE(1);
285-
return false;
286-
}
287-
288-
/* Use hierarchial chip operations re-trigger */
289-
info->chip->irq_retrigger = irq_chip_retrigger_hierarchy;
290-
291-
/*
292-
* Mask out the domain specific MSI feature flags which are not
293-
* supported by the real parent.
294-
*/
295-
info->flags &= pops->supported_flags;
296-
297-
/* Enforce the required flags */
298-
info->flags |= pops->required_flags;
299-
300-
return true;
301-
}
302-
303-
#define MATCH_PLATFORM_MSI BIT(DOMAIN_BUS_PLATFORM_MSI)
304-
305200
static const struct msi_parent_ops imsic_msi_parent_ops = {
306201
.supported_flags = MSI_GENERIC_FLAGS_MASK |
307202
MSI_FLAG_PCI_MSIX,
308203
.required_flags = MSI_FLAG_USE_DEF_DOM_OPS |
309-
MSI_FLAG_USE_DEF_CHIP_OPS,
204+
MSI_FLAG_USE_DEF_CHIP_OPS |
205+
MSI_FLAG_PCI_MSI_MASK_PARENT,
310206
.bus_select_token = DOMAIN_BUS_NEXUS,
311207
.bus_select_mask = MATCH_PCI_MSI | MATCH_PLATFORM_MSI,
312-
.init_dev_msi_info = imsic_init_dev_msi_info,
208+
.init_dev_msi_info = msi_lib_init_dev_msi_info,
313209
};
314210

315211
int imsic_irqdomain_init(void)

0 commit comments

Comments
 (0)