tune command execute time to resolve FPE_INTDIV error
There's below error which trigger FPE_INTDIV becuase tuner->config isn't
set in time.
CMD_TUNE is executed before CMD_CONFIG after being opened immediately
11:27:10.307 21151 21151 I radio_hw_stub: rdev_open_tuner rdev 0x7b36ea03e000
11:27:10.307 21151 21151 V radio_hw_stub: send_command_l 1 delay_ms 500
11:27:10.307 21151 21151 V radio_hw_stub: send_command_l CMD_CONFIG type 0
11:27:10.307 21151 21151 I radio_hw_stub: rdev_open_tuner DONE
11:27:10.307 21151 22015 I radio_hw_stub: callback_thread_loop
11:27:10.603 21151 22015 E radio_hw_stub: callback_thread_loop processing command 4 time 1321010830.603019830
11:27:10.604 21151 22015 F libc : Fatal signal 8 (SIGFPE), code 1, fault addr 0x7b36e704b5d6 in tid 22015 (sound trigger c)
11:27:10.632 22021 22021 F DEBUG : signal 8 (SIGFPE), code 1 (FPE_INTDIV), fault addr 0x7b36e704b5d6
There's no need to use seq lock to correct the sequence. Adjust the time
is the simple way to fix above error.
Change-Id: I1bd5535840fe990db1f6c355af85c93443d9de87
Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>
Signed-off-by: Jerry Liu <primerlink@gmail.com>
diff --git a/modules/radio/radio_hw.c b/modules/radio/radio_hw.c
index 29204df..93b8c88 100644
--- a/modules/radio/radio_hw.c
+++ b/modules/radio/radio_hw.c
@@ -114,8 +114,19 @@
CMD_CANCEL,
CMD_METADATA,
CMD_ANNOUNCEMENTS,
+ CMD_NUM
} thread_cmd_type_t;
+uint32_t thread_cmd_delay_ms[CMD_NUM] = {
+ [CMD_EXIT] = 0,
+ [CMD_CONFIG] = 50,
+ [CMD_STEP] = 100,
+ [CMD_SCAN] = 200,
+ [CMD_TUNE] = 150,
+ [CMD_CANCEL] = 0,
+ [CMD_METADATA] = 1000,
+ [CMD_ANNOUNCEMENTS] = 1000
+};
struct thread_command {
struct listnode node;
thread_cmd_type_t type;
@@ -401,7 +412,7 @@
(tuner->config.spacings[0] * 5)) % 2;
if (tuner->program.tuned) {
- send_command_l(tuner, CMD_ANNOUNCEMENTS, 1000, NULL);
+ send_command_l(tuner, CMD_ANNOUNCEMENTS, thread_cmd_delay_ms[CMD_ANNOUNCEMENTS], NULL);
}
tuner->program.signal_strength = 100;
if (tuner->config.type == RADIO_BAND_FM)
@@ -481,7 +492,7 @@
free(cmd);
}
}
- send_command_l(tuner, CMD_METADATA, 1000, NULL);
+ send_command_l(tuner, CMD_METADATA, thread_cmd_delay_ms[CMD_METADATA], NULL);
}
}
@@ -510,8 +521,8 @@
status = -EINVAL;
goto exit;
}
- send_command_l(stub_tuner, CMD_CANCEL, 0, NULL);
- send_command_l(stub_tuner, CMD_CONFIG, 500, (void *)config);
+ send_command_l(stub_tuner, CMD_CANCEL, thread_cmd_delay_ms[CMD_CANCEL], NULL);
+ send_command_l(stub_tuner, CMD_CONFIG, thread_cmd_delay_ms[CMD_CONFIG], (void *)config);
exit:
pthread_mutex_unlock(&stub_tuner->lock);
@@ -556,7 +567,7 @@
__func__, stub_tuner, direction, skip_sub_channel);
pthread_mutex_lock(&stub_tuner->lock);
- send_command_l(stub_tuner, CMD_STEP, 20, &direction);
+ send_command_l(stub_tuner, CMD_STEP, thread_cmd_delay_ms[CMD_STEP], &direction);
pthread_mutex_unlock(&stub_tuner->lock);
return 0;
}
@@ -570,7 +581,7 @@
__func__, stub_tuner, direction, skip_sub_channel);
pthread_mutex_lock(&stub_tuner->lock);
- send_command_l(stub_tuner, CMD_SCAN, 200, &direction);
+ send_command_l(stub_tuner, CMD_SCAN, thread_cmd_delay_ms[CMD_SCAN], &direction);
pthread_mutex_unlock(&stub_tuner->lock);
return 0;
}
@@ -589,7 +600,7 @@
ALOGI("%s channel out of range", __func__);
return -EINVAL;
}
- send_command_l(stub_tuner, CMD_TUNE, 100, &channel);
+ send_command_l(stub_tuner, CMD_TUNE, thread_cmd_delay_ms[CMD_TUNE], &channel);
pthread_mutex_unlock(&stub_tuner->lock);
return 0;
}
@@ -601,7 +612,7 @@
ALOGI("%s stub_tuner %p", __func__, stub_tuner);
pthread_mutex_lock(&stub_tuner->lock);
- send_command_l(stub_tuner, CMD_CANCEL, 0, NULL);
+ send_command_l(stub_tuner, CMD_CANCEL, thread_cmd_delay_ms[CMD_CANCEL], NULL);
pthread_mutex_unlock(&stub_tuner->lock);
return 0;
}
@@ -696,7 +707,7 @@
list_init(&rdev->tuner->command_list);
pthread_mutex_lock(&rdev->tuner->lock);
- send_command_l(rdev->tuner, CMD_CONFIG, 500, (void *)config);
+ send_command_l(rdev->tuner, CMD_CONFIG, thread_cmd_delay_ms[CMD_CONFIG], (void *)config);
pthread_mutex_unlock(&rdev->tuner->lock);
*tuner = &rdev->tuner->interface;
@@ -724,7 +735,7 @@
pthread_mutex_lock(&stub_tuner->lock);
stub_tuner->callback = NULL;
- send_command_l(stub_tuner, CMD_EXIT, 0, NULL);
+ send_command_l(stub_tuner, CMD_EXIT, thread_cmd_delay_ms[CMD_EXIT], NULL);
pthread_mutex_unlock(&stub_tuner->lock);
pthread_join(stub_tuner->callback_thread, (void **) NULL);