Skip to content

[dt,otp] Rename misleadingly name field and its documentation#28795

Merged
pamaury merged 2 commits intolowRISC:masterfrom
pamaury:dt_otp_rename_field
Dec 4, 2025
Merged

[dt,otp] Rename misleadingly name field and its documentation#28795
pamaury merged 2 commits intolowRISC:masterfrom
pamaury:dt_otp_rename_field

Conversation

@pamaury
Copy link
Contributor

@pamaury pamaury commented Nov 20, 2025

This is a follow-up on #28794 which is a backport of #25975 where the misleading name lead to an error in the ROM. Since master uses the DT, the fix is a bit different but fundamentally achieves the exact same renaming.

@pamaury pamaury requested a review from a team as a code owner November 20, 2025 16:22
@pamaury pamaury requested review from a team, Razer6, sameo and timothytrippel and removed request for a team November 20, 2025 16:22
@pamaury pamaury force-pushed the dt_otp_rename_field branch 2 times, most recently from 2ca7d07 to ac1955c Compare November 20, 2025 16:39
@pamaury pamaury requested a review from AlexJones0 November 21, 2025 13:06
name = self.OTP_PARTITION_INFO_STRUCT_DIGEST_ADDR_FIELD_NAME,
field_type = ScalarType("uint32_t"),
docstring = "The absolute OTP address at which this partition's digest starts",
docstring = "The OTP digest CSR (where the digest is buffered) offset for " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: the new wording here suggests that the digest occupies one CSR but in actuality an OTP digest is 8 bytes and falls across 2 CSRs. Maybe this should just be "digest_offset" as a name and the wording should be more like "The OTP address (offset from this partition) at which this partition's digest starts."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not an otp_ctrl expert but I think your phrasing is incorrect because this value is set to the offset of a CSR, e.g. https://opentitan.org/book/hw/top_earlgrey/ip_autogen/otp_ctrl/doc/registers.html#hw_cfg0_digest (you can see the content here).
The idea of using the word "register" is to make it clear that this is the offset of a CSR and not the offset within the OTP partition.

Maybe I could change the wording to "The first (_DIGEST_0) OTP digest CSR" ?

Copy link
Contributor

@AlexJones0 AlexJones0 Nov 21, 2025

Choose a reason for hiding this comment

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

I see, I misunderstood this as the DAI digest offset rather than the buffered CSR digest (I forgot there was that duplication there and thought that the change was just absolute -> relative address completely 😅) I agree with your new wording.

/*relative_address=*/
otp_readable_partition_info(kOtpPartitionCreatorSwCfg)
.digest_reg_offset -
OTP_CTRL_PARAM_CREATOR_SW_CFG_OFFSET,
Copy link
Contributor

@AlexJones0 AlexJones0 Nov 21, 2025

Choose a reason for hiding this comment

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

Perhaps I'm getting confused, but is this correct? It's taking the digest offset relative to the start of the partition and then subtracting the autogenerated OTP_CTRL_PARAM_CREATOR_SW_CFG_OFFSET (from the mmap), which from my memory is the offset of field from the start of OTP DAI, i.e. the absolute address. Should this not subtract the partition start address from the DT from this offset first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes the code is incorrect, as I noted this code is fixed in #28794 which is why this PR doesn't touch it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am confused what you are trying to do here? are you trying to read the digest registers (i.e. CSRs that buffer the digest)? or are you trying read the digest from the memory mapped window?

Copy link
Contributor Author

@pamaury pamaury Dec 3, 2025

Choose a reason for hiding this comment

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

Hi Tim, the comment above explains the situation: while doing the PR I realized that the code was wrong and that it had been fixed on earlgrey_1.0.0 so I backported the fix in #28794. I was waiting for this to be merged so that I can rebase the code. The above code is now fixed which should clarify the situation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok. Thats what it looked like. Glad I was not the only one that made the same bug when I first implemented this :)

Copy link
Contributor

@timothytrippel timothytrippel left a comment

Choose a reason for hiding this comment

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

Dropped a comment above

The documentation was probably copy-paste: the digest is not
actually an OTP address but a CSR. Rename the field to make it
clearer.

Signed-off-by: Amaury Pouly <[email protected]>
@pamaury pamaury force-pushed the dt_otp_rename_field branch from ac1955c to 20265d1 Compare December 3, 2025 14:27
@timothytrippel timothytrippel self-requested a review December 3, 2025 20:08
@pamaury pamaury added this pull request to the merge queue Dec 4, 2025
Merged via the queue into lowRISC:master with commit 4c3e144 Dec 4, 2025
47 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.

3 participants