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

RISCV: Support pm cpu ops for SMP #63884

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

quic-lingutla
Copy link
Contributor

Add pm cpu ops to call the platform specific implementations for bringing up secondary cores.

@github-actions
Copy link

Hello @quic-lingutla, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@quic-lingutla quic-lingutla marked this pull request as ready for review October 12, 2023 22:41
@zephyrbot zephyrbot added the area: RISCV RISCV Architecture (32-bit & 64-bit) label Oct 12, 2023
#ifdef CONFIG_PM_CPU_OPS
uintptr_t entry = (uintptr_t)&__start;

if (pm_cpu_on(cpu_num, entry)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't get it. Is RISCV supporting PSCI and SMCCC now? What PM CPU ops driver is this using?

Copy link
Contributor Author

@quic-lingutla quic-lingutla Oct 13, 2023

Choose a reason for hiding this comment

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

I am not sure why PM CPU ops tightly coupled with PSCI or SMCC. RISCV SMP's arch_start_cpu() assumes secondary core is already powered up and looping at boot_secondary_core, but some platforms needs to do initialization (either via opensbi or regular MMIO to enable clocks, etc,.) to bring up secondary cores.

As of now, RISCV doesn't have any PM CPU Ops driver, but platforms can choose to implement these pm cpu ops weak functions to bringup secondary cores.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My point is exactly that RISCV doesn't have any PM CPU ops driver in tree so you are adding this for some out-of-tree platform?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, as of now the platform is out of tree.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, do you plan to upstream it? I'm not willing to push code into the tree that is basically dead code without any user for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Summarizing the offline conversation we had...

This code is in support of a microcontroller core embedded in a larger SoC design so there's not a clear path to share a buildable platform. In this particular platform the driver implementing the CPU Ops talks to some proprietary power/clock/reset controlling hardware.

As a separate discussion supporting Zephyr-on-SBI on an upstream platform (at least QEMU) would be really interesting.

@@ -18,6 +19,10 @@ volatile struct {
volatile uintptr_t riscv_cpu_wake_flag;
volatile void *riscv_cpu_sp;

#ifdef CONFIG_PM_CPU_OPS
extern void __start(void);
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be CONFIG_KERNEL_ENTRY?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you referring to the above #ifdef check ? or function declaration ?

If its for function declaration,
I am not sure, if we have any helpers to declare function like:
extern void CONFIG_KERNEL_ENTRY(void);

Copy link
Collaborator

Choose a reason for hiding this comment

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

uhm, I see. This should really be fixed somehow, it is really useless to have CONFIG_KERNEL_ENTRY and not being able to use it in C code (but only in the linker script).

arch/riscv/core/smp.c Outdated Show resolved Hide resolved
arch/riscv/core/smp.c Outdated Show resolved Hide resolved
Add pm cpu ops to call the platform specific implementations for
bringing up secondary cores.

Signed-off-by: Lingutla Chandrasekhar <[email protected]>
@carlescufi carlescufi merged commit 64aa25a into zephyrproject-rtos:main Oct 23, 2023
17 checks passed
@github-actions
Copy link

Hi @quic-lingutla!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

@quic-lingutla quic-lingutla deleted the riscv_pm_cpu_ops branch October 23, 2023 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: RISCV RISCV Architecture (32-bit & 64-bit)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants