remoteproc: k3: Refactor .kick rproc ops into common driver

The .kick rproc ops implementations in TI K3 R5, DSP and M4 remoteproc
drivers sends a mailbox message to the remote processor in the same
way. Refactor the implementations into a common function
'k3_rproc_kick()' in the ti_k3_common.c driver.

Signed-off-by: Beleswar Padhi <b-padhi@ti.com>
Acked-by: Andrew Davis <afd@ti.com>
Tested-by: Judith Mendez <jm@ti.com>
Reviewed-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20250513054510.3439842-15-b-padhi@ti.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
This commit is contained in:
Beleswar Padhi
2025-05-13 11:14:48 +05:30
committed by Mathieu Poirier
parent 95dac7e212
commit 9352aadafe
5 changed files with 29 additions and 62 deletions

View File

@@ -84,5 +84,30 @@ void k3_rproc_mbox_callback(struct mbox_client *client, void *data)
}
EXPORT_SYMBOL_GPL(k3_rproc_mbox_callback);
/*
* Kick the remote processor to notify about pending unprocessed messages.
* The vqid usage is not used and is inconsequential, as the kick is performed
* through a simulated GPIO (a bit in an IPC interrupt-triggering register),
* the remote processor is expected to process both its Tx and Rx virtqueues.
*/
void k3_rproc_kick(struct rproc *rproc, int vqid)
{
struct k3_rproc *kproc = rproc->priv;
struct device *dev = kproc->dev;
u32 msg = (u32)vqid;
int ret;
/*
* Send the index of the triggered virtqueue in the mailbox payload.
* NOTE: msg is cast to uintptr_t to prevent compiler warnings when
* void* is 64bit. It is safely cast back to u32 in the mailbox driver.
*/
ret = mbox_send_message(kproc->mbox, (void *)(uintptr_t)msg);
if (ret < 0)
dev_err(dev, "failed to send mailbox message, status = %d\n",
ret);
}
EXPORT_SYMBOL_GPL(k3_rproc_kick);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("TI K3 common Remoteproc code");

View File

@@ -94,4 +94,5 @@ struct k3_rproc {
};
void k3_rproc_mbox_callback(struct mbox_client *client, void *data);
void k3_rproc_kick(struct rproc *rproc, int vqid);
#endif /* REMOTEPROC_TI_K3_COMMON_H */

View File

@@ -24,26 +24,6 @@
#define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1)
/*
* Kick the remote processor to notify about pending unprocessed messages.
* The vqid usage is not used and is inconsequential, as the kick is performed
* through a simulated GPIO (a bit in an IPC interrupt-triggering register),
* the remote processor is expected to process both its Tx and Rx virtqueues.
*/
static void k3_dsp_rproc_kick(struct rproc *rproc, int vqid)
{
struct k3_rproc *kproc = rproc->priv;
struct device *dev = rproc->dev.parent;
mbox_msg_t msg = (mbox_msg_t)vqid;
int ret;
/* send the index of the triggered virtqueue in the mailbox payload */
ret = mbox_send_message(kproc->mbox, (void *)msg);
if (ret < 0)
dev_err(dev, "failed to send mailbox message (%pe)\n",
ERR_PTR(ret));
}
/* Put the DSP processor into reset */
static int k3_dsp_rproc_reset(struct k3_rproc *kproc)
{
@@ -342,7 +322,7 @@ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool
static const struct rproc_ops k3_dsp_rproc_ops = {
.start = k3_dsp_rproc_start,
.stop = k3_dsp_rproc_stop,
.kick = k3_dsp_rproc_kick,
.kick = k3_rproc_kick,
.da_to_va = k3_dsp_rproc_da_to_va,
};

View File

@@ -21,30 +21,6 @@
#include "ti_sci_proc.h"
#include "ti_k3_common.h"
/*
* Kick the remote processor to notify about pending unprocessed messages.
* The vqid usage is not used and is inconsequential, as the kick is performed
* through a simulated GPIO (a bit in an IPC interrupt-triggering register),
* the remote processor is expected to process both its Tx and Rx virtqueues.
*/
static void k3_m4_rproc_kick(struct rproc *rproc, int vqid)
{
struct k3_rproc *kproc = rproc->priv;
struct device *dev = kproc->dev;
u32 msg = (u32)vqid;
int ret;
/*
* Send the index of the triggered virtqueue in the mailbox payload.
* NOTE: msg is cast to uintptr_t to prevent compiler warnings when
* void* is 64bit. It is safely cast back to u32 in the mailbox driver.
*/
ret = mbox_send_message(kproc->mbox, (void *)(uintptr_t)msg);
if (ret < 0)
dev_err(dev, "failed to send mailbox message, status = %d\n",
ret);
}
static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc)
{
struct device *dev = kproc->dev;
@@ -448,7 +424,7 @@ static const struct rproc_ops k3_m4_rproc_ops = {
.stop = k3_m4_rproc_stop,
.attach = k3_m4_rproc_attach,
.detach = k3_m4_rproc_detach,
.kick = k3_m4_rproc_kick,
.kick = k3_rproc_kick,
.da_to_va = k3_m4_rproc_da_to_va,
.get_loaded_rsc_table = k3_m4_get_loaded_rsc_table,
};

View File

@@ -129,21 +129,6 @@ struct k3_r5_core {
bool released_from_reset;
};
/* kick a virtqueue */
static void k3_r5_rproc_kick(struct rproc *rproc, int vqid)
{
struct k3_rproc *kproc = rproc->priv;
struct device *dev = rproc->dev.parent;
mbox_msg_t msg = (mbox_msg_t)vqid;
int ret;
/* send the index of the triggered virtqueue in the mailbox payload */
ret = mbox_send_message(kproc->mbox, (void *)msg);
if (ret < 0)
dev_err(dev, "failed to send mailbox message, status = %d\n",
ret);
}
static int k3_r5_split_reset(struct k3_rproc *kproc)
{
int ret;
@@ -735,7 +720,7 @@ static const struct rproc_ops k3_r5_rproc_ops = {
.unprepare = k3_r5_rproc_unprepare,
.start = k3_r5_rproc_start,
.stop = k3_r5_rproc_stop,
.kick = k3_r5_rproc_kick,
.kick = k3_rproc_kick,
.da_to_va = k3_r5_rproc_da_to_va,
};