2021-08-12 17:47:24

by Kai-Heng Feng

[permalink] [raw]
Subject: [PATCH v2 1/2] r8169: Implement dynamic ASPM mechanism

r8169 NICs on some platforms have abysmal speed when ASPM is enabled.
Same issue can be observed with older vendor drivers.

The issue is however solved by the latest vendor driver. There's a new
mechanism, which disables r8169's internal ASPM when the NIC traffic has
more than 10 packets, and vice versa.

Realtek confirmed that all their PCIe LAN NICs, r8106, r8168 and r8125
use dynamic ASPM under Windows. So implement the same mechanism here to
resolve the issue.

Signed-off-by: Kai-Heng Feng <[email protected]>
---
v2:
- Use delayed_work instead of timer_list to avoid interrupt context
- Use mutex to serialize packet counter read/write
- Wording change

drivers/net/ethernet/realtek/r8169_main.c | 45 +++++++++++++++++++++++
1 file changed, 45 insertions(+)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index c7af5bc3b8af..7ab2e841dc69 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -624,6 +624,11 @@ struct rtl8169_private {

unsigned supports_gmii:1;
unsigned aspm_manageable:1;
+ unsigned aspm_enabled:1;
+ struct delayed_work aspm_toggle;
+ struct mutex aspm_mutex;
+ u32 aspm_packet_count;
+
dma_addr_t counters_phys_addr;
struct rtl8169_counters *counters;
struct rtl8169_tc_offsets tc_offset;
@@ -2671,6 +2676,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable)
RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~ASPM_en);
}

+ tp->aspm_enabled = enable;
+
udelay(10);
}

@@ -4408,6 +4415,9 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,

dirty_tx = tp->dirty_tx;

+ mutex_lock(&tp->aspm_mutex);
+ tp->aspm_packet_count += tp->cur_tx - dirty_tx;
+ mutex_unlock(&tp->aspm_mutex);
while (READ_ONCE(tp->cur_tx) != dirty_tx) {
unsigned int entry = dirty_tx % NUM_TX_DESC;
u32 status;
@@ -4552,6 +4562,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, int budget
rtl8169_mark_to_asic(desc);
}

+ mutex_lock(&tp->aspm_mutex);
+ tp->aspm_packet_count += count;
+ mutex_unlock(&tp->aspm_mutex);
+
return count;
}

@@ -4659,8 +4673,33 @@ static int r8169_phy_connect(struct rtl8169_private *tp)
return 0;
}

+#define ASPM_PACKET_THRESHOLD 10
+#define ASPM_TOGGLE_INTERVAL 1000
+
+static void rtl8169_aspm_toggle(struct work_struct *work)
+{
+ struct rtl8169_private *tp = container_of(work, struct rtl8169_private,
+ aspm_toggle.work);
+ bool enable;
+
+ mutex_lock(&tp->aspm_mutex);
+ enable = tp->aspm_packet_count <= ASPM_PACKET_THRESHOLD;
+ tp->aspm_packet_count = 0;
+ mutex_unlock(&tp->aspm_mutex);
+
+ if (tp->aspm_enabled != enable) {
+ rtl_unlock_config_regs(tp);
+ rtl_hw_aspm_clkreq_enable(tp, enable);
+ rtl_lock_config_regs(tp);
+ }
+
+ schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
+}
+
static void rtl8169_down(struct rtl8169_private *tp)
{
+ cancel_delayed_work_sync(&tp->aspm_toggle);
+
/* Clear all task flags */
bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);

@@ -4687,6 +4726,8 @@ static void rtl8169_up(struct rtl8169_private *tp)
rtl_reset_work(tp);

phy_start(tp->phydev);
+
+ schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
}

static int rtl8169_close(struct net_device *dev)
@@ -5347,6 +5388,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)

INIT_WORK(&tp->wk.work, rtl_task);

+ INIT_DELAYED_WORK(&tp->aspm_toggle, rtl8169_aspm_toggle);
+
+ mutex_init(&tp->aspm_mutex);
+
rtl_init_mac_address(tp);

dev->ethtool_ops = &rtl8169_ethtool_ops;
--
2.32.0


2021-08-12 20:40:26

by Heiner Kallweit

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] r8169: Implement dynamic ASPM mechanism

On 12.08.2021 17:53, Kai-Heng Feng wrote:
> r8169 NICs on some platforms have abysmal speed when ASPM is enabled.
> Same issue can be observed with older vendor drivers.
>
> The issue is however solved by the latest vendor driver. There's a new
> mechanism, which disables r8169's internal ASPM when the NIC traffic has
> more than 10 packets, and vice versa.
>
> Realtek confirmed that all their PCIe LAN NICs, r8106, r8168 and r8125
> use dynamic ASPM under Windows. So implement the same mechanism here to
> resolve the issue.
>
Realtek using something in their Windows drivers isn't really a proof of
quality. Still my concerns haven't been addressed. If ASPM is enabled and
there's a congestion in the chip it may take up to a second until ASPM
gets disabled. In this second traffic very likely is heavily affected.
Who takes care in case of problem reports?

This is a massive change for basically all chip versions. And experience
shows that in case of problem reports Realtek never cares, even though
they are listed as maintainers. All I see is that they copy more and more
code from r8169 into their own drivers. This seems to indicate that they
consider quality of their own drivers as not sufficient.

Still my proposal: Apply this downstream, and if there are no complaints
after a few months it may be considered for mainline.

Last but not least the formal issues:
- no cover letter
- no net/net-next annotation

> Signed-off-by: Kai-Heng Feng <[email protected]>
> ---
> v2:
> - Use delayed_work instead of timer_list to avoid interrupt context
> - Use mutex to serialize packet counter read/write
> - Wording change
>
> drivers/net/ethernet/realtek/r8169_main.c | 45 +++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index c7af5bc3b8af..7ab2e841dc69 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -624,6 +624,11 @@ struct rtl8169_private {
>
> unsigned supports_gmii:1;
> unsigned aspm_manageable:1;
> + unsigned aspm_enabled:1;
> + struct delayed_work aspm_toggle;
> + struct mutex aspm_mutex;
> + u32 aspm_packet_count;
> +
> dma_addr_t counters_phys_addr;
> struct rtl8169_counters *counters;
> struct rtl8169_tc_offsets tc_offset;
> @@ -2671,6 +2676,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable)
> RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~ASPM_en);
> }
>
> + tp->aspm_enabled = enable;
> +
> udelay(10);
> }
>
> @@ -4408,6 +4415,9 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
>
> dirty_tx = tp->dirty_tx;
>
> + mutex_lock(&tp->aspm_mutex);

We are in soft irq context here, therefore you shouldn't sleep.

> + tp->aspm_packet_count += tp->cur_tx - dirty_tx;
> + mutex_unlock(&tp->aspm_mutex);
> while (READ_ONCE(tp->cur_tx) != dirty_tx) {
> unsigned int entry = dirty_tx % NUM_TX_DESC;
> u32 status;
> @@ -4552,6 +4562,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, int budget
> rtl8169_mark_to_asic(desc);
> }
>
> + mutex_lock(&tp->aspm_mutex);
> + tp->aspm_packet_count += count;
> + mutex_unlock(&tp->aspm_mutex);
> +
> return count;
> }
>
> @@ -4659,8 +4673,33 @@ static int r8169_phy_connect(struct rtl8169_private *tp)
> return 0;
> }
>
> +#define ASPM_PACKET_THRESHOLD 10
> +#define ASPM_TOGGLE_INTERVAL 1000
> +
> +static void rtl8169_aspm_toggle(struct work_struct *work)
> +{
> + struct rtl8169_private *tp = container_of(work, struct rtl8169_private,
> + aspm_toggle.work);
> + bool enable;
> +
> + mutex_lock(&tp->aspm_mutex);
> + enable = tp->aspm_packet_count <= ASPM_PACKET_THRESHOLD;
> + tp->aspm_packet_count = 0;
> + mutex_unlock(&tp->aspm_mutex);
> +
> + if (tp->aspm_enabled != enable) {
> + rtl_unlock_config_regs(tp);
> + rtl_hw_aspm_clkreq_enable(tp, enable);
> + rtl_lock_config_regs(tp);
> + }
> +
> + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
> +}
> +
> static void rtl8169_down(struct rtl8169_private *tp)
> {
> + cancel_delayed_work_sync(&tp->aspm_toggle);
> +
> /* Clear all task flags */
> bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);
>
> @@ -4687,6 +4726,8 @@ static void rtl8169_up(struct rtl8169_private *tp)
> rtl_reset_work(tp);
>
> phy_start(tp->phydev);
> +
> + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);

In the first version you used msecs_to_jiffies(ASPM_TIMER_INTERVAL).
Now you use 1000 jiffies what is a major difference.

> }
>
> static int rtl8169_close(struct net_device *dev)
> @@ -5347,6 +5388,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>
> INIT_WORK(&tp->wk.work, rtl_task);
>
> + INIT_DELAYED_WORK(&tp->aspm_toggle, rtl8169_aspm_toggle);
> +
> + mutex_init(&tp->aspm_mutex);
> +
> rtl_init_mac_address(tp);
>
> dev->ethtool_ops = &rtl8169_ethtool_ops;
>

2021-08-13 06:33:07

by kernel test robot

[permalink] [raw]
Subject: [r8169] 5b4904cded: BUG:sleeping_function_called_from_invalid_context_at_kernel/locking/mutex.c



Greeting,

FYI, we noticed the following commit (built with gcc-9):

commit: 5b4904cded4b193ac64fae60dd0acff19144b385 ("[PATCH v2 1/2] r8169: Implement dynamic ASPM mechanism")
url: https://github.com/0day-ci/linux/commits/Kai-Heng-Feng/r8169-Implement-dynamic-ASPM-mechanism/20210812-235554
base: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git 1746f4db513563bb22e0ba0c419d0c90912dfae1

in testcase: ltp
version: ltp-x86_64-14c1f76-1_20210807
with following parameters:

disk: 1HDD
fs: f2fs
test: io
ucode: 0x21

test-description: The LTP testsuite contains a collection of tools for testing the Linux kernel and related features.
test-url: http://linux-test-project.github.io/


on test machine: 4 threads 1 sockets Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz with 8G memory

caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):



If you fix the issue, kindly add following tag
Reported-by: kernel test robot <[email protected]>


[ 51.552652][ C2] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:281
[ 51.552818][ C2] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 340, name: sed
[ 51.552952][ C2] CPU: 2 PID: 340 Comm: sed Tainted: G W 5.14.0-rc5-00023-g5b4904cded4b #1
[ 51.553108][ C2] Hardware name: Hewlett-Packard p6-1451cx/2ADA, BIOS 8.15 02/05/2013
[ 51.553237][ C2] Call Trace:
[ 51.553293][ C2] dump_stack_lvl (lib/dump_stack.c:106)
[ 51.553371][ C2] ___might_sleep.cold (kernel/sched/core.c:9135 kernel/sched/core.c:9092)
[ 51.553453][ C2] mutex_lock (kernel/locking/mutex.c:281)
[ 51.553523][ C2] rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4419 drivers/net/ethernet/realtek/r8169_main.c:4629)
[ 51.553597][ C2] __napi_poll (net/core/dev.c:7047)
[ 51.553669][ C2] net_rx_action (net/core/dev.c:7116 net/core/dev.c:7201)
[ 51.553744][ C2] __do_softirq (arch/x86/include/asm/jump_label.h:27 include/linux/jump_label.h:212 include/trace/events/irq.h:142 kernel/softirq.c:559)
[ 51.553817][ C2] irq_exit_rcu (kernel/softirq.c:432 kernel/softirq.c:636 kernel/softirq.c:648)
[ 51.553890][ C2] common_interrupt (arch/x86/kernel/irq.c:240 (discriminator 13))
[ 51.553968][ C2] ? asm_common_interrupt (arch/x86/include/asm/idtentry.h:629)
[ 51.554050][ C2] asm_common_interrupt (arch/x86/include/asm/idtentry.h:629)
[ 51.554131][ C2] RIP: 0033:0x55719d21df44
[ 51.554204][ C2] Code: 89 d5 41 54 49 89 fc 55 53 48 83 ec 08 48 8b 6a 08 48 8b 02 48 85 ed 0f 8e d4 00 00 00 48 89 ee 31 db eb 0b 66 90 48 8d 5a 01 <48> 39 de 7e 24 48 8d 14 1e 48 d1 fa 48 89 d1 48 c1 e1 04 48 01 c1
All code
========
0: 89 d5 mov %edx,%ebp
2: 41 54 push %r12
4: 49 89 fc mov %rdi,%r12
7: 55 push %rbp
8: 53 push %rbx
9: 48 83 ec 08 sub $0x8,%rsp
d: 48 8b 6a 08 mov 0x8(%rdx),%rbp
11: 48 8b 02 mov (%rdx),%rax
14: 48 85 ed test %rbp,%rbp
17: 0f 8e d4 00 00 00 jle 0xf1
1d: 48 89 ee mov %rbp,%rsi
20: 31 db xor %ebx,%ebx
22: eb 0b jmp 0x2f
24: 66 90 xchg %ax,%ax
26: 48 8d 5a 01 lea 0x1(%rdx),%rbx
2a:* 48 39 de cmp %rbx,%rsi <-- trapping instruction
2d: 7e 24 jle 0x53
2f: 48 8d 14 1e lea (%rsi,%rbx,1),%rdx
33: 48 d1 fa sar %rdx
36: 48 89 d1 mov %rdx,%rcx
39: 48 c1 e1 04 shl $0x4,%rcx
3d: 48 01 c1 add %rax,%rcx

Code starting with the faulting instruction
===========================================
0: 48 39 de cmp %rbx,%rsi
3: 7e 24 jle 0x29
5: 48 8d 14 1e lea (%rsi,%rbx,1),%rdx
9: 48 d1 fa sar %rdx
c: 48 89 d1 mov %rdx,%rcx
f: 48 c1 e1 04 shl $0x4,%rcx
13: 48 01 c1 add %rax,%rcx
[ 51.554509][ C2] RSP: 002b:00007ffe39caa680 EFLAGS: 00000297
[ 51.554606][ C2] RAX: 00005571a3c5c6b0 RBX: 0000000000000e02 RCX: 00005571a3c6a6c0
[ 51.554732][ C2] RDX: 0000000000000e01 RSI: 0000000000000e03 RDI: 0000000000000e03
[ 51.554858][ C2] RBP: 0000000000000e14 R08: 0000000000000003 R09: 000000000000007a
[ 51.554983][ C2] R10: 000055719e1c9010 R11: 0000000000000000 R12: 0000000000000e03
[ 51.555109][ C2] R13: 00007ffe39caa710 R14: 00000000000001ff R15: 000055719f376400
[ 52.038897][ T2479] device-mapper: uevent: version 1.0.3
[ 52.039057][ T2479] device-mapper: ioctl: 4.45.0-ioctl (2021-03-22) initialised: [email protected]
[ 52.709527][ C2] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:281
[ 52.709689][ C2] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 340, name: sed
[ 52.709818][ C2] CPU: 2 PID: 340 Comm: sed Tainted: G W 5.14.0-rc5-00023-g5b4904cded4b #1
[ 52.709970][ C2] Hardware name: Hewlett-Packard p6-1451cx/2ADA, BIOS 8.15 02/05/2013
[ 52.710094][ C2] Call Trace:
[ 52.710149][ C2] dump_stack_lvl (lib/dump_stack.c:106)
[ 52.710223][ C2] ___might_sleep.cold (kernel/sched/core.c:9135 kernel/sched/core.c:9092)
[ 52.710303][ C2] mutex_lock (kernel/locking/mutex.c:281)
[ 52.710370][ C2] rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4419 drivers/net/ethernet/realtek/r8169_main.c:4629)
[ 52.710441][ C2] __napi_poll (net/core/dev.c:7047)
[ 52.710510][ C2] net_rx_action (net/core/dev.c:7116 net/core/dev.c:7201)
[ 52.710583][ C2] __do_softirq (arch/x86/include/asm/jump_label.h:27 include/linux/jump_label.h:212 include/trace/events/irq.h:142 kernel/softirq.c:559)
[ 52.710653][ C2] irq_exit_rcu (kernel/softirq.c:432 kernel/softirq.c:636 kernel/softirq.c:648)
[ 52.710724][ C2] common_interrupt (arch/x86/kernel/irq.c:240 (discriminator 13))
[ 52.710799][ C2] ? asm_common_interrupt (arch/x86/include/asm/idtentry.h:629)
[ 52.710878][ C2] asm_common_interrupt (arch/x86/include/asm/idtentry.h:629)
[ 52.710956][ C2] RIP: 0033:0x55719d21f18b
[ 52.711027][ C2] Code: e0 04 48 03 02 4c 89 e2 48 8b 70 08 48 8b 38 e8 9b ed ff ff 49 8b b7 58 03 00 00 48 01 ee 48 8b 46 08 48 8b 04 18 48 8d 14 40 <49> 8b 87 70 03 00 00 48 8d 14 d0 4c 39 72 08 77 bc 49 83 c5 01 4c
All code
========
0: e0 04 loopne 0x6
2: 48 03 02 add (%rdx),%rax
5: 4c 89 e2 mov %r12,%rdx
8: 48 8b 70 08 mov 0x8(%rax),%rsi
c: 48 8b 38 mov (%rax),%rdi
f: e8 9b ed ff ff callq 0xffffffffffffedaf
14: 49 8b b7 58 03 00 00 mov 0x358(%r15),%rsi
1b: 48 01 ee add %rbp,%rsi
1e: 48 8b 46 08 mov 0x8(%rsi),%rax
22: 48 8b 04 18 mov (%rax,%rbx,1),%rax
26: 48 8d 14 40 lea (%rax,%rax,2),%rdx
2a:* 49 8b 87 70 03 00 00 mov 0x370(%r15),%rax <-- trapping instruction
31: 48 8d 14 d0 lea (%rax,%rdx,8),%rdx
35: 4c 39 72 08 cmp %r14,0x8(%rdx)
39: 77 bc ja 0xfffffffffffffff7
3b: 49 83 c5 01 add $0x1,%r13
3f: 4c rex.WR

Code starting with the faulting instruction
===========================================
0: 49 8b 87 70 03 00 00 mov 0x370(%r15),%rax
7: 48 8d 14 d0 lea (%rax,%rdx,8),%rdx
b: 4c 39 72 08 cmp %r14,0x8(%rdx)
f: 77 bc ja 0xffffffffffffffcd
11: 49 83 c5 01 add $0x1,%r13
15: 4c rex.WR
[ 52.711324][ C2] RSP: 002b:00007ffe39caa6c0 EFLAGS: 00000202
[ 52.711418][ C2] RAX: 00000000000002f5 RBX: 00000000000002b0 RCX: 00005571a3d4f5c0
[ 52.711539][ C2] RDX: 00000000000008df RSI: 00005571a38ee380 RDI: 0000000000000a15
[ 52.711659][ C2] RBP: 0000000000005c80 R08: 0000000000000000 R09: 00007fbfea9fe0f0
[ 52.711780][ C2] R10: 000055719e1c9010 R11: 00007fbfea9fe0f0 R12: 00007ffe39caa710
[ 52.711901][ C2] R13: 000000000000002b R14: 000000000000071d R15: 000055719f376400
[ 53.049161][ T340] RESULT_ROOT=/result/ltp/1HDD-f2fs-io-ucode=0x21/lkp-ivb-d05/debian-10.4-x86_64-20200603.cgz/x86_64-rhel-8.3/gcc-9/5b4904cded4b193ac64fae60dd0acff19144b385/3
[ 53.049168][ T340]
[ 53.312219][ T2492] F2FS-fs (sda1): Found nat_bits in checkpoint
[ 53.383901][ T340] job=/lkp/jobs/scheduled/lkp-ivb-d05/ltp-1HDD-f2fs-io-ucode=0x21-debian-10.4-x86_64-20200603.cgz-5b4904cded4b193ac64fae60dd0acff19144b385-20210813-26622-fyb8n4-4.yaml
[ 53.383907][ T340]
[ 53.441099][ T2492] F2FS-fs (sda1): Mounted with checkpoint version = 31a3739f
[ 53.489831][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.490098][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.513715][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.513939][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.536924][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.537148][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.560064][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.560289][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.583184][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.583403][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.606384][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.606604][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.629526][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.629759][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.652701][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.652919][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.675842][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.676062][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.698961][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.699180][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.722163][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.722381][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.722384][ C2] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:281
[ 53.722799][ C2] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/2
[ 53.723049][ C2] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G W 5.14.0-rc5-00023-g5b4904cded4b #1
[ 53.723334][ C2] Hardware name: Hewlett-Packard p6-1451cx/2ADA, BIOS 8.15 02/05/2013
[ 53.723562][ C2] Call Trace:
[ 53.723656][ C2] <IRQ>
[ 53.723738][ C2] dump_stack_lvl (lib/dump_stack.c:106)
[ 53.723870][ C2] ___might_sleep.cold (kernel/sched/core.c:9135 kernel/sched/core.c:9092)
[ 53.724012][ C2] mutex_lock (kernel/locking/mutex.c:281)
[ 53.724134][ C2] rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4419 drivers/net/ethernet/realtek/r8169_main.c:4629)
[ 53.724261][ C2] ? scheduler_tick (kernel/sched/core.c:6634 kernel/sched/core.c:4965)
[ 53.724395][ C2] __napi_poll (net/core/dev.c:7047)
[ 53.724517][ C2] net_rx_action (net/core/dev.c:7116 net/core/dev.c:7201)
[ 53.724649][ C2] __do_softirq (arch/x86/include/asm/jump_label.h:27 include/linux/jump_label.h:212 include/trace/events/irq.h:142 kernel/softirq.c:559)
[ 53.724776][ C2] irq_exit_rcu (kernel/softirq.c:432 kernel/softirq.c:636 kernel/softirq.c:648)
[ 53.724900][ C2] common_interrupt (arch/x86/kernel/irq.c:240 (discriminator 14))
[ 53.725032][ C2] </IRQ>
[ 53.725115][ C2] asm_common_interrupt (arch/x86/include/asm/idtentry.h:629)
[ 53.725257][ C2] RIP: 0010:cpuidle_enter_state (drivers/cpuidle/cpuidle.c:259)
[ 53.725425][ C2] Code: 49 89 c5 0f 1f 44 00 00 31 ff e8 49 20 70 ff 45 84 ff 74 12 9c 58 f6 c4 02 0f 85 62 02 00 00 31 ff e8 b2 63 77 ff fb 45 85 f6 <0f> 88 fb 00 00 00 49 63 c6 4c 2b 2c 24 48 8d 14 40 48 8d 14 90 49
All code
========
0: 49 89 c5 mov %rax,%r13
3: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
8: 31 ff xor %edi,%edi
a: e8 49 20 70 ff callq 0xffffffffff702058
f: 45 84 ff test %r15b,%r15b
12: 74 12 je 0x26
14: 9c pushfq
15: 58 pop %rax
16: f6 c4 02 test $0x2,%ah
19: 0f 85 62 02 00 00 jne 0x281
1f: 31 ff xor %edi,%edi
21: e8 b2 63 77 ff callq 0xffffffffff7763d8
26: fb sti
27: 45 85 f6 test %r14d,%r14d
2a:* 0f 88 fb 00 00 00 js 0x12b <-- trapping instruction
30: 49 63 c6 movslq %r14d,%rax
33: 4c 2b 2c 24 sub (%rsp),%r13
37: 48 8d 14 40 lea (%rax,%rax,2),%rdx
3b: 48 8d 14 90 lea (%rax,%rdx,4),%rdx
3f: 49 rex.WB

Code starting with the faulting instruction
===========================================
0: 0f 88 fb 00 00 00 js 0x101
6: 49 63 c6 movslq %r14d,%rax
9: 4c 2b 2c 24 sub (%rsp),%r13
d: 48 8d 14 40 lea (%rax,%rax,2),%rdx
11: 48 8d 14 90 lea (%rax,%rdx,4),%rdx
15: 49 rex.WB
[ 53.725966][ C2] RSP: 0018:ffffc9000009fe80 EFLAGS: 00000202
[ 53.726136][ C2] RAX: ffff8881e292bd00 RBX: 0000000000000004 RCX: 000000000000001f
[ 53.726362][ C2] RDX: 0000000000000000 RSI: 0000000026e04163 RDI: 0000000000000000
[ 53.726583][ C2] RBP: ffff8881e2935820 R08: 0000000c821a6d88 R09: 0000000000000000
[ 53.726803][ C2] R10: 0000000000000000 R11: 000000000000000f R12: ffffffff82ce4860
[ 53.727026][ C2] R13: 0000000c821a6d88 R14: 0000000000000004 R15: 0000000000000000
[ 53.727254][ C2] cpuidle_enter (drivers/cpuidle/cpuidle.c:353)
[ 53.727384][ C2] do_idle (kernel/sched/idle.c:243 kernel/sched/idle.c:306)
[ 53.727504][ C2] cpu_startup_entry (kernel/sched/idle.c:402 (discriminator 1))
[ 53.727637][ C2] start_secondary (arch/x86/kernel/smpboot.c:271)
[ 53.727769][ C2] secondary_startup_64_no_verify (arch/x86/kernel/head_64.S:283)
[ 53.747440][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.747679][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.770567][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.770797][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.793688][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.793905][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.816809][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 53.817026][ T2522] x86/PAT: bmc-watchdog:2522 map pfn expected mapping type uncached-minus for [mem 0xd8d1e000-0xd8d1efff], got write-back
[ 54.619788][ T2724] LTP: starting aio01
[ 54.662025][ T2724] LTP: starting aio02
[ 54.777073][ C2] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:281
[ 54.777234][ C2] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/2
[ 54.777373][ C2] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G W 5.14.0-rc5-00023-g5b4904cded4b #1
[ 54.777535][ C2] Hardware name: Hewlett-Packard p6-1451cx/2ADA, BIOS 8.15 02/05/2013
[ 54.777665][ C2] Call Trace:
[ 54.777721][ C2] <IRQ>
[ 54.777769][ C2] dump_stack_lvl (lib/dump_stack.c:106)
[ 54.777847][ C2] ___might_sleep.cold (kernel/sched/core.c:9135 kernel/sched/core.c:9092)
[ 54.777929][ C2] mutex_lock (kernel/locking/mutex.c:281)
[ 54.778000][ C2] rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4419 drivers/net/ethernet/realtek/r8169_main.c:4629)
[ 54.778074][ C2] ? scheduler_tick (kernel/sched/core.c:6634 kernel/sched/core.c:4965)
[ 54.778153][ C2] __napi_poll (net/core/dev.c:7047)
[ 54.778225][ C2] net_rx_action (net/core/dev.c:7116 net/core/dev.c:7201)
[ 54.778300][ C2] __do_softirq (arch/x86/include/asm/jump_label.h:27 include/linux/jump_label.h:212 include/trace/events/irq.h:142 kernel/softirq.c:559)
[ 54.778374][ C2] irq_exit_rcu (kernel/softirq.c:432 kernel/softirq.c:636 kernel/softirq.c:648)
[ 54.778447][ C2] common_interrupt (arch/x86/kernel/irq.c:240 (discriminator 14))
[ 54.778525][ C2] </IRQ>
[ 54.778574][ C2] asm_common_interrupt (arch/x86/include/asm/idtentry.h:629)
[ 54.778656][ C2] RIP: 0010:cpuidle_enter_state (drivers/cpuidle/cpuidle.c:259)
[ 54.778754][ C2] Code: 49 89 c5 0f 1f 44 00 00 31 ff e8 49 20 70 ff 45 84 ff 74 12 9c 58 f6 c4 02 0f 85 62 02 00 00 31 ff e8 b2 63 77 ff fb 45 85 f6 <0f> 88 fb 00 00 00 49 63 c6 4c 2b 2c 24 48 8d 14 40 48 8d 14 90 49
All code
========
0: 49 89 c5 mov %rax,%r13
3: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
8: 31 ff xor %edi,%edi
a: e8 49 20 70 ff callq 0xffffffffff702058
f: 45 84 ff test %r15b,%r15b
12: 74 12 je 0x26
14: 9c pushfq
15: 58 pop %rax
16: f6 c4 02 test $0x2,%ah
19: 0f 85 62 02 00 00 jne 0x281
1f: 31 ff xor %edi,%edi
21: e8 b2 63 77 ff callq 0xffffffffff7763d8
26: fb sti
27: 45 85 f6 test %r14d,%r14d
2a:* 0f 88 fb 00 00 00 js 0x12b <-- trapping instruction
30: 49 63 c6 movslq %r14d,%rax
33: 4c 2b 2c 24 sub (%rsp),%r13
37: 48 8d 14 40 lea (%rax,%rax,2),%rdx
3b: 48 8d 14 90 lea (%rax,%rdx,4),%rdx
3f: 49 rex.WB

Code starting with the faulting instruction
===========================================
0: 0f 88 fb 00 00 00 js 0x101
6: 49 63 c6 movslq %r14d,%rax
9: 4c 2b 2c 24 sub (%rsp),%r13
d: 48 8d 14 40 lea (%rax,%rax,2),%rdx
11: 48 8d 14 90 lea (%rax,%rdx,4),%rdx
15: 49 rex.WB
[ 54.779062][ C2] RSP: 0018:ffffc9000009fe80 EFLAGS: 00000202
[ 54.779159][ C2] RAX: ffff8881e292bd00 RBX: 0000000000000004 RCX: 000000000000001f
[ 54.779286][ C2] RDX: 0000000000000000 RSI: 0000000026e04163 RDI: 0000000000000000
[ 54.779413][ C2] RBP: ffff8881e2935820 R08: 0000000cc0f7b21f R09: 000000007fffffff
[ 54.779539][ C2] R10: 000000000000038a R11: ffff8881e292aa44 R12: ffffffff82ce4860
[ 54.779668][ C2] R13: 0000000cc0f7b21f R14: 0000000000000004 R15: 0000000000000000
[ 54.779796][ C2] cpuidle_enter (drivers/cpuidle/cpuidle.c:353)
[ 54.779868][ C2] do_idle (kernel/sched/idle.c:243 kernel/sched/idle.c:306)
[ 54.779937][ C2] cpu_startup_entry (kernel/sched/idle.c:402 (discriminator 1))
[ 54.780015][ C2] start_secondary (arch/x86/kernel/smpboot.c:271)
[ 54.780095][ C2] secondary_startup_64_no_verify (arch/x86/kernel/head_64.S:283)
[ 55.811558][ C2] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:281
[ 55.811732][ C2] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/2
[ 55.811886][ C2] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G W 5.14.0-rc5-00023-g5b4904cded4b #1
[ 55.812057][ C2] Hardware name: Hewlett-Packard p6-1451cx/2ADA, BIOS 8.15 02/05/2013
[ 55.812189][ C2] Call Trace:
[ 55.812246][ C2] <IRQ>
[ 55.812296][ C2] dump_stack_lvl (lib/dump_stack.c:106)
[ 55.812374][ C2] ___might_sleep.cold (kernel/sched/core.c:9135 kernel/sched/core.c:9092)
[ 55.812457][ C2] mutex_lock (kernel/locking/mutex.c:281)
[ 55.812528][ C2] rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4419 drivers/net/ethernet/realtek/r8169_main.c:4629)
[ 55.812605][ C2] __napi_poll (net/core/dev.c:7047)
[ 55.812678][ C2] net_rx_action (net/core/dev.c:7116 net/core/dev.c:7201)
[ 55.812755][ C2] __do_softirq (arch/x86/include/asm/jump_label.h:27 include/linux/jump_label.h:212 include/trace/events/irq.h:142 kernel/softirq.c:559)
[ 55.812830][ C2] irq_exit_rcu (kernel/softirq.c:432 kernel/softirq.c:636 kernel/softirq.c:648)
[ 55.812904][ C2] common_interrupt (arch/x86/kernel/irq.c:240 (discriminator 14))
[ 55.812983][ C2] </IRQ>
[ 55.813033][ C2] asm_common_interrupt (arch/x86/include/asm/idtentry.h:629)
[ 55.813116][ C2] RIP: 0010:cpuidle_enter_state (drivers/cpuidle/cpuidle.c:259)
[ 55.813213][ C2] Code: 49 89 c5 0f 1f 44 00 00 31 ff e8 49 20 70 ff 45 84 ff 74 12 9c 58 f6 c4 02 0f 85 62 02 00 00 31 ff e8 b2 63 77 ff fb 45 85 f6 <0f> 88 fb 00 00 00 49 63 c6 4c 2b 2c 24 48 8d 14 40 48 8d 14 90 49
All code
========
0: 49 89 c5 mov %rax,%r13
3: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
8: 31 ff xor %edi,%edi
a: e8 49 20 70 ff callq 0xffffffffff702058
f: 45 84 ff test %r15b,%r15b
12: 74 12 je 0x26
14: 9c pushfq
15: 58 pop %rax
16: f6 c4 02 test $0x2,%ah
19: 0f 85 62 02 00 00 jne 0x281
1f: 31 ff xor %edi,%edi
21: e8 b2 63 77 ff callq 0xffffffffff7763d8
26: fb sti
27: 45 85 f6 test %r14d,%r14d
2a:* 0f 88 fb 00 00 00 js 0x12b <-- trapping instruction
30: 49 63 c6 movslq %r14d,%rax
33: 4c 2b 2c 24 sub (%rsp),%r13
37: 48 8d 14 40 lea (%rax,%rax,2),%rdx
3b: 48 8d 14 90 lea (%rax,%rdx,4),%rdx
3f: 49 rex.WB

Code starting with the faulting instruction
===========================================
0: 0f 88 fb 00 00 00 js 0x101
6: 49 63 c6 movslq %r14d,%rax
9: 4c 2b 2c 24 sub (%rsp),%r13
d: 48 8d 14 40 lea (%rax,%rax,2),%rdx
11: 48 8d 14 90 lea (%rax,%rdx,4),%rdx
15: 49 rex.WB
[ 55.813523][ C2] RSP: 0018:ffffc9000009fe80 EFLAGS: 00000202
[ 55.813622][ C2] RAX: ffff8881e292bd00 RBX: 0000000000000004 RCX: 000000000000001f
[ 55.813751][ C2] RDX: 0000000000000000 RSI: 0000000026e04163 RDI: 0000000000000000
[ 55.813878][ C2] RBP: ffff8881e2935820 R08: 0000000cfea0b3b4 R09: 0000000000000394
[ 55.814006][ C2] R10: 0000000000006242 R11: ffff8881e292aa44 R12: ffffffff82ce4860
[ 55.814134][ C2] R13: 0000000cfea0b3b4 R14: 0000000000000004 R15: 0000000000000000
[ 55.814264][ C2] cpuidle_enter (drivers/cpuidle/cpuidle.c:353)
[ 55.814338][ C2] do_idle (kernel/sched/idle.c:243 kernel/sched/idle.c:306)
[ 55.814408][ C2] cpu_startup_entry (kernel/sched/idle.c:402 (discriminator 1))
[ 55.814488][ C2] start_secondary (arch/x86/kernel/smpboot.c:271)
[ 55.814569][ C2] secondary_startup_64_no_verify (arch/x86/kernel/head_64.S:283)
[ 56.908985][ T340] result_service: raw_upload, RESULT_MNT: /internal-lkp-server/result, RESULT_ROOT: /internal-lkp-server/result/ltp/1HDD-f2fs-io-ucode=0x21/lkp-ivb-d05/debian-10.4-x86_64-20200603.cgz/x86_64-rhel-8.3/gcc-9/5b4904cded4b193ac64fae60dd0acff19144b385/3, TMP_RESULT_ROOT: /tmp/lkp/result
[ 56.908991][ T340]
[ 56.909428][ C2] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:281
[ 56.909608][ C2] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/2
[ 56.909761][ C2] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G W 5.14.0-rc5-00023-g5b4904cded4b #1
[ 56.909935][ C2] Hardware name: Hewlett-Packard p6-1451cx/2ADA, BIOS 8.15 02/05/2013
[ 56.910070][ C2] Call Trace:
[ 56.910128][ C2] <IRQ>
[ 56.910178][ C2] dump_stack_lvl (lib/dump_stack.c:106)
[ 56.910256][ C2] ___might_sleep.cold (kernel/sched/core.c:9135 kernel/sched/core.c:9092)
[ 56.910340][ C2] mutex_lock (kernel/locking/mutex.c:281)
[ 56.910412][ C2] rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4419 drivers/net/ethernet/realtek/r8169_main.c:4629)
[ 56.910487][ C2] ? irqtime_account_irq (kernel/sched/cputime.c:61)
[ 56.910573][ C2] __napi_poll (net/core/dev.c:7047)
[ 56.910646][ C2] net_rx_action (net/core/dev.c:7116 net/core/dev.c:7201)
[ 56.910723][ C2] __do_softirq (arch/x86/include/asm/jump_label.h:27 include/linux/jump_label.h:212 include/trace/events/irq.h:142 kernel/softirq.c:559)
[ 56.910800][ C2] irq_exit_rcu (kernel/softirq.c:432 kernel/softirq.c:636 kernel/softirq.c:648)
[ 56.910875][ C2] common_interrupt (arch/x86/kernel/irq.c:240 (discriminator 14))
[ 56.910954][ C2] </IRQ>
[ 56.911004][ C2] asm_common_interrupt (arch/x86/include/asm/idtentry.h:629)
[ 56.911086][ C2] RIP: 0010:cpuidle_enter_state (drivers/cpuidle/cpuidle.c:259)
[ 56.911183][ C2] Code: 49 89 c5 0f 1f 44 00 00 31 ff e8 49 20 70 ff 45 84 ff 74 12 9c 58 f6 c4 02 0f 85 62 02 00 00 31 ff e8 b2 63 77 ff fb 45 85 f6 <0f> 88 fb 00 00 00 49 63 c6 4c 2b 2c 24 48 8d 14 40 48 8d 14 90 49
All code
========
0: 49 89 c5 mov %rax,%r13
3: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
8: 31 ff xor %edi,%edi
a: e8 49 20 70 ff callq 0xffffffffff702058
f: 45 84 ff test %r15b,%r15b
12: 74 12 je 0x26
14: 9c pushfq
15: 58 pop %rax
16: f6 c4 02 test $0x2,%ah
19: 0f 85 62 02 00 00 jne 0x281
1f: 31 ff xor %edi,%edi
21: e8 b2 63 77 ff callq 0xffffffffff7763d8
26: fb sti
27: 45 85 f6 test %r14d,%r14d
2a:* 0f 88 fb 00 00 00 js 0x12b <-- trapping instruction
30: 49 63 c6 movslq %r14d,%rax
33: 4c 2b 2c 24 sub (%rsp),%r13
37: 48 8d 14 40 lea (%rax,%rax,2),%rdx
3b: 48 8d 14 90 lea (%rax,%rdx,4),%rdx
3f: 49 rex.WB

Code starting with the faulting instruction
===========================================
0: 0f 88 fb 00 00 00 js 0x101
6: 49 63 c6 movslq %r14d,%rax
9: 4c 2b 2c 24 sub (%rsp),%r13
d: 48 8d 14 40 lea (%rax,%rax,2),%rdx
11: 48 8d 14 90 lea (%rax,%rdx,4),%rdx
15: 49 rex.WB
[ 56.911493][ C2] RSP: 0018:ffffc9000009fe80 EFLAGS: 00000202
[ 56.911593][ C2] RAX: ffff8881e292bd00 RBX: 0000000000000002 RCX: 000000000000001f
[ 56.911722][ C2] RDX: 0000000000000000 RSI: 0000000026e04163 RDI: 0000000000000000
[ 56.911850][ C2] RBP: ffff8881e2935820 R08: 0000000d4010db80 R09: 000000007fffffff
[ 56.911977][ C2] R10: 0000000000000030 R11: ffff8881e292aa44 R12: ffffffff82ce4860
[ 56.912105][ C2] R13: 0000000d4010db80 R14: 0000000000000002 R15: 0000000000000000
[ 56.912235][ C2] cpuidle_enter (drivers/cpuidle/cpuidle.c:353)
[ 56.912310][ C2] do_idle (kernel/sched/idle.c:243 kernel/sched/idle.c:306)
[ 56.912380][ C2] cpu_startup_entry (kernel/sched/idle.c:402 (discriminator 1))
[ 56.912459][ C2] start_secondary (arch/x86/kernel/smpboot.c:271)
[ 56.912540][ C2] secondary_startup_64_no_verify (arch/x86/kernel/head_64.S:283)
[ 56.913727][ T340] run-job /lkp/jobs/scheduled/lkp-ivb-d05/ltp-1HDD-f2fs-io-ucode=0x21-debian-10.4-x86_64-20200603.cgz-5b4904cded4b193ac64fae60dd0acff19144b385-20210813-26622-fyb8n4-4.yaml
[ 56.913731][ T340]
[ 58.114213][ C2] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:281
[ 58.114373][ C2] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/2
[ 58.114511][ C2] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G W 5.14.0-rc5-00023-g5b4904cded4b #1
[ 58.114672][ C2] Hardware name: Hewlett-Packard p6-1451cx/2ADA, BIOS 8.15 02/05/2013
[ 58.114801][ C2] Call Trace:
[ 58.114855][ C2] <IRQ>
[ 58.114903][ C2] dump_stack_lvl (lib/dump_stack.c:106)
[ 58.114980][ C2] ___might_sleep.cold (kernel/sched/core.c:9135 kernel/sched/core.c:9092)
[ 58.115061][ C2] mutex_lock (kernel/locking/mutex.c:281)
[ 58.115131][ C2] rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4419 drivers/net/ethernet/realtek/r8169_main.c:4629)
[ 58.115204][ C2] __napi_poll (net/core/dev.c:7047)
[ 58.115276][ C2] net_rx_action (net/core/dev.c:7116 net/core/dev.c:7201)
[ 58.115351][ C2] __do_softirq (arch/x86/include/asm/jump_label.h:27 include/linux/jump_label.h:212 include/trace/events/irq.h:142 kernel/softirq.c:559)
[ 58.115425][ C2] irq_exit_rcu (kernel/softirq.c:432 kernel/softirq.c:636 kernel/softirq.c:648)
[ 58.115499][ C2] common_interrupt (arch/x86/kernel/irq.c:240 (discriminator 14))
[ 58.115525][ T340] /usr/bin/wget -q --timeout=1800 --tries=1 --local-encoding=UTF-8 http://internal-lkp-server:80/~lkp/cgi-bin/lkp-jobfile-append-var?job_file=/lkp/jobs/scheduled/lkp-ivb-d05/ltp-1HDD-f2fs-io-ucode=0x21-debian-10.4-x86_64-20200603.cgz-5b4904cded4b193ac64fae60dd0acff19144b385-20210813-26622-fyb8n4-4.yaml&job_state=running -O /dev/null
[ 58.115576][ C2] </IRQ>
[ 58.115578][ T340]
[ 58.116058][ C2] asm_common_interrupt (arch/x86/include/asm/idtentry.h:629)
[ 58.116060][ C2] RIP: 0010:cpuidle_enter_state (drivers/cpuidle/cpuidle.c:259)
[ 58.116064][ C2] Code: 49 89 c5 0f 1f 44 00 00 31 ff e8 49 20 70 ff 45 84 ff 74 12 9c 58 f6 c4 02 0f 85 62 02 00 00 31 ff e8 b2 63 77 ff fb 45 85 f6 <0f> 88 fb 00 00 00 49 63 c6 4c 2b 2c 24 48 8d 14 40 48 8d 14 90 49
All code
========
0: 49 89 c5 mov %rax,%r13
3: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
8: 31 ff xor %edi,%edi
a: e8 49 20 70 ff callq 0xffffffffff702058
f: 45 84 ff test %r15b,%r15b
12: 74 12 je 0x26
14: 9c pushfq
15: 58 pop %rax
16: f6 c4 02 test $0x2,%ah
19: 0f 85 62 02 00 00 jne 0x281
1f: 31 ff xor %edi,%edi
21: e8 b2 63 77 ff callq 0xffffffffff7763d8
26: fb sti
27: 45 85 f6 test %r14d,%r14d
2a:* 0f 88 fb 00 00 00 js 0x12b <-- trapping instruction
30: 49 63 c6 movslq %r14d,%rax
33: 4c 2b 2c 24 sub (%rsp),%r13
37: 48 8d 14 40 lea (%rax,%rax,2),%rdx
3b: 48 8d 14 90 lea (%rax,%rdx,4),%rdx
3f: 49 rex.WB

Code starting with the faulting instruction
===========================================
0: 0f 88 fb 00 00 00 js 0x101
6: 49 63 c6 movslq %r14d,%rax
9: 4c 2b 2c 24 sub (%rsp),%r13
d: 48 8d 14 40 lea (%rax,%rax,2),%rdx
11: 48 8d 14 90 lea (%rax,%rdx,4),%rdx
15: 49 rex.WB
[ 58.116066][ C2] RSP: 0018:ffffc9000009fe80 EFLAGS: 00000202
[ 58.116068][ C2] RAX: ffff8881e292bd00 RBX: 0000000000000002 RCX: 000000000000001f
[ 58.116601][ T340] target ucode: 0x21
[ 58.116677][ C2] RDX: 0000000000000000 RSI: 0000000026e04163 RDI: 0000000000000000
[ 58.116679][ C2] RBP: ffff8881e2935820 R08: 0000000d87e06d43 R09: 000000007fffffff
[ 58.116681][ C2] R10: 0000000000000030 R11: ffff8881e292aa44 R12: ffffffff82ce4860
[ 58.116784][ T340]
[ 58.116919][ C2] R13: 0000000d87e06d43 R14: 0000000000000002 R15: 0000000000000000
[ 58.117536][ C2] cpuidle_enter (drivers/cpuidle/cpuidle.c:353)
[ 58.117610][ C2] do_idle (kernel/sched/idle.c:243 kernel/sched/idle.c:306)
[ 58.117682][ C2] cpu_startup_entry (kernel/sched/idle.c:402 (discriminator 1))
[ 58.117770][ C2] start_secondary (arch/x86/kernel/smpboot.c:271)
[ 58.117853][ C2] secondary_startup_64_no_verify (arch/x86/kernel/head_64.S:283)
[ 58.117932][ T340] current_version: 21, target_version: 21
[ 58.117951][ T340]
[ 58.118994][ T340] 2021-08-13 00:43:40 dmsetup remove_all
[ 58.118997][ T340]
[ 58.120238][ T340] 2021-08-13 00:43:40 wipefs -a --force /dev/sda1
[ 58.120240][ T340]
[ 58.122084][ T340] /dev/sda1: 4 bytes were erased at offset 0x00000400 (f2fs): 10 20 f5 f2
[ 58.122086][ T340]
[ 58.123251][ T340] 2021-08-13 00:43:40 mkfs -t f2fs /dev/sda1
[ 58.123253][ T340]
[ 58.123405][ T340]
[ 58.123406][ T340]
[ 58.124599][ T340] F2FS-tools: mkfs.f2fs Ver: 1.11.0 (2018-07-10)
[ 58.124601][ T340]
[ 58.124766][ T340]
[ 58.124767][ T340]
[ 58.125567][ T340] Info: Disable heap-based policy
[ 58.125568][ T340]
[ 58.126187][ T340] Info: Debug level = 0
[ 58.126189][ T340]
[ 58.126628][ T340] Info: Label =
[ 58.126630][ T340]
[ 58.127220][ T340] Info: Trim is enabled
[ 58.127221][ T340]
[ 58.129066][ T340] Info: [/dev/sda1] Disk Model: ST1000DM003-1CH1CC49
[ 58.129068][ T340]
[ 58.129918][ T340] Info: Segments per section = 1
[ 58.129920][ T340]
[ 58.130679][ T340] Info: Sections per zone = 1
[ 58.130681][ T340]
[ 58.131329][ T340] Info: sector size = 512
[ 58.131331][ T340]
[ 58.132454][ T340] Info: total sectors = 419430400 (204800 MB)
[ 58.132456][ T340]
[ 58.133533][ T340] Info: zone aligned segment0 blkaddr: 512
[ 58.133534][ T340]
[ 58.134256][ T340] Info: format version with
[ 58.134258][ T340]
[ 58.139019][ T340] "Linux version 5.14.0-rc5-00023-g5b4904cded4b (kbuild@0aad27be3742) (gcc-9 (Debian 9.3.0-22) 9.3.0, GNU ld (GNU Binutils for Debian) 2.35.2) #1 SMP Fri Aug 13 08:04:18 CST 2021"
[ 58.139022][ T340]
[ 58.140179][ T340] Info: [/dev/sda1] Discarding device
[ 58.140182][ T340]
[ 58.141419][ T340] Info: This device doesn't support BLKSECDISCARD
[ 58.141421][ T340]
[ 58.142601][ T340] Info: This device doesn't support BLKDISCARD
[ 58.142603][ T340]
[ 58.143540][ T340] Info: Overprovision ratio = 0.440%
[ 58.143541][ T340]
[ 58.144944][ T340] Info: Overprovision segments = 909 (GC reserved = 462)
[ 58.144946][ T340]
[ 58.145633][ T340] Info: format successful
[ 58.145634][ T340]
[ 58.146610][ T340] 2021-08-13 00:43:41 mkdir -p /fs/sda1
[ 58.146612][ T340]
[ 58.146878][ T340] f2fs
[ 58.146880][ T340]
[ 58.148188][ T340] 2021-08-13 00:43:41 mount -t f2fs /dev/sda1 /fs/sda1
[ 58.148190][ T340]
[ 58.149853][ T340] 2021-08-13 00:43:42 ln -sf /usr/bin/genisoimage /usr/bin/mkisofs
[ 58.149855][ T340]
[ 58.151267][ T340] 2021-08-13 00:43:42 ./runltp -f io -d /fs/sda1/tmpdir
[ 58.151269][ T340]


To reproduce:

git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
bin/lkp install job.yaml # job file is attached in this email
bin/lkp split-job --compatible job.yaml # generate the yaml file for lkp run
bin/lkp run generated-yaml-file



---
0DAY/LKP+ Test Infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation

Thanks,
Oliver Sang


Attachments:
(No filename) (36.61 kB)
config-5.14.0-rc5-00023-g5b4904cded4b (178.15 kB)
job-script (5.81 kB)
dmesg.xz (6.25 kB)
ltp (6.92 kB)
job.yaml (4.71 kB)
reproduce (207.00 B)
Download all attachments

2021-08-13 06:56:51

by Heiner Kallweit

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] r8169: Implement dynamic ASPM mechanism

On 12.08.2021 17:53, Kai-Heng Feng wrote:
> r8169 NICs on some platforms have abysmal speed when ASPM is enabled.
> Same issue can be observed with older vendor drivers.
>
> The issue is however solved by the latest vendor driver. There's a new
> mechanism, which disables r8169's internal ASPM when the NIC traffic has
> more than 10 packets, and vice versa.
>
> Realtek confirmed that all their PCIe LAN NICs, r8106, r8168 and r8125

As we have Realtek in this mail thread:
Typically hw issues affect 1-3 chip versions only. The ASPM problems seem
to have been existing for at least 15 years now, in every chip version.
It seems that even the new RTL8125 chip generation still has broken ASPM.
Why was this never fixed? ASPM not considered to be relevant? HW design
too broken?

> use dynamic ASPM under Windows. So implement the same mechanism here to
> resolve the issue.
>
> Signed-off-by: Kai-Heng Feng <[email protected]>
> ---
> v2:
> - Use delayed_work instead of timer_list to avoid interrupt context
> - Use mutex to serialize packet counter read/write
> - Wording change
>
> drivers/net/ethernet/realtek/r8169_main.c | 45 +++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index c7af5bc3b8af..7ab2e841dc69 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -624,6 +624,11 @@ struct rtl8169_private {
>
> unsigned supports_gmii:1;
> unsigned aspm_manageable:1;
> + unsigned aspm_enabled:1;
> + struct delayed_work aspm_toggle;
> + struct mutex aspm_mutex;
> + u32 aspm_packet_count;
> +
> dma_addr_t counters_phys_addr;
> struct rtl8169_counters *counters;
> struct rtl8169_tc_offsets tc_offset;
> @@ -2671,6 +2676,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable)
> RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~ASPM_en);
> }
>
> + tp->aspm_enabled = enable;
> +
> udelay(10);
> }
>
> @@ -4408,6 +4415,9 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
>
> dirty_tx = tp->dirty_tx;
>
> + mutex_lock(&tp->aspm_mutex);
> + tp->aspm_packet_count += tp->cur_tx - dirty_tx;
> + mutex_unlock(&tp->aspm_mutex);
> while (READ_ONCE(tp->cur_tx) != dirty_tx) {
> unsigned int entry = dirty_tx % NUM_TX_DESC;
> u32 status;
> @@ -4552,6 +4562,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, int budget
> rtl8169_mark_to_asic(desc);
> }
>
> + mutex_lock(&tp->aspm_mutex);
> + tp->aspm_packet_count += count;
> + mutex_unlock(&tp->aspm_mutex);
> +
> return count;
> }
>
> @@ -4659,8 +4673,33 @@ static int r8169_phy_connect(struct rtl8169_private *tp)
> return 0;
> }
>
> +#define ASPM_PACKET_THRESHOLD 10
> +#define ASPM_TOGGLE_INTERVAL 1000
> +
> +static void rtl8169_aspm_toggle(struct work_struct *work)
> +{
> + struct rtl8169_private *tp = container_of(work, struct rtl8169_private,
> + aspm_toggle.work);
> + bool enable;
> +
> + mutex_lock(&tp->aspm_mutex);
> + enable = tp->aspm_packet_count <= ASPM_PACKET_THRESHOLD;
> + tp->aspm_packet_count = 0;
> + mutex_unlock(&tp->aspm_mutex);
> +
> + if (tp->aspm_enabled != enable) {
> + rtl_unlock_config_regs(tp);
> + rtl_hw_aspm_clkreq_enable(tp, enable);
> + rtl_lock_config_regs(tp);
> + }
> +
> + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
> +}
> +
> static void rtl8169_down(struct rtl8169_private *tp)
> {
> + cancel_delayed_work_sync(&tp->aspm_toggle);
> +
> /* Clear all task flags */
> bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);
>
> @@ -4687,6 +4726,8 @@ static void rtl8169_up(struct rtl8169_private *tp)
> rtl_reset_work(tp);
>
> phy_start(tp->phydev);
> +
> + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
> }
>
> static int rtl8169_close(struct net_device *dev)
> @@ -5347,6 +5388,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>
> INIT_WORK(&tp->wk.work, rtl_task);
>
> + INIT_DELAYED_WORK(&tp->aspm_toggle, rtl8169_aspm_toggle);
> +
> + mutex_init(&tp->aspm_mutex);
> +
> rtl_init_mac_address(tp);
>
> dev->ethtool_ops = &rtl8169_ethtool_ops;
>

2021-08-13 10:07:20

by Kai-Heng Feng

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] r8169: Implement dynamic ASPM mechanism

j

On Fri, Aug 13, 2021 at 3:39 AM Heiner Kallweit <[email protected]> wrote:
>
> On 12.08.2021 17:53, Kai-Heng Feng wrote:
> > r8169 NICs on some platforms have abysmal speed when ASPM is enabled.
> > Same issue can be observed with older vendor drivers.
> >
> > The issue is however solved by the latest vendor driver. There's a new
> > mechanism, which disables r8169's internal ASPM when the NIC traffic has
> > more than 10 packets, and vice versa.
> >
> > Realtek confirmed that all their PCIe LAN NICs, r8106, r8168 and r8125
> > use dynamic ASPM under Windows. So implement the same mechanism here to
> > resolve the issue.
> >
> Realtek using something in their Windows drivers isn't really a proof of
> quality.

I agree. So it'll be great if Realtek can work with us here.

> Still my concerns haven't been addressed. If ASPM is enabled and
> there's a congestion in the chip it may take up to a second until ASPM
> gets disabled. In this second traffic very likely is heavily affected.
> Who takes care in case of problem reports?

I think we'll know that once the patch is merged in downstream kernel.

>
> This is a massive change for basically all chip versions. And experience
> shows that in case of problem reports Realtek never cares, even though
> they are listed as maintainers. All I see is that they copy more and more
> code from r8169 into their own drivers. This seems to indicate that they
> consider quality of their own drivers as not sufficient.

I wonder why they don't want to put their efforts to r8169...
Obviously they are doing a great job for rtw88 and r8152.

>
> Still my proposal: Apply this downstream, and if there are no complaints
> after a few months it may be considered for mainline.

Yes that's my plan. But I'd still like it to be reviewed before
putting it to the downstream kernel.

>
> Last but not least the formal issues:
> - no cover letter

Will write it up once it's tested dowstream.

> - no net/net-next annotation

Does it mean put "net/net-next" in the subject line?


>
> > Signed-off-by: Kai-Heng Feng <[email protected]>
> > ---
> > v2:
> > - Use delayed_work instead of timer_list to avoid interrupt context
> > - Use mutex to serialize packet counter read/write
> > - Wording change
> >
> > drivers/net/ethernet/realtek/r8169_main.c | 45 +++++++++++++++++++++++
> > 1 file changed, 45 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> > index c7af5bc3b8af..7ab2e841dc69 100644
> > --- a/drivers/net/ethernet/realtek/r8169_main.c
> > +++ b/drivers/net/ethernet/realtek/r8169_main.c
> > @@ -624,6 +624,11 @@ struct rtl8169_private {
> >
> > unsigned supports_gmii:1;
> > unsigned aspm_manageable:1;
> > + unsigned aspm_enabled:1;
> > + struct delayed_work aspm_toggle;
> > + struct mutex aspm_mutex;
> > + u32 aspm_packet_count;
> > +
> > dma_addr_t counters_phys_addr;
> > struct rtl8169_counters *counters;
> > struct rtl8169_tc_offsets tc_offset;
> > @@ -2671,6 +2676,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable)
> > RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~ASPM_en);
> > }
> >
> > + tp->aspm_enabled = enable;
> > +
> > udelay(10);
> > }
> >
> > @@ -4408,6 +4415,9 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
> >
> > dirty_tx = tp->dirty_tx;
> >
> > + mutex_lock(&tp->aspm_mutex);
>
> We are in soft irq context here, therefore you shouldn't sleep.

I thought napi_poll is not using softirq, apparent I was wrong. Will
correct it too.

>
> > + tp->aspm_packet_count += tp->cur_tx - dirty_tx;
> > + mutex_unlock(&tp->aspm_mutex);
> > while (READ_ONCE(tp->cur_tx) != dirty_tx) {
> > unsigned int entry = dirty_tx % NUM_TX_DESC;
> > u32 status;
> > @@ -4552,6 +4562,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, int budget
> > rtl8169_mark_to_asic(desc);
> > }
> >
> > + mutex_lock(&tp->aspm_mutex);
> > + tp->aspm_packet_count += count;
> > + mutex_unlock(&tp->aspm_mutex);
> > +
> > return count;
> > }
> >
> > @@ -4659,8 +4673,33 @@ static int r8169_phy_connect(struct rtl8169_private *tp)
> > return 0;
> > }
> >
> > +#define ASPM_PACKET_THRESHOLD 10
> > +#define ASPM_TOGGLE_INTERVAL 1000
> > +
> > +static void rtl8169_aspm_toggle(struct work_struct *work)
> > +{
> > + struct rtl8169_private *tp = container_of(work, struct rtl8169_private,
> > + aspm_toggle.work);
> > + bool enable;
> > +
> > + mutex_lock(&tp->aspm_mutex);
> > + enable = tp->aspm_packet_count <= ASPM_PACKET_THRESHOLD;
> > + tp->aspm_packet_count = 0;
> > + mutex_unlock(&tp->aspm_mutex);
> > +
> > + if (tp->aspm_enabled != enable) {
> > + rtl_unlock_config_regs(tp);
> > + rtl_hw_aspm_clkreq_enable(tp, enable);
> > + rtl_lock_config_regs(tp);
> > + }
> > +
> > + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
> > +}
> > +
> > static void rtl8169_down(struct rtl8169_private *tp)
> > {
> > + cancel_delayed_work_sync(&tp->aspm_toggle);
> > +
> > /* Clear all task flags */
> > bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);
> >
> > @@ -4687,6 +4726,8 @@ static void rtl8169_up(struct rtl8169_private *tp)
> > rtl_reset_work(tp);
> >
> > phy_start(tp->phydev);
> > +
> > + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
>
> In the first version you used msecs_to_jiffies(ASPM_TIMER_INTERVAL).
> Now you use 1000 jiffies what is a major difference.

msecs_to_jiffies() was omitted. Will correct it.

Kai-Heng

>
> > }
> >
> > static int rtl8169_close(struct net_device *dev)
> > @@ -5347,6 +5388,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> >
> > INIT_WORK(&tp->wk.work, rtl_task);
> >
> > + INIT_DELAYED_WORK(&tp->aspm_toggle, rtl8169_aspm_toggle);
> > +
> > + mutex_init(&tp->aspm_mutex);
> > +
> > rtl_init_mac_address(tp);
> >
> > dev->ethtool_ops = &rtl8169_ethtool_ops;
> >
>

2021-08-13 10:07:32

by Kai-Heng Feng

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] r8169: Implement dynamic ASPM mechanism

On Fri, Aug 13, 2021 at 2:49 PM Heiner Kallweit <[email protected]> wrote:
>
> On 12.08.2021 17:53, Kai-Heng Feng wrote:
> > r8169 NICs on some platforms have abysmal speed when ASPM is enabled.
> > Same issue can be observed with older vendor drivers.
> >
> > The issue is however solved by the latest vendor driver. There's a new
> > mechanism, which disables r8169's internal ASPM when the NIC traffic has
> > more than 10 packets, and vice versa.
> >
> > Realtek confirmed that all their PCIe LAN NICs, r8106, r8168 and r8125
>
> As we have Realtek in this mail thread:

Is it still in active use? I always think it's just a dummy address...

> Typically hw issues affect 1-3 chip versions only. The ASPM problems seem
> to have been existing for at least 15 years now, in every chip version.
> It seems that even the new RTL8125 chip generation still has broken ASPM.

Is there a bug report for that?

> Why was this never fixed? ASPM not considered to be relevant? HW design
> too broken?

IIUC, ASPM is extremely relevant to pass EU/US power consumption
regulation. So I really don't know why the situation under Linux is so
dire.

Kai-Heng

>
> > use dynamic ASPM under Windows. So implement the same mechanism here to
> > resolve the issue.
> >
> > Signed-off-by: Kai-Heng Feng <[email protected]>
> > ---
> > v2:
> > - Use delayed_work instead of timer_list to avoid interrupt context
> > - Use mutex to serialize packet counter read/write
> > - Wording change
> >
> > drivers/net/ethernet/realtek/r8169_main.c | 45 +++++++++++++++++++++++
> > 1 file changed, 45 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> > index c7af5bc3b8af..7ab2e841dc69 100644
> > --- a/drivers/net/ethernet/realtek/r8169_main.c
> > +++ b/drivers/net/ethernet/realtek/r8169_main.c
> > @@ -624,6 +624,11 @@ struct rtl8169_private {
> >
> > unsigned supports_gmii:1;
> > unsigned aspm_manageable:1;
> > + unsigned aspm_enabled:1;
> > + struct delayed_work aspm_toggle;
> > + struct mutex aspm_mutex;
> > + u32 aspm_packet_count;
> > +
> > dma_addr_t counters_phys_addr;
> > struct rtl8169_counters *counters;
> > struct rtl8169_tc_offsets tc_offset;
> > @@ -2671,6 +2676,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable)
> > RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~ASPM_en);
> > }
> >
> > + tp->aspm_enabled = enable;
> > +
> > udelay(10);
> > }
> >
> > @@ -4408,6 +4415,9 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
> >
> > dirty_tx = tp->dirty_tx;
> >
> > + mutex_lock(&tp->aspm_mutex);
> > + tp->aspm_packet_count += tp->cur_tx - dirty_tx;
> > + mutex_unlock(&tp->aspm_mutex);
> > while (READ_ONCE(tp->cur_tx) != dirty_tx) {
> > unsigned int entry = dirty_tx % NUM_TX_DESC;
> > u32 status;
> > @@ -4552,6 +4562,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, int budget
> > rtl8169_mark_to_asic(desc);
> > }
> >
> > + mutex_lock(&tp->aspm_mutex);
> > + tp->aspm_packet_count += count;
> > + mutex_unlock(&tp->aspm_mutex);
> > +
> > return count;
> > }
> >
> > @@ -4659,8 +4673,33 @@ static int r8169_phy_connect(struct rtl8169_private *tp)
> > return 0;
> > }
> >
> > +#define ASPM_PACKET_THRESHOLD 10
> > +#define ASPM_TOGGLE_INTERVAL 1000
> > +
> > +static void rtl8169_aspm_toggle(struct work_struct *work)
> > +{
> > + struct rtl8169_private *tp = container_of(work, struct rtl8169_private,
> > + aspm_toggle.work);
> > + bool enable;
> > +
> > + mutex_lock(&tp->aspm_mutex);
> > + enable = tp->aspm_packet_count <= ASPM_PACKET_THRESHOLD;
> > + tp->aspm_packet_count = 0;
> > + mutex_unlock(&tp->aspm_mutex);
> > +
> > + if (tp->aspm_enabled != enable) {
> > + rtl_unlock_config_regs(tp);
> > + rtl_hw_aspm_clkreq_enable(tp, enable);
> > + rtl_lock_config_regs(tp);
> > + }
> > +
> > + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
> > +}
> > +
> > static void rtl8169_down(struct rtl8169_private *tp)
> > {
> > + cancel_delayed_work_sync(&tp->aspm_toggle);
> > +
> > /* Clear all task flags */
> > bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);
> >
> > @@ -4687,6 +4726,8 @@ static void rtl8169_up(struct rtl8169_private *tp)
> > rtl_reset_work(tp);
> >
> > phy_start(tp->phydev);
> > +
> > + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
> > }
> >
> > static int rtl8169_close(struct net_device *dev)
> > @@ -5347,6 +5388,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> >
> > INIT_WORK(&tp->wk.work, rtl_task);
> >
> > + INIT_DELAYED_WORK(&tp->aspm_toggle, rtl8169_aspm_toggle);
> > +
> > + mutex_init(&tp->aspm_mutex);
> > +
> > rtl_init_mac_address(tp);
> >
> > dev->ethtool_ops = &rtl8169_ethtool_ops;
> >
>

2021-08-14 11:36:51

by Heiner Kallweit

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] r8169: Implement dynamic ASPM mechanism

On 13.08.2021 11:54, Kai-Heng Feng wrote:
> On Fri, Aug 13, 2021 at 2:49 PM Heiner Kallweit <[email protected]> wrote:
>>
>> On 12.08.2021 17:53, Kai-Heng Feng wrote:
>>> r8169 NICs on some platforms have abysmal speed when ASPM is enabled.
>>> Same issue can be observed with older vendor drivers.
>>>
>>> The issue is however solved by the latest vendor driver. There's a new
>>> mechanism, which disables r8169's internal ASPM when the NIC traffic has
>>> more than 10 packets, and vice versa.
>>>
>>> Realtek confirmed that all their PCIe LAN NICs, r8106, r8168 and r8125
>>
>> As we have Realtek in this mail thread:
>
> Is it still in active use? I always think it's just a dummy address...
At least mails to this address are not bounced, and this address still is
in MAINTAINERS. But right, I've never any reaction on mails to this
address. So it may make sense to remove it from MAINTAINERS.
Not sure what the process would be to do this.

>
>> Typically hw issues affect 1-3 chip versions only. The ASPM problems seem
>> to have been existing for at least 15 years now, in every chip version.
>> It seems that even the new RTL8125 chip generation still has broken ASPM.
>
> Is there a bug report for that?
>
No. This was referring to your statement that also r8125 vendor driver
includes this "dynamic ASPM" workaround. They wouldn't have done this
if RTL8125 had proper ASPM support, or?

>> Why was this never fixed? ASPM not considered to be relevant? HW design
>> too broken?
>
> IIUC, ASPM is extremely relevant to pass EU/US power consumption
> regulation. So I really don't know why the situation under Linux is so
> dire.
>
It's not something related to Linux, ASPM support in the Realtek chips
is simply broken. This needs to be fixed in HW.
The behavior we see may indicate that certain buffers in the chips are
too small to buffer traffic for full period of ASPM exit latency.

> Kai-Heng
>
>>
>>> use dynamic ASPM under Windows. So implement the same mechanism here to
>>> resolve the issue.
>>>
>>> Signed-off-by: Kai-Heng Feng <[email protected]>
>>> ---
>>> v2:
>>> - Use delayed_work instead of timer_list to avoid interrupt context
>>> - Use mutex to serialize packet counter read/write
>>> - Wording change
>>>
>>> drivers/net/ethernet/realtek/r8169_main.c | 45 +++++++++++++++++++++++
>>> 1 file changed, 45 insertions(+)
>>>
>>> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
>>> index c7af5bc3b8af..7ab2e841dc69 100644
>>> --- a/drivers/net/ethernet/realtek/r8169_main.c
>>> +++ b/drivers/net/ethernet/realtek/r8169_main.c
>>> @@ -624,6 +624,11 @@ struct rtl8169_private {
>>>
>>> unsigned supports_gmii:1;
>>> unsigned aspm_manageable:1;
>>> + unsigned aspm_enabled:1;
>>> + struct delayed_work aspm_toggle;
>>> + struct mutex aspm_mutex;
>>> + u32 aspm_packet_count;
>>> +
>>> dma_addr_t counters_phys_addr;
>>> struct rtl8169_counters *counters;
>>> struct rtl8169_tc_offsets tc_offset;
>>> @@ -2671,6 +2676,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable)
>>> RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~ASPM_en);
>>> }
>>>
>>> + tp->aspm_enabled = enable;
>>> +
>>> udelay(10);
>>> }
>>>
>>> @@ -4408,6 +4415,9 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
>>>
>>> dirty_tx = tp->dirty_tx;
>>>
>>> + mutex_lock(&tp->aspm_mutex);
>>> + tp->aspm_packet_count += tp->cur_tx - dirty_tx;
>>> + mutex_unlock(&tp->aspm_mutex);
>>> while (READ_ONCE(tp->cur_tx) != dirty_tx) {
>>> unsigned int entry = dirty_tx % NUM_TX_DESC;
>>> u32 status;
>>> @@ -4552,6 +4562,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, int budget
>>> rtl8169_mark_to_asic(desc);
>>> }
>>>
>>> + mutex_lock(&tp->aspm_mutex);
>>> + tp->aspm_packet_count += count;
>>> + mutex_unlock(&tp->aspm_mutex);
>>> +
>>> return count;
>>> }
>>>
>>> @@ -4659,8 +4673,33 @@ static int r8169_phy_connect(struct rtl8169_private *tp)
>>> return 0;
>>> }
>>>
>>> +#define ASPM_PACKET_THRESHOLD 10
>>> +#define ASPM_TOGGLE_INTERVAL 1000
>>> +
>>> +static void rtl8169_aspm_toggle(struct work_struct *work)
>>> +{
>>> + struct rtl8169_private *tp = container_of(work, struct rtl8169_private,
>>> + aspm_toggle.work);
>>> + bool enable;
>>> +
>>> + mutex_lock(&tp->aspm_mutex);
>>> + enable = tp->aspm_packet_count <= ASPM_PACKET_THRESHOLD;
>>> + tp->aspm_packet_count = 0;
>>> + mutex_unlock(&tp->aspm_mutex);
>>> +
>>> + if (tp->aspm_enabled != enable) {
>>> + rtl_unlock_config_regs(tp);
>>> + rtl_hw_aspm_clkreq_enable(tp, enable);
>>> + rtl_lock_config_regs(tp);
>>> + }
>>> +
>>> + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
>>> +}
>>> +
>>> static void rtl8169_down(struct rtl8169_private *tp)
>>> {
>>> + cancel_delayed_work_sync(&tp->aspm_toggle);
>>> +
>>> /* Clear all task flags */
>>> bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);
>>>
>>> @@ -4687,6 +4726,8 @@ static void rtl8169_up(struct rtl8169_private *tp)
>>> rtl_reset_work(tp);
>>>
>>> phy_start(tp->phydev);
>>> +
>>> + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
>>> }
>>>
>>> static int rtl8169_close(struct net_device *dev)
>>> @@ -5347,6 +5388,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>>>
>>> INIT_WORK(&tp->wk.work, rtl_task);
>>>
>>> + INIT_DELAYED_WORK(&tp->aspm_toggle, rtl8169_aspm_toggle);
>>> +
>>> + mutex_init(&tp->aspm_mutex);
>>> +
>>> rtl_init_mac_address(tp);
>>>
>>> dev->ethtool_ops = &rtl8169_ethtool_ops;
>>>
>>

2021-08-14 11:37:07

by Heiner Kallweit

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] r8169: Implement dynamic ASPM mechanism

On 13.08.2021 11:46, Kai-Heng Feng wrote:
> j
>
> On Fri, Aug 13, 2021 at 3:39 AM Heiner Kallweit <[email protected]> wrote:
>>
>> On 12.08.2021 17:53, Kai-Heng Feng wrote:
>>> r8169 NICs on some platforms have abysmal speed when ASPM is enabled.
>>> Same issue can be observed with older vendor drivers.
>>>
>>> The issue is however solved by the latest vendor driver. There's a new
>>> mechanism, which disables r8169's internal ASPM when the NIC traffic has
>>> more than 10 packets, and vice versa.
>>>
>>> Realtek confirmed that all their PCIe LAN NICs, r8106, r8168 and r8125
>>> use dynamic ASPM under Windows. So implement the same mechanism here to
>>> resolve the issue.
>>>
>> Realtek using something in their Windows drivers isn't really a proof of
>> quality.
>
> I agree. So it'll be great if Realtek can work with us here.
>
>> Still my concerns haven't been addressed. If ASPM is enabled and
>> there's a congestion in the chip it may take up to a second until ASPM
>> gets disabled. In this second traffic very likely is heavily affected.
>> Who takes care in case of problem reports?
>
> I think we'll know that once the patch is merged in downstream kernel.
>
>>
>> This is a massive change for basically all chip versions. And experience
>> shows that in case of problem reports Realtek never cares, even though
>> they are listed as maintainers. All I see is that they copy more and more
>> code from r8169 into their own drivers. This seems to indicate that they
>> consider quality of their own drivers as not sufficient.
>
> I wonder why they don't want to put their efforts to r8169...
> Obviously they are doing a great job for rtw88 and r8152.
>
>>
>> Still my proposal: Apply this downstream, and if there are no complaints
>> after a few months it may be considered for mainline.
>
> Yes that's my plan. But I'd still like it to be reviewed before
> putting it to the downstream kernel.
>
>>
>> Last but not least the formal issues:
>> - no cover letter
>
> Will write it up once it's tested dowstream.
>
>> - no net/net-next annotation
>
> Does it mean put "net/net-next" in the subject line?
>

https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html#how-do-i-indicate-which-tree-net-vs-net-next-my-patch-should-be-in

>
>>
>>> Signed-off-by: Kai-Heng Feng <[email protected]>
>>> ---
>>> v2:
>>> - Use delayed_work instead of timer_list to avoid interrupt context
>>> - Use mutex to serialize packet counter read/write
>>> - Wording change
>>>
>>> drivers/net/ethernet/realtek/r8169_main.c | 45 +++++++++++++++++++++++
>>> 1 file changed, 45 insertions(+)
>>>
>>> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
>>> index c7af5bc3b8af..7ab2e841dc69 100644
>>> --- a/drivers/net/ethernet/realtek/r8169_main.c
>>> +++ b/drivers/net/ethernet/realtek/r8169_main.c
>>> @@ -624,6 +624,11 @@ struct rtl8169_private {
>>>
>>> unsigned supports_gmii:1;
>>> unsigned aspm_manageable:1;
>>> + unsigned aspm_enabled:1;
>>> + struct delayed_work aspm_toggle;
>>> + struct mutex aspm_mutex;
>>> + u32 aspm_packet_count;
>>> +
>>> dma_addr_t counters_phys_addr;
>>> struct rtl8169_counters *counters;
>>> struct rtl8169_tc_offsets tc_offset;
>>> @@ -2671,6 +2676,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable)
>>> RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~ASPM_en);
>>> }
>>>
>>> + tp->aspm_enabled = enable;
>>> +
>>> udelay(10);
>>> }
>>>
>>> @@ -4408,6 +4415,9 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
>>>
>>> dirty_tx = tp->dirty_tx;
>>>
>>> + mutex_lock(&tp->aspm_mutex);
>>
>> We are in soft irq context here, therefore you shouldn't sleep.
>
> I thought napi_poll is not using softirq, apparent I was wrong. Will
> correct it too.
>
I saw an automated mail from a test bot to you complaining about this.

>>
>>> + tp->aspm_packet_count += tp->cur_tx - dirty_tx;
>>> + mutex_unlock(&tp->aspm_mutex);
>>> while (READ_ONCE(tp->cur_tx) != dirty_tx) {
>>> unsigned int entry = dirty_tx % NUM_TX_DESC;
>>> u32 status;
>>> @@ -4552,6 +4562,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, int budget
>>> rtl8169_mark_to_asic(desc);
>>> }
>>>
>>> + mutex_lock(&tp->aspm_mutex);
>>> + tp->aspm_packet_count += count;
>>> + mutex_unlock(&tp->aspm_mutex);
>>> +
>>> return count;
>>> }
>>>
>>> @@ -4659,8 +4673,33 @@ static int r8169_phy_connect(struct rtl8169_private *tp)
>>> return 0;
>>> }
>>>
>>> +#define ASPM_PACKET_THRESHOLD 10
>>> +#define ASPM_TOGGLE_INTERVAL 1000
>>> +
>>> +static void rtl8169_aspm_toggle(struct work_struct *work)
>>> +{
>>> + struct rtl8169_private *tp = container_of(work, struct rtl8169_private,
>>> + aspm_toggle.work);
>>> + bool enable;
>>> +
>>> + mutex_lock(&tp->aspm_mutex);
>>> + enable = tp->aspm_packet_count <= ASPM_PACKET_THRESHOLD;
>>> + tp->aspm_packet_count = 0;
>>> + mutex_unlock(&tp->aspm_mutex);
>>> +
>>> + if (tp->aspm_enabled != enable) {
>>> + rtl_unlock_config_regs(tp);
>>> + rtl_hw_aspm_clkreq_enable(tp, enable);
>>> + rtl_lock_config_regs(tp);
>>> + }
>>> +
>>> + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
>>> +}
>>> +
>>> static void rtl8169_down(struct rtl8169_private *tp)
>>> {
>>> + cancel_delayed_work_sync(&tp->aspm_toggle);
>>> +
>>> /* Clear all task flags */
>>> bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);
>>>
>>> @@ -4687,6 +4726,8 @@ static void rtl8169_up(struct rtl8169_private *tp)
>>> rtl_reset_work(tp);
>>>
>>> phy_start(tp->phydev);
>>> +
>>> + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
>>
>> In the first version you used msecs_to_jiffies(ASPM_TIMER_INTERVAL).
>> Now you use 1000 jiffies what is a major difference.
>
> msecs_to_jiffies() was omitted. Will correct it.
>
> Kai-Heng
>
>>
>>> }
>>>
>>> static int rtl8169_close(struct net_device *dev)
>>> @@ -5347,6 +5388,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>>>
>>> INIT_WORK(&tp->wk.work, rtl_task);
>>>
>>> + INIT_DELAYED_WORK(&tp->aspm_toggle, rtl8169_aspm_toggle);
>>> +
>>> + mutex_init(&tp->aspm_mutex);
>>> +
>>> rtl_init_mac_address(tp);
>>>
>>> dev->ethtool_ops = &rtl8169_ethtool_ops;
>>>
>>

2021-08-19 03:13:37

by Kai-Heng Feng

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] r8169: Implement dynamic ASPM mechanism

On Sat, Aug 14, 2021 at 7:34 PM Heiner Kallweit <[email protected]> wrote:
>
> On 13.08.2021 11:54, Kai-Heng Feng wrote:
> > On Fri, Aug 13, 2021 at 2:49 PM Heiner Kallweit <[email protected]> wrote:
> >>
> >> On 12.08.2021 17:53, Kai-Heng Feng wrote:
> >>> r8169 NICs on some platforms have abysmal speed when ASPM is enabled.
> >>> Same issue can be observed with older vendor drivers.
> >>>
> >>> The issue is however solved by the latest vendor driver. There's a new
> >>> mechanism, which disables r8169's internal ASPM when the NIC traffic has
> >>> more than 10 packets, and vice versa.
> >>>
> >>> Realtek confirmed that all their PCIe LAN NICs, r8106, r8168 and r8125
> >>
> >> As we have Realtek in this mail thread:
> >
> > Is it still in active use? I always think it's just a dummy address...
> At least mails to this address are not bounced, and this address still is
> in MAINTAINERS. But right, I've never any reaction on mails to this
> address. So it may make sense to remove it from MAINTAINERS.
> Not sure what the process would be to do this.
>
> >
> >> Typically hw issues affect 1-3 chip versions only. The ASPM problems seem
> >> to have been existing for at least 15 years now, in every chip version.
> >> It seems that even the new RTL8125 chip generation still has broken ASPM.
> >
> > Is there a bug report for that?
> >
> No. This was referring to your statement that also r8125 vendor driver
> includes this "dynamic ASPM" workaround. They wouldn't have done this
> if RTL8125 had proper ASPM support, or?

They call it "performance tuning".

>
> >> Why was this never fixed? ASPM not considered to be relevant? HW design
> >> too broken?
> >
> > IIUC, ASPM is extremely relevant to pass EU/US power consumption
> > regulation. So I really don't know why the situation under Linux is so
> > dire.
> >
> It's not something related to Linux, ASPM support in the Realtek chips
> is simply broken. This needs to be fixed in HW.
> The behavior we see may indicate that certain buffers in the chips are
> too small to buffer traffic for full period of ASPM exit latency.

The smaller buffers is part of the reason why they are dirt cheap and
makes them so pervasive...
So the dynamic ASPM is actually a good thing because it can deal with
this defect and saves power at the same time.

Kai-Heng

>
> > Kai-Heng
> >
> >>
> >>> use dynamic ASPM under Windows. So implement the same mechanism here to
> >>> resolve the issue.
> >>>
> >>> Signed-off-by: Kai-Heng Feng <[email protected]>
> >>> ---
> >>> v2:
> >>> - Use delayed_work instead of timer_list to avoid interrupt context
> >>> - Use mutex to serialize packet counter read/write
> >>> - Wording change
> >>>
> >>> drivers/net/ethernet/realtek/r8169_main.c | 45 +++++++++++++++++++++++
> >>> 1 file changed, 45 insertions(+)
> >>>
> >>> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> >>> index c7af5bc3b8af..7ab2e841dc69 100644
> >>> --- a/drivers/net/ethernet/realtek/r8169_main.c
> >>> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> >>> @@ -624,6 +624,11 @@ struct rtl8169_private {
> >>>
> >>> unsigned supports_gmii:1;
> >>> unsigned aspm_manageable:1;
> >>> + unsigned aspm_enabled:1;
> >>> + struct delayed_work aspm_toggle;
> >>> + struct mutex aspm_mutex;
> >>> + u32 aspm_packet_count;
> >>> +
> >>> dma_addr_t counters_phys_addr;
> >>> struct rtl8169_counters *counters;
> >>> struct rtl8169_tc_offsets tc_offset;
> >>> @@ -2671,6 +2676,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable)
> >>> RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~ASPM_en);
> >>> }
> >>>
> >>> + tp->aspm_enabled = enable;
> >>> +
> >>> udelay(10);
> >>> }
> >>>
> >>> @@ -4408,6 +4415,9 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
> >>>
> >>> dirty_tx = tp->dirty_tx;
> >>>
> >>> + mutex_lock(&tp->aspm_mutex);
> >>> + tp->aspm_packet_count += tp->cur_tx - dirty_tx;
> >>> + mutex_unlock(&tp->aspm_mutex);
> >>> while (READ_ONCE(tp->cur_tx) != dirty_tx) {
> >>> unsigned int entry = dirty_tx % NUM_TX_DESC;
> >>> u32 status;
> >>> @@ -4552,6 +4562,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, int budget
> >>> rtl8169_mark_to_asic(desc);
> >>> }
> >>>
> >>> + mutex_lock(&tp->aspm_mutex);
> >>> + tp->aspm_packet_count += count;
> >>> + mutex_unlock(&tp->aspm_mutex);
> >>> +
> >>> return count;
> >>> }
> >>>
> >>> @@ -4659,8 +4673,33 @@ static int r8169_phy_connect(struct rtl8169_private *tp)
> >>> return 0;
> >>> }
> >>>
> >>> +#define ASPM_PACKET_THRESHOLD 10
> >>> +#define ASPM_TOGGLE_INTERVAL 1000
> >>> +
> >>> +static void rtl8169_aspm_toggle(struct work_struct *work)
> >>> +{
> >>> + struct rtl8169_private *tp = container_of(work, struct rtl8169_private,
> >>> + aspm_toggle.work);
> >>> + bool enable;
> >>> +
> >>> + mutex_lock(&tp->aspm_mutex);
> >>> + enable = tp->aspm_packet_count <= ASPM_PACKET_THRESHOLD;
> >>> + tp->aspm_packet_count = 0;
> >>> + mutex_unlock(&tp->aspm_mutex);
> >>> +
> >>> + if (tp->aspm_enabled != enable) {
> >>> + rtl_unlock_config_regs(tp);
> >>> + rtl_hw_aspm_clkreq_enable(tp, enable);
> >>> + rtl_lock_config_regs(tp);
> >>> + }
> >>> +
> >>> + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
> >>> +}
> >>> +
> >>> static void rtl8169_down(struct rtl8169_private *tp)
> >>> {
> >>> + cancel_delayed_work_sync(&tp->aspm_toggle);
> >>> +
> >>> /* Clear all task flags */
> >>> bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);
> >>>
> >>> @@ -4687,6 +4726,8 @@ static void rtl8169_up(struct rtl8169_private *tp)
> >>> rtl_reset_work(tp);
> >>>
> >>> phy_start(tp->phydev);
> >>> +
> >>> + schedule_delayed_work(&tp->aspm_toggle, ASPM_TOGGLE_INTERVAL);
> >>> }
> >>>
> >>> static int rtl8169_close(struct net_device *dev)
> >>> @@ -5347,6 +5388,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> >>>
> >>> INIT_WORK(&tp->wk.work, rtl_task);
> >>>
> >>> + INIT_DELAYED_WORK(&tp->aspm_toggle, rtl8169_aspm_toggle);
> >>> +
> >>> + mutex_init(&tp->aspm_mutex);
> >>> +
> >>> rtl_init_mac_address(tp);
> >>>
> >>> dev->ethtool_ops = &rtl8169_ethtool_ops;
> >>>
> >>
>