summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2016-08-10 10:58:43 (GMT)
committerGreg Kroah-Hartman <gregkh@google.com>2016-08-11 12:13:07 (GMT)
commit0e7cd0d259890f21d13171d5798eed24a03903dc (patch)
tree21d1a9711e5108d280f910289069a40c2155f0d0
parenta9dc1cf5b7b5ce8183249c2229ae0ab849525e37 (diff)
downloadlinux-0e7cd0d259890f21d13171d5798eed24a03903dc.tar.xz
greybus: hd/es2: add cport_quiesce callback and ARPC
Add a host-device cport_quiesce callback, which will be called as part of the new connection tear-down sequence to disable flow control after first making sure that enough peer buffer space is available for the next messages about to be sent. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Sandeep Patil <sspatil@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
-rw-r--r--drivers/staging/greybus/arpc.h7
-rw-r--r--drivers/staging/greybus/es2.c30
-rw-r--r--drivers/staging/greybus/hd.h2
3 files changed, 39 insertions, 0 deletions
diff --git a/drivers/staging/greybus/arpc.h b/drivers/staging/greybus/arpc.h
index 8a90271..9fb1608 100644
--- a/drivers/staging/greybus/arpc.h
+++ b/drivers/staging/greybus/arpc.h
@@ -78,6 +78,7 @@ struct arpc_response_message {
/* ARPC requests */
#define ARPC_TYPE_CPORT_RESET 0x00
#define ARPC_TYPE_CPORT_CONNECTED 0x01
+#define ARPC_TYPE_CPORT_QUIESCE 0x02
struct arpc_cport_reset_req {
__le16 cport_id;
@@ -87,5 +88,11 @@ struct arpc_cport_connected_req {
__le16 cport_id;
} __packed;
+struct arpc_cport_quiesce_req {
+ __le16 cport_id;
+ __le16 peer_space;
+ __le16 timeout;
+} __packed;
+
#endif /* __ARPC_H */
diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c
index 9af9b73..42f2483 100644
--- a/drivers/staging/greybus/es2.c
+++ b/drivers/staging/greybus/es2.c
@@ -765,6 +765,35 @@ static int es2_cport_connected(struct gb_host_device *hd, u16 cport_id)
return 0;
}
+static int es2_cport_quiesce(struct gb_host_device *hd, u16 cport_id,
+ size_t peer_space, unsigned int timeout)
+{
+ struct es2_ap_dev *es2 = hd_to_es2(hd);
+ struct device *dev = &es2->usb_dev->dev;
+ struct arpc_cport_quiesce_req req;
+ int result;
+ int ret;
+
+ if (peer_space > U16_MAX)
+ return -EINVAL;
+
+ if (timeout > U16_MAX)
+ return -EINVAL;
+
+ req.cport_id = cpu_to_le16(cport_id);
+ req.peer_space = cpu_to_le16(peer_space);
+ req.timeout = cpu_to_le16(timeout);
+ ret = arpc_sync(es2, ARPC_TYPE_CPORT_QUIESCE, &req, sizeof(req),
+ &result, ES2_ARPC_CPORT_TIMEOUT + timeout);
+ if (ret) {
+ dev_err(dev, "failed to quiesce cport %u: %d (%d)\n",
+ cport_id, ret, result);
+ return ret;
+ }
+
+ return 0;
+}
+
static int latency_tag_enable(struct gb_host_device *hd, u16 cport_id)
{
int retval;
@@ -950,6 +979,7 @@ static struct gb_hd_driver es2_driver = {
.cport_enable = cport_enable,
.cport_disable = cport_disable,
.cport_connected = es2_cport_connected,
+ .cport_quiesce = es2_cport_quiesce,
.latency_tag_enable = latency_tag_enable,
.latency_tag_disable = latency_tag_disable,
.output = output,
diff --git a/drivers/staging/greybus/hd.h b/drivers/staging/greybus/hd.h
index be81879..feaba01 100644
--- a/drivers/staging/greybus/hd.h
+++ b/drivers/staging/greybus/hd.h
@@ -25,6 +25,8 @@ struct gb_hd_driver {
int (*cport_connected)(struct gb_host_device *hd, u16 cport_id);
int (*cport_flush)(struct gb_host_device *hd, u16 cport_id);
int (*cport_ping)(struct gb_host_device *hd, u16 cport_id);
+ int (*cport_quiesce)(struct gb_host_device *hd, u16 cport_id,
+ size_t peer_space, unsigned int timeout);
int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id,
struct gb_message *message, gfp_t gfp_mask);
void (*message_cancel)(struct gb_message *message);