net: wireless: bcm4329: Add memory barriers to wait functions
authorDmitry Shmidt <dimitrysh@google.com>
Fri, 13 Aug 2010 19:16:13 +0000 (12:16 -0700)
committerColin Cross <ccross@android.com>
Thu, 30 Sep 2010 00:49:43 +0000 (17:49 -0700)
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
drivers/net/wireless/bcm4329/dhd.h
drivers/net/wireless/bcm4329/dhd_linux.c
drivers/net/wireless/bcm4329/dhd_proto.h

index 9db5c6370972d42a41189bb5cb21ca205ffb7b3d..838b3adf80b37df52404433b217a875937890499 100644 (file)
@@ -162,16 +162,17 @@ typedef struct dhd_pub {
 
 } dhd_pub_t;
 
-       #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
 
        #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
-       #define _DHD_PM_RESUME_WAIT(a, b) do {\
+       #define _DHD_PM_RESUME_WAIT(a, b) do { \
                        int retry = 0; \
+                       smp_mb(); \
                        while (dhd_mmc_suspend && retry++ != b) { \
                                wait_event_interruptible_timeout(a, FALSE, HZ/100); \
                        } \
                }       while (0)
-       #define DHD_PM_RESUME_WAIT(a)                   _DHD_PM_RESUME_WAIT(a, 30)
+       #define DHD_PM_RESUME_WAIT(a)           _DHD_PM_RESUME_WAIT(a, 30)
        #define DHD_PM_RESUME_WAIT_FOREVER(a)   _DHD_PM_RESUME_WAIT(a, ~0)
        #define DHD_PM_RESUME_RETURN_ERROR(a)   do { if (dhd_mmc_suspend) return a; } while (0)
        #define DHD_PM_RESUME_RETURN            do { if (dhd_mmc_suspend) return; } while (0)
@@ -185,7 +186,7 @@ typedef struct dhd_pub {
                } \
        } while (0)
 
-       #else
+#else
 
        #define DHD_PM_RESUME_WAIT_INIT(a)
        #define DHD_PM_RESUME_WAIT(a)
@@ -202,7 +203,8 @@ typedef struct dhd_pub {
                } \
        } while (0)
 
-       #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
+
 #define DHD_IF_VIF     0x01    /* Virtual IF (Hidden from user) */
 
 /* Wakelock Functions */
index 45329e9a8b2caeebf71d3a680584f6ddee8ad8fd..8b424e58308c112b9a6ff5a967fbe1157d7d9659 100644 (file)
@@ -469,18 +469,22 @@ static int dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
 static int dhd_sleep_pm_callback(struct notifier_block *nfb, unsigned long action, void *ignored)
 {
-       switch (action)
-       {
-               case PM_HIBERNATION_PREPARE:
-               case PM_SUSPEND_PREPARE:
-                       dhd_mmc_suspend = TRUE;
-                       return NOTIFY_OK;
-               case PM_POST_HIBERNATION:
-               case PM_POST_SUSPEND:
-                       dhd_mmc_suspend = FALSE;
-               return NOTIFY_OK;
+       int ret = NOTIFY_DONE;
+
+       switch (action) {
+       case PM_HIBERNATION_PREPARE:
+       case PM_SUSPEND_PREPARE:
+               dhd_mmc_suspend = TRUE;
+               ret = NOTIFY_OK;
+               break;
+       case PM_POST_HIBERNATION:
+       case PM_POST_SUSPEND:
+               dhd_mmc_suspend = FALSE;
+               ret = NOTIFY_OK;
+               break;
        }
-       return 0;
+       smp_mb();
+       return ret;
 }
 
 static struct notifier_block dhd_sleep_pm_notifier = {
@@ -2577,14 +2581,17 @@ dhd_os_ioctl_resp_wait(dhd_pub_t *pub, uint *condition, bool *pending)
        int timeout = dhd_ioctl_timeout_msec;
 
        /* Convert timeout in millsecond to jiffies */
-       timeout = timeout * HZ / 1000;
+       /* timeout = timeout * HZ / 1000; */
+       timeout = msecs_to_jiffies(timeout);
 
        /* Wait until control frame is available */
        add_wait_queue(&dhd->ioctl_resp_wait, &wait);
        set_current_state(TASK_INTERRUPTIBLE);
-
-       while (!(*condition) && (!signal_pending(current) && timeout))
+       smp_mb();
+       while (!(*condition) && (!signal_pending(current) && timeout)) {
                timeout = schedule_timeout(timeout);
+               smp_mb();
+       }
 
        if (signal_pending(current))
                *pending = TRUE;
index 382785a1ff6b47baf31f1febd2ac54b71bdaa57a..7ef6929a5bf728a693c9b761220d4a760d4c2498 100644 (file)
@@ -34,7 +34,7 @@
 #include <wlioctl.h>
 
 #ifndef IOCTL_RESP_TIMEOUT
-#define IOCTL_RESP_TIMEOUT  2000 /* In milli second */
+#define IOCTL_RESP_TIMEOUT  3000 /* In milli second */
 #endif
 
 #ifndef IOCTL_CHIP_ACTIVE_TIMEOUT