Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3782473rdb; Sun, 10 Dec 2023 22:22:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgEYbKaRajdseaD0vDkuBWNcXuJZQq6woc6fjAEREzkYIxLFMJkCgSOGpipPGnW8Pq0WVv X-Received: by 2002:a05:620a:cc2:b0:77f:2ba4:9720 with SMTP id b2-20020a05620a0cc200b0077f2ba49720mr4603379qkj.50.1702275766955; Sun, 10 Dec 2023 22:22:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702275766; cv=none; d=google.com; s=arc-20160816; b=lwLS0X50N5UGOUNwboAbAY3DsGUXqPFKcCQZWSgSwQg21soEjFP8WWGWhCYcW0kRRO CAimQ7hPnelQqKD7iR0H3Y1j+yOaoiLba9OIZGT4h/1h+907JD0gI88be5c1xE+oaEVs 4dUMu5VgnBRNCna6oxQju2QgkpmZcm8FxyLRDl6KUaa5+pA9prbL0D7PskztJwWsQw9N /hdocrkDT2xpjNQAuytQ5fq98pVoDo5aI0uTrReYOBHhRv9WgbhjdW0+y0Cir8jlNGP0 cc4glUeH21NUJumkIhiXiH85Z4PrVUrEezug6R9jvaFFSY37NDtfLm3swKuZzilkWJYO VmIg== 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=HwSwMARNFjn+nIE8YysW6y0J/FgBqqp2AOrcoHQl1+I=; fh=HNEfiow5aIDtnUkYYiB/tbonwaEcG8+i6SMa583BOko=; b=xuK0aj7A1s/UkBHniRghH7eDG+dclgk8WT2yviTG6zcAoSuOlZD8wV6/i0txoczKPw N5hitAQac0pX0F79XMVGXG+C1K/A1aVvc1h0Pm/MVzX7xgWo+im3DpWsIpps8eI2Sp0d eSG4V1jA6KP8jYhKl66uJjTZdkcc5MZVveinwW1jX44Ye4wDUaqluJmo++4eW9yAlQCg jD7I8l145jcj55DxOlKoy8qaNtHR3mRG3Afa5p/GZCLO5wkIZT+SMMkVNdA3KC7x1PMf +wJfyR69LpDImzK3ASQ3ekd+yWVDGmiy6m/1/dZdxAALuyqxB6YnHmbr9B/eZUmq5q3D IbZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Q+jKsMkg; spf=pass (google.com: domain of linux-wireless+bounces-620-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-620-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. [147.75.199.223]) by mx.google.com with ESMTPS id v2-20020a05620a440200b00773dc958046si7964521qkp.258.2023.12.10.22.22.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 22:22:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-620-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Q+jKsMkg; spf=pass (google.com: domain of linux-wireless+bounces-620-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-620-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 B46FE1C208DC for ; Mon, 11 Dec 2023 06:22:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEC971F617; Mon, 11 Dec 2023 06:22:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Q+jKsMkg" X-Original-To: linux-wireless@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 199F9F1 for ; Sun, 10 Dec 2023 22:22:33 -0800 (PST) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BB66en9003732; Mon, 11 Dec 2023 06:22:31 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=HwSwMARNFjn+nIE8YysW6y0J/FgBqqp2AOrcoHQl1+I=; b=Q+ jKsMkg0oOxDunpAOa0jvRZ8rDFjNGQGBCUf3MKfw3xaOJgLxwjOTDdeoT1zw8BX5 AHf0b7pMIh5umrny5YwJ/+5oFu+2p/JzNBOeV2saeUY+CKvYJG3KiRk4B9St0Tuc 4HF5zY4LaXudgtEYpotDOnPrFm7zlqn5G7/E9OHcIpwIMkI8xlEJhoE78fFsJJwn ZWzYOKtiBC3Dco2kVxjqdxJIhb7qKISIfsQOeWVnn+bW9WKnASwocksoFHsTkECB 9VSh72ZOZISL1ZBfg4YTdkiafwUP2WV/h7JomDp7UAuWkPpZcAVahX/rI0Is8LW3 OencSq/XNaNqz9HSnG0A== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uvney2fa5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 06:22:31 +0000 (GMT) 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 3BB6MULL029293 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 06:22:30 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; Sun, 10 Dec 2023 22:22:29 -0800 From: Baochen Qiang To: CC: Subject: [PATCH v9 03/12] wifi: ath11k: fix a possible dead lock caused by ab->base_lock Date: Mon, 11 Dec 2023 14:22:07 +0800 Message-ID: <20231211062216.382164-4-quic_bqiang@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231211062216.382164-1-quic_bqiang@quicinc.com> References: <20231211062216.382164-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-GUID: uBptQsBEOCW6RZEiiVzd1x4Sj9uiFWAG X-Proofpoint-ORIG-GUID: uBptQsBEOCW6RZEiiVzd1x4Sj9uiFWAG 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 adultscore=0 bulkscore=0 impostorscore=0 mlxlogscore=968 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312110051 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 --- 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 78bc2715e476..1d033507a24c 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