1
0
Fork 0
alistair23-linux/drivers/net/dsa/sja1105
Vladimir Oltean 3e8db7e560 net: dsa: sja1105: Fix sleeping while atomic in .port_hwtstamp_set
Currently this stack trace can be seen with CONFIG_DEBUG_ATOMIC_SLEEP=y:

[   41.568348] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:909
[   41.576757] in_atomic(): 1, irqs_disabled(): 0, pid: 208, name: ptp4l
[   41.583212] INFO: lockdep is turned off.
[   41.587123] CPU: 1 PID: 208 Comm: ptp4l Not tainted 5.3.0-rc6-01445-ge950f2d4bc7f-dirty #1827
[   41.599873] [<c0313d7c>] (unwind_backtrace) from [<c030e13c>] (show_stack+0x10/0x14)
[   41.607584] [<c030e13c>] (show_stack) from [<c1212d50>] (dump_stack+0xd4/0x100)
[   41.614863] [<c1212d50>] (dump_stack) from [<c037dfc8>] (___might_sleep+0x1c8/0x2b4)
[   41.622574] [<c037dfc8>] (___might_sleep) from [<c122ea90>] (__mutex_lock+0x48/0xab8)
[   41.630368] [<c122ea90>] (__mutex_lock) from [<c122f51c>] (mutex_lock_nested+0x1c/0x24)
[   41.638340] [<c122f51c>] (mutex_lock_nested) from [<c0c6fe08>] (sja1105_static_config_reload+0x30/0x27c)
[   41.647779] [<c0c6fe08>] (sja1105_static_config_reload) from [<c0c7015c>] (sja1105_hwtstamp_set+0x108/0x1cc)
[   41.657562] [<c0c7015c>] (sja1105_hwtstamp_set) from [<c0feb650>] (dev_ifsioc+0x18c/0x330)
[   41.665788] [<c0feb650>] (dev_ifsioc) from [<c0febbd8>] (dev_ioctl+0x320/0x6e8)
[   41.673064] [<c0febbd8>] (dev_ioctl) from [<c0f8b1f4>] (sock_ioctl+0x334/0x5e8)
[   41.680340] [<c0f8b1f4>] (sock_ioctl) from [<c05404a8>] (do_vfs_ioctl+0xb0/0xa10)
[   41.687789] [<c05404a8>] (do_vfs_ioctl) from [<c0540e3c>] (ksys_ioctl+0x34/0x58)
[   41.695151] [<c0540e3c>] (ksys_ioctl) from [<c0301000>] (ret_fast_syscall+0x0/0x28)
[   41.702768] Exception stack(0xe8495fa8 to 0xe8495ff0)
[   41.707796] 5fa0:                   beff4a8c 00000001 00000011 000089b0 beff4a8c beff4a80
[   41.715933] 5fc0: beff4a8c 00000001 0000000c 00000036 b6fa98c8 004e19c1 00000001 00000000
[   41.724069] 5fe0: 004dcedc beff4a6c 004c0738 b6e7af4c
[   41.729860] BUG: scheduling while atomic: ptp4l/208/0x00000002
[   41.735682] INFO: lockdep is turned off.

Enabling RX timestamping will logically disturb the fastpath (processing
of meta frames). Replace bool hwts_rx_en with a bit that is checked
atomically from the fastpath and temporarily unset from the sleepable
context during a change of the RX timestamping process (a destructive
operation anyways, requires switch reset).
If found unset, the fastpath (net/dsa/tag_sja1105.c) will just drop any
received meta frame and not take the meta_lock at all.

Fixes: a602afd200 ("net: dsa: sja1105: Expose PTP timestamping ioctls to userspace")
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-10-02 12:19:53 -04:00
..
Kconfig net: dsa: sja1105: Add dependency for NET_DSA_SJA1105_TAS 2019-09-21 19:41:19 -07:00
Makefile net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload 2019-09-16 21:32:58 +02:00
sja1105.h net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload 2019-09-16 21:32:58 +02:00
sja1105_clocking.c net: dsa: sja1105: Add RGMII delay support for P/Q/R/S chips 2019-06-09 20:06:54 -07:00
sja1105_dynamic_config.c net: dsa: sja1105: Add static config tables for scheduling 2019-09-16 21:32:57 +02:00
sja1105_dynamic_config.h net: dsa: sja1105: Plug in support for TCAM searches via the dynamic interface 2019-06-04 11:49:19 -07:00
sja1105_ethtool.c net: dsa: sja1105: Fix status initialization in sja1105_get_ethtool_stats 2019-05-07 12:20:46 -07:00
sja1105_main.c net: dsa: sja1105: Fix sleeping while atomic in .port_hwtstamp_set 2019-10-02 12:19:53 -04:00
sja1105_ptp.c net: dsa: sja1105: Really fix panic on unregistering PTP clock 2019-08-06 14:37:02 -07:00
sja1105_ptp.h net: dsa: sja1105: Add logic for TX timestamping 2019-06-08 15:20:40 -07:00
sja1105_spi.c net: dsa: sja1105: Prevent leaking memory 2019-09-30 17:24:43 -07:00
sja1105_static_config.c net: dsa: sja1105: Add static config tables for scheduling 2019-09-16 21:32:57 +02:00
sja1105_static_config.h net: dsa: sja1105: Add static config tables for scheduling 2019-09-16 21:32:57 +02:00
sja1105_tas.c net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload 2019-09-16 21:32:58 +02:00
sja1105_tas.h net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload 2019-09-16 21:32:58 +02:00