Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp197725rdb; Thu, 16 Nov 2023 16:39:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPoic2HsjDh2l4y29ouPIQJaeFHaxEv3/NsDkwwJ60bC2VvKN8CBRF1PfSyeZwhMWJJXhy X-Received: by 2002:a17:90b:3a8f:b0:27d:1334:d266 with SMTP id om15-20020a17090b3a8f00b0027d1334d266mr15626139pjb.27.1700181589750; Thu, 16 Nov 2023 16:39:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700181589; cv=none; d=google.com; s=arc-20160816; b=tsLi9+WIUGvv6Uqc/52Aq34Qy6gpk2tLEA+9P33fvZa288S8RLEMZfk+XKOSdkvLgm n3t6zrkIjpWrgGfwmiwGoSfrArhdFrr68RwTq4JW2gm5vx1t8TpxQ7asUSG02dgJQouW azlZvTlMsk9Rxjcj0vXX45Wa3sXoYJUzwT7NgeTdqFd0XTYrm4492z98+zuqyfhHVKdO r9rUUTHiYTuwChpBxkndNmOOC6pOr/HSO30NrGQ3BkjrOcwDPCsCXAOunuCU6ltdn979 hjPO7IVAv48eeseUbI7LibM5eqBBrMKGj8R0n2IHW5RUcvdbvsAuA8qFSu6+1l9HmjmQ Nzmw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=txnuiTa0Z12sp0K/RsZveJF3kG7JhsDHiWnQnhf6CK8=; fh=HNEfiow5aIDtnUkYYiB/tbonwaEcG8+i6SMa583BOko=; b=DIQm4Og4x7RXhZtP5+AR+oOkfxdQpzrml0qdL0GE/xCT9hBNslgqBsnI3zDulZmNTc dxqUjrCNRZpGG2Yn6itTSXkvrojeniItE1RgeaDKekTveP4KagHd8IreiGi9utsYAyAN JtQ6w8D5DTFxH5MMApwkXykeuKji2+HWFnsaDVXD3z0SGYYIV9rheZOMrJpiCBgGL/yO suE2+EMBZnmTPqR5LuWHbpP1RNohmoGXFKnPZSb3rkleeR4sVjZqPrjxDd2TCr/6FMeu apmzVWkXZdd7WN6GjZ4gAL5i+qRKrrEjbcXH0995+84dIIHz3qIjTd0+vzek3/6BVIE3 bpYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=YNa3Jeo1; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id mu7-20020a17090b388700b0027ffcd44adasi734730pjb.133.2023.11.16.16.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 16:39:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=YNa3Jeo1; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 37D9A81F3320; Thu, 16 Nov 2023 16:39:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229783AbjKQAjo (ORCPT + 53 others); Thu, 16 Nov 2023 19:39:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjKQAjo (ORCPT ); Thu, 16 Nov 2023 19:39:44 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC913129 for ; Thu, 16 Nov 2023 16:39:40 -0800 (PST) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AGNNxuR005980; Fri, 17 Nov 2023 00:39:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=txnuiTa0Z12sp0K/RsZveJF3kG7JhsDHiWnQnhf6CK8=; b=YNa3Jeo1mTJCNUPwC0S+Rd3VEUHsSX8ksinIUznU6Dvuc11IdmtAKLNvN3yljyUhW86s k0b8xgl5McHNmGr7rvQZsNo5vs4XJsavu6ilUzv/K+CfzVCN9thjln3vVfFwYgfINl+k 7jPhP9v/7+rWQz6QW5Ws05tVMqTVOD0CUJXOGTRFAKZIZTUonuCw5lH6lhxQyQtd2Ajg Pp6p5iNIgc5Ng2O0o406b/G83ohDDQq3fZxnJwM9HHdYirbH/SlXLPKzTMgTolIJNXkB 8b9kMYzY4NF2Wtj4bKkp2WdHPZvZIYLQPc1qIDQq1rnjidCopvzNEuIWhPQ8nmW1yb1s Rg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3udt8bre9r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Nov 2023 00:39:32 +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 3AH0dW3d029432 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Nov 2023 00:39:32 GMT Received: from bqiang-SFF.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.39; Thu, 16 Nov 2023 16:39:31 -0800 From: Baochen Qiang To: CC: Subject: [PATCH] wifi: ath11k: fix race due to setting ATH11K_FLAG_EXT_IRQ_ENABLED too early Date: Fri, 17 Nov 2023 08:39:19 +0800 Message-ID: <20231117003919.26218-1-quic_bqiang@quicinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] 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: 6mfAgX1eoRDIgDx7wLscMM9JYC4mPZ8J X-Proofpoint-GUID: 6mfAgX1eoRDIgDx7wLscMM9JYC4mPZ8J X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-16_24,2023-11-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 mlxlogscore=758 adultscore=0 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311170002 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 16 Nov 2023 16:39:43 -0800 (PST) We are seeing below error randomly in the case where only one MSI vector is configured: kernel: ath11k_pci 0000:03:00.0: wmi command 16387 timeout The reason is, currently, in ath11k_pcic_ext_irq_enable(), ATH11K_FLAG_EXT_IRQ_ENABLED is set before NAPI is enabled. This results in a race condition: after ATH11K_FLAG_EXT_IRQ_ENABLED is set but before NAPI enabled, CE interrupt breaks in. Since IRQ is shared by CE and data path, ath11k_pcic_ext_interrupt_handler() is also called where we call disable_irq_nosync() to disable IRQ. Then napi_schedule() is called but it does nothing because NAPI is not enabled at that time, meaning ath11k_pcic_ext_grp_napi_poll() will never run, so we have no chance to call enable_irq() to enable IRQ back. Finally we get above error. Fix it by setting ATH11K_FLAG_EXT_IRQ_ENABLED after all NAPI and IRQ work are done. With the fix, we are sure that by the time ATH11K_FLAG_EXT_IRQ_ENABLED is set, NAPI is enabled. Note that the fix above also introduce some side effects: if ath11k_pcic_ext_interrupt_handler() breaks in after NAPI enabled but before ATH11K_FLAG_EXT_IRQ_ENABLED set, nothing will be done by the handler this time, the work will be postponed till the next time the IRQ fires. Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23 Signed-off-by: Baochen Qiang --- drivers/net/wireless/ath/ath11k/pcic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/pcic.c b/drivers/net/wireless/ath/ath11k/pcic.c index 16d1e332193f..e602d4130105 100644 --- a/drivers/net/wireless/ath/ath11k/pcic.c +++ b/drivers/net/wireless/ath/ath11k/pcic.c @@ -460,8 +460,6 @@ void ath11k_pcic_ext_irq_enable(struct ath11k_base *ab) { int i; - set_bit(ATH11K_FLAG_EXT_IRQ_ENABLED, &ab->dev_flags); - for (i = 0; i < ATH11K_EXT_IRQ_GRP_NUM_MAX; i++) { struct ath11k_ext_irq_grp *irq_grp = &ab->ext_irq_grp[i]; @@ -471,6 +469,8 @@ void ath11k_pcic_ext_irq_enable(struct ath11k_base *ab) } ath11k_pcic_ext_grp_enable(irq_grp); } + + set_bit(ATH11K_FLAG_EXT_IRQ_ENABLED, &ab->dev_flags); } EXPORT_SYMBOL(ath11k_pcic_ext_irq_enable); base-commit: 9a36440d929d134c56030a8492405708a143f580 -- 2.25.1