Message ID | 20211013221701.2826793-1-luiz.dentz@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Luiz Von Dentz |
Headers | show |
Series | [v3] Bluetooth: vhci: Add support for setting msft_opcode and aosp_capable | expand |
Context | Check | Description |
---|---|---|
tedd_an/checkpatch | success | Checkpatch PASS |
tedd_an/gitlint | success | Gitlint PASS |
tedd_an/buildkernel | success | Build Kernel PASS |
tedd_an/testrunnersetup | success | Test Runner Setup PASS |
tedd_an/testrunnerl2cap-tester | success | Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0 |
tedd_an/testrunnerbnep-tester | success | Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0 |
tedd_an/testrunnermgmt-tester | success | Total: 468, Passed: 468 (100.0%), Failed: 0, Not Run: 0 |
tedd_an/testrunnerrfcomm-tester | success | Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0 |
tedd_an/testrunnersco-tester | success | Total: 12, Passed: 12 (100.0%), Failed: 0, Not Run: 0 |
tedd_an/testrunnersmp-tester | success | Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0 |
tedd_an/testrunneruserchan-tester | success | Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0 |
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=563071 ---Test result--- Test Summary: CheckPatch PASS 1.59 seconds GitLint PASS 0.93 seconds BuildKernel PASS 615.15 seconds TestRunner: Setup PASS 453.00 seconds TestRunner: l2cap-tester PASS 10.03 seconds TestRunner: bnep-tester PASS 5.38 seconds TestRunner: mgmt-tester PASS 95.52 seconds TestRunner: rfcomm-tester PASS 6.63 seconds TestRunner: sco-tester PASS 7.10 seconds TestRunner: smp-tester PASS 6.76 seconds TestRunner: userchan-tester PASS 5.59 seconds --- Regards, Linux Bluetooth
Hi Luiz, > This adds a debugfs entries to set msft_opcode and aosp_capable enabling > vhci to emulate controllers with MSFT/AOSP extension support. > > Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > --- > v2: Fix typos: s/extention/extension/g > v3: Remove checks for HCI_SETUP, merge changes to introduce MSFT/AOSP support > at the same time. > > drivers/bluetooth/hci_vhci.c | 92 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 92 insertions(+) patch has been applied to bluetooth-next tree (with slight modifications). Regards Marcel
Hi Marcel, On Thu, Oct 14, 2021 at 5:39 AM Marcel Holtmann <marcel@holtmann.org> wrote: > > Hi Luiz, > > > This adds a debugfs entries to set msft_opcode and aosp_capable enabling > > vhci to emulate controllers with MSFT/AOSP extension support. > > > > Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > --- > > v2: Fix typos: s/extention/extension/g > > v3: Remove checks for HCI_SETUP, merge changes to introduce MSFT/AOSP support > > at the same time. > > > > drivers/bluetooth/hci_vhci.c | 92 ++++++++++++++++++++++++++++++++++++ > > 1 file changed, 92 insertions(+) > > patch has been applied to bluetooth-next tree (with slight modifications). ++<<<<<<< HEAD + hci_set_msft_opcode(hdev, vhci->msft_opcode); + hci_set_aosp_capable(hdev); ++======= + if (vhci->msft_opcode) + hci_set_msft_opcode(hdev, vhci->msft_opcode); + + if (vhci->aosp_capable) + hci_set_aosp_capable(hdev); ++>>>>>>> 9bbbb6a7ad09 (Bluetooth: vhci: Add support for setting msft_opcode and aosp_capable) I suspect the above changes won't work if we don't init the fields in the vhci_data, msft_opcode would be set to 0x0000 so it won't be enabled anyway but aosp_capable would be enabled which would be out of sync with vhci->aosp_capable, so perhaps we want to change hci_set_aosp_capable to take a parameter: diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 74c0eb28c422..9e67517b6cef 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c @@ -264,7 +264,7 @@ static int vhci_setup(struct hci_dev *hdev) struct vhci_data *vhci = hci_get_drvdata(hdev); hci_set_msft_opcode(hdev, vhci->msft_opcode); - hci_set_aosp_capable(hdev); + hci_set_aosp_capable(hdev, vhci->aosp_capable); return 0; } diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index dd8840e70e25..d007b487d4c1 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1279,10 +1279,10 @@ static inline void hci_set_msft_opcode(struct hci_dev *hdev, __u16 opcode) #endif } -static inline void hci_set_aosp_capable(struct hci_dev *hdev) +static inline void hci_set_aosp_capable(struct hci_dev *hdev, bool enable) { #if IS_ENABLED(CONFIG_BT_AOSPEXT) - hdev->aosp_capable = true; + hdev->aosp_capable = enable; #endif } > Regards > > Marcel >
Hi Luiz, >>> This adds a debugfs entries to set msft_opcode and aosp_capable enabling >>> vhci to emulate controllers with MSFT/AOSP extension support. >>> >>> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> >>> --- >>> v2: Fix typos: s/extention/extension/g >>> v3: Remove checks for HCI_SETUP, merge changes to introduce MSFT/AOSP support >>> at the same time. >>> >>> drivers/bluetooth/hci_vhci.c | 92 ++++++++++++++++++++++++++++++++++++ >>> 1 file changed, 92 insertions(+) >> >> patch has been applied to bluetooth-next tree (with slight modifications). > > ++<<<<<<< HEAD > + hci_set_msft_opcode(hdev, vhci->msft_opcode); > + hci_set_aosp_capable(hdev); > ++======= > + if (vhci->msft_opcode) > + hci_set_msft_opcode(hdev, vhci->msft_opcode); > + > + if (vhci->aosp_capable) > + hci_set_aosp_capable(hdev); > ++>>>>>>> 9bbbb6a7ad09 (Bluetooth: vhci: Add support for setting > msft_opcode and aosp_capable) > > I suspect the above changes won't work if we don't init the fields in > the vhci_data, msft_opcode would be set to 0x0000 so it won't be > enabled anyway but aosp_capable would be enabled which would be out of > sync with vhci->aosp_capable, so perhaps we want to change > hci_set_aosp_capable to take a parameter: I went to bed yesterday and today, I realized that I have done something stupid. I fixed this upstream and also made sure that you can only ever set this once per debugfs. Regards Marcel
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 56c6b22be10b..dc05729104a1 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c @@ -42,6 +42,8 @@ struct vhci_data { bool suspended; bool wakeup; + __u16 msft_opcode; + bool aosp_capable; }; static int vhci_open_dev(struct hci_dev *hdev) @@ -194,6 +196,82 @@ static const struct file_operations force_wakeup_fops = { .llseek = default_llseek, }; +static int msft_opcode_set(void *data, u64 val) +{ + struct vhci_data *vhci = data; + + if (val > 0xffff || (val & 0xffff >> 10) != 0x3f) + return -EINVAL; + + vhci->msft_opcode = val; + + return 0; +} + +static int msft_opcode_get(void *data, u64 *val) +{ + struct vhci_data *vhci = data; + + *val = vhci->msft_opcode; + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(msft_opcode_fops, msft_opcode_get, msft_opcode_set, + "%llu\n"); + +static ssize_t aosp_capable_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct vhci_data *vhci = file->private_data; + char buf[3]; + + buf[0] = vhci->aosp_capable ? 'Y' : 'N'; + buf[1] = '\n'; + buf[2] = '\0'; + return simple_read_from_buffer(user_buf, count, ppos, buf, 2); +} + +static ssize_t aosp_capable_write(struct file *file, + const char __user *user_buf, size_t count, + loff_t *ppos) +{ + struct vhci_data *vhci = file->private_data; + bool enable; + int err; + + err = kstrtobool_from_user(user_buf, count, &enable); + if (err) + return err; + + if (vhci->aosp_capable == enable) + return -EALREADY; + + vhci->aosp_capable = enable; + + return count; +} + +static const struct file_operations aosp_capable_fops = { + .open = simple_open, + .read = aosp_capable_read, + .write = aosp_capable_write, + .llseek = default_llseek, +}; + +static int vhci_setup(struct hci_dev *hdev) +{ + struct vhci_data *vhci = hci_get_drvdata(hdev); + + if (vhci->msft_opcode) + hci_set_msft_opcode(hdev, vhci->msft_opcode); + + if (vhci->aosp_capable) + hci_set_aosp_capable(hdev); + + return 0; +} + static int __vhci_create_device(struct vhci_data *data, __u8 opcode) { struct hci_dev *hdev; @@ -237,6 +315,12 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode) hdev->get_codec_config_data = vhci_get_codec_config_data; hdev->wakeup = vhci_wakeup; + /* Enable custom setup if CONFIG_BT_MSFTEXT or CONFIG_BT_AOSPEXT is + * selected. + */ + hdev->setup = vhci_setup; + set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks); + /* bit 6 is for external configuration */ if (opcode & 0x40) set_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks); @@ -259,6 +343,14 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode) debugfs_create_file("force_wakeup", 0644, hdev->debugfs, data, &force_wakeup_fops); + if (IS_ENABLED(CONFIG_BT_MSFTEXT)) + debugfs_create_file("msft_opcode", 0644, hdev->debugfs, data, + &msft_opcode_fops); + + if (IS_ENABLED(CONFIG_BT_AOSPEXT)) + debugfs_create_file("aosp_capable", 0644, hdev->debugfs, data, + &aosp_capable_fops); + hci_skb_pkt_type(skb) = HCI_VENDOR_PKT; skb_put_u8(skb, 0xff);