Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3781602ybe; Mon, 16 Sep 2019 00:47:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwU9H/biRuZ0abwU/9w57S5Boyrwruu4mu4sBKPFhZNYpCJ4Zm5fu2pKU9yis82xetOOVUa X-Received: by 2002:a05:6402:3ca:: with SMTP id t10mr60828061edw.271.1568620078260; Mon, 16 Sep 2019 00:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568620078; cv=none; d=google.com; s=arc-20160816; b=B4KKAP9lFF+b29YWax/vMXvMoaxu8q+y6sO+vpS4VW6qPTySoE6i2k5hoWYWppL0L5 9NroQVo6Chv7DeV2M24AS/x8qoHkPjha3IsoNxKMIHGh3BVAQYzWoy4kOE7PSpTKEvP5 rsJfiyeJBbB5J/fn39FX3AWTX66CIA7MAVygzUc3dU0dQqBDBVjpVFsontUA15dN4vHe s9XWg07u+kp8nOexojlPUr9AP8bjI7bj6qvDh7no13DxJj4XdoE9KyhTZ0vAvmXTpPOi hLMWyYEHanzxh91pIZHM0vSoBRiCLzmp5S/zJvMBRaeIZN7gPuN7fSdrzrjhAIY8fUP+ bXhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:authenticated-by; bh=1BaUQ4MJE0pzyB10aXgqzj+qe/VetSktpe4AXogyxbQ=; b=JKsElvD2Ftl3WFG57/q77cYXdSiadvx5M02Jfvu5/HuU5kEx3ydBGYUtQNnLlU/BZw Nsmp+9B4rAHZizA6BmSpxNOBr/8gsgWlgOsy3W3kNgZSeUYWCPpH+Ige41zGnyQMa2BU 7lPeqSPUtr2X2/4I6rQ879vSwugXzr+555fne3feHiK8sk5z6liFQHhF+B68vaLzEVMQ FlJ7d7xcvE9R5WHt9oF2zpVh1TtTVZR2Clk5RszmeG/6UksFOU+WZHkFZEa4hqSPp2b8 cu+H349JVqW0luOICblE83xdY8HMrcapTqbW3wUrtv6L92IbBKNBP3JkoOJNa6Nj1yXS 89Fg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m17si19715952ejn.237.2019.09.16.00.47.33; Mon, 16 Sep 2019 00:47:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730280AbfIPHED (ORCPT + 99 others); Mon, 16 Sep 2019 03:04:03 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:60350 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730250AbfIPHEC (ORCPT ); Mon, 16 Sep 2019 03:04:02 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x8G73uMs029998, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (RTITCASV01.realtek.com.tw[172.21.6.18]) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTPS id x8G73uMs029998 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 16 Sep 2019 15:03:56 +0800 Received: from localhost.localdomain (172.21.68.126) by RTITCASV01.realtek.com.tw (172.21.6.18) with Microsoft SMTP Server id 14.3.468.0; Mon, 16 Sep 2019 15:03:56 +0800 From: To: CC: , Subject: [PATCH 09/15] rtw88: LPS enter/leave should be protected by lock Date: Mon, 16 Sep 2019 15:03:39 +0800 Message-ID: <1568617425-28062-10-git-send-email-yhchuang@realtek.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1568617425-28062-1-git-send-email-yhchuang@realtek.com> References: <1568617425-28062-1-git-send-email-yhchuang@realtek.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.68.126] Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Yan-Hsuan Chuang Protect LPS enter/leave routine with rtwdev->mutex. This helps to synchronize with driver's states correctly. Signed-off-by: Yan-Hsuan Chuang --- drivers/net/wireless/realtek/rtw88/mac80211.c | 4 ++-- drivers/net/wireless/realtek/rtw88/main.c | 9 +++++++-- drivers/net/wireless/realtek/rtw88/ps.c | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c index 66c05c4..984644f 100644 --- a/drivers/net/wireless/realtek/rtw88/mac80211.c +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c @@ -464,10 +464,10 @@ static void rtw_ops_sw_scan_start(struct ieee80211_hw *hw, struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv; u32 config = 0; - rtw_leave_lps(rtwdev); - mutex_lock(&rtwdev->mutex); + rtw_leave_lps(rtwdev); + ether_addr_copy(rtwvif->mac_addr, mac_addr); config |= PORT_SET_MAC_ADDR; rtw_vif_port_config(rtwdev, rtwvif, config); diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 85d83f1..f55eda9 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -152,8 +152,10 @@ static void rtw_watch_dog_work(struct work_struct *work) struct rtw_watch_dog_iter_data data = {}; bool busy_traffic = test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); + mutex_lock(&rtwdev->mutex); + if (!test_bit(RTW_FLAG_RUNNING, rtwdev->flags)) - return; + goto unlock; ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->watch_dog_work, RTW_WATCH_DOG_DELAY_TIME); @@ -186,11 +188,14 @@ static void rtw_watch_dog_work(struct work_struct *work) rtw_leave_lps(rtwdev); if (test_bit(RTW_FLAG_SCANNING, rtwdev->flags)) - return; + goto unlock; rtw_phy_dynamic_mechanism(rtwdev); rtwdev->watch_dog_cnt++; + +unlock: + mutex_unlock(&rtwdev->mutex); } static void rtw_c2h_work(struct work_struct *work) diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c index d57996e..af5c7be 100644 --- a/drivers/net/wireless/realtek/rtw88/ps.c +++ b/drivers/net/wireless/realtek/rtw88/ps.c @@ -95,6 +95,8 @@ void rtw_enter_lps(struct rtw_dev *rtwdev, u8 port_id) { struct rtw_lps_conf *conf = &rtwdev->lps_conf; + lockdep_assert_held(&rtwdev->mutex); + if (test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags)) return; @@ -108,6 +110,8 @@ void rtw_leave_lps(struct rtw_dev *rtwdev) { struct rtw_lps_conf *conf = &rtwdev->lps_conf; + lockdep_assert_held(&rtwdev->mutex); + if (!test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags)) return; -- 2.7.4