Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp193196pxt; Wed, 4 Aug 2021 08:51:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDwkCWntgEVjpGldRGG2VEZSzNH3nWT09cO9X78/za5utuZl5Lqa6zHNR5HynrxIGYNmTn X-Received: by 2002:aa7:d6cf:: with SMTP id x15mr455600edr.59.1628092272095; Wed, 04 Aug 2021 08:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628092272; cv=none; d=google.com; s=arc-20160816; b=ihB3QEdQnoaIqNvlzVWrDG4hHicXdcaBZ3Ubg9vWVH7j1TXr43vr7Qg6Zy6LUKAkbf 7QwclCYVQyWTljItJRwHuJ5PPXSlRn59gmyAIB0HFGTqRQce+LMwFE2gAD8W8mseRHRo 2sjuRq//IOgKN+nGD7y2bLbjIcM18+2lM/Ir3/Ydetj6VLOvgSqTi24IMU6xqvzWam8p SCPe3z2o81pf+frhgJkD9ZXI/q2UgGmeuOaR2UAOS+1OnQs7cMvx+W0kC20bwu/mT0I0 bBNLhz1ZA5YiqkQAUIULDT0OWOoGXKAD9TiIrKBnxxBQw2mR4nW0l3Cs0f6bMZl+P4n/ 23kQ== 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=TRKYkdOIgWJ5EiGOGovL7BoCL888xKaE/ywEpPEztaE=; b=j25kCeuW7WlLvE0vr8g+f85AT4wawwp2joZ1BLzq2b448QI+In44hmjV4zonkHdkwC P20tnUmiSBR9uI0OfzwllIeYwP/Uv9Airi9/2SY1pYakxVuy62Oeg6FFHnNAc+ONhkel K/QD4725TQTQU94iMD4eWS2ZKHDmjNSHEtIPgcn+EHrddYZIFXbmSb07BMIaKRAKlLc2 VXt1Zqi4evxPJTuPuMrH004iFAdVmeBpjKqXZkZd8tePIlF8qwvKteMPIc52bf8pj9e2 Woemsk9bTBk39ZTsmYX8O+XCA3DSVp2eJMStn1AheJCoMZewmF0SGlnT0uwbyTK/s9EA 9MSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nGMnEBds; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dh13si2308678edb.447.2021.08.04.08.50.31; Wed, 04 Aug 2021 08:51:12 -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=@gmail.com header.s=20161025 header.b=nGMnEBds; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232361AbhHDPtA (ORCPT + 99 others); Wed, 4 Aug 2021 11:49:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239456AbhHDPs6 (ORCPT ); Wed, 4 Aug 2021 11:48:58 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B05FC0613D5; Wed, 4 Aug 2021 08:48:44 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id pj14-20020a17090b4f4eb029017786cf98f9so4188327pjb.2; Wed, 04 Aug 2021 08:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TRKYkdOIgWJ5EiGOGovL7BoCL888xKaE/ywEpPEztaE=; b=nGMnEBdsX4+MpiNfdvpcYZqkEXFJ4tGdh6hc/ltfFv7odyfHgRyqi3UYjNi9PRnx67 YiVXS1xjUN9bFFrqHRt2ROQzvhtI9acxdZfguDZsnIA/Vf9kKZQGTyjuQXqcZhNvjF7j 9xecdG/MkBcM/0CCWaBmiC5IvKJW+hXe5Hi09/awZOGg2YGlYNTOV3QPiPikv7QzChTA rwTdzsmSNMzcbyTFvR9QM1rcpiKsDcxxGASQRz+brZIY5M7vIVMQyj2zadSk/FXtMfP2 zV8SY7Tr4vL8lZLL7MQ9JZ5oke67NmQnJwH/h9FdEdDq3mrSxfbzRozaDiJJ836PZSt9 +ekQ== 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=TRKYkdOIgWJ5EiGOGovL7BoCL888xKaE/ywEpPEztaE=; b=UxTVURf896xassJYsF4eDci21YCe3rbaXMmFsUAi8Vh2Ab+Q7F7u9/5GUbuARF3oMi gIRKoc7TcUCODDFdR8kUVip+mWtp0Wfg6PrkZ0dOllJ9gHW2Y7kyEF3JKMAd1gBwaXfy kESjfOG5mRaDz4DIHAEyf372aJSzI/7DM9R0ZwlEmGX4L0mpahcl3yWJMllEO/Q+I1cy SlGubvpRFnlDTuIRLntjhUhb4q+TGWTIRbXizxMjvEWC1CiH4tU0H3yAkRrHFsLeP0lO iBKtXKiccU6okRwl06CFNeTURfTRH2bPBRSG9Hpnk6ksoEcC/6Bb3LgDzZjxLgHAZlIm hUeg== X-Gm-Message-State: AOAM533WesUG2opAQbeWR84TzJhmZ2vUqOJBnf/WbgOvUxik58sfA1uJ uHV0szckDgJOxpIB+CT1cf4= X-Received: by 2002:a05:6a00:888:b029:3c3:ff1:38e with SMTP id q8-20020a056a000888b02903c30ff1038emr10350145pfj.17.1628092124217; Wed, 04 Aug 2021 08:48:44 -0700 (PDT) Received: from localhost.localdomain ([118.200.190.93]) by smtp.gmail.com with ESMTPSA id b15sm4007274pgj.60.2021.08.04.08.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 08:48:43 -0700 (PDT) From: Desmond Cheong Zhi Xi To: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, davem@davemloft.net, kuba@kernel.org, sudipm.mukherjee@gmail.com Cc: Desmond Cheong Zhi Xi , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, gregkh@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: [RESEND PATCH v5 3/6] Bluetooth: switch to lock_sock in SCO Date: Wed, 4 Aug 2021 23:47:09 +0800 Message-Id: <20210804154712.929986-4-desmondcheongzx@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210804154712.929986-1-desmondcheongzx@gmail.com> References: <20210804154712.929986-1-desmondcheongzx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Since sco_sock_timeout is now scheduled using delayed work, it is no longer run in SOFTIRQ context. Hence bh_lock_sock is no longer necessary in SCO to synchronise between user contexts and SOFTIRQ processing. As such, calls to bh_lock_sock should be replaced with lock_sock to synchronize with other concurrent processes that use lock_sock. Signed-off-by: Desmond Cheong Zhi Xi --- net/bluetooth/sco.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 558f8874b65e..1246e6bc09fe 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -93,10 +93,10 @@ static void sco_sock_timeout(struct work_struct *work) BT_DBG("sock %p state %d", sk, sk->sk_state); - bh_lock_sock(sk); + lock_sock(sk); sk->sk_err = ETIMEDOUT; sk->sk_state_change(sk); - bh_unlock_sock(sk); + release_sock(sk); sco_sock_kill(sk); sock_put(sk); @@ -199,10 +199,10 @@ static void sco_conn_del(struct hci_conn *hcon, int err) if (sk) { sock_hold(sk); - bh_lock_sock(sk); + lock_sock(sk); sco_sock_clear_timer(sk); sco_chan_del(sk, err); - bh_unlock_sock(sk); + release_sock(sk); sco_sock_kill(sk); sock_put(sk); @@ -1111,10 +1111,10 @@ static void sco_conn_ready(struct sco_conn *conn) if (sk) { sco_sock_clear_timer(sk); - bh_lock_sock(sk); + lock_sock(sk); sk->sk_state = BT_CONNECTED; sk->sk_state_change(sk); - bh_unlock_sock(sk); + release_sock(sk); } else { sco_conn_lock(conn); @@ -1129,12 +1129,12 @@ static void sco_conn_ready(struct sco_conn *conn) return; } - bh_lock_sock(parent); + lock_sock(parent); sk = sco_sock_alloc(sock_net(parent), NULL, BTPROTO_SCO, GFP_ATOMIC, 0); if (!sk) { - bh_unlock_sock(parent); + release_sock(parent); sco_conn_unlock(conn); return; } @@ -1155,7 +1155,7 @@ static void sco_conn_ready(struct sco_conn *conn) /* Wake up parent */ parent->sk_data_ready(parent); - bh_unlock_sock(parent); + release_sock(parent); sco_conn_unlock(conn); } -- 2.25.1