Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2528038pxy; Tue, 3 Aug 2021 08:29:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrEcJrZlQXuOAAC29g56Kja2yWep/TwUFWfWgYYPztIlL/KLV6mo0QR/TFyoULj/rn4EXv X-Received: by 2002:a17:906:4b18:: with SMTP id y24mr20637816eju.42.1628004597921; Tue, 03 Aug 2021 08:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628004597; cv=none; d=google.com; s=arc-20160816; b=pyEMG9ciplYAQFdHJvENz3wWSSfurIrTtED9uh/JOldb/ikJk7OPp+pApTTyLwyDVX RFl/v+J+Y6HK3riIqlvrWWiwuND30H5K2iFHcK/KQjR/lo1kgsSWCSOI4yKl9sThnvbk yWtyU5luKY8mTYitSSOKOLNh6cIjjpoEiUoNVs9TFS2Z2gkf70zfoqz2SapRMLEkDQdy R2siIxVq2hzeDfrOCWc82yqowK8OzhzORsaojRa+WoBTRnd8un0JgwcwPREr6edZs+GH 6CNfrrZmTSsPILskHVgdl9jm2ioEKhQLSNVZwYgTY2jl5T5k0FVJg6NsTlfIwkBO3cED f4tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0NMDLRvCd8Q/Sr5vCBPPnUG/lOK2F47kcAWNHlgBnNo=; b=ReTgRza0qFGm7UdwRj8a+4sJgBY9tJ4g0IUqj9+dUHks7E2JNxBLmP8h3g7/U27iHU ruvz1PhS0uYvGbDP98FfU6xkStYOXis1GSt3o+WUMABA8JCdqd8qzOjaiU8BPs5WwSkV 8L9dauVvMiGqxodsytpFNusa+c6OeZ4a6vkdhB0Olzo/qFUrBL5x6LEKaqGJ6LtDN1Td pXowGCGczFwMOcLeZrd+N0hyRzsThHSruwnCDOVjHMkKydwKG5D3ACUcmPKXSXinZAup fzMN7GPF5RdDwfVifcZV7iHJ/Iyf80V1iijDENhapUlK+SZleBw8dq0vF+sYcFAcIfjs iIgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lf6lLXzT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n22si14481170ejz.331.2021.08.03.08.29.08; Tue, 03 Aug 2021 08:29:57 -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; dkim=pass header.i=@chromium.org header.s=google header.b=lf6lLXzT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236729AbhHCP1q (ORCPT + 99 others); Tue, 3 Aug 2021 11:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236730AbhHCP1p (ORCPT ); Tue, 3 Aug 2021 11:27:45 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE6CFC061764 for ; Tue, 3 Aug 2021 08:27:33 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id pj14-20020a17090b4f4eb029017786cf98f9so5191239pjb.2 for ; Tue, 03 Aug 2021 08:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0NMDLRvCd8Q/Sr5vCBPPnUG/lOK2F47kcAWNHlgBnNo=; b=lf6lLXzT0+v5MPDgFLkljZAOcR52vQKJHTUUAW4AUs//Upt6/iYEpa8dPMTH6FOH1t Nt30zcrcpgM6X7P94U1bf7tyegZqnoF4t0hqtUTagSBRKHCIQz2DFUz0XQIKoeZk5nWG belIoiekv78wi+AjUewGnkWA6HOjrDAug/o7g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0NMDLRvCd8Q/Sr5vCBPPnUG/lOK2F47kcAWNHlgBnNo=; b=K4oBC1fQMzgDH1XBQaT2PTQgMp970+ewArI2frPylwJHKqnMdS6xkP7oB1w+Pcg6lP p0/jZDxwXWhzOx5RoWYb5B2pbXVeYo2kWiCX2ON/yGVO48QL1BHfSBfruig6m391yBuV NKoRHVKbRGP1ofM11dzHdfSRRE44B/IJgsFCp5Ef2jKosje4efBdl2b0TOycuh515Hgy wGugyeabs2jhIEIG2FqRV/PADlofe4LgfhoGCp/N/PUbHhorI16tk6sTndEhqKln74hO M94nhuXZagqiFUuCmNjuKeAHpE9/ChtIUNT/rLYX5MVhCsyetEI/dHdl76V1sSamErS2 49Gw== X-Gm-Message-State: AOAM533rr+SjgJnEbj72T8z2C31RD7WkdnIW0dWKpJ3My0sHe2CltwSS bN8uOCFuAldnkcW1Z//nemD2EzJF0YWDog== X-Received: by 2002:a05:6a00:16d6:b029:32a:ffe9:76a with SMTP id l22-20020a056a0016d6b029032affe9076amr22990851pfc.60.1628004453262; Tue, 03 Aug 2021 08:27:33 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:7cf5:7e9:5266:c8ba]) by smtp.gmail.com with ESMTPSA id v30sm14922493pgk.25.2021.08.03.08.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 08:27:32 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Joseph Hwang , Miao-chen Chou , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH v5 3/4] Bluetooth: set quality report callback for Intel Date: Tue, 3 Aug 2021 23:27:18 +0800 Message-Id: <20210803232539.v5.3.I50ffa4cd0b3ab11669ff2541fc719fee00b4e244@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210803232539.v5.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> References: <20210803232539.v5.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch sets up set_quality_report callback for Intel to set and reset the debug features. Reviewed-by: Miao-chen Chou Signed-off-by: Joseph Hwang --- Changes in v5: - Removed CONFIG_BT_FEATURE_QUALITY_REPORT since there was no large size impact. drivers/bluetooth/btintel.c | 73 ++++++++++++++++++++++++++++++++++++- drivers/bluetooth/btintel.h | 9 +++++ drivers/bluetooth/btusb.c | 8 ++++ 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index fd21ddb76928..28ca51227453 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -1254,8 +1254,10 @@ int btintel_set_debug_features(struct hci_dev *hdev, u8 trace_enable = 0x02; struct sk_buff *skb; - if (!features) + if (!features) { + bt_dev_warn(hdev, "Debug features not read"); return -EINVAL; + } if (!(features->page1[0] & 0x3f)) { bt_dev_info(hdev, "Telemetry exception format not supported"); @@ -1286,10 +1288,79 @@ int btintel_set_debug_features(struct hci_dev *hdev, } kfree_skb(skb); + bt_dev_info(hdev, "set debug features: trace_enable 0x%02x mask 0x%02x", + trace_enable, mask[3]); + return 0; } EXPORT_SYMBOL_GPL(btintel_set_debug_features); +int btintel_reset_debug_features(struct hci_dev *hdev, + const struct intel_debug_features *features) +{ + u8 mask[11] = { 0x0a, 0x92, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00 }; + u8 trace_enable = 0x00; + struct sk_buff *skb; + + if (!features) { + bt_dev_warn(hdev, "Debug features not read"); + return -EINVAL; + } + + if (!(features->page1[0] & 0x3f)) { + bt_dev_info(hdev, "Telemetry exception format not supported"); + return 0; + } + + /* Should stop the trace before writing ddc event mask. */ + skb = __hci_cmd_sync(hdev, 0xfca1, 1, &trace_enable, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Stop tracing of link statistics events failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + kfree_skb(skb); + + skb = __hci_cmd_sync(hdev, 0xfc8b, 11, mask, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Setting Intel telemetry ddc write event mask failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + kfree_skb(skb); + + bt_dev_info(hdev, "reset debug features: trace_enable 0x%02x mask 0x%02x", + trace_enable, mask[3]); + + return 0; +} +EXPORT_SYMBOL_GPL(btintel_reset_debug_features); + +int btintel_set_quality_report(struct hci_dev *hdev, bool enable) +{ + struct intel_debug_features features; + int err; + + bt_dev_dbg(hdev, "enable %d", enable); + + /* Read the Intel supported features and if new exception formats + * supported, need to load the additional DDC config to enable. + */ + err = btintel_read_debug_features(hdev, &features); + if (err) + return err; + + /* Set or reset the debug features. */ + if (enable) + err = btintel_set_debug_features(hdev, &features); + else + err = btintel_reset_debug_features(hdev, &features); + + return err; +} +EXPORT_SYMBOL_GPL(btintel_set_quality_report); + MODULE_AUTHOR("Marcel Holtmann "); MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION); MODULE_VERSION(VERSION); diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index d184064a5e7c..0926b8196021 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -175,6 +175,9 @@ int btintel_read_debug_features(struct hci_dev *hdev, struct intel_debug_features *features); int btintel_set_debug_features(struct hci_dev *hdev, const struct intel_debug_features *features); +int btintel_reset_debug_features(struct hci_dev *hdev, + const struct intel_debug_features *features); +int btintel_set_quality_report(struct hci_dev *hdev, bool enable); #else static inline int btintel_check_bdaddr(struct hci_dev *hdev) @@ -307,4 +310,10 @@ static inline int btintel_set_debug_features(struct hci_dev *hdev, return -EOPNOTSUPP; } +static inline int btintel_reset_debug_features(struct hci_dev *hdev, + const struct intel_debug_features *features) +{ + return -EOPNOTSUPP; +} + #endif diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 97414746c029..9a860e4d8777 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2918,6 +2918,9 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) btintel_load_ddc_config(hdev, ddcname); } + hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT); + bt_dev_dbg(hdev, "HCI_QUALITY_REPORT cleared"); + /* Read the Intel version information after loading the FW */ err = btintel_read_version(hdev, &ver); if (err) @@ -3005,6 +3008,9 @@ static int btusb_setup_intel_newgen(struct hci_dev *hdev) */ btintel_load_ddc_config(hdev, ddcname); + hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT); + bt_dev_dbg(hdev, "HCI_QUALITY_REPORT cleared"); + /* Read the Intel version information after loading the FW */ err = btintel_read_version_tlv(hdev, &version); if (err) @@ -4665,6 +4671,7 @@ static int btusb_probe(struct usb_interface *intf, hdev->set_diag = btintel_set_diag; hdev->set_bdaddr = btintel_set_bdaddr; hdev->cmd_timeout = btusb_intel_cmd_timeout; + hdev->set_quality_report = btintel_set_quality_report; set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); @@ -4679,6 +4686,7 @@ static int btusb_probe(struct usb_interface *intf, hdev->set_diag = btintel_set_diag; hdev->set_bdaddr = btintel_set_bdaddr; hdev->cmd_timeout = btusb_intel_cmd_timeout; + hdev->set_quality_report = btintel_set_quality_report; set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); -- 2.32.0.554.ge1b32706d8-goog