diff options
| author | Jamie Gibbons <[email protected]> | 2026-07-22 16:45:44 +0100 |
|---|---|---|
| committer | Leo Yu-Chi Liang <[email protected]> | 2026-08-05 02:03:23 -0700 |
| commit | a5f93037f28624c612288e2d97604d73e03af5a3 (patch) | |
| tree | 3bc0b632bab1615876e887f45b75c7453d869522 | |
| parent | baa64b2f892890f00a377eac4a3e685472bb56b5 (diff) | |
misc: mpfs_syscontroller: add mailbox RX helper for service responses
The MPFS system controller run_service() helper only submits the mailbox
request but does not read back the response data. However, the caller
must explicitly receive the response.
Add a public system controller helper to receive mailbox service
responses to populate the response buffer after issuing a system
controller request.
Without this, the drivers copy uninitialised stack data instead of
mailbox response data, resulting in deterministic output.
Signed-off-by: Jamie Gibbons <[email protected]>
Acked-by: Conor Dooley <[email protected]>
| -rw-r--r-- | drivers/misc/mpfs_syscontroller.c | 30 | ||||
| -rw-r--r-- | include/mpfs-mailbox.h | 2 |
2 files changed, 28 insertions, 4 deletions
diff --git a/drivers/misc/mpfs_syscontroller.c b/drivers/misc/mpfs_syscontroller.c index f608d5518b0..d29cb2e9e59 100644 --- a/drivers/misc/mpfs_syscontroller.c +++ b/drivers/misc/mpfs_syscontroller.c @@ -86,6 +86,30 @@ int mpfs_syscontroller_run_service(struct mpfs_syscontroller_priv *sys_controlle EXPORT_SYMBOL_GPL(mpfs_syscontroller_run_service); /** + * mpfs_syscontroller_recv_response() - Receive the MPFS system service response + * @sys_controller: MPFS system controller instance + * @msg: System service message + * @timeout_ms: Timeout in milliseconds + * + * Receive the mailbox response for a previously issued MPFS system + * controller service request and populate the response buffer. + * + * Return: 0 if all goes good, else appropriate error message. + */ +int mpfs_syscontroller_recv_response(struct mpfs_syscontroller_priv *sys_controller, struct + mpfs_mss_msg * msg, unsigned long timeout_ms) +{ + int ret; + + ret = mbox_recv(&sys_controller->chan, msg, timeout_ms); + if (ret) + dev_err(sys_controller->chan.dev, "Service failed: %d, abort. Failure: %u\n", ret, + msg->response->resp_status); + return ret; +} +EXPORT_SYMBOL_GPL(mpfs_syscontroller_recv_response); + +/** * mpfs_syscontroller_read_sernum() - Use system service to read the device serial number * @sys_serv_priv: system service private data * @device_serial_number: device serial number @@ -116,11 +140,9 @@ int mpfs_syscontroller_read_sernum(struct mpfs_sys_serv *sys_serv_priv, u8 *devi } /* Receive the response */ - ret = mbox_recv(&sys_serv_priv->sys_controller->chan, &msg, timeoutsecs); - if (ret) { - dev_err(sys_serv_priv->sys_controller->chan.dev, "Service failed: %d, abort. Failure: %u\n", ret, msg.response->resp_status); + ret = mpfs_syscontroller_recv_response(sys_serv_priv->sys_controller, &msg, timeoutsecs); + if (ret) return ret; - } debug("%s: Read successful %s\n", __func__, sys_serv_priv->sys_controller->chan.dev->name); diff --git a/include/mpfs-mailbox.h b/include/mpfs-mailbox.h index c0ff327a4ce..39c998e4c8d 100644 --- a/include/mpfs-mailbox.h +++ b/include/mpfs-mailbox.h @@ -58,6 +58,8 @@ struct mpfs_sys_serv { }; int mpfs_syscontroller_run_service(struct mpfs_syscontroller_priv *sys_controller, struct mpfs_mss_msg *msg); +int mpfs_syscontroller_recv_response(struct mpfs_syscontroller_priv + *sys_controller, struct mpfs_mss_msg *msg, unsigned long timeout_ms); int mpfs_syscontroller_read_sernum(struct mpfs_sys_serv *sys_serv_priv, u8 *device_serial_number); void mpfs_syscontroller_process_dtbo(struct mpfs_sys_serv *sys_serv_priv); struct mpfs_syscontroller_priv *mpfs_syscontroller_get(struct udevice *dev); |
