2012-08-11 00:30:15

by Hauke Mehrtens

[permalink] [raw]
Subject: [PATCH 0/4] compat: some fixes

With these patches and "compat: fixup error in no_printk definition" by
Andy Gospodarek <[email protected]> compat and compat-wireless are
building for me on all supported kernel versions. There is also a patch
for compat-wireless needed.

Results of ckmake on compat and compat-wireless:
Trying kernel 3.6.0-030600rc1-generic [OK]
Trying kernel 3.5.0-030500-generic [OK]
Trying kernel 3.4.7-030407-generic [OK]
Trying kernel 3.3.8-030308-generic [OK]
Trying kernel 3.2.26-030226-generic [OK]
Trying kernel 3.1.10-030110-generic [OK]
Trying kernel 3.0.39-030039-generic [OK]
Trying kernel 2.6.39-02063904-generic [OK]
Trying kernel 2.6.38-02063808-generic [OK]
Trying kernel 2.6.37-02063706-generic [OK]
Trying kernel 2.6.36-02063604-generic [OK]
Trying kernel 2.6.35-02063513-generic [OK]
Trying kernel 2.6.34-02063410-generic [OK]
Trying kernel 2.6.33-02063307-generic [OK]
Trying kernel 2.6.32-02063254-generic [OK]
Trying kernel 2.6.31-02063113-generic [OK]
Trying kernel 2.6.30-02063010-generic [OK]
Trying kernel 2.6.29-02062906-generic [OK]
Trying kernel 2.6.28-02062810-generic [OK]
Trying kernel 2.6.27-02062731-generic [OK]
Trying kernel 2.6.26-020626-generic [OK]
Trying kernel 2.6.25-020625-generic [OK]
Trying kernel 2.6.24-02062407-generic [OK]

Hauke Mehrtens (4):
compat: fix SIMPLE_DEV_PM_OPS() on kernel 2.6.29
compat: generate CONFIG_COMPAT_KERNEL_3_7
compat: fix mod_delayed_work
compat: move RHEL mask for qdisc_cb_private_validate

compat/compat-3.7.c | 2 ++
include/linux/compat-2.6.29.h | 80 +++++++++++++++++++++++++++++------------
include/linux/compat-2.6.32.h | 44 ++++-------------------
include/linux/compat-2.6.33.h | 13 +++++++
include/linux/compat-3.3.h | 6 ++--
scripts/gen-compat-config.sh | 2 +-
6 files changed, 83 insertions(+), 64 deletions(-)

--
1.7.9.5



2012-08-11 00:30:23

by Hauke Mehrtens

[permalink] [raw]
Subject: [PATCH 3/4] compat: fix mod_delayed_work

* Add return value to function
* make EXPORT_SYMBOL_GPL work by including the needed header file

Signed-off-by: Hauke Mehrtens <[email protected]>
---
compat/compat-3.7.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/compat/compat-3.7.c b/compat/compat-3.7.c
index 8fd07ff..f251788 100644
--- a/compat/compat-3.7.c
+++ b/compat/compat-3.7.c
@@ -9,11 +9,13 @@
*/

#include <linux/workqueue.h>
+#include <linux/export.h>

bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork,
unsigned long delay)
{
cancel_delayed_work(dwork);
queue_delayed_work(wq, dwork, delay);
+ return false;
}
EXPORT_SYMBOL_GPL(mod_delayed_work);
--
1.7.9.5


2012-08-11 00:52:56

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH 0/4] compat: some fixes

On Fri, Aug 10, 2012 at 5:30 PM, Hauke Mehrtens <[email protected]> wrote:
> With these patches and "compat: fixup error in no_printk definition" by
> Andy Gospodarek <[email protected]> compat and compat-wireless are
> building for me on all supported kernel versions. There is also a patch
> for compat-wireless needed.
>
> Results of ckmake on compat and compat-wireless:
> Trying kernel 3.6.0-030600rc1-generic [OK]
> Trying kernel 3.5.0-030500-generic [OK]
> Trying kernel 3.4.7-030407-generic [OK]
> Trying kernel 3.3.8-030308-generic [OK]
> Trying kernel 3.2.26-030226-generic [OK]
> Trying kernel 3.1.10-030110-generic [OK]
> Trying kernel 3.0.39-030039-generic [OK]
> Trying kernel 2.6.39-02063904-generic [OK]
> Trying kernel 2.6.38-02063808-generic [OK]
> Trying kernel 2.6.37-02063706-generic [OK]
> Trying kernel 2.6.36-02063604-generic [OK]
> Trying kernel 2.6.35-02063513-generic [OK]
> Trying kernel 2.6.34-02063410-generic [OK]
> Trying kernel 2.6.33-02063307-generic [OK]
> Trying kernel 2.6.32-02063254-generic [OK]
> Trying kernel 2.6.31-02063113-generic [OK]
> Trying kernel 2.6.30-02063010-generic [OK]
> Trying kernel 2.6.29-02062906-generic [OK]
> Trying kernel 2.6.28-02062810-generic [OK]
> Trying kernel 2.6.27-02062731-generic [OK]
> Trying kernel 2.6.26-020626-generic [OK]
> Trying kernel 2.6.25-020625-generic [OK]
> Trying kernel 2.6.24-02062407-generic [OK]

Nice! Thanks so much for this, applied all compat and compat-drivers
patches and pushed (BTW we should start using compat-drivers for
subject soon).

Luis

2012-08-11 00:30:24

by Hauke Mehrtens

[permalink] [raw]
Subject: [PATCH 4/4] compat: move RHEL mask for qdisc_cb_private_validate

Move the mask for qdisc_cb_private_validate directly in front of the
function to it is only included when this function is really used from
compat.

Signed-off-by: Hauke Mehrtens <[email protected]>
---
include/linux/compat-3.3.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h
index 956d4c0..61d33b0 100644
--- a/include/linux/compat-3.3.h
+++ b/include/linux/compat-3.3.h
@@ -10,15 +10,17 @@
#include <linux/skbuff.h>
#include <net/sch_generic.h>

-/* mask qdisc_cb_private_validate as RHEL6 backports this */
-#define qdisc_cb_private_validate(a,b) compat_qdisc_cb_private_validate(a,b)
#if !((LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,9) && LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,23) && LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)))
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37))
+/* mask qdisc_cb_private_validate as RHEL6 backports this */
+#define qdisc_cb_private_validate(a,b) compat_qdisc_cb_private_validate(a,b)
static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)
{
BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct qdisc_skb_cb) + sz);
}
#else
+/* mask qdisc_cb_private_validate as RHEL6 backports this */
+#define qdisc_cb_private_validate(a,b) compat_qdisc_cb_private_validate(a,b)
static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)
{
/* XXX ? */
--
1.7.9.5


2012-08-11 00:30:19

by Hauke Mehrtens

[permalink] [raw]
Subject: [PATCH 2/4] compat: generate CONFIG_COMPAT_KERNEL_3_7


Signed-off-by: Hauke Mehrtens <[email protected]>
---
scripts/gen-compat-config.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh
index 3eba34e..391a75d 100755
--- a/scripts/gen-compat-config.sh
+++ b/scripts/gen-compat-config.sh
@@ -17,7 +17,7 @@ fi
KERNEL_VERSION=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p')

# 3.0 kernel stuff
-COMPAT_LATEST_VERSION="5"
+COMPAT_LATEST_VERSION="7"
KERNEL_SUBLEVEL="-1"

# Note that this script will export all variables explicitly,
--
1.7.9.5


2012-08-16 19:19:42

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/4] compat: fix SIMPLE_DEV_PM_OPS() on kernel 2.6.29

On Sat, 2012-08-11 at 02:30 +0200, Hauke Mehrtens wrote:
> This patch reworks this commit:
> commit 8e661d67b1965afcfd9d3672803e2fc37765f6ef
> Author: Johannes Berg <[email protected]>
> Date: Thu Aug 2 22:15:05 2012 +0200
>
> compat: handle pci suspend/resume on kernel 2.6.29
>
> The functions for pci suspend and resume are now created by
> compat_pci_suspend and compat_pci_resume and then used by
> SIMPLE_DEV_PM_OPS. This way attributes like static, const and so on are
> forwarded in the struct dev_pm_ops define on all kernel versions.
>
> In addition this patch adds an own SIMPLE_DEV_PM_OPS() for kernel
> 2.6.32 overwriting the original, because in kernel 2.6.32 const is
> needed for struct dev_pm_ops in pci drivers.
>
> This is based on work done by Johannes Berg.

Thanks!

johannes


2012-08-11 00:30:18

by Hauke Mehrtens

[permalink] [raw]
Subject: [PATCH 1/4] compat: fix SIMPLE_DEV_PM_OPS() on kernel 2.6.29

This patch reworks this commit:
commit 8e661d67b1965afcfd9d3672803e2fc37765f6ef
Author: Johannes Berg <[email protected]>
Date: Thu Aug 2 22:15:05 2012 +0200

compat: handle pci suspend/resume on kernel 2.6.29

The functions for pci suspend and resume are now created by
compat_pci_suspend and compat_pci_resume and then used by
SIMPLE_DEV_PM_OPS. This way attributes like static, const and so on are
forwarded in the struct dev_pm_ops define on all kernel versions.

In addition this patch adds an own SIMPLE_DEV_PM_OPS() for kernel
2.6.32 overwriting the original, because in kernel 2.6.32 const is
needed for struct dev_pm_ops in pci drivers.

This is based on work done by Johannes Berg.

CC: Johannes Berg <[email protected]>
Signed-off-by: Hauke Mehrtens <[email protected]>
---
include/linux/compat-2.6.29.h | 80 +++++++++++++++++++++++++++++------------
include/linux/compat-2.6.32.h | 44 ++++-------------------
include/linux/compat-2.6.33.h | 13 +++++++
3 files changed, 76 insertions(+), 61 deletions(-)

diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h
index e65c229..e859a19 100644
--- a/include/linux/compat-2.6.29.h
+++ b/include/linux/compat-2.6.29.h
@@ -325,6 +325,30 @@ static inline struct net *read_pnet(struct net * const *pnet)

extern int init_dummy_netdev(struct net_device *dev);

+#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */
+
+/* Kernels >= 2.6.29 follows */
+
+/* XXX: this can probably just go upstream ! */
+static inline void netdev_attach_ops(struct net_device *dev,
+ const struct net_device_ops *ops)
+{
+ dev->netdev_ops = ops;
+}
+
+/* XXX: this can probably just go upstream! */
+static inline int ndo_do_ioctl(struct net_device *dev,
+ struct ifreq *ifr,
+ int cmd)
+{
+ if (dev->netdev_ops && dev->netdev_ops->ndo_do_ioctl)
+ return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd);
+ return -EOPNOTSUPP;
+}
+
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
#define compat_pci_suspend(fn) \
int fn##_compat(struct pci_dev *pdev, pm_message_t state) \
{ \
@@ -354,31 +378,41 @@ extern int init_dummy_netdev(struct net_device *dev);
\
return fn(&pdev->dev); \
}
+#elif LINUX_VERSION_CODE == KERNEL_VERSION(2,6,29)
+#define compat_pci_suspend(fn) \
+ int fn##_compat(struct device *dev) \
+ { \
+ struct pci_dev *pdev = to_pci_dev(dev); \
+ int r; \
+ \
+ r = fn(&pdev->dev); \
+ if (r) \
+ return r; \
+ \
+ pci_save_state(pdev); \
+ pci_disable_device(pdev); \
+ pci_set_power_state(pdev, PCI_D3hot); \
+ \
+ return 0; \
+ }

-#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */
-
-/* Kernels >= 2.6.29 follows */
-
-/* XXX: this can probably just go upstream ! */
-static inline void netdev_attach_ops(struct net_device *dev,
- const struct net_device_ops *ops)
-{
- dev->netdev_ops = ops;
-}
-
-/* XXX: this can probably just go upstream! */
-static inline int ndo_do_ioctl(struct net_device *dev,
- struct ifreq *ifr,
- int cmd)
-{
- if (dev->netdev_ops && dev->netdev_ops->ndo_do_ioctl)
- return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd);
- return -EOPNOTSUPP;
-}
-
+#define compat_pci_resume(fn) \
+ int fn##_compat(struct device *dev) \
+ { \
+ struct pci_dev *pdev = to_pci_dev(dev); \
+ int r; \
+ \
+ pci_set_power_state(pdev, PCI_D0); \
+ r = pci_enable_device(pdev); \
+ if (r) \
+ return r; \
+ pci_restore_state(pdev); \
+ \
+ return fn(&pdev->dev); \
+ }
+#else
#define compat_pci_suspend(fn)
#define compat_pci_resume(fn)
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */
+#endif

#endif /* LINUX_26_29_COMPAT_H */
diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h
index ff57dca..f8320cf 100644
--- a/include/linux/compat-2.6.32.h
+++ b/include/linux/compat-2.6.32.h
@@ -128,46 +128,14 @@ typedef enum netdev_tx netdev_tx_t;
* weren't included yet though, so include them here.
*/
#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, \
+ .suspend = suspend_fn ## _compat, \
+ .resume = resume_fn ## _compat, \
+ .freeze = suspend_fn ## _compat, \
+ .thaw = resume_fn ## _compat, \
+ .poweroff = suspend_fn ## _compat, \
+ .restore = resume_fn ## _compat, \
}
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30))
/*
diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h
index dcdf765..381146d 100644
--- a/include/linux/compat-2.6.33.h
+++ b/include/linux/compat-2.6.33.h
@@ -173,6 +173,19 @@ static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
return !ptr || IS_ERR_VALUE((unsigned long)ptr);
}

+#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,32))
+#undef SIMPLE_DEV_PM_OPS
+#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
+const struct dev_pm_ops name = { \
+ .suspend = suspend_fn, \
+ .resume = resume_fn, \
+ .freeze = suspend_fn, \
+ .thaw = resume_fn, \
+ .poweroff = suspend_fn, \
+ .restore = resume_fn, \
+}
+#endif /* (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,32)) */
+
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */

#endif /* LINUX_26_33_COMPAT_H */
--
1.7.9.5