Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2556309rdb; Mon, 4 Dec 2023 00:13:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNnBq9TjNMrDzBQgWAwRdQVIC9vHXg26RvShNU2C1TTa6fpCoMlSw7prxU8CxqP/7TFDhP X-Received: by 2002:a9d:754b:0:b0:6d8:7c3e:f5dd with SMTP id b11-20020a9d754b000000b006d87c3ef5ddmr2722700otl.8.1701677631410; Mon, 04 Dec 2023 00:13:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701677631; cv=none; d=google.com; s=arc-20160816; b=mSCBOrM/+OhumR0NoUHmay9RAxZZIZEtUZrXTyqbp5BzQtdFmxogxzFzoTwgmaDPRM UKt0CgApp1IHMbTvJUdZRESFCyTPjxVuq2K+/8Af7NeWFfU2NsSiYeZ1+QtjUm6zZKN1 91JyUjUsYsGU2d1KoTcgIsWHSzQokWsdb0NsHpvj2RX3lLhy8dYWZiLHaK8Mih+A0xIY q4DftM7oScD/SqpwoJQN8TKCXBnpIz9OnqaKIy0tMTgy9V/abqnknecmeHiUFYUy5O3/ N1aa6IcWFBFNU8vaXvvpP7U/g/rQV5N9TmTrA8EMPvKoudzbyttSzRSc1RVEJmNJ3obi AdRg== 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=FcqFJo9TPMzxG/MHT15UDlu2X2WeYmoOM6aLSIt9Yts=; fh=HNEfiow5aIDtnUkYYiB/tbonwaEcG8+i6SMa583BOko=; b=fb93OYXo9xJNSg5+Fm3Ib6dBYMqU4B5EOVbWr/uzuvWVQtmZ2Uncn0PipWxktlh7U9 lygwHXT01pL1o5IpUKQJ2JIsf/P5aOBX2cfI0N0UrjYfoeVTBsd6wuxM7Nhch8dnAHnl ulyHYgGu76MkfwnSywTyDslMWYONCh2DoNi6Ix/OeDVut5HrFiFhMWA7pK5UenwYJ1XV qy2iJIVcvp9MgBGXAAH2JDzMWhb8ZZcRM8lYDVWkkgEXXnGJ7upcgHfOhPAbvCzRVaBu BM8ChvmZFYFo/b4W73IWK49mGIO0ykOkY7e4Ft983chBIjZ3HFuqnGE2TJoW4FXKAnOi 2Ukw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Kfujqjzl; spf=pass (google.com: domain of linux-wireless+bounces-357-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-357-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u1-20020a6540c1000000b005b882238681si7555133pgp.620.2023.12.04.00.13.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 00:13:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-357-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Kfujqjzl; spf=pass (google.com: domain of linux-wireless+bounces-357-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-357-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B49C8280D3E for ; Mon, 4 Dec 2023 08:13:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5ECD7D2F4; Mon, 4 Dec 2023 08:13:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Kfujqjzl" X-Original-To: linux-wireless@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20070BB for ; Mon, 4 Dec 2023 00:13:45 -0800 (PST) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B45MGi6016439; Mon, 4 Dec 2023 08:13:42 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=FcqFJo9TPMzxG/MHT15UDlu2X2WeYmoOM6aLSIt9Yts=; b=KfujqjzlqasQCbgw3Trol20Mld2PchygUPMuJN4e2iSqmRAwIcmE/UxD6lzTm+gK3qnL UDfSGj/vv2xwi4UjBtHDmraqo8yaZvxgcR6uNhcwBYff7K8xhxlLEGqkNm9UhgaM8BM9 RkVISp4G/88/8r1bbsO9pHTfOOymNby89X5rnAWqSp6bFKvOzYEgVAgWjiXtQ9K0egp/ THsHp4dx5N7un0x2dMqX9ZX7pJFwJLna7WMPxqP/JTVcFOggd19CZDCFK5ZQUdt7sd9+ RzvLNnIhwOAY4Skjz91wZrzgkeoaIC7f6z/aSYcjSn17w6aVgVP+WICb30gjkm8/x9+Q IA== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uqvyeuawe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Dec 2023 08:13:41 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3B48DefI002133 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 4 Dec 2023 08:13:40 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, 4 Dec 2023 00:13:38 -0800 From: Baochen Qiang To: CC: Subject: [PATCH v8 03/12] wifi: ath11k: fix a possible dead lock caused by ab->base_lock Date: Mon, 4 Dec 2023 16:13:14 +0800 Message-ID: <20231204081323.5582-4-quic_bqiang@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231204081323.5582-1-quic_bqiang@quicinc.com> References: <20231204081323.5582-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: RKb6FjYdnrRn7DmVKEKNBRWYNj_uN3cQ X-Proofpoint-GUID: RKb6FjYdnrRn7DmVKEKNBRWYNj_uN3cQ 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-04_06,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 mlxlogscore=966 bulkscore=0 suspectscore=0 clxscore=1015 spamscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312040061 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 --- 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 4d484d29826e..6f0a35fcc9c1 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -7139,13 +7139,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 @@ -7198,7 +7198,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 @@ -7218,7 +7218,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