Merge tag 'pci-v6.16-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci

Pull PCI fixes from Bjorn Helgaas:

- Track apple Root Ports explicitly and look up the driver data from
the struct device instead of using dev->driver_data, which is used by
pci_host_common_init() for the generic host bridge pointer (Marc
Zyngier)

- Set dev->driver_data before pci_host_common_init() calls
gen_pci_init() because some drivers need it to set up ECAM mappings;
this fixes a regression on MicroChip MPFS Icicle (Geert Uytterhoeven)

- Revert the now-unnecessary use of ECAM pci_config_window.priv to
store a copy of dev->driver_data (Marc Zyngier)

* tag 'pci-v6.16-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci:
Revert "PCI: ecam: Allow cfg->priv to be pre-populated from the root port device"
PCI: host-generic: Set driver_data before calling gen_pci_init()
PCI: apple: Add tracking of probed root ports

+51 -8
+2 -2
drivers/pci/controller/pci-host-common.c
··· 64 65 of_pci_check_probe_only(); 66 67 /* Parse and map our Configuration Space windows */ 68 cfg = gen_pci_init(dev, bridge, ops); 69 if (IS_ERR(cfg)) 70 return PTR_ERR(cfg); 71 - 72 - platform_set_drvdata(pdev, bridge); 73 74 bridge->sysdata = cfg; 75 bridge->ops = (struct pci_ops *)&ops->pci_ops;
··· 64 65 of_pci_check_probe_only(); 66 67 + platform_set_drvdata(pdev, bridge); 68 + 69 /* Parse and map our Configuration Space windows */ 70 cfg = gen_pci_init(dev, bridge, ops); 71 if (IS_ERR(cfg)) 72 return PTR_ERR(cfg); 73 74 bridge->sysdata = cfg; 75 bridge->ops = (struct pci_ops *)&ops->pci_ops;
+49 -4
drivers/pci/controller/pcie-apple.c
··· 187 const struct hw_info *hw; 188 unsigned long *bitmap; 189 struct list_head ports; 190 struct completion event; 191 struct irq_fwspec fwspec; 192 u32 nvecs; ··· 205 int sid_map_sz; 206 int idx; 207 }; 208 209 static void rmw_set(u32 set, void __iomem *addr) 210 { ··· 724 return 0; 725 } 726 727 static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev) 728 { 729 struct pci_config_window *cfg = pdev->sysdata; 730 - struct apple_pcie *pcie = cfg->priv; 731 struct pci_dev *port_pdev; 732 struct apple_pcie_port *port; 733 734 /* Find the root port this device is on */ 735 port_pdev = pcie_find_root_port(pdev); ··· 842 843 static int apple_pcie_init(struct pci_config_window *cfg) 844 { 845 - struct apple_pcie *pcie = cfg->priv; 846 struct device *dev = cfg->parent; 847 int ret; 848 849 for_each_available_child_of_node_scoped(dev->of_node, of_port) { 850 ret = apple_pcie_setup_port(pcie, of_port); ··· 892 893 mutex_init(&pcie->lock); 894 INIT_LIST_HEAD(&pcie->ports); 895 - dev_set_drvdata(dev, pcie); 896 897 ret = apple_msi_init(pcie); 898 if (ret) 899 return ret; 900 901 - return pci_host_common_init(pdev, &apple_pcie_cfg_ecam_ops); 902 } 903 904 static const struct of_device_id apple_pcie_of_match[] = {
··· 187 const struct hw_info *hw; 188 unsigned long *bitmap; 189 struct list_head ports; 190 + struct list_head entry; 191 struct completion event; 192 struct irq_fwspec fwspec; 193 u32 nvecs; ··· 204 int sid_map_sz; 205 int idx; 206 }; 207 + 208 + static LIST_HEAD(pcie_list); 209 + static DEFINE_MUTEX(pcie_list_lock); 210 211 static void rmw_set(u32 set, void __iomem *addr) 212 { ··· 720 return 0; 721 } 722 723 + static void apple_pcie_register(struct apple_pcie *pcie) 724 + { 725 + guard(mutex)(&pcie_list_lock); 726 + 727 + list_add_tail(&pcie->entry, &pcie_list); 728 + } 729 + 730 + static void apple_pcie_unregister(struct apple_pcie *pcie) 731 + { 732 + guard(mutex)(&pcie_list_lock); 733 + 734 + list_del(&pcie->entry); 735 + } 736 + 737 + static struct apple_pcie *apple_pcie_lookup(struct device *dev) 738 + { 739 + struct apple_pcie *pcie; 740 + 741 + guard(mutex)(&pcie_list_lock); 742 + 743 + list_for_each_entry(pcie, &pcie_list, entry) { 744 + if (pcie->dev == dev) 745 + return pcie; 746 + } 747 + 748 + return NULL; 749 + } 750 + 751 static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev) 752 { 753 struct pci_config_window *cfg = pdev->sysdata; 754 + struct apple_pcie *pcie; 755 struct pci_dev *port_pdev; 756 struct apple_pcie_port *port; 757 + 758 + pcie = apple_pcie_lookup(cfg->parent); 759 + if (WARN_ON(!pcie)) 760 + return NULL; 761 762 /* Find the root port this device is on */ 763 port_pdev = pcie_find_root_port(pdev); ··· 806 807 static int apple_pcie_init(struct pci_config_window *cfg) 808 { 809 struct device *dev = cfg->parent; 810 + struct apple_pcie *pcie; 811 int ret; 812 + 813 + pcie = apple_pcie_lookup(dev); 814 + if (WARN_ON(!pcie)) 815 + return -ENOENT; 816 817 for_each_available_child_of_node_scoped(dev->of_node, of_port) { 818 ret = apple_pcie_setup_port(pcie, of_port); ··· 852 853 mutex_init(&pcie->lock); 854 INIT_LIST_HEAD(&pcie->ports); 855 856 ret = apple_msi_init(pcie); 857 if (ret) 858 return ret; 859 860 + apple_pcie_register(pcie); 861 + 862 + ret = pci_host_common_init(pdev, &apple_pcie_cfg_ecam_ops); 863 + if (ret) 864 + apple_pcie_unregister(pcie); 865 + 866 + return ret; 867 } 868 869 static const struct of_device_id apple_pcie_of_match[] = {
-2
drivers/pci/ecam.c
··· 84 goto err_exit_iomap; 85 } 86 87 - cfg->priv = dev_get_drvdata(dev); 88 - 89 if (ops->init) { 90 err = ops->init(cfg); 91 if (err)
··· 84 goto err_exit_iomap; 85 } 86 87 if (ops->init) { 88 err = ops->init(cfg); 89 if (err)