* [PATCH] compat: handle pci suspend/resume on kernel 2.6.29
@ 2012-08-02 20:15 Johannes Berg
2012-08-06 19:15 ` Luis R. Rodriguez
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2012-08-02 20:15 UTC (permalink / raw)
To: linux-wireless; +Cc: Luis R. Rodriguez
From: Johannes Berg <johannes.berg@intel.com>
Before kernel 2.6.29, we use compat_pci_{suspend,resume}
and not the SIMPLE_DEV_PM_OPS, which include the code for
PCI device handling. For 2.6.30 and higher, the core PCI
code includes the device handling.
That leaves 2.6.29 as the odd one out and causes suspend
and resume to fail. Fix it by including the PCI device
handling code in the definition of SIMPLE_DEV_PM_OPS for
that kernel version.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
I'm not sure what the word on this is yet, it hasn't been tested, but
from the looks of it this should fix the issue with 2.6.29 and not
calling the PCI functions there in suspend/resume. Could have a stupid
bug though for all I know...
include/linux/compat-2.6.32.h | 47 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 45 insertions(+), 2 deletions(-)
diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h
index b0c699a..0a6d0e4 100644
--- a/include/linux/compat-2.6.32.h
+++ b/include/linux/compat-2.6.32.h
@@ -116,9 +116,52 @@ typedef enum netdev_tx netdev_tx_t;
/*
* dev_pm_ops is only available on kernels >= 2.6.29, for
* older kernels we rely on reverting the work to old
- * power management style stuff.
+ * power management style stuff. On 2.6.29 the pci calls
+ * weren't included yet though, so include them here.
*/
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
+#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,29))
+/*
+ * Note the lack of "static" in this definition. The code may put
+ * a "static" in front of using the define, which makes it impossible
+ * to put static here. We lose that static if it is present (it ends
+ * up being on the suspend_fn) but that doesn't really matter much
+ * unless a driver defines multiple pm_ops structs with the same name
+ * (in which case we'll need to fix it)
+ */
+#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
+int __compat_suspend_fn_ ## name(struct device *dev) \
+{ \
+ int ret = suspend_fn(dev); \
+ if (ret) \
+ return ret; \
+ if (dev->bus == &pci_bus_type) { \
+ pci_save_state(to_pci_dev(dev)); \
+ pci_disable_device(to_pci_dev(dev)); \
+ pci_set_power_state(to_pci_dev(dev), PCI_D3hot);\
+ } \
+ return 0; \
+} \
+int __compat_resume_fn_ ## name(struct device *dev) \
+{ \
+ int ret; \
+ if (dev->bus == &pci_bus_type) { \
+ pci_set_power_state(to_pci_dev(dev), PCI_D0); \
+ ret = pci_enable_device(to_pci_dev(dev)); \
+ if (ret) \
+ return ret; \
+ pci_restore_state(to_pci_dev(dev)); \
+ } \
+ return resume_fn(dev); \
+} \
+struct dev_pm_ops name = { \
+ .suspend = __compat_suspend_fn_ ## name, \
+ .resume = __compat_resume_fn_ ## name, \
+ .freeze = __compat_suspend_fn_ ## name, \
+ .thaw = __compat_resume_fn_ ## name, \
+ .poweroff = __compat_suspend_fn_ ## name, \
+ .restore = __compat_resume_fn_ ## name, \
+}
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30))
/*
* Use this if you want to use the same suspend and resume callbacks for suspend
* to RAM and hibernation.
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] compat: handle pci suspend/resume on kernel 2.6.29
2012-08-02 20:15 [PATCH] compat: handle pci suspend/resume on kernel 2.6.29 Johannes Berg
@ 2012-08-06 19:15 ` Luis R. Rodriguez
2012-08-07 17:55 ` Luis R. Rodriguez
0 siblings, 1 reply; 6+ messages in thread
From: Luis R. Rodriguez @ 2012-08-06 19:15 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless
On Thu, Aug 2, 2012 at 1:15 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> From: Johannes Berg <johannes.berg@intel.com>
>
> Before kernel 2.6.29, we use compat_pci_{suspend,resume}
> and not the SIMPLE_DEV_PM_OPS, which include the code for
> PCI device handling. For 2.6.30 and higher, the core PCI
> code includes the device handling.
>
> That leaves 2.6.29 as the odd one out and causes suspend
> and resume to fail. Fix it by including the PCI device
> handling code in the definition of SIMPLE_DEV_PM_OPS for
> that kernel version.
>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Applied and pushed, thanks!
Luis
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] compat: handle pci suspend/resume on kernel 2.6.29
2012-08-06 19:15 ` Luis R. Rodriguez
@ 2012-08-07 17:55 ` Luis R. Rodriguez
2012-08-07 18:05 ` Johannes Berg
0 siblings, 1 reply; 6+ messages in thread
From: Luis R. Rodriguez @ 2012-08-07 17:55 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless
On Mon, Aug 6, 2012 at 12:15 PM, Luis R. Rodriguez <mcgrof@gmail.com> wrote:
> On Thu, Aug 2, 2012 at 1:15 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
>> From: Johannes Berg <johannes.berg@intel.com>
>>
>> Before kernel 2.6.29, we use compat_pci_{suspend,resume}
>> and not the SIMPLE_DEV_PM_OPS, which include the code for
>> PCI device handling. For 2.6.30 and higher, the core PCI
>> code includes the device handling.
>>
>> That leaves 2.6.29 as the odd one out and causes suspend
>> and resume to fail. Fix it by including the PCI device
>> handling code in the definition of SIMPLE_DEV_PM_OPS for
>> that kernel version.
>>
>> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
>
> Applied and pushed, thanks!
I applied this onto the linux-3.5.y branch for compat but get this
when compiling against 2.6.29:
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/ipw2x00/libipw_rx.c:338:10:
warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:
In function ‘il_enqueue_hcmd’:
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:3089:6:
warning: variable ‘len’ set but not used [-Wunused-but-set-variable]
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:
In function ‘__check_bt_coex_active’:
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:3316:1:
warning: return from incompatible pointer type [enabled by default]
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:
At top level:
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:4916:7:
error: conflicting type qualifiers for ‘il_pm_ops’
In file included from
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:43:0:
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.h:1854:32:
note: previous declaration of ‘il_pm_ops’ was here
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:4916:7:
warning: initialization from incompatible pointer type [enabled by
default]
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:4916:7:
warning: (near initialization for ‘il_pm_ops.suspend’) [enabled by
default]
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:4916:7:
warning: initialization from incompatible pointer type [enabled by
default]
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:4916:7:
warning: (near initialization for ‘il_pm_ops.freeze’) [enabled by
default]
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:4916:7:
warning: initialization from incompatible pointer type [enabled by
default]
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:4916:7:
warning: (near initialization for ‘il_pm_ops.poweroff’) [enabled by
default]
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:4922:1:
error: conflicting type qualifiers for ‘il_pm_ops’
In file included from
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:43:0:
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.h:1854:32:
note: previous declaration of ‘il_pm_ops’ was here
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:
In function ‘il_isr’:
/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:5415:12:
warning: variable ‘inta_mask’ set but not used
[-Wunused-but-set-variable]
CC [M] /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/ath/ath6kl/sdio.o
make[4]: *** [/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.o]
Error 1
make[3]: *** [/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy]
Error 2
Luis
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] compat: handle pci suspend/resume on kernel 2.6.29
2012-08-07 17:55 ` Luis R. Rodriguez
@ 2012-08-07 18:05 ` Johannes Berg
2012-08-07 18:24 ` Johannes Berg
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2012-08-07 18:05 UTC (permalink / raw)
To: Luis R. Rodriguez; +Cc: linux-wireless
On Tue, 2012-08-07 at 10:55 -0700, Luis R. Rodriguez wrote:
> /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:4922:1:
> error: conflicting type qualifiers for ‘il_pm_ops’
> In file included from
> /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:43:0:
> /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.h:1854:32:
> note: previous declaration of ‘il_pm_ops’ was here
> /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:
> In function ‘il_isr’:
> /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:5415:12:
> warning: variable ‘inta_mask’ set but not used
> [-Wunused-but-set-variable]
> CC [M] /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/ath/ath6kl/sdio.o
> make[4]: *** [/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.o]
> Error 1
> make[3]: *** [/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy]
> Error 2
Gee, fun, that's because of the static ... more hackery required then I
guess :-(
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] compat: handle pci suspend/resume on kernel 2.6.29
2012-08-07 18:05 ` Johannes Berg
@ 2012-08-07 18:24 ` Johannes Berg
2012-08-07 18:32 ` Johannes Berg
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2012-08-07 18:24 UTC (permalink / raw)
To: Luis R. Rodriguez; +Cc: linux-wireless
On Tue, 2012-08-07 at 20:05 +0200, Johannes Berg wrote:
> On Tue, 2012-08-07 at 10:55 -0700, Luis R. Rodriguez wrote:
>
> > /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:4922:1:
> > error: conflicting type qualifiers for ‘il_pm_ops’
> > In file included from
> > /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:43:0:
> > /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.h:1854:32:
> > note: previous declaration of ‘il_pm_ops’ was here
> > /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:
> > In function ‘il_isr’:
> > /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:5415:12:
> > warning: variable ‘inta_mask’ set but not used
> > [-Wunused-but-set-variable]
> > CC [M] /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/ath/ath6kl/sdio.o
> > make[4]: *** [/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.o]
> > Error 1
> > make[3]: *** [/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy]
> > Error 2
>
> Gee, fun, that's because of the static ... more hackery required then I
> guess :-(
Not static, of course, the "const"
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] compat: handle pci suspend/resume on kernel 2.6.29
2012-08-07 18:24 ` Johannes Berg
@ 2012-08-07 18:32 ` Johannes Berg
0 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2012-08-07 18:32 UTC (permalink / raw)
To: Luis R. Rodriguez; +Cc: linux-wireless
On Tue, 2012-08-07 at 20:24 +0200, Johannes Berg wrote:
> On Tue, 2012-08-07 at 20:05 +0200, Johannes Berg wrote:
> > On Tue, 2012-08-07 at 10:55 -0700, Luis R. Rodriguez wrote:
> >
> > > /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:4922:1:
> > > error: conflicting type qualifiers for ‘il_pm_ops’
> > > In file included from
> > > /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:43:0:
> > > /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.h:1854:32:
> > > note: previous declaration of ‘il_pm_ops’ was here
> > > /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:
> > > In function ‘il_isr’:
> > > /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.c:5415:12:
> > > warning: variable ‘inta_mask’ set but not used
> > > [-Wunused-but-set-variable]
> > > CC [M] /home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/ath/ath6kl/sdio.o
> > > make[4]: *** [/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy/common.o]
> > > Error 1
> > > make[3]: *** [/home/mcgrof/staging/2/compat-wireless-3.5-3-snpc/drivers/net/wireless/iwlegacy]
> > > Error 2
> >
> > Gee, fun, that's because of the static ... more hackery required then I
> > guess :-(
>
> Not static, of course, the "const"
This should work, but I didn't test it:
http://p.sipsolutions.net/448a4a1fe8f98b30.txt
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-08-07 18:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-02 20:15 [PATCH] compat: handle pci suspend/resume on kernel 2.6.29 Johannes Berg
2012-08-06 19:15 ` Luis R. Rodriguez
2012-08-07 17:55 ` Luis R. Rodriguez
2012-08-07 18:05 ` Johannes Berg
2012-08-07 18:24 ` Johannes Berg
2012-08-07 18:32 ` Johannes Berg
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).