Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base_fw: update mem_state_info TLV #8871

Merged
merged 1 commit into from
May 13, 2024

Conversation

dnikodem
Copy link
Contributor

@dnikodem dnikodem commented Feb 19, 2024

This change improves the TLV assembly algorithm in accordance with how the part for hpsram is assembled. In the case when ebb_state_dword_count is equal to 0, we skip adding the LSPGCTL register value for lpsram.

The following PR must be merged into the Zephyr repository before we can merge this PR:

@@ -47,7 +47,8 @@
#define L2HSBPM(x) (0x17A800 + 0x0008 * (x))
#define SHIM_HSPGCTL(x) (L2HSBPM(x) + 0x0000)

#define LSPGCTL 0x71D80
#define LSPGCTL0 0x71D80
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnikodem can we read this from Zephyr headers today ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnikodem sorry I mean we should use the Zephyr header for these HW specific macros (and not use any duplicated values from the SOF directory which is deprecated).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will update this PR, thanks.

@dnikodem
Copy link
Contributor Author

Added zephyrproject-rtos/zephyr#70221 - this is the first step to clean up SOF headers.

#endif
}
tuple_data[index++] = info.page_alloc_struct.page_alloc_count;
ptr = (uint16_t *)(tuple_data + index);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this of course changes the behaviour significantly. Before this commit index was incremented twice in lines 226 and 228, now it isn't any more. Is this intended? Was that a bug?

Copy link
Contributor Author

@dnikodem dnikodem Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tuple_data should contain the correct number of LPSRAM PGCTL register values (in the same way as it is done for HPSRAM). In the previous solution, if the number of ebb_state_dword_count equaled 0, a dword was added in tuple_data with the PGCTL status value for a non-existing/not used LPSRAM bank.

Therefore, the parser that is using data from tuple_data should not expect an "extra" LSPGCTL status value in the tuple_data, and then it could misinterpret it as some other type of data or status.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnikodem right, but if ebb_state_dword_count != 0? Then you'd add several register values into tuple_data without incrementing index, so after the loop you'd overwrite the first of those values... I think you actually wanted to do

	for (i = 0; i < info.ebb_state_dword_count; i++) {
#ifdef INTEL_ADSP
		tuple_data[index++] = LPSRAM_REGS(i)->USxPGCTL;
#else
		tuple_data[index++] = 0;
#endif
	}
	if (info.ebb_state_dword_count)
		tuple_data[index++] = info.page_alloc_struct.page_alloc_count;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh Fixed, thanks

@dnikodem dnikodem force-pushed the update_tlv_mem_state_info branch 2 times, most recently from a2f6588 to 749e8a4 Compare April 11, 2024 16:30
lyakh
lyakh previously requested changes Apr 12, 2024
#endif
}
tuple_data[index++] = info.page_alloc_struct.page_alloc_count;
ptr = (uint16_t *)(tuple_data + index);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnikodem right, but if ebb_state_dword_count != 0? Then you'd add several register values into tuple_data without incrementing index, so after the loop you'd overwrite the first of those values... I think you actually wanted to do

	for (i = 0; i < info.ebb_state_dword_count; i++) {
#ifdef INTEL_ADSP
		tuple_data[index++] = LPSRAM_REGS(i)->USxPGCTL;
#else
		tuple_data[index++] = 0;
#endif
	}
	if (info.ebb_state_dword_count)
		tuple_data[index++] = info.page_alloc_struct.page_alloc_count;

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnikodem I assume you will make non draft after the Zephyr part is merged and we can rebase/merge.

@dnikodem
Copy link
Contributor Author

@dnikodem I assume you will make non draft after the Zephyr part is merged and we can rebase/merge.

correct, we need firstly zephyr part merged.

@lyakh lyakh dismissed their stale review April 30, 2024 06:06

bug fixed

@dnikodem dnikodem force-pushed the update_tlv_mem_state_info branch from 72de4c0 to 2a9a70c Compare May 7, 2024 10:34
@dnikodem dnikodem marked this pull request as ready for review May 7, 2024 11:09
@kv2019i
Copy link
Collaborator

kv2019i commented May 7, 2024

Oops, @dnikodem I didn't realize this PR was still open as well. I was intending to get he pending base_fw changes out of the wait, but missed this one. This will now conflict with #9103

Let's see which gets the reviews together first, and then rebase the other one.

@lgirdwood
Copy link
Member

Oops, @dnikodem I didn't realize this PR was still open as well. I was intending to get he pending base_fw changes out of the wait, but missed this one. This will now conflict with #9103

Let's see which gets the reviews together first, and then rebase the other one.

oh, yeah - this one was blocked on Zephyr PR merging (now merged). @dnikodem do we need a west update ? I think @kv2019i did a west update a few days ago so we may be good just to rebase this ?

@dnikodem
Copy link
Contributor Author

dnikodem commented May 8, 2024

Yes, the west was updated by Kai and points on correct commit. Here is needed to rebase / resolve conflict with base_fw_platform.c file. I will do this today.

@dnikodem dnikodem force-pushed the update_tlv_mem_state_info branch from 2a9a70c to e1c8e7d Compare May 8, 2024 11:02
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question on ifdefs, but otherwise LGTM.

src/audio/base_fw_intel.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dnikodem , this is a welcome update. Code looks good, but I think you can go a bit further and drop the ifdefs as this code is now only compiled for Intel targets that have enabled the IPC4 basefw Intel extensions (so should cover all platforms now covered by INTEL_ADSP ifdef guard).

src/audio/base_fw_intel.c Outdated Show resolved Hide resolved
@@ -154,7 +156,13 @@ static int basefw_mem_state_info(uint32_t *data_offset, char *data)
index = 0;
tuple_data[index++] = info.free_phys_mem_pages;
tuple_data[index++] = info.ebb_state_dword_count;
tuple_data[index++] = io_reg_read(LSPGCTL);
for (i = 0; i < info.ebb_state_dword_count; i++) {
#ifdef INTEL_ADSP
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks :)

This commit refactors the memory power management register access to use
the HPSRAM_REGS and LPSRAM_REGS macros instead of direct io_reg_read calls.

Signed-off-by: Damian Nikodem <damian.nikodem@intel.com>
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good now!

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to remove all the old macros :)

@lgirdwood lgirdwood merged commit 529a4c6 into thesofproject:main May 13, 2024
43 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants