All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath9k: fix sleeping in atomic context
@ 2021-08-09  4:05 Miaoqing Pan
  2021-08-29  7:12 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Miaoqing Pan @ 2021-08-09  4:05 UTC (permalink / raw)
  To: linux-wireless
  Cc: ath9k-devel, kvalo, dan.carpenter, linux-gpio, Miaoqing Pan

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>
---
 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 2ca3b86..172081f 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1621,7 +1621,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);
 	}
 }
 
@@ -2728,14 +2727,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.7.4


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

* Re: [PATCH] ath9k: fix sleeping in atomic context
  2021-08-09  4:05 [PATCH] ath9k: fix sleeping in atomic context Miaoqing Pan
@ 2021-08-29  7:12 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2021-08-29  7:12 UTC (permalink / raw)
  To: Miaoqing Pan
  Cc: linux-wireless, ath9k-devel, dan.carpenter, linux-gpio, Miaoqing Pan

Miaoqing Pan <miaoqing@codeaurora.org> wrote:

> 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>

Patch applied to ath-next branch of ath.git, thanks.

7c48662b9d56 ath9k: fix sleeping in atomic context

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/1628481916-15030-1-git-send-email-miaoqing@codeaurora.org/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2021-08-29  7:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09  4:05 [PATCH] ath9k: fix sleeping in atomic context Miaoqing Pan
2021-08-29  7:12 ` Kalle Valo

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.