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

Adsp main remoteproc #2497

Open
wants to merge 4 commits into
base: adsp-main
Choose a base branch
from
Open

Adsp main remoteproc #2497

wants to merge 4 commits into from

Conversation

UtsavAgarwalADI
Copy link

@UtsavAgarwalADI UtsavAgarwalADI commented Jun 3, 2024

PR Description

Added a verification function for LDR files
Simplifying code and introducing early returns where possible

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly (if there is the case)

- Renamed variables for a clearer relevance to their function
- Reorganizing code for better readibility
- introducing early returns where possible

Signed-off-by: UtsavAgarwalADI <[email protected]>
default:
dev_err(rproc_data->dev,
"%s, invalid svect:0x%lx, cord_id:%d\n",
__func__, svect, core_id);

Choose a reason for hiding this comment

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

before change core_id was rpoc_data->core_id,
after the change core_id = !!svect && rproc_data->core_id

dev_err core_id will not behave same as before

@@ -211,11 +226,15 @@ static int adi_core_reset(struct adi_rproc_data *rproc_data)

static int adi_core_stop(struct adi_rproc_data *rproc_data)
{
if (!rproc_data->adi_rsc_table)

Choose a reason for hiding this comment

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

if adi_core_stop is called, thats because the adi_core_start succeeded, so no need double check rpoc_data->adi_rsc_table as that was already done

* to verify the block header via an xor checksum of the bcode_flag field.
*/

static int verify_buffer(struct adi_rproc_data *rproc_data,

Choose a reason for hiding this comment

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

can this be renamed to more specif name, this generic can be adi_verify_blk_header or anything meaningful

uint8_t expected_xor_checksum;

expected_xor_checksum = block_hdr->bcode_flag.bHdrCHK;
curr_hdr_xor_checksum = (0xFF000000 & *(uint32_t *)block_hdr) ^ \

Choose a reason for hiding this comment

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

doesn't seems right, operating with uint32_t and then doing XOR and making equal to uint8_t seems that upper 3 bytes values will be lost in conversion

}

if (rproc_data->rpmsg_state == ADI_RP_RPMSG_SYNCED)
if (rproc_data->rproc_state == ADI_REMOTEPROC_SYNCED) {
adi_tru_trigger_device(rproc_data->tru, rproc_data->dev);

Choose a reason for hiding this comment

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

does second time adi_tru_trigger_device is required, its already done once on line 816

Copy link
Author

@UtsavAgarwalADI UtsavAgarwalADI Jun 3, 2024

Choose a reason for hiding this comment

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

Thats the case when its already synced, if its not waiting but not synced either, the state is changed again and then tru is triggered. I could maybe add a goto statement for more code reuse, but I think that an extra jump since that would just be substituting the one line function call.


hdr = &rproc_data->adi_rsc_table->adi_table_hdr;
core_init = hdr->initialized;
for (wait_time = 0; wait_time < CORE_INIT_TIMEOUT_MS; wait_time += 20) {

Choose a reason for hiding this comment

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

Before the logic was to wait if state ADI_RP_RPMSG_WAITING , now logic changed to if not ADI_RP_RPMSG_WAITING state then wait. Is this required?

Copy link
Author

Choose a reason for hiding this comment

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

Inverting it allows us to return early and avoid indentation. If you see further in the code, the logic for a wait is still preserved

- Remoteproc can now verify ldr headers to ensure uncorrupted
stream (including using XOR checksum where possible)

Signed-off-by: UtsavAgarwalADI <[email protected]>
- Fixing core_id for loading svect
- Removing extra check for resource table from adi_core_stop
- Renaming verification function for a more accurate representation
of its working

Signed-off-by: UtsavAgarwalADI <[email protected]>
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.

2 participants