Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp407019ybn; Tue, 1 Oct 2019 23:31:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwulNFfcdHIYSrFLo3Tb/mAGrOhzPVY4B5S2VBobwgP4C8kKUP2MTNbENqOrC6U9Yvyuyiz X-Received: by 2002:a50:a8a2:: with SMTP id k31mr2022385edc.79.1569997905349; Tue, 01 Oct 2019 23:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569997905; cv=none; d=google.com; s=arc-20160816; b=HuPd2RAUiwzFWHiCXv1LkhIb/jhZc8/GgSpqdyRXFjuHQXJXl7OX/FwX7aEaCuWmTt hfyN862K00wkGj81WjTGw2ctxlfAup/1kJHpnXJc7uublCHwmctRPg0GrYqNjzc5s+k3 /mkfhiPMIVsH4QF7X2lxSSzNaAB8IpIOw6zA0WkyQU4UvBbc83D4peD3vLkXKLV5s9rD t15GmqbwggVGCA475OgUyb1W92DUip0JzEfugL6cguT2BphYRp4JBglV88n0wRuIBwfS ZQhXrY4yb7Zp3/OIaHeLgBjOA2Q2mGQxsQ9w59763CHqTlPZHENM0TguuMtnipBkyT09 Mw4A== 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=LXibkyLiSrq/nVd1/Q9bzZpHEV1r1ktp7vlEjJP/fdM=; b=e1cKl2ISkpWOLVRjr25OwRN4uvhkq4cSGIjcA+yJgeiegy57GaPBG0HAsciqQLj1k4 6TZmIHnrJUz5e4K6t8PVfixqlQIbDD91Px7ihEQanNwBgSXbUNHcOp8O/WB7IpHS9S0F 6GiaLrIKTUyxo8By4HQbfLVQeMp1c8/cHebKQ7hfMpWkcsooarC7MAshpSOq3kP26E2n Q15E9MTtCYZndeLkYDx6BcovcpVlAPmR9B/5D+o87FXd02g78kcHVChHIPFjaY/Mvv4R DvlChDfW/PWqiIzcJnff8WdMcp0zI9ev+VuKtYAgGgCvOEPGyvkUErM/YV8WOV4SgoOW 41mw== 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 j46si10715405eda.9.2019.10.01.23.31.20; Tue, 01 Oct 2019 23:31:45 -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 S1729759AbfJBCbj (ORCPT + 99 others); Tue, 1 Oct 2019 22:31:39 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:45998 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729190AbfJBCbj (ORCPT ); Tue, 1 Oct 2019 22:31:39 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x922VXGr031835, 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 x922VXGr031835 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 2 Oct 2019 10:31:33 +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:32 +0800 From: To: CC: , Subject: [PATCH v2 03/12] rtw88: not to enter or leave PS under IRQ Date: Wed, 2 Oct 2019 10:31:19 +0800 Message-ID: <20191002023128.12090-4-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 Remove PS related *_irqsafe functions to avoid entering/leaving PS under interrupt context. Instead, make PS decision in watch_dog. This could simplify the logic and make the code look clean. But it could have a little side-effect that if the driver is having heavy traffic before the every-2-second watch_dog detect the traffic and decide to leave PS, the thoughput will be lower. Once traffic is detected by watch_dog and left PS state, the throughput will resume to the peak the hardware ought to have again. Signed-off-by: Yan-Hsuan Chuang --- v1 -> v2 - rebase on top of wireless-drivers-next drivers/net/wireless/realtek/rtw88/main.c | 3 +- drivers/net/wireless/realtek/rtw88/main.h | 1 - drivers/net/wireless/realtek/rtw88/ps.c | 44 ----------------------- drivers/net/wireless/realtek/rtw88/ps.h | 3 -- drivers/net/wireless/realtek/rtw88/rx.c | 2 -- drivers/net/wireless/realtek/rtw88/tx.c | 2 -- 6 files changed, 2 insertions(+), 53 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 36ba2211faaf..22fc5d6f6b62 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -182,6 +182,8 @@ static void rtw_watch_dog_work(struct work_struct *work) if (rtw_fw_support_lps && data.rtwvif && !data.active && data.assoc_cnt == 1) rtw_enter_lps(rtwdev, data.rtwvif); + else + rtw_leave_lps(rtwdev, rtwdev->lps_conf.rtwvif); if (test_bit(RTW_FLAG_SCANNING, rtwdev->flags)) return; @@ -1152,7 +1154,6 @@ int rtw_core_init(struct rtw_dev *rtwdev) rtw_tx_report_purge_timer, 0); INIT_DELAYED_WORK(&rtwdev->watch_dog_work, rtw_watch_dog_work); - INIT_DELAYED_WORK(&rtwdev->lps_work, rtw_lps_work); INIT_DELAYED_WORK(&coex->bt_relink_work, rtw_coex_bt_relink_work); INIT_DELAYED_WORK(&coex->bt_reenable_work, rtw_coex_bt_reenable_work); INIT_DELAYED_WORK(&coex->defreeze_work, rtw_coex_defreeze_work); diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index 11ab9967617b..0955970d6f4d 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1361,7 +1361,6 @@ struct rtw_dev { /* lps power state & handler work */ struct rtw_lps_conf lps_conf; - struct delayed_work lps_work; struct dentry *debugfs; diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c index 4896953ec4b9..ffba3bd7bb31 100644 --- a/drivers/net/wireless/realtek/rtw88/ps.c +++ b/drivers/net/wireless/realtek/rtw88/ps.c @@ -91,50 +91,6 @@ static void rtw_enter_lps_core(struct rtw_dev *rtwdev) set_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags); } -void rtw_lps_work(struct work_struct *work) -{ - struct rtw_dev *rtwdev = container_of(work, struct rtw_dev, - lps_work.work); - struct rtw_lps_conf *conf = &rtwdev->lps_conf; - struct rtw_vif *rtwvif = conf->rtwvif; - - if (WARN_ON(!rtwvif)) - return; - - if (conf->mode == RTW_MODE_LPS) - rtw_enter_lps_core(rtwdev); - else - rtw_leave_lps_core(rtwdev); -} - -void rtw_enter_lps_irqsafe(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif) -{ - struct rtw_lps_conf *conf = &rtwdev->lps_conf; - - if (rtwvif->in_lps) - return; - - conf->mode = RTW_MODE_LPS; - conf->rtwvif = rtwvif; - rtwvif->in_lps = true; - - ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->lps_work, 0); -} - -void rtw_leave_lps_irqsafe(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif) -{ - struct rtw_lps_conf *conf = &rtwdev->lps_conf; - - if (!rtwvif->in_lps) - return; - - conf->mode = RTW_MODE_ACTIVE; - conf->rtwvif = rtwvif; - rtwvif->in_lps = false; - - ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->lps_work, 0); -} - bool rtw_in_lps(struct rtw_dev *rtwdev) { return test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags); diff --git a/drivers/net/wireless/realtek/rtw88/ps.h b/drivers/net/wireless/realtek/rtw88/ps.h index 09e57405dc1b..0ac6c2983a06 100644 --- a/drivers/net/wireless/realtek/rtw88/ps.h +++ b/drivers/net/wireless/realtek/rtw88/ps.h @@ -10,9 +10,6 @@ int rtw_enter_ips(struct rtw_dev *rtwdev); int rtw_leave_ips(struct rtw_dev *rtwdev); -void rtw_lps_work(struct work_struct *work); -void rtw_enter_lps_irqsafe(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif); -void rtw_leave_lps_irqsafe(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif); void rtw_enter_lps(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif); void rtw_leave_lps(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif); bool rtw_in_lps(struct rtw_dev *rtwdev); diff --git a/drivers/net/wireless/realtek/rtw88/rx.c b/drivers/net/wireless/realtek/rtw88/rx.c index 48b9ed49b79a..16b22eb57171 100644 --- a/drivers/net/wireless/realtek/rtw88/rx.c +++ b/drivers/net/wireless/realtek/rtw88/rx.c @@ -25,8 +25,6 @@ void rtw_rx_stats(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, rtwvif = (struct rtw_vif *)vif->drv_priv; rtwvif->stats.rx_unicast += skb->len; rtwvif->stats.rx_cnt++; - if (rtwvif->stats.rx_cnt > RTW_LPS_THRESHOLD) - rtw_leave_lps_irqsafe(rtwdev, rtwvif); } } } diff --git a/drivers/net/wireless/realtek/rtw88/tx.c b/drivers/net/wireless/realtek/rtw88/tx.c index 8eaa9809ca44..91bfd8c28ff7 100644 --- a/drivers/net/wireless/realtek/rtw88/tx.c +++ b/drivers/net/wireless/realtek/rtw88/tx.c @@ -27,8 +27,6 @@ void rtw_tx_stats(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, rtwvif = (struct rtw_vif *)vif->drv_priv; rtwvif->stats.tx_unicast += skb->len; rtwvif->stats.tx_cnt++; - if (rtwvif->stats.tx_cnt > RTW_LPS_THRESHOLD) - rtw_leave_lps_irqsafe(rtwdev, rtwvif); } } } -- 2.17.1