2012-06-11 12:38:20

by Rajkumar Manoharan

[permalink] [raw]
Subject: [PATCH 1/2] ath9k: defer btcoex scheme update

As btcoex scheme updation might sleep, remove the function call
from tasklet context and queue it up as a separate work.

Signed-off-by: Rajkumar Manoharan <[email protected]>
---
drivers/net/wireless/ath/ath9k/ath9k.h | 1 +
drivers/net/wireless/ath/ath9k/main.c | 3 +++
drivers/net/wireless/ath/ath9k/mci.c | 14 +++++++++++---
3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 02fc1c1..a8c0500 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -698,6 +698,7 @@ struct ath_softc {
#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
struct ath_btcoex btcoex;
struct ath_mci_coex mci_coex;
+ struct work_struct mci_work;
#endif

struct ath_descdma txsdma;
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index e655f2a..c618414 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -188,6 +188,9 @@ static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)

ath9k_debug_samp_bb_mac(sc);
ath9k_hw_disable_interrupts(ah);
+#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
+ cancel_work_sync(&sc->mci_work);
+#endif

if (!ath_stoprecv(sc))
ret = false;
diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c
index 92d61cc..e53df86 100644
--- a/drivers/net/wireless/ath/ath9k/mci.c
+++ b/drivers/net/wireless/ath/ath9k/mci.c
@@ -52,7 +52,7 @@ static bool ath_mci_add_profile(struct ath_common *common,
(info->type != MCI_GPM_COEX_PROFILE_VOICE))
return false;

- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry)
return false;

@@ -219,6 +219,13 @@ static void ath_mci_cal_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload)
}
}

+static void ath9k_mci_work(struct work_struct *work)
+{
+ struct ath_softc *sc = container_of(work, struct ath_softc, mci_work);
+
+ ath_mci_update_scheme(sc);
+}
+
static void ath_mci_process_profile(struct ath_softc *sc,
struct ath_mci_profile_info *info)
{
@@ -249,7 +256,7 @@ static void ath_mci_process_profile(struct ath_softc *sc,
btcoex->duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE;
}

- ath_mci_update_scheme(sc);
+ ieee80211_queue_work(sc->hw, &sc->mci_work);
}

static void ath_mci_process_status(struct ath_softc *sc,
@@ -283,7 +290,7 @@ static void ath_mci_process_status(struct ath_softc *sc,
} while (++i < ATH_MCI_MAX_PROFILE);

if (old_num_mgmt != mci->num_mgmt)
- ath_mci_update_scheme(sc);
+ ieee80211_queue_work(sc->hw, &sc->mci_work);
}

static void ath_mci_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload)
@@ -377,6 +384,7 @@ int ath_mci_setup(struct ath_softc *sc)
mci->gpm_buf.bf_addr, (mci->gpm_buf.bf_len >> 4),
mci->sched_buf.bf_paddr);

+ INIT_WORK(&sc->mci_work, ath9k_mci_work);
ath_dbg(common, MCI, "MCI Initialized\n");

return 0;
--
1.7.10.4



2012-06-11 17:39:05

by Rajkumar Manoharan

[permalink] [raw]
Subject: Re: [PATCH 1/2] ath9k: defer btcoex scheme update

On Mon, Jun 11, 2012 at 06:46:00PM +0530, Sujith Manoharan wrote:
> Rajkumar Manoharan wrote:
> > As btcoex scheme updation might sleep, remove the function call
> > from tasklet context and queue it up as a separate work.
> >
> > Signed-off-by: Rajkumar Manoharan <[email protected]>
> > ---
> > --- a/drivers/net/wireless/ath/ath9k/main.c
> > +++ b/drivers/net/wireless/ath/ath9k/main.c
> > @@ -188,6 +188,9 @@ static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
> >
> > ath9k_debug_samp_bb_mac(sc);
> > ath9k_hw_disable_interrupts(ah);
> > +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
> > + cancel_work_sync(&sc->mci_work);
> > +#endif
>
> I think this should go inside __ath_cancel_work(), otherwise there is a
> chance that this would not be cleaned up properly when stopping the
> interface or unloading the driver.
>
mci_work is queued up by the ath9k_tasklet that is triggered by interrupt
routine. So it is safer to cancel the mci_work after disabling interrupt.
Does it make sense?

--
Rajkumar

2012-06-11 13:17:08

by Sujith Manoharan

[permalink] [raw]
Subject: [PATCH 1/2] ath9k: defer btcoex scheme update

Rajkumar Manoharan wrote:
> As btcoex scheme updation might sleep, remove the function call
> from tasklet context and queue it up as a separate work.
>
> Signed-off-by: Rajkumar Manoharan <[email protected]>
> ---
> drivers/net/wireless/ath/ath9k/ath9k.h | 1 +
> drivers/net/wireless/ath/ath9k/main.c | 3 +++
> drivers/net/wireless/ath/ath9k/mci.c | 14 +++++++++++---
> 3 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
> index 02fc1c1..a8c0500 100644
> --- a/drivers/net/wireless/ath/ath9k/ath9k.h
> +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
> @@ -698,6 +698,7 @@ struct ath_softc {
> #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
> struct ath_btcoex btcoex;
> struct ath_mci_coex mci_coex;
> + struct work_struct mci_work;
> #endif
>
> struct ath_descdma txsdma;
> diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
> index e655f2a..c618414 100644
> --- a/drivers/net/wireless/ath/ath9k/main.c
> +++ b/drivers/net/wireless/ath/ath9k/main.c
> @@ -188,6 +188,9 @@ static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
>
> ath9k_debug_samp_bb_mac(sc);
> ath9k_hw_disable_interrupts(ah);
> +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
> + cancel_work_sync(&sc->mci_work);
> +#endif

I think this should go inside __ath_cancel_work(), otherwise there is a
chance that this would not be cleaned up properly when stopping the
interface or unloading the driver.

Sujith

2012-06-11 12:38:20

by Rajkumar Manoharan

[permalink] [raw]
Subject: [PATCH 2/2] ath9k: fix btcoex duty cycle

* Reset duty cycle before updating btcoex scheme. Otherwise duty cycle
reaches max limit and never be reduced again
* Adjust duty cycle with proper BDR profile value

Signed-off-by: Rajkumar Manoharan <[email protected]>
---
drivers/net/wireless/ath/ath9k/mci.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c
index e53df86..5246067 100644
--- a/drivers/net/wireless/ath/ath9k/mci.c
+++ b/drivers/net/wireless/ath/ath9k/mci.c
@@ -120,6 +120,9 @@ static void ath_mci_update_scheme(struct ath_softc *sc)
if (mci_hw->config & ATH_MCI_CONFIG_DISABLE_TUNING)
goto skip_tuning;

+ btcoex->duty_cycle = num_profile ? ath_mci_duty_cycle[num_profile] :
+ ATH_BTCOEX_DEF_DUTY_CYCLE;
+
if (num_profile == 1) {
info = list_first_entry(&mci->info,
struct ath_mci_profile_info,
@@ -178,7 +181,7 @@ skip_tuning:
if (IS_CHAN_5GHZ(sc->sc_ah->curchan))
return;

- btcoex->duty_cycle += (mci->num_bdr ? ATH_MCI_MAX_DUTY_CYCLE : 0);
+ btcoex->duty_cycle += (mci->num_bdr ? ATH_MCI_BDR_DUTY_CYCLE : 0);
if (btcoex->duty_cycle > ATH_MCI_MAX_DUTY_CYCLE)
btcoex->duty_cycle = ATH_MCI_MAX_DUTY_CYCLE;

--
1.7.10.4


2012-06-11 17:58:03

by Rajkumar Manoharan

[permalink] [raw]
Subject: Re: [PATCH 1/2] ath9k: defer btcoex scheme update

On Mon, Jun 11, 2012 at 11:10:20PM +0530, Rajkumar Manoharan wrote:
> On Mon, Jun 11, 2012 at 06:46:00PM +0530, Sujith Manoharan wrote:
> > Rajkumar Manoharan wrote:
> > > As btcoex scheme updation might sleep, remove the function call
> > > from tasklet context and queue it up as a separate work.
> > >
> > > Signed-off-by: Rajkumar Manoharan <[email protected]>
> > > ---
> > > --- a/drivers/net/wireless/ath/ath9k/main.c
> > > +++ b/drivers/net/wireless/ath/ath9k/main.c
> > > @@ -188,6 +188,9 @@ static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
> > >
> > > ath9k_debug_samp_bb_mac(sc);
> > > ath9k_hw_disable_interrupts(ah);
> > > +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
> > > + cancel_work_sync(&sc->mci_work);
> > > +#endif
> >
> > I think this should go inside __ath_cancel_work(), otherwise there is a
> > chance that this would not be cleaned up properly when stopping the
> > interface or unloading the driver.
> >
> mci_work is queued up by the ath9k_tasklet that is triggered by interrupt
> routine. So it is safer to cancel the mci_work after disabling interrupt.
> Does it make sense?
>
Sujith,

you are correct. I'll move it into ath_cancel_work.

Rajkumar