Received: by 2002:a05:7412:b112:b0:f9:3106:f1c0 with SMTP id az18csp128153rdb; Mon, 18 Dec 2023 00:59:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFGxJf7wQzSXs26h2gFwgTsJ/TRmj2RWBRMfCeoVrokMguvb7juOWscnW2rqu2JY3wN1tSo X-Received: by 2002:a05:622a:11cc:b0:425:4043:8d31 with SMTP id n12-20020a05622a11cc00b0042540438d31mr13423155qtk.76.1702889966701; Mon, 18 Dec 2023 00:59:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702889966; cv=none; d=google.com; s=arc-20160816; b=kdQ2IqKe6iCQpIe7+uP4Gj9GkGDsYladOdgNHwXd4PeHV2vfl/N+AbKD4E2ELWg7/o iNVuhXb1vXpNFkg3yVofQ2mm/jnWkpYB3oIu7kWPZq3Dzb1ZcfmRkfATV1BBXfuc05Hx bNKS0ruxLZ5MzFSRmbIItIhNG9oeU2iJj8QjnHijBRytudWLpLOpaDkAvJVDtEYUpTnE n+bCtskmLgcjbIU30I35U84z1fZ1HlPPkjmJXY9eLTKOSciNWKLbN91MPy5FKMhk7Hdg sr3G2zm9WnUkEHC5yM0eOQW55CjgtbNcQWr9azCmYEmVnGeJjCaLH8iZNSdiDTukVLvS i0yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+PFvKnl6l9vYkT//vzJAeMYyHimY6L+vXtOXI7QEk0s=; fh=HNEfiow5aIDtnUkYYiB/tbonwaEcG8+i6SMa583BOko=; b=VKtzd0hO6XWJg80kla6NB/ad6kM5pCMQ9Ig7FmMvwZJt3icAMZiaAHeo/p7VRMhWet plufqeBf5aZfa22fyVdElIrHAQcyKDBdWC+uiZr0IOibzFaK1khB3PDfgffy5OfiFWYA LGXVvPpRi+ZK+nx0o2+VaaUBbz/KgoyOdxFnQZdwr0RCFI18s8ZbRm1gMxDKz87qLLE8 JsBcUEKBZWBwhV0t5AT+4oJNwbbZtt1j/s+7SdAKI1SrghPoy5MwrXKmynlGRzqKjFJS LsXyWqdm8D/jhpgphnsi/pc4A0qHIX+9wj7IJ5msUNPbrPKiOt5TsPYHSMYLkUe8bP7L w7pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=dHP1hHiX; spf=pass (google.com: domain of linux-wireless+bounces-898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-898-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bb27-20020a05622a1b1b00b004236ed850d4si23889473qtb.166.2023.12.18.00.59.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 00:59:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=dHP1hHiX; spf=pass (google.com: domain of linux-wireless+bounces-898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-898-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 579DC1C22525 for ; Mon, 18 Dec 2023 08:59:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B52211706; Mon, 18 Dec 2023 08:59:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="dHP1hHiX" X-Original-To: linux-wireless@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E50A10A3A for ; Mon, 18 Dec 2023 08:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BI6uGGf019617; Mon, 18 Dec 2023 08:59:00 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=+PFvKnl6l9vYkT//vzJAeMYyHimY6L+vXtOXI7QEk0s=; b=dH P1hHiXKCPTV+tNsVj2wA3K8LA2hoqbtBWhLjhi/fuBsUwAjt9UvkWK7Eu901P+qm AuG8Q3XLl8EQrHnArrewsmiPMxdvrRZim6w3xrx4RGsqrC0ekAUfp19neleX19uO TtHL0iADlkvVcsSprGa1vtWfuVihQKkBh0HKLUsTZYt5VcCNf4yq4mC61j4SvIfR TjntbvkpqKuXvGBDRbGC+713JgXEElF+w+GajTRbwZPTGSc6x/PzyZoHDTSGwHIC YBA8tuxpQteqMSWTx0F+j+IQ1K6YzFq/fd0v8lf5UazBRuquRfezbcP2sdjY8Yv3 CZns98IFec8Ai+0gbNAQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v152qbsyg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Dec 2023 08:59:00 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BI8wxFv009813 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Dec 2023 08:58:59 GMT Received: from bqiang-Celadon-RN.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.40; Mon, 18 Dec 2023 00:58:58 -0800 From: Baochen Qiang To: CC: Subject: [PATCH v10 03/12] wifi: ath11k: fix a possible dead lock caused by ab->base_lock Date: Mon, 18 Dec 2023 16:58:35 +0800 Message-ID: <20231218085844.2658-4-quic_bqiang@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218085844.2658-1-quic_bqiang@quicinc.com> References: <20231218085844.2658-1-quic_bqiang@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: hHCbMkwk9R0q-mssDpFOTCPsCZS-1Axi X-Proofpoint-GUID: hHCbMkwk9R0q-mssDpFOTCPsCZS-1Axi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 phishscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1015 malwarescore=0 mlxlogscore=958 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312180064 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 Acked-by: Jeff Johnson --- v10: no change. v9: no change. v8: no change. v7: no change. 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 a48aafc79b90..9f8a62c334b0 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -7142,13 +7142,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 @@ -7201,7 +7201,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 @@ -7221,7 +7221,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.25.1