Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3945325pxf; Tue, 6 Apr 2021 04:28:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjOWyWuGxTVbhhpWwFknG4auofSQtuuR9DEb8cMRtVuJ8qkyPTjwFEMZk6Jqcv8jV33Rip X-Received: by 2002:a17:906:fa93:: with SMTP id lt19mr10405921ejb.182.1617708496746; Tue, 06 Apr 2021 04:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617708496; cv=none; d=google.com; s=arc-20160816; b=l8ZixdPVVCCrw+vIOWX+qxKIqOP7nNrvtJvde7GPpF28DlRBwOQZfEGko1+yliacKj bi7uW5ovJFaQJADiRZR8HnLBqjvtnu1ktYIbaiqyFJUmNDBeHa04lQuhXsDw/CyVFJRU ZItw8RJMld15NnpgElpHJZWyYhccSD0FPSC9k0MGNKRQ8radqLIDbX7iCByXr2p/3TR5 mjSideTAcVhr1vDYahCiwnUSyRVfTAyP1tSBg9QdStswp3uutCL7zwidP3+vr+OvMPy+ seUvTsQNZEP95y5JrZ96Etg2kfXMS3RKxh2qfAJ8L/wERdGZicWCaLumoCaAaNRcRNzG kH5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=to6Vxja+Arjc3jgF2y75CIMjsTw24v2WgNqXzBAN2G4=; b=LIRwIvDZOoLTfCA98PCAnHPx3G0OPi/0ja/XOWMRwbbXhrMs+y7odVNEeL6rpNje0N 376ztDwYZDV6K31VZaXjEJpTDD62v8osrP1JN6NlEIhtgfmx99QjMXEV/uiV3IRQ/Dbo a87Qok4C84f2Y2LS+AzMm/TN7uGA5tAFjNE12BvjxvE5fqCpQJXXttRqskT801gfqxnb Lu6hgFbd2/XvSVOEMQj2ppThjFriO5iXsnQ0oqpHk1TVnHvACnAFFDGajgRvFBs8bHLi spYbgRsee48+1tpki+PGgsxjVO4R9Co0rksqdVydiybH4ONsIUYKXp+G8ImaBkVAVA/8 wMnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jEYZqFK4; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s13si19252791edc.150.2021.04.06.04.27.50; Tue, 06 Apr 2021 04:28:16 -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=@google.com header.s=20161025 header.b=jEYZqFK4; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241839AbhDEXdk (ORCPT + 99 others); Mon, 5 Apr 2021 19:33:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241780AbhDEXdg (ORCPT ); Mon, 5 Apr 2021 19:33:36 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22A8BC061756 for ; Mon, 5 Apr 2021 16:33:29 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id k15so12207998ybh.6 for ; Mon, 05 Apr 2021 16:33:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=to6Vxja+Arjc3jgF2y75CIMjsTw24v2WgNqXzBAN2G4=; b=jEYZqFK4qYXZjXqxm8kJnUCJ/HGf/4pQIRB3IfRcS9nSXWq37L5cg4Hi2cjXeoec+Y QnyrSCmtSZLs/Wo+mR1kcl0lYR1DdUH485SifgpfypYPOhxj9SOOkLl5fZZ4tsAIQ9Qf rDIgDY5ZuSYQt3oPjxqLelVRZdVuEfncudKq9I++0cqVs9dEy1LV5rCOV698B0jjw4J5 CI39vHBdXuePVt9HTbWvUfu/6q6I4jfkGC/jm8Hx/STZPVNilKzwWk3DvjDaHzxLqAEX emx3YEzYVMaedIFqzd3/NrmWhZNUOa/AQb1U60F1GLzo9Bfpp6VOWQ8til8ccyzxFDBD woDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=to6Vxja+Arjc3jgF2y75CIMjsTw24v2WgNqXzBAN2G4=; b=F8nWyJ3AdMj28t/4YhUhsYtNlONxTB535sUdUTXNfIjtcKaKbuSFbYK13z0D6cSWIb oI9W2adT036zSBMGvS70CNEkRlcX8TflcbryRc1/+9b5eYZsVRVzQpIbmkZbcS6vHWDp g5CT5Qj4cjwef2IpNFig28y+9sD9IGH92vYu8XnSpJWJG6AwxHBkYXn6wODwU7cqOmN4 afoGY4yixNd4icfnnP1djlcCCBpMNuU9ST07ij9kWTH3FP1kWXlmMWLCHXp6Y6SyyEB/ 6rnXvHqfdoIOoP+UxMuRMAqtNl+ZhTEgwTdcvZZHbOo7EEgPeWP5Lc5R4up//MblkHK4 Uw3Q== X-Gm-Message-State: AOAM530uMMJfCTSPqCiVS9Q9IvXVMlIvG60vfNxLscZcunc3qrGLaVtw L4D1Ea9Y2aKfvPIhSlbI4kOe5prv24sSsyT66VCc X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:1cb3:ad22:2ed6:7c62]) (user=danielwinkler job=sendgmr) by 2002:a5b:448:: with SMTP id s8mr37252543ybp.363.1617665608348; Mon, 05 Apr 2021 16:33:28 -0700 (PDT) Date: Mon, 5 Apr 2021 16:33:05 -0700 In-Reply-To: <20210405233305.92431-1-danielwinkler@google.com> Message-Id: <20210405162905.2.Iaac4fb40841e46f9ab815bffee439c91e44f0639@changeid> Mime-Version: 1.0 References: <20210405233305.92431-1-danielwinkler@google.com> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog Subject: [PATCH 2/2] Bluetooth: Do not set cur_adv_instance in adv param MGMT request From: Daniel Winkler To: marcel@holtmann.org, linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler , Miao-chen Chou , "David S. Miller" , Jakub Kicinski , Johan Hedberg , Luiz Augusto von Dentz , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We set hdev->cur_adv_instance in the adv param MGMT request to allow the callback to the hci param request to set the tx power to the correct instance. Now that the callbacks use the advertising handle from the hci request (as they should), this workaround is no longer necessary. Furthermore, this change resolves a race condition that is more prevalent when using the extended advertising MGMT calls - if hdev->cur_adv_instance is set in the params request, then when the data request is called, we believe our new instance is already active. This treats it as an update and immediately schedules the instance with the controller, which has a potential race with the software rotation adv update. By not setting hdev->cur_adv_instance too early, the new instance is queued as it should be, to be used when the rotation comes around again. This change is tested on harrison peak to confirm that it resolves the race condition on registration, and that there is no regression in single- and multi-advertising automated tests. Reviewed-by: Miao-chen Chou Signed-off-by: Daniel Winkler --- net/bluetooth/mgmt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 09e099c419f251..59f8016c486626 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -7979,7 +7979,6 @@ static int add_ext_adv_params(struct sock *sk, struct hci_dev *hdev, goto unlock; } - hdev->cur_adv_instance = cp->instance; /* Submit request for advertising params if ext adv available */ if (ext_adv_capable(hdev)) { hci_req_init(&req, hdev); -- 2.31.0.208.g409f899ff0-goog