Commit 10520528 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

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: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3e9cb4a1
...@@ -65,31 +65,16 @@ static void gb_operation_insert(struct gb_operation *operation) ...@@ -65,31 +65,16 @@ static void gb_operation_insert(struct gb_operation *operation)
struct rb_node *above = NULL; struct rb_node *above = NULL;
struct gb_operation_msg_hdr *header; struct gb_operation_msg_hdr *header;
unsigned long timeout; unsigned long timeout;
bool start_timer;
__le16 wire_id;
/* /* Assign the operation's id, and store it in the header of
* Assign the operation's id, and store it in the header of * the request message header.
* both request and response message headers.
*/ */
operation->id = gb_connection_operation_id(connection); operation->id = gb_connection_operation_id(connection);
wire_id = cpu_to_le16(operation->id);
header = operation->request->transfer_buffer; 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); 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) { while (*link) {
struct gb_operation *other; struct gb_operation *other;
...@@ -105,11 +90,9 @@ static void gb_operation_insert(struct gb_operation *operation) ...@@ -105,11 +90,9 @@ static void gb_operation_insert(struct gb_operation *operation)
rb_insert_color(node, root); rb_insert_color(node, root);
spin_unlock_irq(&gb_operations_lock); spin_unlock_irq(&gb_operations_lock);
/* We impose a time limit for requests to complete. */
timeout = msecs_to_jiffies(OPERATION_TIMEOUT_DEFAULT); timeout = msecs_to_jiffies(OPERATION_TIMEOUT_DEFAULT);
if (start_timer)
schedule_delayed_work(&operation->timeout_work, timeout); schedule_delayed_work(&operation->timeout_work, timeout);
else
mod_delayed_work(system_wq, &operation->timeout_work, timeout);
} }
static void gb_operation_remove(struct gb_operation *operation) static void gb_operation_remove(struct gb_operation *operation)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment