Skip to content

Commit 7a91ad7

Browse files
committed
irqchip/alpine-msi: Switch to msi_create_parent_irq_domain()
Move away from the legacy MSI domain setup, switch to use msi_create_parent_irq_domain(). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Nam Cao <namcao@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/ec08fea004e7c3aa18c3f5657a8cafeb1adfcc1d.1750860131.git.namcao@linutronix.de
1 parent f7c2dd9 commit 7a91ad7

2 files changed

Lines changed: 28 additions & 42 deletions

File tree

drivers/irqchip/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ config ALPINE_MSI
8585
bool
8686
depends on PCI
8787
select PCI_MSI
88+
select IRQ_MSI_LIB
8889
select GENERIC_IRQ_CHIP
8990

9091
config AL_FIC

drivers/irqchip/irq-alpine-msi.c

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <linux/irqchip.h>
1616
#include <linux/irqchip/arm-gic.h>
17+
#include <linux/irqchip/irq-msi-lib.h>
1718
#include <linux/msi.h>
1819
#include <linux/of.h>
1920
#include <linux/of_address.h>
@@ -36,26 +37,6 @@ struct alpine_msix_data {
3637
unsigned long *msi_map;
3738
};
3839

39-
static void alpine_msix_mask_msi_irq(struct irq_data *d)
40-
{
41-
pci_msi_mask_irq(d);
42-
irq_chip_mask_parent(d);
43-
}
44-
45-
static void alpine_msix_unmask_msi_irq(struct irq_data *d)
46-
{
47-
pci_msi_unmask_irq(d);
48-
irq_chip_unmask_parent(d);
49-
}
50-
51-
static struct irq_chip alpine_msix_irq_chip = {
52-
.name = "MSIx",
53-
.irq_mask = alpine_msix_mask_msi_irq,
54-
.irq_unmask = alpine_msix_unmask_msi_irq,
55-
.irq_eoi = irq_chip_eoi_parent,
56-
.irq_set_affinity = irq_chip_set_affinity_parent,
57-
};
58-
5940
static int alpine_msix_allocate_sgi(struct alpine_msix_data *priv, int num_req)
6041
{
6142
int first;
@@ -88,12 +69,6 @@ static void alpine_msix_compose_msi_msg(struct irq_data *data, struct msi_msg *m
8869
msg->data = 0;
8970
}
9071

91-
static struct msi_domain_info alpine_msix_domain_info = {
92-
.flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
93-
MSI_FLAG_PCI_MSIX,
94-
.chip = &alpine_msix_irq_chip,
95-
};
96-
9772
static struct irq_chip middle_irq_chip = {
9873
.name = "alpine_msix_middle",
9974
.irq_mask = irq_chip_mask_parent,
@@ -164,13 +139,35 @@ static void alpine_msix_middle_domain_free(struct irq_domain *domain, unsigned i
164139
}
165140

166141
static const struct irq_domain_ops alpine_msix_middle_domain_ops = {
142+
.select = msi_lib_irq_domain_select,
167143
.alloc = alpine_msix_middle_domain_alloc,
168144
.free = alpine_msix_middle_domain_free,
169145
};
170146

147+
#define ALPINE_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
148+
MSI_FLAG_USE_DEF_CHIP_OPS | \
149+
MSI_FLAG_PCI_MSI_MASK_PARENT)
150+
151+
#define ALPINE_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \
152+
MSI_FLAG_PCI_MSIX)
153+
154+
static struct msi_parent_ops alpine_msi_parent_ops = {
155+
.supported_flags = ALPINE_MSI_FLAGS_SUPPORTED,
156+
.required_flags = ALPINE_MSI_FLAGS_REQUIRED,
157+
.chip_flags = MSI_CHIP_FLAG_SET_EOI,
158+
.bus_select_token = DOMAIN_BUS_NEXUS,
159+
.bus_select_mask = MATCH_PCI_MSI,
160+
.prefix = "ALPINE-",
161+
.init_dev_msi_info = msi_lib_init_dev_msi_info,
162+
};
163+
171164
static int alpine_msix_init_domains(struct alpine_msix_data *priv, struct device_node *node)
172165
{
173-
struct irq_domain *middle_domain, *msi_domain, *gic_domain;
166+
struct irq_domain_info info = {
167+
.fwnode = of_fwnode_handle(node),
168+
.ops = &alpine_msix_middle_domain_ops,
169+
.host_data = priv,
170+
};
174171
struct device_node *gic_node;
175172

176173
gic_node = of_irq_find_parent(node);
@@ -179,29 +176,17 @@ static int alpine_msix_init_domains(struct alpine_msix_data *priv, struct device
179176
return -ENODEV;
180177
}
181178

182-
gic_domain = irq_find_host(gic_node);
179+
info.parent = irq_find_host(gic_node);
183180
of_node_put(gic_node);
184-
if (!gic_domain) {
181+
if (!info.parent) {
185182
pr_err("Failed to find the GIC domain\n");
186183
return -ENXIO;
187184
}
188185

189-
middle_domain = irq_domain_create_hierarchy(gic_domain, 0, 0, NULL,
190-
&alpine_msix_middle_domain_ops, priv);
191-
if (!middle_domain) {
192-
pr_err("Failed to create the MSIX middle domain\n");
193-
return -ENOMEM;
194-
}
195-
196-
msi_domain = pci_msi_create_irq_domain(of_fwnode_handle(node),
197-
&alpine_msix_domain_info,
198-
middle_domain);
199-
if (!msi_domain) {
186+
if (!msi_create_parent_irq_domain(&info, &alpine_msi_parent_ops)) {
200187
pr_err("Failed to create MSI domain\n");
201-
irq_domain_remove(middle_domain);
202188
return -ENOMEM;
203189
}
204-
205190
return 0;
206191
}
207192

0 commit comments

Comments
 (0)