Skip to content

Commit

Permalink
r8152: fix a WOL issue
Browse files Browse the repository at this point in the history
commit cdf0b86 upstream.

This fixes that the platform is waked by an unexpected packet. The
size and range of FIFO is different when the device enters S3 state,
so it is necessary to correct some settings when suspending.

Regardless of jumbo frame, set RMS to 1522 and MTPS to MTPS_DEFAULT.
Besides, enable MCU_BORW_EN to update the method of calculating the
pointer of data. Then, the hardware could get the correct data.

Fixes: 195aae3 ("r8152: support new chips")
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Link: https://lore.kernel.org/r/20220718082120.10957-391-nic_swsd@realtek.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
hayesorz authored and gregkh committed Jul 29, 2022
1 parent 3ce4ea0 commit 6097d00
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions drivers/net/usb/r8152.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define NETNEXT_VERSION "12"

/* Information for net */
#define NET_VERSION "12"
#define NET_VERSION "13"

#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION
#define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>"
Expand Down Expand Up @@ -5915,7 +5915,8 @@ static void r8153_enter_oob(struct r8152 *tp)

wait_oob_link_list_ready(tp);

ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, mtu_to_size(tp->netdev->mtu));
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, 1522);
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_DEFAULT);

switch (tp->version) {
case RTL_VER_03:
Expand Down Expand Up @@ -5951,6 +5952,10 @@ static void r8153_enter_oob(struct r8152 *tp)
ocp_data |= NOW_IS_OOB | DIS_MCU_CLROOB;
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data);

ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7);
ocp_data |= MCU_BORW_EN;
ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data);

rxdy_gated_en(tp, false);

ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
Expand Down Expand Up @@ -6553,6 +6558,9 @@ static void rtl8156_down(struct r8152 *tp)
rtl_disable(tp);
rtl_reset_bmu(tp);

ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, 1522);
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_DEFAULT);

/* Clear teredo wake event. bit[15:8] is the teredo wakeup
* type. Set it to zero. bits[7:0] are the W1C bits about
* the events. Set them to all 1 to clear them.
Expand All @@ -6563,6 +6571,10 @@ static void rtl8156_down(struct r8152 *tp)
ocp_data |= NOW_IS_OOB;
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data);

ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7);
ocp_data |= MCU_BORW_EN;
ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data);

rtl_rx_vlan_en(tp, true);
rxdy_gated_en(tp, false);

Expand Down

0 comments on commit 6097d00

Please sign in to comment.