"fails to get read ret:%d timeout:%d\n", ret, timeout);
}
+ if (__raw_readl(&ipc->chub_status) != CHUB_ST_RUN) {
+ dev_warn(ipc->dev, "%s: chub isn't run:%d\n", __raw_readl(&ipc->chub_status));
+ return 0;
+ }
+
if (contexthub_get_token(ipc)) {
dev_warn(ipc->dev, "no-active: read fails\n");
return 0;
{
int ret;
+ if (__raw_readl(&ipc->chub_status) != CHUB_ST_RUN) {
+ dev_warn(ipc->dev, "%s: chub isn't run:%d\n", __raw_readl(&ipc->chub_status));
+ return 0;
+ }
+
if (contexthub_get_token(ipc)) {
dev_warn(ipc->dev, "no-active: write fails\n");
return 0;
return (((ipc_evt->eq + 1) % IPC_EVT_NUM) == ipc_evt->dq);
}
+static inline bool __ipc_evt_queue_index_check(struct ipc_evt_ctrl *ipc_evt)
+{
+ return ((ipc_evt->eq > IPC_EVT_NUM) || (ipc_evt->dq > IPC_EVT_NUM));
+}
+
struct ipc_evt_buf *ipc_get_evt(enum ipc_evt_list evtq)
{
struct ipc_evt *ipc_evt = &ipc_map->evt[evtq];
bool retried = 0;
#endif
+ if (__ipc_evt_queue_index_check(&ipc_evt->ctrl)) {
+ CSP_PRINTF_ERROR("%s:%s: failed by ipc index corrupt\n", NAME_PREFIX, __func__);
+ return NULL;
+ }
+
retry:
/* only called by isr DISABLE_IRQ(); */
if (!__ipc_evt_queue_empty(&ipc_evt->ctrl)) {
int trycnt = 0;
u64 time = CUR_TIME();
+ if (__ipc_evt_queue_index_check(&ipc_evt->ctrl)) {
+ CSP_PRINTF_ERROR("%s:%s: failed by ipc index corrupt\n", NAME_PREFIX, __func__);
+ return -1;
+ }
+
/* don't sleep on ap */
do {
pass = __ipc_evt_queue_full(&ipc_evt->ctrl);
return -EINVAL;
}
+ if (__ipc_evt_queue_index_check(&ipc_evt->ctrl)) {
+ CSP_PRINTF_ERROR("%s:%s: failed by ipc index corrupt\n", NAME_PREFIX, __func__);
+ return -EINVAL;
+ }
+
retry:
DISABLE_IRQ(LOCK_ADD_EVT, &flag);
if (!__ipc_evt_queue_full(&ipc_evt->ctrl)) {
return (((ipc_data->eq + 1) % IPC_CH_BUF_NUM) == __raw_readl(&ipc_data->dq));
}
+static inline bool __ipc_queue_index_check(struct ipc_buf *ipc_data)
+{
+ return ((ipc_data->eq > IPC_CH_BUF_NUM) || (ipc_data->dq > IPC_CH_BUF_NUM));
+}
+
static inline int __ipc_data_wait_full(struct ipc_buf *ipc_data)
{
volatile u32 pass;
int trycnt = 0;
u64 time = CUR_TIME();
+ if (__ipc_queue_index_check(ipc_data)) {
+ CSP_PRINTF_ERROR("%s:%s: failed by ipc index corrupt\n", NAME_PREFIX, __func__);
+ return -EINVAL;
+ }
+
/* don't sleep on ap */
do {
pass = __ipc_queue_full(ipc_data);
int trycnt = 0;
unsigned long flag;
+ if (__ipc_queue_index_check(ipc_data)) {
+ CSP_PRINTF_ERROR("%s:%s: failed by ipc index corrupt\n", NAME_PREFIX, __func__);
+ return -EINVAL;
+ }
+
if (length <= PACKET_SIZE_MAX) {
retry:
DISABLE_IRQ(LOCK_WT_DATA, &flag);
struct ipc_buf *ipc_data = ipc_get_base(reg);
void *buf = NULL;
+ if (__ipc_queue_index_check(ipc_data)) {
+ CSP_PRINTF_ERROR("%s:%s: failed by ipc index corrupt\n", NAME_PREFIX, __func__);
+ return NULL;
+ }
+
DISABLE_IRQ(LOCK_RD_DATA, NULL);
retry:
if (!__ipc_queue_empty(ipc_data)) {