From patchwork Wed Apr 1 11:03:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 216136 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3035EC2D0F1 for ; Wed, 1 Apr 2020 11:07:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED8C12082F for ; Wed, 1 Apr 2020 11:07:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="FzSP18HF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732535AbgDALHQ (ORCPT ); Wed, 1 Apr 2020 07:07:16 -0400 Received: from mail-bn7nam10on2067.outbound.protection.outlook.com ([40.107.92.67]:6024 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732360AbgDALFF (ORCPT ); Wed, 1 Apr 2020 07:05:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AWOLof8BeUkcAShp8UtzVX3QWAvw0/wvLbjIA/TzzqcE/wA12p1UiPFOKvUvdngvWskKpv4g/A7aMiqqFq+oVGzaKAFJRkq8ky41q8VIom/gOxFZhxtQsqBXA2U4k8AV8n8E+YuAyWWTsCj4IYeyhqe2KRgj6XBm938WrEDUquCwJxHU/Vl1hKYhvPQKSrToRmuxMR8mDbzduVFFQSGt8MByVDVj1vIiYzot5zngZUK++JnY4l74GUt33VJlgN0CyWpKyTT6psTCVNjPtUxkbaDOmlUNAtu6VCVkSXOiEf82BgYl74wxlFr6xaMFdenGxtnMrsVEyVR1+1SkSwj//A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zwnnlp0rg2bPpdzDiOZIrKpP7GITQwa8v5Y5n3ZgLMM=; b=gECgh3m+3hzPDMKDxrzUCystlp+oyeEQkJlVjERpR06GgMgMW8mBOEzX5oAI3H+PWKZWNOF6IoEnrlgT/TNyqQo1A39j9H4eDAlZzK1qqbLKXev74g0b6jbB4/oda+fvOtm8V9qVF91u4w/prR96yJ9FpF7EQ8psfh55vOXIrr2WYpgoe8g15d4AxK0ipT/Zb+9paU6pm+kfRBiN7o/7ex4txkyS/ZcJ/x4/arNyAH/S/yIEe1Hzhe4MNFx1/51Nr1gZl0gIyS22EOg9Mn1KBDAD5umgkmijQG8hn34lyCn/gYxfs1QZOMZnCvOONf+qxncBfUd2DFvfkJiIb/JO8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zwnnlp0rg2bPpdzDiOZIrKpP7GITQwa8v5Y5n3ZgLMM=; b=FzSP18HFStzfflJ8FOBKnByETLwdMXwvZK1mC+xyPyhj04EnLlOAqdof/b3xkWDQ3iQALZ3Y0i2j+MHiOOzFoIbygH1ElvH8YuWMjECcPNOfBkolQaZox2yXHMPb9pmxDfdks/axDrVRgimE2BdBQ96AxcxC0qBSyYlenXcrr9c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB4285.namprd11.prod.outlook.com (2603:10b6:208:191::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.20; Wed, 1 Apr 2020 11:04:50 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::ade4:5702:1c8b:a2b3]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::ade4:5702:1c8b:a2b3%7]) with mapi id 15.20.2856.019; Wed, 1 Apr 2020 11:04:50 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 15/32] staging: wfx: drop useless link_map_cache Date: Wed, 1 Apr 2020 13:03:48 +0200 Message-Id: <20200401110405.80282-16-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200401110405.80282-1-Jerome.Pouiller@silabs.com> References: <20200401110405.80282-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: SN4PR0501CA0156.namprd05.prod.outlook.com (2603:10b6:803:2c::34) To MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (2a01:e35:2435:66a0:1265:30ff:fefd:6e7f) by SN4PR0501CA0156.namprd05.prod.outlook.com (2603:10b6:803:2c::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.9 via Frontend Transport; Wed, 1 Apr 2020 11:04:48 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [2a01:e35:2435:66a0:1265:30ff:fefd:6e7f] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f9415d82-8b5a-4082-742f-08d7d62c7f6a X-MS-TrafficTypeDiagnostic: MN2PR11MB4285: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1923; X-Forefront-PRVS: 03607C04F0 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR11MB4063.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(136003)(366004)(346002)(376002)(39850400004)(396003)(7696005)(8676002)(1076003)(16526019)(186003)(5660300002)(86362001)(4326008)(66574012)(52116002)(478600001)(66946007)(66476007)(54906003)(36756003)(8936002)(316002)(81156014)(6486002)(2906002)(66556008)(107886003)(81166006)(2616005); DIR:OUT; SFP:1101; Received-SPF: None (protection.outlook.com: silabs.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KPgPMW7QC/X9UXQ5QF5Mc6H0uFKZs99yEaRKvfc5SaGR5rbgFEykn/7/8P4B5Qb2n9pEXEBlls1/NdhaDLyDHlCPL/r6SyIkg1SczLV2KcSl62N3RrMHqDGbCHHsUvCsFCI8sFcIBQaQP25Yfz9/6rTwb0f6h0bCwbuHae5P3w5nuIeuXfHR96+LfZtIhJ1sPsSqi4oQuQP0Y1HjOc3JYHGOPz0JTp7PqpVJSuNn+AQa42c7MDh5NYyB0WKhDcNzYiOauWHKbWCk5TscHLssoXIgPNA1oFvr9vVGpQvPygCXSNR3Ga1e3m1RCo+GVDIjBRm4FBTMNgKKvAfOLTXr5Kb652x1RfGc8QNQgjwT9Bi/wxO2dISDWL+78R8Uusm0wLKpdCR6kpmq00hRkfwe35Ir/a7S4V333ouCryOLOpnwUG9lXQG2TaKznosSfYw+ X-MS-Exchange-AntiSpam-MessageData: jOB+flDVkLIzuFuEJkZAvwjzoq3vsb3gGI1FRPUv0qAZ37+LE89JVS2ljsYC3rQG0X95QpKwyBBra9pUT0Ow3rdsN06ffEMbvc3LQC9UqTTZDOvAnOUrKxnem+O1vY9zlqNJKN3nAQfoL7OkqpbfR5/BAalStn65BAeZsVY2FOYT8zXVPSmNAQ1qlnt6kdHgKcoKDkhXLU+VR96AF3lFsQ== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9415d82-8b5a-4082-742f-08d7d62c7f6a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2020 11:04:50.3051 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Q/DfLUB9YtTtRUfpAjg3Hjw10HsYiWHvRLX0aO0eF4AO+dU+XZ8TMOskyHH1IeYeDjTERB20O4jobIEh6X6/YQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4285 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller Driver does not use link_map_cache anymore. So we can drop it. In add, we do not have to keep this counter in sync with skb_queue item, so we can drop explicit spin_locks. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/queue.c | 60 ++++++++----------------------------- drivers/staging/wfx/queue.h | 3 -- 2 files changed, 12 insertions(+), 51 deletions(-) diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 6fa8f4e083d3..82c2781b1f78 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -94,20 +94,10 @@ void wfx_tx_queues_wait_empty_vif(struct wfx_vif *wvif) static void wfx_tx_queue_clear(struct wfx_dev *wdev, struct wfx_queue *queue, struct sk_buff_head *gc_list) { - int i; struct sk_buff *item; - struct wfx_queue_stats *stats = &wdev->tx_queue_stats; - spin_lock_bh(&queue->queue.lock); - while ((item = __skb_dequeue(&queue->queue)) != NULL) + while ((item = skb_dequeue(&queue->queue)) != NULL) skb_queue_head(gc_list, item); - spin_lock_nested(&stats->pending.lock, 1); - for (i = 0; i < ARRAY_SIZE(stats->link_map_cache); ++i) { - stats->link_map_cache[i] -= queue->link_map_cache[i]; - queue->link_map_cache[i] = 0; - } - spin_unlock(&stats->pending.lock); - spin_unlock_bh(&queue->queue.lock); } void wfx_tx_queues_clear(struct wfx_dev *wdev) @@ -163,28 +153,15 @@ int wfx_tx_queue_get_num_queued(struct wfx_queue *queue) void wfx_tx_queue_put(struct wfx_dev *wdev, struct wfx_queue *queue, struct sk_buff *skb) { - struct wfx_queue_stats *stats = &wdev->tx_queue_stats; - struct wfx_tx_priv *tx_priv = wfx_skb_tx_priv(skb); - - WARN(tx_priv->link_id >= ARRAY_SIZE(stats->link_map_cache), "invalid link-id value"); - spin_lock_bh(&queue->queue.lock); - __skb_queue_tail(&queue->queue, skb); - - ++queue->link_map_cache[tx_priv->link_id]; - - spin_lock_nested(&stats->pending.lock, 1); - ++stats->link_map_cache[tx_priv->link_id]; - spin_unlock(&stats->pending.lock); - spin_unlock_bh(&queue->queue.lock); + skb_queue_tail(&queue->queue, skb); } static struct sk_buff *wfx_tx_queue_get(struct wfx_dev *wdev, struct wfx_queue *queue, u32 link_id_map) { - struct sk_buff *skb = NULL; - struct sk_buff *item; struct wfx_queue_stats *stats = &wdev->tx_queue_stats; + struct sk_buff *item, *skb = NULL; struct wfx_tx_priv *tx_priv; spin_lock_bh(&queue->queue.lock); @@ -195,39 +172,28 @@ static struct sk_buff *wfx_tx_queue_get(struct wfx_dev *wdev, break; } } + spin_unlock_bh(&queue->queue.lock); if (skb) { + skb_unlink(skb, &queue->queue); tx_priv = wfx_skb_tx_priv(skb); tx_priv->xmit_timestamp = ktime_get(); - __skb_unlink(skb, &queue->queue); - --queue->link_map_cache[tx_priv->link_id]; - - spin_lock_nested(&stats->pending.lock, 1); - __skb_queue_tail(&stats->pending, skb); - --stats->link_map_cache[tx_priv->link_id]; - spin_unlock(&stats->pending.lock); + skb_queue_tail(&stats->pending, skb); + if (skb_queue_empty(&queue->queue)) + wake_up(&stats->wait_link_id_empty); + return skb; } - spin_unlock_bh(&queue->queue.lock); - if (skb_queue_empty(&queue->queue)) - wake_up(&stats->wait_link_id_empty); return skb; } int wfx_pending_requeue(struct wfx_dev *wdev, struct sk_buff *skb) { struct wfx_queue_stats *stats = &wdev->tx_queue_stats; - struct wfx_tx_priv *tx_priv = wfx_skb_tx_priv(skb); struct wfx_queue *queue = &wdev->tx_queue[skb_get_queue_mapping(skb)]; WARN_ON(skb_get_queue_mapping(skb) > 3); - spin_lock_bh(&queue->queue.lock); - ++queue->link_map_cache[tx_priv->link_id]; - spin_lock_nested(&stats->pending.lock, 1); - ++stats->link_map_cache[tx_priv->link_id]; - __skb_unlink(skb, &stats->pending); - spin_unlock(&stats->pending.lock); - __skb_queue_tail(&queue->queue, skb); - spin_unlock_bh(&queue->queue.lock); + skb_unlink(skb, &stats->pending); + skb_queue_tail(&queue->queue, skb); return 0; } @@ -235,9 +201,7 @@ int wfx_pending_remove(struct wfx_dev *wdev, struct sk_buff *skb) { struct wfx_queue_stats *stats = &wdev->tx_queue_stats; - spin_lock_bh(&stats->pending.lock); - __skb_unlink(skb, &stats->pending); - spin_unlock_bh(&stats->pending.lock); + skb_unlink(skb, &stats->pending); wfx_skb_dtor(wdev, skb); return 0; diff --git a/drivers/staging/wfx/queue.h b/drivers/staging/wfx/queue.h index 58da216d47dd..dd141cb4bf63 100644 --- a/drivers/staging/wfx/queue.h +++ b/drivers/staging/wfx/queue.h @@ -16,18 +16,15 @@ #define WFX_LINK_ID_NO_ASSOC 15 #define WFX_LINK_ID_AFTER_DTIM (WFX_LINK_ID_NO_ASSOC + 1) #define WFX_LINK_ID_UAPSD (WFX_LINK_ID_NO_ASSOC + 2) -#define WFX_LINK_ID_MAX (WFX_LINK_ID_NO_ASSOC + 3) struct wfx_dev; struct wfx_vif; struct wfx_queue { struct sk_buff_head queue; - int link_map_cache[WFX_LINK_ID_MAX]; }; struct wfx_queue_stats { - int link_map_cache[WFX_LINK_ID_MAX]; struct sk_buff_head pending; wait_queue_head_t wait_link_id_empty; };