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