]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
mailbox: Add get_max_txsize() to mbox_chan_ops
authorAkhilesh Reddy Khumbum <akhumbum@nvidia.com>
Wed, 21 Jun 2017 19:23:55 +0000 (12:23 -0700)
committerWinnie Hsu <whsu@nvidia.com>
Fri, 30 Jun 2017 18:54:13 +0000 (11:54 -0700)
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>
drivers/mailbox/mailbox.c
include/linux/mailbox_client.h
include/linux/mailbox_controller.h

index 6a4811f857056aaa64baff75265902b59be12ac9..bcd20877ef9933fc431918d2f49e8640782b9603 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * 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>
@@ -222,6 +223,29 @@ bool mbox_client_peek_data(struct mbox_chan *chan)
 }
 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.
index 44348710953f277576975b1bfe37375fc50e899c..eb1a259c24e51e928aeed96a64337ee6f667ec17 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2017, NVIDIA CORPORATION.  All rights reserved.
  * Copyright (C) 2013-2014 Linaro Ltd.
  * Author: Jassi Brar <jassisinghbrar@gmail.com>
  *
@@ -47,5 +48,6 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg);
 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 */
index 74deadb42d76747e8f8f66b32bc839b052ed20a8..d242d8f9e8e99cc92465d2e026aac1fe82fcd4de 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * 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.
@@ -43,6 +45,10 @@ struct mbox_chan;
  *               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);
@@ -50,6 +56,7 @@ struct mbox_chan_ops {
        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);
 };
 
 /**