From 10520528fee29f29ec3d4d3f651294247b07c0a9 Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Wed, 12 Nov 2014 15:17:51 -0600 Subject: [PATCH] greybus: fix request timeout bug This commit changed the timeout behavior for operations: 6a8732e operation: make the timeout a per-operation thing... It unfortunately left in place some code that was only appropriate for per-connection timeouts. In particular, the timer for an operation is currently getting started only if no existing operations are in flight. Fix that oversight, and schedule an operation's timer unconditionally. Signed-off-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/operation.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c index 302ab00..beac353 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -65,31 +65,16 @@ static void gb_operation_insert(struct gb_operation *operation) struct rb_node *above = NULL; struct gb_operation_msg_hdr *header; unsigned long timeout; - bool start_timer; - __le16 wire_id; - /* - * Assign the operation's id, and store it in the header of - * both request and response message headers. + /* Assign the operation's id, and store it in the header of + * the request message header. */ operation->id = gb_connection_operation_id(connection); - wire_id = cpu_to_le16(operation->id); header = operation->request->transfer_buffer; - header->id = wire_id; + header->id = cpu_to_le16(operation->id); - /* OK, insert the operation into its connection's tree */ + /* OK, insert the operation into its connection's pending tree */ spin_lock_irq(&gb_operations_lock); - - /* - * We impose a time limit for requests to complete. If - * there are no requests pending there is no need for a - * timer. So if this will be the only one in flight we'll - * need to start the timer. Otherwise we just update the - * existing one to give this request a full timeout period - * to complete. - */ - start_timer = RB_EMPTY_ROOT(root); - while (*link) { struct gb_operation *other; @@ -105,11 +90,9 @@ static void gb_operation_insert(struct gb_operation *operation) rb_insert_color(node, root); spin_unlock_irq(&gb_operations_lock); + /* We impose a time limit for requests to complete. */ timeout = msecs_to_jiffies(OPERATION_TIMEOUT_DEFAULT); - if (start_timer) - schedule_delayed_work(&operation->timeout_work, timeout); - else - mod_delayed_work(system_wq, &operation->timeout_work, timeout); + schedule_delayed_work(&operation->timeout_work, timeout); } static void gb_operation_remove(struct gb_operation *operation) -- 2.7.4