From nobody Fri Nov 29 08:33:08 2024 Received: from e3i110.smtp2go.com (e3i110.smtp2go.com [158.120.84.110]) (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 43C531AC896 for ; Tue, 24 Sep 2024 19:27:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=158.120.84.110 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727206051; cv=none; b=Q0nbmVWsff3GEz74U3J5ZSDKb/12RCicZmSJz8Hgf/Clg7r66mmLOwLvE7wQLY2E5hxISRiKdjVYHx1uTrFTcxiI0TlvX6rUoPNxwY9473lQyHvuw3ugxvBLoMtWC8XhN4nvCoZmwr9ySJ9qfQ5FU2S7yqyJi9ZdgrIwU0ImSvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727206051; c=relaxed/simple; bh=o9AheMXyJ5Cmyc7lZF52KShBkTdeQHX7e9sg1eH8R50=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QoIU+/bWkXsHw+cb5hThRV6+uOh/m6DSixKPN1WqUEDeU+XHq3BpjiYD21DCS0/msXk0x6N4HlvVncSsDuwtbmkV/z7Xcth/b8xl7VcVmaDPdcAHU8vplunENcWEYcL9zj9AYK9ZK1uImxsBh5jLEp5M+RAb1ueekxNRiLkDXYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=triplefau.lt; spf=pass smtp.mailfrom=em510616.triplefau.lt; dkim=pass (2048-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b=nIot1445; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b=TrXAzbuB; arc=none smtp.client-ip=158.120.84.110 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=triplefau.lt Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=em510616.triplefau.lt Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b="nIot1445"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b="TrXAzbuB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smtpservice.net; i=@smtpservice.net; q=dns/txt; s=a1-4; t=1727206039; h=feedback-id : x-smtpcorp-track : date : message-id : to : subject : from : reply-to : sender : list-unsubscribe : list-unsubscribe-post; bh=jHlTPG4NgHWnOrGLqSDIw8d/8MpR/1AQpbQk+oiNe2Q=; b=nIot1445T3M2Go+ukBYkDAcsg0qn/aNKs97xbdnvzfoFWbcRJiHFuuHJtBSSSURGukr6W EOi3qw/kyICkoI66FG21bcP2gqKmx7kyJy+Upwx2r2O9LIo8bjFvtkWq++OkzrTaeIor4co 6Dvz6g7cDOfyXd2A6IdjUEgej8HeNynaJIsJJvqBWaRq1nXzP+c9NfWWsZ4WBCjCLbdiRT5 C8LKZmSOOX9WSpLQQYBLX5tYQujNBTBm1GMNwXnJ+cNMEyUxeo2l6msEhLkKPpHVxxU0/I2 cyYFiaXneQnLiHX7ygKqXeLXnHL73DIHJrQGc4Ghf9RHcObEvAC81Z9+WXNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1727206039; h=from : subject : to : message-id : date; bh=jHlTPG4NgHWnOrGLqSDIw8d/8MpR/1AQpbQk+oiNe2Q=; b=TrXAzbuBNvNR3psAVDd+bQ9Loa3xIAPl7kuOuSVaOyzLJdyhMHXld3U8lkPgDnFwg1R6z OjffqFjcoNh35Pr//Tnr4ot5ani6XaRTbXj40cWXKMTFeeRmX/wys/AMMByVTTeIPc+0ouk 4rfjdXd7Lz9DJutdPH13T0rI1ZTcJr/cysi9uDe5K0XHATWETwEJlWgm2zhDDHw2dEiVmpe fkLAJ1j9vd9U8nEqkDtrWC61nxbtOG6ZGn+l0n3x4cVShSINZHBGQXOM2hUE9Rmaudxm2IK lMzSb8TRxgko3Fe307Qg/8cmuq3lZ146Hy5g0Nuxgth6WBqes+bSoYVoIcew== Received: from [10.12.239.196] (helo=localhost) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97.1-S2G) (envelope-from ) id 1stBBs-4o5NDgrlCD5-plB2; Tue, 24 Sep 2024 19:27:16 +0000 From: Remi Pommarel To: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Johannes Berg , Nicolas Cavallari , Nicolas Escande , Remi Pommarel Subject: [PATCH 1/2] wifi: cfg80211: Add wiphy_delayed_work_pending() Date: Tue, 24 Sep 2024 21:28:04 +0200 Message-Id: <20240924192805.13859-2-repk@triplefau.lt> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20240924192805.13859-1-repk@triplefau.lt> References: <20240924192805.13859-1-repk@triplefau.lt> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please forward a copy of this message, including all headers, to Feedback-ID: 510616m:510616apGKSTK:510616sPHEybd7wU X-smtpcorp-track: zzz-q7KFr31j.cexLJDwcJWnW.dJj51AiTsyY Content-Type: text/plain; charset="utf-8" Add wiphy_delayed_work_pending() to check if any delayed work timer is pending, that can be used to be sure that wiphy_delayed_work_queue() won't postpone an already pending delayed work. Signed-off-by: Remi Pommarel --- include/net/cfg80211.h | 44 ++++++++++++++++++++++++++++++++++++++++++ net/wireless/core.c | 7 +++++++ 2 files changed, 51 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 192d72c8b465..01697b624095 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -6129,6 +6129,50 @@ void wiphy_delayed_work_cancel(struct wiphy *wiphy, void wiphy_delayed_work_flush(struct wiphy *wiphy, struct wiphy_delayed_work *dwork); =20 +/** + * wiphy_delayed_work_pending - Find out whether a wiphy delayable + * work item is currently pending. + * + * @wiphy: the wiphy, for debug purposes + * @dwork: the delayed work in question + * + * return value: true if timer is pending, false otherwise + * + * How wiphy_delayed_work_queue() works is by setting a timer which + * when it expires calls wiphy_work_queue() to queue the wiphy work. + * Because wiphy_delayed_work_queue() uses mod_timer(), if it is + * called twice and the second call happens before the first call + * deadline, the work will rescheduled for the second deadline and + * won't run before that. + * + * wiphy_delayed_work_pending() can be used to detect if calling + * wiphy_work_delayed_work_queue() would start a new work schedule + * or delayed a previous one. As seen below it cannot be used to + * detect precisely if the work has finished to execute nor if it + * is currently executing. + * + * CPU0 CPU1 + * wiphy_delayed_work_queue(wk) + * mod_timer(wk->timer) + * wiphy_delayed_work_pending(wk) -> t= rue + * + * [...] + * expire_timers(wk->timer) + * detach_timer(wk->timer) + * wiphy_delayed_work_pending(wk) -> f= alse + * wk->timer->function() | + * wiphy_work_queue(wk) | delayed work pending + * list_add_tail() | returns false but + * queue_work(cfg80211_wiphy_work) | wk->func() has not + * | been run yet + * [...] | + * cfg80211_wiphy_work() | + * wk->func() V + * + */ +bool wiphy_delayed_work_pending(struct wiphy *wiphy, + struct wiphy_delayed_work *dwork); + /** * enum ieee80211_ap_reg_power - regulatory power for an Access Point * diff --git a/net/wireless/core.c b/net/wireless/core.c index 4d5d351bd0b5..c9a1158dbdd1 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -1704,6 +1704,13 @@ void wiphy_delayed_work_flush(struct wiphy *wiphy, } EXPORT_SYMBOL_GPL(wiphy_delayed_work_flush); =20 +bool wiphy_delayed_work_pending(struct wiphy *wiphy, + struct wiphy_delayed_work *dwork) +{ + return timer_pending(&dwork->timer); +} +EXPORT_SYMBOL_GPL(wiphy_delayed_work_pending); + static int __init cfg80211_init(void) { int err; --=20 2.46.0