Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1434971lqt; Wed, 20 Mar 2024 04:09:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUB3M1vGEaxez1Dq0Ms0ADeoeeC1oUqsihforM9oIniIQQBBywuenLLLwpTuImbSBt5kAi0E1+T0m0LwjXsfEMTw8+79AuGibKWgpNmAw== X-Google-Smtp-Source: AGHT+IF2YHLLTU1TAWkV7BDQ+rmD6fyDZn/4RF499FAf+dHRj3pVTqe+/tcO/1xDkgjLee+H7U+m X-Received: by 2002:a9d:6189:0:b0:6e4:8fa3:d861 with SMTP id g9-20020a9d6189000000b006e48fa3d861mr17788891otk.34.1710932980173; Wed, 20 Mar 2024 04:09:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710932980; cv=pass; d=google.com; s=arc-20160816; b=SVYlglJUnU/fQRV4IMeYcdHSJWws1Q7kXgiBevlfDrVjrtKSzDtM/umvggATotRuLj Ll6jI/iMd57zyOTC+Hm9/9y/tdYBGUCm9RKnNwhmGHQJQDNxwScaAudF8ibwWi0KJAdz 078dhgsMtJEZg2f+g6LalV2LkjiPodoyr0a/R/36lNOOtXCq5AN4kD9Vw42phE+vTwis 6mQkk2f+C4JQY440DKlrUjbEzvATuYd33d2FFN9x/LgAGt2n4tTdjRThc6hAM3zujcC4 9hxw1zsyuI+UnoyYQVC1M05xLRfSncqGIz1QQbpYbom1p0Fr3zGO0CzmhfQm9/PaEz8/ bgxw== ARC-Message-Signature: i=2; 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=gOrIZkIrcVV+GEoWV1OmKv6z/f07V5RnvOpBqKJxDOw=; fh=Z+Z00P3BX4/PycutDmQesIMsG0rblVqNN0fMHyC5sgk=; b=ag+oGoZadxQu6uzwGJvw3AnPsia8EM0fwTob6tlXxJlljh9T4HWClEb6+0vIp8I8T4 c7Nf+30zgOgTdQgpCxiOZPfFlTNkzWV0TUD87YQzrsrVytxAxr+x2K/IN1rcIcbS8pQg iUM4xooMYwOoGyty9mwwDOWwQWCcSVlCSsmz9rfoneYXqiCj6JuTm59Hpui5pqdr7rgf 7LXTD8X8mFMRfcWPDlncwtCTDyIUslByCEIYMmZqGrahp8/6YY2eHiUAUpNcLDFTaFTy kveyBLsQnK6sxtDEJEiZQc25BeEHSQv4+n7NzZ68X3j+6xQRska/4gqzRqZvB68TiQES MB6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Q1aALXCS; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-wireless+bounces-4969-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i9-20020a05620a248900b0078875079cfbsi14857244qkn.739.2024.03.20.04.09.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 04:09:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-4969-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=@mediatek.com header.s=dk header.b=Q1aALXCS; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-wireless+bounces-4969-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4969-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B023C1C22EFD for ; Wed, 20 Mar 2024 11:09:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B41483BBE0; Wed, 20 Mar 2024 11:09:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Q1aALXCS" X-Original-To: linux-wireless@vger.kernel.org Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 BF5C7381AC for ; Wed, 20 Mar 2024 11:09:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710932973; cv=none; b=hATAvlYdwcnoTAjPyGy4lz79jXrYNrYppYb4FxMNdpHplIq+tM8Sm0CCGzP/gI/PM564IBJ5RDyedAuSNUyHdKp+Qf8yjFB0XaOCMDvP+7ubp0NSbOJNpMp2wzEjHhhslK6LnEMG2sLA3aMZd8lLoe4/ATqDwtX0mfhHkp2wmic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710932973; c=relaxed/simple; bh=/LE61X8y/DdGcEpKMaHMMhHVEyTCNolALQsVuGo2OdA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k9vYwW96Q5VtjnZI1uEh+yKRYm4CBhG0W598kMA0NQkcFVEWGTC2fBLyGHQYL7hqsEZLuNqxYqGtPWmZf/SKHB1rRnKAQ17rBiObOwkltwSOue9kK8SOZqz16eCYFwEz3NQDAPq6+4JnCjyVpIxqxJRgGrl28Qi3jOTLzvdw9Xo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=Q1aALXCS; arc=none smtp.client-ip=60.244.123.138 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: 4f5ee388e6aa11eeb8927bc1f75efef4-20240320 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=gOrIZkIrcVV+GEoWV1OmKv6z/f07V5RnvOpBqKJxDOw=; b=Q1aALXCSvHu8+5CtOqR2lc6W2QCol0v7aHB3jaWo57YbwYiIVnRNwwY+/K+MabC1ctHr1aon9w+QfFHpJn5f2zQ2HYhPNIkbmr0uKwkuJxJtG0wh/qPEOuFmOAJGmcGOrkTm07Y4ny5wtg7r8GLEpfVP5Ganrl0EHSfbFD8+nIw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:077bf87f-4b6a-4c1a-92b4-59701bef646f,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:6f543d0,CLOUDID:dcd9b881-4f93-4875-95e7-8c66ea833d57,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,RT: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,TF_CID_SPAM_ULN X-UUID: 4f5ee388e6aa11eeb8927bc1f75efef4-20240320 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 639166594; Wed, 20 Mar 2024 19:09:24 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 20 Mar 2024 19:09:24 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 20 Mar 2024 19:09:24 +0800 From: Shayne Chen To: Felix Fietkau CC: linux-wireless , Lorenzo Bianconi , Ryder Lee , Evelyn Tsai , Bo Jiao , linux-mediatek , StanleyYP Wang , Shayne Chen Subject: [PATCH 08/10] wifi: mt76: mt7996: add sanity checks for background radar trigger Date: Wed, 20 Mar 2024 19:09:16 +0800 Message-ID: <20240320110918.3488-8-shayne.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240320110918.3488-1-shayne.chen@mediatek.com> References: <20240320110918.3488-1-shayne.chen@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 X-MTK: N From: StanleyYP Wang Check if background radar is enabled or not before manually triggering it, and also add more checks in radar detected event. Signed-off-by: StanleyYP Wang Signed-off-by: Shayne Chen --- drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c | 5 +++++ drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c index 9bd953586b04..62c03d088925 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c @@ -225,6 +225,11 @@ mt7996_radar_trigger(void *data, u64 val) if (val > MT_RX_SEL2) return -EINVAL; + if (val == MT_RX_SEL2 && !dev->rdd2_phy) { + dev_err(dev->mt76.dev, "Background radar is not enabled\n"); + return -EINVAL; + } + return mt7996_mcu_rdd_cmd(dev, RDD_RADAR_EMULATE, val, 0, 0); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c index ccae954a22f8..c024f138f1ca 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c @@ -355,7 +355,10 @@ mt7996_mcu_rx_radar_detected(struct mt7996_dev *dev, struct sk_buff *skb) if (r->band_idx >= ARRAY_SIZE(dev->mt76.phys)) return; - if (dev->rdd2_phy && r->band_idx == MT_RX_SEL2) + if (r->band_idx == MT_RX_SEL2 && !dev->rdd2_phy) + return; + + if (r->band_idx == MT_RX_SEL2) mphy = dev->rdd2_phy->mt76; else mphy = dev->mt76.phys[r->band_idx]; -- 2.39.2