Skip to content

Commit 2eab5ef

Browse files
sumanannaandersson
authored andcommitted
remoteproc: k3-dsp: Refactor mbox request code in start
Refactor out the mailbox request and associated ping logic code from k3_dsp_rproc_start() function into its own separate function so that it can be re-used in the soon to be added .attach() ops callback. Signed-off-by: Suman Anna <s-anna@ti.com> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Link: https://lore.kernel.org/r/20220213201246.25952-5-s-anna@ti.com
1 parent 1168af4 commit 2eab5ef

File tree

1 file changed

+40
-27
lines changed

1 file changed

+40
-27
lines changed

drivers/remoteproc/ti_k3_dsp_remoteproc.c

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* TI K3 DSP Remote Processor(s) driver
44
*
5-
* Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/
5+
* Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
66
* Suman Anna <s-anna@ti.com>
77
*/
88

@@ -216,6 +216,43 @@ static int k3_dsp_rproc_release(struct k3_dsp_rproc *kproc)
216216
return ret;
217217
}
218218

219+
static int k3_dsp_rproc_request_mbox(struct rproc *rproc)
220+
{
221+
struct k3_dsp_rproc *kproc = rproc->priv;
222+
struct mbox_client *client = &kproc->client;
223+
struct device *dev = kproc->dev;
224+
int ret;
225+
226+
client->dev = dev;
227+
client->tx_done = NULL;
228+
client->rx_callback = k3_dsp_rproc_mbox_callback;
229+
client->tx_block = false;
230+
client->knows_txdone = false;
231+
232+
kproc->mbox = mbox_request_channel(client, 0);
233+
if (IS_ERR(kproc->mbox)) {
234+
ret = -EBUSY;
235+
dev_err(dev, "mbox_request_channel failed: %ld\n",
236+
PTR_ERR(kproc->mbox));
237+
return ret;
238+
}
239+
240+
/*
241+
* Ping the remote processor, this is only for sanity-sake for now;
242+
* there is no functional effect whatsoever.
243+
*
244+
* Note that the reply will _not_ arrive immediately: this message
245+
* will wait in the mailbox fifo until the remote processor is booted.
246+
*/
247+
ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST);
248+
if (ret < 0) {
249+
dev_err(dev, "mbox_send_message failed: %d\n", ret);
250+
mbox_free_channel(kproc->mbox);
251+
return ret;
252+
}
253+
254+
return 0;
255+
}
219256
/*
220257
* The C66x DSP cores have a local reset that affects only the CPU, and a
221258
* generic module reset that powers on the device and allows the DSP internal
@@ -273,37 +310,13 @@ static int k3_dsp_rproc_unprepare(struct rproc *rproc)
273310
static int k3_dsp_rproc_start(struct rproc *rproc)
274311
{
275312
struct k3_dsp_rproc *kproc = rproc->priv;
276-
struct mbox_client *client = &kproc->client;
277313
struct device *dev = kproc->dev;
278314
u32 boot_addr;
279315
int ret;
280316

281-
client->dev = dev;
282-
client->tx_done = NULL;
283-
client->rx_callback = k3_dsp_rproc_mbox_callback;
284-
client->tx_block = false;
285-
client->knows_txdone = false;
286-
287-
kproc->mbox = mbox_request_channel(client, 0);
288-
if (IS_ERR(kproc->mbox)) {
289-
ret = -EBUSY;
290-
dev_err(dev, "mbox_request_channel failed: %ld\n",
291-
PTR_ERR(kproc->mbox));
317+
ret = k3_dsp_rproc_request_mbox(rproc);
318+
if (ret)
292319
return ret;
293-
}
294-
295-
/*
296-
* Ping the remote processor, this is only for sanity-sake for now;
297-
* there is no functional effect whatsoever.
298-
*
299-
* Note that the reply will _not_ arrive immediately: this message
300-
* will wait in the mailbox fifo until the remote processor is booted.
301-
*/
302-
ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST);
303-
if (ret < 0) {
304-
dev_err(dev, "mbox_send_message failed: %d\n", ret);
305-
goto put_mbox;
306-
}
307320

308321
boot_addr = rproc->bootaddr;
309322
if (boot_addr & (kproc->data->boot_align_addr - 1)) {

0 commit comments

Comments
 (0)