@@ -1745,119 +1745,6 @@ static enum enable_type pci_realloc_detect(struct pci_bus *bus,
1745
1745
}
1746
1746
#endif
1747
1747
1748
- /*
1749
- * First try will not touch PCI bridge res.
1750
- * Second and later try will clear small leaf bridge res.
1751
- * Will stop till to the max depth if can not find good one.
1752
- */
1753
- void pci_assign_unassigned_root_bus_resources (struct pci_bus * bus )
1754
- {
1755
- LIST_HEAD (realloc_head );
1756
- /* List of resources that want additional resources */
1757
- struct list_head * add_list = NULL ;
1758
- int tried_times = 0 ;
1759
- enum release_type rel_type = leaf_only ;
1760
- LIST_HEAD (fail_head );
1761
- struct pci_dev_resource * fail_res ;
1762
- int pci_try_num = 1 ;
1763
- enum enable_type enable_local ;
1764
-
1765
- /* Don't realloc if asked to do so */
1766
- enable_local = pci_realloc_detect (bus , pci_realloc_enable );
1767
- if (pci_realloc_enabled (enable_local )) {
1768
- int max_depth = pci_bus_get_depth (bus );
1769
-
1770
- pci_try_num = max_depth + 1 ;
1771
- dev_info (& bus -> dev , "max bus depth: %d pci_try_num: %d\n" ,
1772
- max_depth , pci_try_num );
1773
- }
1774
-
1775
- again :
1776
- /*
1777
- * Last try will use add_list, otherwise will try good to have as must
1778
- * have, so can realloc parent bridge resource
1779
- */
1780
- if (tried_times + 1 == pci_try_num )
1781
- add_list = & realloc_head ;
1782
- /*
1783
- * Depth first, calculate sizes and alignments of all subordinate buses.
1784
- */
1785
- __pci_bus_size_bridges (bus , add_list );
1786
-
1787
- /* Depth last, allocate resources and update the hardware. */
1788
- __pci_bus_assign_resources (bus , add_list , & fail_head );
1789
- if (add_list )
1790
- BUG_ON (!list_empty (add_list ));
1791
- tried_times ++ ;
1792
-
1793
- /* Any device complain? */
1794
- if (list_empty (& fail_head ))
1795
- goto dump ;
1796
-
1797
- if (tried_times >= pci_try_num ) {
1798
- if (enable_local == undefined )
1799
- dev_info (& bus -> dev , "Some PCI device resources are unassigned, try booting with pci=realloc\n" );
1800
- else if (enable_local == auto_enabled )
1801
- dev_info (& bus -> dev , "Automatically enabled pci realloc, if you have problem, try booting with pci=realloc=off\n" );
1802
-
1803
- free_list (& fail_head );
1804
- goto dump ;
1805
- }
1806
-
1807
- dev_info (& bus -> dev , "No. %d try to assign unassigned res\n" ,
1808
- tried_times + 1 );
1809
-
1810
- /* Third times and later will not check if it is leaf */
1811
- if ((tried_times + 1 ) > 2 )
1812
- rel_type = whole_subtree ;
1813
-
1814
- /*
1815
- * Try to release leaf bridge's resources that doesn't fit resource of
1816
- * child device under that bridge.
1817
- */
1818
- list_for_each_entry (fail_res , & fail_head , list )
1819
- pci_bus_release_bridge_resources (fail_res -> dev -> bus ,
1820
- fail_res -> flags & PCI_RES_TYPE_MASK ,
1821
- rel_type );
1822
-
1823
- /* Restore size and flags */
1824
- list_for_each_entry (fail_res , & fail_head , list ) {
1825
- struct resource * res = fail_res -> res ;
1826
- int idx ;
1827
-
1828
- res -> start = fail_res -> start ;
1829
- res -> end = fail_res -> end ;
1830
- res -> flags = fail_res -> flags ;
1831
-
1832
- if (pci_is_bridge (fail_res -> dev )) {
1833
- idx = res - & fail_res -> dev -> resource [0 ];
1834
- if (idx >= PCI_BRIDGE_RESOURCES &&
1835
- idx <= PCI_BRIDGE_RESOURCE_END )
1836
- res -> flags = 0 ;
1837
- }
1838
- }
1839
- free_list (& fail_head );
1840
-
1841
- goto again ;
1842
-
1843
- dump :
1844
- /* Dump the resource on buses */
1845
- pci_bus_dump_resources (bus );
1846
- }
1847
-
1848
- void __init pci_assign_unassigned_resources (void )
1849
- {
1850
- struct pci_bus * root_bus ;
1851
-
1852
- list_for_each_entry (root_bus , & pci_root_buses , node ) {
1853
- pci_assign_unassigned_root_bus_resources (root_bus );
1854
-
1855
- /* Make sure the root bridge has a companion ACPI device */
1856
- if (ACPI_HANDLE (root_bus -> bridge ))
1857
- acpi_ioapic_add (ACPI_HANDLE (root_bus -> bridge ));
1858
- }
1859
- }
1860
-
1861
1748
static void adjust_bridge_window (struct pci_dev * bridge , struct resource * res ,
1862
1749
struct list_head * add_list ,
1863
1750
resource_size_t new_size )
@@ -2047,6 +1934,119 @@ static void pci_bridge_distribute_available_resources(struct pci_dev *bridge,
2047
1934
available_mmio_pref );
2048
1935
}
2049
1936
1937
+ /*
1938
+ * First try will not touch PCI bridge res.
1939
+ * Second and later try will clear small leaf bridge res.
1940
+ * Will stop till to the max depth if can not find good one.
1941
+ */
1942
+ void pci_assign_unassigned_root_bus_resources (struct pci_bus * bus )
1943
+ {
1944
+ LIST_HEAD (realloc_head );
1945
+ /* List of resources that want additional resources */
1946
+ struct list_head * add_list = NULL ;
1947
+ int tried_times = 0 ;
1948
+ enum release_type rel_type = leaf_only ;
1949
+ LIST_HEAD (fail_head );
1950
+ struct pci_dev_resource * fail_res ;
1951
+ int pci_try_num = 1 ;
1952
+ enum enable_type enable_local ;
1953
+
1954
+ /* Don't realloc if asked to do so */
1955
+ enable_local = pci_realloc_detect (bus , pci_realloc_enable );
1956
+ if (pci_realloc_enabled (enable_local )) {
1957
+ int max_depth = pci_bus_get_depth (bus );
1958
+
1959
+ pci_try_num = max_depth + 1 ;
1960
+ dev_info (& bus -> dev , "max bus depth: %d pci_try_num: %d\n" ,
1961
+ max_depth , pci_try_num );
1962
+ }
1963
+
1964
+ again :
1965
+ /*
1966
+ * Last try will use add_list, otherwise will try good to have as must
1967
+ * have, so can realloc parent bridge resource
1968
+ */
1969
+ if (tried_times + 1 == pci_try_num )
1970
+ add_list = & realloc_head ;
1971
+ /*
1972
+ * Depth first, calculate sizes and alignments of all subordinate buses.
1973
+ */
1974
+ __pci_bus_size_bridges (bus , add_list );
1975
+
1976
+ /* Depth last, allocate resources and update the hardware. */
1977
+ __pci_bus_assign_resources (bus , add_list , & fail_head );
1978
+ if (add_list )
1979
+ BUG_ON (!list_empty (add_list ));
1980
+ tried_times ++ ;
1981
+
1982
+ /* Any device complain? */
1983
+ if (list_empty (& fail_head ))
1984
+ goto dump ;
1985
+
1986
+ if (tried_times >= pci_try_num ) {
1987
+ if (enable_local == undefined )
1988
+ dev_info (& bus -> dev , "Some PCI device resources are unassigned, try booting with pci=realloc\n" );
1989
+ else if (enable_local == auto_enabled )
1990
+ dev_info (& bus -> dev , "Automatically enabled pci realloc, if you have problem, try booting with pci=realloc=off\n" );
1991
+
1992
+ free_list (& fail_head );
1993
+ goto dump ;
1994
+ }
1995
+
1996
+ dev_info (& bus -> dev , "No. %d try to assign unassigned res\n" ,
1997
+ tried_times + 1 );
1998
+
1999
+ /* Third times and later will not check if it is leaf */
2000
+ if ((tried_times + 1 ) > 2 )
2001
+ rel_type = whole_subtree ;
2002
+
2003
+ /*
2004
+ * Try to release leaf bridge's resources that doesn't fit resource of
2005
+ * child device under that bridge.
2006
+ */
2007
+ list_for_each_entry (fail_res , & fail_head , list )
2008
+ pci_bus_release_bridge_resources (fail_res -> dev -> bus ,
2009
+ fail_res -> flags & PCI_RES_TYPE_MASK ,
2010
+ rel_type );
2011
+
2012
+ /* Restore size and flags */
2013
+ list_for_each_entry (fail_res , & fail_head , list ) {
2014
+ struct resource * res = fail_res -> res ;
2015
+ int idx ;
2016
+
2017
+ res -> start = fail_res -> start ;
2018
+ res -> end = fail_res -> end ;
2019
+ res -> flags = fail_res -> flags ;
2020
+
2021
+ if (pci_is_bridge (fail_res -> dev )) {
2022
+ idx = res - & fail_res -> dev -> resource [0 ];
2023
+ if (idx >= PCI_BRIDGE_RESOURCES &&
2024
+ idx <= PCI_BRIDGE_RESOURCE_END )
2025
+ res -> flags = 0 ;
2026
+ }
2027
+ }
2028
+ free_list (& fail_head );
2029
+
2030
+ goto again ;
2031
+
2032
+ dump :
2033
+ /* Dump the resource on buses */
2034
+ pci_bus_dump_resources (bus );
2035
+ }
2036
+
2037
+ void __init pci_assign_unassigned_resources (void )
2038
+ {
2039
+ struct pci_bus * root_bus ;
2040
+
2041
+ list_for_each_entry (root_bus , & pci_root_buses , node ) {
2042
+ pci_assign_unassigned_root_bus_resources (root_bus );
2043
+
2044
+ /* Make sure the root bridge has a companion ACPI device */
2045
+ if (ACPI_HANDLE (root_bus -> bridge ))
2046
+ acpi_ioapic_add (ACPI_HANDLE (root_bus -> bridge ));
2047
+ }
2048
+ }
2049
+
2050
2050
void pci_assign_unassigned_bridge_resources (struct pci_dev * bridge )
2051
2051
{
2052
2052
struct pci_bus * parent = bridge -> subordinate ;
0 commit comments