From patchwork Mon Dec 10 21:40:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153366 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4044987ljp; Mon, 10 Dec 2018 13:42:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/XVc1/RANgc85GIA1VYCCx/HwtjdGgMRchI4ehQ6GBhVykEeS8gMAZTTsszWPaj7LANoivG X-Received: by 2002:a62:65c5:: with SMTP id z188mr14380541pfb.64.1544478138257; Mon, 10 Dec 2018 13:42:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544478138; cv=none; d=google.com; s=arc-20160816; b=FWRxQyvz+ofJRsxEtBR24LXHcZ2OVuEgYv/0fOteDGKWEmTVnCpcVyucCCVhRUjxzk 0gCY04sazmAufYYm5kzBRrDl373+zY53Ykfn1KX9KC/cpSpSZmPZIOLS7miojZ3rd2m6 RyBi+X9z9AxFBXrPONjw3DnqspNCiSijGWJD5McOC2QgPHbkW9wer97LJtXrIwJ1iyWx 17EPzGwAQAyv+P3AueaZruKtwE+K5vEvRdDXr0+8ZX4S641ClhLcs1Xjq24AoZqe0RIR UFPM6D5V/iahshinu8DwlcjyASYcGZZIB2sgwT9Fy9TB3NRnUrNcdWfAbN5wbQ3Ct2fI coAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ZpOhfRIBXkneCpQmlghdbsU21mi0kl4BnGqMVrXngjc=; b=lxSm6HACYrUCfh4cXnZDrDf93Sz3lB0k0+g+d+CWVlT1qN3HMi2kCrKvJ4AQVfnDY9 esLwYkoW2h4xeP4z1RMMtskUSSmTn46spOxO5dMeU4F4RhxSRQW7KIz2wAEOfthkInPr bWpyByo5rbgsovxOLBD7e8vIG2seWbNf1NEU/e0fJHNFov5Qd0/g65kfkTxBbHRNocQC fKif0ffRMnzHmT4GUu6Kp9X4AzMQmIpbAXKfipZF8hH1wnC9DvU/G0weVxUdYStYIcpq s1kIWGEp5zodDJOR9N8/r+r06icsYdtwknSlCQO+5WJQvviLr5R3Pqbm5MO4M3LTVm45 mzig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 h5si10145681pgc.237.2018.12.10.13.42.17; Mon, 10 Dec 2018 13:42:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730173AbeLJVmP (ORCPT + 31 others); Mon, 10 Dec 2018 16:42:15 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:45159 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726562AbeLJVmM (ORCPT ); Mon, 10 Dec 2018 16:42:12 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.145]) with ESMTPA (Nemesis) id 1MnqbU-1hFzaf1XY2-00pPgx; Mon, 10 Dec 2018 22:40:39 +0100 From: Arnd Bergmann To: Greg Kroah-Hartman Cc: Bastien Nocera , Hans de Goede , Larry Finger , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, Arnd Bergmann Subject: [PATCH 2/3] staging: rtl8723bs: change pwrctrl lock to a mutex Date: Mon, 10 Dec 2018 22:40:31 +0100 Message-Id: <20181210214032.1441224-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181210214032.1441224-1-arnd@arndb.de> References: <20181210214032.1441224-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:kU1YSpPI7NDX/q8rJpemaYBk8HvXSD+Yp4i/IoNfBKOnI/YSig0 sX87HBIXAZ6sUVuoUpdNWswnQRxfouD8R/rR+vebZso1GB6Vngzi1qTw8D05IYhqzMCKEXj hoQ8d9vxGRt35fL1nZW4/dZdGS5MxiNcQ1SE3lQVjCGMTPNHeV2OLXK1nE/iegXTKH0Vp/h TcjYFiskyawWAuKryVRsw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:pIjIbR75Yyg=:0csEZgsHJx2zbI9ivV4MxV qjKn6rxG2i8nz+NvtHQg2+4M46HAM5RsA57hMosk5Qv17qFsgD4qI5my/yDlmQy+Ooj31F8bs 48R6olKfZ28JFivsXJjFL+cGuKdkTc8RvbiBNbcTV1QBTMQPLemtjepOUZHh/EjOCB60rZLuL YKn5oA6MJ7ThEVFrANiktXQj8XpK73JEqhVNLA4lZfJ0Kw3O/Efxn5bFzankJfXiHR8ErZSzo bsdhwT346Q10pShIV1fu5qWNFvSzVgtVdcRCXBtyzVgoDBMlHzZNGvmTBME9h5+cYBuv4FS8x Yov6/ZF2ExUphvcrPWXwQkiNhK0Dh3xqbzRzURUU4218wbbQXczMlAbR2LnyStr5+umnYoYcD n3kleGpdYiFgdxym8o5F3TSXeMK5002vZF9Q2/878DeUqzaffMOt+eO+ZsLYdZ+/ieo1Z8xYW YXGXm9OjbvEsDCBUpxB8c8uVMZjAtShyaKxSaqdEKvovb6dU5F844lM02q2+D3CbLiDbwHsnm kRIqThOEEjLdgxU/EKWQsqSKsGJX8bwKj1UbwhfG/2aOVdI75SyVGOjsrBQ5QStJkb7REQXtW Pk/62YTFjEO3Hp4wsp2iJpa37nVyzZ5JsWdUWaYcNrAgASP9Z/zZnfZH/VJW84Mh8k+P5utWb fP1yWjGfG+2ic0aeXL5y5cJSePV9dYAQlNK0XOORnrDOlxatPnPkIQg5SBI6XFxWC04ga1htx 0sJuoHRnPLcOKyOE3SFS6c2TTIdDjx1GmbgOWg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This semaphore is used like a mutex, so it should use the regular mutex API, as we do in the other copies of this driver. Signed-off-by: Arnd Bergmann --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 4 +- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 73 +++++++++---------- .../staging/rtl8723bs/include/rtw_pwrctrl.h | 3 +- 3 files changed, 40 insertions(+), 40 deletions(-) -- 2.20.0 diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 3d206c33eafa..984db6f2217c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1621,7 +1621,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim) if (rtw_btcoex_IsBtControlLps(padapter) == true) return; - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if (pwrpriv->dtim != dtim) { DBG_871X("change DTIM from %d to %d, bFwCurrentInPSMode =%d, ps_mode =%d\n", pwrpriv->dtim, dtim, @@ -1638,7 +1638,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim) rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); } - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); } static void rtw_dm_ra_mask_hdl(struct adapter *padapter, struct sta_info *psta) diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index a0d8fbeecf9b..b7dd5fec9b31 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -45,9 +45,9 @@ void ips_enter(struct adapter *padapter) rtw_btcoex_IpsNotify(padapter, pwrpriv->ips_mode_req); - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); _ips_enter(padapter); - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); } int _ips_leave(struct adapter *padapter) @@ -85,9 +85,9 @@ int ips_leave(struct adapter *padapter) if (!is_primary_adapter(padapter)) return _SUCCESS; - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); ret = _ips_leave(padapter); - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); if (_SUCCESS == ret) rtw_btcoex_IpsNotify(padapter, IPS_NONE); @@ -158,9 +158,9 @@ void rtw_ps_processor(struct adapter *padapter) struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; u32 ps_deny = 0; - down(&adapter_to_pwrctl(padapter)->lock); + mutex_lock(&adapter_to_pwrctl(padapter)->lock); ps_deny = rtw_ps_deny_get(padapter); - up(&adapter_to_pwrctl(padapter)->lock); + mutex_unlock(&adapter_to_pwrctl(padapter)->lock); if (ps_deny != 0) { DBG_871X(FUNC_ADPT_FMT ": ps_deny = 0x%08X, skip power save!\n", FUNC_ADPT_ARG(padapter), ps_deny); @@ -413,7 +413,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a return; - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); /* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */ if (ps_mode == PS_MODE_ACTIVE) { @@ -494,7 +494,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a } } - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); } /* @@ -628,11 +628,11 @@ void LeaveAllPowerSaveModeDirect(struct adapter *Adapter) return; } - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); rtw_set_rpwm(Adapter, PS_STATE_S4); - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); rtw_lps_ctrl_wk_cmd(pri_padapter, LPS_CTRL_LEAVE, 0); } else{ @@ -696,7 +696,7 @@ void LPS_Leave_check( cond_resched(); while (1) { - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if ((padapter->bSurpriseRemoved == true) || (padapter->hw_init_completed == false) @@ -704,7 +704,7 @@ void LPS_Leave_check( ) bReady = true; - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); if (true == bReady) break; @@ -732,11 +732,10 @@ void cpwm_int_hdl( pwrpriv = adapter_to_pwrctl(padapter); - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if (pwrpriv->rpwm < PS_STATE_S2) { DBG_871X("%s: Redundant CPWM Int. RPWM = 0x%02X CPWM = 0x%02x\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); - up(&pwrpriv->lock); goto exit; } @@ -751,9 +750,9 @@ void cpwm_int_hdl( complete(&padapter->xmitpriv.xmit_comp); } - up(&pwrpriv->lock); - exit: + mutex_unlock(&pwrpriv->lock); + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("cpwm_int_hdl: cpwm = 0x%02x\n", pwrpriv->cpwm)); } @@ -783,12 +782,12 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work) padapter = dvobj->if1; /* DBG_871X("+%s: rpwm = 0x%02X cpwm = 0x%02X\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); */ - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) { DBG_871X("%s: rpwm = 0x%02X cpwm = 0x%02X CPWM done!\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); goto exit; } - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); if (rtw_read8(padapter, 0x100) != 0xEA) { struct reportpwrstate_parm report; @@ -800,7 +799,7 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work) return; } - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) { DBG_871X("%s: cpwm =%d, nothing to do!\n", __func__, pwrpriv->cpwm); @@ -811,7 +810,7 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work) pwrpriv->brpwmtimeout = false; exit: - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); } /* @@ -867,7 +866,7 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 task) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S2; - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); register_task_alive(pwrctrl, task); @@ -884,7 +883,7 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 task) } } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); if (_FAIL == res) if (pwrctrl->cpwm >= PS_STATE_S2) @@ -920,7 +919,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) pslv = PS_STATE_S2; } - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); unregister_task_alive(pwrctrl, task); @@ -936,7 +935,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); } /* @@ -962,7 +961,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S2; - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); register_task_alive(pwrctrl, XMIT_ALIVE); @@ -979,7 +978,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter) } } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); if (_FAIL == res) if (pwrctrl->cpwm >= PS_STATE_S2) @@ -1011,7 +1010,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S2; - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); register_task_alive(pwrctrl, CMD_ALIVE); @@ -1028,7 +1027,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter) } } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); if (_FAIL == res) if (pwrctrl->cpwm >= PS_STATE_S2) @@ -1061,7 +1060,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter) pslv = PS_STATE_S2; } - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); unregister_task_alive(pwrctrl, XMIT_ALIVE); @@ -1076,7 +1075,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter) rtw_set_rpwm(padapter, pslv); } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); } /* @@ -1103,7 +1102,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter) pslv = PS_STATE_S2; } - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); unregister_task_alive(pwrctrl, CMD_ALIVE); @@ -1119,14 +1118,14 @@ void rtw_unregister_cmd_alive(struct adapter *padapter) } } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); } void rtw_init_pwrctrl_priv(struct adapter *padapter) { struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); - sema_init(&pwrctrlpriv->lock, 1); + mutex_init(&pwrctrlpriv->lock); sema_init(&pwrctrlpriv->check_32k_lock, 1); pwrctrlpriv->rf_pwrstate = rf_on; pwrctrlpriv->ips_enter_cnts = 0; @@ -1357,13 +1356,13 @@ void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason) pwrpriv = adapter_to_pwrctl(padapter); - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if (pwrpriv->ps_deny & BIT(reason)) { DBG_871X(FUNC_ADPT_FMT ": [WARNING] Reason %d had been set before!!\n", FUNC_ADPT_ARG(padapter), reason); } pwrpriv->ps_deny |= BIT(reason); - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */ /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */ @@ -1383,13 +1382,13 @@ void rtw_ps_deny_cancel(struct adapter *padapter, enum PS_DENY_REASON reason) pwrpriv = adapter_to_pwrctl(padapter); - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if ((pwrpriv->ps_deny & BIT(reason)) == 0) { DBG_871X(FUNC_ADPT_FMT ": [ERROR] Reason %d had been canceled before!!\n", FUNC_ADPT_ARG(padapter), reason); } pwrpriv->ps_deny &= ~BIT(reason); - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */ /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */ diff --git a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h index 72df6cffe62e..abf48ae01900 100644 --- a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h @@ -7,6 +7,7 @@ #ifndef __RTW_PWRCTRL_H_ #define __RTW_PWRCTRL_H_ +#include #define FW_PWR0 0 #define FW_PWR1 1 @@ -207,7 +208,7 @@ typedef struct pno_scan_info struct pwrctrl_priv { - _pwrlock lock; + struct mutex lock; _pwrlock check_32k_lock; volatile u8 rpwm; /* requested power state for fw */ volatile u8 cpwm; /* fw current power state. updated when 1. read from HCPWM 2. driver lowers power level */