mei: amthif: don't drop read packets on timeout
authorAlexander Usyskin <alexander.usyskin@intel.com>
Sun, 7 Feb 2016 21:35:22 +0000 (23:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 7 Feb 2016 22:47:20 +0000 (14:47 -0800)
Since the driver now uses a list for storing read packets instead of
single variable a pending read is no longer blocking other connections.
A pending read will be discarded up the file closure.

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>
drivers/misc/mei/amthif.c
drivers/misc/mei/hw.h
drivers/misc/mei/interrupt.c
drivers/misc/mei/main.c
drivers/misc/mei/mei_dev.h

index c3f514027c80e3ac2bcff69fe8e80711b316cb85..5da1654bc2092e3179ec1f9154edd61a245a5a8d 100644 (file)
@@ -50,7 +50,6 @@ void mei_amthif_reset_params(struct mei_device *dev)
        dev->iamthif_current_cb = NULL;
        dev->iamthif_canceled = false;
        dev->iamthif_state = MEI_IAMTHIF_IDLE;
-       dev->iamthif_timer = 0;
        dev->iamthif_stall_timer = 0;
        dev->iamthif_open_count = 0;
 }
@@ -124,18 +123,10 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
 int mei_amthif_read(struct mei_device *dev, struct file *file,
               char __user *ubuf, size_t length, loff_t *offset)
 {
-       struct mei_cl *cl = file->private_data;
        struct mei_cl_cb *cb;
-       unsigned long timeout;
        int rets;
        int wait_ret;
 
-       /* Only possible if we are in timeout */
-       if (!cl) {
-               dev_err(dev->dev, "bad file ext.\n");
-               return -ETIME;
-       }
-
        dev_dbg(dev->dev, "checking amthif data\n");
        cb = mei_amthif_find_read_list_entry(dev, file);
 
@@ -168,20 +159,6 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
        }
 
        dev_dbg(dev->dev, "Got amthif data\n");
-       dev->iamthif_timer = 0;
-
-       timeout = cb->read_time +
-               mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
-       dev_dbg(dev->dev, "amthif timeout = %lud\n",
-                       timeout);
-
-       if  (time_after(jiffies, timeout)) {
-               dev_dbg(dev->dev, "amthif Time out\n");
-               /* 15 sec for the message has expired */
-               list_del_init(&cb->list);
-               rets = -ETIME;
-               goto free;
-       }
        /* if the whole message will fit remove it from the list */
        if (cb->buf_idx >= *offset && length >= (cb->buf_idx - *offset))
                list_del_init(&cb->list);
@@ -303,7 +280,6 @@ int mei_amthif_run_next_cmd(struct mei_device *dev)
 
        dev->iamthif_canceled = false;
        dev->iamthif_state = MEI_IAMTHIF_IDLE;
-       dev->iamthif_timer = 0;
        dev->iamthif_file_object = NULL;
 
        dev_dbg(dev->dev, "complete amthif cmd_list cb.\n");
@@ -462,9 +438,6 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)
                dev->iamthif_stall_timer = 0;
                list_add_tail(&cb->list, &dev->amthif_rd_complete_list.list);
                dev_dbg(dev->dev, "amthif read completed\n");
-               dev->iamthif_timer = jiffies;
-               dev_dbg(dev->dev, "dev->iamthif_timer = %ld\n",
-                       dev->iamthif_timer);
        } else {
                mei_amthif_run_next_cmd(dev);
        }
index 4cebde85924f8f33085b45e27b7df8deae17ada5..4c5d6cfd79b4f254f974f01c0b0c7df88fa2f700 100644 (file)
@@ -29,7 +29,6 @@
 #define MEI_CLIENTS_INIT_TIMEOUT   15  /* HPS: Clients Enumeration Timeout */
 
 #define MEI_IAMTHIF_STALL_TIMER    12  /* HPS */
-#define MEI_IAMTHIF_READ_TIMER     10  /* HPS */
 
 #define MEI_PGI_TIMEOUT             1  /* PG Isolation time response 1 sec */
 #define MEI_D0I3_TIMEOUT            5  /* D0i3 set/unset max response time */
index b8aa047ec2585d967d8888fee3e08d361a5018e6..78978193d19be5e7b1cb1df67f7d4c388b02e608 100644 (file)
@@ -156,7 +156,6 @@ int mei_cl_irq_read_msg(struct mei_cl *cl,
        cb->buf_idx += mei_hdr->length;
 
        if (mei_hdr->msg_complete) {
-               cb->read_time = jiffies;
                cl_dbg(dev, cl, "completed read length = %lu\n", cb->buf_idx);
                list_move_tail(&cb->list, &complete_list->list);
        } else {
@@ -458,7 +457,6 @@ static void mei_connect_timeout(struct mei_cl *cl)
  */
 void mei_timer(struct work_struct *work)
 {
-       unsigned long timeout;
        struct mei_cl *cl;
 
        struct mei_device *dev = container_of(work,
@@ -504,7 +502,6 @@ void mei_timer(struct work_struct *work)
                        mei_reset(dev);
                        dev->iamthif_canceled = false;
                        dev->iamthif_state = MEI_IAMTHIF_IDLE;
-                       dev->iamthif_timer = 0;
 
                        mei_io_cb_free(dev->iamthif_current_cb);
                        dev->iamthif_current_cb = NULL;
@@ -514,35 +511,6 @@ void mei_timer(struct work_struct *work)
                }
        }
 
-       if (dev->iamthif_timer) {
-
-               timeout = dev->iamthif_timer +
-                       mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
-
-               dev_dbg(dev->dev, "dev->iamthif_timer = %ld\n",
-                               dev->iamthif_timer);
-               dev_dbg(dev->dev, "timeout = %ld\n", timeout);
-               dev_dbg(dev->dev, "jiffies = %ld\n", jiffies);
-               if (time_after(jiffies, timeout)) {
-                       /*
-                        * User didn't read the AMTHI data on time (15sec)
-                        * freeing AMTHI for other requests
-                        */
-
-                       dev_dbg(dev->dev, "freeing AMTHI for other requests\n");
-
-                       mei_io_list_flush(&dev->amthif_rd_complete_list,
-                               &dev->iamthif_cl);
-                       mei_io_cb_free(dev->iamthif_current_cb);
-                       dev->iamthif_current_cb = NULL;
-
-                       dev->iamthif_file_object->private_data = NULL;
-                       dev->iamthif_file_object = NULL;
-                       dev->iamthif_timer = 0;
-                       mei_amthif_run_next_cmd(dev);
-
-               }
-       }
 out:
        if (dev->dev_state != MEI_DEV_DISABLED)
                schedule_delayed_work(&dev->timer_work, 2 * HZ);
index 47dc6d9ae6554885e5459f9ebe750838546cc24d..5f2b63460d8820b899e9d782eb18751a91ed22ef 100644 (file)
@@ -274,7 +274,6 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
        struct mei_cl *cl = file->private_data;
        struct mei_cl_cb *write_cb = NULL;
        struct mei_device *dev;
-       unsigned long timeout = 0;
        int rets;
 
        if (WARN_ON(!cl || !cl->dev))
@@ -310,21 +309,6 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
                goto out;
        }
 
-       if (cl == &dev->iamthif_cl) {
-               write_cb = mei_amthif_find_read_list_entry(dev, file);
-
-               if (write_cb) {
-                       timeout = write_cb->read_time +
-                               mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
-
-                       if (time_after(jiffies, timeout)) {
-                               *offset = 0;
-                               mei_io_cb_free(write_cb);
-                               write_cb = NULL;
-                       }
-               }
-       }
-
        *offset = 0;
        write_cb = mei_cl_alloc_cb(cl, length, MEI_FOP_WRITE, file);
        if (!write_cb) {
index 9b793f87b7d471d8a1b974639edf9b505412794e..4d0e066703ef57d7b0fcec4d67dd644fefaae0a4 100644 (file)
@@ -179,7 +179,6 @@ struct mei_cl;
  * @fop_type: file operation type
  * @buf: buffer for data associated with the callback
  * @buf_idx: last read index
- * @read_time: last read operation time stamp (iamthif)
  * @file_object: pointer to file structure
  * @status: io status of the cb
  * @internal: communication between driver and FW flag
@@ -191,7 +190,6 @@ struct mei_cl_cb {
        enum mei_cb_file_ops fop_type;
        struct mei_msg_data buf;
        size_t buf_idx;
-       unsigned long read_time;
        struct file *file_object;
        int status;
        u32 internal:1;
@@ -413,7 +411,6 @@ const char *mei_pg_state_str(enum mei_pg_state state);
  * @iamthif_cl  : amthif host client
  * @iamthif_current_cb : amthif current operation callback
  * @iamthif_open_count : number of opened amthif connections
- * @iamthif_timer : time stamp of current amthif command completion
  * @iamthif_stall_timer : timer to detect amthif hang
  * @iamthif_state : amthif processor state
  * @iamthif_canceled : current amthif command is canceled
@@ -504,7 +501,6 @@ struct mei_device {
        struct mei_cl iamthif_cl;
        struct mei_cl_cb *iamthif_current_cb;
        long iamthif_open_count;
-       unsigned long iamthif_timer;
        u32 iamthif_stall_timer;
        enum iamthif_states iamthif_state;
        bool iamthif_canceled;