Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp274348rwn; Wed, 7 Sep 2022 16:34:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR7BX0lulqVtuylGs5ZOOun1Q7m5lsloPNSj7U91tgo1zaq1NgubaiEniIcGclGhyWoiGVED X-Received: by 2002:a17:90a:c782:b0:1f7:a4ed:11a1 with SMTP id gn2-20020a17090ac78200b001f7a4ed11a1mr1027828pjb.12.1662593663495; Wed, 07 Sep 2022 16:34:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662593663; cv=none; d=google.com; s=arc-20160816; b=oiCV8fg53GqqSL1VGNS/MAb+IjPHJTZ9b7XpUvhtYiQhDI/znYvUJmGPzZ+An+Kgwy kJLlqYD82ddO4S21sr5k7C4vh51ms1Hyfr/fcCM6DymODcU/kGkEvO0MrkyGB7SG+48R OmmS6h3/s3vMB4RVgzKGbzM+Bc9PL7mQQpNE/OE5//2rN6a94MHgtJulfktwmmPZsV4n E+IX0Gv2R/WHQBAo9c2xm4ZyAgL/Pn83stZ/HBBnwOxYtDsOXHwVNlDdiTX7IyCmyP9u pPO7xkNMWxctlhh4HiTGCuNd1j9cTIByfuTQ4qgzsE2815ENFekqCIH+NGEi1+HWJCd6 7qLw== 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 :message-id:date:subject:to:from:dkim-signature; bh=k8Xtps4ZdAE3VhEKw8jsuRmLjTJAgNC/3l4zoVX7kLw=; b=xn/owe7mOoDbEj5+knxhVbHJYjW4qIum0syiXnSgA5gD4yDJdegtg7wlYQvBtO84Tv sQrBj3bQPqOG10HRmTJEmR+rDzsSfOvuj1pI3Z0EwHQoLfWPhz6wyoPdYSSFLurF07VS hycxIlxDB7C+fHuZvdsHsae233OyxA2QTykR561q7Dn95ZTHYvQvJ+ZKuj8TlLLEbEaL WdqIFTsHThzDE5/c0Z0klE+0xFAdhAtEjAt00Dg4Z0BDd25EcidkE7MuLyQfc8UsOXqP fYFQ6l9KWR9huN7bFn2rXMhrS4U5jaSsjx6UBNekZQra2gRwTcfi7IyaQv1fjjBs58aI lsbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=g9mipdVl; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mi15-20020a17090b4b4f00b001f0d1914b69si482472pjb.9.2022.09.07.16.33.29; Wed, 07 Sep 2022 16:34:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=g9mipdVl; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbiIGXWg (ORCPT + 99 others); Wed, 7 Sep 2022 19:22:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbiIGXWf (ORCPT ); Wed, 7 Sep 2022 19:22:35 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E346F9E0C2 for ; Wed, 7 Sep 2022 16:22:34 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id r17so2578692pgr.7 for ; Wed, 07 Sep 2022 16:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date; bh=k8Xtps4ZdAE3VhEKw8jsuRmLjTJAgNC/3l4zoVX7kLw=; b=g9mipdVlqj89UoMbKU4H2ODk8uD9ogDrwWpQ3aqRu2/jlf5OopRsIaaPtmqkS7gVUd bRMZoC6kcKJg62iWqP5z1eK+zsNhrw4X/nOilCHtcVq1grkCohdoJ/DBzZGB3GiS//kv XuDqSeovlVIVXhmRta5Ul3czl98iRgb12AXjuwS01BzXgJneUOwRGUTQsfL9hvm8pC6X kYfWTw/oAZGwzxORD3a5072axBsmlNJgjcrM7HuE+uiQIAiwPfeM2illZIlccBQvJaKB TeGH3oT5sImCVPz1v3y8oQxCqRiQJGRykC0AS9YCUL2fk7KZWYgKd6UoNFOeSOtGEPQ6 T/3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=k8Xtps4ZdAE3VhEKw8jsuRmLjTJAgNC/3l4zoVX7kLw=; b=hG8+iBbw/27R4kCowyUYUCM9vH+Dzmo+dQH625VvLPvc5Duj1hirmD4Aqz3bj4xQff HHz9gDkVOdKFe3aC4vYqW3GQG11XfjZfZtvk4EpGmwnxzPIOdKETmZUCCMSdb6t2NhyB bTdquwo3OwRKjOjVVvYtIDOLIGblq2ylBLL2YXGsZyUR2XbYto6OtWI1GHMDuKjKDmoM fMPevFZET4EW6C3AvIXv26RLhEJRJMCbDRmZKhT+JU1zDjsM1zgDfs0k6vAGoeAnifSc J8f2jNZVO1UBHgDDjbwP+AEqjzhyHdIHweqYWovCYgXqtfB+NgyWOXB2TlSOsRCWVegE O1dw== X-Gm-Message-State: ACgBeo2Il6JEmW3mDzjFMeTI2CVabI65DrL8TrZuz7NMt/UHOtitl43e QiMtFeApOjLBoK79ecNBqIAB/OWyzus15Q== X-Received: by 2002:a63:5522:0:b0:42b:976d:dcd4 with SMTP id j34-20020a635522000000b0042b976ddcd4mr5152573pgb.421.1662592953824; Wed, 07 Sep 2022 16:22:33 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id x11-20020a170902ec8b00b00176b63535adsm7241789plg.260.2022.09.07.16.22.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 16:22:33 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 1/2] Bluetooth: MGMT: Fix Set PHY Configuration command Date: Wed, 7 Sep 2022 16:22:31 -0700 Message-Id: <20220907232232.3248525-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz The command shall accept any subset that is considered configurable but instead it was only accepting the exact match causing errors such as: [mgmt]# phy Supported phys: BR1M1SLOT BR1M3SLOT BR1M5SLOT EDR2M1SLOT EDR2M3SLOT EDR2M5SLOT EDR3M1SLOT EDR3M3SLOT EDR3M5SLOT LE1MTX LE1MRX LE2MTX LE2MRX LECODEDTX LECODEDRX Configurable phys: BR1M3SLOT BR1M5SLOT EDR2M1SLOT EDR2M3SLOT EDR2M5SLOT EDR3M1SLOT EDR3M3SLOT EDR3M5SLOT LE2MTX LE2MRX LECODEDTX LECODEDRX Selected phys: BR1M1SLOT BR1M3SLOT BR1M5SLOT EDR2M1SLOT EDR2M3SLOT EDR2M5SLOT EDR3M1SLOT EDR3M3SLOT EDR3M5SLOT LE1MTX LE1MRX [mgmt]# phy BR1M3SLOT BR1M5SLOT EDR2M1SLOT EDR2M3SLOT EDR2M5SLOT EDR3M1SLOT EDR3M3SLOT EDR3M5SLOT LE2MTX LE2MRX Could not set PHY Configuration with status 0x0d (Invalid Parameters) Fixes: 0314f2867fa0 ("Bluetooth: Implement Set PHY Confguration command") Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/mgmt.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 4c421ebac669..34443db21e44 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -4020,8 +4020,8 @@ static int set_default_phy_sync(struct hci_dev *hdev, void *data) if (!(selected_phys & MGMT_PHY_LE_RX_MASK)) cp_phy.all_phys |= 0x02; - if (selected_phys & MGMT_PHY_LE_1M_TX) - cp_phy.tx_phys |= HCI_LE_SET_PHY_1M; + /* 1M PHY shall always be supported */ + cp_phy.tx_phys |= HCI_LE_SET_PHY_1M; if (selected_phys & MGMT_PHY_LE_2M_TX) cp_phy.tx_phys |= HCI_LE_SET_PHY_2M; @@ -4029,8 +4029,8 @@ static int set_default_phy_sync(struct hci_dev *hdev, void *data) if (selected_phys & MGMT_PHY_LE_CODED_TX) cp_phy.tx_phys |= HCI_LE_SET_PHY_CODED; - if (selected_phys & MGMT_PHY_LE_1M_RX) - cp_phy.rx_phys |= HCI_LE_SET_PHY_1M; + /* 1M PHY shall always be supported */ + cp_phy.rx_phys |= HCI_LE_SET_PHY_1M; if (selected_phys & MGMT_PHY_LE_2M_RX) cp_phy.rx_phys |= HCI_LE_SET_PHY_2M; @@ -4049,14 +4049,13 @@ static int set_phy_configuration(struct sock *sk, struct hci_dev *hdev, { struct mgmt_cp_set_phy_configuration *cp = data; struct mgmt_pending_cmd *cmd; - u32 selected_phys, configurable_phys, supported_phys, unconfigure_phys; + u32 selected_phys, supported_phys; u16 pkt_type = (HCI_DH1 | HCI_DM1); bool changed = false; int err; bt_dev_dbg(hdev, "sock %p", sk); - configurable_phys = get_configurable_phys(hdev); supported_phys = get_supported_phys(hdev); selected_phys = __le32_to_cpu(cp->selected_phys); @@ -4065,13 +4064,6 @@ static int set_phy_configuration(struct sock *sk, struct hci_dev *hdev, MGMT_OP_SET_PHY_CONFIGURATION, MGMT_STATUS_INVALID_PARAMS); - unconfigure_phys = supported_phys & ~configurable_phys; - - if ((selected_phys & unconfigure_phys) != unconfigure_phys) - return mgmt_cmd_status(sk, hdev->id, - MGMT_OP_SET_PHY_CONFIGURATION, - MGMT_STATUS_INVALID_PARAMS); - if (selected_phys == get_selected_phys(hdev)) return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_PHY_CONFIGURATION, -- 2.37.2