Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2704537pxt; Mon, 9 Aug 2021 07:04:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXk+dDeyn3fPyQpPjNaKVL2ZqAlipNEIClGKR/TKmWHXarDUYO38W0dcnXLIr32Yw9/kEv X-Received: by 2002:a05:6e02:550:: with SMTP id i16mr499301ils.207.1628517872009; Mon, 09 Aug 2021 07:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628517871; cv=none; d=google.com; s=arc-20160816; b=E0w3DqXg58mjlR/iXcgghHh+e77PiQHRY8I+uAX42iQeeKJEDyS5kktadnb+DtVzOx MYhhDQO1Nekei8jec2Izm8tpWeZq9DJ4BojGfnzouTNcXBFrf/zvHgHYldJed97oops3 frTqNuG4LqbUWhw4LOazSEf8Vs906zE5iBWtl8zYDi+eFyEUY1nUQnmKmdkhSgH79Gr2 e8rgcDJdJ09XWQVXaDOcA4Z53zJYVl8e1wa/3OgcMO4ZcnBUj+6DGSGuQUGA19B5JEO/ USc3VVKE+bQ+o1oh3ONp3R6azxf+bWmICErpfeuHh4ud1vscQ5dB082/JDeW35DYz76i dtEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :authenticated-by; bh=lSje5apQOUZq765Wlk4t6pSh04UmlfvCb9jrvzkMryc=; b=ouUuxbbCQPmeGhkstMTHYoeA4N8ef0CtzghCOZV0Sx2K6Rsk+b5Pw+qDV3PAozoTpA B3X/83M+XM8LKSevAe4Fu7794eli+0fUgftTBCudfBNKLbYWo0g0us8mKKtmhQmOWGHB w7PmCelSCVWTf7S6UpWgz+2B+M9lxjygD9eYigjrZmdyavLDhKZSTvs/gBX3LAcSe/uA p+rh1ZsCiU+Qv45SB2fc/1rLay3ZVZwOtVthJCgLLJTasmBm2ZSyel5SUdC8RDi1WoS3 RMu/e/y/FyB1dtGjQrgiyb5MEGXfOOeJKxc4yQR1kTE0IU6f5N8bPn6EyIdmFHmmKOb2 VBBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 a10si18960524ilv.72.2021.08.09.07.04.20; Mon, 09 Aug 2021 07:04:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234282AbhHINCx (ORCPT + 99 others); Mon, 9 Aug 2021 09:02:53 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:32986 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234075AbhHINCw (ORCPT ); Mon, 9 Aug 2021 09:02:52 -0400 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.73 with qID 179D1wGH2026755, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36502.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.71/5.88) with ESMTPS id 179D1wGH2026755 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 9 Aug 2021 21:01:58 +0800 Received: from RTEXMBS03.realtek.com.tw (172.21.6.96) by RTEXH36502.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 9 Aug 2021 21:01:57 +0800 Received: from localhost (172.21.132.185) by RTEXMBS03.realtek.com.tw (172.21.6.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 9 Aug 2021 21:01:56 +0800 From: To: , , , , , , , CC: , , , , , , Subject: [PATCH] Bluetooth: btusb: Remove WAKEUP_DISABLE and add WAKEUP_AUTOSUSPEND for Realtek devices Date: Mon, 9 Aug 2021 21:01:52 +0800 Message-ID: <20210809130152.12528-1-max.chou@realtek.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.132.185] X-ClientProxiedBy: RTEXMBS02.realtek.com.tw (172.21.6.95) To RTEXMBS03.realtek.com.tw (172.21.6.96) X-KSE-ServerInfo: RTEXMBS03.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: trusted connection X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Deterministic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 08/09/2021 12:50:00 X-KSE-AttachmentFiltering-Interceptor-Info: no applicable attachment filtering rules found X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: =?big5?B?Q2xlYW4sIGJhc2VzOiAyMDIxLzgvOSCkV6TIIDA3OjA0OjAw?= X-KSE-BulkMessagesFiltering-Scan-Result: protection disabled X-KSE-ServerInfo: RTEXH36502.realtek.com.tw, 9 X-KSE-Attachment-Filter-Triggered-Rules: Clean X-KSE-Attachment-Filter-Triggered-Filters: Clean X-KSE-BulkMessagesFiltering-Scan-Result: protection disabled X-KSE-AntiSpam-Outbound-Interceptor-Info: scan successful X-KSE-AntiSpam-Version: 5.9.20, Database issued on: 08/09/2021 12:47:36 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 0 X-KSE-AntiSpam-Info: Lua profiles 165471 [Aug 09 2021] X-KSE-AntiSpam-Info: Version: 5.9.20.0 X-KSE-AntiSpam-Info: Envelope from: max.chou@realtek.com X-KSE-AntiSpam-Info: LuaCore: 454 454 39c6e442fd417993330528e7f9d13ac1bf7fdf8c X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: 127.0.0.199:7.1.2;realtek.com:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1 X-KSE-AntiSpam-Info: Rate: 0 X-KSE-AntiSpam-Info: Status: not_detected X-KSE-AntiSpam-Info: Method: none X-KSE-AntiSpam-Info: Auth:dkim=none X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Heuristic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 08/09/2021 12:50:00 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Max Chou For the commit of 9e45524a011107a73bc2cdde8370c61e82e93a4d, wakeup is always disabled for Realtek devices. However, there's the capability for Realtek devices to apply USB wake-up. In this commit, remove WAKEUP_DISABLE feature for Realtek devices. If users would switch wake-up, they should access "/sys/bus/usb/.../power/wakeup" In this commit, it also adds the feature as WAKEUP_AUTOSUSPEND for Realtek devices because it should set do_remote_wakeup on autosuspend. Signed-off-by: Max Chou Tested-by: Hilda Wu Reviewed-by: Archie Pusaka Reviewed-by: Abhishek Pandit-Subedi --- drivers/bluetooth/btusb.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 488f110e17e2..73a835bf37f7 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -527,7 +527,7 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { #define BTUSB_OOB_WAKE_ENABLED 11 #define BTUSB_HW_RESET_ACTIVE 12 #define BTUSB_TX_WAIT_VND_EVT 13 -#define BTUSB_WAKEUP_DISABLE 14 +#define BTUSB_WAKEUP_AUTOSUSPEND 14 struct btusb_data { struct hci_dev *hdev; @@ -1349,13 +1349,6 @@ static int btusb_open(struct hci_dev *hdev) data->intf->needs_remote_wakeup = 1; - /* Disable device remote wakeup when host is suspended - * For Realtek chips, global suspend without - * SET_FEATURE (DEVICE_REMOTE_WAKEUP) can save more power in device. - */ - if (test_bit(BTUSB_WAKEUP_DISABLE, &data->flags)) - device_wakeup_disable(&data->udev->dev); - if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags)) goto done; @@ -1422,7 +1415,7 @@ static int btusb_close(struct hci_dev *hdev) data->intf->needs_remote_wakeup = 0; /* Enable remote wake up for auto-suspend */ - if (test_bit(BTUSB_WAKEUP_DISABLE, &data->flags)) + if (test_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data->flags)) data->intf->needs_remote_wakeup = 1; usb_autopm_put_interface(data->intf); @@ -3877,11 +3870,8 @@ static int btusb_probe(struct usb_interface *intf, hdev->shutdown = btrtl_shutdown_realtek; hdev->cmd_timeout = btusb_rtl_cmd_timeout; - /* Realtek devices lose their updated firmware over global - * suspend that means host doesn't send SET_FEATURE - * (DEVICE_REMOTE_WAKEUP) - */ - set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); + /* Realtek devices need to set remote wakeup on auto-suspend */ + set_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data->flags); } if (!reset) @@ -4056,12 +4046,15 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message) * Actually, it depends on whether the usb host sends * set feature (enable wakeup) or not. */ - if (test_bit(BTUSB_WAKEUP_DISABLE, &data->flags)) { + if (test_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data->flags)) { if (PMSG_IS_AUTO(message) && device_can_wakeup(&data->udev->dev)) data->udev->do_remote_wakeup = 1; - else if (!PMSG_IS_AUTO(message)) + else if (!PMSG_IS_AUTO(message) && + !device_may_wakeup(&data->udev->dev)) { + data->udev->do_remote_wakeup = 0; data->udev->reset_resume = 1; + } } return 0; -- 2.17.1