linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleksij Rempel <linux@rempel-privat.de>
To: Stanislaw Gruszka <sgruszka@redhat.com>, ath9k-devel@venema.h4ckr.net
Cc: linux-wireless@vger.kernel.org
Subject: Re: [RFC/RFT] ath9k_htc: avoid scheduling while atomic on sta_rc_update
Date: Fri, 31 Jan 2014 19:24:05 +0100	[thread overview]
Message-ID: <52EBEA45.5090606@rempel-privat.de> (raw)
In-Reply-To: <20140131133707.GA7648@redhat.com>

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

I have different HW. How can trigger sta_rc_update?


Am 31.01.2014 14:37, schrieb Stanislaw Gruszka:
> mac80211 ->sta_rc_update() callback must be atomic. Since we have to
> take mutex and do other operations that can sleep when sending fimrware
> commands to device, the only option to satisfy atomicity requirement of
> ->sta_rc_update(), that I can see, is introduce work_struct and defer
> uploading new rates to that work.
> 
> I don't have h/w to test this patch. Since sta_rc_update() calls are
> very unlikely, those who would like to test that patch should remove
> my previous patch "ath9k_htc: make ->sta_rc_update atomic for most
> calls" and possibly even modify mac80211 to call sta_rc_update(),
> without actual reason, just to test changed ath9k_htc code.
> 
> Thanks
> Stanislaw
> ---
>  drivers/net/wireless/ath/ath9k/htc.h          |  2 +
>  drivers/net/wireless/ath/ath9k/htc_drv_main.c | 60 +++++++++++++++++----------
>  2 files changed, 40 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
> index 58da346..99a2031 100644
> --- a/drivers/net/wireless/ath/ath9k/htc.h
> +++ b/drivers/net/wireless/ath/ath9k/htc.h
> @@ -262,6 +262,8 @@ enum tid_aggr_state {
>  struct ath9k_htc_sta {
>  	u8 index;
>  	enum tid_aggr_state tid_state[ATH9K_HTC_MAX_TID];
> +	struct work_struct rc_update_work;
> +	struct ath9k_htc_priv *htc_priv;
>  };
>  
>  #define ATH9K_HTC_RXBUF 256
> diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> index a57af9b..c9254a6 100644
> --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> @@ -1270,18 +1270,50 @@ static void ath9k_htc_configure_filter(struct ieee80211_hw *hw,
>  	mutex_unlock(&priv->mutex);
>  }
>  
> +static void ath9k_htc_sta_rc_update_work(struct work_struct *work)
> +{
> +	struct ath9k_htc_sta *ista =
> +	    container_of(work, struct ath9k_htc_sta, rc_update_work);
> +	struct ieee80211_sta *sta =
> +	    container_of((void *)ista, struct ieee80211_sta, drv_priv);
> +	struct ath9k_htc_priv *priv = ista->htc_priv;
> +	struct ath_common *common = ath9k_hw_common(priv->ah);
> +	struct ath9k_htc_target_rate trate;
> +
> +	mutex_lock(&priv->mutex);
> +	ath9k_htc_ps_wakeup(priv);
> +
> +	memset(&trate, 0, sizeof(struct ath9k_htc_target_rate));
> +	ath9k_htc_setup_rate(priv, sta, &trate);
> +	if (!ath9k_htc_send_rate_cmd(priv, &trate))
> +		ath_dbg(common, CONFIG,
> +			"Supported rates for sta: %pM updated, rate caps: 0x%X\n",
> +			sta->addr, be32_to_cpu(trate.capflags));
> +	else
> +		ath_dbg(common, CONFIG,
> +			"Unable to update supported rates for sta: %pM\n",
> +			sta->addr);
> +
> +	ath9k_htc_ps_restore(priv);
> +	mutex_unlock(&priv->mutex);
> +}
> +
>  static int ath9k_htc_sta_add(struct ieee80211_hw *hw,
>  			     struct ieee80211_vif *vif,
>  			     struct ieee80211_sta *sta)
>  {
>  	struct ath9k_htc_priv *priv = hw->priv;
> +	struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
>  	int ret;
>  
>  	mutex_lock(&priv->mutex);
>  	ath9k_htc_ps_wakeup(priv);
>  	ret = ath9k_htc_add_station(priv, vif, sta);
> -	if (!ret)
> +	if (!ret) {
> +		INIT_WORK(&ista->rc_update_work, ath9k_htc_sta_rc_update_work);
> +		ista->htc_priv = priv;
>  		ath9k_htc_init_rate(priv, sta);
> +	}
>  	ath9k_htc_ps_restore(priv);
>  	mutex_unlock(&priv->mutex);
>  
> @@ -1293,12 +1325,13 @@ static int ath9k_htc_sta_remove(struct ieee80211_hw *hw,
>  				struct ieee80211_sta *sta)
>  {
>  	struct ath9k_htc_priv *priv = hw->priv;
> -	struct ath9k_htc_sta *ista;
> +	struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
>  	int ret;
>  
> +	cancel_work_sync(&ista->rc_update_work);
> +
>  	mutex_lock(&priv->mutex);
>  	ath9k_htc_ps_wakeup(priv);
> -	ista = (struct ath9k_htc_sta *) sta->drv_priv;
>  	htc_sta_drain(priv->htc, ista->index);
>  	ret = ath9k_htc_remove_station(priv, vif, sta);
>  	ath9k_htc_ps_restore(priv);
> @@ -1311,29 +1344,12 @@ static void ath9k_htc_sta_rc_update(struct ieee80211_hw *hw,
>  				    struct ieee80211_vif *vif,
>  				    struct ieee80211_sta *sta, u32 changed)
>  {
> -	struct ath9k_htc_priv *priv = hw->priv;
> -	struct ath_common *common = ath9k_hw_common(priv->ah);
> -	struct ath9k_htc_target_rate trate;
> +	struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
>  
>  	if (!(changed & IEEE80211_RC_SUPP_RATES_CHANGED))
>  		return;
>  
> -	mutex_lock(&priv->mutex);
> -	ath9k_htc_ps_wakeup(priv);
> -
> -	memset(&trate, 0, sizeof(struct ath9k_htc_target_rate));
> -	ath9k_htc_setup_rate(priv, sta, &trate);
> -	if (!ath9k_htc_send_rate_cmd(priv, &trate))
> -		ath_dbg(common, CONFIG,
> -			"Supported rates for sta: %pM updated, rate caps: 0x%X\n",
> -			sta->addr, be32_to_cpu(trate.capflags));
> -	else
> -		ath_dbg(common, CONFIG,
> -			"Unable to update supported rates for sta: %pM\n",
> -			sta->addr);
> -
> -	ath9k_htc_ps_restore(priv);
> -	mutex_unlock(&priv->mutex);
> +	schedule_work(&ista->rc_update_work);
>  }
>  
>  static int ath9k_htc_conf_tx(struct ieee80211_hw *hw,
> 


-- 
Regards,
Oleksij


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 278 bytes --]

  reply	other threads:[~2014-01-31 18:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-31 13:37 [RFC/RFT] ath9k_htc: avoid scheduling while atomic on sta_rc_update Stanislaw Gruszka
2014-01-31 18:24 ` Oleksij Rempel [this message]
2014-01-31 19:38   ` Stanislaw Gruszka
2014-02-02  9:02     ` Oleksij Rempel
2014-02-03 10:39       ` Stanislaw Gruszka

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=52EBEA45.5090606@rempel-privat.de \
    --to=linux@rempel-privat.de \
    --cc=ath9k-devel@venema.h4ckr.net \
    --cc=linux-wireless@vger.kernel.org \
    --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).