aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2012-11-01 15:17:14 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-01 15:31:19 -0400
commit3870c3206b96c900ce29c8068bd5ad46fae71f5b (patch)
treefdf26b80c5b67b758afbe7d1d4814b2f8f56b843 /drivers
parentb0d0cf77e72a9d233015f8f21e9dfc9d9b5d0711 (diff)
mei: normalize timeouts definitions
1. The hardware book defines timeouts in seconds so we stick to this and define the wrapper function mei_secs_to_jiffies around msecs_to_jiffies to use be used instead multiplying by HZ 2. We add name space prefix MEI_ to all timer defines Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/mei/hw.h14
-rw-r--r--drivers/misc/mei/init.c18
-rw-r--r--drivers/misc/mei/interrupt.c4
-rw-r--r--drivers/misc/mei/iorw.c8
-rw-r--r--drivers/misc/mei/main.c2
-rw-r--r--drivers/misc/mei/mei_dev.h5
-rw-r--r--drivers/misc/mei/wd.c2
7 files changed, 29 insertions, 24 deletions
diff --git a/drivers/misc/mei/hw.h b/drivers/misc/mei/hw.h
index 9700532f02f6..f21721aa4dc1 100644
--- a/drivers/misc/mei/hw.h
+++ b/drivers/misc/mei/hw.h
@@ -20,16 +20,16 @@
20#include <linux/uuid.h> 20#include <linux/uuid.h>
21 21
22/* 22/*
23 * Timeouts 23 * Timeouts in Seconds
24 */ 24 */
25#define MEI_INTEROP_TIMEOUT (HZ * 7) 25#define MEI_INTEROP_TIMEOUT 7 /* Timeout on ready message */
26#define MEI_CONNECT_TIMEOUT 3 /* at least 2 seconds */ 26#define MEI_CONNECT_TIMEOUT 3 /* HPS: at least 2 seconds */
27 27
28#define CONNECT_TIMEOUT 15 /* HPS definition */ 28#define MEI_CL_CONNECT_TIMEOUT 15 /* HPS: Client Connect Timeout */
29#define INIT_CLIENTS_TIMEOUT 15 /* HPS definition */ 29#define MEI_CLIENTS_INIT_TIMEOUT 15 /* HPS: Clients Enumeration Timeout */
30 30
31#define IAMTHIF_STALL_TIMER 12 /* seconds */ 31#define MEI_IAMTHIF_STALL_TIMER 12 /* HPS */
32#define IAMTHIF_READ_TIMER 10000 /* ms */ 32#define MEI_IAMTHIF_READ_TIMER 10 /* HPS */
33 33
34/* 34/*
35 * Internal Clients Number 35 * Internal Clients Number
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index 1f13eb97a10a..e6951ec4840f 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -184,7 +184,8 @@ int mei_hw_init(struct mei_device *dev)
184 if (!dev->recvd_msg) { 184 if (!dev->recvd_msg) {
185 mutex_unlock(&dev->device_lock); 185 mutex_unlock(&dev->device_lock);
186 err = wait_event_interruptible_timeout(dev->wait_recvd_msg, 186 err = wait_event_interruptible_timeout(dev->wait_recvd_msg,
187 dev->recvd_msg, MEI_INTEROP_TIMEOUT); 187 dev->recvd_msg,
188 mei_secs_to_jiffies(MEI_INTEROP_TIMEOUT));
188 mutex_lock(&dev->device_lock); 189 mutex_lock(&dev->device_lock);
189 } 190 }
190 191
@@ -381,7 +382,7 @@ void mei_host_start_message(struct mei_device *dev)
381 mei_reset(dev, 1); 382 mei_reset(dev, 1);
382 } 383 }
383 dev->init_clients_state = MEI_START_MESSAGE; 384 dev->init_clients_state = MEI_START_MESSAGE;
384 dev->init_clients_timer = INIT_CLIENTS_TIMEOUT; 385 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
385 return ; 386 return ;
386} 387}
387 388
@@ -414,7 +415,7 @@ void mei_host_enum_clients_message(struct mei_device *dev)
414 mei_reset(dev, 1); 415 mei_reset(dev, 1);
415 } 416 }
416 dev->init_clients_state = MEI_ENUM_CLIENTS_MESSAGE; 417 dev->init_clients_state = MEI_ENUM_CLIENTS_MESSAGE;
417 dev->init_clients_timer = INIT_CLIENTS_TIMEOUT; 418 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
418 return; 419 return;
419} 420}
420 421
@@ -502,7 +503,7 @@ int mei_host_client_properties(struct mei_device *dev)
502 return -EIO; 503 return -EIO;
503 } 504 }
504 505
505 dev->init_clients_timer = INIT_CLIENTS_TIMEOUT; 506 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
506 dev->me_client_index = b; 507 dev->me_client_index = b;
507 return 1; 508 return 1;
508 } 509 }
@@ -621,7 +622,7 @@ void mei_host_init_iamthif(struct mei_device *dev)
621 dev->iamthif_cl.state = MEI_FILE_DISCONNECTED; 622 dev->iamthif_cl.state = MEI_FILE_DISCONNECTED;
622 dev->iamthif_cl.host_client_id = 0; 623 dev->iamthif_cl.host_client_id = 0;
623 } else { 624 } else {
624 dev->iamthif_cl.timer_count = CONNECT_TIMEOUT; 625 dev->iamthif_cl.timer_count = MEI_CONNECT_TIMEOUT;
625 } 626 }
626} 627}
627 628
@@ -658,9 +659,8 @@ struct mei_cl *mei_cl_allocate(struct mei_device *dev)
658 */ 659 */
659int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl) 660int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl)
660{ 661{
661 int rets, err;
662 long timeout = 15; /* 15 seconds */
663 struct mei_cl_cb *cb; 662 struct mei_cl_cb *cb;
663 int rets, err;
664 664
665 if (!dev || !cl) 665 if (!dev || !cl)
666 return -ENODEV; 666 return -ENODEV;
@@ -690,8 +690,8 @@ int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl)
690 mutex_unlock(&dev->device_lock); 690 mutex_unlock(&dev->device_lock);
691 691
692 err = wait_event_timeout(dev->wait_recvd_msg, 692 err = wait_event_timeout(dev->wait_recvd_msg,
693 (MEI_FILE_DISCONNECTED == cl->state), 693 MEI_FILE_DISCONNECTED == cl->state,
694 timeout * HZ); 694 mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT));
695 695
696 mutex_lock(&dev->device_lock); 696 mutex_lock(&dev->device_lock);
697 if (MEI_FILE_DISCONNECTED == cl->state) { 697 if (MEI_FILE_DISCONNECTED == cl->state) {
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 5c65bac2fdec..248f581bde31 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -269,7 +269,7 @@ static int _mei_irq_thread_iamthif_read(struct mei_device *dev, s32 *slots)
269 dev->iamthif_flow_control_pending = false; 269 dev->iamthif_flow_control_pending = false;
270 dev->iamthif_msg_buf_index = 0; 270 dev->iamthif_msg_buf_index = 0;
271 dev->iamthif_msg_buf_size = 0; 271 dev->iamthif_msg_buf_size = 0;
272 dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER; 272 dev->iamthif_stall_timer = MEI_IAMTHIF_STALL_TIMER;
273 dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev); 273 dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
274 return 0; 274 return 0;
275} 275}
@@ -1379,7 +1379,7 @@ void mei_timer(struct work_struct *work)
1379 if (dev->iamthif_timer) { 1379 if (dev->iamthif_timer) {
1380 1380
1381 timeout = dev->iamthif_timer + 1381 timeout = dev->iamthif_timer +
1382 msecs_to_jiffies(IAMTHIF_READ_TIMER); 1382 mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
1383 1383
1384 dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n", 1384 dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
1385 dev->iamthif_timer); 1385 dev->iamthif_timer);
diff --git a/drivers/misc/mei/iorw.c b/drivers/misc/mei/iorw.c
index 541c157f325a..8026cbf755db 100644
--- a/drivers/misc/mei/iorw.c
+++ b/drivers/misc/mei/iorw.c
@@ -173,7 +173,7 @@ int mei_ioctl_connect_client(struct file *file,
173 struct mei_cl *cl; 173 struct mei_cl *cl;
174 struct mei_cl *cl_pos = NULL; 174 struct mei_cl *cl_pos = NULL;
175 struct mei_cl *cl_next = NULL; 175 struct mei_cl *cl_next = NULL;
176 long timeout = CONNECT_TIMEOUT; 176 long timeout = mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT);
177 int i; 177 int i;
178 int err; 178 int err;
179 int rets; 179 int rets;
@@ -291,8 +291,7 @@ int mei_ioctl_connect_client(struct file *file,
291 mutex_unlock(&dev->device_lock); 291 mutex_unlock(&dev->device_lock);
292 err = wait_event_timeout(dev->wait_recvd_msg, 292 err = wait_event_timeout(dev->wait_recvd_msg,
293 (MEI_FILE_CONNECTED == cl->state || 293 (MEI_FILE_CONNECTED == cl->state ||
294 MEI_FILE_DISCONNECTED == cl->state), 294 MEI_FILE_DISCONNECTED == cl->state), timeout);
295 timeout * HZ);
296 295
297 mutex_lock(&dev->device_lock); 296 mutex_lock(&dev->device_lock);
298 if (MEI_FILE_CONNECTED == cl->state) { 297 if (MEI_FILE_CONNECTED == cl->state) {
@@ -415,7 +414,8 @@ int amthi_read(struct mei_device *dev, struct file *file,
415 dev->iamthif_timer = 0; 414 dev->iamthif_timer = 0;
416 415
417 if (cb) { 416 if (cb) {
418 timeout = cb->read_time + msecs_to_jiffies(IAMTHIF_READ_TIMER); 417 timeout = cb->read_time +
418 mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
419 dev_dbg(&dev->pdev->dev, "amthi timeout = %lud\n", 419 dev_dbg(&dev->pdev->dev, "amthi timeout = %lud\n",
420 timeout); 420 timeout);
421 421
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 7a03d772fb11..659727a79012 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -567,7 +567,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
567 567
568 if (write_cb) { 568 if (write_cb) {
569 timeout = write_cb->read_time + 569 timeout = write_cb->read_time +
570 msecs_to_jiffies(IAMTHIF_READ_TIMER); 570 mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
571 571
572 if (time_after(jiffies, timeout) || 572 if (time_after(jiffies, timeout) ||
573 cl->reading_state == MEI_READ_COMPLETE) { 573 cl->reading_state == MEI_READ_COMPLETE) {
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 6adcb3f6621a..32c951ab1221 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -270,6 +270,11 @@ struct mei_device {
270 bool iamthif_canceled; 270 bool iamthif_canceled;
271}; 271};
272 272
273static inline unsigned long mei_secs_to_jiffies(unsigned long sec)
274{
275 return msecs_to_jiffies(sec * MSEC_PER_SEC);
276}
277
273 278
274/* 279/*
275 * mei init function prototypes 280 * mei init function prototypes
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
index d96c537f046f..8edb054d4b36 100644
--- a/drivers/misc/mei/wd.c
+++ b/drivers/misc/mei/wd.c
@@ -85,7 +85,7 @@ int mei_wd_host_init(struct mei_device *dev)
85 dev->wd_cl.host_client_id = 0; 85 dev->wd_cl.host_client_id = 0;
86 return -EIO; 86 return -EIO;
87 } 87 }
88 dev->wd_cl.timer_count = CONNECT_TIMEOUT; 88 dev->wd_cl.timer_count = MEI_CONNECT_TIMEOUT;
89 89
90 return 0; 90 return 0;
91} 91}