Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1180236rdb; Wed, 20 Sep 2023 01:46:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnhuTko7IIKxtV18xubgVbvqhtxGr/eVod2kx6l5sQI3z/9AS5Hw9lTfEEzwourQJm4DEK X-Received: by 2002:a17:902:bd43:b0:1c5:7aac:6e5d with SMTP id b3-20020a170902bd4300b001c57aac6e5dmr1429250plx.66.1695199567507; Wed, 20 Sep 2023 01:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695199567; cv=none; d=google.com; s=arc-20160816; b=N3mxRrLe/IOO9om8fPCpLdQ3sGZfB+LepsxomuYiCcaI296OZKCeH/j/6xKKuLkYuN lxHrf5nKtUmrskgKS9uG8cA/337JQT9STIWuLsjfnZwik5vhXZtzIbMXNyRVNUzFq3+F VKIaSeOSJfEc7fkl7SBZG9R5+oOI8pXe32PQIMBRCJHjzDGbYkwytM5xQ8J9/eK12ZMe SxuE0moUDdoCpCrJ6bgp0b486zgyLNiLg8EB3uD6Kc3/DZvW8XG63PopDhGuuGJvtTky pAf60Bp1OtlcuWog+MYCc7vn5oLNHo7safBbM1SJhrG5SKtz2shlE6HiVKOOU5ddm6CW kS6Q== 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=EysjVsKhxKTBRNOBOtcafFbVC4vZxcWWUoM7+RoG6uY=; b=IUvBITLRagltb3xa73+HRCM+GPwXazoeam11xkDeQ4vI8yE30mpdGyLLSjvgl8zWix K3YSQqg4Xo1e/ng3Bh9B1+Q88vH991Snif2r5O6IISDyCOhBcqjnT3hdryuxt4Ewd6fs SmcoLq+0qQVtie7Bp387FcSaq4IqrjV/Ef1kZXwtkfLREj2AiTzTCmdVZQbsfGbXgwnf 9pG6x74EBZG97uiBERP2s+xD2iFSi40FtuSvADVbtdYxlSFuCYWHzqZEs518G2gr5aD3 /Csq6p+mEIhiIxhkzqvFZRYJSvEhGTGAGpoxXMJAOTI9uNkkiLtRZ1WhCJnpqVWpbUOF qtMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=QMM3PHPP; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id ky15-20020a170902f98f00b001c3976e22f5si10987141plb.515.2023.09.20.01.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 01:46:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=QMM3PHPP; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 45A6682589B7; Wed, 20 Sep 2023 01:24:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233313AbjITIY0 (ORCPT + 56 others); Wed, 20 Sep 2023 04:24:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232799AbjITIYY (ORCPT ); Wed, 20 Sep 2023 04:24:24 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40C2BA3 for ; Wed, 20 Sep 2023 01:24:18 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38K5wMfF001769; Wed, 20 Sep 2023 08:24:13 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=QMM3PHPPbMWQV8n97CEKphdkZpNzAFOf1WA5QJBo6cKVdNlsqLv6Vcl0vLomsIwNKOnR eIDS7bROXENshgwGUE3SEhwIKNuGVwxOxuncCTYqQKccryZ8CW7SR7Tq5Q5YF88zwBSW oY0lvdlhLGvE7fqdoObvdfdrUGTjnZj/+ojqd/2H9o9MpSMJSNTvuTh5PuQ2AME/HRds 0rVOVvMqu5Z884Yl4D7/7dbQMwM2ahl08HIj+Q+LauIPloE9s9GpKHGJbht+PATWwAab biOBb9vruJFickY0JfTBggCaYRmrJkQlcK7G3NkHFVZZegXl8w3bkaD5ndHAsEHwNnlC RA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t746g2w1b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Sep 2023 08:24:13 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38K8OCnE006322 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Sep 2023 08:24:12 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.36; Wed, 20 Sep 2023 01:24:10 -0700 From: Wen Gong To: CC: , , , , Baochen Qiang Subject: [PATCH v6 03/13] wifi: ath11k: fix a possible dead lock caused by ab->base_lock Date: Wed, 20 Sep 2023 04:23:39 -0400 Message-ID: <20230920082349.29111-4-quic_wgong@quicinc.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230920082349.29111-1-quic_wgong@quicinc.com> References: <20230920082349.29111-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-ORIG-GUID: -HjQfpGhSpit8-Y95QKsNhU6aNUf7HBM X-Proofpoint-GUID: -HjQfpGhSpit8-Y95QKsNhU6aNUf7HBM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-20_02,2023-09-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 spamscore=0 mlxlogscore=919 impostorscore=0 adultscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309200067 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 20 Sep 2023 01:24:58 -0700 (PDT) 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