Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp279825lqp; Wed, 12 Jun 2024 00:58:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV64SClKjBOcKmpZA4Baf5mY4GBBhws650A6noGcK8V1DhJFOcNB9WA4XthEdKKYv/ToiGKk51mbT0yY36nVopkQnI/w+V5I8jPkARm0A== X-Google-Smtp-Source: AGHT+IG849fw3nGl5RK7yhCmWeH1AijKfX6wmIfDYonXReAu2DwNAAcBstfps73wmmKBMIHEjMkp X-Received: by 2002:a17:906:da09:b0:a6f:4961:1c83 with SMTP id a640c23a62f3a-a6f49611da3mr59149166b.22.1718179130775; Wed, 12 Jun 2024 00:58:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718179130; cv=pass; d=google.com; s=arc-20160816; b=G2c5EafYGkJkXFulzmfXCafJ46Ud2grGYUOxZIyD3JrH+/Pi26cUlB/bCLSmkoFbLV 9/yvCwBs4KmiCOxlvN9j7h7ISG4iXc9ZZIgC3Etkr8h0eHqwU1QB8A1eGTfvD366B36V fBB6pVeII3RwVOYDgK1Qtglbi7nJVUMWlynVLAVoL67gowNa+2i1Bfi99AnH4VAsJK51 XXc9VeXxH2uPIUb8yECMaI9znYDp5DMBtxsFmHo9UoOvIy6BKP0uH5ZybqKHtlQZmyOl Mq0iWzbhPdKbflgFxJiM/xo4KH3dUWmaKgdHGiJQzIb6Z88ktPod31Pg18zYMHc51Cca R7nA== 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 :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=ndOyxQUJxrNxnsAspzStG/x5rg/w1hxjNghGsxB7p88=; fh=YalJvZsXqCMV1dWs4efIUmPI/5o7DmA6mUFitDKjk+A=; b=ECiAwkp2fuiGGcSdIdo/UVlGmOGfF7q2CjQ5mwcMHxEI270yv4Dsqk0nohZO8yZ4gN /piMCGVfYP15/vhjmGWCpY0PzV/Qj/KXmjtMER/jg5ne95ezWsNakIvRzTqZ1QzkAaVw woS7pCZMDyXtpGER+4qZtg7xznKbkOms6/ZNulWd0netHOz+eoqRZWG6i04AlGfg3BSu WSWvICYzBQA7m7cGX/WeU3MQ7HTJHICXJOSr/mskBYEzVWWpXmuPU2QT/IuLbYISpy2O itANqOd8lvz4fHgf+OzykxC2nHCMdIh/SAvirwqXweTtDD4r1S0auqQUOvby+DNhEgTe TMNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=BCx1hMRm; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-8837-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8837-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6ef71f0ca0si458417266b.323.2024.06.12.00.58.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 00:58:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8837-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=@sipsolutions.net header.s=mail header.b=BCx1hMRm; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-8837-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8837-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net 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 035DD1F23E2B for ; Wed, 12 Jun 2024 07:58:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22EDA16C6B1; Wed, 12 Jun 2024 07:58:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="BCx1hMRm" X-Original-To: linux-wireless@vger.kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 3FD9A16B736; Wed, 12 Jun 2024 07:58:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718179100; cv=none; b=kh3Z39NarP3zDnBxbFaW+qUma6wug0cAcNS9m2lCUV18yeiBlmMtNuEiah6f+tPg3UmeCXyChPUCILuWsvXDmVB22OZJU+PDZlaPeAaH0zrCimW81eK+GHCIgBTNfPAY2OvkKV0r/cpHIGeWfpc8g05xZhZTshQEVRfbywtHp1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718179100; c=relaxed/simple; bh=2jKJ20lACwa8Lhy1jPFHX9qJeJNWe+wNDq/R6ZIvLEU=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=m6vVIM0QRMBkz/zsGKjSMI3no4S9mawTMeIudofoobtxzPnaskPqhHSjcH5Yn9IRpdYzwkcsjGPtQciXBCKM/aAhXbx2QxGulSPrdg1dxiv75HjO7LvqT0N29PMweS3epQRIchGMcmkz4yMdA9eXksYBy7BEp4KN9AI0g/9U1mY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=BCx1hMRm; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=ndOyxQUJxrNxnsAspzStG/x5rg/w1hxjNghGsxB7p88=; t=1718179098; x=1719388698; b=BCx1hMRmC4U1XdOuSVJX8a6DM9QWHWmGM0RfTFx97Ig/7WN N8n87o7A043LalhVEtQ94bWUV4U0X9NWriFwjD09YlapAutT4UDs15SBl/gMUKh/dznGQZg+ybhJt z+AgxFsjeWXotfsVz4m2BV159G9RXBLoEpMYd4hzDzLpOcDN4oCUX0jaKc1s0E7oSo6XFwsYrq/Z0 g698Tab+zsWii/HHVVN5F0msk3Qk1t9FkPCLk+TwaG9VXU3Eg+L4mP0qIyxFmdVhzxS3RmVnYZC+y Uic823OrYt+gFApUaC/gcmuqd5vztWrv+TBvWe9w5EdebProp33X6fTJcIYWi+ag==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1sHIs1-0000000A1tt-1BRh; Wed, 12 Jun 2024 09:58:13 +0200 Message-ID: <7869b9b29b6796c95fd5af649e4bd6696e56dcaf.camel@sipsolutions.net> Subject: Re: [REGRESSION][BISECTED] wifi: RTL8821CE does not work in monitor mode From: Johannes Berg To: Ping-Ke Shih , Thorsten Leemhuis , Savyasaachi Vanga , Christian Heusel Cc: Kalle Valo , "linux-wireless@vger.kernel.org" , "regressions@lists.linux.dev" Date: Wed, 12 Jun 2024 09:58:12 +0200 In-Reply-To: <6a88e0d3e47ebbd1f0f383094e4804a627c41870.camel@sipsolutions.net> References: <809d2332-625e-4a46-a77e-ca2e49b0d651@leemhuis.info> <0e65ca6b471b4186a370b9a57de11abe@realtek.com> <36c1f49acfcc2cc16c7e54ffeb76f1e93cb96e91.camel@sipsolutions.net> <5318640d6eb74301b1fbf6d9385ba69e@realtek.com> <6a88e0d3e47ebbd1f0f383094e4804a627c41870.camel@sipsolutions.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.2 (3.52.2-1.fc40) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-malware-bazaar: not-scanned On Wed, 2024-06-12 at 09:07 +0200, Johannes Berg wrote: > On Wed, 2024-06-12 at 00:56 +0000, Ping-Ke Shih wrote: >=20 >=20 > > > Just got pinged (sp?) about this, can you share the driver fix so I c= an > > > take a look what the issue is about? > > >=20 > >=20 > > Please reference patch below. I copy this idea from rtw89 [1], which th= e main > > stuff is to add WANT_MONITOR_VIF and case NL80211_IFTYPE_MONITOR in add= _interface().=20 >=20 > Ah, OK, but that gives me a hint. Yes, I see the issue now. >=20 > OK it's not trivial and it might leave ath12k still not working (though > not sure it ever did before? or maybe I'm missing something...), but I > think I can fix this. Let's see. >=20 I don't have any of the affected hardware, could someone test this? https://p.sipsolutions.net/619a4ce4a197b2b4.txt diff --git a/net/mac80211/driver-ops.c b/net/mac80211/driver-ops.c index dce37ba8ebe3..254d745832cb 100644 --- a/net/mac80211/driver-ops.c +++ b/net/mac80211/driver-ops.c @@ -311,6 +311,18 @@ int drv_assign_vif_chanctx(struct ieee80211_local *loc= al, might_sleep(); lockdep_assert_wiphy(local->hw.wiphy); =20 + /* + * We should perhaps push emulate chanctx down and only + * make it call ->config() when the chanctx is actually + * assigned here (and unassigned below), but that's yet + * another change to all drivers to add assign/unassign + * emulation callbacks. Maybe later. + */ + if (sdata->vif.type =3D=3D NL80211_IFTYPE_MONITOR && + local->emulate_chanctx && + !ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) + return 0; + if (!check_sdata_in_driver(sdata)) return -EIO; =20 @@ -338,6 +350,11 @@ void drv_unassign_vif_chanctx(struct ieee80211_local *= local, might_sleep(); lockdep_assert_wiphy(local->hw.wiphy); =20 + if (sdata->vif.type =3D=3D NL80211_IFTYPE_MONITOR && + local->emulate_chanctx && + !ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) + return; + if (!check_sdata_in_driver(sdata)) return; =20 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index dc42902e2693..4a49e834a9f5 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1121,9 +1121,6 @@ int ieee80211_add_virtual_monitor(struct ieee80211_lo= cal *local) struct ieee80211_sub_if_data *sdata; int ret; =20 - if (!ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) - return 0; - ASSERT_RTNL(); lockdep_assert_wiphy(local->hw.wiphy); =20 @@ -1145,11 +1142,13 @@ int ieee80211_add_virtual_monitor(struct ieee80211_= local *local) =20 ieee80211_set_default_queues(sdata); =20 - ret =3D drv_add_interface(local, sdata); - if (WARN_ON(ret)) { - /* ok .. stupid driver, it asked for this! */ - kfree(sdata); - return ret; + if (ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) { + ret =3D drv_add_interface(local, sdata); + if (WARN_ON(ret)) { + /* ok .. stupid driver, it asked for this! */ + kfree(sdata); + return ret; + } } =20 set_bit(SDATA_STATE_RUNNING, &sdata->state); @@ -1187,9 +1186,6 @@ void ieee80211_del_virtual_monitor(struct ieee80211_l= ocal *local) { struct ieee80211_sub_if_data *sdata; =20 - if (!ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) - return; - ASSERT_RTNL(); lockdep_assert_wiphy(local->hw.wiphy); =20 @@ -1209,7 +1205,8 @@ void ieee80211_del_virtual_monitor(struct ieee80211_l= ocal *local) =20 ieee80211_link_release_channel(&sdata->deflink); =20 - drv_remove_interface(local, sdata); + if (ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) + drv_remove_interface(local, sdata); =20 kfree(sdata); } diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 283bfc99417e..963ed75deb76 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1843,7 +1843,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) =20 /* add interfaces */ sdata =3D wiphy_dereference(local->hw.wiphy, local->monitor_sdata); - if (sdata) { + if (sdata && ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) { /* in HW restart it exists already */ WARN_ON(local->resuming); res =3D drv_add_interface(local, sdata);