Skip to contentSkip to conversation

sdio: Prevent re-tuning conflicting with custom sleep

PATCH New Adrian Hunter 1 participant 3 messages Dec 8, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover sdio: Prevent re-tuning conflicting with custom sleep

Hi

Here are 2 patches that allow brcmfmac to awake from a custom sleep state that conflicts with re-tuning.

The first patch adds sdio_retune_hold_now() and sdio_retune_release(). They are used in the 2nd patch to prevent re-tuning for the 'wake-up' command.

These patches were last posted here:

	https://marc.info/?l=linux-mmc&m=143023247221784

Changes in V2:

brcmfmac: Prevent re-tuning conflicting with 'wake-up'
Apply to file moved from:
drivers/net/wireless/brcm80211/brcmfmac/sdio.c
to:
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c

Adrian Hunter (2):
mmc: core: Add functions for SDIO to hold re-tuning
brcmfmac: Prevent re-tuning conflicting with 'wake-up'

 drivers/mmc/core/host.c                                 |  6 ++++++
 drivers/mmc/core/host.h                                 |  1 +
 drivers/mmc/core/sdio_io.c                              | 13 +++++++++++++
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c |  6 ++++++
 include/linux/mmc/sdio_func.h                           |  3 +++
 5 files changed, 29 insertions(+)

Regards
Adrian

#1 lore raw

PATCH v2 1/2 mmc: core: Add functions for SDIO to hold re-tuning

Add sdio_retune_hold_now() and sdio_retune_release() in order to allow SDIO function drivers to prevent re-tuning in cases where it conflicts with the device state.

---
 drivers/mmc/core/host.c       |  6 ++++++
 drivers/mmc/core/host.h       |  1 +
 drivers/mmc/core/sdio_io.c    | 13 +++++++++++++
 include/linux/mmc/sdio_func.h |  3 +++
 4 files changed, 23 insertions(+)
drivers/mmc/core/host.c +6 -0
index 98f25ffb4258..6c0f33c70b4a 100644
@@ -113,6 +113,12 @@ void mmc_retune_hold(struct mmc_host *host)
 	host->hold_retune += 1;
 }
 
+void mmc_retune_hold_now(struct mmc_host *host)
+{
+	host->retune_now = 0;
+	host->hold_retune += 1;
+}
+
 void mmc_retune_release(struct mmc_host *host)
 {
 	if (host->hold_retune)
drivers/mmc/core/host.h +1 -0
index 992bf5397633..5e9a1293091b 100644
@@ -18,6 +18,7 @@
 void mmc_retune_enable(struct mmc_host *host);
 void mmc_retune_disable(struct mmc_host *host);
 void mmc_retune_hold(struct mmc_host *host);
+void mmc_retune_hold_now(struct mmc_host *host);
 void mmc_retune_release(struct mmc_host *host);
 int mmc_retune(struct mmc_host *host);
 
drivers/mmc/core/sdio_io.c +13 -0
index 406e5f037e32..a840d8c76a24 100644
@@ -15,6 +15,7 @@
 #include <linux/mmc/sdio.h>
 #include <linux/mmc/sdio_func.h>
 
+#include "host.h"
 #include "sdio_ops.h"
 
 /**
@@ -735,3 +736,15 @@ int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags)
 	return 0;
 }
 EXPORT_SYMBOL_GPL(sdio_set_host_pm_flags);
+
+void sdio_retune_hold_now(struct sdio_func *func)
+{
+	mmc_retune_hold_now(func->card->host);
+}
+EXPORT_SYMBOL_GPL(sdio_retune_hold_now);
+
+void sdio_retune_release(struct sdio_func *func)
+{
+	mmc_retune_release(func->card->host);
+}
+EXPORT_SYMBOL_GPL(sdio_retune_release);
include/linux/mmc/sdio_func.h +3 -0
index aab032a6ae61..50d667b76a08 100644
@@ -159,4 +159,7 @@ extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b,
 extern mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func);
 extern int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags);
 
+extern void sdio_retune_hold_now(struct sdio_func *func);
+extern void sdio_retune_release(struct sdio_func *func);
+
 #endif /* LINUX_MMC_SDIO_FUNC_H */
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/2 brcmfmac: Prevent re-tuning conflicting with 'wake-up'

In reply to Adrian Hunter

If the device is in a custom sleep state, then re-tuning will fail. Add calls to sdio_retune_hold_now() and sdio_retune_release() to prevent re-tuning before the wake-up command. In the case re-tuning was needed, the wake-up command might return an error, but the wake-up is expected still to have happened, and the error is anyway ignored.

---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +6 -0
index b892dac70f4b..a69abbb0923a 100644
@@ -684,11 +684,17 @@ static int w_sdreg32(struct brcmf_sdio *bus, u32 regval, u32 reg_offset)
 	brcmf_dbg(TRACE, "Enter: on=%d\n", on);
 
 	wr_val = (on << SBSDIO_FUNC1_SLEEPCSR_KSO_SHIFT);
+
+	/* Cannot re-tune if device is asleep */
+	if (on)
+		sdio_retune_hold_now(bus->sdiodev->func[1]);
+
 	/* 1st KSO write goes to AOS wake up core if device is asleep  */
 	brcmf_sdiod_regwb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR,
 			  wr_val, &err);
 
 	if (on) {
+		sdio_retune_release(bus->sdiodev->func[1]);
 		/* device WAKEUP through KSO:
 		 * write bit 0 & read back until
 		 * both bits 0 (kso bit) & 1 (dev on status) are set
Signature · 1 line
1.9.1