Skip to content

Conversation

@KozhinovAlexander
Copy link
Contributor

@KozhinovAlexander KozhinovAlexander commented Jun 10, 2021

Use none-cacheable region by alias (e.g. DT_ALIAS(sramnocache)) instad of node-label (e.g. DT_NODELABEL(sram3)).

This PR allows defining no-cacheable RAM in any of existion sram3, sram4 or backup-sram. It provides more flexibility than current fixed naming implementation. For example current none-cacheable region for stm32h7 series is named sram3, but atm32h723 does not have auch named sram. Thus it is simpler and flexibler to define it with label by pointing on ram region of your choice.

this PR needed for the next-step: definifg none-cacheable region's size by getting value as DT attribute!

Copy link
Contributor

@JordanYates JordanYates left a comment

Choose a reason for hiding this comment

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

This adds a great deal of complexity to the linker script to address a single use case. I am also not sure how these changes are required for the stated goal of defining the size from devicetree, it is already possible to get the size of SRAM3 in linker scripts.

I think this solution is much easier to support and generalize if memory region names were derived directly from the devicetree node label property, as then GROUP_DATA_LINK_IN(sramnocache, sramnocache) becomes GROUP_DATA_LINK_IN(DT_LABEL(DT_ALIAS(sramnocache)),...) , removing the need for the core linker file changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

This change means that only STM32H7X boards that define sramnocache will work with this driver now.
As this is more than just nucleo_h745zi_q, this will break the driver for many boards without further board updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. This is not. The other boards will still work. Please take a look on on first #if and last #else. There are many cases upon sramnocache already covered.
There maybe some documentation effort for stm32 needed to advice users to use sramnocache.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, they will still work, but you are changing the behavior for every STM32H7X board apart from nucleo_h745zi_q. This is not necessarily wrong, but it is not explained anywhere in the commits as to why this is a good idea / why the previous way was bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good point. I would say, it would be nice to add some documentation to the whole he series. But there is no docs for it, as I know. Maybe it can be added to .yaml or the soc? @erwango?

Copy link
Contributor

Choose a reason for hiding this comment

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

The point is not that it is not documented in the code, but that you have provided no justification for the change in the commit messages.

Copy link
Contributor

Choose a reason for hiding this comment

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

It appears that the purpose of these changes is purely to rename the memory region of whichever node sramnocache points to to sramnocache. This adds a lot of conditional and duplication to achieve this, and will become unreadable as soon as another node also needs to have its name changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, some knowledge in preprocessor and linker skripts is already assumend. But my implementation is simpliest possible for this purpose.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unreadable from the perspective of the number of conditionals that need to be added.
This only looks "simple" because this is the first special case. When someone wants to add DT_ALIAS(sramcache) that changes the name of a different SRAM region, you end up in a case of 2^n combinations.
I disagree that this is the simplest way possible to change the name of a single memory region.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do You have then any better ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the PR which mentions this one, #36196.
This allows both changing the memory region name, and automatically extracting the region name from a chosen or alias node.

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. Thanks for that. I see your point. Of course, using some script is more elegant solution, than using ifdefs in linker skript. Moreover it definitely increase readability.
Anyway I still would prefer defining special use cases like none-cacheable memory regions by fixed aliases instead of fixed label names. The reason for that is that, labels may be changed b the user and used for other stuff than linker script. Thus your solution fixes label names, which is not completely cosy to use. I think, if you would add aliases in your PR it would be best one solution based on good readable script and you would not need to change lable names in multiple boards.
For example: Adding aliases like sramnocache256b, sramnocache16k - would increase usability.

Copy link
Contributor

@JordanYates JordanYates Jun 13, 2021

Choose a reason for hiding this comment

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

I have no problem with using fixed aliases instead of fixed label names, in fact I think that is definitely what you should do. That the memory region name is generated from the label is beside the point. The point is that there is a defined mapping from a devicetree node to the name of the region generated by that node.

As I noted above, GROUP_DATA_LINK_IN(sramnocache, sramnocache) becomes GROUP_DATA_LINK_IN(DT_LABEL(DT_ALIAS(sramnocache)),DT_LABEL(DT_ALIAS(sramnocache))). At that point you can change the label to "ALEXANDERS_SRAM" and everything will still work fine.

@KozhinovAlexander
Copy link
Contributor Author

This adds a great deal of complexity to the linker script to address a single use case. I am also not sure how these changes are required for the stated goal of defining the size from devicetree, it is already possible to get the size of SRAM3 in linker scripts.

I think this solution is much easier to support and generalize if memory region names were derived directly from the devicetree node label property, as then GROUP_DATA_LINK_IN(sramnocache, sramnocache) becomes GROUP_DATA_LINK_IN(DT_LABEL(DT_ALIAS(sramnocache)),...) , removing the need for the core linker file changes.

I disagree with it. I think aliases are more flexible for users later.

@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch from a4a5709 to c1ce574 Compare June 15, 2021 07:13
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch from c1ce574 to 53e2581 Compare June 17, 2021 20:25
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch from 53e2581 to 8b9feae Compare June 28, 2021 07:49
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch 2 times, most recently from cb63d60 to bf0e2d0 Compare July 18, 2021 20:25
@KozhinovAlexander
Copy link
Contributor Author

KozhinovAlexander commented Jul 19, 2021

@erwango Can you please take a look on it? I need this mostly for stm32h723 but it is of course scalable solution.

@KozhinovAlexander
Copy link
Contributor Author

@JordanYates Do you have any progress with your PR? Can we somehow consolidate our work?

1 similar comment
@KozhinovAlexander
Copy link
Contributor Author

@JordanYates Do you have any progress with your PR? Can we somehow consolidate our work?

@JordanYates
Copy link
Contributor

@JordanYates Do you have any progress with your PR? Can we somehow consolidate our work?

Yes my PR is progressing, we just need to finalize which property we are using for the name generation.
This will be discussed and hopefully resolved at the next dev-review meeting (Thursday), if not before then.

@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch 4 times, most recently from 77f5570 to 39844dd Compare July 26, 2021 07:46
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch from 39844dd to f604233 Compare July 28, 2021 09:14
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch 2 times, most recently from 75f04de to 6220014 Compare August 1, 2021 10:01
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch 2 times, most recently from 9adff8d to f470d6e Compare August 13, 2021 10:13
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch from f470d6e to 2a57dce Compare September 7, 2021 09:54
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch 2 times, most recently from b6d8a39 to 0c29cfd Compare September 20, 2021 08:35
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch from 0c29cfd to e66bee5 Compare September 29, 2021 13:22
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch from e66bee5 to ae316f4 Compare October 17, 2021 12:22
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch from ae316f4 to 6f608e3 Compare October 29, 2021 13:22
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch from 6f608e3 to 05b84ab Compare November 7, 2021 11:12
Alexander Kozhinov added 4 commits November 22, 2021 19:10
add sramnocache label pointing to sram3

Signed-off-by: Alexander Kozhinov <AlexanderKozhinov@yandex.com>
use sram by alias istead of label

Signed-off-by: Alexander Kozhinov <AlexanderKozhinov@yandex.com>
add non-cached MPU region section by alias instead of label

Signed-off-by: Alexander Kozhinov <AlexanderKozhinov@yandex.com>
update linker script to use noncaheable region by alias

Signed-off-by: Alexander Kozhinov <AlexanderKozhinov@yandex.com>
@KozhinovAlexander KozhinovAlexander force-pushed the stm32h7_use_non_cacheable_region_by_alias branch from 05b84ab to 849ccb1 Compare November 22, 2021 18:10
@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Jan 22, 2022
@github-actions github-actions bot closed this Feb 5, 2022
@KozhinovAlexander KozhinovAlexander deleted the stm32h7_use_non_cacheable_region_by_alias branch May 3, 2022 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants