Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3722718pxt; Tue, 10 Aug 2021 09:50:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0Ng3e1QFJTDCEuBjNBkFoEFPV/tD7eBFGziAn3V+aEVVmrWfno1Ymi5EBHc+sx/Y3Su0+ X-Received: by 2002:a17:906:c443:: with SMTP id ck3mr28040431ejb.195.1628614202562; Tue, 10 Aug 2021 09:50:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628614202; cv=none; d=google.com; s=arc-20160816; b=W1BHIefwCq9xip9utLp7fr5e5cv5JHvwLllPKwN3C+twgflA4e7kjBPIYhzggghTl/ IZUqw6PU+IGMwqG/3cUYjRrQBVajSSZxkDyhPWXaPDGyvZ/P7zuMxrHArF3CT7NmYEnT zlTS0c0TRCCO9LZQAj3xThXvEu4lp7BsgkQVPYtjO6AuI1iqNf14SaPRtRyVgx79srV0 YoINZM/lT7RvL9Oq9qysDt/GEvQv69bEWyrHRyxLNJQWXACrX72iDea+BvzL0K7DRsDs CX02AkqTlY/HgowUKVzCUODhd71sR6PObtJVf4JWkqIYCZBDAUreGQGbuET3gUxiBCXI Spzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Z8DFjP+KuQ1dksQO2ExvJY7WwUp9W6gc9a/aguSAYfY=; b=m6HF9eYCkBqpOVzhVqQEABUo6MjRnicq6niUiosBRUYJvVrvqOvbM1twlEgsXHVohQ YK5T95VB+ZgaNm2AXd6JHIr2q7awzodIH42DI3bl72HZxRlOsMSSwZtfFjYC1Bbnq2jU BhyWwNz5uub62aK0h8GF25L1Kqvih8MDbx5A6M+3vXyoPAOOeBk1nzY5bN+z+3aWrnXg qCTOpVlAkShx2AOggbQT4Wv/V391Md4F9YU/ALyK2r/zFtWAzweTHWXAiDy0K8aFRXME y8t+YAZyPxNs7Nk2p9/vZK1NRH6bk7tQNhzKFwbMhZDVnh5BSLqSKVEPsffKUG1KVNqO lszA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e26si6911450edr.7.2021.08.10.09.49.35; Tue, 10 Aug 2021 09:50:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229516AbhHJQs7 (ORCPT + 99 others); Tue, 10 Aug 2021 12:48:59 -0400 Received: from fgw20-4.mail.saunalahti.fi ([62.142.5.107]:32016 "EHLO fgw20-4.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229474AbhHJQsu (ORCPT ); Tue, 10 Aug 2021 12:48:50 -0400 Received: from ydin.reaktio.net (reaktio.net [85.76.255.15]) by fgw20.mail.saunalahti.fi (Halon) with ESMTP id c50273d6-f9fa-11eb-bea8-005056bd6ce9; Tue, 10 Aug 2021 19:48:21 +0300 (EEST) Received: by ydin.reaktio.net (Postfix, from userid 1001) id 997BE20089; Tue, 10 Aug 2021 19:48:20 +0300 (EEST) Date: Tue, 10 Aug 2021 19:48:20 +0300 From: Pasi =?iso-8859-1?Q?K=E4rkk=E4inen?= To: Marcel Holtmann Cc: Pauli Virtanen , linux-bluetooth , Joseph Hwang , Hilda Wu , Johan Hedberg , Luiz Augusto von Dentz , =?utf-8?B?TWljaGHFgiBLxJlwaWXFhA==?= Subject: Re: [PATCH v2] Bluetooth: btusb: check conditions before enabling USB ALT 3 for WBS Message-ID: <20210810164820.GA12064@reaktio.net> References: <872F0B33-594E-4BD7-8B75-EA96DE8DBA8F@holtmann.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <872F0B33-594E-4BD7-8B75-EA96DE8DBA8F@holtmann.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hello Marcel, On Fri, Jul 23, 2021 at 02:19:09PM +0200, Marcel Holtmann wrote: > Hi Pauli, > > > Some USB BT adapters don't satisfy the MTU requirement mentioned in > > commit e848dbd364ac ("Bluetooth: btusb: Add support USB ALT 3 for WBS") > > and have ALT 3 setting that produces no/garbled audio. Some adapters > > with larger MTU were also reported to have problems with ALT 3. > > > > Add a flag and check it and MTU before selecting ALT 3, falling back to > > ALT 1. Enable the flag for Realtek, restoring the previous behavior for > > non-Realtek devices. > > > > Tested with USB adapters (mtu<72, no/garbled sound with ALT3, ALT1 > > works) BCM20702A1 0b05:17cb, CSR8510A10 0a12:0001, and (mtu>=72, ALT3 > > works) RTL8761BU 0bda:8771, Intel AX200 8087:0029 (after disabling > > ALT6). Also got reports for (mtu>=72, ALT 3 reported to produce bad > > audio) Intel 8087:0a2b. > > > > Signed-off-by: Pauli Virtanen > > Fixes: e848dbd364ac ("Bluetooth: btusb: Add support USB ALT 3 for WBS") > > before I will apply this, I need Tested-by or Ack-by people that confirm that this fixes their issues now. > Is v3 ok/enough? It has one Tested-by. It would probably be good to send v4 anyway with CC stable@kernel.org .. Thanks, -- Pasi > > > --- > > > > Changes in v2: > > - Explain magic number 72 in a comment; didn't add the table for them, > > because it's not used elsewhere and we need just one number from it. > > - Add flag for ALT3 support, restoring the behavior > > for non-Realtek devices the same as before e848dbd364ac, due to > > the problems reported on an Intel adapter. Don't have the device > > myself. > > > > drivers/bluetooth/btusb.c | 22 ++++++++++++++-------- > > 1 file changed, 14 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > > index 6d23308119d1..5cec719f6cba 100644 > > --- a/drivers/bluetooth/btusb.c > > +++ b/drivers/bluetooth/btusb.c > > @@ -516,6 +516,7 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { > > #define BTUSB_HW_RESET_ACTIVE 12 > > #define BTUSB_TX_WAIT_VND_EVT 13 > > #define BTUSB_WAKEUP_DISABLE 14 > > +#define BTUSB_ALT3_OK_FOR_WBS 15 > > Rename this to BTUSB_USE_ALT3_FOR_WBS. > > > > > struct btusb_data { > > struct hci_dev *hdev; > > @@ -1748,16 +1749,20 @@ static void btusb_work(struct work_struct *work) > > /* Bluetooth USB spec recommends alt 6 (63 bytes), but > > * many adapters do not support it. Alt 1 appears to > > * work for all adapters that do not have alt 6, and > > - * which work with WBS at all. > > + * which work with WBS at all. Some devices prefer > > + * alt 3 (HCI payload >= 60 Bytes let air packet > > + * data satisfy 60 bytes), requiring > > + * MTU >= 3 (packets) * 25 (size) - 3 (headers) = 72 > > + * see also Core spec 5, vol 4, B 2.1.1 & Table 2.1. > > */ > > - new_alts = btusb_find_altsetting(data, 6) ? 6 : 1; > > - /* Because mSBC frames do not need to be aligned to the > > - * SCO packet boundary. If support the Alt 3, use the > > - * Alt 3 for HCI payload >= 60 Bytes let air packet > > - * data satisfy 60 bytes. > > - */ > > - if (new_alts == 1 && btusb_find_altsetting(data, 3)) > > + if (btusb_find_altsetting(data, 6)) > > + new_alts = 6; > > + else if (test_bit(BTUSB_ALT3_OK_FOR_WBS, &data->flags) && > > + hdev->sco_mtu >= 72 && > > + btusb_find_altsetting(data, 3)) > > This is whitespace damaged. > > > new_alts = 3; > > + else > > + new_alts = 1; > > } > > > > if (btusb_switch_alt_setting(hdev, new_alts) < 0) > > @@ -4733,6 +4738,7 @@ static int btusb_probe(struct usb_interface *intf, > > * (DEVICE_REMOTE_WAKEUP) > > */ > > set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); > > + set_bit(BTUSB_ALT3_OK_FOR_WBS, &data->flags); > > } > > Regards > > Marcel >