From patchwork Mon Jan 22 12:46:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 10178461 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A42E760224 for ; Mon, 22 Jan 2018 12:47:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0FEA281DB for ; Mon, 22 Jan 2018 12:47:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95D9128236; Mon, 22 Jan 2018 12:47:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09377281DB for ; Mon, 22 Jan 2018 12:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751178AbeAVMrO (ORCPT ); Mon, 22 Jan 2018 07:47:14 -0500 Received: from mail-bl2nam02on0084.outbound.protection.outlook.com ([104.47.38.84]:56768 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751156AbeAVMrM (ORCPT ); Mon, 22 Jan 2018 07:47:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=seRZ0tz9KQ6LsBqOyRHNaRQabNPI/nVyl+/bAUovcI4=; b=LsFp3Qjx334Fueb/qhkqBfVizAvdVo0qaXpnbu9i4bpGKb02+XGisTjD5zmZzDwu9G3NSje4QTlwhJQIJ3zg397RxRBXSHzvy1+ErRGhEQRZn9Uaz+oNCZpeIqHB5PGT8KL4gQofYtf0suRwMPTGhgCav/dXTYUglGQ37jSVMuI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=sergey.matyukevich.os@quantenna.com; Received: from bars.quantenna.com (195.182.157.78) by CY1PR05MB1931.namprd05.prod.outlook.com (10.162.216.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.5; Mon, 22 Jan 2018 12:47:10 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Avinash Patil Subject: [PATCH 09/11] qtnfmac: do not use mutexes in timer context Date: Mon, 22 Jan 2018 15:46:32 +0300 Message-Id: <20180122124634.8430-10-sergey.matyukevich.os@quantenna.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180122124634.8430-1-sergey.matyukevich.os@quantenna.com> References: <20180122124634.8430-1-sergey.matyukevich.os@quantenna.com> MIME-Version: 1.0 X-Originating-IP: [195.182.157.78] X-ClientProxiedBy: VI1PR08CA0220.eurprd08.prod.outlook.com (10.170.234.157) To CY1PR05MB1931.namprd05.prod.outlook.com (10.162.216.13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 47849e36-497e-4598-6825-08d5619641a3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534125)(4602075)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020); SRVR:CY1PR05MB1931; X-Microsoft-Exchange-Diagnostics: 1; CY1PR05MB1931; 3:5GITNujLzO0mc6nqY71Kaxag/BEBfPglg1oCUieu/dGMjJopCY9L4C/l2TXf0POTR4RyLb2k7OsfsE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pnn+kvGL4LU6UIBSQn5GM0eCRLcRdeSMzNFHXnwtFPGMT14IkSOJuUTb6orn22m/rhEJyz8PzyWRuXSwbt9HSOcxmRad7bL3dAT/k2iltZma2kSvVovm7Nq8/J7FAON91Q5nEEyFBC8amMlrleX5Wg4UH4qVEsTCwab3QbjhTL4ToRqGlv3ytL8hU0nSaFHGI55YRd8STt6cbvXZvGJPuTUQsR+FhcUDPHM8QSArE5nC+3Cr8iEhbbs1lVlXoYFH9OAijZ5Y7issdndsVKfkm0TcDz0i2; 4:/YIzoxPNNwH44io5hHXByUaZ5iGa8xJ49VmErBnQg+qx5yc//DKJGXLiyDcfgAErocQ707jdi8N3sD70zUe6Zui73Gr3kj6zQNmbJ2w+pKP1Ambg/oiGD4kbIKBnHSjfKASQ5TuzINDGek84G2NvIOoncWaFiW9JJlO8sXu0H5/HhbKraGze28+w/zxOgr6p3M0bxmehfvbZx47Tu88oUY142LOQqHNju0eDTo0VuYprQaOeHDBwQW2KDp4nRpREAtNSOHdQ+NuaDR+WPhLR1w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231023)(2400081)(944501161)(10201501046)(3002001)(93006095)(93001095)(6041288)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY1PR05MB1931; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY1PR05MB1931; X-Forefront-PRVS: 0560A2214D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39840400004)(396003)(366004)(346002)(39380400002)(199004)(189003)(2351001)(25786009)(52116002)(1076002)(6116002)(26005)(59450400001)(2361001)(36756003)(4326008)(76176011)(107886003)(478600001)(8676002)(8936002)(50226002)(7736002)(81166006)(6916009)(6666003)(2950100002)(305945005)(2906002)(106356001)(105586002)(68736007)(6486002)(81156014)(53936002)(48376002)(66066001)(16526018)(47776003)(103116003)(97736004)(50466002)(5660300001)(3846002)(386003)(16586007)(316002)(51416003)(7696005)(53416004)(54906003)(69596002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR05MB1931; H:bars.quantenna.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR05MB1931; 23:/+x3q/zbuLhnDhfML5mJBNHcm6gL+6+nJi1mFPHMO?= =?us-ascii?Q?99yjlZ5r2RD1QyevIu62IWS2XKfZDoftWOwJf2QhYEwU1xW3+YTQyaxNnFvL?= =?us-ascii?Q?UznS6hPN241OWrN3CN26u6+hbyoiRkCO0cjfC/IxLv3a0LHlici9EhyUrzs+?= =?us-ascii?Q?7qo41F12CBMukaahsFyCl0jjD67cJdWLz2NOsi9LIzmwppegZjgW1hCFIPQD?= =?us-ascii?Q?/IqK0ksuu8bG1BxDVD43/G7+6qidL/KwFzzPQRzvMAxnABAjAfKo8GuaDvfu?= =?us-ascii?Q?7qIDRfEvVMcMeAGqFRmzjN+L9NFgtMt8fjrjOYy/cJI5HTwaxiYLn8sVqNz6?= =?us-ascii?Q?ws7b/ZjFFH8plHLccvHvZj1VS1aDqUEhyEh2srICOyn7ard88hK/vo5fZS8p?= =?us-ascii?Q?jvXXR7VEKhrg6A+amouF4TeQOZIUrzk7yJSslVhmyBOeq9pnTaEj5/jLpn1Z?= =?us-ascii?Q?f5yiU0Fu2TC89d6tNrVLg5AJOrgUVDWR2gvnEqgNDAOeHnpud6nstY8Ip/va?= =?us-ascii?Q?U9qzQ2rewPkO7dESeZSgRo00EfkXva9dT7dhWpBVB9xkzvJSV/LT7btZ5bvV?= =?us-ascii?Q?j2AJdmxavcMvNsYWEoSHHeLS8/yy09cOGC5H4WPdVWJdZdpcUHJpO0dQmAnv?=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7AlHT1TBDWhVfwB5mi/mi7K5hYH6kCG5TWgP9HzVRvrmX5YlIEsfPKHMjLs6YwusD4JA4DqYdnP6L4ZOC+qsf3V/O0s=; 5:6g7hUXhHszRVQIbhy84ykRVGF2btw3kZkyFa6EFeA94UsdHFUqqXuNiwI35aztBtPIRWKZi8OOpcauHozl7drtuzK0hZ6o0lgAH5bO3Hz6g/0KXzY7tV4ACIUZzYimn+ODNugeV8Mtx2y9ry1XrZr0tnVZ6xNxMd7vTzBFXGTYM=; 24:oftlfs4EjXcgLYCUbZUYj6kBSOJUT1JSuPJr1B+7PIEkynBOdBOzVB2ua3wKDPUmwQswPNYxnb4aNJ6YnbPXGnJ+zGptRV5ABkmdJM5jGfA=; 7:qz6Xxm4OCTuIxpI2UQdX70Q0njve45ZRxiSjlhYVGaAnyeO+PWxKqJ6A1NPPeiqBZjHwlGA0Irb83Z67mPWYzi6EiZGujLJyAr8nh7njbMpB1iH/8R6QjG2MOTsPQUycvY/slv2bSCNzQ6xVNJW6kG+QhlodUOyPWTgKhA2UOWiPg9AXRbOajB06gHvko2W3YWVgAx/KKFZzDHV4hkct49FrJ1MOdd8u2D/9+Mq2ng3LKGVvN4Qi0xKbO2gkoa87 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2018 12:47:10.6072 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47849e36-497e-4598-6825-08d5619641a3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR05MB1931 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Igor Mitsyanko The function qtnf_scan_done makes use of mutexes which is wrong since it may be called from timer context. Move scan timeout handler from timer to deferred work. Signed-off-by: Igor Mitsyanko --- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 15 +++-------- drivers/net/wireless/quantenna/qtnfmac/cfg80211.h | 19 ------------- drivers/net/wireless/quantenna/qtnfmac/core.c | 33 ++++++++++++++++++++++- drivers/net/wireless/quantenna/qtnfmac/core.h | 3 ++- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c index edebf23e8eae..0398bece5782 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c @@ -595,19 +595,13 @@ qtnf_del_station(struct wiphy *wiphy, struct net_device *dev, return ret; } -static void qtnf_scan_timeout(struct timer_list *t) -{ - struct qtnf_wmac *mac = from_timer(mac, t, scan_timeout); - - pr_warn("mac%d scan timed out\n", mac->macid); - qtnf_scan_done(mac, true); -} - static int qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) { struct qtnf_wmac *mac = wiphy_priv(wiphy); + cancel_delayed_work_sync(&mac->scan_timeout); + mac->scan_req = request; if (qtnf_cmd_send_scan(mac)) { @@ -616,9 +610,8 @@ qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) return -EFAULT; } - mac->scan_timeout.function = qtnf_scan_timeout; - mod_timer(&mac->scan_timeout, - jiffies + QTNF_SCAN_TIMEOUT_SEC * HZ); + queue_delayed_work(mac->bus->workqueue, &mac->scan_timeout, + QTNF_SCAN_TIMEOUT_SEC * HZ); return 0; } diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h index 66db26613b1f..b73425122a10 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h +++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h @@ -28,23 +28,4 @@ void qtnf_band_init_rates(struct ieee80211_supported_band *band); void qtnf_band_setup_htvht_caps(struct qtnf_mac_info *macinfo, struct ieee80211_supported_band *band); -static inline void qtnf_scan_done(struct qtnf_wmac *mac, bool aborted) -{ - struct cfg80211_scan_info info = { - .aborted = aborted, - }; - - if (timer_pending(&mac->scan_timeout)) - del_timer_sync(&mac->scan_timeout); - - mutex_lock(&mac->mac_lock); - - if (mac->scan_req) { - cfg80211_scan_done(mac->scan_req, &info); - mac->scan_req = NULL; - } - - mutex_unlock(&mac->mac_lock); -} - #endif /* _QTN_FMAC_CFG80211_H_ */ diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c index b1344d0731d7..cf26c15a84f8 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.c +++ b/drivers/net/wireless/quantenna/qtnfmac/core.c @@ -311,6 +311,37 @@ static void qtnf_mac_init_primary_intf(struct qtnf_wmac *mac) vif->cons_tx_timeout_cnt = 0; } +static void qtnf_mac_scan_finish(struct qtnf_wmac *mac, bool aborted) +{ + struct cfg80211_scan_info info = { + .aborted = aborted, + }; + + mutex_lock(&mac->mac_lock); + + if (mac->scan_req) { + cfg80211_scan_done(mac->scan_req, &info); + mac->scan_req = NULL; + } + + mutex_unlock(&mac->mac_lock); +} + +void qtnf_scan_done(struct qtnf_wmac *mac, bool aborted) +{ + cancel_delayed_work_sync(&mac->scan_timeout); + qtnf_mac_scan_finish(mac, aborted); +} + +static void qtnf_mac_scan_timeout(struct work_struct *work) +{ + struct qtnf_wmac *mac = + container_of(work, struct qtnf_wmac, scan_timeout.work); + + pr_warn("MAC%d: scan timed out\n", mac->macid); + qtnf_mac_scan_finish(mac, true); +} + static struct qtnf_wmac *qtnf_core_mac_alloc(struct qtnf_bus *bus, unsigned int macid) { @@ -334,7 +365,7 @@ static struct qtnf_wmac *qtnf_core_mac_alloc(struct qtnf_bus *bus, mac->iflist[i].vifid = i; qtnf_sta_list_init(&mac->iflist[i].sta_list); mutex_init(&mac->mac_lock); - timer_setup(&mac->scan_timeout, NULL, 0); + INIT_DELAYED_WORK(&mac->scan_timeout, qtnf_mac_scan_timeout); mac->iflist[i].stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); if (!mac->iflist[i].stats64) diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h b/drivers/net/wireless/quantenna/qtnfmac/core.h index 29f38bd3b491..3b884c80b6ab 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.h +++ b/drivers/net/wireless/quantenna/qtnfmac/core.h @@ -133,7 +133,7 @@ struct qtnf_wmac { struct qtnf_vif iflist[QTNF_MAX_INTF]; struct cfg80211_scan_request *scan_req; struct mutex mac_lock; /* lock during wmac speicific ops */ - struct timer_list scan_timeout; + struct delayed_work scan_timeout; }; struct qtnf_hw_info { @@ -168,6 +168,7 @@ void qtnf_update_tx_stats(struct net_device *ndev, const struct sk_buff *skb); void qtnf_virtual_intf_cleanup(struct net_device *ndev); void qtnf_netdev_updown(struct net_device *ndev, bool up); +void qtnf_scan_done(struct qtnf_wmac *mac, bool aborted); static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev) {