setup-bus.c (053eb5c150fd732624a1ea2f456337972d52b163) | setup-bus.c (d555a50fd6e0280735cabf8581feff875f3f39d7) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Support routines for initializing a PCI subsystem 4 * 5 * Extruded from code written by 6 * Dave Rusling (david.rusling@reo.mts.dec.com) 7 * David Mosberger (davidm@cs.arizona.edu) 8 * David Miller (davem@redhat.com) --- 1851 unchanged lines hidden (view full) --- 1860 1861 dev_res->add_size = available - resource_size(res); 1862 pci_dbg(bridge, "bridge window %pR extended by %pa\n", res, 1863 &dev_res->add_size); 1864} 1865 1866static void pci_bus_distribute_available_resources(struct pci_bus *bus, 1867 struct list_head *add_list, | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Support routines for initializing a PCI subsystem 4 * 5 * Extruded from code written by 6 * Dave Rusling (david.rusling@reo.mts.dec.com) 7 * David Mosberger (davidm@cs.arizona.edu) 8 * David Miller (davem@redhat.com) --- 1851 unchanged lines hidden (view full) --- 1860 1861 dev_res->add_size = available - resource_size(res); 1862 pci_dbg(bridge, "bridge window %pR extended by %pa\n", res, 1863 &dev_res->add_size); 1864} 1865 1866static void pci_bus_distribute_available_resources(struct pci_bus *bus, 1867 struct list_head *add_list, |
1868 resource_size_t available_io, 1869 resource_size_t available_mmio, 1870 resource_size_t available_mmio_pref) | 1868 struct resource io, 1869 struct resource mmio, 1870 struct resource mmio_pref) |
1871{ | 1871{ |
1872 resource_size_t available_io, available_mmio, available_mmio_pref; |
|
1872 resource_size_t remaining_io, remaining_mmio, remaining_mmio_pref; 1873 unsigned int normal_bridges = 0, hotplug_bridges = 0; 1874 struct resource *io_res, *mmio_res, *mmio_pref_res; 1875 struct pci_dev *dev, *bridge = bus->self; 1876 resource_size_t io_per_hp, mmio_per_hp, mmio_pref_per_hp; 1877 1878 io_res = &bridge->resource[PCI_BRIDGE_RESOURCES + 0]; 1879 mmio_res = &bridge->resource[PCI_BRIDGE_RESOURCES + 1]; 1880 mmio_pref_res = &bridge->resource[PCI_BRIDGE_RESOURCES + 2]; 1881 1882 /* 1883 * Update additional resource list (add_list) to fill all the 1884 * extra resource space available for this port except the space 1885 * calculated in __pci_bus_size_bridges() which covers all the 1886 * devices currently connected to the port and below. 1887 */ | 1873 resource_size_t remaining_io, remaining_mmio, remaining_mmio_pref; 1874 unsigned int normal_bridges = 0, hotplug_bridges = 0; 1875 struct resource *io_res, *mmio_res, *mmio_pref_res; 1876 struct pci_dev *dev, *bridge = bus->self; 1877 resource_size_t io_per_hp, mmio_per_hp, mmio_pref_per_hp; 1878 1879 io_res = &bridge->resource[PCI_BRIDGE_RESOURCES + 0]; 1880 mmio_res = &bridge->resource[PCI_BRIDGE_RESOURCES + 1]; 1881 mmio_pref_res = &bridge->resource[PCI_BRIDGE_RESOURCES + 2]; 1882 1883 /* 1884 * Update additional resource list (add_list) to fill all the 1885 * extra resource space available for this port except the space 1886 * calculated in __pci_bus_size_bridges() which covers all the 1887 * devices currently connected to the port and below. 1888 */ |
1889 available_io = resource_size(&io); 1890 available_mmio = resource_size(&mmio); 1891 available_mmio_pref = resource_size(&mmio_pref); 1892 |
|
1888 extend_bridge_window(bridge, io_res, add_list, available_io); 1889 extend_bridge_window(bridge, mmio_res, add_list, available_mmio); 1890 extend_bridge_window(bridge, mmio_pref_res, add_list, 1891 available_mmio_pref); 1892 1893 /* 1894 * Calculate how many hotplug bridges and normal bridges there 1895 * are on this bus. We will distribute the additional available --- 10 unchanged lines hidden (view full) --- 1906 * There is only one bridge on the bus so it gets all available 1907 * resources which it can then distribute to the possible hotplug 1908 * bridges below. 1909 */ 1910 if (hotplug_bridges + normal_bridges == 1) { 1911 dev = list_first_entry(&bus->devices, struct pci_dev, bus_list); 1912 if (dev->subordinate) 1913 pci_bus_distribute_available_resources(dev->subordinate, | 1893 extend_bridge_window(bridge, io_res, add_list, available_io); 1894 extend_bridge_window(bridge, mmio_res, add_list, available_mmio); 1895 extend_bridge_window(bridge, mmio_pref_res, add_list, 1896 available_mmio_pref); 1897 1898 /* 1899 * Calculate how many hotplug bridges and normal bridges there 1900 * are on this bus. We will distribute the additional available --- 10 unchanged lines hidden (view full) --- 1911 * There is only one bridge on the bus so it gets all available 1912 * resources which it can then distribute to the possible hotplug 1913 * bridges below. 1914 */ 1915 if (hotplug_bridges + normal_bridges == 1) { 1916 dev = list_first_entry(&bus->devices, struct pci_dev, bus_list); 1917 if (dev->subordinate) 1918 pci_bus_distribute_available_resources(dev->subordinate, |
1914 add_list, available_io, available_mmio, 1915 available_mmio_pref); | 1919 add_list, io, mmio, mmio_pref); |
1916 return; 1917 } 1918 1919 if (hotplug_bridges == 0) 1920 return; 1921 1922 /* 1923 * Calculate the total amount of extra resource space we can --- 57 unchanged lines hidden (view full) --- 1981 1982 align = pci_resource_alignment(bridge, mmio_pref_res); 1983 mmio_pref_per_hp = div64_ul(available_mmio_pref, 1984 hotplug_bridges); 1985 mmio_pref_per_hp = min(ALIGN(mmio_pref_per_hp, align), 1986 remaining_mmio_pref); 1987 remaining_mmio_pref -= mmio_pref_per_hp; 1988 | 1920 return; 1921 } 1922 1923 if (hotplug_bridges == 0) 1924 return; 1925 1926 /* 1927 * Calculate the total amount of extra resource space we can --- 57 unchanged lines hidden (view full) --- 1985 1986 align = pci_resource_alignment(bridge, mmio_pref_res); 1987 mmio_pref_per_hp = div64_ul(available_mmio_pref, 1988 hotplug_bridges); 1989 mmio_pref_per_hp = min(ALIGN(mmio_pref_per_hp, align), 1990 remaining_mmio_pref); 1991 remaining_mmio_pref -= mmio_pref_per_hp; 1992 |
1989 pci_bus_distribute_available_resources(b, add_list, io_per_hp, 1990 mmio_per_hp, 1991 mmio_pref_per_hp); | 1993 io.end = io.start + io_per_hp - 1; 1994 mmio.end = mmio.start + mmio_per_hp - 1; 1995 mmio_pref.end = mmio_pref.start + mmio_pref_per_hp - 1; 1996 1997 pci_bus_distribute_available_resources(b, add_list, io, mmio, 1998 mmio_pref); |
1992 } 1993} 1994 1995static void pci_bridge_distribute_available_resources(struct pci_dev *bridge, 1996 struct list_head *add_list) 1997{ | 1999 } 2000} 2001 2002static void pci_bridge_distribute_available_resources(struct pci_dev *bridge, 2003 struct list_head *add_list) 2004{ |
1998 resource_size_t available_io, available_mmio, available_mmio_pref; 1999 const struct resource *res; | 2005 struct resource available_io, available_mmio, available_mmio_pref; |
2000 2001 if (!bridge->is_hotplug_bridge) 2002 return; 2003 2004 /* Take the initial extra resources from the hotplug port */ | 2006 2007 if (!bridge->is_hotplug_bridge) 2008 return; 2009 2010 /* Take the initial extra resources from the hotplug port */ |
2005 res = &bridge->resource[PCI_BRIDGE_RESOURCES + 0]; 2006 available_io = resource_size(res); 2007 res = &bridge->resource[PCI_BRIDGE_RESOURCES + 1]; 2008 available_mmio = resource_size(res); 2009 res = &bridge->resource[PCI_BRIDGE_RESOURCES + 2]; 2010 available_mmio_pref = resource_size(res); | 2011 available_io = bridge->resource[PCI_BRIDGE_RESOURCES + 0]; 2012 available_mmio = bridge->resource[PCI_BRIDGE_RESOURCES + 1]; 2013 available_mmio_pref = bridge->resource[PCI_BRIDGE_RESOURCES + 2]; |
2011 2012 pci_bus_distribute_available_resources(bridge->subordinate, 2013 add_list, available_io, 2014 available_mmio, 2015 available_mmio_pref); 2016} 2017 2018void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge) --- 192 unchanged lines hidden --- | 2014 2015 pci_bus_distribute_available_resources(bridge->subordinate, 2016 add_list, available_io, 2017 available_mmio, 2018 available_mmio_pref); 2019} 2020 2021void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge) --- 192 unchanged lines hidden --- |