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 <jamie.gibbons@microchip.com> Acked-by: Conor Dooley <conor.dooley@microchip.com>
This commit is contained in:
committed by
Leo Yu-Chi Liang
parent
baa64b2f89
commit
a5f93037f2
@@ -85,6 +85,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
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user