Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1224928pxb; Fri, 10 Sep 2021 00:37:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7LppGIHzGIyVtZ0cGIklhMCu1gDN8c/sXvqb2cBGFt1gGtDgI6qhZEayHWQ8fDlPRXCBE X-Received: by 2002:a17:906:4892:: with SMTP id v18mr7737941ejq.541.1631259420650; Fri, 10 Sep 2021 00:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631259420; cv=none; d=google.com; s=arc-20160816; b=IJbezKX2Oasr5vAIpgfsERFOqeL+x33dovEmgT+SIzPgD7hBmYA4dT677QH7rQbMfd SThfDmQdBrjLu+0d4PEqQO06WQcMUgt8TuljCu/pytQSI67io27xBbPCK0UiFLQ+Qyuh N/u+HyMVtWBZ/Zes4vZ2m9eyoFE3YA//L1NEBsKHqu3UAifBQ3C+r/MHD+Pefo01CO46 ZaSLd/20xpftQHKRID9OZCCbs9Z7aU4Dcr3sNRzMSyisTTnLQI/2xR+5pjLqGWC51uJ0 JATFuc0yO9izFgjncuO7eQWJZQM1TRg9q0DMUE4M0DfHt02u/OY4gBG9VjHAT+YWZn4q 80/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=9LQrvuynstR77z/+XUxLY4G4eodUnVxGCNwjwzbXS6Q=; b=B1hgap4DxFAT7V4PhYCH8XSzV1YDmJQsq6ww0K249o39+EfDV5RZ8E8EXWuVrWTxm0 PYpc0UQc/FP6pQcMPfWtjgzcqezBcE3BlKJfSxmUpHicwmGZFhQmrN8RtGGyGRvi+ZNm +VDMPy8vHzWpac6F8mdLCNB+CSq4R21aH5iyflaLLjxem4wLwZ9GF+r9i68QP27BGdrj 3bTLpjzwQ3Xd5csUo8qgKFDzT8j2xGvEbEQm/4kvvqBE6Hk1nmIW/HdxON4xoj/Fm3Qx 2MVJ2Y/X36d5jymNbAZtIbQLIiny65gjd6ZolkekvA8uijwFjpynM3brM+dxli5VnXcD BlJw== 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 k16si4598400edo.475.2021.09.10.00.36.36; Fri, 10 Sep 2021 00:37:00 -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 S231569AbhIJHg2 convert rfc822-to-8bit (ORCPT + 99 others); Fri, 10 Sep 2021 03:36:28 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:57235 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231465AbhIJHgX (ORCPT ); Fri, 10 Sep 2021 03:36:23 -0400 Received: from smtpclient.apple (p5b3d2185.dip0.t-ipconnect.de [91.61.33.133]) by mail.holtmann.org (Postfix) with ESMTPSA id 14D2BCED3D; Fri, 10 Sep 2021 09:35:12 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: [PATCH v13 12/12] Bluetooth: Allow usb to auto-suspend when SCO use non-HCI transport From: Marcel Holtmann In-Reply-To: Date: Fri, 10 Sep 2021 09:35:11 +0200 Cc: Kiran K , "linux-bluetooth@vger.kernel.org" , Chethan T N Content-Transfer-Encoding: 8BIT Message-Id: References: <20210831115637.6713-1-kiran.k@intel.com> <20210831115637.6713-12-kiran.k@intel.com> <135FFE98-549B-4C02-9AC3-AD7F18EC0564@holtmann.org> To: Luiz Augusto von Dentz X-Mailer: Apple Mail (2.3654.120.0.1.13) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Luiz, >>>> Currently usb tranport is not allowed to suspend when SCO over >>>> HCI tranport is active. >>>> >>>> This patch shall enable the usb tranport to suspend when SCO >>>> link use non-HCI transport >>>> >>>> Signed-off-by: Chethan T N >>>> Signed-off-by: Kiran K >>>> --- >>>> >>>> Notes: >>>> changes in v13: >>>> - suspend usb in HFP offload use case >>>> >>>> drivers/bluetooth/btintel.c | 2 +- >>>> include/net/bluetooth/bluetooth.h | 4 ++++ >>>> net/bluetooth/hci_event.c | 20 +++++++++++--------- >>>> net/bluetooth/sco.c | 2 +- >>>> 4 files changed, 17 insertions(+), 11 deletions(-) >>>> >>>> diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c >>>> index 6091b691ddc2..2d64e289cf6e 100644 >>>> --- a/drivers/bluetooth/btintel.c >>>> +++ b/drivers/bluetooth/btintel.c >>>> @@ -2215,7 +2215,7 @@ static int btintel_get_codec_config_data(struct hci_dev *hdev, >>>> static int btintel_get_data_path_id(struct hci_dev *hdev, __u8 *data_path_id) >>>> { >>>> /* Intel uses 1 as data path id for all the usecases */ >>>> - *data_path_id = 1; >>>> + *data_path_id = BT_SCO_PCM_PATH; >>>> return 0; >>>> } >>>> >>>> diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h >>>> index c1fa90fb7502..9e2745863b33 100644 >>>> --- a/include/net/bluetooth/bluetooth.h >>>> +++ b/include/net/bluetooth/bluetooth.h >>>> @@ -177,6 +177,10 @@ struct bt_codecs { >>>> #define CODING_FORMAT_TRANSPARENT 0x03 >>>> #define CODING_FORMAT_MSBC 0x05 >>>> >>>> +/* Audio data transport path used for SCO */ >>>> +#define BT_SCO_HCI_PATH 0x00 >>>> +#define BT_SCO_PCM_PATH 0x01 >>> >>> If this is in fact vendor specific perhaps you should be declared in >>> btintel.h not here. >>> >>>> + >>>> __printf(1, 2) >>>> void bt_info(const char *fmt, ...); >>>> __printf(1, 2) >>>> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c >>>> index b48e24629fa4..7ff11cba89cf 100644 >>>> --- a/net/bluetooth/hci_event.c >>>> +++ b/net/bluetooth/hci_event.c >>>> @@ -4516,15 +4516,17 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev, >>>> >>>> bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); >>>> >>>> - switch (ev->air_mode) { >>>> - case 0x02: >>>> - if (hdev->notify) >>>> - hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); >>>> - break; >>>> - case 0x03: >>>> - if (hdev->notify) >>>> - hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); >>>> - break; >>>> + if (conn->codec.data_path == BT_SCO_HCI_PATH) { >>>> + switch (ev->air_mode) { >>>> + case 0x02: >>>> + if (hdev->notify) >>>> + hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); >>>> + break; >>>> + case 0x03: >>>> + if (hdev->notify) >>>> + hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); >>>> + break; >>>> + } >>> >>> Hmm I think we might need to notify the driver to enable PCM routing >>> so the likes of btusb can call >>> usb_disable_endpoint/usb_enable_endpoint for example since in theory >>> userspace may choose to switch from software to hardware offload and >>> vice-versa, note without calling usb_disable_endpoint there might not >>> be much power saving after all since the endpoint will remain active >>> or do we actually have a good explanation why it shall not be called >>> when using PCM routing? Note that usb_set_interface will call >>> usb_enable_interface that will then call usb_enable_endpoint so >>> perhaps we need to call usb_disable_interface, either way we can't >>> assume the platform will be restricted to only use one or the other. >> >> actually for the Intel hardware we shouldn’t do this at all. We should switch to vendor specific SCO over bulk endpoints and not claim the ISOC endpoints at all. > > Yep, but I guess that requires switching to SCO over bulk then which > perhaps needs more changes, not sure if we should pursue that or go > with all the way with H4 mode like we did in Zephyr, anyway for the > purpose of offload I would be fine skipping the SCO over bulk since we > are already at v13 of these. actually SCO over bulk is rather simple. You jus send one extra HCI command at init (just need to figure out if it survices HCI_Reset) and then you only need to look up the handle if it is SCO or ACL. Regards Marcel