Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1866477rwo; Thu, 3 Aug 2023 00:31:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlF42ngnAUVs7rI5Bgb2b74keBe4pfoqYgoRsbZAXl0hlitmdKiaUmHTAWaAsiE2w7GiE7js X-Received: by 2002:a17:906:8a75:b0:994:4f17:ba73 with SMTP id hy21-20020a1709068a7500b009944f17ba73mr6801067ejc.11.1691047881381; Thu, 03 Aug 2023 00:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691047881; cv=none; d=google.com; s=arc-20160816; b=fSPf2y0nsCUNTymr7ieLUyZkIa5xE/krzBL01KjNjUjKqgk51LYutYxX6Rjsl/BGp3 k+uqXool6/t0vMSCRRp5ieM5pQqfRql/jUSJ1+2CNaiP4T5KOxq1m2VcFc3yitBk2zAy pj+xlyVAYKlAU4gPg9IQAUx8pgP7Lug+eSLwsOrU8Jl2vzcCmjcjKUFXcrcv+HJ1Pfcj i/3A7VpTPJy1FCikcoWYjx2QYvceX2XjROdoxOrGiKMevIY+7ipK5E/53uJpkuIooNoF rllt4ab1Du5B9H6ddHoh19KpDsYEL2/6pDQMwkr44aAlQmhw1m7futSzzN11yLtECAUi Bxmg== 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=l+suyGsoe41ErzmRfO+VlfYJ9OlO3qrQAsgpsbKpqkI=; fh=MJW3bcwpcCdWq0ria43znzdI422V5j7eQ3I8rNP6zeA=; b=d8QXOGkcw+0gZbFU7YvaEpkHmpDycE+JBLQH+Ec19K+MBgLsVF7Fn6n9ZAvrcEOFiT EzOwz3TNWpSau7NNM1UAbvz5wutRqA+qVob+BZbgEPgbLwhgdFEvp0gRaHTMQyGtMm55 LgNrMLf+wQF/vCq54KVjp+nDu49XQ/t1nU+WApV21zRaSsl7E4pXP+hXQRqYZi98T/Ke qf58Y4mEyTApOpvIRxwouOU9A+WpLEyDPWwHIgd/rCWhvtgr4TiOhpVqOXs10FqXN9G3 c00H3VHf6No0xS+ojBP3vlr18P3+dxj11vRbPLka60mubpVIBPA3fI3rCAwg0N5kF2fB 8C7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=iORqZJa7; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xo24-20020a170907bb9800b0099316721725si8463501ejc.1044.2023.08.03.00.31.06; Thu, 03 Aug 2023 00:31:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@quicinc.com header.s=qcppdkim1 header.b=iORqZJa7; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233397AbjHCHRa (ORCPT + 58 others); Thu, 3 Aug 2023 03:17:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbjHCHR3 (ORCPT ); Thu, 3 Aug 2023 03:17:29 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ABA1FF for ; Thu, 3 Aug 2023 00:17:28 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3736ss7A005034; Thu, 3 Aug 2023 07:17:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=l+suyGsoe41ErzmRfO+VlfYJ9OlO3qrQAsgpsbKpqkI=; b=iORqZJa7SY3+GeKFXgiv3EMjoIdzUHek0kYJCcxkmfDWLn70eig4ISRWzoLNph4CMFT2 Uu8KAzgJhatuhMWnkZzC9iNFJk1Q9AQcjIacHjdh2RJHAQZ6x8nPLMpoyLvj95p2YN+/ N+Rl3gWiBy4tzqOFjdvMXxa7STB1+EfAp9dTHqOo6IzS+jZgSveSxNICmwBAS5M82WZ5 odxevkgXyeCsIce2v5b45xSW8NYlxDNekhIBPxyeWIt02FBDu8PQgUQUVtWKITffCJGT oqT4/OGtKFAnF6lwfZ0S5SfMbiwME4+Rd57vOwS2ffBfxeXsnjYJyFCyFCLzGtI6uA4+ gA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s7sgnhheb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Aug 2023 07:17:22 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3737HLmw017328 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 3 Aug 2023 07:17:21 GMT Received: from wgong-HP3-Z230-SFF-Workstation.qca.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Thu, 3 Aug 2023 00:17:20 -0700 From: Wen Gong To: CC: , Baochen Qiang , Wen Gong Subject: [PATCH v5 3/5] wifi: ath11k: fix a possible dead lock caused by ab->base_lock Date: Thu, 3 Aug 2023 03:16:59 -0400 Message-ID: <20230803071701.15084-4-quic_wgong@quicinc.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230803071701.15084-1-quic_wgong@quicinc.com> References: <20230803071701.15084-1-quic_wgong@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: Respg-N276ZfthKsMqNgT7PR4H01btz4 X-Proofpoint-GUID: Respg-N276ZfthKsMqNgT7PR4H01btz4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-03_05,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 mlxlogscore=973 priorityscore=1501 impostorscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308030064 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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-wireless@vger.kernel.org From: Baochen Qiang spin_lock/spin_unlock are used in ath11k_reg_chan_list_event to acquire/release ab->base_lock, for now this is safe because that function is only called in soft IRQ context. But ath11k_reg_chan_list_event() will be called from process context in an upcoming patch, and this can result in a deadlock if ab->base_lock is acquired in process context and then soft IRQ occurs on the same CPU and tries to acquire that lock. Fix it by using spin_lock_bh and spin_unlock_bh instead. Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23 Fixes: 69a0fcf8a9f2 ("ath11k: Avoid reg rules update during firmware recovery") Signed-off-by: Baochen Qiang Signed-off-by: Wen Gong --- drivers/net/wireless/ath/ath11k/wmi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 1fb445106872..c427299b7202 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -7138,13 +7138,13 @@ int ath11k_reg_handle_chan_list(struct ath11k_base *ab, /* Avoid default reg rule updates sent during FW recovery if * it is already available */ - spin_lock(&ab->base_lock); + spin_lock_bh(&ab->base_lock); if (test_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags) && ab->default_regd[pdev_idx]) { - spin_unlock(&ab->base_lock); + spin_unlock_bh(&ab->base_lock); goto retfail; } - spin_unlock(&ab->base_lock); + spin_unlock_bh(&ab->base_lock); if (pdev_idx >= ab->num_radios) { /* Process the event for phy0 only if single_pdev_only @@ -7194,7 +7194,7 @@ int ath11k_reg_handle_chan_list(struct ath11k_base *ab, ab->reg_info_store[pdev_idx] = *reg_info; } - spin_lock(&ab->base_lock); + spin_lock_bh(&ab->base_lock); if (ab->default_regd[pdev_idx]) { /* The initial rules from FW after WMI Init is to build * the default regd. From then on, any rules updated for @@ -7214,7 +7214,7 @@ int ath11k_reg_handle_chan_list(struct ath11k_base *ab, ab->default_regd[pdev_idx] = regd; } ab->dfs_region = reg_info->dfs_region; - spin_unlock(&ab->base_lock); + spin_unlock_bh(&ab->base_lock); return 0; -- 2.40.1