Skip to content
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
19 changes: 17 additions & 2 deletions kernel/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@
#if CONFIG_SOC_FAMILY_REALTEK_BEE
/* To support RTK PM */
extern void sys_clock_only_add_cycle_count(int32_t ticks);
extern void CPU_DLPS_Exit(void);
struct _timeout *get_first_timeout(void)
{
return first();
Expand Down Expand Up @@ -371,6 +372,7 @@

void sys_clock_announce_process_timeout(void)
{
/* Update the timeout list: only handle pended ticks. */
k_spinlock_key_t key = k_spin_lock(&timeout_lock);

struct _timeout *t;
Expand All @@ -388,11 +390,24 @@

pended_ticks = 0;

/* Separate the handling of pending tick counts and timeout
* callback functions to avoid errors when a timer is started
k_spin_unlock(&timeout_lock, key);

/* Resume NVIC to trigger interrupts that occurred during DLPS.
* ISR might update the timout list, so ensure this is done after updating

Check warning on line 396 in kernel/timeout.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TYPO_SPELLING

kernel/timeout.c:396 'timout' may be misspelled - perhaps 'timeout'?
* the timeout list.
*/
__disable_irq();
CPU_DLPS_Exit();
__enable_irq();

/* Manually trigger processing of the timeout callback.
* Separating updating pended ticks and timeout
* callback processing to avoid errors if timer behaivor happens
* during the timer callback.
*/

key = k_spin_lock(&timeout_lock);

Check warning on line 409 in kernel/timeout.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

kernel/timeout.c:409 please, no spaces at the start of a line

Check warning on line 409 in kernel/timeout.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACE_BEFORE_TAB

kernel/timeout.c:409 please, no space before tabs

Check failure on line 409 in kernel/timeout.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

kernel/timeout.c:409 code indent should use tabs where possible

for (t = first(); (t != NULL) && (t->dticks == 0); t = first()) {
remove_timeout(t);

Expand Down
5 changes: 2 additions & 3 deletions soc/arm/realtek_bee/rtl87x2g/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@
PM_DEVICE_ACTION_RESUME);
}

CPU_DLPS_Exit();

num_susp_rtk = 0;
}

Expand All @@ -183,7 +181,8 @@
sys_clock_restore_tick_and_cycle();
__enable_irq();

/* Subtract the pended tick from the timeout list and manually trigger a timeout process. */
/* Subtract the pended tick from the timeout list, resume NVIC and manually trigger the
* timeout callback process. */

Check warning on line 185 in soc/arm/realtek_bee/rtl87x2g/power.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

BLOCK_COMMENT_STYLE

soc/arm/realtek_bee/rtl87x2g/power.c:185 Block comments use a trailing */ on a separate line
sys_clock_announce_process_timeout();
}

Expand Down
13 changes: 6 additions & 7 deletions tests/boards/rtl8762gn_evb/pm/timeout_wakeup/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,15 @@
uint32_t wakeup_count_thread;

power_get_statistics(&wakeup_count_before_test, &last_wakeup_clk, &last_sleep_clk);
while (test_thread_sleep_num <= THREAD_SLEEP_NUMBERS) {
while (test_thread_sleep_num < THREAD_SLEEP_NUMBERS) {
k_msleep(100);
test_thread_sleep_num++;
}
power_get_statistics(&wakeup_count_after_test, &last_wakeup_clk, &last_sleep_clk);
wakeup_count_thread = wakeup_count_after_test - wakeup_count_before_test;
TC_PRINT("wakeupCount: %d, last_wakeup_clk:%d, last_sleep_clk:%d\n", wakeup_count_thread,
last_wakeup_clk, last_sleep_clk);
zassert_true(wakeup_count_thread <= THREAD_SLEEP_NUMBERS + 1 && wakeup_count_thread >=
THREAD_SLEEP_NUMBERS - 1, "test_k_timer_wakeup failed, wakeup Count: %d\n",
zassert_true(wakeup_count_thread == THREAD_SLEEP_NUMBERS, "test_k_timer_wakeup failed, wakeup Count: %d\n",

Check warning on line 100 in tests/boards/rtl8762gn_evb/pm/timeout_wakeup/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE_STRING

tests/boards/rtl8762gn_evb/pm/timeout_wakeup/src/main.c:100 line length of 115 exceeds 100 columns
wakeup_count_thread);

}
Expand Down Expand Up @@ -152,17 +151,17 @@
tag2 = k_uptime_get();
time_diff = tag2-tag1;
LOG_INF("after dlps!");/*check log time stamp*/
zassert_true(time_diff >= TRIGGERED_WORK_NUMBERS*100 && time_diff <=
TRIGGERED_WORK_NUMBERS * 100 + 1020,
"k_uptime_get is not accurate after dlps! time diff (ms) is %lld",
time_diff);
power_get_statistics(&wakeup_count_after_test, &last_wakeup_clk, &last_sleep_clk);
wakeup_count_triggered_work = wakeup_count_after_test - wakeup_count_before_test;
TC_PRINT("wakeupCount: %d, last_wakeup_clk:%d, last_sleep_clk:%d\n",
wakeup_count_triggered_work, last_wakeup_clk, last_sleep_clk);
zassert_true(wakeup_count_triggered_work <= TRIGGERED_WORK_NUMBERS + 1
&& wakeup_count_triggered_work >= TRIGGERED_WORK_NUMBERS - 1,
"test_k_timer_wakeup failed, wakeup Count: %d\n", wakeup_count_triggered_work);
zassert_true(time_diff >= TRIGGERED_WORK_NUMBERS*100 && time_diff <=
TRIGGERED_WORK_NUMBERS * 100 + 1400,
"k_uptime_get is not accurate after dlps! time diff (ms) is %lld",
time_diff);
}

void teardown_fn(void *data)
Expand Down
Loading