Skip to contentSkip to conversation

ath9k: make GPIO API to support both of WMAC and SOC

bug report Dan Carpenter 1 participant 1 message Aug 2, 2021 GPIO

lore
Share & tools
lore
#0 lore raw

Hello Miaoqing Pan,

The patch b2d70d4944c1: "ath9k: make GPIO API to support both of WMAC and SOC" from Mar 7, 2016, leads to the following static checker warning:

	drivers/gpio/gpiolib.c:1960 gpiod_free_commit()
	warn: sleeping in atomic context

drivers/net/wireless/ath/ath9k/hw.c
2728 static void ath9k_hw_gpio_cfg_soc(struct ath_hw *ah, u32 gpio, bool out,
2729 const char *label)
2730 {
2731 if (ah->caps.gpio_requested & BIT(gpio))
2732 return;
2733
2734 /* may be requested by BSP, free anyway */

  2735          gpio_free(gpio);
                ^^^^^^^^^^^^^^^^

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()
  2736  
  2737          if (gpio_request_one(gpio, out ? GPIOF_OUT_INIT_LOW : GPIOF_IN, label))
  2738                  return;
  2739  
  2740          ah->caps.gpio_requested |= BIT(gpio);
  2741  }

regards,
dan carpenter