Linux Sound subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Leon Romanovsky" <leon@kernel.org>
Cc: linux-input@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-pci@vger.kernel.org, linux-sound@vger.kernel.org,
	dmitry.torokhov@gmail.com
Subject: Re: [PATCH v3 02/31] Bluetooth: btusb: Fix MediaTek ISO claim locking
Date: Thu, 19 Nov 2026 19:29:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-223888@kernel.org> (raw)
In-Reply-To: <20261118-device-trust-core-v3-2-d655875c4bfb@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] Bluetooth: btusb: btusb_mtk_setup() aborts when interface 2 is
  claimed by Wi-Fi
--

commit 40159ea2da44fd76ee32a7e5d004d0dc5227de46
Author: Leon Romanovsky <leon@kernel.org>

Bluetooth: btusb: Fix MediaTek ISO claim locking

This commit resumes the USB interface, acquires the parent device lock with
bounded retries before claiming the MediaTek ISO interface, and propagates
claim errors to btusb_mtk_setup().

> diff --git a/drivers/bluetooth/btusb_main.c b/drivers/bluetooth/btusb_main.c
> index 92a78a7e60396..8307fd819cc2e 100644
> --- a/drivers/bluetooth/btusb_main.c
> +++ b/drivers/bluetooth/btusb_main.c
> @@ -2993,40 +2993,57 @@ static int btusb_recv_event_realtek(struct hci_dev *hdev, struct sk_buff *skb)
>  	return hci_recv_frame(hdev, skb);
>  }
>  
> -static void btusb_mtk_claim_iso_intf(struct btusb_data *data)
> +#define BTUSB_MTK_ISO_LOCK_TRIES	5
> +static int btusb_mtk_claim_iso_intf(struct btusb_data *data)
>  {
>  	struct btmtk_data *btmtk_data;
> -	int err;
> +	int err, i;
>  
>  	if (!data->hdev)
> -		return;
> +		return 0;
>  
>  	btmtk_data = hci_get_priv(data->hdev);
>  	if (!btmtk_data)
> -		return;
> +		return 0;
>  
>  	if (!btmtk_data->isopkt_intf) {
>  		bt_dev_err(data->hdev, "Can't claim NULL iso interface");
> -		return;
> +		return 0;
>  	}
>  
> -	/*
> -	 * The function usb_driver_claim_interface() is documented to need
> -	 * locks held if it's not called from a probe routine. The code here
> -	 * is called from the hci_power_on workqueue, so grab the lock.
> -	 */
> +	err = usb_autopm_get_interface(data->intf);
> +	if (err)
> +		goto err_clear_iso_intf;
> +
> +	/* Disconnect may hold the parent lock while waiting for this work. */
> +	for (i = 0; i < BTUSB_MTK_ISO_LOCK_TRIES; i++) {
> +		err = usb_lock_device_for_reset(data->udev, data->intf);
> +		if (err != -EBUSY)
> +			break;
> +	}
> +	if (err)
> +		goto err_put_interface;
> +
>  	device_lock(&btmtk_data->isopkt_intf->dev);
>  	err = usb_driver_claim_interface(&btusb_driver,
>  					 btmtk_data->isopkt_intf, data);
>  	device_unlock(&btmtk_data->isopkt_intf->dev);
> -	if (err < 0) {
> -		btmtk_data->isopkt_intf = NULL;
> -		bt_dev_err(data->hdev, "Failed to claim iso interface: %d", err);
> -		return;
> -	}
> +	if (err)
> +		goto err_unlock;
>  
> -	set_bit(BTMTK_ISOPKT_OVER_INTR, &btmtk_data->flags);
>  	init_usb_anchor(&btmtk_data->isopkt_anchor);
> +	set_bit(BTMTK_ISOPKT_OVER_INTR, &btmtk_data->flags);
> +	usb_unlock_device(data->udev);
> +	usb_autopm_put_interface(data->intf);
> +	return 0;
> +
> +err_unlock:
> +	usb_unlock_device(data->udev);
> +err_put_interface:
> +	usb_autopm_put_interface(data->intf);
> +err_clear_iso_intf:
> +	bt_dev_err(data->hdev, "Failed to claim iso interface: %d", err);
> +	return err;
>  }
>  
>  static void btusb_mtk_release_iso_intf(struct hci_dev *hdev)
> @@ -3169,7 +3186,11 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
>  	/* Claim ISO data interface and endpoint */
>  	if (!test_bit(BTMTK_ISOPKT_OVER_INTR, &btmtk_data->flags)) {
>  		btmtk_data->isopkt_intf = usb_ifnum_to_if(data->udev, MTK_ISO_IFNUM);
> -		btusb_mtk_claim_iso_intf(data);
> +		err = btusb_mtk_claim_iso_intf(data);
> +		if (err) {
> +			btmtk_data->isopkt_intf = NULL;
> +			return err;
> +		}
>  	}
>  
>  	err = btmtk_usb_setup(hdev);

[Severity: High]
Does propagating the usb_driver_claim_interface() error abort
btusb_mtk_setup() on composite MediaTek Wi-Fi/Bluetooth USB devices where
interface 2 (MTK_ISO_IFNUM) belongs to Wi-Fi?

btusb_mtk_setup() runs for all BTUSB_MEDIATEK devices and unconditionally
attempts to claim interface 2 before btmtk_usb_setup() identifies the chip.
On composite devices such as MT7663U (0e8d:7663, 043e:310c), MT7921U
(0e8d:7961) and MT7925U (0e8d:7925), interface 2 is the vendor-specific
Wi-Fi interface bound to mt76 (mt7615u, mt7921u, mt7925u).

Because usb_set_configuration() holds the parent device lock while probing
all interfaces and btusb_mtk_claim_iso_intf() now waits for that lock from
the hci_power_on workqueue, the Wi-Fi driver binds to interface 2 first.
usb_driver_claim_interface() then returns -EBUSY, and returning that error
from btusb_mtk_setup() prevents Bluetooth from powering on instead of
continuing without the optional ISO-over-interrupt interface.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-device-trust-core-v3-0-d655875c4bfb@nvidia.com?part=2

  reply	other threads:[~2026-11-19 19:29 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 19:26 [PATCH v3 00/31] driver core: Authorize device trust before driver binding Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 01/31] wifi: mac80211_hwsim: lock device for manual " Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 02/31] Bluetooth: btusb: Fix MediaTek ISO claim locking Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot [this message]
2026-11-18 19:26 ` [PATCH v3 03/31] USB: Lock interfaces during manual driver binding Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 04/31] USB: serial: Register USB drivers with their owning module Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 05/31] USB: Reject claims of DT-disabled interfaces Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 06/31] USB: Release interface claims according to binding state Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 07/31] USB: Reject claims after interface registration failure Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 08/31] ALSA: usb-audio: Release interface claims when probe fails Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 09/31] USB: Pin modules for unregistered interface claims Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 10/31] USB: Add helpers to release unpublished " Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 11/31] USB: Unwind interface claims after registration or binding failure Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 12/31] PNP: Attach card devices through the driver core Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 13/31] cdx: Propagate DMA configuration errors Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 14/31] driver core: Report deferred probes through sysfs drivers_probe Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 15/31] driver core: Add a compatibility API for manual driver attachment Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 16/31] Input: gameport - use the compatibility driver attachment API Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 17/31] Input: serio " Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 18/31] net: phy: Use " Leon Romanovsky
2026-11-18 20:21   ` Andrew Lunn
2026-11-19  7:18     ` Leon Romanovsky
2026-11-19 13:30       ` Andrew Lunn
2026-11-18 19:26 ` [PATCH v3 19/31] driver core: Introduce a generic device trust level Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 20/31] driver core: Expose device trust authorization interfaces Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 21/31] driver core: Accept device trust policy on the kernel command line Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 22/31] driver core: Accept device trust policy by driver name Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 23/31] driver core: Expose committed device trust level Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 24/31] driver core: Cover trust authorization and binding with KUnit Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 25/31] driver core: Document trust admission and initrd authorization Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 26/31] PCI: Use device trust for platform restrictions Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:26 ` [PATCH v3 27/31] iommu: Use device trust for DMA restrictions Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 28/31] driver core: Allow driver attachment with the device lock held Leon Romanovsky
2026-11-18 19:26 ` [PATCH v3 29/31] USB: Retain the result of configuration requests Leon Romanovsky
2026-11-18 19:27 ` [PATCH v3 30/31] USB: Authorize interfaces through device trust Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot
2026-11-18 19:27 ` [PATCH v3 31/31] USB: Authorize devices " Leon Romanovsky
2026-11-19 19:29   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-223888@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=leon@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox