22
22
#include <linux/kernel.h>
23
23
#include <linux/iopoll.h>
24
24
#include <linux/irqchip/chained_irq.h>
25
+ #include <linux/irqchip/irq-msi-lib.h>
25
26
#include <linux/irqdomain.h>
26
27
#include <linux/list.h>
27
28
#include <linux/module.h>
@@ -133,7 +134,6 @@ struct apple_pcie {
133
134
struct mutex lock ;
134
135
struct device * dev ;
135
136
void __iomem * base ;
136
- struct irq_domain * domain ;
137
137
unsigned long * bitmap ;
138
138
struct list_head ports ;
139
139
struct completion event ;
@@ -162,27 +162,6 @@ static void rmw_clear(u32 clr, void __iomem *addr)
162
162
writel_relaxed (readl_relaxed (addr ) & ~clr , addr );
163
163
}
164
164
165
- static void apple_msi_top_irq_mask (struct irq_data * d )
166
- {
167
- pci_msi_mask_irq (d );
168
- irq_chip_mask_parent (d );
169
- }
170
-
171
- static void apple_msi_top_irq_unmask (struct irq_data * d )
172
- {
173
- pci_msi_unmask_irq (d );
174
- irq_chip_unmask_parent (d );
175
- }
176
-
177
- static struct irq_chip apple_msi_top_chip = {
178
- .name = "PCIe MSI" ,
179
- .irq_mask = apple_msi_top_irq_mask ,
180
- .irq_unmask = apple_msi_top_irq_unmask ,
181
- .irq_eoi = irq_chip_eoi_parent ,
182
- .irq_set_affinity = irq_chip_set_affinity_parent ,
183
- .irq_set_type = irq_chip_set_type_parent ,
184
- };
185
-
186
165
static void apple_msi_compose_msg (struct irq_data * data , struct msi_msg * msg )
187
166
{
188
167
msg -> address_hi = upper_32_bits (DOORBELL_ADDR );
@@ -226,8 +205,7 @@ static int apple_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
226
205
227
206
for (i = 0 ; i < nr_irqs ; i ++ ) {
228
207
irq_domain_set_hwirq_and_chip (domain , virq + i , hwirq + i ,
229
- & apple_msi_bottom_chip ,
230
- domain -> host_data );
208
+ & apple_msi_bottom_chip , pcie );
231
209
}
232
210
233
211
return 0 ;
@@ -251,12 +229,6 @@ static const struct irq_domain_ops apple_msi_domain_ops = {
251
229
.free = apple_msi_domain_free ,
252
230
};
253
231
254
- static struct msi_domain_info apple_msi_info = {
255
- .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
256
- MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX ),
257
- .chip = & apple_msi_top_chip ,
258
- };
259
-
260
232
static void apple_port_irq_mask (struct irq_data * data )
261
233
{
262
234
struct apple_pcie_port * port = irq_data_get_irq_chip_data (data );
@@ -595,11 +567,28 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
595
567
return 0 ;
596
568
}
597
569
570
+ static const struct msi_parent_ops apple_msi_parent_ops = {
571
+ .supported_flags = (MSI_GENERIC_FLAGS_MASK |
572
+ MSI_FLAG_PCI_MSIX |
573
+ MSI_FLAG_MULTI_PCI_MSI ),
574
+ .required_flags = (MSI_FLAG_USE_DEF_DOM_OPS |
575
+ MSI_FLAG_USE_DEF_CHIP_OPS |
576
+ MSI_FLAG_PCI_MSI_MASK_PARENT ),
577
+ .chip_flags = MSI_CHIP_FLAG_SET_EOI ,
578
+ .bus_select_token = DOMAIN_BUS_PCI_MSI ,
579
+ .init_dev_msi_info = msi_lib_init_dev_msi_info ,
580
+ };
581
+
598
582
static int apple_msi_init (struct apple_pcie * pcie )
599
583
{
600
584
struct fwnode_handle * fwnode = dev_fwnode (pcie -> dev );
585
+ struct irq_domain_info info = {
586
+ .fwnode = fwnode ,
587
+ .ops = & apple_msi_domain_ops ,
588
+ .size = pcie -> nvecs ,
589
+ .host_data = pcie ,
590
+ };
601
591
struct of_phandle_args args = {};
602
- struct irq_domain * parent ;
603
592
int ret ;
604
593
605
594
ret = of_parse_phandle_with_args (to_of_node (fwnode ), "msi-ranges" ,
@@ -619,28 +608,16 @@ static int apple_msi_init(struct apple_pcie *pcie)
619
608
if (!pcie -> bitmap )
620
609
return - ENOMEM ;
621
610
622
- parent = irq_find_matching_fwspec (& pcie -> fwspec , DOMAIN_BUS_WIRED );
623
- if (!parent ) {
611
+ info . parent = irq_find_matching_fwspec (& pcie -> fwspec , DOMAIN_BUS_WIRED );
612
+ if (!info . parent ) {
624
613
dev_err (pcie -> dev , "failed to find parent domain\n" );
625
614
return - ENXIO ;
626
615
}
627
616
628
- parent = irq_domain_create_hierarchy (parent , 0 , pcie -> nvecs , fwnode ,
629
- & apple_msi_domain_ops , pcie );
630
- if (!parent ) {
617
+ if (!msi_create_parent_irq_domain (& info , & apple_msi_parent_ops )) {
631
618
dev_err (pcie -> dev , "failed to create IRQ domain\n" );
632
619
return - ENOMEM ;
633
620
}
634
- irq_domain_update_bus_token (parent , DOMAIN_BUS_NEXUS );
635
-
636
- pcie -> domain = pci_msi_create_irq_domain (fwnode , & apple_msi_info ,
637
- parent );
638
- if (!pcie -> domain ) {
639
- dev_err (pcie -> dev , "failed to create MSI domain\n" );
640
- irq_domain_remove (parent );
641
- return - ENOMEM ;
642
- }
643
-
644
621
return 0 ;
645
622
}
646
623
0 commit comments