2024-03-04 14:49:07

by Peter Tsao (曹珆彰)

[permalink] [raw]
Subject: [PATCH] [PATCH] Bluetooth: btusb: Add support Mediatek MT7920

This patch is added support Mediatek MT7920
The firmware location of MT7920 will set to
/lib/firmware/mediatek/

The information in /sys/kernel/debug/usb/devices about MT7920U
Bluetooth device is listed as the below

T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 12 Spd=480 MxCh= 0
D: Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=0e8d ProdID=7920 Rev= 1.00
S: Manufacturer=MediaTek Inc.
S: Product=Wireless_Device
S: SerialNumber=000000000
C:* #Ifs= 3 Cfg#= 1 Atr=e0 MxPwr=100mA
A: FirstIf#= 0 IfCount= 3 Cls=e0(wlcon) Sub=01 Prot=01
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=125us
E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms
E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms
I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms
E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms
I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms
E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms
I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms
E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms
I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms
E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms
I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms
I: If#= 1 Alt= 6 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E: Ad=83(I) Atr=01(Isoc) MxPS= 63 Ivl=1ms
E: Ad=03(O) Atr=01(Isoc) MxPS= 63 Ivl=1ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
E: Ad=8a(I) Atr=03(Int.) MxPS= 64 Ivl=125us
E: Ad=0a(O) Atr=03(Int.) MxPS= 64 Ivl=125us
I: If#= 2 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
E: Ad=8a(I) Atr=03(Int.) MxPS= 512 Ivl=125us
E: Ad=0a(O) Atr=03(Int.) MxPS= 512 Ivl=125us

Signed-off-by: Peter Tsao <[email protected]>
---
drivers/bluetooth/btusb.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index edfb49bbaa28..ba6ac853110b 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3088,7 +3088,7 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
int err, status;
u32 dev_id = 0;
char fw_bin_name[64];
- u32 fw_version = 0;
+ u32 fw_version = 0, fw_flavor = 0;
u8 param;
struct btmediatek_data *mediatek;

@@ -3111,6 +3111,11 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
bt_dev_err(hdev, "Failed to get fw version (%d)", err);
return err;
}
+ err = btusb_mtk_id_get(data, 0x70010020, &fw_flavor);
+ if (err < 0) {
+ bt_dev_err(hdev, "Failed to get fw flavor (%d)", err);
+ return err;
+ }
}

mediatek = hci_get_priv(hdev);
@@ -3135,6 +3140,10 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
snprintf(fw_bin_name, sizeof(fw_bin_name),
"mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
dev_id & 0xffff, dev_id & 0xffff, (fw_version & 0xff) + 1);
+ else if (dev_id == 0x7961 && fw_flavor)
+ snprintf(fw_bin_name, sizeof(fw_bin_name),
+ "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
+ dev_id & 0xffff, (fw_version & 0xff) + 1);
else
snprintf(fw_bin_name, sizeof(fw_bin_name),
"mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
--
2.18.0



2024-03-04 15:35:02

by bluez.test.bot

[permalink] [raw]
Subject: RE: Bluetooth: btusb: Add support Mediatek MT7920

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=832126

---Test result---

Test Summary:
CheckPatch PASS 0.52 seconds
GitLint PASS 0.23 seconds
SubjectPrefix PASS 0.07 seconds
BuildKernel PASS 28.10 seconds
CheckAllWarning PASS 30.80 seconds
CheckSparse PASS 36.71 seconds
CheckSmatch PASS 101.59 seconds
BuildKernel32 PASS 27.65 seconds
TestRunnerSetup PASS 505.81 seconds
TestRunner_l2cap-tester PASS 18.28 seconds
TestRunner_iso-tester PASS 99.47 seconds
TestRunner_bnep-tester PASS 4.79 seconds
TestRunner_mgmt-tester FAIL 112.18 seconds
TestRunner_rfcomm-tester PASS 7.47 seconds
TestRunner_sco-tester PASS 15.03 seconds
TestRunner_ioctl-tester PASS 7.97 seconds
TestRunner_mesh-tester PASS 5.96 seconds
TestRunner_smp-tester PASS 6.87 seconds
TestRunner_userchan-tester PASS 5.03 seconds
IncrementalBuild PASS 26.49 seconds

Details
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 492, Passed: 489 (99.4%), Failed: 1, Not Run: 2

Failed Test Cases
LL Privacy - Add Device 7 (AL is full) Failed 0.201 seconds


---
Regards,
Linux Bluetooth

2024-04-01 14:44:44

by Mike Lothian

[permalink] [raw]
Subject: Re: [PATCH] [PATCH] Bluetooth: btusb: Add support Mediatek MT7920

Hi

I think this patch is cauisng issues with older firmware

Bus 003 Device 002: ID 13d3:3563 IMC Networks Wireless_Device

[ 0.315064] Bluetooth: Core ver 2.22
[ 0.315064] NET: Registered PF_BLUETOOTH protocol family
[ 0.315064] Bluetooth: HCI device and connection manager initialized
[ 0.315064] Bluetooth: HCI socket layer initialized
[ 0.315064] Bluetooth: L2CAP socket layer initialized
[ 0.315064] Bluetooth: SCO socket layer initialized
[ 4.670811] Bluetooth: RFCOMM TTY layer initialized
[ 4.671029] Bluetooth: RFCOMM socket layer initialized
[ 4.671790] Bluetooth: RFCOMM ver 1.11
[ 4.673416] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 4.673659] Bluetooth: BNEP filters: protocol multicast
[ 4.673895] Bluetooth: BNEP socket layer initialized
[ 4.674125] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[ 4.674360] Bluetooth: HIDP socket layer initialized
[ 5.016365] bluetooth hci0: Direct firmware load for mediatek/BT_RAM_CODE_MT7961_1a_2_hdr.bin failed with error -2
[ 5.017163] Bluetooth: hci0: Failed to load firmware file (-2)
[ 5.017557] Bluetooth: hci0: Failed to set up firmware (-2)
[ 5.018129] Bluetooth: hci0: HCI Enhanced Setup Synchronous Connection command is advertised, but not supported.

The correct name should be mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin

Reverting this patch fixes things

Cheers

Mike

2024-04-01 15:22:09

by Mike Lothian

[permalink] [raw]
Subject: Re: [PATCH] [PATCH] Bluetooth: btusb: Add support Mediatek MT7920

On Mon, 1 Apr 2024 at 15:44, Mike Lothian <[email protected]> wrote:
>
> Hi
>
> I think this patch is causing issues with older firmware
>
> Bus 003 Device 002: ID 13d3:3563 IMC Networks Wireless_Device
>
> [ 0.315064] Bluetooth: Core ver 2.22
> [ 0.315064] NET: Registered PF_BLUETOOTH protocol family
> [ 0.315064] Bluetooth: HCI device and connection manager initialized
> [ 0.315064] Bluetooth: HCI socket layer initialized
> [ 0.315064] Bluetooth: L2CAP socket layer initialized
> [ 0.315064] Bluetooth: SCO socket layer initialized
> [ 4.670811] Bluetooth: RFCOMM TTY layer initialized
> [ 4.671029] Bluetooth: RFCOMM socket layer initialized
> [ 4.671790] Bluetooth: RFCOMM ver 1.11
> [ 4.673416] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
> [ 4.673659] Bluetooth: BNEP filters: protocol multicast
> [ 4.673895] Bluetooth: BNEP socket layer initialized
> [ 4.674125] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
> [ 4.674360] Bluetooth: HIDP socket layer initialized
> [ 5.016365] bluetooth hci0: Direct firmware load for mediatek/BT_RAM_CODE_MT7961_1a_2_hdr.bin failed with error -2
> [ 5.017163] Bluetooth: hci0: Failed to load firmware file (-2)
> [ 5.017557] Bluetooth: hci0: Failed to set up firmware (-2)
> [ 5.018129] Bluetooth: hci0: HCI Enhanced Setup Synchronous Connection command is advertised, but not supported.
>
> The correct name should be mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin
>
> Reverting this patch fixes things
>
> Cheers
>
> Mike

If it helps, the device ID is 0x7961 and the fw_flavour is 24 or 0x18 in hex

2024-04-05 08:34:48

by Thorsten Leemhuis

[permalink] [raw]
Subject: Re: [PATCH] [PATCH] Bluetooth: btusb: Add support Mediatek MT7920

[CCing the regression list, as it should be in the loop for regressions:
https://docs.kernel.org/admin-guide/reporting-regressions.html]

On 01.04.24 17:20, Mike Lothian wrote:
> On Mon, 1 Apr 2024 at 15:44, Mike Lothian <[email protected]> wrote:
>>
>> I think this patch is causing issues with older firmware
>>
>> Bus 003 Device 002: ID 13d3:3563 IMC Networks Wireless_Device
>>
>> [ 0.315064] Bluetooth: Core ver 2.22
>> [ 0.315064] NET: Registered PF_BLUETOOTH protocol family
>> [ 0.315064] Bluetooth: HCI device and connection manager initialized
>> [ 0.315064] Bluetooth: HCI socket layer initialized
>> [ 0.315064] Bluetooth: L2CAP socket layer initialized
>> [ 0.315064] Bluetooth: SCO socket layer initialized
>> [ 4.670811] Bluetooth: RFCOMM TTY layer initialized
>> [ 4.671029] Bluetooth: RFCOMM socket layer initialized
>> [ 4.671790] Bluetooth: RFCOMM ver 1.11
>> [ 4.673416] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
>> [ 4.673659] Bluetooth: BNEP filters: protocol multicast
>> [ 4.673895] Bluetooth: BNEP socket layer initialized
>> [ 4.674125] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
>> [ 4.674360] Bluetooth: HIDP socket layer initialized
>> [ 5.016365] bluetooth hci0: Direct firmware load for mediatek/BT_RAM_CODE_MT7961_1a_2_hdr.bin failed with error -2
>> [ 5.017163] Bluetooth: hci0: Failed to load firmware file (-2)
>> [ 5.017557] Bluetooth: hci0: Failed to set up firmware (-2)
>> [ 5.018129] Bluetooth: hci0: HCI Enhanced Setup Synchronous Connection command is advertised, but not supported.
>>
>> The correct name should be mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin
>>
>> Reverting this patch fixes things
>
> If it helps, the device ID is 0x7961 and the fw_flavour is 24 or 0x18 in hex

Thanks for the report!

Peter, did you look into this?

Anyway: To be sure the issue doesn't fall through the cracks unnoticed,
I'm adding it to regzbot, the Linux kernel regression tracking bot:

#regzbot report:
https://lore.kernel.org/all/[email protected]/
#regzbot introduced: 1cb63d80fff6c4
#regzbot title: net: Bluetooth: firmware loading problems with older
firmware
#regzbot ignore-activity

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
--
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
That page also explains what to do if mails like this annoy you.

2024-04-05 09:17:30

by Deren Wu

[permalink] [raw]
Subject: Re: [SPAM]Re: [PATCH] [PATCH] Bluetooth: btusb: Add support Mediatek MT7920

Hi Thorsten,

Thanks for the note. We are looking for solution for this issue. Peter
would post the new patch. :)

Regards,
Deren

On Fri, 2024-04-05 at 10:34 +0200, Linux regression tracking (Thorsten
Leemhuis) wrote:
> [CCing the regression list, as it should be in the loop for
> regressions:
>
https://urldefense.com/v3/__https://docs.kernel.org/admin-guide/reporting-regressions.html__;!!CTRNKA9wMg0ARbw!n9OQDQtfMiQdddzNLvMEOMLnnEHhw12KRY5W5YPscQJTiNQtuIVuJufNc2UYpy-rUlRtMUwZsL5NDERIf1CoGox8J2I$
> ]
>
> On 01.04.24 17:20, Mike Lothian wrote:
> > On Mon, 1 Apr 2024 at 15:44, Mike Lothian <[email protected]>
> > wrote:
> > >
> > > I think this patch is causing issues with older firmware
> > >
> > > Bus 003 Device 002: ID 13d3:3563 IMC Networks Wireless_Device
> > >
> > > [ 0.315064] Bluetooth: Core ver 2.22
> > > [ 0.315064] NET: Registered PF_BLUETOOTH protocol family
> > > [ 0.315064] Bluetooth: HCI device and connection manager
> > > initialized
> > > [ 0.315064] Bluetooth: HCI socket layer initialized
> > > [ 0.315064] Bluetooth: L2CAP socket layer initialized
> > > [ 0.315064] Bluetooth: SCO socket layer initialized
> > > [ 4.670811] Bluetooth: RFCOMM TTY layer initialized
> > > [ 4.671029] Bluetooth: RFCOMM socket layer initialized
> > > [ 4.671790] Bluetooth: RFCOMM ver 1.11
> > > [ 4.673416] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
> > > [ 4.673659] Bluetooth: BNEP filters: protocol multicast
> > > [ 4.673895] Bluetooth: BNEP socket layer initialized
> > > [ 4.674125] Bluetooth: HIDP (Human Interface Emulation) ver
> > > 1.2
> > > [ 4.674360] Bluetooth: HIDP socket layer initialized
> > > [ 5.016365] bluetooth hci0: Direct firmware load for
> > > mediatek/BT_RAM_CODE_MT7961_1a_2_hdr.bin failed with error -2
> > > [ 5.017163] Bluetooth: hci0: Failed to load firmware file (-2)
> > > [ 5.017557] Bluetooth: hci0: Failed to set up firmware (-2)
> > > [ 5.018129] Bluetooth: hci0: HCI Enhanced Setup Synchronous
> > > Connection command is advertised, but not supported.
> > >
> > > The correct name should be
> > > mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin
> > >
> > > Reverting this patch fixes things
> >
> > If it helps, the device ID is 0x7961 and the fw_flavour is 24 or
> > 0x18 in hex
>
> Thanks for the report!
>
> Peter, did you look into this?
>
> Anyway: To be sure the issue doesn't fall through the cracks
> unnoticed,
> I'm adding it to regzbot, the Linux kernel regression tracking bot:
>
> #regzbot report:
>
https://lore.kernel.org/all/[email protected]/
> #regzbot introduced: 1cb63d80fff6c4
> #regzbot title: net: Bluetooth: firmware loading problems with older
> firmware
> #regzbot ignore-activity
>
> Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker'
> hat)
> --
> Everything you wanna know about Linux kernel regression tracking:
>
https://urldefense.com/v3/__https://linux-regtracking.leemhuis.info/about/*tldr__;Iw!!CTRNKA9wMg0ARbw!n9OQDQtfMiQdddzNLvMEOMLnnEHhw12KRY5W5YPscQJTiNQtuIVuJufNc2UYpy-rUlRtMUwZsL5NDERIf1CoQcaol0s$
>
> That page also explains what to do if mails like this annoy you.

2024-04-15 12:31:37

by Thorsten Leemhuis

[permalink] [raw]
Subject: Re: [PATCH] [PATCH] Bluetooth: btusb: Add support Mediatek MT7920

On 05.04.24 11:15, Deren Wu (武德仁) wrote:
>
> Thanks for the note. We are looking for solution for this issue. Peter
> would post the new patch. :)

Anyone still working on this, as that afaics did not happen -- or was
there progress and I just missed it?

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
--
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
If I did something stupid, please tell me, as explained on that page.

#regzbot poke

> On Fri, 2024-04-05 at 10:34 +0200, Linux regression tracking (Thorsten
> Leemhuis) wrote:
>> [CCing the regression list, as it should be in the loop for
>> regressions:
>>
> https://urldefense.com/v3/__https://docs.kernel.org/admin-guide/reporting-regressions.html__;!!CTRNKA9wMg0ARbw!n9OQDQtfMiQdddzNLvMEOMLnnEHhw12KRY5W5YPscQJTiNQtuIVuJufNc2UYpy-rUlRtMUwZsL5NDERIf1CoGox8J2I$
>> ]
>>
>> On 01.04.24 17:20, Mike Lothian wrote:
>>> On Mon, 1 Apr 2024 at 15:44, Mike Lothian <[email protected]>
>>> wrote:
>>>>
>>>> I think this patch is causing issues with older firmware
>>>>
>>>> Bus 003 Device 002: ID 13d3:3563 IMC Networks Wireless_Device
>>>>
>>>> [ 0.315064] Bluetooth: Core ver 2.22
>>>> [ 0.315064] NET: Registered PF_BLUETOOTH protocol family
>>>> [ 0.315064] Bluetooth: HCI device and connection manager
>>>> initialized
>>>> [ 0.315064] Bluetooth: HCI socket layer initialized
>>>> [ 0.315064] Bluetooth: L2CAP socket layer initialized
>>>> [ 0.315064] Bluetooth: SCO socket layer initialized
>>>> [ 4.670811] Bluetooth: RFCOMM TTY layer initialized
>>>> [ 4.671029] Bluetooth: RFCOMM socket layer initialized
>>>> [ 4.671790] Bluetooth: RFCOMM ver 1.11
>>>> [ 4.673416] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
>>>> [ 4.673659] Bluetooth: BNEP filters: protocol multicast
>>>> [ 4.673895] Bluetooth: BNEP socket layer initialized
>>>> [ 4.674125] Bluetooth: HIDP (Human Interface Emulation) ver
>>>> 1.2
>>>> [ 4.674360] Bluetooth: HIDP socket layer initialized
>>>> [ 5.016365] bluetooth hci0: Direct firmware load for
>>>> mediatek/BT_RAM_CODE_MT7961_1a_2_hdr.bin failed with error -2
>>>> [ 5.017163] Bluetooth: hci0: Failed to load firmware file (-2)
>>>> [ 5.017557] Bluetooth: hci0: Failed to set up firmware (-2)
>>>> [ 5.018129] Bluetooth: hci0: HCI Enhanced Setup Synchronous
>>>> Connection command is advertised, but not supported.
>>>>
>>>> The correct name should be
>>>> mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin
>>>>
>>>> Reverting this patch fixes things
>>>
>>> If it helps, the device ID is 0x7961 and the fw_flavour is 24 or
>>> 0x18 in hex
>>
>> Thanks for the report!
>>
>> Peter, did you look into this?
>>
>> Anyway: To be sure the issue doesn't fall through the cracks
>> unnoticed,
>> I'm adding it to regzbot, the Linux kernel regression tracking bot:
>>
>> #regzbot report:
>>
> https://lore.kernel.org/all/[email protected]/
>> #regzbot introduced: 1cb63d80fff6c4
>> #regzbot title: net: Bluetooth: firmware loading problems with older
>> firmware
>> #regzbot ignore-activity
>>
>> Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker'
>> hat)
>> --
>> Everything you wanna know about Linux kernel regression tracking:
>>
> https://urldefense.com/v3/__https://linux-regtracking.leemhuis.info/about/*tldr__;Iw!!CTRNKA9wMg0ARbw!n9OQDQtfMiQdddzNLvMEOMLnnEHhw12KRY5W5YPscQJTiNQtuIVuJufNc2UYpy-rUlRtMUwZsL5NDERIf1CoQcaol0s$
>>
>> That page also explains what to do if mails like this annoy you.