From patchwork Tue Mar 7 22:17:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Germann X-Patchwork-Id: 13164821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE8AFC742A7 for ; Tue, 7 Mar 2023 22:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbjCGWRx (ORCPT ); Tue, 7 Mar 2023 17:17:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230172AbjCGWRv (ORCPT ); Tue, 7 Mar 2023 17:17:51 -0500 Received: from stravinsky.debian.org (stravinsky.debian.org [IPv6:2001:41b8:202:deb::311:108]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 281A3ABB1B; Tue, 7 Mar 2023 14:17:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-Type:Content-ID:Content-Description; bh=JItJ57Z4GpJWKFyTqaNeN7pdg1hN+SPB7i8JZUMvOd4=; b=QY7Yq9K3qNpO7SGW1sUxlH1gjc 9qShVzOsGwVtmZH38w2uQzFcOwkybsMwQjV1HUwopPaqAtXL6V9elOmSnH7nFqmn+fvc/lwlkSuv1 NqTLMYI32Ggqw+LCecW/2sMcBOcth9e8j9VVHY1egSMi7fGWdP3uDUpkPVeEV+SrDr2dmtvyYafR7 HC8P0n+b/A3299HQZHohgx9k+QHAdHpTw0wtiaSkrhenYWp+lG/Qr83BWR1zjIobEZcuJOgTQ3M82 +JmLQ+j39Q1D7W5nS/YyYMy3lV9YeRADVX/vgmotlBl/O8xYP6YmTCy2VLNoKi1bySJU/YJh2GHpr y+TsCz+w==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1pZfcq-0034fC-RY; Tue, 07 Mar 2023 22:17:40 +0000 From: Bastian Germann To: Marcel Holtmann , Luiz Augusto von Dentz Cc: Vasily Khoruzhick , Johan Hedberg , "David S . Miller" , Eric Dumazet , Jakub Kicinski , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Bastian Germann Subject: [PATCH v6 1/2] Bluetooth: Add new quirk for broken local ext features page 2 Date: Tue, 7 Mar 2023 23:17:30 +0100 Message-Id: <20230307221732.3391-2-bage@debian.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307221732.3391-1-bage@debian.org> References: <20230307221732.3391-1-bage@debian.org> MIME-Version: 1.0 X-Debian-User: bage Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Vasily Khoruzhick Some adapters (e.g. RTL8723CS) advertise that they have more than 2 pages for local ext features, but they don't support any features declared in these pages. RTL8723CS reports max_page = 2 and declares support for sync train and secure connection, but it responds with either garbage or with error in status on corresponding commands. Signed-off-by: Vasily Khoruzhick Signed-off-by: Bastian Germann --- include/net/bluetooth/hci.h | 7 +++++++ net/bluetooth/hci_event.c | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 400f8a7d0c3f..997107bfc0b1 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -294,6 +294,13 @@ enum { * during the hdev->setup vendor callback. */ HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG, + + /* When this quirk is set, max_page for local extended features + * is set to 1, even if controller reports higher number. Some + * controllers (e.g. RTL8723CS) report more pages, but they + * don't actually support features declared there. + */ + HCI_QUIRK_BROKEN_LOCAL_EXT_FEATURES_PAGE_2, }; /* HCI device flags */ diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index ad92a4be5851..8d8547fa9032 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -886,8 +886,13 @@ static u8 hci_cc_read_local_ext_features(struct hci_dev *hdev, void *data, if (rp->status) return rp->status; - if (hdev->max_page < rp->max_page) - hdev->max_page = rp->max_page; + if (hdev->max_page < rp->max_page) { + if (test_bit(HCI_QUIRK_BROKEN_LOCAL_EXT_FEATURES_PAGE_2, + &hdev->quirks)) + bt_dev_warn(hdev, "broken local ext features page 2"); + else + hdev->max_page = rp->max_page; + } if (rp->page < HCI_MAX_PAGES) memcpy(hdev->features[rp->page], rp->features, 8);