Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2926668lqo; Tue, 21 May 2024 01:07:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUNWHiGnkfVaLJ0XqJM5XUJZ3KxCwo3DugNOvdG4jRXS2XqYLaNTeU2g2EqT7adY4BFL8TQM4sth7gQ+EAIRRCTTNL9qepD8rYsiYc2Rw== X-Google-Smtp-Source: AGHT+IHf5ulF/EpMdGrPci7txwiarU5OO66u1vHUJa7Y2RXoYhpJBiXCgfBuY1Pt9zt7VegKUrTw X-Received: by 2002:a05:6870:f609:b0:23f:9ca6:a3b0 with SMTP id 586e51a60fabf-24172e26e5bmr35278074fac.40.1716278838793; Tue, 21 May 2024 01:07:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716278838; cv=pass; d=google.com; s=arc-20160816; b=1JLnq0aEbQy9/vVUjjNnWSRXPsVEkm17J6Sk9sJboKHAsfg4TKetEJ0m9cIYSpj39T brA8adxNa3chMir2+MWL2hesV5KUT1Dv47kAZ1HFdeN0BiDqiTUJxYETULRPplUvogpM +5DsDhPlsr6cNeW/Da3Ibjxw7nhi2/SVORkTy4swXLk6IfhrDaGdS2KblVYUkBE+s4gZ hE8G1taFbCsYI77HxGSIlOnvqJnPkQ2IXU0mZOOhaZbs1gs73kXR/CaUlxFITsIh3bsn vKlehYLtQ+dK8ptAXAmFwjP6eU5P2LQerBbprqRxZtcwgT2mWK29XJb03ySJpdOZh0Kp wUdg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:message-id:user-agent:cc:to:references:in-reply-to:from :subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=ntGqwjlw/VpUBdoIKGESwsg/nQn6FWvV2bdS6BwnAMs=; fh=q0pWxAdL0cyDcfHi0eFkTCBsBNeBmItsjEnoI8WnNeM=; b=jbfnu0JzgE4LfCqeMJv9b5G+bd3cldzVoBQ50ohCPe5rvwc4FDc9gMNsuWDENXj4pr 7LvW9Ey47oKTXtJlIu5Unj1n8L6F89i0EFzbbHxTe4FzwhkkkzOPYcqOuxnmtmfMgWIi mLnfdxYYKL8IUnISN0FdnLNoQ0cbIuw4KKly3uBTxcmbxPCkqQkJSuMUpGb9nF4QARCH yTn/OGamFHvEkEJS3Zif9kAXSVr0UuMHoRrsCAJ8pdMkjVDkBsK3BJtHA10mwN76B8PU u2o117OHE/eA21rNgYoeDZCGL7wJx7b8bgEeEh865VDUNWCTY5p82s/3YJfSYBC62NKB f8kA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GjxIbjOh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-7877-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7877-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6680c3ed95asi4194817a12.169.2024.05.21.01.07.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 01:07:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-7877-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GjxIbjOh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-7877-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7877-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id CF2D0B22717 for ; Tue, 21 May 2024 08:06:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 540E6548EC; Tue, 21 May 2024 08:05:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GjxIbjOh" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F51D54777 for ; Tue, 21 May 2024 08:05:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716278749; cv=none; b=GW/tYoFa3rxKrSoBV1ZgcrP3sqVRJ+Sm1xoyUbw2EZL7S+UNr9S2a+VXxLwjaXw88645O67U5oAS1lmoDUTRwhKGzdrbpl9ZyE/Tys1Q3Hk8+bL9ai94Ng/JGoC7L9k5nDdoRjHRCtmXvcF2yFuxIy+Rz2kjiig3FmYu7hSaKmk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716278749; c=relaxed/simple; bh=R5x1eX0Ez4WjR44vMnMHTWgfZRTKYLOH3IUFemOI+PE=; h=Content-Type:MIME-Version:Subject:From:In-Reply-To:References:To: Cc:Message-ID:Date; b=jyEFB3laG/fJfbPQo7VYJQ3DgLb+90Z6bj6YFQDcxYVsEP0bBUn3fgoMHHqYvTsIJ74B+vpnnaF/gzFlNekkhu/ubaTa/Gmy4socuc9aT+EJt/s746pRD8Kk+LuiGdBwXUuSfntyDY5Cpsqvu+fJXS3kgWs8Xuh8bhzm/eMwOAo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GjxIbjOh; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6BAAC2BD11; Tue, 21 May 2024 08:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716278748; bh=R5x1eX0Ez4WjR44vMnMHTWgfZRTKYLOH3IUFemOI+PE=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=GjxIbjOhQcI0p6Sr5nzrlHc6uBEsuTnfkeMOfrqrWi31r2I7AfvCEiJcrf1ilAlwE P+ziaQS6BdbiHrDD/mw9aeELEX6zIL3pEvawhiND+sZno6ZXqyBTzqrK+SW3tj5nET s7YOcJT5QiBdLLnxvTK/FV6hVej/WFZQT5qANb/LNhP+1wyFAybH8lNCmSvNe3/368 wbxUTxt4HhggwTx6OOKCbbY14c8YGU7i+JJ76+jsu0BC09Sko1SU564EHjzYp7Xm+c oupLhrb11ALmWgK302+T0iUp05U+3giblhtj0ZoxHRnkR10huNCXES131dwAX2/Wjt rMZAadGRk4CEA== Content-Type: text/plain; charset="utf-8" Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PATCH] wifi: ath12k: fix Smatch warnings on ath12k_core_suspend() From: Kalle Valo In-Reply-To: <20240511095045.9623-1-quic_bqiang@quicinc.com> References: <20240511095045.9623-1-quic_bqiang@quicinc.com> To: Baochen Qiang Cc: , , User-Agent: pwcli/0.1.1-git (https://github.com/kvalo/pwcli/) Python/3.11.2 Message-ID: <171627874515.3970531.14849401766701912789.kvalo@kernel.org> Date: Tue, 21 May 2024 08:05:46 +0000 (UTC) Baochen Qiang wrote: > Smatch is throwing below warning: > > Commit 692921ead832 ("wifi: ath12k: flush all packets before > suspend") leads to the following Smatch static checker warning: > > drivers/net/wireless/ath/ath12k/core.c:58 ath12k_core_suspend() > warn: sleeping in atomic context > > and also gives the reason: > > drivers/net/wireless/ath/ath12k/core.c > 48 int ret, i; > 49 > 50 if (!ab->hw_params->supports_suspend) > 51 return -EOPNOTSUPP; > 52 > 53 rcu_read_lock(); > ^^^^^^^^^^^^^^^ > Disables preemption. > > 54 for (i = 0; i < ab->num_radios; i++) { > 55 ar = ath12k_mac_get_ar_by_pdev_id(ab, i); > 56 if (!ar) > 57 continue; > --> 58 ret = ath12k_mac_wait_tx_complete(ar); > ^^^^^^^ > Sleeping in atomic context. > > 59 if (ret) { > 60 ath12k_warn(ab, "failed to wait tx complete: %d\n", ret); > 61 rcu_read_unlock(); > 62 return ret; > 63 } > 64 } > 65 rcu_read_unlock(); > > But it is weird that no warning on this in run time even with > CONFIG_DEBUG_ATOMIC_SLEEP=y. With some debug it is found that this is > because: when system goes to suspend, ath12k_mac_op_stop() gets called > where then in ath12k_mac_stop() ab->pdevs_active[ar->pdev_idx] is cleared. > This results in ath12k_mac_get_ar_by_pdev_id() always returning a NULL ar, > and thereby ath12k_mac_wait_tx_complete() never gets a chance to run. > > Fix it by retrieving ar directly from ab->pdevs[].ar instead of using > ath12k_mac_get_ar_by_pdev_id(). Since ab->pdevs[].ar is set at boot time > and won't get cleared when suspend, ath12k_mac_wait_tx_complete() won't > be skipped. In addition, with ath12k_mac_get_ar_by_pdev_id() removed, > rcu_read_lock()/unlock() are not needed any more, so remove them. This > also fixes the warning above. > > Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4 > > Fixes: 692921ead832 ("wifi: ath12k: flush all packets before suspend") > Reported-by: Dan Carpenter > Closes: https://lore.kernel.org/ath12k/7a96ca11-80b5-4751-8cfc-fa637f3aa63a@moroto.mountain/ > Signed-off-by: Baochen Qiang > Acked-by: Jeff Johnson > Signed-off-by: Kalle Valo Patch applied to ath-next branch of ath.git, thanks. 33370412eced wifi: ath12k: fix Smatch warnings on ath12k_core_suspend() -- https://patchwork.kernel.org/project/linux-wireless/patch/20240511095045.9623-1-quic_bqiang@quicinc.com/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches