@@ -31,7 +31,8 @@ static u64 gru_start_paddr, gru_end_paddr;
3131static union uvh_apicid uvh_apicid ;
3232static int uv_node_id ;
3333
34- /* Unpack OEM/TABLE ID's to be NULL terminated strings */
34+ /* Unpack AT/OEM/TABLE ID's to be NULL terminated strings */
35+ static u8 uv_archtype [UV_AT_SIZE ];
3536static u8 oem_id [ACPI_OEM_ID_SIZE + 1 ];
3637static u8 oem_table_id [ACPI_OEM_TABLE_ID_SIZE + 1 ];
3738
@@ -284,18 +285,102 @@ static void __init uv_stringify(int len, char *to, char *from)
284285 strncpy (to , from , len - 1 );
285286}
286287
288+ /* Find UV arch type entry in UVsystab */
289+ static unsigned long __init early_find_archtype (struct uv_systab * st )
290+ {
291+ int i ;
292+
293+ for (i = 0 ; st -> entry [i ].type != UV_SYSTAB_TYPE_UNUSED ; i ++ ) {
294+ unsigned long ptr = st -> entry [i ].offset ;
295+
296+ if (!ptr )
297+ continue ;
298+ ptr += (unsigned long )st ;
299+ if (st -> entry [i ].type == UV_SYSTAB_TYPE_ARCH_TYPE )
300+ return ptr ;
301+ }
302+ return 0 ;
303+ }
304+
305+ /* Validate UV arch type field in UVsystab */
306+ static int __init decode_arch_type (unsigned long ptr )
307+ {
308+ struct uv_arch_type_entry * uv_ate = (struct uv_arch_type_entry * )ptr ;
309+ int n = strlen (uv_ate -> archtype );
310+
311+ if (n > 0 && n < sizeof (uv_ate -> archtype )) {
312+ pr_info ("UV: UVarchtype received from BIOS\n" );
313+ uv_stringify (UV_AT_SIZE , uv_archtype , uv_ate -> archtype );
314+ return 1 ;
315+ }
316+ return 0 ;
317+ }
318+
319+ /* Determine if UV arch type entry might exist in UVsystab */
320+ static int __init early_get_arch_type (void )
321+ {
322+ unsigned long uvst_physaddr , uvst_size , ptr ;
323+ struct uv_systab * st ;
324+ u32 rev ;
325+ int ret ;
326+
327+ uvst_physaddr = get_uv_systab_phys (0 );
328+ if (!uvst_physaddr )
329+ return 0 ;
330+
331+ st = early_memremap_ro (uvst_physaddr , sizeof (struct uv_systab ));
332+ if (!st ) {
333+ pr_err ("UV: Cannot access UVsystab, remap failed\n" );
334+ return 0 ;
335+ }
336+
337+ rev = st -> revision ;
338+ if (rev < UV_SYSTAB_VERSION_UV5 ) {
339+ early_memunmap (st , sizeof (struct uv_systab ));
340+ return 0 ;
341+ }
342+
343+ uvst_size = st -> size ;
344+ early_memunmap (st , sizeof (struct uv_systab ));
345+ st = early_memremap_ro (uvst_physaddr , uvst_size );
346+ if (!st ) {
347+ pr_err ("UV: Cannot access UVarchtype, remap failed\n" );
348+ return 0 ;
349+ }
350+
351+ ptr = early_find_archtype (st );
352+ if (!ptr ) {
353+ early_memunmap (st , uvst_size );
354+ return 0 ;
355+ }
356+
357+ ret = decode_arch_type (ptr );
358+ early_memunmap (st , uvst_size );
359+ return ret ;
360+ }
361+
287362static int __init uv_set_system_type (char * _oem_id )
288363{
289- /* Save OEM ID */
364+ /* Save OEM_ID passed from ACPI MADT */
290365 uv_stringify (sizeof (oem_id ), oem_id , _oem_id );
291366
292- /* Set hubless type if true */
293- if (strncmp (oem_id , "SGI" , 3 ) != 0 ) {
294- if (strncmp (oem_id , "NSGI" , 4 ) != 0 )
367+ /* Check if BIOS sent us a UVarchtype */
368+ if (!early_get_arch_type ())
369+
370+ /* If not use OEM ID for UVarchtype */
371+ uv_stringify (UV_AT_SIZE , uv_archtype , _oem_id );
372+
373+ /* Check if not hubbed */
374+ if (strncmp (uv_archtype , "SGI" , 3 ) != 0 ) {
375+
376+ /* (Not hubbed), check if not hubless */
377+ if (strncmp (uv_archtype , "NSGI" , 4 ) != 0 )
378+
379+ /* (Not hubless), not a UV */
295380 return 0 ;
296381
297382 /* UV4 Hubless: CH */
298- if (strncmp (oem_id , "NSGI4" , 5 ) == 0 )
383+ if (strncmp (uv_archtype , "NSGI4" , 5 ) == 0 )
299384 uv_hubless_system = 0x11 ;
300385
301386 /* UV3 Hubless: UV300/MC990X w/o hub */
@@ -314,10 +399,10 @@ static int __init uv_set_system_type(char *_oem_id)
314399
315400 /* Set hubbed type if true */
316401 uv_hub_info -> hub_revision =
317- !strncmp (oem_id , "SGI5" , 4 ) ? UV5_HUB_REVISION_BASE :
318- !strncmp (oem_id , "SGI4" , 4 ) ? UV4_HUB_REVISION_BASE :
319- !strncmp (oem_id , "SGI3" , 4 ) ? UV3_HUB_REVISION_BASE :
320- !strcmp (oem_id , "SGI2" ) ? UV2_HUB_REVISION_BASE : 0 ;
402+ !strncmp (uv_archtype , "SGI5" , 4 ) ? UV5_HUB_REVISION_BASE :
403+ !strncmp (uv_archtype , "SGI4" , 4 ) ? UV4_HUB_REVISION_BASE :
404+ !strncmp (uv_archtype , "SGI3" , 4 ) ? UV3_HUB_REVISION_BASE :
405+ !strcmp (uv_archtype , "SGI2" ) ? UV2_HUB_REVISION_BASE : 0 ;
321406
322407 switch (uv_hub_info -> hub_revision ) {
323408 case UV5_HUB_REVISION_BASE :
@@ -388,8 +473,7 @@ static int __init uv_acpi_madt_oem_check(char *_oem_id, char *_oem_table_id)
388473 return 0 ;
389474
390475badbios :
391- pr_err ("UV: OEM_ID:%s OEM_TABLE_ID:%s\n" , oem_id , oem_table_id );
392- pr_err ("UV: Current UV Type or BIOS not supported\n" );
476+ pr_err ("UV: UVarchtype:%s not supported\n" , uv_archtype );
393477 BUG ();
394478}
395479
@@ -1180,6 +1264,7 @@ static void __init decode_gam_rng_tbl(unsigned long ptr)
11801264 pr_info ("UV: GRT: %d entries, sockets(min:%x,max:%x) pnodes(min:%x,max:%x)\n" , index , _min_socket , _max_socket , _min_pnode , _max_pnode );
11811265}
11821266
1267+ /* Walk through UVsystab decoding the fields */
11831268static int __init decode_uv_systab (void )
11841269{
11851270 struct uv_systab * st ;
@@ -1209,7 +1294,8 @@ static int __init decode_uv_systab(void)
12091294 if (!ptr )
12101295 continue ;
12111296
1212- ptr = ptr + (unsigned long )st ;
1297+ /* point to payload */
1298+ ptr += (unsigned long )st ;
12131299
12141300 switch (st -> entry [i ].type ) {
12151301 case UV_SYSTAB_TYPE_GAM_PARAMS :
@@ -1219,6 +1305,15 @@ static int __init decode_uv_systab(void)
12191305 case UV_SYSTAB_TYPE_GAM_RNG_TBL :
12201306 decode_gam_rng_tbl (ptr );
12211307 break ;
1308+
1309+ case UV_SYSTAB_TYPE_ARCH_TYPE :
1310+ /* already processed in early startup */
1311+ break ;
1312+
1313+ default :
1314+ pr_err ("UV:%s:Unrecognized UV_SYSTAB_TYPE:%d, skipped\n" ,
1315+ __func__ , st -> entry [i ].type );
1316+ break ;
12221317 }
12231318 }
12241319 return 0 ;
@@ -1259,7 +1354,7 @@ static void __init build_socket_tables(void)
12591354 pr_info ("UV: No UVsystab socket table, ignoring\n" );
12601355 return ;
12611356 }
1262- pr_crit ("UV: Error: UVsystab address translations not available!\n" );
1357+ pr_err ("UV: Error: UVsystab address translations not available!\n" );
12631358 BUG ();
12641359 }
12651360
@@ -1385,9 +1480,9 @@ static int __maybe_unused proc_hubless_show(struct seq_file *file, void *data)
13851480 return 0 ;
13861481}
13871482
1388- static int __maybe_unused proc_oemid_show (struct seq_file * file , void * data )
1483+ static int __maybe_unused proc_archtype_show (struct seq_file * file , void * data )
13891484{
1390- seq_printf (file , "%s/%s\n" , oem_id , oem_table_id );
1485+ seq_printf (file , "%s/%s\n" , uv_archtype , oem_table_id );
13911486 return 0 ;
13921487}
13931488
@@ -1396,7 +1491,7 @@ static __init void uv_setup_proc_files(int hubless)
13961491 struct proc_dir_entry * pde ;
13971492
13981493 pde = proc_mkdir (UV_PROC_NODE , NULL );
1399- proc_create_single ("oemid " , 0 , pde , proc_oemid_show );
1494+ proc_create_single ("archtype " , 0 , pde , proc_archtype_show );
14001495 if (hubless )
14011496 proc_create_single ("hubless" , 0 , pde , proc_hubless_show );
14021497 else
@@ -1448,12 +1543,14 @@ static void __init uv_system_init_hub(void)
14481543
14491544 map_low_mmrs ();
14501545
1451- /* Get uv_systab for decoding: */
1546+ /* Get uv_systab for decoding, setup UV BIOS calls */
14521547 uv_bios_init ();
14531548
14541549 /* If there's an UVsystab problem then abort UV init: */
1455- if (decode_uv_systab () < 0 )
1550+ if (decode_uv_systab () < 0 ) {
1551+ pr_err ("UV: Mangled UVsystab format\n" );
14561552 return ;
1553+ }
14571554
14581555 build_socket_tables ();
14591556 build_uv_gr_table ();
0 commit comments