Skip to content

Commit 55140e6

Browse files
shuoniu-intelpcolberg
authored andcommitted
Explicitly clear the CSR_done bit and bump the CSR version
1 parent b729c4e commit 55140e6

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/acl_kernel_if.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ acl_process_autorun_profiler_scan_chain(unsigned int physical_device_id,
4343
// Version number in the top 16-bits of the 32-bit status register. Used
4444
// to verify that the hardware and HAL have an identical view of the CSR
4545
// address map.
46-
#define CSR_VERSION_ID_181 (3)
47-
#define CSR_VERSION_ID (4)
46+
#define CSR_VERSION_ID_18_1 (3)
47+
#define CSR_VERSION_ID_19_1 (4)
48+
#define CSR_VERSION_ID_2022_3 (5)
49+
#define CSR_VERSION_ID CSR_VERSION_ID_2022_3
4850

4951
// Address map
5052
// For unit tests to work, these defines must match those in the unit test
@@ -1137,8 +1139,8 @@ void acl_kernel_if_launch_kernel_on_custom_sof(
11371139
// Version is defined in upper 16-bits of the status register and cached
11381140
// in the kern->csr_version field. The value is cached after PLL init to
11391141
// avoid reading back on every kernel launch, which would add overhead.
1140-
if (kern->csr_version != CSR_VERSION_ID &&
1141-
kern->csr_version != CSR_VERSION_ID_181) {
1142+
if (!(kern->csr_version >= CSR_VERSION_ID_18_1 &&
1143+
kern->csr_version <= CSR_VERSION_ID)) {
11421144
kern->io.printf("Hardware CSR version ID differs from version expected by "
11431145
"software. Either:\n");
11441146
kern->io.printf(" a) Ensure your compiled design was generated by the "
@@ -1185,7 +1187,7 @@ void acl_kernel_if_launch_kernel_on_custom_sof(
11851187
size_t image_size_static;
11861188
unsigned int offset;
11871189
acl_dev_kernel_invocation_image_181_t image_181;
1188-
if (kern->csr_version == CSR_VERSION_ID_181) {
1190+
if (kern->csr_version == CSR_VERSION_ID_18_1) {
11891191
offset = (unsigned int)KERNEL_OFFSET_INVOCATION_IMAGE_181;
11901192
image_p = (uintptr_t)&image_181;
11911193
image_size_static =
@@ -1224,7 +1226,7 @@ void acl_kernel_if_launch_kernel_on_custom_sof(
12241226
(void *)(offset + p), pword);
12251227
}
12261228

1227-
if (kern->csr_version != CSR_VERSION_ID_181) {
1229+
if (kern->csr_version != CSR_VERSION_ID_18_1) {
12281230
for (uintptr_t p = 0; p < image->arg_value_size; p += sizeof(int)) {
12291231
unsigned int pword = *(unsigned int *)(image->arg_value + p);
12301232
ACL_KERNEL_IF_DEBUG_MSG_VERBOSE(
@@ -1238,7 +1240,7 @@ void acl_kernel_if_launch_kernel_on_custom_sof(
12381240
// it is in dynamic memory
12391241
acl_kernel_cra_write_block(kern, accel_id, offset, (unsigned int *)image_p,
12401242
image_size_static);
1241-
if (kern->csr_version != CSR_VERSION_ID_181) {
1243+
if (kern->csr_version != CSR_VERSION_ID_18_1) {
12421244
acl_kernel_cra_write_block(
12431245
kern, accel_id, offset + (unsigned int)image_size_static,
12441246
(unsigned int *)image->arg_value, image->arg_value_size);
@@ -1439,7 +1441,7 @@ void acl_kernel_if_update_status(acl_kernel_if *kern) {
14391441

14401442
kern->last_kern_update = acl_kernel_if_get_time_us(kern);
14411443

1442-
if (kern->csr_version == CSR_VERSION_ID_181) {
1444+
if (kern->csr_version == CSR_VERSION_ID_18_1) {
14431445
// Only expect single completion for older csr version
14441446
finish_counter = 1;
14451447
} else {
@@ -1470,8 +1472,10 @@ void acl_kernel_if_update_status(acl_kernel_if *kern) {
14701472

14711473
// Just clear the "done" bit. The "go" bit should already have been
14721474
// cleared, but this is harmless anyway.
1473-
// Since csr version 19, done bit is cleared when finish counter is read
1474-
if (kern->csr_version == CSR_VERSION_ID_181) {
1475+
// Since csr version 19, done bit is cleared when finish counter is read.
1476+
// Since csr version 2022.3, done bit needs to be cleared explicitly.
1477+
if (kern->csr_version == CSR_VERSION_ID_18_1 ||
1478+
kern->csr_version >= CSR_VERSION_ID_2022_3) {
14751479
unsigned int dum;
14761480
acl_kernel_cra_write(kern, k, KERNEL_OFFSET_CSR, 0);
14771481
acl_kernel_cra_read(kern, k, KERNEL_OFFSET_CSR, &dum);

0 commit comments

Comments
 (0)