Commit Graph

16 Commits

Author SHA1 Message Date
INAGAKI Hiroshi
614bba0958 realtek: use irq_force_affinity on otto timer instead
After commit e0d2c59ee995 ("genirq: Always limit the affinity to online
CPUs", 5.10) on Linux, the cpumask passed to irq_set_affinity of irqchip
driver is limited to online CPUs. When irq_do_set_affinity called from
otto timer driver with only one secondary CPU, that CPU is not marked as
online yet, filtered out by cpu_online_mask and fall to error path.
Then, fail to set affinity for that CPU and it leads to instability of
timer on secondary CPU(s).

At least, RTL839x system will be affected.

log:

[   37.560020] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[   37.638025] rcu:     1-...!: (0 ticks this GP) idle=6ac/0/0x0 softirq=0/0 fqs=1  (false positive?)
[   37.752683]  (detected by 0, t=6002 jiffies, g=-1179, q=26293)
[   37.829510] Sending NMI from CPU 0 to CPUs 1:
[   37.886857] NMI backtrace for cpu 1 skipped: idling at r4k_wait_irqoff+0x1c/0x24
[   37.984801] rcu: rcu_sched kthread timer wakeup didn't happen for 5999 jiffies! g-1179 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402
[   38.132743] rcu:     Possible timer handling issue on cpu=1 timer-softirq=0
[   38.221033] rcu: rcu_sched kthread starved for 6000 jiffies! g-1179 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402 ->cpu=1
[   38.356336] rcu:     Unless rcu_sched kthread gets sufficient CPU time, OOM is now expected behavior.
[   38.474440] rcu: RCU grace-period kthread stack dump:
...

Replace to irq_force_affinity from irq_set_affinity and ignore
cpu_online_mask to fix the issue.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
Tested-by: Olliver Schinagl <oliver@schinagl.nl>
2023-01-21 19:58:24 +01:00
Markus Stockhausen
c03e458c86 realtek: Follow kernel comment style recommendation
While Linus is fine with longer code lines, comments should still be
within the 80 char limit.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
2023-01-13 22:34:16 +01:00
Pascal Ernster
720b243171 realtek: 5.15: Improve error handling in rtl838x_pie_rule_write()
In target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c,
make rtl838x_pie_rule_write() return non-zero value case of error.

Signed-off-by: Pascal Ernster <git@hardfalcon.net>
2023-01-05 23:09:23 +01:00
Pascal Ernster
a188536ef6 realtek: 5.15: Improve rtl838x dsa driver error handling
Make sure functions calling rtl838x_smi_wait_op() return its return
value in target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c.
This brings the code style in line with the rtl839x implementation.

Suggested-by: Sander Vanheule <sander@svanheule.net>
Signed-off-by: Pascal Ernster <git@hardfalcon.net>
2023-01-05 23:08:13 +01:00
Pascal Ernster
de2dc3feae realtek: return correct error value for phy ops
A behavioural change was introduced with commit 758c88b969 ("realtek:
Whitespace and codestyle cleanup") causing rtl838x_read_phy() and
rtl838x_write_phy() to unconditionally return -ETIMEDOUT. As a result,
probing the device during boot fails:

    Error setting up netdev, freeing it again.
    rtl838x-eth: probe of 1b00a300.ethernet failed with error -5

Fix the bootloop caused by this regression with kernel 5.15 on rtl838x
devices, by properly returning 0 on success.

Tested on a Netgear GS108T v3, a Netgear GS310TP v1, a Zyxel GS1900-8HP
v1 and an HPE 1920-8G.

Fixes: 758c88b969 ("realtek: Whitespace and codestyle cleanup")
Tested-by: Stijn Segers <foss@volatilesystems.org>
Tested-by: Jan Hoffmann <jan@3e8.eu>
Signed-off-by: Pascal Ernster <git@hardfalcon.net>
2023-01-05 23:08:04 +01:00
Birger Koblitz
e143e27c8c realtek: Fix reset register access
The reset register on RTL93xx not merely have bits to execute
a reset of a hardware component, but also configuration bits for
reset procedures. Keep them during executing a reset.

Signed-off-by: Birger Koblitz <git@birger-koblitz.de>
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
[backport to 5.10 kernel]
Signed-off-by: Sander Vanheule <sander@svanheule.net>
2022-12-28 16:53:56 +01:00
Olliver Schinagl
0a83889e89 realtek: Reduce variable scopes
Linus prefers to have loop initializers nice and tightly scoped. In
OpenWRT this has been possible since 41a1a652fb ("kernel: backport
gnu11 upgrade").

This patch cleans up variable scope while trying to do the above for
'simple for loops'.

This cleans up and simplifies some functions and code, and pulls in
variables to a smaller scope.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2022-12-27 16:33:15 +01:00
Olliver Schinagl
0a931767cf realtek: Replace C++ style comments
The only exception to C++ style comments are SPDX license identifier
markers at the start of C files (even headers have C style markers).

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2022-12-27 16:33:01 +01:00
Olliver Schinagl
758c88b969 realtek: Whitespace and codestyle cleanup
Fix some ugly whitepsaces and codestyle issues around the realtek sources.

While this is by no means perfect, it catches what it caught.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2022-12-27 16:31:48 +01:00
Jan Hoffmann
2c40359c5c realtek: add cond_resched to loops accessing the FDB table
A full loop accessing all FDB entries can take several milliseconds
(on RTL839x about 20 ms), so give other kernel tasks a chance to run.
This is especially important for rtl83xx_port_fdb_dump which is itself
called in a loop for all ports by the kernel.

Signed-off-by: Jan Hoffmann <jan@3e8.eu>
2022-12-27 16:29:57 +01:00
Jan Hoffmann
ae0a3f88ac realtek: restructure rtl_table_read/write
These two functions are identical apart from writing different values to
the read/write bit. Create a new function rtl_table_exec to reduce code
duplication.

Also replace the unbounded busy-waiting loop. The new implementation may
sleep, but as the hardware typically responds before the first poll, any
callers doing many table accesses still need to make sure not to block
other kernel tasks themselves.

So far, polling timeout errors are only handled by logging an error, but
a return value is added to allow proper handling in the future.

Signed-off-by: Jan Hoffmann <jan@3e8.eu>
2022-12-27 16:29:57 +01:00
Jan Hoffmann
9aa123d778 realtek: simplify log messages in rtl83xx_mdio_probe
This function currently prints three messages for every switch port at
KERN_INFO level. This takes a considerable amount of time during bootup
and can even trigger an external watchdog.

Replace these log messages by a single one at KERN_DEBUG level.

Signed-off-by: Jan Hoffmann <jan@3e8.eu>
2022-12-27 16:29:57 +01:00
Jan Hoffmann
c94ca63ed4 realtek: don't set L2LEARNING flag in rtl83xx TX header
As learning for the CPU port is now disabled globally, the bit in the
TX header doesn't have any effect anymore. Remove it to make the header
consistent with the global configuration.

Originally, this change was intended to be applied before commit
eb456aedfe ("realtek: use assisted learning on CPU port"), which is
why the commit message incorrectly mentions that the TX header already
disables learning.

The reason for disabling learning on the CPU port in the first place is
that it doesn't work correctly when packets are trapped to the CPU and
then forwarded by the CPU to other ports. In that case, the switch would
incorrectly learn the CPU port as source. An example that triggered this
issue are Multicast Listener Reports and IGMP membership reports.

Signed-off-by: Jan Hoffmann <jan@3e8.eu>
2022-12-27 16:29:39 +01:00
INAGAKI Hiroshi
69055a5412 realtek: enable needs_standalone_vlan_filtering on DSA driver in 5.15
To configure VLAN 0, enable needs_standalone_vlan_filtering option
of dsa_switch struct.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2022-12-15 20:54:03 +01:00
INAGAKI Hiroshi
109962d8bf realtek: update dsa.c of DSA driver for 5.15
- rtl83xx_vlan_filtering()

  "struct switchdev_trans *trans" parameter was removed[1] and
  "struct netlink_ext_ack *extack" was added[2].

[1]: https://www.spinics.net/lists/netdev/msg712250.html
[2]: https://www.spinics.net/lists/netdev/msg722496.html

- rtl83xx_vlan_add/del()

  vlan->vid_begin and vlan->vid_end were removed and vlan->vid was
  added[3].

[3]: https://www.spinics.net/lists/netdev/msg712248.html

- rtl83xx_vlan_prepare()

  "port_vlan_prepare" member was removed from "dsa_switch_ops" struct
  in dsa.h[4] and vlan_prepare function should be called from vlan_add
  function. Also, change return type of vlan_add function to int.

[4]: https://www.spinics.net/lists/netdev/msg712252.html

- rtl83xx_port_mdb_add()

  "port_mdb_prepare" member in "dsa_switch_ops" struct was removed and
  preparation need to be done in the function of "port_mdb_add" member
  instead. And also, int type need to be returned on "port_mdb_add"
  member[5].

[5]: https://www.spinics.net/lists/netdev/msg712251.html

- rtl83xx_port_pre_bridge_flags(), rtl83xx_port_bridge_flags()

  The current "port_pre_bridge_flags" member and "port_bridge_flags"
  member in "dsa_switch_ops" in dsa.h has flags of
  "struct switchdev_brport_flags" type instead[6], so adjust to it.
  And, the changed features are passed by flags.mask[7] in
  rtl83xx_port_bridge_flags(), so check it before calling function
  to enable/disable fieature.

[6]: https://lore.kernel.org/lkml/20210212151600.3357121-7-olteanv@gmail.com/
[7]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e18f4c18ab5b0dd47caaf8377c2e36d66f632a8c

Suggested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
[shorten final return statement of rtl83xx_port_mdb_add()]
Signed-off-by: Sander Vanheule <sander@svanheule.net>
2022-12-15 20:52:40 +01:00
INAGAKI Hiroshi
8fb15ea52a realtek: copy dts/files/patches/configs for 5.15
Copy dts/files/patches/configs from 5.10 to 5.15.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
[refresh with updated DGS-1210 dts files]
Signed-off-by: Sander Vanheule <sander@svanheule.net>
2022-12-15 20:52:09 +01:00