summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2016-08-26 10:55:47 (GMT)
committerGreg Kroah-Hartman <gregkh@google.com>2016-08-26 11:21:13 (GMT)
commitd2dee94b66162d0839dcccee663c90400492fd1b (patch)
treee93dfbf1f6c6c99f2f09c354191c410d19350bf7
parent6ac9166d4e91a6dea03b64b64f128e0f927aa7ec (diff)
downloadlinux-d2dee94b66162d0839dcccee663c90400492fd1b.tar.xz
greybus: es2: implement flush callback
Implement the flush callback which is called as part of connection tear down to flush host-device queues and stop any ongoing transfers. Note that this should be considered an optimisation of sort since if the CPort is stuck waiting for credit, the CPort is likely still stuck when we try to send the cport_shutdown request over it after the callback returns. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
-rw-r--r--drivers/staging/greybus/arpc.h4
-rw-r--r--drivers/staging/greybus/es2.c19
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/staging/greybus/arpc.h b/drivers/staging/greybus/arpc.h
index 6d27769..d44434f 100644
--- a/drivers/staging/greybus/arpc.h
+++ b/drivers/staging/greybus/arpc.h
@@ -80,6 +80,7 @@ struct arpc_response_message {
#define ARPC_TYPE_CPORT_CONNECTED 0x01
#define ARPC_TYPE_CPORT_QUIESCE 0x02
#define ARPC_TYPE_CPORT_CLEAR 0x03
+#define ARPC_TYPE_CPORT_FLUSH 0x04
struct arpc_cport_reset_req {
__le16 cport_id;
@@ -99,5 +100,8 @@ struct arpc_cport_clear_req {
__le16 cport_id;
} __packed;
+struct arpc_cport_flush_req {
+ __le16 cport_id;
+} __packed;
#endif /* __ARPC_H */
diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c
index 8803bc9..1817c35 100644
--- a/drivers/staging/greybus/es2.c
+++ b/drivers/staging/greybus/es2.c
@@ -765,6 +765,24 @@ static int es2_cport_connected(struct gb_host_device *hd, u16 cport_id)
return 0;
}
+static int es2_cport_flush(struct gb_host_device *hd, u16 cport_id)
+{
+ struct es2_ap_dev *es2 = hd_to_es2(hd);
+ struct device *dev = &es2->usb_dev->dev;
+ struct arpc_cport_flush_req req;
+ int ret;
+
+ req.cport_id = cpu_to_le16(cport_id);
+ ret = arpc_sync(es2, ARPC_TYPE_CPORT_FLUSH, &req, sizeof(req),
+ NULL, ES2_ARPC_CPORT_TIMEOUT);
+ if (ret) {
+ dev_err(dev, "failed to flush cport %u: %d\n", cport_id, ret);
+ return ret;
+ }
+
+ return 0;
+}
+
static int es2_cport_quiesce(struct gb_host_device *hd, u16 cport_id,
size_t peer_space, unsigned int timeout)
{
@@ -997,6 +1015,7 @@ static struct gb_hd_driver es2_driver = {
.cport_enable = cport_enable,
.cport_disable = cport_disable,
.cport_connected = es2_cport_connected,
+ .cport_flush = es2_cport_flush,
.cport_quiesce = es2_cport_quiesce,
.cport_clear = es2_cport_clear,
.latency_tag_enable = latency_tag_enable,