Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3081939rwb; Mon, 15 Aug 2022 17:40:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VoQyTHSA8uWJF27sPKCnarn1mv4O3KI49RSM9VDZb8G+yx93zXeZVsH+B4VmuWiRNkdp0 X-Received: by 2002:a17:906:c10:b0:6f4:6c70:b00f with SMTP id s16-20020a1709060c1000b006f46c70b00fmr12188326ejf.660.1660610456358; Mon, 15 Aug 2022 17:40:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610456; cv=none; d=google.com; s=arc-20160816; b=UXJTkrruiy+3/yhksirjatsCGuIci8CuwSCX+JVdn+LmTqEKa4nza1rwLITr+fRoiB b++4baUAnOBdChVjpwwZZmg9Y511it5gWBqdDqlWc/pNtrcoS3y6mzezMUTJCQGYo4my Q1P+kCZdoITCV7qVh1pGAieDmyp/tQ9pJ41d7MbJe95QTLQhF2G1LDu+v/JCWm2K/hQQ c0YTTUAeCtzEzV6isT2nxkr4C1QiV4aPsRFAcK5VRpwqPFucqQBdmjiGStdstdzLU58V 6zIidpVTjFYjKes1wguCWlkgWrraPInORBX6RHHrvaz74sw2ZhIip3ba09uKubSMiY9i Jt4g== 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=KTOkYOniIS3xJLDxgPAfwWkXp2uNtM4l09kdIpvMGiQ=; b=SWcb7P23tm8mBceHCHLgHNgSS2FfLjC/sMDhNkcpnnaSHagmUamHLKP1VVhllNsWRR MhsQQj37WYr0NK1nkr/1Bxkjp+DlhUgq6pLzgX5DzVewjxNd4mvLUt/UzLMD1udbK6eh cPImtkdk8AWq1nnkwtalmS/9N0b54PRy5Dr2VhwIS6RxbE3n+/vn/1nXuuL7wf4OtbXo bdaAMZQHm8tCaEA3OfGzH8Z7/sP9U+LALDZxlb9B0Lmh258hIA8gVAlzHB3XVC/c/Qok jLl32mkl8lNNqfnAljfjpgFa67XRprmwYkLh+/xfUpeFH86kbxgjaRgvOtZoN4LiWauV Z/uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="uEGr/MwH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q28-20020a50c35c000000b0043cd18d34e1si7706056edb.177.2022.08.15.17.40.31; Mon, 15 Aug 2022 17:40:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="uEGr/MwH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1353824AbiHOXid (ORCPT + 99 others); Mon, 15 Aug 2022 19:38:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233088AbiHOXeC (ORCPT ); Mon, 15 Aug 2022 19:34:02 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 550F4642CF; Mon, 15 Aug 2022 13:09:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 7CA07CE12EB; Mon, 15 Aug 2022 20:08:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 620D9C433C1; Mon, 15 Aug 2022 20:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594136; bh=onNzqU9gBi851rma8Gsvyi5mkNCQG3TIVFTGJst1Yew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uEGr/MwHsm82jGO9kDetYu+6tk0DtQqd4lfRF8WYeO9mP4+UsXvPJuSrxDe/fEezq 6aa1oqAbqSxYga/l5pFzPOkhdjHIHCgquyMZou8eeTsW7Eq1mnbZT7ZfjeEbWIrZ6L NQOaD+Fj+DLpKq9FtGu7MoEqK/1eYA6BlFUqX19Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ping-Ke Shih , Kalle Valo , Sasha Levin Subject: [PATCH 5.19 0384/1157] wifi: rtw89: 8852a: rfk: fix div 0 exception Date: Mon, 15 Aug 2022 19:55:40 +0200 Message-Id: <20220815180455.079403632@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ping-Ke Shih [ Upstream commit 683a4647a7a3044868cfdc14c117525091b9fa0c ] The DPK is a kind of RF calibration whose algorithm is to fine tune parameters and calibrate, and check the result. If the result isn't good enough, it could adjust parameters and try again. This issue is to read and show the result, but it could be a negative calibration result that causes divisor 0 and core dump. So, fix it by phy_div() that does division only if divisor isn't zero; otherwise, zero is adopted. divide error: 0000 [#1] PREEMPT SMP NOPTI CPU: 1 PID: 728 Comm: wpa_supplicant Not tainted 5.10.114-16019-g462a1661811a #1 RIP: 0010:rtw8852a_dpk+0x14ae/0x288f [rtw89_core] RSP: 0018:ffffa9bb412a7520 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 00000000000180fc RDI: ffffa141d01023c0 RBP: ffffa9bb412a76a0 R08: 0000000000001319 R09: 00000000ffffff92 R10: ffffffffc0292de3 R11: ffffffffc00d2f51 R12: 0000000000000000 R13: ffffa141d01023c0 R14: ffffffffc0290250 R15: ffffa141d0102638 FS: 00007fa99f5c2740(0000) GS:ffffa142e5e80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000013e8e010 CR3: 0000000110d2c000 CR4: 0000000000750ee0 PKRU: 55555554 Call Trace: rtw89_core_sta_add+0x95/0x9c [rtw89_core ] rtw89_ops_sta_state+0x5d/0x108 [rtw89_core ] drv_sta_state+0x115/0x66f [mac80211 ] sta_info_insert_rcu+0x45c/0x713 [mac80211 ] sta_info_insert+0xf/0x1b [mac80211 ] ieee80211_prep_connection+0x9d6/0xb0c [mac80211 ] ieee80211_mgd_auth+0x2aa/0x352 [mac80211 ] cfg80211_mlme_auth+0x160/0x1f6 [cfg80211 ] nl80211_authenticate+0x2e5/0x306 [cfg80211 ] genl_rcv_msg+0x371/0x3a1 ? nl80211_stop_sched_scan+0xe5/0xe5 [cfg80211 ] ? genl_rcv+0x36/0x36 netlink_rcv_skb+0x8a/0xf9 genl_rcv+0x28/0x36 netlink_unicast+0x27b/0x3a0 netlink_sendmsg+0x2aa/0x469 sock_sendmsg_nosec+0x49/0x4d ____sys_sendmsg+0xe5/0x213 __sys_sendmsg+0xec/0x157 ? syscall_enter_from_user_mode+0xd7/0x116 do_syscall_64+0x43/0x55 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fa99f6e689b Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver") Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220613065144.15647-1-pkshih@realtek.com Signed-off-by: Sasha Levin --- drivers/net/wireless/realtek/rtw89/rtw8852a_rfk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852a_rfk.c b/drivers/net/wireless/realtek/rtw89/rtw8852a_rfk.c index e3c2fce32651..3d60feb78312 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8852a_rfk.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8852a_rfk.c @@ -2330,8 +2330,8 @@ static u8 _dpk_pas_read(struct rtw89_dev *rtwdev, bool is_check) val2_q = abs(sign_extend32(val2_q, 11)); rtw89_debug(rtwdev, RTW89_DBG_RFK, "[DPK] PAS_delta = 0x%x\n", - (val1_i * val1_i + val1_q * val1_q) / - (val2_i * val2_i + val2_q * val2_q)); + phy_div(val1_i * val1_i + val1_q * val1_q, + val2_i * val2_i + val2_q * val2_q)); } else { for (i = 0; i < 32; i++) { -- 2.35.1