Add mbox_get_max_txsize() API to the mailbox client API's as
currently there is no provision for the client to get the max
tx message size that can be sent. This API queries the controller
driver and returns the max tx message size.
Bug
200278347
Change-Id: I533f9d137c7eba473b9004ad1000fb85b50c33d7
Signed-off-by: Akhilesh Reddy Khumbum <akhumbum@nvidia.com>
Reviewed-on: https://git-master/r/
1511159
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Tested-by: Rohit Vaswani <rvaswani@nvidia.com>
Reviewed-by: Winnie Hsu <whsu@nvidia.com>
/*
* Mailbox: Common code for Mailbox controllers and users
+ * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
*
* Copyright (C) 2013-2014 Linaro Ltd.
* Author: Jassi Brar <jassisinghbrar@gmail.com>
}
EXPORT_SYMBOL_GPL(mbox_client_peek_data);
+/**
+ * mbox_get_max_txsize - For client to query the maximum tx message
+ * size to send to the remote.
+ * @chan: Mailbox channel assigned to this client.
+ *
+ * Queries the controller driver for the maximum tx message size that
+ * can be transmitted.
+ *
+ * Return: max tx size on success
+ * Negative value on failure.
+ */
+int mbox_get_max_txsize(struct mbox_chan *chan)
+{
+ if (!chan || !chan->cl)
+ return -EINVAL;
+
+ if (!chan->mbox->ops->get_max_txsize)
+ return INT_MAX;
+
+ return chan->mbox->ops->get_max_txsize(chan);
+}
+EXPORT_SYMBOL_GPL(mbox_get_max_txsize);
+
/**
* mbox_send_message - For client to submit a message to be
* sent to the remote.
/*
+ * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
* Copyright (C) 2013-2014 Linaro Ltd.
* Author: Jassi Brar <jassisinghbrar@gmail.com>
*
void mbox_client_txdone(struct mbox_chan *chan, int r); /* atomic */
bool mbox_client_peek_data(struct mbox_chan *chan); /* atomic */
void mbox_free_channel(struct mbox_chan *chan); /* may sleep */
+int mbox_get_max_txsize(struct mbox_chan *chan);
#endif /* __MAILBOX_CLIENT_H */
/*
+ * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
* Used only if txdone_poll:=true && txdone_irq:=false
* @peek_data: Atomic check for any received data. Return true if controller
* has some data to push to the client. False otherwise.
+ * @get_max_txsize: The API aks the queries the MBOX controller driver for
+ * max tx message len and returns it to the client. Returns
+ * negative on failure, max_txlen on success. If the controller
+ * driver does not impose a limit, returns INT_MAX.
*/
struct mbox_chan_ops {
int (*send_data)(struct mbox_chan *chan, void *data);
void (*shutdown)(struct mbox_chan *chan);
bool (*last_tx_done)(struct mbox_chan *chan);
bool (*peek_data)(struct mbox_chan *chan);
+ int (*get_max_txsize)(struct mbox_chan *chan);
};
/**