Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp651207lqo; Thu, 16 May 2024 18:34:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgNnmfFAdfMGuU/A9QZjk2mKqlVL1AVn+E7Lc+Ad01K6lnno+IagOVlwCkY15BvA7PZZ1Kt+be7kemfT/nkp/tzlc3Vqiw8nztrPWqwQ== X-Google-Smtp-Source: AGHT+IG0FwoD8pJtHZ01A3XcMSh66H4L2/VHqhdnUobWVSWYvXt/yGO0OPIdDtO8GSLvPjHiKowf X-Received: by 2002:a17:903:22c1:b0:1e2:7d3b:353c with SMTP id d9443c01a7336-1ef43e281a3mr247511385ad.18.1715909657021; Thu, 16 May 2024 18:34:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715909657; cv=pass; d=google.com; s=arc-20160816; b=Q2NnRDmD+CoBWfr6vp+EATXcl0lQvfji1LsLP2kip6wLFO1cMcuLULumA1tQcPDVFp za+pILcwUDqXeeObKxEK4sgTiyr9LY0n3j2Ea/jKYBN8oMWKrM4GN3i+ptSL0YlHDcr1 kYK34HVoMXxfL10WCC/YMhewT0DvsW8BoKWyhdtjIe4p0Cx21Hj7RREFdC6PNhUP8iMk POnECYrkb6us8bRyAnRoXXwKU+UULWIYdZwuiW6495dKLgXrifU7z5o4ATCgbZdRCYlc 2VJDUG1dOSVuask97qeaG+zZ3xnYSL71i2UKoBERUP2KdCtcOEZtytb2umJoDqmGvOfQ qi0A== 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:message-id:date:subject:cc:to :from; bh=e2LJzu+ytJWVER2SXWnwpend85O0T2DdkMYfXOLCOD0=; fh=5IVV3mzpgE2+DMz2aZO5H7E/lEyT+cJ+S2SEduAT1ls=; b=hijoSJ+NDG08/Eru5C1ZAB23MIXmQOkfKDo9oMAhOiS83+OE4Sp4Nl90vJVLd3Qu7y l2h2PXLsueRYP2n5h2hkuDR8A1pa4vTds0gnYsLaBizMxp9bRrad/IFoi2lafLCt4yai xSwYy5ylaxFQ60ip01siv+sB54m2hEzwJB5pzbuJrCKtbp5qcHCxKlXqIDZrYFOGOIW8 5475yr3j+uFWKeXBPF3SGGLrV/6WrjKi1lzdey5gqKKVHUw21yNmsMhHQzLzr9v+Wgmj kSrrCLj4LAV7gAIS6fzLDLK99jZ6xObmzL7wAF7gYMeHPYIHDYjJKirfpS0HmKeAoRfy KQvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-7755-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7755-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0b9cffe0si12426235ad.73.2024.05.16.18.34.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 18:34:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-7755-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-7755-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7755-linux.lists.archive=gmail.com@vger.kernel.org" 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 3E1E4284705 for ; Fri, 17 May 2024 01:34:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 04E911849; Fri, 17 May 2024 01:34:14 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 697B71854 for ; Fri, 17 May 2024 01:34:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715909653; cv=none; b=UuwudV/ICIasHHlc2x0D39V0xtGvZp+jq0LBJDgRiHGywVWpK5D37chd5HJpkr4CpMCqz8Xbc2zGVuXWrv4Sbl1HqWG2PZ9xKf69vPC+O69k39afEcBNvK5wJVmXTOn8O2wu3JufrH/aQMfHeAEAalNj/LLRCmYMF7tR5JZIdUs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715909653; c=relaxed/simple; bh=AkV6XeHClK+Fq1wvrLHeG+bWnMzsVCeLe4Vq/9STrvU=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=aBxOFwk2kfz+NWLMihB5iXNf/bM4pzosywTUEEd4EqI7EVff24+sxCn7AKblPS8YPXg/KzfOXlD80BfTB0ic0Zx0+KcycCFFt5Y8zE6JB7vf45unBInM8pvPt3bnMwsShT+KpeH/y7i+NKc8DTJmXSH+dsmsM3c2j2Z8HDP2qhQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 44H1Y6Se81833139, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 44H1Y6Se81833139 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 17 May 2024 09:34:06 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 17 May 2024 09:34:07 +0800 Received: from [127.0.1.1] (172.21.69.94) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 17 May 2024 09:34:06 +0800 From: Ping-Ke Shih To: CC: , Subject: [PATCH v2] wifi: rtw89: fix HW scan not aborting properly Date: Fri, 17 May 2024 09:33:50 +0800 Message-ID: <20240517013350.11278-1-pkshih@realtek.com> X-Mailer: git-send-email 2.25.1 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: RTEXMBS02.realtek.com.tw (172.21.6.95) To RTEXMBS04.realtek.com.tw (172.21.6.97) From: Po-Hao Huang There is a length limit on the commands we send to firmware, so dividing to two commands is sometimes required when scanning. When aborting scan, we should not send second scan command to firmware after the first one is finished. This could cause some unexpected errors when we cannot receive firmware events (e.g. in suspend). Another case is scan happens before suspending, ieee80211_do_stop() is called to abort scan and driver indicate scan completion by ieee80211_scan_completed(), which queues event to scan work. But scan work might be late to execute after ieee80211_do_stop(). To correct this, driver indicates ieee80211_scan_completed() before returning, so that ieee80211_do_stop() can flush scan work properly. Fixes: bcbefbd032df ("wifi: rtw89: add wait/completion for abort scan") Cc: stable@vger.kernel.org Co-developed-by: Chih-Kang Chang Signed-off-by: Chih-Kang Chang Signed-off-by: Po-Hao Huang Signed-off-by: Ping-Ke Shih --- v2: - scan abort case only wait for scan completion event, but no need to handle event in C2H work to do further things. - add more description in commit message --- drivers/net/wireless/realtek/rtw89/fw.c | 9 ++++++++- drivers/net/wireless/realtek/rtw89/mac.c | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c index 044a5b90c7f4..f5cd06c35982 100644 --- a/drivers/net/wireless/realtek/rtw89/fw.c +++ b/drivers/net/wireless/realtek/rtw89/fw.c @@ -6245,7 +6245,14 @@ void rtw89_hw_scan_abort(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif) ret = rtw89_hw_scan_offload(rtwdev, vif, false); if (ret) - rtw89_hw_scan_complete(rtwdev, vif, true); + rtw89_warn(rtwdev, "rtw89_hw_scan_offload failed ret %d\n", ret); + + /* Indicate ieee80211_scan_completed() before returning, which is safe + * because scan abort command always waits for completion of + * RTW89_SCAN_END_SCAN_NOTIFY, so that ieee80211_stop() can flush scan + * work properly. + */ + rtw89_hw_scan_complete(rtwdev, vif, true); } static bool rtw89_is_any_vif_connected_or_connecting(struct rtw89_dev *rtwdev) diff --git a/drivers/net/wireless/realtek/rtw89/mac.c b/drivers/net/wireless/realtek/rtw89/mac.c index baefc30b88c4..824ece03d92d 100644 --- a/drivers/net/wireless/realtek/rtw89/mac.c +++ b/drivers/net/wireless/realtek/rtw89/mac.c @@ -4756,6 +4756,9 @@ rtw89_mac_c2h_scanofld_rsp(struct rtw89_dev *rtwdev, struct sk_buff *skb, } return; case RTW89_SCAN_END_SCAN_NOTIFY: + if (rtwdev->scan_info.abort) + return; + if (rtwvif && rtwvif->scan_req && last_chan < rtwvif->scan_req->n_channels) { ret = rtw89_hw_scan_offload(rtwdev, vif, true); @@ -4764,7 +4767,7 @@ rtw89_mac_c2h_scanofld_rsp(struct rtw89_dev *rtwdev, struct sk_buff *skb, rtw89_warn(rtwdev, "HW scan failed: %d\n", ret); } } else { - rtw89_hw_scan_complete(rtwdev, vif, rtwdev->scan_info.abort); + rtw89_hw_scan_complete(rtwdev, vif, false); } break; case RTW89_SCAN_ENTER_OP_NOTIFY: -- 2.25.1