1515#include <linux/pci.h>
1616#include <linux/slab.h>
1717
18+ #include "irq-msi-lib.h"
19+
1820static int nr_pics ;
1921
2022struct pch_msi_data {
@@ -27,26 +29,6 @@ struct pch_msi_data {
2729
2830static struct fwnode_handle * pch_msi_handle [MAX_IO_PICS ];
2931
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-
5032static int pch_msi_allocate_hwirq (struct pch_msi_data * priv , int num_req )
5133{
5234 int first ;
@@ -85,12 +67,6 @@ static void pch_msi_compose_msi_msg(struct irq_data *data,
8567 msg -> data = data -> hwirq ;
8668}
8769
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-
9470static struct irq_chip middle_irq_chip = {
9571 .name = "PCH MSI" ,
9672 .irq_mask = irq_chip_mask_parent ,
@@ -155,13 +131,31 @@ static void pch_msi_middle_domain_free(struct irq_domain *domain,
155131static const struct irq_domain_ops pch_msi_middle_domain_ops = {
156132 .alloc = pch_msi_middle_domain_alloc ,
157133 .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 ,
158152};
159153
160154static int pch_msi_init_domains (struct pch_msi_data * priv ,
161155 struct irq_domain * parent ,
162156 struct fwnode_handle * domain_handle )
163157{
164- struct irq_domain * middle_domain , * msi_domain ;
158+ struct irq_domain * middle_domain ;
165159
166160 middle_domain = irq_domain_create_hierarchy (parent , 0 , priv -> num_irqs ,
167161 domain_handle ,
@@ -174,14 +168,8 @@ static int pch_msi_init_domains(struct pch_msi_data *priv,
174168
175169 irq_domain_update_bus_token (middle_domain , DOMAIN_BUS_NEXUS );
176170
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 ;
185173
186174 return 0 ;
187175}
0 commit comments