forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ext qmsi: Add config support and kernel events for enabling SoCWatch
tests: power_states app updated to support SoCWatch collection Add CONFIG_SOC_WATCH option for enabling the SoCWatch QMSI driver and associated instrumentation hooks. Bug fix for soc_watch.c to use local irq_lock/unlock This will be put into QMSI as well. JIRA: ZEP-1121 Change-Id: I0514324e81ca02c1d01ffc2d6cf4d31aee491544 Signed-off-by: Jon Moeller <[email protected]>
- Loading branch information
Jon Moeller
authored and
Anas Nashif
committed
Nov 12, 2016
1 parent
ff23cb5
commit 8358468
Showing
10 changed files
with
257 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
CONFIG_ARC_INIT=n | ||
CONFIG_SYS_POWER_MANAGEMENT=y | ||
CONFIG_SYS_POWER_DEEP_SLEEP=n | ||
CONFIG_SYS_POWER_LOW_POWER_STATE=y | ||
CONFIG_DEVICE_POWER_MANAGEMENT=y | ||
CONFIG_TICKLESS_IDLE=y | ||
|
||
# RTC Wake Event | ||
CONFIG_RTC=y | ||
|
||
# COUNTER Wake Event | ||
CONFIG_COUNTER=n | ||
|
||
# GPIO 1 Wake Event | ||
CONFIG_GPIO=n | ||
CONFIG_GPIO_QMSI=n | ||
CONFIG_GPIO_QMSI_1=n | ||
CONFIG_GPIO_QMSI_1_NAME="GPIO_1" | ||
CONFIG_GPIO_QMSI_1_PRI=2 | ||
|
||
# Comparator Wake Event | ||
CONFIG_AIO_COMPARATOR=n | ||
|
||
# Enable SoCWatch power event tracing | ||
CONFIG_SOC_WATCH=y | ||
CONFIG_RING_BUFFER=y | ||
CONFIG_NANO_TIMEOUTS=y | ||
CONFIG_IDLE_STACK_SIZE=512 | ||
CONFIG_KERNEL_EVENT_LOGGER=y | ||
CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE=16 | ||
CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH=y | ||
CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
obj-y = main.o | ||
obj-$(CONFIG_SOC_WATCH) += soc_watch_logger.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright (c) 2016 Intel Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "soc_watch_logger.h" | ||
|
||
#define STSIZE 512 | ||
char __stack soc_watch_event_logger_stack[1][STSIZE]; | ||
|
||
/** | ||
* @brief soc_watch data collector thread | ||
* | ||
* @details Collect the kernel event messages and pass them to | ||
* soc_watch | ||
* | ||
* @return No return value. | ||
*/ | ||
void soc_watch_data_collector(void) | ||
{ | ||
#ifdef CONFIG_SOC_WATCH | ||
int res; | ||
uint32_t data[4]; | ||
uint8_t dropped_count; | ||
uint16_t event_id; | ||
|
||
/* We register the thread as collector to avoid this thread generating a | ||
* context switch event every time it collects the data | ||
*/ | ||
sys_k_event_logger_register_as_collector(); | ||
|
||
while (1) { | ||
/* collect the data */ | ||
uint8_t data_length = SIZE32_OF(data); | ||
|
||
res = sys_k_event_logger_get_wait(&event_id, &dropped_count, | ||
data, &data_length); | ||
|
||
if (res > 0) { | ||
|
||
/* process the data */ | ||
switch (event_id) { | ||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH | ||
case KERNEL_EVENT_LOGGER_CONTEXT_SWITCH_EVENT_ID: | ||
if (data_length != 2) { | ||
PRINTF("\x1b[13;1HError in context switch message. " | ||
"event_id = %d, Expected %d, received %d\n", | ||
event_id, 2, data_length); | ||
} else { | ||
/* Log context switch event for SoCWatch */ | ||
SOC_WATCH_LOG_APP_EVENT(SOCW_EVENT_APP, | ||
event_id, data[1]); | ||
} | ||
break; | ||
#endif | ||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT | ||
case KERNEL_EVENT_LOGGER_INTERRUPT_EVENT_ID: | ||
if (data_length != 2) { | ||
PRINTF("\x1b[13;1HError in interrupt message. " | ||
"event_id = %d, Expected %d, received %d\n", | ||
event_id, 2, data_length); | ||
} else { | ||
/* Log interrupt event for SoCWatch */ | ||
SOC_WATCH_LOG_EVENT(SOCW_EVENT_INTERRUPT, data[1]); | ||
} | ||
break; | ||
#endif | ||
default: | ||
PRINTF("unrecognized event id %d", event_id); | ||
} | ||
} else { | ||
/* This error should never happen */ | ||
if (res == -EMSGSIZE) { | ||
PRINTF("FATAL ERROR. The buffer provided to collect the " | ||
"profiling events is too small\n"); | ||
} | ||
} | ||
} | ||
#endif | ||
} | ||
|
||
/** | ||
* @brief Start the soc_watch logger thread | ||
* | ||
* @details Start the soc_watch data collector thread | ||
* | ||
* @return No return value. | ||
*/ | ||
void soc_watch_logger_thread_start(void) | ||
{ | ||
PRINTF("\x1b[2J\x1b[15;1H"); | ||
|
||
k_thread_spawn(&soc_watch_event_logger_stack[0][0], STSIZE, | ||
(k_thread_entry_t) soc_watch_data_collector, 0, 0, 0, | ||
6, 0, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2016 Intel Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <zephyr.h> | ||
#include <misc/printk.h> | ||
#include <string.h> | ||
#include <misc/kernel_event_logger.h> | ||
#include "soc_watch.h" | ||
|
||
#if defined(CONFIG_STDOUT_CONSOLE) | ||
#define PRINTF(...) { char output[256]; \ | ||
sprintf(output, __VA_ARGS__); puts(output); } | ||
#else | ||
#define PRINTF(...) printk(__VA_ARGS__) | ||
#endif | ||
|
||
void soc_watch_data_collector(void); | ||
void soc_watch_logger_thread_start(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters