* Re: [PATCH] greybus: operation: arm the timeout timer before sending the request
2026-10-17 17:17 [PATCH] greybus: operation: arm the timeout timer before sending the request Nguyen Ngoc Thang
@ 2026-10-18 6:47 ` Greg Kroah-Hartman
2026-10-18 6:52 ` kernel test robot
2026-10-18 9:27 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-10-18 6:47 UTC (permalink / raw)
To: Nguyen Ngoc Thang
Cc: Johan Hovold, Alex Elder, greybus-dev, linux-kernel, stable,
syzbot+a2e50fb40695811c2dab
On Sun, Oct 18, 2026 at 12:17:43AM +0700, Nguyen Ngoc Thang wrote:
> gb_operation_request_send() sends the request message and only then arms
> the operation timer. The host driver can complete the operation before
> add_timer() runs, e.g. when the transfer fails right away. The completion
> work then calls timer_delete_sync() on a timer that is not armed yet,
> the synchronous caller wakes up and drops the last reference, and
> the operation is freed while the timer is still pending:
>
> ODEBUG: free active (active state 0) object type: timer_list
> hint: gb_operation_timeout+0x0/0xc0
> WARNING: lib/debugobjects.c:629 at debug_print_object+0x198/0x2b0
> kmem_cache_free+0xfd/0x6d0
> gb_operation_sync_timeout+0x1c7/0x270
> gb_svc_process_deferred_request+0x5f3/0x1150
How was this generated and tested?
> Arm the timer before the message is sent. If sending fails, delete the
> timer again. If it has already fired, its work is queued and drops the
> active and operation references itself, so the error path must not drop
> them a second time.
>
> Fixes: dbec27298b0d ("staging: greybus: operation: add generic timeout support")
> Cc: stable@vger.kernel.org
> Reported-by: syzbot+a2e50fb40695811c2dab@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=a2e50fb40695811c2dab
> Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
> ---
> drivers/greybus/operation.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/greybus/operation.c b/drivers/greybus/operation.c
> index 7e12ffb2dd60..19b0cdeca498 100644
> --- a/drivers/greybus/operation.c
> +++ b/drivers/greybus/operation.c
> @@ -766,17 +766,22 @@ int gb_operation_request_send(struct gb_operation *operation,
> if (ret)
> goto err_put;
>
> - ret = gb_message_send(operation->request, gfp);
> - if (ret)
> - goto err_put_active;
> -
> + /* Arm before sending, as the response may complete the operation at once. */
"Arm" what?
> if (timeout) {
> operation->timer.expires = jiffies + msecs_to_jiffies(timeout);
> add_timer(&operation->timer);
> }
>
> + ret = gb_message_send(operation->request, gfp);
> + if (ret)
> + goto err_del_timer;
> +
> return 0;
>
> +err_del_timer:
> + /* A timer that already fired has queued work which drops our references. */
Why is this comment needed?
> + if (timeout && !timer_delete_sync(&operation->timer))
> + return ret;
Did you just leak this:
> err_put_active:
> gb_operation_put_active(operation);
And again, how was this tested?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] greybus: operation: arm the timeout timer before sending the request
2026-10-17 17:17 [PATCH] greybus: operation: arm the timeout timer before sending the request Nguyen Ngoc Thang
2026-10-18 6:47 ` Greg Kroah-Hartman
@ 2026-10-18 6:52 ` kernel test robot
2026-10-18 9:27 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-10-18 6:52 UTC (permalink / raw)
To: Nguyen Ngoc Thang, Johan Hovold, Alex Elder, Greg Kroah-Hartman
Cc: oe-kbuild-all, greybus-dev, linux-kernel, stable,
syzbot+a2e50fb40695811c2dab, Nguyen Ngoc Thang
Hi Nguyen,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v7.3-rc7 next-20261016]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Nguyen-Ngoc-Thang/greybus-operation-arm-the-timeout-timer-before-sending-the-request/20261018-001743
base: linus/master
patch link: https://lore.kernel.org/r/20261017171743.24612-1-ngocthang2710.1999%40gmail.com
patch subject: [PATCH] greybus: operation: arm the timeout timer before sending the request
config: arc-randconfig-1000-20261018 (https://download.01.org/0day-ci/archive/20261018/202610181452.8uUjB47B-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261018/202610181452.8uUjB47B-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610181452.8uUjB47B-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/greybus/operation.c: In function 'gb_operation_request_send':
>> drivers/greybus/operation.c:785:1: warning: label 'err_put_active' defined but not used [-Wunused-label]
785 | err_put_active:
| ^~~~~~~~~~~~~~
vim +/err_put_active +785 drivers/greybus/operation.c
10c69399043351 drivers/staging/greybus/operation.c Alex Elder 2014-11-21 703
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 704 /**
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 705 * gb_operation_request_send() - send an operation request message
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 706 * @operation: the operation to initiate
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 707 * @callback: the operation completion callback
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 708 * @timeout: operation timeout in milliseconds, or zero for no timeout
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 709 * @gfp: the memory flags to use for any allocations
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 710 *
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 711 * The caller has filled in any payload so the request message is ready to go.
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 712 * The callback function supplied will be called when the response message has
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 713 * arrived, a unidirectional request has been sent, or the operation is
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 714 * cancelled, indicating that the operation is complete. The callback function
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 715 * can fetch the result of the operation using gb_operation_result() if
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 716 * desired.
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 717 *
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 718 * Return: 0 if the request was successfully queued in the host-driver queues,
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 719 * or a negative errno.
d90c25b0a279b0 drivers/staging/greybus/operation.c Alex Elder 2014-10-16 720 */
d90c25b0a279b0 drivers/staging/greybus/operation.c Alex Elder 2014-10-16 721 int gb_operation_request_send(struct gb_operation *operation,
a52c4352aef855 drivers/staging/greybus/operation.c Johan Hovold 2015-07-01 722 gb_operation_callback callback,
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 723 unsigned int timeout,
a52c4352aef855 drivers/staging/greybus/operation.c Johan Hovold 2015-07-01 724 gfp_t gfp)
d90c25b0a279b0 drivers/staging/greybus/operation.c Alex Elder 2014-10-16 725 {
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 726 struct gb_connection *connection = operation->connection;
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 727 struct gb_operation_msg_hdr *header;
4afb7fd0154753 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 728 unsigned int cycle;
ea2c2ee8057138 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 729 int ret;
d90c25b0a279b0 drivers/staging/greybus/operation.c Alex Elder 2014-10-16 730
ca1f8f809024db drivers/staging/greybus/operation.c Johan Hovold 2016-05-11 731 if (gb_connection_is_offloaded(connection))
ca1f8f809024db drivers/staging/greybus/operation.c Johan Hovold 2016-05-11 732 return -EBUSY;
ca1f8f809024db drivers/staging/greybus/operation.c Johan Hovold 2016-05-11 733
37754030b0b9f7 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 734 if (!callback)
37754030b0b9f7 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 735 return -EINVAL;
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 736
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 737 /*
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 738 * Record the callback function, which is executed in
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 739 * non-atomic (workqueue) context when the final result
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 740 * of an operation has been set.
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 741 */
d90c25b0a279b0 drivers/staging/greybus/operation.c Alex Elder 2014-10-16 742 operation->callback = callback;
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 743
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 744 /*
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 745 * Assign the operation's id, and store it in the request header.
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 746 * Zero is a reserved operation id for unidirectional operations.
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 747 */
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 748 if (gb_operation_is_unidirectional(operation)) {
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 749 operation->id = 0;
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 750 } else {
4afb7fd0154753 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 751 cycle = (unsigned int)atomic_inc_return(&connection->op_cycle);
4afb7fd0154753 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 752 operation->id = (u16)(cycle % U16_MAX + 1);
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 753 }
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 754
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 755 header = operation->request->header;
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 756 header->operation_id = cpu_to_le16(operation->id);
e8b48d1586abd6 drivers/staging/greybus/operation.c Alex Elder 2014-11-20 757
3deb37d4ad04c6 drivers/staging/greybus/operation.c Alex Elder 2014-11-25 758 gb_operation_result_set(operation, -EINPROGRESS);
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 759
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 760 /*
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 761 * Get an extra reference on the operation. It'll be dropped when the
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 762 * operation completes.
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 763 */
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 764 gb_operation_get(operation);
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 765 ret = gb_operation_get_active(operation);
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 766 if (ret)
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 767 goto err_put;
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 768
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 769 /* Arm before sending, as the response may complete the operation at once. */
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 770 if (timeout) {
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 771 operation->timer.expires = jiffies + msecs_to_jiffies(timeout);
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 772 add_timer(&operation->timer);
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 773 }
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 774
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 775 ret = gb_message_send(operation->request, gfp);
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 776 if (ret)
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 777 goto err_del_timer;
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 778
008974cb528d30 drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 779 return 0;
008974cb528d30 drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 780
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 781 err_del_timer:
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 782 /* A timer that already fired has queued work which drops our references. */
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 783 if (timeout && !timer_delete_sync(&operation->timer))
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 784 return ret;
008974cb528d30 drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 @785 err_put_active:
3eeac7e37ce985 drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 786 gb_operation_put_active(operation);
008974cb528d30 drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 787 err_put:
ea2c2ee8057138 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 788 gb_operation_put(operation);
ea2c2ee8057138 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 789
ea2c2ee8057138 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 790 return ret;
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 791 }
1dad6b3515b2ca drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 792 EXPORT_SYMBOL_GPL(gb_operation_request_send);
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 793
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] greybus: operation: arm the timeout timer before sending the request
2026-10-17 17:17 [PATCH] greybus: operation: arm the timeout timer before sending the request Nguyen Ngoc Thang
2026-10-18 6:47 ` Greg Kroah-Hartman
2026-10-18 6:52 ` kernel test robot
@ 2026-10-18 9:27 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-10-18 9:27 UTC (permalink / raw)
To: Nguyen Ngoc Thang, Johan Hovold, Alex Elder, Greg Kroah-Hartman
Cc: llvm, oe-kbuild-all, greybus-dev, linux-kernel, stable,
syzbot+a2e50fb40695811c2dab, Nguyen Ngoc Thang
Hi Nguyen,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v7.3-rc7 next-20261016]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Nguyen-Ngoc-Thang/greybus-operation-arm-the-timeout-timer-before-sending-the-request/20261018-001743
base: linus/master
patch link: https://lore.kernel.org/r/20261017171743.24612-1-ngocthang2710.1999%40gmail.com
patch subject: [PATCH] greybus: operation: arm the timeout timer before sending the request
config: i386-buildonly-randconfig-1000-20261018 (https://download.01.org/0day-ci/archive/20261018/202610181737.03A4hebl-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261018/202610181737.03A4hebl-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610181737.03A4hebl-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/greybus/operation.c:785:1: warning: unused label 'err_put_active' [-Wunused-label]
785 | err_put_active:
| ^~~~~~~~~~~~~~~
1 warning generated.
vim +/err_put_active +785 drivers/greybus/operation.c
10c69399043351 drivers/staging/greybus/operation.c Alex Elder 2014-11-21 703
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 704 /**
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 705 * gb_operation_request_send() - send an operation request message
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 706 * @operation: the operation to initiate
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 707 * @callback: the operation completion callback
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 708 * @timeout: operation timeout in milliseconds, or zero for no timeout
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 709 * @gfp: the memory flags to use for any allocations
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 710 *
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 711 * The caller has filled in any payload so the request message is ready to go.
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 712 * The callback function supplied will be called when the response message has
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 713 * arrived, a unidirectional request has been sent, or the operation is
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 714 * cancelled, indicating that the operation is complete. The callback function
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 715 * can fetch the result of the operation using gb_operation_result() if
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 716 * desired.
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 717 *
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 718 * Return: 0 if the request was successfully queued in the host-driver queues,
613c15e86b7ac3 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 719 * or a negative errno.
d90c25b0a279b0 drivers/staging/greybus/operation.c Alex Elder 2014-10-16 720 */
d90c25b0a279b0 drivers/staging/greybus/operation.c Alex Elder 2014-10-16 721 int gb_operation_request_send(struct gb_operation *operation,
a52c4352aef855 drivers/staging/greybus/operation.c Johan Hovold 2015-07-01 722 gb_operation_callback callback,
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 723 unsigned int timeout,
a52c4352aef855 drivers/staging/greybus/operation.c Johan Hovold 2015-07-01 724 gfp_t gfp)
d90c25b0a279b0 drivers/staging/greybus/operation.c Alex Elder 2014-10-16 725 {
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 726 struct gb_connection *connection = operation->connection;
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 727 struct gb_operation_msg_hdr *header;
4afb7fd0154753 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 728 unsigned int cycle;
ea2c2ee8057138 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 729 int ret;
d90c25b0a279b0 drivers/staging/greybus/operation.c Alex Elder 2014-10-16 730
ca1f8f809024db drivers/staging/greybus/operation.c Johan Hovold 2016-05-11 731 if (gb_connection_is_offloaded(connection))
ca1f8f809024db drivers/staging/greybus/operation.c Johan Hovold 2016-05-11 732 return -EBUSY;
ca1f8f809024db drivers/staging/greybus/operation.c Johan Hovold 2016-05-11 733
37754030b0b9f7 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 734 if (!callback)
37754030b0b9f7 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 735 return -EINVAL;
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 736
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 737 /*
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 738 * Record the callback function, which is executed in
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 739 * non-atomic (workqueue) context when the final result
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 740 * of an operation has been set.
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 741 */
d90c25b0a279b0 drivers/staging/greybus/operation.c Alex Elder 2014-10-16 742 operation->callback = callback;
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 743
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 744 /*
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 745 * Assign the operation's id, and store it in the request header.
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 746 * Zero is a reserved operation id for unidirectional operations.
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 747 */
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 748 if (gb_operation_is_unidirectional(operation)) {
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 749 operation->id = 0;
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 750 } else {
4afb7fd0154753 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 751 cycle = (unsigned int)atomic_inc_return(&connection->op_cycle);
4afb7fd0154753 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 752 operation->id = (u16)(cycle % U16_MAX + 1);
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 753 }
3e2ee2c1e50541 drivers/staging/greybus/operation.c Johan Hovold 2016-04-29 754
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 755 header = operation->request->header;
afb2e1342e75b5 drivers/staging/greybus/operation.c Alex Elder 2014-12-03 756 header->operation_id = cpu_to_le16(operation->id);
e8b48d1586abd6 drivers/staging/greybus/operation.c Alex Elder 2014-11-20 757
3deb37d4ad04c6 drivers/staging/greybus/operation.c Alex Elder 2014-11-25 758 gb_operation_result_set(operation, -EINPROGRESS);
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 759
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 760 /*
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 761 * Get an extra reference on the operation. It'll be dropped when the
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 762 * operation completes.
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 763 */
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 764 gb_operation_get(operation);
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 765 ret = gb_operation_get_active(operation);
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 766 if (ret)
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 767 goto err_put;
3325a4ad7122ac drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 768
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 769 /* Arm before sending, as the response may complete the operation at once. */
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 770 if (timeout) {
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 771 operation->timer.expires = jiffies + msecs_to_jiffies(timeout);
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 772 add_timer(&operation->timer);
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 773 }
dbec27298b0df8 drivers/staging/greybus/operation.c Johan Hovold 2017-01-23 774
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 775 ret = gb_message_send(operation->request, gfp);
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 776 if (ret)
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 777 goto err_del_timer;
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 778
008974cb528d30 drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 779 return 0;
008974cb528d30 drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 780
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 781 err_del_timer:
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 782 /* A timer that already fired has queued work which drops our references. */
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 783 if (timeout && !timer_delete_sync(&operation->timer))
7a8e53d4f57e9c drivers/greybus/operation.c Nguyen Ngoc Thang 2026-10-18 784 return ret;
008974cb528d30 drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 @785 err_put_active:
3eeac7e37ce985 drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 786 gb_operation_put_active(operation);
008974cb528d30 drivers/staging/greybus/operation.c Johan Hovold 2015-07-14 787 err_put:
ea2c2ee8057138 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 788 gb_operation_put(operation);
ea2c2ee8057138 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 789
ea2c2ee8057138 drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 790 return ret;
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 791 }
1dad6b3515b2ca drivers/staging/greybus/operation.c Johan Hovold 2015-03-27 792 EXPORT_SYMBOL_GPL(gb_operation_request_send);
c25572ca943a1f drivers/staging/greybus/operation.c Alex Elder 2014-12-03 793
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread