From patchwork Wed Jan 15 13:54:29 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: 216623 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.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,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 9739AC33CB1 for ; Wed, 15 Jan 2020 14:00:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5C52D2467C for ; Wed, 15 Jan 2020 14:00:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="dvcZD+Gb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729518AbgAONyr (ORCPT ); Wed, 15 Jan 2020 08:54:47 -0500 Received: from mail-dm6nam11on2085.outbound.protection.outlook.com ([40.107.223.85]:14113 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729454AbgAONyq (ORCPT ); Wed, 15 Jan 2020 08:54:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Te0daHa6Hy88EMAnbIKWHh99DYl84LH8Wc2QTkB6uwPmZH9w/YQ5ImcWS3LivYzoJdG4r8v/d8GUCEhBPVIKDxv1DnpXkjRWG/oCzlHxhpiaqSTisAhnt3/Lk2T31Sd+J+se7o1d1nWdMHzQN3gPv0e0sGSDbLInIAyoD/vPH2clvB4dx4CSj2ApIXn1lcJM+CN+STNKeTjzSyySv+zccODObeUQmQqVv+YEgnWKL8m9uS/C3fq7ImicJYhFjy3gqLcv4qmvcwf2kgpYN+ZYp4djD/ZGACUM4jluEvnN0U2gD1DBKvAR780ig0DKUM6ndSc8h8nss+kw3m1RqPyPcw== 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=9v8lmwrZH/RnjmTRFxIndgVQtr5M/Rb020b3Yufs6f8=; b=czBbthKRyd3vyj0NGMthtLLHrpoAPA5PbjxtGDgZMWkwUZYEZ06cbPM6acSyPRsq9azZFO8GfThzOAkLXgyAS/npYqrUI382LiLKwDOwKjhK4s+BZavtB3Ioak3eJjNkhTQ8naH/apFogeckLx7a00DhYYSWZQzUzH9GIJUdGb2B+87jEOeCqX8KqxLi5KRpWKxOuiwEbEliDNueAaNouw9FjvwgMz2DhN8Ju+3XiHrHXKbqiEgP8pHbQhD5rFQwmaSfbUIA5Xhhb4miZSlkmX8DfCRU2hp3U3ZCH5SIk+amLQMpwb2ZvEZtnwS5zSouNu5ZAxn5XYmh397g2zaZYA== 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=9v8lmwrZH/RnjmTRFxIndgVQtr5M/Rb020b3Yufs6f8=; b=dvcZD+GbmbUOcpCx2CcJ4GK/g9PXyTKzHgjKHRNFZmUYoaFxxXm0vw69NLXiOHkPUQFFAsnUhN+UyoYas6PMZNiFhZuAY336Eba1vG1ByHPpMChyVqhqQx2jJfMeQe7M48BXtrxnge5hCaCFLdx/Gqf5CiQiVBXyz/0PXkGJMmU= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB4094.namprd11.prod.outlook.com (10.255.180.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.19; Wed, 15 Jan 2020 13:54:29 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::f46c:e5b4:2a85:f0bf]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::f46c:e5b4:2a85:f0bf%4]) with mapi id 15.20.2623.018; Wed, 15 Jan 2020 13:54:29 +0000 Received: from pc-42.home (2a01:e35:8bf5:66a0:3dbe:4cb5:6059:a948) by PR2P264CA0008.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.18 via Frontend Transport; Wed, 15 Jan 2020 13:54:27 +0000 From: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= 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?SsOpcsO0bWUgUG91?= =?utf-8?q?iller?= Subject: [PATCH v2 19/65] staging: wfx: fix __wfx_flush() when drop == false Thread-Topic: [PATCH v2 19/65] staging: wfx: fix __wfx_flush() when drop == false Thread-Index: AQHVy6tOjJgVdNaIeEm4iALKY8/T+Q== Date: Wed, 15 Jan 2020 13:54:29 +0000 Message-ID: <20200115135338.14374-20-Jerome.Pouiller@silabs.com> References: <20200115135338.14374-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20200115135338.14374-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR2P264CA0008.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::20) To MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.25.0 x-originating-ip: [2a01:e35:8bf5:66a0:3dbe:4cb5:6059:a948] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 724be364-0141-4c1a-c623-08d799c2709e x-ms-traffictypediagnostic: MN2PR11MB4094: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 02830F0362 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39850400004)(366004)(396003)(346002)(136003)(376002)(189003)(199004)(316002)(110136005)(54906003)(85202003)(81156014)(5660300002)(8676002)(71200400001)(8936002)(81166006)(186003)(6506007)(86362001)(66946007)(66446008)(66476007)(66556008)(2906002)(64756008)(478600001)(6512007)(52116002)(66574012)(6486002)(1076003)(16526019)(4326008)(85182001)(107886003)(36756003)(8886007)(2616005); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4094; H:MN2PR11MB4063.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; 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: BFVKgGbPcwqP6yrBXPBYCLM/QwwwUojMH4+1vw01rffuoidf+VkdyLuYSpQGDb6pA4Xr9caSTyDQz+/zzr5xWN7yrs8EsKzuEPQdJKNmmrarTzXCr202D3AflRYRuz+5uzWDKy5u6e4eNDdiQ+MVA+UDTeTr37481iFiakwt0eWbaF7Ux7gd1IWktKuMEGgfSaB3oqL6T0153HnXs05QgkCa20F+oPEHEE7V1wSRWd+wG5H4wHw19nnTTN2z4PiTA4xexJLpgj/9P1rpC9Juzva2ZFdNCPLqFpswNfG6Kapoim7oV3O+zBcDAMeveXJtjhaRcqobqyippeO3EwUvNUn0+llSw714PMuay7Z8kdMV+pV7DLF6u2F+smHjaMRdbVI6YWCLj+Vi1zjmEj3Q5IhITlf/KYr+M3YlCxm0rIaJKYOaoAtTBHkX7Nq9S/Qt Content-ID: MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 724be364-0141-4c1a-c623-08d799c2709e X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 13:54:29.0502 (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: lOQbPPAs26qcXBwIoaLFSyKED6qyoXoC2kXYXnhL6atqzXXU2Oi/3YGG64FPt/MtdF/3QlZXM17fqxZIfwJrWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4094 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller wfx_tx_queues_clear() only clear not yet sent requests. So, it always necessary to wait for tx_queue_stats.wait_link_id_empty whatever the value of "drop" argument. In add, it is not necessary to return with tx queue locked since all calls to __wfx_flush() unlock the tx queue just after the call to __wfx_tx_flush(). Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/queue.c | 2 -- drivers/staging/wfx/sta.c | 42 ++++++++++--------------------------- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index abfbad7c9f75..92bb9a794f30 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -31,8 +31,6 @@ void wfx_tx_flush(struct wfx_dev *wdev) { int ret; - WARN(!atomic_read(&wdev->tx_lock), "tx_lock is not locked"); - // Do not wait for any reply if chip is frozen if (wdev->chip_frozen) return; diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 0c73691ab736..3d665eef8ba7 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -343,42 +343,25 @@ int wfx_set_rts_threshold(struct ieee80211_hw *hw, u32 value) return 0; } -/* If successful, LOCKS the TX queue! */ static int __wfx_flush(struct wfx_dev *wdev, bool drop) { - int ret; - for (;;) { - if (drop) { + if (drop) wfx_tx_queues_clear(wdev); - } else { - ret = wait_event_timeout( - wdev->tx_queue_stats.wait_link_id_empty, - wfx_tx_queues_is_empty(wdev), - 2 * HZ); - } - - if (!drop && ret <= 0) { - ret = -ETIMEDOUT; - break; - } - ret = 0; - - wfx_tx_lock_flush(wdev); - if (!wfx_tx_queues_is_empty(wdev)) { - /* Highly unlikely: WSM requeued frames. */ - wfx_tx_unlock(wdev); - continue; - } - break; + if (wait_event_timeout(wdev->tx_queue_stats.wait_link_id_empty, + wfx_tx_queues_is_empty(wdev), + 2 * HZ) <= 0) + return -ETIMEDOUT; + wfx_tx_flush(wdev); + if (wfx_tx_queues_is_empty(wdev)) + return 0; + dev_warn(wdev->dev, "frames queued while flushing tx queues"); } - return ret; } void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u32 queues, bool drop) { - struct wfx_dev *wdev = hw->priv; struct wfx_vif *wvif; if (vif) { @@ -389,10 +372,8 @@ void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, !wvif->enable_beacon) drop = true; } - // FIXME: only flush requested vif - if (!__wfx_flush(wdev, drop)) - wfx_tx_unlock(wdev); + __wfx_flush(hw->priv, drop); } /* WSM callbacks */ @@ -1046,8 +1027,7 @@ static int wfx_set_tim_impl(struct wfx_vif *wvif, bool aid0_bit_set) skb = ieee80211_beacon_get_tim(wvif->wdev->hw, wvif->vif, &tim_offset, &tim_length); if (!skb) { - if (!__wfx_flush(wvif->wdev, true)) - wfx_tx_unlock(wvif->wdev); + __wfx_flush(wvif->wdev, true); return -ENOENT; } tim_ptr = skb->data + tim_offset;