From patchwork Mon Dec 23 08:58:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Lu X-Patchwork-Id: 853315 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40DF913C9A3; Mon, 23 Dec 2024 08:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734944336; cv=none; b=JiSB5Wq/noQ7d3YlpjKAuTR2B6MhOkvrwJh23BOa8eO/iWzE6qGUVgmV5z66YgVHGQBnnsg4uYwMTv85WwzyAWOkMehi4ejLEDadzJlazImhb2BiP0CpaV3BObR/g8K7xCEnGYJIlYyrZxeEOQCuAZn9bT5kDyNR9eyMd2oxd40= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734944336; c=relaxed/simple; bh=UcmYlg1lyMkeg+0VKaW2XgPIhI4XvLwGOFVLPPz4Sto=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=NfR3bps3KbmSn2s9mgjo9FOSuqYLLvsHLM02OLzob28ChWABG0fTPxUamkF3pSxw4mO5EbeKaC3ZUtz3PSgGJoPfq9Y1CDKkUj3TuwvACFOJayrWKkwFyn1fuC/9jPd0R+tUUMFcl4iPtwmgt2WT6/11GT1/4NvpxasXScZZ5k0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=hNeOlpLF; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="hNeOlpLF" X-UUID: 100b4be4c10c11ef99858b75a2457dd9-20241223 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=Ns2wwu3L1qU4OwwNBwHYMN3+ScKST7Uw6JR3esYfznM=; b=hNeOlpLFk6o35o8s3vXRX/+fbVSPLT+AvB8YdXt7V70P5N+ab00V0FTDUAZahHz3fEy02F7PpuRwGqo3M2j6irMBjCenVqTaizMAyOk7nUjnMqLmd5vWdHm38LjpiLyN2Wep3SYKocDoShC1pIexhBnk0dRowxL4cv3asGoGcJU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45, REQID:9973153e-7ec6-419f-8429-72c5eb9cd5b2, IP:-32 768,URL:-32768,TC:-32768,Content:-32768,EDM:-32768,RT:-32768,SF:-32768,FIL E:-32768,BULK:-32768,RULE:Release_Ham,ACTION:release,TS:0 X-CID-META: VersionHash:6493067, CLOUDID:nil, BulkID:nil, BulkQuantity:0, Recheck: 0,SF:nil,TC:nil,Content:nil,EDM:nil,IP:nil,URL:nil,File:nil,RT:nil,Bulk:ni l,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE :0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 100b4be4c10c11ef99858b75a2457dd9-20241223 Received: from mtkmbs09n1.mediatek.inc [(172.21.101.35)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1969339349; Mon, 23 Dec 2024 16:58:22 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 23 Dec 2024 16:58:21 +0800 Received: from mtksitap99.mediatek.inc (10.233.130.16) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 23 Dec 2024 16:58:21 +0800 From: Chris Lu To: Marcel Holtmann , Johan Hedberg , Luiz Von Dentz CC: Sean Wang , Aaron Hou , Steve Lee , linux-bluetooth , linux-kernel , linux-mediatek , Chris Lu Subject: [PATCH v1] Bluetooth: btmtk: Fix failed to send func ctrl for MediaTek devices. Date: Mon, 23 Dec 2024 16:58:18 +0800 Message-ID: <20241223085818.722707-1-chris.lu@mediatek.com> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use usb_autopm_get_interface() and usb_autopm_put_interface() in btmtk_usb_shutdown(), it could send func ctrl after enabling autosuspend. Bluetooth: btusb_mtk_hci_wmt_sync() hci0: Execution of wmt command timed out Bluetooth: btusb_mtk_shutdown() hci0: Failed to send wmt func ctrl (-110) Signed-off-by: Chris Lu --- drivers/bluetooth/btmtk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c index 7fd9d5ddce02..224eafc27dbe 100644 --- a/drivers/bluetooth/btmtk.c +++ b/drivers/bluetooth/btmtk.c @@ -1472,10 +1472,15 @@ EXPORT_SYMBOL_GPL(btmtk_usb_setup); int btmtk_usb_shutdown(struct hci_dev *hdev) { + struct btmtk_data *data = hci_get_priv(hdev); struct btmtk_hci_wmt_params wmt_params; u8 param = 0; int err; + err = usb_autopm_get_interface(data->intf); + if (err < 0) + return err; + /* Disable the device */ wmt_params.op = BTMTK_WMT_FUNC_CTRL; wmt_params.flag = 0; @@ -1486,9 +1491,11 @@ int btmtk_usb_shutdown(struct hci_dev *hdev) err = btmtk_usb_hci_wmt_sync(hdev, &wmt_params); if (err < 0) { bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err); + usb_autopm_put_interface(data->intf); return err; } + usb_autopm_put_interface(data->intf); return 0; } EXPORT_SYMBOL_GPL(btmtk_usb_shutdown);