Skip to contentSkip to conversation

Enable cw1200 on >=2.6.34

PATCH Applied Solomon Peachy 3 participants 7 messages Aug 17, 2013 – Aug 27, 2013

lore
Share & tools
lore
#0 lore raw

v2 cover Enable cw1200 on >=2.6.34

This superscedes the earlier patch set I posted when apparently sleep deprived. It enables the cw1200_wlan_sdio driver to build cleanly on

Quoted 2 lines

=2.6.34 kernels, and the cw1200_wlan_spi driver to build cleanly on =2.6.35 kernels.

#1 lore raw

PATCH v2 1/4 backport: Add an implementation of get_random_int() for <3.10 kernels.

get_random_int() was present, but simply not exported for use in modules until 3.10. Implement it in terms of the more expensive get_random_bytes()

This is needed by the cw1200 driver.

---
 backport/compat/backport-3.10.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
backport/compat/backport-3.10.c +13 -0
index 980ed59..5273758 100644
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/err.h>
 #include <linux/proc_fs.h>
+#include <linux/random.h>
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
 #include <linux/init.h>
@@ -77,3 +78,15 @@ void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid)
 	de->gid = gid;
 }
 EXPORT_SYMBOL_GPL(proc_set_user);
+
+/* get_random_int() was not exported for module use until 3.10-rc.
+   Implement it here in terms of the more expensive get_random_bytes()
+ */
+unsigned int get_random_int(void)
+{
+	unsigned int r;
+	get_random_bytes(&r, sizeof(r));
+
+	return r;
+}
+EXPORT_SYMBOL_GPL(get_random_int);
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v2 2/4 backports: move the cw1200 sdio quirk into 26-sdio-quirks

In reply to Solomon Peachy
---
 .../26-sdio-quirks/drivers_net_wireless_cw1200_sdio.patch | 15 +++++++++++++++
 .../network/75-cw1200-sdio-quirk/cw1200.patch             | 15 ---------------
 2 files changed, 15 insertions(+), 15 deletions(-)
 create mode 100644 patches/collateral-evolutions/network/26-sdio-quirks/drivers_net_wireless_cw1200_sdio.patch
 delete mode 100644 patches/collateral-evolutions/network/75-cw1200-sdio-quirk/cw1200.patch
patches/collateral-evolutions/network/26-sdio-quirks/drivers_net_wireless_cw1200_sdio.patch new file +15 -0
new file mode 100644
index 0000000..2533051
@@ -0,0 +1,15 @@
+--- a/drivers/net/wireless/cw1200/cw1200_sdio.c
++++ b/drivers/net/wireless/cw1200/cw1200_sdio.c
+@@ -253,6 +253,12 @@ static size_t cw1200_sdio_align_size(struct hwbus_priv *self, size_t size)
+ 	else
+ 		size = sdio_align_size(self->func, size);
+ 
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0))
++	/* A quirk to handle this was committed in 3.2-rc */
++	if (size == SDIO_BLOCK_SIZE)
++		size += SDIO_BLOCK_SIZE;  /* HW bug; force use of block mode */
++#endif
++
+ 	return size;
+ }
+ 
patches/collateral-evolutions/network/75-cw1200-sdio-quirk/cw1200.patch deleted +0 -15
deleted file mode 100644
index 2533051..0000000
@@ -1,15 +0,0 @@
---- a/drivers/net/wireless/cw1200/cw1200_sdio.c
-+++ b/drivers/net/wireless/cw1200/cw1200_sdio.c
-@@ -253,6 +253,12 @@ static size_t cw1200_sdio_align_size(struct hwbus_priv *self, size_t size)
- 	else
- 		size = sdio_align_size(self->func, size);
- 
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0))
-+	/* A quirk to handle this was committed in 3.2-rc */
-+	if (size == SDIO_BLOCK_SIZE)
-+		size += SDIO_BLOCK_SIZE;  /* HW bug; force use of block mode */
-+#endif
-+
- 	return size;
- }
- 
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH v2 3/4 backports: cw1200 utilizes kthreads for <= 2.6.35

In reply to Solomon Peachy

The new workqueue APIs in 2.6.36 allowed us to scrap the old kthread worker that had been used; unfortunately the backported API isn't complete so in order to support older kernels, resurrect this patch.

---
 .../75-cw1200-workqueues/cw1200_workqueues.patch   | 133 +++++++++++++++++++++
 1 file changed, 133 insertions(+)
 create mode 100644 patches/collateral-evolutions/network/75-cw1200-workqueues/cw1200_workqueues.patch
patches/collateral-evolutions/network/75-cw1200-workqueues/cw1200_workqueues.patch new file +133 -0
new file mode 100644
index 0000000..3bf3197
@@ -0,0 +1,133 @@
+diff --git a/drivers/net/wireless/cw1200/bh.c b/drivers/net/wireless/cw1200/bh.c
+index c1ec2a4..5dcbb4e 100644
+--- a/drivers/net/wireless/cw1200/bh.c
++++ b/drivers/net/wireless/cw1200/bh.c
+@@ -48,16 +48,22 @@ enum cw1200_bh_pm_state {
+ typedef int (*cw1200_wsm_handler)(struct cw1200_common *priv,
+ 	u8 *data, size_t size);
+ 
++#ifndef CW1200_USE_COMPAT_KTHREAD
+ static void cw1200_bh_work(struct work_struct *work)
+ {
+ 	struct cw1200_common *priv =
+ 	container_of(work, struct cw1200_common, bh_work);
+ 	cw1200_bh(priv);
+ }
++#endif
+ 
+ int cw1200_register_bh(struct cw1200_common *priv)
+ {
+ 	int err = 0;
++#ifdef CW1200_USE_COMPAT_KTHREAD
++	struct sched_param param = { .sched_priority = 1 };
++	BUG_ON(priv->bh_thread);
++#else
+ 	/* Realtime workqueue */
+ 	priv->bh_workqueue = alloc_workqueue("cw1200_bh",
+ 				WQ_MEM_RECLAIM | WQ_HIGHPRI
+@@ -67,6 +73,7 @@ int cw1200_register_bh(struct cw1200_common *priv)
+ 		return -ENOMEM;
+ 
+ 	INIT_WORK(&priv->bh_work, cw1200_bh_work);
++#endif
+ 
+ 	pr_debug("[BH] register.\n");
+ 
+@@ -81,20 +88,44 @@ int cw1200_register_bh(struct cw1200_common *priv)
+ 	init_waitqueue_head(&priv->bh_wq);
+ 	init_waitqueue_head(&priv->bh_evt_wq);
+ 
++#ifdef CW1200_USE_COMPAT_KTHREAD
++	priv->bh_thread = kthread_create(&cw1200_bh, priv, "cw1200_bh");
++	if (IS_ERR(priv->bh_thread)) {
++		err = PTR_ERR(priv->bh_thread);
++		priv->bh_thread = NULL;
++	} else {
++		WARN_ON(sched_setscheduler(priv->bh_thread,
++					   SCHED_FIFO, &param));
++		wake_up_process(priv->bh_thread);
++	}
++#else
+ 	err = !queue_work(priv->bh_workqueue, &priv->bh_work);
+ 	WARN_ON(err);
++#endif
++
+ 	return err;
+ }
+ 
+ void cw1200_unregister_bh(struct cw1200_common *priv)
+ {
++#ifdef CW1200_USE_COMPAT_KTHREAD
++	struct task_struct *thread = priv->bh_thread;
++	if (WARN_ON(!thread))
++		return;
++#endif
++
+ 	atomic_add(1, &priv->bh_term);
+ 	wake_up(&priv->bh_wq);
+ 
++#ifdef CW1200_USE_COMPAT_KTHREAD
++	kthread_stop(thread);
++	priv->bh_thread = NULL;
++#else
+ 	flush_workqueue(priv->bh_workqueue);
+ 
+ 	destroy_workqueue(priv->bh_workqueue);
+ 	priv->bh_workqueue = NULL;
++#endif
+ 
+ 	pr_debug("[BH] unregistered.\n");
+ }
+@@ -614,6 +645,16 @@ static int cw1200_bh(void *arg)
+ 		pr_err("[BH] Fatal error, exiting.\n");
+ 		priv->bh_error = 1;
+ 		/* TODO: schedule_work(recovery) */
++#ifdef CW1200_USE_COMPAT_KTHREAD
++		for (;;) {
++			int status = wait_event_interruptible(priv->bh_wq, ({
++				term = atomic_xchg(&priv->bh_term, 0);
++				(term);
++			}));
++		if (status || term)
++			break;
++	}
++#endif
+ 	}
+ 	return 0;
+ }
+diff --git a/drivers/net/wireless/cw1200/cw1200.h b/drivers/net/wireless/cw1200/cw1200.h
+index 1ad7d36..300dbbb 100644
+--- a/drivers/net/wireless/cw1200/cw1200.h
++++ b/drivers/net/wireless/cw1200/cw1200.h
+@@ -23,12 +23,18 @@
+ #include <linux/workqueue.h>
+ #include <net/mac80211.h>
+ 
++#include <linux/version.h>
++
+ #include "queue.h"
+ #include "wsm.h"
+ #include "scan.h"
+ #include "txrx.h"
+ #include "pm.h"
+ 
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36))
++#define CW1200_USE_COMPAT_KTHREAD
++#endif
++
+ /* Forward declarations */
+ struct hwbus_ops;
+ struct task_struct;
+@@ -190,8 +196,12 @@ struct cw1200_common {
+ 	atomic_t			bh_term;
+ 	atomic_t			bh_suspend;
+ 
++#ifdef CW1200_USE_COMPAT_KTHREAD
++	struct task_struct              *bh_thread;
++#else
+ 	struct workqueue_struct         *bh_workqueue;
+ 	struct work_struct              bh_work;
++#endif
+ 
+ 	int				bh_error;
+ 	wait_queue_head_t		bh_wq;
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v2 4/4 backports: cw1200 needs the multicast API changes to support <=2.6.35

In reply to Solomon Peachy

Also, update the dependencies:

cw1200_wlan_sdio needs >=2.6.34 due to missing sdio_set_host_pm_flags() cw1200_wlan_spi needs >=2.6.35 due to missing request_any_context_irq()

---
 dependencies                                       |  3 +
 .../drivers_net_wireless_cw1200_sta.patch          | 77 ++++++++++++++++++++++
 2 files changed, 80 insertions(+)
 create mode 100644 patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_cw1200_sta.patch
dependencies +3 -0
index f1e514b..9bd5763 100644
@@ -36,6 +36,9 @@ P54_SPI 2.6.25
 WL1251_SDIO 2.6.37
 WLCORE_SDIO 2.6.38
 
+CW1200_WLAN_SDIO 2.6.34
+CW1200_WLAN_SPI 2.6.35
+
 BRCMFMAC 2.6.29
 
 WL_TI 2.6.30
patches/collateral-evolutions/network/25-multicast-list_head/drivers_net_wireless_cw1200_sta.patch new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#5 lore raw
In reply to Solomon Peachy
Quoted 4 lines · Solomon Peachy

This superscedes the earlier patch set I posted when apparently sleep deprived. It enables the cw1200_wlan_sdio driver to build cleanly on

Quoted 2 lines

=2.6.34 kernels, and the cw1200_wlan_spi driver to build cleanly on =2.6.35 kernels.

Hi Solomon,

I compile tested this and haven't found any problems in cw1200 with this patches applied.

Hauke

#6 lore raw
Quoted 10 lines · Hauke Mehrtens
Quoted 4 lines · Solomon Peachy

This superscedes the earlier patch set I posted when apparently sleep deprived. It enables the cw1200_wlan_sdio driver to build cleanly on

Quoted 2 lines

=2.6.34 kernels, and the cw1200_wlan_spi driver to build cleanly on =2.6.35 kernels.

Hi Solomon,

I compile tested this and haven't found any problems in cw1200 with this patches applied.

I've applied these and will push out later. Thanks!

Luis