Merge "diag: Add mutex protection while closing SMD"
This commit is contained in:
commit
115a8ef46d
4 changed files with 12 additions and 0 deletions
|
@ -509,6 +509,7 @@ struct diagchar_dev {
|
||||||
struct list_head cmd_reg_list;
|
struct list_head cmd_reg_list;
|
||||||
struct mutex cmd_reg_mutex;
|
struct mutex cmd_reg_mutex;
|
||||||
uint32_t cmd_reg_count;
|
uint32_t cmd_reg_count;
|
||||||
|
struct mutex diagfwd_channel_mutex;
|
||||||
/* Sizes that reflect memory pool sizes */
|
/* Sizes that reflect memory pool sizes */
|
||||||
unsigned int poolsize;
|
unsigned int poolsize;
|
||||||
unsigned int poolsize_hdlc;
|
unsigned int poolsize_hdlc;
|
||||||
|
|
|
@ -3394,6 +3394,7 @@ static int __init diagchar_init(void)
|
||||||
mutex_init(&driver->diag_file_mutex);
|
mutex_init(&driver->diag_file_mutex);
|
||||||
mutex_init(&driver->delayed_rsp_mutex);
|
mutex_init(&driver->delayed_rsp_mutex);
|
||||||
mutex_init(&apps_data_mutex);
|
mutex_init(&apps_data_mutex);
|
||||||
|
mutex_init(&driver->diagfwd_channel_mutex);
|
||||||
init_waitqueue_head(&driver->wait_q);
|
init_waitqueue_head(&driver->wait_q);
|
||||||
INIT_WORK(&(driver->diag_drain_work), diag_drain_work_fn);
|
INIT_WORK(&(driver->diag_drain_work), diag_drain_work_fn);
|
||||||
INIT_WORK(&(driver->update_user_clients),
|
INIT_WORK(&(driver->update_user_clients),
|
||||||
|
|
|
@ -657,6 +657,7 @@ void diagfwd_close_transport(uint8_t transport, uint8_t peripheral)
|
||||||
fwd_info = &early_init_info[transport][peripheral];
|
fwd_info = &early_init_info[transport][peripheral];
|
||||||
if (fwd_info->p_ops && fwd_info->p_ops->close)
|
if (fwd_info->p_ops && fwd_info->p_ops->close)
|
||||||
fwd_info->p_ops->close(fwd_info->ctxt);
|
fwd_info->p_ops->close(fwd_info->ctxt);
|
||||||
|
mutex_lock(&driver->diagfwd_channel_mutex);
|
||||||
fwd_info = &early_init_info[transport_open][peripheral];
|
fwd_info = &early_init_info[transport_open][peripheral];
|
||||||
dest_info = &peripheral_info[TYPE_CNTL][peripheral];
|
dest_info = &peripheral_info[TYPE_CNTL][peripheral];
|
||||||
dest_info->inited = 1;
|
dest_info->inited = 1;
|
||||||
|
@ -677,6 +678,7 @@ void diagfwd_close_transport(uint8_t transport, uint8_t peripheral)
|
||||||
diagfwd_late_open(dest_info);
|
diagfwd_late_open(dest_info);
|
||||||
diagfwd_cntl_open(dest_info);
|
diagfwd_cntl_open(dest_info);
|
||||||
init_fn(peripheral);
|
init_fn(peripheral);
|
||||||
|
mutex_unlock(&driver->diagfwd_channel_mutex);
|
||||||
diagfwd_queue_read(&peripheral_info[TYPE_DATA][peripheral]);
|
diagfwd_queue_read(&peripheral_info[TYPE_DATA][peripheral]);
|
||||||
diagfwd_queue_read(&peripheral_info[TYPE_CMD][peripheral]);
|
diagfwd_queue_read(&peripheral_info[TYPE_CMD][peripheral]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -959,7 +959,9 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len)
|
||||||
(info->data_ready > 0) || (!info->hdl) ||
|
(info->data_ready > 0) || (!info->hdl) ||
|
||||||
(atomic_read(&info->diag_state) == 0));
|
(atomic_read(&info->diag_state) == 0));
|
||||||
if (err) {
|
if (err) {
|
||||||
|
mutex_lock(&driver->diagfwd_channel_mutex);
|
||||||
diagfwd_channel_read_done(info->fwd_ctxt, buf, 0);
|
diagfwd_channel_read_done(info->fwd_ctxt, buf, 0);
|
||||||
|
mutex_unlock(&driver->diagfwd_channel_mutex);
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -971,7 +973,9 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len)
|
||||||
DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
|
DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
|
||||||
"%s closing read thread. diag state is closed\n",
|
"%s closing read thread. diag state is closed\n",
|
||||||
info->name);
|
info->name);
|
||||||
|
mutex_lock(&driver->diagfwd_channel_mutex);
|
||||||
diagfwd_channel_read_done(info->fwd_ctxt, buf, 0);
|
diagfwd_channel_read_done(info->fwd_ctxt, buf, 0);
|
||||||
|
mutex_unlock(&driver->diagfwd_channel_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1038,8 +1042,10 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len)
|
||||||
if (total_recd > 0) {
|
if (total_recd > 0) {
|
||||||
DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "%s read total bytes: %d\n",
|
DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "%s read total bytes: %d\n",
|
||||||
info->name, total_recd);
|
info->name, total_recd);
|
||||||
|
mutex_lock(&driver->diagfwd_channel_mutex);
|
||||||
err = diagfwd_channel_read_done(info->fwd_ctxt,
|
err = diagfwd_channel_read_done(info->fwd_ctxt,
|
||||||
buf, total_recd);
|
buf, total_recd);
|
||||||
|
mutex_unlock(&driver->diagfwd_channel_mutex);
|
||||||
if (err)
|
if (err)
|
||||||
goto fail;
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1052,7 +1058,9 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
mutex_lock(&driver->diagfwd_channel_mutex);
|
||||||
diagfwd_channel_read_done(info->fwd_ctxt, buf, 0);
|
diagfwd_channel_read_done(info->fwd_ctxt, buf, 0);
|
||||||
|
mutex_unlock(&driver->diagfwd_channel_mutex);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue