@@ -477,6 +477,7 @@ static uintptr_t acl_kernel_cra_set_segment_rom(acl_kernel_if *kern,
477
477
478
478
static int acl_kernel_cra_read (acl_kernel_if *kern, unsigned int accel_id,
479
479
unsigned int addr, unsigned int *val) {
480
+ assert (kern->cra_ring_root_exist );
480
481
uintptr_t segment_offset = acl_kernel_cra_set_segment (kern, accel_id, addr);
481
482
acl_assert_locked_or_sig ();
482
483
return acl_kernel_if_read_32b (
@@ -485,6 +486,7 @@ static int acl_kernel_cra_read(acl_kernel_if *kern, unsigned int accel_id,
485
486
486
487
int acl_kernel_cra_read_64b (acl_kernel_if *kern, unsigned int accel_id,
487
488
unsigned int addr, uint64_t *val) {
489
+ assert (kern->cra_ring_root_exist );
488
490
uintptr_t segment_offset = acl_kernel_cra_set_segment (kern, accel_id, addr);
489
491
acl_assert_locked_or_sig ();
490
492
return acl_kernel_if_read_64b (
@@ -536,6 +538,7 @@ static int acl_kernel_rom_cra_read_block(acl_kernel_if *kern, unsigned int addr,
536
538
537
539
static int acl_kernel_cra_write (acl_kernel_if *kern, unsigned int accel_id,
538
540
unsigned int addr, unsigned int val) {
541
+ assert (kern->cra_ring_root_exist );
539
542
uintptr_t segment_offset = acl_kernel_cra_set_segment (kern, accel_id, addr);
540
543
acl_assert_locked_or_sig ();
541
544
return acl_kernel_if_write_32b (
@@ -544,6 +547,7 @@ static int acl_kernel_cra_write(acl_kernel_if *kern, unsigned int accel_id,
544
547
545
548
static int acl_kernel_cra_write_64b (acl_kernel_if *kern, unsigned int accel_id,
546
549
unsigned int addr, uint64_t val) {
550
+ assert (kern->cra_ring_root_exist );
547
551
uintptr_t segment_offset = acl_kernel_cra_set_segment (kern, accel_id, addr);
548
552
acl_assert_locked ();
549
553
return acl_kernel_if_write_64b (
@@ -553,6 +557,7 @@ static int acl_kernel_cra_write_64b(acl_kernel_if *kern, unsigned int accel_id,
553
557
static int acl_kernel_cra_write_block (acl_kernel_if *kern,
554
558
unsigned int accel_id, unsigned int addr,
555
559
unsigned int *val, size_t size) {
560
+ assert (kern->cra_ring_root_exist );
556
561
uintptr_t segment_offset = acl_kernel_cra_set_segment (kern, accel_id, addr);
557
562
uintptr_t logical_addr =
558
563
kern->accel_csr [accel_id].address + addr - OFFSET_KERNEL_CRA;
@@ -712,8 +717,6 @@ int acl_kernel_if_init(acl_kernel_if *kern, acl_bsp_io bsp_io,
712
717
kern->accel_perf_mon = NULL ;
713
718
kern->accel_num_printfs = NULL ;
714
719
715
- kern->csr_version = 0 ;
716
-
717
720
kern->autorun_profiling_kernel_id = -1 ;
718
721
719
722
// The simulator doesn't have any kernel interface information until the aocx
@@ -897,6 +900,11 @@ int acl_kernel_if_update(const acl_device_def_autodiscovery_t &devdef,
897
900
898
901
acl_kernel_if_close (kern);
899
902
903
+ // Initialize whether the cra_ring_root exist in the design
904
+ kern->cra_ring_root_exist = devdef.cra_ring_root_exist ;
905
+ ACL_KERNEL_IF_DEBUG_MSG (kern, " Number of cra_ring_root : %d\n " ,
906
+ kern->cra_ring_root_exist );
907
+
900
908
// Setup the PCIe HAL Structures
901
909
kern->num_accel = static_cast <unsigned >(devdef.accel .size ());
902
910
ACL_KERNEL_IF_DEBUG_MSG (kern, " Number of Accelerators : %d\n " ,
@@ -1040,7 +1048,8 @@ int acl_kernel_if_post_pll_config_init(acl_kernel_if *kern) {
1040
1048
kern->io .printf (" HAL Kern Error: Post PLL init: Invalid kernel handle" );
1041
1049
assert (0 && " Invalid kernel handle" );
1042
1050
}
1043
- if (kern->num_accel > 0 ) {
1051
+
1052
+ if (kern->num_accel > 0 && kern->cra_ring_root_exist ) {
1044
1053
acl_kernel_cra_read (kern, 0 , KERNEL_OFFSET_CSR, &csr);
1045
1054
version = ACL_KERNEL_READ_BIT_RANGE (csr, KERNEL_CSR_LAST_VERSION_BIT,
1046
1055
KERNEL_CSR_FIRST_VERSION_BIT);
@@ -1054,7 +1063,9 @@ int acl_kernel_if_post_pll_config_init(acl_kernel_if *kern) {
1054
1063
kern->cra_address_offset = 0 ;
1055
1064
}
1056
1065
} else {
1057
- kern->csr_version = 0 ;
1066
+ ACL_KERNEL_IF_DEBUG_MSG (kern,
1067
+ " No accelerator found or CRA ring root doesn't "
1068
+ " exist, not setting kern->csr_version\n " );
1058
1069
}
1059
1070
1060
1071
// If environment variables set, configure the profile hardware
@@ -1161,7 +1172,8 @@ void acl_kernel_if_launch_kernel_on_custom_sof(
1161
1172
// Version is defined in upper 16-bits of the status register and cached
1162
1173
// in the kern->csr_version field. The value is cached after PLL init to
1163
1174
// avoid reading back on every kernel launch, which would add overhead.
1164
- if (!(kern->csr_version >= CSR_VERSION_ID_18_1 &&
1175
+ if (kern->csr_version .has_value () &&
1176
+ !(kern->csr_version >= CSR_VERSION_ID_18_1 &&
1165
1177
kern->csr_version <= CSR_VERSION_ID)) {
1166
1178
kern->io .printf (" Hardware CSR version ID differs from version expected by "
1167
1179
" software. Either:\n " );
@@ -1253,7 +1265,8 @@ void acl_kernel_if_launch_kernel_on_custom_sof(
1253
1265
}
1254
1266
}
1255
1267
1256
- if (kern->csr_version != CSR_VERSION_ID_18_1) {
1268
+ if (kern->csr_version .has_value () &&
1269
+ (kern->csr_version != CSR_VERSION_ID_18_1)) {
1257
1270
for (uintptr_t p = 0 ; p < image->arg_value_size ; p += sizeof (int )) {
1258
1271
unsigned int pword = *(unsigned int *)(image->arg_value + p);
1259
1272
ACL_KERNEL_IF_DEBUG_MSG_VERBOSE (
@@ -1270,7 +1283,9 @@ void acl_kernel_if_launch_kernel_on_custom_sof(
1270
1283
acl_kernel_cra_write_block (kern, accel_id, offset, (unsigned int *)image_p,
1271
1284
image_size_static);
1272
1285
}
1273
- if (kern->csr_version != CSR_VERSION_ID_18_1 && image->arg_value_size > 0 ) {
1286
+
1287
+ if (kern->csr_version .has_value () &&
1288
+ (kern->csr_version != CSR_VERSION_ID_18_1 && image->arg_value_size > 0 )) {
1274
1289
acl_kernel_cra_write_block (
1275
1290
kern, accel_id, offset + (unsigned int )image_size_static,
1276
1291
(unsigned int *)image->arg_value , image->arg_value_size );
0 commit comments