lists.linaro.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
List overview
Download
greybus-dev
February 2017
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
greybus-dev@lists.linaro.org
14 participants
13 discussions
Start a n
N
ew thread
[PATCH] staging: greybus: operation: add generic timeout support
by Johan Hovold
Add a struct timer_list to struct gb_operation and use that to implement generic operation timeouts. This simplifies the synchronous operation handling somewhat while also providing a generic timeout mechanism that drivers can use for asynchronous operations. Signed-off-by: Johan Hovold <johan(a)kernel.org> --- drivers/staging/greybus/loopback.c | 1 + drivers/staging/greybus/operation.c | 50 ++++++++++++++++++++++++++----------- drivers/staging/greybus/operation.h | 2 ++ 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 6c2a41c638c3..4bee33f62fd4 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -629,6 +629,7 @@ static int gb_loopback_async_operation(struct gb_loopback *gb, int type, mutex_lock(&gb->mutex); ret = gb_operation_request_send(operation, gb_loopback_async_operation_callback, + 0, GFP_KERNEL); if (ret) goto error; diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c index 0123109a1070..3023012808d9 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -273,18 +273,40 @@ static void gb_operation_request_handle(struct gb_operation *operation) static void gb_operation_work(struct work_struct *work) { struct gb_operation *operation; + int ret; operation = container_of(work, struct gb_operation, work); - if (gb_operation_is_incoming(operation)) + if (gb_operation_is_incoming(operation)) { gb_operation_request_handle(operation); - else + } else { + ret = del_timer_sync(&operation->timer); + if (!ret) { + /* Cancel request message if scheduled by timeout. */ + if (gb_operation_result(operation) == -ETIMEDOUT) + gb_message_cancel(operation->request); + } + operation->callback(operation); + } gb_operation_put_active(operation); gb_operation_put(operation); } +static void gb_operation_timeout(unsigned long arg) +{ + struct gb_operation *operation = (void *)arg; + + if (gb_operation_result_set(operation, -ETIMEDOUT)) { + /* + * A stuck request message will be cancelled from the + * workqueue. + */ + queue_work(gb_operation_completion_wq, &operation->work); + } +} + static void gb_operation_message_init(struct gb_host_device *hd, struct gb_message *message, u16 operation_id, size_t payload_size, u8 type) @@ -518,6 +540,9 @@ gb_operation_create_common(struct gb_connection *connection, u8 type, gfp_flags)) { goto err_request; } + + setup_timer(&operation->timer, gb_operation_timeout, + (unsigned long)operation); } operation->flags = op_flags; @@ -679,6 +704,7 @@ static void gb_operation_sync_callback(struct gb_operation *operation) * gb_operation_request_send() - send an operation request message * @operation: the operation to initiate * @callback: the operation completion callback + * @timeout: operation timeout in milliseconds, or zero for no timeout * @gfp: the memory flags to use for any allocations * * The caller has filled in any payload so the request message is ready to go. @@ -693,6 +719,7 @@ static void gb_operation_sync_callback(struct gb_operation *operation) */ int gb_operation_request_send(struct gb_operation *operation, gb_operation_callback callback, + unsigned int timeout, gfp_t gfp) { struct gb_connection *connection = operation->connection; @@ -742,6 +769,11 @@ int gb_operation_request_send(struct gb_operation *operation, if (ret) goto err_put_active; + if (timeout) { + operation->timer.expires = jiffies + msecs_to_jiffies(timeout); + add_timer(&operation->timer); + } + return 0; err_put_active: @@ -763,26 +795,16 @@ int gb_operation_request_send_sync_timeout(struct gb_operation *operation, unsigned int timeout) { int ret; - unsigned long timeout_jiffies; ret = gb_operation_request_send(operation, gb_operation_sync_callback, - GFP_KERNEL); + timeout, GFP_KERNEL); if (ret) return ret; - if (timeout) - timeout_jiffies = msecs_to_jiffies(timeout); - else - timeout_jiffies = MAX_SCHEDULE_TIMEOUT; - - ret = wait_for_completion_interruptible_timeout(&operation->completion, - timeout_jiffies); + ret = wait_for_completion_interruptible(&operation->completion); if (ret < 0) { /* Cancel the operation if interrupted */ gb_operation_cancel(operation, -ECANCELED); - } else if (ret == 0) { - /* Cancel the operation if op timed out */ - gb_operation_cancel(operation, -ETIMEDOUT); } return gb_operation_result(operation); diff --git a/drivers/staging/greybus/operation.h b/drivers/staging/greybus/operation.h index de09a2c7de54..7529f01b2529 100644 --- a/drivers/staging/greybus/operation.h +++ b/drivers/staging/greybus/operation.h @@ -98,6 +98,7 @@ struct gb_operation { struct work_struct work; gb_operation_callback callback; struct completion completion; + struct timer_list timer; struct kref kref; atomic_t waiters; @@ -164,6 +165,7 @@ bool gb_operation_response_alloc(struct gb_operation *operation, int gb_operation_request_send(struct gb_operation *operation, gb_operation_callback callback, + unsigned int timeout, gfp_t gfp); int gb_operation_request_send_sync_timeout(struct gb_operation *operation, unsigned int timeout); -- 2.10.2
7 years, 11 months
3
16
0
0
[PATCH] staging: greybus: Move Documentation to Documentation/
by Viresh Kumar
Move all greybus documentation to the top level Documentation/ directory, as that's the obvious place where everyone will look for it. Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org> --- .../Documentation => Documentation/greybus}/firmware/authenticate.c | 0 .../Documentation => Documentation/greybus}/firmware/firmware-management | 0 .../greybus/Documentation => Documentation/greybus}/firmware/firmware.c | 0 .../greybus/Documentation => Documentation/greybus}/sysfs-bus-greybus | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {drivers/staging/greybus/Documentation => Documentation/greybus}/firmware/authenticate.c (100%) rename {drivers/staging/greybus/Documentation => Documentation/greybus}/firmware/firmware-management (100%) rename {drivers/staging/greybus/Documentation => Documentation/greybus}/firmware/firmware.c (100%) rename {drivers/staging/greybus/Documentation => Documentation/greybus}/sysfs-bus-greybus (100%) diff --git a/drivers/staging/greybus/Documentation/firmware/authenticate.c b/Documentation/greybus/firmware/authenticate.c similarity index 100% rename from drivers/staging/greybus/Documentation/firmware/authenticate.c rename to Documentation/greybus/firmware/authenticate.c diff --git a/drivers/staging/greybus/Documentation/firmware/firmware-management b/Documentation/greybus/firmware/firmware-management similarity index 100% rename from drivers/staging/greybus/Documentation/firmware/firmware-management rename to Documentation/greybus/firmware/firmware-management diff --git a/drivers/staging/greybus/Documentation/firmware/firmware.c b/Documentation/greybus/firmware/firmware.c similarity index 100% rename from drivers/staging/greybus/Documentation/firmware/firmware.c rename to Documentation/greybus/firmware/firmware.c diff --git a/drivers/staging/greybus/Documentation/sysfs-bus-greybus b/Documentation/greybus/sysfs-bus-greybus similarity index 100% rename from drivers/staging/greybus/Documentation/sysfs-bus-greybus rename to Documentation/greybus/sysfs-bus-greybus -- 2.7.1.410.g6faf27b
7 years, 11 months
2
2
0
0
[PATCH] [linux-next] staging: greybus: Remove duplicate include file
by Masanari Iida
This patch removed duplicated include line. Signed-off-by: Masanari Iida <standby24x7(a)gmail.com> --- drivers/staging/greybus/authentication.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/greybus/authentication.c b/drivers/staging/greybus/authentication.c index 168626ba0c03..6c5dcb1c226b 100644 --- a/drivers/staging/greybus/authentication.c +++ b/drivers/staging/greybus/authentication.c @@ -16,7 +16,6 @@ #include "greybus_authentication.h" #include "firmware.h" -#include "greybus.h" #define CAP_TIMEOUT_MS 1000 -- 2.11.0.616.g8f60064c1f53
7 years, 11 months
2
1
0
0
← Newer
1
2
Older →
Jump to page:
1
2
Results per page:
10
25
50
100
200