mei: push credentials inside the irq write handler
authorTomas Winkler <tomas.winkler@intel.com>
Mon, 16 Sep 2013 20:44:44 +0000 (23:44 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Sep 2013 15:42:02 +0000 (08:42 -0700)
this eventually allows as use a single write queue
both for control and data messages and removing possible
race

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/amthif.c
drivers/misc/mei/client.c
drivers/misc/mei/interrupt.c

index 718f3a14c1ca4b6f06265deef880381501be74c9..04fd3856772975b0c9061f24e56777e8232ed615 100644 (file)
@@ -460,6 +460,15 @@ int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
        u32 msg_slots = mei_data2slots(len);
        int rets;
 
+       rets = mei_cl_flow_ctrl_creds(cl);
+       if (rets < 0)
+               return rets;
+
+       if (rets == 0) {
+               cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
+               return 0;
+       }
+
        mei_hdr.host_addr = cl->host_client_id;
        mei_hdr.me_addr = cl->me_client_id;
        mei_hdr.reserved = 0;
index 1a53d961302a7e1e3d7d474dfed74afad22bb4eb..2ab9d1613ffcb2eb009cd8e44a9ea3cbaa99ccc7 100644 (file)
@@ -702,12 +702,33 @@ err:
 int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
                                     s32 *slots, struct mei_cl_cb *cmpl_list)
 {
-       struct mei_device *dev = cl->dev;
+       struct mei_device *dev;
+       struct mei_msg_data *buf;
        struct mei_msg_hdr mei_hdr;
-       size_t len = cb->request_buffer.size - cb->buf_idx;
-       u32 msg_slots = mei_data2slots(len);
+       size_t len;
+       u32 msg_slots;
        int rets;
 
+
+       if (WARN_ON(!cl || !cl->dev))
+               return -ENODEV;
+
+       dev = cl->dev;
+
+       buf = &cb->request_buffer;
+
+       rets = mei_cl_flow_ctrl_creds(cl);
+       if (rets < 0)
+               return rets;
+
+       if (rets == 0) {
+               cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
+               return 0;
+       }
+
+       len = buf->size - cb->buf_idx;
+       msg_slots = mei_data2slots(len);
+
        mei_hdr.host_addr = cl->host_client_id;
        mei_hdr.me_addr = cl->me_client_id;
        mei_hdr.reserved = 0;
@@ -730,8 +751,7 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
                        cb->request_buffer.size, cb->buf_idx);
 
        *slots -=  msg_slots;
-       rets = mei_write_message(dev, &mei_hdr,
-                       cb->request_buffer.data + cb->buf_idx);
+       rets = mei_write_message(dev, &mei_hdr, buf->data + cb->buf_idx);
        if (rets) {
                cl->status = rets;
                list_move_tail(&cb->list, &cmpl_list->list);
index e4bb9aee40a1f8e7b83d771d96e72e9f8b8058ac..7a95c07e59a6d675a4cc37a41c70fbd3e95961d7 100644 (file)
@@ -513,11 +513,6 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
                cl = cb->cl;
                if (cl == NULL)
                        continue;
-               if (mei_cl_flow_ctrl_creds(cl) <= 0) {
-                       cl_dbg(dev, cl, "No flow control credentials, not sending.\n");
-                       continue;
-               }
-
                if (cl == &dev->iamthif_cl)
                        ret = mei_amthif_irq_write_complete(cl, cb,
                                                &slots, cmpl_list);