linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: linux-wireless@vger.kernel.org, Felix Fietkau <nbd@nbd.name>
Subject: Re: [RFC 3/3] mt76x02: remove bogus mutex usage
Date: Tue, 16 Apr 2019 11:29:36 +0200	[thread overview]
Message-ID: <20190416092935.GC11046@localhost.localdomain> (raw)
In-Reply-To: <20190416091305.4218-4-sgruszka@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4053 bytes --]

> mac .start(), .stop() callbacks are never called concurrently with other
> mac callbacks. The only concurencly is with mt76 works which we cancel
> on stop() and schedule on start().
> 
> This fixes possible deadlock on cancel_delayed_work_sync(&dev->mac_work)
> as mac_work also take mutex.
> 
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
>  .../net/wireless/mediatek/mt76/mt76x0/pci.c   |  6 -----
>  .../net/wireless/mediatek/mt76/mt76x0/usb.c   | 22 +++++--------------
>  .../wireless/mediatek/mt76/mt76x2/pci_main.c  |  5 -----
>  .../wireless/mediatek/mt76/mt76x2/usb_main.c  | 10 ++-------
>  4 files changed, 7 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
> index 156d3d064ba0..ac979128386a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
> @@ -25,8 +25,6 @@ static int mt76x0e_start(struct ieee80211_hw *hw)
>  {
>  	struct mt76x02_dev *dev = hw->priv;
>  
> -	mutex_lock(&dev->mt76.mutex);
> -
>  	mt76x02_mac_start(dev);
>  	mt76x0_phy_calibrate(dev, true);
>  	ieee80211_queue_delayed_work(dev->mt76.hw, &dev->mac_work,
> @@ -35,8 +33,6 @@ static int mt76x0e_start(struct ieee80211_hw *hw)
>  				     MT_CALIBRATE_INTERVAL);
>  	set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
>  
> -	mutex_unlock(&dev->mt76.mutex);
> -
>  	return 0;
>  }
>  
> @@ -62,10 +58,8 @@ static void mt76x0e_stop(struct ieee80211_hw *hw)
>  {
>  	struct mt76x02_dev *dev = hw->priv;
>  
> -	mutex_lock(&dev->mt76.mutex);
>  	clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
>  	mt76x0e_stop_hw(dev);
> -	mutex_unlock(&dev->mt76.mutex);
>  }
>  
>  static void

[..]

>  static const struct ieee80211_ops mt76x0u_ops = {
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c
> index 16dc8e2451b5..1b5caabebff5 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c
> @@ -22,8 +22,6 @@ mt76x2_start(struct ieee80211_hw *hw)
>  	struct mt76x02_dev *dev = hw->priv;
>  	int ret;
>  
> -	mutex_lock(&dev->mt76.mutex);
> -
>  	ret = mt76x2_mac_start(dev);
>  	if (ret)
>  		goto out;

You can remove goto here and just return ret (same below)

> @@ -40,7 +38,6 @@ mt76x2_start(struct ieee80211_hw *hw)
>  	set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
>  
>  out:
> -	mutex_unlock(&dev->mt76.mutex);
>  	return ret;
>  }
>  
> @@ -49,10 +46,8 @@ mt76x2_stop(struct ieee80211_hw *hw)
>  {
>  	struct mt76x02_dev *dev = hw->priv;
>  
> -	mutex_lock(&dev->mt76.mutex);
>  	clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
>  	mt76x2_stop_hardware(dev);
> -	mutex_unlock(&dev->mt76.mutex);
>  }
>  
>  static int
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
> index 0771de210c6a..32726b4906ea 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
> @@ -21,30 +21,24 @@ static int mt76x2u_start(struct ieee80211_hw *hw)
>  	struct mt76x02_dev *dev = hw->priv;
>  	int ret;
>  
> -	mutex_lock(&dev->mt76.mutex);
> -
>  	ret = mt76x2u_mac_start(dev);
>  	if (ret)
> -		goto out;
> +		return ret;
>  
>  	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work,
>  				     MT_MAC_WORK_INTERVAL);
>  	set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
>  
> -out:
> -	mutex_unlock(&dev->mt76.mutex);
> -	return ret;
> +	return 0;
>  }
>  
>  static void mt76x2u_stop(struct ieee80211_hw *hw)
>  {
>  	struct mt76x02_dev *dev = hw->priv;
>  
> -	mutex_lock(&dev->mt76.mutex);
>  	clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
>  	mt76u_stop_tx(&dev->mt76);
>  	mt76x2u_stop_hw(dev);
> -	mutex_unlock(&dev->mt76.mutex);
>  }
>  
>  static int
> -- 
> 2.20.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2019-04-16  9:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16  9:13 [RFC 0/3] mt76: suspend/stop/removal fixes Stanislaw Gruszka
2019-04-16  9:13 ` [RFC 1/3] mt76x02u: remove bogus stop on suspend Stanislaw Gruszka
2019-04-16  9:13 ` [RFC 2/3] mt76usb: fix tx/rx stop Stanislaw Gruszka
2019-04-23  7:59   ` Stanislaw Gruszka
2019-04-16  9:13 ` [RFC 3/3] mt76x02: remove bogus mutex usage Stanislaw Gruszka
2019-04-16  9:29   ` Lorenzo Bianconi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190416092935.GC11046@localhost.localdomain \
    --to=lorenzo.bianconi@redhat.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    --cc=sgruszka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).