All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Hayes Wang <hayeswang@realtek.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.4 14/27] r8152: fix rx issue for runtime suspend
Date: Fri, 13 Jan 2017 12:38:31 +0100	[thread overview]
Message-ID: <20170113113723.228612021@linuxfoundation.org> (raw)
In-Reply-To: <20170113113722.669106991@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: hayeswang <hayeswang@realtek.com>


[ Upstream commit 75dc692eda114cb234a46cb11893a9c3ea520934 ]

Pause the rx and make sure the rx fifo is empty when the autosuspend
occurs.

If the rx data comes when the driver is canceling the rx urb, the host
controller would stop getting the data from the device and continue
it after next rx urb is submitted. That is, one continuing data is
split into two different urb buffers. That let the driver take the
data as a rx descriptor, and unexpected behavior happens.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/usb/r8152.c |   31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3452,17 +3452,42 @@ static int rtl8152_rumtime_suspend(struc
 	int ret = 0;
 
 	if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
+		u32 rcr = 0;
+
 		if (delay_autosuspend(tp)) {
 			ret = -EBUSY;
 			goto out1;
 		}
 
+		if (netif_carrier_ok(netdev)) {
+			u32 ocp_data;
+
+			rcr = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
+			ocp_data = rcr & ~RCR_ACPT_ALL;
+			ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
+			rxdy_gated_en(tp, true);
+			ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA,
+						 PLA_OOB_CTRL);
+			if (!(ocp_data & RXFIFO_EMPTY)) {
+				rxdy_gated_en(tp, false);
+				ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr);
+				ret = -EBUSY;
+				goto out1;
+			}
+		}
+
 		clear_bit(WORK_ENABLE, &tp->flags);
 		usb_kill_urb(tp->intr_urb);
-		napi_disable(&tp->napi);
-		rtl_stop_rx(tp);
+
 		rtl_runtime_suspend_enable(tp, true);
-		napi_enable(&tp->napi);
+
+		if (netif_carrier_ok(netdev)) {
+			napi_disable(&tp->napi);
+			rtl_stop_rx(tp);
+			rxdy_gated_en(tp, false);
+			ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr);
+			napi_enable(&tp->napi);
+		}
 	}
 
 	set_bit(SELECTIVE_SUSPEND, &tp->flags);

  parent reply	other threads:[~2017-01-13 11:39 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170113113908epcas2p26894f438616da1bf9f7b6b31f735fedc@epcas2p2.samsung.com>
2017-01-13 11:38 ` [PATCH 4.4 00/27] 4.4.43-stable review Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 01/27] netvsc: reduce maximum GSO size Greg Kroah-Hartman
2017-02-09 19:37     ` Ben Hutchings
2017-02-09 19:37       ` Ben Hutchings
2017-02-10 21:15       ` Greg Kroah-Hartman
2017-02-10 21:15         ` Greg Kroah-Hartman
2017-02-10 21:41       ` Patch "[PATCH] netvsc: Set maximum GSO size in the right place" has been added to the 4.4-stable tree gregkh
2017-01-13 11:38   ` [PATCH 4.4 02/27] ser_gigaset: return -ENOMEM on error instead of success Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 03/27] net: vrf: Drop conntrack data after pass through VRF device on Tx Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 04/27] ipv6: handle -EFAULT from skb_copy_bits Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 05/27] net, sched: fix soft lockup in tc_classify Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 06/27] net: stmmac: Fix race between stmmac_drv_probe and stmmac_open Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 07/27] net/mlx5: Check FW limitations on log_max_qp before setting it Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 08/27] net/mlx5: Avoid shadowing numa_node Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 09/27] drop_monitor: add missing call to genlmsg_end Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 10/27] drop_monitor: consider inserted data in genlmsg_end Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 11/27] igmp: Make igmp group member RFC 3376 compliant Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 12/27] ipv4: Do not allow MAIN to be alias for new LOCAL w/ custom rules Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 13/27] r8152: split rtl8152_suspend function Greg Kroah-Hartman
2017-01-13 11:38   ` Greg Kroah-Hartman [this message]
2017-01-13 11:38   ` [PATCH 4.4 15/27] gro: Enter slow-path if there is no tailroom Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 16/27] gro: use min_t() in skb_gro_reset_offset() Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 17/27] gro: Disable frag0 optimization on IPv6 ext headers Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 18/27] net: ipv4: Fix multipath selection with vrf Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 19/27] net: vrf: do not allow table id 0 Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 20/27] HID: hid-cypress: validate length of report Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 21/27] ALSA: firewire-tascam: Fix to handle error from initialization of stream data Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 22/27] powerpc: Fix build warning on 32-bit PPC Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 23/27] ARM: zynq: Reserve correct amount of non-DMA RAM Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 24/27] ARM: OMAP4+: Fix bad fallthrough for cpuidle Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 26/27] ALSA: usb-audio: Add a quirk for Plantronics BT600 Greg Kroah-Hartman
2017-01-13 11:38   ` [PATCH 4.4 27/27] mm/init: fix zone boundary creation Greg Kroah-Hartman
2017-01-13 20:19   ` [PATCH 4.4 00/27] 4.4.43-stable review Guenter Roeck
2017-01-14  7:24     ` Greg Kroah-Hartman
2017-01-13 21:57   ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170113113723.228612021@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=hayeswang@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.