@@ -546,14 +546,14 @@ unsigned long sn_rtc_cycles_per_second;
546
546
EXPORT_SYMBOL (sn_rtc_cycles_per_second );
547
547
548
548
/* The following values are used for the per node hub info struct */
549
- static __initdata unsigned short * _node_to_pnode ;
550
549
static __initdata unsigned short _min_socket , _max_socket ;
551
550
static __initdata unsigned short _min_pnode , _max_pnode , _gr_table_len ;
552
551
static __initdata struct uv_gam_range_entry * uv_gre_table ;
553
552
static __initdata struct uv_gam_parameters * uv_gp_table ;
554
553
static __initdata unsigned short * _socket_to_node ;
555
554
static __initdata unsigned short * _socket_to_pnode ;
556
555
static __initdata unsigned short * _pnode_to_socket ;
556
+ static __initdata unsigned short * _node_to_socket ;
557
557
558
558
static __initdata struct uv_gam_range_s * _gr_table ;
559
559
@@ -1293,6 +1293,7 @@ static void __init uv_init_hub_info(struct uv_hub_info_s *hi)
1293
1293
hi -> nasid_shift = uv_cpuid .nasid_shift ;
1294
1294
hi -> min_pnode = _min_pnode ;
1295
1295
hi -> min_socket = _min_socket ;
1296
+ hi -> node_to_socket = _node_to_socket ;
1296
1297
hi -> pnode_to_socket = _pnode_to_socket ;
1297
1298
hi -> socket_to_node = _socket_to_node ;
1298
1299
hi -> socket_to_pnode = _socket_to_pnode ;
@@ -1526,6 +1527,11 @@ static void __init free_1_to_1_table(unsigned short **tp, char *tname, int min,
1526
1527
pr_info ("UV: %s is 1:1, conversion table removed\n" , tname );
1527
1528
}
1528
1529
1530
+ /*
1531
+ * Build Socket Tables
1532
+ * If the number of nodes is >1 per socket, socket to node table will
1533
+ * contain lowest node number on that socket.
1534
+ */
1529
1535
static void __init build_socket_tables (void )
1530
1536
{
1531
1537
struct uv_gam_range_entry * gre = uv_gre_table ;
@@ -1552,27 +1558,25 @@ static void __init build_socket_tables(void)
1552
1558
/* Allocate and clear tables */
1553
1559
if ((alloc_conv_table (nump , & _pnode_to_socket ) < 0 )
1554
1560
|| (alloc_conv_table (nums , & _socket_to_pnode ) < 0 )
1555
- || (alloc_conv_table (numn , & _node_to_pnode ) < 0 )
1561
+ || (alloc_conv_table (numn , & _node_to_socket ) < 0 )
1556
1562
|| (alloc_conv_table (nums , & _socket_to_node ) < 0 )) {
1557
1563
kfree (_pnode_to_socket );
1558
1564
kfree (_socket_to_pnode );
1559
- kfree (_node_to_pnode );
1565
+ kfree (_node_to_socket );
1560
1566
return ;
1561
1567
}
1562
1568
1563
1569
/* Fill in pnode/node/addr conversion list values: */
1564
- pr_info ("UV: GAM Building socket/pnode conversion tables\n" );
1565
1570
for (; gre -> type != UV_GAM_RANGE_TYPE_UNUSED ; gre ++ ) {
1566
1571
if (gre -> type == UV_GAM_RANGE_TYPE_HOLE )
1567
1572
continue ;
1568
1573
i = gre -> sockid - minsock ;
1569
- /* Duplicate: */
1570
- if (_socket_to_pnode [i ] != SOCK_EMPTY )
1571
- continue ;
1572
- _socket_to_pnode [i ] = gre -> pnode ;
1574
+ if (_socket_to_pnode [i ] == SOCK_EMPTY )
1575
+ _socket_to_pnode [i ] = gre -> pnode ;
1573
1576
1574
1577
i = gre -> pnode - minpnode ;
1575
- _pnode_to_socket [i ] = gre -> sockid ;
1578
+ if (_pnode_to_socket [i ] == SOCK_EMPTY )
1579
+ _pnode_to_socket [i ] = gre -> sockid ;
1576
1580
1577
1581
pr_info ("UV: sid:%02x type:%d nasid:%04x pn:%02x pn2s:%2x\n" ,
1578
1582
gre -> sockid , gre -> type , gre -> nasid ,
@@ -1582,41 +1586,37 @@ static void __init build_socket_tables(void)
1582
1586
1583
1587
/* Set socket -> node values: */
1584
1588
lnid = NUMA_NO_NODE ;
1585
- for_each_present_cpu (cpu ) {
1589
+ for_each_possible_cpu (cpu ) {
1586
1590
int nid = cpu_to_node (cpu );
1587
1591
int apicid , sockid ;
1588
1592
1589
1593
if (lnid == nid )
1590
1594
continue ;
1591
1595
lnid = nid ;
1596
+
1592
1597
apicid = per_cpu (x86_cpu_to_apicid , cpu );
1593
1598
sockid = apicid >> uv_cpuid .socketid_shift ;
1594
- _socket_to_node [sockid - minsock ] = nid ;
1595
- pr_info ("UV: sid:%02x: apicid:%04x node:%2d\n" ,
1596
- sockid , apicid , nid );
1597
- }
1598
1599
1599
- /* Set up physical blade to pnode translation from GAM Range Table: */
1600
- for (lnid = 0 ; lnid < num_possible_nodes (); lnid ++ ) {
1601
- unsigned short sockid ;
1600
+ if (_socket_to_node [sockid - minsock ] == SOCK_EMPTY )
1601
+ _socket_to_node [sockid - minsock ] = nid ;
1602
1602
1603
- for (sockid = minsock ; sockid <= maxsock ; sockid ++ ) {
1604
- if (lnid == _socket_to_node [sockid - minsock ]) {
1605
- _node_to_pnode [lnid ] = _socket_to_pnode [sockid - minsock ];
1606
- break ;
1607
- }
1608
- }
1609
- if (sockid > maxsock ) {
1610
- pr_err ("UV: socket for node %d not found!\n" , lnid );
1611
- BUG ();
1612
- }
1603
+ if (_node_to_socket [nid ] == SOCK_EMPTY )
1604
+ _node_to_socket [nid ] = sockid ;
1605
+
1606
+ pr_info ("UV: sid:%02x: apicid:%04x socket:%02d node:%03x s2n:%03x\n" ,
1607
+ sockid ,
1608
+ apicid ,
1609
+ _node_to_socket [nid ],
1610
+ nid ,
1611
+ _socket_to_node [sockid - minsock ]);
1613
1612
}
1614
1613
1615
1614
/*
1616
1615
* If e.g. socket id == pnode for all pnodes,
1617
1616
* system runs faster by removing corresponding conversion table.
1618
1617
*/
1619
1618
FREE_1_TO_1_TABLE (_socket_to_node , _min_socket , nums , numn );
1619
+ FREE_1_TO_1_TABLE (_node_to_socket , _min_socket , nums , numn );
1620
1620
FREE_1_TO_1_TABLE (_socket_to_pnode , _min_pnode , nums , nump );
1621
1621
FREE_1_TO_1_TABLE (_pnode_to_socket , _min_pnode , nums , nump );
1622
1622
}
@@ -1702,12 +1702,13 @@ static __init int uv_system_init_hubless(void)
1702
1702
static void __init uv_system_init_hub (void )
1703
1703
{
1704
1704
struct uv_hub_info_s hub_info = {0 };
1705
- int bytes , cpu , nodeid ;
1705
+ int bytes , cpu , nodeid , bid ;
1706
1706
unsigned short min_pnode = USHRT_MAX , max_pnode = 0 ;
1707
1707
char * hub = is_uv5_hub () ? "UV500" :
1708
1708
is_uv4_hub () ? "UV400" :
1709
1709
is_uv3_hub () ? "UV300" :
1710
1710
is_uv2_hub () ? "UV2000/3000" : NULL ;
1711
+ struct uv_hub_info_s * * uv_hub_info_list_blade ;
1711
1712
1712
1713
if (!hub ) {
1713
1714
pr_err ("UV: Unknown/unsupported UV hub\n" );
@@ -1730,9 +1731,12 @@ static void __init uv_system_init_hub(void)
1730
1731
build_uv_gr_table ();
1731
1732
set_block_size ();
1732
1733
uv_init_hub_info (& hub_info );
1733
- uv_possible_blades = num_possible_nodes ();
1734
- if (! _node_to_pnode )
1734
+ /* If UV2 or UV3 may need to get # blades from HW */
1735
+ if (is_uv ( UV2 | UV3 ) && ! uv_gre_table )
1735
1736
boot_init_possible_blades (& hub_info );
1737
+ else
1738
+ /* min/max sockets set in decode_gam_rng_tbl */
1739
+ uv_possible_blades = (_max_socket - _min_socket ) + 1 ;
1736
1740
1737
1741
/* uv_num_possible_blades() is really the hub count: */
1738
1742
pr_info ("UV: Found %d hubs, %d nodes, %d CPUs\n" , uv_num_possible_blades (), num_possible_nodes (), num_possible_cpus ());
@@ -1741,86 +1745,108 @@ static void __init uv_system_init_hub(void)
1741
1745
hub_info .coherency_domain_number = sn_coherency_id ;
1742
1746
uv_rtc_init ();
1743
1747
1748
+ /*
1749
+ * __uv_hub_info_list[] is indexed by node, but there is only
1750
+ * one hub_info structure per blade. First, allocate one
1751
+ * structure per blade. Further down we create a per-node
1752
+ * table (__uv_hub_info_list[]) pointing to hub_info
1753
+ * structures for the correct blade.
1754
+ */
1755
+
1744
1756
bytes = sizeof (void * ) * uv_num_possible_blades ();
1745
- __uv_hub_info_list = kzalloc (bytes , GFP_KERNEL );
1746
- BUG_ON (!__uv_hub_info_list );
1757
+ uv_hub_info_list_blade = kzalloc (bytes , GFP_KERNEL );
1758
+ if (WARN_ON_ONCE (!uv_hub_info_list_blade ))
1759
+ return ;
1747
1760
1748
1761
bytes = sizeof (struct uv_hub_info_s );
1749
- for_each_node ( nodeid ) {
1762
+ for_each_possible_blade ( bid ) {
1750
1763
struct uv_hub_info_s * new_hub ;
1751
1764
1752
- if (__uv_hub_info_list [nodeid ]) {
1753
- pr_err ("UV: Node %d UV HUB already initialized!?\n" , nodeid );
1754
- BUG ();
1765
+ /* Allocate & fill new per hub info list */
1766
+ new_hub = (bid == 0 ) ? & uv_hub_info_node0
1767
+ : kzalloc_node (bytes , GFP_KERNEL , uv_blade_to_node (bid ));
1768
+ if (WARN_ON_ONCE (!new_hub )) {
1769
+ /* do not kfree() bid 0, which is statically allocated */
1770
+ while (-- bid > 0 )
1771
+ kfree (uv_hub_info_list_blade [bid ]);
1772
+ kfree (uv_hub_info_list_blade );
1773
+ return ;
1755
1774
}
1756
1775
1757
- /* Allocate new per hub info list */
1758
- new_hub = (nodeid == 0 ) ? & uv_hub_info_node0 : kzalloc_node (bytes , GFP_KERNEL , nodeid );
1759
- BUG_ON (!new_hub );
1760
- __uv_hub_info_list [nodeid ] = new_hub ;
1761
- new_hub = uv_hub_info_list (nodeid );
1762
- BUG_ON (!new_hub );
1776
+ uv_hub_info_list_blade [bid ] = new_hub ;
1763
1777
* new_hub = hub_info ;
1764
1778
1765
1779
/* Use information from GAM table if available: */
1766
- if (_node_to_pnode )
1767
- new_hub -> pnode = _node_to_pnode [ nodeid ] ;
1780
+ if (uv_gre_table )
1781
+ new_hub -> pnode = uv_blade_to_pnode ( bid ) ;
1768
1782
else /* Or fill in during CPU loop: */
1769
1783
new_hub -> pnode = 0xffff ;
1770
1784
1771
- new_hub -> numa_blade_id = uv_node_to_blade_id ( nodeid ) ;
1785
+ new_hub -> numa_blade_id = bid ;
1772
1786
new_hub -> memory_nid = NUMA_NO_NODE ;
1773
1787
new_hub -> nr_possible_cpus = 0 ;
1774
1788
new_hub -> nr_online_cpus = 0 ;
1775
1789
}
1776
1790
1791
+ /*
1792
+ * Now populate __uv_hub_info_list[] for each node with the
1793
+ * pointer to the struct for the blade it resides on.
1794
+ */
1795
+
1796
+ bytes = sizeof (void * ) * num_possible_nodes ();
1797
+ __uv_hub_info_list = kzalloc (bytes , GFP_KERNEL );
1798
+ if (WARN_ON_ONCE (!__uv_hub_info_list )) {
1799
+ for_each_possible_blade (bid )
1800
+ /* bid 0 is statically allocated */
1801
+ if (bid != 0 )
1802
+ kfree (uv_hub_info_list_blade [bid ]);
1803
+ kfree (uv_hub_info_list_blade );
1804
+ return ;
1805
+ }
1806
+
1807
+ for_each_node (nodeid )
1808
+ __uv_hub_info_list [nodeid ] = uv_hub_info_list_blade [uv_node_to_blade_id (nodeid )];
1809
+
1777
1810
/* Initialize per CPU info: */
1778
1811
for_each_possible_cpu (cpu ) {
1779
- int apicid = per_cpu (x86_cpu_to_apicid , cpu );
1780
- int numa_node_id ;
1812
+ int apicid = early_per_cpu (x86_cpu_to_apicid , cpu );
1813
+ unsigned short bid ;
1781
1814
unsigned short pnode ;
1782
1815
1783
- nodeid = cpu_to_node (cpu );
1784
- numa_node_id = numa_cpu_node (cpu );
1785
1816
pnode = uv_apicid_to_pnode (apicid );
1817
+ bid = uv_pnode_to_socket (pnode ) - _min_socket ;
1786
1818
1787
- uv_cpu_info_per (cpu )-> p_uv_hub_info = uv_hub_info_list ( nodeid ) ;
1819
+ uv_cpu_info_per (cpu )-> p_uv_hub_info = uv_hub_info_list_blade [ bid ] ;
1788
1820
uv_cpu_info_per (cpu )-> blade_cpu_id = uv_cpu_hub_info (cpu )-> nr_possible_cpus ++ ;
1789
1821
if (uv_cpu_hub_info (cpu )-> memory_nid == NUMA_NO_NODE )
1790
1822
uv_cpu_hub_info (cpu )-> memory_nid = cpu_to_node (cpu );
1791
1823
1792
- /* Init memoryless node: */
1793
- if (nodeid != numa_node_id &&
1794
- uv_hub_info_list (numa_node_id )-> pnode == 0xffff )
1795
- uv_hub_info_list (numa_node_id )-> pnode = pnode ;
1796
- else if (uv_cpu_hub_info (cpu )-> pnode == 0xffff )
1824
+ if (uv_cpu_hub_info (cpu )-> pnode == 0xffff )
1797
1825
uv_cpu_hub_info (cpu )-> pnode = pnode ;
1798
1826
}
1799
1827
1800
- for_each_node ( nodeid ) {
1801
- unsigned short pnode = uv_hub_info_list ( nodeid ) -> pnode ;
1828
+ for_each_possible_blade ( bid ) {
1829
+ unsigned short pnode = uv_hub_info_list_blade [ bid ] -> pnode ;
1802
1830
1803
- /* Add pnode info for pre-GAM list nodes without CPUs: */
1804
- if (pnode == 0xffff ) {
1805
- unsigned long paddr ;
1831
+ if (pnode == 0xffff )
1832
+ continue ;
1806
1833
1807
- paddr = node_start_pfn (nodeid ) << PAGE_SHIFT ;
1808
- pnode = uv_gpa_to_pnode (uv_soc_phys_ram_to_gpa (paddr ));
1809
- uv_hub_info_list (nodeid )-> pnode = pnode ;
1810
- }
1811
1834
min_pnode = min (pnode , min_pnode );
1812
1835
max_pnode = max (pnode , max_pnode );
1813
- pr_info ("UV: UVHUB node :%2d pn:%02x nrcpus:%d\n" ,
1814
- nodeid ,
1815
- uv_hub_info_list ( nodeid ) -> pnode ,
1816
- uv_hub_info_list ( nodeid ) -> nr_possible_cpus );
1836
+ pr_info ("UV: HUB :%2d pn:%02x nrcpus:%d\n" ,
1837
+ bid ,
1838
+ uv_hub_info_list_blade [ bid ] -> pnode ,
1839
+ uv_hub_info_list_blade [ bid ] -> nr_possible_cpus );
1817
1840
}
1818
1841
1819
1842
pr_info ("UV: min_pnode:%02x max_pnode:%02x\n" , min_pnode , max_pnode );
1820
1843
map_gru_high (max_pnode );
1821
1844
map_mmr_high (max_pnode );
1822
1845
map_mmioh_high (min_pnode , max_pnode );
1823
1846
1847
+ kfree (uv_hub_info_list_blade );
1848
+ uv_hub_info_list_blade = NULL ;
1849
+
1824
1850
uv_nmi_setup ();
1825
1851
uv_cpu_init ();
1826
1852
uv_setup_proc_files (0 );
0 commit comments