Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2566880lkm; Mon, 20 Sep 2021 18:54:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7yPVjFSG4u7axRrseF++/QQ6CcPTiJak422Prf9joxxrG2x/tn+qTl2zwoWW/3bK7u6RR X-Received: by 2002:a6b:7104:: with SMTP id q4mr12761477iog.29.1632189247508; Mon, 20 Sep 2021 18:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189247; cv=none; d=google.com; s=arc-20160816; b=iJ/Jt4+dh9Im6gM+EB+F3Hl5V55hiYRrpWnaWeSXXTOIu6Ryp1Xz70mgyjjVOA070U fuecEsAnn2+emLwZB4hDyhKoLx8Jy5MrEb7akLcu5N464t/N7INJU+OIJRj0ERz1cfMN GZuLIFrOAGIY7KUlNF8XCftsqB3/0GhKVDX5YSrD2w2eRWvzSELlE6eWp9F/sTOmZWtp FEpvjSChMjKZXKLO6W+1Jf8czt/SkonL4cwunpH2EJNeEx7zYgDna1Uwm2M/dfzpMsEg K1zN5asmGZeTJgbH0+TpcpSBw+dscqv/eJb8PfJ7EAwV7Tv0ECPHEAHf0Oh0wXMEeJ6b rJqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lZgrjn9F6X62lFmsGHQ5zHfjoeXz2B58EQSbIJGf4Js=; b=LsIqrB0eYZlRnYayctgzst4mybNJn4KPeHUHI4USDjvs2iAUEW/GbCC4yF2PimmMkC LGoCI5/NCjCKCkQEzCYgjmE2K61WaKlm7GQsEZ7NBkh/W0x1FNus9Y5aukawtYnXvfun m2dXMtqkudF4iQ6jFentwG42GPDUmuAUffoycy7FGYJ4betlsLlLx/Qhk+b+nNRjjCjY X84ECoiUKQmwHIk4KJxPGOQLMgQ26zfTFnky9HH3MLmaLxdPGr9QfDNncr/GjGi4FlEV WitCzHC4hnasK+/P/2u7v67YoYzKZ8YKTTRHvU9aQQulS5z223VLu7aoYkfgN3z96nPd LTXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hPi7sO8Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si3287953jac.12.2021.09.20.18.53.56; Mon, 20 Sep 2021 18:54:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hPi7sO8Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377495AbhITSTR (ORCPT + 99 others); Mon, 20 Sep 2021 14:19:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:35792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376598AbhITSNY (ORCPT ); Mon, 20 Sep 2021 14:13:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 747C263283; Mon, 20 Sep 2021 17:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158466; bh=wdwkhDQfnQvYJY1RBZzGawuoDVJPTFDTxaNVaUyKE4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hPi7sO8Qg0ZFQifyJVRj1OQ4kryqXaOEQRPfl1cCGR71MTozjEzzLkaRssRKvpuL5 SSktA+3DVWG6y1AuWMZ75KoNH8W2HNHYwVV1xZoBQSn4tAEKBcWt+xdpBUi9511ff0 Di4yWLQ5NnFyu+YMKtubd9u0KgEPzNPl43Ii4ZiY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqing Pan , Kalle Valo , Sasha Levin Subject: [PATCH 5.4 170/260] ath9k: fix sleeping in atomic context Date: Mon, 20 Sep 2021 18:43:08 +0200 Message-Id: <20210920163936.861056931@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaoqing Pan [ 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 Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1628481916-15030-1-git-send-email-miaoqing@codeaurora.org Signed-off-by: Sasha Levin --- 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 9fd8e64288ff..7e2e22b6bbbc 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); } } @@ -2730,14 +2729,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