@@ -206,6 +206,7 @@ struct scmi_chan_info {
* @get_max_msg: Optional callback to provide max_msg dynamically
* @max_msg: Maximum number of messages for the channel type (tx or rx)
* that can be pending simultaneously in the system
+ * @xfer_init_buffers: Callback to initialize buffers for scmi_xfer
* @send_message: Callback to send a message
* @mark_txdone: Callback to mark tx as done
* @fetch_response: Callback to fetch response
@@ -220,6 +221,8 @@ struct scmi_transport_ops {
int (*chan_free)(int id, void *p, void *data);
int (*get_max_msg)(bool tx, struct scmi_chan_info *base_cinfo,
int *max_msg);
+ int (*xfer_init_buffers)(struct scmi_chan_info *cinfo,
+ struct scmi_xfer *xfer, int max_msg_size);
int (*send_message)(struct scmi_chan_info *cinfo,
struct scmi_xfer *xfer);
void (*mark_txdone)(struct scmi_chan_info *cinfo, int ret);
@@ -632,12 +632,21 @@ static int __scmi_xfer_info_init(struct scmi_info *sinfo,
/* Pre-initialize the buffer pointer to pre-allocated buffers */
for (i = 0, xfer = info->xfer_block; i < info->max_msg; i++, xfer++) {
- xfer->rx.buf = devm_kcalloc(dev, sizeof(u8), desc->max_msg_size,
- GFP_KERNEL);
- if (!xfer->rx.buf)
- return -ENOMEM;
-
- xfer->tx.buf = xfer->rx.buf;
+ if (desc->ops->xfer_init_buffers) {
+ int ret = desc->ops->xfer_init_buffers(
+ base_cinfo, xfer, desc->max_msg_size);
+
+ if (ret)
+ return ret;
+ } else {
+ xfer->rx.buf = devm_kcalloc(dev, sizeof(u8),
+ desc->max_msg_size,
+ GFP_KERNEL);
+ if (!xfer->rx.buf)
+ return -ENOMEM;
+
+ xfer->tx.buf = xfer->rx.buf;
+ }
init_completion(&xfer->done);
}