From patchwork Sat Nov 18 15:50:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 745153 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32BBBC2BB3F for ; Sat, 18 Nov 2023 15:52:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230479AbjKRPwl (ORCPT ); Sat, 18 Nov 2023 10:52:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbjKRPw0 (ORCPT ); Sat, 18 Nov 2023 10:52:26 -0500 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 113DC1705; Sat, 18 Nov 2023 07:51:27 -0800 (PST) Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-d9a6399cf78so2391158276.0; Sat, 18 Nov 2023 07:51:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700322685; x=1700927485; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SrDABjtie/YsTla3oR4TwoLfOAKA91LiKhvoQvuKuZ0=; b=kjjbNi9ampdDnKd3zsNfGlvyotuVRpTMFasdFcBZSuASyM7r0SZeuKIg9iXIWqr8FF kjOdeEnby6zw0bWAlnZeK+skpxFk85DrayPy1N70H/xesbLTMqO/cn0HhhSTtDimrejm H/JeiPxktiKXqn6UlFFbLVSHdaHRR6dXUihHu4dxoBs4R9vmxmuGsttGGeK1+C7cSA22 pRsbuKiu/ODwIABAgL8cdZ3lG6FNG/xGU2YkhYSzPWMuEMEtGj+sifZQLuxtu7ZoGfqa B2HBINkWNoP0tPrucZmrIqDwEy8VVsCYaSc2RxtZHecJ89/q0L+b1jqP9CNsURLKrleq aDMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700322685; x=1700927485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SrDABjtie/YsTla3oR4TwoLfOAKA91LiKhvoQvuKuZ0=; b=M/9I8S0aHZDkNfUL/rmE3xhIxYSoDkIjbp3AX4ebud0xx2rYzDPD2E4QRcoCa6uR48 v7xzuS0yrngL5b/U1vDgtnaV4Avz/xXB8C/8VvTjzhhluiLrpeHIyh8NgD7pP2o4hzIR plVkIeSlyhiGL2b0VGO+UVrjjjp59oW4c4MVP9V6VWaJrAgJY0s3XK7xrB37PsCkeEun X5nUtLYbARaDVb1DNKalCZj2Pw9RxoMQpEdJW9fopEAWB7pjII78830l6QXK/aNe7M1z jaodA1eHQDOwSpbUpSRe4hDy0HLdT6SgpprQCH7omBhBWW7EGxY5pi8/q49AhTgmubwp k7/A== X-Gm-Message-State: AOJu0Yzu6LjgcBVP+RUuzpN6J3C1+4CQcrSwvI2bmfUl0r3mtDpjXP42 5blB62JtLVKnJpTf+1RpGAUM6FgobsTPdmMR X-Google-Smtp-Source: AGHT+IFTfzteXdMOCngH4g6ThBL8jMLQtAxdwFQMPhz1ymRIf3wQ4UJX7I6T1IJmIedN4upY2EbAuQ== X-Received: by 2002:a25:ad4f:0:b0:daf:7702:fd60 with SMTP id l15-20020a25ad4f000000b00daf7702fd60mr1666269ybe.1.1700322684938; Sat, 18 Nov 2023 07:51:24 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:48a9:bd4c:868d:dc97]) by smtp.gmail.com with ESMTPSA id e14-20020a25d30e000000b00d9cd730e4d0sm1000457ybf.26.2023.11.18.07.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 07:51:24 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, Kalle Valo , Jeff Johnson , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org Cc: Yury Norov , Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov Subject: [PATCH 10/34] ath10k: optimize ath10k_snoc_napi_poll() by using find_bit() Date: Sat, 18 Nov 2023 07:50:41 -0800 Message-Id: <20231118155105.25678-11-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231118155105.25678-1-yury.norov@gmail.com> References: <20231118155105.25678-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org ath10k_snoc_napi_poll() traverses pending_ce_irqs bitmap bit by bit. We can do it faster by using for_each_test_and_clear_bit() iterator. Signed-off-by: Yury Norov --- drivers/net/wireless/ath/ath10k/snoc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 2c39bad7ebfb..a1db5a973780 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -1237,11 +1237,10 @@ static int ath10k_snoc_napi_poll(struct napi_struct *ctx, int budget) return done; } - for (ce_id = 0; ce_id < CE_COUNT; ce_id++) - if (test_and_clear_bit(ce_id, ar_snoc->pending_ce_irqs)) { - ath10k_ce_per_engine_service(ar, ce_id); - ath10k_ce_enable_interrupt(ar, ce_id); - } + for_each_test_and_clear_bit(ce_id, ar_snoc->pending_ce_irqs, CE_COUNT) { + ath10k_ce_per_engine_service(ar, ce_id); + ath10k_ce_enable_interrupt(ar, ce_id); + } done = ath10k_htt_txrx_compl_task(ar, budget); From patchwork Sat Nov 18 15:50:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 745152 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0ECBCC5ACB3 for ; Sat, 18 Nov 2023 15:52:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230382AbjKRPwu (ORCPT ); Sat, 18 Nov 2023 10:52:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231134AbjKRPw2 (ORCPT ); Sat, 18 Nov 2023 10:52:28 -0500 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D5381728; Sat, 18 Nov 2023 07:51:29 -0800 (PST) Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-da0359751dbso2372606276.1; Sat, 18 Nov 2023 07:51:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700322688; x=1700927488; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/7UbIoFa3HLA+YNouSNyxHd1ANvqTMMe1TaZ6Yb0imk=; b=KAi1o1Lp2NXwdu7Wp2qrYSU1kAU39h4nCxehYxl8oMXiayPkh0Q3w/J9ydhyMErtxH 4qcESin55kISPjFb4nD6h7tm8Drs9yk9ITYtfYpqhRTc1ZLLV3Hxy3EzxlpoTAVcnFIF HrF+Cks34FmnTYFTG1GezpcK3MxWcW5vRrrZEiuLZo45H4OImCbrOS4s1vGq81zYoFFA MzPsW+2v3WUuNPg17AqgaNfFqIdsA7bK0GOIRKUkDzRwvtu63GfYqRvQ3XlsnBbMGOCA kuUhkDvJj/MXlAOEHpBRWsCGlE/nhsoGr5rfga4yWUDCOzXSywEmuG3FC2KCoaonDgIJ atxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700322688; x=1700927488; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/7UbIoFa3HLA+YNouSNyxHd1ANvqTMMe1TaZ6Yb0imk=; b=tByGhZ5Qiz9yPFEuwaCgeDROxQEZA1QwOkU7blb+kM6cfMvG+M7LHn7V9RKwm+lZE9 xKONKvwhXDiHhDAs75OwCbhabqiFqykPFvOiIwh/6ZwVg1IFRmPwkC9ceKGrbWGn5xnn lp03mxOPC1d47QbflBbrJeRfDwrB76dw6LDuYWSsM2Mapy8XZ3rjqTe1dqyadqKQto0o nW9GjbJrGkk4Lp85GypdWldfZg2mb5+2IABjwp1rc1RFwLChF4o6rKCU2fFimeTb4hAK CcYtJqwtuuQDVcSpJ1YQZroYSGkkGdr2saseBF6P8wI5f2GEzKOdtX48ZjBkLAyujQV4 tKBg== X-Gm-Message-State: AOJu0YzYzv4yYTGCKXFCN/v11vwMFj/gIIbxgs96Sz2acUt45KbXES62 8bsaVeiCKoKsFuGrhC3mypDrVjfXGtsZXaVp X-Google-Smtp-Source: AGHT+IG2fdzu87N53rGqJR9N9gQqCXQKJNf4sG4KZv9s0gbPje53w6L12nPkNTqg8pVr1QpQJBOnQg== X-Received: by 2002:a25:ad4f:0:b0:daf:7702:fd60 with SMTP id l15-20020a25ad4f000000b00daf7702fd60mr1666371ybe.1.1700322688428; Sat, 18 Nov 2023 07:51:28 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:48a9:bd4c:868d:dc97]) by smtp.gmail.com with ESMTPSA id w4-20020a254904000000b00da3b52e3cf5sm1010714yba.10.2023.11.18.07.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 07:51:27 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, Stanislaw Gruszka , Kalle Valo , Gregory Greenman , Hans de Goede , Johannes Berg , Kees Cook , Yury Norov , Miri Korenblit , linux-wireless@vger.kernel.org Cc: Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov Subject: [PATCH 12/34] wifi: intel: use atomic find_bit() API where appropriate Date: Sat, 18 Nov 2023 07:50:43 -0800 Message-Id: <20231118155105.25678-13-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231118155105.25678-1-yury.norov@gmail.com> References: <20231118155105.25678-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org iwlegacy and iwlwifi code opencodes atomic bit allocation/traversing by using loops. Switch it to use dedicated functions. Signed-off-by: Yury Norov --- .../net/wireless/intel/iwlegacy/4965-mac.c | 7 ++----- drivers/net/wireless/intel/iwlegacy/common.c | 8 ++------ drivers/net/wireless/intel/iwlwifi/dvm/sta.c | 8 ++------ drivers/net/wireless/intel/iwlwifi/dvm/tx.c | 19 ++++++++----------- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c b/drivers/net/wireless/intel/iwlegacy/4965-mac.c index 69276266ce6f..8fb738c95cb4 100644 --- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c @@ -2089,12 +2089,9 @@ il4965_txq_ctx_stop(struct il_priv *il) static int il4965_txq_ctx_activate_free(struct il_priv *il) { - int txq_id; + int txq_id = find_and_set_bit(&il->txq_ctx_active_msk, il->hw_params.max_txq_num); - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) - if (!test_and_set_bit(txq_id, &il->txq_ctx_active_msk)) - return txq_id; - return -1; + return txq_id < il->hw_params.max_txq_num ? txq_id : -1; } /* diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c index 054fef680aba..c6353e17be50 100644 --- a/drivers/net/wireless/intel/iwlegacy/common.c +++ b/drivers/net/wireless/intel/iwlegacy/common.c @@ -2303,13 +2303,9 @@ EXPORT_SYMBOL(il_restore_stations); int il_get_free_ucode_key_idx(struct il_priv *il) { - int i; - - for (i = 0; i < il->sta_key_max_num; i++) - if (!test_and_set_bit(i, &il->ucode_key_table)) - return i; + int i = find_and_set_bit(&il->ucode_key_table, il->sta_key_max_num); - return WEP_INVALID_OFFSET; + return i < il->sta_key_max_num ? i : WEP_INVALID_OFFSET; } EXPORT_SYMBOL(il_get_free_ucode_key_idx); diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/sta.c b/drivers/net/wireless/intel/iwlwifi/dvm/sta.c index 8b01ab986cb1..21e663d2bc44 100644 --- a/drivers/net/wireless/intel/iwlwifi/dvm/sta.c +++ b/drivers/net/wireless/intel/iwlwifi/dvm/sta.c @@ -719,13 +719,9 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) int iwl_get_free_ucode_key_offset(struct iwl_priv *priv) { - int i; - - for (i = 0; i < priv->sta_key_max_num; i++) - if (!test_and_set_bit(i, &priv->ucode_key_table)) - return i; + int i = find_and_set_bit(&priv->ucode_key_table, priv->sta_key_max_num); - return WEP_INVALID_OFFSET; + return i < priv->sta_key_max_num ? i : WEP_INVALID_OFFSET; } void iwl_dealloc_bcast_stations(struct iwl_priv *priv) diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/tx.c b/drivers/net/wireless/intel/iwlwifi/dvm/tx.c index 111ed1873006..1b3dc99b968c 100644 --- a/drivers/net/wireless/intel/iwlwifi/dvm/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/dvm/tx.c @@ -460,17 +460,14 @@ int iwlagn_tx_skb(struct iwl_priv *priv, static int iwlagn_alloc_agg_txq(struct iwl_priv *priv, int mq) { - int q; - - for (q = IWLAGN_FIRST_AMPDU_QUEUE; - q < priv->trans->trans_cfg->base_params->num_of_queues; q++) { - if (!test_and_set_bit(q, priv->agg_q_alloc)) { - priv->queue_to_mac80211[q] = mq; - return q; - } - } - - return -ENOSPC; + int q = find_and_set_next_bit(priv->agg_q_alloc, + priv->trans->trans_cfg->base_params->num_of_queues, + IWLAGN_FIRST_AMPDU_QUEUE); + if (q >= priv->trans->trans_cfg->base_params->num_of_queues) + return -ENOSPC; + + priv->queue_to_mac80211[q] = mq; + return q; } static void iwlagn_dealloc_agg_txq(struct iwl_priv *priv, int q)