Skip to content

Commit cd3a7c6

Browse files
GalkinIvanandrewc-arm
authored andcommitted
Update modem driver to make it more reliable
Phase 2 - fix some minor bugs Signed-off-by: Ivan <[email protected]>
1 parent 0921e8c commit cd3a7c6

File tree

4 files changed

+44
-48
lines changed

4 files changed

+44
-48
lines changed

targets/TARGET_Samsung/TARGET_SIDK_S5JS100/modem/modem_io_device.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ unsigned short ModemIoDevice::exynos_build_fr_config(unsigned int count)
110110
void ModemIoDevice::exynos_build_header(unsigned char *buff, unsigned short cfg, unsigned char ctl, int count)
111111
{
112112
unsigned short *exynos_header = (unsigned short *)(buff + EXYNOS_START_OFFSET);
113-
unsigned short *frame_seq = (unsigned short *)(buff + EXYNOS_FRAME_SEQ_OFFSET);
113+
//unsigned short *frame_seq = (unsigned short *)(buff + EXYNOS_FRAME_SEQ_OFFSET);
114114
unsigned short *frag_cfg = (unsigned short *)(buff + EXYNOS_FRAG_CONFIG_OFFSET);
115115
unsigned short *size = (unsigned short *)(buff + EXYNOS_LEN_OFFSET);
116116

117117
*exynos_header = EXYNOS_START_MASK;
118-
*frame_seq = ++(seq_num.frame_cnt);
118+
//*frame_seq = ++(seq_num.frame_cnt);
119119
*frag_cfg = cfg;
120120
*size = (unsigned short)(EXYNOS_HEADER_SIZE + count);
121121
buff[EXYNOS_CH_ID_OFFSET] = id;
@@ -124,7 +124,7 @@ void ModemIoDevice::exynos_build_header(unsigned char *buff, unsigned short cfg,
124124
*frag_cfg = cfg;
125125
}
126126

127-
buff[EXYNOS_CH_SEQ_OFFSET] = ++seq_num.ch_cnt[id];
127+
buff[EXYNOS_CH_SEQ_OFFSET] = ++ch_cnt;
128128
}
129129

130130
int ModemIoDevice::write(const char *buf, int count)

targets/TARGET_Samsung/TARGET_SIDK_S5JS100/modem/modem_io_device.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ModemIoDevice {
3838
int id;
3939
ShmemIpcDevice *ipc;
4040
link_mode mode;
41-
struct exynos_seq_num seq_num;
41+
unsigned char ch_cnt;
4242
void (*read_cb)(mio_buf *, void *);
4343
void *cb_data;
4444

@@ -79,7 +79,7 @@ class IoDevMisc : public ModemIoDevice {
7979
id = ch;
8080
ipc = ipc_dev;
8181
mode = LINK_MODE_OFFLINE;
82-
memset((void *)(&seq_num), 0, sizeof(struct exynos_seq_num));
82+
ch_cnt = 0;
8383
read_cb = NULL;
8484
}
8585
void IoReadCallback(mio_buf *);
@@ -97,7 +97,7 @@ class IoDevNet : public ModemIoDevice {
9797
id = ch;
9898
ipc = ipc_dev;
9999
mode = LINK_MODE_OFFLINE;
100-
memset((void *)(&seq_num), 0, sizeof(struct exynos_seq_num));
100+
ch_cnt = 0;
101101
read_cb = NULL;
102102
}
103103
void IoReadCallback(mio_buf *);

targets/TARGET_Samsung/TARGET_SIDK_S5JS100/modem/modem_link_device_shmem.cpp

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ void ShmemIpcDevice::write_ipc_to_txq(mio_buf *mio)
8888
unsigned int len = mio->len;
8989
unsigned int pad = mio->pad;
9090
unsigned int i, j;
91+
unsigned short *frame_seq = (unsigned short *)((void *)header + EXYNOS_FRAME_SEQ_OFFSET);
92+
93+
*frame_seq = ++header_cnt;
9194

9295
/* Write HEADER to the TXQ, assume that with padding aligned on 4 bytes */
9396
i = in >> 2;
@@ -431,11 +434,15 @@ void ShmemIpcDevice::done_req_ack(void)
431434

432435
void ShmemIpcDevice::recv_res_ack(unsigned short intr)
433436
{
434-
//MODEM_LINK_DEVICE_SHMEM_DBG("%s:%d\n", __func__, __LINE__);
435-
436-
if (intr & mask_res_ack) {
437-
req_ack_cmpl->release();
438-
}
437+
/*
438+
This method is used to nodify about receiving response
439+
from CP on req_ack sent earlier to confirm CPis alive
440+
In fact we never sent is, so nothing to receive.
441+
*/
442+
if(intr & mask_res_ack) {
443+
/* We should not get here!!! */
444+
while(1);
445+
}
439446
}
440447

441448
void ShmemIpcDevice::recv_req_ack(unsigned short intr)
@@ -474,6 +481,8 @@ ShmemIpcFmtDevice::ShmemIpcFmtDevice()
474481

475482
tx_lock = new Mutex("IPC_FMT");
476483
req_ack_cmpl = new Semaphore(1, 1);
484+
485+
header_cnt = 0;
477486
}
478487

479488
ShmemIpcFmtDevice *ShmemIpcFmtDevice::getInstance(void)
@@ -491,9 +500,12 @@ int ShmemIpcDevice::rx_ipc_frames(void)
491500
{
492501
int i;
493502

503+
/* buffer indeces are corrupted*/
494504
if((*rxq.head >= rxq.size) || (*rxq.tail >= rxq.size))
495505
return -5;
496-
506+
/* nothing to read */
507+
if (*rxq.head == *rxq.tail)
508+
return 0;
497509

498510
ShmemLinkDevice *ld = pShmemLinkDevice;
499511

@@ -606,6 +618,8 @@ ShmemIpcRawDevice::ShmemIpcRawDevice()
606618

607619
req_ack_cmpl = new Semaphore(1, 1);
608620
tx_lock = new Mutex("IPC_RAW");
621+
622+
header_cnt = 0;
609623
}
610624

611625
ShmemIpcRawDevice *ShmemIpcRawDevice::getInstance(void)
@@ -674,30 +688,20 @@ void msg_handler(void)
674688
system_halt();
675689
}
676690

677-
678691
/* Skip RX processing if there is no data in the RXQ */
679692
/* Read data in the RXQ */
680693
/* Process REQ_ACK (At this point, the RXQ may be empty.) */
681694
for (i = 0; i < MAX_IPC_DEV; i++) {
682695
ipc = ld->ipc_device[i];
683-
if (*(ipc->rxq.head) == *(ipc->rxq.tail))
684-
{
685-
ipc->done_req_ack();
686-
continue;
687-
}
688-
689696
ret = ipc->rx_ipc_frames();
690-
if (ret < 0)
691-
return;
692-
}
693697

694-
if (!ret)
695-
break;
696-
}
698+
/* TODO review below case and handle it properly!!! */
699+
/* In case of error just return. Shall we do aything here? */
700+
if (ret < 0)
701+
while(1);
697702

698703
ipc->done_req_ack();
699704
}
700-
701705
}
702706

703707
void ipc_rx_task(void)
@@ -715,27 +719,19 @@ void ipc_rx_task(void)
715719
return;
716720
}
717721

718-
719-
/* Check and receive RES_ACK from CP */
720-
/* Check and receive REQ_ACK from CP */
721-
for (i = 0; i < MAX_IPC_DEV; i++) {
722-
switch (int2ap) {
723-
case INT_MASK_RES_ACK_F:
724-
case INT_MASK_RES_ACK_R:
725-
case INT_MASK_RES_ACK_RFS:
726-
ld->ipc_device[i]->recv_res_ack(int2ap);
727-
break;
728-
case INT_MASK_REQ_ACK_F:
729-
case INT_MASK_REQ_ACK_R:
730-
case INT_MASK_REQ_ACK_RFS:
731-
ld->ipc_device[i]->recv_req_ack(int2ap);
732-
break;
733-
default:
734-
break;
735-
}
736-
}
737-
738-
msg_handler();
722+
if(INT_VALID(int2ap)) {
723+
/* Make CP happy with our fake responses we are alive ... */
724+
/* However CP never sends it ... only SEND_R and SEND_F */
725+
/* Check and receive RES_ACK from CP */
726+
/* Check and receive REQ_ACK from CP */
727+
for (i = 0; i < MAX_IPC_DEV; i++)
728+
{
729+
ld->ipc_device[i]->recv_res_ack(int2ap);
730+
ld->ipc_device[i]->recv_req_ack(int2ap);
731+
}
732+
733+
msg_handler();
734+
}
739735
}
740736

741737
void msg_rx_work(void)

targets/TARGET_Samsung/TARGET_SIDK_S5JS100/modem/modem_link_device_shmem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ShmemIpcDevice {
7373
int res_required;
7474
Mutex *tx_lock;
7575
Semaphore *req_ack_cmpl;
76-
76+
unsigned short header_cnt;
7777
public:
7878

7979
void done_req_ack(void);

0 commit comments

Comments
 (0)