15
15
#include <linux/pci.h>
16
16
#include <linux/slab.h>
17
17
18
+ #include "irq-msi-lib.h"
19
+
18
20
static int nr_pics ;
19
21
20
22
struct pch_msi_data {
@@ -27,26 +29,6 @@ struct pch_msi_data {
27
29
28
30
static struct fwnode_handle * pch_msi_handle [MAX_IO_PICS ];
29
31
30
- static void pch_msi_mask_msi_irq (struct irq_data * d )
31
- {
32
- pci_msi_mask_irq (d );
33
- irq_chip_mask_parent (d );
34
- }
35
-
36
- static void pch_msi_unmask_msi_irq (struct irq_data * d )
37
- {
38
- irq_chip_unmask_parent (d );
39
- pci_msi_unmask_irq (d );
40
- }
41
-
42
- static struct irq_chip pch_msi_irq_chip = {
43
- .name = "PCH PCI MSI" ,
44
- .irq_mask = pch_msi_mask_msi_irq ,
45
- .irq_unmask = pch_msi_unmask_msi_irq ,
46
- .irq_ack = irq_chip_ack_parent ,
47
- .irq_set_affinity = irq_chip_set_affinity_parent ,
48
- };
49
-
50
32
static int pch_msi_allocate_hwirq (struct pch_msi_data * priv , int num_req )
51
33
{
52
34
int first ;
@@ -85,12 +67,6 @@ static void pch_msi_compose_msi_msg(struct irq_data *data,
85
67
msg -> data = data -> hwirq ;
86
68
}
87
69
88
- static struct msi_domain_info pch_msi_domain_info = {
89
- .flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
90
- MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX ,
91
- .chip = & pch_msi_irq_chip ,
92
- };
93
-
94
70
static struct irq_chip middle_irq_chip = {
95
71
.name = "PCH MSI" ,
96
72
.irq_mask = irq_chip_mask_parent ,
@@ -155,13 +131,31 @@ static void pch_msi_middle_domain_free(struct irq_domain *domain,
155
131
static const struct irq_domain_ops pch_msi_middle_domain_ops = {
156
132
.alloc = pch_msi_middle_domain_alloc ,
157
133
.free = pch_msi_middle_domain_free ,
134
+ .select = msi_lib_irq_domain_select ,
135
+ };
136
+
137
+ #define PCH_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
138
+ MSI_FLAG_USE_DEF_CHIP_OPS | \
139
+ MSI_FLAG_PCI_MSI_MASK_PARENT)
140
+
141
+ #define PCH_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \
142
+ MSI_FLAG_PCI_MSIX | \
143
+ MSI_FLAG_MULTI_PCI_MSI)
144
+
145
+ static struct msi_parent_ops pch_msi_parent_ops = {
146
+ .required_flags = PCH_MSI_FLAGS_REQUIRED ,
147
+ .supported_flags = PCH_MSI_FLAGS_SUPPORTED ,
148
+ .bus_select_mask = MATCH_PCI_MSI ,
149
+ .bus_select_token = DOMAIN_BUS_NEXUS ,
150
+ .prefix = "PCH-" ,
151
+ .init_dev_msi_info = msi_lib_init_dev_msi_info ,
158
152
};
159
153
160
154
static int pch_msi_init_domains (struct pch_msi_data * priv ,
161
155
struct irq_domain * parent ,
162
156
struct fwnode_handle * domain_handle )
163
157
{
164
- struct irq_domain * middle_domain , * msi_domain ;
158
+ struct irq_domain * middle_domain ;
165
159
166
160
middle_domain = irq_domain_create_hierarchy (parent , 0 , priv -> num_irqs ,
167
161
domain_handle ,
@@ -174,14 +168,8 @@ static int pch_msi_init_domains(struct pch_msi_data *priv,
174
168
175
169
irq_domain_update_bus_token (middle_domain , DOMAIN_BUS_NEXUS );
176
170
177
- msi_domain = pci_msi_create_irq_domain (domain_handle ,
178
- & pch_msi_domain_info ,
179
- middle_domain );
180
- if (!msi_domain ) {
181
- pr_err ("Failed to create PCI MSI domain\n" );
182
- irq_domain_remove (middle_domain );
183
- return - ENOMEM ;
184
- }
171
+ middle_domain -> flags |= IRQ_DOMAIN_FLAG_MSI_PARENT ;
172
+ middle_domain -> msi_parent_ops = & pch_msi_parent_ops ;
185
173
186
174
return 0 ;
187
175
}
0 commit comments