Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1733269pxb; Thu, 16 Sep 2021 14:16:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkzN0xbi1JZj7YDDkHqGcYDjz1aCWnF8I+Ro6atnM5SRSydgatZokdYRStqK4dqLD7GPYR X-Received: by 2002:a05:6602:340a:: with SMTP id n10mr5936256ioz.188.1631826993193; Thu, 16 Sep 2021 14:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631826993; cv=none; d=google.com; s=arc-20160816; b=wKofgFrqjgYQzY9NZ4vDqJ/n85gQKJHn+PL45zZ8GiHBJq1DK4XJG509j1/xiZ/5qP wFhX7Aov/OxQRiLksy16dZ7UETvokG7IQ/CcZHHrk6no6LrUQiBFpLJPLTTzBMHJs1xW jPw9fDuHGN1WxOfz5hYbqGYWEvNYoyFDU5vVNVWsqKAW284cVWlwxdEAl7j2GtIbwkD2 Xw5UF+TnM1FdnhBVLvMfQxYNN9I+tE0+BadzjsXSpj2mYHw/MvzT2sHmp6lh1v7RfOiE qzBzbVwgsDC2f3iXlJKMq+bOHG+CMOCkaate2jktzeyFQh15MM8D3/3gbWH05s5LpCiM 9Umg== 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=LxaQFTRkfDkYkI0140MsKEnnyyldMPLDcfM1GOnLCWA=; b=oMwX8ioUZ99Rvc/gJCbJ8XKrm0M9fUJ1Z+P1qdcl2z1N0Z6jQ5GQCNFnsVO8jus9lL DB4qYVxAcfjkb7BaAZI6ictg4f1r2nHHhHe2rXv8sagKIAY6Bdv2GQYJHbYDuGI7/tG/ /NOvJDz1e6IG6LvpfrGQypP9dxLvQkJ4smH1gbbso8iuepWF1MpoxL8yOsDfPexb3t13 EK/3v19IqiOldl+omPVFBuUUCqSw5rYjQpXFYl7w9WDBa6MvqjsE5wyt2od2HO58Egu/ CfxDX5PFhjTuGqG8bB8yJ/YZAaCupLyak1ooIkAs731mcf/aOReWbaaMvCH4BBo1qrCZ HjHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f7Hocbz3; 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 q11si3601222ilg.114.2021.09.16.14.16.21; Thu, 16 Sep 2021 14:16:33 -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=f7Hocbz3; 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 S242348AbhIPQ2N (ORCPT + 99 others); Thu, 16 Sep 2021 12:28:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:58822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241632AbhIPQTz (ORCPT ); Thu, 16 Sep 2021 12:19:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A8C2613A0; Thu, 16 Sep 2021 16:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808828; bh=S0XaWsB7k/mB7Pcpqzo+AJANBh9RP8g0gr0MnXtt/zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f7Hocbz3hlNTmG1SdemF9/Rwtexc3s0V2AOQHJA4n3Dlpt44Z3UcfEsVxAzDA5zpL tkpY7pMj59CTcK+2KAgQpWZaLVQ3jmUyRN91STD6uIh476ZmKj/hxqmRampE6S/7ZE VQiA6kJSnRPhX8EqSxGSxTefgCDSTjz7nBBw1l9Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chin-Yen Lee , Ping-Ke Shih , Kalle Valo , Sasha Levin Subject: [PATCH 5.10 237/306] rtw88: use read_poll_timeout instead of fixed sleep Date: Thu, 16 Sep 2021 17:59:42 +0200 Message-Id: <20210916155802.138780350@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: Chin-Yen Lee [ Upstream commit 02a55c0009a55b204e1e5c17295431f0a9e7d3b6 ] In current wow flow, driver calls rtw_wow_fw_start and sleep for 100ms, to wait firmware finish preliminary work and then update the value of WOWLAN_WAKE_REASON register to zero. But later firmware will start wow function with power-saving mode, in which mode the value of WOWLAN_WAKE_REASON register is 0xea. So driver may get 0xea value and return fail. We use read_poll_timeout instead to check the value to avoid this issue. Signed-off-by: Chin-Yen Lee Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20210728014335.8785-2-pkshih@realtek.com Signed-off-by: Sasha Levin --- drivers/net/wireless/realtek/rtw88/wow.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/wow.c b/drivers/net/wireless/realtek/rtw88/wow.c index 2fcdf70a3a77..bb2fd4e544f0 100644 --- a/drivers/net/wireless/realtek/rtw88/wow.c +++ b/drivers/net/wireless/realtek/rtw88/wow.c @@ -283,15 +283,26 @@ static void rtw_wow_rx_dma_start(struct rtw_dev *rtwdev) static int rtw_wow_check_fw_status(struct rtw_dev *rtwdev, bool wow_enable) { - /* wait 100ms for wow firmware to finish work */ - msleep(100); + int ret; + u8 check; + u32 check_dis; if (wow_enable) { - if (rtw_read8(rtwdev, REG_WOWLAN_WAKE_REASON)) + ret = read_poll_timeout(rtw_read8, check, !check, 1000, + 100000, true, rtwdev, + REG_WOWLAN_WAKE_REASON); + if (ret) goto wow_fail; } else { - if (rtw_read32_mask(rtwdev, REG_FE1IMR, BIT_FS_RXDONE) || - rtw_read32_mask(rtwdev, REG_RXPKT_NUM, BIT_RW_RELEASE)) + ret = read_poll_timeout(rtw_read32_mask, check_dis, + !check_dis, 1000, 100000, true, rtwdev, + REG_FE1IMR, BIT_FS_RXDONE); + if (ret) + goto wow_fail; + ret = read_poll_timeout(rtw_read32_mask, check_dis, + !check_dis, 1000, 100000, false, rtwdev, + REG_RXPKT_NUM, BIT_RW_RELEASE); + if (ret) goto wow_fail; } -- 2.30.2