diff mbox series

[v3,02/12] wcn36xx: Run suspend for the first ieee80211_vif

Message ID 20210319161520.3590510-3-bryan.odonoghue@linaro.org
State New
Headers show
Series wcn36xx: Enable downstream consistent Wake on Lan | expand

Commit Message

Bryan O'Donoghue March 19, 2021, 4:15 p.m. UTC
A subsequent set of patches will extend out suspend/resume support in this
driver, we cannot set the firmware up for multiple ipv4/ipv6 addresses and
as such we can't iterate through a list of ieee80211_vif.

Constrain the interaction with the firmware to the first ieee80211_vif on
the suspend/resume/wowlan path.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

---
 drivers/net/wireless/ath/wcn36xx/main.c | 43 +++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 3 deletions(-)

-- 
2.30.1


_______________________________________________
wcn36xx mailing list
wcn36xx@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/wcn36xx

Comments

Loic Poulain March 19, 2021, 4:57 p.m. UTC | #1
On Fri, 19 Mar 2021 at 17:13, Bryan O'Donoghue
<bryan.odonoghue@linaro.org> wrote:
>

> A subsequent set of patches will extend out suspend/resume support in this

> driver, we cannot set the firmware up for multiple ipv4/ipv6 addresses and

> as such we can't iterate through a list of ieee80211_vif.


You mean connection can only be maintained (offloaded) in suspend for
only one vif? If so maybe what you want to retrieve is the first
client-associated vif and not the first vif.

>

> Constrain the interaction with the firmware to the first ieee80211_vif on

> the suspend/resume/wowlan path.

>

> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

> ---

>  drivers/net/wireless/ath/wcn36xx/main.c | 43 +++++++++++++++++++++++--

>  1 file changed, 40 insertions(+), 3 deletions(-)

>

> diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c

> index b361e40697a6..c0c1ea18864f 100644

> --- a/drivers/net/wireless/ath/wcn36xx/main.c

> +++ b/drivers/net/wireless/ath/wcn36xx/main.c

> @@ -1088,15 +1088,39 @@ static int wcn36xx_sta_remove(struct ieee80211_hw *hw,

>

>  #ifdef CONFIG_PM

>

> +struct ieee80211_vif *wcn36xx_get_first_vif(struct wcn36xx *wcn)

> +{

> +       struct wcn36xx_vif *tmp;

> +       struct ieee80211_vif *vif = NULL;

> +

> +       list_for_each_entry(tmp, &wcn->vif_list, list) {

> +               vif = wcn36xx_priv_to_vif(tmp);

> +               if (vif)

> +                       break;

> +       }

> +       return vif;

> +}

> +

>  static int wcn36xx_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow)

>  {

>         struct wcn36xx *wcn = hw->priv;

> -       int ret;

> +       struct ieee80211_vif *vif = NULL;

> +       struct wcn36xx_vif *vif_priv = NULL;

> +       int ret = 0;

>

>         wcn36xx_dbg(WCN36XX_DBG_MAC, "mac suspend\n");

>

>         flush_workqueue(wcn->hal_ind_wq);

> -       ret = wcn36xx_smd_set_power_params(wcn, true);

> +       mutex_lock(&wcn->conf_mutex);

> +       vif = wcn36xx_get_first_vif(wcn);

> +       if (vif) {

> +               vif_priv = wcn36xx_vif_to_priv(vif);

> +               if (!vif_priv->sta_assoc)

> +                       goto out;

> +               ret = wcn36xx_smd_set_power_params(wcn, true);

> +       }

> +out:

> +       mutex_unlock(&wcn->conf_mutex);

>

>         return ret;

>  }

> @@ -1104,11 +1128,24 @@ static int wcn36xx_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow)

>  static int wcn36xx_resume(struct ieee80211_hw *hw)

>  {

>         struct wcn36xx *wcn = hw->priv;

> +       struct ieee80211_vif *vif = NULL;

> +       struct wcn36xx_vif *vif_priv = NULL;

>

>         wcn36xx_dbg(WCN36XX_DBG_MAC, "mac resume\n");

>

>         flush_workqueue(wcn->hal_ind_wq);

> -       wcn36xx_smd_set_power_params(wcn, false);

> +       mutex_lock(&wcn->conf_mutex);

> +       vif = wcn36xx_get_first_vif(wcn);

> +       if (vif) {

> +               vif_priv = wcn36xx_vif_to_priv(vif);

> +               if (!vif_priv->sta_assoc)

> +                       goto out;

> +

> +               wcn36xx_smd_set_power_params(wcn, false);

> +       }

> +out:

> +       mutex_unlock(&wcn->conf_mutex);

> +

>         return 0;

>  }

>

> --

> 2.30.1

>


_______________________________________________
wcn36xx mailing list
wcn36xx@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/wcn36xx
Bryan O'Donoghue March 20, 2021, 12:40 p.m. UTC | #2
On 19/03/2021 16:57, Loic Poulain wrote:
> You mean connection can only be maintained (offloaded) in suspend for

> only one vif? 


Just the one ip.

If so maybe what you want to retrieve is the first
> client-associated vif and not the first vif.


Hmm, yeah OK I can see how it might be the case you need to do that.

---
bod


_______________________________________________
wcn36xx mailing list
wcn36xx@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/wcn36xx
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index b361e40697a6..c0c1ea18864f 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -1088,15 +1088,39 @@  static int wcn36xx_sta_remove(struct ieee80211_hw *hw,
 
 #ifdef CONFIG_PM
 
+struct ieee80211_vif *wcn36xx_get_first_vif(struct wcn36xx *wcn)
+{
+	struct wcn36xx_vif *tmp;
+	struct ieee80211_vif *vif = NULL;
+
+	list_for_each_entry(tmp, &wcn->vif_list, list) {
+		vif = wcn36xx_priv_to_vif(tmp);
+		if (vif)
+			break;
+	}
+	return vif;
+}
+
 static int wcn36xx_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow)
 {
 	struct wcn36xx *wcn = hw->priv;
-	int ret;
+	struct ieee80211_vif *vif = NULL;
+	struct wcn36xx_vif *vif_priv = NULL;
+	int ret = 0;
 
 	wcn36xx_dbg(WCN36XX_DBG_MAC, "mac suspend\n");
 
 	flush_workqueue(wcn->hal_ind_wq);
-	ret = wcn36xx_smd_set_power_params(wcn, true);
+	mutex_lock(&wcn->conf_mutex);
+	vif = wcn36xx_get_first_vif(wcn);
+	if (vif) {
+		vif_priv = wcn36xx_vif_to_priv(vif);
+		if (!vif_priv->sta_assoc)
+			goto out;
+		ret = wcn36xx_smd_set_power_params(wcn, true);
+	}
+out:
+	mutex_unlock(&wcn->conf_mutex);
 
 	return ret;
 }
@@ -1104,11 +1128,24 @@  static int wcn36xx_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow)
 static int wcn36xx_resume(struct ieee80211_hw *hw)
 {
 	struct wcn36xx *wcn = hw->priv;
+	struct ieee80211_vif *vif = NULL;
+	struct wcn36xx_vif *vif_priv = NULL;
 
 	wcn36xx_dbg(WCN36XX_DBG_MAC, "mac resume\n");
 
 	flush_workqueue(wcn->hal_ind_wq);
-	wcn36xx_smd_set_power_params(wcn, false);
+	mutex_lock(&wcn->conf_mutex);
+	vif = wcn36xx_get_first_vif(wcn);
+	if (vif) {
+		vif_priv = wcn36xx_vif_to_priv(vif);
+		if (!vif_priv->sta_assoc)
+			goto out;
+
+		wcn36xx_smd_set_power_params(wcn, false);
+	}
+out:
+	mutex_unlock(&wcn->conf_mutex);
+
 	return 0;
 }