Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1125888lqt; Sat, 20 Apr 2024 01:38:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW4gpDrabOw1QndQf3gzRK2xDKtbaQ/QgxWxnlrk3ormYm8NV+cieP0NGTijebfUJ0kUmiGjNDgRWdRYxMKewqRRgi+E4cbKlNjWqX9GA== X-Google-Smtp-Source: AGHT+IG1SOrmBHuW6tB0FSsu/456Tnrr8LHDPpZtKrXUZ9/sg5NDDcL8viv/w9YWCKErMsGr5+yT X-Received: by 2002:a50:999d:0:b0:56d:fca8:d2d6 with SMTP id m29-20020a50999d000000b0056dfca8d2d6mr3731116edb.6.1713602323552; Sat, 20 Apr 2024 01:38:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713602323; cv=pass; d=google.com; s=arc-20160816; b=DblzQMDDgE5BH7kUMZV3IsA8aMEbOGE0xBi6KDcpNtp3MRzRuvy8R5MJcHTWyt/4a7 CIQ3yOJYKAg/L5F1bsHkdHJmqq0/Hma2xrRdZGc3hjFAuc8dZoHNFwxHDBiLe4o4pqA/ m+78VHWrCEYFIloQeHULiTvUt1c2wYCO3OXYSDDHgSYUyoNQtmzVvrzh6kTUlly/Cz6V 0AgSo6zD6oxQSzbFgO5BI/1Bgv/YtOEKSJbq26p6SZeMiHexPhBXsE7lHfO6TMVe4rum kNXcRVQ1S7vnsihkwT7PNz94NjEQT8RQ2a9TNXkTXqnooSY6RC9ci4LbP8nZJjO69ZYk t+ag== ARC-Message-Signature: i=2; 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=sq9432ZFir+evqP5wAopwf0BMl4ZsgD64wzX2bns52U=; fh=wnySVr9+WO9j7lO1L6CVbSw/CjEiK6R10EUaKUiDPbE=; b=tQqGFUIztBMXLNtT71sdJlHHjwxOV94b4PGAN3/qXCUfziawITuz6NIG1+/UBU1VNX 19u4aAMeRH0j+YgrqBVxOzm2XNoa01PJtd/qLwtP3UxiAOitTAoJTKhgvd0T/3juljhy LK0g0x6jrd+YJ1jSiqsYK0hr2eTtxbyWCdHwcNy79uTHp9yzl+XzQT1ZnoGVX4N+Lbh9 shMXP1XXxpsKIzzTb5RfZ3+HPds5Dn8EJwnTyXKTXaMpzhqTB40exJubppDDcnNtVV9O Wu6i0wM+jwcAFF0pWs1Kw9P+delecHShsuAxQhTmG8ggbjbRyXJpshOzVPBt1GWgDx2X ysNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ak2fVeV1; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-6599-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b18-20020a05640202d200b0056e47321892si3198763edx.374.2024.04.20.01.38.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 01:38:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-6599-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ak2fVeV1; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-6599-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6599-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 20B9D1F2225D for ; Sat, 20 Apr 2024 08:38:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F2451758C; Sat, 20 Apr 2024 08:38:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="ak2fVeV1" 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 5FD1017584 for ; Sat, 20 Apr 2024 08:38:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713602300; cv=none; b=Utvk6E4Z4XtONs7ILJiP0lcI7vANIi/Xj6Hxcqakh/8nYiqUPnbsGp3SjNxOssbtKy4FZ+nqA3xDwX/OoXkVXPsBOECzrMrpJfPgsdGwyi+1+hQjCkUPotiow/zItAfx8BMjDPMqSaFQXg1MROHzp0CIKid5074jjtsCyIHwpG8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713602300; c=relaxed/simple; bh=BCJWF/dLfgW0pR76j+7YXTGDB+1vJ/OsmsEOqzivyN8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YtXNce5WY2Ks3QCU0D6qiDZ1uV5KHljJOnWcrkk+c+13QSdVA2dWcIo1ft7PnfCyhkD2E3DKQMKKx5O2u/esmopBGBs7lNKqx44A45oU0bAGzx1Zru62eWPR1f269R+FjG4p9vl+1X51oA7jrzxqO/NvqvQZ3xBc7qc9WvmPvkI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=ak2fVeV1; arc=none smtp.client-ip=205.220.168.131 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=qualcomm.com Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43K8FRH5031415; Sat, 20 Apr 2024 08:38:16 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; s=qcppdkim1; bh=sq9432Z Fir+evqP5wAopwf0BMl4ZsgD64wzX2bns52U=; b=ak2fVeV1ldf1lxAJLzVK46D VzKw9emr8AXccVaU1viglbimcHf46fZusK5mDG294nI0FM48GY/QIDkOSF/wjb87 K3UjGiH4LlesEyNkkZR8YZb0DbZM2+j0hLFoG0jgHn4ga+71qv+Sq8/O/Y3y3A5J PMCm5CPZXu/P6BoNpwm1rYN0sCwFEOUB7t5VrFJHSO2y55qiVIkh4X8mKL4e2s0k WjvpM2a+GpUnLkRiDAMVdcUpQDs4fRiVPrap+bualw230R48PM+GRxvanj3IiSDp RVJ2PAED/jjMYEC3zc0TyD1H7VnQK08ljYaBh0kXe7etdJTXWrIFyCQ+qXgPTKQ= = Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xm6vr8amq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 20 Apr 2024 08:38:15 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 43K8c37t030861; Sat, 20 Apr 2024 08:38:12 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3xm6sk95md-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 20 Apr 2024 08:38:12 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 43K8ZsfZ028305; Sat, 20 Apr 2024 08:38:12 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 43K8cB2m030964 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 20 Apr 2024 08:38:12 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 1B24F411A5; Sat, 20 Apr 2024 14:08:11 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem Subject: [PATCH 7/8] wifi: ath12k: refactor core start based on hardware group Date: Sat, 20 Apr 2024 14:07:49 +0530 Message-Id: <20240420083750.1545670-8-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240420083750.1545670-1-quic_hprem@quicinc.com> References: <20240420083750.1545670-1-quic_hprem@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 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 5fHm_mcQaq9jOIwZNEbgUiAf-KjWAY-W X-Proofpoint-ORIG-GUID: 5fHm_mcQaq9jOIwZNEbgUiAf-KjWAY-W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-20_07,2024-04-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=885 impostorscore=0 phishscore=0 clxscore=1015 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404200062 From: Karthikeyan Periyasamy Currently, mac allocate/register and core_pdev_create are initiated immediately when QMI firmware ready event is received for a particular device. With hardware device group abstraction, QMI firmware ready event can be received simultaneously for different devices in the group and so, it should not be registered immediately rather it has to be deferred until all devices in the group has received QMI firmware ready. To handle this, refactor the code of core start to move the following apis inside a wrapper ath12k_core_hw_group_start() * ath12k_mac_allocate() * ath12k_core_pdev_create() * ath12k_core_rfkill_config() * ath12k_mac_register() * ath12k_hif_irq_enable() similarly, move the corresponding destroy/unregister/disable apis inside wrapper ath12k_core_hw_group_stop() Add the device flags to indicate pdev created and IRQ enabled which would be helpful for device clean up during failure cases. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy Co-developed-by: Harshitha Prem Signed-off-by: Harshitha Prem --- drivers/net/wireless/ath/ath12k/core.c | 215 +++++++++++++++++++------ drivers/net/wireless/ath/ath12k/core.h | 32 ++++ 2 files changed, 196 insertions(+), 51 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index 0ad3c4cf48e1..72cef537da8f 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -543,6 +543,8 @@ u32 ath12k_core_get_max_num_tids(struct ath12k_base *ab) static void ath12k_core_stop(struct ath12k_base *ab) { + clear_bit(ATH12K_FLAG_CORE_STARTED, &ab->dev_flags); + ath12k_dec_num_core_started(ab); ath12k_dp_rx_pdev_reo_cleanup(ab); ath12k_hif_stop(ab); ath12k_wmi_detach(ab); @@ -667,11 +669,15 @@ static int ath12k_core_pdev_create(struct ath12k_base *ab) return ret; } + set_bit(ATH12K_FLAG_PDEV_CREATED, &ab->dev_flags); + return 0; } static void ath12k_core_pdev_destroy(struct ath12k_base *ab) { + clear_bit(ATH12K_FLAG_PDEV_CREATED, &ab->dev_flags); + ath12k_dp_pdev_free(ab); } @@ -679,6 +685,7 @@ static int ath12k_core_start(struct ath12k_base *ab, enum ath12k_firmware_mode mode) { int ret; + lockdep_assert_held(&ab->core_lock); ret = ath12k_wmi_attach(ab); if (ret) { @@ -768,6 +775,11 @@ static int ath12k_core_start(struct ath12k_base *ab, goto err_reo_cleanup; } + /* Indicate the core start in the appropriate group */ + ath12k_inc_num_core_started(ab); + + set_bit(ATH12K_FLAG_CORE_STARTED, &ab->dev_flags); + return 0; err_reo_cleanup: @@ -779,6 +791,109 @@ static int ath12k_core_start(struct ath12k_base *ab, return ret; } +static void ath12k_core_device_cleanup(struct ath12k_base *ab) +{ + mutex_lock(&ab->core_lock); + + if (test_and_clear_bit(ATH12K_FLAG_CORE_HIF_IRQ_ENABLED, &ab->dev_flags)) + ath12k_hif_irq_disable(ab); + + if (test_bit(ATH12K_FLAG_PDEV_CREATED, &ab->dev_flags)) + ath12k_core_pdev_destroy(ab); + + if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) { + ath12k_mac_unregister(ab); + ath12k_mac_destroy(ab); + } + + mutex_unlock(&ab->core_lock); +} + +static void ath12k_core_hw_group_stop(struct ath12k_hw_group *ag) +{ + struct ath12k_base *ab; + int i; + + lockdep_assert_held(&ag->mutex_lock); + + for (i = ag->num_devices - 1; i >= 0; i--) { + ab = ag->ab[i]; + if (!ab) + continue; + ath12k_core_device_cleanup(ab); + } +} + +static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) +{ + struct ath12k_base *ab; + int ret, i; + bool is_registered; + + lockdep_assert_held(&ag->mutex_lock); + + for (i = 0; i < ag->num_devices; i++) { + ab = ag->ab[i]; + if (!ab) + continue; + + mutex_lock(&ab->core_lock); + + /* Check if already registered or not, since same flow + * execute for HW restart case. + */ + is_registered = test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); + + if (is_registered) + goto core_pdev_create; + + ret = ath12k_mac_allocate(ab); + if (ret) { + ath12k_err(ab, "failed to create new hw device with mac80211 :%d\n", + ret); + mutex_unlock(&ab->core_lock); + return ret; + } + + ret = ath12k_mac_register(ab); + if (ret) { + ath12k_err(ab, "failed to register radio with mac80211: %d\n", + ret); + mutex_unlock(&ab->core_lock); + goto err; + } + +core_pdev_create: + ret = ath12k_core_pdev_create(ab); + if (ret) { + ath12k_err(ab, "failed to create pdev core %d\n", ret); + mutex_unlock(&ab->core_lock); + goto err; + } + + ret = ath12k_core_rfkill_config(ab); + if (ret && ret != -EOPNOTSUPP) { + mutex_unlock(&ab->core_lock); + goto err; + } + + ath12k_hif_irq_enable(ab); + + set_bit(ATH12K_FLAG_CORE_HIF_IRQ_ENABLED, &ab->dev_flags); + + mutex_unlock(&ab->core_lock); + } + + set_bit(ATH12K_GROUP_FLAG_REGISTERED, &ag->flags); + + return 0; + +err: + ath12k_core_hw_group_stop(ag); + + return ret; +} + static int ath12k_core_start_firmware(struct ath12k_base *ab, enum ath12k_firmware_mode mode) { @@ -796,9 +911,18 @@ static int ath12k_core_start_firmware(struct ath12k_base *ab, return ret; } +static inline +bool ath12k_core_hw_group_start_ready(struct ath12k_hw_group *ag) +{ + lockdep_assert_held(&ag->mutex_lock); + + return (ag->num_started == ag->num_devices); +} + int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab) { - int ret; + struct ath12k_hw_group *ag; + int ret, i; ret = ath12k_core_start_firmware(ab, ATH12K_FIRMWARE_MODE_NORMAL); if (ret) { @@ -818,59 +942,50 @@ int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab) goto err_firmware_stop; } + ag = ath12k_ab_to_ag(ab); + + mutex_lock(&ag->mutex_lock); mutex_lock(&ab->core_lock); ret = ath12k_core_start(ab, ATH12K_FIRMWARE_MODE_NORMAL); if (ret) { ath12k_err(ab, "failed to start core: %d\n", ret); goto err_dp_free; } + mutex_unlock(&ab->core_lock); - ret = ath12k_mac_allocate(ab); - if (ret) { - ath12k_err(ab, "failed to create new hw device with mac80211 :%d\n", - ret); - goto err_core_stop; - } - - ret = ath12k_mac_register(ab); - if (ret) { - ath12k_err(ab, "failed register the radio with mac80211: %d\n", ret); - goto err_mac_destroy; + if (ath12k_core_hw_group_start_ready(ag)) { + ret = ath12k_core_hw_group_start(ag); + if (ret) { + ath12k_warn(ab, "unable to start hw group\n"); + goto err_core_stop; + } + ath12k_dbg(ab, ATH12K_DBG_BOOT, "group %d started\n", ag->id); } + mutex_unlock(&ag->mutex_lock); - ret = ath12k_core_pdev_create(ab); - if (ret) { - ath12k_err(ab, "failed to create pdev core: %d\n", ret); - goto err_mac_unregister; - } + return 0; - ath12k_hif_irq_enable(ab); +err_core_stop: + for (i = ag->num_devices - 1; i >= 0; i--) { + ab = ag->ab[i]; + if (!ab) + continue; - ret = ath12k_core_rfkill_config(ab); - if (ret && ret != -EOPNOTSUPP) { - ath12k_err(ab, "failed to config rfkill: %d\n", ret); - goto err_core_pdev_destroy; + mutex_lock(&ab->core_lock); + if (test_bit(ATH12K_FLAG_CORE_STARTED, &ab->dev_flags)) + ath12k_core_stop(ab); + mutex_unlock(&ab->core_lock); } + goto exit; - mutex_unlock(&ab->core_lock); - - return 0; - -err_core_pdev_destroy: - ath12k_hif_irq_disable(ab); - ath12k_core_pdev_destroy(ab); -err_mac_unregister: - ath12k_mac_unregister(ab); -err_mac_destroy: - ath12k_mac_destroy(ab); -err_core_stop: - ath12k_core_stop(ab); err_dp_free: ath12k_dp_free(ab); mutex_unlock(&ab->core_lock); err_firmware_stop: ath12k_qmi_firmware_stop(ab); +exit: + mutex_unlock(&ag->mutex_lock); return ret; } @@ -1127,6 +1242,10 @@ static void ath12k_core_reset(struct work_struct *work) ath12k_dbg(ab, ATH12K_DBG_BOOT, "reset starting\n"); + mutex_lock(&ab->ag->mutex_lock); + ath12k_dec_num_core_started(ab); + mutex_unlock(&ab->ag->mutex_lock); + ab->is_reset = true; atomic_set(&ab->recovery_start_count, 0); reinit_completion(&ab->recovery_start); @@ -1234,7 +1353,7 @@ static struct ath12k_hw_group *ath12k_core_assign_hw_group(struct ath12k_base *a void ath12k_core_unassign_hw_group(struct ath12k_base *ab) { - struct ath12k_hw_group *ag = ab->ag; + struct ath12k_hw_group *ag = ath12k_ab_to_ag(ab); u8 device_id = ab->device_id; int num_probed; @@ -1268,19 +1387,6 @@ void ath12k_core_unassign_hw_group(struct ath12k_base *ab) ath12k_core_hw_group_free(ag); } -static void ath12k_core_device_cleanup(struct ath12k_base *ab) -{ - mutex_lock(&ab->core_lock); - - ath12k_hif_irq_disable(ab); - ath12k_core_pdev_destroy(ab); - ath12k_mac_unregister(ab); - ath12k_mac_destroy(ab); - ath12k_core_stop(ab); - - mutex_unlock(&ab->core_lock); -} - static void ath12k_core_hw_group_destroy(struct ath12k_hw_group *ag) { struct ath12k_base *ab; @@ -1291,13 +1397,20 @@ static void ath12k_core_hw_group_destroy(struct ath12k_hw_group *ag) mutex_lock(&ag->mutex_lock); + if (test_and_clear_bit(ATH12K_GROUP_FLAG_REGISTERED, &ag->flags)) + ath12k_core_hw_group_stop(ag); + for (i = 0; i < ag->num_devices; i++) { ab = ag->ab[i]; if (!ab) continue; - if (test_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, &ab->dev_flags)) - ath12k_core_device_cleanup(ab); + mutex_lock(&ab->core_lock); + + if (test_bit(ATH12K_FLAG_CORE_STARTED, &ab->dev_flags)) + ath12k_core_stop(ab); + + mutex_unlock(&ab->core_lock); if (test_and_clear_bit(ATH12K_FLAG_HW_GROUP_ATTACHED, &ab->dev_flags)) ath12k_core_soc_destroy(ab); diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index fd3e4e66d27c..10a09ddb7bc5 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -200,6 +200,10 @@ enum ath12k_scan_state { ATH12K_SCAN_ABORTING, }; +enum ath12k_hw_group_flags { + ATH12K_GROUP_FLAG_REGISTERED, +}; + enum ath12k_dev_flags { ATH12K_CAC_RUNNING, ATH12K_FLAG_CRASH_FLUSH, @@ -214,6 +218,9 @@ enum ath12k_dev_flags { ATH12K_FLAG_EXT_IRQ_ENABLED, ATH12K_FLAG_QMI_FW_READY_COMPLETE, ATH12K_FLAG_HW_GROUP_ATTACHED, + ATH12K_FLAG_PDEV_CREATED, + ATH12K_FLAG_CORE_STARTED, + ATH12K_FLAG_CORE_HIF_IRQ_ENABLED, }; enum ath12k_monitor_flags { @@ -734,6 +741,8 @@ struct ath12k_hw_group { u8 id; u8 num_devices; u8 num_probed; + u8 num_started; + unsigned long flags; struct ath12k_base *ab[ATH12K_MAX_SOCS]; /* To synchronize group create, assign, start, stop */ struct mutex mutex_lock; @@ -1064,4 +1073,27 @@ static inline int ath12k_get_num_hw(struct ath12k_base *ab) { return ab->num_hw; } + +static inline +struct ath12k_hw_group *ath12k_ab_to_ag(struct ath12k_base *ab) +{ + return ab->ag; +} + +static inline +void ath12k_inc_num_core_started(struct ath12k_base *ab) +{ + lockdep_assert_held(&ab->ag->mutex_lock); + + ab->ag->num_started++; +} + +static inline +void ath12k_dec_num_core_started(struct ath12k_base *ab) +{ + lockdep_assert_held(&ab->ag->mutex_lock); + + ab->ag->num_started--; +} + #endif /* _CORE_H_ */ -- 2.34.1