wil6210: run-time PM when interface down
Allow run-time suspend when interface is down, keep card alive when interface is up. If driver is in wmi only or debug_fw mode run-time PM won't suspend. Signed-off-by: Lazar Alexei <qca_ailizaro@qca.qualcomm.com> Signed-off-by: Maya Erez <qca_merez@qca.qualcomm.com> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
This commit is contained in:

zatwierdzone przez
Kalle Valo

rodzic
8ed05ed06f
commit
94162666cd
@@ -16,15 +16,30 @@
|
||||
|
||||
#include "wil6210.h"
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
|
||||
#define WIL6210_AUTOSUSPEND_DELAY_MS (1000)
|
||||
|
||||
int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime)
|
||||
{
|
||||
int rc = 0;
|
||||
struct wireless_dev *wdev = wil->wdev;
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
bool wmi_only = test_bit(WMI_FW_CAPABILITY_WMI_ONLY,
|
||||
wil->fw_capabilities);
|
||||
|
||||
wil_dbg_pm(wil, "can_suspend: %s\n", is_runtime ? "runtime" : "system");
|
||||
|
||||
if (wmi_only || debug_fw) {
|
||||
wil_dbg_pm(wil, "Deny any suspend - %s mode\n",
|
||||
wmi_only ? "wmi_only" : "debug_fw");
|
||||
rc = -EBUSY;
|
||||
goto out;
|
||||
}
|
||||
if (is_runtime && !wil->platform_ops.suspend) {
|
||||
rc = -EBUSY;
|
||||
goto out;
|
||||
}
|
||||
if (!(ndev->flags & IFF_UP)) {
|
||||
/* can always sleep when down */
|
||||
wil_dbg_pm(wil, "Interface is down\n");
|
||||
@@ -44,6 +59,10 @@ int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime)
|
||||
/* interface is running */
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_MONITOR:
|
||||
wil_dbg_pm(wil, "Sniffer\n");
|
||||
rc = -EBUSY;
|
||||
goto out;
|
||||
/* for STA-like interface, don't runtime suspend */
|
||||
case NL80211_IFTYPE_STATION:
|
||||
case NL80211_IFTYPE_P2P_CLIENT:
|
||||
if (test_bit(wil_status_fwconnecting, wil->status)) {
|
||||
@@ -51,6 +70,12 @@ int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime)
|
||||
rc = -EBUSY;
|
||||
goto out;
|
||||
}
|
||||
/* Runtime pm not supported in case the interface is up */
|
||||
if (is_runtime) {
|
||||
wil_dbg_pm(wil, "STA-like interface\n");
|
||||
rc = -EBUSY;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
/* AP-like interface - can't suspend */
|
||||
default:
|
||||
@@ -348,3 +373,44 @@ out:
|
||||
is_runtime ? "runtime" : "system", rc, suspend_time_usec);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void wil_pm_runtime_allow(struct wil6210_priv *wil)
|
||||
{
|
||||
struct device *dev = wil_to_dev(wil);
|
||||
|
||||
pm_runtime_put_noidle(dev);
|
||||
pm_runtime_set_autosuspend_delay(dev, WIL6210_AUTOSUSPEND_DELAY_MS);
|
||||
pm_runtime_use_autosuspend(dev);
|
||||
pm_runtime_allow(dev);
|
||||
}
|
||||
|
||||
void wil_pm_runtime_forbid(struct wil6210_priv *wil)
|
||||
{
|
||||
struct device *dev = wil_to_dev(wil);
|
||||
|
||||
pm_runtime_forbid(dev);
|
||||
pm_runtime_get_noresume(dev);
|
||||
}
|
||||
|
||||
int wil_pm_runtime_get(struct wil6210_priv *wil)
|
||||
{
|
||||
int rc;
|
||||
struct device *dev = wil_to_dev(wil);
|
||||
|
||||
rc = pm_runtime_get_sync(dev);
|
||||
if (rc < 0) {
|
||||
wil_err(wil, "pm_runtime_get_sync() failed, rc = %d\n", rc);
|
||||
pm_runtime_put_noidle(dev);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wil_pm_runtime_put(struct wil6210_priv *wil)
|
||||
{
|
||||
struct device *dev = wil_to_dev(wil);
|
||||
|
||||
pm_runtime_mark_last_busy(dev);
|
||||
pm_runtime_put_autosuspend(dev);
|
||||
}
|
||||
|
Reference in New Issue
Block a user