1212#include <linux/delay.h>
1313#include <linux/iopoll.h>
1414#include <linux/irq.h>
15+ #include <linux/irqchip/irq-msi-lib.h>
1516#include <linux/irqchip/chained_irq.h>
1617#include <linux/irqdomain.h>
1718#include <linux/kernel.h>
@@ -187,7 +188,6 @@ struct mtk_msi_set {
187188 * @saved_irq_state: IRQ enable state saved at suspend time
188189 * @irq_lock: lock protecting IRQ register access
189190 * @intx_domain: legacy INTx IRQ domain
190- * @msi_domain: MSI IRQ domain
191191 * @msi_bottom_domain: MSI IRQ bottom domain
192192 * @msi_sets: MSI sets information
193193 * @lock: lock protecting IRQ bit map
@@ -210,7 +210,6 @@ struct mtk_gen3_pcie {
210210 u32 saved_irq_state ;
211211 raw_spinlock_t irq_lock ;
212212 struct irq_domain * intx_domain ;
213- struct irq_domain * msi_domain ;
214213 struct irq_domain * msi_bottom_domain ;
215214 struct mtk_msi_set msi_sets [PCIE_MSI_SET_NUM ];
216215 struct mutex lock ;
@@ -526,30 +525,22 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
526525 return 0 ;
527526}
528527
529- static void mtk_pcie_msi_irq_mask (struct irq_data * data )
530- {
531- pci_msi_mask_irq (data );
532- irq_chip_mask_parent (data );
533- }
534-
535- static void mtk_pcie_msi_irq_unmask (struct irq_data * data )
536- {
537- pci_msi_unmask_irq (data );
538- irq_chip_unmask_parent (data );
539- }
540-
541- static struct irq_chip mtk_msi_irq_chip = {
542- .irq_ack = irq_chip_ack_parent ,
543- .irq_mask = mtk_pcie_msi_irq_mask ,
544- .irq_unmask = mtk_pcie_msi_irq_unmask ,
545- .name = "MSI" ,
546- };
547-
548- static struct msi_domain_info mtk_msi_domain_info = {
549- .flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
550- MSI_FLAG_NO_AFFINITY | MSI_FLAG_PCI_MSIX |
551- MSI_FLAG_MULTI_PCI_MSI ,
552- .chip = & mtk_msi_irq_chip ,
528+ #define MTK_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
529+ MSI_FLAG_USE_DEF_CHIP_OPS | \
530+ MSI_FLAG_NO_AFFINITY | \
531+ MSI_FLAG_PCI_MSI_MASK_PARENT)
532+
533+ #define MTK_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \
534+ MSI_FLAG_PCI_MSIX | \
535+ MSI_FLAG_MULTI_PCI_MSI)
536+
537+ static const struct msi_parent_ops mtk_msi_parent_ops = {
538+ .required_flags = MTK_MSI_FLAGS_REQUIRED ,
539+ .supported_flags = MTK_MSI_FLAGS_SUPPORTED ,
540+ .bus_select_token = DOMAIN_BUS_PCI_MSI ,
541+ .chip_flags = MSI_CHIP_FLAG_SET_ACK ,
542+ .prefix = "MTK3-" ,
543+ .init_dev_msi_info = msi_lib_init_dev_msi_info ,
553544};
554545
555546static void mtk_compose_msi_msg (struct irq_data * data , struct msi_msg * msg )
@@ -756,28 +747,23 @@ static int mtk_pcie_init_irq_domains(struct mtk_gen3_pcie *pcie)
756747 /* Setup MSI */
757748 mutex_init (& pcie -> lock );
758749
759- pcie -> msi_bottom_domain = irq_domain_create_linear (dev_fwnode (dev ), PCIE_MSI_IRQS_NUM ,
760- & mtk_msi_bottom_domain_ops , pcie );
750+ struct irq_domain_info info = {
751+ .fwnode = dev_fwnode (dev ),
752+ .ops = & mtk_msi_bottom_domain_ops ,
753+ .host_data = pcie ,
754+ .size = PCIE_MSI_IRQS_NUM ,
755+ };
756+
757+ pcie -> msi_bottom_domain = msi_create_parent_irq_domain (& info , & mtk_msi_parent_ops );
761758 if (!pcie -> msi_bottom_domain ) {
762759 dev_err (dev , "failed to create MSI bottom domain\n" );
763760 ret = - ENODEV ;
764761 goto err_msi_bottom_domain ;
765762 }
766763
767- pcie -> msi_domain = pci_msi_create_irq_domain (dev -> fwnode ,
768- & mtk_msi_domain_info ,
769- pcie -> msi_bottom_domain );
770- if (!pcie -> msi_domain ) {
771- dev_err (dev , "failed to create MSI domain\n" );
772- ret = - ENODEV ;
773- goto err_msi_domain ;
774- }
775-
776764 of_node_put (intc_node );
777765 return 0 ;
778766
779- err_msi_domain :
780- irq_domain_remove (pcie -> msi_bottom_domain );
781767err_msi_bottom_domain :
782768 irq_domain_remove (pcie -> intx_domain );
783769out_put_node :
@@ -792,9 +778,6 @@ static void mtk_pcie_irq_teardown(struct mtk_gen3_pcie *pcie)
792778 if (pcie -> intx_domain )
793779 irq_domain_remove (pcie -> intx_domain );
794780
795- if (pcie -> msi_domain )
796- irq_domain_remove (pcie -> msi_domain );
797-
798781 if (pcie -> msi_bottom_domain )
799782 irq_domain_remove (pcie -> msi_bottom_domain );
800783
0 commit comments