Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6131161rwn; Mon, 12 Sep 2022 22:17:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR6b8eTjs0R7Afgm8me3aoYohL+73XnW4mQj2YsUr7lAY7Ac3FJGC/lDuKs79sJSNho2Dq41 X-Received: by 2002:a63:ea05:0:b0:434:9dc1:a59f with SMTP id c5-20020a63ea05000000b004349dc1a59fmr27181439pgi.374.1663046220695; Mon, 12 Sep 2022 22:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663046220; cv=none; d=google.com; s=arc-20160816; b=xI8xCPzs12VyhDH5d5qD3lYrmJSaw8gud1ibDuDFOn+sXvBsVH3KaPEdKtHuYGNVNt ko7GCVBhB0WOlQJCwr+hwyMD9Vn/DDT5YEzfSdoNtRNAujTRRmTbct8D3/FhzvgOsavQ SvBsanS7iN7itkuApACIpFOUea3nZJym27i3DvXUUFNB9hR/4mHOaPzlq2pd6xHfn/ft elpptkHzZMgditEZ1ucLpxY9cqxJ2P04Qj7zBNKcd4HPQDsFNf8ayhqQt2gaqLgSU+IS bAmscQ6RGpZ4Py59iadsE1D+ZLM9wbA0j5nAQnGskjUAJLw6kZsuls6vclvD/uR13dCw WmyA== 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=Qpd0ROgdLQAjxgDU9Payr7dGQLBeBHexWTtPP4UevJc=; b=M4/mQe9XNtEU8mFlQdMrZTxC26TyqqJV9/vTH9nZ8xt9TSkfEH7P1G8P73x1+gd/c4 UvkMYWrHUUXpB6OBCBz1X09vJnMe4cClFvEgL+huMc21NoUg02C87IEvlr4LS0NbaKQG EJk/pBKF8NBdQGd6CwtqSUE1nC8PYQJsuVGZzU5eOOIng8J6lVLQI40U72mqU4jOaHWN VXjyzua6fYYvYf0YaEC2fL8WXQn5IOJjfuhsihmGgoJz/P/v7dEsuNN2hmaIX3Xzeiyn TnKng+l9gzbcd6iUBdPUVPcFKpNxjj2PVuTfkEAylLMwkTQMqf2dQUGKVLBBcRJbP815 PJag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=M5JZIuo4; 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 192-20020a6302c9000000b00438d7ca729bsi8223874pgc.207.2022.09.12.22.16.50; Mon, 12 Sep 2022 22:17:00 -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=M5JZIuo4; 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 S229876AbiIMFQT (ORCPT + 64 others); Tue, 13 Sep 2022 01:16:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbiIMFPs (ORCPT ); Tue, 13 Sep 2022 01:15:48 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8246F4BD3C for ; Mon, 12 Sep 2022 22:15:46 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28D59Mqk003606; Tue, 13 Sep 2022 05:15:43 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=Qpd0ROgdLQAjxgDU9Payr7dGQLBeBHexWTtPP4UevJc=; b=M5JZIuo4AoLZKfUFEeUEzt4iwlp0Gg9ZeG/87mV8NXUmXR/QB+r1hy3Mqxvxe3teQ9oD oyC0b0YjFeUVL4NiM3gqmxTyfMt/3xKsE+v42x/wUtz7lBTcBkkBGML+Xc6mdon0JsC6 dwYQF8uPnZKF6iE3TjPAphQG04cQBW/fPg2c1Pi1r1oyOH8BaIHEKI4LAuQ27Qu1ksoG xE72KrgEXlVSYsgoY+/X95qRLv8NWIqHSmOEBTapm7KSBN4Aosec+Nvie9AAsjtNi6VE qfUJPI5wXw3RxSRtQTCCcYZZjuaDxOZyGh/JiOUidMOPSz1lq8ySLhvrKVFXemzpocFu iQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jgkgpe228-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Sep 2022 05:15:43 +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 28D5FgbH011558 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Sep 2022 05:15:42 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.986.29; Mon, 12 Sep 2022 22:15:40 -0700 From: Wen Gong To: CC: , Subject: [PATCH v3 05/15] wifi: ath11k: fix a possible dead lock caused by ab->base_lock Date: Tue, 13 Sep 2022 01:15:08 -0400 Message-ID: <20220913051518.23051-6-quic_wgong@quicinc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220913051518.23051-1-quic_wgong@quicinc.com> References: <20220913051518.23051-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: nasanex01a.na.qualcomm.com (10.52.223.231) 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-GUID: ogOMRnaSyCx5QKBZ3bUWeXvEsRYI2l25 X-Proofpoint-ORIG-GUID: ogOMRnaSyCx5QKBZ3bUWeXvEsRYI2l25 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-13_02,2022-09-12_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=896 priorityscore=1501 spamscore=0 bulkscore=0 malwarescore=0 impostorscore=0 clxscore=1015 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209130023 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 in an upcoming patch ath11k_reg_chan_list_event() will be called from process context, 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 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 d2d0873fda83..8187b644078b 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -6835,13 +6835,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 @@ -6891,7 +6891,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 @@ -6911,7 +6911,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.31.1