lkml.org 
[lkml]   [2021]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 4.19 72/74] ath9k: fix sleeping in atomic context
    Date
    From: Miaoqing Pan <miaoqing@codeaurora.org>

    [ Upstream commit 7c48662b9d56666219f526a71ace8c15e6e12f1f ]

    The problem is that gpio_free() can sleep and the cfg_soc() can be
    called with spinlocks held. One problematic call tree is:

    --> ath_reset_internal() takes &sc->sc_pcu_lock spin lock
    --> ath9k_hw_reset()
    --> ath9k_hw_gpio_request_in()
    --> ath9k_hw_gpio_request()
    --> ath9k_hw_gpio_cfg_soc()

    Remove gpio_free(), use error message instead, so we should make sure
    there is no GPIO conflict.

    Also remove ath9k_hw_gpio_free() from ath9k_hw_apply_gpio_override(),
    as gpio_mask will never be set for SOC chips.

    Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/1628481916-15030-1-git-send-email-miaoqing@codeaurora.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/wireless/ath/ath9k/hw.c | 12 +++++++-----
    1 file changed, 7 insertions(+), 5 deletions(-)

    diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
    index 9f438d8e59f2..daad9e7b17cf 100644
    --- a/drivers/net/wireless/ath/ath9k/hw.c
    +++ b/drivers/net/wireless/ath/ath9k/hw.c
    @@ -1622,7 +1622,6 @@ static void ath9k_hw_apply_gpio_override(struct ath_hw *ah)
    ath9k_hw_gpio_request_out(ah, i, NULL,
    AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
    ath9k_hw_set_gpio(ah, i, !!(ah->gpio_val & BIT(i)));
    - ath9k_hw_gpio_free(ah, i);
    }
    }

    @@ -2729,14 +2728,17 @@ static void ath9k_hw_gpio_cfg_output_mux(struct ath_hw *ah, u32 gpio, u32 type)
    static void ath9k_hw_gpio_cfg_soc(struct ath_hw *ah, u32 gpio, bool out,
    const char *label)
    {
    + int err;
    +
    if (ah->caps.gpio_requested & BIT(gpio))
    return;

    - /* may be requested by BSP, free anyway */
    - gpio_free(gpio);
    -
    - if (gpio_request_one(gpio, out ? GPIOF_OUT_INIT_LOW : GPIOF_IN, label))
    + err = gpio_request_one(gpio, out ? GPIOF_OUT_INIT_LOW : GPIOF_IN, label);
    + if (err) {
    + ath_err(ath9k_hw_common(ah), "request GPIO%d failed:%d\n",
    + gpio, err);
    return;
    + }

    ah->caps.gpio_requested |= BIT(gpio);
    }
    --
    2.30.2
    \
     
     \ /
      Last update: 2021-09-09 15:37    [W:4.401 / U:1.120 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site