-
Notifications
You must be signed in to change notification settings - Fork 618
os/pm: Add PMIOC_STOP to stop pm and show state in pm_procfs #6979
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
base: master
Are you sure you want to change the base?
Changes from all commits
e59d9af
446a1f4
e27f330
40a7baa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ static int pm_sleep_test(void *args) | |
|
|
||
| int fd = open(PM_DRVPATH, O_WRONLY); | ||
| if (fd < 0) { | ||
| printf("Fail to open pm sleep(errno %d)", get_errno()); | ||
| printf("Fail to open pm driver(errno %d)", get_errno()); | ||
| return -1; | ||
| } | ||
|
|
||
|
|
@@ -75,7 +75,7 @@ static void _pm_suspend(char *name) | |
| int domain_id; | ||
| int fd = open(PM_DRVPATH, O_WRONLY); | ||
| if (fd < 0) { | ||
| printf("Fail to open pm(errno %d)", get_errno()); | ||
| printf("Fail to open pm driver(errno %d)", get_errno()); | ||
| return; | ||
| } | ||
| domain_arg.domain_name = name; | ||
|
|
@@ -98,7 +98,7 @@ static void _pm_resume(char *name) | |
| int domain_id; | ||
| int fd = open(PM_DRVPATH, O_WRONLY); | ||
| if (fd < 0) { | ||
| printf("Fail to open pm(errno %d)", get_errno()); | ||
| printf("Fail to open pm driver(errno %d)", get_errno()); | ||
| return; | ||
| } | ||
| domain_arg.domain_name = name; | ||
|
|
@@ -123,7 +123,7 @@ static int pm_suspend_resume_test(void) | |
| int test_count = 0; | ||
| int fd = open(PM_DRVPATH, O_WRONLY); | ||
| if (fd < 0) { | ||
| printf("Fail to open pm(errno %d)", get_errno()); | ||
| printf("Fail to open pm driver(errno %d)", get_errno()); | ||
| return -1; | ||
| } | ||
|
|
||
|
|
@@ -167,11 +167,11 @@ static int start_pm_test(int argc, char *argv[]) | |
|
|
||
| fd = open(PM_DRVPATH, O_WRONLY); | ||
| if (fd < 0) { | ||
| printf("Fail to open pm start(errno %d)", get_errno()); | ||
| printf("Fail to open pm driver(errno %d)", get_errno()); | ||
| return -1; | ||
| } | ||
|
|
||
| if(ioctl(fd, PMIOC_START, 0) < 0) { | ||
| if (ioctl(fd, PMIOC_START, 0) < 0) { | ||
| printf("Fail to pm start(errno %d)\n", get_errno()); | ||
| close(fd); | ||
| return -1; | ||
|
|
@@ -223,6 +223,27 @@ static int start_pm_test(int argc, char *argv[]) | |
| } | ||
| } | ||
|
|
||
| close(fd); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| static int stop_pm_test(int argc, char *argv[]) | ||
| { | ||
| int fd; | ||
|
|
||
| fd = open(PM_DRVPATH, O_WRONLY); | ||
| if (fd < 0) { | ||
| printf("Fail to open pm driver(errno %d)", get_errno()); | ||
| return -1; | ||
| } | ||
|
|
||
| if (ioctl(fd, PMIOC_STOP, 0) < 0) { | ||
| printf("Fail to pm stop(errno %d)\n", get_errno()); | ||
| close(fd); | ||
| return -1; | ||
| } | ||
|
|
||
| close(fd); | ||
| printf("######################### PM LONG TERM TEST END #########################\n"); | ||
|
|
||
|
|
@@ -287,6 +308,12 @@ int power_main(int argc, char *argv[]) | |
| return 0; | ||
| } | ||
|
|
||
| pid = task_create("stop_pm_test", 100, 1024, stop_pm_test, NULL); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason why we should do start and stop test in separate tasks? |
||
| if (pid < 0) { | ||
| printf("Fail to create stop_pm_test task(errno %d)\n", get_errno()); | ||
| return -1; | ||
| } | ||
|
|
||
| is_running = false; | ||
|
|
||
| } else if (strncmp(argv[1], "suspend", 8) == 0 && argc == 3) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,7 +88,7 @@ const char *wakeup_src_name[PM_WAKEUP_SRC_COUNT] = {"UNKNOWN", "BLE", "WIFI", "U | |
| * | ||
| * Description: | ||
| * This function is called by the application thread to start the Power | ||
| * Management system. This fucntion sets the is_running flag which | ||
| * Management system. This function sets the is_running flag which | ||
| * enables pm to transition between low and high power states. | ||
| * | ||
| * Input parameters: | ||
|
|
@@ -99,10 +99,32 @@ const char *wakeup_src_name[PM_WAKEUP_SRC_COUNT] = {"UNKNOWN", "BLE", "WIFI", "U | |
| * | ||
| ****************************************************************************/ | ||
|
|
||
| void pm_start(void) { | ||
| void pm_start(void) | ||
| { | ||
| g_pmglobals.is_running = true; | ||
| } | ||
|
|
||
| /**************************************************************************** | ||
| * Name: pm_stop | ||
| * | ||
| * Description: | ||
| * This function is called by the application thread to stop the Power | ||
| * Management system. This function resets the is_running flag which | ||
| * enables pm to transition between low and high power states. | ||
| * | ||
| * Input parameters: | ||
| * None. | ||
| * | ||
| * Returned value: | ||
| * None. | ||
| * | ||
| ****************************************************************************/ | ||
|
|
||
| void pm_stop(void) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is |
||
| { | ||
| g_pmglobals.is_running = false; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pm_ioctl doesn't use semaphore, so I think this is not 'thread-safe' |
||
| } | ||
|
Comment on lines
+123
to
+126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good to me this stop fucntion. |
||
|
|
||
| /**************************************************************************** | ||
| * Name: pm_initialize | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,6 +203,8 @@ static void power_read_domains(void (*readprint)(const char *, ...)) | |
| static void power_read_state(void (*readprint)(const char *, ...)) | ||
| { | ||
| enum pm_state_e pm_state; | ||
|
|
||
| readprint("PM %s\n\n", (g_pmglobals.is_running) ? "RUNNING" : "STOPPED"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. procfs is not only for information. |
||
| for (pm_state = PM_NORMAL; pm_state < PM_COUNT; pm_state++) { | ||
| readprint("%s %s\n", (pm_state == g_pmglobals.state) ? "*" : " ", pm_state_name[pm_state]); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code can be called first than "start_pm_test" task termination
like