mei: get rid of ext_msg
authorTomas Winkler <tomas.winkler@intel.com>
Wed, 12 Feb 2014 19:41:52 +0000 (21:41 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2014 19:12:46 +0000 (11:12 -0800)
Use more standard message writing for
oob data.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/hbm.c
drivers/misc/mei/hbm.h
drivers/misc/mei/hw-me.c
drivers/misc/mei/init.c
drivers/misc/mei/interrupt.c
drivers/misc/mei/mei_dev.h

index 0c770255bf8914415e1e8cf5fa51c6a2c1a5d10e..d3fcb23bb0810179266b5f294b26c06fc7221a74 100644 (file)
@@ -283,17 +283,18 @@ static int mei_hbm_prop_req(struct mei_device *dev)
 }
 
 /**
- * mei_hbm_stop_req_prepare - prepare stop request message
+ * mei_hbm_stop_req - send stop request message
  *
  * @dev - mei device
- * @mei_hdr - mei message header
- * @data - hbm message body buffer
+ * @cl: client info
+ *
+ * This function returns -EIO on write failure
  */
-static void mei_hbm_stop_req_prepare(struct mei_device *dev,
-               struct mei_msg_hdr *mei_hdr, unsigned char *data)
+static int mei_hbm_stop_req(struct mei_device *dev)
 {
+       struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
        struct hbm_host_stop_request *req =
-                       (struct hbm_host_stop_request *)data;
+                       (struct hbm_host_stop_request *)dev->wr_msg.data;
        const size_t len = sizeof(struct hbm_host_stop_request);
 
        mei_hbm_hdr(mei_hdr, len);
@@ -301,6 +302,8 @@ static void mei_hbm_stop_req_prepare(struct mei_device *dev,
        memset(req, 0, len);
        req->hbm_cmd = HOST_STOP_REQ_CMD;
        req->reason = DRIVER_STOP_REQUEST;
+
+       return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
 }
 
 /**
@@ -404,6 +407,25 @@ int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
        return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
 }
 
+/**
+ * mei_hbm_cl_disconnect_rsp - sends disconnect respose to the FW
+ *
+ * @dev: the device structure
+ * @cl: a client to disconnect from
+ *
+ * This function returns -EIO on write failure
+ */
+int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl)
+{
+       struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
+       const size_t len = sizeof(struct hbm_client_connect_response);
+
+       mei_hbm_hdr(mei_hdr, len);
+       mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_RES_CMD, dev->wr_msg.data, len);
+
+       return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
+}
+
 /**
  * mei_hbm_cl_disconnect_res - disconnect response from ME
  *
@@ -525,12 +547,14 @@ static void mei_hbm_cl_connect_res(struct mei_device *dev,
  *
  * @dev: the device structure.
  * @disconnect_req: disconnect request bus message from the me
+ *
+ * returns -ENOMEM on allocation failure
  */
-static void mei_hbm_fw_disconnect_req(struct mei_device *dev,
+static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
                struct hbm_client_connect_request *disconnect_req)
 {
        struct mei_cl *cl, *next;
-       const size_t len = sizeof(struct hbm_client_connect_response);
+       struct mei_cl_cb *cb;
 
        list_for_each_entry_safe(cl, next, &dev->file_list, link) {
                if (mei_hbm_cl_addr_equal(cl, disconnect_req)) {
@@ -544,13 +568,17 @@ static void mei_hbm_fw_disconnect_req(struct mei_device *dev,
                        else if (cl == &dev->iamthif_cl)
                                dev->iamthif_timer = 0;
 
-                       /* prepare disconnect response */
-                       mei_hbm_hdr(&dev->wr_ext_msg.hdr, len);
-                       mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_RES_CMD,
-                                        dev->wr_ext_msg.data, len);
+                       cb = mei_io_cb_init(cl, NULL);
+                       if (!cb)
+                               return -ENOMEM;
+                       cb->fop_type = MEI_FOP_DISCONNECT_RSP;
+                       cl_dbg(dev, cl, "add disconnect response as first\n");
+                       list_add(&cb->list, &dev->ctrl_wr_list.list);
+
                        break;
                }
        }
+       return 0;
 }
 
 
@@ -629,10 +657,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
                        dev_warn(&dev->pdev->dev, "hbm: start: version mismatch - stopping the driver.\n");
 
                        dev->hbm_state = MEI_HBM_STOPPED;
-                       mei_hbm_stop_req_prepare(dev, &dev->wr_msg.hdr,
-                                               dev->wr_msg.data);
-                       if (mei_write_message(dev, &dev->wr_msg.hdr,
-                                       dev->wr_msg.data)) {
+                       if (mei_hbm_stop_req(dev)) {
                                dev_err(&dev->pdev->dev, "hbm: start: failed to send stop request\n");
                                return -EIO;
                        }
@@ -778,10 +803,11 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
 
        case ME_STOP_REQ_CMD:
                dev_dbg(&dev->pdev->dev, "hbm: stop request: message received\n");
-
                dev->hbm_state = MEI_HBM_STOPPED;
-               mei_hbm_stop_req_prepare(dev, &dev->wr_ext_msg.hdr,
-                                       dev->wr_ext_msg.data);
+               if (mei_hbm_stop_req(dev)) {
+                       dev_err(&dev->pdev->dev, "hbm: start: failed to send stop request\n");
+                       return -EIO;
+               }
                break;
        default:
                BUG();
index 5f92188a5cd7323653026dc5c4f57cdedb3c107e..20e8782711c0c5f53e8e43c97b0c32476b3d27c8 100644 (file)
@@ -54,6 +54,7 @@ int mei_hbm_start_req(struct mei_device *dev);
 int mei_hbm_start_wait(struct mei_device *dev);
 int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl);
 int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl);
+int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl);
 int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl);
 bool mei_hbm_version_is_supported(struct mei_device *dev);
 
index 54286f3049393b9df00ede9497fdc9c04f785990..847c9e5746cb09b2a82d26c9bcd7780a888a4440 100644 (file)
@@ -505,9 +505,6 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)
        /* check slots available for reading */
        slots = mei_count_full_read_slots(dev);
        while (slots > 0) {
-               /* we have urgent data to send so break the read */
-               if (dev->wr_ext_msg.hdr.length)
-                       break;
                dev_dbg(&dev->pdev->dev, "slots to read = %08x\n", slots);
                rets = mei_irq_read_handler(dev, &complete_list, &slots);
                if (rets && dev->dev_state != MEI_DEV_RESETTING) {
index 95a7180c75eaf5fa64bd125a208fd8f999022a01..214dcef9750a4853cc03fc4b0d904be5096cbace 100644 (file)
@@ -116,7 +116,6 @@ int mei_reset(struct mei_device *dev)
                mei_cl_unlink(&dev->wd_cl);
                mei_cl_unlink(&dev->iamthif_cl);
                mei_amthif_reset_params(dev);
-               memset(&dev->wr_ext_msg, 0, sizeof(dev->wr_ext_msg));
        }
 
 
index 3f0b0b9ce9515e79261492bd63e803730ed46095..75ff4092953e6f47a96605db18cc4c65482aa60c 100644 (file)
@@ -160,6 +160,41 @@ static int mei_cl_irq_read_msg(struct mei_device *dev,
        return 0;
 }
 
+/**
+ * mei_cl_irq_disconnect_rsp - send disconnection response message
+ *
+ * @cl: client
+ * @cb: callback block.
+ * @slots: free slots.
+ * @cmpl_list: complete list.
+ *
+ * returns 0, OK; otherwise, error.
+ */
+static int mei_cl_irq_disconnect_rsp(struct mei_cl *cl, struct mei_cl_cb *cb,
+                       s32 *slots, struct mei_cl_cb *cmpl_list)
+{
+       struct mei_device *dev = cl->dev;
+       int ret;
+
+       u32 msg_slots =
+               mei_data2slots(sizeof(struct hbm_client_connect_response));
+
+       if (*slots < msg_slots)
+               return -EMSGSIZE;
+
+       *slots -= msg_slots;
+
+       ret = mei_hbm_cl_disconnect_rsp(dev, cl);
+
+       cl->state = MEI_FILE_DISCONNECTED;
+       cl->status = 0;
+       mei_io_cb_free(cb);
+
+       return ret;
+}
+
+
+
 /**
  * mei_cl_irq_close - processes close related operation from
  *     interrupt thread context - send disconnect request
@@ -452,12 +487,6 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
                wake_up_interruptible(&dev->wait_stop_wd);
        }
 
-       if (dev->wr_ext_msg.hdr.length) {
-               mei_write_message(dev, &dev->wr_ext_msg.hdr,
-                               dev->wr_ext_msg.data);
-               slots -= mei_data2slots(dev->wr_ext_msg.hdr.length);
-               dev->wr_ext_msg.hdr.length = 0;
-       }
        if (dev->dev_state == MEI_DEV_ENABLED) {
                if (dev->wd_pending &&
                    mei_cl_flow_ctrl_creds(&dev->wd_cl) > 0) {
@@ -505,7 +534,11 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
                                return ret;
 
                        break;
-
+               case MEI_FOP_DISCONNECT_RSP:
+                       /* send disconnect resp */
+                       ret = mei_cl_irq_disconnect_rsp(cl, cb, &slots, cmpl_list);
+                       if (ret)
+                               return ret;
                default:
                        BUG();
                }
index f2c949ef3f2850c69d78965ec68aa912ebbc45dd..21e52496bc6e68301ffcd0e33f6a275a676a5dd5 100644 (file)
@@ -133,6 +133,7 @@ enum mei_wd_states {
  * @MEI_FOP_READ      - read
  * @MEI_FOP_WRITE     - write
  * @MEI_FOP_CONNECT   - connect
+ * @MEI_FOP_DISCONNECT_RSP - disconnect response
  * @MEI_FOP_OPEN      - open
  * @MEI_FOP_CLOSE     - close
  */
@@ -140,6 +141,7 @@ enum mei_cb_file_ops {
        MEI_FOP_READ = 0,
        MEI_FOP_WRITE,
        MEI_FOP_CONNECT,
+       MEI_FOP_DISCONNECT_RSP,
        MEI_FOP_OPEN,
        MEI_FOP_CLOSE
 };
@@ -339,7 +341,6 @@ struct mei_cl_device {
  * @hbuf_depth - depth of hardware host/write buffer is slots
  * @hbuf_is_ready - query if the host host/write buffer is ready
  * @wr_msg - the buffer for hbm control messages
- * @wr_ext_msg - the buffer for hbm control responses (set in read cycle)
  */
 struct mei_device {
        struct pci_dev *pdev;   /* pointer to pci device struct */
@@ -394,11 +395,6 @@ struct mei_device {
                unsigned char data[128];
        } wr_msg;
 
-       struct {
-               struct mei_msg_hdr hdr;
-               unsigned char data[4];  /* All HBM messages are 4 bytes */
-       } wr_ext_msg;           /* for control responses */
-
        struct hbm_version version;
 
        struct mei_me_client *me_clients; /* Note: memory has to be allocated */