Return-Path: Received: from mail-by2nam01on0115.outbound.protection.outlook.com ([104.47.34.115]:14144 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933509AbeCCWav (ORCPT ); Sat, 3 Mar 2018 17:30:51 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Adiel Aloni , Luca Coelho , Johannes Berg , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 73/84] mac80211_hwsim: enforce PS_MANUAL_POLL to be set after PS_ENABLED Date: Sat, 3 Mar 2018 22:26:43 +0000 Message-ID: <20180303222518.26271-73-alexander.levin@microsoft.com> References: <20180303222518.26271-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222518.26271-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Adiel Aloni [ Upstream commit e16ea4bb516bc21ea2202f2107718b29218bea59 ] Enforce using PS_MANUAL_POLL in ps hwsim debugfs to trigger a poll, only if PS_ENABLED was set before. This is required due to commit c9491367b759 ("mac80211: always update the PM state of a peer on MGMT / DATA frames") that enforces the ap to check only mgmt/data frames ps bit, and then update station's power save accordingly. When sending only ps-poll (control frame) the ap will not be aware that the station entered power save. Setting ps enable before triggering ps_poll, will send NDP with PM bit enabled first. Signed-off-by: Adiel Aloni Signed-off-by: Luca Coelho Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- drivers/net/wireless/mac80211_hwsim.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/m= ac80211_hwsim.c index 052e67bce6b3..afbb5a813d46 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -727,16 +727,21 @@ static int hwsim_fops_ps_write(void *dat, u64 val) val !=3D PS_MANUAL_POLL) return -EINVAL; =20 - old_ps =3D data->ps; - data->ps =3D val; - - local_bh_disable(); if (val =3D=3D PS_MANUAL_POLL) { + if (data->ps !=3D PS_ENABLED) + return -EINVAL; + local_bh_disable(); ieee80211_iterate_active_interfaces_atomic( data->hw, IEEE80211_IFACE_ITER_NORMAL, hwsim_send_ps_poll, data); - data->ps_poll_pending =3D true; - } else if (old_ps =3D=3D PS_DISABLED && val !=3D PS_DISABLED) { + local_bh_enable(); + return 0; + } + old_ps =3D data->ps; + data->ps =3D val; + + local_bh_disable(); + if (old_ps =3D=3D PS_DISABLED && val !=3D PS_DISABLED) { ieee80211_iterate_active_interfaces_atomic( data->hw, IEEE80211_IFACE_ITER_NORMAL, hwsim_send_nullfunc_ps, data); --=20 2.14.1