From patchwork Fri Sep 22 11:12:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13395546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4F75ECD4F49 for ; Fri, 22 Sep 2023 11:13:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=x1Dlg8nE93AY1wAR+U32Ln6mwtbAmsrGSac84dDSPLc=; b=xflDtF91i2OJeA N/al+cfw47WpIfzxI44CEv20KuYHlLC71es9lJfR7/Np0Xg61HaW4tXL9LK6ErPzNbP4af0D55V2y EDg0XQRDvLZ++UPwIcmQmbsgag8Tfu2OK+Efj82T9cJNOpzGdQ7YlhSBH4W3IBU6TLIAo0RvZrjit qpAU47XkgHxFd+4gbxZAvomdvm6ChDgeAT4f1u9Dy0sZyaWyOr7aMU/oOK50mL9JQmsAPCTTb1cRf MAA4yWlK0cz/5mY+FW85kMtmey8WGISGDsdqNswM9mdWMNfgEqFsQPyAOGD2DdwBmmUcmuZ0MeGjv O7iQjLXyHo6BMVz1aEVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qje5v-008vT6-27; Fri, 22 Sep 2023 11:13:11 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qje5s-008vSL-1L for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 11:13:09 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-31dcf18f9e2so1917679f8f.0 for ; Fri, 22 Sep 2023 04:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695381186; x=1695985986; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Mo60L/CqsBXTZMp9OSNBO8agQpgsikCTWPBLj8xU0z8=; b=JvM8X+FR+6Eu9ieoBRSqG+C1FWk2SLeRdeBayZi0s9Mcolthuzvj3avWdfRlQJh8ur FnYMOOVIXzO4oqmookOpo7hWBgfZtuZl/96jHVfWcLonIJVcmH/ar4LU6ovHbyIsTxUf CEUC0o8qv83+EjA08XIZG/I0mN69m1RDvRVm883fzfleJ7SO4dyd+2pmz/4YUVBMAnGB Qd5ykcc+A8iHNj+Yaxy+qwIr6Ay/7x/ivyH70bhUPqOqjnDWia/11oy6+jhD+QEf6zBo 0FXWfAoVbArwo60lOjB8kumbxSQGv/CrumZtrWt0rUORTqMAPdkZH85RoOtX++L5QNpw mRYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695381186; x=1695985986; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Mo60L/CqsBXTZMp9OSNBO8agQpgsikCTWPBLj8xU0z8=; b=Kbe799ybhaa7pKUv5gjX6DQdnDTlmv6IB43hEPCnnmVw+WUaNFaCrGAhV6PyoPsvoM gWvqZEsT4rFD0sOoOi4fAre6t0Nza2NQczneNle0e9OycX5knwqA/5eEPK31G/PCK8E7 E2MVatrkwIVoWVx6fKBzaUSxtSJRU27G3s8HDLhJVRFcNL9cALfqTcpm7bk5PHFJ/8HZ uy3pjUFI9L2WmIJWVMBS/+o+WAUchv080LlkAFVcXUlbByjZs1mKtJJXgmkMvBC4u5nh 3fBbq3zjWhzXuwpL8HwkT20hX3IvPn8xx0yZtFPbH86qc0eQ5DL4LieAWGgru/0QpET2 OJZA== X-Gm-Message-State: AOJu0YyF+RpgKE+vCRcKGpAvPH0z75nO3SIXzq91kUNA4zfK/bTb3Ity D4Zdc5rxwapjfQ/R0cWvr1U= X-Google-Smtp-Source: AGHT+IH7mPXmlPp61fOS1UbXVt881rz7wfseEorF4MkXdznkIZPNZgazS5rBLuHv+qOU+uGgsaXdlQ== X-Received: by 2002:a5d:694d:0:b0:314:12c:4322 with SMTP id r13-20020a5d694d000000b00314012c4322mr7281735wrw.4.1695381185667; Fri, 22 Sep 2023 04:13:05 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id g10-20020adffc8a000000b003176c6e87b1sm4191765wrr.81.2023.09.22.04.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 04:13:04 -0700 (PDT) From: Christian Marangi To: Vincent Whitchurch , Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Ping-Ke Shih , Kalle Valo , Simon Horman , Daniel Borkmann , Jiri Pirko , Hangbin Liu , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH 1/3] net: introduce napi_is_scheduled helper Date: Fri, 22 Sep 2023 13:12:45 +0200 Message-Id: <20230922111247.497-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_041308_478197_E53DECBD X-CRM114-Status: GOOD ( 17.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We currently have napi_if_scheduled_mark_missed that can be used to check if napi is scheduled but that does more thing than simply checking it and return a bool. Some driver already implement custom function to check if napi is scheduled. Drop these custom function and introduce napi_is_scheduled that simply check if napi is scheduled atomically. Update any driver and code that implement a similar check and instead use this new helper. Signed-off-by: Christian Marangi Reviewed-by: Amritha Nambiar --- drivers/net/ethernet/chelsio/cxgb3/sge.c | 8 -------- drivers/net/wireless/realtek/rtw89/core.c | 2 +- include/linux/netdevice.h | 5 +++++ net/core/dev.c | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c index 2e9a74fe0970..71fa2dc19034 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c @@ -2501,14 +2501,6 @@ static int napi_rx_handler(struct napi_struct *napi, int budget) return work_done; } -/* - * Returns true if the device is already scheduled for polling. - */ -static inline int napi_is_scheduled(struct napi_struct *napi) -{ - return test_bit(NAPI_STATE_SCHED, &napi->state); -} - /** * process_pure_responses - process pure responses from a response queue * @adap: the adapter diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c index 133bf289bacb..bbf4ea3639d4 100644 --- a/drivers/net/wireless/realtek/rtw89/core.c +++ b/drivers/net/wireless/realtek/rtw89/core.c @@ -1744,7 +1744,7 @@ static void rtw89_core_rx_to_mac80211(struct rtw89_dev *rtwdev, struct napi_struct *napi = &rtwdev->napi; /* In low power mode, napi isn't scheduled. Receive it to netif. */ - if (unlikely(!test_bit(NAPI_STATE_SCHED, &napi->state))) + if (unlikely(!napi_is_scheduled(napi))) napi = NULL; rtw89_core_hw_to_sband_rate(rx_status); diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index db3d8429d50d..8eac00cd3b92 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -482,6 +482,11 @@ static inline bool napi_prefer_busy_poll(struct napi_struct *n) return test_bit(NAPI_STATE_PREFER_BUSY_POLL, &n->state); } +static inline bool napi_is_scheduled(struct napi_struct *n) +{ + return test_bit(NAPI_STATE_SCHED, &n->state); +} + bool napi_schedule_prep(struct napi_struct *n); /** diff --git a/net/core/dev.c b/net/core/dev.c index cc03a5758d2d..32ba8002f65a 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6523,7 +6523,7 @@ static int __napi_poll(struct napi_struct *n, bool *repoll) * accidentally calling ->poll() when NAPI is not scheduled. */ work = 0; - if (test_bit(NAPI_STATE_SCHED, &n->state)) { + if (napi_is_scheduled(n)) { work = n->poll(n, weight); trace_napi_poll(n, work, weight); }