| From 1474539c24ac7f196582e0ebd6da4cd297bb61cf Mon Sep 17 00:00:00 2001 |
| From: Hayes Wang <hayeswang@realtek.com> |
| Date: Wed, 22 Jan 2020 16:02:09 +0800 |
| Subject: [PATCH] r8152: Disable PLA MCU clock speed down |
| |
| commit 08997b5eec08a2c29367f19a74abdea54b299406 upstream. |
| |
| PLA MCU clock speed down could only be enabled when tx/rx are disabled. |
| Otherwise, the packet loss may occur. |
| |
| Signed-off-by: Hayes Wang <hayeswang@realtek.com> |
| Signed-off-by: David S. Miller <davem@davemloft.net> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c |
| index fa36554654ac..4187944e2a57 100644 |
| --- a/drivers/net/usb/r8152.c |
| +++ b/drivers/net/usb/r8152.c |
| @@ -306,6 +306,7 @@ |
| #define MAC_CLK_SPDWN_EN BIT(15) |
| |
| /* PLA_MAC_PWR_CTRL3 */ |
| +#define PLA_MCU_SPDWN_EN BIT(14) |
| #define PKT_AVAIL_SPDWN_EN 0x0100 |
| #define SUSPEND_SPDWN_EN 0x0004 |
| #define U1U2_SPDWN_EN 0x0002 |
| @@ -3754,6 +3755,8 @@ static void rtl8153_down(struct r8152 *tp) |
| |
| static void rtl8153b_up(struct r8152 *tp) |
| { |
| + u32 ocp_data; |
| + |
| if (test_bit(RTL8152_UNPLUG, &tp->flags)) |
| return; |
| |
| @@ -3764,17 +3767,27 @@ static void rtl8153b_up(struct r8152 *tp) |
| r8153_first_init(tp); |
| ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_BUF_TH, RX_THR_B); |
| |
| + ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3); |
| + ocp_data &= ~PLA_MCU_SPDWN_EN; |
| + ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, ocp_data); |
| + |
| r8153b_aldps_en(tp, true); |
| r8153b_u1u2en(tp, true); |
| } |
| |
| static void rtl8153b_down(struct r8152 *tp) |
| { |
| + u32 ocp_data; |
| + |
| if (test_bit(RTL8152_UNPLUG, &tp->flags)) { |
| rtl_drop_queued_tx(tp); |
| return; |
| } |
| |
| + ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3); |
| + ocp_data |= PLA_MCU_SPDWN_EN; |
| + ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, ocp_data); |
| + |
| r8153b_u1u2en(tp, false); |
| r8153_u2p3en(tp, false); |
| r8153b_power_cut_en(tp, false); |
| @@ -4230,6 +4243,10 @@ static void r8153b_init(struct r8152 *tp) |
| ocp_data |= MAC_CLK_SPDWN_EN; |
| ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL2, ocp_data); |
| |
| + ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3); |
| + ocp_data &= ~PLA_MCU_SPDWN_EN; |
| + ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, ocp_data); |
| + |
| set_bit(GREEN_ETHERNET, &tp->flags); |
| |
| /* rx aggregation */ |
| -- |
| 2.7.4 |
| |