@@ -45,7 +45,8 @@ acl_process_autorun_profiler_scan_chain(unsigned int physical_device_id,
45
45
// address map.
46
46
#define CSR_VERSION_ID_18_1 (3 )
47
47
#define CSR_VERSION_ID_19_1 (4 )
48
- #define CSR_VERSION_ID CSR_VERSION_ID_19_1
48
+ #define CSR_VERSION_ID_23_1 (5 )
49
+ #define CSR_VERSION_ID CSR_VERSION_ID_23_1
49
50
50
51
// Address map
51
52
// For unit tests to work, these defines must match those in the unit test
@@ -66,6 +67,8 @@ acl_process_autorun_profiler_scan_chain(unsigned int physical_device_id,
66
67
#define KERNEL_ROM_SIZE_BYTES 8
67
68
68
69
// Byte offsets into the CRA:
70
+ // For CSR version >= 5 byte offsets are pushed back with the proper
71
+ // value except for the CSR later on in the runtime execution
69
72
#define KERNEL_OFFSET_CSR 0
70
73
#define KERNEL_OFFSET_PRINTF_BUFFER_SIZE 0x4
71
74
#define KERNEL_OFFSET_CSR_PROFILE_CTRL 0xC
@@ -75,11 +78,14 @@ acl_process_autorun_profiler_scan_chain(unsigned int physical_device_id,
75
78
#define KERNEL_OFFSET_FINISH_COUNTER 0x28
76
79
#define KERNEL_OFFSET_INVOCATION_IMAGE 0x30
77
80
81
+ // CSR version >= 5 byte offsets
82
+ #define KERNEL_OFFSET_START_REG 0x8
83
+
78
84
// Backwards compatibility with CSR_VERSION_ID 3
79
85
#define KERNEL_OFFSET_INVOCATION_IMAGE_181 0x28
80
86
81
87
// Bit positions
82
- #define KERNEL_CSR_GO 0
88
+ #define KERNEL_CSR_START 0
83
89
#define KERNEL_CSR_DONE 1
84
90
#define KERNEL_CSR_STALLED 3
85
91
#define KERNEL_CSR_UNSTALL 4
@@ -593,8 +599,9 @@ static int acl_kernel_if_issue_profile_hw_command(acl_kernel_if *kern,
593
599
int status;
594
600
acl_assert_locked_or_sig ();
595
601
assert (acl_kernel_if_is_valid (kern));
596
- status = acl_kernel_cra_read (kern, accel_id, KERNEL_OFFSET_CSR_PROFILE_CTRL,
597
- &profile_ctrl_val);
602
+ status = acl_kernel_cra_read (
603
+ kern, accel_id, KERNEL_OFFSET_CSR_PROFILE_CTRL + kern->cra_address_offset ,
604
+ &profile_ctrl_val);
598
605
if (status)
599
606
return status;
600
607
ACL_KERNEL_IF_DEBUG_MSG (
@@ -609,8 +616,9 @@ static int acl_kernel_if_issue_profile_hw_command(acl_kernel_if *kern,
609
616
ACL_KERNEL_IF_DEBUG_MSG (
610
617
kern, " :: Issue profile HW command:: Accelerator %d new csr is %x.\n " ,
611
618
accel_id, profile_ctrl_val);
612
- status = acl_kernel_cra_write (kern, accel_id, KERNEL_OFFSET_CSR_PROFILE_CTRL,
613
- profile_ctrl_val);
619
+ status = acl_kernel_cra_write (
620
+ kern, accel_id, KERNEL_OFFSET_CSR_PROFILE_CTRL + kern->cra_address_offset ,
621
+ profile_ctrl_val);
614
622
if (status)
615
623
return status;
616
624
return 0 ;
@@ -1040,6 +1048,11 @@ int acl_kernel_if_post_pll_config_init(acl_kernel_if *kern) {
1040
1048
ACL_KERNEL_IF_DEBUG_MSG (kern,
1041
1049
" Read CSR version from kernel 0: Version = %u\n " ,
1042
1050
kern->csr_version );
1051
+ if (kern->csr_version < 5 ) {
1052
+ // Register addresses are pushed back since previous versions
1053
+ // doesn't have the start register
1054
+ kern->cra_address_offset = 0 ;
1055
+ }
1043
1056
} else {
1044
1057
kern->csr_version = 0 ;
1045
1058
}
@@ -1220,7 +1233,8 @@ void acl_kernel_if_launch_kernel_on_custom_sof(
1220
1233
}
1221
1234
1222
1235
} else {
1223
- offset = (unsigned int )KERNEL_OFFSET_INVOCATION_IMAGE;
1236
+ offset = (unsigned int )(KERNEL_OFFSET_INVOCATION_IMAGE +
1237
+ kern->cra_address_offset );
1224
1238
image_p = (uintptr_t ) & (image->work_dim );
1225
1239
image_size_static =
1226
1240
(size_t )((uintptr_t ) & (image->arg_value ) - (uintptr_t ) &
@@ -1279,11 +1293,15 @@ void acl_kernel_if_launch_kernel_on_custom_sof(
1279
1293
return ;
1280
1294
}
1281
1295
1282
- unsigned int new_csr = 0 ;
1283
- acl_kernel_cra_read (kern, accel_id, KERNEL_OFFSET_CSR, &new_csr);
1284
- ACL_KERNEL_SET_BIT (new_csr, KERNEL_CSR_GO);
1285
- acl_kernel_cra_write (kern, accel_id, KERNEL_OFFSET_CSR, new_csr);
1286
-
1296
+ // backwards compatibility for version prior to 2023.1
1297
+ if (kern->csr_version < CSR_VERSION_ID) {
1298
+ unsigned int new_csr = 0 ;
1299
+ acl_kernel_cra_read (kern, accel_id, KERNEL_OFFSET_CSR, &new_csr);
1300
+ ACL_KERNEL_SET_BIT (new_csr, KERNEL_CSR_START);
1301
+ acl_kernel_cra_write (kern, accel_id, KERNEL_OFFSET_CSR, new_csr);
1302
+ } else {
1303
+ acl_kernel_cra_write (kern, accel_id, KERNEL_OFFSET_START_REG, 1 );
1304
+ }
1287
1305
// IRQ handler takes care of the completion event through
1288
1306
// acl_kernel_if_update_status()
1289
1307
}
@@ -1362,7 +1380,9 @@ static void acl_kernel_if_update_status_query(acl_kernel_if *kern,
1362
1380
// kernel arguments
1363
1381
printf_size = 0 ;
1364
1382
if (kern->accel_num_printfs [accel_id] > 0 ) {
1365
- acl_kernel_cra_read (kern, accel_id, KERNEL_OFFSET_PRINTF_BUFFER_SIZE,
1383
+ acl_kernel_cra_read (kern, accel_id,
1384
+ KERNEL_OFFSET_PRINTF_BUFFER_SIZE +
1385
+ kern->cra_address_offset ,
1366
1386
&printf_size);
1367
1387
assert (printf_size <= ACL_PRINTF_BUFFER_TOTAL_SIZE);
1368
1388
ACL_KERNEL_IF_DEBUG_MSG (kern,
@@ -1427,7 +1447,8 @@ static void acl_kernel_if_update_status_query(acl_kernel_if *kern,
1427
1447
// Only expect single completion for older csr version
1428
1448
finish_counter = 1 ;
1429
1449
} else {
1430
- acl_kernel_cra_read (kern, accel_id, KERNEL_OFFSET_FINISH_COUNTER,
1450
+ acl_kernel_cra_read (kern, accel_id,
1451
+ KERNEL_OFFSET_FINISH_COUNTER + kern->cra_address_offset ,
1431
1452
&finish_counter);
1432
1453
ACL_KERNEL_IF_DEBUG_MSG (kern, " :: Accelerator %d has %d finishes.\n " ,
1433
1454
accel_id, finish_counter);
@@ -1586,8 +1607,9 @@ void acl_kernel_if_debug_dump_printf(acl_kernel_if *kern, unsigned k) {
1586
1607
next_queue_back = kern->accel_queue_back [k] + 1 ;
1587
1608
1588
1609
if (kern->accel_num_printfs [k] > 0 ) {
1589
- acl_kernel_cra_read (kern, k, KERNEL_OFFSET_PRINTF_BUFFER_SIZE,
1590
- &printf_size);
1610
+ acl_kernel_cra_read (
1611
+ kern, k, KERNEL_OFFSET_PRINTF_BUFFER_SIZE + kern->cra_address_offset ,
1612
+ &printf_size);
1591
1613
assert (printf_size <= ACL_PRINTF_BUFFER_TOTAL_SIZE);
1592
1614
ACL_KERNEL_IF_DEBUG_MSG (
1593
1615
kern, " :: Accelerator %d printf buffer size is %d.\n " , k, printf_size);
@@ -1785,16 +1807,19 @@ static uint64_t acl_kernel_if_get_profile_data_word(acl_kernel_if *kern,
1785
1807
#ifdef _WIN32
1786
1808
// Use 32-bit reads on Windows.
1787
1809
unsigned int low_word, high_word;
1788
- status = acl_kernel_cra_read (kern, accel_id, KERNEL_OFFSET_CSR_PROFILE_DATA,
1789
- &low_word);
1810
+ status = acl_kernel_cra_read (
1811
+ kern, accel_id, KERNEL_OFFSET_CSR_PROFILE_DATA + kern->cra_address_offset ,
1812
+ &low_word);
1790
1813
if (status)
1791
1814
return (uint64_t )status;
1792
1815
ACL_KERNEL_IF_DEBUG_MSG (kern,
1793
1816
" :: Read profile hardware:: Accelerator %d "
1794
1817
" profile_data low_word is %x.\n " ,
1795
1818
accel_id, low_word);
1796
1819
status = acl_kernel_cra_read (kern, accel_id,
1797
- KERNEL_OFFSET_CSR_PROFILE_DATA + 4 , &high_word);
1820
+ KERNEL_OFFSET_CSR_PROFILE_DATA + 4 +
1821
+ kern->cra_address_offset ,
1822
+ &high_word);
1798
1823
if (status)
1799
1824
return (uint64_t )status;
1800
1825
ACL_KERNEL_IF_DEBUG_MSG (kern,
@@ -1805,7 +1830,8 @@ static uint64_t acl_kernel_if_get_profile_data_word(acl_kernel_if *kern,
1805
1830
((((uint64_t )high_word) & 0xFFFFFFFF ) << 32 ) | (low_word & 0xFFFFFFFF );
1806
1831
#else
1807
1832
status = acl_kernel_cra_read_64b (
1808
- kern, accel_id, KERNEL_OFFSET_CSR_PROFILE_DATA, &read_result);
1833
+ kern, accel_id, KERNEL_OFFSET_CSR_PROFILE_DATA + kern->cra_address_offset ,
1834
+ &read_result);
1809
1835
if (status)
1810
1836
return (uint64_t )status;
1811
1837
ACL_KERNEL_IF_DEBUG_MSG (kern,
@@ -1905,7 +1931,8 @@ int acl_kernel_if_set_profile_start_cycle(acl_kernel_if *kern, cl_uint accel_id,
1905
1931
assert (acl_kernel_if_is_valid (kern));
1906
1932
assert (accel_id < kern->num_accel );
1907
1933
status = acl_kernel_cra_write_64b (
1908
- kern, accel_id, KERNEL_OFFSET_CSR_PROFILE_START_CYCLE, value);
1934
+ kern, accel_id,
1935
+ KERNEL_OFFSET_CSR_PROFILE_START_CYCLE + kern->cra_address_offset , value);
1909
1936
1910
1937
return status;
1911
1938
}
@@ -1919,6 +1946,7 @@ int acl_kernel_if_set_profile_stop_cycle(acl_kernel_if *kern, cl_uint accel_id,
1919
1946
assert (acl_kernel_if_is_valid (kern));
1920
1947
assert (accel_id < kern->num_accel );
1921
1948
status = acl_kernel_cra_write_64b (
1922
- kern, accel_id, KERNEL_OFFSET_CSR_PROFILE_STOP_CYCLE, value);
1949
+ kern, accel_id,
1950
+ KERNEL_OFFSET_CSR_PROFILE_STOP_CYCLE + kern->cra_address_offset , value);
1923
1951
return status;
1924
1952
}
0 commit comments