Skip to contentSkip to conversation

ath6kl: fix suspend and resume

PATCH In review Kalle Valo 2 participants 3 messages Jul 21, 2011 Staging

lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

PATCH 1/1 ath6kl: fix suspend and resume

The current suspend code in ath6kl is not working properly. Most of the time during response there are sdio errors and sdio stack reloads the driver.

I was pondering different options how to fix this and decided to take the simplest route. First remove all the existing suspend/resume code which was complicated and replace it with code which will leave the chip powered on but will put it to deep sleep state. Now suspend works much faster and realiably, the cost being that power consumption will increase a bit during suspend.

---
 .../staging/ath6kl/hif/sdio/linux_sdio/src/hif.c   |  127 ----
 drivers/staging/ath6kl/os/linux/ar6000_drv.c       |   35 -
 drivers/staging/ath6kl/os/linux/ar6000_pm.c        |  603 --------------------
 drivers/staging/ath6kl/os/linux/cfg80211.c         |   65 ++
 .../staging/ath6kl/os/linux/include/ar6000_drv.h   |    8 
 .../ath6kl/os/linux/include/ar6xapi_linux.h        |    7 
 6 files changed, 65 insertions(+), 780 deletions(-)
drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif.c +0 -127
index 5f5d677..156b552 100644
@@ -50,10 +50,6 @@
 #endif
 
 /* ATHENV */
-#if defined(CONFIG_PM)
-#define dev_to_sdio_func(d)	container_of(d, struct sdio_func, dev)
-#define to_sdio_driver(d)      container_of(d, struct sdio_driver, drv)
-#endif /* CONFIG_PM */
 static void delHifDevice(struct hif_device * device);
 static int Func0_CMD52WriteByte(struct mmc_card *card, unsigned int address, unsigned char byte);
 static int Func0_CMD52ReadByte(struct mmc_card *card, unsigned int address, unsigned char *byte);
@@ -160,72 +156,11 @@ static void ath6kl_hifdev_remove(struct sdio_func *func)
 	delHifDevice(device);
 }
 
-#if defined(CONFIG_PM)
-static int ath6kl_hifdev_suspend(struct device *dev)
-{
-	struct sdio_func *func = dev_to_sdio_func(dev);
-	int status = 0;
-	struct hif_device *device;
-
-	device = ath6kl_get_hifdev(func);
-
-	if (device && device->claimedContext &&
-	    osdrvCallbacks.deviceSuspendHandler) {
-		/* set true first for PowerStateChangeNotify(..) */
-		device->is_suspend = true;
-		status = osdrvCallbacks.
-			deviceSuspendHandler(device->claimedContext);
-		if (status)
-			device->is_suspend = false;
-	}
-
-	CleanupHIFScatterResources(device);
-
-	switch (status) {
-	case 0:
-		return 0;
-	case A_EBUSY:
-		/* Hack for kernel in order to support deep sleep and wow */
-		return -EBUSY;
-	default:
-		return -1;
-	}
-}
-
-static int ath6kl_hifdev_resume(struct device *dev)
-{
-	struct sdio_func *func = dev_to_sdio_func(dev);
-	int status = 0;
-	struct hif_device *device;
-
-	device = ath6kl_get_hifdev(func);
-	if (device && device->claimedContext &&
-	    osdrvCallbacks.deviceSuspendHandler) {
-		status = osdrvCallbacks.
-			deviceResumeHandler(device->claimedContext);
-		if (status == 0)
-			device->is_suspend = false;
-	}
-
-	return status;
-}
-
-static const struct dev_pm_ops ath6kl_hifdev_pmops = {
-	.suspend = ath6kl_hifdev_suspend,
-	.resume = ath6kl_hifdev_resume,
-};
-#endif /* CONFIG_PM */
-
 static struct sdio_driver ath6kl_hifdev_driver = {
 	.name = "ath6kl_hifdev",
 	.id_table = ath6kl_hifdev_ids,
 	.probe = ath6kl_hifdev_probe,
 	.remove = ath6kl_hifdev_remove,
-#if defined(CONFIG_PM)
-	.drv = {
-		.pm = &ath6kl_hifdev_pmops,
-	},
-#endif
 };
 
 /* make sure we only unregister when registered. */
@@ -769,42 +704,6 @@ int
 PowerStateChangeNotify(struct hif_device *device, HIF_DEVICE_POWER_CHANGE_TYPE config)
 {
     int status = 0;
-#if defined(CONFIG_PM)
-	struct sdio_func *func = device->func;
-    int old_reset_val;
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +PowerStateChangeNotify %d\n", config));
-    switch (config) {
-       case HIF_DEVICE_POWER_DOWN:
-       case HIF_DEVICE_POWER_CUT:
-            old_reset_val = reset_sdio_on_unload;
-            reset_sdio_on_unload = 1;
-            status = hifDisableFunc(device, func);
-            reset_sdio_on_unload = old_reset_val;
-            if (!device->is_suspend) {
-                struct mmc_host *host = func->card->host;
-	            host->ios.clock = 0;
-	            host->ios.vdd = 0;
-                host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
-                host->ios.chip_select = MMC_CS_DONTCARE;
-                host->ios.power_mode = MMC_POWER_OFF;
-                host->ios.bus_width = MMC_BUS_WIDTH_1;
-                host->ios.timing = MMC_TIMING_LEGACY;
-                host->ops->set_ios(host, &host->ios);
-            }
-            break;
-       case HIF_DEVICE_POWER_UP:
-            if (device->powerConfig == HIF_DEVICE_POWER_CUT) {
-                status = ReinitSDIO(device);
-            }
-            if (status == 0) {
-                status = hifEnableFunc(device, func);
-            }
-            break;
-    } 
-    device->powerConfig = config;
-
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: -PowerStateChangeNotify\n"));
-#endif
     return status;
 }
 
@@ -921,26 +820,6 @@ static int startup_task(void *param)
     return 0;
 }
 
-#if defined(CONFIG_PM)
-static int enable_task(void *param)
-{
-    struct hif_device *device;
-    device = (struct hif_device *)param;
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: call  from resume_task\n"));
-
-        /* start  up inform DRV layer */
-    if (device && 
-        device->claimedContext && 
-        osdrvCallbacks.devicePowerChangeHandler &&
-        osdrvCallbacks.devicePowerChangeHandler(device->claimedContext, HIF_DEVICE_POWER_UP) != 0)
-    {
-        AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: Device rejected\n"));
-    }
-
-    return 0;
-}
-#endif
-
 void
 HIFAckInterrupt(struct hif_device *device)
 {
@@ -1132,12 +1011,6 @@ static int hifEnableFunc(struct hif_device *device, struct sdio_func *func)
         taskFunc = startup_task;
         taskName = "AR6K startup";
         ret = 0;
-#if defined(CONFIG_PM)
-    } else {
-        taskFunc = enable_task;
-        taskName = "AR6K enable";
-        ret = -ENOMEM;
-#endif /* CONFIG_PM */
     }
     /* create resume thread */
     pTask = kthread_create(taskFunc, (void *)device, taskName);
drivers/staging/ath6kl/os/linux/ar6000_drv.c +1 -34
index 499b7a9..f12d9f6 100644
@@ -634,11 +634,6 @@ ar6000_init_module(void)
     A_MEMZERO(&osdrvCallbacks,sizeof(osdrvCallbacks));
     osdrvCallbacks.deviceInsertedHandler = ar6000_avail_ev;
     osdrvCallbacks.deviceRemovedHandler = ar6000_unavail_ev;
-#ifdef CONFIG_PM
-    osdrvCallbacks.deviceSuspendHandler = ar6000_suspend_ev;
-    osdrvCallbacks.deviceResumeHandler = ar6000_resume_ev;
-    osdrvCallbacks.devicePowerChangeHandler = ar6000_power_change_ev;
-#endif
 
 #ifdef DEBUG
     /* Set the debug flags if specified at load time */
@@ -1704,14 +1699,6 @@ ar6000_avail_ev(void *context, void *hif_handle)
 
     ar->arWlanPowerState     = WLAN_POWER_STATE_ON;
     ar->arWlanOff            = false;   /* We are in ON state */
-#ifdef CONFIG_PM
-    ar->arWowState           = WLAN_WOW_STATE_NONE;
-    ar->arBTOff              = true;   /* BT chip assumed to be OFF */
-    ar->arBTSharing          = WLAN_CONFIG_BT_SHARING; 
-    ar->arWlanOffConfig      = WLAN_CONFIG_WLAN_OFF;
-    ar->arSuspendConfig      = WLAN_CONFIG_PM_SUSPEND;
-    ar->arWow2Config         = WLAN_CONFIG_PM_WOW2;
-#endif /* CONFIG_PM */
 
     A_INIT_TIMER(&ar->arHBChallengeResp.timer, ar6000_detect_error, dev);
     ar->arHBChallengeResp.seqNum = 0;
@@ -2944,12 +2931,6 @@ ar6000_data_tx(struct sk_buff *skb, struct net_device *dev)
     bool            checkAdHocPsMapping = false,bMoreData = false;
     HTC_TX_TAG        htc_tag = AR6K_DATA_PKT_TAG;
     u8 dot11Hdr = processDot11Hdr;
-#ifdef CONFIG_PM
-    if (ar->arWowState != WLAN_WOW_STATE_NONE) {
-        A_NETBUF_FREE(skb);
-        return 0;
-    }
-#endif /* CONFIG_PM */
 
     AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX,("ar6000_data_tx start - skb=0x%lx, data=0x%lx, len=0x%x\n",
                      (unsigned long)skb, (unsigned long)A_NETBUF_DATA(skb),
@@ -3668,9 +3649,6 @@ ar6000_rx(void *Context, struct htc_packet *pPacket)
            /*
             * this is a wmi control msg
             */
-#ifdef CONFIG_PM 
-            ar6000_check_wow_status(ar, skb, true);
-#endif /* CONFIG_PM */
             wmi_control_rx(ar->arWmi, skb);
         } else {
                 WMI_DATA_HDR *dhdr = (WMI_DATA_HDR *)A_NETBUF_DATA(skb);
@@ -3693,9 +3671,6 @@ ar6000_rx(void *Context, struct htc_packet *pPacket)
 			return;
 		}
 
-#ifdef CONFIG_PM 
-                ar6000_check_wow_status(ar, NULL, false);
-#endif /* CONFIG_PM */
                 /*
                  * this is a wmi data packet
                  */
@@ -3912,9 +3887,6 @@ ar6000_deliver_frames_to_nw_stack(void *dev, void *osbuf)
     if(skb) {
         skb->dev = dev;
         if ((skb->dev->flags & IFF_UP) == IFF_UP) {
-#ifdef CONFIG_PM 
-            ar6000_check_wow_status((struct ar6_softc *)ar6k_priv(dev), skb, false);
-#endif /* CONFIG_PM */
             skb->protocol = eth_type_trans(skb, skb->dev);
         /*
          * If this routine is called on a ISR (Hard IRQ) or DSR (Soft IRQ)
@@ -5189,12 +5161,7 @@ ar6000_control_tx(void *devt, void *osbuf, HTC_ENDPOINT_ID eid)
     int         status = 0;
     struct ar_cookie *cookie = NULL;
     int i;
-#ifdef CONFIG_PM
-    if (ar->arWowState != WLAN_WOW_STATE_NONE) {
-        A_NETBUF_FREE(osbuf);
-        return A_EACCES;
-    }
-#endif /* CONFIG_PM */
+
         /* take lock to protect ar6000_alloc_cookie() */
     AR6000_SPIN_LOCK(&ar->arLock, 0);
 
drivers/staging/ath6kl/os/linux/ar6000_pm.c +0 -603

606 lines not on this page · raw message

drivers/staging/ath6kl/os/linux/cfg80211.c +64 -1

85 lines not on this page · raw message

drivers/staging/ath6kl/os/linux/include/ar6000_drv.h +0 -8
index 05cc774..2240da9 100644
@@ -627,14 +627,6 @@ struct ar6_softc {
     u32 smeState;
     u16 arWlanPowerState;
     bool                  arWlanOff;
-#ifdef CONFIG_PM
-    u16 arWowState;
-    bool                  arBTOff;
-    bool                  arBTSharing;
-    u16 arSuspendConfig;
-    u16 arWlanOffConfig;
-    u16 arWow2Config;
-#endif
     u8 scan_triggered;
     WMI_SCAN_PARAMS_CMD     scParams;
 #define AR_MCAST_FILTER_MAC_ADDR_SIZE  4
drivers/staging/ath6kl/os/linux/include/ar6xapi_linux.h +0 -7
index 184dbdb..063a8ec 100644
@@ -171,13 +171,6 @@ int ar6000_update_wlan_pwr_state(struct ar6_softc *ar, AR6000_WLAN_STATE state,
 int ar6000_set_wlan_state(struct ar6_softc *ar, AR6000_WLAN_STATE state);
 int ar6000_set_bt_hw_state(struct ar6_softc *ar, u32 state);
 
-#ifdef CONFIG_PM
-int ar6000_suspend_ev(void *context);
-int ar6000_resume_ev(void *context);
-int ar6000_power_change_ev(void *context, u32 config);
-void ar6000_check_wow_status(struct ar6_softc *ar, struct sk_buff *skb, bool isEvent);
-#endif
-
 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
 int ar6000_add_ap_interface(struct ar6_softc *ar, char *ifname);
 int ar6000_remove_ap_interface(struct ar6_softc *ar);
#1 lore raw

Hi Greg,

Quoted 10 lines · Kalle Valo

The current suspend code in ath6kl is not working properly. Most of the time during response there are sdio errors and sdio stack reloads the driver.

I was pondering different options how to fix this and decided to take the simplest route. First remove all the existing suspend/resume code which was complicated and replace it with code which will leave the chip powered on but will put it to deep sleep state. Now suspend works much faster and realiably, the cost being that power consumption will increase a bit during suspend.

With ath6kl-cleanup we missed the 3.1 deadline for the wireless code so the staging version of ath6kl will be still in 3.1. Because of this I need to send few critical fixes for 3.1, this suspend fix being one of them. There are might few others as well, but the patches are not ready yet.

I'm doing the big mistake of sending new code and going for a trip the next day and not have internet access for 10 days. If there are any issues my collagues will jump in.

Signature · 1 line
Kalle Valo
#2 lore raw
In reply to Kalle Valo
Quoted 10 lines · Kalle Valo

The current suspend code in ath6kl is not working properly. Most of the time during response there are sdio errors and sdio stack reloads the driver.

I was pondering different options how to fix this and decided to take the simplest route. First remove all the existing suspend/resume code which was complicated and replace it with code which will leave the chip powered on but will put it to deep sleep state. Now suspend works much faster and realiably, the cost being that power consumption will increase a bit during suspend.

Please drop this patch. I missed a compiler warning:

drivers/staging/ath6kl/os/linux/cfg80211.c:1877: warning:
initialization from incompatible pointer type

Signature · 1 line
Kalle Valo