From patchwork Wed Apr 1 11:03:42 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: 216135 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 4A995C43331 for ; Wed, 1 Apr 2020 11:07:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1262120857 for ; Wed, 1 Apr 2020 11:07:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="JkRezrZF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732361AbgDALFD (ORCPT ); Wed, 1 Apr 2020 07:05:03 -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 S1732336AbgDALE7 (ORCPT ); Wed, 1 Apr 2020 07:04:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EXpNqxVZ36DKGXSO4zUy6HJII2UTmqpgYtmHHc5vF2vzycgIxxIG84xLs+Y7r00fn/ttXekr/HZEsnRo4S0xALBpdqxrMZeLGcldpT+iO/JBhXSjuEnWkVZsOmKUWBaORAmAox3Kh4j7scLPXjsAXHBTLGFdAI5rPMV1rY7XUkIx44OtKHtxKEwUVsalYjcEOpN97DiNUXmwVMYiUrCmyS9rlRg5FQnA7eMtcJTrDZYryulAx3o+s1g9d9HLiZDkbwVwlfm4dgoU7Sx8D3JdZQ5BcssuRSp6r+sVG1PaBhiWVC3ok5W2sPnsKLI5FLWrtkn36m4vlbA2CPU4JLqWvg== 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=x+eX5nf2XUfm/gzl2JO527/3MkvsW0eUhq6lGEQMTLQ=; b=EOWq9n8zYJ0n/2PtF7llRg38kqrDT8fDWto1smtC8JCdDWBjL6nvkIrl5iIjBcsjqPswyBj+QNv/UNcDq4Pn8R4XGEkzLAMmTQV6JxerbkBEPuo78I6T7jg6r+nAvS2IOiPHTaDEh91yUDXqzArCLWO/vM/k3t3x9WYMRxwXvsa3HKTHqaqxhlpKlROV1QGeBE+xSSUMfGEorJTLpMO4s6M68lL4c5X/zefUUFyfLHtcyYvUFO4TYl6cfo+HjGEvEOUXWOB/lBbldklpZwFQKAvSOaO+JqvcT+A0nW4t7/UTwLao194IJMfxwYSrZMgo4xgMX42yyJRdpVPP0kdUVQ== 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=x+eX5nf2XUfm/gzl2JO527/3MkvsW0eUhq6lGEQMTLQ=; b=JkRezrZFi0T8U20gHfu3OTHCwWTrS4U5vU34154jj/XLcdpl7iUw0MlPnwXyuDGnKsHvGYRiHhh6dCkR2jUXTc5tR8xEOCVSg64aoT77p0qtsWhaeAHBAfz7Xz05O8wnCLg4ldL6sigZCGSsw2JCRNEXSYQlJ1Wx1WxWSmczPi4= 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:38 +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:38 +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 09/32] staging: wfx: simplify wfx_tx_queues_empty() Date: Wed, 1 Apr 2020 13:03:42 +0200 Message-Id: <20200401110405.80282-10-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:36 +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: 89ec6921-7e35-4b4b-8487-08d7d62c7857 X-MS-TrafficTypeDiagnostic: MN2PR11MB4285: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; 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)(6666004)(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: iN0tFBjk/Ff/Imcr0m8ioARP9oqpF6JFePGGsJw137nnI1zrjx/QZXKbBToEQVUTYlbTplRnGiAoS3eimYyo8VHEQmnan7z6jcP3NLhdSXBWZKNUBqpzBgjq407Ig2NVwY6yU5PJklidHvZj3T3UrK5SwrKwHLnG8uxXO+ZySBykEzh7DdqZTfLu8p271TvTrlnF4E+dlbGyirFG15b6i0WZfBvJA+oUeK0fxnYREZ7hmz6ZTDrVVH/8R/i69+HBzxBS3QDcMk06yK9hKeM112AVH/G06Hq3VCGCRCQgyKlsaHDvxC/0DTNGFLVt6zoNplXmel3E4nfq7OVv3oeSzq3PeSJuHCZ6EqUyVNVGRUPXlpikagxJB65MMxdpqKQPByyHy6zmuRkNFi3e6AyY8MVxit460ulNyP4d1a1vwtcB4ZXvfhoY43XxD3LuiwMK X-MS-Exchange-AntiSpam-MessageData: 0tl48AQxG9HbRamJmOO/lLtYySxapJK/1fijyp7SPfELAmCbtWzansTV+lE9fuTO+iopeaRQuXYVnr8weWz0T087TgFhsuSz5a6qIaLcdUpJT1BMevKa4VKl+w0RJN5E/JK5WHJ/Bsk5o2vf5vyid6nnRVGyH9TMEerLuOA+ZIrRWK0uTo9gtvY39emfFtfGFXa8Gxx2KDfssFDLmIEbXg== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89ec6921-7e35-4b4b-8487-08d7d62c7857 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2020 11:04:38.5489 (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: XRa6XDyMQlaqq1PJxZMRF1c43d6kAHeNYaneluqMTnLz+IKj2Bq03MKJ5VRQ2g1+UDg9JCXezqw0ADHXMiWxQQ== 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 Thanks to skb_queue_empty_lockless(), it is not necessary to acquire the spin_lock before to check if the queue is empty. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/queue.c | 16 +++++----------- drivers/staging/wfx/queue.h | 2 +- drivers/staging/wfx/sta.c | 4 ++-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 8647731e02c0..09f823929fb6 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -303,20 +303,14 @@ unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, return ktime_us_delta(now, tx_priv->xmit_timestamp); } -bool wfx_tx_queues_is_empty(struct wfx_dev *wdev) +bool wfx_tx_queues_empty(struct wfx_dev *wdev) { int i; - struct sk_buff_head *queue; - bool ret = true; - for (i = 0; i < IEEE80211_NUM_ACS; i++) { - queue = &wdev->tx_queue[i].queue; - spin_lock_bh(&queue->lock); - if (!skb_queue_empty(queue)) - ret = false; - spin_unlock_bh(&queue->lock); - } - return ret; + for (i = 0; i < IEEE80211_NUM_ACS; i++) + if (!skb_queue_empty_lockless(&wdev->tx_queue[i].queue)) + return false; + return true; } static bool wfx_handle_tx_data(struct wfx_dev *wdev, struct sk_buff *skb) diff --git a/drivers/staging/wfx/queue.h b/drivers/staging/wfx/queue.h index 2284fa64b625..5a5aa38dbb2f 100644 --- a/drivers/staging/wfx/queue.h +++ b/drivers/staging/wfx/queue.h @@ -40,7 +40,7 @@ void wfx_tx_lock_flush(struct wfx_dev *wdev); void wfx_tx_queues_init(struct wfx_dev *wdev); void wfx_tx_queues_deinit(struct wfx_dev *wdev); void wfx_tx_queues_clear(struct wfx_dev *wdev); -bool wfx_tx_queues_is_empty(struct wfx_dev *wdev); +bool wfx_tx_queues_empty(struct wfx_dev *wdev); void wfx_tx_queues_wait_empty_vif(struct wfx_vif *wvif); struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev); struct hif_msg *wfx_tx_queues_get_after_dtim(struct wfx_vif *wvif); diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index a275330f5518..be493b5f2b5d 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -325,11 +325,11 @@ static int __wfx_flush(struct wfx_dev *wdev, bool drop) if (drop) wfx_tx_queues_clear(wdev); if (wait_event_timeout(wdev->tx_queue_stats.wait_link_id_empty, - wfx_tx_queues_is_empty(wdev), + wfx_tx_queues_empty(wdev), 2 * HZ) <= 0) return -ETIMEDOUT; wfx_tx_flush(wdev); - if (wfx_tx_queues_is_empty(wdev)) + if (wfx_tx_queues_empty(wdev)) return 0; dev_warn(wdev->dev, "frames queued while flushing tx queues"); }