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

Fix: CPU power down #197

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/arch/armv8/armv8-a/psci.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void psci_wake_from_powerdown(void)

vcpu_arch_reset(cpu()->vcpu, cpu()->vcpu->arch.psci_ctx.entrypoint);
vcpu_writereg(cpu()->vcpu, 0, cpu()->vcpu->arch.psci_ctx.context_id);
vcpu_run(cpu()->vcpu);
cpu_powerdown_wakeup();
}

void psci_wake_from_off(void);
Expand Down
5 changes: 5 additions & 0 deletions src/core/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ void cpu_standby_wakeup(void)

void cpu_powerdown_wakeup(void)
Copy link
Member

Choose a reason for hiding this comment

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

I think we can merge this with cpu_standby_wakeup and have a single wake up function

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can merge this with cpu_standby_wakeup and have a single wake up function

My question is: how can we invoke the cpu_standby() and cpu_powerdown() functions if cpu()->vcpu is NULL? Should we pass an argument to the new cpu_wakeup() function and determine the specific method to call based on that argument?

Copy link
Member

Choose a reason for hiding this comment

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

For me it's ok how it is currently
IMO in this case it is better to have the two separate but similar functions

{
if (interrupts_check(interrupts_ipi_id)) {
interrupts_clear(interrupts_ipi_id);
cpu_msg_handler();
}

if (cpu()->vcpu != NULL) {
vcpu_run(cpu()->vcpu);
} else {
Expand Down
16 changes: 9 additions & 7 deletions src/platform/qemu-aarch64-virt/inc/plat/psci.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
#ifndef __PLAT_PSCI_H__
#define __PLAT_PSCI_H__

#define PSCI_POWER_STATE_LVL_0 0x0000000
#define PSCI_POWER_STATE_LVL_1 0x1000000
#define PSCI_POWER_STATE_LVL_2 0x2000000
#define PSCI_STATE_TYPE_STANDBY 0x1
#define PSCI_STATE_TYPE_BIT (1UL << 16)
#define PSCI_STATE_ID_RETENTION 0x2
#define PSCI_STATE_TYPE_POWERDOWN PSCI_STATE_TYPE_BIT | PSCI_STATE_ID_RETENTION
#define PSCI_POWER_STATE_LVL_0 0x0000000
#define PSCI_POWER_STATE_LVL_1 0x1000000
#define PSCI_POWER_STATE_LVL_2 0x2000000
#define PSCI_STATE_TYPE_STANDBY 0x1
#define PSCI_STATE_TYPE_BIT (1UL << 16)
#define PSCI_STATE_ID_RETENTION 0x2
#define PSCI_STATE_TYPE_POWERDOWN PSCI_STATE_TYPE_BIT | PSCI_STATE_ID_RETENTION

#define PLAT_PSCI_POWERDOWN_NOT_SUPPORTED 1

#endif // __PLAT_PSCI_H__
Loading