Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1945749pxb; Thu, 16 Sep 2021 21:09:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9v3DxFdzfmeLZMQGLu0YQgDYB+qnB4Ztqn1tTW/+PP31SKtkojR9HrPsFCSglbIHN3PKc X-Received: by 2002:a05:6638:2183:: with SMTP id s3mr7163719jaj.11.1631851740082; Thu, 16 Sep 2021 21:09:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631851740; cv=none; d=google.com; s=arc-20160816; b=XfW9EAJeTm5PHp5r2Zz81r/3LA5+sC2ViFXVFdXHfDw9K4/+csZ3ESVlCppQtdeC25 yYoVKllA1xqaE79v01+Lm/Dcy74MgN2jpYksabCOwpy0hfNQNtPSWGE6ftu6ZC+XLsBO mSD/r8YpeMJ/BsFdZ+SBoWiCxXhq5aE5B05LOBkBI4Ll5+I/JOe+EEWrYYKcDpnsh/hZ 11dUYFbjcbcSi/RIq/NH1N4ZoGsQ5hPU5UdJKT/69F/eljrpz20aenDX0p/KhtyUshsj 211/VH8GQ4VdhEb/kVDhTnPjjxpsrRvdlTONn0CTOHfjc0FKdzlwYBniKDvuiQuOxm7W af8g== 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=xjIGR/EVrnzJqxB8wsxkDUg+//1px0lOBBtMXepIkj8=; b=Cj62xxbJ6Hrucvbtknwtq8RgFvbLToFKCL5W+n+IBF2BUH627CNzbtWV4/rYbbl0nj TqWzonoG4P/kHqUsWFCJO2KGWBzWVmdF0AbQfOcpru0BhuTcy4cCmADzGE/anmjWTOn/ KwDmmv83vep+5J3kmJx3mjKNb5FND7wEFA7frBEl1pJlzhKeWb7Ut21hqQpJPWfYMDRw 9iiQOBH9yPpMGu1TVdPY4wWG7jsiui1ro76ce2h7RPyMnLHWz/EyUntSb4wNDAFN7UJU 5kvwEsI6pNlH7GYAzww87codLXlmC/jUuI44xVAr4bin2kDFNRiUwdz/d/lmocJjr6Pa hb2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nEltelqw; 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 y7si4279364ilb.100.2021.09.16.21.08.43; Thu, 16 Sep 2021 21:09:00 -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=nEltelqw; 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 S1344772AbhIPRmq (ORCPT + 99 others); Thu, 16 Sep 2021 13:42:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:53764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344613AbhIPRf5 (ORCPT ); Thu, 16 Sep 2021 13:35:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8820061506; Thu, 16 Sep 2021 16:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810962; bh=PkHgKvoyfPY4SUoPcVWWAVmKs/676bv9UplHgoqlefg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nEltelqwdRSIL7da6AzwIkzA0PUNX+NSNO7F535jJJPBIqE3m86ibAK/qF7jXiqFp UUbY0bwDRdcOc7aWQTVJSz17hPc9fq4m60zlyNUHJIYeW01zRYPopd9LLdXgE+p0bS ca2ucz8j5DlgSm8NQaT+wTnhkx2HLZGo7wyqH8hk= 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.14 331/432] rtw88: use read_poll_timeout instead of fixed sleep Date: Thu, 16 Sep 2021 18:01:20 +0200 Message-Id: <20210916155822.065438102@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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 fc9544f4e5e4..bdccfa70dddc 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