Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1719134pxb; Thu, 16 Sep 2021 13:54:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygUBWFjRjHa6XSF/KleRql/iROrunByYaR5iDV0eoAiJQL+JV0na15Zi96rOBLnoZbVzPZ X-Received: by 2002:aa7:db56:: with SMTP id n22mr8921836edt.148.1631825669891; Thu, 16 Sep 2021 13:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631825669; cv=none; d=google.com; s=arc-20160816; b=AMiu/C+0WvYy0gKB3CucW3EkIjYNBxrrkZRTpeJV0Bsl2Dw5BbiWkEGDpstnhu7Ggq ukIQp9EerF4GTcu47kfvZyOQXxqF6c0uubvnrid+Vzjg8sCGwX3qBDvMJqeBRP7LPndX jO5wnmFODrXKkt3yI4BvglOJdm3yiCRaNETOOiMEPo4fB9DR81U/SttHT5Yh0UspTSv3 UvLbZ37WBb3Zah+CAsE3+VWllC00mGfDHZY4H4lb9asAxQFTiP31+7exe46+YqxR5SG5 WIpCmj3/OVucKI6ZvpORcEtIR5DneJjfQ40xNjwXMS8sR7h/aJr31l9q/mEKXz5PCi/9 Wv0g== 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=GeVSRapxX9f7gY9apqYeyfSTclLhvW7Q/73FA5IPP3U=; b=MsgeHzQbxqp311xHfOPAbj43pg+lyVmdIbfYHeQu5hgB89VQHzZpSF+hn9a5kjP2qA Gq1L88OgBb2xvPCyrvX/TuVgoOkkxufiPxKhUbEax/2tJkiVYIfbNaB2e4jiHFoBlhhu G8jVSUA8p/Y9ro45zYUUubuqJjek2im+36PLovo+oyE1iujU9EFw90jBP7dq+nVwjK9b EHSVJPcdCV8C8dKYusf7yGftnrl6EWicu0Qzg0dzdDfETjmN9f1YMTJhy52Hykpc5OO0 ACL3i8LEwznATtW/wkH9g5Li1wWnhFv86Lade/8/bbOfuQ9t57qR/9Rq9nlGIYFwRrTG QyCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="UM/gHw8o"; 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 i13si4615397edq.512.2021.09.16.13.53.57; Thu, 16 Sep 2021 13:54:29 -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="UM/gHw8o"; 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 S235476AbhIPQcc (ORCPT + 99 others); Thu, 16 Sep 2021 12:32:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:60150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241320AbhIPQWi (ORCPT ); Thu, 16 Sep 2021 12:22:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3AED46141B; Thu, 16 Sep 2021 16:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808926; bh=b8uqT+IdXHTCWdfTeDRGw60YPedOurUWpACJtIdz0jA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UM/gHw8oMGRYsoMV/uCd/k56nwhTf8JonG2WeCqwTCVpmSMFKasP1hDw95RmJ4RTg IAlHtb1UXGfe36PJrYN7vBuchyHzYS9ueR1JHF7Nk4BkxBkihqNi78me9v/xNb/aEt GNjDwZXlafEo6ivH911OcGGnelNuNs+B+TOa1uBk= 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.10 273/306] ath9k: fix sleeping in atomic context Date: Thu, 16 Sep 2021 18:00:18 +0200 Message-Id: <20210916155803.380321435@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 c86faebbc459..6b2668f065d5 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