* [RFC] Bluetooth: hci_sync: Add hci_cmd_sync_queue_once
@ 2023-08-09 21:39 Luiz Augusto von Dentz
2023-08-09 22:35 ` bluez.test.bot
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2023-08-09 21:39 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds hci_cmd_sync_queue_once which can be used for callback that
shall be schedule only once.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
include/net/bluetooth/hci_sync.h | 5 +++
net/bluetooth/hci_sync.c | 56 +++++++++++++++++++++++++++-----
2 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/include/net/bluetooth/hci_sync.h b/include/net/bluetooth/hci_sync.h
index 57eeb07aeb25..3d2ffcb6c461 100644
--- a/include/net/bluetooth/hci_sync.h
+++ b/include/net/bluetooth/hci_sync.h
@@ -48,6 +48,11 @@ int hci_cmd_sync_submit(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
void *data, hci_cmd_sync_work_destroy_t destroy);
int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
void *data, hci_cmd_sync_work_destroy_t destroy);
+bool hci_cmd_sync_lookup(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
+ void *data, hci_cmd_sync_work_destroy_t destroy,
+ bool cancel);
+int hci_cmd_sync_queue_once(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
+ void *data, hci_cmd_sync_work_destroy_t destroy);
int hci_update_eir_sync(struct hci_dev *hdev);
int hci_update_class_sync(struct hci_dev *hdev);
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 5eb30ba21370..32fa9006f381 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -639,6 +639,17 @@ void hci_cmd_sync_init(struct hci_dev *hdev)
INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire);
}
+static void _hci_cmd_sync_cancel_entry(struct hci_dev *hdev,
+ struct hci_cmd_sync_work_entry *entry,
+ int err)
+{
+ if (entry->destroy)
+ entry->destroy(hdev, entry->data, err);
+
+ list_del(&entry->list);
+ kfree(entry);
+}
+
void hci_cmd_sync_clear(struct hci_dev *hdev)
{
struct hci_cmd_sync_work_entry *entry, *tmp;
@@ -647,13 +658,8 @@ void hci_cmd_sync_clear(struct hci_dev *hdev)
cancel_work_sync(&hdev->reenable_adv_work);
mutex_lock(&hdev->cmd_sync_work_lock);
- list_for_each_entry_safe(entry, tmp, &hdev->cmd_sync_work_list, list) {
- if (entry->destroy)
- entry->destroy(hdev, entry->data, -ECANCELED);
-
- list_del(&entry->list);
- kfree(entry);
- }
+ list_for_each_entry_safe(entry, tmp, &hdev->cmd_sync_work_list, list)
+ _hci_cmd_sync_cancel_entry(hdev, entry, -ECANCELED);
mutex_unlock(&hdev->cmd_sync_work_lock);
}
@@ -740,6 +746,39 @@ int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
}
EXPORT_SYMBOL(hci_cmd_sync_queue);
+bool hci_cmd_sync_lookup(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
+ void *data, hci_cmd_sync_work_destroy_t destroy,
+ bool cancel)
+{
+ struct hci_cmd_sync_work_entry *entry, *tmp;
+
+ mutex_lock(&hdev->cmd_sync_work_lock);
+ list_for_each_entry_safe(entry, tmp, &hdev->cmd_sync_work_list, list) {
+ if (entry->func == func && entry->data == data &&
+ entry->destroy == destroy) {
+ if (cancel)
+ _hci_cmd_sync_cancel_entry(hdev, entry,
+ -ECANCELED);
+ mutex_unlock(&hdev->cmd_sync_work_lock);
+ return true;
+ }
+ }
+ mutex_unlock(&hdev->cmd_sync_work_lock);
+
+ return false;
+}
+EXPORT_SYMBOL(hci_cmd_sync_pending);
+
+int hci_cmd_sync_queue_once(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
+ void *data, hci_cmd_sync_work_destroy_t destroy)
+{
+ if (hci_cmd_sync_lookup(hdev, func, data, destroy, false))
+ return 0;
+
+ return hci_cmd_sync_queue(hdev, func, data, destroy);
+}
+EXPORT_SYMBOL(hci_cmd_sync_queue_once);
+
int hci_update_eir_sync(struct hci_dev *hdev)
{
struct hci_cp_write_eir cp;
@@ -2949,7 +2988,8 @@ int hci_update_passive_scan(struct hci_dev *hdev)
hci_dev_test_flag(hdev, HCI_UNREGISTER))
return 0;
- return hci_cmd_sync_queue(hdev, update_passive_scan_sync, NULL, NULL);
+ return hci_cmd_sync_queue_once(hdev, update_passive_scan_sync, NULL,
+ NULL);
}
int hci_write_sc_support_sync(struct hci_dev *hdev, u8 val)
--
2.41.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* RE: [RFC] Bluetooth: hci_sync: Add hci_cmd_sync_queue_once
2023-08-09 21:39 [RFC] Bluetooth: hci_sync: Add hci_cmd_sync_queue_once Luiz Augusto von Dentz
@ 2023-08-09 22:35 ` bluez.test.bot
2023-08-09 23:26 ` kernel test robot
2023-08-10 0:28 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2023-08-09 22:35 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 1427 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=774703
---Test result---
Test Summary:
CheckPatch PASS 0.97 seconds
GitLint PASS 0.37 seconds
SubjectPrefix PASS 0.14 seconds
BuildKernel PASS 34.36 seconds
CheckAllWarning PASS 37.62 seconds
CheckSparse PASS 42.89 seconds
CheckSmatch PASS 114.80 seconds
BuildKernel32 PASS 32.97 seconds
TestRunnerSetup PASS 500.42 seconds
TestRunner_l2cap-tester PASS 23.92 seconds
TestRunner_iso-tester PASS 47.37 seconds
TestRunner_bnep-tester PASS 10.75 seconds
TestRunner_mgmt-tester PASS 222.24 seconds
TestRunner_rfcomm-tester PASS 16.37 seconds
TestRunner_sco-tester PASS 19.50 seconds
TestRunner_ioctl-tester PASS 18.45 seconds
TestRunner_mesh-tester PASS 13.75 seconds
TestRunner_smp-tester PASS 14.72 seconds
TestRunner_userchan-tester PASS 11.37 seconds
IncrementalBuild PASS 31.40 seconds
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] Bluetooth: hci_sync: Add hci_cmd_sync_queue_once
2023-08-09 21:39 [RFC] Bluetooth: hci_sync: Add hci_cmd_sync_queue_once Luiz Augusto von Dentz
2023-08-09 22:35 ` bluez.test.bot
@ 2023-08-09 23:26 ` kernel test robot
2023-08-10 0:28 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-08-09 23:26 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: oe-kbuild-all
Hi Luiz,
[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:
[auto build test ERROR on bluetooth-next/master]
[also build test ERROR on bluetooth/master linus/master v6.5-rc5 next-20230809]
[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/Luiz-Augusto-von-Dentz/Bluetooth-hci_sync-Add-hci_cmd_sync_queue_once/20230810-054032
base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
patch link: https://lore.kernel.org/r/20230809213916.1636311-1-luiz.dentz%40gmail.com
patch subject: [RFC] Bluetooth: hci_sync: Add hci_cmd_sync_queue_once
config: arc-randconfig-r043-20230809 (https://download.01.org/0day-ci/archive/20230810/202308100752.2ywy3qXp-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230810/202308100752.2ywy3qXp-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/202308100752.2ywy3qXp-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from include/linux/linkage.h:7,
from include/linux/printk.h:8,
from include/asm-generic/bug.h:22,
from arch/arc/include/asm/bug.h:30,
from include/linux/ktime.h:26,
from include/linux/poll.h:7,
from include/net/bluetooth/bluetooth.h:29,
from net/bluetooth/hci_sync.c:11:
>> net/bluetooth/hci_sync.c:770:15: error: 'hci_cmd_sync_pending' undeclared here (not in a function); did you mean 'hci_cmd_sync_init'?
770 | EXPORT_SYMBOL(hci_cmd_sync_pending);
| ^~~~~~~~~~~~~~~~~~~~
include/linux/export.h:74:23: note: in definition of macro '__EXPORT_SYMBOL'
74 | extern typeof(sym) sym; \
| ^~~
include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
86 | #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
| ^~~~~~~~~~~~~~
net/bluetooth/hci_sync.c:770:1: note: in expansion of macro 'EXPORT_SYMBOL'
770 | EXPORT_SYMBOL(hci_cmd_sync_pending);
| ^~~~~~~~~~~~~
vim +770 net/bluetooth/hci_sync.c
748
749 bool hci_cmd_sync_lookup(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
750 void *data, hci_cmd_sync_work_destroy_t destroy,
751 bool cancel)
752 {
753 struct hci_cmd_sync_work_entry *entry, *tmp;
754
755 mutex_lock(&hdev->cmd_sync_work_lock);
756 list_for_each_entry_safe(entry, tmp, &hdev->cmd_sync_work_list, list) {
757 if (entry->func == func && entry->data == data &&
758 entry->destroy == destroy) {
759 if (cancel)
760 _hci_cmd_sync_cancel_entry(hdev, entry,
761 -ECANCELED);
762 mutex_unlock(&hdev->cmd_sync_work_lock);
763 return true;
764 }
765 }
766 mutex_unlock(&hdev->cmd_sync_work_lock);
767
768 return false;
769 }
> 770 EXPORT_SYMBOL(hci_cmd_sync_pending);
771
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [RFC] Bluetooth: hci_sync: Add hci_cmd_sync_queue_once
2023-08-09 21:39 [RFC] Bluetooth: hci_sync: Add hci_cmd_sync_queue_once Luiz Augusto von Dentz
2023-08-09 22:35 ` bluez.test.bot
2023-08-09 23:26 ` kernel test robot
@ 2023-08-10 0:28 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-08-10 0:28 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: llvm, oe-kbuild-all
Hi Luiz,
[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:
[auto build test ERROR on bluetooth-next/master]
[also build test ERROR on bluetooth/master linus/master v6.5-rc5 next-20230809]
[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/Luiz-Augusto-von-Dentz/Bluetooth-hci_sync-Add-hci_cmd_sync_queue_once/20230810-054032
base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
patch link: https://lore.kernel.org/r/20230809213916.1636311-1-luiz.dentz%40gmail.com
patch subject: [RFC] Bluetooth: hci_sync: Add hci_cmd_sync_queue_once
config: i386-randconfig-i012-20230809 (https://download.01.org/0day-ci/archive/20230810/202308100811.4dzOf3kV-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20230810/202308100811.4dzOf3kV-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/202308100811.4dzOf3kV-lkp@intel.com/
All errors (new ones prefixed by >>):
>> net/bluetooth/hci_sync.c:770:15: error: use of undeclared identifier 'hci_cmd_sync_pending'; did you mean 'hci_cmd_sync_init'?
EXPORT_SYMBOL(hci_cmd_sync_pending);
^~~~~~~~~~~~~~~~~~~~
hci_cmd_sync_init
include/linux/export.h:86:44: note: expanded from macro 'EXPORT_SYMBOL'
#define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
^
include/linux/export.h:83:54: note: expanded from macro '_EXPORT_SYMBOL'
#define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, "")
^
include/linux/export.h:74:16: note: expanded from macro '__EXPORT_SYMBOL'
extern typeof(sym) sym; \
^
net/bluetooth/hci_sync.c:628:6: note: 'hci_cmd_sync_init' declared here
void hci_cmd_sync_init(struct hci_dev *hdev)
^
1 error generated.
vim +770 net/bluetooth/hci_sync.c
748
749 bool hci_cmd_sync_lookup(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
750 void *data, hci_cmd_sync_work_destroy_t destroy,
751 bool cancel)
752 {
753 struct hci_cmd_sync_work_entry *entry, *tmp;
754
755 mutex_lock(&hdev->cmd_sync_work_lock);
756 list_for_each_entry_safe(entry, tmp, &hdev->cmd_sync_work_list, list) {
757 if (entry->func == func && entry->data == data &&
758 entry->destroy == destroy) {
759 if (cancel)
760 _hci_cmd_sync_cancel_entry(hdev, entry,
761 -ECANCELED);
762 mutex_unlock(&hdev->cmd_sync_work_lock);
763 return true;
764 }
765 }
766 mutex_unlock(&hdev->cmd_sync_work_lock);
767
768 return false;
769 }
> 770 EXPORT_SYMBOL(hci_cmd_sync_pending);
771
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-10 0:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 21:39 [RFC] Bluetooth: hci_sync: Add hci_cmd_sync_queue_once Luiz Augusto von Dentz
2023-08-09 22:35 ` bluez.test.bot
2023-08-09 23:26 ` kernel test robot
2023-08-10 0:28 ` kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.