All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] backports: move us up to next-20130419
@ 2013-05-11  0:26 Luis R. Rodriguez
  2013-05-11  0:26 ` [PATCH 01/12] backports: make compat module use subsys_initcall() Luis R. Rodriguez
                   ` (11 more replies)
  0 siblings, 12 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:26 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

As far as compilation for all of the drivers is concerned
we're currently at next-20130409, this series bumps us up to
next-20130419.

I do have patches that takes us up to next-20130423 as well but those
are currently being tested. I'll post them as a separate series in
case anyone wants to help. I'll be out for a bit now.

Note these are the next tags we've tested or are testing:

next-20130402 OK
next-20130403 OK
next-20130404
next-20130405 OK
next-20130408 OK
next-20130409 OK
next-20130410 OK
next-20130411
next-20130412
next-20130415 OK
next-20130416
next-20130417
next-20130418
next-20130419 OK
next-20130422
next-20130423 testing -- I'll post patches as RFTs
next-20130424
next-20130426
 ~~ around here Linus blessed v3.9 ~~
next-20130429
next-20130430

We want to be sure to atomically test next-20130424,
next-20130426, next-20130429 and next-20130430 given
that one of those will serve as a branch point for
our linux-3.10.y stable branch once Linus releases
v3.10.

Luis R. Rodriguez (12):
  backports: make compat module use subsys_initcall()
  backports: backport dma-buf debugfs support
  compat: backport radix-tree bit optimized iterator
  backports: copy brcmfmac-sdio.h
  backports: remove brcmsmac / brcmutil Makefile patches
  backports: remove ath5k trace fix patch
  backports: enable the CONFIG_DRM_QXL driver on >= v3.3
  backports: enable REGULATOR_WM8994 only on >= 3.8
  backports: refresh patches for next-20130415
  backports: fix atl1.c dev-pm-ops patch
  backports: backport new bluetooth hidp session-management
  backports: refresh patches for next-20130419

 backport/backport-include/linux/radix-tree.h       |  218 ++++++++++++++++
 backport/compat/Kconfig                            |    7 +
 backport/compat/Makefile                           |    1 +
 backport/compat/backports.h                        |   14 ++
 backport/compat/lib-radix-tree-helpers.c           |  266 ++++++++++++++++++++
 backport/compat/main.c                             |    7 +-
 copy-list                                          |    1 +
 dependencies                                       |    8 +-
 patches/backport-adjustments/dma-buf.patch         |   30 ++-
 .../network/0001-netdev_ops/atlx.patch             |    2 +-
 .../network/0001-netdev_ops/ipw2100.patch          |    2 +-
 .../network/0001-netdev_ops/mac80211.patch         |    6 +-
 .../network/0001-netdev_ops/mac80211_hwsim.patch   |    2 +-
 .../network/0001-netdev_ops/usbnet.patch           |    2 +-
 .../mac80211.patch                                 |    4 +-
 .../0005-netlink-portid/mac80211_hwsim.patch       |    4 +-
 .../include_net_cfg80211.patch                     |    2 +-
 .../drivers_net_ethernet_atheros_atlx_atl1.patch   |   10 +-
 .../drivers_net_wireless_iwlwifi_pcie_drv.patch    |    4 +-
 .../drivers_net_wireless_ipw2x00_ipw2100.patch     |    2 +-
 .../16-bluetooth/net_bluetooth_hci_sysfs.patch     |    2 +-
 .../16-bluetooth/net_bluetooth_hidp_core.patch     |  109 ++++----
 .../16-bluetooth/net_bluetooth_hidp_sock.patch     |    2 +-
 .../network/16-bluetooth/net_bluetooth_sco.patch   |    2 +-
 .../17-netdev-queue/net_mac80211_iface.patch       |    4 +-
 .../drivers_net_wireless_adm8211.patch             |    2 +-
 .../drivers_net_wireless_ath_carl9170_main.patch   |    2 +-
 .../drivers_net_wireless_mwl8k.patch               |    6 +-
 .../include_net_mac80211.patch                     |    2 +-
 .../net_mac80211_ieee80211_i.patch                 |    2 +-
 .../net_mac80211_iface.patch                       |    6 +-
 .../25-multicast-list_head/net_mac80211_main.patch |    2 +-
 ..._wireless_brcm80211_brcmfmac_bcmsdh_sdmmc.patch |   10 +-
 .../network/36-workqueue/net_mac80211_main.patch   |    2 +-
 .../drivers_net_ethernet_atheros_atlx_atl1.patch   |    8 +-
 .../net_bluetooth_hci_core.patch                   |    2 +-
 .../drivers_net_ethernet_atheros_atlx_atl1.patch   |    2 +-
 .../drivers_bluetooth_btusb.patch                  |    2 +-
 .../drivers_net_usb_cdc_ether.patch                |    2 +-
 .../network/72-brcm80211-makefiles/brcmsmac.patch  |   25 --
 .../network/72-brcm80211-makefiles/brcmutil.patch  |   15 --
 .../network/73-ath5k-tracing/ath5k.patch           |   21 --
 42 files changed, 644 insertions(+), 178 deletions(-)
 create mode 100644 backport/backport-include/linux/radix-tree.h
 create mode 100644 backport/compat/backports.h
 create mode 100644 backport/compat/lib-radix-tree-helpers.c
 delete mode 100644 patches/collateral-evolutions/network/72-brcm80211-makefiles/brcmsmac.patch
 delete mode 100644 patches/collateral-evolutions/network/72-brcm80211-makefiles/brcmutil.patch
 delete mode 100644 patches/collateral-evolutions/network/73-ath5k-tracing/ath5k.patch

-- 
1.7.10.4


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

* [PATCH 01/12] backports: make compat module use subsys_initcall()
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
@ 2013-05-11  0:26 ` Luis R. Rodriguez
  2013-05-13 12:02   ` Johannes Berg
  2013-05-11  0:26 ` [PATCH 02/12] backports: backport dma-buf debugfs support Luis R. Rodriguez
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:26 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez, pstew

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

This is a no-op for the modular use case of the
backports project but by enabling this it allows
for developers a way to embed the backports releases
onto a target source Linux directory, with obvious
pending modifications, by adding our backport_init()
onto the target kernel's init/main.c start_kernel().

Enable this theoretical use case. Hackers welcome to
go play on this theoretical integration strategy now.

Cc: pstew@chromium.org
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 backport/compat/main.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/backport/compat/main.c b/backport/compat/main.c
index 90ce751..b7dff1a 100644
--- a/backport/compat/main.c
+++ b/backport/compat/main.c
@@ -69,7 +69,7 @@ static int __init backport_init(void)
 
         return 0;
 }
-module_init(backport_init);
+subsys_initcall(backport_init);
 
 static void __exit backport_exit(void)
 {
@@ -78,5 +78,4 @@ static void __exit backport_exit(void)
 
         return;
 }
-module_exit(backport_exit);
-
+__exitcall(backport_exit);
-- 
1.7.10.4


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

* [PATCH 02/12] backports: backport dma-buf debugfs support
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
  2013-05-11  0:26 ` [PATCH 01/12] backports: make compat module use subsys_initcall() Luis R. Rodriguez
@ 2013-05-11  0:26 ` Luis R. Rodriguez
  2013-05-11  0:26 ` [PATCH 03/12] compat: backport radix-tree bit optimized iterator Luis R. Rodriguez
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:26 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

Commit 5a753a4 on next-20130410 extended the
dma-buf implementation to add debugfs support.
We backport support for this by adding its own
subsys_init() call as a helper to the backport
module (still called compat) respective subsys_init()
call, backport_init(). For kernels where this is
already supported this is a no-op.

This didn't make it to v3.9 but I see Linus has
already merged this as part of the merge window
what will be v3.10.

This also refreshes patches for next-20130410 and
I supply the refresh as part of this same patch
given that the only patch refreshed was the one
modifyin the drivers/base/dma-buf.c.

commit 5a753a49fb7e17fa83ea9cf39c7b1a902363d828
Author: Sumit Semwal <sumit.semwal@linaro.org>
Date:   Thu Apr 4 11:44:37 2013 +0530

    dma-buf: Add debugfs support

    Add debugfs support to make it easier to print debug information
    about the dma-buf buffers.

    Cc: Dave Airlie <airlied@redhat.com>
     [minor fixes on init and warning fix]
    Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>

$ ckmake --allyesconfig

1   2.6.24              [  OK  ]
2   2.6.25              [  OK  ]
3   2.6.26              [  OK  ]
4   2.6.27              [  OK  ]
5   2.6.28              [  OK  ]
6   2.6.29              [  OK  ]
7   2.6.30              [  OK  ]
8   2.6.31              [  OK  ]
9   2.6.32              [  OK  ]
10  2.6.33              [  OK  ]
11  2.6.34              [  OK  ]
12  2.6.35              [  OK  ]
13  2.6.36              [  OK  ]
14  2.6.37              [  OK  ]
15  2.6.38              [  OK  ]
16  2.6.39              [  OK  ]
17  3.0.76              [  OK  ]
18  3.1.10              [  OK  ]
19  3.2.44              [  OK  ]
20  3.3.8               [  OK  ]
21  3.4.43              [  OK  ]
22  3.5.7               [  OK  ]
23  3.6.11              [  OK  ]
24  3.7.10              [  OK  ]
25  3.8.11              [  OK  ]
26  3.9.0               [  OK  ]

real    30m10.328s
user    797m1.841s
sys     125m15.978s

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 backport/compat/backports.h                |   14 +++++++++++++
 backport/compat/main.c                     |    2 ++
 patches/backport-adjustments/dma-buf.patch |   30 +++++++++++++++++++++++-----
 3 files changed, 41 insertions(+), 5 deletions(-)
 create mode 100644 backport/compat/backports.h

diff --git a/backport/compat/backports.h b/backport/compat/backports.h
new file mode 100644
index 0000000..b609058
--- /dev/null
+++ b/backport/compat/backports.h
@@ -0,0 +1,14 @@
+#ifndef LINUX_BACKPORTS_PRIVATE_H
+#define LINUX_BACKPORTS_PRIVATE_H
+
+#include <linux/version.h>
+
+#ifdef CPTCFG_BACKPORT_BUILD_DMA_SHARED_BUFFER
+int __init dma_buf_init(void);
+void __exit dma_buf_deinit(void);
+#else
+static inline int __init dma_buf_init(void) { return 0; }
+static inline void __exit dma_buf_deinit(void) { }
+#endif
+
+#endif /* LINUX_BACKPORTS_PRIVATE_H */
diff --git a/backport/compat/main.c b/backport/compat/main.c
index b7dff1a..b4c021b 100644
--- a/backport/compat/main.c
+++ b/backport/compat/main.c
@@ -2,6 +2,7 @@
 #include <linux/pm_qos.h>
 #include <linux/workqueue.h>
 #include "compat-2.6.34.h"
+#include "backports.h"
 
 MODULE_AUTHOR("Luis R. Rodriguez");
 MODULE_DESCRIPTION("Kernel backport module");
@@ -55,6 +56,7 @@ static int __init backport_init(void)
 	backport_pm_qos_power_init();
 	backport_system_workqueue_create();
 	backport_init_mmc_pm_flags();
+	dma_buf_init();
 
 	printk(KERN_INFO "Loading modules backported from " BACKPORTED_KERNEL_NAME
 #ifndef BACKPORTS_GIT_TRACKED
diff --git a/patches/backport-adjustments/dma-buf.patch b/patches/backport-adjustments/dma-buf.patch
index a0f3393..75d7b73 100644
--- a/patches/backport-adjustments/dma-buf.patch
+++ b/patches/backport-adjustments/dma-buf.patch
@@ -8,12 +8,12 @@
 +#include <linux/fdtable.h>
 +#include <linux/bitops.h>
 +#include <linux/sched.h>
+ #include <linux/debugfs.h>
+ #include <linux/seq_file.h>
  
- static inline int is_dma_buf_file(struct file *);
- 
-@@ -126,6 +130,27 @@ struct dma_buf *dma_buf_export(void *pri
+@@ -147,6 +151,27 @@ struct dma_buf *dma_buf_export_named(voi
  }
- EXPORT_SYMBOL_GPL(dma_buf_export);
+ EXPORT_SYMBOL_GPL(dma_buf_export_named);
  
 +static void dma_buf_fd_set_flag(int fd, int flags)
 +{
@@ -39,7 +39,7 @@
  
  /**
   * dma_buf_fd - returns a file descriptor for the given dma_buf
-@@ -141,9 +166,10 @@ int dma_buf_fd(struct dma_buf *dmabuf, i
+@@ -162,9 +187,10 @@ int dma_buf_fd(struct dma_buf *dmabuf, i
  	if (!dmabuf || !dmabuf->file)
  		return -EINVAL;
  
@@ -51,3 +51,23 @@
  
  	fd_install(fd, dmabuf->file);
  
+@@ -696,17 +722,15 @@ static inline void dma_buf_uninit_debugf
+ }
+ #endif
+ 
+-static int __init dma_buf_init(void)
++int __init dma_buf_init(void)
+ {
+ 	mutex_init(&db_list.lock);
+ 	INIT_LIST_HEAD(&db_list.head);
+ 	dma_buf_init_debugfs();
+ 	return 0;
+ }
+-subsys_initcall(dma_buf_init);
+ 
+-static void __exit dma_buf_deinit(void)
++void __exit dma_buf_deinit(void)
+ {
+ 	dma_buf_uninit_debugfs();
+ }
+-__exitcall(dma_buf_deinit);
-- 
1.7.10.4


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

* [PATCH 03/12] compat: backport radix-tree bit optimized iterator
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
  2013-05-11  0:26 ` [PATCH 01/12] backports: make compat module use subsys_initcall() Luis R. Rodriguez
  2013-05-11  0:26 ` [PATCH 02/12] backports: backport dma-buf debugfs support Luis R. Rodriguez
@ 2013-05-11  0:26 ` Luis R. Rodriguez
  2013-05-11  0:26 ` [PATCH 04/12] backports: copy brcmfmac-sdio.h Luis R. Rodriguez
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:26 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

This backport's Konstantin's radix-tree bit optimized
iterator, 78c1d7848, added on v3.4. This is used by a new
drivers in the future. The new bit optimized iterator relies
on the stack optimization introduced via e2bdb933 added as of
v3.3. Backporting the bit optimized iterator requires
adjusting it to the old v3.2 radix_tree_node which is not
implemented here. For kernels v3.3 - v3.3 we can backport
the bit optimized iterator given that the radix_tree_node
did not changed between v3.3 - v3.4, in fact it hasn't
changed even up to v3.10. The backport relies on the same
helpers and inlines present on v3.3-v3.10 to implement
radix_tree_next_chunk().

This was tested as of next-20130410.

Throw the helper into compat config build option
CPTCFG_BACKPORT_BUILD_RADIX_HELPERS only to be built
on v3.3 right now unless someone really wants to
backport 78c1d7848 support onto v3.2.

mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 78c1d7848
v3.4-rc2~15^2~26

mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains e2bdb933
v3.3-rc1~81^2~8

ckmake below, and then the commit log references above.

== ckmake-report.log ==

1   2.6.24              [  OK  ]
2   2.6.25              [  OK  ]
3   2.6.26              [  OK  ]
4   2.6.27              [  OK  ]
5   2.6.28              [  OK  ]
6   2.6.29              [  OK  ]
7   2.6.30              [  OK  ]
8   2.6.31              [  OK  ]
9   2.6.32              [  OK  ]
10  2.6.33              [  OK  ]
11  2.6.34              [  OK  ]
12  2.6.35              [  OK  ]
13  2.6.36              [  OK  ]
14  2.6.37              [  OK  ]
15  2.6.38              [  OK  ]
16  2.6.39              [  OK  ]
17  3.0.76              [  OK  ]
18  3.1.10              [  OK  ]
19  3.2.44              [  OK  ]
20  3.3.8               [  OK  ]
21  3.4.43              [  OK  ]
22  3.5.7               [  OK  ]
23  3.6.11              [  OK  ]
24  3.7.10              [  OK  ]
25  3.8.11              [  OK  ]
26  3.9.0               [  OK  ]

real    30m37.773s
user    809m37.644s
sys     126m30.806s

commit 78c1d78488a3c45685d993130c9f17102dc79a54
Author: Konstantin Khlebnikov <khlebnikov@openvz.org>
Date:   Wed Mar 28 14:42:53 2012 -0700

    radix-tree: introduce bit-optimized iterator

    A series of radix tree cleanups, and usage of them in the core pagecache
    code.

    Micro-benchmark:

    lookup 14 slots (typical page-vector size)
    in radix-tree there earch <step> slot filled and tagged
    before/after - nsec per full scan through tree

    * Intel Sandy Bridge i7-2620M 4Mb L3
    New code always faster

    * AMD Athlon 6000+ 2x1Mb L2, without L3
    New code generally faster,
    Minor degradation (marked with "*") for huge sparse trees

    * i386 on Sandy Bridge
    New code faster for common cases: tagged and dense trees.
    Some degradations for non-tagged lookup on sparse trees.

    Ideally, there might help __ffs() analog for searching first non-zero
    long element in array, gcc sometimes cannot optimize this loop corretly.

    Numbers:

    CPU: Intel Sandy Bridge i7-2620M 4Mb L3

    radix-tree with 1024 slots:

    tagged lookup

    step  1      before  7156        after  3613
    step  2      before  5399        after  2696
    step  3      before  4779        after  1928
    step  4      before  4456        after  1429
    step  5      before  4292        after  1213
    step  6      before  4183        after  1052
    step  7      before  4157        after  951
    step  8      before  4016        after  812
    step  9      before  3952        after  851
    step  10     before  3937        after  732
    step  11     before  4023        after  709
    step  12     before  3872        after  657
    step  13     before  3892        after  633
    step  14     before  3720        after  591
    step  15     before  3879        after  578
    step  16     before  3561        after  513

    normal lookup

    step  1      before  4266       after  3301
    step  2      before  2695       after  2129
    step  3      before  2083       after  1712
    step  4      before  1801       after  1534
    step  5      before  1628       after  1313
    step  6      before  1551       after  1263
    step  7      before  1475       after  1185
    step  8      before  1432       after  1167
    step  9      before  1373       after  1092
    step  10     before  1339       after  1134
    step  11     before  1292       after  1056
    step  12     before  1319       after  1030
    step  13     before  1276       after  1004
    step  14     before  1256       after  987
    step  15     before  1228       after  992
    step  16     before  1247       after  999

    radix-tree with 1024*1024*128 slots:

    tagged lookup

commit e2bdb933ab8b7db71c318a4ddcf78a9fffd61ecb
Author: Hugh Dickins <hughd@google.com>
Date:   Thu Jan 12 17:20:41 2012 -0800

    radix_tree: take radix_tree_path off stack

    Down, down in the deepest depths of GFP_NOIO page reclaim, we have
    shrink_page_list() calling __remove_mapping() calling __delete_from_
    swap_cache() or __delete_from_page_cache().

    You would not expect those to need much stack, but in fact they call
    radix_tree_delete(): which declares a 192-byte radix_tree_path array on
    its stack (to record the node,offsets it visits when descending, in case
    it needs to ascend to update them).  And if any tag is still set [1],
    that calls radix_tree_tag_clear(), which declares a further such
    192-byte radix_tree_path array on the stack.  (At least we have
    interrupts disabled here, so won't then be pushing registers too.)

    That was probably a good choice when most users were 32-bit (array of
    half the size), and adding fields to radix_tree_node would have bloated
    it unnecessarily.  But nowadays many are 64-bit, and each
    radix_tree_node contains a struct rcu_head, which is only used when
    freeing; whereas the radix_tree_path info is only used for updating the
    tree (deleting, clearing tags or setting tags if tagged) when a lock
    must be held, of no interest when accessing the tree locklessly.

    So add a parent pointer to the radix_tree_node, in union with the
    rcu_head, and remove all uses of the radix_tree_path.  There would be
    space in that union to save the offset when descending as before (we can
    argue that a lock must already be held to exclude other users), but
    recalculating it when ascending is both easy (a constant shift and a
    constant mask) and uncommon, so it seems better just to do that.

    Two little optimizations: no need to decrement height when descending,
    adjusting shift is enough; and once radix_tree_tag_if_tagged() has set
    tag on a node and its ancestors, it need not ascend from that node
    again.

    perf on the radix tree test harness reports radix_tree_insert() as 2%
    slower (now having to set parent), but radix_tree_delete() 24% faster.
    Surely that's an exaggeration from rtth's artificially low map shift 3,
    but forcing it back to 6 still rates radix_tree_delete() 8% faster.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 backport/backport-include/linux/radix-tree.h |  218 +++++++++++++++++++++
 backport/compat/Kconfig                      |    7 +
 backport/compat/Makefile                     |    1 +
 backport/compat/lib-radix-tree-helpers.c     |  266 ++++++++++++++++++++++++++
 4 files changed, 492 insertions(+)
 create mode 100644 backport/backport-include/linux/radix-tree.h
 create mode 100644 backport/compat/lib-radix-tree-helpers.c

diff --git a/backport/backport-include/linux/radix-tree.h b/backport/backport-include/linux/radix-tree.h
new file mode 100644
index 0000000..6ca7c05
--- /dev/null
+++ b/backport/backport-include/linux/radix-tree.h
@@ -0,0 +1,218 @@
+/*
+ * Copyright (C) 2013 Konstantin Khlebnikov
+ * Copyright (C) 2013 Luis R. Rodriguez <mcgrof@do-not-panic.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2, or (at
+ * your option) any later version.
+ *
+ */
+#ifndef BACKPORT_LINUX_RADIX_TREE_H
+#define BACKPORT_LINUX_RADIX_TREE_H
+
+#include_next <linux/radix-tree.h>
+
+#ifdef CPTCFG_BACKPORT_BUILD_RADIX_HELPERS
+
+/**
+ * struct radix_tree_iter - radix tree iterator state
+ *
+ * @index:	index of current slot
+ * @next_index:	next-to-last index for this chunk
+ * @tags:	bit-mask for tag-iterating
+ *
+ * This radix tree iterator works in terms of "chunks" of slots.  A chunk is a
+ * subinterval of slots contained within one radix tree leaf node.  It is
+ * described by a pointer to its first slot and a struct radix_tree_iter
+ * which holds the chunk's position in the tree and its size.  For tagged
+ * iteration radix_tree_iter also holds the slots' bit-mask for one chosen
+ * radix tree tag.
+ */
+struct radix_tree_iter {
+	unsigned long	index;
+	unsigned long	next_index;
+	unsigned long	tags;
+};
+
+#define RADIX_TREE_ITER_TAG_MASK	0x00FF	/* tag index in lower byte */
+#define RADIX_TREE_ITER_TAGGED		0x0100	/* lookup tagged slots */
+#define RADIX_TREE_ITER_CONTIG		0x0200	/* stop at first hole */
+
+/**
+ * radix_tree_iter_init - initialize radix tree iterator
+ *
+ * @iter:	pointer to iterator state
+ * @start:	iteration starting index
+ * Returns:	NULL
+ */
+static __always_inline void **
+radix_tree_iter_init(struct radix_tree_iter *iter, unsigned long start)
+{
+	/*
+	 * Leave iter->tags uninitialized. radix_tree_next_chunk() will fill it
+	 * in the case of a successful tagged chunk lookup.  If the lookup was
+	 * unsuccessful or non-tagged then nobody cares about ->tags.
+	 *
+	 * Set index to zero to bypass next_index overflow protection.
+	 * See the comment in radix_tree_next_chunk() for details.
+	 */
+	iter->index = 0;
+	iter->next_index = start;
+	return NULL;
+}
+
+/**
+ * radix_tree_next_chunk - find next chunk of slots for iteration
+ *
+ * @root:	radix tree root
+ * @iter:	iterator state
+ * @flags:	RADIX_TREE_ITER_* flags and tag index
+ * Returns:	pointer to chunk first slot, or NULL if there no more left
+ *
+ * This function looks up the next chunk in the radix tree starting from
+ * @iter->next_index.  It returns a pointer to the chunk's first slot.
+ * Also it fills @iter with data about chunk: position in the tree (index),
+ * its end (next_index), and constructs a bit mask for tagged iterating (tags).
+ */
+void **radix_tree_next_chunk(struct radix_tree_root *root,
+			     struct radix_tree_iter *iter, unsigned flags);
+
+/**
+ * radix_tree_chunk_size - get current chunk size
+ *
+ * @iter:	pointer to radix tree iterator
+ * Returns:	current chunk size
+ */
+static __always_inline unsigned
+radix_tree_chunk_size(struct radix_tree_iter *iter)
+{
+	return iter->next_index - iter->index;
+}
+
+/**
+ * radix_tree_next_slot - find next slot in chunk
+ *
+ * @slot:	pointer to current slot
+ * @iter:	pointer to interator state
+ * @flags:	RADIX_TREE_ITER_*, should be constant
+ * Returns:	pointer to next slot, or NULL if there no more left
+ *
+ * This function updates @iter->index in the case of a successful lookup.
+ * For tagged lookup it also eats @iter->tags.
+ */
+static __always_inline void **
+radix_tree_next_slot(void **slot, struct radix_tree_iter *iter, unsigned flags)
+{
+	if (flags & RADIX_TREE_ITER_TAGGED) {
+		iter->tags >>= 1;
+		if (likely(iter->tags & 1ul)) {
+			iter->index++;
+			return slot + 1;
+		}
+		if (!(flags & RADIX_TREE_ITER_CONTIG) && likely(iter->tags)) {
+			unsigned offset = __ffs(iter->tags);
+
+			iter->tags >>= offset;
+			iter->index += offset + 1;
+			return slot + offset + 1;
+		}
+	} else {
+		unsigned size = radix_tree_chunk_size(iter) - 1;
+
+		while (size--) {
+			slot++;
+			iter->index++;
+			if (likely(*slot))
+				return slot;
+			if (flags & RADIX_TREE_ITER_CONTIG) {
+				/* forbid switching to the next chunk */
+				iter->next_index = 0;
+				break;
+			}
+		}
+	}
+	return NULL;
+}
+
+/**
+ * radix_tree_for_each_chunk - iterate over chunks
+ *
+ * @slot:	the void** variable for pointer to chunk first slot
+ * @root:	the struct radix_tree_root pointer
+ * @iter:	the struct radix_tree_iter pointer
+ * @start:	iteration starting index
+ * @flags:	RADIX_TREE_ITER_* and tag index
+ *
+ * Locks can be released and reacquired between iterations.
+ */
+#define radix_tree_for_each_chunk(slot, root, iter, start, flags)	\
+	for (slot = radix_tree_iter_init(iter, start) ;			\
+	      (slot = radix_tree_next_chunk(root, iter, flags)) ;)
+
+/**
+ * radix_tree_for_each_chunk_slot - iterate over slots in one chunk
+ *
+ * @slot:	the void** variable, at the beginning points to chunk first slot
+ * @iter:	the struct radix_tree_iter pointer
+ * @flags:	RADIX_TREE_ITER_*, should be constant
+ *
+ * This macro is designed to be nested inside radix_tree_for_each_chunk().
+ * @slot points to the radix tree slot, @iter->index contains its index.
+ */
+#define radix_tree_for_each_chunk_slot(slot, iter, flags)		\
+	for (; slot ; slot = radix_tree_next_slot(slot, iter, flags))
+
+/**
+ * radix_tree_for_each_slot - iterate over non-empty slots
+ *
+ * @slot:	the void** variable for pointer to slot
+ * @root:	the struct radix_tree_root pointer
+ * @iter:	the struct radix_tree_iter pointer
+ * @start:	iteration starting index
+ *
+ * @slot points to radix tree slot, @iter->index contains its index.
+ */
+#define radix_tree_for_each_slot(slot, root, iter, start)		\
+	for (slot = radix_tree_iter_init(iter, start) ;			\
+	     slot || (slot = radix_tree_next_chunk(root, iter, 0)) ;	\
+	     slot = radix_tree_next_slot(slot, iter, 0))
+
+/**
+ * radix_tree_for_each_contig - iterate over contiguous slots
+ *
+ * @slot:	the void** variable for pointer to slot
+ * @root:	the struct radix_tree_root pointer
+ * @iter:	the struct radix_tree_iter pointer
+ * @start:	iteration starting index
+ *
+ * @slot points to radix tree slot, @iter->index contains its index.
+ */
+#define radix_tree_for_each_contig(slot, root, iter, start)		\
+	for (slot = radix_tree_iter_init(iter, start) ;			\
+	     slot || (slot = radix_tree_next_chunk(root, iter,		\
+				RADIX_TREE_ITER_CONTIG)) ;		\
+	     slot = radix_tree_next_slot(slot, iter,			\
+				RADIX_TREE_ITER_CONTIG))
+
+/**
+ * radix_tree_for_each_tagged - iterate over tagged slots
+ *
+ * @slot:	the void** variable for pointer to slot
+ * @root:	the struct radix_tree_root pointer
+ * @iter:	the struct radix_tree_iter pointer
+ * @start:	iteration starting index
+ * @tag:	tag index
+ *
+ * @slot points to radix tree slot, @iter->index contains its index.
+ */
+#define radix_tree_for_each_tagged(slot, root, iter, start, tag)	\
+	for (slot = radix_tree_iter_init(iter, start) ;			\
+	     slot || (slot = radix_tree_next_chunk(root, iter,		\
+			      RADIX_TREE_ITER_TAGGED | tag)) ;		\
+	     slot = radix_tree_next_slot(slot, iter,			\
+				RADIX_TREE_ITER_TAGGED))
+
+#endif /* CPTCFG_BACKPORT_BUILD_RADIX_HELPERS */
+
+#endif /* BACKPORT_LINUX_RADIX_TREE_H */
diff --git a/backport/compat/Kconfig b/backport/compat/Kconfig
index 215de8e..e2f0cdd 100644
--- a/backport/compat/Kconfig
+++ b/backport/compat/Kconfig
@@ -185,6 +185,13 @@ config BACKPORT_LEDS_CLASS
 config BACKPORT_LEDS_TRIGGERS
 	bool
 
+config BACKPORT_BUILD_RADIX_HELPERS
+	bool
+	# You have selected to build backported DRM drivers
+	# Build only if on < 3.4
+	depends on DRM && BACKPORT_KERNEL_3_4
+	default y if BACKPORT_USERSEL_BUILD_ALL
+
 config BACKPORT_USERSEL_BUILD_ALL
 	bool "Build all compat code"
 	help
diff --git a/backport/compat/Makefile b/backport/compat/Makefile
index 19d4d2d..2ab3169 100644
--- a/backport/compat/Makefile
+++ b/backport/compat/Makefile
@@ -38,3 +38,4 @@ compat-$(CPTCFG_BACKPORT_KERNEL_3_9) += compat-3.9.o
 compat-$(CPTCFG_BACKPORT_BUILD_KFIFO) += kfifo.o
 compat-$(CPTCFG_BACKPORT_BUILD_GENERIC_ATOMIC64) += compat_atomic.o
 compat-$(CPTCFG_BACKPORT_BUILD_DMA_SHARED_HELPERS) += dma-shared-helpers.o
+compat-$(CPTCFG_BACKPORT_BUILD_RADIX_HELPERS) += lib-radix-tree-helpers.o
diff --git a/backport/compat/lib-radix-tree-helpers.c b/backport/compat/lib-radix-tree-helpers.c
new file mode 100644
index 0000000..837de04
--- /dev/null
+++ b/backport/compat/lib-radix-tree-helpers.c
@@ -0,0 +1,266 @@
+/*
+ * Copyright (C) 2013 Konstantin Khlebnikov
+ * Copyright (c) 2013 Luis R. Rodriguez <mcgrof@do-not-panic.com>
+ *
+ * Backports radix_tree_next_chunk()
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2, or (at
+ * your option) any later version.
+ */
+
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/export.h>
+#include <linux/radix-tree.h>
+#include <linux/percpu.h>
+#include <linux/slab.h>
+#include <linux/notifier.h>
+#include <linux/cpu.h>
+#include <linux/string.h>
+#include <linux/bitops.h>
+#include <linux/rcupdate.h>
+
+#ifdef __KERNEL__
+#define RADIX_TREE_MAP_SHIFT	(CONFIG_BASE_SMALL ? 4 : 6)
+#else
+#define RADIX_TREE_MAP_SHIFT	3	/* For more stressful testing */
+#endif
+
+#define RADIX_TREE_MAP_SIZE	(1UL << RADIX_TREE_MAP_SHIFT)
+#define RADIX_TREE_MAP_MASK	(RADIX_TREE_MAP_SIZE-1)
+
+#define RADIX_TREE_TAG_LONGS	\
+	((RADIX_TREE_MAP_SIZE + BITS_PER_LONG - 1) / BITS_PER_LONG)
+
+struct radix_tree_node {
+	unsigned int	height;		/* Height from the bottom */
+	unsigned int	count;
+	union {
+		struct radix_tree_node *parent;	/* Used when ascending tree */
+		struct rcu_head	rcu_head;	/* Used when freeing node */
+	};
+	void __rcu	*slots[RADIX_TREE_MAP_SIZE];
+	unsigned long	tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS];
+};
+
+static inline void *ptr_to_indirect(void *ptr)
+{
+	return (void *)((unsigned long)ptr | RADIX_TREE_INDIRECT_PTR);
+}
+
+static inline void *indirect_to_ptr(void *ptr)
+{
+	return (void *)((unsigned long)ptr & ~RADIX_TREE_INDIRECT_PTR);
+}
+
+static inline gfp_t root_gfp_mask(struct radix_tree_root *root)
+{
+	return root->gfp_mask & __GFP_BITS_MASK;
+}
+
+static inline void tag_set(struct radix_tree_node *node, unsigned int tag,
+		int offset)
+{
+	__set_bit(offset, node->tags[tag]);
+}
+
+static inline void tag_clear(struct radix_tree_node *node, unsigned int tag,
+		int offset)
+{
+	__clear_bit(offset, node->tags[tag]);
+}
+
+static inline int tag_get(struct radix_tree_node *node, unsigned int tag,
+		int offset)
+{
+	return test_bit(offset, node->tags[tag]);
+}
+
+static inline void root_tag_set(struct radix_tree_root *root, unsigned int tag)
+{
+	root->gfp_mask |= (__force gfp_t)(1 << (tag + __GFP_BITS_SHIFT));
+}
+
+static inline void root_tag_clear(struct radix_tree_root *root, unsigned int tag)
+{
+	root->gfp_mask &= (__force gfp_t)~(1 << (tag + __GFP_BITS_SHIFT));
+}
+
+static inline void root_tag_clear_all(struct radix_tree_root *root)
+{
+	root->gfp_mask &= __GFP_BITS_MASK;
+}
+
+static inline int root_tag_get(struct radix_tree_root *root, unsigned int tag)
+{
+	return (__force unsigned)root->gfp_mask & (1 << (tag + __GFP_BITS_SHIFT));
+}
+
+/*
+ * Returns 1 if any slot in the node has this tag set.
+ * Otherwise returns 0.
+ */
+static inline int any_tag_set(struct radix_tree_node *node, unsigned int tag)
+{
+	int idx;
+	for (idx = 0; idx < RADIX_TREE_TAG_LONGS; idx++) {
+		if (node->tags[tag][idx])
+			return 1;
+	}
+	return 0;
+}
+
+/**
+ * radix_tree_find_next_bit - find the next set bit in a memory region
+ *
+ * @addr: The address to base the search on
+ * @size: The bitmap size in bits
+ * @offset: The bitnumber to start searching at
+ *
+ * Unrollable variant of find_next_bit() for constant size arrays.
+ * Tail bits starting from size to roundup(size, BITS_PER_LONG) must be zero.
+ * Returns next bit offset, or size if nothing found.
+ */
+static __always_inline unsigned long
+radix_tree_find_next_bit(const unsigned long *addr,
+			 unsigned long size, unsigned long offset)
+{
+	if (!__builtin_constant_p(size))
+		return find_next_bit(addr, size, offset);
+
+	if (offset < size) {
+		unsigned long tmp;
+
+		addr += offset / BITS_PER_LONG;
+		tmp = *addr >> (offset % BITS_PER_LONG);
+		if (tmp)
+			return __ffs(tmp) + offset;
+		offset = (offset + BITS_PER_LONG) & ~(BITS_PER_LONG - 1);
+		while (offset < size) {
+			tmp = *++addr;
+			if (tmp)
+				return __ffs(tmp) + offset;
+			offset += BITS_PER_LONG;
+		}
+	}
+	return size;
+}
+
+/**
+ * radix_tree_next_chunk - find next chunk of slots for iteration
+ *
+ * @root:	radix tree root
+ * @iter:	iterator state
+ * @flags:	RADIX_TREE_ITER_* flags and tag index
+ * Returns:	pointer to chunk first slot, or NULL if iteration is over
+ */
+void **radix_tree_next_chunk(struct radix_tree_root *root,
+			     struct radix_tree_iter *iter, unsigned flags)
+{
+	unsigned shift, tag = flags & RADIX_TREE_ITER_TAG_MASK;
+	struct radix_tree_node *rnode, *node;
+	unsigned long index, offset;
+
+	if ((flags & RADIX_TREE_ITER_TAGGED) && !root_tag_get(root, tag))
+		return NULL;
+
+	/*
+	 * Catch next_index overflow after ~0UL. iter->index never overflows
+	 * during iterating; it can be zero only at the beginning.
+	 * And we cannot overflow iter->next_index in a single step,
+	 * because RADIX_TREE_MAP_SHIFT < BITS_PER_LONG.
+	 *
+	 * This condition also used by radix_tree_next_slot() to stop
+	 * contiguous iterating, and forbid swithing to the next chunk.
+	 */
+	index = iter->next_index;
+	if (!index && iter->index)
+		return NULL;
+
+	rnode = rcu_dereference_raw(root->rnode);
+	if (radix_tree_is_indirect_ptr(rnode)) {
+		rnode = indirect_to_ptr(rnode);
+	} else if (rnode && !index) {
+		/* Single-slot tree */
+		iter->index = 0;
+		iter->next_index = 1;
+		iter->tags = 1;
+		return (void **)&root->rnode;
+	} else
+		return NULL;
+
+restart:
+	shift = (rnode->height - 1) * RADIX_TREE_MAP_SHIFT;
+	offset = index >> shift;
+
+	/* Index outside of the tree */
+	if (offset >= RADIX_TREE_MAP_SIZE)
+		return NULL;
+
+	node = rnode;
+	while (1) {
+		if ((flags & RADIX_TREE_ITER_TAGGED) ?
+				!test_bit(offset, node->tags[tag]) :
+				!node->slots[offset]) {
+			/* Hole detected */
+			if (flags & RADIX_TREE_ITER_CONTIG)
+				return NULL;
+
+			if (flags & RADIX_TREE_ITER_TAGGED)
+				offset = radix_tree_find_next_bit(
+						node->tags[tag],
+						RADIX_TREE_MAP_SIZE,
+						offset + 1);
+			else
+				while (++offset	< RADIX_TREE_MAP_SIZE) {
+					if (node->slots[offset])
+						break;
+				}
+			index &= ~((RADIX_TREE_MAP_SIZE << shift) - 1);
+			index += offset << shift;
+			/* Overflow after ~0UL */
+			if (!index)
+				return NULL;
+			if (offset == RADIX_TREE_MAP_SIZE)
+				goto restart;
+		}
+
+		/* This is leaf-node */
+		if (!shift)
+			break;
+
+		node = rcu_dereference_raw(node->slots[offset]);
+		if (node == NULL)
+			goto restart;
+		shift -= RADIX_TREE_MAP_SHIFT;
+		offset = (index >> shift) & RADIX_TREE_MAP_MASK;
+	}
+
+	/* Update the iterator state */
+	iter->index = index;
+	iter->next_index = (index | RADIX_TREE_MAP_MASK) + 1;
+
+	/* Construct iter->tags bit-mask from node->tags[tag] array */
+	if (flags & RADIX_TREE_ITER_TAGGED) {
+		unsigned tag_long, tag_bit;
+
+		tag_long = offset / BITS_PER_LONG;
+		tag_bit  = offset % BITS_PER_LONG;
+		iter->tags = node->tags[tag][tag_long] >> tag_bit;
+		/* This never happens if RADIX_TREE_TAG_LONGS == 1 */
+		if (tag_long < RADIX_TREE_TAG_LONGS - 1) {
+			/* Pick tags from next element */
+			if (tag_bit)
+				iter->tags |= node->tags[tag][tag_long + 1] <<
+						(BITS_PER_LONG - tag_bit);
+			/* Clip chunk size, here only BITS_PER_LONG tags */
+			iter->next_index = index + BITS_PER_LONG;
+		}
+	}
+
+	return node->slots + offset;
+}
+EXPORT_SYMBOL_GPL(radix_tree_next_chunk);
-- 
1.7.10.4


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

* [PATCH 04/12] backports: copy brcmfmac-sdio.h
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
                   ` (2 preceding siblings ...)
  2013-05-11  0:26 ` [PATCH 03/12] compat: backport radix-tree bit optimized iterator Luis R. Rodriguez
@ 2013-05-11  0:26 ` Luis R. Rodriguez
  2013-05-11  0:26 ` [PATCH 05/12] backports: remove brcmsmac / brcmutil Makefile patches Luis R. Rodriguez
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:26 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

On next-20130415 commit 668761ac0 added platform
specific data for brcmfmac for SDIO. Copy that
over. This is the first in a series of changes
required for next-20130415.

commit 668761ac01d6f5a36b8e5a24d4e154550e2c4c3b
Author: Hante Meuleman <meuleman@broadcom.com>
Date:   Fri Apr 12 10:55:55 2013 +0200

    brcmfmac: define and use platform specific data for SDIO.

    This patch adds support for platform specific data for SDIO
    fullmac devices. Currently OOB interrupts are configured by Kconfig
    BRCMFMAC_SDIO_OOB but that is now determined dynamically by checking
    availibility of platform data.

    Cc: Hauke Mehrtens <hauke@hauke-m.de>
    Reviewed-by: Arend Van Spriel <arend@broadcom.com>
    Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
    Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
    Reviewed-by: Piotr Haber <phaber@broadcom.com>
    Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
    Signed-off-by: Arend van Spriel <arend@broadcom.com>
    Signed-off-by: John W. Linville <linville@tuxdriver.com>

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 copy-list |    1 +
 1 file changed, 1 insertion(+)

diff --git a/copy-list b/copy-list
index 6db79a3..8b3de0c 100644
--- a/copy-list
+++ b/copy-list
@@ -27,6 +27,7 @@ include/linux/bcm47xx_wdt.h
 include/linux/usb/usbnet.h
 include/linux/usb/rndis_host.h
 include/linux/spi/libertas_spi.h
+include/linux/platform_data/brcmfmac-sdio.h
 
 include/uapi/linux/nl80211.h
 include/linux/rfkill.h -> include/linux/rfkill_backport.h
-- 
1.7.10.4


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

* [PATCH 05/12] backports: remove brcmsmac / brcmutil Makefile patches
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
                   ` (3 preceding siblings ...)
  2013-05-11  0:26 ` [PATCH 04/12] backports: copy brcmfmac-sdio.h Luis R. Rodriguez
@ 2013-05-11  0:26 ` Luis R. Rodriguez
  2013-05-11  0:26 ` [PATCH 06/12] backports: remove ath5k trace fix patch Luis R. Rodriguez
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:26 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

These are now upstream thanks to commit 8e8d4ff0 on
next-20130415.

commit 8e8d4ff051672d4a2939e7d6925c4acd234b0220
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Thu Apr 11 16:15:28 2013 +0200

    brcm80211: simplify makefiles

    This came up during my backporting work but it seems
    perfectly appropriate for the kernel as well.

    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Acked-by: Arend van Spriel <arend@broadcom.com>
    Signed-off-by: John W. Linville <linville@tuxdriver.com>

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 .../network/72-brcm80211-makefiles/brcmsmac.patch  |   25 --------------------
 .../network/72-brcm80211-makefiles/brcmutil.patch  |   15 ------------
 2 files changed, 40 deletions(-)
 delete mode 100644 patches/collateral-evolutions/network/72-brcm80211-makefiles/brcmsmac.patch
 delete mode 100644 patches/collateral-evolutions/network/72-brcm80211-makefiles/brcmutil.patch

diff --git a/patches/collateral-evolutions/network/72-brcm80211-makefiles/brcmsmac.patch b/patches/collateral-evolutions/network/72-brcm80211-makefiles/brcmsmac.patch
deleted file mode 100644
index 112c769..0000000
--- a/patches/collateral-evolutions/network/72-brcm80211-makefiles/brcmsmac.patch
+++ /dev/null
@@ -1,25 +0,0 @@
---- a/drivers/net/wireless/brcm80211/brcmsmac/Makefile
-+++ b/drivers/net/wireless/brcm80211/brcmsmac/Makefile
-@@ -21,7 +21,7 @@ ccflags-y := \
- 	-Idrivers/net/wireless/brcm80211/brcmsmac/phy \
- 	-Idrivers/net/wireless/brcm80211/include
- 
--BRCMSMAC_OFILES := \
-+brcmsmac-y := \
- 	mac80211_if.o \
- 	ucode_loader.o \
- 	ampdu.o \
-@@ -43,11 +43,6 @@ BRCMSMAC_OFILES := \
- 	brcms_trace_events.o \
- 	debug.o
- 
--ifdef CONFIG_BCMA_DRIVER_GPIO
--BRCMSMAC_OFILES += led.o
--endif
-+brcmsmac-$(CONFIG_BCMA_DRIVER_GPIO) += led.o
- 
--MODULEPFX := brcmsmac
--
--obj-$(CONFIG_BRCMSMAC)	+= $(MODULEPFX).o
--$(MODULEPFX)-objs	= $(BRCMSMAC_OFILES)
-+obj-$(CONFIG_BRCMSMAC)	+= brcmsmac.o
diff --git a/patches/collateral-evolutions/network/72-brcm80211-makefiles/brcmutil.patch b/patches/collateral-evolutions/network/72-brcm80211-makefiles/brcmutil.patch
deleted file mode 100644
index 3b84733..0000000
--- a/patches/collateral-evolutions/network/72-brcm80211-makefiles/brcmutil.patch
+++ /dev/null
@@ -1,15 +0,0 @@
---- a/drivers/net/wireless/brcm80211/brcmutil/Makefile
-+++ b/drivers/net/wireless/brcm80211/brcmutil/Makefile
-@@ -19,10 +19,5 @@ ccflags-y :=				\
- 	-Idrivers/net/wireless/brcm80211/brcmutil \
- 	-Idrivers/net/wireless/brcm80211/include
- 
--BRCMUTIL_OFILES := \
--	utils.o
--
--MODULEPFX := brcmutil
--
--obj-$(CONFIG_BRCMUTIL)	+= $(MODULEPFX).o
--$(MODULEPFX)-objs	= $(BRCMUTIL_OFILES)
-+obj-$(CONFIG_BRCMUTIL)	+= brcmutil.o
-+brcmutil-objs	= utils.o
-- 
1.7.10.4


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

* [PATCH 06/12] backports: remove ath5k trace fix patch
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
                   ` (4 preceding siblings ...)
  2013-05-11  0:26 ` [PATCH 05/12] backports: remove brcmsmac / brcmutil Makefile patches Luis R. Rodriguez
@ 2013-05-11  0:26 ` Luis R. Rodriguez
  2013-05-11  0:26 ` [PATCH 07/12] backports: enable the CONFIG_DRM_QXL driver on >= v3.3 Luis R. Rodriguez
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:26 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

This is no longer required thanks to commit cc5569f6
present on next-20130415.

commit cc5569f63ecb82965f3fe2fde5e60bf1689d107a
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Thu Apr 11 16:22:08 2013 +0200

    ath5k: use more idiomatic tracing include style

    Pretty much everywhere that uses a trace definition
    header that's not in include/trace/events/ uses the
    make system for the include path rather than putting
    it into the sources, so do that in ath5k as well.

    This came up during backporting work (where this is
    required), but since all other drivers do it this
    way upstream it seemed applicable.

    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: John W. Linville <linville@tuxdriver.com>

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 .../network/73-ath5k-tracing/ath5k.patch           |   21 --------------------
 1 file changed, 21 deletions(-)
 delete mode 100644 patches/collateral-evolutions/network/73-ath5k-tracing/ath5k.patch

diff --git a/patches/collateral-evolutions/network/73-ath5k-tracing/ath5k.patch b/patches/collateral-evolutions/network/73-ath5k-tracing/ath5k.patch
deleted file mode 100644
index 1adb3f9..0000000
--- a/patches/collateral-evolutions/network/73-ath5k-tracing/ath5k.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/drivers/net/wireless/ath/ath5k/trace.h
-+++ b/drivers/net/wireless/ath/ath5k/trace.h
-@@ -97,7 +97,7 @@ TRACE_EVENT(ath5k_tx_complete,
- #if defined(CONFIG_ATH5K_TRACER) && !defined(__CHECKER__)
- 
- #undef TRACE_INCLUDE_PATH
--#define TRACE_INCLUDE_PATH ../../drivers/net/wireless/ath/ath5k
-+#define TRACE_INCLUDE_PATH .
- #undef TRACE_INCLUDE_FILE
- #define TRACE_INCLUDE_FILE trace
- 
---- a/drivers/net/wireless/ath/ath5k/Makefile
-+++ b/drivers/net/wireless/ath/ath5k/Makefile
-@@ -10,6 +10,7 @@ ath5k-y				+= phy.o
- ath5k-y				+= reset.o
- ath5k-y				+= attach.o
- ath5k-y				+= base.o
-+CFLAGS_base.o			+= -I$(src)
- ath5k-y				+= led.o
- ath5k-y				+= rfkill.o
- ath5k-y				+= ani.o
-- 
1.7.10.4


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

* [PATCH 07/12] backports: enable the CONFIG_DRM_QXL driver on >= v3.3
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
                   ` (5 preceding siblings ...)
  2013-05-11  0:26 ` [PATCH 06/12] backports: remove ath5k trace fix patch Luis R. Rodriguez
@ 2013-05-11  0:26 ` Luis R. Rodriguez
  2013-05-11  0:26 ` [PATCH 08/12] backports: enable REGULATOR_WM8994 only on >= 3.8 Luis R. Rodriguez
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:26 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

This provides a requirement of the new qxl DRM driver to
be available only on kernels >= 3.3. The requirement
comes from the usage of radix_tree_for_each_slot() that
this uses the new radix bit-optimized iterator added
via 78c1d7848 on 3.4. We backport this via the compat
module but only for v3.3 given that addressing this
backport for v3.2 requires addressing e2bdb933 which
changes the radix_tree_node.

qxl was added on next-20130415.

mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 78c1d7848
v3.4-rc2~15^2~26

mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains e2bdb933
v3.3-rc1~81^2~8

Someone wishing to #ifdef this to enable qxl support on
v3.2 by using the old radix_tree_gang_lookup_slot()
can look at 0fc9d1040313047edf6a39fd4d7c7defdca97c62
as an example collateral evolution change.

commit f64122c1f6ade301585569863b4b3b18f6e4e332
Author: Dave Airlie <airlied@gmail.com>
Date:   Mon Feb 25 14:47:55 2013 +1000

    drm: add new QXL driver. (v1.4)

    QXL is a paravirtual graphics device used by the Spice virtual desktop
    interface.

    The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
    is quite different than normal TTM expects, we have to keep track of a number
    of non-linear fence ids per bo that we need to have released by the hardware.

    The releases are freed from a workqueue that wakes up and processes the
    release ring.

    releases are suballocated from a BO, there are 3 release categories, drawables,
    surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.

    The hardware also have a surface id tracking mechnaism and the driver
    encapsulates it completely inside the kernel, userspace never sees the actual hw sur
    ids.

    This requires a newer version of the QXL userspace driver, so shouldn't be
    enabled until that has been placed into your distro of choice.

    Authors: Dave Airlie, Alon Levy

    v1.1: fixup some issues in the ioctl interface with padding
    v1.2: add module device table
    v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
          don't try flush release ring (broken hw), fix -modesetting.
    v1.4: fbcon cpu usage reduction + suitable accel flags.

    Signed-off-by: Alon Levy <alevy@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 dependencies |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/dependencies b/dependencies
index 5ae6bce..c85577c 100644
--- a/dependencies
+++ b/dependencies
@@ -47,6 +47,12 @@ MWIFIEX 2.6.27
 HDMI 3.2
 DRM 3.2
 DRM_TTM 3.2
+# See e2bdb933, this was added on v3.3, in order to
+# support DRM_QXL on 3.2 you'd have to backport 78c1d7848
+# to 3.2 on BACKPORT_BUILD_RADIX_HELPERS and that requires
+# taking into consideration the radix_tree_node rcu change
+# on e2bdb933.
+DRM_QXL 3.3
 
 # Regulator
 # Because of -EPROBE_DEFER see commit d1c3414c and note that
-- 
1.7.10.4


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

* [PATCH 08/12] backports: enable REGULATOR_WM8994 only on >= 3.8
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
                   ` (6 preceding siblings ...)
  2013-05-11  0:26 ` [PATCH 07/12] backports: enable the CONFIG_DRM_QXL driver on >= v3.3 Luis R. Rodriguez
@ 2013-05-11  0:26 ` Luis R. Rodriguez
  2013-05-11  0:27 ` [PATCH 09/12] backports: refresh patches for next-20130415 Luis R. Rodriguez
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:26 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

Compilation is failing and we need to move forward,
I can't look at this right now.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 dependencies |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dependencies b/dependencies
index c85577c..07fd3bf 100644
--- a/dependencies
+++ b/dependencies
@@ -101,7 +101,7 @@ REGULATOR_TPS65023 3.6
 REGULATOR_TPS6507X 3.6
 REGULATOR_TPS6524X 3.6
 REGULATOR_WM8400 3.5
-REGULATOR_WM8994 3.5
+REGULATOR_WM8994 3.8
 
 # Media
 MEDIA_SUPPORT 3.2
-- 
1.7.10.4


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

* [PATCH 09/12] backports: refresh patches for next-20130415
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
                   ` (7 preceding siblings ...)
  2013-05-11  0:26 ` [PATCH 08/12] backports: enable REGULATOR_WM8994 only on >= 3.8 Luis R. Rodriguez
@ 2013-05-11  0:27 ` Luis R. Rodriguez
  2013-05-11  0:27 ` [PATCH 10/12] backports: fix atl1.c dev-pm-ops patch Luis R. Rodriguez
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:27 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

== ckmake-report.log ==

1   2.6.24              [  OK  ]
2   2.6.25              [  OK  ]
3   2.6.26              [  OK  ]
4   2.6.27              [  OK  ]
5   2.6.28              [  OK  ]
6   2.6.29              [  OK  ]
7   2.6.30              [  OK  ]
8   2.6.31              [  OK  ]
9   2.6.32              [  OK  ]
10  2.6.33              [  OK  ]
11  2.6.34              [  OK  ]
12  2.6.35              [  OK  ]
13  2.6.36              [  OK  ]
14  2.6.37              [  OK  ]
15  2.6.38              [  OK  ]
16  2.6.39              [  OK  ]
17  3.0.76              [  OK  ]
18  3.1.10              [  OK  ]
19  3.2.44              [  OK  ]
20  3.3.8               [  OK  ]
21  3.4.43              [  OK  ]
22  3.5.7               [  OK  ]
23  3.6.11              [  OK  ]
24  3.7.10              [  OK  ]
25  3.8.11              [  OK  ]
26  3.9.0               [  OK  ]

real    30m38.595s
user    808m49.549s
sys     127m31.602s

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 patches/backport-adjustments/dma-buf.patch                   |    2 +-
 .../network/0001-netdev_ops/ipw2100.patch                    |    2 +-
 .../network/0001-netdev_ops/mac80211.patch                   |    6 +++---
 .../network/0001-netdev_ops/mac80211_hwsim.patch             |    2 +-
 .../network/0001-netdev_ops/usbnet.patch                     |    2 +-
 .../0003-netdev-needed_headroom_tailroom/mac80211.patch      |    4 ++--
 .../network/0005-netlink-portid/mac80211_hwsim.patch         |    4 ++--
 .../09-cfg80211-wext-padding/include_net_cfg80211.patch      |    2 +-
 .../drivers_net_wireless_iwlwifi_pcie_drv.patch              |    4 ++--
 .../drivers_net_wireless_ipw2x00_ipw2100.patch               |    2 +-
 .../network/16-bluetooth/net_bluetooth_sco.patch             |    2 +-
 .../network/17-netdev-queue/net_mac80211_iface.patch         |    4 ++--
 .../drivers_net_wireless_adm8211.patch                       |    2 +-
 .../drivers_net_wireless_ath_carl9170_main.patch             |    2 +-
 .../25-multicast-list_head/drivers_net_wireless_mwl8k.patch  |    6 +++---
 .../25-multicast-list_head/include_net_mac80211.patch        |    2 +-
 .../25-multicast-list_head/net_mac80211_ieee80211_i.patch    |    2 +-
 .../network/25-multicast-list_head/net_mac80211_iface.patch  |    6 +++---
 .../network/25-multicast-list_head/net_mac80211_main.patch   |    2 +-
 ...rivers_net_wireless_brcm80211_brcmfmac_bcmsdh_sdmmc.patch |   10 +++++-----
 .../network/36-workqueue/net_mac80211_main.patch             |    2 +-
 .../network/62-usb_driver_lpm/drivers_bluetooth_btusb.patch  |    2 +-
 .../62-usb_driver_lpm/drivers_net_usb_cdc_ether.patch        |    2 +-
 23 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/patches/backport-adjustments/dma-buf.patch b/patches/backport-adjustments/dma-buf.patch
index 75d7b73..faefc93 100644
--- a/patches/backport-adjustments/dma-buf.patch
+++ b/patches/backport-adjustments/dma-buf.patch
@@ -51,7 +51,7 @@
  
  	fd_install(fd, dmabuf->file);
  
-@@ -696,17 +722,15 @@ static inline void dma_buf_uninit_debugf
+@@ -695,17 +721,15 @@ static inline void dma_buf_uninit_debugf
  }
  #endif
  
diff --git a/patches/collateral-evolutions/network/0001-netdev_ops/ipw2100.patch b/patches/collateral-evolutions/network/0001-netdev_ops/ipw2100.patch
index 1cde9f4..0d174d3 100644
--- a/patches/collateral-evolutions/network/0001-netdev_ops/ipw2100.patch
+++ b/patches/collateral-evolutions/network/0001-netdev_ops/ipw2100.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ipw2x00/ipw2100.c
 +++ b/drivers/net/wireless/ipw2x00/ipw2100.c
-@@ -6086,7 +6086,7 @@ static struct net_device *ipw2100_alloc_
+@@ -6068,7 +6068,7 @@ static struct net_device *ipw2100_alloc_
  	priv->ieee->perfect_rssi = -20;
  	priv->ieee->worst_rssi = -85;
  
diff --git a/patches/collateral-evolutions/network/0001-netdev_ops/mac80211.patch b/patches/collateral-evolutions/network/0001-netdev_ops/mac80211.patch
index 6b67fb7..d8b4169 100644
--- a/patches/collateral-evolutions/network/0001-netdev_ops/mac80211.patch
+++ b/patches/collateral-evolutions/network/0001-netdev_ops/mac80211.patch
@@ -1,6 +1,6 @@
 --- a/net/mac80211/iface.c
 +++ b/net/mac80211/iface.c
-@@ -1028,7 +1028,7 @@ static void ieee80211_if_setup(struct ne
+@@ -1068,7 +1068,7 @@ static void ieee80211_if_setup(struct ne
  {
  	ether_setup(dev);
  	dev->priv_flags &= ~IFF_TX_SKB_SHARING;
@@ -9,7 +9,7 @@
  	dev->destructor = free_netdev;
  }
  
-@@ -1191,7 +1191,7 @@ static void ieee80211_setup_sdata(struct
+@@ -1231,7 +1231,7 @@ static void ieee80211_setup_sdata(struct
  
  	/* only monitor/p2p-device differ */
  	if (sdata->dev) {
@@ -18,7 +18,7 @@
  		sdata->dev->type = ARPHRD_ETHER;
  	}
  
-@@ -1229,7 +1229,7 @@ static void ieee80211_setup_sdata(struct
+@@ -1269,7 +1269,7 @@ static void ieee80211_setup_sdata(struct
  		break;
  	case NL80211_IFTYPE_MONITOR:
  		sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
diff --git a/patches/collateral-evolutions/network/0001-netdev_ops/mac80211_hwsim.patch b/patches/collateral-evolutions/network/0001-netdev_ops/mac80211_hwsim.patch
index a9842b2..f23c3e4 100644
--- a/patches/collateral-evolutions/network/0001-netdev_ops/mac80211_hwsim.patch
+++ b/patches/collateral-evolutions/network/0001-netdev_ops/mac80211_hwsim.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/mac80211_hwsim.c
 +++ b/drivers/net/wireless/mac80211_hwsim.c
-@@ -1695,7 +1695,7 @@ static const struct net_device_ops hwsim
+@@ -1707,7 +1707,7 @@ static const struct net_device_ops hwsim
  
  static void hwsim_mon_setup(struct net_device *dev)
  {
diff --git a/patches/collateral-evolutions/network/0001-netdev_ops/usbnet.patch b/patches/collateral-evolutions/network/0001-netdev_ops/usbnet.patch
index 5052c1f..b12acc9 100644
--- a/patches/collateral-evolutions/network/0001-netdev_ops/usbnet.patch
+++ b/patches/collateral-evolutions/network/0001-netdev_ops/usbnet.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/usb/usbnet.c
 +++ b/drivers/net/usb/usbnet.c
-@@ -1446,7 +1446,7 @@ usbnet_probe (struct usb_interface *udev
+@@ -1474,7 +1474,7 @@ usbnet_probe (struct usb_interface *udev
  		net->features |= NETIF_F_HIGHDMA;
  #endif
  
diff --git a/patches/collateral-evolutions/network/0003-netdev-needed_headroom_tailroom/mac80211.patch b/patches/collateral-evolutions/network/0003-netdev-needed_headroom_tailroom/mac80211.patch
index 6099f45..0d48e3c 100644
--- a/patches/collateral-evolutions/network/0003-netdev-needed_headroom_tailroom/mac80211.patch
+++ b/patches/collateral-evolutions/network/0003-netdev-needed_headroom_tailroom/mac80211.patch
@@ -1,6 +1,6 @@
 --- a/net/mac80211/iface.c
 +++ b/net/mac80211/iface.c
-@@ -1524,6 +1524,7 @@ int ieee80211_if_add(struct ieee80211_lo
+@@ -1564,6 +1564,7 @@ int ieee80211_if_add(struct ieee80211_lo
  			return -ENOMEM;
  		dev_net_set(ndev, wiphy_net(local->hw.wiphy));
  
@@ -8,7 +8,7 @@
  		ndev->needed_headroom = local->tx_headroom +
  					4*6 /* four MAC addresses */
  					+ 2 + 2 + 2 + 2 /* ctl, dur, seq, qos */
-@@ -1532,6 +1533,7 @@ int ieee80211_if_add(struct ieee80211_lo
+@@ -1572,6 +1573,7 @@ int ieee80211_if_add(struct ieee80211_lo
  					- ETH_HLEN /* ethernet hard_header_len */
  					+ IEEE80211_ENCRYPT_HEADROOM;
  		ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM;
diff --git a/patches/collateral-evolutions/network/0005-netlink-portid/mac80211_hwsim.patch b/patches/collateral-evolutions/network/0005-netlink-portid/mac80211_hwsim.patch
index c1ab942..3910fd8 100644
--- a/patches/collateral-evolutions/network/0005-netlink-portid/mac80211_hwsim.patch
+++ b/patches/collateral-evolutions/network/0005-netlink-portid/mac80211_hwsim.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/mac80211_hwsim.c
 +++ b/drivers/net/wireless/mac80211_hwsim.c
-@@ -2019,10 +2019,10 @@ static int hwsim_register_received_nl(st
+@@ -2031,10 +2031,10 @@ static int hwsim_register_received_nl(st
  	if (info == NULL)
  		goto out;
  
@@ -13,7 +13,7 @@
  
  	return 0;
  out:
-@@ -2059,7 +2059,7 @@ static int mac80211_hwsim_netlink_notify
+@@ -2071,7 +2071,7 @@ static int mac80211_hwsim_netlink_notify
  	if (state != NETLINK_URELEASE)
  		return NOTIFY_DONE;
  
diff --git a/patches/collateral-evolutions/network/09-cfg80211-wext-padding/include_net_cfg80211.patch b/patches/collateral-evolutions/network/09-cfg80211-wext-padding/include_net_cfg80211.patch
index fa82867..8ac85f7 100644
--- a/patches/collateral-evolutions/network/09-cfg80211-wext-padding/include_net_cfg80211.patch
+++ b/patches/collateral-evolutions/network/09-cfg80211-wext-padding/include_net_cfg80211.patch
@@ -1,6 +1,6 @@
 --- a/include/net/cfg80211.h
 +++ b/include/net/cfg80211.h
-@@ -2561,6 +2561,9 @@ struct wiphy_wowlan_support {
+@@ -2565,6 +2565,9 @@ struct wiphy_wowlan_support {
  struct wiphy {
  	/* assign these fields before you register the wiphy */
  
diff --git a/patches/collateral-evolutions/network/11-dev-pm-ops/drivers_net_wireless_iwlwifi_pcie_drv.patch b/patches/collateral-evolutions/network/11-dev-pm-ops/drivers_net_wireless_iwlwifi_pcie_drv.patch
index 8e9e9af..900e355 100644
--- a/patches/collateral-evolutions/network/11-dev-pm-ops/drivers_net_wireless_iwlwifi_pcie_drv.patch
+++ b/patches/collateral-evolutions/network/11-dev-pm-ops/drivers_net_wireless_iwlwifi_pcie_drv.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/iwlwifi/pcie/drv.c
 +++ b/drivers/net/wireless/iwlwifi/pcie/drv.c
-@@ -347,6 +347,9 @@ static int iwl_pci_resume(struct device
+@@ -348,6 +348,9 @@ static int iwl_pci_resume(struct device
  	return iwl_trans_resume(iwl_trans);
  }
  
@@ -10,7 +10,7 @@
  static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume);
  
  #define IWL_PM_OPS	(&iwl_dev_pm_ops)
-@@ -362,7 +365,12 @@ static struct pci_driver iwl_pci_driver
+@@ -363,7 +366,12 @@ static struct pci_driver iwl_pci_driver
  	.id_table = iwl_hw_card_ids,
  	.probe = iwl_pci_probe,
  	.remove = iwl_pci_remove,
diff --git a/patches/collateral-evolutions/network/12-iw_handler-changes/drivers_net_wireless_ipw2x00_ipw2100.patch b/patches/collateral-evolutions/network/12-iw_handler-changes/drivers_net_wireless_ipw2x00_ipw2100.patch
index d7a6a6d..1d515a7 100644
--- a/patches/collateral-evolutions/network/12-iw_handler-changes/drivers_net_wireless_ipw2x00_ipw2100.patch
+++ b/patches/collateral-evolutions/network/12-iw_handler-changes/drivers_net_wireless_ipw2x00_ipw2100.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ipw2x00/ipw2100.c
 +++ b/drivers/net/wireless/ipw2x00/ipw2100.c
-@@ -6089,7 +6089,11 @@ static struct net_device *ipw2100_alloc_
+@@ -6071,7 +6071,11 @@ static struct net_device *ipw2100_alloc_
  	netdev_attach_ops(dev, &ipw2100_netdev_ops);
  	dev->ethtool_ops = &ipw2100_ethtool_ops;
  	dev->wireless_handlers = &ipw2100_wx_handler_def;
diff --git a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_sco.patch b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_sco.patch
index b165915..6b6d9a5 100644
--- a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_sco.patch
+++ b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_sco.patch
@@ -13,7 +13,7 @@
  {
  	struct sock *sk;
  
-@@ -676,7 +680,11 @@ static int sco_sock_recvmsg(struct kiocb
+@@ -675,7 +679,11 @@ static int sco_sock_recvmsg(struct kiocb
  	return bt_sock_recvmsg(iocb, sock, msg, len, flags);
  }
  
diff --git a/patches/collateral-evolutions/network/17-netdev-queue/net_mac80211_iface.patch b/patches/collateral-evolutions/network/17-netdev-queue/net_mac80211_iface.patch
index afe9ec4..c38ea75 100644
--- a/patches/collateral-evolutions/network/17-netdev-queue/net_mac80211_iface.patch
+++ b/patches/collateral-evolutions/network/17-netdev-queue/net_mac80211_iface.patch
@@ -1,6 +1,6 @@
 --- a/net/mac80211/iface.c
 +++ b/net/mac80211/iface.c
-@@ -1649,6 +1649,7 @@ void ieee80211_sdata_stop(struct ieee802
+@@ -1689,6 +1689,7 @@ void ieee80211_sdata_stop(struct ieee802
   * Remove all interfaces, may only be called at hardware unregistration
   * time because it doesn't do RCU-safe list removals.
   */
@@ -8,7 +8,7 @@
  void ieee80211_remove_interfaces(struct ieee80211_local *local)
  {
  	struct ieee80211_sub_if_data *sdata, *tmp;
-@@ -1676,6 +1677,22 @@ void ieee80211_remove_interfaces(struct
+@@ -1716,6 +1717,22 @@ void ieee80211_remove_interfaces(struct
  		kfree(sdata);
  	}
  }
diff --git a/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_adm8211.patch b/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_adm8211.patch
index 049512c..7793f2c 100644
--- a/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_adm8211.patch
+++ b/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_adm8211.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/adm8211.c
 +++ b/drivers/net/wireless/adm8211.c
-@@ -1320,19 +1320,37 @@ static void adm8211_bss_info_changed(str
+@@ -1321,19 +1321,37 @@ static void adm8211_bss_info_changed(str
  }
  
  static u64 adm8211_prepare_multicast(struct ieee80211_hw *hw,
diff --git a/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_ath_carl9170_main.patch b/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_ath_carl9170_main.patch
index 57a303b..5b7e439 100644
--- a/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_ath_carl9170_main.patch
+++ b/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_ath_carl9170_main.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/carl9170/main.c
 +++ b/drivers/net/wireless/ath/carl9170/main.c
-@@ -967,17 +967,35 @@ out:
+@@ -970,17 +970,35 @@ out:
  	return err;
  }
  
diff --git a/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_mwl8k.patch b/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_mwl8k.patch
index dbeffcc..6f36d72 100644
--- a/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_mwl8k.patch
+++ b/patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_mwl8k.patch
@@ -50,7 +50,7 @@
  		}
  	}
  
-@@ -5022,7 +5042,11 @@ mwl8k_bss_info_changed(struct ieee80211_
+@@ -5026,7 +5046,11 @@ mwl8k_bss_info_changed(struct ieee80211_
  }
  
  static u64 mwl8k_prepare_multicast(struct ieee80211_hw *hw,
@@ -62,7 +62,7 @@
  {
  	struct mwl8k_cmd_pkt *cmd;
  
-@@ -5033,7 +5057,11 @@ static u64 mwl8k_prepare_multicast(struc
+@@ -5037,7 +5061,11 @@ static u64 mwl8k_prepare_multicast(struc
  	 * we'll end up throwing this packet away and creating a new
  	 * one in mwl8k_configure_filter().
  	 */
@@ -74,7 +74,7 @@
  
  	return (unsigned long)cmd;
  }
-@@ -5155,7 +5183,11 @@ static void mwl8k_configure_filter(struc
+@@ -5159,7 +5187,11 @@ static void mwl8k_configure_filter(struc
  	 */
  	if (*total_flags & FIF_ALLMULTI) {
  		kfree(cmd);
diff --git a/patches/collateral-evolutions/network/25-multicast-list_head/include_net_mac80211.patch b/patches/collateral-evolutions/network/25-multicast-list_head/include_net_mac80211.patch
index 6482bab..e2393b4 100644
--- a/patches/collateral-evolutions/network/25-multicast-list_head/include_net_mac80211.patch
+++ b/patches/collateral-evolutions/network/25-multicast-list_head/include_net_mac80211.patch
@@ -1,6 +1,6 @@
 --- a/include/net/mac80211.h
 +++ b/include/net/mac80211.h
-@@ -2603,14 +2603,24 @@ struct ieee80211_ops {
+@@ -2612,14 +2612,24 @@ struct ieee80211_ops {
  	void (*stop_ap)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
  
  	u64 (*prepare_multicast)(struct ieee80211_hw *hw,
diff --git a/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_ieee80211_i.patch b/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_ieee80211_i.patch
index 5936ffb..629007d 100644
--- a/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_ieee80211_i.patch
+++ b/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_ieee80211_i.patch
@@ -1,6 +1,6 @@
 --- a/net/mac80211/ieee80211_i.h
 +++ b/net/mac80211/ieee80211_i.h
-@@ -908,7 +908,12 @@ struct ieee80211_local {
+@@ -907,7 +907,12 @@ struct ieee80211_local {
  	struct work_struct reconfig_filter;
  
  	/* aggregated multicast list */
diff --git a/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_iface.patch b/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_iface.patch
index 7f5e679..e08b4d0 100644
--- a/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_iface.patch
+++ b/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_iface.patch
@@ -1,6 +1,6 @@
 --- a/net/mac80211/iface.c
 +++ b/net/mac80211/iface.c
-@@ -754,8 +754,13 @@ static void ieee80211_do_stop(struct iee
+@@ -770,8 +770,13 @@ static void ieee80211_do_stop(struct iee
  	if (sdata->dev) {
  		netif_addr_lock_bh(sdata->dev);
  		spin_lock_bh(&local->filter_lock);
@@ -13,8 +13,8 @@
 +#endif
  		spin_unlock_bh(&local->filter_lock);
  		netif_addr_unlock_bh(sdata->dev);
- 
-@@ -938,10 +943,20 @@ static void ieee80211_set_multicast_list
+ 	}
+@@ -978,10 +983,20 @@ static void ieee80211_set_multicast_list
  	if (sdata->vif.type != NL80211_IFTYPE_MONITOR &&
  	    sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  	    sdata->vif.type != NL80211_IFTYPE_AP)
diff --git a/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_main.patch b/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_main.patch
index 0cbdac5..38a8540 100644
--- a/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_main.patch
+++ b/patches/collateral-evolutions/network/25-multicast-list_head/net_mac80211_main.patch
@@ -12,7 +12,7 @@
  	spin_unlock_bh(&local->filter_lock);
  
  	/* be a bit nasty */
-@@ -592,9 +596,11 @@ struct ieee80211_hw *ieee80211_alloc_hw(
+@@ -599,9 +603,11 @@ struct ieee80211_hw *ieee80211_alloc_hw(
  	wiphy->vht_capa_mod_mask = &mac80211_vht_capa_mod_mask;
  
  	INIT_LIST_HEAD(&local->interfaces);
diff --git a/patches/collateral-evolutions/network/29-sdio_no_suspend/drivers_net_wireless_brcm80211_brcmfmac_bcmsdh_sdmmc.patch b/patches/collateral-evolutions/network/29-sdio_no_suspend/drivers_net_wireless_brcm80211_brcmfmac_bcmsdh_sdmmc.patch
index f0b8544..ab95682 100644
--- a/patches/collateral-evolutions/network/29-sdio_no_suspend/drivers_net_wireless_brcm80211_brcmfmac_bcmsdh_sdmmc.patch
+++ b/patches/collateral-evolutions/network/29-sdio_no_suspend/drivers_net_wireless_brcm80211_brcmfmac_bcmsdh_sdmmc.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
 +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
-@@ -71,7 +71,7 @@ static bool
+@@ -70,7 +70,7 @@ static bool
  brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev)
  {
  	bool is_err = false;
@@ -9,7 +9,7 @@
  	is_err = atomic_read(&sdiodev->suspend);
  #endif
  	return is_err;
-@@ -80,7 +80,7 @@ brcmf_pm_resume_error(struct brcmf_sdio_
+@@ -79,7 +79,7 @@ brcmf_pm_resume_error(struct brcmf_sdio_
  static void
  brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev, wait_queue_head_t *wq)
  {
@@ -18,7 +18,7 @@
  	int retry = 0;
  	while (atomic_read(&sdiodev->suspend) && retry++ != 30)
  		wait_event_timeout(*wq, false, HZ/100);
-@@ -546,7 +546,7 @@ static void brcmf_ops_sdio_remove(struct
+@@ -516,7 +516,7 @@ static void brcmf_ops_sdio_remove(struct
  	brcmf_dbg(SDIO, "Exit\n");
  }
  
@@ -27,9 +27,9 @@
  static int brcmf_sdio_suspend(struct device *dev)
  {
  	mmc_pm_flag_t sdio_flags;
-@@ -596,7 +596,7 @@ static struct sdio_driver brcmf_sdmmc_dr
+@@ -566,7 +566,7 @@ static struct sdio_driver brcmf_sdmmc_dr
  	.remove = brcmf_ops_sdio_remove,
- 	.name = "brcmfmac",
+ 	.name = BRCMFMAC_SDIO_PDATA_NAME,
  	.id_table = brcmf_sdmmc_ids,
 -#ifdef CONFIG_PM_SLEEP
 +#if defined(CONFIG_PM_SLEEP) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
diff --git a/patches/collateral-evolutions/network/36-workqueue/net_mac80211_main.patch b/patches/collateral-evolutions/network/36-workqueue/net_mac80211_main.patch
index d8759fe..04e1cac 100644
--- a/patches/collateral-evolutions/network/36-workqueue/net_mac80211_main.patch
+++ b/patches/collateral-evolutions/network/36-workqueue/net_mac80211_main.patch
@@ -1,6 +1,6 @@
 --- a/net/mac80211/main.c
 +++ b/net/mac80211/main.c
-@@ -1152,6 +1152,10 @@ static void __exit ieee80211_exit(void)
+@@ -1151,6 +1151,10 @@ static void __exit ieee80211_exit(void)
  	rc80211_minstrel_ht_exit();
  	rc80211_minstrel_exit();
  
diff --git a/patches/collateral-evolutions/network/62-usb_driver_lpm/drivers_bluetooth_btusb.patch b/patches/collateral-evolutions/network/62-usb_driver_lpm/drivers_bluetooth_btusb.patch
index 2084db0..e93af5f 100644
--- a/patches/collateral-evolutions/network/62-usb_driver_lpm/drivers_bluetooth_btusb.patch
+++ b/patches/collateral-evolutions/network/62-usb_driver_lpm/drivers_bluetooth_btusb.patch
@@ -1,6 +1,6 @@
 --- a/drivers/bluetooth/btusb.c
 +++ b/drivers/bluetooth/btusb.c
-@@ -1246,7 +1246,9 @@ static struct usb_driver btusb_driver =
+@@ -1242,7 +1242,9 @@ static struct usb_driver btusb_driver =
  #endif
  	.id_table	= btusb_table,
  	.supports_autosuspend = 1,
diff --git a/patches/collateral-evolutions/network/62-usb_driver_lpm/drivers_net_usb_cdc_ether.patch b/patches/collateral-evolutions/network/62-usb_driver_lpm/drivers_net_usb_cdc_ether.patch
index 214c576..8b54e5f 100644
--- a/patches/collateral-evolutions/network/62-usb_driver_lpm/drivers_net_usb_cdc_ether.patch
+++ b/patches/collateral-evolutions/network/62-usb_driver_lpm/drivers_net_usb_cdc_ether.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/usb/cdc_ether.c
 +++ b/drivers/net/usb/cdc_ether.c
-@@ -720,7 +720,9 @@ static struct usb_driver cdc_driver = {
+@@ -717,7 +717,9 @@ static struct usb_driver cdc_driver = {
  	.resume =	usbnet_resume,
  	.reset_resume =	usbnet_resume,
  	.supports_autosuspend = 1,
-- 
1.7.10.4


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

* [PATCH 10/12] backports: fix atl1.c dev-pm-ops patch
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
                   ` (8 preceding siblings ...)
  2013-05-11  0:27 ` [PATCH 09/12] backports: refresh patches for next-20130415 Luis R. Rodriguez
@ 2013-05-11  0:27 ` Luis R. Rodriguez
  2013-05-11  0:27 ` [PATCH 11/12] backports: backport new bluetooth hidp session-management Luis R. Rodriguez
  2013-05-11  0:27 ` [PATCH 12/12] backports: refresh patches for next-20130419 Luis R. Rodriguez
  11 siblings, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:27 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

As of next-20130419 the atl1.c driver uses
atl1_pm_ops directly instead of the ATL1_PM_OPS
macro. This fixes that hunk.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 .../drivers_net_ethernet_atheros_atlx_atl1.patch             |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/patches/collateral-evolutions/network/11-dev-pm-ops/drivers_net_ethernet_atheros_atlx_atl1.patch b/patches/collateral-evolutions/network/11-dev-pm-ops/drivers_net_ethernet_atheros_atlx_atl1.patch
index 1e3cb6d..7fd2a4d 100644
--- a/patches/collateral-evolutions/network/11-dev-pm-ops/drivers_net_ethernet_atheros_atlx_atl1.patch
+++ b/patches/collateral-evolutions/network/11-dev-pm-ops/drivers_net_ethernet_atheros_atlx_atl1.patch
@@ -1,21 +1,21 @@
 --- a/drivers/net/ethernet/atheros/atlx/atl1.c
 +++ b/drivers/net/ethernet/atheros/atlx/atl1.c
-@@ -2877,6 +2877,9 @@ static int atl1_resume(struct device *de
- 	return 0;
+@@ -2878,6 +2878,9 @@ static int atl1_resume(struct device *de
  }
+ #endif
  
 +compat_pci_suspend(atl1_suspend)
 +compat_pci_resume(atl1_resume)
 +
  static SIMPLE_DEV_PM_OPS(atl1_pm_ops, atl1_suspend, atl1_resume);
- #define ATL1_PM_OPS	(&atl1_pm_ops)
  
-@@ -3147,7 +3150,12 @@ static struct pci_driver atl1_driver = {
+ static void atl1_shutdown(struct pci_dev *pdev)
+@@ -3142,7 +3145,12 @@ static struct pci_driver atl1_driver = {
  	.probe = atl1_probe,
  	.remove = atl1_remove,
  	.shutdown = atl1_shutdown,
 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
- 	.driver.pm = ATL1_PM_OPS,
+ 	.driver.pm = &atl1_pm_ops,
 +#elif defined(CONFIG_PM_SLEEP)
 +	.suspend        = atl1_suspend_compat,
 +	.resume         = atl1_resume_compat,
-- 
1.7.10.4


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

* [PATCH 11/12] backports: backport new bluetooth hidp session-management
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
                   ` (9 preceding siblings ...)
  2013-05-11  0:27 ` [PATCH 10/12] backports: fix atl1.c dev-pm-ops patch Luis R. Rodriguez
@ 2013-05-11  0:27 ` Luis R. Rodriguez
  2013-05-12 12:26   ` David Herrmann
  2013-05-11  0:27 ` [PATCH 12/12] backports: refresh patches for next-20130419 Luis R. Rodriguez
  11 siblings, 1 reply; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:27 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez, dh.herrmann

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

Commit b4f34d8d9 on next-20130419 added new bluetooth hidp
session-management helper, then commit 520518 also on
next-20130419 replaced the old management code with
the new one.

Someone really needs to run time test this for regressions.

commit b4f34d8d9d26b2428fa7cf7c8f97690a297978e6
Author: David Herrmann <dh.herrmann@gmail.com>
Date:   Sat Apr 6 20:28:46 2013 +0200

    Bluetooth: hidp: add new session-management helpers

    This is a rewrite of the HIDP session management. It implements HIDP as an
    l2cap_user sub-module so we get proper notification when the underlying
    connection goes away.

    The helpers are not yet used but only added in this commit. The old
    session management is still used and will be removed in a following patch.

    The old session-management was flawed. Hotplugging is horribly broken and
    we have no way of getting notified when the underlying connection goes
    down. The whole idea of removing the HID/input sub-devices from within the
    session itself is broken and suffers from major dead-locks. We never can
    guarantee that the session can unregister itself as long as we use
    synchronous shutdowns. This can only work with asynchronous shutdowns.
    However, in this case we _must_ be able to unregister the session from the
    outside as otherwise the l2cap_conn object might be unlinked before we
    are.

    The new session-management is based on l2cap_user. There is only one
    way how to add a session and how to delete a session: "probe" and "remove"
    callbacks from l2cap_user.
    This guarantees that the session can be registered and unregistered at
    _any_ time without any synchronous shutdown.
    On the other hand, much work has been put into proper session-refcounting.
    We can unregister/unlink the session only if we can guarantee that it will
    stay alive. But for asynchronous shutdowns we never know when the last
    user goes away so we must use proper ref-counting.

    The old ->conn field has been renamed to ->hconn so we can reuse ->conn in
    the new session management. No other existing HIDP code is modified.

    Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
    Acked-by: Marcel Holtmann <marcel@holtmann.org>
    Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

commit 5205185d461d5902325e457ca80bd421127b7308
Author: David Herrmann <dh.herrmann@gmail.com>
Date:   Sat Apr 6 20:28:47 2013 +0200

    Bluetooth: hidp: remove old session-management

    We have the full new session-management now available so lets switch over
    and remove all the old code. Few semantics changed, so we need to adjust
    the sock.c callers a bit. But this mostly simplifies the logic.

    Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
    Acked-by: Marcel Holtmann <marcel@holtmann.org>
    Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Cc: dh.herrmann@gmail.com
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 .../16-bluetooth/net_bluetooth_hidp_core.patch     |  109 +++++++++-----------
 1 file changed, 51 insertions(+), 58 deletions(-)

diff --git a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_core.patch b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_core.patch
index 60a97e6..01a859a 100644
--- a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_core.patch
+++ b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_core.patch
@@ -1,6 +1,6 @@
 --- a/net/bluetooth/hidp/core.c
 +++ b/net/bluetooth/hidp/core.c
-@@ -383,6 +383,7 @@ err:
+@@ -329,6 +329,7 @@ err:
  	return ret;
  }
  
@@ -8,7 +8,7 @@
  static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count,
  		unsigned char report_type)
  {
-@@ -441,6 +442,16 @@ err:
+@@ -386,6 +387,16 @@ err:
  	mutex_unlock(&session->report_mutex);
  	return ret;
  }
@@ -25,22 +25,7 @@
  
  static void hidp_idle_timeout(unsigned long arg)
  {
-@@ -743,8 +754,14 @@ static int hidp_session(void *arg)
- 	}
- 
- 	if (session->hid) {
-+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
- 		hid_destroy_device(session->hid);
- 		session->hid = NULL;
-+#else
-+		if (session->hid->claimed & HID_CLAIMED_INPUT)
-+			hidinput_disconnect(session->hid);
-+		hid_free_device(session->hid);
-+#endif
- 	}
- 
- 	/* Wakeup user-space polling for socket errors */
-@@ -855,6 +872,70 @@ static void hidp_close(struct hid_device
+@@ -674,6 +685,70 @@ static void hidp_close(struct hid_device
  {
  }
  
@@ -111,8 +96,8 @@
  static int hidp_parse(struct hid_device *hid)
  {
  	struct hidp_session *session = hid->driver_data;
-@@ -946,7 +1027,9 @@ static int hidp_setup_hid(struct hidp_se
- 	hid->dev.parent = &session->conn->dev;
+@@ -764,13 +839,21 @@ static int hidp_setup_hid(struct hidp_se
+ 	hid->dev.parent = &session->conn->hcon->dev;
  	hid->ll_driver = &hidp_hid_driver;
  
 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
@@ -121,17 +106,46 @@
  	hid->hid_output_raw_report = hidp_output_raw_report;
  
  	/* True if device is blacklisted in drivers/hid/hid-core.c */
-@@ -964,6 +1047,7 @@ fault:
+ 	if (hid_ignore(hid)) {
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
+ 		hid_destroy_device(session->hid);
+ 		session->hid = NULL;
++#else
++		if (session->hid->claimed & HID_CLAIMED_INPUT)
++			hidinput_disconnect(session->hid);
++		hid_free_device(session->hid);
++#endif
+ 		return -ENODEV;
+ 	}
+ 
+@@ -782,6 +865,7 @@ fault:
  
  	return err;
  }
 +#endif
  
- int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock)
+ /* initialize session devices */
+ static int hidp_session_dev_init(struct hidp_session *session,
+@@ -844,8 +928,15 @@ static int hidp_session_dev_add(struct h
+ /* remove HID/input devices from their bus systems */
+ static void hidp_session_dev_del(struct hidp_session *session)
  {
-@@ -981,6 +1065,39 @@ int hidp_add_connection(struct hidp_conn
- 
- 	BT_DBG("rd_data %p rd_size %d", req->rd_data, req->rd_size);
+-	if (session->hid)
++	if (session->hid) {
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
+ 		hid_destroy_device(session->hid);
++#else
++		if (session->hid->claimed & HID_CLAIMED_INPUT)
++			hidinput_disconnect(session->hid);
++		hid_free_device(session->hid);
++#endif
++	}
+ 	else if (session->input)
+ 		input_unregister_device(session->input);
+ }
+@@ -1049,6 +1140,39 @@ static int hidp_session_probe(struct l2c
+ 	struct hidp_session *s;
+ 	int ret;
  
 +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
 +	if (req->rd_size > 0) {
@@ -168,20 +182,12 @@
 +#endif
  	down_write(&hidp_session_sem);
  
- 	s = __hidp_get_session(&bt_sk(ctrl_sock->sk)->dst);
-@@ -1028,6 +1145,7 @@ int hidp_add_connection(struct hidp_conn
- 
- 	__hidp_link_session(session);
- 
-+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
- 	if (req->rd_size > 0) {
- 		err = hidp_setup_hid(session, req);
- 		if (err && err != -ENODEV)
-@@ -1039,6 +1157,16 @@ int hidp_add_connection(struct hidp_conn
- 		if (err < 0)
- 			goto purge;
+ 	/* check that no other session for this device exists */
+@@ -1057,6 +1181,16 @@ static int hidp_session_probe(struct l2c
+ 		ret = -EEXIST;
+ 		goto out_unlock;
  	}
-+#else
++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
 +	if (session->input) {
 +		err = hidp_setup_input(session, req);
 +		if (err < 0)
@@ -192,29 +198,16 @@
 +		hidp_setup_hid(session, req);
 +#endif
  
- 	hidp_set_timer(session);
- 
-@@ -1097,6 +1225,7 @@ unlink:
- 		session->input = NULL;
- 	}
- 
-+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
- 	if (session->hid) {
- 		hid_destroy_device(session->hid);
- 		session->hid = NULL;
-@@ -1110,10 +1239,15 @@ purge:
- 
- 	skb_queue_purge(&session->ctrl_transmit);
- 	skb_queue_purge(&session->intr_transmit);
-+#endif
- 
- failed:
+ 	ret = hidp_session_start_sync(session);
+ 	if (ret)
+@@ -1075,6 +1209,10 @@ out_stop:
+ 	hidp_session_terminate(session);
+ out_unlock:
  	up_write(&hidp_session_sem);
- 
 +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
 +	if (session->hid)
 +		hid_free_device(session->hid);
 +#endif
- 	kfree(session);
- 	return err;
+ 	return ret;
  }
+ 
-- 
1.7.10.4


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

* [PATCH 12/12] backports: refresh patches for next-20130419
  2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
                   ` (10 preceding siblings ...)
  2013-05-11  0:27 ` [PATCH 11/12] backports: backport new bluetooth hidp session-management Luis R. Rodriguez
@ 2013-05-11  0:27 ` Luis R. Rodriguez
  11 siblings, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-11  0:27 UTC (permalink / raw)
  To: johannes; +Cc: backports, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

== ckmake-report.log ==

1   2.6.24              [  OK  ]
2   2.6.25              [  OK  ]
3   2.6.26              [  OK  ]
4   2.6.27              [  OK  ]
5   2.6.28              [  OK  ]
6   2.6.29              [  OK  ]
7   2.6.30              [  OK  ]
8   2.6.31              [  OK  ]
9   2.6.32              [  OK  ]
10  2.6.33              [  OK  ]
11  2.6.34              [  OK  ]
12  2.6.35              [  OK  ]
13  2.6.36              [  OK  ]
14  2.6.37              [  OK  ]
15  2.6.38              [  OK  ]
16  2.6.39              [  OK  ]
17  3.0.76              [  OK  ]
18  3.1.10              [  OK  ]
19  3.2.44              [  OK  ]
20  3.3.8               [  OK  ]
21  3.4.43              [  OK  ]
22  3.5.7               [  OK  ]
23  3.6.11              [  OK  ]
24  3.7.10              [  OK  ]
25  3.8.11              [  OK  ]
26  3.9.0               [  OK  ]

real    30m44.234s
user    813m54.992s
sys     126m44.115s

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 .../collateral-evolutions/network/0001-netdev_ops/atlx.patch   |    2 +-
 .../network/16-bluetooth/net_bluetooth_hci_sysfs.patch         |    2 +-
 .../network/16-bluetooth/net_bluetooth_hidp_sock.patch         |    2 +-
 .../network/16-bluetooth/net_bluetooth_sco.patch               |    2 +-
 .../drivers_net_ethernet_atheros_atlx_atl1.patch               |    8 ++++----
 .../46-use_other_workqueue/net_bluetooth_hci_core.patch        |    2 +-
 .../drivers_net_ethernet_atheros_atlx_atl1.patch               |    2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/patches/collateral-evolutions/network/0001-netdev_ops/atlx.patch b/patches/collateral-evolutions/network/0001-netdev_ops/atlx.patch
index de6ad23..8cab3be 100644
--- a/patches/collateral-evolutions/network/0001-netdev_ops/atlx.patch
+++ b/patches/collateral-evolutions/network/0001-netdev_ops/atlx.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/ethernet/atheros/atlx/atl1.c
 +++ b/drivers/net/ethernet/atheros/atlx/atl1.c
-@@ -3009,7 +3009,7 @@ static int atl1_probe(struct pci_dev *pd
+@@ -3004,7 +3004,7 @@ static int atl1_probe(struct pci_dev *pd
  	adapter->mii.phy_id_mask = 0x1f;
  	adapter->mii.reg_num_mask = 0x1f;
  
diff --git a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hci_sysfs.patch b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hci_sysfs.patch
index ac74a0e..4def823 100644
--- a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hci_sysfs.patch
+++ b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hci_sysfs.patch
@@ -24,7 +24,7 @@
  		put_device(dev);
  	}
  
-@@ -379,7 +387,11 @@ static struct attribute_group bt_host_gr
+@@ -378,7 +386,11 @@ static struct attribute_group bt_host_gr
  	.attrs = bt_host_attrs,
  };
  
diff --git a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_sock.patch b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_sock.patch
index b7bb653..3bd4644 100644
--- a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_sock.patch
+++ b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_sock.patch
@@ -1,6 +1,6 @@
 --- a/net/bluetooth/hidp/sock.c
 +++ b/net/bluetooth/hidp/sock.c
-@@ -235,8 +235,12 @@ static struct proto hidp_proto = {
+@@ -226,8 +226,12 @@ static struct proto hidp_proto = {
  	.obj_size	= sizeof(struct bt_sock)
  };
  
diff --git a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_sco.patch b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_sco.patch
index 6b6d9a5..bc63111 100644
--- a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_sco.patch
+++ b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_sco.patch
@@ -13,7 +13,7 @@
  {
  	struct sock *sk;
  
-@@ -675,7 +679,11 @@ static int sco_sock_recvmsg(struct kiocb
+@@ -711,7 +715,11 @@ static int sco_sock_recvmsg(struct kiocb
  	return bt_sock_recvmsg(iocb, sock, msg, len, flags);
  }
  
diff --git a/patches/collateral-evolutions/network/40-netdev-hw-features/drivers_net_ethernet_atheros_atlx_atl1.patch b/patches/collateral-evolutions/network/40-netdev-hw-features/drivers_net_ethernet_atheros_atlx_atl1.patch
index e44aee8..2d36137 100644
--- a/patches/collateral-evolutions/network/40-netdev-hw-features/drivers_net_ethernet_atheros_atlx_atl1.patch
+++ b/patches/collateral-evolutions/network/40-netdev-hw-features/drivers_net_ethernet_atheros_atlx_atl1.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/ethernet/atheros/atlx/atl1.c
 +++ b/drivers/net/ethernet/atheros/atlx/atl1.c
-@@ -2917,8 +2917,10 @@ static const struct net_device_ops atl1_
+@@ -2912,8 +2912,10 @@ static const struct net_device_ops atl1_
  	.ndo_validate_addr	= eth_validate_addr,
  	.ndo_set_mac_address	= atl1_set_mac,
  	.ndo_change_mtu		= atl1_change_mtu,
@@ -11,7 +11,7 @@
  	.ndo_do_ioctl		= atlx_ioctl,
  	.ndo_tx_timeout		= atlx_tx_timeout,
  #ifdef CONFIG_NET_POLL_CONTROLLER
-@@ -3028,11 +3030,13 @@ static int atl1_probe(struct pci_dev *pd
+@@ -3023,11 +3025,13 @@ static int atl1_probe(struct pci_dev *pd
  	netdev->features |= NETIF_F_SG;
  	netdev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX);
  
@@ -25,7 +25,7 @@
  
  	/*
  	 * patch for some L1 of old version,
-@@ -3645,6 +3649,14 @@ static int atl1_set_pauseparam(struct ne
+@@ -3640,6 +3644,14 @@ static int atl1_set_pauseparam(struct ne
  	return 0;
  }
  
@@ -40,7 +40,7 @@
  static void atl1_get_strings(struct net_device *netdev, u32 stringset,
  	u8 *data)
  {
-@@ -3717,4 +3729,10 @@ static const struct ethtool_ops atl1_eth
+@@ -3712,4 +3724,10 @@ static const struct ethtool_ops atl1_eth
  	.nway_reset		= atl1_nway_reset,
  	.get_ethtool_stats	= atl1_get_ethtool_stats,
  	.get_sset_count		= atl1_get_sset_count,
diff --git a/patches/collateral-evolutions/network/46-use_other_workqueue/net_bluetooth_hci_core.patch b/patches/collateral-evolutions/network/46-use_other_workqueue/net_bluetooth_hci_core.patch
index 33f0fde..9d12fdb 100644
--- a/patches/collateral-evolutions/network/46-use_other_workqueue/net_bluetooth_hci_core.patch
+++ b/patches/collateral-evolutions/network/46-use_other_workqueue/net_bluetooth_hci_core.patch
@@ -1,6 +1,6 @@
 --- a/net/bluetooth/hci_core.c
 +++ b/net/bluetooth/hci_core.c
-@@ -2181,16 +2181,24 @@ int hci_register_dev(struct hci_dev *hde
+@@ -2191,16 +2191,24 @@ int hci_register_dev(struct hci_dev *hde
  	list_add(&hdev->list, &hci_dev_list);
  	write_unlock(&hci_dev_list_lock);
  
diff --git a/patches/collateral-evolutions/network/61-netdev-addr_assign_type/drivers_net_ethernet_atheros_atlx_atl1.patch b/patches/collateral-evolutions/network/61-netdev-addr_assign_type/drivers_net_ethernet_atheros_atlx_atl1.patch
index 593de7b..c09ad69 100644
--- a/patches/collateral-evolutions/network/61-netdev-addr_assign_type/drivers_net_ethernet_atheros_atlx_atl1.patch
+++ b/patches/collateral-evolutions/network/61-netdev-addr_assign_type/drivers_net_ethernet_atheros_atlx_atl1.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/ethernet/atheros/atlx/atl1.c
 +++ b/drivers/net/ethernet/atheros/atlx/atl1.c
-@@ -3060,7 +3060,9 @@ static int atl1_probe(struct pci_dev *pd
+@@ -3055,7 +3055,9 @@ static int atl1_probe(struct pci_dev *pd
  	/* copy the MAC address out of the EEPROM */
  	if (atl1_read_mac_addr(&adapter->hw)) {
  		/* mark random mac */
-- 
1.7.10.4


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

* Re: [PATCH 11/12] backports: backport new bluetooth hidp session-management
  2013-05-11  0:27 ` [PATCH 11/12] backports: backport new bluetooth hidp session-management Luis R. Rodriguez
@ 2013-05-12 12:26   ` David Herrmann
  2013-05-12 19:33     ` Luis R. Rodriguez
  0 siblings, 1 reply; 27+ messages in thread
From: David Herrmann @ 2013-05-12 12:26 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: Johannes Berg, backports

Hi Luis

On Sat, May 11, 2013 at 2:27 AM, Luis R. Rodriguez
<mcgrof@do-not-panic.com> wrote:
> From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
>
> Commit b4f34d8d9 on next-20130419 added new bluetooth hidp
> session-management helper, then commit 520518 also on
> next-20130419 replaced the old management code with
> the new one.
>
> Someone really needs to run time test this for regressions.

I never worked with the backports tree, so excuse me if I am not
entirely sure about all of this. I also doubt that it introduces
regressions, as it actually was intended to fix 5-year old
regressions.. Anyhow, I can try.

Is there a more recent version of the 16-bluetooth/ patches, or do I
need to generate these myself? I only found
  https://git.kernel.org/cgit/linux/kernel/git/mcgrof/compat-drivers.git/tree/patches/collateral-evolutions/network/16-bluetooth.patch
which is definitely too old.

Some comments below.

> commit b4f34d8d9d26b2428fa7cf7c8f97690a297978e6
> Author: David Herrmann <dh.herrmann@gmail.com>
> Date:   Sat Apr 6 20:28:46 2013 +0200
>
>     Bluetooth: hidp: add new session-management helpers
>
>     This is a rewrite of the HIDP session management. It implements HIDP as an
>     l2cap_user sub-module so we get proper notification when the underlying
>     connection goes away.
>
>     The helpers are not yet used but only added in this commit. The old
>     session management is still used and will be removed in a following patch.
>
>     The old session-management was flawed. Hotplugging is horribly broken and
>     we have no way of getting notified when the underlying connection goes
>     down. The whole idea of removing the HID/input sub-devices from within the
>     session itself is broken and suffers from major dead-locks. We never can
>     guarantee that the session can unregister itself as long as we use
>     synchronous shutdowns. This can only work with asynchronous shutdowns.
>     However, in this case we _must_ be able to unregister the session from the
>     outside as otherwise the l2cap_conn object might be unlinked before we
>     are.
>
>     The new session-management is based on l2cap_user. There is only one
>     way how to add a session and how to delete a session: "probe" and "remove"
>     callbacks from l2cap_user.
>     This guarantees that the session can be registered and unregistered at
>     _any_ time without any synchronous shutdown.
>     On the other hand, much work has been put into proper session-refcounting.
>     We can unregister/unlink the session only if we can guarantee that it will
>     stay alive. But for asynchronous shutdowns we never know when the last
>     user goes away so we must use proper ref-counting.
>
>     The old ->conn field has been renamed to ->hconn so we can reuse ->conn in
>     the new session management. No other existing HIDP code is modified.
>
>     Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
>     Acked-by: Marcel Holtmann <marcel@holtmann.org>
>     Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> commit 5205185d461d5902325e457ca80bd421127b7308
> Author: David Herrmann <dh.herrmann@gmail.com>
> Date:   Sat Apr 6 20:28:47 2013 +0200
>
>     Bluetooth: hidp: remove old session-management
>
>     We have the full new session-management now available so lets switch over
>     and remove all the old code. Few semantics changed, so we need to adjust
>     the sock.c callers a bit. But this mostly simplifies the logic.
>
>     Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
>     Acked-by: Marcel Holtmann <marcel@holtmann.org>
>     Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> Cc: dh.herrmann@gmail.com
> Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
> ---
>  .../16-bluetooth/net_bluetooth_hidp_core.patch     |  109 +++++++++-----------
>  1 file changed, 51 insertions(+), 58 deletions(-)
>
> diff --git a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_core.patch b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_core.patch
> index 60a97e6..01a859a 100644
> --- a/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_core.patch
> +++ b/patches/collateral-evolutions/network/16-bluetooth/net_bluetooth_hidp_core.patch
> @@ -1,6 +1,6 @@
>  --- a/net/bluetooth/hidp/core.c
>  +++ b/net/bluetooth/hidp/core.c
> -@@ -383,6 +383,7 @@ err:
> +@@ -329,6 +329,7 @@ err:
>         return ret;
>   }
>
> @@ -8,7 +8,7 @@
>   static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count,
>                 unsigned char report_type)
>   {
> -@@ -441,6 +442,16 @@ err:
> +@@ -386,6 +387,16 @@ err:
>         mutex_unlock(&session->report_mutex);
>         return ret;
>   }
> @@ -25,22 +25,7 @@
>
>   static void hidp_idle_timeout(unsigned long arg)
>   {
> -@@ -743,8 +754,14 @@ static int hidp_session(void *arg)
> -       }
> -
> -       if (session->hid) {
> -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
> -               hid_destroy_device(session->hid);
> -               session->hid = NULL;
> -+#else
> -+              if (session->hid->claimed & HID_CLAIMED_INPUT)
> -+                      hidinput_disconnect(session->hid);
> -+              hid_free_device(session->hid);
> -+#endif
> -       }
> -
> -       /* Wakeup user-space polling for socket errors */

This looks fine to me.

> -@@ -855,6 +872,70 @@ static void hidp_close(struct hid_device
> +@@ -674,6 +685,70 @@ static void hidp_close(struct hid_device
>   {
>   }
>
> @@ -111,8 +96,8 @@
>   static int hidp_parse(struct hid_device *hid)
>   {
>         struct hidp_session *session = hid->driver_data;
> -@@ -946,7 +1027,9 @@ static int hidp_setup_hid(struct hidp_se
> -       hid->dev.parent = &session->conn->dev;
> +@@ -764,13 +839,21 @@ static int hidp_setup_hid(struct hidp_se
> +       hid->dev.parent = &session->conn->hcon->dev;

looks good

>         hid->ll_driver = &hidp_hid_driver;
>
>  +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
> @@ -121,17 +106,46 @@
>         hid->hid_output_raw_report = hidp_output_raw_report;
>
>         /* True if device is blacklisted in drivers/hid/hid-core.c */
> -@@ -964,6 +1047,7 @@ fault:
> +       if (hid_ignore(hid)) {
> ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
> +               hid_destroy_device(session->hid);
> +               session->hid = NULL;
> ++#else
> ++              if (session->hid->claimed & HID_CLAIMED_INPUT)
> ++                      hidinput_disconnect(session->hid);
> ++              hid_free_device(session->hid);
> ++#endif
> +               return -ENODEV;
> +       }
> +
> +@@ -782,6 +865,7 @@ fault:

looks good

>
>         return err;
>   }
>  +#endif
>
> - int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock)
> + /* initialize session devices */
> + static int hidp_session_dev_init(struct hidp_session *session,
> +@@ -844,8 +928,15 @@ static int hidp_session_dev_add(struct h
> + /* remove HID/input devices from their bus systems */
> + static void hidp_session_dev_del(struct hidp_session *session)
>   {
> -@@ -981,6 +1065,39 @@ int hidp_add_connection(struct hidp_conn
> -
> -       BT_DBG("rd_data %p rd_size %d", req->rd_data, req->rd_size);
> +-      if (session->hid)
> ++      if (session->hid) {
> ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
> +               hid_destroy_device(session->hid);
> ++#else
> ++              if (session->hid->claimed & HID_CLAIMED_INPUT)
> ++                      hidinput_disconnect(session->hid);
> ++              hid_free_device(session->hid);
> ++#endif
> ++      }
> +       else if (session->input)
> +               input_unregister_device(session->input);
> + }
> +@@ -1049,6 +1140,39 @@ static int hidp_session_probe(struct l2c
> +       struct hidp_session *s;
> +       int ret;

looks good

>
>  +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
>  +      if (req->rd_size > 0) {
> @@ -168,20 +182,12 @@
>  +#endif
>         down_write(&hidp_session_sem);
>
> -       s = __hidp_get_session(&bt_sk(ctrl_sock->sk)->dst);
> -@@ -1028,6 +1145,7 @@ int hidp_add_connection(struct hidp_conn
> -
> -       __hidp_link_session(session);
> -
> -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
> -       if (req->rd_size > 0) {
> -               err = hidp_setup_hid(session, req);
> -               if (err && err != -ENODEV)
> -@@ -1039,6 +1157,16 @@ int hidp_add_connection(struct hidp_conn
> -               if (err < 0)
> -                       goto purge;

looks good

> +       /* check that no other session for this device exists */
> +@@ -1057,6 +1181,16 @@ static int hidp_session_probe(struct l2c
> +               ret = -EEXIST;
> +               goto out_unlock;
>         }
> -+#else
> ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
>  +      if (session->input) {
>  +              err = hidp_setup_input(session, req);
>  +              if (err < 0)
> @@ -192,29 +198,16 @@
>  +              hidp_setup_hid(session, req);
>  +#endif

This looks wrong. hidp_session_probe() no longer handles input/hid
devices. This should be done in hidp_session_dev_init().

>
> -       hidp_set_timer(session);
> -
> -@@ -1097,6 +1225,7 @@ unlink:
> -               session->input = NULL;
> -       }
> -
> -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
> -       if (session->hid) {
> -               hid_destroy_device(session->hid);
> -               session->hid = NULL;
> -@@ -1110,10 +1239,15 @@ purge:
> -
> -       skb_queue_purge(&session->ctrl_transmit);
> -       skb_queue_purge(&session->intr_transmit);
> -+#endif
> -
> - failed:
> +       ret = hidp_session_start_sync(session);
> +       if (ret)
> +@@ -1075,6 +1209,10 @@ out_stop:
> +       hidp_session_terminate(session);
> + out_unlock:
>         up_write(&hidp_session_sem);
> -
>  +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
>  +      if (session->hid)
>  +              hid_free_device(session->hid);
>  +#endif

That looks wrong, too, but as it is the bottom half of the diff above,
it's probably related.

Thanks
David

> -       kfree(session);
> -       return err;
> +       return ret;
>   }
> +
> --
> 1.7.10.4
>

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

* Re: [PATCH 11/12] backports: backport new bluetooth hidp session-management
  2013-05-12 12:26   ` David Herrmann
@ 2013-05-12 19:33     ` Luis R. Rodriguez
  2013-05-12 20:21       ` Luis R. Rodriguez
  2013-05-12 21:38       ` David Herrmann
  0 siblings, 2 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-12 19:33 UTC (permalink / raw)
  To: David Herrmann; +Cc: Johannes Berg, backports

On Sun, May 12, 2013 at 5:26 AM, David Herrmann <dh.herrmann@gmail.com> wrote:
> On Sat, May 11, 2013 at 2:27 AM, Luis R. Rodriguez <mcgrof@do-not-panic.com> wrote:
>> From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
>
> I never worked with the backports tree, so excuse me if I am not
> entirely sure about all of this. I also doubt that it introduces
> regressions, as it actually was intended to fix 5-year old
> regressions.. Anyhow, I can try.

No worries and forgive us for the lack of up to date documentation but
in between the last part of the development cycle for v3.10 Johannes
made some huge changes that we're incorporating into the releases
planned based on v3.10, and two new subsystems were added, as it is
now a new temporary tree is being used for development which I then
will fork on kernel.org once ready for releases. I will add the
documentation required but for now we've just been trying to catch up
to each linux-next tag to ensure we can get a release brewed in time
for the v3.10 release (rc1 is out today). Progress is good though.

The temporary tree is:

git://git.sipsolutions.net/backports.git

Then I have 26 patch delta on top of this which for now you can get here:

http://drvbp1.linux-foundation.org/~mcgrof/backport-tmp/pending-next-20130426.patch

You can git am that. That would get you up to my latest changes. The
change we are reviewing here in this thread is commit
b8d21c2845038e334c8976b7f54e921afcbc7924 once that delta is applied.

To generate a release you'd need a linux-next tree as well reset to
next-20130426 and then from the backports tree you can do:

./gentree.py --verbose /home/mcgrof/linux-next
/home/mcgrof/build/backports-20130426

> Is there a more recent version of the 16-bluetooth/ patches, or do I
> need to generate these myself? I only found
>   https://git.kernel.org/cgit/linux/kernel/git/mcgrof/compat-drivers.git/tree/patches/collateral-evolutions/network/16-bluetooth.patch
> which is definitely too old.

Indeed, given the current state of affairs of development on the
backports project to make things easier for you you can either get the
changes as described above or I can give you a temporary tarball and
if you can send me the delta to what you think should go in place?

http://drvbp1.linux-foundation.org/~mcgrof/backport-tmp/backports-20130426.tar.bz2

If you'd like to build, just make menuconfig on whatever kernel you're on.

Feel free to use whatever works best for you and I really appreciate
you taking time to review this.

>> +       /* check that no other session for this device exists */
>> +@@ -1057,6 +1181,16 @@ static int hidp_session_probe(struct l2c
>> +               ret = -EEXIST;
>> +               goto out_unlock;
>>         }
>> -+#else
>> ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
>>  +      if (session->input) {
>>  +              err = hidp_setup_input(session, req);
>>  +              if (err < 0)
>> @@ -192,29 +198,16 @@
>>  +              hidp_setup_hid(session, req);
>>  +#endif
>
> This looks wrong. hidp_session_probe() no longer handles input/hid
> devices. This should be done in hidp_session_dev_init().

Got it.

>> -       hidp_set_timer(session);
>> -
>> -@@ -1097,6 +1225,7 @@ unlink:
>> -               session->input = NULL;
>> -       }
>> -
>> -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
>> -       if (session->hid) {
>> -               hid_destroy_device(session->hid);
>> -               session->hid = NULL;
>> -@@ -1110,10 +1239,15 @@ purge:
>> -
>> -       skb_queue_purge(&session->ctrl_transmit);
>> -       skb_queue_purge(&session->intr_transmit);
>> -+#endif
>> -
>> - failed:
>> +       ret = hidp_session_start_sync(session);
>> +       if (ret)
>> +@@ -1075,6 +1209,10 @@ out_stop:
>> +       hidp_session_terminate(session);
>> + out_unlock:
>>         up_write(&hidp_session_sem);
>> -
>>  +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
>>  +      if (session->hid)
>>  +              hid_free_device(session->hid);
>>  +#endif
>
> That looks wrong, too, but as it is the bottom half of the diff above,
> it's probably related.

I think patch miserably guessed the hunks where to apply some of these
changes to. I tried to make sense of it but the rewrite was a bit big
so I was not sure where to places things correctly, hence me Cc'ing
you, I really appreciate you reviewing this.

  Luis

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

* Re: [PATCH 11/12] backports: backport new bluetooth hidp session-management
  2013-05-12 19:33     ` Luis R. Rodriguez
@ 2013-05-12 20:21       ` Luis R. Rodriguez
  2013-05-12 21:38       ` David Herrmann
  1 sibling, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-12 20:21 UTC (permalink / raw)
  To: David Herrmann; +Cc: Johannes Berg, backports

On Sun, May 12, 2013 at 12:33 PM, Luis R. Rodriguez
<mcgrof@do-not-panic.com> wrote:
>
> http://drvbp1.linux-foundation.org/~mcgrof/backport-tmp/backports-20130426.tar.bz2

Realizing that you might want to see what this looked like prior to
your changes being merged into linux-next here is a tarball for that,
its based on next-20130415 and the backports git tree reset to
43c24dc310979c70d04269a5138eb1b5e77ac3d0.

http://drvbp1.linux-foundation.org/~mcgrof/backport-tmp/backports-20130415.tar.bz2

  Luis

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

* Re: [PATCH 11/12] backports: backport new bluetooth hidp session-management
  2013-05-12 19:33     ` Luis R. Rodriguez
  2013-05-12 20:21       ` Luis R. Rodriguez
@ 2013-05-12 21:38       ` David Herrmann
  2013-05-13  1:30         ` Luis R. Rodriguez
  1 sibling, 1 reply; 27+ messages in thread
From: David Herrmann @ 2013-05-12 21:38 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: Johannes Berg, backports

[-- Attachment #1: Type: text/plain, Size: 5079 bytes --]

Hi Luis

On Sun, May 12, 2013 at 9:33 PM, Luis R. Rodriguez
<mcgrof@do-not-panic.com> wrote:
> On Sun, May 12, 2013 at 5:26 AM, David Herrmann <dh.herrmann@gmail.com> wrote:
>> On Sat, May 11, 2013 at 2:27 AM, Luis R. Rodriguez <mcgrof@do-not-panic.com> wrote:
>>> From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
>>
>> I never worked with the backports tree, so excuse me if I am not
>> entirely sure about all of this. I also doubt that it introduces
>> regressions, as it actually was intended to fix 5-year old
>> regressions.. Anyhow, I can try.
>
> No worries and forgive us for the lack of up to date documentation but
> in between the last part of the development cycle for v3.10 Johannes
> made some huge changes that we're incorporating into the releases
> planned based on v3.10, and two new subsystems were added, as it is
> now a new temporary tree is being used for development which I then
> will fork on kernel.org once ready for releases. I will add the
> documentation required but for now we've just been trying to catch up
> to each linux-next tag to ensure we can get a release brewed in time
> for the v3.10 release (rc1 is out today). Progress is good though.
>
> The temporary tree is:
>
> git://git.sipsolutions.net/backports.git
>
> Then I have 26 patch delta on top of this which for now you can get here:
>
> http://drvbp1.linux-foundation.org/~mcgrof/backport-tmp/pending-next-20130426.patch
>
> You can git am that. That would get you up to my latest changes. The
> change we are reviewing here in this thread is commit
> b8d21c2845038e334c8976b7f54e921afcbc7924 once that delta is applied.
>
> To generate a release you'd need a linux-next tree as well reset to
> next-20130426 and then from the backports tree you can do:
>
> ./gentree.py --verbose /home/mcgrof/linux-next
> /home/mcgrof/build/backports-20130426
>
>> Is there a more recent version of the 16-bluetooth/ patches, or do I
>> need to generate these myself? I only found
>>   https://git.kernel.org/cgit/linux/kernel/git/mcgrof/compat-drivers.git/tree/patches/collateral-evolutions/network/16-bluetooth.patch
>> which is definitely too old.
>
> Indeed, given the current state of affairs of development on the
> backports project to make things easier for you you can either get the
> changes as described above or I can give you a temporary tarball and
> if you can send me the delta to what you think should go in place?
>
> http://drvbp1.linux-foundation.org/~mcgrof/backport-tmp/backports-20130426.tar.bz2

That one helped a lot, thx!

> If you'd like to build, just make menuconfig on whatever kernel you're on.
>
> Feel free to use whatever works best for you and I really appreciate
> you taking time to review this.
>
>>> +       /* check that no other session for this device exists */
>>> +@@ -1057,6 +1181,16 @@ static int hidp_session_probe(struct l2c
>>> +               ret = -EEXIST;
>>> +               goto out_unlock;
>>>         }
>>> -+#else
>>> ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
>>>  +      if (session->input) {
>>>  +              err = hidp_setup_input(session, req);
>>>  +              if (err < 0)
>>> @@ -192,29 +198,16 @@
>>>  +              hidp_setup_hid(session, req);
>>>  +#endif
>>
>> This looks wrong. hidp_session_probe() no longer handles input/hid
>> devices. This should be done in hidp_session_dev_init().
>
> Got it.
>
>>> -       hidp_set_timer(session);
>>> -
>>> -@@ -1097,6 +1225,7 @@ unlink:
>>> -               session->input = NULL;
>>> -       }
>>> -
>>> -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
>>> -       if (session->hid) {
>>> -               hid_destroy_device(session->hid);
>>> -               session->hid = NULL;
>>> -@@ -1110,10 +1239,15 @@ purge:
>>> -
>>> -       skb_queue_purge(&session->ctrl_transmit);
>>> -       skb_queue_purge(&session->intr_transmit);
>>> -+#endif
>>> -
>>> - failed:
>>> +       ret = hidp_session_start_sync(session);
>>> +       if (ret)
>>> +@@ -1075,6 +1209,10 @@ out_stop:
>>> +       hidp_session_terminate(session);
>>> + out_unlock:
>>>         up_write(&hidp_session_sem);
>>> -
>>>  +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
>>>  +      if (session->hid)
>>>  +              hid_free_device(session->hid);
>>>  +#endif
>>
>> That looks wrong, too, but as it is the bottom half of the diff above,
>> it's probably related.
>
> I think patch miserably guessed the hunks where to apply some of these
> changes to. I tried to make sense of it but the rewrite was a bit big
> so I was not sure where to places things correctly, hence me Cc'ing
> you, I really appreciate you reviewing this.

Yeah, it was really weird. I fixed it up how I think it should work.
However, compiling kernels takes like 50min here (hurray, intel
Atom!), so this isn't even compile-tested. I can do this later this
week if you want.

The net/bluetooth/hidp/core.c file is attached. It is from the tarball
you created above (2013-04-26). I fixed some other small issues. Can
you tell me whether that works for you? The diff to linux-next is
pretty small.

Thanks
David

[-- Attachment #2: core.c --]
[-- Type: text/x-csrc, Size: 39274 bytes --]

/*
   HIDP implementation for Linux Bluetooth stack (BlueZ).
   Copyright (C) 2003-2004 Marcel Holtmann <marcel@holtmann.org>
   Copyright (C) 2013 David Herrmann <dh.herrmann@gmail.com>

   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;

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
   SOFTWARE IS DISCLAIMED.
*/

#include <linux/kref.h>
#include <linux/module.h>
#include <linux/file.h>
#include <linux/kthread.h>
#include <linux/hidraw.h>

#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/l2cap.h>

#include "hidp.h"

#define VERSION "1.2"

static DECLARE_RWSEM(hidp_session_sem);
static LIST_HEAD(hidp_session_list);

static unsigned char hidp_keycode[256] = {
	  0,   0,   0,   0,  30,  48,  46,  32,  18,  33,  34,  35,  23,  36,
	 37,  38,  50,  49,  24,  25,  16,  19,  31,  20,  22,  47,  17,  45,
	 21,  44,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  28,   1,
	 14,  15,  57,  12,  13,  26,  27,  43,  43,  39,  40,  41,  51,  52,
	 53,  58,  59,  60,  61,  62,  63,  64,  65,  66,  67,  68,  87,  88,
	 99,  70, 119, 110, 102, 104, 111, 107, 109, 106, 105, 108, 103,  69,
	 98,  55,  74,  78,  96,  79,  80,  81,  75,  76,  77,  71,  72,  73,
	 82,  83,  86, 127, 116, 117, 183, 184, 185, 186, 187, 188, 189, 190,
	191, 192, 193, 194, 134, 138, 130, 132, 128, 129, 131, 137, 133, 135,
	136, 113, 115, 114,   0,   0,   0, 121,   0,  89,  93, 124,  92,  94,
	 95,   0,   0,   0, 122, 123,  90,  91,  85,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
	 29,  42,  56, 125,  97,  54, 100, 126, 164, 166, 165, 163, 161, 115,
	114, 113, 150, 158, 159, 128, 136, 177, 178, 176, 142, 152, 173, 140
};

static unsigned char hidp_mkeyspat[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };

static int hidp_session_probe(struct l2cap_conn *conn,
			      struct l2cap_user *user);
static void hidp_session_remove(struct l2cap_conn *conn,
				struct l2cap_user *user);
static int hidp_session_thread(void *arg);
static void hidp_session_terminate(struct hidp_session *s);

static void hidp_copy_session(struct hidp_session *session, struct hidp_conninfo *ci)
{
	memset(ci, 0, sizeof(*ci));
	bacpy(&ci->bdaddr, &session->bdaddr);

	ci->flags = session->flags;
	ci->state = BT_CONNECTED;

	ci->vendor  = 0x0000;
	ci->product = 0x0000;
	ci->version = 0x0000;

	if (session->input) {
		ci->vendor  = session->input->id.vendor;
		ci->product = session->input->id.product;
		ci->version = session->input->id.version;
		if (session->input->name)
			strncpy(ci->name, session->input->name, 128);
		else
			strncpy(ci->name, "HID Boot Device", 128);
	}

	if (session->hid) {
		ci->vendor  = session->hid->vendor;
		ci->product = session->hid->product;
		ci->version = session->hid->version;
		strncpy(ci->name, session->hid->name, 128);
	}
}

/* assemble skb, queue message on @transmit and wake up the session thread */
static int hidp_send_message(struct hidp_session *session, struct socket *sock,
			     struct sk_buff_head *transmit, unsigned char hdr,
			     const unsigned char *data, int size)
{
	struct sk_buff *skb;
	struct sock *sk = sock->sk;

	BT_DBG("session %p data %p size %d", session, data, size);

	if (atomic_read(&session->terminate))
		return -EIO;

	skb = alloc_skb(size + 1, GFP_ATOMIC);
	if (!skb) {
		BT_ERR("Can't allocate memory for new frame");
		return -ENOMEM;
	}

	*skb_put(skb, 1) = hdr;
	if (data && size > 0)
		memcpy(skb_put(skb, size), data, size);

	skb_queue_tail(transmit, skb);
	wake_up_interruptible(sk_sleep(sk));

	return 0;
}

static int hidp_send_ctrl_message(struct hidp_session *session,
				  unsigned char hdr, const unsigned char *data,
				  int size)
{
	return hidp_send_message(session, session->ctrl_sock,
				 &session->ctrl_transmit, hdr, data, size);
}

static int hidp_send_intr_message(struct hidp_session *session,
				  unsigned char hdr, const unsigned char *data,
				  int size)
{
	return hidp_send_message(session, session->intr_sock,
				 &session->intr_transmit, hdr, data, size);
}

static int hidp_input_event(struct input_dev *dev, unsigned int type,
			    unsigned int code, int value)
{
	struct hidp_session *session = input_get_drvdata(dev);
	unsigned char newleds;
	unsigned char hdr, data[2];

	BT_DBG("session %p type %d code %d value %d",
	       session, type, code, value);

	if (type != EV_LED)
		return -1;

	newleds = (!!test_bit(LED_KANA,    dev->led) << 3) |
		  (!!test_bit(LED_COMPOSE, dev->led) << 3) |
		  (!!test_bit(LED_SCROLLL, dev->led) << 2) |
		  (!!test_bit(LED_CAPSL,   dev->led) << 1) |
		  (!!test_bit(LED_NUML,    dev->led));

	if (session->leds == newleds)
		return 0;

	session->leds = newleds;

	hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT;
	data[0] = 0x01;
	data[1] = newleds;

	return hidp_send_intr_message(session, hdr, data, 2);
}

static void hidp_input_report(struct hidp_session *session, struct sk_buff *skb)
{
	struct input_dev *dev = session->input;
	unsigned char *keys = session->keys;
	unsigned char *udata = skb->data + 1;
	signed char *sdata = skb->data + 1;
	int i, size = skb->len - 1;

	switch (skb->data[0]) {
	case 0x01:	/* Keyboard report */
		for (i = 0; i < 8; i++)
			input_report_key(dev, hidp_keycode[i + 224], (udata[0] >> i) & 1);

		/* If all the key codes have been set to 0x01, it means
		 * too many keys were pressed at the same time. */
		if (!memcmp(udata + 2, hidp_mkeyspat, 6))
			break;

		for (i = 2; i < 8; i++) {
			if (keys[i] > 3 && memscan(udata + 2, keys[i], 6) == udata + 8) {
				if (hidp_keycode[keys[i]])
					input_report_key(dev, hidp_keycode[keys[i]], 0);
				else
					BT_ERR("Unknown key (scancode %#x) released.", keys[i]);
			}

			if (udata[i] > 3 && memscan(keys + 2, udata[i], 6) == keys + 8) {
				if (hidp_keycode[udata[i]])
					input_report_key(dev, hidp_keycode[udata[i]], 1);
				else
					BT_ERR("Unknown key (scancode %#x) pressed.", udata[i]);
			}
		}

		memcpy(keys, udata, 8);
		break;

	case 0x02:	/* Mouse report */
		input_report_key(dev, BTN_LEFT,   sdata[0] & 0x01);
		input_report_key(dev, BTN_RIGHT,  sdata[0] & 0x02);
		input_report_key(dev, BTN_MIDDLE, sdata[0] & 0x04);
		input_report_key(dev, BTN_SIDE,   sdata[0] & 0x08);
		input_report_key(dev, BTN_EXTRA,  sdata[0] & 0x10);

		input_report_rel(dev, REL_X, sdata[1]);
		input_report_rel(dev, REL_Y, sdata[2]);

		if (size > 3)
			input_report_rel(dev, REL_WHEEL, sdata[3]);
		break;
	}

	input_sync(dev);
}

static int hidp_send_report(struct hidp_session *session, struct hid_report *report)
{
	unsigned char buf[32], hdr;
	int rsize;

	rsize = ((report->size - 1) >> 3) + 1 + (report->id > 0);
	if (rsize > sizeof(buf))
		return -EIO;

	hid_output_report(report, buf);
	hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT;

	return hidp_send_intr_message(session, hdr, buf, rsize);
}

static int hidp_get_raw_report(struct hid_device *hid,
		unsigned char report_number,
		unsigned char *data, size_t count,
		unsigned char report_type)
{
	struct hidp_session *session = hid->driver_data;
	struct sk_buff *skb;
	size_t len;
	int numbered_reports = hid->report_enum[report_type].numbered;
	int ret;

	if (atomic_read(&session->terminate))
		return -EIO;

	switch (report_type) {
	case HID_FEATURE_REPORT:
		report_type = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_FEATURE;
		break;
	case HID_INPUT_REPORT:
		report_type = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_INPUT;
		break;
	case HID_OUTPUT_REPORT:
		report_type = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_OUPUT;
		break;
	default:
		return -EINVAL;
	}

	if (mutex_lock_interruptible(&session->report_mutex))
		return -ERESTARTSYS;

	/* Set up our wait, and send the report request to the device. */
	session->waiting_report_type = report_type & HIDP_DATA_RTYPE_MASK;
	session->waiting_report_number = numbered_reports ? report_number : -1;
	set_bit(HIDP_WAITING_FOR_RETURN, &session->flags);
	data[0] = report_number;
	ret = hidp_send_ctrl_message(session, report_type, data, 1);
	if (ret)
		goto err;

	/* Wait for the return of the report. The returned report
	   gets put in session->report_return.  */
	while (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags) &&
	       !atomic_read(&session->terminate)) {
		int res;

		res = wait_event_interruptible_timeout(session->report_queue,
			!test_bit(HIDP_WAITING_FOR_RETURN, &session->flags)
				|| atomic_read(&session->terminate),
			5*HZ);
		if (res == 0) {
			/* timeout */
			ret = -EIO;
			goto err;
		}
		if (res < 0) {
			/* signal */
			ret = -ERESTARTSYS;
			goto err;
		}
	}

	skb = session->report_return;
	if (skb) {
		len = skb->len < count ? skb->len : count;
		memcpy(data, skb->data, len);

		kfree_skb(skb);
		session->report_return = NULL;
	} else {
		/* Device returned a HANDSHAKE, indicating  protocol error. */
		len = -EIO;
	}

	clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags);
	mutex_unlock(&session->report_mutex);

	return len;

err:
	clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags);
	mutex_unlock(&session->report_mutex);
	return ret;
}

#if defined(CPTCFG_BACKPORT_OPTION_BT_SOCK_CREATE_NEEDS_KERN)
static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count,
		unsigned char report_type)
{
	struct hidp_session *session = hid->driver_data;
	int ret;

	if (report_type == HID_OUTPUT_REPORT) {
		report_type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT;
		return hidp_send_intr_message(session, report_type,
					      data, count);
	} else if (report_type != HID_FEATURE_REPORT) {
		return -EINVAL;
	}

	if (mutex_lock_interruptible(&session->report_mutex))
		return -ERESTARTSYS;

	/* Set up our wait, and send the report request to the device. */
	set_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags);
	report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE;
	ret = hidp_send_ctrl_message(session, report_type, data, count);
	if (ret)
		goto err;

	/* Wait for the ACK from the device. */
	while (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags) &&
	       !atomic_read(&session->terminate)) {
		int res;

		res = wait_event_interruptible_timeout(session->report_queue,
			!test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)
				|| atomic_read(&session->terminate),
			10*HZ);
		if (res == 0) {
			/* timeout */
			ret = -EIO;
			goto err;
		}
		if (res < 0) {
			/* signal */
			ret = -ERESTARTSYS;
			goto err;
		}
	}

	if (!session->output_report_success) {
		ret = -EIO;
		goto err;
	}

	ret = count;

err:
	clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags);
	mutex_unlock(&session->report_mutex);
	return ret;
}
#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count)
{
	if (hidp_send_ctrl_message(hid->driver_data,
			HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE,
			data, count))
		return -ENOMEM;
	return count;
}
#endif

static void hidp_idle_timeout(unsigned long arg)
{
	struct hidp_session *session = (struct hidp_session *) arg;

	hidp_session_terminate(session);
}

static void hidp_set_timer(struct hidp_session *session)
{
	if (session->idle_to > 0)
		mod_timer(&session->timer, jiffies + HZ * session->idle_to);
}

static void hidp_del_timer(struct hidp_session *session)
{
	if (session->idle_to > 0)
		del_timer(&session->timer);
}

static void hidp_process_handshake(struct hidp_session *session,
					unsigned char param)
{
	BT_DBG("session %p param 0x%02x", session, param);
	session->output_report_success = 0; /* default condition */

	switch (param) {
	case HIDP_HSHK_SUCCESSFUL:
		/* FIXME: Call into SET_ GET_ handlers here */
		session->output_report_success = 1;
		break;

	case HIDP_HSHK_NOT_READY:
	case HIDP_HSHK_ERR_INVALID_REPORT_ID:
	case HIDP_HSHK_ERR_UNSUPPORTED_REQUEST:
	case HIDP_HSHK_ERR_INVALID_PARAMETER:
		if (test_and_clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags))
			wake_up_interruptible(&session->report_queue);

		/* FIXME: Call into SET_ GET_ handlers here */
		break;

	case HIDP_HSHK_ERR_UNKNOWN:
		break;

	case HIDP_HSHK_ERR_FATAL:
		/* Device requests a reboot, as this is the only way this error
		 * can be recovered. */
		hidp_send_ctrl_message(session,
			HIDP_TRANS_HID_CONTROL | HIDP_CTRL_SOFT_RESET, NULL, 0);
		break;

	default:
		hidp_send_ctrl_message(session,
			HIDP_TRANS_HANDSHAKE | HIDP_HSHK_ERR_INVALID_PARAMETER, NULL, 0);
		break;
	}

	/* Wake up the waiting thread. */
	if (test_and_clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags))
		wake_up_interruptible(&session->report_queue);
}

static void hidp_process_hid_control(struct hidp_session *session,
					unsigned char param)
{
	BT_DBG("session %p param 0x%02x", session, param);

	if (param == HIDP_CTRL_VIRTUAL_CABLE_UNPLUG) {
		/* Flush the transmit queues */
		skb_queue_purge(&session->ctrl_transmit);
		skb_queue_purge(&session->intr_transmit);

		hidp_session_terminate(session);
	}
}

/* Returns true if the passed-in skb should be freed by the caller. */
static int hidp_process_data(struct hidp_session *session, struct sk_buff *skb,
				unsigned char param)
{
	int done_with_skb = 1;
	BT_DBG("session %p skb %p len %d param 0x%02x", session, skb, skb->len, param);

	switch (param) {
	case HIDP_DATA_RTYPE_INPUT:
		hidp_set_timer(session);

		if (session->input)
			hidp_input_report(session, skb);

		if (session->hid)
			hid_input_report(session->hid, HID_INPUT_REPORT, skb->data, skb->len, 0);
		break;

	case HIDP_DATA_RTYPE_OTHER:
	case HIDP_DATA_RTYPE_OUPUT:
	case HIDP_DATA_RTYPE_FEATURE:
		break;

	default:
		hidp_send_ctrl_message(session,
			HIDP_TRANS_HANDSHAKE | HIDP_HSHK_ERR_INVALID_PARAMETER, NULL, 0);
	}

	if (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags) &&
				param == session->waiting_report_type) {
		if (session->waiting_report_number < 0 ||
		    session->waiting_report_number == skb->data[0]) {
			/* hidp_get_raw_report() is waiting on this report. */
			session->report_return = skb;
			done_with_skb = 0;
			clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags);
			wake_up_interruptible(&session->report_queue);
		}
	}

	return done_with_skb;
}

static void hidp_recv_ctrl_frame(struct hidp_session *session,
					struct sk_buff *skb)
{
	unsigned char hdr, type, param;
	int free_skb = 1;

	BT_DBG("session %p skb %p len %d", session, skb, skb->len);

	hdr = skb->data[0];
	skb_pull(skb, 1);

	type = hdr & HIDP_HEADER_TRANS_MASK;
	param = hdr & HIDP_HEADER_PARAM_MASK;

	switch (type) {
	case HIDP_TRANS_HANDSHAKE:
		hidp_process_handshake(session, param);
		break;

	case HIDP_TRANS_HID_CONTROL:
		hidp_process_hid_control(session, param);
		break;

	case HIDP_TRANS_DATA:
		free_skb = hidp_process_data(session, skb, param);
		break;

	default:
		hidp_send_ctrl_message(session,
			HIDP_TRANS_HANDSHAKE | HIDP_HSHK_ERR_UNSUPPORTED_REQUEST, NULL, 0);
		break;
	}

	if (free_skb)
		kfree_skb(skb);
}

static void hidp_recv_intr_frame(struct hidp_session *session,
				struct sk_buff *skb)
{
	unsigned char hdr;

	BT_DBG("session %p skb %p len %d", session, skb, skb->len);

	hdr = skb->data[0];
	skb_pull(skb, 1);

	if (hdr == (HIDP_TRANS_DATA | HIDP_DATA_RTYPE_INPUT)) {
		hidp_set_timer(session);

		if (session->input)
			hidp_input_report(session, skb);

		if (session->hid) {
			hid_input_report(session->hid, HID_INPUT_REPORT, skb->data, skb->len, 1);
			BT_DBG("report len %d", skb->len);
		}
	} else {
		BT_DBG("Unsupported protocol header 0x%02x", hdr);
	}

	kfree_skb(skb);
}

static int hidp_send_frame(struct socket *sock, unsigned char *data, int len)
{
	struct kvec iv = { data, len };
	struct msghdr msg;

	BT_DBG("sock %p data %p len %d", sock, data, len);

	if (!len)
		return 0;

	memset(&msg, 0, sizeof(msg));

	return kernel_sendmsg(sock, &msg, &iv, 1, len);
}

/* dequeue message from @transmit and send via @sock */
static void hidp_process_transmit(struct hidp_session *session,
				  struct sk_buff_head *transmit,
				  struct socket *sock)
{
	struct sk_buff *skb;
	int ret;

	BT_DBG("session %p", session);

	while ((skb = skb_dequeue(transmit))) {
		ret = hidp_send_frame(sock, skb->data, skb->len);
		if (ret == -EAGAIN) {
			skb_queue_head(transmit, skb);
			break;
		} else if (ret < 0) {
			hidp_session_terminate(session);
			kfree_skb(skb);
			break;
		}

		hidp_set_timer(session);
		kfree_skb(skb);
	}
}

static int hidp_setup_input(struct hidp_session *session,
				struct hidp_connadd_req *req)
{
	struct input_dev *input;
	int i;

	input = input_allocate_device();
	if (!input)
		return -ENOMEM;

	session->input = input;

	input_set_drvdata(input, session);

	input->name = "Bluetooth HID Boot Protocol Device";

	input->id.bustype = BUS_BLUETOOTH;
	input->id.vendor  = req->vendor;
	input->id.product = req->product;
	input->id.version = req->version;

	if (req->subclass & 0x40) {
		set_bit(EV_KEY, input->evbit);
		set_bit(EV_LED, input->evbit);
		set_bit(EV_REP, input->evbit);

		set_bit(LED_NUML,    input->ledbit);
		set_bit(LED_CAPSL,   input->ledbit);
		set_bit(LED_SCROLLL, input->ledbit);
		set_bit(LED_COMPOSE, input->ledbit);
		set_bit(LED_KANA,    input->ledbit);

		for (i = 0; i < sizeof(hidp_keycode); i++)
			set_bit(hidp_keycode[i], input->keybit);
		clear_bit(0, input->keybit);
	}

	if (req->subclass & 0x80) {
		input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
		input->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) |
			BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
		input->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
		input->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_SIDE) |
			BIT_MASK(BTN_EXTRA);
		input->relbit[0] |= BIT_MASK(REL_WHEEL);
	}

	input->dev.parent = &session->conn->hcon->dev;

	input->event = hidp_input_event;

	return 0;
}

static int hidp_open(struct hid_device *hid)
{
	return 0;
}

static void hidp_close(struct hid_device *hid)
{
}

#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
static const struct {
	__u16 idVendor;
	__u16 idProduct;
	unsigned quirks;
} hidp_blacklist[] = {
	/* Apple wireless Mighty Mouse */
	{ 0x05ac, 0x030c, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL },

	{ }	/* Terminating entry */
};
static void hidp_setup_quirks(struct hid_device *hid)
{
	unsigned int n;

	for (n = 0; hidp_blacklist[n].idVendor; n++)
		if (hidp_blacklist[n].idVendor == le16_to_cpu(hid->vendor) &&
				hidp_blacklist[n].idProduct == le16_to_cpu(hid->product))
			hid->quirks = hidp_blacklist[n].quirks;
}

static int hidp_setup_hid(struct hidp_session *session,
			  struct hidp_connadd_req *req)
{
	struct hid_device *hid;
	struct hid_report *report;
	bdaddr_t src, dst;
	unsigned char *buf;

	buf = kmalloc(req->rd_size, GFP_KERNEL);
	if (!buf)
		return -ENOMEM;

	if (copy_from_user(buf, req->rd_data, req->rd_size)) {
		kfree(buf);
		return -EFAULT;
	}

	hid = hid_parse_report(buf, req->rd_size);
	kfree(buf);
	if (!session->hid)
		return -EINVAL;

	session->hid = hid;

	hid->driver_data = session;

	baswap(&src, &bt_sk(session->ctrl_sock->sk)->src);
	baswap(&dst, &bt_sk(session->ctrl_sock->sk)->dst);

	hid->bus     = BUS_BLUETOOTH;
	hid->vendor  = req->vendor;
	hid->product = req->product;
	hid->version = req->version;
	hid->country = req->country;

	strlcpy(hid->name, req->name, 128);
	strlcpy(hid->phys, batostr(&src), 64);
	strlcpy(hid->uniq, batostr(&dst), 64);

	hid->dev = hidp_get_device(session);
	hid->hid_open  = hidp_open;
	hid->hid_close = hidp_close;

	hid->hidinput_input_event = hidp_hidinput_event;

	hidp_setup_quirks(hid);

	list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list)
		hidp_send_report(session, report);

	list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list)
		hidp_send_report(session, report);

	if (hidinput_connect(hid) == 0)
		hid->claimed |= HID_CLAIMED_INPUT;

	return 0;
}
#else

static int hidp_parse(struct hid_device *hid)
{
	struct hidp_session *session = hid->driver_data;

	return hid_parse_report(session->hid, session->rd_data,
			session->rd_size);
}

static int hidp_start(struct hid_device *hid)
{
	struct hidp_session *session = hid->driver_data;
	struct hid_report *report;

	if (hid->quirks & HID_QUIRK_NO_INIT_REPORTS)
		return 0;

	list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].
			report_list, list)
		hidp_send_report(session, report);

	list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].
			report_list, list)
		hidp_send_report(session, report);

	return 0;
}

static void hidp_stop(struct hid_device *hid)
{
	struct hidp_session *session = hid->driver_data;

	skb_queue_purge(&session->ctrl_transmit);
	skb_queue_purge(&session->intr_transmit);

	hid->claimed = 0;
}

static struct hid_ll_driver hidp_hid_driver = {
	.parse = hidp_parse,
	.start = hidp_start,
	.stop = hidp_stop,
	.open  = hidp_open,
	.close = hidp_close,
};

/* This function sets up the hid device. It does not add it
   to the HID system. That is done in hidp_add_connection(). */
static int hidp_setup_hid(struct hidp_session *session,
				struct hidp_connadd_req *req)
{
	struct hid_device *hid;
	int err;

	session->rd_data = kzalloc(req->rd_size, GFP_KERNEL);
	if (!session->rd_data)
		return -ENOMEM;

	if (copy_from_user(session->rd_data, req->rd_data, req->rd_size)) {
		err = -EFAULT;
		goto fault;
	}
	session->rd_size = req->rd_size;

	hid = hid_allocate_device();
	if (IS_ERR(hid)) {
		err = PTR_ERR(hid);
		goto fault;
	}

	session->hid = hid;

	hid->driver_data = session;

	hid->bus     = BUS_BLUETOOTH;
	hid->vendor  = req->vendor;
	hid->product = req->product;
	hid->version = req->version;
	hid->country = req->country;

	strncpy(hid->name, req->name, sizeof(req->name) - 1);

	snprintf(hid->phys, sizeof(hid->phys), "%pMR",
		 &bt_sk(session->ctrl_sock->sk)->src);

	snprintf(hid->uniq, sizeof(hid->uniq), "%pMR",
		 &bt_sk(session->ctrl_sock->sk)->dst);

	hid->dev.parent = &session->conn->hcon->dev;
	hid->ll_driver = &hidp_hid_driver;

#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
	hid->hid_get_raw_report = hidp_get_raw_report;
#endif
	hid->hid_output_raw_report = hidp_output_raw_report;

	/* True if device is blacklisted in drivers/hid/hid-core.c */
	if (hid_ignore(hid)) {
		hid_destroy_device(session->hid);
		session->hid = NULL;
		return -ENODEV;
	}

	return 0;

fault:
	kfree(session->rd_data);
	session->rd_data = NULL;

	return err;
}
#endif

/* initialize session devices */
static int hidp_session_dev_init(struct hidp_session *session,
				 struct hidp_connadd_req *req)
{
	int ret;

	if (req->rd_size > 0) {
		ret = hidp_setup_hid(session, req);
		if (ret && ret != -ENODEV)
			return ret;
	}

	if (!session->hid) {
		ret = hidp_setup_input(session, req);
		if (ret < 0)
			return ret;
	}

	return 0;
}

/* destroy session devices */
static void hidp_session_dev_destroy(struct hidp_session *session)
{
	if (session->hid)
		put_device(&session->hid->dev);
	else if (session->input)
		input_put_device(session->input);

	kfree(session->rd_data);
	session->rd_data = NULL;
}

/* add HID/input devices to their underlying bus systems */
static int hidp_session_dev_add(struct hidp_session *session)
{
	int ret;

	/* Both HID and input systems drop a ref-count when unregistering the
	 * device but they don't take a ref-count when registering them. Work
	 * around this by explicitly taking a refcount during registration
	 * which is dropped automatically by unregistering the devices. */

	if (session->hid) {
		ret = hid_add_device(session->hid);
		if (ret)
			return ret;
		get_device(&session->hid->dev);
	} else if (session->input) {
		ret = input_register_device(session->input);
		if (ret)
			return ret;
		input_get_device(session->input);
	}

	return 0;
}

/* remove HID/input devices from their bus systems */
static void hidp_session_dev_del(struct hidp_session *session)
{
	if (session->hid) {
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
		hid_destroy_device(session->hid);
#else
		if (session->hid->claimed & HID_CLAIMED_INPUT)
			hidinput_disconnect(session->hid);
		hid_free_device(session->hid);
#endif
	} else if (session->input) {
		input_unregister_device(session->input);
	}
}

/*
 * Create new session object
 * Allocate session object, initialize static fields, copy input data into the
 * object and take a reference to all sub-objects.
 * This returns 0 on success and puts a pointer to the new session object in
 * \out. Otherwise, an error code is returned.
 * The new session object has an initial ref-count of 1.
 */
static int hidp_session_new(struct hidp_session **out, const bdaddr_t *bdaddr,
			    struct socket *ctrl_sock,
			    struct socket *intr_sock,
			    struct hidp_connadd_req *req,
			    struct l2cap_conn *conn)
{
	struct hidp_session *session;
	int ret;
	struct bt_sock *ctrl, *intr;

	ctrl = bt_sk(ctrl_sock->sk);
	intr = bt_sk(intr_sock->sk);

	session = kzalloc(sizeof(*session), GFP_KERNEL);
	if (!session)
		return -ENOMEM;

	/* object and runtime management */
	kref_init(&session->ref);
	atomic_set(&session->state, HIDP_SESSION_IDLING);
	init_waitqueue_head(&session->state_queue);
	session->flags = req->flags & (1 << HIDP_BLUETOOTH_VENDOR_ID);

	/* connection management */
	bacpy(&session->bdaddr, bdaddr);
	session->conn = conn;
	session->user.probe = hidp_session_probe;
	session->user.remove = hidp_session_remove;
	session->ctrl_sock = ctrl_sock;
	session->intr_sock = intr_sock;
	skb_queue_head_init(&session->ctrl_transmit);
	skb_queue_head_init(&session->intr_transmit);
	session->ctrl_mtu = min_t(uint, l2cap_pi(ctrl)->chan->omtu,
					l2cap_pi(ctrl)->chan->imtu);
	session->intr_mtu = min_t(uint, l2cap_pi(intr)->chan->omtu,
					l2cap_pi(intr)->chan->imtu);
	session->idle_to = req->idle_to;

	/* device management */
	setup_timer(&session->timer, hidp_idle_timeout,
		    (unsigned long)session);

	/* session data */
	mutex_init(&session->report_mutex);
	init_waitqueue_head(&session->report_queue);

	ret = hidp_session_dev_init(session, req);
	if (ret)
		goto err_free;

	l2cap_conn_get(session->conn);
	get_file(session->intr_sock->file);
	get_file(session->ctrl_sock->file);
	*out = session;
	return 0;

err_free:
	kfree(session);
	return ret;
}

/* increase ref-count of the given session by one */
static void hidp_session_get(struct hidp_session *session)
{
	kref_get(&session->ref);
}

/* release callback */
static void session_free(struct kref *ref)
{
	struct hidp_session *session = container_of(ref, struct hidp_session,
						    ref);

	hidp_session_dev_destroy(session);
	skb_queue_purge(&session->ctrl_transmit);
	skb_queue_purge(&session->intr_transmit);
	fput(session->intr_sock->file);
	fput(session->ctrl_sock->file);
	l2cap_conn_put(session->conn);
	kfree(session);
}

/* decrease ref-count of the given session by one */
static void hidp_session_put(struct hidp_session *session)
{
	kref_put(&session->ref, session_free);
}

/*
 * Search the list of active sessions for a session with target address
 * \bdaddr. You must hold at least a read-lock on \hidp_session_sem. As long as
 * you do not release this lock, the session objects cannot vanish and you can
 * safely take a reference to the session yourself.
 */
static struct hidp_session *__hidp_session_find(const bdaddr_t *bdaddr)
{
	struct hidp_session *session;

	list_for_each_entry(session, &hidp_session_list, list) {
		if (!bacmp(bdaddr, &session->bdaddr))
			return session;
	}

	return NULL;
}

/*
 * Same as __hidp_session_find() but no locks must be held. This also takes a
 * reference of the returned session (if non-NULL) so you must drop this
 * reference if you no longer use the object.
 */
static struct hidp_session *hidp_session_find(const bdaddr_t *bdaddr)
{
	struct hidp_session *session;

	down_read(&hidp_session_sem);

	session = __hidp_session_find(bdaddr);
	if (session)
		hidp_session_get(session);

	up_read(&hidp_session_sem);

	return session;
}

/*
 * Start session synchronously
 * This starts a session thread and waits until initialization
 * is done or returns an error if it couldn't be started.
 * If this returns 0 the session thread is up and running. You must call
 * hipd_session_stop_sync() before deleting any runtime resources.
 */
static int hidp_session_start_sync(struct hidp_session *session)
{
	unsigned int vendor, product;

	if (session->hid) {
		vendor  = session->hid->vendor;
		product = session->hid->product;
	} else if (session->input) {
		vendor  = session->input->id.vendor;
		product = session->input->id.product;
	} else {
		vendor = 0x0000;
		product = 0x0000;
	}

	session->task = kthread_run(hidp_session_thread, session,
				    "khidpd_%04x%04x", vendor, product);
	if (IS_ERR(session->task))
		return PTR_ERR(session->task);

	while (atomic_read(&session->state) <= HIDP_SESSION_IDLING)
		wait_event(session->state_queue,
			   atomic_read(&session->state) > HIDP_SESSION_IDLING);

	return 0;
}

/*
 * Terminate session thread
 * Wake up session thread and notify it to stop. This is asynchronous and
 * returns immediately. Call this whenever a runtime error occurs and you want
 * the session to stop.
 * Note: wake_up_process() performs any necessary memory-barriers for us.
 */
static void hidp_session_terminate(struct hidp_session *session)
{
	atomic_inc(&session->terminate);
	wake_up_process(session->task);
}

/*
 * Probe HIDP session
 * This is called from the l2cap_conn core when our l2cap_user object is bound
 * to the hci-connection. We get the session via the \user object and can now
 * start the session thread, register the HID/input devices and link it into
 * the global session list.
 * The global session-list owns its own reference to the session object so you
 * can drop your own reference after registering the l2cap_user object.
 */
static int hidp_session_probe(struct l2cap_conn *conn,
			      struct l2cap_user *user)
{
	struct hidp_session *session = container_of(user,
						    struct hidp_session,
						    user);
	struct hidp_session *s;
	int ret;

	down_write(&hidp_session_sem);

	/* check that no other session for this device exists */
	s = __hidp_session_find(&session->bdaddr);
	if (s) {
		ret = -EEXIST;
		goto out_unlock;
	}

	ret = hidp_session_start_sync(session);
	if (ret)
		goto out_unlock;

	ret = hidp_session_dev_add(session);
	if (ret)
		goto out_stop;

	hidp_session_get(session);
	list_add(&session->list, &hidp_session_list);
	ret = 0;
	goto out_unlock;

out_stop:
	hidp_session_terminate(session);
out_unlock:
	up_write(&hidp_session_sem);
	return ret;
}

/*
 * Remove HIDP session
 * Called from the l2cap_conn core when either we explicitly unregistered
 * the l2cap_user object or if the underlying connection is shut down.
 * We signal the hidp-session thread to shut down, unregister the HID/input
 * devices and unlink the session from the global list.
 * This drops the reference to the session that is owned by the global
 * session-list.
 * Note: We _must_ not synchronosly wait for the session-thread to shut down.
 * This is, because the session-thread might be waiting for an HCI lock that is
 * held while we are called. Therefore, we only unregister the devices and
 * notify the session-thread to terminate. The thread itself owns a reference
 * to the session object so it can safely shut down.
 */
static void hidp_session_remove(struct l2cap_conn *conn,
				struct l2cap_user *user)
{
	struct hidp_session *session = container_of(user,
						    struct hidp_session,
						    user);

	down_write(&hidp_session_sem);

	hidp_session_terminate(session);
	hidp_session_dev_del(session);
	list_del(&session->list);

	up_write(&hidp_session_sem);

	hidp_session_put(session);
}

/*
 * Session Worker
 * This performs the actual main-loop of the HIDP worker. We first check
 * whether the underlying connection is still alive, then parse all pending
 * messages and finally send all outstanding messages.
 */
static void hidp_session_run(struct hidp_session *session)
{
	struct sock *ctrl_sk = session->ctrl_sock->sk;
	struct sock *intr_sk = session->intr_sock->sk;
	struct sk_buff *skb;

	for (;;) {
		/*
		 * This thread can be woken up two ways:
		 *  - You call hidp_session_terminate() which sets the
		 *    session->terminate flag and wakes this thread up.
		 *  - Via modifying the socket state of ctrl/intr_sock. This
		 *    thread is woken up by ->sk_state_changed().
		 *
		 * Note: set_current_state() performs any necessary
		 * memory-barriers for us.
		 */
		set_current_state(TASK_INTERRUPTIBLE);

		if (atomic_read(&session->terminate))
			break;

		if (ctrl_sk->sk_state != BT_CONNECTED ||
		    intr_sk->sk_state != BT_CONNECTED)
			break;

		/* parse incoming intr-skbs */
		while ((skb = skb_dequeue(&intr_sk->sk_receive_queue))) {
			skb_orphan(skb);
			if (!skb_linearize(skb))
				hidp_recv_intr_frame(session, skb);
			else
				kfree_skb(skb);
		}

		/* send pending intr-skbs */
		hidp_process_transmit(session, &session->intr_transmit,
				      session->intr_sock);

		/* parse incoming ctrl-skbs */
		while ((skb = skb_dequeue(&ctrl_sk->sk_receive_queue))) {
			skb_orphan(skb);
			if (!skb_linearize(skb))
				hidp_recv_ctrl_frame(session, skb);
			else
				kfree_skb(skb);
		}

		/* send pending ctrl-skbs */
		hidp_process_transmit(session, &session->ctrl_transmit,
				      session->ctrl_sock);

		schedule();
	}

	atomic_inc(&session->terminate);
	set_current_state(TASK_RUNNING);
}

/*
 * HIDP session thread
 * This thread runs the I/O for a single HIDP session. Startup is synchronous
 * which allows us to take references to ourself here instead of doing that in
 * the caller.
 * When we are ready to run we notify the caller and call hidp_session_run().
 */
static int hidp_session_thread(void *arg)
{
	struct hidp_session *session = arg;
	wait_queue_t ctrl_wait, intr_wait;

	BT_DBG("session %p", session);

	/* initialize runtime environment */
	hidp_session_get(session);
	__module_get(THIS_MODULE);
	set_user_nice(current, -15);
	hidp_set_timer(session);

	init_waitqueue_entry(&ctrl_wait, current);
	init_waitqueue_entry(&intr_wait, current);
	add_wait_queue(sk_sleep(session->ctrl_sock->sk), &ctrl_wait);
	add_wait_queue(sk_sleep(session->intr_sock->sk), &intr_wait);
	/* This memory barrier is paired with wq_has_sleeper(). See
	 * sock_poll_wait() for more information why this is needed. */
	smp_mb();

	/* notify synchronous startup that we're ready */
	atomic_inc(&session->state);
	wake_up(&session->state_queue);

	/* run session */
	hidp_session_run(session);

	/* cleanup runtime environment */
	remove_wait_queue(sk_sleep(session->intr_sock->sk), &intr_wait);
	remove_wait_queue(sk_sleep(session->intr_sock->sk), &ctrl_wait);
	wake_up_interruptible(&session->report_queue);
	hidp_del_timer(session);

	/*
	 * If we stopped ourself due to any internal signal, we should try to
	 * unregister our own session here to avoid having it linger until the
	 * parent l2cap_conn dies or user-space cleans it up.
	 * This does not deadlock as we don't do any synchronous shutdown.
	 * Instead, this call has the same semantics as if user-space tried to
	 * delete the session.
	 */
	l2cap_unregister_user(session->conn, &session->user);
	hidp_session_put(session);

	module_put_and_exit(0);
	return 0;
}

static int hidp_verify_sockets(struct socket *ctrl_sock,
			       struct socket *intr_sock)
{
	struct bt_sock *ctrl, *intr;
	struct hidp_session *session;

	if (!l2cap_is_socket(ctrl_sock) || !l2cap_is_socket(intr_sock))
		return -EINVAL;

	ctrl = bt_sk(ctrl_sock->sk);
	intr = bt_sk(intr_sock->sk);

	if (bacmp(&ctrl->src, &intr->src) || bacmp(&ctrl->dst, &intr->dst))
		return -ENOTUNIQ;
	if (ctrl->sk.sk_state != BT_CONNECTED ||
	    intr->sk.sk_state != BT_CONNECTED)
		return -EBADFD;

	/* early session check, we check again during session registration */
	session = hidp_session_find(&ctrl->dst);
	if (session) {
		hidp_session_put(session);
		return -EEXIST;
	}

	return 0;
}

int hidp_connection_add(struct hidp_connadd_req *req,
			struct socket *ctrl_sock,
			struct socket *intr_sock)
{
	struct hidp_session *session;
	struct l2cap_conn *conn;
	struct l2cap_chan *chan = l2cap_pi(ctrl_sock->sk)->chan;
	int ret;

	ret = hidp_verify_sockets(ctrl_sock, intr_sock);
	if (ret)
		return ret;

	conn = NULL;
	l2cap_chan_lock(chan);
	if (chan->conn) {
		l2cap_conn_get(chan->conn);
		conn = chan->conn;
	}
	l2cap_chan_unlock(chan);

	if (!conn)
		return -EBADFD;

	ret = hidp_session_new(&session, &bt_sk(ctrl_sock->sk)->dst, ctrl_sock,
			       intr_sock, req, conn);
	if (ret)
		goto out_conn;

	ret = l2cap_register_user(conn, &session->user);
	if (ret)
		goto out_session;

	ret = 0;

out_session:
	hidp_session_put(session);
out_conn:
	l2cap_conn_put(conn);
	return ret;
}

int hidp_connection_del(struct hidp_conndel_req *req)
{
	struct hidp_session *session;

	session = hidp_session_find(&req->bdaddr);
	if (!session)
		return -ENOENT;

	if (req->flags & (1 << HIDP_VIRTUAL_CABLE_UNPLUG))
		hidp_send_ctrl_message(session,
				       HIDP_TRANS_HID_CONTROL |
				         HIDP_CTRL_VIRTUAL_CABLE_UNPLUG,
				       NULL, 0);
	else
		l2cap_unregister_user(session->conn, &session->user);

	hidp_session_put(session);

	return 0;
}

int hidp_get_connlist(struct hidp_connlist_req *req)
{
	struct hidp_session *session;
	int err = 0, n = 0;

	BT_DBG("");

	down_read(&hidp_session_sem);

	list_for_each_entry(session, &hidp_session_list, list) {
		struct hidp_conninfo ci;

		hidp_copy_session(session, &ci);

		if (copy_to_user(req->ci, &ci, sizeof(ci))) {
			err = -EFAULT;
			break;
		}

		if (++n >= req->cnum)
			break;

		req->ci++;
	}
	req->cnum = n;

	up_read(&hidp_session_sem);
	return err;
}

int hidp_get_conninfo(struct hidp_conninfo *ci)
{
	struct hidp_session *session;

	session = hidp_session_find(&ci->bdaddr);
	if (session) {
		hidp_copy_session(session, ci);
		hidp_session_put(session);
	}

	return session ? 0 : -ENOENT;
}

static int __init hidp_init(void)
{
	BT_INFO("HIDP (Human Interface Emulation) ver %s", VERSION);

	return hidp_init_sockets();
}

static void __exit hidp_exit(void)
{
	hidp_cleanup_sockets();
}

module_init(hidp_init);
module_exit(hidp_exit);

MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>");
MODULE_DESCRIPTION("Bluetooth HIDP ver " VERSION);
MODULE_VERSION(VERSION);
MODULE_LICENSE("GPL");
MODULE_ALIAS("bt-proto-6");

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

* Re: [PATCH 11/12] backports: backport new bluetooth hidp session-management
  2013-05-12 21:38       ` David Herrmann
@ 2013-05-13  1:30         ` Luis R. Rodriguez
  2013-05-13  2:36           ` Luis R. Rodriguez
  0 siblings, 1 reply; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-13  1:30 UTC (permalink / raw)
  To: David Herrmann; +Cc: Johannes Berg, backports

On Sun, May 12, 2013 at 2:38 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
> On Sun, May 12, 2013 at 9:33 PM, Luis R. Rodriguez
>> http://drvbp1.linux-foundation.org/~mcgrof/backport-tmp/backports-20130426.tar.bz2
>
> That one helped a lot, thx!

Great!

>> I think patch miserably guessed the hunks where to apply some of these
>> changes to. I tried to make sense of it but the rewrite was a bit big
>> so I was not sure where to places things correctly, hence me Cc'ing
>> you, I really appreciate you reviewing this.
>
> Yeah, it was really weird. I fixed it up how I think it should work.
> However, compiling kernels takes like 50min here (hurray, intel
> Atom!), so this isn't even compile-tested. I can do this later this
> week if you want.

No worries we have a crazy build box for the backports project that
lets us test compile these releases across 26 kernels (2.6.24-3.9) in
about 30 minutes using our script ckmake, all in RAM, so I just
integrated your changes and in 30 minutes we'll know if anything
broke, and I can provide the log then.

> The net/bluetooth/hidp/core.c file is attached. It is from the tarball
> you created above (2013-04-26). I fixed some other small issues.

Nice, can you provide me a Signed-off-by tag ? With it I'd just amend
it to my commit provided everything compiles fine.

> Can you tell me whether that works for you? The diff to linux-next is pretty small.

Indeed, I used the core.c file to generate the new diff by removing
first completely the patch in question. We'll now just wait for
compilation test results.

As for run time tests I'm personally on 3.2, I suppose what we can do
is if this compiles fine just let this move forward and then at a
later time ask on linux-blueooth list to see if anyone is on a kernel
older than or equal to 2.6.27 using bluetooth to be able to run time
test this. Is there any particular run time test anyone can do to test
if this worked ?

  Luis

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

* Re: [PATCH 11/12] backports: backport new bluetooth hidp session-management
  2013-05-13  1:30         ` Luis R. Rodriguez
@ 2013-05-13  2:36           ` Luis R. Rodriguez
  2013-05-13  4:35             ` David Herrmann
  2013-05-13  9:53             ` Johannes Berg
  0 siblings, 2 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-13  2:36 UTC (permalink / raw)
  To: David Herrmann; +Cc: Johannes Berg, backports

On Sun, May 12, 2013 at 6:30 PM, Luis R. Rodriguez
<mcgrof@do-not-panic.com> wrote:
>
> No worries we have a crazy build box for the backports project that
> lets us test compile these releases across 26 kernels (2.6.24-3.9) in
> about 30 minutes using our script ckmake, all in RAM, so I just
> integrated your changes and in 30 minutes we'll know if anything
> broke, and I can provide the log then.

$ time ckmake --allyesconfig

1   2.6.24              [  OK  ]
2   2.6.25              [  OK  ]
3   2.6.26              [  OK  ]
4   2.6.27              [  OK  ]
5   2.6.28              [  OK  ]
6   2.6.29              [  OK  ]
7   2.6.30              [  OK  ]
8   2.6.31              [  OK  ]
9   2.6.32              [  OK  ]
10  2.6.33              [  OK  ]
11  2.6.34              [  OK  ]
12  2.6.35              [  OK  ]
13  2.6.36              [  OK  ]
14  2.6.37              [  OK  ]
15  2.6.38              [  OK  ]
16  2.6.39              [  OK  ]
17  3.0.76              [  OK  ]
18  3.1.10              [  OK  ]
19  3.2.44              [  OK  ]
20  3.3.8               [  OK  ]
21  3.4.43              [  OK  ]
22  3.5.7               [  OK  ]
23  3.6.11              [  OK  ]
24  3.7.10              [  OK  ]
25  3.8.11              [  OK  ]
26  3.9.0               [  OK  ]

real    30m53.311s
user    817m3.260s
sys     127m37.555s

>> The net/bluetooth/hidp/core.c file is attached. It is from the tarball
>> you created above (2013-04-26). I fixed some other small issues.
>
> Nice, can you provide me a Signed-off-by tag ? With it I'd just amend
> it to my commit provided everything compiles fine.

Just need a Signed-off-by from you and we're good, thanks so much.

  Luis

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

* Re: [PATCH 11/12] backports: backport new bluetooth hidp session-management
  2013-05-13  2:36           ` Luis R. Rodriguez
@ 2013-05-13  4:35             ` David Herrmann
  2013-05-13  9:53             ` Johannes Berg
  1 sibling, 0 replies; 27+ messages in thread
From: David Herrmann @ 2013-05-13  4:35 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: backports, Johannes Berg, David Herrmann

[-- Attachment #1: Type: text/plain, Size: 1952 bytes --]

Hi

On May 13, 2013 4:36 AM, "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
wrote:
>
> On Sun, May 12, 2013 at 6:30 PM, Luis R. Rodriguez
> <mcgrof@do-not-panic.com> wrote:
> >
> > No worries we have a crazy build box for the backports project that
> > lets us test compile these releases across 26 kernels (2.6.24-3.9) in
> > about 30 minutes using our script ckmake, all in RAM, so I just
> > integrated your changes and in 30 minutes we'll know if anything
> > broke, and I can provide the log then.
>
> $ time ckmake --allyesconfig
>
> 1   2.6.24              [  OK  ]
> 2   2.6.25              [  OK  ]
> 3   2.6.26              [  OK  ]
> 4   2.6.27              [  OK  ]
> 5   2.6.28              [  OK  ]
> 6   2.6.29              [  OK  ]
> 7   2.6.30              [  OK  ]
> 8   2.6.31              [  OK  ]
> 9   2.6.32              [  OK  ]
> 10  2.6.33              [  OK  ]
> 11  2.6.34              [  OK  ]
> 12  2.6.35              [  OK  ]
> 13  2.6.36              [  OK  ]
> 14  2.6.37              [  OK  ]
> 15  2.6.38              [  OK  ]
> 16  2.6.39              [  OK  ]
> 17  3.0.76              [  OK  ]
> 18  3.1.10              [  OK  ]
> 19  3.2.44              [  OK  ]
> 20  3.3.8               [  OK  ]
> 21  3.4.43              [  OK  ]
> 22  3.5.7               [  OK  ]
> 23  3.6.11              [  OK  ]
> 24  3.7.10              [  OK  ]
> 25  3.8.11              [  OK  ]
> 26  3.9.0               [  OK  ]
>
> real    30m53.311s
> user    817m3.260s
> sys     127m37.555s

Perfect, thanks!

> >> The net/bluetooth/hidp/core.c file is attached. It is from the tarball
> >> you created above (2013-04-26). I fixed some other small issues.
> >
> > Nice, can you provide me a Signed-off-by tag ? With it I'd just amend
> > it to my commit provided everything compiles fine.
>
> Just need a Signed-off-by from you and we're good, thanks so much.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>

Thanks!
David

[-- Attachment #2: Type: text/html, Size: 2659 bytes --]

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

* Re: [PATCH 11/12] backports: backport new bluetooth hidp session-management
  2013-05-13  2:36           ` Luis R. Rodriguez
  2013-05-13  4:35             ` David Herrmann
@ 2013-05-13  9:53             ` Johannes Berg
  2013-05-13 10:05               ` Luis R. Rodriguez
  1 sibling, 1 reply; 27+ messages in thread
From: Johannes Berg @ 2013-05-13  9:53 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: David Herrmann, backports

On Sun, 2013-05-12 at 19:36 -0700, Luis R. Rodriguez wrote:

> >> The net/bluetooth/hidp/core.c file is attached. It is from the tarball
> >> you created above (2013-04-26). I fixed some other small issues.
> >
> > Nice, can you provide me a Signed-off-by tag ? With it I'd just amend
> > it to my commit provided everything compiles fine.

You're going to send a new version of patch 11 then?

johannes


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

* Re: [PATCH 11/12] backports: backport new bluetooth hidp session-management
  2013-05-13  9:53             ` Johannes Berg
@ 2013-05-13 10:05               ` Luis R. Rodriguez
  0 siblings, 0 replies; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-13 10:05 UTC (permalink / raw)
  To: Johannes Berg; +Cc: David Herrmann, backports

On Mon, May 13, 2013 at 2:53 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Sun, 2013-05-12 at 19:36 -0700, Luis R. Rodriguez wrote:
>
>> >> The net/bluetooth/hidp/core.c file is attached. It is from the tarball
>> >> you created above (2013-04-26). I fixed some other small issues.
>> >
>> > Nice, can you provide me a Signed-off-by tag ? With it I'd just amend
>> > it to my commit provided everything compiles fine.
>
> You're going to send a new version of patch 11 then?

Sure, sent.

  Luis

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

* Re: [PATCH 01/12] backports: make compat module use subsys_initcall()
  2013-05-11  0:26 ` [PATCH 01/12] backports: make compat module use subsys_initcall() Luis R. Rodriguez
@ 2013-05-13 12:02   ` Johannes Berg
  2013-05-13 17:29     ` Luis R. Rodriguez
  0 siblings, 1 reply; 27+ messages in thread
From: Johannes Berg @ 2013-05-13 12:02 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: backports, pstew

On Fri, 2013-05-10 at 17:26 -0700, Luis R. Rodriguez wrote:
> From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
> 
> This is a no-op for the modular use case of the
> backports project but by enabling this it allows
> for developers a way to embed the backports releases
> onto a target source Linux directory, with obvious
> pending modifications, by adding our backport_init()
> onto the target kernel's init/main.c start_kernel().
> 
> Enable this theoretical use case. Hackers welcome to
> go play on this theoretical integration strategy now.

I applied all but this one, it caused a compiler warning that seemed
important (missing an include?)

/tmp/i/compat/main.c:83:1: warning: data definition has no type or
storage class [enabled by default]
/tmp/i/compat/main.c:83:1: warning: type defaults to ‘int’ in
declaration of ‘__exitcall’ [-Wimplicit-int]
/tmp/i/compat/main.c:83:1: warning: parameter names (without types) in
function declaration [enabled by default]
/tmp/i/compat/main.c:76:123: warning: ‘backport_exit’ defined but not
used [-Wunused-function]


johannes


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

* Re: [PATCH 01/12] backports: make compat module use subsys_initcall()
  2013-05-13 12:02   ` Johannes Berg
@ 2013-05-13 17:29     ` Luis R. Rodriguez
  2013-05-14  6:25       ` Johannes Berg
  0 siblings, 1 reply; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-13 17:29 UTC (permalink / raw)
  To: Johannes Berg; +Cc: backports, Paul Stewart

On Mon, May 13, 2013 at 5:02 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Fri, 2013-05-10 at 17:26 -0700, Luis R. Rodriguez wrote:
>> From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
>>
>> This is a no-op for the modular use case of the
>> backports project but by enabling this it allows
>> for developers a way to embed the backports releases
>> onto a target source Linux directory, with obvious
>> pending modifications, by adding our backport_init()
>> onto the target kernel's init/main.c start_kernel().
>>
>> Enable this theoretical use case. Hackers welcome to
>> go play on this theoretical integration strategy now.
>
> I applied all but this one, it caused a compiler warning that seemed
> important (missing an include?)
>
> /tmp/i/compat/main.c:83:1: warning: data definition has no type or
> storage class [enabled by default]
> /tmp/i/compat/main.c:83:1: warning: type defaults to ‘int’ in
> declaration of ‘__exitcall’ [-Wimplicit-int]
> /tmp/i/compat/main.c:83:1: warning: parameter names (without types) in
> function declaration [enabled by default]
> /tmp/i/compat/main.c:76:123: warning: ‘backport_exit’ defined but not
> used [-Wunused-function]

Sorry can you try this?

>From e9b18b9f99716fb382e7b8e2cde8248fc82806cf Mon Sep 17 00:00:00 2001
From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Date: Wed, 8 May 2013 19:20:55 +0000
Subject: [PATCH v2] backports: make compat module use subsys_initcall()

This is a no-op for the modular use case of the
backports project but by enabling this it allows
for developers a way to embed the backports releases
onto a target source Linux directory, with obvious
pending modifications, by adding our backport_init()
onto the target kernel's init/main.c start_kernel().

Enable this theoretical use case. Hackers welcome to
go play on this theoretical integration strategy now.

Cc: pstew@chromium.org
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 backport/compat/main.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/backport/compat/main.c b/backport/compat/main.c
index 90ce751..394e413 100644
--- a/backport/compat/main.c
+++ b/backport/compat/main.c
@@ -1,4 +1,5 @@
 #include <linux/module.h>
+#include <linux/init.h>
 #include <linux/pm_qos.h>
 #include <linux/workqueue.h>
 #include "compat-2.6.34.h"
@@ -69,7 +70,7 @@ static int __init backport_init(void)

         return 0;
 }
-module_init(backport_init);
+subsys_initcall(backport_init);

 static void __exit backport_exit(void)
 {
@@ -78,5 +79,4 @@ static void __exit backport_exit(void)

         return;
 }
-module_exit(backport_exit);
-
+__exitcall(backport_exit);
--
1.7.10.4


  Luis

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

* Re: [PATCH 01/12] backports: make compat module use subsys_initcall()
  2013-05-13 17:29     ` Luis R. Rodriguez
@ 2013-05-14  6:25       ` Johannes Berg
  2013-05-14  6:35         ` Luis R. Rodriguez
  0 siblings, 1 reply; 27+ messages in thread
From: Johannes Berg @ 2013-05-14  6:25 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: backports, Paul Stewart

> > I applied all but this one, it caused a compiler warning that seemed
> > important (missing an include?)
> >
> > /tmp/i/compat/main.c:83:1: warning: data definition has no type or
> > storage class [enabled by default]
> > /tmp/i/compat/main.c:83:1: warning: type defaults to ‘int’ in
> > declaration of ‘__exitcall’ [-Wimplicit-int]
> > /tmp/i/compat/main.c:83:1: warning: parameter names (without types) in
> > function declaration [enabled by default]
> > /tmp/i/compat/main.c:76:123: warning: ‘backport_exit’ defined but not
> > used [-Wunused-function]
> 
> Sorry can you try this?

It can't work, because the definition of __exitcall is under "#ifndef
MODULE" in include/init.h. But since module_exit() is defined to be
__exitcall (in case the module is built-in) why not just keep
module_exit()? And vice versa, subsys_init() is defined to be
module_init() in case of being built modular.

johannes


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

* Re: [PATCH 01/12] backports: make compat module use subsys_initcall()
  2013-05-14  6:25       ` Johannes Berg
@ 2013-05-14  6:35         ` Luis R. Rodriguez
  2013-05-14  7:32           ` Johannes Berg
  0 siblings, 1 reply; 27+ messages in thread
From: Luis R. Rodriguez @ 2013-05-14  6:35 UTC (permalink / raw)
  To: Johannes Berg; +Cc: backports, Paul Stewart

On Mon, May 13, 2013 at 11:25 PM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> why not just keep module_exit()?

Sure.

>From e9b18b9f99716fb382e7b8e2cde8248fc82806cf Mon Sep 17 00:00:00 2001
From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Date: Wed, 8 May 2013 19:20:55 +0000
Subject: [PATCH v3] backports: make compat module use subsys_initcall()

This is a no-op for the modular use case of the
backports project but by enabling this it allows
for developers a way to embed the backports releases
onto a target source Linux directory, with obvious
pending modifications, by adding our backport_init()
onto the target kernel's init/main.c start_kernel().

Enable this theoretical use case. Hackers welcome to
go play on this theoretical integration strategy now.

Cc: pstew@chromium.org
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 backport/compat/main.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/backport/compat/main.c b/backport/compat/main.c
index 90ce751..394e413 100644
--- a/backport/compat/main.c
+++ b/backport/compat/main.c
@@ -1,4 +1,5 @@
 #include <linux/module.h>
+#include <linux/init.h>
 #include <linux/pm_qos.h>
 #include <linux/workqueue.h>
 #include "compat-2.6.34.h"
@@ -69,7 +70,7 @@ static int __init backport_init(void)

         return 0;
 }
-module_init(backport_init);
+subsys_initcall(backport_init);

 static void __exit backport_exit(void)
 {

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

* Re: [PATCH 01/12] backports: make compat module use subsys_initcall()
  2013-05-14  6:35         ` Luis R. Rodriguez
@ 2013-05-14  7:32           ` Johannes Berg
  0 siblings, 0 replies; 27+ messages in thread
From: Johannes Berg @ 2013-05-14  7:32 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: backports, Paul Stewart

On Mon, 2013-05-13 at 23:35 -0700, Luis R. Rodriguez wrote:
> On Mon, May 13, 2013 at 11:25 PM, Johannes Berg
> <johannes@sipsolutions.net> wrote:
> > why not just keep module_exit()?
> 
> Sure.

This one works, applied. In fact it makes no difference in code
generation at all, as I thought.

johannes


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

end of thread, other threads:[~2013-05-14  7:32 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-11  0:26 [PATCH 00/12] backports: move us up to next-20130419 Luis R. Rodriguez
2013-05-11  0:26 ` [PATCH 01/12] backports: make compat module use subsys_initcall() Luis R. Rodriguez
2013-05-13 12:02   ` Johannes Berg
2013-05-13 17:29     ` Luis R. Rodriguez
2013-05-14  6:25       ` Johannes Berg
2013-05-14  6:35         ` Luis R. Rodriguez
2013-05-14  7:32           ` Johannes Berg
2013-05-11  0:26 ` [PATCH 02/12] backports: backport dma-buf debugfs support Luis R. Rodriguez
2013-05-11  0:26 ` [PATCH 03/12] compat: backport radix-tree bit optimized iterator Luis R. Rodriguez
2013-05-11  0:26 ` [PATCH 04/12] backports: copy brcmfmac-sdio.h Luis R. Rodriguez
2013-05-11  0:26 ` [PATCH 05/12] backports: remove brcmsmac / brcmutil Makefile patches Luis R. Rodriguez
2013-05-11  0:26 ` [PATCH 06/12] backports: remove ath5k trace fix patch Luis R. Rodriguez
2013-05-11  0:26 ` [PATCH 07/12] backports: enable the CONFIG_DRM_QXL driver on >= v3.3 Luis R. Rodriguez
2013-05-11  0:26 ` [PATCH 08/12] backports: enable REGULATOR_WM8994 only on >= 3.8 Luis R. Rodriguez
2013-05-11  0:27 ` [PATCH 09/12] backports: refresh patches for next-20130415 Luis R. Rodriguez
2013-05-11  0:27 ` [PATCH 10/12] backports: fix atl1.c dev-pm-ops patch Luis R. Rodriguez
2013-05-11  0:27 ` [PATCH 11/12] backports: backport new bluetooth hidp session-management Luis R. Rodriguez
2013-05-12 12:26   ` David Herrmann
2013-05-12 19:33     ` Luis R. Rodriguez
2013-05-12 20:21       ` Luis R. Rodriguez
2013-05-12 21:38       ` David Herrmann
2013-05-13  1:30         ` Luis R. Rodriguez
2013-05-13  2:36           ` Luis R. Rodriguez
2013-05-13  4:35             ` David Herrmann
2013-05-13  9:53             ` Johannes Berg
2013-05-13 10:05               ` Luis R. Rodriguez
2013-05-11  0:27 ` [PATCH 12/12] backports: refresh patches for next-20130419 Luis R. Rodriguez

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.