All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
@ 2014-06-16  5:49 ` Fu, Zhonghui
  0 siblings, 0 replies; 20+ messages in thread
From: Fu, Zhonghui @ 2014-06-16  5:49 UTC (permalink / raw)
  To: brudley, arend, frankyl, meuleman, linville, pieterpg, dekim,
	mcgrof, antonio, johannes.berg
  Cc: linux-wireless, brcm80211-dev-list, netdev, linux-kernel

>From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
From: Fu zhonghui <zhonghui.fu@linux.intel.com>
Date: Wed, 11 Jun 2014 11:06:55 +0800
Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting

Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
before completion of scanning or connecting.

This will lead to scanning or connecting failure.

Increasing temporarily idle-time threshold during scanning or
connecting can ensure scanning or connecting success without
watchdog interference.

Signed-off-by: Fu zhonghui <zhonghui.fu@linux.intel.com>
---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
 .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index 13c89a0..729deab 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -34,6 +34,7 @@
 #include <linux/vmalloc.h>
 #include <linux/platform_data/brcmfmac-sdio.h>
 #include <linux/moduleparam.h>
+#include <net/cfg80211.h>
 #include <asm/unaligned.h>
 #include <defs.h>
 #include <brcmu_wifi.h>
@@ -43,6 +44,10 @@
 #include "sdio_host.h"
 #include "chip.h"
 #include "nvram.h"
+#include "dhd.h"
+#include "fwil_types.h"
+#include "p2p.h"
+#include "wl_cfg80211.h"
 
 #define DCMD_RESP_TIMEOUT  2000	/* In milli second */
 
@@ -307,6 +312,7 @@ struct rte_console {
 					 * when idle
 					 */
 #define BRCMF_IDLE_INTERVAL	1
+#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING	100
 
 #define KSO_WAIT_US 50
 #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
@@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
 
 static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
 {
-#ifdef DEBUG
 	struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
-#endif	/* DEBUG */
+	struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
+	struct brcmf_if *ifp = cfg->pub->iflist[0];
 
 	brcmf_dbg(TIMER, "Enter\n");
 
@@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
 
 	/* On idle timeout clear activity flag and/or turn off clock */
 	if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
+
+		if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) ||
+		    test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
+			bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
+		} else {
+			bus->idletime = BRCMF_IDLE_INTERVAL;
+		}
+
 		if (++bus->idlecount >= bus->idletime) {
 			bus->idlecount = 0;
 			if (bus->activity) {
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
index be19852..e76517e 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
 		return -EAGAIN;
 	}
 
+	set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
+
 	/* If scan req comes for p2p0, send it over primary I/F */
 	if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
 		vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
@@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
 	}
 
 	cfg->scan_request = request;
-	set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
 	if (escan_req) {
 		cfg->escan_info.run = brcmf_run_escan;
 		err = brcmf_p2p_scan_prep(wiphy, request, vif);
-- 1.7.1


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

* [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
@ 2014-06-16  5:49 ` Fu, Zhonghui
  0 siblings, 0 replies; 20+ messages in thread
From: Fu, Zhonghui @ 2014-06-16  5:49 UTC (permalink / raw)
  To: brudley-dY08KVG/lbpWk0Htik3J/w, arend-dY08KVG/lbpWk0Htik3J/w,
	frankyl-dY08KVG/lbpWk0Htik3J/w, meuleman-dY08KVG/lbpWk0Htik3J/w,
	linville-2XuSBdqkA4R54TAoqtyWWQ, pieterpg-dY08KVG/lbpWk0Htik3J/w,
	dekim-dY08KVG/lbpWk0Htik3J/w, mcgrof-3uybbJdB1yH774rrrx3eTA,
	antonio-2BnEqQcu77q1Z/+hSey0Gg,
	johannes.berg-ral2JQCrhuEAvxtiuMwx3w
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	brcm80211-dev-list-dY08KVG/lbpWk0Htik3J/w,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

>From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
From: Fu zhonghui <zhonghui.fu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Date: Wed, 11 Jun 2014 11:06:55 +0800
Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting

Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
before completion of scanning or connecting.

This will lead to scanning or connecting failure.

Increasing temporarily idle-time threshold during scanning or
connecting can ensure scanning or connecting success without
watchdog interference.

Signed-off-by: Fu zhonghui <zhonghui.fu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
 .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index 13c89a0..729deab 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -34,6 +34,7 @@
 #include <linux/vmalloc.h>
 #include <linux/platform_data/brcmfmac-sdio.h>
 #include <linux/moduleparam.h>
+#include <net/cfg80211.h>
 #include <asm/unaligned.h>
 #include <defs.h>
 #include <brcmu_wifi.h>
@@ -43,6 +44,10 @@
 #include "sdio_host.h"
 #include "chip.h"
 #include "nvram.h"
+#include "dhd.h"
+#include "fwil_types.h"
+#include "p2p.h"
+#include "wl_cfg80211.h"
 
 #define DCMD_RESP_TIMEOUT  2000	/* In milli second */
 
@@ -307,6 +312,7 @@ struct rte_console {
 					 * when idle
 					 */
 #define BRCMF_IDLE_INTERVAL	1
+#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING	100
 
 #define KSO_WAIT_US 50
 #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
@@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
 
 static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
 {
-#ifdef DEBUG
 	struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
-#endif	/* DEBUG */
+	struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
+	struct brcmf_if *ifp = cfg->pub->iflist[0];
 
 	brcmf_dbg(TIMER, "Enter\n");
 
@@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
 
 	/* On idle timeout clear activity flag and/or turn off clock */
 	if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
+
+		if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) ||
+		    test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
+			bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
+		} else {
+			bus->idletime = BRCMF_IDLE_INTERVAL;
+		}
+
 		if (++bus->idlecount >= bus->idletime) {
 			bus->idlecount = 0;
 			if (bus->activity) {
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
index be19852..e76517e 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
 		return -EAGAIN;
 	}
 
+	set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
+
 	/* If scan req comes for p2p0, send it over primary I/F */
 	if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
 		vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
@@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
 	}
 
 	cfg->scan_request = request;
-	set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
 	if (escan_req) {
 		cfg->escan_info.run = brcmf_run_escan;
 		err = brcmf_p2p_scan_prep(wiphy, request, vif);
-- 1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
  2014-06-16  5:49 ` Fu, Zhonghui
@ 2014-06-16  8:15   ` Arend van Spriel
  -1 siblings, 0 replies; 20+ messages in thread
From: Arend van Spriel @ 2014-06-16  8:15 UTC (permalink / raw)
  To: Fu, Zhonghui, brudley, Franky Lin, meuleman, linville, pieterpg,
	dekim, mcgrof, antonio, johannes.berg
  Cc: linux-wireless, brcm80211-dev-list, netdev, linux-kernel,
	linux-mmc, Russell King

On 16-06-14 07:49, Fu, Zhonghui wrote:
>  From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
> From: Fu zhonghui <zhonghui.fu@linux.intel.com>
> Date: Wed, 11 Jun 2014 11:06:55 +0800
> Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
>
> Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
> before completion of scanning or connecting.
>
> This will lead to scanning or connecting failure.
>
> Increasing temporarily idle-time threshold during scanning or
> connecting can ensure scanning or connecting success without
> watchdog interference.

Are you sure you are not having runtime PM enabled. That could be your 
problem as the host controller code disables sdio irqs. Please see this 
thread [1]. For our device runtime pm should not be enabled, but I am 
not sure if that is taken into account in mmc_attach_sdio() (see code 
below).

Gr. AvS

[1] http://www.spinics.net/lists/linux-mmc/msg25978.html

--8<----------------------------------------------------------------

	/*
	 * Enable runtime PM only if supported by host+card+board
	 */
	if (host->caps & MMC_CAP_POWER_OFF_CARD) {
		/*
		 * Let runtime PM core know our card is active
		 */
		err = pm_runtime_set_active(&card->dev);
		if (err)
			goto remove;

		/*
		 * Enable runtime PM for this card
		 */
		pm_runtime_enable(&card->dev);
	}

> Signed-off-by: Fu zhonghui <zhonghui.fu@linux.intel.com>
> ---
>   drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
>   .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
>   2 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> index 13c89a0..729deab 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> @@ -34,6 +34,7 @@
>   #include <linux/vmalloc.h>
>   #include <linux/platform_data/brcmfmac-sdio.h>
>   #include <linux/moduleparam.h>
> +#include <net/cfg80211.h>
>   #include <asm/unaligned.h>
>   #include <defs.h>
>   #include <brcmu_wifi.h>
> @@ -43,6 +44,10 @@
>   #include "sdio_host.h"
>   #include "chip.h"
>   #include "nvram.h"
> +#include "dhd.h"
> +#include "fwil_types.h"
> +#include "p2p.h"
> +#include "wl_cfg80211.h"
>
>   #define DCMD_RESP_TIMEOUT  2000	/* In milli second */
>
> @@ -307,6 +312,7 @@ struct rte_console {
>   					 * when idle
>   					 */
>   #define BRCMF_IDLE_INTERVAL	1
> +#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING	100
>
>   #define KSO_WAIT_US 50
>   #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
> @@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
>
>   static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>   {
> -#ifdef DEBUG
>   	struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
> -#endif	/* DEBUG */
> +	struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
> +	struct brcmf_if *ifp = cfg->pub->iflist[0];
>
>   	brcmf_dbg(TIMER, "Enter\n");
>
> @@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>
>   	/* On idle timeout clear activity flag and/or turn off clock */
>   	if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
> +
> +		if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) ||
> +		    test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
> +			bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
> +		} else {
> +			bus->idletime = BRCMF_IDLE_INTERVAL;
> +		}
> +
>   		if (++bus->idlecount >= bus->idletime) {
>   			bus->idlecount = 0;
>   			if (bus->activity) {
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
> index be19852..e76517e 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
> @@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>   		return -EAGAIN;
>   	}
>
> +	set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
> +
>   	/* If scan req comes for p2p0, send it over primary I/F */
>   	if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
>   		vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
> @@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>   	}
>
>   	cfg->scan_request = request;
> -	set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>   	if (escan_req) {
>   		cfg->escan_info.run = brcmf_run_escan;
>   		err = brcmf_p2p_scan_prep(wiphy, request, vif);
> -- 1.7.1
>


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
@ 2014-06-16  8:15   ` Arend van Spriel
  0 siblings, 0 replies; 20+ messages in thread
From: Arend van Spriel @ 2014-06-16  8:15 UTC (permalink / raw)
  To: Fu, Zhonghui, brudley, Franky Lin, meuleman, linville, pieterpg,
	dekim, mcgrof, antonio, johannes.berg
  Cc: linux-wireless, brcm80211-dev-list, netdev, linux-kernel,
	linux-mmc, Russell King

On 16-06-14 07:49, Fu, Zhonghui wrote:
>  From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
> From: Fu zhonghui <zhonghui.fu@linux.intel.com>
> Date: Wed, 11 Jun 2014 11:06:55 +0800
> Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
>
> Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
> before completion of scanning or connecting.
>
> This will lead to scanning or connecting failure.
>
> Increasing temporarily idle-time threshold during scanning or
> connecting can ensure scanning or connecting success without
> watchdog interference.

Are you sure you are not having runtime PM enabled. That could be your 
problem as the host controller code disables sdio irqs. Please see this 
thread [1]. For our device runtime pm should not be enabled, but I am 
not sure if that is taken into account in mmc_attach_sdio() (see code 
below).

Gr. AvS

[1] http://www.spinics.net/lists/linux-mmc/msg25978.html

--8<----------------------------------------------------------------

	/*
	 * Enable runtime PM only if supported by host+card+board
	 */
	if (host->caps & MMC_CAP_POWER_OFF_CARD) {
		/*
		 * Let runtime PM core know our card is active
		 */
		err = pm_runtime_set_active(&card->dev);
		if (err)
			goto remove;

		/*
		 * Enable runtime PM for this card
		 */
		pm_runtime_enable(&card->dev);
	}

> Signed-off-by: Fu zhonghui <zhonghui.fu@linux.intel.com>
> ---
>   drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
>   .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
>   2 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> index 13c89a0..729deab 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> @@ -34,6 +34,7 @@
>   #include <linux/vmalloc.h>
>   #include <linux/platform_data/brcmfmac-sdio.h>
>   #include <linux/moduleparam.h>
> +#include <net/cfg80211.h>
>   #include <asm/unaligned.h>
>   #include <defs.h>
>   #include <brcmu_wifi.h>
> @@ -43,6 +44,10 @@
>   #include "sdio_host.h"
>   #include "chip.h"
>   #include "nvram.h"
> +#include "dhd.h"
> +#include "fwil_types.h"
> +#include "p2p.h"
> +#include "wl_cfg80211.h"
>
>   #define DCMD_RESP_TIMEOUT  2000	/* In milli second */
>
> @@ -307,6 +312,7 @@ struct rte_console {
>   					 * when idle
>   					 */
>   #define BRCMF_IDLE_INTERVAL	1
> +#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING	100
>
>   #define KSO_WAIT_US 50
>   #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
> @@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
>
>   static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>   {
> -#ifdef DEBUG
>   	struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
> -#endif	/* DEBUG */
> +	struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
> +	struct brcmf_if *ifp = cfg->pub->iflist[0];
>
>   	brcmf_dbg(TIMER, "Enter\n");
>
> @@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>
>   	/* On idle timeout clear activity flag and/or turn off clock */
>   	if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
> +
> +		if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) ||
> +		    test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
> +			bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
> +		} else {
> +			bus->idletime = BRCMF_IDLE_INTERVAL;
> +		}
> +
>   		if (++bus->idlecount >= bus->idletime) {
>   			bus->idlecount = 0;
>   			if (bus->activity) {
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
> index be19852..e76517e 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
> @@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>   		return -EAGAIN;
>   	}
>
> +	set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
> +
>   	/* If scan req comes for p2p0, send it over primary I/F */
>   	if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
>   		vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
> @@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>   	}
>
>   	cfg->scan_request = request;
> -	set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>   	if (escan_req) {
>   		cfg->escan_info.run = brcmf_run_escan;
>   		err = brcmf_p2p_scan_prep(wiphy, request, vif);
> -- 1.7.1
>


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
  2014-06-16  8:15   ` Arend van Spriel
  (?)
@ 2014-06-19 16:28   ` Fu, Zhonghui
  2014-06-19 16:37       ` Arend van Spriel
  -1 siblings, 1 reply; 20+ messages in thread
From: Fu, Zhonghui @ 2014-06-19 16:28 UTC (permalink / raw)
  To: Arend van Spriel, brudley, Franky Lin, meuleman, linville,
	pieterpg, dekim, mcgrof, antonio, johannes.berg
  Cc: linux-wireless, brcm80211-dev-list, netdev, linux-kernel,
	linux-mmc, Russell King


On 2014/6/16 16:15, Arend van Spriel wrote:
> On 16-06-14 07:49, Fu, Zhonghui wrote:
>>  From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
>> From: Fu zhonghui <zhonghui.fu@linux.intel.com>
>> Date: Wed, 11 Jun 2014 11:06:55 +0800
>> Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
>>
>> Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
>> before completion of scanning or connecting.
>>
>> This will lead to scanning or connecting failure.
>>
>> Increasing temporarily idle-time threshold during scanning or
>> connecting can ensure scanning or connecting success without
>> watchdog interference.
>
> Are you sure you are not having runtime PM enabled. That could be your problem as the host controller code disables sdio irqs. Please see this thread [1]. For our device runtime pm should not be enabled, but I am not sure if that is taken into account in mmc_attach_sdio() (see code below).
I have tried brcmfmac driver with "CONFIG_PM_RUNTIME is not set", and scanning and connecting  always succeeded. This means that CONFIG_PM_RUNTIME should not be set if we use SDIO WiFi device driven by brcmfmac driver, right?


Thanks,
Zhonghui
>
> Gr. AvS
>
> [1] http://www.spinics.net/lists/linux-mmc/msg25978.html
>
> --8<----------------------------------------------------------------
>
>     /*
>      * Enable runtime PM only if supported by host+card+board
>      */
>     if (host->caps & MMC_CAP_POWER_OFF_CARD) {
>         /*
>          * Let runtime PM core know our card is active
>          */
>         err = pm_runtime_set_active(&card->dev);
>         if (err)
>             goto remove;
>
>         /*
>          * Enable runtime PM for this card
>          */
>         pm_runtime_enable(&card->dev);
>     }
>
>> Signed-off-by: Fu zhonghui <zhonghui.fu@linux.intel.com>
>> ---
>>   drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
>>   .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
>>   2 files changed, 18 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>> index 13c89a0..729deab 100644
>> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>> @@ -34,6 +34,7 @@
>>   #include <linux/vmalloc.h>
>>   #include <linux/platform_data/brcmfmac-sdio.h>
>>   #include <linux/moduleparam.h>
>> +#include <net/cfg80211.h>
>>   #include <asm/unaligned.h>
>>   #include <defs.h>
>>   #include <brcmu_wifi.h>
>> @@ -43,6 +44,10 @@
>>   #include "sdio_host.h"
>>   #include "chip.h"
>>   #include "nvram.h"
>> +#include "dhd.h"
>> +#include "fwil_types.h"
>> +#include "p2p.h"
>> +#include "wl_cfg80211.h"
>>
>>   #define DCMD_RESP_TIMEOUT  2000    /* In milli second */
>>
>> @@ -307,6 +312,7 @@ struct rte_console {
>>                        * when idle
>>                        */
>>   #define BRCMF_IDLE_INTERVAL    1
>> +#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING    100
>>
>>   #define KSO_WAIT_US 50
>>   #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
>> @@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
>>
>>   static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>   {
>> -#ifdef DEBUG
>>       struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
>> -#endif    /* DEBUG */
>> +    struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
>> +    struct brcmf_if *ifp = cfg->pub->iflist[0];
>>
>>       brcmf_dbg(TIMER, "Enter\n");
>>
>> @@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>
>>       /* On idle timeout clear activity flag and/or turn off clock */
>>       if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
>> +
>> +        if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) ||
>> +            test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
>> +            bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
>> +        } else {
>> +            bus->idletime = BRCMF_IDLE_INTERVAL;
>> +        }
>> +
>>           if (++bus->idlecount >= bus->idletime) {
>>               bus->idlecount = 0;
>>               if (bus->activity) {
>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>> index be19852..e76517e 100644
>> --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>> @@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>           return -EAGAIN;
>>       }
>>
>> +    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>> +
>>       /* If scan req comes for p2p0, send it over primary I/F */
>>       if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
>>           vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
>> @@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>       }
>>
>>       cfg->scan_request = request;
>> -    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>>       if (escan_req) {
>>           cfg->escan_info.run = brcmf_run_escan;
>>           err = brcmf_p2p_scan_prep(wiphy, request, vif);
>> -- 1.7.1
>>
>
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
  2014-06-19 16:28   ` Fu, Zhonghui
@ 2014-06-19 16:37       ` Arend van Spriel
  0 siblings, 0 replies; 20+ messages in thread
From: Arend van Spriel @ 2014-06-19 16:37 UTC (permalink / raw)
  To: Fu, Zhonghui, brudley, Franky Lin, meuleman, linville, pieterpg,
	dekim, mcgrof, antonio, johannes.berg
  Cc: linux-wireless, brcm80211-dev-list, netdev, linux-kernel,
	linux-mmc, Russell King

On 19-06-14 18:28, Fu, Zhonghui wrote:
>
> On 2014/6/16 16:15, Arend van Spriel wrote:
>> On 16-06-14 07:49, Fu, Zhonghui wrote:
>>>   From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
>>> From: Fu zhonghui <zhonghui.fu@linux.intel.com>
>>> Date: Wed, 11 Jun 2014 11:06:55 +0800
>>> Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
>>>
>>> Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
>>> before completion of scanning or connecting.
>>>
>>> This will lead to scanning or connecting failure.
>>>
>>> Increasing temporarily idle-time threshold during scanning or
>>> connecting can ensure scanning or connecting success without
>>> watchdog interference.
>>
>> Are you sure you are not having runtime PM enabled. That could be your problem as the host controller code disables sdio irqs. Please see this thread [1]. For our device runtime pm should not be enabled, but I am not sure if that is taken into account in mmc_attach_sdio() (see code below).
> I have tried brcmfmac driver with "CONFIG_PM_RUNTIME is not set", and scanning and connecting  always succeeded. This means that CONFIG_PM_RUNTIME should not be set if we use SDIO WiFi device driven by brcmfmac driver, right?

Depends which kernel you are using. In 3.16-rc1 the sdio interrupt issue 
has been fixed so you should be fine to use CONFIG_PM_RUNTIME. Here is 
the commit

commit be138554a7923658ded799b0e8794d9c1d08a6e5
Author: Russell King <rmk+kernel@arm.linux.org.uk>
Date:   Fri Apr 25 12:55:56 2014 +0100

     mmc: sdhci: allow sdio interrupts while sdhci runtime suspended

Regards,
Arend

> Thanks,
> Zhonghui
>>
>> Gr. AvS
>>
>> [1] http://www.spinics.net/lists/linux-mmc/msg25978.html
>>
>> --8<----------------------------------------------------------------
>>
>>      /*
>>       * Enable runtime PM only if supported by host+card+board
>>       */
>>      if (host->caps & MMC_CAP_POWER_OFF_CARD) {
>>          /*
>>           * Let runtime PM core know our card is active
>>           */
>>          err = pm_runtime_set_active(&card->dev);
>>          if (err)
>>              goto remove;
>>
>>          /*
>>           * Enable runtime PM for this card
>>           */
>>          pm_runtime_enable(&card->dev);
>>      }
>>
>>> Signed-off-by: Fu zhonghui <zhonghui.fu@linux.intel.com>
>>> ---
>>>    drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
>>>    .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
>>>    2 files changed, 18 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>> index 13c89a0..729deab 100644
>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>> @@ -34,6 +34,7 @@
>>>    #include <linux/vmalloc.h>
>>>    #include <linux/platform_data/brcmfmac-sdio.h>
>>>    #include <linux/moduleparam.h>
>>> +#include <net/cfg80211.h>
>>>    #include <asm/unaligned.h>
>>>    #include <defs.h>
>>>    #include <brcmu_wifi.h>
>>> @@ -43,6 +44,10 @@
>>>    #include "sdio_host.h"
>>>    #include "chip.h"
>>>    #include "nvram.h"
>>> +#include "dhd.h"
>>> +#include "fwil_types.h"
>>> +#include "p2p.h"
>>> +#include "wl_cfg80211.h"
>>>
>>>    #define DCMD_RESP_TIMEOUT  2000    /* In milli second */
>>>
>>> @@ -307,6 +312,7 @@ struct rte_console {
>>>                         * when idle
>>>                         */
>>>    #define BRCMF_IDLE_INTERVAL    1
>>> +#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING    100
>>>
>>>    #define KSO_WAIT_US 50
>>>    #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
>>> @@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
>>>
>>>    static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>    {
>>> -#ifdef DEBUG
>>>        struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
>>> -#endif    /* DEBUG */
>>> +    struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
>>> +    struct brcmf_if *ifp = cfg->pub->iflist[0];
>>>
>>>        brcmf_dbg(TIMER, "Enter\n");
>>>
>>> @@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>
>>>        /* On idle timeout clear activity flag and/or turn off clock */
>>>        if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
>>> +
>>> +        if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) ||
>>> +            test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
>>> +            bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
>>> +        } else {
>>> +            bus->idletime = BRCMF_IDLE_INTERVAL;
>>> +        }
>>> +
>>>            if (++bus->idlecount >= bus->idletime) {
>>>                bus->idlecount = 0;
>>>                if (bus->activity) {
>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>> index be19852..e76517e 100644
>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>> @@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>            return -EAGAIN;
>>>        }
>>>
>>> +    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>>> +
>>>        /* If scan req comes for p2p0, send it over primary I/F */
>>>        if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
>>>            vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
>>> @@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>        }
>>>
>>>        cfg->scan_request = request;
>>> -    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>>>        if (escan_req) {
>>>            cfg->escan_info.run = brcmf_run_escan;
>>>            err = brcmf_p2p_scan_prep(wiphy, request, vif);
>>> -- 1.7.1
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
@ 2014-06-19 16:37       ` Arend van Spriel
  0 siblings, 0 replies; 20+ messages in thread
From: Arend van Spriel @ 2014-06-19 16:37 UTC (permalink / raw)
  To: Fu, Zhonghui, brudley, Franky Lin, meuleman, linville, pieterpg,
	dekim, mcgrof, antonio, johannes.berg
  Cc: linux-wireless, brcm80211-dev-list, netdev, linux-kernel,
	linux-mmc, Russell King

On 19-06-14 18:28, Fu, Zhonghui wrote:
>
> On 2014/6/16 16:15, Arend van Spriel wrote:
>> On 16-06-14 07:49, Fu, Zhonghui wrote:
>>>   From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
>>> From: Fu zhonghui <zhonghui.fu@linux.intel.com>
>>> Date: Wed, 11 Jun 2014 11:06:55 +0800
>>> Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
>>>
>>> Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
>>> before completion of scanning or connecting.
>>>
>>> This will lead to scanning or connecting failure.
>>>
>>> Increasing temporarily idle-time threshold during scanning or
>>> connecting can ensure scanning or connecting success without
>>> watchdog interference.
>>
>> Are you sure you are not having runtime PM enabled. That could be your problem as the host controller code disables sdio irqs. Please see this thread [1]. For our device runtime pm should not be enabled, but I am not sure if that is taken into account in mmc_attach_sdio() (see code below).
> I have tried brcmfmac driver with "CONFIG_PM_RUNTIME is not set", and scanning and connecting  always succeeded. This means that CONFIG_PM_RUNTIME should not be set if we use SDIO WiFi device driven by brcmfmac driver, right?

Depends which kernel you are using. In 3.16-rc1 the sdio interrupt issue 
has been fixed so you should be fine to use CONFIG_PM_RUNTIME. Here is 
the commit

commit be138554a7923658ded799b0e8794d9c1d08a6e5
Author: Russell King <rmk+kernel@arm.linux.org.uk>
Date:   Fri Apr 25 12:55:56 2014 +0100

     mmc: sdhci: allow sdio interrupts while sdhci runtime suspended

Regards,
Arend

> Thanks,
> Zhonghui
>>
>> Gr. AvS
>>
>> [1] http://www.spinics.net/lists/linux-mmc/msg25978.html
>>
>> --8<----------------------------------------------------------------
>>
>>      /*
>>       * Enable runtime PM only if supported by host+card+board
>>       */
>>      if (host->caps & MMC_CAP_POWER_OFF_CARD) {
>>          /*
>>           * Let runtime PM core know our card is active
>>           */
>>          err = pm_runtime_set_active(&card->dev);
>>          if (err)
>>              goto remove;
>>
>>          /*
>>           * Enable runtime PM for this card
>>           */
>>          pm_runtime_enable(&card->dev);
>>      }
>>
>>> Signed-off-by: Fu zhonghui <zhonghui.fu@linux.intel.com>
>>> ---
>>>    drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
>>>    .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
>>>    2 files changed, 18 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>> index 13c89a0..729deab 100644
>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>> @@ -34,6 +34,7 @@
>>>    #include <linux/vmalloc.h>
>>>    #include <linux/platform_data/brcmfmac-sdio.h>
>>>    #include <linux/moduleparam.h>
>>> +#include <net/cfg80211.h>
>>>    #include <asm/unaligned.h>
>>>    #include <defs.h>
>>>    #include <brcmu_wifi.h>
>>> @@ -43,6 +44,10 @@
>>>    #include "sdio_host.h"
>>>    #include "chip.h"
>>>    #include "nvram.h"
>>> +#include "dhd.h"
>>> +#include "fwil_types.h"
>>> +#include "p2p.h"
>>> +#include "wl_cfg80211.h"
>>>
>>>    #define DCMD_RESP_TIMEOUT  2000    /* In milli second */
>>>
>>> @@ -307,6 +312,7 @@ struct rte_console {
>>>                         * when idle
>>>                         */
>>>    #define BRCMF_IDLE_INTERVAL    1
>>> +#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING    100
>>>
>>>    #define KSO_WAIT_US 50
>>>    #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
>>> @@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
>>>
>>>    static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>    {
>>> -#ifdef DEBUG
>>>        struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
>>> -#endif    /* DEBUG */
>>> +    struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
>>> +    struct brcmf_if *ifp = cfg->pub->iflist[0];
>>>
>>>        brcmf_dbg(TIMER, "Enter\n");
>>>
>>> @@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>
>>>        /* On idle timeout clear activity flag and/or turn off clock */
>>>        if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
>>> +
>>> +        if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) ||
>>> +            test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
>>> +            bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
>>> +        } else {
>>> +            bus->idletime = BRCMF_IDLE_INTERVAL;
>>> +        }
>>> +
>>>            if (++bus->idlecount >= bus->idletime) {
>>>                bus->idlecount = 0;
>>>                if (bus->activity) {
>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>> index be19852..e76517e 100644
>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>> @@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>            return -EAGAIN;
>>>        }
>>>
>>> +    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>>> +
>>>        /* If scan req comes for p2p0, send it over primary I/F */
>>>        if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
>>>            vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
>>> @@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>        }
>>>
>>>        cfg->scan_request = request;
>>> -    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>>>        if (escan_req) {
>>>            cfg->escan_info.run = brcmf_run_escan;
>>>            err = brcmf_p2p_scan_prep(wiphy, request, vif);
>>> -- 1.7.1
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
  2014-06-19 16:37       ` Arend van Spriel
  (?)
@ 2014-07-21  7:42       ` Fu, Zhonghui
  2014-07-24 15:22         ` Fu, Zhonghui
  -1 siblings, 1 reply; 20+ messages in thread
From: Fu, Zhonghui @ 2014-07-21  7:42 UTC (permalink / raw)
  To: Arend van Spriel, brudley, Franky Lin, meuleman, linville,
	pieterpg, dekim, mcgrof, antonio, johannes.berg
  Cc: linux-wireless, brcm80211-dev-list, netdev, linux-kernel,
	linux-mmc, Russell King


On 2014/6/20 0:37, Arend van Spriel wrote:
> On 19-06-14 18:28, Fu, Zhonghui wrote:
>>
>> On 2014/6/16 16:15, Arend van Spriel wrote:
>>> On 16-06-14 07:49, Fu, Zhonghui wrote:
>>>>   From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
>>>> From: Fu zhonghui <zhonghui.fu@linux.intel.com>
>>>> Date: Wed, 11 Jun 2014 11:06:55 +0800
>>>> Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
>>>>
>>>> Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
>>>> before completion of scanning or connecting.
>>>>
>>>> This will lead to scanning or connecting failure.
>>>>
>>>> Increasing temporarily idle-time threshold during scanning or
>>>> connecting can ensure scanning or connecting success without
>>>> watchdog interference.
>>>
>>> Are you sure you are not having runtime PM enabled. That could be your problem as the host controller code disables sdio irqs. Please see this thread [1]. For our device runtime pm should not be enabled, but I am not sure if that is taken into account in mmc_attach_sdio() (see code below).
>> I have tried brcmfmac driver with "CONFIG_PM_RUNTIME is not set", and scanning and connecting  always succeeded. This means that CONFIG_PM_RUNTIME should not be set if we use SDIO WiFi device driven by brcmfmac driver, right?
>
> Depends which kernel you are using. In 3.16-rc1 the sdio interrupt issue has been fixed so you should be fine to use CONFIG_PM_RUNTIME. Here is the commit

I run 3.16-rc4 and 3.16-rc5 kernel with CONFIG_PM_RUNTIME set, the issue still exists as follows:

1 step: modprobe brcmfmac
2 step: iwlist wlan1 scan         get scanning result successfully.
3 step: wait a while, no any operation
4 step: iwlist wlan1 scan         scanning timeout, can't get scanning result.


Thanks,
Zhonghui

>
> commit be138554a7923658ded799b0e8794d9c1d08a6e5
> Author: Russell King <rmk+kernel@arm.linux.org.uk>
> Date:   Fri Apr 25 12:55:56 2014 +0100
>
>     mmc: sdhci: allow sdio interrupts while sdhci runtime suspended
>
> Regards,
> Arend
>
>> Thanks,
>> Zhonghui
>>>
>>> Gr. AvS
>>>
>>> [1] http://www.spinics.net/lists/linux-mmc/msg25978.html
>>>
>>> --8<----------------------------------------------------------------
>>>
>>>      /*
>>>       * Enable runtime PM only if supported by host+card+board
>>>       */
>>>      if (host->caps & MMC_CAP_POWER_OFF_CARD) {
>>>          /*
>>>           * Let runtime PM core know our card is active
>>>           */
>>>          err = pm_runtime_set_active(&card->dev);
>>>          if (err)
>>>              goto remove;
>>>
>>>          /*
>>>           * Enable runtime PM for this card
>>>           */
>>>          pm_runtime_enable(&card->dev);
>>>      }
>>>
>>>> Signed-off-by: Fu zhonghui <zhonghui.fu@linux.intel.com>
>>>> ---
>>>>    drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
>>>>    .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
>>>>    2 files changed, 18 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>> index 13c89a0..729deab 100644
>>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>> @@ -34,6 +34,7 @@
>>>>    #include <linux/vmalloc.h>
>>>>    #include <linux/platform_data/brcmfmac-sdio.h>
>>>>    #include <linux/moduleparam.h>
>>>> +#include <net/cfg80211.h>
>>>>    #include <asm/unaligned.h>
>>>>    #include <defs.h>
>>>>    #include <brcmu_wifi.h>
>>>> @@ -43,6 +44,10 @@
>>>>    #include "sdio_host.h"
>>>>    #include "chip.h"
>>>>    #include "nvram.h"
>>>> +#include "dhd.h"
>>>> +#include "fwil_types.h"
>>>> +#include "p2p.h"
>>>> +#include "wl_cfg80211.h"
>>>>
>>>>    #define DCMD_RESP_TIMEOUT  2000    /* In milli second */
>>>>
>>>> @@ -307,6 +312,7 @@ struct rte_console {
>>>>                         * when idle
>>>>                         */
>>>>    #define BRCMF_IDLE_INTERVAL    1
>>>> +#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING    100
>>>>
>>>>    #define KSO_WAIT_US 50
>>>>    #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
>>>> @@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
>>>>
>>>>    static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>>    {
>>>> -#ifdef DEBUG
>>>>        struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
>>>> -#endif    /* DEBUG */
>>>> +    struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
>>>> +    struct brcmf_if *ifp = cfg->pub->iflist[0];
>>>>
>>>>        brcmf_dbg(TIMER, "Enter\n");
>>>>
>>>> @@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>>
>>>>        /* On idle timeout clear activity flag and/or turn off clock */
>>>>        if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
>>>> +
>>>> +        if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) ||
>>>> +            test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
>>>> +            bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
>>>> +        } else {
>>>> +            bus->idletime = BRCMF_IDLE_INTERVAL;
>>>> +        }
>>>> +
>>>>            if (++bus->idlecount >= bus->idletime) {
>>>>                bus->idlecount = 0;
>>>>                if (bus->activity) {
>>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>> index be19852..e76517e 100644
>>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>> @@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>>            return -EAGAIN;
>>>>        }
>>>>
>>>> +    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>>>> +
>>>>        /* If scan req comes for p2p0, send it over primary I/F */
>>>>        if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
>>>>            vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
>>>> @@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>>        }
>>>>
>>>>        cfg->scan_request = request;
>>>> -    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>>>>        if (escan_req) {
>>>>            cfg->escan_info.run = brcmf_run_escan;
>>>>            err = brcmf_p2p_scan_prep(wiphy, request, vif);
>>>> -- 1.7.1
>>>>
>>>
>>> -- 
>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>> Please read the FAQ at  http://www.tux.org/lkml/
>>
>
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
  2014-07-21  7:42       ` Fu, Zhonghui
@ 2014-07-24 15:22         ` Fu, Zhonghui
  2014-08-04 16:36           ` Fu, Zhonghui
  0 siblings, 1 reply; 20+ messages in thread
From: Fu, Zhonghui @ 2014-07-24 15:22 UTC (permalink / raw)
  To: Arend van Spriel, brudley, Franky Lin, meuleman, linville,
	pieterpg, dekim, mcgrof, antonio, johannes.berg
  Cc: linux-wireless, brcm80211-dev-list, netdev, linux-kernel,
	linux-mmc, Russell King


On 2014/7/21 15:42, Fu, Zhonghui wrote:
> On 2014/6/20 0:37, Arend van Spriel wrote:
>> On 19-06-14 18:28, Fu, Zhonghui wrote:
>>> On 2014/6/16 16:15, Arend van Spriel wrote:
>>>> On 16-06-14 07:49, Fu, Zhonghui wrote:
>>>>>   From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
>>>>> From: Fu zhonghui <zhonghui.fu@linux.intel.com>
>>>>> Date: Wed, 11 Jun 2014 11:06:55 +0800
>>>>> Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
>>>>>
>>>>> Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
>>>>> before completion of scanning or connecting.
>>>>>
>>>>> This will lead to scanning or connecting failure.
>>>>>
>>>>> Increasing temporarily idle-time threshold during scanning or
>>>>> connecting can ensure scanning or connecting success without
>>>>> watchdog interference.
>>>> Are you sure you are not having runtime PM enabled. That could be your problem as the host controller code disables sdio irqs. Please see this thread [1]. For our device runtime pm should not be enabled, but I am not sure if that is taken into account in mmc_attach_sdio() (see code below).
>>> I have tried brcmfmac driver with "CONFIG_PM_RUNTIME is not set", and scanning and connecting  always succeeded. This means that CONFIG_PM_RUNTIME should not be set if we use SDIO WiFi device driven by brcmfmac driver, right?
>> Depends which kernel you are using. In 3.16-rc1 the sdio interrupt issue has been fixed so you should be fine to use CONFIG_PM_RUNTIME. Here is the commit
Any clues or comments to the following issue?
> I run 3.16-rc4 and 3.16-rc5 kernel with CONFIG_PM_RUNTIME set, the issue still exists as follows:
>
> 1 step: modprobe brcmfmac
> 2 step: iwlist wlan1 scan         get scanning result successfully.
> 3 step: wait a while, no any operation
> 4 step: iwlist wlan1 scan         scanning timeout, can't get scanning result.
>
>
> Thanks,
> Zhonghui
>
>> commit be138554a7923658ded799b0e8794d9c1d08a6e5
>> Author: Russell King <rmk+kernel@arm.linux.org.uk>
>> Date:   Fri Apr 25 12:55:56 2014 +0100
>>
>>     mmc: sdhci: allow sdio interrupts while sdhci runtime suspended
>>
>> Regards,
>> Arend
>>
>>> Thanks,
>>> Zhonghui
>>>> Gr. AvS
>>>>
>>>> [1] http://www.spinics.net/lists/linux-mmc/msg25978.html
>>>>
>>>> --8<----------------------------------------------------------------
>>>>
>>>>      /*
>>>>       * Enable runtime PM only if supported by host+card+board
>>>>       */
>>>>      if (host->caps & MMC_CAP_POWER_OFF_CARD) {
>>>>          /*
>>>>           * Let runtime PM core know our card is active
>>>>           */
>>>>          err = pm_runtime_set_active(&card->dev);
>>>>          if (err)
>>>>              goto remove;
>>>>
>>>>          /*
>>>>           * Enable runtime PM for this card
>>>>           */
>>>>          pm_runtime_enable(&card->dev);
>>>>      }
>>>>
>>>>> Signed-off-by: Fu zhonghui <zhonghui.fu@linux.intel.com>
>>>>> ---
>>>>>    drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
>>>>>    .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
>>>>>    2 files changed, 18 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>> index 13c89a0..729deab 100644
>>>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>> @@ -34,6 +34,7 @@
>>>>>    #include <linux/vmalloc.h>
>>>>>    #include <linux/platform_data/brcmfmac-sdio.h>
>>>>>    #include <linux/moduleparam.h>
>>>>> +#include <net/cfg80211.h>
>>>>>    #include <asm/unaligned.h>
>>>>>    #include <defs.h>
>>>>>    #include <brcmu_wifi.h>
>>>>> @@ -43,6 +44,10 @@
>>>>>    #include "sdio_host.h"
>>>>>    #include "chip.h"
>>>>>    #include "nvram.h"
>>>>> +#include "dhd.h"
>>>>> +#include "fwil_types.h"
>>>>> +#include "p2p.h"
>>>>> +#include "wl_cfg80211.h"
>>>>>
>>>>>    #define DCMD_RESP_TIMEOUT  2000    /* In milli second */
>>>>>
>>>>> @@ -307,6 +312,7 @@ struct rte_console {
>>>>>                         * when idle
>>>>>                         */
>>>>>    #define BRCMF_IDLE_INTERVAL    1
>>>>> +#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING    100
>>>>>
>>>>>    #define KSO_WAIT_US 50
>>>>>    #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
>>>>> @@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
>>>>>
>>>>>    static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>>>    {
>>>>> -#ifdef DEBUG
>>>>>        struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
>>>>> -#endif    /* DEBUG */
>>>>> +    struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
>>>>> +    struct brcmf_if *ifp = cfg->pub->iflist[0];
>>>>>
>>>>>        brcmf_dbg(TIMER, "Enter\n");
>>>>>
>>>>> @@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>>>
>>>>>        /* On idle timeout clear activity flag and/or turn off clock */
>>>>>        if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
>>>>> +
>>>>> +        if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) ||
>>>>> +            test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
>>>>> +            bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
>>>>> +        } else {
>>>>> +            bus->idletime = BRCMF_IDLE_INTERVAL;
>>>>> +        }
>>>>> +
>>>>>            if (++bus->idlecount >= bus->idletime) {
>>>>>                bus->idlecount = 0;
>>>>>                if (bus->activity) {
>>>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>> index be19852..e76517e 100644
>>>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>> @@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>>>            return -EAGAIN;
>>>>>        }
>>>>>
>>>>> +    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>>>>> +
>>>>>        /* If scan req comes for p2p0, send it over primary I/F */
>>>>>        if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
>>>>>            vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
>>>>> @@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>>>        }
>>>>>
>>>>>        cfg->scan_request = request;
>>>>> -    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>>>>>        if (escan_req) {
>>>>>            cfg->escan_info.run = brcmf_run_escan;
>>>>>            err = brcmf_p2p_scan_prep(wiphy, request, vif);
>>>>> -- 1.7.1
>>>>>
>>>> -- 
>>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>> Please read the FAQ at  http://www.tux.org/lkml/
>> -- 
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
  2014-07-24 15:22         ` Fu, Zhonghui
@ 2014-08-04 16:36           ` Fu, Zhonghui
  2014-08-04 16:52             ` Russell King - ARM Linux
  2014-08-04 17:29               ` Arend van Spriel
  0 siblings, 2 replies; 20+ messages in thread
From: Fu, Zhonghui @ 2014-08-04 16:36 UTC (permalink / raw)
  To: Arend van Spriel, brudley, Franky Lin, meuleman, linville,
	pieterpg, dekim, mcgrof, antonio, johannes.berg
  Cc: linux-wireless, brcm80211-dev-list, netdev, linux-kernel,
	linux-mmc, Russell King


On 2014/7/24 23:22, Fu, Zhonghui wrote:
> On 2014/7/21 15:42, Fu, Zhonghui wrote:
>> On 2014/6/20 0:37, Arend van Spriel wrote:
>>> On 19-06-14 18:28, Fu, Zhonghui wrote:
>>>> On 2014/6/16 16:15, Arend van Spriel wrote:
>>>>> On 16-06-14 07:49, Fu, Zhonghui wrote:
>>>>>>   From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
>>>>>> From: Fu zhonghui <zhonghui.fu@linux.intel.com>
>>>>>> Date: Wed, 11 Jun 2014 11:06:55 +0800
>>>>>> Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
>>>>>>
>>>>>> Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
>>>>>> before completion of scanning or connecting.
>>>>>>
>>>>>> This will lead to scanning or connecting failure.
>>>>>>
>>>>>> Increasing temporarily idle-time threshold during scanning or
>>>>>> connecting can ensure scanning or connecting success without
>>>>>> watchdog interference.
>>>>> Are you sure you are not having runtime PM enabled. That could be your problem as the host controller code disables sdio irqs. Please see this thread [1]. For our device runtime pm should not be enabled, but I am not sure if that is taken into account in mmc_attach_sdio() (see code below).
>>>> I have tried brcmfmac driver with "CONFIG_PM_RUNTIME is not set", and scanning and connecting  always succeeded. This means that CONFIG_PM_RUNTIME should not be set if we use SDIO WiFi device driven by brcmfmac driver, right?
>>> Depends which kernel you are using. In 3.16-rc1 the sdio interrupt issue has been fixed so you should be fine to use CONFIG_PM_RUNTIME. Here is the commit

Hi, Arend

I investigated this issue, and its root cause is still that sdio controller can't receive interrupts from WiFi chip on sdio bus when sdio controller is in runtime suspend status. I am running 3.16-rc5 linux kernel on ASUS T100TA tablet, and using sdhci-acpi driver.


Thanks,
Zhonghui
> Any clues or comments to the following issue?
>> I run 3.16-rc4 and 3.16-rc5 kernel with CONFIG_PM_RUNTIME set, the issue still exists as follows:
>>
>> 1 step: modprobe brcmfmac
>> 2 step: iwlist wlan1 scan         get scanning result successfully.
>> 3 step: wait a while, no any operation
>> 4 step: iwlist wlan1 scan         scanning timeout, can't get scanning result.
>>
>>
>> Thanks,
>> Zhonghui
>>
>>> commit be138554a7923658ded799b0e8794d9c1d08a6e5
>>> Author: Russell King <rmk+kernel@arm.linux.org.uk>
>>> Date:   Fri Apr 25 12:55:56 2014 +0100
>>>
>>>     mmc: sdhci: allow sdio interrupts while sdhci runtime suspended
>>>
>>> Regards,
>>> Arend
>>>
>>>> Thanks,
>>>> Zhonghui
>>>>> Gr. AvS
>>>>>
>>>>> [1] http://www.spinics.net/lists/linux-mmc/msg25978.html
>>>>>
>>>>> --8<----------------------------------------------------------------
>>>>>
>>>>>      /*
>>>>>       * Enable runtime PM only if supported by host+card+board
>>>>>       */
>>>>>      if (host->caps & MMC_CAP_POWER_OFF_CARD) {
>>>>>          /*
>>>>>           * Let runtime PM core know our card is active
>>>>>           */
>>>>>          err = pm_runtime_set_active(&card->dev);
>>>>>          if (err)
>>>>>              goto remove;
>>>>>
>>>>>          /*
>>>>>           * Enable runtime PM for this card
>>>>>           */
>>>>>          pm_runtime_enable(&card->dev);
>>>>>      }
>>>>>
>>>>>> Signed-off-by: Fu zhonghui <zhonghui.fu@linux.intel.com>
>>>>>> ---
>>>>>>    drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
>>>>>>    .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
>>>>>>    2 files changed, 18 insertions(+), 3 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>>> index 13c89a0..729deab 100644
>>>>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>>> @@ -34,6 +34,7 @@
>>>>>>    #include <linux/vmalloc.h>
>>>>>>    #include <linux/platform_data/brcmfmac-sdio.h>
>>>>>>    #include <linux/moduleparam.h>
>>>>>> +#include <net/cfg80211.h>
>>>>>>    #include <asm/unaligned.h>
>>>>>>    #include <defs.h>
>>>>>>    #include <brcmu_wifi.h>
>>>>>> @@ -43,6 +44,10 @@
>>>>>>    #include "sdio_host.h"
>>>>>>    #include "chip.h"
>>>>>>    #include "nvram.h"
>>>>>> +#include "dhd.h"
>>>>>> +#include "fwil_types.h"
>>>>>> +#include "p2p.h"
>>>>>> +#include "wl_cfg80211.h"
>>>>>>
>>>>>>    #define DCMD_RESP_TIMEOUT  2000    /* In milli second */
>>>>>>
>>>>>> @@ -307,6 +312,7 @@ struct rte_console {
>>>>>>                         * when idle
>>>>>>                         */
>>>>>>    #define BRCMF_IDLE_INTERVAL    1
>>>>>> +#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING    100
>>>>>>
>>>>>>    #define KSO_WAIT_US 50
>>>>>>    #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
>>>>>> @@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
>>>>>>
>>>>>>    static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>>>>    {
>>>>>> -#ifdef DEBUG
>>>>>>        struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
>>>>>> -#endif    /* DEBUG */
>>>>>> +    struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
>>>>>> +    struct brcmf_if *ifp = cfg->pub->iflist[0];
>>>>>>
>>>>>>        brcmf_dbg(TIMER, "Enter\n");
>>>>>>
>>>>>> @@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>>>>
>>>>>>        /* On idle timeout clear activity flag and/or turn off clock */
>>>>>>        if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
>>>>>> +
>>>>>> +        if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) ||
>>>>>> +            test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
>>>>>> +            bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
>>>>>> +        } else {
>>>>>> +            bus->idletime = BRCMF_IDLE_INTERVAL;
>>>>>> +        }
>>>>>> +
>>>>>>            if (++bus->idlecount >= bus->idletime) {
>>>>>>                bus->idlecount = 0;
>>>>>>                if (bus->activity) {
>>>>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>>> index be19852..e76517e 100644
>>>>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>>> @@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>>>>            return -EAGAIN;
>>>>>>        }
>>>>>>
>>>>>> +    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>>>>>> +
>>>>>>        /* If scan req comes for p2p0, send it over primary I/F */
>>>>>>        if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
>>>>>>            vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
>>>>>> @@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>>>>        }
>>>>>>
>>>>>>        cfg->scan_request = request;
>>>>>> -    set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
>>>>>>        if (escan_req) {
>>>>>>            cfg->escan_info.run = brcmf_run_escan;
>>>>>>            err = brcmf_p2p_scan_prep(wiphy, request, vif);
>>>>>> -- 1.7.1
>>>>>>
>>>>> -- 
>>>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>>>> the body of a message to majordomo@vger.kernel.org
>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>> Please read the FAQ at  http://www.tux.org/lkml/
>>> -- 
>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>> Please read the FAQ at  http://www.tux.org/lkml/


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
  2014-06-19 16:37       ` Arend van Spriel
  (?)
  (?)
@ 2014-08-04 16:47       ` Russell King - ARM Linux
  -1 siblings, 0 replies; 20+ messages in thread
From: Russell King - ARM Linux @ 2014-08-04 16:47 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: Fu, Zhonghui, brudley, Franky Lin, meuleman, linville, pieterpg,
	dekim, mcgrof, antonio, johannes.berg, linux-wireless,
	brcm80211-dev-list, netdev, linux-kernel, linux-mmc

On Thu, Jun 19, 2014 at 06:37:56PM +0200, Arend van Spriel wrote:
> On 19-06-14 18:28, Fu, Zhonghui wrote:
>> I have tried brcmfmac driver with "CONFIG_PM_RUNTIME is not set", and scanning and connecting  always succeeded. This means that CONFIG_PM_RUNTIME should not be set if we use SDIO WiFi device driven by brcmfmac driver, right?
>
> Depends which kernel you are using. In 3.16-rc1 the sdio interrupt issue  
> has been fixed so you should be fine to use CONFIG_PM_RUNTIME. Here is  
> the commit

I have to say that scanning with the 4329 device seems utterly useless,
whereas 4330 works fine.  Apart from the broadcom chip, the rest of the
hardware is identical.

-- 
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
  2014-08-04 16:36           ` Fu, Zhonghui
@ 2014-08-04 16:52             ` Russell King - ARM Linux
  2014-08-04 20:12                 ` Arend van Spriel
  2014-08-05  5:38               ` Fu, Zhonghui
  2014-08-04 17:29               ` Arend van Spriel
  1 sibling, 2 replies; 20+ messages in thread
From: Russell King - ARM Linux @ 2014-08-04 16:52 UTC (permalink / raw)
  To: Fu, Zhonghui
  Cc: Arend van Spriel, brudley, Franky Lin, meuleman, linville,
	pieterpg, dekim, mcgrof, antonio, johannes.berg, linux-wireless,
	brcm80211-dev-list, netdev, linux-kernel, linux-mmc

On Tue, Aug 05, 2014 at 12:36:49AM +0800, Fu, Zhonghui wrote:
> Hi, Arend
> 
> I investigated this issue, and its root cause is still that sdio
> controller can't receive interrupts from WiFi chip on sdio bus when
> sdio controller is in runtime suspend status. I am running 3.16-rc5
> linux kernel on ASUS T100TA tablet, and using sdhci-acpi driver.

That's the root cause.  I fixed this with the Freescale i.MX SD driver
which is now able to report pending SDIO interrupts while runtime PM
suspended.

Other host drivers probably need fixing too, or having runtime PM
disabled on them - if you can't receive SDIO interrupts while runtime
PM suspended, then entering runtime PM while you have a SDIO device
attached is a bug.

This is something for the MMC people to deal with rather than Arend.

-- 
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
  2014-08-04 16:36           ` Fu, Zhonghui
@ 2014-08-04 17:29               ` Arend van Spriel
  2014-08-04 17:29               ` Arend van Spriel
  1 sibling, 0 replies; 20+ messages in thread
From: Arend van Spriel @ 2014-08-04 17:29 UTC (permalink / raw)
  To: Fu, Zhonghui
  Cc: brudley, Franky Lin, meuleman, linville, pieterpg, dekim, mcgrof,
	antonio, johannes.berg, linux-wireless, brcm80211-dev-list,
	netdev, linux-kernel, linux-mmc, Russell King

On 08/04/14 18:36, Fu, Zhonghui wrote:
>
> On 2014/7/24 23:22, Fu, Zhonghui wrote:
>> On 2014/7/21 15:42, Fu, Zhonghui wrote:
>>> On 2014/6/20 0:37, Arend van Spriel wrote:
>>>> On 19-06-14 18:28, Fu, Zhonghui wrote:
>>>>> On 2014/6/16 16:15, Arend van Spriel wrote:
>>>>>> On 16-06-14 07:49, Fu, Zhonghui wrote:
>>>>>>>     From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
>>>>>>> From: Fu zhonghui<zhonghui.fu@linux.intel.com>
>>>>>>> Date: Wed, 11 Jun 2014 11:06:55 +0800
>>>>>>> Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
>>>>>>>
>>>>>>> Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
>>>>>>> before completion of scanning or connecting.
>>>>>>>
>>>>>>> This will lead to scanning or connecting failure.
>>>>>>>
>>>>>>> Increasing temporarily idle-time threshold during scanning or
>>>>>>> connecting can ensure scanning or connecting success without
>>>>>>> watchdog interference.
>>>>>> Are you sure you are not having runtime PM enabled. That could be your problem as the host controller code disables sdio irqs. Please see this thread [1]. For our device runtime pm should not be enabled, but I am not sure if that is taken into account in mmc_attach_sdio() (see code below).
>>>>> I have tried brcmfmac driver with "CONFIG_PM_RUNTIME is not set", and scanning and connecting  always succeeded. This means that CONFIG_PM_RUNTIME should not be set if we use SDIO WiFi device driven by brcmfmac driver, right?
>>>> Depends which kernel you are using. In 3.16-rc1 the sdio interrupt issue has been fixed so you should be fine to use CONFIG_PM_RUNTIME. Here is the commit
>
> Hi, Arend
>
> I investigated this issue, and its root cause is still that sdio controller can't receive interrupts from WiFi chip on sdio bus when sdio controller is in runtime suspend status. I am running 3.16-rc5 linux kernel on ASUS T100TA tablet, and using sdhci-acpi driver.

Thanks, Zhonghui

Given that the patches Russell made were covering sdhci (as far as I 
recall) your issue may be specific to the sdhci-acpi driver. In 
sdhci_acpi_probe() it is enabled by use_runtime_pm field in private data:

c->use_runtime_pm = sdhci_acpi_flag(c, SDHCI_ACPI_RUNTIME_PM);

Regards,
Arend

> Thanks,
> Zhonghui
>> Any clues or comments to the following issue?
>>> I run 3.16-rc4 and 3.16-rc5 kernel with CONFIG_PM_RUNTIME set, the issue still exists as follows:
>>>
>>> 1 step: modprobe brcmfmac
>>> 2 step: iwlist wlan1 scan         get scanning result successfully.
>>> 3 step: wait a while, no any operation
>>> 4 step: iwlist wlan1 scan         scanning timeout, can't get scanning result.
>>>
>>>
>>> Thanks,
>>> Zhonghui
>>>
>>>> commit be138554a7923658ded799b0e8794d9c1d08a6e5
>>>> Author: Russell King<rmk+kernel@arm.linux.org.uk>
>>>> Date:   Fri Apr 25 12:55:56 2014 +0100
>>>>
>>>>      mmc: sdhci: allow sdio interrupts while sdhci runtime suspended
>>>>
>>>> Regards,
>>>> Arend
>>>>
>>>>> Thanks,
>>>>> Zhonghui
>>>>>> Gr. AvS
>>>>>>
>>>>>> [1] http://www.spinics.net/lists/linux-mmc/msg25978.html
>>>>>>
>>>>>> --8<----------------------------------------------------------------
>>>>>>
>>>>>>       /*
>>>>>>        * Enable runtime PM only if supported by host+card+board
>>>>>>        */
>>>>>>       if (host->caps&  MMC_CAP_POWER_OFF_CARD) {
>>>>>>           /*
>>>>>>            * Let runtime PM core know our card is active
>>>>>>            */
>>>>>>           err = pm_runtime_set_active(&card->dev);
>>>>>>           if (err)
>>>>>>               goto remove;
>>>>>>
>>>>>>           /*
>>>>>>            * Enable runtime PM for this card
>>>>>>            */
>>>>>>           pm_runtime_enable(&card->dev);
>>>>>>       }
>>>>>>
>>>>>>> Signed-off-by: Fu zhonghui<zhonghui.fu@linux.intel.com>
>>>>>>> ---
>>>>>>>     drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
>>>>>>>     .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
>>>>>>>     2 files changed, 18 insertions(+), 3 deletions(-)
>>>>>>>
>>>>>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>>>> index 13c89a0..729deab 100644
>>>>>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>>>> @@ -34,6 +34,7 @@
>>>>>>>     #include<linux/vmalloc.h>
>>>>>>>     #include<linux/platform_data/brcmfmac-sdio.h>
>>>>>>>     #include<linux/moduleparam.h>
>>>>>>> +#include<net/cfg80211.h>
>>>>>>>     #include<asm/unaligned.h>
>>>>>>>     #include<defs.h>
>>>>>>>     #include<brcmu_wifi.h>
>>>>>>> @@ -43,6 +44,10 @@
>>>>>>>     #include "sdio_host.h"
>>>>>>>     #include "chip.h"
>>>>>>>     #include "nvram.h"
>>>>>>> +#include "dhd.h"
>>>>>>> +#include "fwil_types.h"
>>>>>>> +#include "p2p.h"
>>>>>>> +#include "wl_cfg80211.h"
>>>>>>>
>>>>>>>     #define DCMD_RESP_TIMEOUT  2000    /* In milli second */
>>>>>>>
>>>>>>> @@ -307,6 +312,7 @@ struct rte_console {
>>>>>>>                          * when idle
>>>>>>>                          */
>>>>>>>     #define BRCMF_IDLE_INTERVAL    1
>>>>>>> +#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING    100
>>>>>>>
>>>>>>>     #define KSO_WAIT_US 50
>>>>>>>     #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
>>>>>>> @@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
>>>>>>>
>>>>>>>     static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>>>>>     {
>>>>>>> -#ifdef DEBUG
>>>>>>>         struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
>>>>>>> -#endif    /* DEBUG */
>>>>>>> +    struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
>>>>>>> +    struct brcmf_if *ifp = cfg->pub->iflist[0];
>>>>>>>
>>>>>>>         brcmf_dbg(TIMER, "Enter\n");
>>>>>>>
>>>>>>> @@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>>>>>
>>>>>>>         /* On idle timeout clear activity flag and/or turn off clock */
>>>>>>>         if ((bus->idletime>  0)&&  (bus->clkstate == CLK_AVAIL)) {
>>>>>>> +
>>>>>>> +        if (test_bit(BRCMF_SCAN_STATUS_BUSY,&cfg->scan_status) ||
>>>>>>> +            test_bit(BRCMF_VIF_STATUS_CONNECTING,&ifp->vif->sme_state)) {
>>>>>>> +            bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
>>>>>>> +        } else {
>>>>>>> +            bus->idletime = BRCMF_IDLE_INTERVAL;
>>>>>>> +        }
>>>>>>> +
>>>>>>>             if (++bus->idlecount>= bus->idletime) {
>>>>>>>                 bus->idlecount = 0;
>>>>>>>                 if (bus->activity) {
>>>>>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>>>> index be19852..e76517e 100644
>>>>>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>>>> @@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>>>>>             return -EAGAIN;
>>>>>>>         }
>>>>>>>
>>>>>>> +    set_bit(BRCMF_SCAN_STATUS_BUSY,&cfg->scan_status);
>>>>>>> +
>>>>>>>         /* If scan req comes for p2p0, send it over primary I/F */
>>>>>>>         if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
>>>>>>>             vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
>>>>>>> @@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>>>>>         }
>>>>>>>
>>>>>>>         cfg->scan_request = request;
>>>>>>> -    set_bit(BRCMF_SCAN_STATUS_BUSY,&cfg->scan_status);
>>>>>>>         if (escan_req) {
>>>>>>>             cfg->escan_info.run = brcmf_run_escan;
>>>>>>>             err = brcmf_p2p_scan_prep(wiphy, request, vif);
>>>>>>> -- 1.7.1
>>>>>>>
>>>>>> --
>>>>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>>> Please read the FAQ at  http://www.tux.org/lkml/
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>> Please read the FAQ at  http://www.tux.org/lkml/
>


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
@ 2014-08-04 17:29               ` Arend van Spriel
  0 siblings, 0 replies; 20+ messages in thread
From: Arend van Spriel @ 2014-08-04 17:29 UTC (permalink / raw)
  To: Fu, Zhonghui
  Cc: brudley, Franky Lin, meuleman, linville, pieterpg, dekim, mcgrof,
	antonio, johannes.berg, linux-wireless, brcm80211-dev-list,
	netdev, linux-kernel, linux-mmc, Russell King

On 08/04/14 18:36, Fu, Zhonghui wrote:
>
> On 2014/7/24 23:22, Fu, Zhonghui wrote:
>> On 2014/7/21 15:42, Fu, Zhonghui wrote:
>>> On 2014/6/20 0:37, Arend van Spriel wrote:
>>>> On 19-06-14 18:28, Fu, Zhonghui wrote:
>>>>> On 2014/6/16 16:15, Arend van Spriel wrote:
>>>>>> On 16-06-14 07:49, Fu, Zhonghui wrote:
>>>>>>>     From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
>>>>>>> From: Fu zhonghui<zhonghui.fu@linux.intel.com>
>>>>>>> Date: Wed, 11 Jun 2014 11:06:55 +0800
>>>>>>> Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
>>>>>>>
>>>>>>> Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
>>>>>>> before completion of scanning or connecting.
>>>>>>>
>>>>>>> This will lead to scanning or connecting failure.
>>>>>>>
>>>>>>> Increasing temporarily idle-time threshold during scanning or
>>>>>>> connecting can ensure scanning or connecting success without
>>>>>>> watchdog interference.
>>>>>> Are you sure you are not having runtime PM enabled. That could be your problem as the host controller code disables sdio irqs. Please see this thread [1]. For our device runtime pm should not be enabled, but I am not sure if that is taken into account in mmc_attach_sdio() (see code below).
>>>>> I have tried brcmfmac driver with "CONFIG_PM_RUNTIME is not set", and scanning and connecting  always succeeded. This means that CONFIG_PM_RUNTIME should not be set if we use SDIO WiFi device driven by brcmfmac driver, right?
>>>> Depends which kernel you are using. In 3.16-rc1 the sdio interrupt issue has been fixed so you should be fine to use CONFIG_PM_RUNTIME. Here is the commit
>
> Hi, Arend
>
> I investigated this issue, and its root cause is still that sdio controller can't receive interrupts from WiFi chip on sdio bus when sdio controller is in runtime suspend status. I am running 3.16-rc5 linux kernel on ASUS T100TA tablet, and using sdhci-acpi driver.

Thanks, Zhonghui

Given that the patches Russell made were covering sdhci (as far as I 
recall) your issue may be specific to the sdhci-acpi driver. In 
sdhci_acpi_probe() it is enabled by use_runtime_pm field in private data:

c->use_runtime_pm = sdhci_acpi_flag(c, SDHCI_ACPI_RUNTIME_PM);

Regards,
Arend

> Thanks,
> Zhonghui
>> Any clues or comments to the following issue?
>>> I run 3.16-rc4 and 3.16-rc5 kernel with CONFIG_PM_RUNTIME set, the issue still exists as follows:
>>>
>>> 1 step: modprobe brcmfmac
>>> 2 step: iwlist wlan1 scan         get scanning result successfully.
>>> 3 step: wait a while, no any operation
>>> 4 step: iwlist wlan1 scan         scanning timeout, can't get scanning result.
>>>
>>>
>>> Thanks,
>>> Zhonghui
>>>
>>>> commit be138554a7923658ded799b0e8794d9c1d08a6e5
>>>> Author: Russell King<rmk+kernel@arm.linux.org.uk>
>>>> Date:   Fri Apr 25 12:55:56 2014 +0100
>>>>
>>>>      mmc: sdhci: allow sdio interrupts while sdhci runtime suspended
>>>>
>>>> Regards,
>>>> Arend
>>>>
>>>>> Thanks,
>>>>> Zhonghui
>>>>>> Gr. AvS
>>>>>>
>>>>>> [1] http://www.spinics.net/lists/linux-mmc/msg25978.html
>>>>>>
>>>>>> --8<----------------------------------------------------------------
>>>>>>
>>>>>>       /*
>>>>>>        * Enable runtime PM only if supported by host+card+board
>>>>>>        */
>>>>>>       if (host->caps&  MMC_CAP_POWER_OFF_CARD) {
>>>>>>           /*
>>>>>>            * Let runtime PM core know our card is active
>>>>>>            */
>>>>>>           err = pm_runtime_set_active(&card->dev);
>>>>>>           if (err)
>>>>>>               goto remove;
>>>>>>
>>>>>>           /*
>>>>>>            * Enable runtime PM for this card
>>>>>>            */
>>>>>>           pm_runtime_enable(&card->dev);
>>>>>>       }
>>>>>>
>>>>>>> Signed-off-by: Fu zhonghui<zhonghui.fu@linux.intel.com>
>>>>>>> ---
>>>>>>>     drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
>>>>>>>     .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
>>>>>>>     2 files changed, 18 insertions(+), 3 deletions(-)
>>>>>>>
>>>>>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>>>> index 13c89a0..729deab 100644
>>>>>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
>>>>>>> @@ -34,6 +34,7 @@
>>>>>>>     #include<linux/vmalloc.h>
>>>>>>>     #include<linux/platform_data/brcmfmac-sdio.h>
>>>>>>>     #include<linux/moduleparam.h>
>>>>>>> +#include<net/cfg80211.h>
>>>>>>>     #include<asm/unaligned.h>
>>>>>>>     #include<defs.h>
>>>>>>>     #include<brcmu_wifi.h>
>>>>>>> @@ -43,6 +44,10 @@
>>>>>>>     #include "sdio_host.h"
>>>>>>>     #include "chip.h"
>>>>>>>     #include "nvram.h"
>>>>>>> +#include "dhd.h"
>>>>>>> +#include "fwil_types.h"
>>>>>>> +#include "p2p.h"
>>>>>>> +#include "wl_cfg80211.h"
>>>>>>>
>>>>>>>     #define DCMD_RESP_TIMEOUT  2000    /* In milli second */
>>>>>>>
>>>>>>> @@ -307,6 +312,7 @@ struct rte_console {
>>>>>>>                          * when idle
>>>>>>>                          */
>>>>>>>     #define BRCMF_IDLE_INTERVAL    1
>>>>>>> +#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING    100
>>>>>>>
>>>>>>>     #define KSO_WAIT_US 50
>>>>>>>     #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
>>>>>>> @@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
>>>>>>>
>>>>>>>     static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>>>>>     {
>>>>>>> -#ifdef DEBUG
>>>>>>>         struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
>>>>>>> -#endif    /* DEBUG */
>>>>>>> +    struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
>>>>>>> +    struct brcmf_if *ifp = cfg->pub->iflist[0];
>>>>>>>
>>>>>>>         brcmf_dbg(TIMER, "Enter\n");
>>>>>>>
>>>>>>> @@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
>>>>>>>
>>>>>>>         /* On idle timeout clear activity flag and/or turn off clock */
>>>>>>>         if ((bus->idletime>  0)&&  (bus->clkstate == CLK_AVAIL)) {
>>>>>>> +
>>>>>>> +        if (test_bit(BRCMF_SCAN_STATUS_BUSY,&cfg->scan_status) ||
>>>>>>> +            test_bit(BRCMF_VIF_STATUS_CONNECTING,&ifp->vif->sme_state)) {
>>>>>>> +            bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
>>>>>>> +        } else {
>>>>>>> +            bus->idletime = BRCMF_IDLE_INTERVAL;
>>>>>>> +        }
>>>>>>> +
>>>>>>>             if (++bus->idlecount>= bus->idletime) {
>>>>>>>                 bus->idlecount = 0;
>>>>>>>                 if (bus->activity) {
>>>>>>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>>>> index be19852..e76517e 100644
>>>>>>> --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>>>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
>>>>>>> @@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>>>>>             return -EAGAIN;
>>>>>>>         }
>>>>>>>
>>>>>>> +    set_bit(BRCMF_SCAN_STATUS_BUSY,&cfg->scan_status);
>>>>>>> +
>>>>>>>         /* If scan req comes for p2p0, send it over primary I/F */
>>>>>>>         if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
>>>>>>>             vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
>>>>>>> @@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
>>>>>>>         }
>>>>>>>
>>>>>>>         cfg->scan_request = request;
>>>>>>> -    set_bit(BRCMF_SCAN_STATUS_BUSY,&cfg->scan_status);
>>>>>>>         if (escan_req) {
>>>>>>>             cfg->escan_info.run = brcmf_run_escan;
>>>>>>>             err = brcmf_p2p_scan_prep(wiphy, request, vif);
>>>>>>> -- 1.7.1
>>>>>>>
>>>>>> --
>>>>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>>> Please read the FAQ at  http://www.tux.org/lkml/
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>> Please read the FAQ at  http://www.tux.org/lkml/
>

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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
  2014-08-04 16:52             ` Russell King - ARM Linux
@ 2014-08-04 20:12                 ` Arend van Spriel
  2014-08-05  5:38               ` Fu, Zhonghui
  1 sibling, 0 replies; 20+ messages in thread
From: Arend van Spriel @ 2014-08-04 20:12 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Fu, Zhonghui, brudley, Franky Lin, meuleman, linville, pieterpg,
	dekim, mcgrof, antonio, johannes.berg, linux-wireless,
	brcm80211-dev-list, netdev, linux-kernel, linux-mmc

On 08/04/14 18:52, Russell King - ARM Linux wrote:
> On Tue, Aug 05, 2014 at 12:36:49AM +0800, Fu, Zhonghui wrote:
>> Hi, Arend
>>
>> I investigated this issue, and its root cause is still that sdio
>> controller can't receive interrupts from WiFi chip on sdio bus when
>> sdio controller is in runtime suspend status. I am running 3.16-rc5
>> linux kernel on ASUS T100TA tablet, and using sdhci-acpi driver.
>
> That's the root cause.  I fixed this with the Freescale i.MX SD driver
> which is now able to report pending SDIO interrupts while runtime PM
> suspended.
>
> Other host drivers probably need fixing too, or having runtime PM
> disabled on them - if you can't receive SDIO interrupts while runtime
> PM suspended, then entering runtime PM while you have a SDIO device
> attached is a bug.
>
> This is something for the MMC people to deal with rather than Arend.

Occasionally, the itch is there to fix mmc code, but this looks a bit 
tricky. The fun starts in sdio.c:mmc_attach_sdio():

	/*
	 * Enable runtime PM only if supported by host+card+board
	 */
	if (host->caps & MMC_CAP_POWER_OFF_CARD) {
		/*
		 * Let runtime PM core know our card is active
		 */
		err = pm_runtime_set_active(&card->dev);
		if (err)
			goto remove;

		/*
		 * Enable runtime PM for this card
		 */
		pm_runtime_enable(&card->dev);
	}

The comment above the if statement seems to be stating the right idea, 
but the code only looks at the host controller capability flags.

Regards,
Arend


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
@ 2014-08-04 20:12                 ` Arend van Spriel
  0 siblings, 0 replies; 20+ messages in thread
From: Arend van Spriel @ 2014-08-04 20:12 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Fu, Zhonghui, brudley, Franky Lin, meuleman, linville, pieterpg,
	dekim, mcgrof, antonio, johannes.berg, linux-wireless,
	brcm80211-dev-list, netdev, linux-kernel, linux-mmc

On 08/04/14 18:52, Russell King - ARM Linux wrote:
> On Tue, Aug 05, 2014 at 12:36:49AM +0800, Fu, Zhonghui wrote:
>> Hi, Arend
>>
>> I investigated this issue, and its root cause is still that sdio
>> controller can't receive interrupts from WiFi chip on sdio bus when
>> sdio controller is in runtime suspend status. I am running 3.16-rc5
>> linux kernel on ASUS T100TA tablet, and using sdhci-acpi driver.
>
> That's the root cause.  I fixed this with the Freescale i.MX SD driver
> which is now able to report pending SDIO interrupts while runtime PM
> suspended.
>
> Other host drivers probably need fixing too, or having runtime PM
> disabled on them - if you can't receive SDIO interrupts while runtime
> PM suspended, then entering runtime PM while you have a SDIO device
> attached is a bug.
>
> This is something for the MMC people to deal with rather than Arend.

Occasionally, the itch is there to fix mmc code, but this looks a bit 
tricky. The fun starts in sdio.c:mmc_attach_sdio():

	/*
	 * Enable runtime PM only if supported by host+card+board
	 */
	if (host->caps & MMC_CAP_POWER_OFF_CARD) {
		/*
		 * Let runtime PM core know our card is active
		 */
		err = pm_runtime_set_active(&card->dev);
		if (err)
			goto remove;

		/*
		 * Enable runtime PM for this card
		 */
		pm_runtime_enable(&card->dev);
	}

The comment above the if statement seems to be stating the right idea, 
but the code only looks at the host controller capability flags.

Regards,
Arend


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
  2014-08-04 16:52             ` Russell King - ARM Linux
  2014-08-04 20:12                 ` Arend van Spriel
@ 2014-08-05  5:38               ` Fu, Zhonghui
  1 sibling, 0 replies; 20+ messages in thread
From: Fu, Zhonghui @ 2014-08-05  5:38 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Arend van Spriel, brudley, Franky Lin, meuleman, linville,
	pieterpg, dekim, mcgrof, antonio, johannes.berg, linux-wireless,
	brcm80211-dev-list, netdev, linux-kernel, linux-mmc


On 2014/8/5 0:52, Russell King - ARM Linux wrote:
> On Tue, Aug 05, 2014 at 12:36:49AM +0800, Fu, Zhonghui wrote:
>> Hi, Arend
>>
>> I investigated this issue, and its root cause is still that sdio
>> controller can't receive interrupts from WiFi chip on sdio bus when
>> sdio controller is in runtime suspend status. I am running 3.16-rc5
>> linux kernel on ASUS T100TA tablet, and using sdhci-acpi driver.
> That's the root cause.  I fixed this with the Freescale i.MX SD driver
> which is now able to report pending SDIO interrupts while runtime PM
> suspended.
>
> Other host drivers probably need fixing too, or having runtime PM
> disabled on them - if you can't receive SDIO interrupts while runtime
> PM suspended, then entering runtime PM while you have a SDIO device
> attached is a bug.
>
> This is something for the MMC people to deal with rather than Arend.
>
Yes, this should be sdhci-acpi bug, I will contact MMC people for this issue.


Thanks,
Zhonghui

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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
@ 2014-08-05  5:42                   ` Fu, Zhonghui
  0 siblings, 0 replies; 20+ messages in thread
From: Fu, Zhonghui @ 2014-08-05  5:42 UTC (permalink / raw)
  To: Arend van Spriel, Russell King - ARM Linux
  Cc: brudley, Franky Lin, meuleman, linville, pieterpg, dekim, mcgrof,
	antonio, johannes.berg, linux-wireless, brcm80211-dev-list,
	netdev, linux-kernel, linux-mmc


On 2014/8/5 4:12, Arend van Spriel wrote:
> On 08/04/14 18:52, Russell King - ARM Linux wrote:
>> On Tue, Aug 05, 2014 at 12:36:49AM +0800, Fu, Zhonghui wrote:
>>> Hi, Arend
>>>
>>> I investigated this issue, and its root cause is still that sdio
>>> controller can't receive interrupts from WiFi chip on sdio bus when
>>> sdio controller is in runtime suspend status. I am running 3.16-rc5
>>> linux kernel on ASUS T100TA tablet, and using sdhci-acpi driver.
>>
>> That's the root cause.  I fixed this with the Freescale i.MX SD driver
>> which is now able to report pending SDIO interrupts while runtime PM
>> suspended.
>>
>> Other host drivers probably need fixing too, or having runtime PM
>> disabled on them - if you can't receive SDIO interrupts while runtime
>> PM suspended, then entering runtime PM while you have a SDIO device
>> attached is a bug.
>>
>> This is something for the MMC people to deal with rather than Arend.
>
> Occasionally, the itch is there to fix mmc code, but this looks a bit tricky. The fun starts in sdio.c:mmc_attach_sdio():
>
>     /*
>      * Enable runtime PM only if supported by host+card+board
>      */
>     if (host->caps & MMC_CAP_POWER_OFF_CARD) {
>         /*
>          * Let runtime PM core know our card is active
>          */
>         err = pm_runtime_set_active(&card->dev);
>         if (err)
>             goto remove;
>
>         /*
>          * Enable runtime PM for this card
>          */
>         pm_runtime_enable(&card->dev);
>     }
>
> The comment above the if statement seems to be stating the right idea, but the code only looks at the host controller capability flags.

Yes, this code section is not implemented as its comments.

Thanks,
Zhonghui

>
> Regards,
> Arend
>
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


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

* Re: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
@ 2014-08-05  5:42                   ` Fu, Zhonghui
  0 siblings, 0 replies; 20+ messages in thread
From: Fu, Zhonghui @ 2014-08-05  5:42 UTC (permalink / raw)
  To: Arend van Spriel, Russell King - ARM Linux
  Cc: brudley-dY08KVG/lbpWk0Htik3J/w, Franky Lin,
	meuleman-dY08KVG/lbpWk0Htik3J/w, linville-2XuSBdqkA4R54TAoqtyWWQ,
	pieterpg-dY08KVG/lbpWk0Htik3J/w, dekim-dY08KVG/lbpWk0Htik3J/w,
	mcgrof-3uybbJdB1yH774rrrx3eTA, antonio-2BnEqQcu77q1Z/+hSey0Gg,
	johannes.berg-ral2JQCrhuEAvxtiuMwx3w,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	brcm80211-dev-list-dY08KVG/lbpWk0Htik3J/w,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA


On 2014/8/5 4:12, Arend van Spriel wrote:
> On 08/04/14 18:52, Russell King - ARM Linux wrote:
>> On Tue, Aug 05, 2014 at 12:36:49AM +0800, Fu, Zhonghui wrote:
>>> Hi, Arend
>>>
>>> I investigated this issue, and its root cause is still that sdio
>>> controller can't receive interrupts from WiFi chip on sdio bus when
>>> sdio controller is in runtime suspend status. I am running 3.16-rc5
>>> linux kernel on ASUS T100TA tablet, and using sdhci-acpi driver.
>>
>> That's the root cause.  I fixed this with the Freescale i.MX SD driver
>> which is now able to report pending SDIO interrupts while runtime PM
>> suspended.
>>
>> Other host drivers probably need fixing too, or having runtime PM
>> disabled on them - if you can't receive SDIO interrupts while runtime
>> PM suspended, then entering runtime PM while you have a SDIO device
>> attached is a bug.
>>
>> This is something for the MMC people to deal with rather than Arend.
>
> Occasionally, the itch is there to fix mmc code, but this looks a bit tricky. The fun starts in sdio.c:mmc_attach_sdio():
>
>     /*
>      * Enable runtime PM only if supported by host+card+board
>      */
>     if (host->caps & MMC_CAP_POWER_OFF_CARD) {
>         /*
>          * Let runtime PM core know our card is active
>          */
>         err = pm_runtime_set_active(&card->dev);
>         if (err)
>             goto remove;
>
>         /*
>          * Enable runtime PM for this card
>          */
>         pm_runtime_enable(&card->dev);
>     }
>
> The comment above the if statement seems to be stating the right idea, but the code only looks at the host controller capability flags.

Yes, this code section is not implemented as its comments.

Thanks,
Zhonghui

>
> Regards,
> Arend
>
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting
@ 2014-06-11  3:52 Fu, Zhonghui
  0 siblings, 0 replies; 20+ messages in thread
From: Fu, Zhonghui @ 2014-06-11  3:52 UTC (permalink / raw)
  To: linux-kernel

>From 14485894add32aedacb3e486ebb2cc2b73861abf Mon Sep 17 00:00:00 2001
From: Fu zhonghui <zhonghui.fu@linux.intel.com>
Date: Wed, 11 Jun 2014 11:06:55 +0800
Subject: [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting

Watchdog in brcmfmac driver may make WiFi chip enter sleep mode
before completion of scanning or connecting.

This will lead to scanning or connecting failure.

Increasing temporarily idle-time threshold during scanning or
connecting can ensure scanning or connecting success without
watchdog interference.

Signed-off-by: Fu zhonghui <zhonghui.fu@linux.intel.com>
---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   18 ++++++++++++++++--
 .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    3 ++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index 13c89a0..729deab 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -34,6 +34,7 @@
 #include <linux/vmalloc.h>
 #include <linux/platform_data/brcmfmac-sdio.h>
 #include <linux/moduleparam.h>
+#include <net/cfg80211.h>
 #include <asm/unaligned.h>
 #include <defs.h>
 #include <brcmu_wifi.h>
@@ -43,6 +44,10 @@
 #include "sdio_host.h"
 #include "chip.h"
 #include "nvram.h"
+#include "dhd.h"
+#include "fwil_types.h"
+#include "p2p.h"
+#include "wl_cfg80211.h"
 
 #define DCMD_RESP_TIMEOUT  2000	/* In milli second */
 
@@ -307,6 +312,7 @@ struct rte_console {
 					 * when idle
 					 */
 #define BRCMF_IDLE_INTERVAL	1
+#define BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING	100
 
 #define KSO_WAIT_US 50
 #define MAX_KSO_ATTEMPTS (PMU_MAX_TRANSITION_DLY/KSO_WAIT_US)
@@ -3613,9 +3619,9 @@ void brcmf_sdio_isr(struct brcmf_sdio *bus)
 
 static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
 {
-#ifdef DEBUG
 	struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
-#endif	/* DEBUG */
+	struct brcmf_cfg80211_info *cfg = bus_if->drvr->config;
+	struct brcmf_if *ifp = cfg->pub->iflist[0];
 
 	brcmf_dbg(TIMER, "Enter\n");
 
@@ -3678,6 +3684,14 @@ static bool brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus)
 
 	/* On idle timeout clear activity flag and/or turn off clock */
 	if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
+
+		if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) ||
+		    test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
+			bus->idletime = BRCMF_IDLE_INTERVAL_SCANNING_CONNECTING;
+		} else {
+			bus->idletime = BRCMF_IDLE_INTERVAL;
+		}
+
 		if (++bus->idlecount >= bus->idletime) {
 			bus->idlecount = 0;
 			if (bus->activity) {
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
index be19852..e76517e 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -913,6 +913,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
 		return -EAGAIN;
 	}
 
+	set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
+
 	/* If scan req comes for p2p0, send it over primary I/F */
 	if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
 		vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
@@ -933,7 +935,6 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
 	}
 
 	cfg->scan_request = request;
-	set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
 	if (escan_req) {
 		cfg->escan_info.run = brcmf_run_escan;
 		err = brcmf_p2p_scan_prep(wiphy, request, vif);
-- 1.7.1


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

end of thread, other threads:[~2014-08-05  5:42 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-16  5:49 [PATCH] brcmfmac: prevent watchdog from interfering with scanning and connecting Fu, Zhonghui
2014-06-16  5:49 ` Fu, Zhonghui
2014-06-16  8:15 ` Arend van Spriel
2014-06-16  8:15   ` Arend van Spriel
2014-06-19 16:28   ` Fu, Zhonghui
2014-06-19 16:37     ` Arend van Spriel
2014-06-19 16:37       ` Arend van Spriel
2014-07-21  7:42       ` Fu, Zhonghui
2014-07-24 15:22         ` Fu, Zhonghui
2014-08-04 16:36           ` Fu, Zhonghui
2014-08-04 16:52             ` Russell King - ARM Linux
2014-08-04 20:12               ` Arend van Spriel
2014-08-04 20:12                 ` Arend van Spriel
2014-08-05  5:42                 ` Fu, Zhonghui
2014-08-05  5:42                   ` Fu, Zhonghui
2014-08-05  5:38               ` Fu, Zhonghui
2014-08-04 17:29             ` Arend van Spriel
2014-08-04 17:29               ` Arend van Spriel
2014-08-04 16:47       ` Russell King - ARM Linux
  -- strict thread matches above, loose matches on Subject: below --
2014-06-11  3:52 Fu, Zhonghui

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.