Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp20860304ybl; Sun, 5 Jan 2020 13:18:44 -0800 (PST) X-Google-Smtp-Source: APXvYqyaxe0Wlv4H/Ziq78KaectqDgRImZ2U+5mlXE3Hyzi28ah9Dn0ZVqLfQT5EYmm1+5PbY9Ok X-Received: by 2002:a05:6830:1bda:: with SMTP id v26mr107914018ota.314.1578259124040; Sun, 05 Jan 2020 13:18:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578259124; cv=none; d=google.com; s=arc-20160816; b=GBjOsO64LcarNKNvbve0ATsrzMpVGOZpUEOe+IIxrq4K1LYa/IqWL0POua4T6HMRb7 WscJdH63Bdir/l1clGlgL9No4fymOj662UxbZUT5yUOzEXOjKYJp3sUyplW3jh2vap8+ Eq87VnX9nbffiTjlVapUDt3pjc0cYDXt1RE7DBmXGF7yI7X7B5/pA6GhNu9BvZM0MW0t LSqzrTS9TScdqD3So7JcCOjOEvV9Ll6dmaMegv4wPrnu5AvgPuY9jUNLuDAb5mqdQRSU EXDUTZd8Ru45jH1ME91f5tr9yrIN8Cy7Ko7wOphQ+LalSuFyenj++aVsd26ID7tk0alz cciw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=P4K2qz4GjXFufFOWdVp4ejUic2U5V/4ZJFiquii3QhM=; b=v5rZS9IzvkdFIo56OIp9wvbfjVENOSgzDWxxZDWnABvAZQVUz3IVqe79peMGToqeRg uDmsYaDXFRgt0wgtGMUh+y3PtOQPHlZLFtkFvCg/5CzA3lzOhZnINtiF4qnjwp5J9ZJb ECKmbPlrpA0zuBcFPDq2gBuI/zPkC6DpQlDIIxhDcIn6scnVSVdv/5ON65e5ldWyw48U AWEiiycfgzH+y7K0zHlCZ/DmXkuFEyx7+c0nuDmTvnh8W9r+YSa6VmQiuiDC2QnahO1F hxPZtB218UFzkss4MmSew5/28BbrugxXyczv0eTls4A+E2YWRfg7ujWUNuoct4tNdlVl W89g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w23si30623773otp.109.2020.01.05.13.18.18; Sun, 05 Jan 2020 13:18:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727067AbgAEVRF (ORCPT + 99 others); Sun, 5 Jan 2020 16:17:05 -0500 Received: from mx2.suse.de ([195.135.220.15]:50038 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726792AbgAEVRE (ORCPT ); Sun, 5 Jan 2020 16:17:04 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 448BAAEF8; Sun, 5 Jan 2020 21:17:02 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id E160FE048B; Sun, 5 Jan 2020 22:17:01 +0100 (CET) Message-Id: In-Reply-To: References: From: Michal Kubecek Subject: [PATCH net-next 1/3] wil6210: get rid of begin() and complete() ethtool_ops To: "David S. Miller" , netdev@vger.kernel.org Cc: Maya Erez , Kalle Valo , linux-wireless@vger.kernel.org, wil6210@qti.qualcomm.com, Francois Romieu , linux-kernel@vger.kernel.org, Andrew Lunn , Florian Fainelli Date: Sun, 5 Jan 2020 22:17:01 +0100 (CET) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The wil6210 driver locks a mutex in begin() ethtool_ops callback and unlocks it in complete() so that all ethtool requests are serialized. This is not going to work correctly with netlink interface; e.g. when ioctl triggers a netlink notification, netlink code would call begin() again while the mutex taken by ioctl code is still held by the same task. Let's get rid of the begin() and complete() callbacks and move the mutex locking into the remaining ethtool_ops handlers except get_drvinfo which only copies strings that are not changing so that there is no need for serialization. Signed-off-by: Michal Kubecek --- drivers/net/wireless/ath/wil6210/ethtool.c | 43 ++++++++-------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/net/wireless/ath/wil6210/ethtool.c b/drivers/net/wireless/ath/wil6210/ethtool.c index 912c4eaf017b..fef10886ca4a 100644 --- a/drivers/net/wireless/ath/wil6210/ethtool.c +++ b/drivers/net/wireless/ath/wil6210/ethtool.c @@ -11,26 +11,6 @@ #include "wil6210.h" -static int wil_ethtoolops_begin(struct net_device *ndev) -{ - struct wil6210_priv *wil = ndev_to_wil(ndev); - - mutex_lock(&wil->mutex); - - wil_dbg_misc(wil, "ethtoolops_begin\n"); - - return 0; -} - -static void wil_ethtoolops_complete(struct net_device *ndev) -{ - struct wil6210_priv *wil = ndev_to_wil(ndev); - - wil_dbg_misc(wil, "ethtoolops_complete\n"); - - mutex_unlock(&wil->mutex); -} - static int wil_ethtoolops_get_coalesce(struct net_device *ndev, struct ethtool_coalesce *cp) { @@ -39,11 +19,12 @@ static int wil_ethtoolops_get_coalesce(struct net_device *ndev, u32 rx_itr_en, rx_itr_val = 0; int ret; + mutex_lock(&wil->mutex); wil_dbg_misc(wil, "ethtoolops_get_coalesce\n"); ret = wil_pm_runtime_get(wil); if (ret < 0) - return ret; + goto out; tx_itr_en = wil_r(wil, RGF_DMA_ITR_TX_CNT_CTL); if (tx_itr_en & BIT_DMA_ITR_TX_CNT_CTL_EN) @@ -57,7 +38,11 @@ static int wil_ethtoolops_get_coalesce(struct net_device *ndev, cp->tx_coalesce_usecs = tx_itr_val; cp->rx_coalesce_usecs = rx_itr_val; - return 0; + ret = 0; + +out: + mutex_unlock(&wil->mutex); + return ret; } static int wil_ethtoolops_set_coalesce(struct net_device *ndev, @@ -67,12 +52,14 @@ static int wil_ethtoolops_set_coalesce(struct net_device *ndev, struct wireless_dev *wdev = ndev->ieee80211_ptr; int ret; + mutex_lock(&wil->mutex); wil_dbg_misc(wil, "ethtoolops_set_coalesce: rx %d usec, tx %d usec\n", cp->rx_coalesce_usecs, cp->tx_coalesce_usecs); if (wdev->iftype == NL80211_IFTYPE_MONITOR) { wil_dbg_misc(wil, "No IRQ coalescing in monitor mode\n"); - return -EINVAL; + ret = -EINVAL; + goto out; } /* only @rx_coalesce_usecs and @tx_coalesce_usecs supported, @@ -88,24 +75,26 @@ static int wil_ethtoolops_set_coalesce(struct net_device *ndev, ret = wil_pm_runtime_get(wil); if (ret < 0) - return ret; + goto out; wil->txrx_ops.configure_interrupt_moderation(wil); wil_pm_runtime_put(wil); + ret = 0; - return 0; +out: + mutex_unlock(&wil->mutex); + return ret; out_bad: wil_dbg_misc(wil, "Unsupported coalescing params. Raw command:\n"); print_hex_dump_debug("DBG[MISC] coal ", DUMP_PREFIX_OFFSET, 16, 4, cp, sizeof(*cp), false); + mutex_unlock(&wil->mutex); return -EINVAL; } static const struct ethtool_ops wil_ethtool_ops = { - .begin = wil_ethtoolops_begin, - .complete = wil_ethtoolops_complete, .get_drvinfo = cfg80211_get_drvinfo, .get_coalesce = wil_ethtoolops_get_coalesce, .set_coalesce = wil_ethtoolops_set_coalesce, -- 2.24.1