@@ -526,39 +526,71 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
526
526
}
527
527
}
528
528
529
+ union gc_info {
530
+ struct gc_info_v1_0 v1 ;
531
+ struct gc_info_v2_0 v2 ;
532
+ };
533
+
529
534
int amdgpu_discovery_get_gfx_info (struct amdgpu_device * adev )
530
535
{
531
536
struct binary_header * bhdr ;
532
- struct gc_info_v1_0 * gc_info ;
537
+ union gc_info * gc_info ;
533
538
534
539
if (!adev -> mman .discovery_bin ) {
535
540
DRM_ERROR ("ip discovery uninitialized\n" );
536
541
return - EINVAL ;
537
542
}
538
543
539
544
bhdr = (struct binary_header * )adev -> mman .discovery_bin ;
540
- gc_info = (struct gc_info_v1_0 * )(adev -> mman .discovery_bin +
545
+ gc_info = (union gc_info * )(adev -> mman .discovery_bin +
541
546
le16_to_cpu (bhdr -> table_list [GC ].offset ));
542
-
543
- adev -> gfx .config .max_shader_engines = le32_to_cpu (gc_info -> gc_num_se );
544
- adev -> gfx .config .max_cu_per_sh = 2 * (le32_to_cpu (gc_info -> gc_num_wgp0_per_sa ) +
545
- le32_to_cpu (gc_info -> gc_num_wgp1_per_sa ));
546
- adev -> gfx .config .max_sh_per_se = le32_to_cpu (gc_info -> gc_num_sa_per_se );
547
- adev -> gfx .config .max_backends_per_se = le32_to_cpu (gc_info -> gc_num_rb_per_se );
548
- adev -> gfx .config .max_texture_channel_caches = le32_to_cpu (gc_info -> gc_num_gl2c );
549
- adev -> gfx .config .max_gprs = le32_to_cpu (gc_info -> gc_num_gprs );
550
- adev -> gfx .config .max_gs_threads = le32_to_cpu (gc_info -> gc_num_max_gs_thds );
551
- adev -> gfx .config .gs_vgt_table_depth = le32_to_cpu (gc_info -> gc_gs_table_depth );
552
- adev -> gfx .config .gs_prim_buffer_depth = le32_to_cpu (gc_info -> gc_gsprim_buff_depth );
553
- adev -> gfx .config .double_offchip_lds_buf = le32_to_cpu (gc_info -> gc_double_offchip_lds_buffer );
554
- adev -> gfx .cu_info .wave_front_size = le32_to_cpu (gc_info -> gc_wave_size );
555
- adev -> gfx .cu_info .max_waves_per_simd = le32_to_cpu (gc_info -> gc_max_waves_per_simd );
556
- adev -> gfx .cu_info .max_scratch_slots_per_cu = le32_to_cpu (gc_info -> gc_max_scratch_slots_per_cu );
557
- adev -> gfx .cu_info .lds_size = le32_to_cpu (gc_info -> gc_lds_size );
558
- adev -> gfx .config .num_sc_per_sh = le32_to_cpu (gc_info -> gc_num_sc_per_se ) /
559
- le32_to_cpu (gc_info -> gc_num_sa_per_se );
560
- adev -> gfx .config .num_packer_per_sc = le32_to_cpu (gc_info -> gc_num_packer_per_sc );
561
-
547
+ switch (gc_info -> v1 .header .version_major ) {
548
+ case 1 :
549
+ adev -> gfx .config .max_shader_engines = le32_to_cpu (gc_info -> v1 .gc_num_se );
550
+ adev -> gfx .config .max_cu_per_sh = 2 * (le32_to_cpu (gc_info -> v1 .gc_num_wgp0_per_sa ) +
551
+ le32_to_cpu (gc_info -> v1 .gc_num_wgp1_per_sa ));
552
+ adev -> gfx .config .max_sh_per_se = le32_to_cpu (gc_info -> v1 .gc_num_sa_per_se );
553
+ adev -> gfx .config .max_backends_per_se = le32_to_cpu (gc_info -> v1 .gc_num_rb_per_se );
554
+ adev -> gfx .config .max_texture_channel_caches = le32_to_cpu (gc_info -> v1 .gc_num_gl2c );
555
+ adev -> gfx .config .max_gprs = le32_to_cpu (gc_info -> v1 .gc_num_gprs );
556
+ adev -> gfx .config .max_gs_threads = le32_to_cpu (gc_info -> v1 .gc_num_max_gs_thds );
557
+ adev -> gfx .config .gs_vgt_table_depth = le32_to_cpu (gc_info -> v1 .gc_gs_table_depth );
558
+ adev -> gfx .config .gs_prim_buffer_depth = le32_to_cpu (gc_info -> v1 .gc_gsprim_buff_depth );
559
+ adev -> gfx .config .double_offchip_lds_buf = le32_to_cpu (gc_info -> v1 .gc_double_offchip_lds_buffer );
560
+ adev -> gfx .cu_info .wave_front_size = le32_to_cpu (gc_info -> v1 .gc_wave_size );
561
+ adev -> gfx .cu_info .max_waves_per_simd = le32_to_cpu (gc_info -> v1 .gc_max_waves_per_simd );
562
+ adev -> gfx .cu_info .max_scratch_slots_per_cu = le32_to_cpu (gc_info -> v1 .gc_max_scratch_slots_per_cu );
563
+ adev -> gfx .cu_info .lds_size = le32_to_cpu (gc_info -> v1 .gc_lds_size );
564
+ adev -> gfx .config .num_sc_per_sh = le32_to_cpu (gc_info -> v1 .gc_num_sc_per_se ) /
565
+ le32_to_cpu (gc_info -> v1 .gc_num_sa_per_se );
566
+ adev -> gfx .config .num_packer_per_sc = le32_to_cpu (gc_info -> v1 .gc_num_packer_per_sc );
567
+ break ;
568
+ case 2 :
569
+ adev -> gfx .config .max_shader_engines = le32_to_cpu (gc_info -> v2 .gc_num_se );
570
+ adev -> gfx .config .max_cu_per_sh = le32_to_cpu (gc_info -> v2 .gc_num_cu_per_sh );
571
+ adev -> gfx .config .max_sh_per_se = le32_to_cpu (gc_info -> v2 .gc_num_sh_per_se );
572
+ adev -> gfx .config .max_backends_per_se = le32_to_cpu (gc_info -> v2 .gc_num_rb_per_se );
573
+ adev -> gfx .config .max_texture_channel_caches = le32_to_cpu (gc_info -> v2 .gc_num_tccs );
574
+ adev -> gfx .config .max_gprs = le32_to_cpu (gc_info -> v2 .gc_num_gprs );
575
+ adev -> gfx .config .max_gs_threads = le32_to_cpu (gc_info -> v2 .gc_num_max_gs_thds );
576
+ adev -> gfx .config .gs_vgt_table_depth = le32_to_cpu (gc_info -> v2 .gc_gs_table_depth );
577
+ adev -> gfx .config .gs_prim_buffer_depth = le32_to_cpu (gc_info -> v2 .gc_gsprim_buff_depth );
578
+ adev -> gfx .config .double_offchip_lds_buf = le32_to_cpu (gc_info -> v2 .gc_double_offchip_lds_buffer );
579
+ adev -> gfx .cu_info .wave_front_size = le32_to_cpu (gc_info -> v2 .gc_wave_size );
580
+ adev -> gfx .cu_info .max_waves_per_simd = le32_to_cpu (gc_info -> v2 .gc_max_waves_per_simd );
581
+ adev -> gfx .cu_info .max_scratch_slots_per_cu = le32_to_cpu (gc_info -> v2 .gc_max_scratch_slots_per_cu );
582
+ adev -> gfx .cu_info .lds_size = le32_to_cpu (gc_info -> v2 .gc_lds_size );
583
+ adev -> gfx .config .num_sc_per_sh = le32_to_cpu (gc_info -> v2 .gc_num_sc_per_se ) /
584
+ le32_to_cpu (gc_info -> v2 .gc_num_sh_per_se );
585
+ adev -> gfx .config .num_packer_per_sc = le32_to_cpu (gc_info -> v2 .gc_num_packer_per_sc );
586
+ break ;
587
+ default :
588
+ dev_err (adev -> dev ,
589
+ "Unhandled GC info table %d.%d\n" ,
590
+ gc_info -> v1 .header .version_major ,
591
+ gc_info -> v1 .header .version_minor );
592
+ return - EINVAL ;
593
+ }
562
594
return 0 ;
563
595
}
564
596
0 commit comments