backports: convert threaded IRQ suport into an SmPL patch
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>
Sat, 21 Dec 2013 19:40:20 +0000 (11:40 -0800)
committerLuis R. Rodriguez <mcgrof@do-not-panic.com>
Wed, 9 Apr 2014 01:16:21 +0000 (18:16 -0700)
commitd6d227dcb1cadd9c53a56b9f88aeb88bcd403dd3
tree784190fe8e136aa4df58682f1766d75ebfee832e
parentfb243741691498c7b218e7abb024da864e8a5591
backports: convert threaded IRQ suport into an SmPL patch

We leave two patches under the 09-threaded-irq series, but there
are six things worth mentioning on this commit that are important.
I'll clarify that this SmPL port is simply done as a proof of
concept on testing the complexity of a backport for with Coccinelle,
this backport is only relevant for kernels older than 2.6.31 which
at this point is ancient and we should probably stop caring for soon.

  1) patches/collateral-evolutions/network/0015-threaded-irq.cocci

We rename the collateral evolution backport from the 09-threaded-irq as
this backport is now formalized and properly atomically split up. We
use 4 digit prefixes for formalized and atomically split up collateral
evolutions. The rest of the patch series that do not have 4 digits
imply that those series could use some love to be formally split up
atomically.

  2) 0015-threaded-irq/

We keep a directory for backported collateral evolutions for either
legacy backports without SmPL Coccinelle patches *or* for series that
are addressed with SmPL but that had some shortcomings with Coccinelle
that we are looking to address. Legacy backports also had an INFO file
in its directory, we keep it around for now for this series as we have
one legacy patch lingering around still but since Coccinelle lets us
put comments on top and the series is for all drivers we can just rely
on the comment section of an SmPL patch for this as patches get
translated.

  3) Rename of 09-threaded-irq/drivers_net_wireless_ti_wlcore_main_extra.patch
    to
    0016-threaded-irq-one-shot.patch

This patch is kept as it deals with driver specific IRQ changes
which are completely unrelated to the 09-threaded-irq series but that
we had tucked under in the older legacy backport. Because of this
we make emphasis by moving out out under the series. This can be
generalized as another backport series if other drivers wish to
backport.

This new seires backports commit b25c340c1 added by Thomas through kernel
v2.6.32 which added support for IRQF_ONESHOT. This lets drivers that use
threaded IRQ support to request that the IRQ is not masked after the
hard interrupt handler as this requires device  access in hard IRQ
context and for buses such as i2c and spi this at times is not
possible.

Note that the TI driver uses this when a platform quirk with
WL12XX_PLATFORM_QUIRK_EDGE_IRQ is detected. In retrospect this quirk
does not seem backportable unless IRQF_ONESHOT is really not a requirement,
but desired. If WL12XX_PLATFORM_QUIRK_EDGE_IRQ is indeed a requirement
for IRQF_ONESHOT then we should not probe complete. Its unclear
if this is a universal thing or not.

mcgrof@ergon ~/linux-next (git::master)$ git describe --contains b25c340c1
v2.6.32-rc1~722^2~3

  4) 0015-threaded-irq/drivers_net_wireless_iwlwifi_iwl-trans.patch

A data structure change to struct iwl_trans is not being done
by Coccinelle given that the driver's Makefile for iwlwifi uses
this for its includes:

ccflags-y += -D__CHECK_ENDIAN__ -I$(src)

Coccinelle doesn't pick up on this even if we use --recursive-includes.
This issue has been reported. An interesting thing about this is that
struct iwl_trans was *not* used before this patch which is why you see
the removal of the file drivers_net_wireless_iwlwifi_pcie_internal.patch
and as a replacement have added drivers_net_wireless_iwlwifi_iwl-trans.patch.
What happened is Coccinelle is consistent and the change, as expressed
in grammar, which reveleas that we were *not* consistent with our manual
backport! The older backport still worked though as it did not really
matter what data structure got changed so long as its an internal data
structure. This also means this backport could be modified to use
a generic backport data structure, which we don't yet have but could
be a good idea to stuff in general backport data structure extensions,
which we typically have not been able to address through backports
unless we use #ifdef's. This would however require some sort of driver
specific backport_device_alloc(), backport_device_init() and a respective
backport_device_free(). The overhead would need to be considered unless
some fancy trickery is introduced. Since 09-threaded-irq is a backport
for kernels >= 2.6.31 I don't recommend we consider this now. The effort
for using SmPL for this series was done simply as a way to demonstrate
the power of Coccinelle.

  5) Space fixes for extra code on Coccinelle modified branches:

This SmPL patch does some space modifications on the wil6210 [0], the reason
could be that Coccinelle is introducing some code on a branch and when it
detects this it puts the code it is adding with braces. This is another
great feature of Coccinelle but the space fixes that Julia has completed
may not be treated in that situation yet.

  6) This requires at least spatch 1.0.0-rc20.

[0] hunk in question shown below:

@@ -499,11 +518,21 @@ int wil6210_init_irq(struct wil6210_priv *wil, int irq)
int rc;
if (wil->n_msi == 3)
rc = wil6210_request_3msi(wil, irq);
-       else
+       else {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
rc = request_threaded_irq(irq, wil6210_hardirq,
-                                         wil6210_thread_irq,
-                                         wil->n_msi ? 0 : IRQF_SHARED,
-                                         WIL_NAME, wil);
+               wil6210_thread_irq,
+               wil->n_msi ? 0 : IRQF_SHARED,
+               WIL_NAME, wil);
+#else
+               rc = compat_request_threaded_irq(&wil->irq_compat, irq,
+                                                wil6210_hardirq,
+                                                wil6210_thread_irq,
+                                                wil->n_msi ? 0 :
IRQF_SHARED,
+                                                WIL_NAME,
+                                                wil);
+#endif
+       }
if (rc)
return rc;

Code generation time:

real    1m6.023s
user    10m0.276s
sys     0m26.196s

$ time ckmake --allyesconfig
1   2.6.25              [  OK  ]
2   2.6.26              [  OK  ]
3   2.6.27              [  OK  ]
4   2.6.28              [  OK  ]
5   2.6.29              [  OK  ]
6   2.6.30              [  OK  ]
7   2.6.31              [  OK  ]
8   2.6.32              [  OK  ]
9   2.6.33              [  OK  ]
10  2.6.34              [  OK  ]
11  2.6.35              [  OK  ]
12  2.6.36              [  OK  ]
13  2.6.37              [  OK  ]
14  2.6.38              [  OK  ]
15  2.6.39              [  OK  ]
16  3.0.101             [  OK  ]
17  3.1.10              [  OK  ]
18  3.2.54              [  OK  ]
19  3.3.8               [  OK  ]
20  3.4.79              [  OK  ]
21  3.5.7               [  OK  ]
22  3.6.11              [  OK  ]
23  3.7.10              [  OK  ]
24  3.8.13              [  OK  ]
25  3.9.11              [  OK  ]
26  3.10.29             [  OK  ]
27  3.11.10             [  OK  ]
28  3.12.10             [  OK  ]
29  3.13.2              [  OK  ]
30  3.14-rc1            [  OK  ]

real    41m12.052s
user    1125m30.996s
sys     151m39.096s

Cc: Peter Senna <peter.senna@gmail.com>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: Gilles Muller <Gilles.Muller@lip6.fr>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
12 files changed:
patches/collateral-evolutions/network/0015-threaded-irq.cocci [new file with mode: 0644]
patches/collateral-evolutions/network/0015-threaded-irq/INFO [new file with mode: 0644]
patches/collateral-evolutions/network/0015-threaded-irq/drivers_net_wireless_iwlwifi_iwl-trans.patch [new file with mode: 0644]
patches/collateral-evolutions/network/0016-threaded-irq-one-shot.patch [new file with mode: 0644]
patches/collateral-evolutions/network/09-threaded-irq/INFO [deleted file]
patches/collateral-evolutions/network/09-threaded-irq/drivers_net_wireless_b43_b43.patch [deleted file]
patches/collateral-evolutions/network/09-threaded-irq/drivers_net_wireless_b43_main.patch [deleted file]
patches/collateral-evolutions/network/09-threaded-irq/drivers_net_wireless_iwlwifi_pcie_internal.patch [deleted file]
patches/collateral-evolutions/network/09-threaded-irq/drivers_net_wireless_iwlwifi_pcie_trans.patch [deleted file]
patches/collateral-evolutions/network/09-threaded-irq/drivers_net_wireless_ti_wlcore_main.patch [deleted file]
patches/collateral-evolutions/network/09-threaded-irq/drivers_net_wireless_ti_wlcore_main_extra.patch [deleted file]
patches/collateral-evolutions/network/09-threaded-irq/drivers_net_wireless_ti_wlcore_wlcore.patch [deleted file]