summaryrefslogtreecommitdiff
path: root/drivers/misc/mei/client.c
diff options
context:
space:
mode:
authorAlexander Usyskin <alexander.usyskin@intel.com>2015-05-04 09:43:55 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-05-24 21:13:48 +0300
commita03d77f6ed7dc74d6244e4d8681ba669d7c414aa (patch)
tree2f4bebc9c73a30b16017bda5cd532aec4ada2ef3 /drivers/misc/mei/client.c
parentd49ed64a6e3f73975b7eb570c4ea8f37e87d7e5d (diff)
downloadlinux-a03d77f6ed7dc74d6244e4d8681ba669d7c414aa.tar.xz
mei: fix flow control for single buffer clients
For ME clients that use single receiving buffer the driver tracks credentials on mei_me_clients structure for all connections. The driver needs to book keep the shared resource correctly and track the connections, particularly the credit has to be cleaned when there is no active connection to a particular me client. This solves issue when subsequent connection will not get an ill impression that it can write. We add active connection counter the particular ME client and when the counter reach zero, we clear the credits. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/client.c')
-rw-r--r--drivers/misc/mei/client.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index aa1d35a51e9f..98335b435b75 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -749,10 +749,31 @@ void mei_cl_set_disconnected(struct mei_cl *cl)
cl->mei_flow_ctrl_creds = 0;
cl->timer_count = 0;
+ if (!cl->me_cl)
+ return;
+
+ if (!WARN_ON(cl->me_cl->connect_count == 0))
+ cl->me_cl->connect_count--;
+
+ if (cl->me_cl->connect_count == 0)
+ cl->me_cl->mei_flow_ctrl_creds = 0;
+
mei_me_cl_put(cl->me_cl);
cl->me_cl = NULL;
}
+static int mei_cl_set_connecting(struct mei_cl *cl, struct mei_me_client *me_cl)
+{
+ cl->me_cl = mei_me_cl_get(me_cl);
+ if (!cl->me_cl)
+ return -ENOENT;
+
+ cl->state = MEI_FILE_CONNECTING;
+ cl->me_cl->connect_count++;
+
+ return 0;
+}
+
/*
* mei_cl_send_disconnect - send disconnect request
*
@@ -1009,13 +1030,9 @@ int mei_cl_connect(struct mei_cl *cl, struct mei_me_client *me_cl,
if (rets)
goto out;
- cl->me_cl = mei_me_cl_get(me_cl);
- if (!cl->me_cl) {
- rets = -ENODEV;
+ rets = mei_cl_set_connecting(cl, me_cl);
+ if (rets)
goto out;
- }
-
- cl->state = MEI_FILE_CONNECTING;
list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
/* run hbuf acquire last so we don't have to undo */