Skip to content

Commit 0fb21cf

Browse files
liuygzhuliwenlingz
authored andcommitted
Tools: Acrnd fix reporting unnecessary error on NUC and UP2
The boards without IOC don't need to call get_sos_wakeup_reason function. The HW IOC can be detected in runtime,via checking "/dev/cbc-early-signals" node. Tracked-On:#1996 Signed-off-by: liuyonggang <yonggangx.liu@intel.com> Acked-by: Yan, Like <like.yan@intel.com> Reviewed-by: Yuan Liu <yuan1.liu@intel.com>
1 parent ff41c00 commit 0fb21cf

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

tools/acrn-manager/acrnd.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static pthread_mutex_t work_mutex = PTHREAD_MUTEX_INITIALIZER;
4040

4141
static pthread_mutex_t acrnd_stop_mutex = PTHREAD_MUTEX_INITIALIZER;
4242
static unsigned int acrnd_stop_timeout;
43+
static unsigned char platform_has_hw_ioc;
4344

4445
static int sigterm = 0; /* Exit acrnd when recevied SIGTERM and stop all vms */
4546
#define VMS_STOP_TIMEOUT 20 /* Wait VMS_STOP_TIMEOUT sec to stop all vms */
@@ -246,7 +247,7 @@ static int active_all_vms(void)
246247
struct vmmngr_struct *vm;
247248
int ret = 0;
248249
pid_t pid;
249-
unsigned reason;
250+
unsigned reason = 0;
250251

251252
vmmngr_update();
252253

@@ -258,7 +259,9 @@ static int active_all_vms(void)
258259
acrnd_run_vm(vm->name);
259260
break;
260261
case VM_SUSPENDED:
261-
reason = get_sos_wakeup_reason();
262+
if (platform_has_hw_ioc) {
263+
reason = get_sos_wakeup_reason();
264+
}
262265
ret += resume_vm(vm->name, reason);
263266
break;
264267
default:
@@ -304,6 +307,8 @@ static int wakeup_suspended_vms(unsigned wakeup_reason)
304307
#define SOS_LCS_SOCK "sos-lcs"
305308
#define DEFAULT_TIMEOUT 2U
306309
#define ACRND_NAME "acrnd"
310+
#define HW_IOC_PATH "/dev/cbc-early-signals"
311+
307312
static int acrnd_fd = -1;
308313

309314
unsigned get_sos_wakeup_reason(void)
@@ -579,14 +584,16 @@ void handle_acrnd_resume(struct mngr_msg *msg, int client_fd, void *param)
579584
{
580585
struct mngr_msg ack;
581586
struct stat st;
582-
int wakeup_reason;
587+
int wakeup_reason = 0;
583588

584589
ack.msgid = msg->msgid;
585590
ack.timestamp = msg->timestamp;
586591
ack.data.err = -1;
587592

588593
/* acrnd get wakeup_reason from sos lcs */
589-
wakeup_reason = get_sos_wakeup_reason();
594+
if (platform_has_hw_ioc) {
595+
wakeup_reason = get_sos_wakeup_reason();
596+
}
590597

591598
if (wakeup_reason & CBC_WK_RSN_RTC) {
592599
printf("Resumed UOS, by RTC timer, reason(%x)!\n", wakeup_reason);
@@ -629,11 +636,13 @@ static void handle_on_exit(void)
629636

630637
int init_vm(void)
631638
{
632-
unsigned int wakeup_reason;
639+
unsigned int wakeup_reason = 0;
633640
int ret;
634641

635642
/* init all UOSs, according wakeup_reason */
636-
wakeup_reason = get_sos_wakeup_reason();
643+
if (platform_has_hw_ioc) {
644+
wakeup_reason = get_sos_wakeup_reason();
645+
}
637646

638647
if (wakeup_reason & CBC_WK_RSN_RTC) {
639648
printf("Loading timer list to set vms wakeup time\n");
@@ -672,7 +681,13 @@ int main(int argc, char *argv[])
672681
printf("Ingrone unknown opt: %c\n", opt);
673682
}
674683
}
675-
684+
685+
if (!access(HW_IOC_PATH, F_OK)) {
686+
platform_has_hw_ioc = 1;
687+
} else {
688+
platform_has_hw_ioc = 0;
689+
}
690+
676691
/* create listening thread */
677692
acrnd_fd = mngr_open_un(ACRND_NAME, MNGR_SERVER);
678693
if (acrnd_fd < 0) {

0 commit comments

Comments
 (0)