All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] backports: deal with timespec64 changes
@ 2015-04-23 11:33 Stefan Assmann
  2015-04-23 11:33 ` [PATCH 1/4] backports: handle ndo_gso_check() to ndo_features_check() changes Stefan Assmann
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Stefan Assmann @ 2015-04-23 11:33 UTC (permalink / raw)
  To: backports; +Cc: mcgrof, hauke, sassmann

This series adds cocci patches to deal with struct timespec64 changes
and also has several other bits to get igb working again. Patches have
been tested against next-20150402.

The struct timespec64 patches are not perfect, but they should get us
started. There are still some warnings, which we can fix along the way.

Stefan Assmann (4):
  backports: handle ndo_gso_check() to ndo_features_check() changes
  backports: add passthru_features_check()
  backports: deal with struct timespec64 changes
  backports: deal with struct struct ptp_clock_info get/settime64
    changes

 backport/backport-include/linux/netdevice.h        |  6 ++
 backport/compat/Makefile                           |  1 +
 backport/compat/backport-4.1.c                     | 19 +++++
 .../network/0056-ndo_features_check/INFO           | 12 ++++
 .../0056-ndo_features_check/features_check.cocci   | 19 +++++
 .../network/0057-timespec64/INFO                   | 11 +++
 .../network/0057-timespec64/igb.patch              | 16 +++++
 .../network/0057-timespec64/timespec64.cocci       | 83 ++++++++++++++++++++++
 .../network/0058-ptp_getsettime64/INFO             | 11 +++
 .../0058-ptp_getsettime64/ptp_getsettime64.cocci   | 33 +++++++++
 10 files changed, 211 insertions(+)
 create mode 100644 backport/compat/backport-4.1.c
 create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/INFO
 create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/features_check.cocci
 create mode 100644 patches/collateral-evolutions/network/0057-timespec64/INFO
 create mode 100644 patches/collateral-evolutions/network/0057-timespec64/igb.patch
 create mode 100644 patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci
 create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/INFO
 create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/ptp_getsettime64.cocci

-- 
2.1.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] backports: handle ndo_gso_check() to ndo_features_check() changes
  2015-04-23 11:33 [PATCH 0/4] backports: deal with timespec64 changes Stefan Assmann
@ 2015-04-23 11:33 ` Stefan Assmann
  2015-04-23 11:33 ` [PATCH 2/4] backports: add passthru_features_check() Stefan Assmann
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Stefan Assmann @ 2015-04-23 11:33 UTC (permalink / raw)
  To: backports; +Cc: mcgrof, hauke, sassmann

In kernel 3.19 function pointer ndo_gso_check is changed into
ndo_features_check in struct net_device_ops.

Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
---
 .../network/0056-ndo_features_check/INFO              | 12 ++++++++++++
 .../0056-ndo_features_check/features_check.cocci      | 19 +++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/INFO
 create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/features_check.cocci

diff --git a/patches/collateral-evolutions/network/0056-ndo_features_check/INFO b/patches/collateral-evolutions/network/0056-ndo_features_check/INFO
new file mode 100644
index 0000000..c3f7a92
--- /dev/null
+++ b/patches/collateral-evolutions/network/0056-ndo_features_check/INFO
@@ -0,0 +1,12 @@
+In kernel 3.19 function pointer ndo_gso_check is changed into
+ndo_features_check in struct net_device_ops.
+Address this by putting ifdef around the code.
+
+commit 5f35227ea34bb616c436d9da47fc325866c428f3
+Author: Jesse Gross <jesse@nicira.com>
+Date:   Tue Dec 23 22:37:26 2014 -0800
+
+    net: Generalize ndo_gso_check to ndo_features_check
+
+git describe --contains 5f35227ea34bb616c436d9da47fc325866c428f3
+v3.19-rc3~16^2~7
diff --git a/patches/collateral-evolutions/network/0056-ndo_features_check/features_check.cocci b/patches/collateral-evolutions/network/0056-ndo_features_check/features_check.cocci
new file mode 100644
index 0000000..7956e5c
--- /dev/null
+++ b/patches/collateral-evolutions/network/0056-ndo_features_check/features_check.cocci
@@ -0,0 +1,19 @@
+@r1@
+identifier s, func;
+@@
+
+struct net_device_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+.ndo_features_check = func,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */
+};
+
+// ----------------------------------------------------------------------
+
+@r2@
+identifier r1.func;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+func(...) { ... }
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] backports: add passthru_features_check()
  2015-04-23 11:33 [PATCH 0/4] backports: deal with timespec64 changes Stefan Assmann
  2015-04-23 11:33 ` [PATCH 1/4] backports: handle ndo_gso_check() to ndo_features_check() changes Stefan Assmann
@ 2015-04-23 11:33 ` Stefan Assmann
  2015-04-23 11:33 ` [PATCH 3/4] backports: deal with struct timespec64 changes Stefan Assmann
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Stefan Assmann @ 2015-04-23 11:33 UTC (permalink / raw)
  To: backports; +Cc: mcgrof, hauke, sassmann

This is required by igb and possibly other network drivers.

Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
---
 backport/backport-include/linux/netdevice.h |  6 ++++++
 backport/compat/Makefile                    |  1 +
 backport/compat/backport-4.1.c              | 19 +++++++++++++++++++
 3 files changed, 26 insertions(+)
 create mode 100644 backport/compat/backport-4.1.c

diff --git a/backport/backport-include/linux/netdevice.h b/backport/backport-include/linux/netdevice.h
index abbfe1d..ae67771 100644
--- a/backport/backport-include/linux/netdevice.h
+++ b/backport/backport-include/linux/netdevice.h
@@ -254,4 +254,10 @@ static inline struct sk_buff *napi_alloc_skb(struct napi_struct *napi,
 #define IFF_TX_SKB_SHARING 0
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
+netdev_features_t passthru_features_check(struct sk_buff *skb,
+					  struct net_device *dev,
+					  netdev_features_t features);
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
 #endif /* __BACKPORT_NETDEVICE_H */
diff --git a/backport/compat/Makefile b/backport/compat/Makefile
index 3d905ed..f60c32b 100644
--- a/backport/compat/Makefile
+++ b/backport/compat/Makefile
@@ -25,6 +25,7 @@ compat-$(CPTCFG_KERNEL_3_15) += backport-3.15.o
 compat-$(CPTCFG_KERNEL_3_17) += backport-3.17.o
 compat-$(CPTCFG_KERNEL_3_18) += backport-3.18.o
 compat-$(CPTCFG_KERNEL_3_19) += backport-3.19.o
+compat-$(CPTCFG_KERNEL_4_1) += backport-4.1.o
 
 compat-$(CPTCFG_BPAUTO_BUILD_CRYPTO_CCM) += crypto-ccm.o
 compat-$(CPTCFG_BPAUTO_BUILD_DMA_SHARED_HELPERS) += dma-shared-helpers.o
diff --git a/backport/compat/backport-4.1.c b/backport/compat/backport-4.1.c
new file mode 100644
index 0000000..f9adb41
--- /dev/null
+++ b/backport/compat/backport-4.1.c
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2015  Stefan Assmann <sassmann@kpanic.de>
+ *
+ * Backport functionality introduced in Linux 4.1.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/netdevice.h>
+
+netdev_features_t passthru_features_check(struct sk_buff *skb,
+					  struct net_device *dev,
+					  netdev_features_t features)
+{
+	return features;
+}
+EXPORT_SYMBOL(passthru_features_check);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] backports: deal with struct timespec64 changes
  2015-04-23 11:33 [PATCH 0/4] backports: deal with timespec64 changes Stefan Assmann
  2015-04-23 11:33 ` [PATCH 1/4] backports: handle ndo_gso_check() to ndo_features_check() changes Stefan Assmann
  2015-04-23 11:33 ` [PATCH 2/4] backports: add passthru_features_check() Stefan Assmann
@ 2015-04-23 11:33 ` Stefan Assmann
  2015-04-23 20:10   ` Hauke Mehrtens
  2015-04-23 11:33 ` [PATCH 4/4] backports: deal with struct struct ptp_clock_info get/settime64 changes Stefan Assmann
  2015-04-25 14:00 ` [PATCH 0/4] backports: deal with timespec64 changes Hauke Mehrtens
  4 siblings, 1 reply; 8+ messages in thread
From: Stefan Assmann @ 2015-04-23 11:33 UTC (permalink / raw)
  To: backports; +Cc: mcgrof, hauke, sassmann

igb now makes use of struct timespec64. Deal with the required
changes via cocci patches where possible. There's one occasion
where coccinelle is not able to deal with defining a struct and
assigning another struct on the same line.
Example:
struct timespec64 now, then = ns_to_timespec64(delta);
Deal with this in a separate patch for now.

Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
---
 .../network/0057-timespec64/INFO                   | 11 +++
 .../network/0057-timespec64/igb.patch              | 16 +++++
 .../network/0057-timespec64/timespec64.cocci       | 83 ++++++++++++++++++++++
 3 files changed, 110 insertions(+)
 create mode 100644 patches/collateral-evolutions/network/0057-timespec64/INFO
 create mode 100644 patches/collateral-evolutions/network/0057-timespec64/igb.patch
 create mode 100644 patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci

diff --git a/patches/collateral-evolutions/network/0057-timespec64/INFO b/patches/collateral-evolutions/network/0057-timespec64/INFO
new file mode 100644
index 0000000..681c1df
--- /dev/null
+++ b/patches/collateral-evolutions/network/0057-timespec64/INFO
@@ -0,0 +1,11 @@
+In kernel 3.17 struct timespec64 was introduced.
+Address this with cocci patches where possible.
+
+commit 361a3bf00582469877f8d18ff20f1efa6b781274
+Author: John Stultz <john.stultz@linaro.org>
+Date:   Wed Jul 16 21:03:58 2014 +0000
+
+    time64: Add time64.h header and define struct timespec64
+
+git describe --contains 361a3bf00582469877f8d18ff20f1efa6b781274
+v3.17-rc1~109^2~62
diff --git a/patches/collateral-evolutions/network/0057-timespec64/igb.patch b/patches/collateral-evolutions/network/0057-timespec64/igb.patch
new file mode 100644
index 0000000..559199f
--- /dev/null
+++ b/patches/collateral-evolutions/network/0057-timespec64/igb.patch
@@ -0,0 +1,16 @@
+diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
+index 060aa75..a660d39 100644
+--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
++++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
+@@ -285,7 +285,11 @@ static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta)
+ 	struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
+ 					       ptp_caps);
+ 	unsigned long flags;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ 	struct timespec64 now, then = ns_to_timespec64(delta);
++#else
++	struct timespec now, then = ns_to_timespec(delta);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
+ 
+ 	spin_lock_irqsave(&igb->tmreg_lock, flags);
+ 
diff --git a/patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci b/patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci
new file mode 100644
index 0000000..4f568cb
--- /dev/null
+++ b/patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci
@@ -0,0 +1,83 @@
+// ----------------------------------------------------------------------------
+// handle struct timespec64 to timespec conversion in prototypes
+@r1@
+identifier func, I1;
+@@
+ func(...
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+      ,struct timespec64 *I1
++#else
++     ,struct timespec *I1
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
+ ) {...}
+
+// ----------------------------------------------------------------------------
+// handle struct timespec64 to timespec conversion in functions
+@r2@
+identifier I1;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ struct timespec64 I1;
++#else
++struct timespec I1;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
+
+// ----------------------------------------------------------------------------
+// handle struct timespec64 to timespec conversion with assignment
+@r3@
+identifier I1;
+expression E1;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ struct timespec64 I1 = E1;
++#else
++struct timespec I1 = E1;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
+
+// ----------------------------------------------------------------------------
+// handle struct timespec64 to timespec casts
+@r4@
+identifier func;
+expression E1, E2;
+@@
+ func(E1
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+      ,(const struct timespec64 *) E2
++#else
++     ,(const struct timespec *) E2
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
+ );
+
+// ----------------------------------------------------------------------------
+// handle timespec64_add to timespec_add function rename
+@r5@
+identifier I1;
+expression E1, E2;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ I1 = timespec64_add(E1, E2);
++#else
++I1 = timespec_add(E1, E2);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
+
+// ----------------------------------------------------------------------------
+// handle ns_to_timespec64 to ns_to_timespec function rename
+@r6@
+expression E1, E2;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ E1 = ns_to_timespec64(E2);
++#else
++E1 = ns_to_timespec(E2);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
+
+// ----------------------------------------------------------------------------
+// handle timespec64_to_ns to timespec_to_ns function rename
+@r7@
+expression E1, E2;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+ E1 = timespec64_to_ns(E2);
++#else
++E1 = timespec_to_ns(E2);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] backports: deal with struct struct ptp_clock_info get/settime64 changes
  2015-04-23 11:33 [PATCH 0/4] backports: deal with timespec64 changes Stefan Assmann
                   ` (2 preceding siblings ...)
  2015-04-23 11:33 ` [PATCH 3/4] backports: deal with struct timespec64 changes Stefan Assmann
@ 2015-04-23 11:33 ` Stefan Assmann
  2015-04-25 14:00 ` [PATCH 0/4] backports: deal with timespec64 changes Hauke Mehrtens
  4 siblings, 0 replies; 8+ messages in thread
From: Stefan Assmann @ 2015-04-23 11:33 UTC (permalink / raw)
  To: backports; +Cc: mcgrof, hauke, sassmann

In kernel 4.1 struct ptp_clock_info changes function pointers gettime,
settime to gettime64, settime64.

Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
---
 .../network/0058-ptp_getsettime64/INFO             | 11 ++++++++
 .../0058-ptp_getsettime64/ptp_getsettime64.cocci   | 33 ++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/INFO
 create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/ptp_getsettime64.cocci

diff --git a/patches/collateral-evolutions/network/0058-ptp_getsettime64/INFO b/patches/collateral-evolutions/network/0058-ptp_getsettime64/INFO
new file mode 100644
index 0000000..9679d31
--- /dev/null
+++ b/patches/collateral-evolutions/network/0058-ptp_getsettime64/INFO
@@ -0,0 +1,11 @@
+In kernel 4.1 struct ptp_clock_info changes function pointers gettime,
+settime to gettime64, settime64.
+
+commit 92f1719407b90475b3be0b7b9c983dec2ff8351e
+Author: Richard Cochran <richardcochran@gmail.com>
+Date:   Sun Mar 29 23:11:51 2015 +0200
+
+    ptp: introduce get/set time methods with explicit 64 bit seconds.
+
+git describe --contains 92f1719407b90475b3be0b7b9c983dec2ff8351e
+next-20150401~92^2~18^2~22
diff --git a/patches/collateral-evolutions/network/0058-ptp_getsettime64/ptp_getsettime64.cocci b/patches/collateral-evolutions/network/0058-ptp_getsettime64/ptp_getsettime64.cocci
new file mode 100644
index 0000000..3f85c2a
--- /dev/null
+++ b/patches/collateral-evolutions/network/0058-ptp_getsettime64/ptp_getsettime64.cocci
@@ -0,0 +1,33 @@
+// ----------------------------------------------------------------------------
+// handle gettime64 to gettime function assignments
+@r1@
+expression E1, E2;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ E1.gettime64 = E2;
++#else
++E1.gettime = E2;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+
+// ----------------------------------------------------------------------------
+// handle calls to gettime64 as calls to gettime
+@r2@
+expression E1, E2, E3;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ E1.gettime64(E2, E3);
++#else
++E1.gettime(E2, E3);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+
+// ----------------------------------------------------------------------------
+// handle settime64 to settime function assignments
+@r3@
+expression E1, E2;
+@@
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ E1.settime64 = E2;
++#else
++E1.settime = E2;
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] backports: deal with struct timespec64 changes
  2015-04-23 11:33 ` [PATCH 3/4] backports: deal with struct timespec64 changes Stefan Assmann
@ 2015-04-23 20:10   ` Hauke Mehrtens
  2015-04-24 15:05     ` Stefan Assmann
  0 siblings, 1 reply; 8+ messages in thread
From: Hauke Mehrtens @ 2015-04-23 20:10 UTC (permalink / raw)
  To: Stefan Assmann, backports; +Cc: mcgrof

On 04/23/2015 01:33 PM, Stefan Assmann wrote:
> igb now makes use of struct timespec64. Deal with the required
> changes via cocci patches where possible. There's one occasion
> where coccinelle is not able to deal with defining a struct and
> assigning another struct on the same line.
> Example:
> struct timespec64 now, then = ns_to_timespec64(delta);
> Deal with this in a separate patch for now.

I think it would be easier if you just replace timespec64 with timespec
in the header files.

Like:
#define ns_to_timespec64 ns_to_timespec
#define timespec64 timespec

Then cocci is only needed to replace the settime64 members with settime
and so on.


> Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
> ---
>  .../network/0057-timespec64/INFO                   | 11 +++
>  .../network/0057-timespec64/igb.patch              | 16 +++++
>  .../network/0057-timespec64/timespec64.cocci       | 83 ++++++++++++++++++++++
>  3 files changed, 110 insertions(+)
>  create mode 100644 patches/collateral-evolutions/network/0057-timespec64/INFO
>  create mode 100644 patches/collateral-evolutions/network/0057-timespec64/igb.patch
>  create mode 100644 patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci
> 
> diff --git a/patches/collateral-evolutions/network/0057-timespec64/INFO b/patches/collateral-evolutions/network/0057-timespec64/INFO
> new file mode 100644
> index 0000000..681c1df
> --- /dev/null
> +++ b/patches/collateral-evolutions/network/0057-timespec64/INFO
> @@ -0,0 +1,11 @@
> +In kernel 3.17 struct timespec64 was introduced.
> +Address this with cocci patches where possible.
> +
> +commit 361a3bf00582469877f8d18ff20f1efa6b781274
> +Author: John Stultz <john.stultz@linaro.org>
> +Date:   Wed Jul 16 21:03:58 2014 +0000
> +
> +    time64: Add time64.h header and define struct timespec64
> +
> +git describe --contains 361a3bf00582469877f8d18ff20f1efa6b781274
> +v3.17-rc1~109^2~62
> diff --git a/patches/collateral-evolutions/network/0057-timespec64/igb.patch b/patches/collateral-evolutions/network/0057-timespec64/igb.patch
> new file mode 100644
> index 0000000..559199f
> --- /dev/null
> +++ b/patches/collateral-evolutions/network/0057-timespec64/igb.patch
> @@ -0,0 +1,16 @@
> +diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
> +index 060aa75..a660d39 100644
> +--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
> ++++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
> +@@ -285,7 +285,11 @@ static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta)
> + 	struct igb_adapter *igb = container_of(ptp, struct igb_adapter,
> + 					       ptp_caps);
> + 	unsigned long flags;
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
> + 	struct timespec64 now, then = ns_to_timespec64(delta);
> ++#else
> ++	struct timespec now, then = ns_to_timespec(delta);
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
> + 
> + 	spin_lock_irqsave(&igb->tmreg_lock, flags);
> + 
> diff --git a/patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci b/patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci
> new file mode 100644
> index 0000000..4f568cb
> --- /dev/null
> +++ b/patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci
> @@ -0,0 +1,83 @@
> +// ----------------------------------------------------------------------------
> +// handle struct timespec64 to timespec conversion in prototypes
> +@r1@
> +identifier func, I1;
> +@@
> + func(...
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
> +      ,struct timespec64 *I1
> ++#else
> ++     ,struct timespec *I1
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
> + ) {...}
> +
> +// ----------------------------------------------------------------------------
> +// handle struct timespec64 to timespec conversion in functions
> +@r2@
> +identifier I1;
> +@@
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
> + struct timespec64 I1;
> ++#else
> ++struct timespec I1;
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
> +
> +// ----------------------------------------------------------------------------
> +// handle struct timespec64 to timespec conversion with assignment
> +@r3@
> +identifier I1;
> +expression E1;
> +@@
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
> + struct timespec64 I1 = E1;
> ++#else
> ++struct timespec I1 = E1;
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
> +
> +// ----------------------------------------------------------------------------
> +// handle struct timespec64 to timespec casts
> +@r4@
> +identifier func;
> +expression E1, E2;
> +@@
> + func(E1
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
> +      ,(const struct timespec64 *) E2
> ++#else
> ++     ,(const struct timespec *) E2
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
> + );
> +
> +// ----------------------------------------------------------------------------
> +// handle timespec64_add to timespec_add function rename
> +@r5@
> +identifier I1;
> +expression E1, E2;
> +@@
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
> + I1 = timespec64_add(E1, E2);
> ++#else
> ++I1 = timespec_add(E1, E2);
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
> +
> +// ----------------------------------------------------------------------------
> +// handle ns_to_timespec64 to ns_to_timespec function rename
> +@r6@
> +expression E1, E2;
> +@@
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
> + E1 = ns_to_timespec64(E2);
> ++#else
> ++E1 = ns_to_timespec(E2);
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
> +
> +// ----------------------------------------------------------------------------
> +// handle timespec64_to_ns to timespec_to_ns function rename
> +@r7@
> +expression E1, E2;
> +@@
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
> + E1 = timespec64_to_ns(E2);
> ++#else
> ++E1 = timespec_to_ns(E2);
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] backports: deal with struct timespec64 changes
  2015-04-23 20:10   ` Hauke Mehrtens
@ 2015-04-24 15:05     ` Stefan Assmann
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Assmann @ 2015-04-24 15:05 UTC (permalink / raw)
  To: Hauke Mehrtens, backports; +Cc: mcgrof

On 23.04.2015 22:10, Hauke Mehrtens wrote:
> On 04/23/2015 01:33 PM, Stefan Assmann wrote:
>> igb now makes use of struct timespec64. Deal with the required
>> changes via cocci patches where possible. There's one occasion
>> where coccinelle is not able to deal with defining a struct and
>> assigning another struct on the same line.
>> Example:
>> struct timespec64 now, then = ns_to_timespec64(delta);
>> Deal with this in a separate patch for now.
> 
> I think it would be easier if you just replace timespec64 with timespec
> in the header files.
> 
> Like:
> #define ns_to_timespec64 ns_to_timespec
> #define timespec64 timespec
> 
> Then cocci is only needed to replace the settime64 members with settime
> and so on.

That seems to work better than I expected. :)
Here's a new patch.

  Stefan

>From b4d4d61c80be782f0cffa151e2eab3774c6cb4f9 Mon Sep 17 00:00:00 2001
From: Stefan Assmann <sassmann@kpanic.de>
Date: Wed, 22 Apr 2015 10:25:56 -0400
Subject: [PATCH v2] backports: deal with struct timespec64 changes

In kernel 3.17 struct timespec64 was introduced.

commit 361a3bf00582469877f8d18ff20f1efa6b781274
Author: John Stultz <john.stultz@linaro.org>
Date:   Wed Jul 16 21:03:58 2014 +0000

    time64: Add time64.h header and define struct timespec64

git describe --contains 361a3bf00582469877f8d18ff20f1efa6b781274
v3.17-rc1~109^2~62

Deal with the required changes via defines.

Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
---
 backport/backport-include/linux/time.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 backport/backport-include/linux/time.h

diff --git a/backport/backport-include/linux/time.h b/backport/backport-include/linux/time.h
new file mode 100644
index 0000000..3d958fe
--- /dev/null
+++ b/backport/backport-include/linux/time.h
@@ -0,0 +1,32 @@
+#ifndef __BACKPORT_LINUX_TIME_H
+#define __BACKPORT_LINUX_TIME_H
+#include_next <linux/time.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
+/* Map the ktime_t to timespec conversion to ns_to_timespec function */
+#define ktime_to_timespec(kt)		ns_to_timespec((kt).tv64)
+
+/* Map the ktime_t to timespec conversion to ns_to_timespec function */
+#define ktime_to_timespec64(kt)		ns_to_timespec64((kt).tv64)
+
+/* Map the ktime_t to timeval conversion to ns_to_timeval function */
+#define ktime_to_timeval(kt)		ns_to_timeval((kt).tv64)
+
+/* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */
+#define ktime_to_ns(kt)			((kt).tv64)
+
+#define timespec64_equal		timespec_equal
+#define timespec64_compare		timespec_compare
+#define set_normalized_timespec64	set_normalized_timespec
+#define timespec64_add_safe		timespec_add_safe
+#define timespec64_add			timespec_add
+#define timespec64_sub			timespec_sub
+#define timespec64_valid		timespec_valid
+#define timespec64_valid_strict		timespec_valid_strict
+#define timespec64_to_ns		timespec_to_ns
+#define ns_to_timespec64		ns_to_timespec
+#define timespec64_add_ns		timespec_add_ns
+#define timespec64			timespec
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0) */
+
+#endif /* __BACKPORT_LINUX_TIME_H */
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/4] backports: deal with timespec64 changes
  2015-04-23 11:33 [PATCH 0/4] backports: deal with timespec64 changes Stefan Assmann
                   ` (3 preceding siblings ...)
  2015-04-23 11:33 ` [PATCH 4/4] backports: deal with struct struct ptp_clock_info get/settime64 changes Stefan Assmann
@ 2015-04-25 14:00 ` Hauke Mehrtens
  4 siblings, 0 replies; 8+ messages in thread
From: Hauke Mehrtens @ 2015-04-25 14:00 UTC (permalink / raw)
  To: Stefan Assmann, backports; +Cc: mcgrof

On 04/23/2015 01:33 PM, Stefan Assmann wrote:
> This series adds cocci patches to deal with struct timespec64 changes
> and also has several other bits to get igb working again. Patches have
> been tested against next-20150402.
> 
> The struct timespec64 patches are not perfect, but they should get us
> started. There are still some warnings, which we can fix along the way.
> 
> Stefan Assmann (4):
>   backports: handle ndo_gso_check() to ndo_features_check() changes
>   backports: add passthru_features_check()
>   backports: deal with struct timespec64 changes
>   backports: deal with struct struct ptp_clock_info get/settime64
>     changes
> 
>  backport/backport-include/linux/netdevice.h        |  6 ++
>  backport/compat/Makefile                           |  1 +
>  backport/compat/backport-4.1.c                     | 19 +++++
>  .../network/0056-ndo_features_check/INFO           | 12 ++++
>  .../0056-ndo_features_check/features_check.cocci   | 19 +++++
>  .../network/0057-timespec64/INFO                   | 11 +++
>  .../network/0057-timespec64/igb.patch              | 16 +++++
>  .../network/0057-timespec64/timespec64.cocci       | 83 ++++++++++++++++++++++
>  .../network/0058-ptp_getsettime64/INFO             | 11 +++
>  .../0058-ptp_getsettime64/ptp_getsettime64.cocci   | 33 +++++++++
>  10 files changed, 211 insertions(+)
>  create mode 100644 backport/compat/backport-4.1.c
>  create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/INFO
>  create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/features_check.cocci
>  create mode 100644 patches/collateral-evolutions/network/0057-timespec64/INFO
>  create mode 100644 patches/collateral-evolutions/network/0057-timespec64/igb.patch
>  create mode 100644 patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci
>  create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/INFO
>  create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/ptp_getsettime64.cocci
> 
Thank you for the patches, I applied and pushed them.

In the patch "backports: add passthru_features_check()" I change the
EXPORT_SYMBOL() to a EXPORT_SYMBOL_GPL().

In "backports: deal with struct timespec64 changes" v2 I moved the
defines into the header files with the same name as where they are
defined in the kernel. If later some code is including time64.h directly
this will now work. In addition I removed some ktime_* defines, because
they are already in all supported kernel versions.

Hauke

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-04-25 14:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-23 11:33 [PATCH 0/4] backports: deal with timespec64 changes Stefan Assmann
2015-04-23 11:33 ` [PATCH 1/4] backports: handle ndo_gso_check() to ndo_features_check() changes Stefan Assmann
2015-04-23 11:33 ` [PATCH 2/4] backports: add passthru_features_check() Stefan Assmann
2015-04-23 11:33 ` [PATCH 3/4] backports: deal with struct timespec64 changes Stefan Assmann
2015-04-23 20:10   ` Hauke Mehrtens
2015-04-24 15:05     ` Stefan Assmann
2015-04-23 11:33 ` [PATCH 4/4] backports: deal with struct struct ptp_clock_info get/settime64 changes Stefan Assmann
2015-04-25 14:00 ` [PATCH 0/4] backports: deal with timespec64 changes Hauke Mehrtens

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.