Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp699752pxa; Fri, 14 Aug 2020 15:48:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdbMJxTdHfxvuKr3CL1oY9ejv5NX3EH+UXF1Ic/5jwqYuJo1lM8Qg3UIkejmKlrmP+1Mbo X-Received: by 2002:a17:906:bc52:: with SMTP id s18mr4270416ejv.298.1597445301023; Fri, 14 Aug 2020 15:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597445301; cv=none; d=google.com; s=arc-20160816; b=JzwdwdYNxPx7MHIP+W7oDCj/8RIiand23yYqZANcUEnXSVB7UIlrFFuRPYjY2d/dG8 sPwTHPow+Gaxu5NptuC0pj8BaZy/7bPOhUGGBcdrTzNbbGdoymHb3ymre3OzNLWDrKJU wwuylDZxuPiAwvYPvSWkZR6JZiZKowtsJ633KmZ7Xiu5s3942MKzRU/Ys8E8wC0ZrpKa RrdexBYDmvZRatf4UhantIb3rdY74d4JKbX1DrWPb3GCEda+FNKLmsSNSrNX8ZYIqlPE ohQDyf0mXP+QoOxp7dM+JMvrMySMIZt51ZAorMznZAupZOTsv3WLJJYIkqbgJi1MxYZp zoog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5jRl27RMtgZLeq7b/WHxRkukWBIOKeVCPevK+sNiPhQ=; b=AXyl5eX/ntXOMEJJUXeAnbWaeboOPrd+PZsa0HSgiB9ENhPgS4wc4RixCRBaRfFEf4 OGG5KPAVlBJSxaoyHT6arcEPCnHhxwbdJ+0jjJTkxjK4j5sF+2sbQleI3+VDebopa8bP zfFS5eC9C59Rzb7p2J+qhz7Yu9iDspudB6S5BjSp+TIzxQmmcn5g2wstpdAPt/7uDNaN +ips52JHh7coEW46XEFuEt+WyCroD+tkTc9n8XPHOx2LKr0OE7HgtOWnkFXe3xPCTamX zQ0f4lkRS7mZwZvfAK4fW1Ejqu8ayu7B1fObxEir4i0D+FBUJg+FXeDHVhyMnIpX657N HSRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=k73o73VN; 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; 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 q24si6068415eds.349.2020.08.14.15.47.58; Fri, 14 Aug 2020 15:48:21 -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; dkim=pass header.i=@chromium.org header.s=google header.b=k73o73VN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727093AbgHNWXo (ORCPT + 99 others); Fri, 14 Aug 2020 18:23:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbgHNWXo (ORCPT ); Fri, 14 Aug 2020 18:23:44 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6859C061388 for ; Fri, 14 Aug 2020 15:23:43 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id k13so4784497plk.13 for ; Fri, 14 Aug 2020 15:23:43 -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:mime-version :content-transfer-encoding; bh=5jRl27RMtgZLeq7b/WHxRkukWBIOKeVCPevK+sNiPhQ=; b=k73o73VNd0qn9M+iiKly87GFMMXb6KyBorDW4eREbb7tWN2jSXYRFziRAoYgSezuUF FLz13Od/1weIFdHYZAkH4EE6DZ2zj7DIZfLAK/em3ojP/RtKqLTLGoQKKszjB6dJ4pV9 mte4YoB6Bc6FECyWkOAdnIkWLrrXIYtyO/yYs= 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:mime-version :content-transfer-encoding; bh=5jRl27RMtgZLeq7b/WHxRkukWBIOKeVCPevK+sNiPhQ=; b=jBgdRzznfNLmoYPcO5+HPpkboy6plBsqd4h1QVUp87h2jBmk5KatyvLaDvwUEhhIzM qmdWhwDwzax0TTJ7eCzpsXtylCxSI1CNh7vvkw4Us/AMm6Gy1XlFEMK/elXr15RVRvD9 KWZhi6n/rjwLadR618iXXXnwqiDLulwofDvYvlLRa6hE0D3uFO6IJKU49cZA4cQcSCi8 j2ro51T7doQF33Oq9b68YhXJZdO5lTOQKgourpQgNvGJe3kISEpuzMru95BguVSPCCfG HwuoO3k7HoaJoP+Vzq+lrvbcALKoOMUFJPifJ6aAn42gla6ARX+CCu8lQHKwAE3FxWab NSQw== X-Gm-Message-State: AOAM530syvcmflvglFz81PnhKnkk+Sl2yId6V6SBKTWpYl/owSaetTT4 //Uq9sKlRK8YddutYnXrHFzmaw== X-Received: by 2002:a17:902:82c2:: with SMTP id u2mr3422745plz.239.1597443823248; Fri, 14 Aug 2020 15:23:43 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id a17sm9302460pgi.26.2020.08.14.15.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 15:23:42 -0700 (PDT) From: Abhishek Pandit-Subedi To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi , Daniel Winkler , "David S. Miller" , Johan Hedberg , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski Subject: [PATCH] bluetooth: Set ext scan response only when it exists Date: Fri, 14 Aug 2020 15:23:36 -0700 Message-Id: <20200814152323.1.Ib022565452fde0c02fbcf619950ef868715dd243@changeid> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Only set extended scan response only when it exists. Otherwise, clear the scan response data. Per the core spec v5.2, Vol 4, Part E, 7.8.55 If the advertising set is non-scannable and the Host uses this command other than to discard existing data, the Controller shall return the error code Invalid HCI Command Parameters (0x12). On WCN3991, the controller correctly responds with Invalid Parameters when this is sent. That error causes __hci_req_hci_power_on to fail with -EINVAL and LE devices can't connect because background scanning isn't configured. Here is an hci trace of where this issue occurs during power on: < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25 Handle: 0x00 Properties: 0x0010 Use legacy advertising PDUs: ADV_NONCONN_IND Min advertising interval: 181.250 msec (0x0122) Max advertising interval: 181.250 msec (0x0122) Channel map: 37, 38, 39 (0x07) Own address type: Random (0x01) Peer address type: Public (0x00) Peer address: 00:00:00:00:00:00 (OUI 00-00-00) Filter policy: Allow Scan Request from Any, Allow Connect... TX power: 127 dbm (0x7f) Primary PHY: LE 1M (0x01) Secondary max skip: 0x00 Secondary PHY: LE 1M (0x01) SID: 0x00 Scan request notifications: Disabled (0x00) > HCI Event: Command Complete (0x0e) plen 5 LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 1 Status: Success (0x00) TX power (selected): 9 dbm (0x09) < HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7 Advertising handle: 0x00 Advertising random address: 08:FD:55:ED:22:28 (OUI 08-FD-55) > HCI Event: Command Complete (0x0e) plen 4 LE Set Advertising Set Random Address (0x08|0x0035) ncmd Status: Success (0x00) < HCI Command: LE Set Extended Scan Response Data (0x08|0x0038) plen 35 Handle: 0x00 Operation: Complete scan response data (0x03) Fragment preference: Minimize fragmentation (0x01) Data length: 0x0d Name (short): Chromebook > HCI Event: Command Complete (0x0e) plen 4 LE Set Extended Scan Response Data (0x08|0x0038) ncmd 1 Status: Invalid HCI Command Parameters (0x12) Signed-off-by: Abhishek Pandit-Subedi Reviewed-by: Daniel Winkler --- net/bluetooth/hci_request.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index e0269192f2e536..e17bc8a1c66ddd 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1533,11 +1533,14 @@ void __hci_req_update_scan_rsp_data(struct hci_request *req, u8 instance) memset(&cp, 0, sizeof(cp)); - if (instance) + /* Extended scan response data doesn't allow a response to be + * set if the instance isn't scannable. + */ + if (get_adv_instance_scan_rsp_len(hdev, instance)) len = create_instance_scan_rsp_data(hdev, instance, cp.data); else - len = create_default_scan_rsp_data(hdev, cp.data); + len = 0; if (hdev->scan_rsp_data_len == len && !memcmp(cp.data, hdev->scan_rsp_data, len)) -- 2.28.0.220.ged08abb693-goog