Skip to content

Commit a8cf2f9

Browse files
authored
Merge pull request #268 from xiulipan/ipcsch
ipc: use scheduler task for IPC process
2 parents 4aff776 + df0d701 commit a8cf2f9

6 files changed

Lines changed: 56 additions & 16 deletions

File tree

src/include/sof/ipc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ struct ipc {
106106
/* mmap for posn_offset */
107107
struct pipeline *posn_map[PLATFORM_MAX_STREAMS];
108108

109+
/* processing task */
110+
struct task ipc_task;
111+
109112
void *private;
110113
};
111114

@@ -120,6 +123,8 @@ int platform_ipc_init(struct ipc *ipc);
120123
void ipc_free(struct ipc *ipc);
121124

122125
int ipc_process_msg_queue(void);
126+
void ipc_process_task(void *data);
127+
void ipc_schedule_process(struct ipc *ipc);
123128

124129
int ipc_stream_send_position(struct comp_dev *cdev,
125130
struct sof_ipc_stream_posn *posn);

src/ipc/apl-ipc.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ static void irq_handler(void *arg)
7777

7878
/* TODO: place message in Q and process later */
7979
/* It's not Q ATM, may overwrite */
80-
if (_ipc->host_pending)
80+
if (_ipc->host_pending) {
8181
trace_ipc_error("Pen");
82-
_ipc->host_msg = msg;
83-
_ipc->host_pending = 1;
84-
82+
} else {
83+
_ipc->host_msg = msg;
84+
_ipc->host_pending = 1;
85+
ipc_schedule_process(_ipc);
86+
}
8587
}
8688

8789
/* reply message(done) from host */
@@ -196,6 +198,10 @@ int platform_ipc_init(struct ipc *ipc)
196198
for (i = 0; i < MSG_QUEUE_SIZE; i++)
197199
list_item_prepend(&ipc->message[i].list, &ipc->empty_list);
198200

201+
/* schedule */
202+
schedule_task_init(&_ipc->ipc_task, ipc_process_task, _ipc);
203+
schedule_task_config(&_ipc->ipc_task, 0, 0);
204+
199205
/* allocate page table buffer */
200206
iipc->page_table = rballoc(RZONE_SYS, SOF_MEM_CAPS_RAM,
201207
HOST_PAGE_SIZE);

src/ipc/byt-ipc.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,13 @@ static void irq_handler(void *arg)
111111

112112
/* TODO: place message in Q and process later */
113113
/* It's not Q ATM, may overwrite */
114-
if (_ipc->host_pending)
114+
if (_ipc->host_pending) {
115115
trace_ipc_error("Pen");
116-
_ipc->host_msg = shim_read(SHIM_IPCXL);
117-
_ipc->host_pending = 1;
116+
} else {
117+
_ipc->host_msg = shim_read(SHIM_IPCXL);
118+
_ipc->host_pending = 1;
119+
ipc_schedule_process(_ipc);
120+
}
118121
}
119122
}
120123

@@ -219,6 +222,10 @@ int platform_ipc_init(struct ipc *ipc)
219222
for (i = 0; i < MSG_QUEUE_SIZE; i++)
220223
list_item_prepend(&ipc->message[i].list, &ipc->empty_list);
221224

225+
/* schedule */
226+
schedule_task_init(&_ipc->ipc_task, ipc_process_task, _ipc);
227+
schedule_task_config(&_ipc->ipc_task, 0, 0);
228+
222229
/* allocate page table buffer */
223230
iipc->page_table = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
224231
PLATFORM_PAGE_TABLE_SIZE);

src/ipc/cnl-ipc.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ static void irq_handler(void *arg)
7878

7979
/* TODO: place message in Q and process later */
8080
/* It's not Q ATM, may overwrite */
81-
if (_ipc->host_pending)
81+
if (_ipc->host_pending) {
8282
trace_ipc_error("Pen");
83-
_ipc->host_msg = msg;
84-
_ipc->host_pending = 1;
83+
} else {
84+
_ipc->host_msg = msg;
85+
_ipc->host_pending = 1;
86+
ipc_schedule_process(_ipc);
87+
}
8588
}
8689

8790
/* reply message(done) from host */
@@ -197,6 +200,10 @@ int platform_ipc_init(struct ipc *ipc)
197200
for (i = 0; i < MSG_QUEUE_SIZE; i++)
198201
list_item_prepend(&ipc->message[i].list, &ipc->empty_list);
199202

203+
/* schedule */
204+
schedule_task_init(&_ipc->ipc_task, ipc_process_task, _ipc);
205+
schedule_task_config(&_ipc->ipc_task, 0, 0);
206+
200207
/* allocate page table buffer */
201208
iipc->page_table = rballoc(RZONE_SYS, SOF_MEM_CAPS_RAM,
202209
HOST_PAGE_SIZE);

src/ipc/handler.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,9 +1122,18 @@ int ipc_queue_host_message(struct ipc *ipc, uint32_t header,
11221122
/* process current message */
11231123
int ipc_process_msg_queue(void)
11241124
{
1125-
if (_ipc->host_pending)
1126-
ipc_platform_do_cmd(_ipc);
11271125
if (_ipc->dsp_pending)
11281126
ipc_platform_send_msg(_ipc);
11291127
return 0;
11301128
}
1129+
1130+
void ipc_process_task(void *data)
1131+
{
1132+
if (_ipc->host_pending)
1133+
ipc_platform_do_cmd(_ipc);
1134+
}
1135+
1136+
void ipc_schedule_process(struct ipc *ipc)
1137+
{
1138+
schedule_task(&ipc->ipc_task, 0, 100);
1139+
}

src/ipc/hsw-ipc.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ static void irq_handler(void *arg)
111111

112112
/* TODO: place message in Q and process later */
113113
/* It's not Q ATM, may overwrite */
114-
if (_ipc->host_pending)
114+
if (_ipc->host_pending) {
115115
trace_ipc_error("Pen");
116-
117-
_ipc->host_msg = shim_read(SHIM_IPCX);
118-
_ipc->host_pending = 1;
116+
} else {
117+
_ipc->host_msg = shim_read(SHIM_IPCX);
118+
_ipc->host_pending = 1;
119+
ipc_schedule_process(_ipc);
120+
}
119121
}
120122
}
121123

@@ -215,6 +217,10 @@ int platform_ipc_init(struct ipc *ipc)
215217
for (i = 0; i < MSG_QUEUE_SIZE; i++)
216218
list_item_prepend(&ipc->message[i].list, &ipc->empty_list);
217219

220+
/* schedule */
221+
schedule_task_init(&_ipc->ipc_task, ipc_process_task, _ipc);
222+
schedule_task_config(&_ipc->ipc_task, 0, 0);
223+
218224
/* allocate page table buffer */
219225
iipc->page_table = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
220226
PLATFORM_PAGE_TABLE_SIZE);

0 commit comments

Comments
 (0)