diag: Synchronize mdlog read and write threads
The patch defines the per peripheral packet length inside the per peripheral structure replacing corresponding global variables. CRs-Fixed: 2050301 Change-Id: I0bb732d93cd98aa46c69c81eeae9872a801a9e18 Signed-off-by: Manoj Prabhu B <bmanoj@codeaurora.org>
This commit is contained in:
parent
c1a2472056
commit
c579b5355e
5 changed files with 46 additions and 43 deletions
|
@ -254,8 +254,6 @@ int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size,
|
|||
struct diag_md_session_t *session_info = NULL;
|
||||
struct pid *pid_struct = NULL;
|
||||
|
||||
mutex_lock(&driver->diagfwd_untag_mutex);
|
||||
|
||||
for (i = 0; i < NUM_DIAG_MD_DEV && !err; i++) {
|
||||
ch = &diag_md[i];
|
||||
for (j = 0; j < ch->num_tbl_entries && !err; j++) {
|
||||
|
@ -365,8 +363,6 @@ drop_data:
|
|||
if (drain_again)
|
||||
chk_logging_wakeup();
|
||||
|
||||
mutex_unlock(&driver->diagfwd_untag_mutex);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -547,7 +547,6 @@ struct diagchar_dev {
|
|||
struct mutex cmd_reg_mutex;
|
||||
uint32_t cmd_reg_count;
|
||||
struct mutex diagfwd_channel_mutex[NUM_PERIPHERALS];
|
||||
struct mutex diagfwd_untag_mutex;
|
||||
/* Sizes that reflect memory pool sizes */
|
||||
unsigned int poolsize;
|
||||
unsigned int poolsize_hdlc;
|
||||
|
@ -613,12 +612,6 @@ struct diagchar_dev {
|
|||
int pd_logging_mode[NUM_UPD];
|
||||
int pd_session_clear[NUM_UPD];
|
||||
int num_pd_session;
|
||||
int cpd_len_1[NUM_PERIPHERALS];
|
||||
int cpd_len_2[NUM_PERIPHERALS];
|
||||
int upd_len_1_a[NUM_PERIPHERALS];
|
||||
int upd_len_1_b[NUM_PERIPHERALS];
|
||||
int upd_len_2_a;
|
||||
int upd_len_2_b;
|
||||
int mask_check;
|
||||
uint32_t md_session_mask;
|
||||
uint8_t md_session_mode;
|
||||
|
|
|
@ -3623,7 +3623,6 @@ static int __init diagchar_init(void)
|
|||
mutex_init(&driver->msg_mask_lock);
|
||||
for (i = 0; i < NUM_PERIPHERALS; i++)
|
||||
mutex_init(&driver->diagfwd_channel_mutex[i]);
|
||||
mutex_init(&driver->diagfwd_untag_mutex);
|
||||
init_waitqueue_head(&driver->wait_q);
|
||||
INIT_WORK(&(driver->diag_drain_work), diag_drain_work_fn);
|
||||
INIT_WORK(&(driver->update_user_clients),
|
||||
|
|
|
@ -363,7 +363,6 @@ static void diagfwd_data_read_untag_done(struct diagfwd_info *fwd_info,
|
|||
if (driver->feature[peripheral].encode_hdlc &&
|
||||
driver->feature[peripheral].untag_header &&
|
||||
driver->peripheral_untag[peripheral]) {
|
||||
mutex_lock(&driver->diagfwd_untag_mutex);
|
||||
temp_buf_cpd = buf;
|
||||
temp_buf_main = buf;
|
||||
if (fwd_info->buf_1 &&
|
||||
|
@ -463,10 +462,10 @@ static void diagfwd_data_read_untag_done(struct diagfwd_info *fwd_info,
|
|||
if (peripheral == PERIPHERAL_LPASS &&
|
||||
fwd_info->type == TYPE_DATA && len_upd_2) {
|
||||
if (flag_buf_1) {
|
||||
driver->upd_len_2_a = len_upd_2;
|
||||
fwd_info->upd_len_2_a = len_upd_2;
|
||||
temp_ptr_upd = fwd_info->buf_upd_2_a;
|
||||
} else {
|
||||
driver->upd_len_2_b = len_upd_2;
|
||||
fwd_info->upd_len_2_b = len_upd_2;
|
||||
temp_ptr_upd = fwd_info->buf_upd_2_b;
|
||||
}
|
||||
temp_ptr_upd->ctxt &= 0x00FFFFFF;
|
||||
|
@ -477,17 +476,17 @@ static void diagfwd_data_read_untag_done(struct diagfwd_info *fwd_info,
|
|||
temp_ptr_upd, len_upd_2);
|
||||
} else {
|
||||
if (flag_buf_1)
|
||||
driver->upd_len_2_a = 0;
|
||||
fwd_info->upd_len_2_a = 0;
|
||||
if (flag_buf_2)
|
||||
driver->upd_len_2_b = 0;
|
||||
fwd_info->upd_len_2_b = 0;
|
||||
}
|
||||
if (fwd_info->type == TYPE_DATA && len_upd_1) {
|
||||
if (flag_buf_1) {
|
||||
driver->upd_len_1_a[peripheral] =
|
||||
fwd_info->upd_len_1_a =
|
||||
len_upd_1;
|
||||
temp_ptr_upd = fwd_info->buf_upd_1_a;
|
||||
} else {
|
||||
driver->upd_len_1_b[peripheral] =
|
||||
fwd_info->upd_len_1_b =
|
||||
len_upd_1;
|
||||
temp_ptr_upd = fwd_info->buf_upd_1_b;
|
||||
}
|
||||
|
@ -499,15 +498,15 @@ static void diagfwd_data_read_untag_done(struct diagfwd_info *fwd_info,
|
|||
temp_ptr_upd, len_upd_1);
|
||||
} else {
|
||||
if (flag_buf_1)
|
||||
driver->upd_len_1_a[peripheral] = 0;
|
||||
fwd_info->upd_len_1_a = 0;
|
||||
if (flag_buf_2)
|
||||
driver->upd_len_1_b[peripheral] = 0;
|
||||
fwd_info->upd_len_1_b = 0;
|
||||
}
|
||||
if (len_cpd) {
|
||||
if (flag_buf_1)
|
||||
driver->cpd_len_1[peripheral] = len_cpd;
|
||||
fwd_info->cpd_len_1 = len_cpd;
|
||||
else
|
||||
driver->cpd_len_2[peripheral] = len_cpd;
|
||||
fwd_info->cpd_len_2 = len_cpd;
|
||||
temp_ptr_cpd->ctxt &= 0x00FFFFFF;
|
||||
temp_ptr_cpd->ctxt |=
|
||||
(SET_PD_CTXT(ctxt_cpd));
|
||||
|
@ -515,11 +514,10 @@ static void diagfwd_data_read_untag_done(struct diagfwd_info *fwd_info,
|
|||
temp_ptr_cpd, len_cpd);
|
||||
} else {
|
||||
if (flag_buf_1)
|
||||
driver->cpd_len_1[peripheral] = 0;
|
||||
fwd_info->cpd_len_1 = 0;
|
||||
if (flag_buf_2)
|
||||
driver->cpd_len_2[peripheral] = 0;
|
||||
fwd_info->cpd_len_2 = 0;
|
||||
}
|
||||
mutex_unlock(&driver->diagfwd_untag_mutex);
|
||||
return;
|
||||
} else {
|
||||
diagfwd_data_read_done(fwd_info, buf, len);
|
||||
|
@ -527,7 +525,6 @@ static void diagfwd_data_read_untag_done(struct diagfwd_info *fwd_info,
|
|||
}
|
||||
end:
|
||||
diag_ws_release();
|
||||
mutex_unlock(&driver->diagfwd_untag_mutex);
|
||||
if (temp_ptr_cpd) {
|
||||
diagfwd_write_done(fwd_info->peripheral, fwd_info->type,
|
||||
GET_BUF_NUM(temp_ptr_cpd->ctxt));
|
||||
|
@ -759,6 +756,12 @@ int diagfwd_peripheral_init(void)
|
|||
fwd_info->inited = 1;
|
||||
fwd_info->read_bytes = 0;
|
||||
fwd_info->write_bytes = 0;
|
||||
fwd_info->cpd_len_1 = 0;
|
||||
fwd_info->cpd_len_2 = 0;
|
||||
fwd_info->upd_len_1_a = 0;
|
||||
fwd_info->upd_len_1_b = 0;
|
||||
fwd_info->upd_len_2_a = 0;
|
||||
fwd_info->upd_len_2_a = 0;
|
||||
mutex_init(&fwd_info->buf_mutex);
|
||||
mutex_init(&fwd_info->data_mutex);
|
||||
spin_lock_init(&fwd_info->write_buf_lock);
|
||||
|
@ -775,6 +778,12 @@ int diagfwd_peripheral_init(void)
|
|||
fwd_info->ch_open = 0;
|
||||
fwd_info->read_bytes = 0;
|
||||
fwd_info->write_bytes = 0;
|
||||
fwd_info->cpd_len_1 = 0;
|
||||
fwd_info->cpd_len_2 = 0;
|
||||
fwd_info->upd_len_1_a = 0;
|
||||
fwd_info->upd_len_1_b = 0;
|
||||
fwd_info->upd_len_2_a = 0;
|
||||
fwd_info->upd_len_2_a = 0;
|
||||
spin_lock_init(&fwd_info->write_buf_lock);
|
||||
mutex_init(&fwd_info->buf_mutex);
|
||||
mutex_init(&fwd_info->data_mutex);
|
||||
|
@ -1273,11 +1282,11 @@ void diagfwd_write_done(uint8_t peripheral, uint8_t type, int ctxt)
|
|||
if (ctxt == 1 && fwd_info->buf_1) {
|
||||
/* Buffer 1 for core PD is freed */
|
||||
atomic_set(&fwd_info->buf_1->in_busy, 0);
|
||||
driver->cpd_len_1[peripheral] = 0;
|
||||
fwd_info->cpd_len_1 = 0;
|
||||
} else if (ctxt == 2 && fwd_info->buf_2) {
|
||||
/* Buffer 2 for core PD is freed */
|
||||
atomic_set(&fwd_info->buf_2->in_busy, 0);
|
||||
driver->cpd_len_2[peripheral] = 0;
|
||||
fwd_info->cpd_len_2 = 0;
|
||||
} else if (ctxt == 3 && fwd_info->buf_upd_1_a) {
|
||||
/* Buffer 1 for user pd 1 is freed */
|
||||
atomic_set(&fwd_info->buf_upd_1_a->in_busy, 0);
|
||||
|
@ -1286,17 +1295,17 @@ void diagfwd_write_done(uint8_t peripheral, uint8_t type, int ctxt)
|
|||
/* if not data in cpd and other user pd
|
||||
* free the core pd buffer for LPASS
|
||||
*/
|
||||
if (!driver->cpd_len_1[PERIPHERAL_LPASS] &&
|
||||
!driver->upd_len_2_a)
|
||||
if (!fwd_info->cpd_len_1 &&
|
||||
!fwd_info->upd_len_2_a)
|
||||
atomic_set(&fwd_info->buf_1->in_busy, 0);
|
||||
} else {
|
||||
/* if not data in cpd
|
||||
* free the core pd buffer for MPSS
|
||||
*/
|
||||
if (!driver->cpd_len_1[PERIPHERAL_MODEM])
|
||||
if (!fwd_info->cpd_len_1)
|
||||
atomic_set(&fwd_info->buf_1->in_busy, 0);
|
||||
}
|
||||
driver->upd_len_1_a[peripheral] = 0;
|
||||
fwd_info->upd_len_1_a = 0;
|
||||
|
||||
} else if (ctxt == 4 && fwd_info->buf_upd_1_b) {
|
||||
/* Buffer 2 for user pd 1 is freed */
|
||||
|
@ -1305,17 +1314,17 @@ void diagfwd_write_done(uint8_t peripheral, uint8_t type, int ctxt)
|
|||
/* if not data in cpd and other user pd
|
||||
* free the core pd buffer for LPASS
|
||||
*/
|
||||
if (!driver->cpd_len_2[peripheral] &&
|
||||
!driver->upd_len_2_b)
|
||||
if (!fwd_info->cpd_len_2 &&
|
||||
!fwd_info->upd_len_2_b)
|
||||
atomic_set(&fwd_info->buf_2->in_busy, 0);
|
||||
} else {
|
||||
/* if not data in cpd
|
||||
* free the core pd buffer for MPSS
|
||||
*/
|
||||
if (!driver->cpd_len_2[PERIPHERAL_MODEM])
|
||||
if (!fwd_info->cpd_len_2)
|
||||
atomic_set(&fwd_info->buf_2->in_busy, 0);
|
||||
}
|
||||
driver->upd_len_1_b[peripheral] = 0;
|
||||
fwd_info->upd_len_1_b = 0;
|
||||
|
||||
} else if (ctxt == 5 && fwd_info->buf_upd_2_a) {
|
||||
/* Buffer 1 for user pd 2 is freed */
|
||||
|
@ -1323,11 +1332,11 @@ void diagfwd_write_done(uint8_t peripheral, uint8_t type, int ctxt)
|
|||
/* if not data in cpd and other user pd
|
||||
* free the core pd buffer for LPASS
|
||||
*/
|
||||
if (!driver->cpd_len_1[PERIPHERAL_LPASS] &&
|
||||
!driver->upd_len_1_a[PERIPHERAL_LPASS])
|
||||
if (!fwd_info->cpd_len_1 &&
|
||||
!fwd_info->upd_len_1_a)
|
||||
atomic_set(&fwd_info->buf_1->in_busy, 0);
|
||||
|
||||
driver->upd_len_2_a = 0;
|
||||
fwd_info->upd_len_2_a = 0;
|
||||
|
||||
} else if (ctxt == 6 && fwd_info->buf_upd_2_b) {
|
||||
/* Buffer 2 for user pd 2 is freed */
|
||||
|
@ -1335,11 +1344,11 @@ void diagfwd_write_done(uint8_t peripheral, uint8_t type, int ctxt)
|
|||
/* if not data in cpd and other user pd
|
||||
* free the core pd buffer for LPASS
|
||||
*/
|
||||
if (!driver->cpd_len_2[PERIPHERAL_LPASS] &&
|
||||
!driver->upd_len_1_b[PERIPHERAL_LPASS])
|
||||
if (!fwd_info->cpd_len_2 &&
|
||||
!fwd_info->upd_len_1_b)
|
||||
atomic_set(&fwd_info->buf_2->in_busy, 0);
|
||||
|
||||
driver->upd_len_2_b = 0;
|
||||
fwd_info->upd_len_2_b = 0;
|
||||
|
||||
} else
|
||||
pr_err("diag: In %s, invalid ctxt %d\n", __func__, ctxt);
|
||||
|
|
|
@ -83,6 +83,12 @@ struct diagfwd_info {
|
|||
struct diagfwd_buf_t *buf_upd_2_a;
|
||||
struct diagfwd_buf_t *buf_upd_2_b;
|
||||
struct diagfwd_buf_t *buf_ptr[NUM_WRITE_BUFFERS];
|
||||
int cpd_len_1;
|
||||
int cpd_len_2;
|
||||
int upd_len_1_a;
|
||||
int upd_len_1_b;
|
||||
int upd_len_2_a;
|
||||
int upd_len_2_b;
|
||||
struct diag_peripheral_ops *p_ops;
|
||||
struct diag_channel_ops *c_ops;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue