Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp406558ybn; Tue, 1 Oct 2019 23:31:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaCjvBu3lw0Kc6fkya89JbI0k64LsGyWjuzZ1Qsf86rvSPUHN62Lwidia/ZP2R1jDS3kTd X-Received: by 2002:a50:a8c5:: with SMTP id k63mr2099155edc.122.1569997869226; Tue, 01 Oct 2019 23:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569997869; cv=none; d=google.com; s=arc-20160816; b=KSKFC5PzIHT+LkWNNTFh4Tl/MCPWqd5tjl9/UeAG7JxBAz6DeN2EodTaHvllucDtGi ghDE3p8lBagBGkHJjsWx8/r8WRWm1gDw/cDsrAKvdy0cBpOKkTJL3fJtf1hnFrMvtOur wYwqRuRnsuPs8pgEUUG9IQaHHnAchT0kBc1igThfiLZEVtlXQzWHi0MF25M+a522WGXu Stq5H2LqKQavkzslyt8jZ69vPJFXxgpC4rLlWu9+hNyURpTjA9nuHfIlCC8CQ3ecjrYG Mj7EZUdYzPIwMheMFaFaj9OfUF/lvnqagIZUCkwYWvA/y+IEwc2FmKz/YqXbhqDOkCFt grxg== 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=Sc0QoB9ywgv6YqC+88LghLMcgK7AJaEY3VuJ0nEexmw=; b=T8ob8Qp8Mgl1ip9sPcDeNyqNUGRDlYDTDlhJwC7upRAmqX0QEYEm88RPp/LCosNkBP oNd/4ajF0hYzsU22UQG28yE4Yryr48h2ydmz/lEq9W2aau7rr6eEwZE1+yWzVGuJQ5Mh Ha5b5TKa+iYZsKXEEK5/+vwJyFqI6dG7GIR+db0ukITSE4NXRAa4M3O0y+DwUz+wR0nw 0M5dDVhyavb9tMmp39pdmTuHE5Zhc/gCnpEhCUjJ8mBOC4kmJEQL5vwkGhjkOTJViWQ8 4nYO8fc6RNccSuNfwaEbsVzF76JhcWCMqps44gtDEzvC4dlZZTHFFxj8O1E4rs0GZNHw kptA== 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 l12si12168851edk.444.2019.10.01.23.30.44; Tue, 01 Oct 2019 23:31:08 -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 S1729787AbfJBCbm (ORCPT + 99 others); Tue, 1 Oct 2019 22:31:42 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:46010 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729348AbfJBCbl (ORCPT ); Tue, 1 Oct 2019 22:31:41 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x922VZEM031848, 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 x922VZEM031848 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 2 Oct 2019 10:31:36 +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; Wed, 2 Oct 2019 10:31:35 +0800 From: To: CC: , Subject: [PATCH v2 06/12] rtw88: LPS enter/leave should be protected by lock Date: Wed, 2 Oct 2019 10:31:22 +0800 Message-ID: <20191002023128.12090-7-yhchuang@realtek.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191002023128.12090-1-yhchuang@realtek.com> References: <20191002023128.12090-1-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 --- v1 -> v2 - rebase on top of wireless-drivers-next 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 66c05c492587..984644f64610 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 85d83f154f71..f55eda9da827 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 d57996e446fb..af5c7be2ef0f 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.17.1