Re: [PATCH 04/31] iwlwifi: pcie: add initial RTPM support for PCI

2016-02-01 Thread Grumbach, Emmanuel


On 02/01/2016 04:32 PM, Kalle Valo wrote:
> Emmanuel Grumbach  writes:
>
>> From: Luca Coelho 
>>
>> Add an initial implementation of runtime power management (RTPM) for
>> PCI devices.  With this patch, RTPM is only used when wifi is off
>> (i.e. the wifi interface is down).  This implementation is behind a
>> new Kconfig flag, IWLWIFI_PCIE_RTPM.
>>
>> Signed-off-by: Luca Coelho 
>> Signed-off-by: Emmanuel Grumbach 
> [...]
>
>> --- a/drivers/net/wireless/intel/iwlwifi/Kconfig
>> +++ b/drivers/net/wireless/intel/iwlwifi/Kconfig
>> @@ -99,6 +99,18 @@ config IWLWIFI_UAPSD
>>  
>>If unsure, say N.
>>  
>> +config IWLWIFI_PCIE_RTPM
>> +   bool "Enable runtime power management mode for PCIe devices"
>> +   depends on IWLMVM && IWLWIFI_PCIE && PM
>> +   default false
>> +   help
>> + Say Y here to enable runtime power management for PCIe
>> + devices.  If enabled, the device will go into low power mode
>> + when idle for a short period of time, allowing for improved
>> + power saving during runtime.
>> +
>> + If unsure, say N.
> I didn't see the new option in menuconfig and then noticed that I can't
> find IWLWIFI_PCIE anywhere. Is that correct?
>

Right... This option is not upstreamed yet...
I'll respin. Sorry...
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/31] iwlwifi: pcie: add initial RTPM support for PCI

2016-02-01 Thread Kalle Valo
Emmanuel Grumbach  writes:

> From: Luca Coelho 
>
> Add an initial implementation of runtime power management (RTPM) for
> PCI devices.  With this patch, RTPM is only used when wifi is off
> (i.e. the wifi interface is down).  This implementation is behind a
> new Kconfig flag, IWLWIFI_PCIE_RTPM.
>
> Signed-off-by: Luca Coelho 
> Signed-off-by: Emmanuel Grumbach 

[...]

> --- a/drivers/net/wireless/intel/iwlwifi/Kconfig
> +++ b/drivers/net/wireless/intel/iwlwifi/Kconfig
> @@ -99,6 +99,18 @@ config IWLWIFI_UAPSD
>  
> If unsure, say N.
>  
> +config IWLWIFI_PCIE_RTPM
> +   bool "Enable runtime power management mode for PCIe devices"
> +   depends on IWLMVM && IWLWIFI_PCIE && PM
> +   default false
> +   help
> + Say Y here to enable runtime power management for PCIe
> + devices.  If enabled, the device will go into low power mode
> + when idle for a short period of time, allowing for improved
> + power saving during runtime.
> +
> +  If unsure, say N.

I didn't see the new option in menuconfig and then noticed that I can't
find IWLWIFI_PCIE anywhere. Is that correct?

-- 
Kalle Valo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/31] iwlwifi: pcie: add initial RTPM support for PCI

2016-02-01 Thread Grumbach, Emmanuel


On 02/01/2016 04:38 PM, Grumbach, Emmanuel wrote:
>
> On 02/01/2016 04:32 PM, Kalle Valo wrote:
>> Emmanuel Grumbach  writes:
>>
>>> From: Luca Coelho 
>>>
>>> Add an initial implementation of runtime power management (RTPM) for
>>> PCI devices.  With this patch, RTPM is only used when wifi is off
>>> (i.e. the wifi interface is down).  This implementation is behind a
>>> new Kconfig flag, IWLWIFI_PCIE_RTPM.
>>>
>>> Signed-off-by: Luca Coelho 
>>> Signed-off-by: Emmanuel Grumbach 
>> [...]
>>
>>> --- a/drivers/net/wireless/intel/iwlwifi/Kconfig
>>> +++ b/drivers/net/wireless/intel/iwlwifi/Kconfig
>>> @@ -99,6 +99,18 @@ config IWLWIFI_UAPSD
>>>  
>>>   If unsure, say N.
>>>  
>>> +config IWLWIFI_PCIE_RTPM
>>> +   bool "Enable runtime power management mode for PCIe devices"
>>> +   depends on IWLMVM && IWLWIFI_PCIE && PM
>>> +   default false
>>> +   help
>>> + Say Y here to enable runtime power management for PCIe
>>> + devices.  If enabled, the device will go into low power mode
>>> + when idle for a short period of time, allowing for improved
>>> + power saving during runtime.
>>> +
>>> +If unsure, say N.
>> I didn't see the new option in menuconfig and then noticed that I can't
>> find IWLWIFI_PCIE anywhere. Is that correct?
>>
> Right... This option is not upstreamed yet...
> I'll respin. Sorry...
>

Next tag: iwlwifi-next-for-kalle-2016-01-31_2

$ git diff
iwlwifi-next-for-kalle-2016-01-31..iwlwifi-next-for-kalle-2016-01-31_2
diff --git a/drivers/net/wireless/intel/iwlwifi/Kconfig
b/drivers/net/wireless/intel/iwlwifi/Kconfig
index acaaf69..11932d5 100644
--- a/drivers/net/wireless/intel/iwlwifi/Kconfig
+++ b/drivers/net/wireless/intel/iwlwifi/Kconfig
@@ -101,7 +101,7 @@ config IWLWIFI_UAPSD
 
 config IWLWIFI_PCIE_RTPM
bool "Enable runtime power management mode for PCIe devices"
-   depends on IWLMVM && IWLWIFI_PCIE && PM
+   depends on IWLMVM && PM
default false
help
  Say Y here to enable runtime power management for PCIe

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/31] iwlwifi: pcie: add initial RTPM support for PCI

2016-01-31 Thread Emmanuel Grumbach
From: Luca Coelho 

Add an initial implementation of runtime power management (RTPM) for
PCI devices.  With this patch, RTPM is only used when wifi is off
(i.e. the wifi interface is down).  This implementation is behind a
new Kconfig flag, IWLWIFI_PCIE_RTPM.

Signed-off-by: Luca Coelho 
Signed-off-by: Emmanuel Grumbach 
---
 drivers/net/wireless/intel/iwlwifi/Kconfig  | 12 +
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c   | 60 +++--
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 27 +++
 3 files changed, 96 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/Kconfig 
b/drivers/net/wireless/intel/iwlwifi/Kconfig
index 8660677..acaaf69 100644
--- a/drivers/net/wireless/intel/iwlwifi/Kconfig
+++ b/drivers/net/wireless/intel/iwlwifi/Kconfig
@@ -99,6 +99,18 @@ config IWLWIFI_UAPSD
 
  If unsure, say N.
 
+config IWLWIFI_PCIE_RTPM
+   bool "Enable runtime power management mode for PCIe devices"
+   depends on IWLMVM && IWLWIFI_PCIE && PM
+   default false
+   help
+ Say Y here to enable runtime power management for PCIe
+ devices.  If enabled, the device will go into low power mode
+ when idle for a short period of time, allowing for improved
+ power saving during runtime.
+
+If unsure, say N.
+
 menu "Debugging Options"
 
 config IWLWIFI_DEBUG
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 6261a68..676d239 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -7,6 +7,7 @@
  *
  * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2016 Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -66,6 +67,9 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include 
+#ifdef CONFIG_IWLWIFI_PCIE_RTPM
+#include 
+#endif /* CONFIG_IWLWIFI_PCIE_RTPM */
 #include 
 #include 
 #include 
@@ -623,6 +627,13 @@ static int iwl_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (ret)
goto out_free_drv;
 
+#ifdef CONFIG_IWLWIFI_PCIE_RTPM
+   pm_runtime_set_active(>dev);
+   pm_runtime_set_autosuspend_delay(>dev,
+iwlwifi_mod_params.d0i3_entry_delay);
+   pm_runtime_use_autosuspend(>dev);
+   pm_runtime_allow(>dev);
+#endif
return 0;
 
 out_free_drv:
@@ -689,15 +700,58 @@ static int iwl_pci_resume(struct device *device)
return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume);
+#ifdef CONFIG_IWLWIFI_PCIE_RTPM
+static int iwl_pci_runtime_suspend(struct device *device)
+{
+   struct pci_dev *pdev = to_pci_dev(device);
+   struct iwl_trans *trans = pci_get_drvdata(pdev);
+
+   IWL_DEBUG_RPM(trans, "entering runtime suspend\n");
+
+   /* For now we only allow D0I3 if the device is off */
+   if (test_bit(STATUS_DEVICE_ENABLED, >status))
+   return -EBUSY;
+
+   trans->system_pm_mode = IWL_PLAT_PM_MODE_D0I3;
+
+   iwl_trans_d3_suspend(trans, false);
+
+   return 0;
+}
+
+static int iwl_pci_runtime_resume(struct device *device)
+{
+   struct pci_dev *pdev = to_pci_dev(device);
+   struct iwl_trans *trans = pci_get_drvdata(pdev);
+   enum iwl_d3_status d3_status;
+
+   IWL_DEBUG_RPM(trans, "exiting runtime suspend (resume)\n");
+
+   iwl_trans_d3_resume(trans, _status, false);
+
+   trans->system_pm_mode = IWL_PLAT_PM_MODE_D3;
+
+   return 0;
+}
+#endif /* CONFIG_IWLWIFI_PCIE_RTPM */
+
+static const struct dev_pm_ops iwl_dev_pm_ops = {
+   SET_SYSTEM_SLEEP_PM_OPS(iwl_pci_suspend,
+   iwl_pci_resume)
+#ifdef CONFIG_IWLWIFI_PCIE_RTPM
+   SET_RUNTIME_PM_OPS(iwl_pci_runtime_suspend,
+  iwl_pci_runtime_resume,
+  NULL)
+#endif /* CONFIG_IWLWIFI_PCIE_RTPM */
+};
 
 #define IWL_PM_OPS (_dev_pm_ops)
 
-#else
+#else /* CONFIG_PM_SLEEP */
 
 #define IWL_PM_OPS NULL
 
-#endif
+#endif /* CONFIG_PM_SLEEP */
 
 static struct pci_driver iwl_pci_driver = {
.name = DRV_NAME,
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 3581096..db94fe1 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -72,6 +72,9 @@
 #include 
 #include 
 #include 
+#ifdef CONFIG_IWLWIFI_PCIE_RTPM
+#include 
+#endif /* CONFIG_IWLWIFI_PCIE_RTPM */
 
 #include "iwl-drv.h"
 #include "iwl-trans.h"
@@ -1194,6 +1197,9 @@ static void _iwl_trans_pcie_stop_device(struct iwl_trans 
*trans, bool