Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp664205rdb; Fri, 22 Dec 2023 00:54:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPtxs1cHkraOTnqRKCiC0mn+2IHHSJuRMbvpqh1WHRpf38e3Jszjx4Zhj4L9S/Vzg2wpIj X-Received: by 2002:a50:8a90:0:b0:553:dff0:a5e0 with SMTP id j16-20020a508a90000000b00553dff0a5e0mr306844edj.110.1703235241936; Fri, 22 Dec 2023 00:54:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703235241; cv=none; d=google.com; s=arc-20160816; b=VwshqNY++potWcq5LaW5/GpZJ09QReniNjbxtEdvg+xezHG2elCsqUhjVI6Dq9sOIq z4AEHtSu0MpEfCac6X/dmH4Zuro541uqiM2NyOCVh5/fqq0gOXsBG5mH/LQpn0uWwSr5 RayW/wLxhJ5cP+Tcpj1ynt8KU+4qXiT15SK7Ph+Tzo/zb0AJxqWrKIMZxeoRORW0WXe3 z/62/iS3iZBCfOvzhpYn9vAvaQZd+jt2Ljfw7kvi7zwuDXcxPasoR4JV45UIuQmrFTPH XujvEqMeTYSb5MDtdMSIM2tuuiqANBTWTtj7KSq6qTd3oIEp2LTfP99f793qsYwENQZS Q6iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G903a+rUPsDraNi3izuk1MYUFsGK+bZ2eCu8WQaAmhc=; fh=jlecVeJ1zmiUcWLoYt7W352gNllWYkqAa/aIazCPBg4=; b=WG7xK+A0wmmmsQzcH0oVuvOG5BFKvsCQe4Jp9yd9rYtnrpWQrF/5D4N8cV8IP5jWs2 0XhUz8hHHmOSSy+yYbBOAYbVdzd31ipJj/5Dihhr/1pQk4wJu8fuJtx2G6BgGCQt6Ho3 RI97H+JvQA5f+burHZ9NOq9+YsCog7V+vk1yRyI7XMtRVy9Z1LSr5plAxkWyNpU8pgKl 5Q1E9623FkkMCsOLiTjg6nlTMl5ZU/Us0ikGORM1YtKTr1S1pQDHSqfYslCKGezbD1lD +riIXB1tz26E2M/es1TLnDxWSMu1m9qInO5OzKnoaQCHSCW2ZogCHRTts+IRdDoXaofl J3oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=DUs5d+un; spf=pass (google.com: domain of linux-wireless+bounces-1210-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1210-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s27-20020a05640217db00b0054c45efad9fsi1607104edy.69.2023.12.22.00.54.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 00:54:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-1210-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=@mediatek.com header.s=dk header.b=DUs5d+un; spf=pass (google.com: domain of linux-wireless+bounces-1210-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1210-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.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 AD7891F23EFA for ; Fri, 22 Dec 2023 08:54:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6275EF9EF; Fri, 22 Dec 2023 08:53:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="DUs5d+un" X-Original-To: linux-wireless@vger.kernel.org Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (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 AFC46F9EA for ; Fri, 22 Dec 2023 08:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: 9ee6236aa0a711eeba30773df0976c77-20231222 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=G903a+rUPsDraNi3izuk1MYUFsGK+bZ2eCu8WQaAmhc=; b=DUs5d+unO7N9INw9ANe+qVV2oiBRqI60eN4BEA3KqrdQfnmOFXMLvVW9o8PqcqsoUg5rJTHjzxTWow6gv+ahJBZCWQuiN9Da2ZEFDMLfejONmOaDXQBlYSJ+yZLaVe/IX4iaTu60rgYTbnvvs5tuviQwZMoV8qeP1rXLxJP40h0=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:2a08bd80-f7b9-4993-831b-31864669d1a2,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:5d391d7,CLOUDID:49b7602e-1ab8-4133-9780-81938111c800,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 9ee6236aa0a711eeba30773df0976c77-20231222 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1073065947; Fri, 22 Dec 2023 16:53:48 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 22 Dec 2023 16:53:46 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 22 Dec 2023 16:53:46 +0800 From: Mingyen Hsieh To: , CC: , , , , , , , , , , , , , , Ming Yen Hsieh , Leon Yen Subject: [PATCH v1 4/4] wifi: mt76: mt7921: fix the unfinished command of regd_notifier before suspend Date: Fri, 22 Dec 2023 16:53:38 +0800 Message-ID: <20231222085338.4530-5-mingyen.hsieh@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231222085338.4530-1-mingyen.hsieh@mediatek.com> References: <20231222085338.4530-1-mingyen.hsieh@mediatek.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain From: Ming Yen Hsieh Before entering suspend, we need to ensure that all MCU command are completed. In some cases, such as with regd_notifier, there is a chance that CLC commands, will be executed before suspend. Signed-off-by: Ming Yen Hsieh Signed-off-by: Leon Yen --- drivers/net/wireless/mediatek/mt76/mt7921/init.c | 6 ++++++ drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 3 +++ drivers/net/wireless/mediatek/mt76/mt792x.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c index 48433c6d5e7d..bb2abf341c68 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c @@ -138,9 +138,14 @@ mt7921_regd_notifier(struct wiphy *wiphy, if (pm->suspended) return; + dev->regd_in_progress = true; + mt792x_mutex_acquire(dev); mt7921_regd_update(dev); mt792x_mutex_release(dev); + + dev->regd_in_progress = true; + wake_up(&dev->wait); } int mt7921_mac_init(struct mt792x_dev *dev) @@ -261,6 +266,7 @@ int mt7921_register_device(struct mt792x_dev *dev) spin_lock_init(&dev->pm.wake.lock); mutex_init(&dev->pm.mutex); init_waitqueue_head(&dev->pm.wait); + init_waitqueue_head(&dev->wait); if (mt76_is_sdio(&dev->mt76)) init_waitqueue_head(&dev->mt76.sdio.wait); spin_lock_init(&dev->pm.txq_lock); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c index 57903c6e4f11..8b226b731ec9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c @@ -409,6 +409,9 @@ static int mt7921_pci_suspend(struct device *device) if (err < 0) goto restore_suspend; + wait_event_timeout(dev->wait, + !dev->regd_in_progress, 5 * HZ); + err = mt76_connac_mcu_set_hif_suspend(mdev, true); if (err) goto restore_suspend; diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h index 3c897b34aaa7..a8556de3d480 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x.h +++ b/drivers/net/wireless/mediatek/mt76/mt792x.h @@ -186,6 +186,8 @@ struct mt792x_dev { bool hw_init_done:1; bool fw_assert:1; bool has_eht:1; + bool regd_in_progress:1; + wait_queue_head_t wait; struct work_struct init_work; -- 2.18.0