*/
struct k3_r5_core {
struct list_head elem;
@@ -148,6 +149,7 @@ struct k3_r5_core {
u32 btcm_enable;
u32 loczrama;
bool released_from_reset;
+ bool is_attach_ongoing;
};
/**
@@ -194,8 +196,11 @@ static void k3_r5_rproc_mbox_callback(struct
mbox_client *client, void *data)
const char *name = kproc->rproc->name;
u32 msg = omap_mbox_message(data);
- /* Do not forward message from a detached core */
- if (kproc->rproc->state == RPROC_DETACHED)
+ /*
+ * Do not forward messages from a detached core, except when
the core
+ * is in the process of being attached in IPC-only mode.
+ */
+ if (!kproc->core->is_attach_ongoing && kproc->rproc->state ==
RPROC_DETACHED)
return;
dev_dbg(dev, "mbox msg: 0x%x\n", msg);
@@ -233,8 +238,11 @@ static void k3_r5_rproc_kick(struct rproc
*rproc, int vqid)
mbox_msg_t msg = (mbox_msg_t)vqid;
int ret;
- /* Do not forward message to a detached core */
- if (kproc->rproc->state == RPROC_DETACHED)
+ /*
+ * Do not forward messages to a detached core, except when the
core is
+ * in the process of being attached in IPC-only mode.
+ */
+ if (!kproc->core->is_attach_ongoing && kproc->rproc->state ==
RPROC_DETACHED)
return;
/* send the index of the triggered virtqueue in the mailbox
payload */
@@ -671,22 +679,39 @@ static int k3_r5_rproc_stop(struct rproc *rproc)
/*
* Attach to a running R5F remote processor (IPC-only mode)
*
- * The R5F attach callback is a NOP. The remote processor is
already booted, and
- * all required resources have been acquired during probe routine,
so there is
- * no need to issue any TI-SCI commands to boot the R5F cores in
IPC-only mode.
- * This callback is invoked only in IPC-only mode and exists because
- * rproc_validate() checks for its existence.
+ * The R5F attach callback only needs to set the
"is_attach_ongoing" flag to
+ * notify k3_r5_rproc_{kick/mbox_callback} functions that the core
is in the
+ * process of getting attached in IPC-only mode. The remote
processor is
+ * already booted, and all required resources have been acquired
during probe
+ * routine, so there is no need to issue any TI-SCI commands to
boot the R5F
+ * cores in IPC-only mode. This callback is invoked only in
IPC-only mode.
*/
-static int k3_r5_rproc_attach(struct rproc *rproc) { return 0; }
+static int k3_r5_rproc_attach(struct rproc *rproc)
+{
+ struct k3_r5_rproc *kproc = rproc->priv;
+
+ kproc->core->is_attach_ongoing = true;
+
+ return 0;
+}
/*
* Detach from a running R5F remote processor (IPC-only mode)
*
- * The R5F detach callback is a NOP. The R5F cores are not stopped
and will be
- * left in booted state in IPC-only mode. This callback is invoked
only in
- * IPC-only mode and exists for sanity sake.
+ * The R5F detach callback performs the opposite operation to
attach callback
+ * and only needs to clear the "is_attach_ongoing" flag to ensure
no mailbox
+ * messages are sent to or received from a detached core. The R5F
cores are
+ * not stopped and will be left in booted state in IPC-only mode. This
+ * callback is invoked only in IPC-only mode.
*/
-static int k3_r5_rproc_detach(struct rproc *rproc) { return 0; }
+static int k3_r5_rproc_detach(struct rproc *rproc)
+{
+ struct k3_r5_rproc *kproc = rproc->priv;
+
+ kproc->core->is_attach_ongoing = false;
+
+ return 0;
+}
/*
* This function implements the .get_loaded_rsc_table() callback
and is used